bdf Package

This is the pyNastran.bdf.rst file.

bdf Module

bdf_Methods Module

Inheritance diagram of pyNastran.bdf.bdf_Methods

This file contains additional methods that do not directly relate to the reading/writing/accessing of BDF data. Such methods include:

  • Mass

    get the mass of the model

  • Mass Poperties

    get the mass & moment of inertia of the model

  • sumMoments / sum_moments

    find the net force/moment on the model

  • sumForces / sum_forces

    find the net force on the model

  • resolve_grids

    change all nodes to a specific coordinate system

  • unresolve_grids

    puts all nodes back to original coordinate system

class pyNastran.bdf.bdf_Methods.BDFMethods[source]

Bases: pyNastran.bdf.deprecated.BDFMethodsDeprecated

_BDFMethods__gravity_load(loadcase_id)

Todo

  1. resolve the load case
  2. grab all of the GRAV cards and combine them into one GRAV vector
  3. run mass_properties to get the mass
  4. multiply by the gravity vector
_apply_mass_symmetry(sym_axis, scale, mass, cg, I)[source]

Scales the mass & moement of inertia based on the symmetry axes and the PARAM WTMASS card

_mass_properties_mp(num_cpus, elements, masses, nelements, reference_point=None)[source]

Caclulates mass properties in the global system about the reference point.

Parameters:
  • self – the BDF object
  • num_cpus – the number of CPUs to use; 2 < num_cpus < 20
  • reference_point – an array that defines the origin of the frame. default = <0,0,0>.
Returns mass:

the mass of the model

Returns cg:

the cg of the model as an array.

Returns I:

moment of inertia array([Ixx, Iyy, Izz, Ixy, Ixz, Iyz])

See also

self.mass_properties

_mass_properties_sp(elements, masses, reference_point)[source]
mass_properties(element_ids=None, reference_point=None, sym_axis=None, num_cpus=1, scale=None)[source]

Caclulates mass properties in the global system about the reference point.

Parameters:
  • self – the BDF object
  • element_ids – an array of element ids
  • reference_point – an array that defines the origin of the frame. default = <0,0,0>.
  • sym_axis – the axis to which the model is symmetric. If AERO cards are used, this can be left blank allowed_values = ‘x’, ‘y’, ‘z’, ‘xy’, ‘yz’, ‘xz’, ‘xyz’
  • scale – the WTMASS scaling value default=None -> PARAM, WTMASS is used float > 0.0
Returns mass:

the mass of the model

Returns cg:

the cg of the model as an array.

Returns I:

moment of inertia array([Ixx, Iyy, Izz, Ixy, Ixz, Iyz])

I = mass * centroid * centroid

\[I_{xx} = m (dy^2 + dz^2)\]
\[I_{yz} = -m * dy * dz\]

where:

\[dx = x_{element} - x_{ref}\]

Note

This doesn’t use the mass matrix formulation like Nastran. It assumes m*r^2 is the dominant term. If you’re trying to get the mass of a single element, it will be wrong, but for real models will be correct.

resolve_grids(cid=0)[source]

Puts all nodes in a common coordinate system (mainly for cid testing)

Parameters:
  • self – the object pointer
  • cid – the cid to resolve the nodes to (default=0)

Note

loses association with previous coordinate systems so to go back requires another fem

sum_forces_moments(p0, loadcase_id, include_grav=False)[source]

Sums applied forces & moments about a reference point p0 for all load cases. Considers:

  • FORCE, FORCE1, FORCE2
  • MOMENT, MOMENT1, MOMENT2
  • PLOAD, PLOAD2, PLOAD4
  • LOAD
Parameters:
  • p0 (NUMPY.NDARRAY shape=(3,) or integer (node ID)) – the reference point
  • loadcase_id (integer) – the LOAD=ID to analyze
  • include_grav (bool) – includes gravity in the summation (not supported)
Returns Forces:

the forces

Returns Moments:
 

the moments

Warning

not full validated

Todo

It’s super slow for cid != 0. We can speed this up a lot if we calculate the normal, area, centroid based on precomputed node locations.

Pressure acts in the normal direction per model/real/loads.bdf and loads.f06

sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)[source]

Sum the forces/moments based on a list of nodes and elements.

