Coverage for fiqus/data/DataFiQuSConductorAC_Rutherford.py: 100%

192 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2025-12-09 14:33 +0000

1from pydantic import BaseModel, Field 

2from typing import List, Literal, Optional, Union 

3 

4 

5class CACRutherfordIOsettingsLoad(BaseModel): 

6 """ 

7 Level 3: Class for Input/Output settings for the cable geometry 

8 """ 

9 load_from_yaml: Optional[bool] = Field( 

10 default=None, 

11 description="True to load cable geometry from yaml-file, false to create the geometry.", 

12 ) 

13 filename: Optional[str] = Field( 

14 default=None, 

15 description="Name of the file from which to load the cable geometry.", 

16 ) 

17 

18 

19class CACRutherfordIOsettingsSave(BaseModel): 

20 """ 

21 Level 3: Class for Input/Output settings for the cable geometry 

22 """ 

23 save_to_yaml: Optional[bool] = Field( 

24 default=None, 

25 description="True to save cable geometry to yaml-file, false to not save the geometry.", 

26 ) 

27 filename: Optional[str] = Field( 

28 default=None, 

29 description="Name of the file to which to save the cable geometry.", 

30 ) 

31 

32 

33class CACRutherfordIOsettings(BaseModel): 

34 """ 

35 Level 3: Class for Input/Output settings for the cable geometry 

36 """ 

37 load: CACRutherfordIOsettingsLoad = ( 

38 CACRutherfordIOsettingsLoad() 

39 ) 

40 save: CACRutherfordIOsettingsSave = ( 

41 CACRutherfordIOsettingsSave() 

42 ) 

43 

44class CACRutherfordExcitationCoils(BaseModel): 

45 """ 

46 Level 3: Class for Input/Output settings for the cable geometry 

47 """ 

48 centers: Optional[List[List[float]]] = Field( 

49 default=None, 

50 description="List of center points for the centers of the excitations coil regions. Each center point is a list of three elements for x, y, and z (=0) coordinates.", 

51 ) 

52 widths: Optional[List[float]] = Field( 

53 default=None, 

54 description="List of widths of the excitation coil regions.", 

55 ) 

56 heights: Optional[List[float]] = Field( 

57 default=None, 

58 description="List of heights of the excitation coil regions.", 

59 ) 

60 

61# ============= GEOMETRY ============= # 

62 

63 

64class CACRutherfordGeometry(BaseModel): 

65 """ 

66 Level 2: Class for cable geometry parameters 

67 """ 

68 io_settings: CACRutherfordIOsettings = CACRutherfordIOsettings() 

69 

70 point_snap_tolerance_relative_to_strand_diameter: Optional[float] = Field( 

71 default=None, 

72 description="The maximum distance between two points, relative to the strand diameter, where the points are considered equal (i.e. they 'snap' together).", 

73 ) 

74 min_roundness_factor: Optional[float] = Field( 

75 default=None, 

76 description="Minimum roundness is the ratio between the min -and max radius for the corner circle-arcs.", 

77 ) 

78 air_radius: Optional[float] = Field( 

79 default=None, description="Radius of the air region (m)." 

80 ) 

81 coating_corner_arc_radius: Optional[float] = Field( 

82 default=0, description="Radius of the corner arcs of the coating (m)." 

83 ) 

84 coating_thickness: Optional[float] = Field( 

85 default=0, description="Thickness of the coating (m)." 

86 ) 

87 keep_strand_area: Optional[bool] = Field( 

88 default=True, description="If True, the area of the strands are determined by the area of the strand described in 'conductors'. If False, the area of the strands are determined based on the cable geometry inputs." 

89 ) 

90 

91 excitation_coils: CACRutherfordExcitationCoils = CACRutherfordExcitationCoils() 

92 

93# ============= MESH ============= # 

94 

95class CACRutherfordMesh(BaseModel): 

96 """ 

97 Level 2: Class for FiQuS ConductorAC 

98 """ 

99 scaling_global: Optional[float] = Field(default=1, description="Global scaling factor for mesh size.") 

100 

101 strand_mesh_size_ratio: Optional[float] = Field(1, description="Mesh size ratio for the strand, relative to the strand diameter.") 

102 coating_mesh_size_ratio: Optional[float] = Field(1, description="Mesh size ratio for the coating, relative to the strand diameter.") 

