Jump to content

KSP Interstellar Extended Continued Development Thread


FreeThinker

Recommended Posts

I have been using the motlen salt reactors for a couple hours in game, and I have some suggestions. I think that the upgraded molten salt reactors should be an entirely different part than the base molten salt reactor. I often times use that reactor as a power source for my stations, my long distance probes, and my mining craft. However, the upgraded reactor uses up its fuel at a much faster rate than the base reactor. I think the base reactor using Uranium lasts something like 3 or 4 times longer before it runs out of fuel compared to the upgraded reactor, and I still have yet to unlock the advanced molten salt reactors. The problem is that once I unlock the upgrade to the molten salt reactor, I cannot place the base reactor on my craft. This breaks some of my old craft files because they did not have enough radiators, and I cannot launch them with the old reactor.

I think that this would also be a good opportunity to make a compromise with the players who did not like the integrated generator in the molten salt reactor. I would suggest that only the low tech reactor should have the integrated generator. Also, perhaps we could limit its maximum size via tweak scale to something like 2.5m. Perhaps the old model could be used for the low tech reactor, and roverdudes model could be used for the advanced reactors.

Or I guess another way to solve this would be to let us toggle the tech level of the reactors in the VAB, I remember there were many requests for this in the old Interstellar thread ran by Fractal, however I cannot remember why this could not be easily implemented.

Link to comment
Share on other sites

I think I've found the issue with KER/MechJeb not displaying the correct Delta-V and thrust numbers.  It appears according to the following posts that the thrust calculation changed in 1.0 to use maxFuelFlow:

http://forum.kerbalspaceprogram.com/index.php?/topic/105996-ksp-10-isp-engine-values/
http://bugs.kerbalspaceprogram.com/issues/4937

I've modified the code for the thermal nozzles as follows and I'm seeing expected values in KER again.  This is for ThermalNozzleController.cs at line 847 and includes the entire first part of the if block (everything between the brackets):
 

            {
                //if (myAttachedReactor is IUpgradeableModule) {
                //    IUpgradeableModule upmod = myAttachedReactor as IUpgradeableModule;
                //    if (upmod.HasTechsRequiredToUpgrade()) {
                //        attached_reactor_upgraded = true;
                //    }
                //}

                _maxISP = (float)(Math.Sqrt((double)AttachedReactor.CoreTemperature) * (PluginHelper.IspCoreTempMult + IspTempMultOffset) * GetIspPropellantModifier());
                //_minISP = _maxISP * 0.4f;
                //atmospherecurve.Add(0, _maxISP, 0, 0);
                //atmospherecurve.Add(1, _minISP, 0, 0);

                //thrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP);
                thrust = ((float)GetPowerThrustModifier() * (float)GetHeatThrustModifier() * AttachedReactor.MaximumThermalPower / _maxISP / PluginHelper.GravityConstant * (float)GetHeatExchangerThrustDivisor() * _thrustPropellantMultiplier);
                myAttachedEngine.maxFuelFlow = thrust / (PluginHelper.GravityConstant * _maxISP);
                myAttachedEngine.maxThrust = thrust;

                _minISP = _maxISP * ((thrust - maxPressureThresholdAtKerbinSurface) / thrust) * (float)GetHeatExchangerThrustDivisor();
                atmospherecurve.Add(0, _maxISP, 0, 0);
                atmospherecurve.Add(1, _minISP, 0, 0);

                myAttachedEngine.atmosphereCurve = atmospherecurve;
            }

 

Link to comment
Share on other sites

14 hours ago, Rabada said:

I have been using the motlen salt reactors for a couple hours in game, and I have some suggestions. I think that the upgraded molten salt reactors should be an entirely different part than the base molten salt reactor. I often times use that reactor as a power source for my stations, my long distance probes, and my mining craft. However, the upgraded reactor uses up its fuel at a much faster rate than the base reactor. I think the base reactor using Uranium lasts something like 3 or 4 times longer before it runs out of fuel compared to the upgraded reactor, and I still have yet to unlock the advanced molten salt reactors. The problem is that once I unlock the upgrade to the molten salt reactor, I cannot place the base reactor on my craft. This breaks some of my old craft files because they did not have enough radiators, and I cannot launch them with the old reactor.

I think that this would also be a good opportunity to make a compromise with the players who did not like the integrated generator in the molten salt reactor. I would suggest that only the low tech reactor should have the integrated generator. Also, perhaps we could limit its maximum size via tweak scale to something like 2.5m. Perhaps the old model could be used for the low tech reactor, and roverdudes model could be used for the advanced reactors.

Or I guess another way to solve this would be to let us toggle the tech level of the reactors in the VAB, I remember there were many requests for this in the old Interstellar thread ran by Fractal, however I cannot remember why this could not be easily implemented.

Alright, there seems to be several problems here.

Problem  A Upgraded reactor doesn't last as long, This is the result of the overal power improving while the minimum utilisation remains the same. The resutt is that more power is wasted and there they don't last not as long. Did  you know that the Upgraded version allows Uranium Reprocessing? However, you need a Lab on board which might not always desired, therefore I plan to reuse the old Reactor model to act as a automated nuclear fuel reprocessor, allowing you to reprecess fuel without a Lab. Another thing that will help is that the amount of molten salt will be restored to it's original amount (3 times as much) which will significantly improve durability.

Problem B is the desire to select a specific version, in both SandBox and Compagin mode. It would be helpfull to allow playesr to test a vessel first  before they dedicate to it in their campagin. This is a valid point. I want to give the possiblity to select the avialabe Generation level in the VAB and allow it to be upgraded in space with an Engeneer and RocketParts resources.

The idea of not fitting the Salt Core Reactor with build in Thermal Electric Generator seems like a bad idea as it is confusing and the Salt Core reacor main purpose if electric power production, not propulsion, for that use the Sold Core Reacor (NERVA).

 

4 hours ago, RzTen1 said:

