deqatn Module

Inheritance diagram of pyNastran.bdf.cards.deqatn

Defines the DEQATN class and sub-functions.

The capitalization of the sub-functions is important.

class pyNastran.bdf.cards.deqatn.DEQATN(equation_id, eqs, comment='')[source]

Bases: pyNastran.bdf.cards.base_card.BaseCard

Design Equation Definition Defines one or more equations for use in design sensitivity analysis.

1

2

3

4

5

6

7

8

DEQATN

EQID

EQUATION

EQUATION (cont.)

Creates a DEQATN card

Parameters
equation_idint

the id of the equation

eqsList[str]

the equations, which may overbound the field split them by a semicolon (;)

commentstr; default=’’

a comment for the card

DEQATN 41 F1(A,B,C,D,R) = A+B *C–(D**3 + 10.0) + sin(PI(1) * R)
  • A**2 / (B - C); F = A + B - F1 * D

def F1(A, B, C, D, R):

F1 = A+B *C-(D**3 + 10.0) + sin(PI(1) * R) + A**2 / (B – C) F = A + B - F1 * D return F

eqs = [

‘F1(A,B,C,D,R) = A+B *C–(D**3 + 10.0) + sin(PI(1) * R) + A**2 / (B – C)’, ‘F = A + B – F1 * D’,

]
>>> deqatn = DEQATN(41, eq, comment=’’)
classmethod _init_from_empty()[source]
_properties = ['dtable']
_setup_equation() → None[source]

creates an executable equation object from self.eqs

x = 10. >>> deqatn.func(x) 42.0

>>> deqatn.func_str
def stress(x):
    x = float(x)
    return x + 32.
classmethod add_card(card: List[str], comment: str = '')[source]

Adds a DEQATN card from BDF.add_card(...)

Parameters
cardList[str]

this card is special and is not a BDFCard like other cards

commentstr; default=’’

a comment for the card

cross_reference(model: BDF) → None[source]

Cross links the card so referenced cards can be extracted directly

Parameters
modelBDF()

the BDF object

evaluate(*args) → float[source]

Makes a call to self.func

raw_fields() → List[str][source]
repr_fields() → List[str][source]

Gets the fields in their simplified form

Returns
fieldsList[varies]

the fields that define the card

safe_cross_reference(model: BDF) → None[source]
type = 'DEQATN'
uncross_reference() → None[source]

Removes cross-reference links

write_card(size: int = 8, is_double: bool = False) → str[source]

Writes the card with the specified width and precision

Parameters
sizeint (default=8)

size of the field; {8, 16}

is_doublebool (default=False)

is this card double precision

Returns
msgstr

the string representation of the card

pyNastran.bdf.cards.deqatn._get_ta(f: float) → float[source]

gets the factors for dba, invdba

pyNastran.bdf.cards.deqatn._join_wrapped_equation_lines(unused_eqs_temp_in, eqs_temp: List[str]) → List[str][source]

helper for lines_to_eqs

pyNastran.bdf.cards.deqatn._split_equation(lines_out: List[str], line: str, n: int, isplit: int = 0) → List[str][source]

Takes an overbounded DEQATN line and shortens it using recursion

Parameters
lines_outList[str]

len(lines) = 0 : first iteration len(lines) = 1 : second iteration

linestr

the line to split

nint

the maximum number of characters allowed the first line of the DEQATN has a different number of fields allowed vs. subsequent lines

isplitint; default=0

the number of levels deep in the recursive function we are

Returns
lines_outList[str]

the long line broken into shorter lines

pyNastran.bdf.cards.deqatn._split_equations_by_semicolon(eqs_in: List[str]) → List[str][source]

helper for lines_to_eqs

pyNastran.bdf.cards.deqatn._write_comment(comment: str) → str[source]

writes the deqatn to the comment block

pyNastran.bdf.cards.deqatn._write_function_line(func_name: str, variables: List[str], default_values: Dict[str, float]) → str[source]

writes the def f(x, y, z=1.): part of the function

pyNastran.bdf.cards.deqatn._write_variables(variables: List[str]) → str[source]

type checks the inputs

pyNastran.bdf.cards.deqatn.atan2h(x, y)[source]

