代码仓库移植
This commit is contained in:
commit
0f57ba94f3
44 files changed
+7119
No files matched your search
@@ -0,0 +1,80 @@
|
||||
# src/cryo_tank/main.py
|
||||
"""
|
||||
Entry point for the cryogenic LN2 tank simulation.
|
||||
|
||||
Run from project root:
|
||||
python3 src/cryo_tank/main.py
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
_HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, os.path.dirname(_HERE))
|
||||
|
||||
from cryo_tank.config import (
|
||||
V_TOTAL, H_TANK, P_WORKING, T_INIT, ULLAGE_FRACTION,
|
||||
MDOT_IN_LN2, T_IN_LN2, MDOT_OUT_LN2, T_IN_HE,
|
||||
H_CONV_SURFACE, T_ENV, A_TOTAL,
|
||||
T_END, RTOL, ATOL, OUTPUT_DIR,
|
||||
)
|
||||
from cryo_tank.tank_model import CryoTank
|
||||
from cryo_tank.heat_leak import MLIHeatLeak
|
||||
from cryo_tank.solver import run
|
||||
from cryo_tank.output import (
|
||||
save_history, plot_temperatures, plot_liquid_level,
|
||||
plot_he_flow, plot_heat_fluxes, plot_pressure,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||
|
||||
# --- Assemble ---
|
||||
heat_leak = MLIHeatLeak(A_total=A_TOTAL, q_mli=1.0)
|
||||
tank = CryoTank(
|
||||
V_total=V_TOTAL, H_tank=H_TANK,
|
||||
P_work=P_WORKING,
|
||||
T_init=T_INIT, ullage_fraction=ULLAGE_FRACTION,
|
||||
mdot_in_ln2=MDOT_IN_LN2, T_in_ln2=T_IN_LN2,
|
||||
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,
|
||||
)
|
||||
|
||||
y0 = tank.initial_state()
|
||||
info0 = tank.derive(y0)
|
||||
print(f"Initial state:")
|
||||
print(f" m_liq = {y0[0]:.2f} kg")
|
||||
print(f" T_liq = {info0['T_liq']:.2f} K, T_ull = {info0['T_ull']:.2f} K")
|
||||
print(f" fill_fraction = {info0['fill_fraction']:.1%}")
|
||||
print(f" m_He = {info0['m_He']*1000:.2f} g")
|
||||
print(f" P_N2 = {info0['P_N2']/1e6:.4f} MPa, P_He = {info0['P_He']/1e6:.4f} MPa")
|
||||
print(f"Running to t_end = {T_END:.0f} s ...")
|
||||
print()
|
||||
|
||||
# --- Run ---
|
||||
history = run(tank, t_end=T_END, rtol=RTOL, atol=ATOL)
|
||||
|
||||
n_steps = len(history['t'])
|
||||
t_final = history['t'][-1]
|
||||
print(f"Simulation complete: {n_steps} output points, t_final = {t_final:.1f} s")
|
||||
print(f" T_liq: {history['T_liq'][0]:.2f} -> {history['T_liq'][-1]:.2f} K")
|
||||
print(f" T_ull: {history['T_ull'][0]:.2f} -> {history['T_ull'][-1]:.2f} K")
|
||||
print(f" fill_fraction: {history['fill_fraction'][0]:.1%} -> {history['fill_fraction'][-1]:.1%}")
|
||||
print(f" m_He: {history['m_He'][0]*1000:.2f} -> {history['m_He'][-1]*1000:.2f} g")
|
||||
print(f" T_out (LN2 outlet) = T_liq = {history['T_liq'][-1]:.2f} K")
|
||||
|
||||
# --- Output ---
|
||||
save_history(history, os.path.join(OUTPUT_DIR, "cryo_tank_history.npz"))
|
||||
plot_temperatures(history, os.path.join(OUTPUT_DIR, "cryo_tank_temperatures.png"))
|
||||
plot_liquid_level(history, os.path.join(OUTPUT_DIR, "cryo_tank_level.png"))
|
||||
plot_he_flow(history, os.path.join(OUTPUT_DIR, "cryo_tank_he_flow.png"))
|
||||
plot_heat_fluxes(history, os.path.join(OUTPUT_DIR, "cryo_tank_heat.png"))
|
||||
plot_pressure(history, os.path.join(OUTPUT_DIR, "cryo_tank_pressure.png"))
|
||||
|
||||
print(f"\nOutputs written to {OUTPUT_DIR}/")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user