Ejemplo n.º 1
0
 def __init__(self, iotype, client, rpath):
     VarTreeMixin.__init__(self, iotype, client, rpath)
     VariableTree.__init__(self, iotype=iotype)
     self.__doc__ = client.get(rpath+'.description')
     xml = client.get(rpath)
     populate_from_xml(self, xml)
     self._dirty = False
Ejemplo n.º 2
0
 def __init__(self, iotype, client, rpath):
     VarTreeMixin.__init__(self, iotype, client, rpath)
     desc = client.get(rpath + '.description')
     VariableTree.__init__(self, doc=desc, iotype=iotype)
     xml = client.get(rpath)
     populate_from_xml(self, xml)
     self._dirty = False
Ejemplo n.º 3
0
 def add(self, name, obj):
     """ Overrides VariableTree to manipulate `_dirty` flag. """
     retval = VariableTree.add(self, name, obj)
     if self._iotype == 'in':
         self.on_trait_change(self._trait_modified, name)
         if isinstance(obj, VariableTree):
             self._register(name, obj)
     return retval
Ejemplo n.º 4
0
 def add(self, name, obj):
     """ Overrides VariableTree to manipulate `_dirty` flag. """
     retval = VariableTree.add(self, name, obj)
     if self._iotype == 'in':
         self.on_trait_change(self._trait_modified, name)
         if isinstance(obj, VariableTree):
             self._register(name, obj)
     return retval
Ejemplo n.º 5
0
    def __init__(self, geom_parts):
        super(STLGroup, self).__init__()

        self._comps = []
        self._i_comps = {}
        self._n_comps = 0

        for name, comp in geom_parts:
            comp.name = name
            self._i_comps[name] = self._n_comps
            self._comps.append(comp)
            self._n_comps += 1
            self.add(
                name,
                VarTree(VariableTree(),
                        iotype="in",
                        desc="inputs for %s component" %
                        name))  #create the input VariableTree for this comp

        io = self._build_io()
        for (comp_name, var_name), meta in io:
            comp = self.get(comp_name)
            val = meta['value']
            del meta['value']
            comp.add(var_name, Array(val, **meta))

        #add the geometry var tree
        n_points = self.points.shape[0]
        n_tria = self.triangles.shape[0]
        self.add(
            'geom_data',
            VarTree(GeomData(n_points, n_tria),
                    iotype="out",
                    desc="geometry points and connectivity"))
        self.geom_data.points = self.points
        self.geom_data.facets = self.triangles

        self._needs_linerize = True
Ejemplo n.º 6
0
 def __setstate__(self, state):
     """ Set state of object from `state`. """
     VariableTree.__setstate__(self, state)
Ejemplo n.º 7
0
 def __getstate__(self):
     """ Return state of object. """
     state = VariableTree.__getstate__(self)
     state['_client'] = None
     return state
Ejemplo n.º 8
0
def _add_object(vartree, member):
    """ Helper for :meth:`_populate_from_xml`. """
    name = member.attrib['name']
    newtree = VariableTree(iotype=vartree.iotype)
    vartree.add(name, VarTree(newtree))
    _populate_from_xml(newtree, member)  # Recurse.
