Esempio n. 1
0
    def __init__(self, comm, tacs_comm, model, n_tacs_procs):
        super(wedgeTACS,self).__init__(comm, tacs_comm, model)

        assembler = None
        mat = None
        pc = None
        gmres = None

        self.T_ref = 300.0

        if comm.Get_rank() < n_tacs_procs:
            # Set constitutive properties
            rho = 4540.0  # density, kg/m^3
            E = 118e9 # elastic modulus, Pa
            nu = 0.325 # poisson's ratio
            ys = 1050e6  # yield stress, Pa
            kappa = 6.89
            specific_heat=463.0
            thickness = 0.015
            volume = 25 # need tacs volume for TACSAverageTemperature function

            # Create the constitutvie propertes and model
            props = constitutive.MaterialProperties(rho=4540.0, specific_heat=463.0,
                                                    kappa = 6.89, E=118e9, nu=0.325, ys=1050e6)
            con = constitutive.SolidConstitutive(props, t=1.0, tNum=0)

            # Set the model type = linear thermoelasticity
            elem_model = elements.LinearThermoelasticity3D(con)

            # Create the basis class
            basis = elements.LinearHexaBasis()

            # Create the element
            element = elements.Element3D(elem_model, basis)
            varsPerNode = elem_model.getVarsPerNode()

            # Load in the mesh
            mesh = TACS.MeshLoader(tacs_comm)
            mesh.scanBDFFile('tacs_aero.bdf')

            # Set the element
            mesh.setElement(0, element)

            # Create the assembler object
            assembler = mesh.createTACS(varsPerNode)

            # Create the preconditioner for the corresponding matrix
            mat = assembler.createSchurMat()
            pc = TACS.Pc(mat)

            # Create GMRES object for structural adjoint solves
            nrestart = 0 # number of restarts before giving up
            m = 30 # size of Krylov subspace (max # of iterations)
            gmres = TACS.KSM(mat, pc, m, nrestart)

        self._initialize_variables(assembler, mat, pc, gmres)

        self.initialize(model.scenarios[0], model.bodies)

        return
Esempio n. 2
0
    def __init__(self, integrator_options, comm, tacs_comm, model,
                 n_tacs_procs):
        self.tacs_proc = False
        if comm.Get_rank() < n_tacs_procs:
            self.tacs_proc = True

            # Set constitutive properties
            T_ref = 300.0
            rho = 4540.0  # density, kg/m^3
            E = 118e9  # elastic modulus, Pa
            nu = 0.325  # poisson's ratio
            ys = 1050e6  # yield stress, Pa
            kappa = 6.89
            specific_heat = 463.0
            thickness = 0.015
            volume = 25  # need tacs volume for TACSAverageTemperature function

            # Create the constitutvie propertes and model
            props_plate = constitutive.MaterialProperties(rho=4540.0,
                                                          specific_heat=463.0,
                                                          kappa=6.89,
                                                          E=118e9,
                                                          nu=0.325,
                                                          ys=1050e6)
            #con_plate = constitutive.ShellConstitutive(props_plate,thickness,1,0.01,0.10)
            #model_plate = elements.ThermoelasticPlateModel(con_plate)
            con_plate = constitutive.PlaneStressConstitutive(props_plate,
                                                             t=1.0,
                                                             tNum=0)
            model_plate = elements.HeatConduction2D(con_plate)

            # Create the basis class
            quad_basis = elements.LinearQuadBasis()

            # Create the element
            #element_shield = elements.Element2D(model_shield, quad_basis)
            #element_insulation = elements.Element2D(model_insulation, quad_basis)
            element_plate = elements.Element2D(model_plate, quad_basis)
            varsPerNode = model_plate.getVarsPerNode()

            # Load in the mesh
            mesh = TACS.MeshLoader(tacs_comm)
            mesh.scanBDFFile('tacs_aero.bdf')

            # Set the element
            mesh.setElement(0, element_plate)

            # Create the assembler object
            #varsPerNode = heat.getVarsPerNode()
            assembler = mesh.createTACS(varsPerNode)

            # Create distributed node vector from TACS Assembler object and
            # extract the node locations
            nbodies = 1
            struct_X = []
            struct_nnodes = []
            for body in range(nbodies):
                self.struct_X_vec = assembler.createNodeVec()
                assembler.getNodes(self.struct_X_vec)
                struct_X.append(self.struct_X_vec.getArray())
                struct_nnodes.append(len(struct_X) / 3)

            assembler.setNodes(self.struct_X_vec)

            # Initialize member variables pertaining to TACS
            self.T_ref = T_ref
            self.vol = volume
            self.assembler = assembler

            self.struct_X = struct_X
            self.struct_nnodes = struct_nnodes

            self.struct_rhs_vec = assembler.createVec()
            #self.psi_T_S_vec = assembler.createVec()
            #psi_T_S = self.psi_T_S_vec.getArray()
            #self.psi_T_S = np.zeros((psi_T_S.size,self.nfunc),dtype=TACS.dtype)

            self.ans = self.assembler.createVec()
            self.bvec_heat_flux = self.assembler.createVec()

            # Things for configuring time marching
            self.integrator = {}
            for scenario in model.scenarios:
                self.integrator[scenario.id] = self.createIntegrator(
                    self.assembler, integrator_options)

        super(wedgeTACS, self).__init__(integrator_options, comm, tacs_comm,
                                        model)
        self.initialize(model.scenarios[0], model.bodies)
Esempio n. 3
0
    def __init__(self, comm, tacs_comm, model, n_tacs_procs):
        super(wedgeTACS, self).__init__(comm, tacs_comm, model)

        self.tacs_proc = False
        if comm.Get_rank() < n_tacs_procs:
            self.tacs_proc = True
            #mesh = TACS.MeshLoader(tacs_comm)
            #mesh.scanBDFFile("tacs_aero.bdf")

            # Set constitutive properties
            T_ref = 300.0
            rho = 4540.0  # density, kg/m^3
            E = 118e9  # elastic modulus, Pa
            nu = 0.325  # poisson's ratio
            ys = 1050e6  # yield stress, Pa
            kappa = 6.89
            specific_heat = 463.0
            thickness = 0.015
            volume = 25  # need tacs volume for TACSAverageTemperature function

            # Create the constitutvie propertes and model
            props_plate = constitutive.MaterialProperties(rho=4540.0,
                                                          specific_heat=463.0,
                                                          kappa=6.89,
                                                          E=118e9,
                                                          nu=0.325,
                                                          ys=1050e6)
            #con_plate = constitutive.ShellConstitutive(props_plate,thickness,1,0.01,0.10)
            #model_plate = elements.ThermoelasticPlateModel(con_plate)
            con_plate = constitutive.PlaneStressConstitutive(props_plate,
                                                             t=1.0,
                                                             tNum=0)
            model_plate = elements.HeatConduction2D(con_plate)

            # Create the basis class
            quad_basis = elements.LinearQuadBasis()

            # Create the element
            #element_shield = elements.Element2D(model_shield, quad_basis)
            #element_insulation = elements.Element2D(model_insulation, quad_basis)
            element_plate = elements.Element2D(model_plate, quad_basis)
            varsPerNode = model_plate.getVarsPerNode()

            # Load in the mesh
            mesh = TACS.MeshLoader(tacs_comm)
            mesh.scanBDFFile('tacs_aero.bdf')

            # Set the element
            mesh.setElement(0, element_plate)

            # Create the assembler object
            #varsPerNode = heat.getVarsPerNode()
            assembler = mesh.createTACS(varsPerNode)
            res = assembler.createVec()
            ans = assembler.createVec()
            mat = assembler.createSchurMat()

            # Create distributed node vector from TACS Assembler object and
            # extract the node locations
            nbodies = 1
            struct_X = []
            struct_nnodes = []
            for body in range(nbodies):
                self.struct_X_vec = assembler.createNodeVec()
                assembler.getNodes(self.struct_X_vec)
                struct_X.append(self.struct_X_vec.getArray())
                struct_nnodes.append(len(struct_X) / 3)

            assembler.setNodes(self.struct_X_vec)

            # Create the preconditioner for the corresponding matrix
            pc = TACS.Pc(mat)

            alpha = 1.0
            beta = 0.0
            gamma = 0.0
            assembler.assembleJacobian(alpha, beta, gamma, res, mat)
            pc.factor()

            # Create GMRES object for structural adjoint solves
            nrestart = 0  # number of restarts before giving up
            m = 30  # size of Krylov subspace (max # of iterations)
            gmres = TACS.KSM(mat, pc, m, nrestart)

            # Initialize member variables pertaining to TACS
            self.T_ref = T_ref
            self.vol = volume
            self.assembler = assembler
            self.res = res
            self.ans = ans
            self.mat = mat
            self.pc = pc
            self.struct_X = struct_X
            self.struct_nnodes = struct_nnodes
            self.gmres = gmres
            self.svsens = assembler.createVec()
            self.struct_rhs_vec = assembler.createVec()
            self.psi_T_S_vec = assembler.createVec()
            psi_T_S = self.psi_T_S_vec.getArray()
            self.psi_T_S = np.zeros((psi_T_S.size, self.nfunc),
                                    dtype=TACS.dtype)
            self.ans_array = []
            self.svsenslist = []
            self.dvsenslist = []

            for func in range(self.nfunc):
                self.svsenslist.append(self.assembler.createVec())
                self.dvsenslist.append(self.assembler.createDesignVec())

            for scenario in range(len(model.scenarios)):
                self.ans_array.append(self.ans.getArray().copy())
        self.initialize(model.scenarios[0], model.bodies)
Esempio n. 4
0
    def __init__(self, comm, tacs_comm, model, n_tacs_procs):
        super(OneraPlate, self).__init__(comm, tacs_comm, model)

        assembler = None
        mat = None

        if comm.Get_rank() < n_tacs_procs:
            # Set the creator object
            ndof = 6
            creator = TACS.Creator(tacs_comm, ndof)

            if tacs_comm.rank == 0:
                # Create the elements
                nx = 10
                ny = 10

                # Set the nodes
                nnodes = (nx+1)*(ny+1)
                nelems = nx*ny
                nodes = np.arange(nnodes).reshape((nx+1, ny+1))

                conn = []
                for j in range(ny):
                    for i in range(nx):
                        # Append the node locations
                        conn.append([nodes[i, j],
                                     nodes[i+1, j],
                                     nodes[i, j+1],
                                     nodes[i+1, j+1]])

                # Set the node pointers
                conn = np.array(conn, dtype=np.intc).flatten()
                ptr = np.arange(0, 4*nelems+1, 4, dtype=np.intc)
                elem_ids = np.zeros(nelems, dtype=np.intc)
                creator.setGlobalConnectivity(nnodes, ptr, conn, elem_ids)

                # Set the boundary conditions - fixed on the root
                bcnodes = np.array(nodes[:, 0], dtype=np.intc)
                creator.setBoundaryConditions(bcnodes)

                root_chord = 0.8
                semi_span = 1.2
                taper_ratio = 0.56
                sweep = 26.7 # degrees

                # Set the node locations
                Xpts = np.zeros(3*nnodes)
                x = np.linspace(0, 1, nx+1)
                y = np.linspace(0, 1, ny+1)
                for j in range(ny+1):
                    for i in range(nx+1):
                        c = root_chord*(1.0 - y[j]) + root_chord*taper_ratio*y[j]
                        xoff = 0.25*root_chord + semi_span*y[j]*np.tan(sweep*np.pi/180.0)

                        Xpts[3*nodes[i,j]] = xoff + c*(x[i] - 0.25)
                        Xpts[3*nodes[i,j]+1] = semi_span*y[j]

                # Set the node locations
                creator.setNodes(Xpts)

            # Set the material properties
            props = constitutive.MaterialProperties(rho=2570.0, E=70e9, nu=0.3, ys=350e6)

            # Set constitutive properties
            t = 0.025
            tnum = 0
            maxt = 0.015
            mint = 0.015
            con = constitutive.IsoShellConstitutive(props, t=t, tNum=tnum)

            # Create a transformation object
            transform = elements.ShellNaturalTransform()

            # Create the element object
            element = elements.Quad4Shell(transform, con)

            # Set the elements
            elems = [ element ]
            creator.setElements(elems)

            # Create TACS Assembler object from the mesh loader
            assembler = creator.createTACS()

            # Create distributed matrix
            mat = assembler.createSchurMat()  # stiffness matrix

        self._initialize_variables(assembler, mat)

        self.initialize(model.scenarios[0], model.bodies)

        return
Esempio n. 5
0
if CHTMarkerID != None:
    nVertex_CHTMarker = SU2Driver.GetNumberVertices(CHTMarkerID)

# get aero nodes
X = []
for i in range(nVertex_CHTMarker):
    X.extend([
        SU2Driver.GetVertexCoordX(CHTMarkerID, i),
        SU2Driver.GetVertexCoordY(CHTMarkerID, i),
        SU2Driver.GetVertexCoordZ(CHTMarkerID, i)
    ])

# initialize TACS
# Create the constitutvie propertes and model
props = constitutive.MaterialProperties()
con = constitutive.PlaneStressConstitutive(props)
heat = elements.HeatConduction2D(con)

# Create the basis class
quad_basis = elements.LinearQuadBasis()

# Create the element
element = elements.Element2D(heat, quad_basis)

# Load in the mesh
mesh = TACS.MeshLoader(comm)
mesh.scanBDFFile('plate_bump.bdf')

# Set the element
mesh.setElement(0, element)
Esempio n. 6
0
from __future__ import print_function
from mpi4py import MPI
import numpy as np
import matplotlib.pyplot as plt
import sys
from tacs import TACS, elements, constitutive
from funtofem import TransferScheme

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

# initialize TACS for left plate
# Create the constitutvie propertes and model
left_kappa = 230.0
props = constitutive.MaterialProperties(kappa=left_kappa)
con = constitutive.PlaneStressConstitutive(props)
heat = elements.HeatConduction2D(con)

# Create the basis class
quad_basis = elements.LinearQuadBasis()

# Create the element
element = elements.Element2D(heat, quad_basis)

# Load in the mesh
mesh = TACS.MeshLoader(comm)
mesh.scanBDFFile('left_plate.bdf')

# Set the element
mesh.setElement(0, element)
Esempio n. 7
0
def createAssembler(tacs_comm):
    # Set constitutive properties
    rho = 4540.0  # density, kg/m^3
    E = 118e9  # elastic modulus, Pa 118e9
    nu = 0.325  # poisson's ratio
    ys = 1050e6  # yield stress, Pa
    kappa = 6.89
    specific_heat = 463.0

    # Set the back-pressure for the traction load
    pb = 654.9  #10.0 # A value for the surface pressure

    # Load in the mesh
    mesh = TACS.MeshLoader(tacs_comm)
    mesh.scanBDFFile('tacs_aero.bdf')

    # Get the number of components set in the mesh. Each component is
    num_components = mesh.getNumComponents()

    # Each domain consists of the union of two components. The component
    # corresponding to the surface traction and the component corresponding
    # to remaining plate elements. There is one design variable associated
    # with each domain that shares a common (x,z) coordinate
    num_domains = num_components // 2

    # Create the constitutvie propertes and model
    props_plate = constitutive.MaterialProperties(rho=rho,
                                                  specific_heat=specific_heat,
                                                  kappp=kappa,
                                                  E=E,
                                                  nu=nu,
                                                  ys=ys)

    # Create the basis class
    basis = elements.LinearHexaBasis()

    element_list = []
    for k in range(num_domains):
        # Create the elements in an element list
        con = constitutive.SolidConstitutive(props_plate, t=1.0, tNum=k)
        phys_model = elements.LinearThermoelasticity3D(con)

        # Create the element
        element_list.append(elements.Element3D(phys_model, basis))
        varsPerNode = phys_model.getVarsPerNode()

    # Set the face index for the side of the element where the traction
    # will be applied. The face indices are as follows for the hexahedral
    # basis class:
    # -x: 0, +x: 1, -y: 2, +y: 3, -z: 4, +z: 5
    faceIndex = 4

    # Set the wedge angle - 5 degrees
    theta = np.radians(5.0)

    # Compute the outward normal components for the face
    nx = np.sin(theta)
    nz = -np.cos(theta)

    # Set the traction components
    tr = [-pb * nx, 0.0, -pb * nz, 0.0]

    # Create the traction class
    traction = elements.Traction3D(varsPerNode, faceIndex, basis, tr)

    # Set the elements corresponding to each component number
    num_components = mesh.getNumComponents()
    for k in range(num_components):
        mesh.setElement(k, element_list[k % num_domains])

    # Create the assembler object
    assembler = mesh.createTACS(varsPerNode)

    # Set the traction load into the assembler object
    aux = TACS.AuxElements(assembler)
    for k in range(num_domains, num_components):
        mesh.addAuxElement(aux, k, traction)
    assembler.setAuxElements(aux)

    return assembler, num_domains
Esempio n. 8
0
alum_tags = []
for quad in forest.getQuadsWithName('aluminum'):
    alum_tags.append(quad.tag)

battery_tags = []
for n in ['battery_0', 'battery_1', 'battery_2', 'battery']:
    for quad in forest.getQuadsWithName(n):
        battery_tags.append(quad.tag)

thickness = 0.065
alum_rho = 2700.0 * thickness
battery_rho = 1460.0 * thickness
alum_props = constitutive.MaterialProperties(rho=alum_rho,
                                             E=72.4e9,
                                             nu=0.33,
                                             ys=345e6,
                                             alpha=24e-6,
                                             kappa=204.0,
                                             specific_heat=883.0)
battery_props = constitutive.MaterialProperties(rho=battery_rho,
                                                kappa=1.3,
                                                specific_heat=880.0)

# Allocate the creator class
creator = CreateMe(bcs)

# Create the initial forest
nlevels = 2
forest.createTrees(nlevels - 1)

# Create the TACS assembler