I think I've found the issue with KER/MechJeb not displaying the correct Delta-V and thrust numbers.  It appears according to the following posts that the thrust calculation changed in 1.0 to use maxFuelFlow:

http://forum.kerbalspaceprogram.com/index.php?/topic/105996-ksp-10-isp-engine-values/
http://bugs.kerbalspaceprogram.com/issues/4937

I've modified the code for the thermal nozzles as follows and I'm seeing expected values in KER again.  This is for ThermalNozzleController.cs at line 847 and includes the entire first part of the if block (everything between the brackets):
 


            {
                //if (myAttachedReactor is IUpgradeableModule) {
                //    IUpgradeableModule upmod = myAttachedReactor as IUpgradeableModule;
                //    if (upmod.HasTechsRequiredToUpgrade()) {
                //        attached_reactor_upgraded = true;
                //    }
                //}

                _maxISP = (float)(Math.Sqrt((double)AttachedReactor.CoreTemperature) * (PluginHelper.IspCoreTempMult + IspTempMultOffset) * GetIspPropellantModifier());
                //_minISP = _maxISP * 0.4f;
                //atmospherecurve.Add(0, _maxISP, 0, 0);
                //atmospherecurve.Add(1, _minISP, 0, 0);

                //thrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP);
                thrust = ((float)GetPowerThrustModifier() * (float)GetHeatThrustModifier() * AttachedReactor.MaximumThermalPower / _maxISP / PluginHelper.GravityConstant * (float)GetHeatExchangerThrustDivisor() * _thrustPropellantMultiplier);
                myAttachedEngine.maxFuelFlow = thrust / (PluginHelper.GravityConstant * _maxISP);
                myAttachedEngine.maxThrust = thrust;

                _minISP = _maxISP * ((thrust - maxPressureThresholdAtKerbinSurface) / thrust) * (float)GetHeatExchangerThrustDivisor();
                atmospherecurve.Add(0, _maxISP, 0, 0);
                atmospherecurve.Add(1, _minISP, 0, 0);

                myAttachedEngine.atmosphereCurve = atmospherecurve;
            }

 

except for some minor details it is looking good. It appears I haven't maintained this part of the code for quite some time. If it doesn't break anything, I will integrrate it in the code for next release

Edited by FreeThinker
Link to comment
Share on other sites

20 hours ago, olekopyto said:

Guys!

How to operate a science lab, i have my Generators, Reactors, Radiators and Mangoes in Syrup, but poor labby just wont generate any science. I pushed every button, but Kerbals wouldn't do nothing but clap and move their mouth silently. I think they are plotting on me!

you need to have 2 kerbals in there, i think one must be a scientist at least.Have enough electricity and of course you need data. Do some sience experiment on the vessel with the lab and then there is a 4th button - besides recycle, keep and transmit - it  will give you data from the experiment. right click the Lab and you will see how much data you got and how much science/day will be produced

Link to comment
Share on other sites

Note that gathering research data can be done by any kerbal, but it realy helps to be scientific (scientist) or  at least technical (engineer) and the level of expertise , also it matters how close you are to the body you are reseaching. Landed Labs (except on kerbin) recieve double reseach bonus.

The actual processing can only be done by Professional, like in stock, they KSPI version only do it more effectivly at the cost of significantly more power to crunch the data on the onboard super computer.

Edited by FreeThinker
Link to comment
Share on other sites

It should be noted that the KSPIE science lab is the best one available that I've found.  Processing science data this way can yield you enough science to completely open the CTT (~120,000 science) without going past the orbit of Minmus.  You can do this with any science lab, but the KSPIE one holds a lot more data, so you can do it in fewer launches.  Just set up an orbital science station in Kerbin orbit, have your craft dock and drop off science on their way back to Kerbin, and then you transmit data back down from the station after it's been researched into science points.

Edited by ss8913
Link to comment
Share on other sites

1 hour ago, ss8913 said:

It should be noted that the KSPIE science lab is the best one available that I've found.  Processing science data this way can yield you enough science to completely open the CTT (~120,000 science) without going past the orbit of Minmus.  You can do this with any science lab, but the KSPIE one holds a lot more data, so you can do it in fewer launches.  Just set up an orbital science station in Kerbin orbit, have your craft dock and drop off science on their way back to Kerbin, and then you transmit data back down from the station after it's been researched into science points.

Personally, I think Squad made this mechanism too exploitable. How can repeatedly reprocessing the same data multiple times over give so much data? Imho this kind of defeats the reason to explore and collect science in the rest of the solar system.

Edited by FreeThinker
Link to comment
Share on other sites

 

14 hours ago, FreeThinker said:

except for some minor details it is looking good. It appears I haven't maintained this part of the code for quite some time. If it doesn't break anything, I will integrrate it in the code for next release

Thanks!  I've been playing with that new code and swapping out different reactors and I've come across two things of note:

1. reactor / thermal nozzle combinations that have no thrust at sealevel can cause minISP to go negative.  It looks like the correct way to fix it would be to add another atmospherecurve with the altitude where the engine actually hit's 0.1isp and clamp sealevel to zero, but it may just be a visual problem and not game impacting as negative values don't seem to break anything.

2. the 'gas core' reactor.  The buoyancy effect causes weird things to happen, even with stock code.  100% throttle actually produces slightly less engine thrust then when set to around 60%.  The reactor control window also seems off, thermal power is lower at 60% (as expected) even though more of it seems to be hitting the engine.  There really needs to be a readout on the buoyancy impact.  I also feel like the reactor needs a tiny boost in total thermal power as you lose a pretty large chunk of it while accelerating, which seems odd for a reactor that looks to be designed for thermal nozzles.

All of this also means that the thrust estimate is still way off on the gas core: 371kN vac is reported on the engine and in KER with the new code, but in space it's usually quite a bit lower.  I'm not sure how to calculate the thrust for this engine as it'll need to take into account both stage mass and throttle position, but I'll keep poking at it.

Link to comment
Share on other sites

