@@ -1317,7 +1317,7 @@ def simulate(self):
13171317 gmsh .fltk .run ()
13181318 else :
13191319 self .onelab_client .runSubClient ("myGetDP" , getdp_filepath + " " + solver_freq + " -msh " + \
1320- self .file_data .e_m_mesh_file + " -solve Analysis -v2 " + verbose + to_file_str )
1320+ self .file_data .e_m_mesh_file + " -solve Analysis -v2" + verbose + to_file_str )
13211321 if self .simulation_type == SimulationType .TimeDomain :
13221322 if self .visualization_mode == VisualizationMode .Stream :
13231323 # 1) Start GUI
@@ -1331,12 +1331,23 @@ def simulate(self):
13311331 else :
13321332 # the two commands work but some changes should be done in fields_time.pro
13331333 self .onelab_client .runSubClient ("myGetDP" , getdp_filepath + " " + solver_time + " -msh " + self .file_data .e_m_mesh_file + \
1334- " -solve Analysis -pos Map_local " + verbose + to_file_str )
1335- # self.onelab_client.runSubClient("myGetDP", getdp_filepath + " " + solver + " -msh " + self.file_data.e_m_mesh_file +
1336- # " -solve Analysis -v2 " + verbose) # freeing solutions
1334+ " -solve Analysis -pos Map_local " + verbose + to_file_str )
13371335 if self .simulation_type == SimulationType .ElectroStatic :
1338- self .onelab_client .runSubClient ("myGetDP" , getdp_filepath + " " + solver_electrostatic + " -msh " + \
1339- self .file_data .e_m_mesh_file + " -solve EleSta_v -v2 " + verbose + to_file_str )
1336+ if self .visualization_mode == VisualizationMode .Stream :
1337+ if not gmsh .isInitialized ():
1338+ gmsh .initialize ()
1339+ if '-nopopup' not in sys .argv :
1340+ gmsh .fltk .initialize ()
1341+ gmsh .onelab .run ("myGetDP" , getdp_filepath + " " + solver_electrostatic + " -msh " + \
1342+ self .file_data .e_m_mesh_file + " -solve EleSta_v -pos Get_global" + verbose + to_file_str )
1343+ gmsh .fltk .run ()
1344+ elif self .visualization_mode == VisualizationMode .Post :
1345+ gmsh .onelab .run ("myGetDP" , getdp_filepath + " " + solver_electrostatic + " -msh " + \
1346+ self .file_data .e_m_mesh_file + " -solve EleSta_v -v2" + verbose + to_file_str )
1347+ gmsh .fltk .run ()
1348+ else :
1349+ self .onelab_client .runSubClient ("myGetDP" , getdp_filepath + " " + solver_electrostatic + " -msh " + \
1350+ self .file_data .e_m_mesh_file + " -solve EleSta_v -v2" + verbose + to_file_str )
13401351
13411352 def write_simulation_parameters_to_pro_files (self ):
13421353 """
@@ -1594,9 +1605,9 @@ def electrostatic_simulation(self, voltage: list[list[float]] = None, charge: li
15941605 ff .json_to_excel (json_file_path , output_excel_path )
15951606 logger .info (f"Data has been successfully written to { output_excel_path } " )
15961607 logging_time = time .time () - start_time
1597-
1598- if show_fem_simulation_results :
1599- self .visualize ()
1608+ if self . visualization_mode == VisualizationMode . Final :
1609+ if show_fem_simulation_results :
1610+ self .visualize ()
16001611
16011612 return generate_electro_magnetic_mesh_time , prepare_simulation_time , real_simulation_time , logging_time
16021613 else :
@@ -1613,8 +1624,9 @@ def electrostatic_simulation(self, voltage: list[list[float]] = None, charge: li
16131624 ff .json_to_excel (json_file_path , output_excel_path )
16141625 logger .info (f"Data has been successfully written to { output_excel_path } " )
16151626
1616- if show_fem_simulation_results :
1617- self .visualize ()
1627+ if self .visualization_mode == VisualizationMode .Final :
1628+ if show_fem_simulation_results :
1629+ self .visualize ()
16181630
16191631 logger .info (f"The electrostatic results are stored here: { self .file_data .electrostatic_results_log_path } " )
16201632
@@ -2957,8 +2969,9 @@ def get_inductance_from_reluctance(self):
29572969
29582970 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29592971 # Post-Processing --- Capacitance extraction---
2960- def get_capacitance_of_inductor_component (self , freq_for_mesh : float = 0.0 , show_visual_outputs : bool = False , plot_interpolation : bool = False ,
2961- show_fem_simulation_results : bool = False , benchmark : bool = False , save_to_excel : bool = False ):
2972+ def get_capacitance_of_inductor_component (self , freq_for_mesh : float = 0.0 , show_visual_outputs : bool = False , show_equivalent_circuit : bool = False ,
2973+ plot_interpolation : bool = False , show_fem_simulation_results : bool = False , benchmark : bool = False ,
2974+ save_to_excel : bool = False ):
29622975 """
29632976 Needed for finding parasitic capacitance of an inductor. A represent the first turn, B represents the last turn. e represents the core.
29642977
@@ -2978,6 +2991,8 @@ def get_capacitance_of_inductor_component(self, freq_for_mesh: float = 0.0, show
29782991 :type freq_for_mesh: float = 0.0
29792992 :param show_visual_outputs: show the electrostatic model before simulation
29802993 :type show_visual_outputs: bool, optional
2994+ :param show_equivalent_circuit: show the equivalent circuit of inductor
2995+ :type show_equivalent_circuit: bool
29812996 :param plot_interpolation: if True, plot the interpolation between the provided values for the material.
29822997 :type plot_interpolation: bool
29832998 :param show_fem_simulation_results: if True, show the simulation results after the simulation has finished
@@ -3031,6 +3046,14 @@ def get_capacitance_of_inductor_component(self, freq_for_mesh: float = 0.0, show
30313046 c_ab_stray = c_ab + (c_ae * c_be ) / (c_ae + c_be )
30323047 logger .info (f"→ C_AB (incl. parasitic): { c_ab_stray :.4e} F" )
30333048
3049+ if show_equivalent_circuit :
3050+ d = ff .draw_capacitive_equivalent_circuit_of_inductor (c_vec )
3051+ d .draw ()
3052+ os .makedirs (self .file_data .e_m_values_folder_path , exist_ok = True )
3053+ figure_path = os .path .join (self .file_data .e_m_values_folder_path , "capacitive_equivalent_circuit_of_inductor.pdf" )
3054+ d .save (figure_path )
3055+ logger .info (f"Equivalent circuit saved to { figure_path } " )
3056+
30343057 return c_vec
30353058
30363059 def get_stray_capacitance_of_inductor_component (self , freq_for_mesh : float = 0.0 , show_visual_outputs : bool = False , plot_interpolation : bool = False ,
@@ -3098,9 +3121,9 @@ def get_stray_capacitance_of_inductor_component(self, freq_for_mesh: float = 0.0
30983121
30993122 def get_capacitance_of_transformer (self , freq_for_mesh : float = 0.0 , c_meas_open : float | None = None ,
31003123 c_meas_short : float | None = None , measured_capacitances : tuple | list | None = None ,
3101- flip_the_sec_terminal : bool = False , show_visual_outputs : bool = False , plot_interpolation : bool = False ,
3102- show_fem_simulation_results : bool = False , benchmark : bool = False , save_to_excel : bool = False ,
3103- show_plot_comparison : bool = True ):
3124+ flip_the_sec_terminal : bool = False , show_visual_outputs : bool = False , show_equivalent_circuit : bool = False ,
3125+ plot_interpolation : bool = False , show_fem_simulation_results : bool = False , benchmark : bool = False ,
3126+ save_to_excel : bool = False , show_plot_comparison : bool = True ):
31043127 r"""
31053128 Get 10 parasitic capacitance of a transformer.
31063129
@@ -3132,6 +3155,8 @@ def get_capacitance_of_transformer(self, freq_for_mesh: float = 0.0, c_meas_open
31323155 :type flip_the_sec_terminal: bool
31333156 :param show_visual_outputs: show the electrostatic model before simulation
31343157 :type show_visual_outputs: bool, optional
3158+ :param show_equivalent_circuit: show the equivalent circuit of transformer
3159+ :type show_equivalent_circuit: bool
31353160 :param plot_interpolation: if True, plot the interpolation between the provided values for the material.
31363161 :type plot_interpolation: bool
31373162 :param show_fem_simulation_results: if True, show the simulation results after the simulation has finished
@@ -3202,6 +3227,15 @@ def get_capacitance_of_transformer(self, freq_for_mesh: float = 0.0, c_meas_open
32023227 if show_plot_comparison and (c_meas_open is not None or c_meas_short is not None ):
32033228 ff .plot_open_and_short_comparison (c_sim_open , c_sim_short , c_meas_open , c_meas_short )
32043229
3230+ # show equivalent circuit
3231+ if show_equivalent_circuit :
3232+ d = ff .draw_capacitive_equivalent_circuit_of_transformer (c_vec )
3233+ d .draw ()
3234+ os .makedirs (self .file_data .e_m_values_folder_path , exist_ok = True )
3235+ figure_path = os .path .join (self .file_data .e_m_values_folder_path , "capacitive_equivalent_circuit_of_transformer.pdf" )
3236+ d .save (figure_path )
3237+ logger .info (f"Equivalent circuit saved to { figure_path } " )
3238+
32053239 return c_vec
32063240
32073241 def get_inductances (self , I0 : float , op_frequency : float = 0 , skin_mesh_factor : float = 1 ,
@@ -3666,6 +3700,11 @@ def write_electro_static_parameter_pro(self):
36663700
36673701 text_file .write ("Flag_Static = 1;\n " )
36683702
3703+ if self .visualization_mode == VisualizationMode .Stream or self .visualization_mode == VisualizationMode .Post :
3704+ text_file .write ("Flag_Stream_Visualization = 1;\n " )
3705+ else :
3706+ text_file .write ("Flag_Stream_Visualization = 0;\n " )
3707+
36693708 # Airgap number
36703709 text_file .write ("n_airgaps = {};\n " .format (len (self .air_gaps .midpoints )))
36713710
0 commit comments