User:RA2lover/Sandbox/Thermodynamics machinery notes/Combustion Processors
More actions
Internal Combustion Engine
Both the Combustion Centrifuge and Combustion Deep Miner share the same Internal Combustion engine, running these stages each tick:
Game Tick Combustion
Performed during game tick before all following actions.
Manual Combust
- Stores Game Tick combustion energy
- Force-combusts internal atmosphere on top of existing combustion (Combustion limiter^2 * 75%), clamped between 0.1% and 100%
- Because maximum combustion limiter setting is 100%, this limits maximum force-combustion to 75% of whatever fuel mix was in the atmosphere after game tick combustion.
- Because the combustion limiter is clamped into 10% increments, this leads to the following force-combustion percentages:
| Combustion Limiter setting | Combustion Percentage |
|---|---|
| 0% | 0.1% |
| 10% | 0.75% |
| 20% | 3% |
| 30% | 6.75% |
| 40% | 12% |
| 50% | 18.75% |
| 60% | 27% |
| 70% | 36.75% |
| 80% | 48% |
| 90% | 60.75% |
| 100% | 75% |
Speed Tick
- Target a 4000 kPa internal chamber pressure. Excess pressure is sent into exhaust during gas output stage.
- If internal atmosphere is above 300°C and total energy combusted combining game tick combustion and manual combustion exceeds 30 J:
- Increase RPM by Internal atmosphere temperature(in Kelvin) / 5000 K (clamped between 0 and 12 RPM/tick)
- Remove 30 J * RPM gained from internal atmosphere.
- Decrease RPM by 1%
- Check net RPM gain/loss after the previous steps.
- If RPM difference compared to is less than 1/ Lerp(0.8, 2, (Current RPM-300) / 1200 ), decrease stress percentage by 0.5, to a minimum of 0.
- Otherwise, increase stress percentage by (RPM difference - 1) * Lerp(0.8, 2, (Current RPM-300) / 1200 )
- If stress percentage is at 100% or more, decrease RPM by 40 and enter shutdown state.
Shutdown state
(Only runs if the machine is powered off or if it has been overstressed to a shutdown state)
- Decrease RPM by 15.
- Target a RPM*4 kPa chamber pressure (limited to 4000 kPa). Excess pressure is sent into exhaust during gas output stage.
Gas Output Stage
- If internal chamber pressure is less than target, skip this stage.
- Otherwise, remove the smaller of:
- PressurePerTick * 10 L at chamber temperature
- 10% of Excess pressure(in kPa) * Internal atmosphere volume at chamber temperature
- Send removed contents into exhaust network.
Gas Input Stage
- If on, powered and not in a stress shutdown/error state:
- Remove 0..0.01 mols from input network and move into combustion network, scaled from 0 to full throttle and add into internal atmosphere, to be combusted during next tick.
- Note throttle is clamped into 10% increments - without a mol-limited input network you can only feed in fuel mix in multiples of 0.001 mol.
After the gas input stage, spark internal atmosphere if device is on and powered. This is not a part of the internal combustion engine's steps, but starts ignition on the next tick.
Combustion Deep Miner
- Process progress during server export tick, adding deltaTime * RPM/200 to progress time for current ore (also applies to regular deep miner)
- If elapsed progress is greater than the current ore's spawn time and machine is able to export, spawn a dirty ore chunk into its export slot and elapsed progress to 0, generating a new time until next chunk.
Combustion Centrifuge
- Process progress between shutdown handling state and gas output stage.
- Add game tick duration * RPM/300 progress time to thing being processed.
- Base processing time for items is 6 seconds/item for dirty ore/reagent mix, 1 second for regular ores.
- Assert an error state if total processed reagents exceeds 3000g.
- If ejecting something during server export tick, increase stress by RPM/10% - 1%, limited to a minimum of 0%, then decrease RPM by 1/10th.
- Reagents only get ejected if the contents for the respective reagent exceed 1g.
- The order in which reagents is ejected is fixed. In descending priority:
| Flour |
| Milk |
| Egg |
| Iron |
| Gold |
| Carbon (Charcoal) |
| Uranium |
| Copper |
| Steel |
| Hydrocarbon (Coal Ore) |
| Silver |
| Nickel |
| Lead |
| Electrum |
| Invar |
| Constantan |
| Solder |
| Plastic |
| Silicon |
| Salicylic Acid |
| Alcohol |
| Oil (Soy Oil) |
| Potato |
| Tomato |
| Fenoxitone |
| Coloring (Red) |
| Coloring (Green) |
| Coloring (Blue) |
| Coloring (Yellow) |
| Coloring (Orange) |
| Pumpkin |
| Rice |
| Waspaloy |
| Stellite |
| Inconel |
| Hastelloy |
| Astroloy |
| Cobalt |
| Corn |
| Wheat |
| Biomass |
| Soy (Soybean) |
| Mushroom |
| Sugar |
| Cocoa |
| Cheese |
Control theory
The centrifuge needs 30 J/tick of combustion to keep torque production and heat capture. For combustion mechanics, we can refer to Atmosphere.TryCombust. As a reminder, within a combustion processor it happens in two stages: natural combustion and manual combustion.
Natural combustion uses a combustion multiplier curve:
- If less than either 0.3 mmol of fuel or oxidizer and less than 0.3mmol of hypergolics is present, full combustion rate happens.
- If either nitrous oxide or ozone exceed 10% of the total oxidizers present, combustion rate is 0.05+(1/(0.025*gas temperature in °C)1.01)
- If not, combustion rate is 0.05+ (1/(0.02*gas temperature in °C)1.6)
- The combustion rate obtained in the above steps is then clamped between 0 and 1 and divided by 5 to get the combustion's ratio.
- With superfuel, full combustion starts dropping off at 42.08°C. With regular fuel, it starts dropping off at 51.63°C.
- Because the combustion centrifuge needs to be at least at 300°C to operate, natural combustion is fully in the combustion multiplier curve regime.
Starting from ~1371°C on regular fuel and 7591°C on superfuel, this equals the lowest combustion limiter setting. Temperatures lower than this equal to higher settings, but even at the maximum burn rate temperatures it's only equal to a ~40% combustion limiter setting.
Outside cooling the centrifuge at the absolute fastest rate possible (which does require this minimum fuel management), acceleration can be handled with a simple temperature control loop as temperature controls the centrifuge's torque production.
The optimal acceleration or deceleration rate for stress reduction is slightly past clamp(1000/(RPM+500), 0.5, 1.25). At that point, stress changes at (1-excess RPM)%*clamp(1000/(RPM+500), 0.5, 1.25)/tick instead of 0.5%/tick, which is always faster than 0.5%/tick when excess RPM is 0. Neutral stress buildup happens with an excess RPM of 1. Because temperature directly controls the engine's torque, we can map an optimal RPM to temperature curve.
Raw Torque produced is lerp(0,12, Internal Temperature/5000 K). Friction then decreases RPM after torque production to 0.99x RPM. After the factors get applied, the temperature required for neutral net torque can be obtained by solving RPM = (RPM + lerp(0,12,T/5000))*0.99:
w = (0.99w+(12T/5000)*0.99)0.01w = 0.0024T*0.990.01w = 0.002376Tw = 0.2376T
We can then use stress as a leeway factor in our control loop:
alias Engine db l r0 Engine RPM #Calculate minimum-stress acceleration add r1 r0 500 div r1 1000 r1 clamp r1 0.5 1.25 #Use stress as a proxy to push the acceleration further, targeting 50% stress l r2 Engine Stress mul r2 r2 0.01 lerp r2 2 0 r2 #neutral stress buildup at 1 add r1 r2 r1 #whether to speed up or slow down, this can be omitted select r2 Accelerating 99 -99 #also applies acceleration factor. mul r1 r1 r2 #416.(6) K offset = 1 RPM/tick. multiplied by 0.2376, we get 99. #Apply acceleration on top of RPM add r1 r0 r1 #convert target RPM to target temperature in Kelvin div r1 0.2376 r1