def initialize(self,vehicle): # unpack conditions_table = self.conditions_table geometry = self.geometry configuration = self.configuration # AoA = conditions_table.angle_of_attack n_conditions = len(AoA) # copy geometry for k in ['fuselages','wings','propulsors']: geometry[k] = deepcopy(vehicle[k]) # reference area geometry.reference_area = vehicle.reference_area # arrays CL = np.zeros_like(AoA) # condition input, local, do not keep konditions = Conditions() konditions.aerodynamics = Data() # calculate aerodynamics for table for i in xrange(n_conditions): # overriding conditions, thus the name mangling konditions.aerodynamics.angle_of_attack = AoA[i] # these functions are inherited from Aerodynamics() or overridden CL[i] = calculate_lift_vortex_lattice(konditions, configuration, geometry) # store table conditions_table.lift_coefficient = CL # build surrogate self.build_surrogate_sub() # calculate aerodynamics for table for i in xrange(n_conditions): # overriding conditions, thus the name mangling konditions.aerodynamics.angle_of_attack = AoA[i] # these functions are inherited from Aerodynamics() or overridden CL[i] = calculate_lift_linear_supersonic(konditions, configuration, geometry) # store table conditions_table.lift_coefficient = CL # build surrogate self.build_surrogate_sup() return
def __defaults__(self): self.unknowns = Unknowns() self.conditions = Conditions() self.residuals = Residuals() self.numerics = Numerics() self.initials = Conditions()
def initialize(self): # build the conditions table self.build_conditions_table() # unpack conditions_table = self.conditions_table geometry = self.geometry configuration = self.configuration # AoA = conditions_table.angle_of_attack #Ma = conditions_table.mach_number #Re = conditions_table.reynolds_number # check #assert len(AoA) == len(Ma) == len(Re) , 'condition length mismatch' n_conditions = len(AoA) # arrays CL = np.zeros_like(AoA) CD = np.zeros_like(AoA) # condition input, local, do not keep konditions = Conditions() # calculate aerodynamics for table for i in xrange(n_conditions): # overriding conditions, thus the name mangling konditions.angle_of_attack = AoA[i] #konditions.mach_number = Ma[i] #konditions.reynolds_number = Re[i] # these functions are inherited from Aerodynamics() or overridden CL[i] = self.calculate_lift(konditions, configuration, geometry) CD[i] = self.calculate_drag(konditions, configuration, geometry) # store table conditions_table.lift_coefficient = CL conditions_table.drag_coefficient = CD # build surrogate self.build_surrogate() return
def initialize(self): # build the conditions table self.build_conditions_table() # unpack conditions_table = self.conditions_table geometry = self.geometry configuration = self.configuration # AoA = conditions_table.angle_of_attack Ma = conditions_table.mach_number Re = conditions_table.reynolds_number # check assert len(AoA) == len(Ma) == len(Re), 'condition length mismatch' n_conditions = len(AoA) # arrays CL = np.zeros_like(AoA) CD = np.zeros_like(AoA) # condition input, local, do not keep konditions = Conditions() # calculate aerodynamics for table for i in xrange(n_conditions): # overriding conditions, thus the name mangling konditions.angle_of_attack = AoA[i] konditions.mach_number = Ma[i] konditions.reynolds_number = Re[i] # these functions are inherited from Aerodynamics() or overridden CL[i] = self.calculate_lift(konditions, configuration, geometry) CD[i] = self.calculate_drag(konditions, configuration, geometry) # store table conditions_table.lift_coefficient = CL conditions_table.drag_coefficient = CD # build surrogate self.build_surrogate() return
def __defaults__(self): self.tag = 'numerics' self.number_control_points = 16 self.discretization_method = chebyshev_data self.solver_jacobian = "none" self.tolerance_solution = 1e-8 self.tolerance_boundary_conditions = 1e-8 self.dimensionless = Conditions() self.dimensionless.control_points = np.empty([0, 0]) self.dimensionless.differentiate = np.empty([0, 0]) self.dimensionless.integrate = np.empty([0, 0]) self.time = Conditions() self.time.control_points = np.empty([0, 0]) self.time.differentiate = np.empty([0, 0]) self.time.integrate = np.empty([0, 0])
def __defaults__(self): self.tag = 'Aerodynamics' self.geometry = Geometry() self.configuration = Configuration() self.conditions_table = Conditions( angle_of_attack=np.linspace(-10., 10., 5) * Units.deg, ) self.model = Data()
def __defaults__(self): self.tag = 'basic_conditions' # start default row vectors ones_1col = self.ones_row(1) ones_2col = self.ones_row(2) ones_3col = self.ones_row(3) # top level conditions self.frames = Conditions() self.weights = Conditions() self.energies = Conditions() # inertial conditions self.frames.inertial = Conditions() self.frames.inertial.position_vector = ones_3col * 0 self.frames.inertial.velocity_vector = ones_3col * 0 self.frames.inertial.acceleration_vector = ones_3col * 0 self.frames.inertial.gravity_force_vector = ones_3col * 0 self.frames.inertial.total_force_vector = ones_3col * 0 self.frames.inertial.time = ones_1col * 0 # body conditions self.frames.body = Conditions() self.frames.body.inertial_rotations = ones_3col * 0 self.frames.body.transform_to_inertial = np.empty([0, 0, 0]) # weights conditions self.weights.total_mass = ones_1col * 0 self.weights.weight_breakdown = Conditions() # energy conditions self.energies.total_energy = ones_1col * 0 self.energies.total_efficiency = ones_1col * 0
def __defaults__(self): self.tag = 'Aerodynamics' self.geometry = Geometry() self.configuration = Configuration() self.conditions_table = Conditions( angle_of_attack=np.linspace(-10., 10., 5) * Units.deg, mach_number=np.linspace(0.0, 1.0, 5), reynolds_number=np.linspace(1.e4, 1.e10, 3), ) self.model = Data()
def __defaults__(self): """This sets the default values. Assumptions: None Source: N/A Inputs: None Outputs: None Properties Used: None """ self.tag = 'numerics' self.number_control_points = 16 self.discretization_method = chebyshev_data self.solver_jacobian = "none" self.tolerance_solution = 1e-8 self.tolerance_boundary_conditions = 1e-8 self.converged = None self.dimensionless = Conditions() self.dimensionless.control_points = np.empty([0, 0]) self.dimensionless.differentiate = np.empty([0, 0]) self.dimensionless.integrate = np.empty([0, 0]) self.time = Conditions() self.time.control_points = np.empty([0, 0]) self.time.differentiate = np.empty([0, 0]) self.time.integrate = np.empty([0, 0])
def __defaults__(self): """ This sets the default values. Assumptions: None Source: N/A Inputs: None Outputs: None Properties Used: None """ self.unknowns = Unknowns() self.conditions = Conditions() self.residuals = Residuals() self.numerics = Numerics() self.initials = Conditions()
class Container(State): def __defaults__(self): self.segments = Conditions() def merged(self): state_out = State() for i,(tag,sub_state) in enumerate(self.segments.items()): for key in ['unknowns','conditions','residuals']: if i == 0: state_out[key].update(sub_state[key]) else: state_out[key] = state_out[key].do_recursive(append_array,sub_state[key]) return state_out
def getCurrent(self): cmd = b'LOOP 1\n' current = None try: self.port.write(cmd) self.lastActv = datetime.datetime.now() data = self.read(100) if len(data) != 100: return None data = bytearray(data) if data[0] == 0x06: data.pop(0) if VPCRC.validate(data): current = Conditions(data) except Exception as e: Logger.error(e) return current
def __defaults__(self): self.tag = 'Fidelity_Zero' self.geometry = Geometry() self.configuration = Configuration() # correction factors self.configuration.fuselage_lift_correction = 1.14 self.configuration.trim_drag_correction_factor = 1.02 self.configuration.wing_parasite_drag_form_factor = 1.1 self.configuration.fuselage_parasite_drag_form_factor = 2.3 self.configuration.aircraft_span_efficiency_factor = 0.78 # vortex lattice configurations self.configuration.number_panels_spanwise = 5 self.configuration.number_panels_chordwise = 1 self.conditions_table = Conditions( angle_of_attack=np.array([-10., -5., 0., 5., 10.]) * Units.deg, ) self.models = Data()
def __defaults__(self): self.tag = 'aerodynamic_conditions' # start default row vectors ones_1col = self.ones_row(1) ones_2col = self.ones_row(2) ones_3col = self.ones_row(3) # wind frame conditions self.frames.wind = Conditions() self.frames.wind.body_rotations = ones_3col * 0 # rotations in [X,Y,Z] -> [phi,theta,psi] self.frames.wind.velocity_vector = ones_3col * 0 self.frames.wind.lift_force_vector = ones_3col * 0 self.frames.wind.drag_force_vector = ones_3col * 0 self.frames.wind.transform_to_inertial = np.empty([0,0,0]) # body frame conditions self.frames.body.thrust_force_vector = ones_3col * 0 # planet frame conditions self.frames.planet = Conditions() self.frames.planet.start_time = None self.frames.planet.latitude = ones_1col * 0 self.frames.planet.longitude = ones_1col * 0 # freestream conditions self.freestream = Conditions() self.freestream.velocity = ones_1col * 0 self.freestream.mach_number = ones_1col * 0 self.freestream.pressure = ones_1col * 0 self.freestream.temperature = ones_1col * 0 self.freestream.density = ones_1col * 0 self.freestream.speed_of_sound = ones_1col * 0 self.freestream.dynamic_viscosity = ones_1col * 0 self.freestream.altitude = ones_1col * 0 self.freestream.gravity = ones_1col * 0 self.freestream.reynolds_number = ones_1col * 0 self.freestream.dynamic_pressure = ones_1col * 0 # aerodynamics conditions self.aerodynamics = Conditions() self.aerodynamics.angle_of_attack = ones_1col * 0 self.aerodynamics.side_slip_angle = ones_1col * 0 self.aerodynamics.roll_angle = ones_1col * 0 self.aerodynamics.lift_coefficient = ones_1col * 0 self.aerodynamics.drag_coefficient = ones_1col * 0 self.aerodynamics.lift_breakdown = Conditions() self.aerodynamics.drag_breakdown = Conditions() self.aerodynamics.drag_breakdown.parasite = Conditions() self.aerodynamics.drag_breakdown.compressible = Conditions() # stability conditions self.stability = Conditions() self.stability.static = Conditions() self.stability.dynamic = Conditions() # propulsion conditions self.propulsion = Conditions() self.propulsion.throttle = ones_1col * 0 self.propulsion.battery_energy = ones_1col * 0 self.propulsion.thrust_breakdown = Conditions() # energy conditions self.energies.gravity_energy = ones_1col * 0 self.energies.propulsion_power = ones_1col * 0 # weights conditions self.weights.vehicle_mass_rate = ones_1col * 0
def __defaults__(self): self.segments = Conditions()
aerodynamics = Aerodynamics_Surrogate() def calculate_drag(conditions, configuration=None, geometry=None): return (conditions.angle_of_attack * 2. * np.pi)**2. def calculate_lift(conditions, configuration=None, geometry=None): return conditions.angle_of_attack * 2. * np.pi # monkey patch the models aerodynamics.calculate_drag = calculate_drag aerodynamics.calculate_lift = calculate_lift aerodynamics.initialize() # test conditions conditions = Conditions( angle_of_attack=8.0 * Units.deg, mach_number=0.5, reynolds_number=1.e6, ) # call the surrogate CL_I, CD_I = aerodynamics.__call__(conditions) # truth data CL_T = aerodynamics.calculate_lift(conditions) CD_T = aerodynamics.calculate_drag(conditions) print 'CL = %.4f = %.4f' % (CL_I[0], CL_T) print 'CD = %.4f = %.4f' % (CD_I[0], CD_T)
shape = (0, 0, SCREEN_SHAPE[0], SCREEN_SHAPE[1]) Population = 1000 conditions = Conditions( gene_weight_probability=0.8, gene_random_probability=0.1, genome_disable_probability=0.75, genome_node_probability=0.03, genome_connection_probability=0.05, species_asexual_probability=0.25, species_interspecies_reproduction_probability=0.001, species_keep_ratio=.5, gene_max_weight=1.0, gene_min_weight=-1.0, gene_weight_shift=.01, genome_weight_coefficient=0.4, genome_disjoint_coefficient=1.0, genome_excess_coefficient=1.0, genome_min_divide=20, species_age_fertility_limit=15, species_threshold=3.0, species_keep_champion=True, species_champion_limit=5, species_niche_divide_min=0, population_age_limit=20, population_size=Population, app_start_node_depth=0, app_end_node_depth=100) sim = DodgingSimulation(9, 5,