Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented the airPressureAt() method. #108

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions app/src/main/java/src/land/LandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class LandingController
private final double AIR_DENSITY = 5.428; // https://www.aero.psu.edu/avia/pubs/LanSch17.pdf, page 3
private final double LANDER_AREA = 1.91; // Mars InSight lander was 1.56 meters in diameter, pi * radius^2
private final double PARACHUTE_AREA = 1000;
private final double airPresSeaLevel = 1.5; // 1.5 bars
private final double grav = 1.352; // acceleration due to gravity
private final double k = 1.38064852e-23; // Boltzmann constants
private final double m = 27.60867588; // average molar mass of air molecules


protected boolean parachuteDeployed = false;

Expand Down Expand Up @@ -141,4 +146,48 @@ protected void deployParachute()
{
parachuteDeployed = true;
}

/*
* Method represents:
* Ph = P0 * e^((-m*g*h)/k*T
* Where:
* Ph is pressure at height, P0 pressure at seal level
* m is mass of one molecule of..., g is gravitational acceleration, h is the height
* k is Boltzmann's constant, t is the absolute temperature (in kelvin)
*
*
* if impact() is true, return 1.5 (on surface)
*/
private double airPressureAt(Vector3d height) {

double h = height.dist(new Vector3d());
double t = generateTemp(h);

double result = airPresSeaLevel * Math.exp((-m*grav*h)/k*t);
return result;
}

private double generateTemp(double height) {
if (height == 0) { // if impacted on surface hence temp is given
return 94;
}
else if (0<height && height<50000) {
long min = (long) 71;
long max = (long) 81;
double randValue = (double)Math.floor(Math.random()*(max-min+1)+min);
return randValue;
}
else if (height>=50000 && height<200000) {
long min = (long) 71;
long max = (long) 180;
double randValue = (double)Math.floor(Math.random()*(max-min+1)+min);
return randValue;
}
else {
long min = (long) 160;
long max = (long) 180;
double randValue = (double)Math.floor(Math.random()*(max-min+1)+min);
return randValue;
}
}
}