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

46 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2026-01-09 01:49 +0000

1from pydantic import BaseModel, Field 

2from typing import Dict, List, Union, Literal, Optional, Any 

3 

4from fiqus.data.DataModelCommon import EnergyExtraction, CLIQ_Class, ESC_Class, E_CLIQ_Class, QuenchDetection, Circuit_Class, PowerSupplyClass, QuenchHeater 

5from fiqus.data.DataConductor import Conductor 

6from fiqus.data.DataFiQuSCCT import CCT 

7from fiqus.data.DataFiQuSMultipole import Multipole 

8from fiqus.data.DataFiQuSPancake3D import Pancake3D 

9from fiqus.data.DataFiQuSConductorAC_Strand import CACStrand 

10from fiqus.data.DataFiQuSHomogenizedConductor import HomogenizedConductor 

11from fiqus.data.DataFiQuSConductorAC_Rutherford import CACRutherford 

12from fiqus.data.DataFiQuSConductorAC_CC import CACCC 

13 

14class RunFiQuS(BaseModel): 

15 """ 

16 Class for FiQuS run 

17 """ 

18 

19 type: Literal[ 

20 "start_from_yaml", 

21 "mesh_only", 

22 "geometry_only", 

23 "geometry_and_mesh", 

24 "pre_process_only", 

25 "mesh_and_solve_with_post_process_python", 

26 "solve_with_post_process_python", 

27 "solve_only", 

28 "post_process_getdp_only", 

29 "post_process_python_only", 

30 "post_process", 

31 "plot_python", 

32 "batch_post_process_python", 

33 "only_create_pro_file_from_mesh", 

34 "postprocess_veusz" 

35 ] = Field( 

36 default="start_from_yaml", 

37 title="Run Type of FiQuS", 

38 description="FiQuS allows you to run the model in different ways. The run type can be specified here. For example, you can just create the geometry and mesh or just solve the model with previous mesh, etc.", 

39 ) 

40 geometry: Optional[Union[str, int]] = Field( 

41 default=None, 

42 title="Geometry Folder Key", 

43 description="This key will be appended to the geometry folder.", 

44 ) 

45 mesh: Optional[Union[str, int]] = Field( 

46 default=None, 

47 title="Mesh Folder Key", 

48 description="This key will be appended to the mesh folder.", 

49 ) 

50 solution: Optional[Union[str, int]] = Field( 

51 default=None, 

52 title="Solution Folder Key", 

53 description="This key will be appended to the solution folder.", 

54 ) 

55 launch_gui: bool = Field( 

56 default=False, 

57 title="Launch GUI", 

58 description="If True, the GUI will be launched after the run.", 

59 ) 

60 overwrite: bool = Field( 

61 default=False, 

62 title="Overwrite", 

63 description="If True, the existing folders will be overwritten, otherwise new folders will be created. NOTE: This setting has no effect for HTCondor runs.", 

64 ) 

65 comments: str = Field( 

66 default="", 

67 title="Comments", 

68 description="Comments for the run. These comments will be saved in the run_log.csv file.", 

69 ) 

70 verbosity_Gmsh: int = Field( 

71 default=5, 

72 title="verbosity_Gmsh", 

73 description="Level of information printed on the terminal and the message console (0: silent except for fatal errors, 1: +errors, 2: +warnings, 3: +direct, 4: +information, 5: +status, 99: +debug)", 

74 ) 

75 verbosity_GetDP: int = Field( 

76 default=5, 

77 title="verbosity_GetDP", 

78 description="Level of information printed on the terminal and the message console. Higher number prints more, good options are 5 or 6.", 

79 ) 

80 verbosity_FiQuS: bool = Field( 

81 default=True, 

82 title="verbosity_FiQuS", 

83 description="Level of information printed on the terminal and the message console by FiQuS. Only True of False for now.", 

84 ) 

85 

86 

87class GeneralFiQuS(BaseModel): 

88 """ 

89 Class for FiQuS general 

90 """ 

91 

92 magnet_name: Optional[str] = None 

93 

94 

95# class QuenchHeaters(BaseModel): 

96# """ 

97# Level 3: Class for FiQuS 

98# """ 

99 

100# N_strips: Optional[int] = None # set to 0 to avoid building quench heater thin shells 

101# t_trigger: Optional[List[float]] = None 

102# U0: Optional[List[float]] = None 

103# C: Optional[List[float]] = None 

104# R_warm: Optional[List[float]] = None 

105# w: Optional[List[float]] = None 

106# h: Optional[List[float]] = None 

107# h_ins: List[List[float]] = [] 

108# type_ins: List[List[str]] = [] 

109# h_ground_ins: List[List[float]] = [] 

110# type_ground_ins: List[List[str]] = [] 

111# l: Optional[List[float]] = None 

112# l_copper: Optional[List[float]] = None 

113# l_stainless_steel: Optional[List[float]] = None 

114# ids: Optional[List[int]] = None 

115# turns: Optional[List[int]] = None 

116# turns_sides: Optional[List[str]] = None 

117 

118 

119 

120class QuenchProtection(BaseModel): 

121 """ 

122 Level 2: Class for FiQuS 

123 """ 

124 

125 energy_extraction: EnergyExtraction = EnergyExtraction() 

126 quench_heaters: QuenchHeater = QuenchHeater() 

127 cliq: CLIQ_Class = CLIQ_Class() 

128 esc: ESC_Class = ESC_Class() 

129 e_cliq: E_CLIQ_Class = E_CLIQ_Class() 

130 

131 

132class SolveDumpDataModel(BaseModel): 

133 solve: Any # this is populated with magnet.solve section in MainFiQuS when dumping the yaml file for reference. The is no information on type in the solve section, so going for "Any" here 

134 circuit: Circuit_Class = Circuit_Class() 

135 power_supply: PowerSupplyClass = PowerSupplyClass() 

136 quench_protection: QuenchProtection = QuenchProtection() 

137 quench_detection: QuenchDetection = QuenchDetection() 

138 conductors: Dict[Optional[str], Conductor] = {} 

139 

140 

141class FDM(BaseModel): 

142 """ 

143 Class for FiQuS 

144 """ 

145 

146 general: GeneralFiQuS = GeneralFiQuS() 

147 run: RunFiQuS = RunFiQuS() 

148 magnet: Union[Multipole, CCT, Pancake3D, CACStrand, HomogenizedConductor, CACRutherford, CACCC] = Field( 

149 default=Multipole(), discriminator="type" 

150 ) 

151 circuit: Circuit_Class = Circuit_Class() 

152 power_supply: PowerSupplyClass = PowerSupplyClass() 

153 quench_protection: QuenchProtection = QuenchProtection() 

154 quench_detection: QuenchDetection = QuenchDetection() 

155 conductors: Dict[Optional[str], Conductor] = {}