Parameters:
  • eids – the list of elements to include (e.g. the loads due to a PLOAD4)
  • nids – the list of nodes to include (e.g. the loads due to a FORCE card)
  • p0

    the point to sum moments about type = int

    sum moments about the specified grid point
    type = (3, ) ndarray/list (e.g. [10., 20., 30]):
    the x, y, z location in the global frame
Nodal Types : FORCE, FORCE1, FORCE2,
MOMENT, MOMENT1, MOMENT2, PLOAD

Element Types: PLOAD1, PLOAD2, PLOAD4, GRAV

If you have a CQUAD4 (eid=3) with a PLOAD4 (eid=3) and a FORCE card (nid=5) acting on it, you can incldue the PLOAD4, but not the FORCE card by using:

For just pressure:

eids = [3]
nids = []

For just force:

eids = []
nids = [5]

or both:

eids = [3]
nids = [5]

Note

If you split the model into sections and sum the loads on each section, you may not get the same result as if you summed the loads on the total model. This is due to the fact that nodal loads on the boundary are double/triple/etc. counted depending on how many breaks you have.

Todo

not done...

unresolve_grids(model_old)[source]

Puts all nodes back to original coordinate system.

Parameters:
  • self – the object pointer
  • model_old – the old model that hasnt lost it’s connection to the node cids

Warning

hasnt been tested well...

pyNastran.bdf.bdf_Methods._mass_properties_mass_mp_func(element)[source]

helper method for mass properties multiprocessing

bdf_replacer Module

caseControlDeck Module

Inheritance diagram of pyNastran.bdf.caseControlDeck

CaseControlDeck parsing and extraction class

class pyNastran.bdf.caseControlDeck.CaseControlDeck(lines, log=None)[source]

Bases: object

CaseControlDeck parsing and extraction class

Parameters:
  • self – the CaseControlDeck object
  • lines – list of lines that represent the case control deck ending with BEGIN BULK
  • log – a :mod: logging object
_add_parameter_to_subcase(key, value, options, param_type, isubcase)[source]

Internal method

self: the CaseControlDeck object

_parse_data_from_user(param)[source]

Parses a case control line

Parameters:
  • self – the CaseControlDeck object
  • param – the variable to add
_parse_entry(lines)[source]

Internal method for parsing a card of the case control deck

Parses a single case control deck card into 4 sections

  1. paramName - obvious
  2. Value - still kind of obvious
  3. options - rarely used data
  4. paramType - STRESS-type, SUBCASE-type, PARAM-type, SET-type, BEGIN_BULK-type

It’s easier with examples:

paramType = SUBCASE-type
SUBCASE 1 -> paramName=SUBCASE value=1 options=[]
paramType = STRESS-type
STRESS = ALL -> paramName=STRESS value=ALL options=[] STRAIN(PLOT) = 5 -> paramName=STRAIN value=5 options=[PLOT] TITLE = stuff -> paramName=TITLE value=stuff options=[]
paramType = SET-type
SET 1 = 10,20,30 -> paramName=SET value=[10,20,30] options = 1
paramType = BEGIN_BULK-type
BEGIN BULK -> paramName=BEGIN value=BULK options = []
paramType = CSV-type
PARAM,FIXEDB,-1 -> paramName=PARAM value=FIXEDB options = [-1]

The paramType is the “macro” form of the data (similar to integer, float, string). The value is generally whats on the RHS of the equals sign (assuming it’s there). Options are modifiers on the data. Form things like the PARAM card or the SET card they arent as clear, but the paramType lets the program know how to format it when writing it out.

Parameters:
  • self – the CaseControlDeck object
  • lines – list of lines
Returns:

paramName see brief

Returns:

value see brief

Returns:

options see brief

Returns:

paramType see brief

_read(lines)[source]

Reads the case control deck

Note

supports comment lines

Warning

doesnt check for 72 character width lines, but will follow that when it’s written out

add_parameter_to_global_subcase(param)[source]

Takes in a single-lined string and adds it to the global Subcase.

Parameters:
  • self – the CaseControlDeck object
  • param – the variable to add

Note

dont worry about overbounding the line

>>> bdf = BDF()
>>> bdf.read_bdf(bdf_filename)
>>> bdf.case_control.add_parameter_to_global_subcase('DISP=ALL')
>>> print(bdf.case_control)
TITLE = DUMMY LINE
DISP = ALL
add_parameter_to_local_subcase(isubcase, param)[source]

