示例#1
0
def main():

    #------------------------------------------------------------------
    # Network
    #------------------------------------------------------------------

    # build network
    net = Solar_Low_Fidelity()
    net.number_of_engines = 1.
    net.nacelle_diameter = 0.05
    net.areas = Data()
    net.areas.wetted = 0.01 * (2 * np.pi * 0.01 / 2)
    net.engine_length = 0.01

    # Component 1 the Sun
    sun = SUAVE.Components.Energy.Processes.Solar_Radiation()
    net.solar_flux = sun

    # Component 2 the solar panels
    panel = SUAVE.Components.Energy.Converters.Solar_Panel()
    panel.ratio = 0.9
    panel.area = 1.0 * panel.ratio
    panel.efficiency = 0.25
    panel.mass_properties.mass = panel.area * (0.60 * Units.kg)
    net.solar_panel = panel

    # Component 3 the ESC
    esc = SUAVE.Components.Energy.Distributors.Electronic_Speed_Controller()
    esc.efficiency = 0.95  # Gundlach for brushless motors
    net.esc = esc

    # Component 5 the Propeller
    prop = SUAVE.Components.Energy.Converters.Propeller_Lo_Fid()
    prop.propulsive_efficiency = 0.825
    net.propeller = prop

    # Component 4 the Motor
    motor = SUAVE.Components.Energy.Converters.Motor_Lo_Fid()
    motor.speed_constant = 800. * Units['rpm/volt']  # RPM/volt is standard
    motor = size_from_kv(motor)
    motor.gear_ratio = 1.  # Gear ratio, no gearbox
    motor.gearbox_efficiency = 1.  # Gear box efficiency, no gearbox
    motor.motor_efficiency = 0.825
    net.motor = motor

    # Component 6 the Payload
    payload = SUAVE.Components.Energy.Peripherals.Payload()
    payload.power_draw = 0.  #Watts
    payload.mass_properties.mass = 0.0 * Units.kg
    net.payload = payload

    # Component 7 the Avionics
    avionics = SUAVE.Components.Energy.Peripherals.Avionics()
    avionics.power_draw = 10.  #Watts
    net.avionics = avionics

    # Component 8 the Battery
    bat = SUAVE.Components.Energy.Storages.Batteries.Constant_Mass.Lithium_Ion(
    )
    bat.mass_properties.mass = 5.0 * Units.kg
    bat.specific_energy = 250. * Units.Wh / Units.kg
    bat.resistance = 0.003
    bat.iters = 0
    initialize_from_mass(bat)
    net.battery = bat

    #Component 9 the system logic controller and MPPT
    logic = SUAVE.Components.Energy.Distributors.Solar_Logic()
    logic.system_voltage = 18.5
    logic.MPPT_efficiency = 0.95
    net.solar_logic = logic

    # Setup the conditions to run the network
    state = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(
    )
    state.numerics = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()

    conditions = state.conditions
    numerics = state.numerics

    # Calculate atmospheric properties
    atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976()
    atmosphere_conditions = atmosphere.compute_values(1000. * Units.ft)

    rho = atmosphere_conditions.density[0, :]
    a = atmosphere_conditions.speed_of_sound[0, :]
    mu = atmosphere_conditions.dynamic_viscosity[0, :]
    T = atmosphere_conditions.temperature[0, :]

    conditions.propulsion.throttle = np.array([[1.0], [1.0]])
    conditions.freestream.velocity = np.array([[1.0], [1.0]])
    conditions.freestream.density = np.array([rho, rho])
    conditions.freestream.dynamic_viscosity = np.array([mu, mu])
    conditions.freestream.speed_of_sound = np.array([a, a])
    conditions.freestream.altitude = np.array([[1000.0], [1000.0]])
    conditions.propulsion.battery_energy = bat.max_energy * np.ones_like(
        conditions.freestream.altitude)
    conditions.frames.body.inertial_rotations = np.zeros([2, 3])
    conditions.frames.inertial.time = np.array([[0.0], [1.0]])
    numerics.time.integrate = np.array([[0, 0], [0, 1]])
    numerics.time.differentiate = np.array([[0, 0], [0, 1]])
    numerics.time.control_points = np.array([[0, 0], [0, 1]])
    conditions.frames.planet.start_time = time.strptime(
        "Sat, Jun 21 06:00:00  2014",
        "%a, %b %d %H:%M:%S %Y",
    )
    conditions.frames.planet.latitude = np.array([[0.0], [0.0]])
    conditions.frames.planet.longitude = np.array([[0.0], [0.0]])
    conditions.freestream.temperature = np.array([T, T])
    conditions.frames.body.transform_to_inertial = np.array([[[1., 0., 0.],
                                                              [0., 1., 0.],
                                                              [0., 0., 1.]],
                                                             [[1., 0., 0.],
                                                              [0., 1., 0.],
                                                              [0., 0., 1.]]])
    # Run the network and print the results
    results = net(state)
    F = results.thrust_force_vector

    # Truth results
    truth_F = [[68.78277813], [68.78277813]]
    truth_i = [[5.75011436], [5.75011436]]
    truth_rpm = [[14390.30435183], [14390.30435183]]
    truth_bat = [[3169014.08450704], [3168897.35916947]]

    error = Data()
    error.Thrust = np.max(np.abs(F[:, 0] - truth_F))
    error.RPM = np.max(np.abs(conditions.propulsion.propeller_rpm - truth_rpm))
    error.Current = np.max(
        np.abs(conditions.propulsion.battery_current - truth_i))
    error.Battery = np.max(np.abs(bat.current_energy - truth_bat))

    print(error)

    for k, v in list(error.items()):
        assert (np.abs(v) < 1e-6)

    return