Calculating effective thrust for Gas Core Reactor is currently indeed very hard, because as you observed, the Reactor is starving itself under acceleration. On way we might solve this problem is to make the boyancy effect more forgiving (clamping it a 0.5 g) and Increase ISP making it accelerate less. That way it will be less likely to starve itself durring burns and therefore more prodictable.

Notice that  already planned to do the last as part of Realsim rebalancing, as I moved the Open Cycle Gas Core Reacor Higher in the Techtree and make it more competive compaired to early Fusion Reactor technology which as in reality are much Larger and Havier.

Edited by FreeThinker
Link to comment
Share on other sites

Hello,

I've had some troubles with parts from this mod, specifically parts disappearing. I've searched around and I see some other people having similar issues but I haven't seen any fixes or conclusive information on what could be causing it.

Basically I have noticed that the Magnetic Nozzle and Orbital Supercollider have vanished from the VAB in career mode; probably other parts as well but I have noticed these 2 things for certain.
I know for certain that the parts were researched and purchased, because I had vehicles with these parts that suddenly became invalid.
This didn't appear to be related to any specific update.
Sometimes the part will come back for a time then vanish again.
The parts appear and function just fine in sandbox mode.
I am running in 64-bit mode, but I feel this isn't a factor.
I have a lot of mods, I can list them if needed.
I've tried reinstalling KSPI without success.
I've wiped all mods, reinstalled without success.


What other information and I provide that could help you to help me?

Thank you,

Link to comment
Share on other sites

1 hour ago, kurdain said:

Hello,

I've had some troubles with parts from this mod, specifically parts disappearing. I've searched around and I see some other people having similar issues but I haven't seen any fixes or conclusive information on what could be causing it.

Basically I have noticed that the Magnetic Nozzle and Orbital Supercollider have vanished from the VAB in career mode; probably other parts as well but I have noticed these 2 things for certain.
I know for certain that the parts were researched and purchased, because I had vehicles with these parts that suddenly became invalid.
This didn't appear to be related to any specific update.
Sometimes the part will come back for a time then vanish again.
The parts appear and function just fine in sandbox mode.
I am running in 64-bit mode, but I feel this isn't a factor.
I have a lot of mods, I can list them if needed.
I've tried reinstalling KSPI without success.
I've wiped all mods, reinstalled without success.


What other information and I provide that could help you to help me?

Thank you,

Weird, you should check your logs they often contain very important clues why part are not showing up.

There could be a number of reason why part aren't showing, including other parts having the same name, double installs but also removal due to replacement ( in the case of magnetic nozzle) or because KSP 1.0.5 suddenly limiting the number op polygons in a game.

Link to comment
Share on other sites

I am familiar with where the crash logs are, but what other logs are you referring to?

If it was a rendering, naming or similar issue why do they appear in sandbox mode?

Thanks for the reply too by the way!

Any known mods that don't get along with KSPI that I could see if I have installed or try uninstalling?

Thank you.

Link to comment
Share on other sites

Btw, for those intrested, I'm working on a new Engine, the Magneto Inertial Fusion Confinement Engine made by nli2work

 

IS2JF3t.jpg

It will be a VISTA light engine, with fixed ISP and uses Lithium instead of Hydrogen as a propellant, but it has the benefit of running at much lower power requirements

Edited by FreeThinker
Link to comment
Share on other sites

I have a bug in the code I posted, I was using AttachedReactor.MaximumThermalPower in the thrust calculation instead of AttachedReactor.MaximumPower.  That was skewing reactors with charged particles.

Fixing that puts everything pretty close to the editor estimate:

Spoiler

 

this is in the format "alt amount shown in editor :: actual in game amount measured by KER"
all numbers with liquid fuel

omega
vac 2209.6 isp - 3115.13kN :: 2209.5 isp - 3049.80kN
sea 1994.0 isp - 2811.94kN :: 1992.2 isp - 2749.29kN

pebble
vac 781.2 - 1566.38 :: 781.2 - 1566.29
sea 629.6 - 1262.41 :: 631.6 - 1266.33

dumbo
vac 781.2 - 3132.77 :: 781.2 - 3132.60
sea 705.4 - 2828.79 :: 706.4 - 2832.71

salt
sea 199.2 - 113.44 :: 206.1 - 117.35

dusty
sea 627.5 - 511.45 :: 632.4 - 515.44

antimater
sea 6082.9 - 3388.03 :: 6090.2 - 3392.05
vac 6628.7 - 3692.00 :: 6628.7 - 3690.56

 

 

Link to comment
Share on other sites

In 1.6.9 noticing that Inertial Confinement Reactors will do something odd when hooked up to a thermal ram jet, basically too much thrust causes them starve themselves and shutdown.  This happens in vacuum, atmosphere, etc.  Apologies if this was already discussed.

Link to comment
Share on other sites

On a related note, BetterBurnTime was also throwing incorrect numbers.  It looks like it depends on engine.MaxThrust to calculate the burn time and it's  just pulled out of the engine config file and never updated.  Since this already getting calculated while the engine is running I just added it into OnFixedUpdate for ThermalNozzleController.cs:

                expectedMaxThrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP);

                expectedMaxThrust *= _thrustPropellantMultiplier * (1f - sootAccumulationPercentage / 200f);

                myAttachedEngine.maxThrust = expectedMaxThrust;

The last line is the only change.  Here's a diff of the changes I've made so far compared to the latest from github:

Spoiler

