本文整理汇总了Python中sheardisp_soln.AnalyticalSoln.displacement方法的典型用法代码示例。如果您正苦于以下问题:Python AnalyticalSoln.displacement方法的具体用法?Python AnalyticalSoln.displacement怎么用?Python AnalyticalSoln.displacement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sheardisp_soln.AnalyticalSoln
的用法示例。
在下文中一共展示了AnalyticalSoln.displacement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
def run(self):
"""
Generate the database.
"""
from sheardisp_soln import AnalyticalSoln
soln = AnalyticalSoln()
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 3
cs._configure()
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
for component in ["x","y","z"]:
if component == "y":
xyz = numpy.array([[-40.0e+3, 0.0, 0.0],
[+40.0e+3, 0.0, 0.0]], dtype=numpy.float64)
ic = 1
elif component == "x":
xyz = numpy.array([[0.0, -40.0e+3, 0.0],
[0.0, +40.0e+3, 0.0]], dtype=numpy.float64)
ic = 0
elif component == "z":
xyz = numpy.array([[0.0, 0.0, -40.0e+3],
[0.0, 0.0, 0.0]], dtype=numpy.float64)
ic = 2
disp = soln.displacement(xyz)
io.inventory.filename = "shear_disp%s.spatialdb" % component
io._configure()
data = {'points': xyz,
'coordsys': cs,
'data_dim': 1,
'values': [{'name': "displacement-%s" % component,
'units': "m",
'data': numpy.ravel(disp[0,:,ic])},
]}
io.write(data)
return
示例2: run
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
def run(self):
"""
Generate the database.
"""
# Domain
x = numpy.arange(-4000.0, 4000.1, 1000.0)
y = numpy.arange(-4000.0, 4000.1, 1000.0)
npts = x.shape[0]
xx = x * numpy.ones((npts, 1), dtype=numpy.float64)
yy = y * numpy.ones((npts, 1), dtype=numpy.float64)
xy = numpy.zeros((npts ** 2, 2), dtype=numpy.float64)
xy[:, 0] = numpy.ravel(xx)
xy[:, 1] = numpy.ravel(numpy.transpose(yy))
from sheardisp_soln import AnalyticalSoln
soln = AnalyticalSoln()
disp = soln.displacement(xy)
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
data = {
"points": xy,
"coordsys": cs,
"data_dim": 2,
"values": [
{"name": "displacement-x", "units": "m", "data": numpy.ravel(disp[0, :, 0])},
{"name": "displacement-y", "units": "m", "data": numpy.ravel(disp[0, :, 1])},
],
}
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
io.inventory.filename = "shear_disp.spatialdb"
io._configure()
io.write(data)
return
示例3: TestShearDisp
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestShearDisp(TestTet4):
"""
Test suite for testing pylith with 2-D shear extension.
"""
def setUp(self):
"""
Setup for test.
"""
TestTet4.setUp(self)
run_pylith()
self.outputRoot = "sheardisp"
self.soln = AnalyticalSoln()
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh['ncells']
pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
示例4: TestFaultsIntersectNoSlip
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestFaultsIntersectNoSlip(TestTet4):
"""
Test suite for testing pylith with shear slip on two faults.
"""
def setUp(self):
"""
Setup for test.
"""
TestTet4.setUp(self)
self.nverticesO = self.mesh['nvertices']
# Fault x
self.mesh['nvertices'] += 8
self.faultMeshX = {'nvertices': 19,
'spaceDim': 3,
'ncells': 20,
'ncorners': 3}
# Fault y
self.mesh['nvertices'] += 2
self.faultMeshY = {'nvertices': 9,
'spaceDim': 3,
'ncells': 8,
'ncorners': 3}
run_pylith()
self.outputRoot = "faultsintersectnoslip"
self.soln = AnalyticalSoln()
return
def test_fault_info(self):
"""
Check fault information.
"""
if not self.checkResults:
return
from pylith.tests.Fault import check_vertex_fields
fields = ["normal_dir", "final_slip", "slip_time"]
self.fault = "x"
filename = "%s-faultx_info.h5" % self.outputRoot
check_vertex_fields(self, filename, self.faultMeshX, fields)
self.fault = "y"
filename = "%s-faulty_info.h5" % self.outputRoot
check_vertex_fields(self, filename, self.faultMeshY, fields)
return
def test_fault_data(self):
"""
Check fault information.
"""
if not self.checkResults:
return
from pylith.tests.Fault import check_vertex_fields
fields = ["slip"]
filename = "%s-faultx.h5" % self.outputRoot
self.fault = "x"
check_vertex_fields(self, filename, self.faultMeshX, fields)
filename = "%s-faulty.h5" % self.outputRoot
self.fault = "y"
check_vertex_fields(self, filename, self.faultMeshY, fields)
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh['ncells']
pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
def calcFaultField(self, name, vertices):
"""
Calculate fault info.
#.........这里部分代码省略.........
示例5: TestShearDispNoSlip
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestShearDispNoSlip(TestTet4):
"""
Test suite for testing pylith with 2-D shear extension.
"""
def setUp(self):
"""
Setup for test.
"""
TestTet4.setUp(self)
self.nverticesO = self.mesh['nvertices']
self.mesh['nvertices'] += 8
self.faultMesh = {'nvertices': 19,
'spaceDim': 3,
'ncells': 20,
'ncorners': 3}
run_pylith()
self.outputRoot = "sheardispnoslip"
self.soln = AnalyticalSoln()
return
def test_fault_info(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault_info.h5" % self.outputRoot
fields = ["normal_dir", "final_slip", "slip_time"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def test_fault_data(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault.h5" % self.outputRoot
fields = ["slip"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh['ncells']
pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress" or name == "cauchy_stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
def calcFaultField(self, name, vertices):
"""
Calculate fault info.
"""
normalDir = (+1.0, 0.0, 0.0)
finalSlip = 0.0
slipTime = 0.0
nvertices = self.faultMesh['nvertices']
if name == "normal_dir":
field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64)
field[0,:,0] = normalDir[0]
field[0,:,1] = normalDir[1]
field[0,:,2] = normalDir[2]
elif name == "final_slip":
field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64)
field[0,:,0] = finalSlip
elif name == "slip_time":
#.........这里部分代码省略.........
示例6: TestShearDispNoSlipRefine
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestShearDispNoSlipRefine(TestHex8):
"""
Test suite for testing pylith with 2-D shear extension.
"""
def setUp(self):
"""
Setup for test.
"""
TestHex8.setUp(self)
self.mesh = {'ncells-elastic': 180*8,
'ncells-viscoelastic': 180*8,
'ncorners': 8,
'nvertices': 3591,
'spaceDim': 3,
'tensorSize': 6}
self.nverticesO = self.mesh['nvertices']
self.mesh['nvertices'] += 44
self.faultMesh = {'nvertices': 65,
'spaceDim': 3,
'ncells': 48,
'ncorners': 4}
run_pylith()
self.outputRoot = "sheardispnosliprefine"
self.soln = AnalyticalSoln()
return
def test_fault_info(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault_info.h5" % self.outputRoot
fields = ["normal_dir", "final_slip", "slip_time"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def test_fault_data(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault.h5" % self.outputRoot
fields = ["slip"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh['ncells']
pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
def calcFaultField(self, name, vertices):
"""
Calculate fault info.
"""
normalDir = (-1.0, 0.0, 0.0)
finalSlip = 0.0
slipTime = 0.0
nvertices = self.faultMesh['nvertices']
if name == "normal_dir":
field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64)
field[0,:,0] = normalDir[0]
field[0,:,1] = normalDir[1]
#.........这里部分代码省略.........
示例7: TestShearDispFriction
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestShearDispFriction(TestTri3):
"""
Test suite for testing pylith with 2-D shear extension.
"""
def setUp(self):
"""
Setup for test.
"""
TestTri3.setUp(self)
self.nverticesO = self.mesh['nvertices']
self.mesh['nvertices'] += 1
self.faultMesh = {'nvertices': 3,
'spaceDim': 2,
'ncells': 2,
'ncorners': 2}
run_pylith()
self.outputRoot = "sheardispfriction"
self.soln = AnalyticalSoln()
return
def test_fault_info(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault_info.h5" % self.outputRoot
fields = ["strike_dir", "normal_dir", "traction_initial","friction_coefficient","cohesion"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def test_fault_data(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault.h5" % self.outputRoot
fields = ["slip"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh['ncells']
pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
def calcFaultField(self, name, vertices):
"""
Calculate fault info.
"""
strikeDir = (-1.0, 0.0)
normalDir = (0.0, 1.0)
initialTraction = (0.0, -100.0e+6)
frictionCoefficient = 1.0
nvertices = self.faultMesh['nvertices']
if name == "strike_dir":
field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64)
field[0,:,0] = strikeDir[0]
field[0,:,1] = strikeDir[1]
elif name == "normal_dir":
field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64)
field[0,:,0] = normalDir[0]
field[0,:,1] = normalDir[1]
#.........这里部分代码省略.........
示例8: TestFrictionNoSlip
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestFrictionNoSlip(TestHex8):
"""
Test suite for testing pylith with 2-D shear extension.
"""
def setUp(self):
"""
Setup for test.
"""
TestHex8.setUp(self)
self.nverticesO = self.mesh["nvertices"]
self.mesh["nvertices"] += 10
self.faultMesh = {"nvertices": 21, "spaceDim": 3, "ncells": 12, "ncorners": 4}
run_pylith()
self.outputRoot = "frictionnoslip"
self.soln = AnalyticalSoln()
return
def test_fault_info(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault_info.h5" % self.outputRoot
fields = ["normal_dir", "strike_dir", "static_coefficient", "traction_initial"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def test_fault_data(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault.h5" % self.outputRoot
fields = ["slip"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh["ncells"]
pts = numpy.zeros((ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
def calcFaultField(self, name, vertices):
"""
Calculate fault info.
"""
normalDir = (-1.0, 0.0, 0.0)
strikeDir = (0.0, -1.0, 0.0)
staticCoef = 0.6
initialTraction = (0.0, 0.0, -100.0e6)
nvertices = self.faultMesh["nvertices"]
if name == "normal_dir":
field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64)
field[0, :, 0] = normalDir[0]
field[0, :, 1] = normalDir[1]
field[0, :, 2] = normalDir[2]
elif name == "strike_dir":
field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64)
field[0, :, 0] = strikeDir[0]
field[0, :, 1] = strikeDir[1]
field[0, :, 2] = strikeDir[2]
elif name == "static_coefficient":
field = staticCoef * numpy.ones((1, nvertices, 1), dtype=numpy.float64)
#.........这里部分代码省略.........
示例9: TestFrictionNoSlipHalo
# 需要导入模块: from sheardisp_soln import AnalyticalSoln [as 别名]
# 或者: from sheardisp_soln.AnalyticalSoln import displacement [as 别名]
class TestFrictionNoSlipHalo(TestHex8):
"""
Test suite for testing pylith with 2-D shear extension.
"""
def setUp(self):
"""
Setup for test.
"""
TestHex8.setUp(self)
self.nverticesO = self.mesh['nvertices']
self.mesh['nvertices'] += 21
self.faultMesh = {'nvertices': 34,
'spaceDim': 3,
'ncells': 23,
'ncorners': 4}
run_pylith()
self.outputRoot = "frictionnoslip_halo"
self.soln = AnalyticalSoln()
return
def test_fault_info(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault_info.h5" % self.outputRoot
fields = ["static_coefficient"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def test_fault_data(self):
"""
Check fault information.
"""
if not self.checkResults:
return
filename = "%s-fault.h5" % self.outputRoot
fields = ["slip"]
from pylith.tests.Fault import check_vertex_fields
check_vertex_fields(self, filename, self.faultMesh, fields)
return
def calcDisplacements(self, vertices):
"""
Calculate displacement field given coordinates of vertices.
"""
return self.soln.displacement(vertices)
def calcStateVar(self, name, vertices, cells):
"""
Calculate state variable.
"""
ncells = self.mesh['ncells']
pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
if name == "total_strain":
stateVar = self.soln.strain(pts)
elif name == "stress":
stateVar = self.soln.stress(pts)
else:
raise ValueError("Unknown state variable '%s'." % name)
return stateVar
def calcFaultField(self, name, vertices):
"""
Calculate fault info.
"""
normalDir = (-1.0, 0.0, 0.0)
strikeDir = (0.0, -1.0, 0.0)
staticCoef = 0.6
initialTraction = (0.0,0.0,-100.0e+6)
nvertices = self.faultMesh['nvertices']
if name == "static_coefficient":
field = staticCoef*numpy.ones( (1, nvertices, 1), dtype=numpy.float64)
elif name == "slip":
field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64)
else:
#.........这里部分代码省略.........