示例#2
0
def main():

    # ------------------------------------------------------------------
    #   Propulsor
    # ------------------------------------------------------------------

    # build network
    net = Solar()
    net.number_of_engines = 1.
    net.nacelle_dia = 0.2

    # Component 1 the Sun?
    sun = SUAVE.Components.Energy.Processes.Solar_Radiation()
    net.solar_flux = sun

    # Component 2 the solar panels
    panel = SUAVE.Components.Energy.Converters.Solar_Panel()
    panel.area = 100 * Units.m
    panel.efficiency = 0.18
    panel.mass_properties.mass = panel.area * .600
    net.solar_panel = panel

    # Component 3 the ESC
    esc = SUAVE.Components.Energy.Distributors.Electronic_Speed_Controller()
    esc.efficiency = 0.95  # Gundlach for brushless motors
    net.esc = esc

    # Component 5 the Propeller

    # Propeller design specs
    design_altitude = 0.0 * Units.km
    Velocity = 10.0  # freestream m/s
    RPM = 5887
    Blades = 2.0
    Radius = .4064
    Hub_Radius = 0.05
    Design_Cl = 0.7
    Thrust = 0.0  #Specify either thrust or power to design for
    Power = 7500.  #Specify either thrust or power to design for

    # Design the Propeller
    prop_attributes = Data()
    prop_attributes.number_blades = Blades
    prop_attributes.freestream_velocity = Velocity
    prop_attributes.angular_velocity = RPM * (2. * np.pi / 60.0)
    prop_attributes.tip_radius = Radius
    prop_attributes.hub_radius = Hub_Radius
    prop_attributes.design_Cl = Design_Cl
    prop_attributes.design_altitude = design_altitude
    prop_attributes.design_thrust = Thrust
    prop_attributes.design_power = Power
    prop_attributes = propeller_design(prop_attributes)

    # Create and attach this propeller
    prop = SUAVE.Components.Energy.Converters.Propeller()
    prop.prop_attributes = prop_attributes
    net.propeller = prop

    # Component 4 the Motor
    motor = SUAVE.Components.Energy.Converters.Motor()
    motor.resistance = 0.01
    motor.no_load_current = 8.0
    motor.speed_constant = 140. * (2. * np.pi / 60.
                                   )  # RPM/volt converted to rad/s
    motor.propeller_radius = prop.prop_attributes.tip_radius
    motor.propeller_Cp = prop.prop_attributes.Cp
    motor.gear_ratio = 1.
    motor.gearbox_efficiency = 1.
    motor.expected_current = 260.
    motor.mass_properties.mass = 2.0
    net.motor = motor

    # Component 6 the Payload
    payload = SUAVE.Components.Energy.Peripherals.Payload()
    payload.power_draw = 0.  #Watts
    payload.mass_properties.mass = 0. * Units.kg
    net.payload = payload

    # Component 7 the Avionics
    avionics = SUAVE.Components.Energy.Peripherals.Avionics()
    avionics.power_draw = 0.  #Watts
    net.avionics = avionics

    # Component 8 the Battery
    bat = SUAVE.Components.Energy.Storages.Batteries.Constant_Mass.Lithium_Ion(
    )
    batterymass = 50.  #kg
    bat.type = 'Li-Ion'
    bat.resistance = 0.0
    bat.energy_density = 250.
    initialize_from_mass(bat, batterymass)
    bat.current_energy = bat.max_energy
    net.battery = bat

    #Component 9 the system logic controller and MPPT
    logic = SUAVE.Components.Energy.Distributors.Solar_Logic()
    logic.system_voltage = 50.0
    logic.MPPT_efficiency = 0.95
    net.solar_logic = logic

    # Setup the conditions to run the network
    state = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(
    )
    state.numerics = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()

    conditions = state.conditions
    numerics = state.numerics

    # Calculate atmospheric properties
    atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976()
    atmosphere_conditions = atmosphere.compute_values(
        prop_attributes.design_altitude)

    rho = atmosphere_conditions.density[0, :]
    a = atmosphere_conditions.speed_of_sound[0, :]
    mu = atmosphere_conditions.dynamic_viscosity[0, :]
    T = atmosphere_conditions.temperature[0, :]

    conditions.propulsion.throttle = np.array([[1.0], [1.0]])
    conditions.freestream.velocity = np.array([[1.0], [1.0]])
    conditions.freestream.density = np.array([rho, rho])
    conditions.freestream.dynamic_viscosity = np.array([mu, mu])
    conditions.freestream.speed_of_sound = np.array([a, a])
    conditions.freestream.altitude = np.array([[design_altitude],
                                               [design_altitude]])
    conditions.propulsion.battery_energy = bat.max_energy * np.ones_like(
        conditions.freestream.altitude)
    conditions.frames.body.inertial_rotations = np.zeros([2, 3])
    conditions.frames.inertial.time = np.array([[0.0], [1.0]])
    numerics.time.integrate = np.array([[0, 0], [0, 1]])
    numerics.time.differentiate = np.array([[0, 0], [0, 1]])
    conditions.frames.planet.start_time = time.strptime(
        "Sat, Jun 21 06:00:00  2014",
        "%a, %b %d %H:%M:%S %Y",
    )
    conditions.frames.planet.latitude = np.array([[0.0], [0.0]])
    conditions.frames.planet.longitude = np.array([[0.0], [0.0]])
    conditions.freestream.temperature = np.array([T, T])

    # Run the network and print the results
    results = net(state)
    F = results.thrust_force_vector

    # Truth results
    truth_F = [[522.40448791], [522.40448791]]
    truth_i = [[314.90485916], [314.90485916]]
    truth_rpm = [[6581.17653732], [6581.17653732]]
    truth_bat = [[36000000.], [35984254.75704217]]

    error = Data()
    error.Thrust = np.max(np.abs(F[:, 0] - truth_F))
    error.RPM = np.max(np.abs(conditions.propulsion.rpm - truth_rpm))
    error.Current = np.max(np.abs(conditions.propulsion.current - truth_i))
    error.Battery = np.max(np.abs(bat.current_energy - truth_bat))

    print error

    for k, v in error.items():
        assert (np.abs(v) < 0.001)

    return