Ejemplo n.º 9
0
    def __init__(self, Ns):
        super(HeliOptM, self).__init__()

        # add an optimizer and a multi-point AeroStructural assembly
        self.add('driver', SLSQPdriver())
        self.add('mp', Multipoint(Ns))

        # Set force_fd to True. This will force the derivative system to treat
        # the whole model as a single entity to finite difference it and force
        # the system decomposition to put all of it into an opaque system.
        #
        # Full-model FD is preferable because:
        # 1. There are no derivatives defined for any comps
        # 2. There are a lot of interior connections that would likely make
        #    it much slower if you allow openmdao to finite difference the
        #    subassemblies like it normally does.
        self.driver.gradient_options.force_fd = True

        self.mp.alt_low = 0.5  # low altitude
        self.mp.alt_high = 3.5  # high altitude
        self.mp.alt_ratio = 35. / 60.  # proportion of time near ground

        self.mp.TWire_high = 900
        self.mp.TWire_wind = 2100
        self.mp.TWire_grav = 110

        self.mp.OmegaRatio = 2

        self.mp.vw = 0 / 3.6  # zero

        self.mp.Cl_max = [1.4, 1.35, 1.55, 0., 0., 0., 0., 0., 0.,
                          0.]  # max control

        # objective: minimize total power
        self.driver.add_objective('mp.P')

        # parameter: rotor speed
        self.driver.add_parameter('mp.Omega_low',
                                  low=0.15 * 2 * pi,
                                  high=0.25 * 2 * pi)
        self.mp.Omega_low = 0.20 * 2 * pi  # initial value

        self.driver.add_parameter('mp.Omega_high',
                                  low=0.15 * 2 * pi,
                                  high=0.19 * 2 * pi)
        self.mp.Omega_high = 0.17 * 2 * pi  # initial value

        # parameter: lift distribution at high altitude
        self.driver.add_parameter('mp.Cl0_high', low=0.8, high=1.4)
        self.mp.Cl0_high = 1.

        self.driver.add_parameter('mp.Cl1_high', low=0.8, high=1.3)
        self.mp.Cl1_high = 1.

        # constraint: lift >= weight
        self.driver.add_constraint('mp.Mtot_low*9.8-mp.Ttot_low<=0')
        self.driver.add_constraint('mp.Mtot_high*9.8-mp.Ttot_high<=0')

        # TODO: optional constraints
        #    if flags.ConFail:
        #       Structural Failure in Rotor Spar (ConFail)
        #       Buckling failure of spar (ConFailBuck)
        #       Tensile failure in wire (ConFailWire)
        #
        #    if flags.ConDef:
        #       Constraints on Maximum Deformation (ConDelta)
        #
        #    if flags.MultiPoint && flags.ConJigCont:
        #       Consistent jig twist (ConAlphaJig)
        #
        #    if flags.MultiPoint && flags.ConWireCont
        #       Wire stretch consistency (conWire)

        # Optimization Constraints  (not used... yet)
        vrCon = VariableTree()
        vrCon.MaxDelta = -0.1
        vrCon.MinDelta = 0.1
        vrCon.FOSmat = 0.55  # 1.3
        vrCon.FOSbuck = 0.5  # 1.3
        vrCon.FOSquadbuck = 5.
        vrCon.FOStorbuck = 0.5  # 1.5
        vrCon.FOSwire = 0.5  # 2
Ejemplo n.º 10
0
    def configure(self):
        # add an optimizer and a multi-point AeroStructural assembly
        if pyopt_driver and 'SNOPT' in pyopt_driver._check_imports():
            self.add("driver", pyopt_driver.pyOptDriver())
            self.driver.optimizer = "SNOPT"
            self.driver.options = {
                # any changes to default SNOPT options?
            }
        else:
            print 'SNOPT not available, using SLSQP'
            self.add('driver', SLSQPdriver())

        # Nothing has anlytical derivaties, but we have a lot of
        # nested assemblies, so it is less problematic to just
        # finite difference it all in one block.
        #self.driver.gradient_options.force_fd = True
        #self.driver.gradient_options.fd_step_type = 'relative'
        #self.driver.gradient_options.fd_step = 1.0e-7
        #self.driver.pyopt_diff = True

        self.add('mp', Multipoint())

        self.mp.alt_low = 0.5         # low altitude
        self.mp.alt_high = 3.5        # high altitude
        self.mp.alt_ratio = 35./60.   # proportion of time near ground

        self.mp.TWire_high = 900
        self.mp.TWire_wind = 2100
        self.mp.TWire_grav = 110

        self.mp.OmegaRatio  = 2

        self.mp.vw = 0/3.6   # zero

        self.mp.Cl_max = [1.4, 1.35, 1.55]    # max control

        # objective: minimize total power
        self.driver.add_objective('mp.P')

        # parameter: rotor speed
        self.driver.add_parameter('mp.Omega_low',
                                  low=0.15*2*pi, high=0.25*2*pi)
        self.mp.Omega_low = 0.20*2*pi  # initial value

        self.driver.add_parameter('mp.Omega_high',
                                  low=0.15*2*pi, high=0.19*2*pi)
        self.mp.Omega_high = 0.17*2*pi  # initial value

        # parameter: lift distribution at high altitude
        self.driver.add_parameter('mp.Cl0_high',
                                  low=0.8, high=1.4)
        self.mp.Cl0_high = 1.

        self.driver.add_parameter('mp.Cl1_high',
                                  low=0.8, high=1.3)
        self.mp.Cl1_high = 1.

        # constraint: lift >= weight
        self.driver.add_constraint('mp.Mtot_low*9.8-mp.Ttot_low<=0')
        self.driver.add_constraint('mp.Mtot_high*9.8-mp.Ttot_high<=0')

        # TODO: optional constraints
        #    if flags.ConFail:
        #       Structural Failure in Rotor Spar (ConFail)
        #       Buckling failure of spar (ConFailBuck)
        #       Tensile failure in wire (ConFailWire)
        #
        #    if flags.ConDef:
        #       Constraints on Maximum Deformation (ConDelta)
        #
        #    if flags.MultiPoint && flags.ConJigCont:
        #       Consistent jig twist (ConAlphaJig)
        #
        #    if flags.MultiPoint && flags.ConWireCont
        #       Wire stretch consistency (conWire)

        # Optimization Constraints  (not used... yet)
        vrCon = VariableTree()
        vrCon.MaxDelta    = -0.1
        vrCon.MinDelta    = 0.1
        vrCon.FOSmat      = 0.55    # 1.3
        vrCon.FOSbuck     = 0.5     # 1.3
        vrCon.FOSquadbuck = 5.
        vrCon.FOStorbuck  = 0.5     # 1.5
        vrCon.FOSwire     = 0.5     # 2

        self.driver.workflow.add('mp')