diff ThermalNozzleController.cs.old ThermalNozzleController.cs -b
885c885,894
<                 _minISP = _maxISP * 0.4f;
---
>                 //_minISP = _maxISP * 0.4f;
>                 //atmospherecurve.Add(0, _maxISP, 0, 0);
>                 //atmospherecurve.Add(1, _minISP, 0, 0);
>
>                 //thrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP);
>                 thrust = ((float)GetPowerThrustModifier() * (float)GetHeatThrustModifier() * AttachedReactor.MaximumPower / _maxISP / PluginHelper.GravityConstant * (float)GetHeatExchangerThrustDivisor() * _thrustPropellantMultiplier);
>                 myAttachedEngine.maxFuelFlow = thrust / (PluginHelper.GravityConstant * _maxISP);
>                 myAttachedEngine.maxThrust = thrust;
>
>                 _minISP = _maxISP * ((thrust - maxPressureThresholdAtKerbinSurface) / thrust) * (float)GetHeatExchangerThrustDivisor();
889,890d897
<                 thrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP);
<                 myAttachedEngine.maxThrust = thrust;
999a1007,1008
>                 myAttachedEngine.maxThrust = expectedMaxThrust;
>

 

Edited by RzTen1
added a diff
Link to comment
Share on other sites

6 hours ago, RzTen1 said:

I have a bug in the code I posted, I was using AttachedReactor.MaximumThermalPower in the thrust calculation instead of AttachedReactor.MaximumPower.  That was skewing reactors with charged particles.

Fixing that puts everything pretty close to the editor estimate:

  Reveal hidden contents

 

this is in the format "alt amount shown in editor :: actual in game amount measured by KER"
all numbers with liquid fuel

omega
vac 2209.6 isp - 3115.13kN :: 2209.5 isp - 3049.80kN
sea 1994.0 isp - 2811.94kN :: 1992.2 isp - 2749.29kN

pebble
vac 781.2 - 1566.38 :: 781.2 - 1566.29
sea 629.6 - 1262.41 :: 631.6 - 1266.33

dumbo
vac 781.2 - 3132.77 :: 781.2 - 3132.60
sea 705.4 - 2828.79 :: 706.4 - 2832.71

salt
sea 199.2 - 113.44 :: 206.1 - 117.35

dusty
sea 627.5 - 511.45 :: 632.4 - 515.44

antimater
sea 6082.9 - 3388.03 :: 6090.2 - 3392.05
vac 6628.7 - 3692.00 :: 6628.7 - 3690.56

 

 

Correct. this was the minor mistake I was referring to

Edited by FreeThinker
Link to comment
Share on other sites

I wasn't all that happy with the prior code I submitted, it was close but still off in odd ways depending on engine/reactor combo, so I've redone all of it.  Orbital thrust and isp now match exactly with actual in game values.  Atmospheric readings are still off by a couple of percent, but that seems to be due to the EarthAtmospherePressureAtSeaLevel constant reading 101.325 while I get closer to 100 on the pad.  In any case, atmospheric is much better and actually usable for orbital insertion calculations.

I also redid the section for BetterBurnTime to accurately calculate the actual maximum thrust so that it matches in flight values exactly.

Buoyancy calculations are still missing, so the open gas core reactor's numbers are optimistic at best.

Here is a diff compared to the current version in github (the last commit added my first patch attempt).  A new vairable has been added to both in-flight sections to avoid stepping on other code, calculatedMaxThrust.  This will contain the maximum thrust at full throttle for the engine at the current altitude both while running and idle, as long as the engine is active.

Spoiler

diff -ub ThermalNozzleController.cs ThermalNozzleController.cs.new
--- ThermalNozzleController.cs  2016-03-17 23:26:59.994654300 -0600
+++ ThermalNozzleController.cs.new      2016-03-17 23:27:04.141891500 -0600
@@ -875,11 +875,33 @@
             {
                 _maxISP = Mathf.Sqrt(AttachedReactor.CoreTemperature) * (PluginHelper.IspCoreTempMult + IspTempMultOffset) * GetIspPropellantModifier();

-                float thrust = GetPowerThrustModifier() * GetHeatThrustModifier() * AttachedReactor.MaximumPower / _maxISP / PluginHelper.GravityConstant * GetHeatExchangerThrustDivisor() * _thrustPropellantMultiplier;
+                float thrust = GetPowerThrustModifier() * GetHeatThrustModifier() * AttachedReactor.MaximumPower / _maxISP / PluginHelper.GravityConstant * GetHeatExchangerThrustDivisor();
+                float max_thrust_in_space = thrust;
+                thrust *= _thrustPropellantMultiplier;
                 myAttachedEngine.maxFuelFlow = thrust / (PluginHelper.GravityConstant * _maxISP);
                 myAttachedEngine.maxThrust = thrust;

-                _minISP = _maxISP * ((thrust - maxPressureThresholdAtKerbinSurface) / thrust) * GetHeatExchangerThrustDivisor();
+                //_minISP = _maxISP * ((thrust - maxPressureThresholdAtKerbinSurface) / thrust) * GetHeatExchangerThrustDivisor();
+                //atmospherecurve.Add(0, _maxISP, 0, 0);
+                //atmospherecurve.Add(1, _minISP, 0, 0);
+
+                float max_thrust_in_current_atmosphere = max_thrust_in_space;
+
+                // update engine thrust/ISP for thermal noozle
+                if (!_currentpropellant_is_jet)
+                {
+                    pressureTreshold = exitArea * (float)GameConstants.EarthAtmospherePressureAtSeaLevel;
+                    if (_maxISP > GameConstants.MaxThermalNozzleIsp )
+                        pressureTreshold *= 10;
+
+                    max_thrust_in_current_atmosphere = max_thrust_in_space - pressureTreshold;
+
+                    var thrustAtmosphereRatio = max_thrust_in_space > 0 ? Math.Max(max_thrust_in_current_atmosphere / max_thrust_in_space, 0.01 ) : 0.01;
+                    _minISP = _maxISP * (float)thrustAtmosphereRatio;
+                }
+                else
+                    _minISP = _maxISP;
+
                 atmospherecurve.Add(0, _maxISP, 0, 0);
                 atmospherecurve.Add(1, _minISP, 0, 0);

@@ -988,19 +1010,26 @@

                 _maxISP = (float)(Math.Sqrt((double)AttachedReactor.CoreTemperature) * (PluginHelper.IspCoreTempMult + IspTempMultOffset) * GetIspPropellantModifier());

-                expectedMaxThrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP);
+                expectedMaxThrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP * (float)GetHeatExchangerThrustDivisor());
+                float calculatedMaxThrust = expectedMaxThrust;
                 expectedMaxThrust *= _thrustPropellantMultiplier * (1f - sootAccumulationPercentage / 200f);