103 air_boundary_mesh_size_ratio: Optional[float] = Field(1, description="Mesh size ratio for the air boundary, relative to the strand diameter.") 

104 

105# ============= SOLVE ============= # 

106# -- General parameters -- # 

107class CACRutherfordSolveGeneralparameters(BaseModel): 

108 """ 

109 Level 3: Class for general parameters 

110 """ 

111 temperature: float = Field(default=1.9, description="Temperature (K) of the strand.") 

112 superconductor_n_value: Optional[float] = Field(default=30, description="n value for the power law (-), used in current sharing law.") 

113 superconductor_Ic: Optional[float] = Field(default=350, description="Critical current of the strands (A) (e.g., typical value at T=1.9K and B=10T). Will be taken as a constant as in this model the field dependence is not included" 

114 " (the main purpose of the model is to verify the more efficient Homogenized Conductor model)." 

115 " Including field-dependence could be done but is not trivial because is mixes global and local quantities in this Rutherford model with strand discretized individually as stranded conductors.") 

116 matrix_resistance: Optional[float] = Field(default=6.536208e-04, description="Resistance of the matrix (per unit length) (Ohm/m) for the current sharing law. Kept constant in this model (for simplicity).") 

117 

118 crossing_coupling_resistance: Optional[float] = Field(default=1e-6, description="Crossing coupling resistance (Ohm).") 

119 adjacent_coupling_resistance: Optional[float] = Field(default=1e-6, description="Adjacent coupling resistance (Ohm).") 

120 

121 rho_coating: Optional[float] = Field(default=1e-7, description="Resistivity of coating domain outside of the strands (Ohm.m).") 

122 rho_strands: Optional[float] = Field(default=1e-12, description="Resistivity of strands, when modelled as massive conductors (Ohm.m).") 

123 

124 noOfMPITasks: Optional[Union[bool, int]] = Field( 

125 default=False, 

126 title="No. of tasks for MPI parallel run of GetDP", 

127 description=( 

128 "If integer, GetDP will be run in parallel using MPI. This is only valid" 

129 " if MPI is installed on the system and an MPI-enabled GetDP is used." 

130 " If False, GetDP will be run in serial without invoking mpiexec." 

131 ), 

132 ) 

133 

134class CACRutherfordSolveInitialConditions(BaseModel): 

135 """ 

136 Level 3: Class for initial conditions 

137 """ 

138 init_from_pos_file: bool = Field( 

139 default=False, description="Do we initialize the solution at a non-zero field." 

140 ) 

141 pos_file_to_init_from: Optional[str] = Field( 

142 default=None, 

143 description="Name of .pos file for magnetic field (A/m) from which the solution should be initialized." 

144 " Should be in the Geometry_xxx/Mesh_xxx/ folder in which the Solution_xxx will be saved.", 

145 ) 

146 

147 

148# -- Source parameters -- # 

149class CACRutherfordSolveSourceparametersSineSuperimposedDC(BaseModel): 

150 """ 

151 Level 5: Class for superimposed DC field or current parameters for the sine source 

152 """ 

153 field_magnitude: Optional[float] = Field(default=0.0, description="DC field magnitude (T) (direction along y-axis). Solution must be initialized with a non-zero field solution stored in a .pos file if non-zero DC field is used.") 

154 current_magnitude: Optional[float] = Field(default=0.0, description="DC current magnitude (A). Solution must be initialized with a non-zero field solution stored in a .pos file if non-zero DC current is used.") 

155 

156class CACRutherfordSolveSourceparametersSine(BaseModel): 

157 """ 

158 Level 4: Class for Sine source parameters 

159 """ 

160 frequency: Optional[float] = Field(default=None, description="Frequency of the sine source (Hz).") 

161 field_amplitude: Optional[float] = Field(default=None, description="Amplitude of the sine field (T).") 

162 current_amplitude: Optional[float] = Field(default=None, description="Amplitude of the sine current (A).") 

163 field_angle: Optional[float] = Field(default=90, description="Angle of the sine field direction, with respect to the x-axis (degrees).") 

164 superimposed_DC: CACRutherfordSolveSourceparametersSineSuperimposedDC = CACRutherfordSolveSourceparametersSineSuperimposedDC() 

165 

166class CACRutherfordSolveSourceparametersPiecewise(BaseModel): 

167 """ 

168 Level 4: Class for piecewise (linear) source parameters 

169 """ 

