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

156 statements  

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

1from pydantic import BaseModel 

2from typing import Dict, List, Tuple, Optional 

3 

4 

5class Coord(BaseModel): 

6 x: Optional[float] = None 

7 y: Optional[float] = None 

8 

9 

10class Area(BaseModel): 

11 loop: Optional[int] = None 

12 surface: Optional[int] = None 

13 

14 

15class Region(BaseModel): 

16 points: Dict[str, int] = {} 

17 lines: Dict[str, int] = {} 

18 areas: Dict[str, Area] = {} 

19 

20 

21# class CableInsulated(BaseModel): 

22# type: #Literal['Insulated'] 

23# insulated: Region = Region() 

24# 

25# 

26# class CableBare(BaseModel): 

27# type: #Literal['Bare'] 

28# bare: Region = Region() 

29# insulation: Region = Region() 

30 

31 

32class BlockData(BaseModel): 

33 half_turns: Region = ( 

34 Region() 

35 ) # Union[CableInsulated, CableBare] = {'type': 'Insulated'} 

36 insulation: Region = Region() 

37 current_sign: Optional[int] = None 

38 

39 

40class Block(BaseModel): 

41 blocks: Dict[int, BlockData] = {} 

42 conductor_name: Optional[str] = None 

43 conductors_number: Optional[int] = None 

44 

45 

46class Winding(BaseModel): 

47 windings: Dict[int, Block] = {} 

48 

49 

50class Layer(BaseModel): 

51 layers: Dict[int, Winding] = {} 

52 

53 

54class Pole(BaseModel): 

55 poles: Dict[int, Layer] = {} 

56 type: Optional[str] = None 

57 bore_center: Coord = Coord() 

58 

59 

60class Order(BaseModel): 

61 coil: Optional[int] = None 

62 pole: Optional[int] = None 

63 layer: Optional[int] = None 

64 winding: Optional[int] = None 

65 block: Optional[int] = None 

66 

67 

68class AnticlockwiseOrder(BaseModel): 

69 pole: Optional[int] = None 

70 winding: Optional[int] = None 

71 block: Optional[int] = None 

72 

73 

74class MidLayer(BaseModel): 

75 half_turn_lists: Dict[str, List[int]] = {} 

76 point_angles: Dict[str, float] = {} 

77 mid_layers: Region = Region() 

78 

79 

80class Iron(BaseModel): 

81 quadrants: Dict[int, Region] = {} 

82 max_radius: float = 0.0 

83 

84 

85class LayerOrder(BaseModel): 

86 layers: Dict[int, List[AnticlockwiseOrder]] = {} 

87 

88 

89class CoilOrder(BaseModel): 

90 coils: Dict[int, LayerOrder] = {} 

91 

92 

93class Coil(BaseModel): 

94 coils: Dict[int, Pole] = {} 

95 physical_order: List[Order] = [] 

96 anticlockwise_order: CoilOrder = CoilOrder() 

97 concentric_coils: Dict[Tuple[float, float], List[int]] = {} 

98 max_radius: float = 0.0 

99 

100 

101class InsulationThickness(BaseModel): 

102 mid_pole: Dict[str, float] = {} 

103 mid_layer: Dict[str, float] = {} 

104 mid_winding: Dict[str, float] = {} 

105 

106 

107class ThinShell(BaseModel): 

108 mid_layers_ht_to_ht: Dict[str, MidLayer] = {} 

109 mid_layers_wdg_to_ht: Dict[str, Region] = {} 

110 mid_layers_ht_to_wdg: Dict[str, Region] = {} 

111 mid_layers_wdg_to_wdg: Dict[str, Region] = {} 

112 mid_poles: Dict[str, Region] = {} 

113 mid_windings: Dict[str, Region] = {} 

114 mid_turn_blocks: Dict[str, Region] = {} 

115 mid_wedge_turn: Dict[str, Region] = {} 

116 mid_layers_aux: Dict[str, Region] = {} 

117 ins_thickness: InsulationThickness = InsulationThickness() 

118 

119 

120class WedgeRegion(BaseModel): 

121 wedges: Dict[int, Region] = {} 

122 block_prev: Dict[int, int] = {} 

123 block_next: Dict[int, int] = {} 

124 

125 

126class WedgeLayer(BaseModel): 

127 layers: Dict[int, WedgeRegion] = {} 

128 

129 

130class Wedge(BaseModel): 

131 coils: Dict[int, WedgeLayer] = {} 

132 

133 

134class InsulationRegion(BaseModel): 

135 ins: Region = Region() 

136 blocks: List[List[int]] = [] 