-                myAttachedEngine.maxThrust = expectedMaxThrust;
-
-                // suggested by RzTen1 to improve compatibility with BetterBurnTime
                 max_fuel_flow_rate = (float)(expectedMaxThrust / _maxISP / PluginHelper.GravityConstant);

-                pressureTreshold = _currentpropellant_is_jet ? 0 : exitArea * (float)FlightGlobals.getStaticPressure(vessel.transform.position);
+                if (!_currentpropellant_is_jet)
+                {
+                    pressureTreshold = exitArea * (float)FlightGlobals.getStaticPressure(vessel.transform.position);
+                    if (_maxISP > GameConstants.MaxThermalNozzleIsp)
+                        pressureTreshold *= 10;
+                }
+                else
+                    pressureTreshold = 0;

                 var thrustAtmosphereRatio = expectedMaxThrust <= 0 ? 0 : Math.Max(0, expectedMaxThrust - pressureTreshold) / expectedMaxThrust;

                 current_isp = _maxISP * (float)thrustAtmosphereRatio;
+                calculatedMaxThrust -= pressureTreshold;
+                calculatedMaxThrust *= (float)_thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider);

                 FloatCurve newISP = new FloatCurve();
                 var effectiveIsp = isJet ? Mathf.Min(current_isp, PluginHelper.MaxThermalNozzleIsp) : current_isp;
@@ -1012,8 +1041,12 @@
                     double vcurve_at_current_velocity = myAttachedEngine.velCurve.Evaluate((float)vessel.srf_velocity.magnitude);

                     if (vcurve_at_current_velocity > 0 && !double.IsInfinity(vcurve_at_current_velocity) && !double.IsNaN(vcurve_at_current_velocity))
+                    {
                         max_fuel_flow_rate = (float)(max_fuel_flow_rate / vcurve_at_current_velocity);
+                        calculatedMaxThrust = calculatedMaxThrust / (float)vcurve_at_current_velocity;
+                    }
                 }
+                myAttachedEngine.maxThrust = calculatedMaxThrust > 0 ? calculatedMaxThrust : 0;

                 // set engines maximum fuel flow
                 myAttachedEngine.maxFuelFlow = Math.Min(1000f, (float)max_fuel_flow_rate);
@@ -1072,11 +1105,13 @@
             heatExchangerThrustDivisor = (float)GetHeatExchangerThrustDivisor();
             radiusModifier = (heatExchangerThrustDivisor * 100).ToString("0.00") + "%";
             engineMaxThrust = 0.01f;
+            float calculatedMaxThrust = 0;
             if (_availableThermalPower > 0)
             {
                 var ispRatio = _currentpropellant_is_jet ? current_isp / _maxISP : 1;
                 var thrustLimit = myAttachedEngine.thrustPercentage / 100.0f;
                 engineMaxThrust = (float)Math.Max(thrustLimit * GetPowerThrustModifier() * GetHeatThrustModifier() * thermal_power_received / _maxISP / PluginHelper.GravityConstant * heatExchangerThrustDivisor * ispRatio / myAttachedEngine.currentThrottle, 0.01);
+                calculatedMaxThrust = GetPowerThrustModifier() * GetHeatThrustModifier() * AttachedReactor.MaximumPower / _maxISP / PluginHelper.GravityConstant * heatExchangerThrustDivisor * ispRatio;
             }

             max_thrust_in_space = engineMaxThrust / myAttachedEngine.thrustPercentage * 100;
@@ -1097,13 +1132,21 @@
                 var thrustAtmosphereRatio = max_thrust_in_space > 0 ? Math.Max(max_thrust_in_current_atmosphere / max_thrust_in_space, 0.01 ) : 0.01;
                 UpdateIspEngineParams(thrustAtmosphereRatio);
                 current_isp = _maxISP * (float)thrustAtmosphereRatio;
+                calculatedMaxThrust -= pressureTreshold;
             }
             else
                 current_isp = _maxISP;

-            final_max_engine_thrust = !Single.IsInfinity(max_thrust_in_current_atmosphere) && !Single.IsNaN(max_thrust_in_current_atmosphere)
-                ? max_thrust_in_current_atmosphere * _thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider)
-                : 0.000001f;
+            if (!Single.IsInfinity(max_thrust_in_current_atmosphere) && !Single.IsNaN(max_thrust_in_current_atmosphere))
+            {
+                final_max_engine_thrust = max_thrust_in_current_atmosphere * _thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider);
+                calculatedMaxThrust *= (float)_thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider);
+            }
+            else
+            {
+                final_max_engine_thrust = 0.000001f;
+                calculatedMaxThrust = final_max_engine_thrust;
+            }

             // amount of fuel being used at max throttle with no atmospheric limits
             if (_maxISP <= 0) return;
@@ -1116,10 +1159,17 @@
                 vcurveAtCurrentVelocity = myAttachedEngine.velCurve.Evaluate((float)(vessel.speed / vessel.speedOfSound));

                 if (vcurveAtCurrentVelocity > 0 && !double.IsInfinity(vcurveAtCurrentVelocity) && !double.IsNaN(vcurveAtCurrentVelocity))
+                {
                     max_fuel_flow_rate = (float)(max_fuel_flow_rate * vcurveAtCurrentVelocity);
+                    calculatedMaxThrust *= (float)vcurveAtCurrentVelocity;
+                }
                 else
+                {
                     max_fuel_flow_rate = 0.000001f;
+                    calculatedMaxThrust = 0;
+                }
             }
+            myAttachedEngine.maxThrust = calculatedMaxThrust > 0 ? calculatedMaxThrust : 0;

             if (atmospheric_limit > 0 && atmospheric_limit != 1 && !double.IsInfinity(atmospheric_limit) && !double.IsNaN(atmospheric_limit))
                 max_fuel_flow_rate = max_fuel_flow_rate * atmospheric_limit;

 

