Coverage for fiqus/mains/MainConductorAC_Rutherford.py: 76%

41 statements  

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

1import math 

2import os 

3 

4from fiqus.geom_generators.GeometryConductorAC_Rutherford import Geometry 

5from fiqus.mesh_generators.MeshConductorAC_Rutherford import CableMesh 

6from fiqus.getdp_runners.RunGetdpConductorAC_Rutherford import Solve 

7from fiqus.post_processors.PostProcessAC_Rutherford import PostProcess 

8from fiqus.plotters.PlotPythonConductorAC import PlotPythonConductorAC 

9 

10from fiqus.mains.MainConductorAC_Strand import MainConductorAC_Strand 

11 

12class 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}