Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates related to electric module #25

Open
wants to merge 30 commits into
base: mit_period_path1_joule_fix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe1542c
feat: implemented Class stack, only for some cases
Jan 8, 2024
373f532
bug fix: modified the lower limit for T_cs
Jan 30, 2024
5a75ebf
fix: error in T_cs of re_123
Feb 5, 2024
61e4a81
chore: remove mod1 to compute Joule power along
DanielePlacidoPolito Feb 9, 2024
3f59744
refactor(indices): fun get_electric_resistance
Feb 12, 2024
20722d6
refactor(indices): fun get_electric_resistance
Feb 12, 2024
fbad580
chore: restored the inductance methods
Feb 12, 2024
51cfa7e
chore: new flags for inductances evaluation
Feb 12, 2024
c01a0d1
Revert "chore: restored the inductance methods"
Feb 13, 2024
b1aad2f
feat!: new methods in class Conductor
Feb 13, 2024
740092a
chore: update methods for inductance evaluation
Feb 13, 2024
a68b515
chore: restored inductance evaluation methods
Feb 13, 2024
59d7c9e
feat!: new variables in file conductor_definitions.xlsx
Feb 13, 2024
95bb054
fix: update temporary solution input loading in Conductor
Feb 13, 2024
c613845
fix: ValueError in method get_electric_resistance
Feb 13, 2024
a33f13e
Merge branch 'main' of https://github.com/AMortara/OPENSC2 into AMort…
DanielePlacidoPolito Feb 14, 2024
0616d1a
Merge branch 'AMortara-main' into try_pr_el_module
DanielePlacidoPolito Feb 14, 2024
e7832b9
feat!: new variables in file conductor_definitions.xlsx
DanielePlacidoPolito Feb 14, 2024
8339b99
fix: update temporary solution input loading in Conductor
Feb 13, 2024
f2d6557
fix: ValueError in method get_electric_resistance
Feb 13, 2024
8eac1e1
Merge pull request #26 from AMortara/main
DanielePlacidoPolito Feb 14, 2024
336f086
Merge branch 'try_pr_el_module' of https://github.com/MAHTEP/OPENSC2 …
DanielePlacidoPolito Feb 14, 2024
ef542ec
fix: equivalent resistivity for stack_component
Apr 3, 2024
270e1d5
fix: deleted previous methos for rho_not_sc
Apr 9, 2024
7feab75
fix: added StackComponent in rho_not_sc update
Apr 9, 2024
1308d12
fix: assignment of current_along at t=0
Apr 10, 2024
5b192ee
fix: T_cs evaluated from current_along
Apr 10, 2024
fd78989
fix: Tolerance on newton halley increased
Apr 10, 2024
4cdc096
fix: update of electrical resistivity for Stack
Apr 16, 2024
0e3533b
doc: update comment in solve_current_divider
Apr 19, 2024
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
233 changes: 160 additions & 73 deletions source_code/conductor.py

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions source_code/conductor_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@
# Electric conductance is not defined per unit length
ELECTRIC_CONDUCTANCE_NOT_UNIT_LENGTH = 2

# Self inductance readed from input file conductor_definition.xlsx
SELF_INDUCTANCE_MODE_0 = 0
# Analytical self inductance is evaluated according to mode 1.
SELF_INDUCTANCE_MODE_1 = 1
# Analytical self inductance is evaluated according to mode 2.
SELF_INDUCTANCE_MODE_2 = 2

# Constant mutual inductance readed from input file conductor_definition.xlsx
CONSTANT_INDUCTANCE = 0
# Flag to evaluate inductance analytically
ANALYTICAL_INDUCTANCE = 0
ANALYTICAL_INDUCTANCE = 1
# Flag to evaluate inductance using an approximation
APPROXIMATE_INDUCTANCE = 1
APPROXIMATE_INDUCTANCE = 2

# Flag to solve the electric problem in steady state conditions.
STATIC_ELECTRIC_SOLVER = 0
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion source_code/properties_of_materials/rare_earth_123.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def critical_current_density_bisection_re123(TT, BB, JOP, TC0M, BC20M, C):