In case that's hard to read, here are the changed functions in their entirety.

EstimateEditorPerformance:
 

Spoiler

        public void EstimateEditorPerformance()
        {
            FloatCurve atmospherecurve = new FloatCurve();
            UpdateRadiusModifier();

            if (AttachedReactor != null)
            {
                _maxISP = Mathf.Sqrt(AttachedReactor.CoreTemperature) * (PluginHelper.IspCoreTempMult + IspTempMultOffset) * GetIspPropellantModifier();

                float thrust = GetPowerThrustModifier() * GetHeatThrustModifier() * AttachedReactor.MaximumPower / _maxISP / PluginHelper.GravityConstant * GetHeatExchangerThrustDivisor();
                float max_thrust_in_space = thrust;
                thrust *= _thrustPropellantMultiplier;
                myAttachedEngine.maxFuelFlow = thrust / (PluginHelper.GravityConstant * _maxISP);
                myAttachedEngine.maxThrust = thrust;

                //_minISP = _maxISP * ((thrust - maxPressureThresholdAtKerbinSurface) / thrust) * GetHeatExchangerThrustDivisor();
                //atmospherecurve.Add(0, _maxISP, 0, 0);
                //atmospherecurve.Add(1, _minISP, 0, 0);
                
                float max_thrust_in_current_atmosphere = max_thrust_in_space;
            
                // update engine thrust/ISP for thermal noozle
                if (!_currentpropellant_is_jet)
                {
                    pressureTreshold = exitArea * (float)GameConstants.EarthAtmospherePressureAtSeaLevel;
                    if (_maxISP > GameConstants.MaxThermalNozzleIsp )
                        pressureTreshold *= 10;

                    max_thrust_in_current_atmosphere = max_thrust_in_space - pressureTreshold;

                    var thrustAtmosphereRatio = max_thrust_in_space > 0 ? Math.Max(max_thrust_in_current_atmosphere / max_thrust_in_space, 0.01 ) : 0.01;
                    _minISP = _maxISP * (float)thrustAtmosphereRatio;
                }
                else
                    _minISP = _maxISP;

                atmospherecurve.Add(0, _maxISP, 0, 0);
                atmospherecurve.Add(1, _minISP, 0, 0);

                myAttachedEngine.atmosphereCurve = atmospherecurve;
            }
            else
            {
                atmospherecurve.Add(0, 0.00001f, 0, 0);
                myAttachedEngine.maxThrust = 0;
                myAttachedEngine.atmosphereCurve = atmospherecurve;
            }
        }

OnFixedUpdate -  if myAttachedEngine.isOperational block:
 

Spoiler

            if (myAttachedEngine.isOperational && myAttachedEngine.currentThrottle > 0)
                GenerateThrustFromReactorHeat();
            else
            {
                //requestedReactorThermalPower = String.Empty;
                //requestedReactorChargedPower = String.Empty;
                //recievedReactorPower = String.Empty;

                consumedWasteHeat = 0;

                atmospheric_limit = GetAtmosphericLimit();

                _maxISP = (float)(Math.Sqrt((double)AttachedReactor.CoreTemperature) * (PluginHelper.IspCoreTempMult + IspTempMultOffset) * GetIspPropellantModifier());

                expectedMaxThrust = (float)(AttachedReactor.MaximumPower * GetPowerThrustModifier() * GetHeatThrustModifier() / PluginHelper.GravityConstant / _maxISP * (float)GetHeatExchangerThrustDivisor());
                float calculatedMaxThrust = expectedMaxThrust;
                expectedMaxThrust *= _thrustPropellantMultiplier * (1f - sootAccumulationPercentage / 200f);

                max_fuel_flow_rate = (float)(expectedMaxThrust / _maxISP / PluginHelper.GravityConstant);

                if (!_currentpropellant_is_jet)
                {
                    pressureTreshold = exitArea * (float)FlightGlobals.getStaticPressure(vessel.transform.position);
                    if (_maxISP > GameConstants.MaxThermalNozzleIsp)
                        pressureTreshold *= 10;
                }
                else
                    pressureTreshold = 0;
            
                var thrustAtmosphereRatio = expectedMaxThrust <= 0 ? 0 : Math.Max(0, expectedMaxThrust - pressureTreshold) / expectedMaxThrust;

                current_isp = _maxISP * (float)thrustAtmosphereRatio;
                calculatedMaxThrust -= pressureTreshold;
                calculatedMaxThrust *= (float)_thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider);

                FloatCurve newISP = new FloatCurve();
                var effectiveIsp = isJet ? Mathf.Min(current_isp, PluginHelper.MaxThermalNozzleIsp) : current_isp;
                newISP.Add(0, effectiveIsp, 0, 0);
                myAttachedEngine.atmosphereCurve = newISP;

                if (myAttachedEngine.useVelCurve)
                {
                    double vcurve_at_current_velocity = myAttachedEngine.velCurve.Evaluate((float)vessel.srf_velocity.magnitude);

                    if (vcurve_at_current_velocity > 0 && !double.IsInfinity(vcurve_at_current_velocity) && !double.IsNaN(vcurve_at_current_velocity))
                    {
                        max_fuel_flow_rate = (float)(max_fuel_flow_rate / vcurve_at_current_velocity);
                        calculatedMaxThrust = calculatedMaxThrust / (float)vcurve_at_current_velocity;
                    }
                }
                myAttachedEngine.maxThrust = calculatedMaxThrust > 0 ? calculatedMaxThrust : 0;

                // set engines maximum fuel flow
                myAttachedEngine.maxFuelFlow = Math.Min(1000f, (float)max_fuel_flow_rate);

                if (myAttachedEngine is ModuleEnginesFX && !String.IsNullOrEmpty(_particleFXName))
                {
                    part.Effect(_particleFXName, 0);
                }
            }

