def configure(self):
        # pylint: disable-msg=E1101

        # Create CONMIN Optimizer instance
        self.add('driver', CONMINdriver())

        # Create Vehicle instance
        self.add('vehicle', Vehicle())

        # Create Driving Simulation instances
        self.add('sim_acc', SimAcceleration())
        self.add('sim_EPA_city', SimEconomy())
        self.add('sim_EPA_highway', SimEconomy())

        # add Sims to optimizer workflow
        self.driver.workflow.add(
            ['sim_acc', 'sim_EPA_city', 'sim_EPA_highway'])

        # Add vehicle to sim workflows.
        self.sim_acc.workflow.add('vehicle')
        self.sim_EPA_city.workflow.add('vehicle')
        self.sim_EPA_highway.workflow.add('vehicle')

        # CONMIN Flags
        self.driver.iprint = 0
        self.driver.itmax = 30

        # CONMIN Objective
        self.driver.add_objective('sim_acc.accel_time')

        # CONMIN Design Variables
        self.driver.add_parameter('vehicle.spark_angle', -50., 10.)
        self.driver.add_parameter('vehicle.bore', 65., 100.)

        # Acceleration Sim setup
        self.sim_acc.velocity_str = 'vehicle.velocity'
        self.sim_acc.throttle_str = 'vehicle.throttle'
        self.sim_acc.gear_str = 'vehicle.current_gear'
        self.sim_acc.acceleration_str = 'vehicle.acceleration'
        self.sim_acc.overspeed_str = 'vehicle.overspeed'

        # EPA City MPG Sim Setup
        self.sim_EPA_city.velocity_str = 'vehicle.velocity'
        self.sim_EPA_city.throttle_str = 'vehicle.throttle'
        self.sim_EPA_city.gear_str = 'vehicle.current_gear'
        self.sim_EPA_city.acceleration_str = 'vehicle.acceleration'
        self.sim_EPA_city.fuel_burn_str = 'vehicle.fuel_burn'
        self.sim_EPA_city.overspeed_str = 'vehicle.overspeed'
        self.sim_EPA_city.underspeed_str = 'vehicle.underspeed'
        self.sim_EPA_city.profilename = 'EPA-city.csv'

        # EPA Highway MPG Sim Setup
        self.sim_EPA_highway.velocity_str = 'vehicle.velocity'
        self.sim_EPA_highway.throttle_str = 'vehicle.throttle'
        self.sim_EPA_highway.gear_str = 'vehicle.current_gear'
        self.sim_EPA_highway.acceleration_str = 'vehicle.acceleration'
        self.sim_EPA_highway.fuel_burn_str = 'vehicle.fuel_burn'
        self.sim_EPA_highway.overspeed_str = 'vehicle.overspeed'
        self.sim_EPA_highway.underspeed_str = 'vehicle.underspeed'
        self.sim_EPA_highway.profilename = 'EPA-highway.csv'
Exemple #2
0
    def configure(self):
        """ Configures a new Assembly for vehicle performance optimization."""

        # Create Vehicle instance
        self.add('vehicle', Vehicle())

        # Create 0-60 Acceleration Simulation instance
        self.add('driver', SimAcceleration())

        # Add vehicle to sim workflows.
        self.driver.workflow.add('vehicle')

        # Acceleration Sim setup
        self.driver.add_parameter('vehicle.velocity',
                                  name='velocity',
                                  low=0.0,
                                  high=150.0)
        self.driver.add_parameter('vehicle.throttle',
                                  name='throttle',
                                  low=0.01,
                                  high=1.0)
        self.driver.add_parameter('vehicle.current_gear',
                                  name='gear',
                                  low=0,
                                  high=5)
        self.driver.add_objective('vehicle.acceleration', name='acceleration')
        self.driver.add_objective('vehicle.overspeed', name='overspeed')