170 source_csv_file: Optional[str] = Field(default=None, description="File name for the from_file source type defining the time evolution of current and field (in-phase). Multipliers are used for each of them. The file should contain two columns: 'time' (s) and 'value' (field/current (T/A)), with these headers. If this field is set, times, applied_fields_relative and transport_currents_relative are ignored.") 

171 times: Optional[List[float]] = Field(default=None, description="Time instants (s) defining the piecewise linear sources. Used only if source_csv_file is not set. Can be scaled by time_multiplier.") 

172 applied_fields_relative: Optional[List[float]] = Field(default=None, description="Applied fields relative to multiplier applied_field_multiplier at the time instants 'times'. Used only if source_csv_file is not set.") 

173 transport_currents_relative: Optional[List[float]] = Field(default=None, description="Transport currents relative to multiplier transport_current_multiplier at the time instants 'times'. Used only if source_csv_file is not set.") 

174 time_multiplier: Optional[float] = Field(default=None, description="Multiplier for the time values in times (scales the time values). Also used for the time values in the source_csv_file.") 

175 applied_field_multiplier: Optional[float] = Field(default=None, description="Multiplier for the applied fields in applied_fields_relative. Also used for the values in the source_csv_file.") 

176 transport_current_multiplier: Optional[float] = Field(default=None, description="Multiplier for the transport currents in transport_currents_relative. Also used for the values in the source_csv_file.") 

177 field_angle: Optional[float] = Field(default=90, description="Angle of the sine field direction, with respect to the x-axis (degrees).") 

178 

179class CACRutherfordSolveSourceparametersExcitationCoils(BaseModel): 

180 """ 

181 Level 4: Class for excitation coils 

182 """ 

183 enable: Optional[bool] = Field(default=False, description="Are the excitation coils used in the model? (they can exist in the geometry and mesh but be ignored at the solution stage)") 

184 source_csv_file: Optional[str] = Field(default=None, description="The file should contain a first column with 'time' (s) and one additional column per excitation coil with 'value', which is the TOTAL current (A) per coil (with appropriate sign).") 

185 

186 

187class CACRutherfordSolveSourceparameters(BaseModel): 

188 """ 

189 Level 3: Class for material properties 

190 """ 

191 source_type: Literal['sine', 'piecewise'] = Field( 

192 default='sine', 

193 description="Time evolution of applied current and magnetic field. Supported options are: sine, sine_with_DC, piecewise_linear, from_list.", 

194 ) 

195 parallel_resistor: Optional[Union[bool, float]] = Field( 

196 default=False, 

197 title="Resistor parallel to the cable", 

198 description=( 

199 "If False, no parallel resistor and the current source directly and only feeds the cable." 

200 " If True, a resistor is placed in parallel with the cable, with a default resistance of 1 Ohm. If float (cannot be zero), this defines the value of the resistance." 

201 ), 

202 ) 

203 boundary_condition_type: str = Field( 

204 default="Natural", 

205 description="Boundary condition type. Supported options are: Natural, Essential. Do not use essential boundary condition with induced currents.", 

206 ) 

207 sine: CACRutherfordSolveSourceparametersSine = CACRutherfordSolveSourceparametersSine() 

208 piecewise: CACRutherfordSolveSourceparametersPiecewise = CACRutherfordSolveSourceparametersPiecewise() 

209 excitation_coils: CACRutherfordSolveSourceparametersExcitationCoils = CACRutherfordSolveSourceparametersExcitationCoils() 

210 

211# -- Numerical parameters -- # 

212class CACRutherfordSolveNumericalparametersSine(BaseModel): 

213 """  

214 Level 4: Numerical parameters corresponding to the sine source 

215 """ 

216 timesteps_per_period: Optional[float] = Field(default=None, description="Initial value for number of time steps (-) per period for the sine source. Determines the initial time step size.") 

217 number_of_periods_to_simulate: Optional[float] = Field(default=None, description="Number of periods (-) to simulate for the sine source.") 

218 

219class CACRutherfordSolveNumericalparametersPiecewise(BaseModel): 

220 """ 

221 Level 4: Numerical parameters corresponding to the piecewise source 

222 """ 

223 time_to_simulate: Optional[float] = Field(default=None, description="Total time to simulate (s). Used for the piecewise source.") 

224 timesteps_per_time_to_simulate: Optional[float] = Field(default=None, description="If variable_max_timestep is False. Number of time steps (-) per period for the piecewise source.") 