示例#3
0
def main():

    # vehicle data
    vehicle = vehicle_setup()
    configs = configs_setup(vehicle)

    # vehicle analyses
    configs_analyses = analyses_setup(configs)

    # mission analyses
    mission = mission_setup(configs_analyses, vehicle)
    missions_analyses = missions_setup(mission)

    analyses = SUAVE.Analyses.Analysis.Container()
    analyses.configs = configs_analyses
    analyses.missions = missions_analyses

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # load older results
    #save_results(results)
    old_results = load_results()

    ## plt the old results
    plot_mission(results)
    plot_mission(old_results, 'k-')

    # Check Results
    F = results.segments.cruise1.conditions.frames.body.thrust_force_vector[1,
                                                                            0]
    rpm = results.segments.cruise1.conditions.propulsion.propeller_rpm[1, 0]
    current = results.segments.cruise1.conditions.propulsion.battery_current[1,
                                                                             0]
    energy = results.segments.cruise1.conditions.propulsion.battery_energy[8,
                                                                           0]

    # Truth results

    truth_F = 105.36115293829462
    truth_rpm = 218.18739964349612
    truth_i = 130.17994767726535
    truth_bat = 136584698.345862

    print('battery energy')
    print(energy)
    print('\n')

    error = Data()
    error.Thrust = np.max(np.abs((F - truth_F) / truth_F))
    error.RPM = np.max(np.abs((rpm - truth_rpm) / truth_rpm))
    error.Current = np.max(np.abs((current - truth_i) / truth_i))
    error.Battery = np.max(np.abs((energy - truth_bat) / truth_bat))

    print(error)

    for k, v in list(error.items()):
        assert (np.abs(v) < 1e-6)

    # Plot vehicle
    plot_vehicle(configs.cruise, save_figure=False, plot_control_points=True)

    return