for _, vv in enumerate(JC_ind):

T_lower = np.array([3.5])
T_lower = np.array([0])
# T_upper = np.array([40.0])
T_upper = np.array([TC0M])

Expand Down
47 changes: 22 additions & 25 deletions source_code/solid_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def get_current(self, conductor: object):
self.dict_Gauss_pt["op_current_sc"] = self.dict_Gauss_pt[
"op_current"
]
if conductor.cond_time[-1] == 0:
self.dict_node_pt["current_along"] = self.dict_node_pt["op_current"]
self.dict_Gauss_pt["current_along"] = self.dict_Gauss_pt["op_current"]


if self.flagSpecfield_current == 2:
# Add also a logger
Expand Down Expand Up @@ -297,6 +301,9 @@ def get_current(self, conductor: object):
self.dict_node_pt["op_current_sc"][:-1]
+ self.dict_node_pt["op_current_sc"][1:]
) / 2.0
if conductor.cond_time[-1] == 0:
self.dict_node_pt["current_along"] = self.dict_node_pt["op_current"]
self.dict_Gauss_pt["current_along"] = self.dict_Gauss_pt["op_current"]

elif conductor.inputs["I0_OP_MODE"] == IOP_NOT_DEFINED:
# User does not specify a current: set current carrient
Expand Down Expand Up @@ -659,8 +666,7 @@ def initialize_electric_quantities(self, conductor):
* self.dict_Gauss_pt["current_along"]
* self.dict_Gauss_pt["delta_voltage_along"]
* self.dict_Gauss_pt["delta_voltage_along_sum"]
* self.dict_Gauss_pt["integral_power_el_res_mod1"]
* self.dict_Gauss_pt["integral_power_el_res_mod2"]
* self.dict_Gauss_pt["integral_power_el_res"]
* self.dict_Gauss_pt["linear_power_el_resistance"]
* self.dict_node_pt["total_linear_power_el_cond"]
* self.dict_node_pt["total_power_el_cond"]
Expand All @@ -675,12 +681,10 @@ def initialize_electric_quantities(self, conductor):
self.dict_Gauss_pt["current_along"] = np.zeros(n_elem)
self.dict_Gauss_pt["delta_voltage_along"] = np.zeros(n_elem)
self.dict_Gauss_pt["delta_voltage_along_sum"] = np.zeros(n_elem)
# Introduced to evaluate the integral value Joule power due to electric
# resistance along the cable in the electric module as R * I^2.
self.dict_Gauss_pt["integral_power_el_res_mod1"] = np.zeros(n_elem)

# Introduced to evaluate the integral value Joule power due to electric
# resistance along the cable in the electric module as Delta V * I.
self.dict_Gauss_pt["integral_power_el_res_mod2"] = np.zeros(n_elem)
self.dict_Gauss_pt["integral_power_el_res"] = np.zeros(n_elem)

self.dict_node_pt["total_power_el_cond"] = np.zeros(n_nod)
# Introduced to evaluate the integral value Joule power due to electric
Expand Down Expand Up @@ -716,12 +720,11 @@ def set_power_array_to_zeros(self, conductor):
n_elem = conductor.grid_input["NELEMS"]

# Set the following arrays to zeros
self.dict_Gauss_pt["integral_power_el_res_mod1"] = np.zeros(n_elem)
self.dict_Gauss_pt["integral_power_el_res_mod2"] = np.zeros(n_elem)
self.dict_Gauss_pt["integral_power_el_res"] = np.zeros(n_elem)
self.dict_node_pt["integral_power_el_cond"] = np.zeros(n_nod)

def get_joule_power_along(self, conductor: object):
"""Method that evaluate the contribution to the integral power in the element of Joule power (in W/m) due to the electic resistances along the SolidComponent objects.
"""Method that evaluate the contribution to the integral power in the element of Joule power (in W/m) due to the voltage difference (due to electric resistance and inductance) along the SolidComponent objects. This approach was discussed with prof. Zach Hartwig and Dr. Nicolò Riva and is more general and coservative that the evaluation that takes into account only the contribution of the electric resistance.
This method should be called in the electric method, when the transient solution is used and only for current carriers.