225 force_stepping_at_times_piecewise_linear: bool = Field(default=False, description="If True, time-stepping will contain exactly the time instants that are in the times_source_piecewise_linear list (to avoid truncation maximum applied field/current values).") 

226 

227 variable_max_timestep: bool = Field(default=False, description="If False, the maximum time step is kept constant through the simulation. If True, it varies according to the piecewise definition.") 

228 times_max_timestep_piecewise_linear: Optional[List[float]] = Field(default=None, description="Time instants (s) defining the piecewise linear maximum time step.") 

229 max_timestep_piecewise_linear: Optional[List[float]] = Field(default=None, description="Maximum time steps (s) at the times_max_timestep_piecewise_linear. Above the limits, linear extrapolation of the last two values.") 

230 

231class CACRutherfordSolveNumericalparameters(BaseModel): 

232 """ 

233 Level 3: Class for numerical parameters 

234 """ 

235 sine: CACRutherfordSolveNumericalparametersSine = CACRutherfordSolveNumericalparametersSine() 

236 piecewise: CACRutherfordSolveNumericalparametersPiecewise = CACRutherfordSolveNumericalparametersPiecewise() 

237 

238 

239class CACRutherfordSolveFormulationparameters(BaseModel): 

240 """ 

241 Level 3: Class for finite element formulation parameters 

242 """ 

243 stranded_strands: bool = Field( 

244 default=True, description="Are the strands solved as 'stranded conductors', i.e., with fixed source current density, and no eddy current effect? Put to True if we solve for homogenized strands." 

245 ) 

246 rohm: bool = Field( 

247 default=True, description="Do we use the ROHM model to describe the stranded strand magnetization? This is only relevant with stranded strands, but can be used without (without much meaning). If fase, solves with permeability mu0." 

248 ) 

249 rohf: bool = Field( 

250 default=True, description="Do we use the ROHF model to describe the stranded strand voltage and inductance? This is only possible with stranded strands. If stranded_strands=false, rohf is considered false as well." 

251 ) 

252 

253class CACRutherfordSolveFrequencydomainsolverFrequencysweep(BaseModel): 

254 """ 

255 Level 4: Class for frequency sweep settings 

256 """ 

257 run_sweep: bool = Field( 

258 default=False, description="Set True to run a frequency sweep (logarithmic)." 

259 ) 

260 start_frequency: float = Field( 

261 default=1, description="Start frequency (Hz) of the sweep." 

262 ) 

263 end_frequency: float = Field( 

264 default=100, description="End frequency (Hz) of the sweep." 

265 ) 

266 number_of_frequencies: int = Field( 

267 default=10, description="Number of frequencies in the sweep." 

268 ) 

269 

270 

271 

272class CACRutherfordSolveFrequencydomainsolver(BaseModel): 

273 """ 

274 Level 3: Class for frequency domain solver settings 

275 """ 

276 enable: bool = Field( 

277 default=False, description="Set True to enable the frequency domain solver." 

278 ) 

279 frequency_sweep: CACRutherfordSolveFrequencydomainsolverFrequencysweep = ( 

280 CACRutherfordSolveFrequencydomainsolverFrequencysweep() 

281 ) 

282 

283 

284 

285class CACRutherfordSolve(BaseModel): 

286 """ 

287 Level 2: Class for FiQuS ConductorAC 

288 """ 

289 pro_template: Optional[str] = Field( 

290 default=None, description="Name of the .pro template file." 

291 ) 

292 conductor_name: Optional[str] = Field( 

293 default=None, description="Name of the conductor." 

294 ) 

295 formulation_parameters: CACRutherfordSolveFormulationparameters = ( 

296 CACRutherfordSolveFormulationparameters() 

297 ) 

298 general_parameters: CACRutherfordSolveGeneralparameters = ( 

299 CACRutherfordSolveGeneralparameters() 

300 ) 

301 initial_conditions: CACRutherfordSolveInitialConditions = ( 

302 CACRutherfordSolveInitialConditions() 

303 ) 

304 frequency_domain_solver: CACRutherfordSolveFrequencydomainsolver = ( 

305 CACRutherfordSolveFrequencydomainsolver() 

306 ) 

307 source_parameters: CACRutherfordSolveSourceparameters = ( 

308 CACRutherfordSolveSourceparameters() 

309 ) 

310 numerical_parameters: CACRutherfordSolveNumericalparameters = ( 

311 CACRutherfordSolveNumericalparameters() 

312 ) 

