Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- fenics-dolfinx=0.9.0
- matplotlib
- scipy
- pint # need to install pint with conda to avoid conflicts (HTM)
- pip
- pip:
- git+https://github.com/remdelaportemathurin/FESTIM@ad3b10b1a0c736ea3cd1e77835ef70de82208a10
Expand Down
3 changes: 3 additions & 0 deletions scenario_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PULSE TYPE, NUMBER OF PULSES, RAMP UP, RAMP DOWN, STEADY STATE, WAITING
FP 2 455 455 650 1000
ICWC 2 36 36 180 1000
19 changes: 9 additions & 10 deletions simple_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ def make_mb_model(nb_mb, scenario_file):
# TODO change the dat file for other pulse types
pulse_type_to_DINA_data = {
"FP": np.loadtxt("Binned_Flux_Data.dat", skiprows=1),
"ICWC": np.loadtxt("ICWC_Data.dat", skiprows=1),
"ICWC": np.loadtxt("ICWC_data.dat", skiprows=1),
"RISP": np.loadtxt("Binned_Flux_Data.dat", skiprows=1),
"GDC": np.loadtxt("GDC_Data.dat", skiprows=1),
"GDC": np.loadtxt("GDC_data.dat", skiprows=1),
"BAKE": np.loadtxt("Binned_Flux_Data.dat", skiprows=1),
}

Expand Down Expand Up @@ -261,7 +261,7 @@ def T_function(x, t: Constant):
a = (T_rear(t) - T_surface(t)) / L
b = T_surface(t)
flat_top_value = a * x[0] + b
resting_value = COOLANT_TEMP
resting_value = np.full_like(x[0], COOLANT_TEMP)
pulse_row = my_scenario.get_row(float(t))
total_time_on = my_scenario.get_pulse_duration_no_waiting(pulse_row)
total_time_pulse = my_scenario.get_pulse_duration(pulse_row)
Expand All @@ -272,14 +272,14 @@ def T_function(x, t: Constant):
else resting_value
)

times = np.linspace(0, total_time_cycle, num=100)
# times = np.linspace(0, total_time_cycle, num=100)

x = [0]
Ts = [T_function(x, t) for t in times]
import matplotlib.pyplot as plt
# x = [0]
# Ts = [T_function(x, t) for t in times]
# import matplotlib.pyplot as plt

plt.plot(times, Ts, marker="o")
plt.show()
# plt.plot(times, Ts, marker="o")
# plt.show()

my_model.temperature = T_function

Expand Down Expand Up @@ -431,7 +431,6 @@ def tritium_atom_flux(t: float):
quantities[species.name] = quantity

############# Settings #############

my_model.settings = F.Settings(
atol=1e-15,
rtol=1e-15,
Expand Down
5 changes: 5 additions & 0 deletions src/hisp/h_transport_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def define_temperature(self):
)

def update_time_dependent_values(self):

# this is for the last time step, don't update the fluxes to avoid overshoot in the scenario file
if float(self.t) > self.settings.final_time:
return

F.ProblemBase.update_time_dependent_values(self)

if not self.temperature_time_dependent:
Expand Down
6 changes: 4 additions & 2 deletions src/hisp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def get_row(self, t: float):
else:
current_time += phase_duration

raise ValueError("Time t is out of bounds of the scenario file")
raise ValueError(
f"Time t {t} is out of bounds of the scenario file. Maximum time is {self.get_maximum_time()}"
)

def get_pulse_type(self, t: float) -> str:
"""Returns the pulse type as a string at time t.
Expand Down Expand Up @@ -88,7 +90,7 @@ def get_pulse_duration(self, row: int) -> float:

total_duration = ramp_up + steady_state + ramp_down + waiting
return total_duration

def get_pulse_duration_no_waiting(self, row: int) -> float:
"""Returns the total duration of a pulse in seconds for a given row in the file.

Expand Down