GenerateThrustFromReactorHeat:
 

Spoiler

private void GenerateThrustFromReactorHeat()
        {
            if (!AttachedReactor.IsActive)
                AttachedReactor.EnableIfPossible();

            GetMaximumIspAndThrustMultiplier();

            float chargedPowerModifier = _isNeutronAbsorber ? 1 : (AttachedReactor.FullPowerForNonNeutronAbsorbants ? 1 : (float)_myAttachedReactor.ChargedPowerRatio);

            thermal_modifiers = myAttachedEngine.currentThrottle * GetAtmosphericLimit() * _myAttachedReactor.GetFractionThermalReciever(id) * chargedPowerModifier;

            var maximum_requested_thermal_power = _currentMaximumPower * thermal_modifiers;

            var neutronAbsorbingModifier = _isNeutronAbsorber ? 1 : (AttachedReactor.FullPowerForNonNeutronAbsorbants ? 1 : 0);
            requested_thermal_power = Math.Min(_availableThermalPower * thermal_modifiers, AttachedReactor.MaximumThermalPower * delayedThrottle * neutronAbsorbingModifier);

            thermal_power_received = consumeFNResource(requested_thermal_power * TimeWarp.fixedDeltaTime, FNResourceManager.FNRESOURCE_THERMALPOWER) * _myAttachedReactor.ThermalPropulsionEfficiency / TimeWarp.fixedDeltaTime;

            if (thermal_power_received < maximum_requested_thermal_power)
            {
                var chargedParticleRatio = (float)Math.Pow(getResourceBarRatio(FNResourceManager.FNRESOURCE_CHARGED_PARTICLES), 2);
                requested_charge_particles = Math.Min((maximum_requested_thermal_power - thermal_power_received), AttachedReactor.MaximumChargedPower) * chargedParticleRatio;

                thermal_power_received += consumeFNResource(requested_charge_particles * TimeWarp.fixedDeltaTime, FNResourceManager.FNRESOURCE_CHARGED_PARTICLES) / TimeWarp.fixedDeltaTime;
            }

            UpdateSootAccumulation();

            var extraWasteheatRedution = AttachedReactor.FullPowerForNonNeutronAbsorbants
                ? TimeWarp.fixedDeltaTime * getResourceAvailability(FNResourceManager.FNRESOURCE_WASTEHEAT) * myAttachedEngine.currentThrottle
                : 0;

            var sootModifier = 1f - (sootAccumulationPercentage / sootHeatDivider);

            consumedWasteHeat = sootModifier * (float)Math.Max(AttachedReactor.ProducedWasteHeat + extraWasteheatRedution, thermal_power_received);

            // consume wasteheat
            consumeFNResource(consumedWasteHeat * TimeWarp.fixedDeltaTime, FNResourceManager.FNRESOURCE_WASTEHEAT);
            
            // calculate max thrust
            heatExchangerThrustDivisor = (float)GetHeatExchangerThrustDivisor();
            radiusModifier = (heatExchangerThrustDivisor * 100).ToString("0.00") + "%";
            engineMaxThrust = 0.01f;
            float calculatedMaxThrust = 0;
            if (_availableThermalPower > 0)
            {
                var ispRatio = _currentpropellant_is_jet ? current_isp / _maxISP : 1;
                var thrustLimit = myAttachedEngine.thrustPercentage / 100.0f;
                engineMaxThrust = (float)Math.Max(thrustLimit * GetPowerThrustModifier() * GetHeatThrustModifier() * thermal_power_received / _maxISP / PluginHelper.GravityConstant * heatExchangerThrustDivisor * ispRatio / myAttachedEngine.currentThrottle, 0.01);
                calculatedMaxThrust = GetPowerThrustModifier() * GetHeatThrustModifier() * AttachedReactor.MaximumPower / _maxISP / PluginHelper.GravityConstant * heatExchangerThrustDivisor * ispRatio;
            }

            max_thrust_in_space = engineMaxThrust / myAttachedEngine.thrustPercentage * 100;

            var nozzleStaticPresure = (float)FlightGlobals.getStaticPressure(vessel.transform.position);

            max_thrust_in_current_atmosphere = max_thrust_in_space;
            
            // update engine thrust/ISP for thermal noozle
            if (!_currentpropellant_is_jet)
            {
                pressureTreshold = exitArea * nozzleStaticPresure;
                if (_maxISP > GameConstants.MaxThermalNozzleIsp )
                    pressureTreshold *= 10;

                max_thrust_in_current_atmosphere = Mathf.Max(max_thrust_in_space - pressureTreshold, Mathf.Max(myAttachedEngine.currentThrottle * 0.01f, 0.0001f));

                var thrustAtmosphereRatio = max_thrust_in_space > 0 ? Math.Max(max_thrust_in_current_atmosphere / max_thrust_in_space, 0.01 ) : 0.01;
                UpdateIspEngineParams(thrustAtmosphereRatio);
                current_isp = _maxISP * (float)thrustAtmosphereRatio;
                calculatedMaxThrust -= pressureTreshold;
            }
            else
                current_isp = _maxISP;

            if (!Single.IsInfinity(max_thrust_in_current_atmosphere) && !Single.IsNaN(max_thrust_in_current_atmosphere))
            {
                final_max_engine_thrust = max_thrust_in_current_atmosphere * _thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider);
                calculatedMaxThrust *= (float)_thrustPropellantMultiplier * (1f - sootAccumulationPercentage / sootThrustDivider);
            }
            else
            {
                final_max_engine_thrust = 0.000001f;
                calculatedMaxThrust = final_max_engine_thrust;
            }

            // amount of fuel being used at max throttle with no atmospheric limits
            if (_maxISP <= 0) return;
            
            // calculate maximum fuel flow rate
            max_fuel_flow_rate = final_max_engine_thrust / current_isp / PluginHelper.GravityConstant / myAttachedEngine.currentThrottle;

            if (myAttachedEngine.useVelCurve && myAttachedEngine.velCurve != null)
            {
                vcurveAtCurrentVelocity = myAttachedEngine.velCurve.Evaluate((float)(vessel.speed / vessel.speedOfSound));

                if (vcurveAtCurrentVelocity > 0 && !double.IsInfinity(vcurveAtCurrentVelocity) && !double.IsNaN(vcurveAtCurrentVelocity))
                {
                    max_fuel_flow_rate = (float)(max_fuel_flow_rate * vcurveAtCurrentVelocity);
                    calculatedMaxThrust *= (float)vcurveAtCurrentVelocity;
                }
                else
                {
                    max_fuel_flow_rate = 0.000001f;
                    calculatedMaxThrust = 0;
                }
            }
            myAttachedEngine.maxThrust = calculatedMaxThrust > 0 ? calculatedMaxThrust : 0;

            if (atmospheric_limit > 0 && atmospheric_limit != 1 && !double.IsInfinity(atmospheric_limit) && !double.IsNaN(atmospheric_limit))
                max_fuel_flow_rate = max_fuel_flow_rate * atmospheric_limit;

            engineHeatProduction = (max_fuel_flow_rate >= 0.0001) ? baseHeatProduction * 350 / max_fuel_flow_rate /(float)Math.Pow(_maxISP, 0.8)  : baseHeatProduction;
            myAttachedEngine.heatProduction = engineHeatProduction;

            // set engines maximum fuel flow
            myAttachedEngine.maxFuelFlow = Math.Min(1000, max_fuel_flow_rate);

            if (myAttachedEngine is ModuleEnginesFX && !String.IsNullOrEmpty(_particleFXName))
            {
                part.Effect(_particleFXName, Mathf.Max(0.1f * myAttachedEngine.currentThrottle,  Mathf.Min((float)Math.Pow(thermal_power_received / requested_thermal_power, 0.5), delayedThrottle)));
            }

            if (_fuelToxicity > 0 && max_fuel_flow_rate > 0 && nozzleStaticPresure > 1)
            {
                _savedReputationCost += (float)(max_fuel_flow_rate * _fuelToxicity * TimeWarp.fixedDeltaTime * Math.Pow(nozzleStaticPresure / 100, 3));
                if (_savedReputationCost > 1)
                {
                    float flooredReputationCost = (int)Math.Floor(_savedReputationCost);

                    if (Reputation.Instance != null)
                        Reputation.Instance.addReputation_discrete(-flooredReputationCost, TransactionReasons.None);
                    else
                        UnityEngine.Debug.Log("[KSPI] - ThermalNozzleController - No Reputation found, was not able to reduce reputation by " + flooredReputationCost);

                    ScreenMessages.PostScreenMessage("You are poisoning the environment with " + _fuelmode + " from your exhaust!", 5.0f, ScreenMessageStyle.LOWER_CENTER);
                    _savedReputationCost -= flooredReputationCost;
                }
            }
        }

 