Exemple #3
0
    def setUp(self):
        
        self.top = set_as_top(Assembly())

        self.top.add('sim_acc', SimAcceleration())
        self.top.add('sim_EPA_city', SimEconomy())
        self.top.add('vehicle', Vehicle())
        
        self.top.driver.workflow.add('sim_acc')
        self.top.driver.workflow.add('sim_EPA_city')
        self.top.driver.workflow.add('sim_EPA_highway')
        
        self.top.sim_acc.workflow.add('vehicle')
        self.top.sim_acc.velocity_str = 'vehicle.velocity'
        self.top.sim_acc.throttle_str = 'vehicle.throttle'
        self.top.sim_acc.gear_str = 'vehicle.current_gear'
        self.top.sim_acc.acceleration_str = 'vehicle.acceleration'
        self.top.sim_acc.overspeed_str = 'vehicle.overspeed'
        
        self.top.sim_EPA_city.workflow.add('vehicle')
        self.top.sim_EPA_city.velocity_str = 'vehicle.velocity'
        self.top.sim_EPA_city.throttle_str = 'vehicle.throttle'
        self.top.sim_EPA_city.gear_str = 'vehicle.current_gear'
        self.top.sim_EPA_city.acceleration_str = 'vehicle.acceleration'
        self.top.sim_EPA_city.fuel_burn_str = 'vehicle.fuel_burn'
        self.top.sim_EPA_city.overspeed_str = 'vehicle.overspeed'
        self.top.sim_EPA_city.underspeed_str = 'vehicle.underspeed'
        self.top.sim_EPA_city.profilename = 'EPA-city.csv'
Exemple #4
0
    def setUp(self):

        self.top = set_as_top(Assembly())

        self.top.add('sim_acc', SimAcceleration())
        self.top.add('sim_EPA_city', SimEconomy())
        self.top.add('vehicle', Vehicle())

        self.top.driver.workflow.add('sim_acc')
        self.top.driver.workflow.add('sim_EPA_city')
        self.top.driver.workflow.add('sim_EPA_highway')

        self.top.sim_acc.workflow.add('vehicle')
        self.top.sim_acc.add_parameter('vehicle.velocity', name='velocity',
                                       low=0.0, high=150.0)
        self.top.sim_acc.add_parameter('vehicle.throttle', name='throttle',
                                       low=0.01, high=1.0)
        self.top.sim_acc.add_parameter('vehicle.current_gear', name='gear',
                                       low=0, high=5)
        self.top.sim_acc.add_objective('vehicle.acceleration', name='acceleration')
        self.top.sim_acc.add_objective('vehicle.overspeed', name='overspeed')

        self.top.sim_EPA_city.workflow.add('vehicle')
        self.top.sim_EPA_city.add_parameter('vehicle.velocity', name='velocity',
                                            low=0.0, high=150.0)
        self.top.sim_EPA_city.add_parameter('vehicle.throttle', name='throttle',
                                            low=0.01, high=1.0)
        self.top.sim_EPA_city.add_parameter('vehicle.current_gear', name='gear',
                                            low=0, high=5)
        self.top.sim_EPA_city.add_objective('vehicle.acceleration', name='acceleration')
        self.top.sim_EPA_city.add_objective('vehicle.fuel_burn', name='fuel_burn')
        self.top.sim_EPA_city.add_objective('vehicle.overspeed', name='overspeed')
        self.top.sim_EPA_city.add_objective('vehicle.underspeed', name='underspeed')
        self.top.sim_EPA_city.profilename = 'EPA-city.csv'
Exemple #5
0
def test_json():
    from openmdao.examples.enginedesign.engine import Engine
    my_engine = Engine()

    print 'RPM =', my_engine.RPM
    json = jsonpickle.encode(my_engine)
    print 'json = ', json

    my_engine.RPM = 4000

    print 'RPM =', my_engine.RPM
    json = jsonpickle.encode(my_engine)
    print 'json = ', json

    from openmdao.examples.enginedesign.vehicle import Vehicle
    my_car = Vehicle()
    my_car.velocity = 25.0
    my_car.current_gear = 3
    my_car.throttle = .5

    json = jsonpickle.encode(my_car)
    print 'json = ', json
