def comp_axis_time(self, p, per_t=None, is_antiper_t=None, Time_in=None): """Compute time axis, with or without periodicities and including normalizations Parameters ---------- self : Input an Input object p: int Number of pole pairs per_t : int time periodicity is_antiper_t : bool if the time axis is antiperiodic Time_in: Data Input time axis Returns ------- Time: Data Requested Time axis """ f_elec = self.OP.get_felec(p=p) N0 = self.OP.get_N0(p=p) A0 = self.angle_rotor_initial # Setup normalizations for time and angle axes norm_time = { "elec_order": Norm_ref(ref=f_elec), "mech_order": Norm_ref(ref=N0 / 60), "angle_elec": Norm_ref(ref=self.current_dir / (2 * pi * f_elec)), "angle_rotor": Norm_affine(slope=self.rot_dir * N0 * 360 / 60, offset=A0 * 180 / pi), } # Compute Time axis based on input one if Time_in is not None: if per_t is None or is_antiper_t is None: # Get periodicity from input Time axis per_t, is_antiper_t = Time_in.get_periodicity() per_t = int(per_t / 2) if is_antiper_t else per_t # Get axis on given periodicities Time = Time_in.get_axis_periodic(Nper=per_t, is_aper=is_antiper_t) Time.normalizations = norm_time # Create time axis elif self.time is None: # Create time axis as a DataLinspace if self.t_final is not None: # Enforce final time t_final = self.t_final elif self.Nrev is not None: # Set final time depending on rotor speed and number of revolutions t_final = 60 / self.OP.N0 * self.Nrev else: # Set final time to p times the number of electrical periods t_final = p / f_elec # Create time axis as a DataLinspace Time = DataLinspace( name="time", unit="s", initial=0, final=t_final, number=self.Nt_tot, include_endpoint=False, normalizations=norm_time, ) # Add time (anti-)periodicity if per_t > 1 or is_antiper_t: Time = Time.get_axis_periodic(per_t, is_antiper_t) else: # Load time data time = self.time.get_data() self.Nt_tot = time.size Time = Data1D(name="time", unit="s", values=time, normalizations=norm_time) # Add time (anti-)periodicity sym_t = dict() if is_antiper_t: sym_t["antiperiod"] = per_t elif per_t > 1: sym_t["period"] = per_t Time.symmetries = sym_t Time = Time.to_linspace() return Time
def comp_axis_angle(self, p, Rag, per_a=None, is_antiper_a=None, Angle_in=None): """Compute angle axis with or without periodicities and including normalizations Parameters ---------- self : Input an Input object p : int Machine pole pair number Rag: float Airgap mean radius [m] per_a : int angle periodicity is_antiper_a : bool if the angle axis is antiperiodic Angle_in: Data Input axis angle Returns ------- Timee_in: Data Requested axis angle """ norm_angle = { "space_order": Norm_ref(ref=p), "distance": Norm_ref(ref=1 / Rag) } # Compute angle axis based on input one if Angle_in is not None: if per_a is None or is_antiper_a is None: # Get periodicity from input Angle axis per_a, is_antiper_a = Angle_in.get_periodicity() per_a = int(per_a / 2) if is_antiper_a else per_a # Get Angle axis on requested periodicities Angle = Angle_in.get_axis_periodic(Nper=per_a, is_aper=is_antiper_a) Angle.normalizations = norm_angle # Create angle axis elif self.angle is None: # Create angle axis as a DataLinspace Angle = DataLinspace( name="angle", unit="rad", initial=0, final=2 * pi, number=self.Na_tot, include_endpoint=False, normalizations=norm_angle, ) # Add angle (anti-)periodicity if per_a > 1 or is_antiper_a: Angle = Angle.get_axis_periodic(per_a, is_antiper_a) else: # Load angle data angle = self.angle.get_data() self.Na_tot = angle.size Angle = Data1D(name="angle", unit="rad", values=angle, normalizations=norm_angle) # Add angle (anti-)periodicity sym_a = dict() if is_antiper_a: sym_a["antiperiod"] = per_a elif per_a > 1: sym_a["period"] = per_a Angle.symmetries = sym_a Angle = Angle.to_linspace() return Angle