Hyperbolic arctangent >>> arctanh(z) = 1/2 Log((1+z)/(1-z))

real:

the following must be true: |x1| > |x2| and x2 ≠ 0.

complex:

x1 = a + bi x2 = b + di a = b = 0 and (sign of c) = (sign of d):

the result is 0.

a = b = 0 and (sign of c) ≠ (sign of d):

the result is π.

c = d = 0 and (sign of a) = (sign of b):

the result is π/2.

c = d = 0 and (sign of a) ≠ (sign of b):

the result is −π/2

pyNastran.bdf.cards.deqatn.avg(*args)[source]

average

pyNastran.bdf.cards.deqatn.db(p, pref)[source]

sound pressure in decibels

pyNastran.bdf.cards.deqatn.dba(p: float, pref: float, f: float) → float[source]

sound pressure in decibels (perceived)

Parameters
pfloat

structural responses or acoustic pressure

ffloat

forcing frequency

preffloat

reference pressure

Returns
dbifloat

acoustic pressure in Decibels

pyNastran.bdf.cards.deqatn.dim(x, y)[source]

positive difference

pyNastran.bdf.cards.deqatn.fortran_to_python(deqatn_id: int, lines: List[str], default_values: Dict[str, Union[float, numpy.ndarray]], comment: str = '') → Tuple[str, int, str][source]

Creates the python function

Parameters
linesList[str]

the equations to write broken up by statement

default_valuesdict[name] = value

the default values from the DTABLE card

Returns
func_namestr

the name of the function

nargsint

the number of variables to the function

func_msgstr

the python function

def f(x, y=10.):

‘’’ $ deqatn DEQATN 1000 f(x,y) = x+y ‘’’ try:

if isinstance(x, (int, float, str)):

x = float(x)

if isinstance(y, (int, float, str)):

y = float(y)

except Exception:

print(locals()) raise

f = x + y return f

pyNastran.bdf.cards.deqatn.fortran_to_python_short(line: str, unused_default_values: Any) → Any[source]

the function used by the DRESP2

pyNastran.bdf.cards.deqatn.invdb(dbi: float, pref: float) → float[source]

inverse Db

pyNastran.bdf.cards.deqatn.invdba(dbai: float, pref: float, f: float) → float[source]

Inverse Dba

Parameters
dbaifloat

acoustic pressure in Decibels (perceived)

ffloat

forcing frequency

preffloat

reference pressure

Returns
pfloat

structural responses or acoustic pressure

pyNastran.bdf.cards.deqatn.lines_to_eqs(eqs_in: List[str]) → List[str][source]

splits the equations

pyNastran.bdf.cards.deqatn.logx(x, y)[source]

log base_x(y)

pyNastran.bdf.cards.deqatn.pi(num)[source]

weird way to multiply π by a number

pyNastran.bdf.cards.deqatn.rss(*args)[source]

2-norm; generalized magnitude of vector for N components

pyNastran.bdf.cards.deqatn.split_equations(lines: List[str]) → List[str][source]

takes an overbounded DEQATN card and shortens it

pyNastran.bdf.cards.deqatn.split_to_equations(lines: List[str]) → List[str][source]

Splits a line like:

b = a + z; c = 42

into:

b = a + z
c = 42
pyNastran.bdf.cards.deqatn.ssq(*args)[source]

sum of squares

pyNastran.bdf.cards.deqatn.write_function_header(func_header: str, eq: str, default_values: Dict[str, float], comment: str = '') → Tuple[str, str, List[str]][source]

initializes the python function

def f(x, y=10.):

‘’’ $ deqatn DEQATN 1000 f(x,y) = x+y ‘’’ try:

if isinstance(x, (int, float, str)):

x = float(x)

if isinstance(y, (int, float, str)):

y = float(y)

except Exception:

print(locals()) raise

Parameters
fstr

the function header f(a, b, c)

eqstr

the value on the other side of the equals sign (f=eq) 1. max(a, b, c)

default_valuesdict[name] = value

the default values from the DTABLE card

Returns
func_namestr

the name of the function f

msgstr

see above

variablesList[str]

the variables used by the equation header a, b, c