Args:
Expand All @@ -733,14 +736,14 @@ def get_joule_power_along(self, conductor: object):

# Finalize the evaluation of the integral value of the Joule power due
# to electric resistance along the current carrier started in method
# conductor.eval_integral_joule_power. Array integral_power_el_res_mod1
# conductor.eval_integral_joule_power. Array integral_power_el_res
# stores the numerator (energy in J) that here is divided by the
# thermal hydraulic to get again a power (W), which is further divided
# by the length of the discreticazion element corrected by cos(theta)
# to get a linear power density (W/m):
# P_Joule = sum_1^N_em P_{Joule,i} / (Delta_t_TH * Delta_z * costheta)
integral_j_pow_along = (
self.dict_Gauss_pt["integral_power_el_res_mod1"]
self.dict_Gauss_pt["integral_power_el_res"]
/ (conductor.grid_features["delta_z"] * self.inputs["COSTETA"]
* conductor.time_step)
)
Expand Down Expand Up @@ -823,39 +826,33 @@ def get_joule_power_across(self, conductor: object):
)

def get_joule_power_along_steady(self, conductor: object):
"""Method that evaluate the contribution to the total power in the element of Joule power (in W/m) due to the electic resistances along the SolidComponent objects.
"""Method that evaluate the contribution to the total power in the element of Joule power (in W/m) due to the voltage difference (due to electric resistance and inductance) along the SolidComponent objects.
This approach was discussed with prof. Zach Hartwig and Dr. Nicolò Riva and is more general and coservative that the evaluation that takes into account only the contribution of the electric resistance.
This method should be called in the electric method, when the transient solution is used and for the solid component that actually carries a current. It works when the steady state solution for the electric module is computed.

Args:
conductor (object): ConductorComponent object with all informations to make the calculation.
"""

# Alias
el_res = self.dict_Gauss_pt["electric_resistance"]
current = self.dict_Gauss_pt["current_along"]
voltage = self.dict_Gauss_pt["delta_voltage_along"]
d_z_tilde = conductor.grid_features["delta_z"] * self.inputs["COSTETA"]

# Mode 1: evaluate Joule linear power along the strand in W, due
# to electric resistances only for current carriers:
# P_along = R_along * I_along ^2
self.dict_Gauss_pt["integral_power_el_res_mod1"] = current ** 2 * el_res

# Mode 2: evaluate Joule linear power along the strand in W, due
# Evaluate Joule linear power along the strand in W, due
# to electric resistances only for current carriers:
# P_along = Delta_Phi_along * I_along
self.dict_Gauss_pt["integral_power_el_res_mod2"] = voltage * current
# N.B. this evaluation accounts aslo for the voltage due to the
# inductance and is a conservative an more general approach. Discussed
# with prof. Zach Hartwig and Dr. Nicolò Riva.
self.dict_Gauss_pt["integral_power_el_res"] = voltage * current

# Check equivalence of Mode 1 and Mode 2 (they should be equivalent
# but Mode 2 may give numerical cancellation).
if not np.allclose(self.dict_Gauss_pt["integral_power_el_res_mod1"],self.dict_Gauss_pt["integral_power_el_res_mod2"]):
warnings.warn("P_Joule = R I^2 != Delta_Phi I. Possible violation of the energy conservation!")
# Convert W in W/m keping into account the cos(theta).
# This is independent of the time integration method since at the
# initialization (when this function is used) BE, CN and AM4 should
# fill only the 0 index column.
self.dict_Gauss_pt["linear_power_el_resistance"][:, 0] = (
self.dict_Gauss_pt["integral_power_el_res_mod1"] / d_z_tilde
self.dict_Gauss_pt["integral_power_el_res"] / d_z_tilde
)

def get_joule_power_across_steady(self, conductor: object):
Expand Down
Loading