def test_json():
    from openmdao.examples.enginedesign.engine import Engine
    my_engine = Engine()

    print 'RPM =',my_engine.RPM
    json = jsonpickle.encode(my_engine)
    print 'json = ',json

    my_engine.RPM = 4000

    print 'RPM =',my_engine.RPM
    json = jsonpickle.encode(my_engine)
    print 'json = ',json

    from openmdao.examples.enginedesign.vehicle import Vehicle
    my_car = Vehicle()
    my_car.velocity = 25.0
    my_car.current_gear = 3
    my_car.throttle = .5

    json = jsonpickle.encode(my_car)
    print 'json = ',json
Exemple #7
0
    def __init__(self):
        """ Creates a new Assembly for vehicle performance optimization."""
        
        super(VehicleSim2, self).__init__()

        # Create Vehicle instance
        self.add('vehicle', Vehicle())
        
        # Create Driving Simulation instances
        self.add('sim_acc', SimAcceleration())
        self.add('sim_EPA_city', SimEconomy())
        self.add('sim_EPA_highway', SimEconomy())
        
        # add Sims to default workflow
        self.driver.workflow.add(['sim_acc', 'sim_EPA_city', 'sim_EPA_highway'])
        
        # Add vehicle to sim workflows.
        self.sim_acc.workflow.add('vehicle')
        self.sim_EPA_city.workflow.add('vehicle')
        self.sim_EPA_highway.workflow.add('vehicle')
    
        # Acceleration Sim setup
        self.sim_acc.velocity_str = 'vehicle.velocity'
        self.sim_acc.throttle_str = 'vehicle.throttle'
        self.sim_acc.gear_str = 'vehicle.current_gear'
        self.sim_acc.acceleration_str = 'vehicle.acceleration'
        self.sim_acc.overspeed_str = 'vehicle.overspeed'
        
        # EPA City MPG Sim Setup
        self.sim_EPA_city.velocity_str = 'vehicle.velocity'
        self.sim_EPA_city.throttle_str = 'vehicle.throttle'
        self.sim_EPA_city.gear_str = 'vehicle.current_gear'
        self.sim_EPA_city.acceleration_str = 'vehicle.acceleration'
        self.sim_EPA_city.fuel_burn_str = 'vehicle.fuel_burn'
        self.sim_EPA_city.overspeed_str = 'vehicle.overspeed'
        self.sim_EPA_city.underspeed_str = 'vehicle.underspeed'
        self.sim_EPA_city.profilename = 'EPA-city.csv'
        self.sim_EPA_city.force_execute = True
        
        # EPA Highway MPG Sim Setup
        self.sim_EPA_highway.velocity_str = 'vehicle.velocity'
        self.sim_EPA_highway.throttle_str = 'vehicle.throttle'
        self.sim_EPA_highway.gear_str = 'vehicle.current_gear'
        self.sim_EPA_highway.acceleration_str = 'vehicle.acceleration'
        self.sim_EPA_highway.fuel_burn_str = 'vehicle.fuel_burn'
        self.sim_EPA_highway.overspeed_str = 'vehicle.overspeed'
        self.sim_EPA_highway.underspeed_str = 'vehicle.underspeed'
        self.sim_EPA_highway.profilename = 'EPA-highway.csv'        
        self.sim_EPA_highway.force_execute = True
    def configure(self):
        """ Configures a new Assembly for vehicle performance optimization."""

        # Create Vehicle instance
        self.add('vehicle', Vehicle())

        # Create 0-60 Acceleration Simulation instance
        self.add('driver', SimAcceleration())

        # Add vehicle to sim workflows.
        self.driver.workflow.add('vehicle')

        # Acceleration Sim setup
        self.driver.velocity_str = 'vehicle.velocity'
        self.driver.throttle_str = 'vehicle.throttle'
        self.driver.gear_str = 'vehicle.current_gear'
        self.driver.acceleration_str = 'vehicle.acceleration'
        self.driver.overspeed_str = 'vehicle.overspeed'
    def __init__(self):
        """ Creates a new Assembly for vehicle performance optimization."""

        super(EngineOptimization, self).__init__()

        # pylint: disable-msg=E1101

        # Create CONMIN Optimizer instance
        self.add('optimizer', CONMINdriver())

        # Create Vehicle instance
        self.add('vehicle', Vehicle())

        # Create Driving Simulation instances
        self.add('sim_acc', SimAcceleration())
        self.add('sim_EPA_city', SimEconomy())
        self.add('sim_EPA_highway', SimEconomy())

        # add the optimizer and economy sims to driver workflow
        self.driver.workflow.add(
            ['optimizer', 'sim_EPA_city', 'sim_EPA_highway'])

        # add the acceleration sim to the optimizer workflow
        self.optimizer.workflow.add('sim_acc')

        # Add vehicle to sim workflows.
        self.sim_acc.workflow.add('vehicle')
        self.sim_EPA_city.workflow.add('vehicle')
        self.sim_EPA_highway.workflow.add('vehicle')

        # CONMIN Flags
        self.optimizer.iprint = 0
        self.optimizer.itmax = 30

        # CONMIN Objective
        self.optimizer.add_objective('sim_acc.accel_time')

        # CONMIN Design Variables
        self.optimizer.add_parameter('vehicle.spark_angle', -50., 10.)
        self.optimizer.add_parameter('vehicle.bore', 65., 100.)

        # Acceleration Sim setup
        self.sim_acc.velocity_str = 'vehicle.velocity'
        self.sim_acc.throttle_str = 'vehicle.throttle'
        self.sim_acc.gear_str = 'vehicle.current_gear'
        self.sim_acc.acceleration_str = 'vehicle.acceleration'
        self.sim_acc.overspeed_str = 'vehicle.overspeed'

        # EPA City MPG Sim Setup
        self.sim_EPA_city.velocity_str = 'vehicle.velocity'
        self.sim_EPA_city.throttle_str = 'vehicle.throttle'
        self.sim_EPA_city.gear_str = 'vehicle.current_gear'
        self.sim_EPA_city.acceleration_str = 'vehicle.acceleration'
        self.sim_EPA_city.fuel_burn_str = 'vehicle.fuel_burn'
        self.sim_EPA_city.overspeed_str = 'vehicle.overspeed'
        self.sim_EPA_city.underspeed_str = 'vehicle.underspeed'
        self.sim_EPA_city.profilename = 'EPA-city.csv'
        self.sim_EPA_city.force_execute = True

        # EPA Highway MPG Sim Setup
        self.sim_EPA_highway.velocity_str = 'vehicle.velocity'
        self.sim_EPA_highway.throttle_str = 'vehicle.throttle'
        self.sim_EPA_highway.gear_str = 'vehicle.current_gear'
        self.sim_EPA_highway.acceleration_str = 'vehicle.acceleration'
        self.sim_EPA_highway.fuel_burn_str = 'vehicle.fuel_burn'
        self.sim_EPA_highway.overspeed_str = 'vehicle.overspeed'
        self.sim_EPA_highway.underspeed_str = 'vehicle.underspeed'
        self.sim_EPA_highway.profilename = 'EPA-highway.csv'
        self.sim_EPA_highway.force_execute = True