313 

314 

315# ============= POSTPROC ============= # 

316class CACRutherfordPostprocBatchpostprocLossMapCrossSection(BaseModel): 

317 """ 

318 Level 5: Class with settings for plotting a cross-section of the loss map. 

319 """ 

320 plot_cross_section: bool = Field( 

321 default=False, description="Set True to plot a cross-section of the loss map." 

322 ) 

323 save_plot: bool = Field(default=False, description="Set True to save the plot.") 

324 filename: str = Field(default="cross_section", description="Name of the plot file.") 

325 axis_to_cut: str = Field( 

326 default="x", description="Axis to cut for the cross-section." 

327 ) 

328 cut_value: float = Field( 

329 default=0, description="Value of the axis to cut for the cross-section." 

330 ) 

331 

332 ylabel: str = Field(default="Loss", description="Label of the y-axis.") 

333 title: Optional[str] = Field( 

334 default=None, 

335 description="Title of the plot. The placeholder <<cut_value>> can be used to indicate the value of the cut axis.", 

336 ) 

337 

338 

339class CACRutherfordPostprocBatchpostprocLossMapCrossSectionSweep(BaseModel): 

340 """ 

341 Level 5: Class with settings for animating a cross-section sweep of the loss map along one axis. 

342 """ 

343 animate_cross_section_sweep: bool = Field( 

344 default=False, 

345 description="Set True to animate a cross-section sweep of the loss map along one axis.", 

346 ) 

347 save_plot: bool = Field( 

348 default=False, description="Set True to save the animation." 

349 ) 

350 filename: str = Field( 

351 default="crossSectionSweep", description="Name of the animation file." 

352 ) 

353 axis_to_sweep: str = Field( 

354 default="x", description="Axis to sweep for the animation." 

355 ) 

356 ylabel: str = Field(default="Loss", description="Label of the y-axis.") 

357 title: Optional[str] = Field( 

358 default=None, 

359 description="Title of the plot. Use <<sweep_value>> to indicate the value of the sweep axis.", 

360 ) 

361 

362 

363class CACRutherfordPostprocBatchpostprocLossMap(BaseModel): 

364 """ 

365 Level 4: Class with settings for generating loss maps 

366 """ 

367 produce_loss_map: bool = Field( 

368 default=False, description="Set True to produce a loss map." 

369 ) 

370 save_plot: bool = Field(default=False, description="Set True to save the plot.") 

371 filename: str = Field(default="loss_map", description="Name of the plot file.") 

372 x_val: Optional[str] = Field( 

373 default=None, description="Parameter to be plotted on the x-axis. This field corresponds to a parameter in the input YAML-file. E.g. 'solve.source_parameters.sine.frequency' will plot the loss map for different frequencies." 

374 ) 

375 y_val: Optional[str] = Field( 

376 default=None, description="Parameter to be plotted on the y-axis. This field corresponds to a parameter in the input YAML-file. E.g. 'solve.source_parameters.sine.field_amplitude' will plot the loss map for different applied field amplitudes." 

377 ) 

378 x_steps: int = Field(default=20, description="Number of steps on the x-axis.") 

379 y_steps: int = Field(default=20, description="Number of steps on the y-axis.") 

380 loss_type: Literal['TotalLoss', 'FilamentLoss', 'CouplingLoss', 'EddyLoss'] = Field( 

381 default='TotalLoss', 

382 description="Type of loss to be plotted. Supported options are: TotalLoss, FilamentLoss, CouplingLoss, EddyLoss." 

383 ) 

384 x_log: bool = Field( 

385 default=True, description="Set True to plot x-axis in log-scale." 

386 ) 

387 y_log: bool = Field( 

388 default=True, description="Set True to plot y-axis in log-scale." 

389 ) 

390 loss_log: bool = Field( 

391 default=True, description="Set True to plot loss in log-scale." 

392 ) 

393 x_norm: float = Field(default=1, description="Normalization factor for x-axis.") 

394 y_norm: float = Field(default=1, description="Normalization factor for y-axis.") 

395 loss_norm: float = Field(default=1, description="Normalization factor for the AC-loss.") 

396 show_datapoints: bool = Field( 

397 default=True, description="Set True to show markers for all the datapoints in the loss map." 

398 ) 

399 

400 title: Optional[str] = Field(default=None, description="Title for the plot.") 

401 xlabel: Optional[str] = Field(default=None, description="Label for the x-axis.") 