Takes in a single-lined string and adds it to a single Subcase.

Parameters:
  • self – the CaseControlDeck object
  • isubcase – the subcase ID to add
  • param – the variable to add

Note

dont worry about overbounding the line

>>> bdf = BDF()
>>> bdf.read_bdf(bdf_filename)
>>> bdf.case_control.add_parameter_to_local_subcase(1, 'DISP=ALL')
>>> print(bdf.case_control)
TITLE = DUMMY LINE
SUBCASE 1
    DISP = ALL
>>>
begin_bulk = None

stores a single copy of ‘BEGIN BULK’ or ‘BEGIN SUPER’

convert_to_sol_200(model)[source]

Takes a case control deck and changes it from a SOL xxx to a SOL 200

Parameters:self – the CaseControlDeck object

Todo

not done...

copy_subcase(i_from_subcase, i_to_subcase, overwrite_subcase=True)[source]

Overwrites the parameters from one subcase to another.

Parameters:
  • self – the CaseControlDeck object
  • i_from_subcase – the Subcase to pull the data from
  • i_to_subcase – the Subcase to map the data to
  • overwrite_subcase – NULLs i_to_subcase before copying i_from_subcase
create_new_subcase(isubcase)[source]

Method create_new_subcase:

Parameters:isubcase (int) – the subcase ID

Warning

be careful you dont add data to the global subcase after running this...is this True???

cross_reference(model)[source]
delete_subcase(isubcase)[source]

Deletes a subcase.

Parameters:
  • self – the CaseControlDeck object
  • isubcase (int) – the Subcase to delete
finish_subcases()[source]

Removes any unwanted data in the subcase...specifically the SUBCASE data member. Otherwise it will print out after a key like stress.

Parameters:self – the CaseControlDeck object
get_local_subcase_list()[source]

Gets the list of subcases that aren’t the global subcase ID

Parameters:self – the CaseControlDeck object
get_op2_data()[source]

Gets the relevant op2 parameters required for a given subcase

Parameters:self – the CaseControlDeck object

Todo

not done...

get_subcase_list()[source]

Gets the list of subcases including the global subcase ID (0)

Parameters:self – the CaseControlDeck object
get_subcase_parameter(isubcase, param_name)[source]

Get the [value, options] of a subcase’s parameter. For example, for STRESS(PLOT,POST)=ALL, param_name=STRESS, value=ALL, options=[‘PLOT’, ‘POST’]

Parameters:
  • self – the CaseControlDeck object
  • isubcase – the subcase ID to check
  • param_name – the parameter name to get the [value, options] for
has_parameter(isubcase, param_name)[source]

Checks to see if a parameter (e.g. STRESS) is defined in a certain subcase ID.

Parameters:
  • self – the CaseControlDeck object
  • isubcase – the subcase ID to check
  • param_name – the parameter name to look for
has_subcase(isubcase)[source]

Checks to see if a subcase exists.

Parameters:
  • self – the CaseControlDeck object
  • isubcase (int) – the subcase ID
Returns val:

does_subcase_exist (type = bool)

update_solution(isubcase, sol)[source]

sol = STATICS, FLUTTER, MODAL, etc.

Parameters:
  • self – the CaseControlDeck object
  • isubcase – the subcase ID to update
  • sol – the solution type to change the solution to
>>> print(bdf.case_control)
SUBCASE 1
    DISP = ALL
>>> bdf.case_control.update_solution(1, 'FLUTTER')
>>> print(bdf.case_control)
SUBCASE 1
    ANALYSIS FLUTTER
    DISP = ALL
>>>
class pyNastran.bdf.caseControlDeck.CaseControlDeckDeprecated[source]

Bases: object

pyNastran.bdf.caseControlDeck._clean_lines(case_control, lines)[source]

Removes comment characters defined by a $.

Parameters:
  • case_control – the CaseControlDeck object
  • lines – the lines to clean.
pyNastran.bdf.caseControlDeck.verify_card(key, value, options, line)[source]
pyNastran.bdf.caseControlDeck.verify_card2(key, value, options, line)[source]

Make sure there are no obvious errors

deprecated Module

