修改体积导数计算逻辑,补充完善index.md
This commit is contained in:
1 parent
1cf8427b52
commit
3994835c65
8 files changed
+557
-232
No files matched your search
@@ -6,6 +6,7 @@ sys.path.insert(0, "src")
|
||||
|
||||
from cryo_tank.properties import (
|
||||
ln2_rho, ln2_h, ln2_u, ln2_T_from_u,
|
||||
ln2_drho_dT_const_p, ln2_du_dT_const_p,
|
||||
he_u, he_h, he_cp, he_cv,
|
||||
)
|
||||
from cryo_tank.config import P_WORKING
|
||||
@@ -32,6 +33,21 @@ class TestLN2Properties:
|
||||
T_recovered = ln2_T_from_u(u, P_WORKING)
|
||||
assert abs(T_recovered - T_orig) < 0.01
|
||||
|
||||
def test_ln2_density_derivative_matches_finite_difference(self):
|
||||
T = 78.0
|
||||
step = 1e-3
|
||||
actual = ln2_drho_dT_const_p(T, P_WORKING)
|
||||
expected = (
|
||||
ln2_rho(T + step, P_WORKING)
|
||||
- ln2_rho(T - step, P_WORKING)
|
||||
) / (2.0 * step)
|
||||
assert actual < 0.0
|
||||
assert abs(actual - expected) / abs(expected) < 1e-5
|
||||
|
||||
def test_ln2_internal_energy_derivative_is_positive(self):
|
||||
du_dT = ln2_du_dT_const_p(78.0, P_WORKING)
|
||||
assert du_dT > 0.0
|
||||
|
||||
|
||||
class TestHeliumProperties:
|
||||
"""Helium properties."""
|
||||
|
||||
@@ -12,10 +12,9 @@ from cryo_tank.config import (
|
||||
)
|
||||
|
||||
|
||||
def _make_tank():
|
||||
def _make_tank(**overrides):
|
||||
"""Create a CryoTank with default config and MLI heat leak."""
|
||||
heat_leak = MLIHeatLeak(A_total=A_TOTAL, q_mli=1.0)
|
||||
return CryoTank(
|
||||
kw = dict(
|
||||
V_total=V_TOTAL, H_tank=H_TANK,
|
||||
P_work=P_WORKING,
|
||||
T_init=T_INIT, ullage_fraction=ULLAGE_FRACTION,
|
||||
@@ -23,8 +22,10 @@ def _make_tank():
|
||||
mdot_out_ln2=MDOT_OUT_LN2,
|
||||
T_in_he=T_IN_HE,
|
||||
h_conv=H_CONV_SURFACE, T_env=T_ENV,
|
||||
heat_leak_model=heat_leak,
|
||||
heat_leak_model=MLIHeatLeak(A_total=A_TOTAL, q_mli=1.0),
|
||||
)
|
||||
kw.update(overrides)
|
||||
return CryoTank(**kw)
|
||||
|
||||
|
||||
class TestGeometry:
|
||||
@@ -75,3 +76,37 @@ class TestInitialState:
|
||||
info = tank.derive(y0)
|
||||
P_He = info['P_He']
|
||||
assert abs(P_He - P_WORKING) / P_WORKING < 1e-12
|
||||
|
||||
|
||||
class TestVolumeRate:
|
||||
|
||||
def test_ullage_volume_rate_includes_liquid_thermal_expansion(self):
|
||||
tank = _make_tank(
|
||||
mdot_in_ln2=0.0,
|
||||
mdot_out_ln2=0.0,
|
||||
h_conv=0.0,
|
||||
)
|
||||
y0 = tank.initial_state()
|
||||
info = tank.derive(y0)
|
||||
|
||||
Q_liq_to_ull = 0.0
|
||||
Q_leak = tank.heat_leak_model.compute(info['T_liq'], tank.T_env)
|
||||
A_wet, A_dry = tank.wetted_areas(info['liquid_level'])
|
||||
Q_leak_liq = Q_leak * A_wet / (A_wet + A_dry)
|
||||
dU_liq_dt = tank._liquid_energy_rate(
|
||||
info, Q_liq_to_ull, Q_leak_liq
|
||||
)
|
||||
|
||||
dV_ull_dt = tank._ullage_volume_rate(
|
||||
info, tank.dm_liq_dt, dU_liq_dt
|
||||
)
|
||||
|
||||
y_next = y0.copy()
|
||||
dt = 1.0
|
||||
y_next[1] += dU_liq_dt * dt
|
||||
finite_difference = (
|
||||
tank.derive(y_next)['V_ull'] - info['V_ull']
|
||||
) / dt
|
||||
|
||||
assert dV_ull_dt < 0.0
|
||||
assert abs(dV_ull_dt - finite_difference) / abs(finite_difference) < 1e-5
|
||||
Reference in new issue
Block a user