fiqus 2025.11.0__py3-none-any.whl → 2026.1.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 +9 -0
- fiqus/data/DataConductor.py +112 -3
- fiqus/data/DataFiQuS.py +4 -3
- fiqus/data/DataFiQuSConductorAC_CC.py +345 -0
- fiqus/data/DataFiQuSConductorAC_Rutherford.py +569 -0
- fiqus/data/DataFiQuSConductorAC_Strand.py +3 -3
- fiqus/data/DataFiQuSHomogenizedConductor.py +478 -0
- fiqus/geom_generators/GeometryConductorAC_CC.py +1906 -0
- fiqus/geom_generators/GeometryConductorAC_Rutherford.py +706 -0
- fiqus/geom_generators/GeometryConductorAC_Strand_RutherfordCopy.py +1848 -0
- fiqus/geom_generators/GeometryHomogenizedConductor.py +183 -0
- fiqus/getdp_runners/RunGetdpConductorAC_CC.py +123 -0
- fiqus/getdp_runners/RunGetdpConductorAC_Rutherford.py +200 -0
- fiqus/getdp_runners/RunGetdpHomogenizedConductor.py +178 -0
- fiqus/mains/MainConductorAC_CC.py +148 -0
- fiqus/mains/MainConductorAC_Rutherford.py +76 -0
- fiqus/mains/MainHomogenizedConductor.py +112 -0
- fiqus/mesh_generators/MeshConductorAC_CC.py +1305 -0
- fiqus/mesh_generators/MeshConductorAC_Rutherford.py +235 -0
- fiqus/mesh_generators/MeshConductorAC_Strand_RutherfordCopy.py +718 -0
- fiqus/mesh_generators/MeshHomogenizedConductor.py +229 -0
- fiqus/post_processors/PostProcessAC_CC.py +65 -0
- fiqus/post_processors/PostProcessAC_Rutherford.py +142 -0
- fiqus/post_processors/PostProcessHomogenizedConductor.py +114 -0
- fiqus/pro_templates/combined/CAC_CC_template.pro +542 -0
- fiqus/pro_templates/combined/CAC_Rutherford_template.pro +1742 -0
- fiqus/pro_templates/combined/HomogenizedConductor_template.pro +1663 -0
- {fiqus-2025.11.0.dist-info → fiqus-2026.1.0.dist-info}/METADATA +9 -12
- {fiqus-2025.11.0.dist-info → fiqus-2026.1.0.dist-info}/RECORD +36 -13
- tests/test_geometry_generators.py +40 -0
- tests/test_mesh_generators.py +76 -0
- tests/test_solvers.py +137 -0
- /fiqus/pro_templates/combined/{ConductorAC_template.pro → CAC_Strand_template.pro} +0 -0
- {fiqus-2025.11.0.dist-info → fiqus-2026.1.0.dist-info}/LICENSE.txt +0 -0
- {fiqus-2025.11.0.dist-info → fiqus-2026.1.0.dist-info}/WHEEL +0 -0
- {fiqus-2025.11.0.dist-info → fiqus-2026.1.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import os, re, subprocess, logging, timeit
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import gmsh
|
|
4
|
+
|
|
5
|
+
from fiqus.data.DataFiQuSConductor import Conductor, SolutionParameters
|
|
6
|
+
from fiqus.data.RegionsModelFiQuS import RegionsModel
|
|
7
|
+
from fiqus.utils.Utils import GmshUtils, FilesAndFolders
|
|
8
|
+
|
|
9
|
+
from fiqus.pro_assemblers.ProAssembler import ASS_PRO
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger('FiQuS')
|
|
12
|
+
|
|
13
|
+
class Solve:
|
|
14
|
+
def __init__(self, fdm, GetDP_path, geometry_folder, mesh_folder, verbose=True):
|
|
15
|
+
self.fdm = fdm
|
|
16
|
+
self.GetDP_path = GetDP_path
|
|
17
|
+
|
|
18
|
+
self.solution_folder = os.path.join(os.getcwd())
|
|
19
|
+
self.geometry_folder = geometry_folder
|
|
20
|
+
self.mesh_folder = mesh_folder
|
|
21
|
+
|
|
22
|
+
self.mesh_file = os.path.join(self.mesh_folder, f"{self.fdm.general.magnet_name}.msh")
|
|
23
|
+
self.pro_file = os.path.join(self.solution_folder, f"{self.fdm.general.magnet_name}.pro")
|
|
24
|
+
self.regions_file = os.path.join(mesh_folder, f"{self.fdm.general.magnet_name}.regions")
|
|
25
|
+
|
|
26
|
+
self.verbose = verbose
|
|
27
|
+
self.gu = GmshUtils(self.solution_folder, self.verbose)
|
|
28
|
+
self.gu.initialize(verbosity_Gmsh=fdm.run.verbosity_Gmsh)
|
|
29
|
+
|
|
30
|
+
self.ass_pro = ASS_PRO(os.path.join(self.solution_folder, self.fdm.general.magnet_name))
|
|
31
|
+
self.regions_model = FilesAndFolders.read_data_from_yaml(self.regions_file, RegionsModel)
|
|
32
|
+
self.material_properties_model = None
|
|
33
|
+
|
|
34
|
+
self.ed = {} # excitation dictionary
|
|
35
|
+
self.rohm = {} # rohm parameter dictionary
|
|
36
|
+
self.rohf = {} # rohf parameter dictionary
|
|
37
|
+
|
|
38
|
+
gmsh.option.setNumber("General.Terminal", verbose)
|
|
39
|
+
|
|
40
|
+
def read_ro_parameters(self, inputs_folder_path):
|
|
41
|
+
"""
|
|
42
|
+
Function for reading the CSV files containing the reduced order parameters for ROHF and ROHM.
|
|
43
|
+
The function expects CSV files with an descriptive first header row (i.e. 'alphas,kappas,taus') and following rows with comma seperated parameter values for each cell starting from cell 1.
|
|
44
|
+
|
|
45
|
+
:param inputs_folder_path: The full path to the folder with input files
|
|
46
|
+
"""
|
|
47
|
+
class reduced_order_params:
|
|
48
|
+
" This structure is used to access the parameter dictionaries inside the pro template with a convenient syntax 'mp.rohf' or 'mp.rohm'."
|
|
49
|
+
def __init__(self, rohf_dict=None, rohm_dict=None):
|
|
50
|
+
self.rohf = rohf_dict
|
|
51
|
+
self.rohm = rohm_dict
|
|
52
|
+
|
|
53
|
+
if self.fdm.magnet.solve.rohm.enable and self.fdm.magnet.solve.rohm.parameter_csv_file:
|
|
54
|
+
parameter_file = os.path.join(inputs_folder_path, self.fdm.magnet.solve.rohm.parameter_csv_file)
|
|
55
|
+
df = pd.read_csv(parameter_file, delimiter=',', engine='python')
|
|
56
|
+
df.index += 1
|
|
57
|
+
logger.info(f'Using ROHM parameters from file: {parameter_file}:')
|
|
58
|
+
logger.info(df)
|
|
59
|
+
self.rohm = df.to_dict(orient='dict')
|
|
60
|
+
|
|
61
|
+
if self.fdm.magnet.solve.rohf.enable and self.fdm.magnet.solve.rohf.parameter_csv_file:
|
|
62
|
+
parameter_file = os.path.join(inputs_folder_path, self.fdm.magnet.solve.rohf.parameter_csv_file)
|
|
63
|
+
df = pd.read_csv(parameter_file, delimiter=',', engine='python')
|
|
64
|
+
df.index += 1
|
|
65
|
+
logger.info(f'Using ROHF parameters from file: {parameter_file}:')
|
|
66
|
+
logger.info(df)
|
|
67
|
+
self.rohf = df.to_dict(orient='dict')
|
|
68
|
+
|
|
69
|
+
# For the moment the reduced order parameters are treated as material properties mp structure.
|
|
70
|
+
self.material_properties_model = reduced_order_params(rohf_dict=self.rohf, rohm_dict=self.rohm)
|
|
71
|
+
|
|
72
|
+
def read_excitation(self, inputs_folder_path):
|
|
73
|
+
"""
|
|
74
|
+
Function for reading a CSV file for the 'from_file' excitation case.
|
|
75
|
+
|
|
76
|
+
:param inputs_folder_path: The full path to the folder with input files.
|
|
77
|
+
:type inputs_folder_path: str
|
|
78
|
+
"""
|
|
79
|
+
if self.fdm.magnet.solve.source_parameters.source_type == 'piecewise' and self.fdm.magnet.solve.source_parameters.piecewise.source_csv_file:
|
|
80
|
+
input_file = os.path.join(inputs_folder_path, self.fdm.magnet.solve.source_parameters.piecewise.source_csv_file)
|
|
81
|
+
logger.info(f'Using excitation from file: {input_file}')
|
|
82
|
+
df = pd.read_csv(input_file, delimiter=',', engine='python')
|
|
83
|
+
excitation_time = df['time'].to_numpy(dtype='float').tolist()
|
|
84
|
+
self.ed['time'] = excitation_time
|
|
85
|
+
excitation_value = df['value'].to_numpy(dtype='float').tolist()
|
|
86
|
+
self.ed['value'] = excitation_value
|
|
87
|
+
|
|
88
|
+
def assemble_pro(self):
|
|
89
|
+
logger.info("Assembling .pro file")
|
|
90
|
+
self.ass_pro.assemble_combined_pro(template = self.fdm.magnet.solve.pro_template, rm = self.regions_model, dm = self.fdm, ed=self.ed, mp=self.material_properties_model)
|
|
91
|
+
|
|
92
|
+
def run_getdp(self, solve = True, postOperation = True, gui = False):
|
|
93
|
+
|
|
94
|
+
command = ["-v2", "-verbose", "3", "-mat_mumps_icntl_14","100"]
|
|
95
|
+
if solve:
|
|
96
|
+
command += ["-solve", "MagDyn"]
|
|
97
|
+
command += ["-pos", "MagDyn"]
|
|
98
|
+
|
|
99
|
+
if self.fdm.magnet.solve.general_parameters.noOfMPITasks:
|
|
100
|
+
mpi_prefix = ["mpiexec", "-np", str(self.fdm.magnet.solve.general_parameters.noOfMPITasks)]
|
|
101
|
+
else:
|
|
102
|
+
mpi_prefix = []
|
|
103
|
+
|
|
104
|
+
startTime = timeit.default_timer()
|
|
105
|
+
|
|
106
|
+
getdpProcess = subprocess.Popen(mpi_prefix + [self.GetDP_path, self.pro_file, "-msh", self.mesh_file] + command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
107
|
+
|
|
108
|
+
with getdpProcess.stdout:
|
|
109
|
+
for line in iter(getdpProcess.stdout.readline, b""):
|
|
110
|
+
line = line.decode("utf-8").rstrip()
|
|
111
|
+
line = line.split("\r")[-1]
|
|
112
|
+
if not "Test" in line:
|
|
113
|
+
if line.startswith("Info"):
|
|
114
|
+
parsedLine = re.sub(r"Info\s+:\s+", "", line)
|
|
115
|
+
logger.info(parsedLine)
|
|
116
|
+
elif line.startswith("Warning"):
|
|
117
|
+
parsedLine = re.sub(r"Warning\s+:\s+", "", line)
|
|
118
|
+
logger.warning(parsedLine)
|
|
119
|
+
elif line.startswith("Error"):
|
|
120
|
+
parsedLine = re.sub(r"Error\s+:\s+", "", line)
|
|
121
|
+
logger.error(parsedLine)
|
|
122
|
+
logger.error("Solving HomogenizedConductor failed.")
|
|
123
|
+
# raise Exception(parsedLine)
|
|
124
|
+
elif re.match("##", line):
|
|
125
|
+
logger.critical(line)
|
|
126
|
+
else:
|
|
127
|
+
logger.info(line)
|
|
128
|
+
|
|
129
|
+
simulation_time = timeit.default_timer()-startTime
|
|
130
|
+
# Save simulation time:
|
|
131
|
+
if solve:
|
|
132
|
+
logger.info(f"Solving HomogenizedConductor has finished in {round(simulation_time, 3)} seconds.")
|
|
133
|
+
with open(os.path.join(self.solution_folder, 'txt_files', 'simulation_time.txt'), 'w') as file:
|
|
134
|
+
file.write(str(simulation_time))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if gui and ((postOperation and not solve) or (solve and postOperation and self.fdm.magnet.postproc.generate_pos_files)):
|
|
138
|
+
# gmsh.option.setNumber("Geometry.Volumes", 1)
|
|
139
|
+
# gmsh.option.setNumber("Geometry.Surfaces", 1)
|
|
140
|
+
# gmsh.option.setNumber("Geometry.Curves", 1)
|
|
141
|
+
# gmsh.option.setNumber("Geometry.Points", 0)
|
|
142
|
+
posFiles = [
|
|
143
|
+
fileName
|
|
144
|
+
for fileName in os.listdir(self.solution_folder)
|
|
145
|
+
if fileName.endswith(".pos")
|
|
146
|
+
]
|
|
147
|
+
for posFile in reversed(posFiles):
|
|
148
|
+
gmsh.open(os.path.join(self.solution_folder, posFile))
|
|
149
|
+
self.gu.launch_interactive_GUI()
|
|
150
|
+
else:
|
|
151
|
+
if gmsh.isInitialized():
|
|
152
|
+
gmsh.clear()
|
|
153
|
+
gmsh.finalize()
|
|
154
|
+
|
|
155
|
+
def cleanup(self):
|
|
156
|
+
"""
|
|
157
|
+
This funtion is used to remove .msh, .pre and .res files from the solution folder, as they may be large and not needed.
|
|
158
|
+
"""
|
|
159
|
+
magnet_name = self.fdm.general.magnet_name
|
|
160
|
+
cleanup = self.fdm.magnet.postproc.cleanup
|
|
161
|
+
|
|
162
|
+
if cleanup.remove_res_file:
|
|
163
|
+
res_file_path = os.path.join(self.solution_folder, f"{magnet_name}.res")
|
|
164
|
+
if os.path.exists(res_file_path):
|
|
165
|
+
os.remove(res_file_path)
|
|
166
|
+
logger.info(f"Removed {magnet_name}.res")
|
|
167
|
+
|
|
168
|
+
if cleanup.remove_pre_file:
|
|
169
|
+
pre_file_path = os.path.join(self.solution_folder, f"{magnet_name}.pre")
|
|
170
|
+
if os.path.exists(pre_file_path):
|
|
171
|
+
os.remove(pre_file_path)
|
|
172
|
+
logger.info(f"Removed {magnet_name}.pre")
|
|
173
|
+
|
|
174
|
+
if cleanup.remove_msh_file:
|
|
175
|
+
msh_file_path = os.path.join(self.mesh_folder, f"{magnet_name}.msh")
|
|
176
|
+
if os.path.exists(msh_file_path):
|
|
177
|
+
os.remove(msh_file_path)
|
|
178
|
+
logger.info(f"Removed {magnet_name}.msh")
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
|
|
2
|
+
"""MainConductorAC_CC.py:"""
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from fiqus.geom_generators.GeometryConductorAC_CC import Generate_geometry
|
|
8
|
+
from fiqus.mesh_generators.MeshConductorAC_CC import Mesh
|
|
9
|
+
from fiqus.getdp_runners.RunGetdpConductorAC_CC import Solve
|
|
10
|
+
from fiqus.post_processors.PostProcessAC_CC import Post_Process
|
|
11
|
+
|
|
12
|
+
if len(sys.argv) == 3:
|
|
13
|
+
sys.path.insert(0, os.path.join(os.getcwd(), 'steam-fiqus-dev'))
|
|
14
|
+
from fiqus.data.DataFiQuS import FDM
|
|
15
|
+
|
|
16
|
+
class MainConductorAC_CC:
|
|
17
|
+
def __init__(self, fdm, inputs_folder_path='', verbose=True):
|
|
18
|
+
"""
|
|
19
|
+
Main class for working with simulations for CAC_CC type magnets
|
|
20
|
+
:param fdm: FiQuS data model
|
|
21
|
+
:type fdm: FDM
|
|
22
|
+
:param inputs_folder_path: full path to folder with input files, i.e. conductor and STEP files
|
|
23
|
+
:type inputs_folder_path: str
|
|
24
|
+
:param verbose: if True, more info is printed in the console
|
|
25
|
+
:type verbose: bool
|
|
26
|
+
:return: nothing, only saves files on disk
|
|
27
|
+
:rtype: none
|
|
28
|
+
"""
|
|
29
|
+
self.verbose = verbose
|
|
30
|
+
self.fdm = fdm
|
|
31
|
+
self.inputs_folder_path = inputs_folder_path
|
|
32
|
+
self.GetDP_path = None
|
|
33
|
+
self.geom_folder = None
|
|
34
|
+
self.mesh_folder = None
|
|
35
|
+
self.solution_folder = None
|
|
36
|
+
self.model_file = None
|
|
37
|
+
self.model_folder = None
|
|
38
|
+
|
|
39
|
+
def generate_geometry(self, gui=False):
|
|
40
|
+
"""
|
|
41
|
+
Main method for loading the geometry of CAC_CC models
|
|
42
|
+
:param gui: if true, graphical user interface (gui) of Gmsh is opened at the end
|
|
43
|
+
:type gui: bool
|
|
44
|
+
:return: nothing, only saves files on disk
|
|
45
|
+
:rtype: none
|
|
46
|
+
"""
|
|
47
|
+
os.chdir(self.geom_folder)
|
|
48
|
+
gg = Generate_geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
|
|
49
|
+
gg.generate_HTS_layer()
|
|
50
|
+
gg.generate_silver_top_layer()
|
|
51
|
+
gg.generate_substrate_layer()
|
|
52
|
+
gg.generate_copper_top_layer()
|
|
53
|
+
gg.generate_silver_bottom_layer()
|
|
54
|
+
gg.generate_copper_bottom_layer()
|
|
55
|
+
gg.generate_copper_left_layer()
|
|
56
|
+
gg.generate_copper_right_layer()
|
|
57
|
+
gg.generate_air_region()
|
|
58
|
+
gg.finalize_and_write()
|
|
59
|
+
|
|
60
|
+
def load_geometry(self, gui=False):
|
|
61
|
+
"""
|
|
62
|
+
Main method for loading the geometry of CAC_CC models
|
|
63
|
+
"""
|
|
64
|
+
os.chdir(self.geom_folder)
|
|
65
|
+
gg = Generate_geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
|
|
66
|
+
self.geometry = gg
|
|
67
|
+
gg.load_geometry(gui=gui)
|
|
68
|
+
|
|
69
|
+
def pre_process(self, gui=False):
|
|
70
|
+
"""
|
|
71
|
+
Main method for preprocessing of CAC_CC models
|
|
72
|
+
:param gui: if true, graphical user interface (gui) of Gmsh is opened at the end
|
|
73
|
+
:type gui: bool
|
|
74
|
+
:return: nothing, only saves files on disk
|
|
75
|
+
:rtype: none
|
|
76
|
+
"""
|
|
77
|
+
os.chdir(self.geom_folder)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def mesh(self, gui=False):
|
|
81
|
+
"""
|
|
82
|
+
Main method for building the mesh of CAC_CC models
|
|
83
|
+
:param gui: if true, graphical user interface (gui) of Gmsh is opened at the end
|
|
84
|
+
:type gui: bool
|
|
85
|
+
:return: dictionary with mesh quality stats
|
|
86
|
+
:rtype: dict
|
|
87
|
+
"""
|
|
88
|
+
os.chdir(self.mesh_folder)
|
|
89
|
+
m = Mesh(self.fdm)
|
|
90
|
+
m.generate_mesh(self.geom_folder)
|
|
91
|
+
return {"gamma": 0}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def load_mesh(self, gui=False):
|
|
95
|
+
"""
|
|
96
|
+
Main method for loading the mesh of CAC_CC models
|
|
97
|
+
:param gui: if true, graphical user interface (gui) of Gmsh is opened at the end
|
|
98
|
+
:type gui: bool
|
|
99
|
+
:return: Nothing, only saves files on disk
|
|
100
|
+
:rtype: none
|
|
101
|
+
"""
|
|
102
|
+
os.chdir(self.mesh_folder)
|
|
103
|
+
|
|
104
|
+
def solve_and_postprocess_getdp(self, gui: bool = False):
|
|
105
|
+
"""
|
|
106
|
+
Assembles the .pro-file from the template, then runs the simulation and the post-processing steps using GetDP.
|
|
107
|
+
"""
|
|
108
|
+
os.chdir(self.solution_folder)
|
|
109
|
+
|
|
110
|
+
s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
|
|
111
|
+
s.read_excitation(inputs_folder_path=self.inputs_folder_path)
|
|
112
|
+
s.assemble_pro()
|
|
113
|
+
s.run_getdp(solve = True, postOperation = True, gui = gui)
|
|
114
|
+
|
|
115
|
+
def post_process_getdp(self, gui: bool = False):
|
|
116
|
+
"""
|
|
117
|
+
Runs the post-processing steps trough GetDP.
|
|
118
|
+
"""
|
|
119
|
+
os.chdir(self.solution_folder)
|
|
120
|
+
|
|
121
|
+
s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
|
|
122
|
+
s.read_excitation(inputs_folder_path=self.inputs_folder_path)
|
|
123
|
+
s.assemble_pro()
|
|
124
|
+
s.run_getdp(solve = False, postOperation = True, gui = gui)
|
|
125
|
+
|
|
126
|
+
def post_process_python(self, gui=False):
|
|
127
|
+
"""
|
|
128
|
+
Main method for postprocessing using python (without solving) of CAC_CC models
|
|
129
|
+
:param gui: if true, graphical user interface (gui) of Gmsh is opened at the end
|
|
130
|
+
:type gui: bool
|
|
131
|
+
:return: Nothing, only saves files on disk
|
|
132
|
+
:rtype: none
|
|
133
|
+
"""
|
|
134
|
+
os.chdir(self.solution_folder)
|
|
135
|
+
p=Post_Process(self.fdm, verbose=self.verbose)
|
|
136
|
+
p.cleanup()
|
|
137
|
+
return {'overall_error': 0}
|
|
138
|
+
|
|
139
|
+
def plot_python(self, gui=False):
|
|
140
|
+
"""
|
|
141
|
+
Main method for making python plots related to CAC_CC models
|
|
142
|
+
:param gui: if true, graphical user interface (gui) of Gmsh is opened at the end
|
|
143
|
+
:type gui: bool
|
|
144
|
+
:return: Nothing, only saves files on disk
|
|
145
|
+
:rtype: none
|
|
146
|
+
"""
|
|
147
|
+
os.chdir(self.solution_folder)
|
|
148
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from fiqus.geom_generators.GeometryConductorAC_Rutherford import Geometry
|
|
5
|
+
from fiqus.mesh_generators.MeshConductorAC_Rutherford import CableMesh
|
|
6
|
+
from fiqus.getdp_runners.RunGetdpConductorAC_Rutherford import Solve
|
|
7
|
+
from fiqus.post_processors.PostProcessAC_Rutherford import PostProcess
|
|
8
|
+
from fiqus.plotters.PlotPythonConductorAC import PlotPythonConductorAC
|
|
9
|
+
|
|
10
|
+
from fiqus.mains.MainConductorAC_Strand import MainConductorAC_Strand
|
|
11
|
+
|
|
12
|
+
class MainConductorAC_Rutherford(MainConductorAC_Strand):
|
|
13
|
+
|
|
14
|
+
def generate_geometry(self, gui=False):
|
|
15
|
+
"""
|
|
16
|
+
Generates the cable geometry.
|
|
17
|
+
"""
|
|
18
|
+
os.chdir(self.geom_folder)
|
|
19
|
+
g = Geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
|
|
20
|
+
g.generate_cable_geometry(gui)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def mesh(self, gui: bool = False):
|
|
25
|
+
"""
|
|
26
|
+
Generates the mesh for the cable geometry.
|
|
27
|
+
"""
|
|
28
|
+
os.chdir(self.mesh_folder)
|
|
29
|
+
|
|
30
|
+
m = CableMesh(fdm=self.fdm, verbose=self.verbose)
|
|
31
|
+
m.generate_mesh(self.geom_folder)
|
|
32
|
+
m.generate_cuts()
|
|
33
|
+
m.generate_regions_file()
|
|
34
|
+
m.save_mesh(gui)
|
|
35
|
+
|
|
36
|
+
return {"test": 0}
|
|
37
|
+
|
|
38
|
+
def solve_and_postprocess_getdp(self, gui: bool = False):
|
|
39
|
+
"""
|
|
40
|
+
Assembles the .pro-file from the template, then runs the simulation and the post-processing steps using GetDP.
|
|
41
|
+
"""
|
|
42
|
+
os.chdir(self.solution_folder)
|
|
43
|
+
|
|
44
|
+
# Checks if the strand type in the conductor data model is 'Homogenized', other types are not allowed (e.g., round) to avoid confusion as inputs in them won't be used
|
|
45
|
+
if self.fdm.conductors[self.fdm.magnet.solve.conductor_name].strand.type != 'Homogenized':
|
|
46
|
+
raise Exception(f"The strand type must be 'Homogenized' in the conductors section of the input .yaml file, any other type is not allowed.")
|
|
47
|
+
|
|
48
|
+
s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
|
|
49
|
+
s.read_excitation(inputs_folder_path=self.inputs_folder_path)
|
|
50
|
+
# s.get_solution_parameters_from_yaml(inputs_folder_path=self.inputs_folder_path)
|
|
51
|
+
s.assemble_pro()
|
|
52
|
+
s.run_getdp(solve = True, postOperation = True, gui = gui)
|
|
53
|
+
s.cleanup()
|
|
54
|
+
|
|
55
|
+
def post_process_getdp(self, gui: bool = False):
|
|
56
|
+
"""
|
|
57
|
+
Runs the post-processing steps trough GetDP.
|
|
58
|
+
"""
|
|
59
|
+
os.chdir(self.solution_folder)
|
|
60
|
+
|
|
61
|
+
s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
|
|
62
|
+
s.read_excitation(inputs_folder_path=self.inputs_folder_path)
|
|
63
|
+
# s.get_solution_parameters_from_yaml(inputs_folder_path=self.inputs_folder_path)
|
|
64
|
+
s.assemble_pro()
|
|
65
|
+
s.run_getdp(solve = False, postOperation = True, gui = gui)
|
|
66
|
+
|
|
67
|
+
def post_process_python(self, gui: bool = False):
|
|
68
|
+
"""
|
|
69
|
+
Runs the post-processing steps in the python PostProccess class.
|
|
70
|
+
"""
|
|
71
|
+
os.chdir(self.solution_folder)
|
|
72
|
+
|
|
73
|
+
p = PostProcess(self.solution_folder)
|
|
74
|
+
p.show()
|
|
75
|
+
|
|
76
|
+
return {'test': 0}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import os, cProfile
|
|
2
|
+
|
|
3
|
+
from fiqus.geom_generators.GeometryHomogenizedConductor import Geometry
|
|
4
|
+
from fiqus.mesh_generators.MeshHomogenizedConductor import Mesh
|
|
5
|
+
from fiqus.getdp_runners.RunGetdpHomogenizedConductor import Solve
|
|
6
|
+
from fiqus.post_processors.PostProcessHomogenizedConductor import PostProcess
|
|
7
|
+
|
|
8
|
+
class MainHomogenizedConductor:
|
|
9
|
+
def __init__(self, fdm, inputs_folder_path='', outputs_folder_path='', verbose=True):
|
|
10
|
+
"""
|
|
11
|
+
Main class for working with simulations for the homogenized conductor model.
|
|
12
|
+
:param fdm: FiQuS data model
|
|
13
|
+
:param inputs_folder_path: full path to folder with input files
|
|
14
|
+
:param verbose: if True, more info is printed in the console
|
|
15
|
+
"""
|
|
16
|
+
self.verbose = verbose
|
|
17
|
+
self.fdm = fdm
|
|
18
|
+
self.inputs_folder_path = inputs_folder_path
|
|
19
|
+
self.outputs_folder_path = outputs_folder_path
|
|
20
|
+
self.GetDP_path = None
|
|
21
|
+
self.geom_folder = None
|
|
22
|
+
self.mesh_folder = None
|
|
23
|
+
self.solution_folder = None
|
|
24
|
+
self.model_file = None
|
|
25
|
+
self.model_folder = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def generate_geometry(self, gui=False):
|
|
29
|
+
"""
|
|
30
|
+
Generates the conductor geometry.
|
|
31
|
+
"""
|
|
32
|
+
os.chdir(self.geom_folder)
|
|
33
|
+
g = Geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
|
|
34
|
+
g.generate_geometry()
|
|
35
|
+
g.generate_vi_file(gui)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def load_geometry(self, gui: bool = False):
|
|
39
|
+
"""
|
|
40
|
+
Loads the previously generated geometry from the .brep file.
|
|
41
|
+
"""
|
|
42
|
+
os.chdir(self.geom_folder)
|
|
43
|
+
g = Geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
|
|
44
|
+
g.load_geometry()
|
|
45
|
+
# self.model_file = g.model_file
|
|
46
|
+
|
|
47
|
+
def pre_process(self, gui=False):
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
def mesh(self, gui: bool = False):
|
|
51
|
+
"""
|
|
52
|
+
Generates the mesh for the geometry.
|
|
53
|
+
"""
|
|
54
|
+
os.chdir(self.mesh_folder)
|
|
55
|
+
|
|
56
|
+
m = Mesh(fdm=self.fdm, verbose=self.verbose)
|
|
57
|
+
m.generate_mesh()
|
|
58
|
+
m.generate_cuts()
|
|
59
|
+
m.generate_regions_file()
|
|
60
|
+
m.save_mesh(gui)
|
|
61
|
+
|
|
62
|
+
return {"test": 0}
|
|
63
|
+
|
|
64
|
+
def load_mesh(self, gui=False):
|
|
65
|
+
"""
|
|
66
|
+
Loads the previously generated mesh from the MSH file.
|
|
67
|
+
"""
|
|
68
|
+
os.chdir(self.mesh_folder)
|
|
69
|
+
m = Mesh(fdm=self.fdm, verbose=self.verbose)
|
|
70
|
+
m.load_mesh(gui)
|
|
71
|
+
|
|
72
|
+
# self.model_file = m.mesh_file
|
|
73
|
+
|
|
74
|
+
def solve_and_postprocess_getdp(self, gui: bool = False):
|
|
75
|
+
"""
|
|
76
|
+
Assembles the .pro-file from the template, then runs the simulation and the post-processing steps using GetDP.
|
|
77
|
+
"""
|
|
78
|
+
os.chdir(self.solution_folder)
|
|
79
|
+
|
|
80
|
+
s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
|
|
81
|
+
s.read_excitation(inputs_folder_path=self.inputs_folder_path)
|
|
82
|
+
s.read_ro_parameters(inputs_folder_path=self.inputs_folder_path)
|
|
83
|
+
s.assemble_pro()
|
|
84
|
+
s.run_getdp(solve = True, postOperation = True, gui = gui)
|
|
85
|
+
s.cleanup()
|
|
86
|
+
|
|
87
|
+
def post_process_getdp(self, gui: bool = False):
|
|
88
|
+
"""
|
|
89
|
+
Runs the post-processing steps trough GetDP.
|
|
90
|
+
"""
|
|
91
|
+
os.chdir(self.solution_folder)
|
|
92
|
+
|
|
93
|
+
s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
|
|
94
|
+
s.read_excitation(inputs_folder_path=self.inputs_folder_path)
|
|
95
|
+
s.read_ro_parameters(inputs_folder_path=self.inputs_folder_path)
|
|
96
|
+
s.assemble_pro()
|
|
97
|
+
s.run_getdp(solve = False, postOperation = True, gui = gui)
|
|
98
|
+
|
|
99
|
+
def post_process_python(self, gui: bool = False):
|
|
100
|
+
"""
|
|
101
|
+
Runs the post-processing steps in the python PostProcess class.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
postProc = PostProcess(self.fdm, self.solution_folder)
|
|
105
|
+
postProc.show()
|
|
106
|
+
|
|
107
|
+
return {'test': 0}
|
|
108
|
+
|
|
109
|
+
def batch_post_process_python(self, gui: bool = False):
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
|