def run(self, props, globdat): globdat.cycle += 1 globdat.time += self.dtime lam = self.loadfunc(globdat.time) disp = globdat.state velo = globdat.velo acce = globdat.acce fint = globdat.fint fhat = globdat.fhat velo += 0.5 * self.dtime * acce disp += self.dtime * velo fint = assembleInternalForce(props, globdat) globdat.dofs.setConstrainFactor(lam) acce = globdat.dofs.solve(self.Mlumped, lam * fhat - fint) velo += 0.5 * self.dtime * acce globdat.acce[:] = acce[:] globdat.elements.commitHistory() self.printStep(globdat) if globdat.cycle == self.maxCycle: globdat.active = False
def run(self, props, global_data): global_data.cycle += 1 K, fint = assembleTangentStiffness(props, global_data) global_data.state = global_data.dofs.solve(K, global_data.fhat) global_data.fint = assembleInternalForce(props, global_data) global_data.elements.commitHistory() global_data.active = False
def run( self , props , globdat ): globdat.cycle += 1 globdat.time += self.dtime lam = self.loadfunc( globdat.time ) disp = globdat.state velo = globdat.velo acce = globdat.acce fint = globdat.fint fhat = globdat.fhat velo += 0.5*self.dtime * acce; disp += self.dtime * velo fint = assembleInternalForce( props, globdat ) globdat.dofs.setConstrainFactor(lam) acce = globdat.dofs.solve( self.Mlumped , lam*fhat-fint ) velo += 0.5 * self.dtime * acce globdat.acce[:] = acce[:] globdat.elements.commitHistory() self.printStep( globdat ) if globdat.cycle == self.maxCycle: globdat.active = False
def run(self, props, globdat): globdat.cycle += 1 dofCount = len(globdat.dofs) a = globdat.state Da = globdat.Dstate Da[:] = zeros(dofCount) fint = zeros(dofCount) fext = zeros(dofCount) print('=================================') print(' Load step %i' % globdat.cycle) print('=================================') print(' NR iter : L2-norm residual') #fext = fext + Dfext globdat.iiter = 0 K = assembleTangentStiffness(props, globdat) error = 1. while error > self.tol: globdat.iiter += 1 da = globdat.dofs.solve(K, fext - fint) Da[:] += da[:] a[:] += da[:] fint = assembleInternalForce(props, globdat) K = assembleTangentStiffness(props, globdat) error = globdat.dofs.norm(fext - fint) print(' Iter', globdat.iiter, ':', error) if globdat.iiter == self.iterMax: raise RuntimeError( 'Newton-Raphson iterations did not converge!') # Converged elements.commitHistory() if globdat.cycle == 10: globdat.active = False
def run( self , props , globdat ): globdat.cycle += 1 K,fint = assembleTangentStiffness( props, globdat ) globdat.state = globdat.dofs.solve( K, globdat.fhat ) globdat.fint = assembleInternalForce( props, globdat ) globdat.elements.commitHistory() globdat.active = False
def run(self, props, globdat): globdat.cycle += 1 K, fint = assembleTangentStiffness(props, globdat) state0 = globdat.state globdat.state = globdat.dofs.solve(K, globdat.fhat) globdat.Dstate = globdat.state - state0 globdat.fint = assembleInternalForce(props, globdat) commit(props, globdat) globdat.elements.commitHistory() globdat.active = False
def run(self, props, globdat): globdat.solverStatus.increaseStep() K, fint = assembleTangentStiffness(props, globdat) fext = assembleExternalForce(props, globdat) state0 = globdat.state globdat.state = globdat.dofs.solve(K, fext) globdat.Dstate = globdat.state - state0 globdat.fint = assembleInternalForce(props, globdat) commit(props, globdat) globdat.elements.commitHistory() globdat.active = False
def run(self, props, globdat): stat = globdat.solverStatus self.stat = stat stat.increaseStep() #fext = zeros( len(globdat.dofs) ) logger.info("Staggered solver ............") logger.info(" =============================================") logger.info(" Load step %i" % globdat.solverStatus.cycle) logger.info(" =============================================") for solver in self.solvers: stat.iiter = 0 error = 1.0 K, fint = assembleTangentStiffness(props, globdat) fext = assembleExternalForce(props, globdat) self.setLoadAndConstraints(solver.cons) da = globdat.dofs.solve(K, fext - fint, solver.cons) globdat.state += da logger.info(' Solver : %s' % solver.name) if solver.type == "Nonlinear": if solver.name == "dummy": norm = 1.0 else: norm = globdat.dofs.norm(fext - fint, solver.cons) logger.info(' Newton-Raphson : L2-norm residual') while error > self.tol: stat.iiter += 1 K, fint = assembleTangentStiffness(props, globdat) solver.cons.setConstrainFactor(0.0) da = globdat.dofs.solve(K, fext - fint, solver.cons) globdat.state += da if solver.name == "dummy": error = 1.0e-8 elif norm < 1.0e16: error = globdat.dofs.norm(fext - fint, solver.cons) else: error = globdat.dofs.norm(fext - fint) / norm logger.info(' Iteration %4i : %6.4e' % (stat.iiter, error)) if stat.iiter == self.iterMax: raise RuntimeError( 'Newton-Raphson iterations did not converge!') # Combine results and calculate stresses globdat.fint = assembleInternalForce(props, globdat) commit(props, globdat) globdat.elements.commitHistory() if stat.cycle == self.maxCycle: # or globdat.lam > self.maxLam: globdat.active = False
def run( self , props , globdat ): globdat.cycle += 1 dofCount = len(globdat.dofs) a = globdat.state Da = globdat.Dstate Da[:] = zeros( dofCount ) fint = zeros( dofCount ) fext = zeros( dofCount ) print '=================================' print ' Load step %i' % globdat.cycle print '=================================' print ' NR iter : L2-norm residual' #fext = fext + Dfext globdat.iiter = 0 K = assembleTangentStiffness( props, globdat ) error = 1. while error > self.tol: globdat.iiter += 1 da = globdat.dofs.solve( K, fext-fint ) Da[:] += da[:] a [:] += da[:] fint = assembleInternalForce ( props, globdat ) K = assembleTangentStiffness( props, globdat ) error = globdat.dofs.norm( fext-fint ) print ' Iter', globdat.iiter, ':', error if globdat.iiter == self.iterMax: raise RuntimeError('Newton-Raphson iterations did not converge!') # Converged elements.commitHistory() if globdat.cycle == 10: globdat.active = False # Solve for new displacement vector, load factor if self.method == 'force-controlled': da = dofs.solve( K, lam*fhat-fint ) elif self.method == 'nrg': h = 0.5 * lam0 * fhat w = -0.5 * dot ( (a-Da) , fhat ) g = 0.5 * dot ( ( lam0 * Da - Dlam * ( a[:] - Da[:] ) ) , fhat ) - dtau d1 = dofs.solve( K , lam*fhat - fint ) d2 = dofs.solve( K , -1.0*fhat ) denom = dot ( h , d2 ) - w da = d1 - ( d2 * ( dot( h , d1 ) + g ) ) / denom dlam = -g - ( dot( -1.0*h , d1 ) - g * ( 1.0 + denom ) ) / denom; Dlam += dlam lam += dlam else: raise RuntimeError('Method not known') # Update displacements Da[:] += da[:] a [:] += da[:] # Solve for new displacement vector, load factor K = assembleTangentStiffness( props, globdat ) fint = assembleInternalForce( props, globdat ) # Check convergence error = globdat.dofs.norm( lam*fhat-fint ) / globdat.dofs.norm( lam*fhat ) # Increment the Newton-Raphson iteration counter # and print error globdat.iiter += 1 print ' Iter %5i : %4.2e ' %(iiter,error) if globdat.iiter == iterMax: plotCurve( output ) raise RuntimeError('Newton-Raphson iterations did not converge!') # If converged, calculate the amount of energy that has been dissipated in the \ # previous step. print '---------------------------------' print ' C O N V E R G E D' if method == 'force-controlled': print ' Diss. nrg : %1.3e ' %dissnrg Da[:] = zeros( len(dofs) ) lam0 = lam if method == 'force-controlled': if dissnrg > switchnrg: print ' Switch to nrg diss. arc-length' self.method = 'nrg' Dlam = 0.; dtau = 0.25*switchnrg else: lam += Dlam else: Dlam = 0.; dtau *= pow(0.5,0.25*(iiter-5)) if dtau > maxnrg: dtau = maxnrg globdat.elements.commitHistory() globdat.dissnrg = 0.5 * dot( ( lam0 * Da - (lam-lam0) * ( a - Da ) ) , fhat )
# Step 6: # # Update Delta a # ############################################### Da[:] += da[:] a[:] += da[:] ############################################### # Step 7-10 # # -> Compute Delta epsilon # # -> Compute Delta sigma # # -> Compute new sigma # # -> Compute new internal force vector # ############################################### fint = assembleInternalForce(props, globdat) K = assembleTangentStiffness(props, globdat) ############################################### # Step 11: # # Convergence check # ############################################### error = dofs.norm(fext - fint) #Increment the Newton-Raphson iteration counter iiter += 1 print(' Iter', iiter, ':', error) if iiter == iterMax: