@@ -1322,7 +1322,10 @@ def write_simulation_parameters_to_pro_files(self):
13221322 logger .info ("Write simulation parameters to .pro files (file communication)." )
13231323
13241324 # Write initialization parameters for simulation in 'Parameter.pro' file
1325- self .write_electro_magnetic_parameter_pro ()
1325+ if self .simulation_type == SimulationType .ElectroStatic :
1326+ self .write_electro_static_parameter_pro ()
1327+ else :
1328+ self .write_electro_magnetic_parameter_pro ()
13261329
13271330 # Write postprocessing parameters in 'postquantities.pro' file
13281331 self .write_electro_magnetic_post_pro ()
@@ -3458,20 +3461,10 @@ def write_electro_magnetic_parameter_pro(self):
34583461 text_file .write ("Flag_Time_Domain = 1;\n " )
34593462 text_file .write ("Flag_Freq_Domain = 0;\n " )
34603463 text_file .write ("Flag_Static = 0;\n " )
3461- if self .simulation_type == SimulationType .ElectroStatic :
3462- text_file .write ("Flag_Static = 1;\n " )
3463- text_file .write ("Flag_Freq_Domain = 0;\n " )
3464- text_file .write ("Flag_Time_Domain = 0;\n " )
3465-
3466- # Airgap number
3467- if self .simulation_type == SimulationType .ElectroStatic :
3468- text_file .write ("n_airgaps = {};\n " .format (len (self .air_gaps .midpoints )))
3469-
3470- # Frequency
3471- if not self .simulation_type == SimulationType .ElectroStatic :
3472- text_file .write ("Freq = %s;\n " % self .frequency )
3473- text_file .write (f"delta = { self .delta } ;\n " )
34743464
3465+ # Frequency
3466+ text_file .write ("Freq = %s;\n " % self .frequency )
3467+ text_file .write (f"delta = { self .delta } ;\n " )
34753468 # time domain parameters
34763469 if self .simulation_type == SimulationType .TimeDomain :
34773470 text_file .write (f"T = { self .time_period } ;\n " )
@@ -3503,8 +3496,6 @@ def write_electro_magnetic_parameter_pro(self):
35033496 winding_number = winding_number )
35043497
35053498 if self .windings [winding_number ].parallel :
3506- if self .simulation_type == SimulationType .ElectroStatic :
3507- raise Exception ("Parallel winding are not considered yet for electrostatic simulation" )
35083499 text_file .write (f"NbrCond_{ winding_number + 1 } = 1;\n " )
35093500 text_file .write (f"AreaCell_{ winding_number + 1 } = { self .windings [winding_number ].a_cell * turns } ;\n " )
35103501 else :
@@ -3551,32 +3542,6 @@ def write_electro_magnetic_parameter_pro(self):
35513542 text_file .write (f"Val_EE_{ winding_number + 1 } = { self .current_density [winding_number ]} ;\n " )
35523543 raise NotImplementedError
35533544
3554- if self .simulation_type == SimulationType .ElectroStatic :
3555- if self .voltage is not None :
3556- text_file .write ("Flag_voltage = 1;\n " )
3557- text_file .write ("Flag_charge = 0;\n " )
3558- turns = self .voltage [winding_number ]
3559- for turn_index , voltage_value in enumerate (turns ):
3560- text_file .write (f"Voltage_{ winding_number + 1 } _{ turn_index + 1 } = { voltage_value } ;\n " )
3561- elif self .charge is not None :
3562- text_file .write ("Flag_charge = 1;\n " )
3563- text_file .write ("Flag_voltage = 0;\n " )
3564- turns = self .charge [winding_number ]
3565- for turn_index , charge_value in enumerate (turns ):
3566- text_file .write (f"Charge_{ winding_number + 1 } _{ turn_index + 1 } = { charge_value } ;\n " )
3567-
3568- if self .v_core is not None :
3569- text_file .write ("v_core = {};\n " .format (self .v_core ))
3570- text_file .write ("Flag_excite_core = 1;\n " )
3571- else :
3572- text_file .write ("Flag_excite_core = 0;\n " )
3573-
3574- if self .v_ground_out_boundary == 0 :
3575- text_file .write ("Flag_ground_OutBoundary = 1;\n " )
3576- text_file .write ("v_ground_OutBoundary = 0;\n " )
3577- else :
3578- text_file .write ("Flag_ground_OutBoundary = 0;\n " )
3579-
35803545 logger .info (f"Cell surface area: { self .windings [winding_number ].a_cell } , "
35813546 f"Reduced frequency: { self .red_freq [winding_number ]} " )
35823547
@@ -3601,35 +3566,123 @@ def write_electro_magnetic_parameter_pro(self):
36013566 text_file .write ("er_layer_insulation = 1.0;\n " )
36023567 text_file .write (f"er_bobbin = { self .insulation .er_bobbin } ;\n " )
36033568
3604- if not self .simulation_type == SimulationType .ElectroStatic :
3605- # Core Material
3606- text_file .write (f"mur = { self .core .material .mu_r_abs } ;\n " ) # mur is predefined to a fixed value
3607- if self .core .material .permeability_type == PermeabilityType .FromData :
3608- text_file .write ("Flag_Permeability_From_Data = 1;\n " ) # mur is predefined to a fixed value
3569+ # Core Material
3570+ text_file .write (f"mur = { self .core .material .mu_r_abs } ;\n " ) # mur is predefined to a fixed value
3571+ if self .core .material .permeability_type == PermeabilityType .FromData :
3572+ text_file .write ("Flag_Permeability_From_Data = 1;\n " ) # mur is predefined to a fixed value
3573+ else :
3574+ text_file .write ("Flag_Permeability_From_Data = 0;\n " ) # mur is predefined to a fixed value
3575+ if self .core .material .permeability_type == PermeabilityType .FixedLossAngle :
3576+ # Real part of complex permeability
3577+ text_file .write (f"mur_real = { self .core .material .mu_r_abs * np .cos (np .deg2rad (self .core .material .phi_mu_deg ))} ;\n " )
3578+ # Imaginary part of complex permeability
3579+ text_file .write (
3580+ f"mur_imag = { self .core .material .mu_r_abs * np .sin (np .deg2rad (self .core .material .phi_mu_deg ))} ;\n " )
3581+ # loss angle for complex representation of hysteresis loss
3582+ text_file .write ("Flag_Fixed_Loss_Angle = 1;\n " )
3583+ else :
3584+ text_file .write (
3585+ "Flag_Fixed_Loss_Angle = 0;\n " ) # loss angle for complex representation of hysteresis loss
3586+
3587+ # Complex (equivalent) conductivity
3588+ self .core .material .complex_conductance = \
3589+ self .core .material .dc_conductivity + complex (0 , 1 ) * 2 * np .pi * self .frequency * self .core .material .complex_permittivity
3590+ if self .core .material .complex_conductance != 0 and self .core .material .complex_conductance is not None :
3591+ text_file .write ("Flag_Conducting_Core = 1;\n " )
3592+ text_file .write (f"sigma_core_real = { self .core .material .complex_conductance .real } ;\n " )
3593+ text_file .write (f"sigma_core_imag = { self .core .material .complex_conductance .imag } ;\n " )
3594+ else :
3595+ text_file .write ("Flag_Conducting_Core = 0;\n " )
3596+
3597+ text_file .close ()
3598+
3599+ def write_electro_static_parameter_pro (self ):
3600+ """
3601+ Write the needed parameters to the "ElectrostaticParameter.pro" file.
3602+
3603+ This file is generated by python and is read by gmsh to hand over some parameters.
3604+ """
3605+ text_file = open (os .path .join (self .file_data .electro_magnetic_folder_path , "ElectrostaticParameter.pro" ), "w" )
3606+
3607+ # component types
3608+ if self .component_type == ComponentType .Inductor :
3609+ text_file .write ("Number_of_Windings = {};\n " .format (len (self .windings )))
3610+
3611+ if self .component_type == ComponentType .Transformer :
3612+ text_file .write ("Number_of_Windings = {};\n " .format (len (self .windings )))
3613+
3614+ if self .component_type == ComponentType .IntegratedTransformer :
3615+ text_file .write ("Number_of_Windings = {};\n " .format (len (self .windings )))
3616+
3617+ text_file .write ("Flag_Static = 1;\n " )
3618+
3619+ # Airgap number
3620+ text_file .write ("n_airgaps = {};\n " .format (len (self .air_gaps .midpoints )))
3621+
3622+ # Conductor specific definitions
3623+ for winding_number in range (len (self .windings )):
3624+ # -- Geometry --
3625+ # Core Parts
3626+ text_file .write (f"nCoreParts = { len (self .mesh .plane_surface_core )} ;\n " )
3627+
3628+ turns = ff .get_number_of_turns_of_winding (winding_windows = self .winding_windows , windings = self .windings ,
3629+ winding_number = winding_number )
3630+
3631+ if self .windings [winding_number ].parallel :
3632+ raise Exception ("Parallel winding are not considered yet for electrostatic simulation" )
36093633 else :
3610- text_file .write ("Flag_Permeability_From_Data = 0;\n " ) # mur is predefined to a fixed value
3611- if self .core .material .permeability_type == PermeabilityType .FixedLossAngle :
3612- # Real part of complex permeability
3613- text_file .write (f"mur_real = { self .core .material .mu_r_abs * np .cos (np .deg2rad (self .core .material .phi_mu_deg ))} ;\n " )
3614- # Imaginary part of complex permeability
3615- text_file .write (
3616- f"mur_imag = { self .core .material .mu_r_abs * np .sin (np .deg2rad (self .core .material .phi_mu_deg ))} ;\n " )
3617- # loss angle for complex representation of hysteresis loss
3618- text_file .write ("Flag_Fixed_Loss_Angle = 1;\n " )
3634+ text_file .write (f"NbrCond_{ winding_number + 1 } = { turns } ;\n " )
3635+ text_file .write (f"AreaCell_{ winding_number + 1 } = { self .windings [winding_number ].a_cell } ;\n " )
3636+
3637+ # relative permittivity
3638+ # Turn insulation is not implemented yet for RectangularSolid
3639+ # Or if the turn insulation is not drawn
3640+ if self .windings [winding_number ].conductor_type == ConductorType .RectangularSolid or not self .insulation .turn_ins :
3641+ text_file .write (f"er_turns_insulation_{ winding_number + 1 } = 1.0;\n " )
36193642 else :
3620- text_file .write (
3621- "Flag_Fixed_Loss_Angle = 0;\n " ) # loss angle for complex representation of hysteresis loss
3622-
3623- # Complex (equivalent) conductivity
3624- self .core .material .complex_conductance = \
3625- self .core .material .dc_conductivity + complex (0 , 1 ) * 2 * np .pi * self .frequency * self .core .material .complex_permittivity
3626- if self .core .material .complex_conductance != 0 and self .core .material .complex_conductance is not None :
3627- text_file .write ("Flag_Conducting_Core = 1;\n " )
3628- text_file .write (f"sigma_core_real = { self .core .material .complex_conductance .real } ;\n " )
3629- text_file .write (f"sigma_core_imag = { self .core .material .complex_conductance .imag } ;\n " )
3643+ text_file .write (f"er_turns_insulation_{ winding_number + 1 } = { self .insulation .er_turn_insulation [winding_number ]} ;\n " )
3644+
3645+ # For stranded Conductors:
3646+ # text_file.write(f"NbrstrandedCond = {self.turns};\n") # redundant
3647+ if self .windings [winding_number ].conductor_type == ConductorType .RoundLitz :
3648+ raise Exception ("RoundLitz conductor type not yet implemented for electrostatic simulation" )
3649+
3650+ # could be needed in future
3651+ text_file .write (f"Rc_{ winding_number + 1 } = { self .windings [winding_number ].conductor_radius } ;\n " )
3652+
3653+ if self .voltage is not None :
3654+ text_file .write ("Flag_voltage = 1;\n " )
3655+ text_file .write ("Flag_charge = 0;\n " )
3656+ turns = self .voltage [winding_number ]
3657+ for turn_index , voltage_value in enumerate (turns ):
3658+ text_file .write (f"Voltage_{ winding_number + 1 } _{ turn_index + 1 } = { voltage_value } ;\n " )
3659+ elif self .charge is not None :
3660+ text_file .write ("Flag_charge = 1;\n " )
3661+ text_file .write ("Flag_voltage = 0;\n " )
3662+ turns = self .charge [winding_number ]
3663+ for turn_index , charge_value in enumerate (turns ):
3664+ text_file .write (f"Charge_{ winding_number + 1 } _{ turn_index + 1 } = { charge_value } ;\n " )
3665+
3666+ if self .v_core is not None :
3667+ text_file .write ("v_core = {};\n " .format (self .v_core ))
3668+ text_file .write ("Flag_excite_core = 1;\n " )
36303669 else :
3631- text_file .write ("Flag_Conducting_Core = 0;\n " )
3670+ text_file .write ("Flag_excite_core = 0;\n " )
36323671
3672+ if self .v_ground_out_boundary == 0 :
3673+ text_file .write ("Flag_ground_OutBoundary = 1;\n " )
3674+ text_file .write ("v_ground_OutBoundary = 0;\n " )
3675+ else :
3676+ text_file .write ("Flag_ground_OutBoundary = 0;\n " )
3677+
3678+ # Nature Constants
3679+ text_file .write (f"e0 = { epsilon_0 } ;\n " )
3680+ text_file .write (f"er_core= { self .core .material .eps_r } ;\n " )
3681+ if self .insulation .er_layer_insulation is not None :
3682+ text_file .write (f"er_layer_insulation = { self .insulation .er_layer_insulation } ;\n " )
3683+ else :
3684+ text_file .write ("er_layer_insulation = 1.0;\n " )
3685+ text_file .write (f"er_bobbin = { self .insulation .er_bobbin } ;\n " )
36333686 text_file .close ()
36343687
36353688 def write_electro_magnetic_post_pro (self ):
0 commit comments