Ejemplo n.º 11
0
    def __init__(self, Ns):
        super(HeliOptM, self).__init__()

        # add an optimizer and a multi-point AeroStructural assembly
        self.add('driver', SLSQPdriver())
        self.add('mp', Multipoint(Ns))

        # Set force_fd to True. This will force the derivative system to treat
        # the whole model as a single entity to finite difference it and force
        # the system decomposition to put all of it into an opaque system.
        #
        # Full-model FD is preferable because:
        # 1. There are no derivatives defined for any comps
        # 2. There are a lot of interior connections that would likely make
        #    it much slower if you allow openmdao to finite difference the
        #    subassemblies like it normally does.
        self.driver.gradient_options.force_fd = True

        self.mp.alt_low   = 0.5       # low altitude
        self.mp.alt_high  = 3.5       # high altitude
        self.mp.alt_ratio = 35./60.   # proportion of time near ground

        self.mp.TWire_high = 900
        self.mp.TWire_wind = 2100
        self.mp.TWire_grav = 110

        self.mp.OmegaRatio = 2

        self.mp.vw = 0/3.6   # zero

        self.mp.Cl_max = [1.4, 1.35, 1.55, 0., 0., 0., 0., 0., 0., 0.]  # max control

        # objective: minimize total power
        self.driver.add_objective('mp.P')

        # parameter: rotor speed
        self.driver.add_parameter('mp.Omega_low',
                                  low=0.15*2*pi, high=0.25*2*pi)
        self.mp.Omega_low = 0.20*2*pi  # initial value

        self.driver.add_parameter('mp.Omega_high',
                                  low=0.15*2*pi, high=0.19*2*pi)
        self.mp.Omega_high = 0.17*2*pi  # initial value

        # parameter: lift distribution at high altitude
        self.driver.add_parameter('mp.Cl0_high',
                                  low=0.8, high=1.4)
        self.mp.Cl0_high = 1.

        self.driver.add_parameter('mp.Cl1_high',
                                  low=0.8, high=1.3)
        self.mp.Cl1_high = 1.

        # constraint: lift >= weight
        self.driver.add_constraint('mp.Mtot_low*9.8-mp.Ttot_low<=0')
        self.driver.add_constraint('mp.Mtot_high*9.8-mp.Ttot_high<=0')

        # TODO: optional constraints
        #    if flags.ConFail:
        #       Structural Failure in Rotor Spar (ConFail)
        #       Buckling failure of spar (ConFailBuck)
        #       Tensile failure in wire (ConFailWire)
        #
        #    if flags.ConDef:
        #       Constraints on Maximum Deformation (ConDelta)
        #
        #    if flags.MultiPoint && flags.ConJigCont:
        #       Consistent jig twist (ConAlphaJig)
        #
        #    if flags.MultiPoint && flags.ConWireCont
        #       Wire stretch consistency (conWire)

        # Optimization Constraints  (not used... yet)
        vrCon = VariableTree()
        vrCon.MaxDelta    = -0.1
        vrCon.MinDelta    = 0.1
        vrCon.FOSmat      = 0.55    # 1.3
        vrCon.FOSbuck     = 0.5     # 1.3
        vrCon.FOSquadbuck = 5.
        vrCon.FOStorbuck  = 0.5     # 1.5
        vrCon.FOSwire     = 0.5     # 2