def main():
   
    #------------------------------------------------------------------
    # Propulsor
    #------------------------------------------------------------------

    # build network
    net = Solar_Low_Fidelity()
    net.number_of_engines = 1.
    net.nacelle_diameter  = 0.05
    net.areas             = Data()
    net.areas.wetted      = 0.01*(2*np.pi*0.01/2)
    net.engine_length     = 0.01

    # Component 1 the Sun
    sun = SUAVE.Components.Energy.Processes.Solar_Radiation()
    net.solar_flux = sun

    # Component 2 the solar panels
    panel = SUAVE.Components.Energy.Converters.Solar_Panel()
    panel.ratio                = 0.9
    panel.area                 = 1.0 * panel.ratio 
    panel.efficiency           = 0.25
    panel.mass_properties.mass = panel.area*(0.60 * Units.kg)
    net.solar_panel            = panel

    # Component 3 the ESC
    esc = SUAVE.Components.Energy.Distributors.Electronic_Speed_Controller()
    esc.efficiency = 0.95 # Gundlach for brushless motors
    net.esc        = esc

    # Component 5 the Propeller
    prop = SUAVE.Components.Energy.Converters.Propeller_Lo_Fid()
    prop.propulsive_efficiency = 0.825
    net.propeller        = prop
    
    # Component 4 the Motor
    motor = SUAVE.Components.Energy.Converters.Motor_Lo_Fid()
    kv                         = 800. * Units['rpm/volt'] # RPM/volt is standard
    motor                      = size_from_kv(motor, kv)    
    motor.gear_ratio           = 1. # Gear ratio, no gearbox
    motor.gearbox_efficiency   = 1. # Gear box efficiency, no gearbox
    motor.motor_efficiency     = 0.825;
    net.motor                  = motor    

    # Component 6 the Payload
    payload = SUAVE.Components.Energy.Peripherals.Payload()
    payload.power_draw           = 0. #Watts 
    payload.mass_properties.mass = 0.0 * Units.kg
    net.payload                  = payload

    # Component 7 the Avionics
    avionics = SUAVE.Components.Energy.Peripherals.Avionics()
    avionics.power_draw = 10. #Watts  
    net.avionics        = avionics      

    # Component 8 the Battery
    bat = SUAVE.Components.Energy.Storages.Batteries.Constant_Mass.Lithium_Ion()
    bat.mass_properties.mass = 5.0  * Units.kg
    bat.specific_energy      = 250. *Units.Wh/Units.kg
    bat.resistance           = 0.003
    bat.iters                = 0
    initialize_from_mass(bat,bat.mass_properties.mass)
    net.battery              = bat

    #Component 9 the system logic controller and MPPT
    logic = SUAVE.Components.Energy.Distributors.Solar_Logic()
    logic.system_voltage  = 18.5
    logic.MPPT_efficiency = 0.95
    net.solar_logic       = logic
    
    # Setup the conditions to run the network
    state            = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics()
    state.numerics   = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()
    
    conditions = state.conditions
    numerics   = state.numerics
    
    # Calculate atmospheric properties
    atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976()
    atmosphere_conditions =  atmosphere.compute_values(1000.*Units.ft)
    
    rho = atmosphere_conditions.density[0,:]
    a   = atmosphere_conditions.speed_of_sound[0,:]
    mu  = atmosphere_conditions.dynamic_viscosity[0,:]
    T   = atmosphere_conditions.temperature[0,:]

    conditions.propulsion.throttle            = np.array([[1.0],[1.0]])
    conditions.freestream.velocity            = np.array([[1.0],[1.0]])
    conditions.freestream.density             = np.array([rho,rho])
    conditions.freestream.dynamic_viscosity   = np.array([mu, mu])
    conditions.freestream.speed_of_sound      = np.array([a, a])
    conditions.freestream.altitude            = np.array([[1000.0],[1000.0]])
    conditions.propulsion.battery_energy      = bat.max_energy*np.ones_like(conditions.freestream.altitude)
    conditions.frames.body.inertial_rotations = np.zeros([2,3])
    conditions.frames.inertial.time           = np.array([[0.0],[1.0]])
    numerics.time.integrate                   = np.array([[0, 0],[0, 1]])
    numerics.time.differentiate               = np.array([[0, 0],[0, 1]])
    conditions.frames.planet.start_time       = time.strptime("Sat, Jun 21 06:00:00  2014", "%a, %b %d %H:%M:%S %Y",) 
    conditions.frames.planet.latitude         = np.array([[0.0],[0.0]])
    conditions.frames.planet.longitude        = np.array([[0.0],[0.0]])
    conditions.freestream.temperature         = np.array([T, T])
    conditions.frames.body.transform_to_inertial = np.array([[[ 1.,  0.,  0.],
                                                              [ 0.,  1.,  0.],
                                                              [ 0.,  0.,  1.]],
                                                             [[ 1.,  0.,  0.],
                                                              [ 0.,  1.,  0.],
                                                              [ 0.,  0.,  1.]]])   
    # Run the network and print the results
    results = net(state)
    F       = results.thrust_force_vector
    
    # Truth results
    truth_F   = [[ 68.78277813   ], [ 68.78277813     ]]
    truth_i   = [[ 5.75011436    ], [ 5.75011436      ]]
    truth_rpm = [[ 14390.30435183], [ 14390.30435183  ]]
    truth_bat = [[ 4500000.      ], [ 4499883.5041616 ]]
    
    error = Data()
    error.Thrust = np.max(np.abs(F[:,0]-truth_F))
    error.RPM = np.max(np.abs(conditions.propulsion.rpm-truth_rpm))
    error.Current  = np.max(np.abs(conditions.propulsion.current-truth_i))
    error.Battery = np.max(np.abs(bat.current_energy-truth_bat))
    
    print(error)
    
    for k,v in list(error.items()):
        assert(np.abs(v)<1e-6)        
    
    return
