Jump to content

wingnut

Members
  • Posts

    27
  • Joined

  • Last visited

Reputation

3 Neutral

Profile Information

  • About me
    Rocketeer
  1. Because you need the True Anomaly to calculate your altitude and speed at any point in the orbit in contrast to Altitude and velocity:orbit:mag only returning the current values. I think the discrepancies may have something to do with the way Sin and Cos are calculated but I'm not sure. I've setup virtually the same script in a Java class and I get accurate results there...
  2. Could someone please review a script for me which is supposed to calculate true anomaly in an eccentric orbit and after that the altitude and speed at this true anomaly. The script seems to deliver results which are not completely wrong but I can't verify that the calculated true anomaly is correct. Further to this, the calculated altitude and speed always seem to be corresponding to the periapsis even when I enter different mean anomalies. My script is based on the algorithm found on http://www.jgiesen.de/kepler/kepler.html as well as the equations and example problems of the Orbital Mechanics page on http://www.braeunig.us/space/. This is the script: // True anomaly set mu to 3.5316000*10^12. // gravitational parameter set rb to 600000. // radius of body declare parameter tof. set a to (rb*2 + periapsis + apoapsis)/2. //SMa set ec to ((rb+apoapsis) - (rb+periapsis))/((rb+apoapsis) + (rb+periapsis)). //eccentricity set t to 2*3.14159*sqrt(a^3/mu). //orbital period set n to sqrt(mu/a^3). //mean motion set M to n * tof. //mean anomaly at tof seconds after periapsis set maxiter to 30. set delta to 10^-3. set i to 0. if ec < 0.8 {set E to m.} //eccentric anomaly if ec >= 0.8 {set E to 3.14159.} set F to E - ec * sin(m) - m. set absF to F. if absF < 0 {set absF to F * (-1).} until absF <= delta OR i < maxiter { set E to E - F / (1.0 - ec * cos(E)). set F to E - ec * sin(E) - m. set absF to F. if absF < 0 {set absF to F * (-1).} set i to i + 1. } //set E to E / (3.14159 / 180). // convert to degree set fak to sqrt(1.0 - ec^2). set phi to arctan2(fak * sin(E), cos(E) - ec). set r to a * (1 - ec^2) / (1 + ec * cos(phi)). // altitude at true anomaly set v to sqrt(mu * (2 / r - 1 / a)). // velocity at true anomaly print "Elements for " + multi + " seconds after periapsis". log "Elements for " + multi + " seconds after periapsis" to orblog. print "True anomaly: " + phi. log "True anomaly: " + phi to orblog. print "Mean anomaly: " + M. log "Mean anomaly: " + M to orblog. print "Eccentric anomaly: " + E. log "Eccentric anomaly: " + E to orblog. print "Radius: " + r. log "Radius: " + r to orblog. print "Speed: " + v. log "Speed: " + v to orblog. This is output created by the script for a ca. 80km x 1,000 km Kerbin orbit: Elements for 3037.5 seconds after periapsis True anomaly: 5.77998497874809 Mean anomaly: 3.14123160679727 Eccentric anomaly: 3.14123160679727 Radius: 679672.744713293 Speed: 2832.04616886257 Elements for 0 seconds after periapsis True anomaly: 0 Mean anomaly: 0 Eccentric anomaly: 0 Radius: 678454.711152033 Speed: 2835.3381463772 Elements for 1518.75 seconds after periapsis True anomaly: 2.89128867366892 Mean anomaly: 1.57061583805724 Eccentric anomaly: 1.57061583805724 Radius: 678759.294063534 Speed: 2834.51419835746
  3. D'oh. Thanks. I already figured it had something to do with the print or log statements but I did not spot the incorrect strings.
  4. This is one of the scripts I'm trying to run and I'm almost certain that I did not change anything before it stopped working. But something significant must have been changed, why would it stop working then?: declare parameter apo. set var to altitude. lock throttle to 1. SAS ON. STAGE. wait until altitude > var. PRINT "GET:"+round(missiontime)+" LIFTOFF". log "GET:"+round(missiontime)+" LIFTOFF" to shiplog. wait until altitude > 10000. print "GET:"+round(missiontime)+" INITIATE PITCH PROGRAMME". log "GET:"+round(missiontime)+" INITIATE PITCH PROGRAMME" to shiplog. SAS OFF. lock steering to heading 90 by 45. print "GET:"+round(missiontime)+" PITCH TO 45". log "GET:"+round(missiontime)+" PITCH TO 45" to shiplog. wait until apoapsis > 70000. lock steering to heading 90 by 0. print "GET:"+round(missiontime)+" PITCH TO 90". log "GET:"+round(missiontime)+" PITCH TO 90" to shiplog. until apoapsis > apo { if stage:liquidfuel < 1 { break. }. }. lock throttle to 0. print "GET:"+round(missiontime)+" MECO". log "GET:"+round(missiontime)+" MECO" to shiplog. log "GET:"+round(missiontime)+" "+ FLOOR(STAGE:LIQUIDFUEL) + "/" + FLOOR(STAGE:OXIDIZER) + " PROPELLANT/OXIDIZER REMAINING" to shiplog. wait 1. STAGE. print "GET:"+round(missiontime)+" STAGE 1 SEPARATION". log "GET:"+round(missiontime)+" STAGE 1 SEPARATION" to shiplog. lock steering to PROGRADE. wait until eta:apoapsis < 60. set r to 600000. set os to r*sqrt(9.807/(r+apoapsis)). set vel to velocity:orbit. set dv to sqrt(vel:x^2 + vel:y^2 + vel:z^2). set dv to os - dv. set bt to dv/(maxthrust/mass). print "GET:"+round(missiontime)+" ORBIT INSERTION BURN. BT " + round(bt,2) + "s". log "GET:"+round(missiontime)+" ORBIT INSERTION BURN. BT " + round(bt,2) + "s" to shiplog. wait until eta:apoapsis < bt/2 + 1. lock throttle to 1. wait until periapsis > 70000. until periapsis > 70000 { if stage:liquidfuel < 1 { break. }. }. set ecc to ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). until ecc < 0.1 { set ecc TO ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). if ecc < ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)) { break. }. }. lock throttle to 0.5. until ecc < 0.05 { set ecc TO ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). if ecc < ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)) { break. }. }. lock throttle to 0.3. until ecc < 0.005 { set ecc TO ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). if ecc < ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)) { break. }. }. lock throttle to 0. TOGGLE AG2. PRINT "GET:"+round(missiontime)+" INSERTION BURN COMPLETE". log "GET:"+round(missiontime)+" INSERTION BURN COMPLETE" to shiplog. set ecc to ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). print "GET:"+round(missiontime)+" ECCENTRICITY " + round(ecc, 4). log "GET:"+round(missiontime)+" ECCENTRICITY " + round(ecc, 4) to shiplog. log "GET:"+round(missiontime)+" "+floor(STAGE:LIQUIDFUEL) + "/" + floor(STAGE:OXIDIZER) + " PROPELLANT/OXIDIZER REMAINING" to shiplog. STAGE. print "GET:"+round(missiontime)+" "PAYLOAD RELEASED". log "GET:"+round(missiontime)+" "PAYLOAD RELEASED" to shiplog. I have other scripts which cause the game to freeze as well when run from the launchpad. It doesn't matter if the script is run from the archive or copied to the vehicle's volume and run from there - both cases cause a freeze. Edit: this is the previous version of the script which still works on the launchpad: I checked it with Tortoise Merge and there are some changes of whitespaces in a couple of lines and I removed some print statements which were paired with log statements. I didn't have the time to investigate it more thoroughly yet. declare parameter apo. set var to altitude. lock throttle to 1. SAS ON. STAGE. wait until altitude > var. PRINT "GET:"+round(missiontime)+" LIFTOFF". log "GET:"+round(missiontime)+" LIFTOFF" to shiplog. wait until altitude > 10000. print "GET:"+round(missiontime)+" INITIATE PITCH PROGRAMME". log "GET:"+round(missiontime)+" INITIATE PITCH PROGRAMME" to shiplog. SAS OFF. lock steering to heading 90 by 45. print "GET:"+round(missiontime)+" PITCH TO 45". log "GET:"+round(missiontime)+" PITCH TO 45" to shiplog. wait until apoapsis > 70000. lock steering to heading 90 by 0. print "GET:"+round(missiontime)+" PITCH TO 90". log "GET:"+round(missiontime)+" PITCH TO 90" to shiplog. until apoapsis > apo { if stage:liquidfuel < 1 { print "GET:"+round(missiontime)+" TARGET APOAPSIS NOT REACHED". log "GET:"+round(missiontime)+" TARGET APOAPSIS NOT REACHED" to shiplog. break. }. }. lock throttle to 0. print "GET:"+round(missiontime)+" MECO". log "GET:"+round(missiontime)+" MECO" to shiplog. print "GET:"+round(missiontime)+" "+ FLOOR(STAGE:LIQUIDFUEL) + "/" + FLOOR(STAGE:OXIDIZER) + " PROPELLANT/OXIDIZER REMAINING". log "GET:"+round(missiontime)+" "+ FLOOR(STAGE:LIQUIDFUEL) + "/" + FLOOR(STAGE:OXIDIZER) + " PROPELLANT/OXIDIZER REMAINING" to shiplog. wait 1. STAGE. print "GET:"+round(missiontime)+" STAGE 1 SEPARATION". log "GET:"+round(missiontime)+" STAGE 1 SEPARATION" to shiplog. lock steering to PROGRADE. wait until eta:apoapsis < 60. set r to 600000. set os to r*sqrt(9.807/(r+apoapsis)). set vel to velocity:orbit. set dv to sqrt(vel:x^2 + vel:y^2 + vel:z^2). set dv to os - dv. set bt to dv/(maxthrust/mass). print "GET:"+round(missiontime)+" ORBIT INSERTION BURN. BT " + round(bt,2) + "s". log "GET:"+round(missiontime)+" ORBIT INSERTION BURN. BT " + round(bt,2) + "s" to shiplog. wait until eta:apoapsis < bt/2 + 1. lock throttle to 1. wait until periapsis > 70000. until periapsis > 70000 { if stage:liquidfuel < 1 { break. }. }. set ecc to ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). until ecc < 0.1 { set ecc TO ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). if ecc < ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)) { break. }. }. lock throttle to 0.5. until ecc < 0.05 { set ecc TO ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). if ecc < ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)) { break. }. }. lock throttle to 0.3. until ecc < 0.005 { set ecc TO ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). if ecc < ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)) { break. }. }. lock throttle to 0. TOGGLE AG2. PRINT "GET:"+round(missiontime)+" CIRCULARIZATION BURN COMPLETE". log "GET:"+round(missiontime)+" CIRCULARIZATION BURN COMPLETE" to shiplog. set ecc to ((r+apoapsis) - (r+periapsis))/((r+apoapsis) + (r+periapsis)). print "GET:"+round(missiontime)+" ECCENTRICITY " + round(ecc, 4). log "GET:"+round(missiontime)+" ECCENTRICITY " + round(ecc, 4) to shiplog. print "GET:"+round(missiontime)+" "+floor(STAGE:LIQUIDFUEL) + "/" + floor(STAGE:OXIDIZER) + " PROPELLANT/OXIDIZER REMAINING". log "GET:"+round(missiontime)+" "+floor(STAGE:LIQUIDFUEL) + "/" + floor(STAGE:OXIDIZER) + " PROPELLANT/OXIDIZER REMAINING" to shiplog. print "GET:"+round(missiontime)+" ANTENNA DEPLOYED". log "GET:"+round(missiontime)+" ANTENNA DEPLOYED" to shiplog.
  5. Did any of you have a problem before, that running a script from the launchpad freezes your game?
  6. Thank you baloan for your explanation. I have follow-up questions please as I am still not able to identify which formula on the Elliptic orbit page you used as basis for your velocity calculations, namely those two lines: set va to sqrt( vom^2 + 2*mu*(1/ra - 1/r) ). set v2 to sqrt( vom^2 + (mu * (2/r2 - 2/r + 1/a - 1/a2 ) ) ). Did you use thie velocity or the energy formula as basis and what did you change to get the tow equations from above?
  7. Baloan, which formula did you use to calculate the deltav for the periapsis node to raise apoapsis? I'm trying to create a node at periapsis with the Hohmann transfer orbit formula but the projected apoapsis always turns out to be higher than specified in the parameter, this is my script launched from a low Kerbin orbit with an eccentricity of roughly 0.03: DECLARE PARAMETER x. SET r TO 600000. SET sma TO (APOAPSIS+2*r+PERIAPSIS)/2. SET gm TO 3531600000000. SET dv1 TO SQRT(gm/sma)*(SQRT(2*(x+r)/(sma+x+r))-1). ADD NODE(TIME:SECONDS + ETA:PERIAPSIS,0,0,dv1).
  8. Thanks Oan, now the calculation in my spreadsheet has a result after all and it is equal to yours.
  9. SanderB and Oan, could you please post examples for both your formulas? In Oan's formula I am not clear what y0 is supposed to be. In SanderB's formular I don't know where to get the velocity of descent Vd from and likewise Ga. Could you please post an example for a suicide burn of a vessel in a 20x20 km Mun orbit with a weight of 5 tons and thrust of 20 kN?
  10. Not sure if this helps, but the same message is shown in a previous version of KSPTOT. I'm not sure though which version it is, there is only the Flyby Maneuver Sequencer and Optimal Two Burn Orbit change items in the Tools menue. Update: D'oh! Well, in the meantime I noticed that I copied the SMa value directly from the persistent.sfs file without noticing that this value represents meters instead of the expected kilometers in KSPTOT. When I input the value as is expected, then the two burn solution is computed fine. My bad.
  11. Hi Arrowstar There appears to be an error in the Optimal Two Burn Orbit Change window/function: The following input into the Optimal Two Burn Orbit Change window produces the following error messgae KSPTOT version is 0.10 MATLAB compiler runtime is v81 as far as I can tell.
  12. I was thinking of this Maximum Total Flight Time constraint highlighted in the red rectangle from your Optimization Tool for Orbiter:
  13. Arrowstar, do you have plans to include flight constraints like maximum flight time for high energy transfer orbits?
  14. Does anyone know who the author of the Solar Glider shown in the gallery of the Wiki article for the PB-Ion Electric Propulsion System is and if there is a .craft file available for download?
  15. Read the tooltip when you hover your mouse over the comic.
×
×
  • Create New...