How to Calm Down in the Explicit mode in Escript

Asked by guan shaoheng

In this work, I organized the script according to the wave propagation example. The proper timestep is evaluated through the wave equation. The PDE is used to calculate the acceleration. Well, there is no dissipation in this method, and thus the system continues bouncing. So 0.5 multiplying the velocity at the last timestep is used as a dissipation scheme. And the acceleration of the system is checked at every iteration until the system is in a relative state. However, there is no specific theory for this. So I wonder if there is something like the viscous resistance to help the model calm down.

` while not convergeFlag:
            iterNum += 1
            self.x = self.__domain.getX()
            strainIncrement = grad(du)
            self.volume = self.volume*(1.+trace(strainIncrement))
            self.strain = self.strain + strainIncrement
            self.__domain.setX(self.x + du)
            self.u = self.u + du

            # 1st calculation
            if 'elastic' in self.mode:
                self.stress = self.stressCalElastic()
            elif 'dem' in self.mode:
                self.stress = self.stressCalDem(strainIncrement=strainIncrement)
            elif 'ml' in self.mode:
                self.stress = self.stressCalML()
            # stressDamp = self.stressDampCal()
            self.__pde.setValue(X=-self.stress)
            self.a = self.__pde.getSolution()

            # aInit = sum(length(a).toListOfTuples())
            # NOTE: the new velocity is renewed after the last velocity attenuation
            v_new = self.v * self.attenuationCoefficient + self.timeStep * self.a
            t = t + self.timeStep
            du = (v_new + self.v) * 0.5 * self.timeStep
            self.v = v_new

            # check convergence
            residual_a = sup(length(self.a))

            if a_l2 < 0:
                a_l2 = residual_a
            # elif residual_a < 0.1 * a_l2:
            elif residual_a < aCovergenceCriterion:
                convergeFlag = True
            elif iterMax and (iterNum >= iterMax):
                convergeFlag = True
                print('\t Exceed the maximum iteration number (%d) ! ' % iterMax)
                continue

            # verbose
            """
                There is something wrong in this early stopping part.

                No bug here. The $min_a$ is renewed at $iterNum$ FIRST 5 or 1000.
            """
            if 'dem' in self.mode:
                if iterNum % 5 == 0:
                    if residual_a < min_a:
                        min_a = residual_a
                        tryNum = 0
                    elif tryNum < patienceNum:
                        tryNum += 1
                    elif tryNum > patienceNum:
                        convergeFlag = True
                        continue
                    print('\t IterNum: %d Residual error: %f/%f=%f tryNum: %d' %
                          (iterNum, residual_a, a_l2, (residual_a / a_l2), tryNum))
            elif 'ml' in self.mode:
                if iterNum % 1000 == 0:
                    if residual_a < min_a:
                        min_a = residual_a
                        tryNum = 0
                    elif tryNum < patienceNum:
                        tryNum += 1
                    elif tryNum >= patienceNum:
                        convergeFlag = True
                        continue
                    print('\t IterNum: %d Residual error: %f/%f=%f tryNum: %d' %
                          (iterNum, residual_a, a_l2, (residual_a / a_l2), tryNum))`

Question information

Language:
English Edit question
Status:
Expired
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.