示例#5
0
def main():

    # ------------------------------------------------------------------
    #   Propulsor
    # ------------------------------------------------------------------
    
    # build network
    net = Solar()
    net.number_of_engines = 1.
    net.nacelle_dia       = 0.2
    
    # Component 1 the Sun?
    sun = SUAVE.Components.Energy.Processes.Solar_Radiation()
    net.solar_flux = sun
    
    # Component 2 the solar panels
    panel = SUAVE.Components.Energy.Converters.Solar_Panel()
    panel.area                 = 100 * Units.m
    panel.efficiency           = 0.18
    panel.mass_properties.mass = panel.area*.600
    net.solar_panel            = panel
    
    # Component 3 the ESC
    esc = SUAVE.Components.Energy.Distributors.Electronic_Speed_Controller()
    esc.efficiency = 0.95 # Gundlach for brushless motors
    net.esc       = esc
    
    # Component 5 the Propeller
    
    # Propeller design specs
    design_altitude = 0.0 * Units.km
    Velocity        = 10.0  # freestream m/s
    RPM             = 5887
    Blades          = 2.0
    Radius          = .4064
    Hub_Radius      = 0.05
    Design_Cl       = 0.7
    Thrust          = 0.0 #Specify either thrust or power to design for
    Power           = 7500.  #Specify either thrust or power to design for
    
    # Design the Propeller
    prop_attributes = Data()
    prop_attributes.number_blades       = Blades 
    prop_attributes.freestream_velocity = Velocity
    prop_attributes.angular_velocity    = RPM*(2.*np.pi/60.0)
    prop_attributes.tip_radius          = Radius
    prop_attributes.hub_radius          = Hub_Radius
    prop_attributes.design_Cl           = Design_Cl 
    prop_attributes.design_altitude     = design_altitude
    prop_attributes.design_thrust       = Thrust
    prop_attributes.design_power        = Power
    prop_attributes                     = propeller_design(prop_attributes)
    
    # Create and attach this propeller
    prop                 = SUAVE.Components.Energy.Converters.Propeller()
    prop.prop_attributes = prop_attributes
    net.propeller        = prop
    
    # Component 4 the Motor
    motor = SUAVE.Components.Energy.Converters.Motor()
    motor.resistance           = 0.01
    motor.no_load_current      = 8.0
    motor.speed_constant       = 140.*(2.*np.pi/60.) # RPM/volt converted to rad/s     
    motor.propeller_radius     = prop.prop_attributes.tip_radius
    #motor.propeller_Cp         = prop.prop_attributes.Cp
    motor.gear_ratio           = 1.
    motor.gearbox_efficiency   = 1.
    motor.expected_current     = 260.
    motor.mass_properties.mass = 2.0
    net.motor                  = motor   
    
    # Component 6 the Payload
    payload = SUAVE.Components.Energy.Peripherals.Payload()
    payload.power_draw           = 0. #Watts 
    payload.mass_properties.mass = 0. * Units.kg
    net.payload                  = payload
    
    # Component 7 the Avionics
    avionics = SUAVE.Components.Energy.Peripherals.Avionics()
    avionics.power_draw = 0. #Watts  
    net.avionics        = avionics      
    
    # Component 8 the Battery
    bat = SUAVE.Components.Energy.Storages.Batteries.Constant_Mass.Lithium_Ion()
    batterymass = 50.  #kg
    bat.type = 'Li-Ion'
    bat.resistance = 0.0
    bat.energy_density = 250.
    initialize_from_mass(bat,batterymass)
    bat.current_energy = bat.max_energy
    net.battery = bat
    
    #Component 9 the system logic controller and MPPT
    logic = SUAVE.Components.Energy.Distributors.Solar_Logic()
    logic.system_voltage  = 50.0
    logic.MPPT_efficiency = 0.95
    net.solar_logic       = logic
    
    # Setup the conditions to run the network
    state            = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics()
    state.numerics   = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()
    
    conditions = state.conditions
    numerics   = state.numerics
    
    # Calculate atmospheric properties
    atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976()
    atmosphere_conditions =  atmosphere.compute_values(prop_attributes.design_altitude)
    
    rho = atmosphere_conditions.density[0,:]
    a   = atmosphere_conditions.speed_of_sound[0,:]
    mu  = atmosphere_conditions.dynamic_viscosity[0,:]
    T   = atmosphere_conditions.temperature[0,:]

    conditions.propulsion.throttle            = np.array([[1.0],[1.0]])
    conditions.freestream.velocity            = np.array([[1.0],[1.0]])
    conditions.freestream.density             = np.array([rho,rho])
    conditions.freestream.dynamic_viscosity   = np.array([mu, mu])
    conditions.freestream.speed_of_sound      = np.array([a, a])
    conditions.freestream.altitude            = np.array([[design_altitude], [design_altitude]])
    conditions.propulsion.battery_energy      = bat.max_energy*np.ones_like(conditions.freestream.altitude)
    conditions.frames.body.inertial_rotations = np.zeros([2,3])
    conditions.frames.inertial.time           = np.array([[0.0],[1.0]])
    numerics.time.integrate                   = np.array([[0, 0],[0, 1]])
    numerics.time.differentiate               = np.array([[0, 0],[0, 1]])
    conditions.frames.planet.start_time       = time.strptime("Sat, Jun 21 06:00:00  2014", "%a, %b %d %H:%M:%S %Y",) 
    conditions.frames.planet.latitude         = np.array([[0.0],[0.0]])
    conditions.frames.planet.longitude        = np.array([[0.0],[0.0]])
    conditions.freestream.temperature         = np.array([T, T])
    conditions.frames.body.transform_to_inertial = np.array([[[ 1.,  0.,  0.],
                                                              [ 0.,  1.,  0.],
                                                              [ 0.,  0.,  1.]],
                                                             [[ 1.,  0.,  0.],
                                                              [ 0.,  1.,  0.],
                                                              [ 0.,  0.,  1.]]])
    conditions.propulsion.propeller_power_coefficient = np.array([[1.], [1.]]) * prop.prop_attributes.Cp
    
    # Run the network and print the results
    results = net(state)
    F       = results.thrust_force_vector
    
    # Truth results
    truth_F   = [[ 545.35952329,  545.35952329]]
    truth_i   = [[ 249.31622624], [ 249.31622624]]
    truth_rpm = [[ 6668.4094191], [ 6668.4094191]]
    truth_bat = [[ 36000000.   ], [ 35987534.18868808]]
    
    error = Data()
    error.Thrust = np.max(np.abs(F[:,0]-truth_F))
    error.RPM = np.max(np.abs(conditions.propulsion.rpm-truth_rpm))
    error.Current  = np.max(np.abs(conditions.propulsion.current-truth_i))
    error.Battery = np.max(np.abs(bat.current_energy-truth_bat))
    
    print(error)
    
    for k,v in list(error.items()):
        assert(np.abs(v)<1e-6)
        
    
    return
