Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list engines in englist.
- local liquid_density is .005. //tonne/unit
- local solid_density is .0075.
- local mono_density is .004.
- set g0 to 9.80665.
- function getthrust{
- parameter englist.
- set sumthrust to 0.
- for eng in englist
- set sumthrust to sumthrust + eng:thrust.
- return sumthrust.
- }
- //not tested with multiple engines.
- function getweightedisp{
- parameter englist.
- set summf to 0.
- set ispmf to 0.
- for eng in englist{
- set massflow to 0.
- if eng:allowshutdown{
- if eng:name = "omsengine"
- set massflow to eng:fuelflow*mono_density.
- else if eng:name = "ionengine"
- . //ignoring ion engines right now. electricity is part of flow
- else set massflow to eng:fuelflow*liquid_density.
- }
- else{//srb
- set massflow to eng:fuelflow*solid_density.
- }
- set ispmf to ispmf + eng:isp * massflow.
- set summf to summf + massflow.
- }
- if summf
- return ispmf/summf.
- else
- return 0.
- }
- function getdensity{
- parameter alti.
- return 1.
- }
- function shipvec{
- parameter vector, veccolor, text, vscale is .5, data is vector:mag, precision is 2.
- VECDRAWARGS(ship:POSITION, vector*vscale, veccolor, text+round(vector:mag,precision), 1, TRUE).
- }
- clearvecdraws().
- set throttle to .1.
- wait .1.
- set t1 to time:seconds.
- set m1 to ship:mass.
- set v1 to ship:velocity:orbit.
- set thrust1 to ship:facing:forevector * getthrust(englist).
- //shipvec(thrust1,blue,"Ti: ",.4). //checked to see if thrust1 = thrust2,yes
- wait 1.
- set t2 to time:seconds.
- set m2 to ship:mass.
- set v2 to ship:velocity:orbit.
- set thrust2 to ship:facing:forevector * getthrust(englist).
- set throttle to 0.
- //the part that actually does the calculation:
- set wisp to getweightedisp(englist).
- set ev to -ship:facing:forevector * (wisp*g0).
- set accel to (v2-v1)/(t2-t1).
- set massflow to (m2-m1)/(t2-t1).
- set totalforce to m1*accel + ev*massflow.
- set gravity to ship:BODY:POSITION:normalized *(body:mu/(altitude+body:radius)^2).
- set weight to m2*gravity.
- print "Weighted isp: " + wisp.
- shipvec(ev,white,"ExhVel: ",.01).
- shipvec(v2,red,"v2: ",.02).
- shipvec(accel,yellow, "Accel: ",3).
- shipvec(totalforce, green, "#Force: ").
- shipvec(thrust2, blue, "Thrust: ").
- shipvec(weight, red, "Weight: ").
- shipvec(thrust2+weight,white,"expectedF: ").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement