bdfInterface Package

addCard Module

Inheritance diagram of pyNastran.bdf.bdfInterface.addCard

class pyNastran.bdf.bdfInterface.addCard.AddMethods[source]

Bases: object

add_AEFACT(aefact, allowOverwrites=False)[source]
add_AELIST(aelist)[source]
add_AEPARM(aeparam)[source]
add_AERO(aero)[source]
add_AEROS(aero)[source]
add_AESTAT(aestat)[source]
add_AESURF(aesurf)[source]
add_ASET(set_obj)[source]
add_BCRPARA(card, allowOverwrites=False)[source]
add_BCTADD(card, allowOverwrites=False)[source]
add_BCTPARA(card, allowOverwrites=False)[source]
add_BCTSET(card, allowOverwrites=False)[source]
add_BSET(set_obj)[source]
add_BSURF(card, allowOverwrites=False)[source]
add_BSURFS(card, allowOverwrites=False)[source]
add_CAERO(caero)[source]
add_CSET(set_obj)[source]
add_DAREA(darea, allowOverwrites=False)[source]
add_DCONSTR(dconstr)[source]
add_DDVAL(ddval)[source]
add_DEQATN(deqatn, allowOverwrites=False)[source]
add_DESVAR(desvar)[source]
add_DMI(dmi, allowOverwrites=False)[source]
add_DMIG(dmig, allowOverwrites=False)[source]
add_DMIJ(dmij, allowOverwrites=False)[source]
add_DMIJI(dmiji, allowOverwrites=False)[source]
add_DMIK(dmik, allowOverwrites=False)[source]
add_DRESP(dresp)[source]
add_DVMREL(dvmrel)[source]
add_DVPREL(dvprel)[source]
add_FLFACT(flfact)[source]
add_FLUTTER(flutter)[source]
add_FREQ(freq)[source]
add_GUST(gust)[source]
add_LSEQ(load)[source]
add_MKAERO(mkaero)[source]
add_NLPARM(nlparm)[source]
add_NLPCI(nlpci)[source]
add_PAERO(paero)[source]
add_PARAM(param, allowOverwrites=False)[source]
add_PBUSHT(prop, allowOverwrites=False)[source]
add_PDAMPT(prop, allowOverwrites=False)[source]
add_PELAST(prop, allowOverwrites=False)[source]
add_PHBDY(prop)[source]
add_QSET(set_obj)[source]
add_SESET(set_obj)[source]
add_SET(set_obj)[source]
add_SPLINE(spline)[source]
add_SPOINT(spoint)[source]
add_TRIM(trim, allowOverwrites=False)[source]
add_TSTEP(tstep, allowOverwrites=False)[source]
add_TSTEPNL(tstepnl, allowOverwrites=False)[source]
add_cmethod(cMethod, allowOverwrites=False)[source]
add_constraint(constraint)[source]
add_constraint_MPC(constraint)[source]
add_constraint_MPCADD(constraint)[source]
add_constraint_SPC(constraint)[source]
add_constraint_SPCADD(constraint)[source]
add_convection_property(prop)[source]
add_coord(coord, allowOverwrites=False)[source]
add_creep_material(material, allowOverwrites=False)[source]

Note

May be removed in the future. Are CREEP cards materials? They have an MID, but reference structural materials.

add_damper(elem, allowOverwrites=False)[source]

Warning

can dampers have the same ID as a standard element?

add_dload(dload)[source]
add_dload_entry(dload)[source]
add_element(elem, allowOverwrites=False)[source]
add_hyperelastic_material(material, allowOverwrites=False)[source]
add_load(load)[source]
add_mass(mass, allowOverwrites=False)[source]
add_material_dependence(material, allowOverwrites=False)[source]
add_method(method, allowOverwrites=False)[source]
add_node(node, allowOverwrites=False)[source]
add_property(prop, allowOverwrites=False)[source]
add_property_mass(prop, allowOverwrites=False)[source]
add_random_table(table)[source]
add_rigid_element(elem, allowOverwrites=False)[source]
add_structural_material(material, allowOverwrites=False)[source]
add_suport(suport)[source]
add_table(table)[source]
add_thermal_BC(bc, key)[source]
add_thermal_element(elem)[source]

same as add_element at the moment...

add_thermal_load(load)[source]
add_thermal_material(material, allowOverwrites=False)[source]