Ejemplo n.º 12
0
 def __setstate__(self, state):
     """ Set state of object from `state`. """
     VariableTree.__setstate__(self, state)
Ejemplo n.º 13
0
 def __getstate__(self):
     """ Return state of object. """
     state = VariableTree.__getstate__(self)
     state['_client'] = None
     return state
Ejemplo n.º 14
0
    def configure(self):
        # add an optimizer and a multi-point AeroStructural assembly
        if pyopt_driver and 'SNOPT' in pyopt_driver._check_imports():
            self.add("driver", pyopt_driver.pyOptDriver())
            self.driver.optimizer = "SNOPT"
            self.driver.options = {
                # any changes to default SNOPT options?
            }
        else:
            print 'SNOPT not available, using SLSQP'
            self.add('driver', SLSQPdriver())

        self.add('mp', Multipoint())

        self.mp.alt_low = 0.5  # low altitude
        self.mp.alt_high = 3.5  # high altitude
        self.mp.alt_ratio = 35. / 60.  # proportion of time near ground

        self.mp.TWire_high = 900
        self.mp.TWire_wind = 2100
        self.mp.TWire_grav = 110

        self.mp.OmegaRatio = 2

        self.mp.vw = 0 / 3.6  # zero

        self.mp.Cl_max = [1.4, 1.35, 1.55]  # max control

        # objective: minimize total power
        self.driver.add_objective('mp.P')

        # parameter: rotor speed
        self.driver.add_parameter('mp.Omega_low',
                                  low=0.15 * 2 * pi,
                                  high=0.25 * 2 * pi)
        self.mp.Omega_low = 0.20 * 2 * pi  # initial value

        self.driver.add_parameter('mp.Omega_high',
                                  low=0.15 * 2 * pi,
                                  high=0.19 * 2 * pi)
        self.mp.Omega_high = 0.17 * 2 * pi  # initial value

        # parameter: lift distribution at high altitude
        self.driver.add_parameter('mp.Cl0_high', low=0.8, high=1.4)
        self.mp.Cl0_high = 1.

        self.driver.add_parameter('mp.Cl1_high', low=0.8, high=1.3)
        self.mp.Cl1_high = 1.

        # constraint: lift >= weight
        self.driver.add_constraint('mp.Mtot_low*9.8-mp.Ttot_low<=0')
        self.driver.add_constraint('mp.Mtot_high*9.8-mp.Ttot_high<=0')

        # TODO: optional constraints
        #    if flags.ConFail:
        #       Structural Failure in Rotor Spar (ConFail)
        #       Buckling failure of spar (ConFailBuck)
        #       Tensile failure in wire (ConFailWire)
        #
        #    if flags.ConDef:
        #       Constraints on Maximum Deformation (ConDelta)
        #
        #    if flags.MultiPoint && flags.ConJigCont:
        #       Consistent jig twist (ConAlphaJig)
        #
        #    if flags.MultiPoint && flags.ConWireCont
        #       Wire stretch consistency (conWire)

        # Optimization Constraints  (not used... yet)
        vrCon = VariableTree()
        vrCon.MaxDelta = -0.1
        vrCon.MinDelta = 0.1
        vrCon.FOSmat = 0.55  # 1.3
        vrCon.FOSbuck = 0.5  # 1.3
        vrCon.FOSquadbuck = 5.
        vrCon.FOStorbuck = 0.5  # 1.5
        vrCon.FOSwire = 0.5  # 2