402 ylabel: Optional[str] = Field(default=None, description="Label for the y-axis.") 

403 

404 # lossType_dominance_contour: CACStrandPostprocBatchpostprocLossMapDominanceCountour = ( 

405 # CACStrandPostprocBatchpostprocLossMapDominanceCountour() 

406 # ) 

407 

408 show_loss_type_dominance_contour: bool = Field( 

409 default=False, 

410 description="Set True to plot a contour curve separating regions where different loss types dominate. ", 

411 ) 

412 

413 cross_section: CACRutherfordPostprocBatchpostprocLossMapCrossSection = ( 

414 CACRutherfordPostprocBatchpostprocLossMapCrossSection() 

415 ) 

416 cross_section_sweep: CACRutherfordPostprocBatchpostprocLossMapCrossSectionSweep = ( 

417 CACRutherfordPostprocBatchpostprocLossMapCrossSectionSweep() 

418 ) 

419 

420 

421class CACRutherfordPostprocBatchpostprocPlot2d(BaseModel): 

422 """ 

423 Level 4: Class for 2D plot settings 

424 """ 

425 produce_plot2d: bool = Field( 

426 default=False, description="Set True to produce a 2D plot." 

427 ) 

428 combined_plot: bool = Field( 

429 default=False, 

430 description="Set True to produce a combined plot for all simulations. If False, a separate plot is produced for each simulation.", 

431 ) 

432 save_plot: bool = Field(default=False, description="Set True to save the plot.") 

433 filename: str = Field(default="plot2d", description="Name of the plot file.") 

434 x_val: Optional[str] = Field( 

435 default=None, description="Value to be plotted on the x-axis. Parameters in the input YAML-file and class-variables from the plotter 'SimulationData' class can be accessed trough the notation << . >>. E.g. '<<solve.source_parameters.sine.frequency>>' will create a 2D plot with frequency on the x-axis. '<<time>>' will create a plot with time on the x-axis." 

436 ) 

437 y_vals: Optional[List[str]] = Field( 

438 default=None, description=" List of values to be plotted on the y-axis. Parameters in the input YAML-file and class-variables from the plotter 'SimulationData' class can be accessed trough the notation << . >>. E.g. total AC-loss per cycle can be accessed as ['<<total_power_per_cycle['TotalLoss_dyn']>>']." 

439 ) 

440 labels: Optional[List[str]] = Field( 

441 default=None, 

442 description="List of labels for the plot. Each label corresponding to a value in y_val.", 

443 ) 

444 linestyle: Optional[str] = Field( 

445 default=None, description="Linestyle for the plot." 

446 ) 

447 

448 title: Optional[str] = Field(default=None, description="Title for the plot.") 

449 xlabel: Optional[str] = Field(default=None, description="Label for the x-axis.") 

450 ylabel: Optional[str] = Field(default=None, description="Label for the y-axis.") 

451 x_log: bool = Field(default=False, description="Set True to plot x-axis in log-scale.") 

452 y_log: bool = Field(default=False, description="Set True to plot y-axis in log-scale.") 

453 legend: bool = Field(default=True, description="Set True to show legend.") 

454 

455 

456class CACRutherfordPostprocBatchpostprocFilter(BaseModel): 

457 """ 

458 Level 4: Field for filtering simulations based on simulation parameters for batch post-processing 

459 """ 

460 apply_filter: bool = Field( 

461 default=False, 

462 description="Set True to filter simulations by parameters from the input YAML-file.", 

463 ) 

464 filter_criterion: Optional[str] = Field( 

465 default=None, 

466 description="Criterion used to filter simulations based on simulation parameters. For example will '<<solve.source_parameters.sine.frequency>> > 100' disregard simulations done with frequencies lower than 100Hz.", 

467 ) 

468 

469 

470class CACRutherfordPostprocBatchpostprocSort(BaseModel): 

471 """ 

472 Level 4: Field for sorting simulations based on simulation parameters for batch post-processing 

473 """ 

474 apply_sort: bool = Field(default=False, description="Set True to sort simulations.") 

475 sort_key: Optional[str] = Field( 

476 default=None, 

477 description="Criterion used to sort simulations based on simulation parameters. For example will 'sd.total_power_per_cycle['TotalLoss'] sort simulations based on the total loss.", 

478 ) 

479 

480 

481class CACRutherfordPostprocBatchpostproc(BaseModel): 