Inheritance diagram of pyNastran.bdf.deprecated

class pyNastran.bdf.deprecated.AeroDeprecated[source]

Bases: object

DisableGroundEffect()[source]
EnableGroundEffect()[source]
IsAntiSymmetricalXY()[source]
IsAntiSymmetricalXZ()[source]
IsSymmetricalXY()[source]
IsSymmetricalXZ()[source]
class pyNastran.bdf.deprecated.BDFMethodsDeprecated[source]

Bases: object

Mass()[source]

See also

mass

MassProperties()[source]

See also

mass_properties

mass(element_ids=None, sym_axis=None)[source]

Calculates mass in the global coordinate system

resolveGrids(cid=0)[source]

See also

resolve_grids

unresolveGrids(femOld)[source]

See also

unresolve_grids

class pyNastran.bdf.deprecated.BaseCardDeprecated[source]

Bases: object

Deprecated in:
  • version 0.7
Removed in:
  • version 0.8
printRawFields(size=8)[source]
rawFields()[source]
reprCard()[source]
reprFields()[source]
repr_card()[source]
class pyNastran.bdf.deprecated.CAERO1Deprecated[source]

Bases: object

Points()[source]
SetPoints(points)[source]
class pyNastran.bdf.deprecated.CAERO2Deprecated[source]

Bases: object

Points()[source]
SetPoints(points)[source]
class pyNastran.bdf.deprecated.CoordDeprecated[source]

Bases: object

T()[source]

Gets the 6 x 6 transformation

\[[\lambda] = [B_{ij}]\]
\[\begin{split}[T] = \left[ \begin{array}{cc} \lambda & 0 \\ 0 & \lambda \\ \end{array} \right]\end{split}\]
transformNodeToGlobal(p)[source]
transformToGlobal(p, debug=False)[source]

Transforms a node from the local frame to the global frame

Parameters:
  • p – the xyz point in the local frame
  • debug – debug flag (default=False; unused)
Retval p2:

the xyz point in the global frame

Retval matrix:

the transformation matrix

transformToLocal(p, beta, debug=False)[source]
transformVectorToGlobal(p)[source]
transform_to_local(p, beta, debug=False)[source]
class pyNastran.bdf.deprecated.DeprecatedCompositeShellProperty[source]

Bases: object

To be deprecated in:
  • Version 0.7
To be removed in:
  • Version 0.8
MassPerArea(iply='all', method='nplies')[source]
Nsm()[source]
Rho(iply)[source]
Theta(iply)[source]
Thickness(iply='all')[source]
isSymmetrical()[source]
nPlies()[source]
sout(iply)[source]
class pyNastran.bdf.deprecated.ElementDeprecated[source]

Bases: object

nodePositions(nodes=None)[source]
class pyNastran.bdf.deprecated.GetMethodsDeprecated[source]

Bases: object

Flfact(sid, msg)[source]

Deprecated since version will: be removed in version 0.8

_get_element_ids_with_pids(pids, mode='list')[source]
coordIDs()[source]

deprecated

elementIDs()[source]

deprecated

getElementIDsWithPID(pid)[source]

Gets all the element IDs with a specific property ID

Parameters:pid – property ID
Returns elementIDs:
 as a list

Deprecated since version will: be removed in version 0.8

The same functionality may be used by calling
>>> self.getElementIDsWithPIDs([pid], mode='list')
getElementIDsWithPIDs(pids, mode='list')[source]

deprecated

getMaterialIDToPropertyIDsMap()[source]

deprecated

getNodeIDToElementIDsMap()[source]

deprecated

getNodeIDsWithElement(eid)[source]

deprecated

getNodeIDsWithElements(eids, msg='')[source]

deprecated

getNodes()[source]

deprecated

getPropertyIDToElementIDsMap()[source]

deprecated

get_coord_ids()[source]
get_element_ids()[source]

deprecated

get_ncaeros()[source]
get_nelements()[source]

deprecated

get_nnodes()[source]

deprecated

get_node_ids()[source]

deprecated

get_property_ids()[source]

deprecated

materialIDs()[source]

deprecated

nCAeros()[source]

deprecated

nElements()[source]

deprecated

nNodes()[source]

deprecated

nodeIDs()[source]

deprecated

propertyIDs()[source]

deprecated

structuralMaterialIDs()[source]

deprecated

thermalMaterialIDs()[source]

deprecated

class pyNastran.bdf.deprecated.GridDeprecated[source]

Bases: object

Position(debug=False)[source]
PositionWRT(model, cid, debug=False)[source]
UpdatePosition(model, xyz, cid=0)[source]
class pyNastran.bdf.deprecated.PointDeprecated[source]

Bases: object

Position(debug=False)[source]
PositionWRT(model, cid, debug=False)[source]
UpdatePosition(model, xyz, cid=0)[source]
class pyNastran.bdf.deprecated.SPOINTsDeprecated[source]

Bases: object

nDOF()[source]
class pyNastran.bdf.deprecated.ShellElementDeprecated[source]

Bases: object

Rho()[source]

Returns the density

fieldWriter Module

Defines legacy import functions

pyNastran.bdf.fieldWriter.print_card(fields, size=8, is_double=False)[source]

Prints a card in 8-character of 16-character Nastran format.

Parameters:
  • fields – all the fields in the BDF card (no trailing Nones)
  • size – 8/16
  • is_double – True/False
Returns card:

string representation of the card

Note

be careful of using is_double on cards that aren’t GRID or COORDx

field_writer_8 Module

Defines functions for single precision 8 character field writing.

pyNastran.bdf.field_writer_8.is_same(value1, value2)[source]

Checks to see if 2 values are the same

Note

this method is used by almost every card when printing

pyNastran.bdf.field_writer_8.print_card_8(fields)[source]

Prints a nastran-style card with 8-character width fields.

Parameters:fields – all the fields in the BDF card (no trailing Nones)
Returns card:string representation of the card in small field format

Note

An internal field value of None or ‘’ will be treated as a blank field

Note

A small field format follows the 8-8-8-8-8-8-8-8 = 80 format where the first 8 is the card name or blank (continuation). The last 8-character field indicates an optional continuation, but because it’s a left-justified unneccessary field, print_card doesnt use it.

>>> fields = ['DUMMY', 1, 2, 3, None, 4, 5, 6, 7, 8.]
>>> print_card_8(fields)
DUMMY          1       2       3               4       5       6       7
DUMMY          1       2       3               4       5       6       7
              8.
pyNastran.bdf.field_writer_8.print_field(value)[source]

helper method for writing cards

pyNastran.bdf.field_writer_8.print_field_8(value)[source]

Prints a 8-character width field

Parameters:value – the value to print
Returns field:an 8-character string
pyNastran.bdf.field_writer_8.print_float_8(value)[source]

Prints a float in nastran 8-character width syntax using the highest precision possbile.

pyNastran.bdf.field_writer_8.print_int_card(fields)[source]

Prints a nastran-style card with 8-character width fields. All fields (other than the first field) must be integers. This is used to speed up SET cards.

Parameters:fields – The list of fields to write to a nastran card.

Warning

Blanks are not allowed! Floats and strings are not allowed.

fields = ['SET', 1, 2, 3, 4, 5, 6, ..., n]
pyNastran.bdf.field_writer_8.print_int_card_blocks(fields_blocks)[source]

Prints a nastran-style card with 8-character width fields. All fields other than the card name must be written in “block” format. This is used to speed up SET cards.

param fields_blocks:
 The fields written in “block” notation.
type msg:list or tuple
returns msg:the field blocks as a 8-character width Nastran card
type msg:str

Note

Blanks are allowed in the False block.

fields_blocks = [
    'SET1',
    [['a', 1.0, 3], False], # these are not all integers
    [[1, 2, 3], True],      # these are all integers
]
msg = print_int_card_blocks(fields_blocks)
print(msg)
>>> 'SET1           a      1.       3       1       2       3

pyNastran.bdf.field_writer_8.print_scientific_8(value)[source]

Prints a value in 8-character scientific notation. This is a sub-method and shouldnt typically be called

pyNastran.bdf.field_writer_8.set_blank_if_default(value, default)[source]

Used when setting the output data of a card to clear default values

Parameters:value – the field value the may be set to None (blank) if value=default, the default value for the field

Note

this method is used by almost every card when printing

pyNastran.bdf.field_writer_8.set_default_if_blank(value, default)[source]

Used when initializing a card and the default value isn’t set Used on PBARL

