models.feed_systems.tank¶
Stateless two-phase propellant tank model backed by CoolProp. The Tank carries no propellant state: pressure and density are pure functions of the state supplied by the caller. get_pressure(fluid_mass) returns the tank pressure from two-phase equilibrium (saturation pressure while liquid is present, single-phase vapour from the real-gas equation of state otherwise), and get_density(fluid_mass) the density at current conditions.
A tank is isothermal by default: its temperature is held where it was loaded, so a self-pressurizing tank holds its saturation pressure flat for as long as any liquid remains. Passing isothermal=False runs an energy balance instead. The tank's internal energy then becomes a second state variable the integrator carries beside the mass, starting from initial_internal_energy and falling by the enthalpy of whatever drains out (get_outflow_specific_enthalpy), so the temperature and the saturation pressure decay over the burn. Every query on such a tank takes that internal energy alongside the mass, and says so when it is missing.
Tanks are identified by CoolProp fluid name (e.g., "N2O", "Oxygen", "Hydrogen").
machwave.models.feed_systems.tank
¶
Tank
¶
A generic two-phase tank model for any single fluid recognized by CoolProp.
This is a static description of the tank: it carries no propellant state. Pressure and density are pure functions of the state passed in by the caller, which lets the integrator own that state and keeps the model re-runnable.
An isothermal tank is a pure function of the fluid mass. Its temperature is held where it was loaded, so a self-pressurizing tank holds its saturation pressure flat for as long as any liquid remains.
A tank running an energy balance is a function of the fluid mass and of the internal energy the integrator carries alongside it. Draining takes enthalpy out with the fluid, the fluid left behind cools as it boils to refill the ullage, and the saturation pressure follows the temperature down over the burn.
Assumptions
- Two-phase equilibrium if there's enough mass to form liquid + vapor.
- If insufficient mass for liquid, treat it as single-phase vapor via the real-gas equation of state.
- Nothing crosses the tank wall: no heat in, and no work other than what the leaving fluid carries.
Source code in machwave/models/feed_systems/tank.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
initial_internal_energy
cached
property
¶
Internal energy of the fluid the tank is loaded with [J].
Where a tank running an energy balance starts. The integrator carries it from here, taking out the enthalpy of whatever leaves.
__init__(fluid_name, volume, temperature, initial_fluid_mass, overfill_tolerance=0.01, isothermal=True)
¶
Initialize a two-phase tank model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fluid_name
|
str
|
Name of the fluid in the CoolProp database. |
required |
volume
|
float
|
Internal volume of the tank [m^3] (>0). |
required |
temperature
|
float
|
Absolute temperature [K] the tank is loaded at (>0). An isothermal tank stays there; a tank running an energy balance starts there and cools from it. |
required |
initial_fluid_mass
|
float
|
Initial total mass of fluid [kg] (>=0). This is the tank's loading; the integrator owns the mass thereafter. |
required |
overfill_tolerance
|
float
|
Allowed fraction over the saturated liquid density, e.g. 0.01 = 1% (>=0). |
0.01
|
isothermal
|
bool
|
Whether the temperature is held where the tank was
loaded. False runs an energy balance instead, and every query
then needs the internal energy the integrator carries beside
the mass, starting from |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the fluid is unknown to CoolProp, if any argument is outside its valid physical range, or if the initial fill is denser than the saturated liquid. |
Source code in machwave/models/feed_systems/tank.py
get_density(fluid_mass, internal_energy=None)
¶
Return fluid density [kg/m^3] for a given fluid state.
1) An empty tank has zero density. 2) Otherwise the fill state fixes the density: a partially liquid tank returns the saturated liquid density (the feed system pulls liquid from the bottom), and an all-vapor tank returns the bulk density.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fluid_mass
|
float
|
Current total mass of fluid in the tank [kg]. |
required |
internal_energy
|
float | None
|
Current internal energy of that fluid [J]. Required for a tank running an energy balance, unused otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Fluid density [kg/m^3]. |
Source code in machwave/models/feed_systems/tank.py
get_outflow_specific_enthalpy(fluid_mass, internal_energy=None)
¶
Return the specific enthalpy of the fluid leaving the tank [J/kg].
What the energy balance takes out per unit mass drained. The feed system draws liquid from the bottom while any remains, and vapor at the bulk state once none does, so this steps up by the latent heat as the last of the liquid goes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fluid_mass
|
float
|
Current total mass of fluid in the tank [kg]. |
required |
internal_energy
|
float | None
|
Current internal energy of that fluid [J]. Required for a tank running an energy balance, unused otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Specific enthalpy of the leaving fluid [J/kg]. |
Source code in machwave/models/feed_systems/tank.py
get_pressure(fluid_mass, internal_energy=None)
¶
Return the tank pressure [Pa] for a given fluid state.
1) An empty tank has zero pressure. 2) If the fluid mass exceeds the mass of saturated vapor that fills the tank, the tank is partially liquid and the pressure is the saturation pressure. 3) Otherwise, the tank is all sub-saturated vapor and the pressure follows the real-gas equation of state at the bulk density. This matches the saturation pressure at the phase boundary, so pressure stays continuous as the tank crosses out of the two-phase regime.
A tank running an energy balance reads both off the state its mass and internal energy fix, which walks the saturation pressure down with the temperature instead of holding it flat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fluid_mass
|
float
|
Current total mass of fluid in the tank [kg]. |
required |
internal_energy
|
float | None
|
Current internal energy of that fluid [J]. Required for a tank running an energy balance, unused otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Tank pressure [Pa]. |
Source code in machwave/models/feed_systems/tank.py
get_temperature(fluid_mass, internal_energy=None)
¶
Return the fluid temperature [K].
An isothermal tank stays where it was loaded. A tank running an energy balance follows its fluid down as the fluid boils to refill the ullage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fluid_mass
|
float
|
Current total mass of fluid in the tank [kg]. |
required |
internal_energy
|
float | None
|
Current internal energy of that fluid [J]. Required for a tank running an energy balance, unused otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Fluid temperature [K]. |
Source code in machwave/models/feed_systems/tank.py
is_delivering_liquid(fluid_mass, internal_energy=None)
¶
Whether the tank still holds liquid to feed, rather than vapor alone.
True while the fluid mass exceeds the mass of saturated vapor that fills the tank, which is where the two-phase equilibrium holds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fluid_mass
|
float
|
Current total mass of fluid in the tank [kg]. |
required |
internal_energy
|
float | None
|
Current internal energy of that fluid [J]. Required for a tank running an energy balance, unused otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if liquid remains in the tank. |
Source code in machwave/models/feed_systems/tank.py
TankFluidState
dataclass
¶
The fluid in a tank at one mass and internal energy.
Attributes:
| Name | Type | Description |
|---|---|---|
temperature |
float
|
Fluid temperature [K]. |
pressure |
float
|
Tank pressure [Pa]. |
saturated_liquid_density |
float
|
Saturated liquid density at the temperature [kg/m^3]. |
saturated_vapor_density |
float
|
Saturated vapor density at the temperature [kg/m^3]. |