482 """ 

483 Level 3: Class for batch post-processing settings 

484 """ 

485 postProc_csv: Optional[str] = Field( 

486 default=None, 

487 description="Name of the .csv file for post-processing (without file extension). This file specifies the simulations to be post-processed. The file is structured into three columns, specifying the folder names to access the simulation results: 'input.run.geometry', 'input.run.mesh' and 'input.run.solve'. Each row corresponds to a simulation to be post-processed.", 

488 ) 

489 output_folder: Optional[str] = Field( 

490 default=None, 

491 description="Batch post-processing creates a folder with the given name in the output directory, where all the plots are saved.", 

492 ) 

493 filter: CACRutherfordPostprocBatchpostprocFilter = CACRutherfordPostprocBatchpostprocFilter() 

494 sort: CACRutherfordPostprocBatchpostprocSort = CACRutherfordPostprocBatchpostprocSort() 

495 loss_map: CACRutherfordPostprocBatchpostprocLossMap = CACRutherfordPostprocBatchpostprocLossMap() 

496 plot2d: CACRutherfordPostprocBatchpostprocPlot2d = CACRutherfordPostprocBatchpostprocPlot2d() 

497 

498 

499class CACRutherfordPostprocPlotInstPower(BaseModel): 

500 """ 

501 Level 3: Class with settings for generating plots of instantaneous power 

502 """ 

503 show: bool = Field(default=False, description="Creates a plot for the calculated instantaneous AC loss (W/m) as a function of time (s).") 

504 title: str = Field(default="Instantaneous Power", description="Title for the plot.") 

505 save: bool = Field(default=False, description="Set True to save the plot.") 

506 save_file_name: str = Field( 

507 default="instantaneous_power", description="Name of the plot file." 

508 ) 

509 

510 

511class CACRutherfordPostprocCleanup(BaseModel): 

512 """ 

513 Level 3: Class for cleanup settings 

514 """ 

515 remove_pre_file: bool = Field( 

516 default=False, 

517 description="Set True to remove the .pre-file after post-processing, to save disk space.", 

518 ) 

519 remove_res_file: bool = Field( 

520 default=False, 

521 description="Set True to remove the .res-file after post-processing, to save disk space.", 

522 ) 

523 remove_msh_file: bool = Field( 

524 default=False, 

525 description="Set True to remove the .msh-file after post-processing, to save disk space.", 

526 ) 

527 

528 

529class CACRutherfordPostproc(BaseModel): 

530 """ 

531 Level 2: Class for FiQuS ConductorAC 

532 """ 

533 generate_pos_files: bool = Field( 

534 default=True, 

535 description="Set True to generate .pos-files during post-processing", 

536 ) 

537 plot_instantaneous_power: CACRutherfordPostprocPlotInstPower = ( 

538 CACRutherfordPostprocPlotInstPower() 

539 ) 

540 compute_current_per_filament: bool = Field( 

541 default=False, 

542 description="Computes current in every filament, with decomposition into magnetization and transport current.", 

543 ) 

544 save_last_current_density: Optional[str] = Field( 

545 default=None, 

546 description="Saves the last current density field solution (out-of-plane) in the file given as a string." 

547 " The '.pos' extension will be appended to it. Nothing is done if None." 

548 " This can be for using the current density as an initial condition (but not implemented yet).", 

549 ) 

550 save_last_magnetic_field: Optional[str] = Field( 

551 default=None, 

552 description="Saves the last magnetic field solution (in-plane) in the file given as a string." 

553 " The '.pos' extension will be appended to it. Nothing is done if None." 

554 " This is for using the magnetic field as an initial condition for another resolution.", 

555 ) 

556 cleanup: CACRutherfordPostprocCleanup = CACRutherfordPostprocCleanup() 

557 batch_postproc: CACRutherfordPostprocBatchpostproc = CACRutherfordPostprocBatchpostproc() 

558 

559 

560# ============= BASE ============= # 

561class CACRutherford(BaseModel): 

562 """ 

563 Level 1: Class for FiQuS ConductorAC 

564 """ 

565 type: Literal["CACRutherford"] 

566 geometry: CACRutherfordGeometry = CACRutherfordGeometry() 

567 mesh: CACRutherfordMesh = CACRutherfordMesh() 

568 solve: CACRutherfordSolve = CACRutherfordSolve() 

569 postproc: CACRutherfordPostproc = CACRutherfordPostproc()