untoldwind / KontrolSystem2

Autopilot scripting system for KSP2
Other
54 stars 14 forks source link

Can't figure out how to get ISP and (related) actual thrust #83

Closed SodaPopinski closed 3 months ago

SodaPopinski commented 1 year ago

I've found vessel.available_thrust gives me the maximum thrust, presumably in vacuum. I'm assuming I can get the sea_level thrust by dividing seal level ISP by vacuum ISP, and multiplying that by available thrust.

That said, I can't figure out how to get the ISP. I could use an example, as I'm still having trouble wrapping my head around what the code should look like based on the descriptions.

For example, my attempt to get ISP looks like this: let ISP = 0.0 for(engine in vessel.engines) if (engine.is_operational) { ISP = engine.enginedeltav.get_ISP("SeaLevel") } ISP

ColJay commented 1 year ago

i'm using a very rough atmos model to guess the likely thrust and it's reasonable.

sync fn model_thrust(vessel: Vessel) -> float = { //ksp::game::sleep(0) const engine_isp_ratio: float = vessel.engines[0].max_thrust_output_vac / vessel.engines[0].max_thrust_output_atm const body_1atm: float = 101.325 (vessel.engines[0].max_thrust_output_vac / ((1+(engine_isp_ratio - 1)*(vessel.static_pressure_kpa / body_1atm)))) }

This is for Kerbin only though, and it's not perfect. Using this as a T/W guide I can acheive hover of with a drift of around 10cm/sec Note - i've only one engine on my craft, and it's probably not proper maths :-D

untoldwind commented 1 year ago

You are right, this is kind of a bug. vessel.available_thrust should return the available thrust in the current situation. Which will be fixed in the next release. I also found a real_isp value in the engine data, which might be what you are looking for.

SodaPopinski commented 1 year ago

Great to hear!

Though, I still don't know how to get the ISP of the engine.

untoldwind commented 1 year ago

Currently there is only the vessel.delta_v.engines list where each element has a get_ISP function that should return the ISP for vaccum, Sealevel and current(?) altitude: https://kontrolsystem2.readthedocs.io/en/latest/reference/ksp/vessel.html#get-isp

I'm not sure how relyable that is, as it is using the Delta-V calculation of the the game (which is still somewhat wonky from time to time).

Maybe there is another way to obtain that information ...

untoldwind commented 1 year ago

Please recheck in the 0.3.5 or 0.4.0.1 version

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.