Exemple #10
0
    def configure(self):

        # pylint: disable-msg=E1101
        
        # Create CONMIN Optimizer instance
        self.add('optimizer', CONMINdriver())
        
        # Create Vehicle instance
        self.add('vehicle', Vehicle())
        
        # Create Driving Simulation instances
        self.add('sim_acc', SimAcceleration())
        self.add('sim_EPA_city', SimEconomy())
        self.add('sim_EPA_highway', SimEconomy())
        
        # add the optimizer and economy sims to driver workflow
        self.driver.workflow.add(['optimizer', 'sim_EPA_city', 'sim_EPA_highway'])
        
        # add the acceleration sim to the optimizer workflow
        self.optimizer.workflow.add('sim_acc')
        
        # Add vehicle to sim workflows.
        self.sim_acc.workflow.add('vehicle')
        self.sim_EPA_city.workflow.add('vehicle')
        self.sim_EPA_highway.workflow.add('vehicle')
    
        # CONMIN Flags
        self.optimizer.iprint = 0
        self.optimizer.itmax = 30
        self.optimizer.conmin_diff = True
        
        # CONMIN Objective 
        self.optimizer.add_objective('sim_acc.accel_time')
        
        # CONMIN Design Variables 
        self.optimizer.add_parameter('vehicle.spark_angle', -50., 10.)
        self.optimizer.add_parameter('vehicle.bore', 65., 100.)
        
        # Acceleration Sim setup
        self.sim_acc.add_parameter('vehicle.velocity', name='velocity',
                                  low=0.0, high=150.0)
        self.sim_acc.add_parameter('vehicle.throttle', name='throttle',
                                  low=0.01, high=1.0)
        self.sim_acc.add_parameter('vehicle.current_gear', name='gear',
                                  low=0, high=5)
        self.sim_acc.add_objective('vehicle.acceleration', name='acceleration')
        self.sim_acc.add_objective('vehicle.overspeed', name='overspeed')
        
        # EPA City MPG Sim Setup
        self.sim_EPA_city.add_parameter('vehicle.velocity', name='velocity',
                                  low=0.0, high=150.0)
        self.sim_EPA_city.add_parameter('vehicle.throttle', name='throttle',
                                  low=0.01, high=1.0)
        self.sim_EPA_city.add_parameter('vehicle.current_gear', name='gear',
                                  low=0, high=5)
        self.sim_EPA_city.add_objective('vehicle.acceleration', name='acceleration')
        self.sim_EPA_city.add_objective('vehicle.fuel_burn', name='fuel_burn')
        self.sim_EPA_city.add_objective('vehicle.overspeed', name='overspeed')
        self.sim_EPA_city.add_objective('vehicle.underspeed', name='underspeed')
        self.sim_EPA_city.profilename = 'EPA-city.csv'
        
        # EPA Highway MPG Sim Setup
        self.sim_EPA_highway.add_parameter('vehicle.velocity', name='velocity',
                                  low=0.0, high=150)
        self.sim_EPA_highway.add_parameter('vehicle.throttle', name='throttle',
                                  low=0.01, high=1.0)
        self.sim_EPA_highway.add_parameter('vehicle.current_gear', name='gear',
                                  low=0, high=5)
        self.sim_EPA_highway.add_objective('vehicle.acceleration', name='acceleration')
        self.sim_EPA_highway.add_objective('vehicle.fuel_burn', name='fuel_burn')
        self.sim_EPA_highway.add_objective('vehicle.overspeed', name='overspeed')
        self.sim_EPA_highway.add_objective('vehicle.underspeed', name='underspeed')
        self.sim_EPA_highway.profilename = 'EPA-highway.csv'