pyNastran.bdf.field_writer_8.set_string8_blank_if_default(value, default)[source]

helper method for writing BDFs

field_writer_16 Module

Defines functions for single precision 16 character field writing.

pyNastran.bdf.field_writer_16.print_card_16(fields, wipe_fields=True)[source]

Prints a nastran-style card with 16-character width fields.

Parameters:
  • fields – all the fields in the BDF card (no trailing Nones)
  • wipe_fields – some cards (e.g. PBEAM) have ending fields that need to be there, others cannot have them.

Note

An internal field value of None or ‘’ will be treated as a blank field

Note

A large field format follows the 8-16-16-16-16-8 = 80 format where the first 8 is the card name or blank (continuation). The last 8-character field indicates an optional continuation, but because it’s a left-justified unneccessary field, print_card doesnt use it.

>>> fields = ['DUMMY', 1, 2, 3, None, 4, 5, 6, 7, 8.]
>>> print_card_16(fields)
DUMMY*                 1               2               3
*                      4               5               6               7
*                     8.
*
pyNastran.bdf.field_writer_16.print_field_16(value)[source]

Prints a 16-character width field

Parameters:value – the value to print
Returns field:an 16-character string
pyNastran.bdf.field_writer_16.print_float_16(value)[source]

Prints a float in nastran 16-character width syntax using the highest precision possbile. .. seealso:: print_float_8

pyNastran.bdf.field_writer_16.print_scientific_16(value)[source]

Prints a value in 16-character scientific notation. This is a sub-method and shouldnt typically be called

See also

print_float_16 for a better method

pyNastran.bdf.field_writer_16.set_string16_blank_if_default(value, default)[source]

helper method for writing BDFs

field_writer_double Module

Defines functions for double precision 16 character field writing.

pyNastran.bdf.field_writer_double.print_card_double(fields, wipe_fields=True)[source]

Prints a nastran-style card with 16-character width fields.

Parameters:
  • fields – all the fields in the BDF card (no trailing Nones)
  • wipe_fields – some cards (e.g. PBEAM) have ending fields that need to be there, others cannot have them.

Note

An internal field value of None or ‘’ will be treated as a blank field

Note

A large field format follows the 8-16-16-16-16-8 = 80 format where the first 8 is the card name or blank (continuation). The last 8-character field indicates an optional continuation, but because it’s a left-justified unneccessary field, print_card doesnt use it.

>>> fields = ['DUMMY', 1, 2, 3, None, 4, 5, 6, 7, 8.]
>>> print_card_double(fields)
DUMMY*                 1               2               3
*                      4               5               6               7
*       8.0000000000D+00
*
pyNastran.bdf.field_writer_double.print_field_double(value)[source]

Prints a 16-character width field

Parameters:value – the value to print
Returns field:an 16-character string
pyNastran.bdf.field_writer_double.print_scientific_double(value)[source]

Prints a value in 16-character scientific double precision.

Scientific Notation: 5.0E+1 Double Precision Scientific Notation: 5.0D+1

subcase Module

Inheritance diagram of pyNastran.bdf.subcase

Subcase creation/extraction class

class pyNastran.bdf.subcase.Subcase(id=0)[source]

Bases: object

Subcase creation/extraction class

_add_data(key, value, options, param_type)[source]
_simplify_data(key, value, options, param_type)[source]
cross_reference(model)[source]

Method crossReference:

Parameters:
  • self – the Subcase object
  • model – the BDF object

Note

this is not integrated and probably never will be as it’s not really that necessary. it’s only really useful when running an analysis.

finish_subcase()[source]

Removes the subcase parameter from the subcase to avoid printing it in a funny spot

Parameters:self – the Subcase object
get_analysis_code(sol)[source]
  • 8 - post-buckling (maybe 7 depending on NLPARM???)
# not important
  • 3/4 - differential stiffness (obsolete)
  • 11 - old geometric nonlinear statics
  • 12 - contran (???)

Todo

verify

get_device_code(options, value)[source]

Gets the device code of a given set of options and value

Parameters:
  • self – the Subcase object
  • options – the options for a parameter
  • value – the value of the parameter
get_format_code(options, value)[source]

Gets the format code that will be used by the op2 based on the options.

Parameters:
  • self – the Subcase object
  • options – the options for a parameter
  • value – the value of the parameter

