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

85 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-12-25 02:54 +0100

1from pydantic import BaseModel, Field 

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

3from fiqus.data.DataRoxieParser import RoxieData 

4from fiqus.data.DataFiQuSCCT import CCTDM 

5from fiqus.data.DataFiQuSMultipole import Multipole 

6from fiqus.data.DataFiQuSPancake3D import Pancake3D 

7from fiqus.data.DataConductor import Conductor 

8from fiqus.data.DataFiQuSConductorAC_Strand import CACStrand 

9 

10 

11class FiQuSGeometry(BaseModel): 

12 """ 

13 Class for Roxie data 

14 """ 

15 

16 Roxie_Data: RoxieData = RoxieData() 

17 

18 

19class RunFiQuS(BaseModel): 

20 """ 

21 Class for FiQuS run 

22 """ 

23 

24 type: Literal[ 

25 "start_from_yaml", 

26 "mesh_only", 

27 "geometry_only", 

28 "geometry_and_mesh", 

29 "pre_process_only", 

30 "mesh_and_solve_with_post_process_python", 

31 "solve_with_post_process_python", 

32 "solve_only", 

33 "post_process_getdp_only", 

34 "post_process_python_only", 

35 "post_process", 

36 "plot_python", 

37 "batch_post_process_python", 

38 ] = Field( 

39 default="start_from_yaml", 

40 title="Run Type of FiQuS", 

41 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.", 

42 ) 

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

44 default=None, 

45 title="Geometry Folder Key", 

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

47 ) 

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

49 default=None, 

50 title="Mesh Folder Key", 

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

52 ) 

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

54 default=None, 

55 title="Solution Folder Key", 

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

57 ) 

58 launch_gui: bool = Field( 

59 default=False, 

60 title="Launch GUI", 

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

62 ) 

63 overwrite: bool = Field( 

64 default=False, 

65 title="Overwrite", 

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

67 ) 

68 comments: str = Field( 

69 default="", 

70 title="Comments", 

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

72 ) 

73 verbosity_Gmsh: int = Field( 

74 default=5, 

75 title="verbosity_Gmsh", 

76 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)", 

77 ) 

78 verbosity_GetDP: int = Field( 

79 default=5, 

80 title="verbosity_GetDP", 

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

82 ) 

83 verbosity_FiQuS: bool = Field( 

84 default=True, 

85 title="verbosity_FiQuS", 

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

87 ) 

88 

89 

90class GeneralFiQuS(BaseModel): 

91 """ 

92 Class for FiQuS general 

93 """ 

94 

95 magnet_name: Optional[str] = None 

96 

97 

98class EnergyExtraction(BaseModel): 

99 """ 

100 Level 3: Class for FiQuS 

101 """ 

102 

103 t_trigger: Optional[float] = None 

104 R_EE: Optional[float] = None 

105 power_R_EE: Optional[float] = None 

106 L: Optional[float] = None 

107 C: Optional[float] = None 

108 

109 

110class QuenchHeaters(BaseModel): 

111 """ 

112 Level 3: Class for FiQuS 

113 """ 

114 

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

116 t_trigger: Optional[List[float]] = None 

117 U0: Optional[List[float]] = None 

118 C: Optional[List[float]] = None 

119 R_warm: Optional[List[float]] = None 

120 w: Optional[List[float]] = None 

121 h: Optional[List[float]] = None 

122 h_ins: List[List[float]] = [] 

123 type_ins: List[List[str]] = [] 

124 h_ground_ins: List[List[float]] = [] 

125 type_ground_ins: List[List[str]] = [] 

126 l: Optional[List[float]] = None 

127 l_copper: Optional[List[float]] = None 

128 l_stainless_steel: Optional[List[float]] = None 

129 ids: Optional[List[int]] = None 

130 turns: Optional[List[int]] = None 

131 turns_sides: Optional[List[str]] = None 

132 

133 

134class Cliq(BaseModel): 

135 """ 

136 Level 3: Class for FiQuS 

137 """ 

138 

139 t_trigger: Optional[float] = None 

140 current_direction: Optional[List[int]] = None 

141 sym_factor: Optional[int] = None 

142 N_units: Optional[int] = None 

143 U0: Optional[float] = None 

144 C: Optional[float] = None 

145 R: Optional[float] = None 

146 L: Optional[float] = None 

147 I0: Optional[float] = None 

148 

149 

150class Circuit(BaseModel): 

151 """ 

152 Level 2: Class for FiQuS 

153 """ 

154 

155 R_circuit: Optional[float] = None 

156 L_circuit: Optional[float] = None 

157 R_parallel: Optional[float] = None 

158 

159 

160class PowerSupply(BaseModel): 

161 """ 

162 Level 2: Class for FiQuS 

163 """ 

164 

165 I_initial: Optional[float] = None 

166 t_off: Optional[float] = None 

167 t_control_LUT: Optional[List[float]] = Field( 

168 default=None, 

169 title="Time Values for Current Source", 

170 description="This list of time values will be matched with the current values in I_control_LUT, and then these (t, I) points will be connected with straight lines.", 

171 ) 

172 I_control_LUT: Optional[List[float]] = Field( 

173 default=None, 

174 title="Current Values for Current Source", 

175 description="This list of current values will be matched with the time values in t_control_LUT, and then these (t, I) points will be connected with straight lines.", 

176 ) 

177 R_crowbar: Optional[float] = None 

178 Ud_crowbar: Optional[float] = None 

179 

180 

181class QuenchProtection(BaseModel): 

182 """ 

183 Level 2: Class for FiQuS 

184 """ 

185 

186 energy_extraction: EnergyExtraction = EnergyExtraction() 

187 quench_heaters: QuenchHeaters = QuenchHeaters() 

188 cliq: Cliq = Cliq() 

189 

190class QuenchDetection(BaseModel): 

191 """ 

192 Level 2: Class for FiQuS 

193 """ 

194 

195 voltage_thresholds: Optional[List[float]] = Field( 

196 default=None, 

197 title="List of quench detection voltage thresholds", 

198 description="Voltage thresholds for quench detection. The quench detection will be triggered when the voltage exceeds these thresholds continuously for a time larger than the discrimination time.", 

199 ) 

200 

201 discrimination_times: Optional[List[float]] = Field( 

202 default=None, 

203 title="List of quench detection discrimination times", 

204 description="Discrimination times for quench detection. The quench detection will be triggered when the voltage exceeds the thresholds continuously for a time larger than these discrimination times.", 

205 ) 

206 

207 voltage_tap_pairs: Optional[List[List[int]]] = Field( 

208 default=None, 

209 title="List of quench detection voltage tap pairs", 

210 description="Voltage tap pairs for quench detection. The voltage difference between these pairs will be used for quench detection.", 

211 ) 

212 

213class FDM(BaseModel): 

214 """ 

215 Class for FiQuS 

216 """ 

217 

218 general: GeneralFiQuS = GeneralFiQuS() 

219 run: RunFiQuS = RunFiQuS() 

220 magnet: Union[Multipole, CCTDM, Pancake3D, CACStrand] = Field( 

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

222 ) 

223 circuit: Circuit = Circuit() 

224 power_supply: PowerSupply = PowerSupply() 

225 quench_protection: QuenchProtection = QuenchProtection() 

226 quench_detection: QuenchDetection = QuenchDetection() 

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