本文整理汇总了Python中pyNastran.bdf.bdf.BDF.cross_reference方法的典型用法代码示例。如果您正苦于以下问题:Python BDF.cross_reference方法的具体用法?Python BDF.cross_reference怎么用?Python BDF.cross_reference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyNastran.bdf.bdf.BDF
的用法示例。
在下文中一共展示了BDF.cross_reference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_solid_03
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_solid_03(self):
"""checks linear static solid material"""
mid = 2
pid = 4
rho = 0.1
cards = [
# $ Solid Nodes
["GRID", 11, 0, 0.0, 0.0, 0.0, 0],
["GRID", 12, 0, 1.0, 0.0, 0.0, 0],
["GRID", 13, 0, 1.0, 1.0, 0.0, 0],
["GRID", 14, 0, 0.0, 1.0, 0.0, 0],
["GRID", 15, 0, 0.0, 0.0, 2.0, 0],
["GRID", 16, 0, 1.0, 0.0, 2.0, 0],
["GRID", 17, 0, 1.0, 1.0, 2.0, 0],
["GRID", 18, 0, 0.0, 1.0, 2.0, 0],
# Solids
["CHEXA", 7, pid, 11, 12, 13, 14, 15, 16, 17, 18],
["CTETRA", 8, pid, 11, 12, 13, 15],
# Solid Nodes
["GRID", 21, 0, 0.0, 0.0, 0.0, 0],
["GRID", 22, 0, 1.0, 0.0, 0.0, 0],
["GRID", 23, 0, 1.0, 1.0, 0.0, 0],
["GRID", 24, 0, 0.0, 0.0, 2.0, 0],
["GRID", 25, 0, 1.0, 0.0, 2.0, 0],
["GRID", 26, 0, 1.0, 1.0, 2.0, 0],
["CPENTA", 9, pid, 21, 22, 23, 24, 25, 26],
# static
["PSOLID", pid, mid, 0],
["MAT1", mid, 1.0, 2.0, 3.0, rho],
["MATS1", mid, None, "PLASTIC", 0.0, 1, 1, 100000.0],
]
model = BDF(debug=False)
for fields in cards:
model.add_card(fields, fields[0], is_list=True)
model.cross_reference()
示例2: getNodes
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def getNodes(self, grids, grids_expected, coords):
model = BDF(debug=False)
for grid in grids:
(nid, cid, x, y, z) = grid
model.add_card(['GRID', nid, cid, x, y, z], 'GRID')
for coord in coords:
(cid, rid, x, y, z) = coord
model.add_card(['CORD2R', cid, rid] + x + y + z, 'CORD2R')
coordObj = model.Coord(cid)
model.cross_reference()
for (i, grid) in enumerate(grids_expected):
(nid, cid, x, y, z) = grid
node = model.Node(nid)
pos = node.Position()
n = array([x, y, z])
msg = 'i=%s expected=%s actual=%s\n' % (i, n, pos)
msg += 'n=%s grid=\n%s' % (nid, node)
coord = node.cp
msg += 'n=%s coord=\n%s' % (node.nid, coord)
while coord.rid:
msg += 'n=%s rcoord=\n%s' % (node.nid, coord.rid)
coord = coord.rid
assert allclose(n, pos), msg
示例3: test_cord2_bad_01
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_cord2_bad_01(self):
model = BDF(debug=False)
cards = [
["CORD2R", 1, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], # fails on self.k
["CORD2R", 2, 0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], # fails on normalize self.j
["CORD2R", 3, 0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], # passes
["CORD2R", 4, 0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], # passes
["CORD2R", 5, 4, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], # passes
]
for card in cards:
cid = card[1]
if cid in [1, 2]:
with self.assertRaises(RuntimeError):
model.add_card(card, card[0], is_list=True)
else:
model.add_card(card, card[0], is_list=True)
# this runs because it's got rid=0
cord4 = model.Coord(4)
cord4.transform_node_to_global([0.0, 0.0, 0.0])
# this doesn't run because rid != 0
cord5 = model.Coord(5)
with self.assertRaises(RuntimeError):
cord5.transform_node_to_global([0.0, 0.0, 0.0])
model.cross_reference()
示例4: _get_nodes
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def _get_nodes(self, grids, grids_expected, coords):
model = BDF(debug=False)
for grid in grids:
(nid, cid, x, y, z) = grid
model.add_card(["GRID", nid, cid, x, y, z], "GRID")
for coord in coords:
(cid, rid, x, y, z) = coord
model.add_card(["CORD2R", cid, rid] + x + y + z, "CORD2R")
coordObj = model.Coord(cid)
model.cross_reference()
for i, grid in enumerate(grids_expected):
nid, cid, x, y, z = grid
node = model.Node(nid)
pos = node.Position()
n = array([x, y, z])
msg = "i=%s expected=%s actual=%s\n" % (i, n, pos)
msg += "n=%s grid=\n%s" % (nid, node)
coord = node.cp
msg += "n=%s coord=\n%s" % (node.nid, coord)
while coord.rid:
msg += "n=%s rcoord=\n%s" % (node.nid, coord.rid)
coord = coord.rid
assert allclose(n, pos), msg
示例5: test_deqatn_9
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_deqatn_9(self):
"""
per nast/tpl/ptdmi1.dat
"""
model = BDF(debug=None)
model.cards_to_read.add('DEQATN')
model.test_deqatn = True
card = [
'deqatn 2 f(x,y,z)= 1.;',
' L=1+2+3+',
' + 4/min(1,2);',
' b= 4.;',
' h= 2.;',
' t1= 200.;',
' t2= 300.;',
' t=t1*(L-x)/L+t2*x/L',
' +4'
]
model.add_card(card, 'DEQATN', is_list=False)
model.cross_reference()
s = StringIO()
model.write_bdf(s, close=False)
s.getvalue()
s.close()
示例6: test_solids_chexa
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_solids_chexa(self):
"""tests a CHEXA8"""
model = BDF(debug=False)
eid = 10
pid = 20
mid = 30
E = 3.e7
G = None
nu = 0.3
model.add_grid(11, xyz=[0., 0., 0.])
model.add_grid(12, xyz=[1., 0., 0.])
model.add_grid(13, xyz=[1., 1., 0.])
model.add_grid(14, xyz=[0., 1., 0.])
model.add_grid(15, xyz=[0., 0., 2.])
model.add_grid(16, xyz=[1., 0., 2.])
model.add_grid(17, xyz=[1., 1., 2.])
model.add_grid(18, xyz=[0., 1., 2.])
model.add_psolid(pid, mid)
model.add_mat1(mid, E, G, nu)
nids = [11, 12, 13, 14, 15, 16, 17, 18]
elem = model.add_chexa(eid, pid, nids, comment='chexa')
elem.write_card(size=8)
elem.write_card(size=16)
model.validate()
model._verify_bdf(xref=False)
model.cross_reference()
model._verify_bdf(xref=True)
示例7: test_cord2r_1
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_cord2r_1(self):
grid = ['GRID 20143 7 -9.31-4 .11841 .028296']
coord = [
'CORD2R 7 1.135 .089237 -.0676 .135 .089237 -.0676',
' 1.135 .089237 .9324']
model = BDF(debug=False)
card = model.process_card(grid)
model.add_card(card, card[0])
card = model.process_card(coord)
model.add_card(card, card[0])
model.cross_reference()
g = model.Node(20143)
#print(g.Position(debug=False))
# by running it through Patran...
#GRID 20143 1.1067 .207647 -.068531
diff = g.Position() - array([1.106704, .207647, -0.068531])
msg = 'diff=%s' % diff
assert allclose(diff, 0.), msg
coord = model.Coord(7)
coord.T()
self.assertTrue(array_equal(coord.T(), coord.beta_n(2)))
示例8: getNodes
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def getNodes(self, grids, gridsExpected, coords, debug=False):
mesh = BDF(debug=False)
for (nid, grid) in enumerate(grids):
(cid, x, y, z) = grid
mesh.add_card(["GRID", nid + 1, cid, x, y, z], "GRID")
gridObj = mesh.Node(nid + 1)
if debug:
print(gridObj)
for (cid, coord) in enumerate(coords):
# print coord
(rid, x, y, z) = coord
obj = mesh.add_card(["CORD2R", cid + 1, rid] + x + y + z, "CORD2R")
coordObj = mesh.Coord(cid + 1)
if debug:
print(coordObj)
mesh.cross_reference()
for (i, grid) in enumerate(gridsExpected):
(cid, x, y, z) = grid
node = mesh.Node(i + 1)
pos = node.Position()
n = array([x, y, z])
msg = "expected=%s actual=%s\n" % (n, pos)
msg += "n=%s grid=\n%s" % (i + 1, node)
coord = node.cp
msg += "n=%s coord=\n%s" % (node.nid, coord)
while coord.rid:
msg += "n=%s rcoord=\n%s" % (node.nid, coord.rid)
coord = coord.rid
assert allclose(n, pos), msg
示例9: test_cord2c_01
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_cord2c_01(self):
lines = [
'CORD2C* 3 0 0. 0.',
'* 0. 0. 0. 1.*',
'* 1. 0. 1.'
]
model = BDF(debug=False)
card = model.process_card(lines)
card = BDFCard(card)
card = CORD2C(card)
model.add_coord(card)
lines = [
'CORD2R 4 3 10. 0. 5. 10. 90. 5.',
' 10. 0. 6.'
]
card = model.process_card(lines)
card = BDFCard(card)
card = CORD2R(card)
model.add_coord(card)
model.cross_reference()
cord2r = model.Coord(3)
self.assertEqual(cord2r.Cid(), 3)
self.assertEqual(cord2r.Rid(), 0)
cord2r = model.Coord(4)
self.assertEqual(cord2r.Cid(), 4)
self.assertEqual(cord2r.Rid(), 3)
self.assertTrue(allclose(cord2r.i, array([0., 0., 1.])))
delta = cord2r.j - array([1., 1., 0.]) / 2**0.5
self.assertTrue(allclose(cord2r.j, array([1., 1., 0.]) / 2**0.5), str(delta))
delta = cord2r.k - array([-1., 1., 0.]) / 2**0.5
self.assertTrue(allclose(cord2r.k, array([-1., 1., 0.]) / 2**0.5), str(delta))
示例10: test_solids_ctetra10
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_solids_ctetra10(self):
"""tests a CTETRA10"""
eid = 10
pid = 20
mid = 30
E = 3.e7
G = None
nu = 0.3
model = BDF(debug=False)
g110 = model.add_grid(110, xyz=[0., 0., 0.])
g120 = model.add_grid(120, xyz=[1., 0., 0.])
g130 = model.add_grid(130, xyz=[1., 1., 0.])
g140 = model.add_grid(140, xyz=[0., 2., 0.])
model.add_grid(111, xyz=g110.xyz+g120.xyz)
model.add_grid(112, xyz=g120.xyz+g130.xyz)
model.add_grid(113, xyz=g130.xyz+g110.xyz)
model.add_grid(121, xyz=g110.xyz+g140.xyz)
model.add_grid(122, xyz=g120.xyz+g140.xyz)
model.add_grid(123, xyz=g130.xyz+g140.xyz)
model.add_psolid(pid, mid)
model.add_mat1(mid, E, G, nu)
nids = [
110, 120, 130, 140,
111, 112, 113,
121, 122, 123
]
model.add_ctetra(eid, pid, nids, comment='ctetra')
model.validate()
model._verify_bdf(xref=False)
model.cross_reference()
model._verify_bdf(xref=True)
示例11: test_cord2r_02
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_cord2r_02(self):
grid = ['GRID 20143 7 -9.31-4 .11841 .028296']
coord = [
'CORD2R 7 1.135 .089237 -.0676 .135 .089237 -.0676',
' 1.135 .089237 .9324'
]
model = BDF(debug=False)
card = model.process_card(grid)
model.add_card(card, card[0])
card = model.process_card(coord)
model.add_card(card, card[0])
model.cross_reference()
coord = model.Coord(7)
#print(coord.origin)
#print(coord.i, coord.j, coord.k)
g = model.Node(20143)
#print(g.Position(debug=False))
xyz = g.Position()
# by running it through Patran...
#GRID 20143 1.1067 .207647 -.068531
expected = array([1.106704, .207647, -0.068531])
diff = xyz - expected
msg = '\nexpected=%s \nactual =%s \ndiff =%s' % (expected, xyz, diff)
assert allclose(diff, 0.), msg
coord = model.Coord(7)
coord.beta_n(1)
coord.beta_n(2)
coord.beta_n(3)
coord.beta_n(6)
self.assertTrue(array_equal(coord.T(), coord.beta_n(2)))
示例12: test_deqatn_10
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_deqatn_10(self):
"""
per nast/tpl/ptdmi1.dat
"""
model = BDF(debug=None)
model.cards_to_read.add('DEQATN')
model.test_deqatn = True
card = [
'deqatn 2 f(x,y,z)= 1.;',
' L=x+y',
]
model.add_card(card, 'DEQATN', is_list=False)
model.cross_reference()
s = StringIO()
model.write_bdf(s, close=False)
s.getvalue()
s.close()
eq = model.dequations[2]
x = zeros(10., dtype='float32')
y = zeros(11., dtype='float32')
z = zeros(12., dtype='float32')
#out = eq.func(x, y, z)
out = eq.func(1.0, 2.0)
print(out)
示例13: test_cord2_rcs_01
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_cord2_rcs_01(self):
"""
all points are located at <30,40,50>
"""
model = BDF(debug=False)
cards = [
[#'$ Femap with NX Nastran Coordinate System 10 : rectangular defined in a rectangular',
'CORD2R* 10 0 10. 5.',
'* 3. 10.3420201433 4.53015368961 3.81379768136* ',
'* 10.7198463104 5.68767171433 3.09449287122',],
[#'$ Femap with NX Nastran Coordinate System 11 : cylindrical defined in rectangular',
'CORD2C* 11 0 7. 3.',
'* 9. 7.64278760969 2.73799736977 9.71984631039* ',
'* 7.75440650673 3.37968226211 8.46454486422',],
[#'$ Femap with NX Nastran Coordinate System 12 : spherical defined in rectangular',
'CORD2S* 12 0 12. 8.',
'* 5. 12.6427876097 7.86697777844 5.75440650673* ',
'* 12.6634139482 8.58906867688 4.53861076379',],
['GRID* 10 10 42.9066011565 34.2422137135',
'* 28.6442730262 0',],
['GRID* 11 11 48.8014631871 78.8394787869',
'* 34.6037164304 0',],
['GRID* 12 12 58.0775343829 44.7276544324',
'* 75.7955331161 0',],
]
for lines in cards:
card = model.process_card(lines)
model.add_card(card, card[0])
model.cross_reference()
for nid in model.nodes:
a = array([30.,40.,50.])
b = model.Node(nid).Position()
self.assertTrue(allclose(array([30.,40.,50.]), model.Node(nid).Position()), str(a-b))
示例14: test_cquad4_01
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_cquad4_01(self):
model = BDF(debug=False)
eid = 10
pid = 20
mid = 30
n1 = 1
n2 = 2
n3 = 3
n4 = 4
n5 = 5
n6 = 6
A = 2.
t = rho = nsm = E = G = nu = 0.1
mid2 = mid3 = mid4 = twelveIt3 = tst = z1 = z2 = None
mass = A * (t * rho + nsm)
cards = [
['grid', n1, 0, 0., 0., 0.],
['grid', n2, 0, 2., 0., 0.],
['grid', n3, 0, 2., 1., 0.],
['grid', n4, 0, 0., 1., 0.],
['grid', n5, 0, 0., 0., 0.],
['grid', n6, 0, 2., 0., 0.],
['cquad4', eid, pid, n1, n2, n3, n4],
['cquad4', eid+1, pid, n5, n6, n3, n4],
['pshell', pid, mid, t, mid2, twelveIt3, mid3, tst, nsm, z1, z2],
['mat1', mid, E, G, nu, rho],
]
for fields in cards:
model.add_card(fields, fields[0], is_list=True)
# get node IDs without cross referencing
eids = [10]
nids = model.get_node_ids_with_elements(eids)
assert nids == set([1, 2, 3, 4]), nids
eids = [11]
nids = model.get_node_ids_with_elements(eids)
assert nids == set([3, 4, 5, 6]), nids
eids = [10, 11]
nids = model.get_node_ids_with_elements(eids)
assert nids == set([1, 2, 3, 4, 5, 6]), nids
# get node IDs with cross referencing
model.cross_reference()
eids = [10]
nids = model.get_node_ids_with_elements(eids)
assert nids == set([1, 2, 3, 4]), nids
eids = [11]
nids = model.get_node_ids_with_elements(eids)
assert nids == set([3, 4, 5, 6]), nids
eids = [10, 11]
nids = model.get_node_ids_with_elements(eids)
assert nids == set([1, 2, 3, 4, 5, 6]), nids
示例15: test_loads_sum_radial_01
# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import cross_reference [as 别名]
def test_loads_sum_radial_01(self):
model = BDF()
from pyNastran.bdf.bdf import CORD2C, GRID, FORCE
model.nodes[1] = GRID(1, cp=1, xyz=[0., 0., 0.], cd=0, ps='', seid=0,
comment='')
cid = 1
origin = [0., 0., 0.]
zaxis = [0., 0., 1.]
xaxis = [1., 0., 0.]
model.coords[1] = CORD2C(cid, rid=0, origin=origin, zaxis=zaxis,
xzplane=xaxis, comment='')
sid = 1
node = 1
cid = 1
mag = 1.1
xyz = [1., 0., 0.]
radial_force = FORCE(sid, node, cid, mag, xyz, comment='')
model.add_card_class(radial_force)
sid = 2
xyz = [1., 90., 0.]
mag = 2.2
theta_force = FORCE(sid, node, cid, mag, xyz, comment='')
model.add_card_class(theta_force)
model.cross_reference()
p0 = 1
eids = None
nids = None
loadcase_id = 1
F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False,
xyz_cid0=None)
F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids,
include_grav=False,
xyz_cid0=None)
assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
F1_expected = np.array([1.1, 0., 0.])
M1_expected = np.array([0., 0., 0.])
self.assertTrue(allclose(F1_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1_expected, F))
self.assertTrue(allclose(M1_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1_expected, M))
loadcase_id = 2
F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False,
xyz_cid0=None)
F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids,
include_grav=False,
xyz_cid0=None)
assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
F2_expected = np.array([0., 2.2, 0.])
M2_expected = np.array([0., 0., 0.])
self.assertTrue(allclose(F2_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F2_expected, F))
self.assertTrue(allclose(M2_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M2_expected, M))