Todo

not done...only supports REAL, IMAG, PHASE, not RANDOM

get_op2_data(sol, solmap_toValue)[source]
get_parameter(param_name)[source]

Gets the [value, options] for a subcase.

Parameters:
  • self – the Subcase object
  • param_name – the case control parameter to check for
get_sort_code(options, value)[source]

Gets the sort code of a given set of options and value

Parameters:
  • self – the Subcase object
  • options – the options for a parameter
  • value – the value of the parameter
get_stress_code(key, options, value)[source]

Method get_stress_code:

Note

the individual element must take the stress_code and reduce

it to what the element can return. For example, for an isotropic CQUAD4 the fiber field doesnt mean anything.

BAR - no von mises/fiber ISOTROPIC - no fiber

Todo

how does the MATERIAL bit get turned on? I’m assuming it’s element dependent...

get_table_code(sol, table_name, options)[source]

Gets the table code of a given parameter. For example, the DISPLACMENT(PLOT,POST)=ALL makes an OUGV1 table and stores the displacement. This has an OP2 table code of 1, unless you’re running a modal solution, in which case it makes an OUGV1 table of eigenvectors and has a table code of 7.

Parameters:
  • self – the Subcase object
  • options – the options for a parameter
  • value – the value of the parameter
has_parameter(param_name)[source]

Checks to see if a parameter name is in the subcase.

Parameters:
  • self – the Subcase object
  • param_name – the case control parameter to check for
print_param(key, param)[source]

Prints a single entry of the a subcase from the global or local subcase list.

Parameters:self – the Subcase object
solCodeMap = {64: 106, 1: 101, 66: 106, 68: 106, 76: 101, 144: 101, 21: 101, 24: 101, 26: 101, 99: 129, 187: 101, 61: 101}
subcase_sorted(lst)[source]

Does a “smart” sort on the keys such that SET cards increment in numerical order. Also puts the sets first.

Parameters:
  • self – the Subcase object
  • lst – the list of subcase list objects
Returns listB:

the sorted version of listA

write_subcase(subcase0)[source]

Internal method to print a subcase

Parameters:
  • self – the Subcase object
  • subcase0 – the global Subcase object
pyNastran.bdf.subcase.update_param_name(param_name)[source]

Takes an abbreviated name and expands it so the user can type DISP or DISPLACEMENT and get the same answer

Parameters:param_name – the parameter name to be standardized (e.g. DISP vs. DIPLACEMENT)

Todo

not a complete list

utils Module

Inheritance diagram of pyNastran.bdf.utils

exception pyNastran.bdf.utils.CardParseSyntaxError[source]

Bases: exceptions.SyntaxError

pyNastran.bdf.utils.Position(xyz, cid, model, is_cid_int=True)[source]

Gets the point in the global XYZ coordinate system.

Parameters:
  • xyz (TYPE = NDARRAY. SIZE=(3,)) – the position of the GRID in an arbitrary coordinate system
  • cid (int) – the coordinate ID for xyz
  • model (BDF()) – the BDF model object
Returns xyz2:

the position of the GRID in an arbitrary coordinate system

pyNastran.bdf.utils.PositionWRT(xyz, cid, cid_new, model, is_cid_int=True)[source]

Gets the location of the GRID which started in some arbitrary system and returns it in the desired coordinate system

Parameters:
  • xyz (TYPE = NDARRAY. SIZE=(3,)) – the position of the GRID in an arbitrary coordinate system
  • cid (int) – the coordinate ID for xyz
  • cid_new (int) – the desired coordinate ID
  • model (BDF()) – the BDF model object
Returns xyz_local:
 

the position of the GRID in an arbitrary coordinate system

pyNastran.bdf.utils.TransformLoadWRT(F, M, cid, cid_new, model, is_cid_int=True)[source]

Transforms a force/moment from an arbitrary coordinate system to another coordinate system.

Parameters:
  • Fxyz (TYPE = NDARRAY. SIZE=(3,)) – the force in an arbitrary coordinate system
  • Mxyz (TYPE = NDARRAY. SIZE=(3,)) – the moment in an arbitrary coordinate system
  • cid (int) – the coordinate ID for xyz
  • cid_new (int) – the desired coordinate ID
  • model (BDF()) – the BDF model object
  • is_cid_int (bool) – is cid/cid_new an integer or a Coord object