示例#6
0
def main():

    # vehicle data
    vehicle = vehicle_setup()
    configs = configs_setup(vehicle)

    # vehicle analyses
    configs_analyses = analyses_setup(configs)

    # mission analyses
    mission = mission_setup(configs_analyses, vehicle)
    missions_analyses = missions_setup(mission)

    analyses = SUAVE.Analyses.Analysis.Container()
    analyses.configs = configs_analyses
    analyses.missions = missions_analyses

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # load older results
    #save_results(results)
    old_results = load_results()

    # plt the old results
    plot_mission(results)
    plot_mission(old_results, 'k-')

    # Check Results
    F = results.segments.cruise1.conditions.frames.body.thrust_force_vector[1,
                                                                            0]
    rpm = results.segments.cruise1.conditions.propulsion.rpm[1, 0]
    current = results.segments.cruise1.conditions.propulsion.current[1, 0]
    energy = results.segments.cruise1.conditions.propulsion.battery_energy[8,
                                                                           0]

    # Truth results
    truth_F = 105.9739169506257
    truth_rpm = 214.27179253741863
    truth_i = 178.88932733145853
    truth_bat = 187815498.6290547

    print('battery energy')
    print(energy)
    print('\n')

    error = Data()
    error.Thrust = np.max(np.abs((F - truth_F) / truth_F))
    error.RPM = np.max(np.abs((rpm - truth_rpm) / truth_rpm))
    error.Current = np.max(np.abs((current - truth_i) / truth_i))
    error.Battery = np.max(np.abs((energy - truth_bat) / truth_bat))

    print(error)

    for k, v in list(error.items()):
        assert (np.abs(v) < 1e-6)

    return