本文整理汇总了Python中esys.escript.linearPDEs.LinearPDE.setTolerance方法的典型用法代码示例。如果您正苦于以下问题:Python LinearPDE.setTolerance方法的具体用法?Python LinearPDE.setTolerance怎么用?Python LinearPDE.setTolerance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类esys.escript.linearPDEs.LinearPDE
的用法示例。
在下文中一共展示了LinearPDE.setTolerance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SimpleStokesProblem
# 需要导入模块: from esys.escript.linearPDEs import LinearPDE [as 别名]
# 或者: from esys.escript.linearPDEs.LinearPDE import setTolerance [as 别名]
class SimpleStokesProblem(SaddlePointProblem):
"""
simple example of saddle point problem
"""
def __init__(self,domain):
super(SimpleStokesProblem, self).__init__(self)
self.__pde_u=LinearPDE(domain)
self.__pde_u.setSymmetryOn()
self.__pde_u.setValue(A=identityTensor4(dom))
self.__pde_p=LinearPDE(domain)
self.__pde_p.setReducedOrderOn()
self.__pde_p.setSymmetryOn()
self.__pde_p.setValue(D=1.)
def initialize(self,f=Data(),fixed_u_mask=Data()):
self.__pde_u.setValue(q=fixed_u_mask,Y=f)
def inner(self,p0,p1):
return integrate(p0*p1,Function(self.__pde_p.getDomain()))
def solve_f(self,u,p,tol=1.e-8):
self.__pde_u.setTolerance(tol)
self.__pde_u.setValue(X=grad(u)+p*kronecker(self.__pde_u.getDomain()))
return self.__pde_u.getSolution()
def solve_g(self,u,tol=1.e-8):
self.__pde_p.setTolerance(tol)
self.__pde_p.setValue(X=-u)
dp=self.__pde_p.getSolution()
return dp
示例2: SlippingFault
# 需要导入模块: from esys.escript.linearPDEs import LinearPDE [as 别名]
# 或者: from esys.escript.linearPDEs.LinearPDE import setTolerance [as 别名]
class SlippingFault(SaddlePointProblem):
"""
simple example of saddle point problem
"""
def __init__(self,domain):
super(SlippingFault, self).__init__(self)
self.domain=domain
self.__pde_u=LinearPDE(domain,numEquations=self.domain.getDim(),numSolutions=self.domain.getDim())
self.__pde_u.setSymmetryOn()
def initialize(self,density=1.,lmbd=1., mu=1., traction=Data(),fixed_u_mask=Data(), slip=0.):
d=self.domain.getDim()
self.slip=slip
A =self.__pde_u.createCoefficientOfGeneralPDE("A")
for i in range(self.domain.getDim()):
for j in range(self.domain.getDim()):
A[i,j,j,i] += mu
A[i,j,i,j] += mu
A[i,i,j,j] += lmbd
self.__pde_u.setValue(A=A,q=fixed_u_mask,Y=-kronecker(Function(self.domain))[d-1]*g*density,y=traction)
def inner(self,p0,p1):
return integrate(inner(p0,p1),FunctionOnContactZero(self.domain))
def solve_f(self,u,p,tol=1.e-8):
self.__pde_u.setTolerance(tol)
self.__pde_u.setValue(y_contact=-p)
# print "p:",inf(p),sup(p)
# print "u:",inf(u),sup(u)
self.__pde_u.setValue(y_contact=-p)
return self.__pde_u.getSolution()
def solve_g(self,u,tol=1.e-8):
dp=Vector(0.,FunctionOnContactZero(self.domain))
h=FunctionOnContactZero(self.domain).getSize()
# print jump(u)-self.slip
dp[0]=(self.slip[0]-jump(u[0]))*lam_mu/h
dp[1]=(self.slip[1]-jump(u[1]))*lam_mu/h
dp[2]=(self.slip[2]-jump(u[2]))*lam_mu/h
return dp
示例3: StokesProblem
# 需要导入模块: from esys.escript.linearPDEs import LinearPDE [as 别名]
# 或者: from esys.escript.linearPDEs.LinearPDE import setTolerance [as 别名]
class StokesProblem(SaddlePointProblem):
"""
simple example of saddle point problem
"""
def __init__(self,domain,debug=False):
super(StokesProblem, self).__init__(self,debug)
self.domain=domain
self.__pde_u=LinearPDE(domain,numEquations=self.domain.getDim(),numSolutions=self.domain.getDim())
self.__pde_u.setSymmetryOn()
self.__pde_p=LinearPDE(domain)
self.__pde_p.setReducedOrderOn()
self.__pde_p.setSymmetryOn()
def initialize(self,f=Data(),fixed_u_mask=Data(),eta=1):
self.eta=eta
A =self.__pde_u.createCoefficientOfGeneralPDE("A")
for i in range(self.domain.getDim()):
for j in range(self.domain.getDim()):
A[i,j,j,i] += self.eta
A[i,j,i,j] += self.eta
self.__pde_p.setValue(D=1/self.eta)
self.__pde_u.setValue(A=A,q=fixed_u_mask,Y=f)
def inner(self,p0,p1):
return integrate(p0*p1,Function(self.__pde_p.getDomain()))
def solve_f(self,u,p,tol=1.e-8):
self.__pde_u.setTolerance(tol)
g=grad(u)
self.__pde_u.setValue(X=self.eta*symmetric(g)+p*kronecker(self.__pde_u.getDomain()))
return self.__pde_u.getSolution()
def solve_g(self,u,tol=1.e-8):
self.__pde_p.setTolerance(tol)
self.__pde_p.setValue(X=-u)
dp=self.__pde_p.getSolution()
return dp
示例4: print
# 需要导入模块: from esys.escript.linearPDEs import LinearPDE [as 别名]
# 或者: from esys.escript.linearPDEs.LinearPDE import setTolerance [as 别名]
print(t,": range u",inf(u0),sup(u0),integrate(u0,Function(dom)))
while t<t_end and c< c_stop:
print("time step t=",t+dt)
u=fc.solve(dt)
print(t+dt,": range u",inf(u),sup(u),integrate(u,Function(dom)))
c+=1
t+=dt
if t>=t_out+dt_out:
c_out,t_out=c_out+1,t_out+dt_out
saveVTK("u.%s.vtu"%c_out,u=u)
print("write time step ",c,"(t=%s) to file u.%s.vtu"%(t,c_out))
if True:
pde=LinearPDE(dom)
pde.setValue(D=1.,C=-THETA*dt*V)
pde.setTolerance(1e-12)
t=0.
t_out=0
c_out=0
c=0
u=u0
print(t,": range u2",inf(u0),sup(u0),integrate(u0,Function(dom)))
while t<t_end and c< c_stop:
print("time step t=",t+dt)
pde.setValue(Y=u+(1.-THETA)*dt*inner(V,grad(u)))
u=pde.getSolution(verbose=True)
print(t+dt,": range u2",inf(u),sup(u),integrate(u,Function(dom)))
c+=1
t+=dt
if t>=t_out+dt_out:
c_out,t_out=c_out+1,t_out+dt_out