Returns Fxyz_local:
 

the force in an arbitrary coordinate system

Returns Mxyz_local:
 

the force in an arbitrary coordinate system

pyNastran.bdf.utils._clean_comment(comment, end=-1)[source]

Removes specific pyNastran comment lines so duplicate lines aren’t created.

Parameters:comment – the comment to possibly remove
pyNastran.bdf.utils.clean_empty_lines(lines)[source]

Removes leading and trailing empty lines don’t remove internally blank lines

pyNastran.bdf.utils.get_include_filename(card_lines, include_dir='')[source]

Parses an INCLUDE file split into multiple lines (as a list).

Parameters:
  • card_lines – the list of lines in the include card (all the lines!)
  • include_dir – the include directory (default=’‘)
Returns filename:
 

the INCLUDE filename

pyNastran.bdf.utils.parse_executive_control_deck(executive_control_lines)[source]

Extracts the solution from the executive control deck

pyNastran.bdf.utils.parse_patran_syntax(node_sets)[source]

Parses Patran’s syntax for compressing nodes/elements

Parameters:node_sets – the node_set to parse
Returns nodes:list of integers

Patran has a short syntax of the form:

String Output
“1 2 3” [1, 2, 3]
“5:10” [5, 6, 7, 8, 9, 10]
“12:20:2” [12, 14, 16, 18, 20]
>>> node_sets = "1 2 3 5:10 12:20:2"
>>> data = parse_patran_syntax(node_sets)
>>> data
data = [1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20]

Warning

Don’t include the n/node or e/element or any other identifier, just a string of “1 2 3 5:10 12:20:2”. Use parse_patran_syntax_dict to consider the identifier.

Note

doesn’t support “1:#”

pyNastran.bdf.utils.parse_patran_syntax_dict(node_sets)[source]

Parses Patran’s syntax for compressing nodes/elements

Parameters:node_sets – the node_set to parse
Returns nodes:list of integers
node_sets = "e 1:3 n 2:6:2 Node 10:13"
data = parse_patran_syntax_dict(node_sets)
data = {
    'e'    : [1, 2, 3],
    'n'    : [2, 4, 6],
    'Node' : [10, 11, 12, 13],
}

Note

the identifier (e.g. “e”) must be used. Use parse_patran_syntax to skip the identifier.

Note

doesn’t support “1:#”

pyNastran.bdf.utils.print_filename(filename, relpath)[source]

Takes a path such as C:/work/fem.bdf and locates the file using relative paths. If it’s on another drive, the path is not modified.

Parameters:filename – a filename string
Returns filename_string:
 a shortened representation of the filename
pyNastran.bdf.utils.to_fields(card_lines, card_name)[source]

Converts a series of lines in a card into string versions of the field. Handles large, small, and CSV formatted cards.

Parameters:
  • lines – the lines of the BDF card object
  • card_name – the card_name -> ‘GRID’
Returns fields:

the string formatted fields of the card

Warning

this function is used by the reader and isn’t intended to be called by a separate process

>>> card_lines = []'GRID,1,,1.0,2.0,3.0']
>>> card_name = 'GRID'
>>> fields = to_fields(lines, card_name)
>>> fields
['GRID', '1', '', '1.0', '2.0', '3.0']

write_path Module

pyNastran.bdf.write_path.main()[source]
pyNastran.bdf.write_path.split_path(abspath)[source]

Takes a path and splits it into the various components

pyNastran.bdf.write_path.write_include(filename, is_windows=True)[source]

Writes a bdf INCLUDE file line given an imported filename.

Parameters:
  • filename – the filename to write
  • is_windows – Windows has a special format for writing INCLUDE files so the format for a BDF that will run on Linux and Windows is different. We could check the platform, but since you might need to change platforms, it’s an option (default=True)

For a model that will run on Linux:

..code-blocK:: python

fname = r’/opt/NASA/test1/test2/test3/test4/formats/pynastran_v0.6/pyNastran/bdf/model.inc’ write_include(fname, is_windows=False)

..code-blocK:: python

INCLUDE /opt/NASA/test1/test2/test3/test4/formats/pynastran_v0.6/
pyNastran/bdf/model.inc