|
| 1 | +from sparging.config import ureg |
| 2 | +from sparging import all_correlations |
| 3 | +from sparging import animation |
| 4 | +from sparging.model import Simulation |
| 5 | +from sparging.inputs import ( |
| 6 | + ColumnGeometry, |
| 7 | + BreederMaterial, |
| 8 | + OperatingParameters, |
| 9 | + SpargingParameters, |
| 10 | + SimulationInput, |
| 11 | +) |
| 12 | +import logging |
| 13 | +from typing import TYPE_CHECKING |
| 14 | + |
| 15 | +if TYPE_CHECKING: |
| 16 | + import pint |
| 17 | + |
| 18 | +logger = logging.getLogger(__name__) |
| 19 | +logging.basicConfig(level=logging.WARNING) |
| 20 | + |
| 21 | + |
| 22 | +geom = ColumnGeometry( |
| 23 | + area=0.2 * ureg.m**2, |
| 24 | + height=1.0 * ureg.m, |
| 25 | + nozzle_diameter=0.001 * ureg.m, |
| 26 | + nb_nozzle=10 * ureg.dimensionless, |
| 27 | +) |
| 28 | + |
| 29 | +flibe = BreederMaterial( |
| 30 | + name="FLiBe", |
| 31 | +) |
| 32 | + |
| 33 | +operating_params = OperatingParameters( |
| 34 | + temperature=600 * ureg.celsius, |
| 35 | + P_top=1 * ureg.atm, |
| 36 | + flow_g_mol=400 * ureg.sccm, |
| 37 | + tbr=0.1 * ureg("triton / neutron"), |
| 38 | + n_gen_rate=1e9 * ureg("neutron / s"), |
| 39 | +) |
| 40 | + |
| 41 | +sparging_params = SpargingParameters( |
| 42 | + h_l=all_correlations("h_l_briggs"), |
| 43 | +) |
| 44 | + |
| 45 | + |
| 46 | +# class method from_parameters that takes in objects like ColumnGeometry, BreederMaterial, OperatingParameters and returns a SimulationInput object with the appropriate correlations for the given parameters. This method should be able to handle cases where some of the parameters are already provided as correlations and should not overwrite them. |
| 47 | +my_input = SimulationInput.from_parameters( |
| 48 | + geom, flibe, operating_params, sparging_params |
| 49 | +) |
| 50 | +logger.info(my_input) |
| 51 | + |
| 52 | + |
| 53 | +def profile_source_T(z: pint.Quantity): |
| 54 | + import numpy as np |
| 55 | + |
| 56 | + # return np.sin(np.pi / (1 * ureg.m) * z) |
| 57 | + return 0.5 * (1 + np.cos(0.5 * np.pi / (1 * ureg.m) * z)) |
| 58 | + |
| 59 | + |
| 60 | +my_simulation = Simulation( |
| 61 | + my_input, |
| 62 | + t_final=3 * ureg.days, |
| 63 | + signal_irr=lambda t: 1 if t < 12 * ureg.hour else 0, |
| 64 | + signal_sparging=lambda t: 1, |
| 65 | +) |
| 66 | +output = my_simulation.solve() |
| 67 | + |
| 68 | +# # save output to file |
| 69 | +# output.profiles_to_csv(f"output_{tank_height}m.csv") |
| 70 | + |
| 71 | +# # plot results |
| 72 | +# from sparging import plotting |
| 73 | +# plotting.plot_animation(output) |
| 74 | + |
| 75 | + |
| 76 | +animation.create_animation(output, show_activity=True) |
0 commit comments