def update(self, simt=1): super(OpenAP, self).update(simt) # update phase, infer from spd, roc, alt self.phase = ph.get(self.lifttype, bs.traf.tas, bs.traf.vs, bs.traf.alt, unit='SI') # update limits, based on phase change limits = self.__construct_limit_matrix(self.actypes, self.phase) self.vmin = limits[:, 0] self.vmax = limits[:, 1] self.vsmin = limits[:, 2] self.vsmax = limits[:, 3] self.hmax = limits[:, 4] self.axmax = limits[:, 5] # compute thrust # = number of engines x engine static thrust x thrust ratio idx_fixwing = np.where(self.lifttype == coeff.LIFT_FIXWING)[0] self.thrustratio[idx_fixwing] = thrust.compute_thrust_ratio( self.phase[idx_fixwing], self.engbpr[idx_fixwing], bs.traf.tas[idx_fixwing], bs.traf.alt[idx_fixwing]) self.thrust[idx_fixwing] = self.engnum[idx_fixwing] * self.engthrust[ idx_fixwing] * self.thrustratio[idx_fixwing] # compute fuel flow self.fuelflow = self.engnum * (self.ff_coeff_a * self.thrustratio**2 \ + self.ff_coeff_b * self.thrustratio \ + self.ff_coeff_c) # TODO: implement thrust computation for rotor aircraft # idx_rotor = np.where(self.lifttype==coeff.LIFT_ROTOR)[0] # self.thrust[idx_rotor] = 0 # update bank angle, due to phase change self.bank = np.where((self.phase == ph.TO) | (self.phase == ph.LD), 15, self.bank) self.bank = np.where((self.phase == ph.IC) | (self.phase == ph.CR) | (self.phase == ph.AP), 35, self.bank) return None
def update(self, dt=bs.settings.performance_dt): super(OpenAP, self).update() # update phase, infer from spd, roc, alt lenph1 = len(self.phase) self.phase = ph.get(self.lifttype, bs.traf.tas, bs.traf.vs, bs.traf.alt, unit="SI") # update speed limits, based on phase change self.vmin, self.vmax = self._construct_v_limits( self.actypes, self.phase) idx_fixwing = np.where(self.lifttype == coeff.LIFT_FIXWING)[0] # ----- compute drag ----- # update drage coefficient based on flight phase self.cd0[self.phase == ph.GD] = ( self.cd0_to[self.phase == ph.GD] + self.delta_cd_gear[self.phase == ph.GD]) self.cd0[self.phase == ph.IC] = self.cd0_to[self.phase == ph.IC] self.cd0[self.phase == ph.AP] = self.cd0_ld[self.phase == ph.AP] self.cd0[self.phase == ph.CL] = self.cd0_clean[self.phase == ph.CL] self.cd0[self.phase == ph.CR] = self.cd0_clean[self.phase == ph.CR] self.cd0[self.phase == ph.DE] = self.cd0_clean[self.phase == ph.DE] self.cd0[self.phase == ph.NA] = self.cd0_clean[self.phase == ph.NA] self.k[self.phase == ph.GD] = self.k_to[self.phase == ph.GD] self.k[self.phase == ph.IC] = self.k_to[self.phase == ph.IC] self.k[self.phase == ph.AP] = self.k_ld[self.phase == ph.AP] self.k[self.phase == ph.CL] = self.k_clean[self.phase == ph.CL] self.k[self.phase == ph.CR] = self.k_clean[self.phase == ph.CR] self.k[self.phase == ph.DE] = self.k_clean[self.phase == ph.DE] self.k[self.phase == ph.NA] = self.k_clean[self.phase == ph.NA] rho = aero.vdensity(bs.traf.alt[idx_fixwing]) vtas = bs.traf.tas[idx_fixwing] rhovs = 0.5 * rho * vtas**2 * self.Sref[idx_fixwing] cl = self.mass[idx_fixwing] * aero.g0 / rhovs self.drag[idx_fixwing] = rhovs * (self.cd0[idx_fixwing] + self.k[idx_fixwing] * cl**2) # ----- compute maximum thrust ----- max_thrustratio_fixwing = thrust.compute_max_thr_ratio( self.phase[idx_fixwing], self.engbpr[idx_fixwing], bs.traf.tas[idx_fixwing], bs.traf.alt[idx_fixwing], bs.traf.vs[idx_fixwing], self.engnum[idx_fixwing] * self.engthrmax[idx_fixwing], ) self.max_thrust[idx_fixwing] = (max_thrustratio_fixwing * self.engnum[idx_fixwing] * self.engthrmax[idx_fixwing]) # ----- compute net thrust ----- self.thrust[idx_fixwing] = ( self.drag[idx_fixwing] + self.mass[idx_fixwing] * bs.traf.ax[idx_fixwing]) # ----- compute duel flow ----- thrustratio_fixwing = self.thrust[idx_fixwing] / ( self.engnum[idx_fixwing] * self.engthrmax[idx_fixwing]) self.fuelflow[idx_fixwing] = self.engnum[idx_fixwing] * ( self.ff_coeff_a[idx_fixwing] * thrustratio_fixwing**2 + self.ff_coeff_b[idx_fixwing] * thrustratio_fixwing + self.ff_coeff_c[idx_fixwing]) # TODO: implement thrust computation for rotor aircraft # idx_rotor = np.where(self.lifttype==coeff.LIFT_ROTOR)[0] # self.thrust[idx_rotor] = 0 # update bank angle, due to phase change self.bank = np.where((self.phase == ph.GD), 15, self.bank) self.bank = np.where( (self.phase == ph.IC) | (self.phase == ph.CR) | (self.phase == ph.AP), 35, self.bank, ) # ----- debug statements ----- # print(bs.traf.id) # print(self.phase) # print(self.thrust.astype(int)) # print(np.round(self.fuelflow, 2)) # print(self.drag.astype(int)) # print() return None
def update(self, dt=bs.settings.performance_dt): super(OpenAP, self).update() # update phase, infer from spd, roc, alt lenph1 = len(self.phase) self.phase = ph.get(self.lifttype, bs.traf.tas, bs.traf.vs, bs.traf.alt, unit='SI') # update limits, based on phase change limits = self.__construct_limit_matrix(self.actypes, self.phase) self.vmin = limits[:, 0] self.vmax = limits[:, 1] self.vsmin = limits[:, 2] self.vsmax = limits[:, 3] self.hmax = limits[:, 4] self.axmax = limits[:, 5] self.vminto = limits[:, 6] idx_fixwing = np.where(self.lifttype==coeff.LIFT_FIXWING)[0] # ----- compute drag ----- # update drage coefficient based on flight phase self.cd0[self.phase==ph.GD] = self.cd0_to[self.phase==ph.GD] self.cd0[self.phase==ph.IC] = self.cd0_ic[self.phase==ph.IC] self.cd0[self.phase==ph.AP] = self.cd0_ap[self.phase==ph.AP] self.cd0[self.phase==ph.CL] = self.cd0_clean[self.phase==ph.CL] self.cd0[self.phase==ph.CR] = self.cd0_clean[self.phase==ph.CR] self.cd0[self.phase==ph.DE] = self.cd0_clean[self.phase==ph.DE] self.cd0[self.phase==ph.NA] = self.cd0_clean[self.phase==ph.NA] rho = aero.vdensity(bs.traf.alt[idx_fixwing]) vtas = bs.traf.tas[idx_fixwing] rhovs = 0.5 * rho * vtas**2 * self.Sref[idx_fixwing] cl = self.mass[idx_fixwing] * aero.g0 / rhovs self.drag[idx_fixwing] = rhovs * (self.cd0[idx_fixwing] + self.k[idx_fixwing] * cl**2) # ----- compute maximum thrust ----- max_thrustratio_fixwing = thrust.compute_max_thr_ratio( self.phase[idx_fixwing], self.engbpr[idx_fixwing], bs.traf.tas[idx_fixwing], bs.traf.alt[idx_fixwing], bs.traf.vs[idx_fixwing], self.engnum[idx_fixwing]*self.engthrmax[idx_fixwing] ) self.max_thrust[idx_fixwing] = max_thrustratio_fixwing * self.engnum[idx_fixwing] * self.engthrmax[idx_fixwing] # ----- compute net thrust ----- self.thrust[idx_fixwing] = self.drag[idx_fixwing] + self.mass[idx_fixwing] * bs.traf.ax[idx_fixwing] # ----- compute duel flow ----- thrustratio_fixwing = self.thrust[idx_fixwing] / (self.engnum[idx_fixwing] * self.engthrmax[idx_fixwing]) self.fuelflow[idx_fixwing] = self.engnum[idx_fixwing] * (self.ff_coeff_a[idx_fixwing] * thrustratio_fixwing**2 \ + self.ff_coeff_b[idx_fixwing] * thrustratio_fixwing \ + self.ff_coeff_c[idx_fixwing]) # TODO: implement thrust computation for rotor aircraft # idx_rotor = np.where(self.lifttype==coeff.LIFT_ROTOR)[0] # self.thrust[idx_rotor] = 0 # update bank angle, due to phase change self.bank = np.where((self.phase==ph.GD), 15, self.bank) self.bank = np.where((self.phase==ph.IC) | (self.phase==ph.CR) | (self.phase==ph.AP), 35, self.bank) # ----- debug statements ----- # print(bs.traf.id) # print(self.phase) # print(self.thrust.astype(int)) # print(np.round(self.fuelflow, 2)) # print(self.drag.astype(int)) # print() return None
def update(self, simt=1): super(OpenAP, self).update(simt) # update phase, infer from spd, roc, alt lenph1 = len(self.phase) self.phase = ph.get(self.lifttype, bs.traf.tas, bs.traf.vs, bs.traf.alt, unit='SI') # update limits, based on phase change limits = self.__construct_limit_matrix(self.actypes, self.phase) self.vmin = limits[:, 0] self.vmax = limits[:, 1] self.vsmin = limits[:, 2] self.vsmax = limits[:, 3] self.hmax = limits[:, 4] self.axmax = limits[:, 5] idx_fixwing = np.where(self.lifttype == coeff.LIFT_FIXWING)[0] # ----- compute drag ----- # update drage coefficient based on flight phase self.cd0[self.phase == ph.TO] = self.cd0_to[self.phase == ph.TO] self.cd0[self.phase == ph.IC] = self.cd0_ic[self.phase == ph.IC] self.cd0[self.phase == ph.AP] = self.cd0_ap[self.phase == ph.AP] self.cd0[self.phase == ph.LD] = self.cd0_ld[self.phase == ph.LD] self.cd0[self.phase == ph.GD] = self.cd0_gd[self.phase == ph.GD] self.cd0[self.phase == ph.CL] = self.cd0_clean[self.phase == ph.CL] self.cd0[self.phase == ph.CR] = self.cd0_clean[self.phase == ph.CR] self.cd0[self.phase == ph.DE] = self.cd0_clean[self.phase == ph.DE] self.cd0[self.phase == ph.NA] = self.cd0_clean[self.phase == ph.NA] rho = aero.vdensity(bs.traf.alt[idx_fixwing]) vtas = bs.traf.tas[idx_fixwing] rhovs = 0.5 * rho * vtas**2 * self.Sref[idx_fixwing] cl = self.mass[idx_fixwing] * aero.g0 / rhovs self.drag[idx_fixwing] = rhovs * (self.cd0[idx_fixwing] + self.k[idx_fixwing] * cl**2) # ----- compute thrust ----- # eq: number of engines x engine static thrust x thrust ratio self.thrustratio[idx_fixwing] = thrust.compute_thrust_ratio( self.phase[idx_fixwing], self.engbpr[idx_fixwing], bs.traf.tas[idx_fixwing], bs.traf.alt[idx_fixwing], bs.traf.vs[idx_fixwing], self.engnum[idx_fixwing] * self.engthrust[idx_fixwing]) self.thrust[idx_fixwing] = self.engnum[idx_fixwing] * self.engthrust[ idx_fixwing] * self.thrustratio[idx_fixwing] # ----- compute duel flow ----- self.fuelflow = self.engnum * (self.ff_coeff_a * self.thrustratio**2 \ + self.ff_coeff_b * self.thrustratio \ + self.ff_coeff_c) # TODO: implement thrust computation for rotor aircraft # idx_rotor = np.where(self.lifttype==coeff.LIFT_ROTOR)[0] # self.thrust[idx_rotor] = 0 # update bank angle, due to phase change self.bank = np.where((self.phase == ph.TO) | (self.phase == ph.LD), 15, self.bank) self.bank = np.where((self.phase == ph.IC) | (self.phase == ph.CR) | (self.phase == ph.AP), 35, self.bank) # ----- debug statements ----- # print(bs.traf.id) # print(self.phase) # print(self.thrust.astype(int)) # print(np.round(self.fuelflow, 2)) # print(self.drag.astype(int)) # print() return None