fiqus 2024.5.2__py3-none-any.whl → 2024.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fiqus/MainFiQuS.py +15 -5
- fiqus/data/DataConductor.py +301 -0
- fiqus/data/DataFiQuS.py +5 -2
- fiqus/data/DataFiQuSConductor.py +84 -0
- fiqus/data/DataFiQuSConductorAC_Strand.py +565 -0
- fiqus/data/DataFiQuSPancake3D.py +149 -39
- fiqus/data/RegionsModelFiQuS.py +4 -2
- fiqus/geom_generators/GeometryCCT.py +19 -17
- fiqus/geom_generators/GeometryConductorAC_Strand.py +1391 -0
- fiqus/getdp_runners/RunGetdpConductorAC_Strand.py +202 -0
- fiqus/getdp_runners/RunGetdpMultipole.py +4 -4
- fiqus/mains/MainConductorAC_Strand.py +133 -0
- fiqus/mesh_generators/MeshCCT.py +8 -8
- fiqus/mesh_generators/MeshConductorAC_Strand.py +657 -0
- fiqus/mesh_generators/MeshMultipole.py +11 -8
- fiqus/mesh_generators/MeshPancake3D.py +20 -18
- fiqus/plotters/PlotPythonConductorAC.py +840 -0
- fiqus/post_processors/PostProcessConductorAC.py +49 -0
- fiqus/pro_assemblers/ProAssembler.py +4 -3
- fiqus/pro_templates/combined/CCT_template.pro +25 -25
- fiqus/pro_templates/combined/ConductorAC_template.pro +1025 -0
- fiqus/pro_templates/combined/Multipole_template.pro +5 -5
- fiqus/pro_templates/combined/Pancake3D_template.pro +131 -46
- fiqus/pro_templates/combined/materials.pro +13 -9
- {fiqus-2024.5.2.dist-info → fiqus-2024.6.0.dist-info}/METADATA +2 -1
- {fiqus-2024.5.2.dist-info → fiqus-2024.6.0.dist-info}/RECORD +34 -22
- {fiqus-2024.5.2.dist-info → fiqus-2024.6.0.dist-info}/WHEEL +1 -1
- tests/test_geometry_generators.py +41 -0
- tests/test_mesh_generators.py +45 -0
- tests/test_solvers.py +52 -0
- tests/utils/fiqus_test_classes.py +42 -6
- tests/utils/generate_reference_files_ConductorAC.py +57 -0
- tests/utils/generate_reference_files_Pancake3D.py +92 -0
- {fiqus-2024.5.2.dist-info → fiqus-2024.6.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import re
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
import matplotlib.pylab as pl
|
|
6
|
+
from matplotlib.animation import FuncAnimation
|
|
7
|
+
import pandas as pd
|
|
8
|
+
from scipy import integrate, interpolate
|
|
9
|
+
from typing import (List, Literal, Callable)
|
|
10
|
+
from pydantic import BaseModel
|
|
11
|
+
|
|
12
|
+
from fiqus.utils.Utils import FilesAndFolders as Util
|
|
13
|
+
from fiqus.data.DataFiQuSConductorAC_Strand import CACStrandSolve, CACStrandPostproc, CACStrandMesh, CACStrandGeometry
|
|
14
|
+
from fiqus.plotters.PlotPythonConductorAC import PlotPython, SimulationData
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PostProcess:
|
|
18
|
+
"""
|
|
19
|
+
This class loads and stores the data from a simulation and can apply various postprocessing operations on the data.
|
|
20
|
+
The simulation data is saved as a SimulationData object.
|
|
21
|
+
"""
|
|
22
|
+
def __init__(self, fdm, model_data_output_path) -> None:
|
|
23
|
+
self.fdm = fdm
|
|
24
|
+
self.model_data_output_path = model_data_output_path
|
|
25
|
+
self.geometry_name = f"Geometry_{self.fdm.run.geometry}"
|
|
26
|
+
self.mesh_name = f"Mesh_{self.fdm.run.mesh}"
|
|
27
|
+
self.solution_name = f"Solution_{self.fdm.run.solution}"
|
|
28
|
+
|
|
29
|
+
self.simulation_data = SimulationData(model_data_output_path, self.geometry_name, self.mesh_name, self.solution_name)
|
|
30
|
+
|
|
31
|
+
def plot_instantaneous_loss(self):
|
|
32
|
+
print("Total loss: ", self.simulation_data.cumulative_power["TotalLoss"].iloc[-1])
|
|
33
|
+
print("Total filament loss: ", self.simulation_data.cumulative_power["FilamentLoss"].iloc[-1])
|
|
34
|
+
print("Total coupling loss: ", self.simulation_data.cumulative_power["CouplingLoss"].iloc[-1])
|
|
35
|
+
print("Total eddy loss: ", self.simulation_data.cumulative_power["EddyLoss"].iloc[-1])
|
|
36
|
+
plot_options = self.fdm.magnet.postproc.plot_instantaneous_power
|
|
37
|
+
self.simulation_data.plot_instantaneous_power(
|
|
38
|
+
show=plot_options.show,
|
|
39
|
+
title=plot_options.title,
|
|
40
|
+
save_plot=plot_options.save,
|
|
41
|
+
save_folder_path=os.path.join(self.model_data_output_path, self.geometry_name, self.mesh_name, self.solution_name),
|
|
42
|
+
save_file_name=plot_options.save_file_name,
|
|
43
|
+
overwrite=self.fdm.run.overwrite
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
@@ -16,7 +16,7 @@ class ASS_PRO:
|
|
|
16
16
|
else:
|
|
17
17
|
self.naming_conv = naming_conv
|
|
18
18
|
|
|
19
|
-
def assemble_combined_pro(self, template, rm, dm, rc=None, mf=None, ps=None, ed=None, BH_curves_path: str = ''):
|
|
19
|
+
def assemble_combined_pro(self, template, rm, dm, rc=None, mf=None, ps=None, ed=None, mp=None, BH_curves_path: str = ''):
|
|
20
20
|
"""
|
|
21
21
|
Generates model .pro file from .pro template and regions model (rm)
|
|
22
22
|
:param BH_curves_path: path of the BH curves pro file
|
|
@@ -27,14 +27,15 @@ class ASS_PRO:
|
|
|
27
27
|
:param mf: full path to mesh file to be used in solution
|
|
28
28
|
:param ps: previous solution folder (this is used by CWS for co-simulation run)
|
|
29
29
|
:param ed: excitation dictionary with lists (e.g. times and currents) to be used in a pro file (e.g. transient simulation)
|
|
30
|
+
:param mp: material properties data structure (for CAC with Geometry YAML)
|
|
30
31
|
:return: None. Generates .pro file and saves it on disk in the model folder under model_name.pro
|
|
31
32
|
"""
|
|
32
33
|
loader = FileSystemLoader(combined.__path__)
|
|
33
34
|
env = Environment(loader=loader, variable_start_string='<<', variable_end_string='>>',
|
|
34
35
|
trim_blocks=True, lstrip_blocks=True)
|
|
35
|
-
env.globals.update(set=set, str=str, int=int, zip=zip, enumerate=enumerate, list=list, len=len, arange=np.arange, Pi=np.pi) # this is to pass python zip function to the template, as normally it is not available. It should work for passing any python function that is not available in .pro template.
|
|
36
|
+
env.globals.update(set=set, str=str, int=int, float=float, zip=zip, enumerate=enumerate, list=list, len=len, isinstance=isinstance, arange=np.arange, Pi=np.pi) # this is to pass python zip function to the template, as normally it is not available. It should work for passing any python function that is not available in .pro template.
|
|
36
37
|
pro_template = env.get_template(template)
|
|
37
|
-
output_from_parsed_template = pro_template.render(BHcurves=BH_curves_path, rm=rm, rc=rc, dm=dm, mf=mf, nc=self.naming_conv, ps=ps, ed=ed)
|
|
38
|
+
output_from_parsed_template = pro_template.render(BHcurves=BH_curves_path, rm=rm, rc=rc, dm=dm, mf=mf, nc=self.naming_conv, ps=ps, ed=ed, mp=mp)
|
|
38
39
|
with open(f"{self.file_base_path}.pro", "w") as tf:
|
|
39
40
|
tf.write(output_from_parsed_template)
|
|
40
41
|
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
Group {
|
|
2
|
-
{% for name, number in zip(rm.powered.vol.names, rm.powered.vol.numbers) %}
|
|
2
|
+
{% for name, number in zip(rm.powered['cct'].vol.names, rm.powered['cct'].vol.numbers) %}
|
|
3
3
|
<<name>> = Region[{<<number>>}];
|
|
4
4
|
{% endfor %}
|
|
5
|
-
{% for name, number in zip(rm.powered.surf_in.names, rm.powered.surf_in.numbers) %}
|
|
5
|
+
{% for name, number in zip(rm.powered['cct'].surf_in.names, rm.powered['cct'].surf_in.numbers) %}
|
|
6
6
|
<<name>> = Region[{<<number>>}];
|
|
7
7
|
{% endfor %}
|
|
8
|
-
{% for name, number in zip(rm.powered.surf_out.names, rm.powered.surf_out.numbers) %}
|
|
8
|
+
{% for name, number in zip(rm.powered['cct'].surf_out.names, rm.powered['cct'].surf_out.numbers) %}
|
|
9
9
|
<<name>> = Region[{<<number>>}];
|
|
10
10
|
{% endfor %}
|
|
11
|
-
{% for name, number in zip(rm.induced.vol.names, rm.induced.vol.numbers) %}
|
|
11
|
+
{% for name, number in zip(rm.induced['cct'].vol.names, rm.induced['cct'].vol.numbers) %}
|
|
12
12
|
<<name>> = Region[{<<number>>}];
|
|
13
13
|
{% endfor %}
|
|
14
|
-
<<nc.omega>><<nc.cond>> = Region[{<<(rm.powered.vol.numbers+rm.induced.vol.numbers)|join(', ')>>}];
|
|
14
|
+
<<nc.omega>><<nc.cond>> = Region[{<<(rm.powered['cct'].vol.numbers+rm.induced['cct'].vol.numbers)|join(', ')>>}];
|
|
15
15
|
//<<nc.line>><<nc.air>> = Region[{<<rm.air.line.number>>}];
|
|
16
16
|
//<<nc.omega>><<nc.air>> = Region[{<<([rm.air.vol.number]+[rm.air.line.number])|join(', ')>>}];
|
|
17
17
|
<<nc.omega>><<nc.air>> = Region[{<<rm.air.vol.number>>}];
|
|
18
|
-
<<nc.omega>> = Region[{<<(rm.powered.vol.numbers+rm.induced.vol.numbers+[rm.air.vol.number])|join(', ')>>}];
|
|
19
|
-
<<nc.terms>> = Region[{<<rm.powered.surf_in.numbers|join(', ')>>, <<rm.powered.surf_out.numbers|join(', ')>>}];
|
|
20
|
-
<<nc.bd>><<nc.omega>> = Region[{<< rm.air.surf.number>>, << rm.powered.surf_in.numbers|join(', ')>>, << rm.powered.surf_out.numbers|join(', ')>>}];
|
|
21
|
-
<<nc.omega>><<nc.powered>> = Region[{<<rm.powered.vol.numbers|join(', ')>>}];
|
|
18
|
+
<<nc.omega>> = Region[{<<(rm.powered['cct'].vol.numbers+rm.induced['cct'].vol.numbers+[rm.air.vol.number])|join(', ')>>}];
|
|
19
|
+
<<nc.terms>> = Region[{<<rm.powered['cct'].surf_in.numbers|join(', ')>>, <<rm.powered['cct'].surf_out.numbers|join(', ')>>}];
|
|
20
|
+
<<nc.bd>><<nc.omega>> = Region[{<< rm.air.surf.number>>, << rm.powered['cct'].surf_in.numbers|join(', ')>>, << rm.powered['cct'].surf_out.numbers|join(', ')>>}];
|
|
21
|
+
<<nc.omega>><<nc.powered>> = Region[{<<rm.powered['cct'].vol.numbers|join(', ')>>}];
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
{% for name, number in zip(rm.powered.cochain.names, rm.powered.cochain.numbers) %}
|
|
24
|
+
{% for name, number in zip(rm.powered['cct'].cochain.names, rm.powered['cct'].cochain.numbers) %}
|
|
25
25
|
DefineConstant[ <<name>> = {<<number>>, Min 1, Step 1, Closed 1,
|
|
26
26
|
Name "Cohomology/<<name>>"} ];
|
|
27
27
|
<<name>> = Region[{<<name>>}];
|
|
28
28
|
{% endfor %}
|
|
29
|
-
Cuts<<nc.powered>> = Region[ {<<rm.powered.cochain.names|join(', ')>>} ];
|
|
30
|
-
{% for name, number in zip(rm.induced.cochain.names, rm.induced.cochain.numbers) %}
|
|
29
|
+
Cuts<<nc.powered>> = Region[ {<<rm.powered['cct'].cochain.names|join(', ')>>} ];
|
|
30
|
+
{% for name, number in zip(rm.induced['cct'].cochain.names, rm.induced['cct'].cochain.numbers) %}
|
|
31
31
|
DefineConstant[ <<name>> = {<<number>>, Min 1, Step 1,
|
|
32
32
|
Name "Cohomology/<<name>>"} ];
|
|
33
33
|
<<name>> = Region[{<<name>>}];
|
|
34
34
|
{% endfor %}
|
|
35
|
-
Cuts<<nc.induced>> = Region[ {<<rm.induced.cochain.names|join(', ')>>} ];
|
|
35
|
+
Cuts<<nc.induced>> = Region[ {<<rm.induced['cct'].cochain.names|join(', ')>>} ];
|
|
36
36
|
DomainDummy = Region[ 12345 ] ; // Dummy region number for postpro with functions
|
|
37
37
|
}
|
|
38
38
|
Function {
|
|
39
39
|
DefineConstant
|
|
40
40
|
[
|
|
41
|
-
{% for vol_name, current in zip(rm.powered.vol.names, rm.powered.vol.currents) %}
|
|
41
|
+
{% for vol_name, current in zip(rm.powered['cct'].vol.names, rm.powered['cct'].vol.currents) %}
|
|
42
42
|
I_<<vol_name>> = {<<current>>, Step 1, Name "Powering/<<vol_name>>_Current [A]"},
|
|
43
43
|
{% endfor %}
|
|
44
|
-
{% for vol_name, sigma, mu_r in zip(rm.powered.vol.names, rm.powered.vol.sigmas, rm.powered.vol.mu_rs) %}
|
|
44
|
+
{% for vol_name, sigma, mu_r in zip(rm.powered['cct'].vol.names, rm.powered['cct'].vol.sigmas, rm.powered['cct'].vol.mu_rs) %}
|
|
45
45
|
<<vol_name>>_Conductivity = {<<sigma>>, Min 0, Step 1e6, Name "Materials/<<vol_name>> Cond. [S per m]"},
|
|
46
46
|
<<vol_name>>_Permeability = {<<mu_r>>, Min 0, Step 1e1, Name "Materials/<<vol_name>> Rel. Perm. [-]"},
|
|
47
47
|
{% endfor %}
|
|
48
|
-
{% for vol_name, sigma, mu_r in zip(rm.induced.vol.names, rm.induced.vol.sigmas, rm.induced.vol.mu_rs) %}
|
|
48
|
+
{% for vol_name, sigma, mu_r in zip(rm.induced['cct'].vol.names, rm.induced['cct'].vol.sigmas, rm.induced['cct'].vol.mu_rs) %}
|
|
49
49
|
<<vol_name>>_Conductivity = {<<sigma>>, Min 0, Step 1e6, Name "Materials/<<vol_name>> Cond. [S per m]"},
|
|
50
50
|
<<vol_name>>_Permeability = {<<mu_r>>, Min 0, Step 1e1, Name "Materials/<<vol_name>> Rel. Perm. [-]"},
|
|
51
51
|
{% endfor %}
|
|
@@ -54,12 +54,12 @@ Function {
|
|
|
54
54
|
];
|
|
55
55
|
mu0 = 4*Pi*1e-7; // Vacuum permeability
|
|
56
56
|
nu [] = 1./mu0;
|
|
57
|
-
{% for vol_name in rm.powered.vol.names %}
|
|
57
|
+
{% for vol_name in rm.powered['cct'].vol.names %}
|
|
58
58
|
I_<<vol_name>>[] = I_<<vol_name>>;
|
|
59
59
|
sigma[<<vol_name>>] = <<vol_name>>_Conductivity;
|
|
60
60
|
mu[<<vol_name>>] = mu0*<<vol_name>>_Permeability;
|
|
61
61
|
{% endfor %}
|
|
62
|
-
{% for vol_name in rm.induced.vol.names %}
|
|
62
|
+
{% for vol_name in rm.induced['cct'].vol.names %}
|
|
63
63
|
sigma[<<vol_name>>] = <<vol_name>>_Conductivity;
|
|
64
64
|
mu[<<vol_name>>] = mu0*<<vol_name>>_Permeability;
|
|
65
65
|
{% endfor %}
|
|
@@ -111,14 +111,14 @@ Constraint {
|
|
|
111
111
|
}
|
|
112
112
|
{ Name VoltageAV ;
|
|
113
113
|
Case {
|
|
114
|
-
{% for cut_name in rm.induced.cochain.names %}
|
|
114
|
+
{% for cut_name in rm.induced['cct'].cochain.names %}
|
|
115
115
|
{ Region <<cut_name>>; Value 0. ; }
|
|
116
116
|
{% endfor %}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
{ Name CurrentAV ;
|
|
120
120
|
Case {
|
|
121
|
-
{% for cut_name, vol_name in zip(rm.powered.cochain.names, rm.powered.vol.names) %}
|
|
121
|
+
{% for cut_name, vol_name in zip(rm.powered['cct'].cochain.names, rm.powered['cct'].vol.names) %}
|
|
122
122
|
{ Region <<cut_name>>; Value I_<<vol_name>>[] ; }
|
|
123
123
|
{% endfor %}
|
|
124
124
|
}
|
|
@@ -187,9 +187,9 @@ Formulation {
|
|
|
187
187
|
In <<nc.omega>><<nc.cond>>; Integration Int; Jacobian Vol; }
|
|
188
188
|
GlobalTerm { [ - Dof{I<<nc.powered>>} , {V<<nc.powered>>} ] ; In Cuts<<nc.powered>>; }
|
|
189
189
|
GlobalTerm { [ - Dof{I<<nc.induced>>} , {V<<nc.induced>>} ] ; In Cuts<<nc.induced>>; }
|
|
190
|
-
{% for cut_name in rm.powered.cochain.names %}
|
|
190
|
+
{% for cut_name in rm.powered['cct'].cochain.names %}
|
|
191
191
|
{% endfor %}
|
|
192
|
-
{% for cut_name in rm.induced.cochain.names %}
|
|
192
|
+
{% for cut_name in rm.induced['cct'].cochain.names %}
|
|
193
193
|
{% endfor %}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
@@ -225,7 +225,7 @@ PostProcessing {
|
|
|
225
225
|
In <<nc.omega>><<nc.cond>>; Jacobian Vol; } } }
|
|
226
226
|
{ Name h; Value{ Local{ [ 1./mu[]*({d a}) ] ;
|
|
227
227
|
In <<nc.omega>>; Jacobian Vol; } } }
|
|
228
|
-
{% for cut_name, vol_name in zip(rm.powered.cochain.names, rm.powered.vol.names) %}
|
|
228
|
+
{% for cut_name, vol_name in zip(rm.powered['cct'].cochain.names, rm.powered['cct'].vol.names) %}
|
|
229
229
|
{ Name I_<<vol_name>> ; Value { Term { [ {I_p} ] ; In <<cut_name>> ; } } }
|
|
230
230
|
{ Name V_<<vol_name>> ; Value { Term { [ {V_p} ] ; In <<cut_name>> ; } } }
|
|
231
231
|
{ Name Z_<<vol_name>> ; Value { Term { [ {V_p}/{I_p} ] ; In <<cut_name>> ; } } }
|
|
@@ -236,7 +236,7 @@ PostProcessing {
|
|
|
236
236
|
{ Name imV_<<vol_name>> ; Value { Term { [ Im[{V_p}] ] ; In <<cut_name>> ; } } }
|
|
237
237
|
{ Name imZ_<<vol_name>> ; Value { Term { [ Im[{V_p}/{I_p}] ] ; In <<cut_name>> ; } } }
|
|
238
238
|
{% endfor %}
|
|
239
|
-
{% for cut_name, vol_name in zip(rm.induced.cochain.names, rm.induced.vol.names) %}
|
|
239
|
+
{% for cut_name, vol_name in zip(rm.induced['cct'].cochain.names, rm.induced['cct'].vol.names) %}
|
|
240
240
|
{ Name I_<<vol_name>> ; Value { Term { [ {I_i} ] ; In <<cut_name>> ; } } }
|
|
241
241
|
{ Name V_<<vol_name>> ; Value { Term { [ {V_i} ] ; In <<cut_name>> ; } } }
|
|
242
242
|
{ Name reI_<<vol_name>> ; Value { Term { [ Re[{I_i}] ] ; In <<cut_name>> ; } } }
|
|
@@ -245,7 +245,7 @@ PostProcessing {
|
|
|
245
245
|
{ Name imV_<<vol_name>> ; Value { Term { [ Im[{V_i}] ] ; In <<cut_name>> ; } } }
|
|
246
246
|
{% endfor %}
|
|
247
247
|
{ Name MagEnergy ; Value { Integral { [ 1/2 * nu[{d a}]*{d a} * {d a} ] ; In <<nc.omega>><<nc.cond>> ; Jacobian Vol ; Integration Int ; } } }
|
|
248
|
-
{ Name Inductance_from_MagEnergy ; Value { Term { Type Global; [ 2 * $MagEnergy /(I_<<rm.powered.vol.names[0]>>[]*I_<<rm.powered.vol.names[0]>>[]) ] ; In DomainDummy ; } } }
|
|
248
|
+
{ Name Inductance_from_MagEnergy ; Value { Term { Type Global; [ 2 * $MagEnergy /(I_<<rm.powered['cct'].vol.names[0]>>[]*I_<<rm.powered['cct'].vol.names[0]>>[]) ] ; In DomainDummy ; } } }
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
}
|