def comp_force_nodal(self, output, axes_dict): """Run the nodal forces calculation based on a tensor. from publications: Parameters ---------- self : ForceTensor A ForceTensor object output : Output an Output object (to update) """ dim = 2 Time = axes_dict["Time"] Nt_tot = Time.get_length() # Number of time step meshsolution_mag = output.mag.meshsolution # Comes from FEMM simulation # Select the target group (stator, rotor ...) meshsolution_group = meshsolution_mag.get_group(self.group) # TODO before: Check if is_same_mesh is True mesh = meshsolution_group.get_mesh() # New meshsolution object for output, that could be different from the one inputed meshsolution = MeshSolution(mesh=[mesh.copy()], is_same_mesh=True, dimension=dim) # Load magnetic flux B and H and mu objects B_sol = meshsolution_group.get_solution(label="B") H_sol = meshsolution_group.get_solution(label="H") mu_sol = meshsolution_group.get_solution(label="\mu") # Import time vector from Time Data object if self.is_periodicity_t is not None: is_periodicity_t = self.is_periodicity_t is_periodicity_t, is_antiper_t = Time.get_periodicity() time = Time.get_values( is_oneperiod=is_periodicity_t, is_antiperiod=is_antiper_t and is_periodicity_t, ) # Load magnetic flux B and H of size (Nt_tot, nb_elem, dim) and mu (Nt_tot, nb_elem) resultB = B_sol.field.get_xyz_along( "indice", "time=axis_data", axis_data={"time": time}, ) indice = resultB["indice"] # Store elements indices Bx = resultB["comp_x"] By = resultB["comp_y"] B = np.stack((Bx, By), axis=2) resultH = H_sol.field.get_xyz_along( "indice", "time=axis_data", axis_data={"time": time}, ) Hx = resultH["comp_x"] Hy = resultH["comp_y"] H = np.stack((Hx, Hy), axis=2) resultmu = mu_sol.field.get_along( "indice", "time=axis_data", axis_data={"time": time}, ) mu = resultmu["\\mu"] # Move time axis at the end for clarity purpose B = np.moveaxis(B, 0, -1) H = np.moveaxis(H, 0, -1) mu = np.moveaxis(mu, 0, -1) # Loop on elements and nodes for nodal forces f, connect = self.element_loop(mesh, B, H, mu, indice, dim, Nt_tot) indices_nodes = np.sort(np.unique(connect)) Indices_Point = Data1D(name="indice", values=indices_nodes, is_components=True) # Time axis goes back to first axis f = np.moveaxis(f, -1, 0) components = {} fx_data = DataTime( name="Nodal force (x)", unit="N", symbol="Fx", axes=[Time, Indices_Point], values=f[..., 0], ) components["comp_x"] = fx_data fy_data = DataTime( name="Nodal force (y)", unit="N", symbol="Fy", axes=[Time, Indices_Point], values=f[..., 1], ) components["comp_y"] = fy_data vec_force = VectorField(name="Nodal forces", symbol="F", components=components) solforce = SolutionVector(field=vec_force, type_cell="node", label="F") meshsolution.solution.append(solforce) out_dict = dict() out_dict["meshsolution"] = meshsolution return out_dict
def __init__( self, time=None, angle=None, Nt_tot=None, Na_tot=None, Br=None, Bt=None, Tem=None, Tem_av=None, Tem_rip=None, Phi_wind_stator=None, emf=None, meshsolution=-1, FEMM_dict=None, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if meshsolution == -1: meshsolution = MeshSolution() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "time", "angle", "Nt_tot", "Na_tot", "Br", "Bt", "Tem", "Tem_av", "Tem_rip", "Phi_wind_stator", "emf", "meshsolution", "FEMM_dict", ], ) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Nt_tot" in list(init_dict.keys()): Nt_tot = init_dict["Nt_tot"] if "Na_tot" in list(init_dict.keys()): Na_tot = init_dict["Na_tot"] if "Br" in list(init_dict.keys()): Br = init_dict["Br"] if "Bt" in list(init_dict.keys()): Bt = init_dict["Bt"] if "Tem" in list(init_dict.keys()): Tem = init_dict["Tem"] if "Tem_av" in list(init_dict.keys()): Tem_av = init_dict["Tem_av"] if "Tem_rip" in list(init_dict.keys()): Tem_rip = init_dict["Tem_rip"] if "Phi_wind_stator" in list(init_dict.keys()): Phi_wind_stator = init_dict["Phi_wind_stator"] if "emf" in list(init_dict.keys()): emf = init_dict["emf"] if "meshsolution" in list(init_dict.keys()): meshsolution = init_dict["meshsolution"] if "FEMM_dict" in list(init_dict.keys()): FEMM_dict = init_dict["FEMM_dict"] # Initialisation by argument self.parent = None # time can be None, a ndarray or a list set_array(self, "time", time) # angle can be None, a ndarray or a list set_array(self, "angle", angle) self.Nt_tot = Nt_tot self.Na_tot = Na_tot # Br can be None, a ndarray or a list set_array(self, "Br", Br) # Bt can be None, a ndarray or a list set_array(self, "Bt", Bt) # Tem can be None, a ndarray or a list set_array(self, "Tem", Tem) self.Tem_av = Tem_av self.Tem_rip = Tem_rip # Phi_wind_stator can be None, a ndarray or a list set_array(self, "Phi_wind_stator", Phi_wind_stator) # emf can be None, a ndarray or a list set_array(self, "emf", emf) # meshsolution can be None, a MeshSolution object or a dict if isinstance(meshsolution, dict): self.meshsolution = MeshSolution(init_dict=meshsolution) else: self.meshsolution = meshsolution self.FEMM_dict = FEMM_dict # The class is frozen, for now it's impossible to add new properties self._freeze()
def get_meshsolution(self, is_get_mesh, is_save_FEA, save_path, j_t0): """Load the mesh data and solution data. FEMM must be working and a simulation must have been solved. Parameters ---------- self : MagFEMM a MagFEMM object is_get_mesh : bool 1 to load the mesh and solution into the simulation is_save_FEA : bool 1 to save the mesh and solution into a .json file j_t0 : int Targeted time step Returns ------- res_path: str path to the result folder """ # TODO: Not saving the mesh (only the solution) when the sliding band is activated idworker = "1" # For parallelization TODO path_txt = join(MAIN_DIR, "Functions", "FEMM") + "\\" path_txt_lua = path_txt.replace("\\", "/") path_lua_in = join(path_txt, "get_mesh_data_FEMM.lua") path_lua_out = join(save_path, "get_mesh_data_FEMM" + idworker + ".lua") path_txt_out = save_path + "\\" path_txt_out = path_txt_out.replace("\\", "/") # Create a new LUA script with current paths file_lua = open(path_lua_in, "r") text_lua = file_lua.read() file_lua.close() text_lua = text_lua.replace("my_path_txt", path_txt_out) text_lua = text_lua.replace("my_id_worker", idworker) file_lua_out = open(path_lua_out, "w") file_lua_out.write(text_lua) file_lua_out.close() # Run the LUA externally using FEMM LUA console and store the data in the # temporary text files path_lua_out2 = path_lua_out.replace("\\", "/") callfemm('dofile("' + path_lua_out2 + '")') # Delete the LUA script os.remove(path_lua_out) # Read the nodes and elements files path_node = join(save_path, "nodes" + idworker + ".txt") path_element = join(save_path, "elements" + idworker + ".txt") listNd0 = np.loadtxt(path_node, delimiter=" ") listElem0 = np.loadtxt(path_element, dtype="i", delimiter=" ") NbNd = len(listNd0) NbElem = len(listElem0) # Node list listNd = np.zeros(shape=(NbNd, 3)) listNd[:, 0] = listNd0[:, 0] listNd[:, 1] = listNd0[:, 1] # Element list # listElem = np.zeros(shape=(NbElem, 3)) listElem = listElem0[:, 0:3] - 1 # Delete text files os.remove(path_node) os.remove(path_element) # Read the results file path_results = join(save_path, "results" + idworker + ".txt") results = np.loadtxt(path_results, delimiter=" ") # Delete text files os.remove(path_results) # Save data if is_get_mesh: # Create Mesh and Solution dictionaries mesh = Mesh() mesh.element = ElementMat( connectivity=listElem, nb_elem=NbElem, group=listElem0[:, 6], nb_node_per_element=3, ) mesh.node = NodeMat(coordinate=listNd[:, 0:2], nb_node=NbNd) solution = SolutionFEMM(B=results[:, 0:2], H=results[:, 2:4], mu=results[:, 4]) meshFEMM = MeshSolution(name="FEMM_magnetic_mesh", mesh=mesh, solution=solution) if is_save_FEA: save_path_fea = join(save_path, "meshFEMM" + str(j_t0) + ".json") meshFEMM.save(save_path_fea) return meshFEMM
class OutMag(FrozenClass): """Gather the magnetic module outputs""" VERSION = 1 # save method is available in all object save = save def __init__( self, time=None, angle=None, Nt_tot=None, Na_tot=None, Br=None, Bt=None, Tem=None, Tem_av=None, Tem_rip=None, Phi_wind_stator=None, emf=None, meshsolution=-1, FEMM_dict=None, init_dict=None, ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if meshsolution == -1: meshsolution = MeshSolution() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, [ "time", "angle", "Nt_tot", "Na_tot", "Br", "Bt", "Tem", "Tem_av", "Tem_rip", "Phi_wind_stator", "emf", "meshsolution", "FEMM_dict", ], ) # Overwrite default value with init_dict content if "time" in list(init_dict.keys()): time = init_dict["time"] if "angle" in list(init_dict.keys()): angle = init_dict["angle"] if "Nt_tot" in list(init_dict.keys()): Nt_tot = init_dict["Nt_tot"] if "Na_tot" in list(init_dict.keys()): Na_tot = init_dict["Na_tot"] if "Br" in list(init_dict.keys()): Br = init_dict["Br"] if "Bt" in list(init_dict.keys()): Bt = init_dict["Bt"] if "Tem" in list(init_dict.keys()): Tem = init_dict["Tem"] if "Tem_av" in list(init_dict.keys()): Tem_av = init_dict["Tem_av"] if "Tem_rip" in list(init_dict.keys()): Tem_rip = init_dict["Tem_rip"] if "Phi_wind_stator" in list(init_dict.keys()): Phi_wind_stator = init_dict["Phi_wind_stator"] if "emf" in list(init_dict.keys()): emf = init_dict["emf"] if "meshsolution" in list(init_dict.keys()): meshsolution = init_dict["meshsolution"] if "FEMM_dict" in list(init_dict.keys()): FEMM_dict = init_dict["FEMM_dict"] # Initialisation by argument self.parent = None # time can be None, a ndarray or a list set_array(self, "time", time) # angle can be None, a ndarray or a list set_array(self, "angle", angle) self.Nt_tot = Nt_tot self.Na_tot = Na_tot # Br can be None, a ndarray or a list set_array(self, "Br", Br) # Bt can be None, a ndarray or a list set_array(self, "Bt", Bt) # Tem can be None, a ndarray or a list set_array(self, "Tem", Tem) self.Tem_av = Tem_av self.Tem_rip = Tem_rip # Phi_wind_stator can be None, a ndarray or a list set_array(self, "Phi_wind_stator", Phi_wind_stator) # emf can be None, a ndarray or a list set_array(self, "emf", emf) # meshsolution can be None, a MeshSolution object or a dict if isinstance(meshsolution, dict): self.meshsolution = MeshSolution(init_dict=meshsolution) else: self.meshsolution = meshsolution self.FEMM_dict = FEMM_dict # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" OutMag_str = "" if self.parent is None: OutMag_str += "parent = None " + linesep else: OutMag_str += "parent = " + str(type( self.parent)) + " object" + linesep OutMag_str += ("time = " + linesep + str(self.time).replace(linesep, linesep + "\t") + linesep + linesep) OutMag_str += ("angle = " + linesep + str(self.angle).replace(linesep, linesep + "\t") + linesep + linesep) OutMag_str += "Nt_tot = " + str(self.Nt_tot) + linesep OutMag_str += "Na_tot = " + str(self.Na_tot) + linesep OutMag_str += ("Br = " + linesep + str(self.Br).replace(linesep, linesep + "\t") + linesep + linesep) OutMag_str += ("Bt = " + linesep + str(self.Bt).replace(linesep, linesep + "\t") + linesep + linesep) OutMag_str += ("Tem = " + linesep + str(self.Tem).replace(linesep, linesep + "\t") + linesep + linesep) OutMag_str += "Tem_av = " + str(self.Tem_av) + linesep OutMag_str += "Tem_rip = " + str(self.Tem_rip) + linesep OutMag_str += ( "Phi_wind_stator = " + linesep + str(self.Phi_wind_stator).replace(linesep, linesep + "\t") + linesep + linesep) OutMag_str += ("emf = " + linesep + str(self.emf).replace(linesep, linesep + "\t") + linesep + linesep) if self.meshsolution is not None: tmp = (self.meshsolution.__str__().replace(linesep, linesep + "\t").rstrip("\t")) OutMag_str += "meshsolution = " + tmp else: OutMag_str += "meshsolution = None" + linesep + linesep OutMag_str += "FEMM_dict = " + str(self.FEMM_dict) + linesep return OutMag_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if not array_equal(other.time, self.time): return False if not array_equal(other.angle, self.angle): return False if other.Nt_tot != self.Nt_tot: return False if other.Na_tot != self.Na_tot: return False if not array_equal(other.Br, self.Br): return False if not array_equal(other.Bt, self.Bt): return False if not array_equal(other.Tem, self.Tem): return False if other.Tem_av != self.Tem_av: return False if other.Tem_rip != self.Tem_rip: return False if not array_equal(other.Phi_wind_stator, self.Phi_wind_stator): return False if not array_equal(other.emf, self.emf): return False if other.meshsolution != self.meshsolution: return False if other.FEMM_dict != self.FEMM_dict: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ OutMag_dict = dict() if self.time is None: OutMag_dict["time"] = None else: OutMag_dict["time"] = self.time.tolist() if self.angle is None: OutMag_dict["angle"] = None else: OutMag_dict["angle"] = self.angle.tolist() OutMag_dict["Nt_tot"] = self.Nt_tot OutMag_dict["Na_tot"] = self.Na_tot if self.Br is None: OutMag_dict["Br"] = None else: OutMag_dict["Br"] = self.Br.tolist() if self.Bt is None: OutMag_dict["Bt"] = None else: OutMag_dict["Bt"] = self.Bt.tolist() if self.Tem is None: OutMag_dict["Tem"] = None else: OutMag_dict["Tem"] = self.Tem.tolist() OutMag_dict["Tem_av"] = self.Tem_av OutMag_dict["Tem_rip"] = self.Tem_rip if self.Phi_wind_stator is None: OutMag_dict["Phi_wind_stator"] = None else: OutMag_dict["Phi_wind_stator"] = self.Phi_wind_stator.tolist() if self.emf is None: OutMag_dict["emf"] = None else: OutMag_dict["emf"] = self.emf.tolist() if self.meshsolution is None: OutMag_dict["meshsolution"] = None else: OutMag_dict["meshsolution"] = self.meshsolution.as_dict() OutMag_dict["FEMM_dict"] = self.FEMM_dict # The class name is added to the dict fordeserialisation purpose OutMag_dict["__class__"] = "OutMag" return OutMag_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.time = None self.angle = None self.Nt_tot = None self.Na_tot = None self.Br = None self.Bt = None self.Tem = None self.Tem_av = None self.Tem_rip = None self.Phi_wind_stator = None self.emf = None if self.meshsolution is not None: self.meshsolution._set_None() self.FEMM_dict = None def _get_time(self): """getter of time""" return self._time def _set_time(self, value): """setter of time""" if type(value) is list: try: value = array(value) except: pass check_var("time", value, "ndarray") self._time = value # Magnetic time vector (no symmetry) # Type : ndarray time = property(fget=_get_time, fset=_set_time, doc=u"""Magnetic time vector (no symmetry)""") def _get_angle(self): """getter of angle""" return self._angle def _set_angle(self, value): """setter of angle""" if type(value) is list: try: value = array(value) except: pass check_var("angle", value, "ndarray") self._angle = value # Magnetic position vector (no symmetry) # Type : ndarray angle = property( fget=_get_angle, fset=_set_angle, doc=u"""Magnetic position vector (no symmetry)""", ) def _get_Nt_tot(self): """getter of Nt_tot""" return self._Nt_tot def _set_Nt_tot(self, value): """setter of Nt_tot""" check_var("Nt_tot", value, "int") self._Nt_tot = value # Length of the time vector # Type : int Nt_tot = property(fget=_get_Nt_tot, fset=_set_Nt_tot, doc=u"""Length of the time vector""") def _get_Na_tot(self): """getter of Na_tot""" return self._Na_tot def _set_Na_tot(self, value): """setter of Na_tot""" check_var("Na_tot", value, "int") self._Na_tot = value # Length of the angle vector # Type : int Na_tot = property(fget=_get_Na_tot, fset=_set_Na_tot, doc=u"""Length of the angle vector""") def _get_Br(self): """getter of Br""" return self._Br def _set_Br(self, value): """setter of Br""" if type(value) is list: try: value = array(value) except: pass check_var("Br", value, "ndarray") self._Br = value # Radial airgap flux density # Type : ndarray Br = property(fget=_get_Br, fset=_set_Br, doc=u"""Radial airgap flux density""") def _get_Bt(self): """getter of Bt""" return self._Bt def _set_Bt(self, value): """setter of Bt""" if type(value) is list: try: value = array(value) except: pass check_var("Bt", value, "ndarray") self._Bt = value # Tangential airgap flux density # Type : ndarray Bt = property(fget=_get_Bt, fset=_set_Bt, doc=u"""Tangential airgap flux density""") def _get_Tem(self): """getter of Tem""" return self._Tem def _set_Tem(self, value): """setter of Tem""" if type(value) is list: try: value = array(value) except: pass check_var("Tem", value, "ndarray") self._Tem = value # Electromagnetic torque # Type : ndarray Tem = property(fget=_get_Tem, fset=_set_Tem, doc=u"""Electromagnetic torque""") def _get_Tem_av(self): """getter of Tem_av""" return self._Tem_av def _set_Tem_av(self, value): """setter of Tem_av""" check_var("Tem_av", value, "float") self._Tem_av = value # Average Electromagnetic torque # Type : float Tem_av = property(fget=_get_Tem_av, fset=_set_Tem_av, doc=u"""Average Electromagnetic torque""") def _get_Tem_rip(self): """getter of Tem_rip""" return self._Tem_rip def _set_Tem_rip(self, value): """setter of Tem_rip""" check_var("Tem_rip", value, "float") self._Tem_rip = value # Torque ripple # Type : float Tem_rip = property(fget=_get_Tem_rip, fset=_set_Tem_rip, doc=u"""Torque ripple""") def _get_Phi_wind_stator(self): """getter of Phi_wind_stator""" return self._Phi_wind_stator def _set_Phi_wind_stator(self, value): """setter of Phi_wind_stator""" if type(value) is list: try: value = array(value) except: pass check_var("Phi_wind_stator", value, "ndarray") self._Phi_wind_stator = value # Stator winding flux # Type : ndarray Phi_wind_stator = property( fget=_get_Phi_wind_stator, fset=_set_Phi_wind_stator, doc=u"""Stator winding flux""", ) def _get_emf(self): """getter of emf""" return self._emf def _set_emf(self, value): """setter of emf""" if type(value) is list: try: value = array(value) except: pass check_var("emf", value, "ndarray") self._emf = value # Electromotive force # Type : ndarray emf = property(fget=_get_emf, fset=_set_emf, doc=u"""Electromotive force""") def _get_meshsolution(self): """getter of meshsolution""" return self._meshsolution def _set_meshsolution(self, value): """setter of meshsolution""" check_var("meshsolution", value, "MeshSolution") self._meshsolution = value if self._meshsolution is not None: self._meshsolution.parent = self # FEA software mesh and solution # Type : MeshSolution meshsolution = property( fget=_get_meshsolution, fset=_set_meshsolution, doc=u"""FEA software mesh and solution""", ) def _get_FEMM_dict(self): """getter of FEMM_dict""" return self._FEMM_dict def _set_FEMM_dict(self, value): """setter of FEMM_dict""" check_var("FEMM_dict", value, "dict") self._FEMM_dict = value # Dictionnary containing the main FEMM parameter # Type : dict FEMM_dict = property( fget=_get_FEMM_dict, fset=_set_FEMM_dict, doc=u"""Dictionnary containing the main FEMM parameter""", )
def solve_FEMM(self, output, sym, FEMM_dict): # Loading parameters for readibilitys angle = output.mag.angle L1 = output.simu.machine.stator.comp_length() Nt_tot = output.mag.Nt_tot # Number of time step Na_tot = output.mag.Na_tot # Number of angular step save_path = self.get_path_save(output) if (hasattr(output.simu.machine.stator, "winding") and output.simu.machine.stator.winding is not None): qs = output.simu.machine.stator.winding.qs # Winding phase number Npcpp = output.simu.machine.stator.winding.Npcpp Phi_wind_stator = zeros((Nt_tot, qs)) else: Phi_wind_stator = None # Create the mesh femm.mi_createmesh() # Initialize results matrix Br = zeros((Nt_tot, Na_tot)) Bt = zeros((Nt_tot, Na_tot)) Tem = zeros((Nt_tot, 1)) lam_int = output.simu.machine.get_lamination(True) lam_ext = output.simu.machine.get_lamination(False) Rgap_mec_int = lam_int.comp_radius_mec() Rgap_mec_ext = lam_ext.comp_radius_mec() if self.is_get_mesh or self.is_save_FEA: meshFEMM = [Mesh() for ii in range(Nt_tot)] solutionFEMM = [Solution() for ii in range(Nt_tot)] else: meshFEMM = [Mesh()] solutionFEMM = [Solution()] # Compute the data for each time step for ii in range(Nt_tot): # Update rotor position and currents update_FEMM_simulation( output=output, materials=FEMM_dict["materials"], circuits=FEMM_dict["circuits"], is_mmfs=self.is_mmfs, is_mmfr=self.is_mmfr, j_t0=ii, is_sliding_band=self.is_sliding_band, ) # try "previous solution" for speed up of FEMM calculation if self.is_sliding_band: try: base = basename(self.get_path_save_fem(output)) ans_file = splitext(base)[0] + ".ans" femm.mi_setprevious(ans_file, 0) except: pass # Run the computation femm.mi_analyze() femm.mi_loadsolution() # Get the flux result if self.is_sliding_band: for jj in range(Na_tot): Br[ii, jj], Bt[ii, jj] = femm.mo_getgapb("bc_ag2", angle[jj] * 180 / pi) else: Rag = (Rgap_mec_ext + Rgap_mec_int) / 2 for jj in range(Na_tot): B = femm.mo_getb(Rag * np.cos(angle[jj]), Rag * np.sin(angle[jj])) Br[ii, jj] = B[0] * np.cos(angle[jj]) + B[1] * np.sin(angle[jj]) Bt[ii, jj] = -B[0] * np.sin(angle[jj]) + B[1] * np.cos(angle[jj]) # Compute the torque Tem[ii] = comp_FEMM_torque(FEMM_dict, sym=sym) if (hasattr(output.simu.machine.stator, "winding") and output.simu.machine.stator.winding is not None): # Phi_wind computation Phi_wind_stator[ii, :] = comp_FEMM_Phi_wind( qs, Npcpp, is_stator=True, Lfemm=FEMM_dict["Lfemm"], L1=L1, sym=sym) # Load mesh data & solution if self.is_get_mesh or self.is_save_FEA: meshFEMM[ii], solutionFEMM[ii] = self.get_meshsolution( self.is_get_mesh, self.is_save_FEA, save_path, ii) # Shift to take into account stator position roll_id = int(self.angle_stator * Na_tot / (2 * pi)) Br = roll(Br, roll_id, axis=1) Bt = roll(Bt, roll_id, axis=1) # Store the results output.mag.Br = Br output.mag.Bt = Bt output.mag.Tem = Tem output.mag.Tem_av = mean(Tem) if output.mag.Tem_av != 0: output.mag.Tem_rip = abs( (np_max(Tem) - np_min(Tem)) / output.mag.Tem_av) output.mag.Phi_wind_stator = Phi_wind_stator output.mag.FEMM_dict = FEMM_dict if self.is_get_mesh: cond = (not self.is_sliding_band) or (Nt_tot == 1) output.mag.meshsolution = MeshSolution( name="FEMM_magnetic_mesh", mesh=meshFEMM, solution=solutionFEMM, is_same_mesh=cond, ) if self.is_save_FEA: save_path_fea = join(save_path, "MeshSolutionFEMM.json") output.mag.meshsolution.save(save_path_fea) if (hasattr(output.simu.machine.stator, "winding") and output.simu.machine.stator.winding is not None): # Electromotive forces computation (update output) self.comp_emf() else: output.mag.emf = None