Example #1
0
def build_scenario():
    cruise = Scenario(name='cruise',
                      group=0,
                      steady=False,
                      fun3d=True,
                      steps=10)

    drag = Function('cd', analysis_type='aerodynamic')
    cruise.add_function(drag)

    mass = Function('mass', analysis_type='structural', adjoint=False)
    cruise.add_function(mass)

    cruise.set_variable('aerodynamic', 'AOA', value=5.0)

    return cruise
Example #2
0
    def __init__(self,
                 solvers,
                 comm,
                 struct_comm,
                 struct_master,
                 aero_comm,
                 aero_master,
                 transfer_options=None,
                 model=None):
        """
        Parameters
        ----------
        solvers: dict
           the various disciplinary solvers
        comm: MPI.comm
            MPI communicator
        transfer_options: dict
            options of the load and displacement transfer scheme
        model: :class:`~funtofem_model.FUNtoFEMmodel`
            The model containing the design data
        """

        # communicator
        self.comm = comm
        self.aero_comm = aero_comm
        self.aero_master = aero_master
        self.struct_comm = struct_comm
        self.struct_master = struct_master

        # Solver classes
        self.solvers = solvers

        # Make a fake model if not given one
        if model is not None:
            self.fakemodel = False
        else:
            print("FUNtoFEM driver: generating fake model")
            from pyfuntofem.model import FUNtoFEMmodel, Body, Scenario, Function

            model = FUNtoFEMmodel('fakemodel')

            fakebody = Body('fakebody')
            model.add_body(fakebody)

            fakescenario = Scenario('fakescenario')
            function = Function('cl', analysis_type='aerodynamic')
            fakescenario.add_function(function)
            model.add_scenario(fakescenario)

            self.fakemodel = True

        self.model = model

        # Initialize transfer scheme
        self._initialize_transfer(transfer_options)

        # Initialize the shape parameterization
        for body in self.model.bodies:
            if body.shape:
                body.initialize_shape_parameterization()
Example #3
0
 def test_function(self):
     func = Function(name='test',
                     id=1,
                     value=2.0,
                     start=3,
                     stop=4,
                     analysis_type='aerodynamic',
                     body=5,
                     adjoint=False,
                     options={'opt': 6},
                     averaging=True)
     assert func.name == 'test'
     assert func.id == 1
     assert func.value == 2.0
     assert func.start == 3
     assert func.stop == 4
     assert func.analysis_type == 'aerodynamic'
     assert func.body == 5
     assert func.adjoint == False
     assert func.options['opt'] == 6
     assert func.averaging == True
qinf0 = 10000.0
lower = 5000.0
upper = 1.0e6

# Set the time step as the only structural design variables
struct_dt = Variable('struct_dt',
                     value=1e-4,
                     lower=0.0,
                     upper=1.0,
                     scaling=1.0)
scenario.add_variable('structural', struct_dt)

# Define the objective
objective = Function('pitch damping estimate',
                     analysis_type='structural',
                     averaging=False,
                     start=0,
                     stop=-1)
scenario.add_function(objective)

model.add_scenario(scenario)

# Instantiate the flow solver
solvers = {}
forward_options = {'timedep_adj_frozen': True}
adjoint_options = {'timedep_adj_frozen': True}
solvers['flow'] = FakeAerodynamics(comm, model, flow_dt=flow_dt)

# Instantiate the structural solver
smodel = SpringStructure(comm,
                         model,