|
14 | 14 | # import classes |
15 | 15 | from component_collection import ComponentCollection |
16 | 16 | from conductor_flags import ( |
| 17 | + CONSTANT_INDUCTANCE, |
17 | 18 | ANALYTICAL_INDUCTANCE, |
18 | 19 | APPROXIMATE_INDUCTANCE, |
19 | 20 | ELECTRIC_CONDUCTANCE_UNIT_LENGTH, |
|
22 | 23 | IOP_CONSTANT, |
23 | 24 | IOP_FROM_EXT_FUNCTION, |
24 | 25 | IOP_FROM_FILE, |
| 26 | + SELF_INDUCTANCE_MODE_0, |
25 | 27 | SELF_INDUCTANCE_MODE_1, |
26 | 28 | SELF_INDUCTANCE_MODE_2, |
27 | 29 | STATIC_ELECTRIC_SOLVER, |
@@ -3753,9 +3755,9 @@ def __inductance_analytical_calculation(self, mode: int = 2): |
3753 | 3755 | mode (int,optional): flag to select the equation for the analytical evaluation of self inductance. 1: mode 1; 2: mode 2. Defaults to 2. |
3754 | 3756 | """ |
3755 | 3757 |
|
3756 | | - if mode != 1 and mode != 2: |
| 3758 | + if mode!= SELF_INDUCTANCE_MODE_0 and mode != SELF_INDUCTANCE_MODE_1 and mode != SELF_INDUCTANCE_MODE_2: |
3757 | 3759 | raise ValueError( |
3758 | | - f"{self.identifier}\nArgument 'mode' must be equal to {SELF_INDUCTANCE_MODE_1 = } or to {SELF_INDUCTANCE_MODE_2 = }. Current value {mode = } is not allowed. Please check sheet {self.workbook_sheet_name[2]} in file {self.workbook_name}.\n" |
| 3760 | + f"{self.identifier}\nArgument 'mode' must be equal to {SELF_INDUCTANCE_MODE_0 = } or to {SELF_INDUCTANCE_MODE_1 = } or to {SELF_INDUCTANCE_MODE_2 = }. Current value {mode = } is not allowed. Please check sheet {self.workbook_sheet_name[2]} in file {self.workbook_name}.\n" |
3759 | 3761 | ) |
3760 | 3762 | ABSTOL = 1e-6 |
3761 | 3763 | lmod = ( |
@@ -3799,6 +3801,7 @@ def __inductance_analytical_calculation(self, mode: int = 2): |
3799 | 3801 |
|
3800 | 3802 | # Switch to evalutae self inductance. |
3801 | 3803 | self_inductance_switch = { |
| 3804 | + SELF_INDUCTANCE_MODE_0: self.__constant_self_inductance_evaluation, |
3802 | 3805 | SELF_INDUCTANCE_MODE_1: self.__self_inductance_mode1, |
3803 | 3806 | SELF_INDUCTANCE_MODE_2: self.__self_inductance_mode2, |
3804 | 3807 | } |
@@ -4053,8 +4056,13 @@ def __self_inductance_mode2(self, lmod: np.ndarray) -> np.ndarray: |
4053 | 4056 |
|
4054 | 4057 | # START: INDUCTANCE APPROXIMATE EVALUATION |
4055 | 4058 |
|
4056 | | - def __inductance_approximate_calculation(self): |
| 4059 | + def __inductance_approximate_calculation(self, mode : int = 2): |
4057 | 4060 | """Private method that approximate the inductance of the system. For an analytical evaluation of the inductance use private method __inductance_analytical_calculation.""" |
| 4061 | + |
| 4062 | + if mode!= SELF_INDUCTANCE_MODE_0 and mode != SELF_INDUCTANCE_MODE_1 and mode != SELF_INDUCTANCE_MODE_2: |
| 4063 | + raise ValueError( |
| 4064 | + f"{self.identifier}\nArgument 'mode' must be equal to {SELF_INDUCTANCE_MODE_0 = } or to {SELF_INDUCTANCE_MODE_1 = } or to {SELF_INDUCTANCE_MODE_2 = }. Current value {mode = } is not allowed. Please check sheet {self.workbook_sheet_name[2]} in file {self.workbook_name}.\n" |
| 4065 | + ) |
4058 | 4066 |
|
4059 | 4067 | ll = ( |
4060 | 4068 | self.nodal_coordinates.iloc[ |
@@ -4088,8 +4096,13 @@ def __inductance_approximate_calculation(self): |
4088 | 4096 | ll, mutual_inductance |
4089 | 4097 | ) |
4090 | 4098 |
|
4091 | | - # Evaluate self inductance |
4092 | | - self_inductance = self.__self_inductance_approximate(lmod) |
| 4099 | + self_inductance_switch = { |
| 4100 | + SELF_INDUCTANCE_MODE_0: self.__constant_self_inductance_evaluation, |
| 4101 | + SELF_INDUCTANCE_MODE_1: self.__self_inductance_mode1, |
| 4102 | + SELF_INDUCTANCE_MODE_2: self.__self_inductance_mode2, |
| 4103 | + } |
| 4104 | + self_inductance = self_inductance_switch[mode](lmod) |
| 4105 | + |
4093 | 4106 | # Evaluate internal inductance |
4094 | 4107 | internal_inductance = lmod.to_numpy() / 2.0 |
4095 | 4108 |
|
@@ -4214,19 +4227,21 @@ def __build_electric_mass_matrix(self): |
4214 | 4227 | """ |
4215 | 4228 |
|
4216 | 4229 | if ( |
4217 | | - self.operations["INDUCTANCE_MODE"] != 0 |
4218 | | - and self.operations["INDUCTANCE_MODE"] != 1 |
| 4230 | + self.operations["INDUCTANCE_MODE"] != CONSTANT_INDUCTANCE |
| 4231 | + and self.operations["INDUCTANCE_MODE"] != ANALYTICAL_INDUCTANCE |
| 4232 | + and self.operations["INDUCTANCE_MODE"] != APPROXIMATE_INDUCTANCE |
4219 | 4233 | ): |
4220 | 4234 | raise ValueError( |
4221 | | - f"{self.identifier = }\nArgument self.operations['INDUCTANCE_MODE'] should be equal to {APPROXIMATE_INDUCTANCE = } or {ANALYTICAL_INDUCTANCE = }. Current value ({self.operations['INDUCTANCE_MODE'] = }) is not allowed. Please check {self.workbook_sheet_name[2]} in file {self.workbook_name}.\n" |
| 4235 | + f"{self.identifier = }\nArgument self.operations['INDUCTANCE_MODE'] should be equal to {CONSTANT_INDUCTANCE = } or {APPROXIMATE_INDUCTANCE = } or {ANALYTICAL_INDUCTANCE = }. Current value ({self.operations['INDUCTANCE_MODE'] = }) is not allowed. Please check {self.workbook_sheet_name[2]} in file {self.workbook_name}.\n" |
4222 | 4236 | ) |
4223 | 4237 |
|
4224 | 4238 | inductance_switch = { |
| 4239 | + CONSTANT_INDUCTANCE: self.__constant_inductance, |
4225 | 4240 | ANALYTICAL_INDUCTANCE: self.__inductance_analytical_calculation, |
4226 | 4241 | APPROXIMATE_INDUCTANCE: self.__inductance_approximate_calculation, |
4227 | 4242 | } |
4228 | 4243 |
|
4229 | | - inductance_switch[self.operations["INDUCTANCE_MODE"]]() |
| 4244 | + inductance_switch[self.operations["INDUCTANCE_MODE"]](self.operations["SELF_INDUCTANCE_MODE"]) |
4230 | 4245 |
|
4231 | 4246 | self.electric_mass_matrix[ |
4232 | 4247 | : self.total_elements_current_carriers, |
|
0 commit comments