assign_type Module

pyNastran.bdf.bdfInterface.assign_type._get_dtype(value)[source]

Get the type of the input value in a form that is clear.

Parameters:value – the value to get the type of
pyNastran.bdf.bdfInterface.assign_type.blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.components(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.components_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.double(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.double_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.double_or_string(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.double_string_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
Returns value:

a double, string, or default value

Raises SyntaxError:
 

if there is an invalid type

pyNastran.bdf.bdfInterface.assign_type.field(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.fields(f, card, fieldname, i, j=None)[source]

Todo

improve fieldname

pyNastran.bdf.bdfInterface.assign_type.integer(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.integer_double_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.integer_double_or_string(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.integer_double_string_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.integer_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.integer_or_double(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
Returns value:

the value with the proper type

Raises SyntaxError:
 

if there’s an invalid type

pyNastran.bdf.bdfInterface.assign_type.integer_or_string(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.integer_string_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)
pyNastran.bdf.bdfInterface.assign_type.interpret_value(value_raw, card='')[source]

Converts a value from nastran format into python format.

pyNastran.bdf.bdfInterface.assign_type.string(card, ifield, fieldname)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
pyNastran.bdf.bdfInterface.assign_type.string_or_blank(card, ifield, fieldname, default=None)[source]
Parameters:
  • card – BDF card as a list
  • ifield – field number
  • fieldname – name of field
  • default – the default value for the field (default=None)

BDF_Card Module

Inheritance diagram of pyNastran.bdf.bdfInterface.BDF_Card

class pyNastran.bdf.bdfInterface.BDF_Card.BDFCard(card=None, debug=False)[source]

Bases: object

field(i, default=None)[source]

Gets the ith field on the card

Parameters:
  • self – the object pointer
  • i (integer) – the ith field on the card (following list notation)
  • default – the default value for the field
Returns value:

the value on the ith field

fields(i=0, j=None, defaults=None)[source]

Gets multiple fields on the card

Parameters:
  • self – the object pointer
  • i (integer >= 0) – the ith field on the card (following list notation)
  • j (integer or None (default=end of card)) – the jth field on the card (None means till the end of the card)
  • defaults – the default value for the field (as a list) len(defaults)=i-j-1
Returns value:

the values on the ith-jth fields

index(i)[source]
nFields()[source]

Gets how many fields are on the card

Parameters:self – the object pointer
Returns nfields:
 the number of fields on the card
pop()[source]

Pops the last value off

bdf_writeMesh Module

Inheritance diagram of pyNastran.bdf.bdfInterface.bdf_writeMesh

This file defines:
  • WriteMesh
class pyNastran.bdf.bdfInterface.bdf_writeMesh.WriteMesh[source]

Bases: object

Major methods:
  • model.write_bdf(...)
  • model.echo_bdf(...)
  • model.auto_reject_bdf(...)
_output_helper(out_filename, interspersed, size, is_double)[source]

Performs type checking on the write_bdf inputs

_write_aero(outfile, size=8, is_double=False)[source]

Writes the aero cards

_write_aero_control(outfile, size=8, is_double=False)[source]

Writes the aero control surface cards

_write_case_control_deck(outfile)[source]

Writes the Case Control Deck.

Parameters:self – the BDF object
_write_common(outfile, size=8, is_double=False)[source]

Write the common outputs so none get missed...

Parameters:self – the BDF object
Returns msg:part of the bdf
_write_constraints(outfile, size=8, is_double=False)[source]

Writes the constraint cards sorted by ID

_write_contact(outfile, size=8, is_double=False)[source]

Writes the contact cards sorted by ID

_write_coords(outfile, size=8, is_double=False)[source]

Writes the coordinate cards in a sorted order

_write_dmigs(outfile, size=8, is_double=False)[source]

Writes the DMIG cards

Parameters:
  • self – the BDF object
  • size – large field (16) or small field (8)
Returns msg:

string representation of the DMIGs

_write_dynamic(outfile, size=8, is_double=False)[source]

Writes the dynamic cards sorted by ID

_write_elements(outfile, size=8, is_double=False)[source]

Writes the elements in a sorted order

Parameters:self – the BDF object
_write_elements_properties(outfile, size=8, is_double=False)[source]

Writes the elements and properties in and interspersed order

_write_executive_control_deck(outfile)[source]

Writes the executive control deck.

Parameters:self – the BDF object
_write_flutter(outfile, size=8, is_double=False)[source]

Writes the flutter cards

_write_header(outfile)[source]

Writes the executive and case control decks.

Parameters:self – the BDF object
_write_loads(outfile, size=8, is_double=False)[source]

Writes the load cards sorted by ID

_write_masses(outfile, size=8, is_double=False)[source]
_write_materials(outfile, size=8, is_double=False)[source]

Writes the materials in a sorted order

_write_nodes(outfile, size=8, is_double=False)[source]

Writes the NODE-type cards

Parameters:self – the BDF object
_write_optimization(outfile, size=8, is_double=False)[source]

Writes the optimization cards sorted by ID

_write_params(outfile, size=8, is_double=False)[source]

Writes the PARAM cards

Parameters:self – the BDF object
_write_properties(outfile, size=8, is_double=False)[source]

Writes the properties in a sorted order

_write_rejects(outfile, size=8, is_double=False)[source]

Writes the rejected (processed) cards and the rejected unprocessed cardLines

_write_rigid_elements(outfile, size=8, is_double=False)[source]

Writes the rigid elements in a sorted order

_write_sets(outfile, size=8, is_double=False)[source]

Writes the SETx cards sorted by ID

_write_tables(outfile, size=8, is_double=False)[source]

Writes the TABLEx cards sorted by ID

_write_thermal(outfile, size=8, is_double=False)[source]

Writes the thermal cards

_write_thermal_materials(outfile, size=8, is_double=False)[source]

Writes the thermal materials in a sorted order

auto_reject_bdf(infile_name)[source]

This method parses supported cards, but does not group them into nodes, elements, properties, etc.

Todo

maybe add the write method

echo_bdf(infile_name)[source]

This method removes all comment lines from the bdf A write method is stil required.

Todo

maybe add the write method

write_bdf(out_filename=None, size=8, is_double=False, interspersed=True, enddata=None)[source]

Writes the BDF.

Parameters:
  • self – the BDF object
  • out_filename – the name to call the output bdf (default=None; pops a dialog)
  • size – the field size (8 is recommended)
  • is_double – small field (False) or large field (True); default=False
  • interspersed – Writes a bdf with properties & elements interspersed like how Patran writes the bdf. This takes slightly longer than if interspersed=False, but makes it much easier to compare to a Patran-formatted bdf and is more clear. (default=True)
  • enddata – Flag to enable/disable writing ENDDATA (default=None -> depends on input BDF)

crossReference Module

Inheritance diagram of pyNastran.bdf.bdfInterface.crossReference

Links up the various cards in the BDF.

For example, with cross referencing...

>>> model = BDF()
>>> model.read_bdf(bdf_filename, xref=True)

>>> nid1 = 1
>>> node1 = model.nodes[nid1]
>>> node.nid
1

>>> node.xyz
[1., 2., 3.]

>>> node.Cid()
3

>>> node.cid
CORD2S, 3, 1, 0., 0., 0., 0., 0., 1.,
        1., 0., 0.
# get the position in the global frame
>>> node.Position()
[4., 5., 6.]

# get the position with respect to another frame
>>> node.PositionWRT(model, cid=2)
[4., 5., 6.]

Without cross referencing...

>>> model = BDF()
>>> model.read_bdf(bdf_filename, xref=True)

>>> nid1 = 1
>>> node1 = model.nodes[nid1]
>>> node.nid
1

>>> node.xyz
[1., 2., 3.]

>>> node.Cid()
3

>>> node.cid
3

# get the position in the global frame
>>> node.Position()
Error!

Cross-referencing allows you to easily jump across cards and also helps with calculating things like position, area, and mass. The BDF is designed around the idea of cross-referencing, so it’s recommended that you use it.

class pyNastran.bdf.bdfInterface.crossReference.XrefMesh[source]

Bases: object

Links up the various cards in the BDF.

The main BDF class defines all the parameters that are used.

_cross_reference_aero()[source]

Links up all the aero cards

_cross_reference_constraints()[source]

Links the SPCADD, SPC, SPCAX, SPCD, MPCADD, MPC cards.

_cross_reference_coordinates()[source]

Links up all the coordinate cards to other coordinate cards and nodes

_cross_reference_elements()[source]

Links the elements to nodes, properties (and materials depending on the card).

_cross_reference_loads()[source]

Links the loads to nodes, coordinate systems, and other loads.

_cross_reference_masses()[source]

Links the mass to nodes, properties (and materials depending on the card).

_cross_reference_materials()[source]

Links the materials to materials (e.g. MAT1, CREEP) often this is a pass statement

_cross_reference_nodes()[source]

Links the nodes to coordinate systems

_cross_reference_properties()[source]

Links the properties to materials

cross_reference(xref=True, xref_elements=True, xref_properties=True, xref_materials=True, xref_loads=True, xref_constraints=True, xref_aero=True)[source]

Links up all the cards to the cards they reference

Parameters:
  • xref – cross references the model (default=True)
  • xref_element – set cross referencing of elements (default=True)
  • xref_properties – set cross referencing of properties (default=True)
  • xref_materials – set cross referencing of materials (default=True)
  • xref_loads – set cross referencing of loads (default=True)
  • xref_constraints – set cross referencing of constraints (default=True)
  • xref_aero – set cross referencing of CAERO/SPLINEs (default=True)

To only cross-reference nodes:

model = BDF()
model.read_bdf(bdf_filename, xref=False)
model.cross_reference(xref=True, xref_loads=False, xref_constraints=False,
                                 xref_materials=False, xref_properties=False,
                                 xref_aero=False, xref_masses=False)

Warning

be careful if you call this method

getCard Module

Inheritance diagram of pyNastran.bdf.bdfInterface.getCard

class pyNastran.bdf.bdfInterface.getCard.GetMethods[source]

Bases: pyNastran.bdf.deprecated.GetMethodsDeprecated

AEFact(aefact, msg=u'')[source]
AEList(aelist, msg=u'')[source]
AEParam(aid, msg=u'')[source]
AEStat(aid, msg=u'')[source]
Aero(acsid, msg=u'')[source]
Aeros(acsid, msg=u'')[source]
CAero(eid, msg=u'')[source]
CMethod(sid, msg=u'')[source]
Coord(cid, msg=u'')[source]
DConstr(oid, msg=u'')[source]
DDVal(oid, msg=u'')[source]
DLoad(sid, msg=u'')[source]
DMIG(dname, msg=u'')[source]
Desvar(oid, msg=u'')[source]
Element(eid, msg=u'')[source]
Elements(eids, msg=u'')[source]
FLFACT(sid, msg=u'')[source]
Flutter(fid, msg=u'')[source]
Gust(sid, msg=u'')[source]
HyperelasticMaterial(mid, msg=u'')[source]
Load(sid, msg=u'')[source]
Mass(eid, msg=u'')[source]
Material(mid, msg=u'')[source]
Materials(mids, msg=u'')[source]
Method(sid, msg=u'')[source]
NLParm(nid, msg=u'')[source]
Node(nid, allowEmptyNodes=False, msg=u'')[source]
Nodes(nids, allowEmptyNodes=False, msg=u'')[source]

Returns a series of node objects given a list of node IDs

PAero(pid, msg=u'')[source]
Phbdy(pid, msg=u'')[source]
Properties(pids, msg=u'')[source]
Property(pid, msg=u'')[source]
PropertyMass(pid, msg=u'')[source]
RandomTable(tid, msg=u'')[source]
RigidElement(eid, msg=u'')[source]
SPC(conid, msg=u'')[source]
Set(sid, msg=u'')[source]
SetSuper(seid, msg=u'')[source]
Spline(eid, msg=u'')[source]
StructuralMaterial(mid, msg=u'')[source]
Table(tid, msg=u'')[source]
ThermalMaterial(mid, msg=u'')[source]
_GetMethods__test_method()
get_dload_entries(sid, msg=u'')[source]
get_element_ids_dict_with_pids(pids)[source]

Gets all the element IDs with a specific property ID.

Parameters:
  • self – the BDF object
  • pids – list of property ID
Returns element_ids:
 

as a dictionary of lists by property

For example, we want all the elements with pids=[4, 5, 6], but we want them in separate groups

model = BDF()
model.read_bdf(bdf_filename)
pids = [4, 5, 6]
eids_dict = model.get_element_ids_with_pids(pids, mode='dict')
get_element_ids_list_with_pids(pids)[source]

Gets all the element IDs with a specific property ID.

Parameters:
  • self – the BDF object
  • pids – list of property ID
Returns element_ids:
 

as a list

For example, we want to get all the element ids with pids=[1, 2, 3]

model = BDF()
model.read_bdf(bdf_filename)
pids = [1, 2, 3]
eids_list = model.get_element_ids_with_pids(pids, mode='list')
get_material_id_to_property_ids_map()[source]

Returns a dictionary that maps a material ID to a list of properties

Returns mid_to_pids_map:
 the mapping
>>> mid_to_pid_map = get_material_id_to_property_ids_map()
>>> mid = 1
>>> pids = get_material_id_to_property_ids_map[mid]
>>> pids
[1, 2, 3]

Note

all properties require an mid to be counted (except for PCOMP, which has multiple mids)

get_material_ids()[source]
get_node_id_to_element_ids_map()[source]

Returns a dictionary that maps a node ID to a list of elemnents

Todo

support 0d or 1d elements

Todo

support elements with missing nodes (e.g. CQUAD8 with missing nodes)

get_node_ids_with_element(eid, msg=u'')[source]
get_node_ids_with_elements(eids, msg=u'')[source]

Get the node IDs associated with a list of element IDs

Parameters:
  • self – the BDF object
  • eids – list of element ID
  • msg – a additional message to print out if an element is not found
Returns node_ids:
 

set of node IDs

For example

>>> eids = [1, 2, 3]  # list of elements with pid=1
>>> msg = ' which are required for pid=1'
>>> node_ids = bdf.get_node_ids_with_elements(eids, msg=msg)
get_property_id_to_element_ids_map()[source]

Returns a dictionary that maps a property ID to a list of elemnents

get_structural_material_ids()[source]
get_thermal_material_ids()[source]
get_x_associated_with_y(xdict, xkeys, ykeys, stop_on_failure=True)[source]

Get the range of sub-properties of a card.

Note

Assumes you’re taking a single path through the cards. You could probably explicitly code these queries faster, but this method has a lot of flexibility with very little user code.

Parameters:
  • self – the BDF object
  • xdict – the BDF attribute that should be querried (e.g. self.elements)
  • xkeys – the list of object keys that should be stepped through associated with xdict (e.g. eids=[1, 2, 3])
  • ykeys – the list of response keys that should be stepped through (e.g. [‘pid’, ‘mid’, ‘mid’])
  • stop_on_failure – Should an error be raised if there is an invalid key? For example, get all material used by elements, but don’t crash on CONRODs.
Returns results:
 

The set of all values used

# Get nodes associated with eid=[1, 2, 3]
nodes = self.get_x_associated_with_y(
    self.elements, [1, 2, 3], ['nodes'])

# Get node IDs associated with eid=[1, 2, 3]
nodesIDs = self.get_x_associated_with_y(
    self.elements, [1, 2, 3], ['nodes', 'nid'])

# Get coord IDs associated with eid=[1, 2, 3]
coordIDs = self.get_x_associated_with_y(
    self.elements, [1, 2, 3], ['nodes', 'cp', 'cid'])

# Get properties associated with eid=[1, 2, 3]
properties = self.get_x_associated_with_y(
    self.elements, [1, 2, 3], ['pid'])

# Get materials associated with eid=[1, 2, 3]
materials = self.get_x_associated_with_y(
    self.elements, [1, 2, 3], ['pid', 'mid'])

# Get material IDs associated with eid=[1, 2, 3]
materialIDs = self.get_x_associated_with_y(
    self.elements, [1, 2, 3], ['pid', 'mid', 'mid'])

# Get the values for Young's Modulus
E = self.get_x_associated_with_y(
    self.elements, None, ['pid', 'mid', 'e'])
pyNastran.bdf.bdfInterface.getCard._getattr(out_set, xi, xkeys, nlevels_left=0, stop_on_failure=True)[source]

Recursive method to help get_x_associated_with_y get the value of xkeys for the given variable xi

Parameters:
  • out_set (SET) – the SET of all outputs that will be filled and implicitly returned
  • xi (BDF BaseCard) – the current variable being iterated over
  • xkeys (LIST of STRINGS) – the variables left to iterate over
  • nlevels_left (INT >= 0) – the number of levels still to iterate over
  • stop_on_failure (bool) – should the code crash if a certain xkey cannot be found