Edited by RzTen1
switched to a unified diff
Link to comment
Share on other sites

I noticed some weirdness in the current build.  I'm getting correct thrust numbers for everything I've thrown at it, but three reactors are acting up:

1. The 'Reactor: Antimatter' reactor is only generating 480KW of power.  The thermal mechanics helper and the reactor control panel both show the same numbers.
2. The 'Antimatter Initiated Fusion Reactor' is only generating 81KW.  Same as above in the helper/panel.
3. The 'Magneto Internal Fusion Reactor' is generating 13.5MW, which seems correct, but the thermal nozzle will only accept Lithium as the fuel source.  I can't get the Lithium cans to attach for some reason, so I can't test with it.

The 'Magnetic Confinement Fusion Reactor' seems unaffected and is generating an expected 27MW.

Also both generators seem to have issues attaching to the rocket:
floaty.png

 

Link to comment
Share on other sites

2 hours ago, RzTen1 said:

 noticed some weirdness in the current build.  I'm getting correct thrust numbers for everything I've thrown at it, but three reactors are acting up:

1. The 'Reactor: Antimatter' reactor is only generating 480KW of power.  The thermal mechanics helper and the reactor control panel both show the same numbers.
2. The 'Antimatter Initiated Fusion Reactor' is only generating 81KW.  Same as above in the helper/panel.
3. The 'Magneto Internal Fusion Reactor' is generating 13.5MW, which seems correct, but the thermal nozzle will only accept Lithium as the fuel source.  I can't get the Lithium cans to attach for some reason, so I can't test with it.

The 'Magnetic Confinement Fusion Reactor' seems unaffected and is generating an expected 27MW.

Also both generators seem to have issues attaching to the rocket:
floaty.png

 

 

2 hours ago, RzTen1 said:

I noticed some weirdness in the current build.  I'm getting correct thrust numbers for everything I've thrown at it, but three reactors are acting up:

1. The 'Reactor: Antimatter' reactor is only generating 480KW of power.  The thermal mechanics helper and the reactor control panel both show the same numbers.
2. The 'Antimatter Initiated Fusion Reactor' is only generating 81KW.  Same as above in the helper/panel.
3. The 'Magneto Internal Fusion Reactor' is generating 13.5MW, which seems correct, but the thermal nozzle will only accept Lithium as the fuel source.  I can't get the Lithium cans to attach for some reason, so I can't test with it.

The 'Magnetic Confinement Fusion Reactor' seems unaffected and is generating an expected 27MW.

Also both generators seem to have issues attaching to the rocket:
floaty.png

 

Are you sure you haven't installed NFT-E or SETI? it reduces all reactors power by a factor 500. But I will verify the 2 Antimatter reactor still work. Something might have broken

Also it is correct that the Magneto Internal Fusion Reactor / Engine can only us lithium, this is intended.The lithrium function both a method of achieving inertial confinment, act as neutron energy conversion medium and propellant to generate thrust. No other 'propellant' can do all this so well.Because it does not need any heat exchange , the temperature can go much higher and therefre achieve higher effective Isp.

Edited by FreeThinker
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...