137 wedges: List[List[int]] = [] 

138 

139 

140class InsulationGroup(BaseModel): 

141 group: Dict[int, InsulationRegion] = {} 

142 

143 

144class Insulation(BaseModel): 

145 coils: Dict[int, InsulationGroup] = {} 

146 

147 

148class Geometry(BaseModel): 

149 coil: Coil = Coil() 

150 iron: Iron = Iron() 

151 wedges: Wedge = Wedge() 

152 air: Region = Region() 

153 air_inf: Region = Region() 

154 symmetric_boundaries: Region = Region() 

155 thin_shells: ThinShell = ThinShell() 

156 insulation: Insulation = Insulation() 

157 

158 

159# Domain classes # 

160class MidLayerLine(BaseModel): 

161 inner: Dict[str, int] = {} 

162 outer: Dict[str, int] = {} 

163 

164 

165class GroupType(BaseModel): 

166 curves: Dict[str, int] = {} 

167 surfaces: Dict[str, int] = {} 

168 

169 

170class PoweredGroup(BaseModel): 

171 tag: Optional[int] = None 

172 group: Optional[str] = None 

173 lines: Dict[str, int] = {} 

174 mid_layer_lines: MidLayerLine = MidLayerLine() 

175 mid_pole_lines: Dict[str, int] = {} 

176 mid_winding_lines: Dict[str, int] = {} 

177 mid_turn_lines: Dict[str, int] = {} 

178 aux_lines: Dict[str, int] = {} 

179 

180 

181class WedgeGroup(BaseModel): 

182 tag: Optional[int] = None 

183 group: Optional[str] = None 

184 lines: Dict[str, int] = {} 

185 mid_layer_lines: MidLayerLine = MidLayerLine() 

186 mid_turn_lines: Dict[str, int] = {} 

187 aux_lines: Dict[str, int] = {} 

188 

189 

190class PoweredBlock(BaseModel): 

191 half_turns: Dict[int, PoweredGroup] = {} 

192 current_sign: Optional[int] = None 

193 conductor: Optional[str] = None 

194 

195 

196class SymmetryGroup(BaseModel): 

197 normal_free: Optional[int] = None 

198 tangential_free: Optional[int] = None 

199 

200 

201class PhysicalGroup(BaseModel): 

202 blocks: Dict[int, PoweredBlock] = {} 

203 wedges: Dict[int, WedgeGroup] = {} 

204 insulations: GroupType = GroupType() 

205 iron: GroupType = GroupType() 

206 air_inf: Optional[int] = None 

207 air_inf_bnd: Optional[int] = None 

208 air: Optional[int] = None 

209 symmetric_boundaries: SymmetryGroup = SymmetryGroup() 

210 half_turns_points: Optional[int] = None 

211 

212 

213class SymmetryBoundaries(BaseModel): 

214 x: List[int] = [] 

215 y: List[int] = [] 

216 

217 

218class GroupEntities(BaseModel): 

219 iron: Dict[str, List[int]] = {} 

220 air: List[int] = [] 

221 symmetric_boundaries: SymmetryBoundaries = SymmetryBoundaries() 

222 

223 

224class Domain(BaseModel): 

225 groups_entities: GroupEntities = GroupEntities() 

226 physical_groups: PhysicalGroup = PhysicalGroup() 

227 

228 

229class MultipoleData(BaseModel): 

230 geometries: Geometry = Geometry() 

231 domains: Domain = Domain() 

232 

233 

234####################################### 

235 

236 

237class NeighbourNode(BaseModel): 

238 groups: Dict[str, List[float]] = {} 

239 

240 

241class IsothermalNodes(BaseModel): 

242 conductors: Dict[str, Dict[int, List[float]]] = {} 

243 wedges: Dict[str, Dict[int, List[float]]] = {} 

244 thin_shells: Dict[int, List[float]] = {} 

245 

246 

247class MultipoleRegionCoordinate(BaseModel): 

248 isothermal_nodes: IsothermalNodes = IsothermalNodes() 

249 neighbouring_nodes: NeighbourNode = NeighbourNode() 

250 

251 

252# if __name__ == "__main__": 

253# write = True 

254# read = False 

255# 

256# def read_regions(regions_file_name): 

257# with open(regions_file_name, 'r') as stream: 

258# yaml_str = ruamel.yaml.safe_load(stream) 

259# return MultipoleData(**yaml_str) 

260# 

261# if write: 

262# model = MultipoleData() 

263# with open('FiQuS_data.yaml', 'w') as yaml_file: 

264# ruamel.yaml.dump(model.dict(), yaml_file, default_flow_style=False)