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 Defintion 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_id : int

the id of the equation

eqs : List[str]

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

comment : str; 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(self)[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, comment='')[source]

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

Parameters:
card : List[str]

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

comment : str; default=’‘

a comment for the card

cross_reference(self, model)[source]

Cross links the card so referenced cards can be extracted directly

Parameters:
model : BDF()

the BDF object

evaluate(self, *args)[source]

Makes a call to self.func

raw_fields(self)[source]
repr_fields(self)[source]

Gets the fields in their simplified form

Returns:
fields : List[varies]

the fields that define the card

type = 'DEQATN'
uncross_reference(self)[source]

Removes cross-reference links

write_card(self, size=8, is_double=False)[source]

Writes the card with the specified width and precision

Parameters:
size : int (default=8)

size of the field; {8, 16}

is_double : bool (default=False)

is this card double precision

Returns:
msg : str

the string representation of the card

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

gets the factors for dba, invdba

pyNastran.bdf.cards.deqatn._join_wrapped_equation_lines(unused_eqs_temp_in, eqs_temp)[source]

helper for lines_to_eqs

pyNastran.bdf.cards.deqatn._split_equation(lines_out, line, n, isplit=0)[source]

Takes an overbounded DEQATN line and shortens it using recursion

Parameters:
lines_out : List[str]

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

line : str

the line to split

n : int

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

isplit : int; default=0

the number of levels deep in the recursive function we are

Returns:
lines_out : List[str]

the long line broken into shorter lines

pyNastran.bdf.cards.deqatn._split_equations_by_semicolon(eqs_in)[source]

helper for lines_to_eqs

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

writes the deqatn to the comment block

pyNastran.bdf.cards.deqatn._write_function_line(func_name, variables, default_values)[source]

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

pyNastran.bdf.cards.deqatn._write_variables(variables)[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, pref, f)[source]

sound pressure in decibels (perceived)

Parameters:
p : float

structural responses or acoustic pressure

f : float

forcing frequency

pref : float

reference pressure

Returns:
dbi : float

acoustic pressure in Decibels

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

positive difference

pyNastran.bdf.cards.deqatn.fortran_to_python(lines, default_values, comment='')[source]

Creates the python function

Parameters:
lines : List[str]

the equations to write broken up by statement

default_values : dict[name] = value

the default values from the DTABLE card

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:

print(locals()) raise

f = x + y return f

pyNastran.bdf.cards.deqatn.fortran_to_python_short(line, unused_default_values)[source]

the function used by the DRESP2

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

inverse Db

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

Inverse Dba

Parameters:
dbai : float

acoustic pressure in Decibels (perceived)

f : float

forcing frequency

pref : float

reference pressure

Returns:
p : float

structural responses or acoustic pressure

pyNastran.bdf.cards.deqatn.lines_to_eqs(eqs_in)[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)[source]

takes an overbounded DEQATN card and shortens it

pyNastran.bdf.cards.deqatn.split_to_equations(lines)[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, eq, default_values, comment='')[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:
print(locals()) raise
Parameters:
f : str

the function header f(a, b, c)

eq : str

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

default_values : dict[name] = value

the default values from the DTABLE card

Returns:
func_name : str

the name of the function f

msg : str

see above

variables : List[str]

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