Exemple #11
0
        return gear


if __name__ == "__main__":  # pragma: no cover

    import time
    ttime = time.time()

    from openmdao.main.api import Assembly
    from openmdao.examples.enginedesign.vehicle import Vehicle

    top = Assembly()
    top.add('sim_acc', SimAcceleration())
    top.add('sim_EPA_city', SimEconomy())
    top.add('sim_EPA_highway', SimEconomy())
    top.add('vehicle', Vehicle())

    top.driver.workflow.add('sim_acc')
    top.driver.workflow.add('sim_EPA_city')
    top.driver.workflow.add('sim_EPA_highway')

    top.sim_acc.workflow.add('vehicle')
    top.sim_acc.velocity_str = 'vehicle.velocity'
    top.sim_acc.throttle_str = 'vehicle.throttle'
    top.sim_acc.gear_str = 'vehicle.current_gear'
    top.sim_acc.acceleration_str = 'vehicle.acceleration'
    top.sim_acc.overspeed_str = 'vehicle.overspeed'

    top.sim_EPA_city.workflow.add('vehicle')
    top.sim_EPA_city.velocity_str = 'vehicle.velocity'
    top.sim_EPA_city.throttle_str = 'vehicle.throttle'
Exemple #12
0
    def configure(self):
        """ Configures a new Assembly for vehicle performance optimization."""

        # Create Vehicle instance
        self.add('vehicle', Vehicle())

        # Create Driving Simulation instances
        self.add('sim_acc', SimAcceleration())
        self.add('sim_EPA_city', SimEconomy())
        self.add('sim_EPA_highway', SimEconomy())

        # add Sims to default workflow
        self.driver.workflow.add(
            ['sim_acc', 'sim_EPA_city', 'sim_EPA_highway'])

        # Add vehicle to sim workflows.
        self.sim_acc.workflow.add('vehicle')
        self.sim_EPA_city.workflow.add('vehicle')
        self.sim_EPA_highway.workflow.add('vehicle')

        # Acceleration Sim setup
        self.sim_acc.add_parameter('vehicle.velocity',
                                   name='velocity',
                                   low=0.0,
                                   high=150.0)
        self.sim_acc.add_parameter('vehicle.throttle',
                                   name='throttle',
                                   low=0.01,
                                   high=1.0)
        self.sim_acc.add_parameter('vehicle.current_gear',
                                   name='gear',
                                   low=0,
                                   high=5)
        self.sim_acc.add_objective('vehicle.acceleration', name='acceleration')
        self.sim_acc.add_objective('vehicle.overspeed', name='overspeed')

        # EPA City MPG Sim Setup
        self.sim_EPA_city.add_parameter('vehicle.velocity',
                                        name='velocity',
                                        low=0.0,
                                        high=150.0)
        self.sim_EPA_city.add_parameter('vehicle.throttle',
                                        name='throttle',
                                        low=0.01,
                                        high=1.0)
        self.sim_EPA_city.add_parameter('vehicle.current_gear',
                                        name='gear',
                                        low=0,
                                        high=5)
        self.sim_EPA_city.add_objective('vehicle.acceleration',
                                        name='acceleration')
        self.sim_EPA_city.add_objective('vehicle.fuel_burn', name='fuel_burn')
        self.sim_EPA_city.add_objective('vehicle.overspeed', name='overspeed')
        self.sim_EPA_city.add_objective('vehicle.underspeed',
                                        name='underspeed')
        self.sim_EPA_city.profilename = 'EPA-city.csv'

        # EPA Highway MPG Sim Setup
        self.sim_EPA_highway.add_parameter('vehicle.velocity',
                                           name='velocity',
                                           low=0.0,
                                           high=150)
        self.sim_EPA_highway.add_parameter('vehicle.throttle',
                                           name='throttle',
                                           low=0.01,
                                           high=1.0)
        self.sim_EPA_highway.add_parameter('vehicle.current_gear',
                                           name='gear',
                                           low=0,
                                           high=5)
        self.sim_EPA_highway.add_objective('vehicle.acceleration',
                                           name='acceleration')
        self.sim_EPA_highway.add_objective('vehicle.fuel_burn',
                                           name='fuel_burn')
        self.sim_EPA_highway.add_objective('vehicle.overspeed',
                                           name='overspeed')
        self.sim_EPA_highway.add_objective('vehicle.underspeed',
                                           name='underspeed')
        self.sim_EPA_highway.profilename = 'EPA-highway.csv'
Exemple #13
0
 def setUp(self):
     self.model = set_as_top(Assembly())
     self.model.add('test_vehicle', Vehicle())
     self.model.driver.workflow.add('test_vehicle')