Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A library of routines to help do basic physics calculations
- @LAZYGLOBAL off.
- // Return the gravity acceleration at SHIP's current location.
- declare function g_here {
- return constant():G * ((ship:body:mass)/((ship:altitude + body:radius)^2)).
- }.
- // Return the force on SHIP due to gravity acceleration at SHIP's current location.
- declare function Fg_here {
- return ship:mass*g_here().
- }.
- declare function mu_body {
- return constant():G * (body:mass)
- }.
- declare function mu_ship {
- return constant():G * (ship:mass)
- }.
- //added by capt-crash
- declare function v_e { //escape velocity calculation
- return sqrt((2 * body:mu)/((ship:altitude + body:radius)))
- }.
- declare function stage_delta_v {
- return stage:engine:isp * ln(ship:mass / (ship:mass - (stage:LQDOXYGEN + stage:LQDHYDROGEN + stage:KEROSENE + stage:Aerozine50 + stage:UDMH + stage:NTO + stage:MMH + stage:HTP + stage:IRFNA-III + stage:NitrousOxide + stage:Aniline + stage:Ethanol75 + stage:LQDAMMONIA + stage:LQDMETHANE + stage:CLF3 + stage:CLF5 + stage:DIBORANE + stage:PENTABORANE + stage:ETHANE + stage:ETHYLENE + stage:OF2 + stage:LQDFLUORINE + stage:N2F4 + stage:FurFuryl + stage:UH25 + stage:TONKA250 + stage:TONKA500 + stage:FLOX30 + stage:FLOX70 + stage: + stage:FLOX88 + stage:IWFNA + stage:IRFNA-IV + stage:AK20 + stage:AK27 + stage:CaveaB + stage:MON1 + stage:MON3 + stage:MON10 + stage:MON15 + stage:MON20 + stage:Hydyne + stage:TEATEB)))
- }. //for real fuels
- //declare function stage_delta_v {
- // return stage:engine:isp * ln(ship:mass / (ship:mass - (stage:LIQUIDFUEL)))
- //}.
- //uncomment the above if using stock fuels
- declare function hohmann {
- //r1 and a2 will be set manually before launch or in flight via relay
- declare parameter
- v1, //initial orbital velocity
- v1_t, //elliptical orbit transfer r1->2
- v2, //orbital velocity in desired orbit
- v2_t, //circularizat
- r1, //inital radius
- a2, //desired orbital altitude, converted to r2 as needed. makes user input simple
- a_t,
- r2.
- set a_t to ( r1 + r2 ) / 2
- set r1 to ( ( orbit:apoapsis + orbit:periapsis ) / 2 ) + body:radius.
- set r2 to a2 + body:radius.
- set v1 to sqrt( body:mu / r1 ).
- set v2 to sqrt( body:mu / r2 ).
- set v1_t to sqrt( body:mu * ( ( 2 / r1 ) - ( 1 / ( a_t ) ) ) ) - sqrt( v1 ).
- set v2_t to sqrt( v2 ) - sqrt( body:mu * ( ( 2 / r2 ) - ( 1 / ( a_t ) ) ) ).
- return v1_t + v2_t
- }.
- //end capt-crash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement