예제 #1
0
    def __init__( self, model, time, referenceTimeSeries, forwardTimeSeries, ddConductivity, *args, **kwargs ):
        TransientFEModel.__init__( self, model.size )

        # Check model type
        # The adjoint system is linear with respect to its state, the system
        # it's derived from must be nonlinear. A simpler structure is used
        # for solving linear systems.
        assert type(model) is NonlinearTransientFEModel, "Invalid model type!"

        self.femodel                = model
        self.time                   = time
        self.referenceSolution      = referenceTimeSeries
        self.forwardSolution        = forwardTimeSeries

        self.timeIndex              = 0
        self._load                  = None

        self.nonsymmetricStiffness  = None

        # Transform model members 
        # TODO: ddConductivity
        self.elements               = []
        for element in model.elements:
            self.elements.append(
                AdjointHeatElement1D(   element,
                                        self.femodel,
                                        self.forwardSolution,
                                        self.referenceSolution,
                                        ddConductivity ) )

        self.computeLoad()
예제 #2
0
integrationOrder = 2 * polynomialOrder + 1
finiteDifferenceImplicity = 0.5

# Adjoint
numberOfAdjointIterations = 50
regularization = 8.0

# Postprocessing
numberOfSamples = 100
convergencePlot = ConvergencePlot()

# ---------------------------------------------------------
# REFERENCE SOLUTION
# ---------------------------------------------------------
# Initialize FE model
model = TransientFEModel(nElements * polynomialOrder + 1, loadFunction=load)

# Create elements
basisFunctions = IntegratedHierarchicBasisFunctions(
    polynomialOrder=polynomialOrder)
initialLoad = lambda x: load(time[0], x)
model.elements = [
    LinearHeatElement1D(
        capacity,
        conductivity, (i * length / nElements, (i + 1) * length / nElements),
        np.asarray(range(i * polynomialOrder, (i + 1) * polynomialOrder + 1)),
        initialLoad,
        basisFunctions=basisFunctions,
        integrationOrder=integrationOrder) for i in range(nElements)
]
예제 #3
0
# Load
load                        = lambda t, x: 0.0

# Discretization
time                        = np.linspace(0.0, 1.0, 200)
nElements                   = 10
polynomialOrder             = 3

# Integration
integrationOrder            = 2*polynomialOrder + 1
finiteDifferenceImplicity   = 0.5

# ---------------------------------------------------------
# Initialize FE model
model               = TransientFEModel( nElements*polynomialOrder + 1, loadFunction=load )

# Create elements
basisFunctions      = IntegratedHierarchicBasisFunctions( polynomialOrder=polynomialOrder )
initialLoad         = lambda x: load( time[0], x )
model.elements      = [ LinearHeatElement1D(    capacity,
                                                conductivity,
                                                (i*length/nElements, (i+1)*length/nElements),
                                                np.asarray( range(i*polynomialOrder, (i+1)*polynomialOrder+1) ),
                                                initialLoad,
                                                basisFunctions=basisFunctions,
                                                integrationOrder=integrationOrder   ) 
                        for i in range(nElements) ]

# Integrate
model.allocateZeros( )
예제 #4
0
 def resetMatrices( self, stiffness=True, mass=True, load=False ):
     TransientFEModel.resetMatrices( self, stiffness=stiffness, mass=mass, load=load )
     if stiffness:
         self.nonsymmetricStiffness.data = np.zeros( self.nonsymmetricStiffness.data.shape, dtype=self.nonsymmetricStiffness.data.dtype )
예제 #5
0
 def allocateZeros( self ):
     DoFs = TransientFEModel.allocateZeros(self)
     self.nonsymmetricStiffness  = sparse.csr_matrix(    ( np.zeros( DoFs.shape[1] ), DoFs ), 
                                                         shape=self.shape )
예제 #6
0
 def integrate( self, *args, stiffness=True, mass=True, load=False, **kwargs ):
     self.resetMatrices( stiffness=stiffness, mass=mass, load=load )
     TransientFEModel.integrate(self,*args,stiffness=stiffness,mass=mass,load=load,**kwargs)
     if stiffness:
         for element in self.elements:
             element.integrateNonsymmetricStiffness(self.nonsymmetricStiffness)