Genesis (structmanager.genesis
)¶
This module contains useful functions for exporting optimization models to GENESIS.
-
class
structmanager.genesis.genesis.
Genesis
[source]¶ GENESIS optimization model
This class corresponds to an optimization model.
Attribute Description dvprops
dict
ofDVPROP3
objectsdeqatns
dict
ofDEQATN
objectsdtables
dict
ofDTABLE
dresps
dict
ofDRESP1
orDRESP23
objectsdcons
dict
ofDCONS
objectsdvars
dict
ofDVAR
objectsdvar_codes
dict
classifying theDVAR
objects by- their unique codes
dlinks
dict
ofDLINK
objectsnewprops
dict
with different NASTRAN cards, seereset_newprops()
nodal_displ
dict
with the nodal displacements constraints as- detailed in
nodal_displ_from_excel()
loads_list
list
containing the load cases’ idsspcs_list
list
containing the single point constraint id- for each load case
num_cycles
int
indicating the number of design cyclesoutputdir
str
path to the output directorygenesisfile
file
handler to GENESIS’s output filenastranfile
file
handler to NASTRAN’s output fileMethods
add_dvprop
(*args)constrain_pbar
(pid, name, rtype, eltype, ...)Add constraints to all stress recovery points of a bar property. constrain_pshell
(pid, cname, rtype, allow_C, ...)Add constraints to the bottom and top faces of a shell property. constrain_two_vars
(var1, var2, maxdiff)Constraint two vars in order to keep a maximum relative difference create_dobj
()Create the design objective. create_dvars
()Create the design variables. create_topometric_data
()dlinks_from_excel
(xls_file)Read links between variables from an Excel file. merge_temp_files
()Merge the temporary file handlers into the final input file. nodal_displ_from_excel
(xls_file)Create nodal displacement constraints based on an Excel file. pickle_dump
(path)pickle_load
(path)print_model
()Print the whole model. reset_newprops
()Reset the dictionary newprops
.set_output_file
(path)Define the data related to the output file. simx_create_output_file
()simx_export_nastran_file
()-
constrain_pbar
(pid, name, rtype, eltype, allow_C, allow_T)[source]¶ Add constraints to all stress recovery points of a bar property.
Parameters: pid : int
Property id.
name : str or list
The name of the constraint, as described in
output_codes
, with only the prefix ('Shear'
,'Normal'
, etc).rtype : str
The type of response. For bar elements it is usually
'STRESS'
.eltype : str
The section type:
'RECT'
,'CIRCLE'
, etc.allow_C : float
The allowable for compression.
allow_T : float
The allowable for tension.
-
constrain_pshell
(pid, cname, rtype, allow_C, allow_T)[source]¶ Add constraints to the bottom and top faces of a shell property.
Parameters: pid : int
Property id.
cname : str or list
The name of the constraint, as described in
output_codes
, without the sufix'Bottom'
or'Top'
.rtype : str
The type of response. For shells it is usually
'STRESS'
.allow_C : float
The allowable for compression.
allow_T : float
The allowable for tension.
-
constrain_two_vars
(var1, var2, maxdiff)[source]¶ Constraint two vars in order to keep a maximum relative difference
Parameters: var1, var2 : int or str
The variables id (int) or code (str).
maxdiff : float
The maximum relative difference that ‘var1’ and ‘var2’ must respect.
-
create_dvars
()[source]¶ Create the design variables.
The method
DVPROP3.create_dvar()
of each property contained in the dictionarydvprops
is called.
-
dlinks_from_excel
(xls_file)[source]¶ Read links between variables from an Excel file.
The Excel file should have the following format:
. col j col j+1 col j+2 col j+3 col j+4 col j+5 col j+6 col j+7 row i DLINK row i+1 row i+2 dvar c0 c ivar1 c1 ivar2 c2 ... row i+3 LP.1.1 LS.1.1 0.4 LS.1.2 0.6 ... where the relative position between the cell with
DLINK
and the others must be held.Parameters: xls_file : str
The full path of the Excel file.
-
merge_temp_files
()[source]¶ Merge the temporary file handlers into the final input file.
The file handlers contained in the attributes
genesisfile
andnastranfile
are used to write a unique output file given by the attributedatname
.
-
nodal_displ_from_excel
(xls_file)[source]¶ Create nodal displacement constraints based on an Excel file.
This function reads the xls file with nodal displacement constraints and returns a dictionary with the format:
nd = {load_case_id1 : {grid_1 : {output : [minvalue, maxvalue], grid_2 : output : [minvalue, maxvalue], grid_3 : output : [minvalue, maxvalue]}} load_case_id2 : {grid_1 : {output : [minvalue, maxvalue], grid_3 : outout : [minvalue, maxvalue]}}}
where
minvalue
andmaxvalue
are the minimum and maximum displacement values.Parameters: xls_file : str
The full path to the Excel file.
Returns: output : str
A string with one of the values:
'Translation X'
'Translation Y'
'Translation Z'
'Rotation X'
'Rotation Y'
'Rotation Z'
'Translation Total'
'Absolute X'
'Absolute Y'
'Absolute Z'
-
reset_newprops
()[source]¶ Reset the dictionary
newprops
.This dictionary contains NASTRAN property cards that should be created along with the optimization model.
The supported cards are those corresponding to the classes defined in
cards_solver
.
Optimization cards (structmanager.genesis.cards_opt
)¶
Many input cards related to the optimization problem are wrapped in this
module. The input cards more related to the solver are contained in module
structmanager.genesis.cards_solver
.
Classes
structmanager.genesis.cards_opt.DCONS (...) |
Design constraint |
structmanager.genesis.cards_opt.DEQATN (eq) |
Equation to calculate customized responses |
structmanager.genesis.cards_opt.DLINK (...[, ...]) |
Link between design variables |
structmanager.genesis.cards_opt.DOBJ (drespid) |
Design objective |
structmanager.genesis.cards_opt.DRESP1 (...) |
Design response DRESP1 |
structmanager.genesis.cards_opt.DRESP2 (...) |
Design response DRESP2 |
structmanager.genesis.cards_opt.DRESP3 (...) |
Design response DRESP3 |
structmanager.genesis.cards_opt.DSPLIT (...) |
Defines a region for topometry optimization. |
structmanager.genesis.cards_opt.DTABLE ([...]) |
Design Table used to define many constants |
structmanager.genesis.cards_opt.DVAR (label, ...) |
Design Variable |
structmanager.genesis.cards_opt.DVPROP3 (...) |
Design Variable-to-Property relation |
-
class
structmanager.genesis.cards_opt.
DCONS
(drespid, lid_lb_ub, stress_type)[source]¶ Design constraint
Attributes
Methods
print_card
-
class
structmanager.genesis.cards_opt.
DEQATN
(eq)[source]¶ Equation to calculate customized responses
Parameters: eq : str
A string containing the equation. For example, the following equation:
\[T(x_1, x_2, x_3) = \sqrt{x_1^2 + x_2^2 + x_3^2}\]can be written as:
eq = 'T(x1,x2,x3)=SQRT(x1**2+x2**2+x3**2)'
Notes
Note
The
DEQATN.print_card()
method will split the equation, when necessary, in order to keep the limit length up to 62 characters in the first line, and 70 characters for the subsequent lines.Methods
print_card
-
class
structmanager.genesis.cards_opt.
DLINK
(dep_var, dvi_ci, c0=0.0, cmult=1.0)[source]¶ Link between design variables
DLINK creates links among variables using the form:
\[dvar_{dependent} = c_0 + c_{mult} \times (c_1 \times {dvar}_1 + c_2 \times {dvar}_2)\]where:
dvar_{dependent}
is the dependent variable{dvar}_i
thei^{th}
design variablec_0
is a constantc_{mult}
is a common multiplierc_i
is an individual multiplier for{dvar}_i
Parameters: ddvid : int
Dependent design variable identification number.
c0 : float
Constant term.
cmult : float
Constant multiplier.
idvs : list
The independent variables.
cs : list
The multipliers for each variable.
Notes
Be sure that no dependent variables are being used as independent variables.
By default
c0 = 0
andcmult = 1
.The values of
dvi
andci
are inputed as follows:indep_dv_c = [dv1, c1, dv2, c2, ...] indep_dv_c = [1000000, 1., 1000001, 1., ...]
Methods
print_card
-
class
structmanager.genesis.cards_opt.
DOBJ
(drespid)[source]¶ Design objective
Methods
defaults
print_card
-
class
structmanager.genesis.cards_opt.
DRESP1
(label, rtype, ptype, region, atta, atti)[source]¶ Design response DRESP1
Parameters: label : str
User defined label.
rtype : str
Response type (‘DISP’, ‘STRESS’, ‘FREQ’ etc).
ptype : str
If
ptype='ELEM'
the ATTi are element IDs, ifptype='PSHELL'
etc the ATTi are property IDs (see design manual for more info).region : int
Region identifier for constraint screening.
atta : int
Displacement component number, item number or eigenvector component.
atti : list
Grid, spoint, field point, property, element or material ids.
Methods
print_card
-
class
structmanager.genesis.cards_opt.
DRESP2
(label, eqid, region=None)[source]¶ Design response DRESP2
Define equation responses that are used in the design, either as an objective function or as constraints.
Parameters: label : str
User-defined label.
eqid : int
DEQATN
entry identification number.region : int or None, optional
Region used for constraint screening.
Notes
To add variables, table entries or other
DRESP1
responses use the methods:add_dvar()
,add_dtable()
andadd_dresp1()
.Methods
add_dresp1
add_dtable
add_dvar
print_aux
print_card
-
class
structmanager.genesis.cards_opt.
DRESP23
[source]¶ Base class for DRESP2 and DRESP3
Methods
add_dresp1
add_dtable
add_dvar
print_aux
-
class
structmanager.genesis.cards_opt.
DRESP3
(label, libid, region=None)[source]¶ Design response DRESP3
Define use-subroutine or built-in responses that can be used in the design either as constraint or as an objective.
Parameters: label : str
User-defined label.
libid : int
Library identification number or a built-in function name (see design manual).
region : int or None, optional
Region used for constraint screening.
Notes
To add variables, table entries or other
DRESP1
responses use the methods:add_dvar()
,add_dtable()
andadd_dresp1()
.Methods
add_dresp1
add_dtable
add_dvar
print_aux
print_card
-
class
structmanager.genesis.cards_opt.
DSPLIT
(label, ptype, pid, cvalue, cid, manufact_cons_input)[source]¶ Defines a region for topometry optimization.
Parameters: label : str
User defined name for output purposes.
ptype : str
Designable region type (‘PROD’, ‘PBAR’, ‘PSHELL’ etc).
pid : int
Property identification number.
cvalue : int
Desired maximum number of elements per group.
cid : int
Coordinate system identification number.
manufact_cons_input : list
A list of strings defining the type1, type2 and type3 of fabrication constraints.
Methods
defaults
manufact_cons
print_card
-
class
structmanager.genesis.cards_opt.
DTABLE
(input_dict={})[source]¶ Design Table used to define many constants
Hints:
- There can be any number of DTABLE entries in the bulk data.
- The user must avoid repeated labels for constants
- The constant label must be <= 8 characters.
All values for the constants must be of the ‘Real’ type. Ex:
input_dict={'c1':1. , 'c2':2., 'max8char':999.}
Methods
print_card
-
class
structmanager.genesis.cards_opt.
DVAR
(label, init, lb, ub, dvsid, dvprop=None, code=None)[source]¶ Design Variable
Parameters: label : str
User-supplied name for printing purposes.
init : float
Initial value.
lb : float
Lower bound.
ub : float
Upper bound.
dvprop :
DVPROP3
or None, optionalThe corresponding design variable-to-property relation.
code : str or None, optional
An additional code to identify the design varible.
Methods
defaults
print_card
show_card
-
class
structmanager.genesis.cards_opt.
DVPROP3
(sizing_data, pid, ptype, eltype, dvar_labels=None, dvar_codes=None)[source]¶ Design Variable-to-Property relation
This is a wrapper for the DVPROP3 card in Genesis.
Parameters: sizing_data : TODO
The sizing data for this entry.
id : :
Methods
create_dvars
defaults
print_card
Optimization cards (feopt.genesis.cards_solver
)¶
Many input cards related to the finite element solver are wrapped in this module.
-
class
structmanager.genesis.cards_solver.
PBARL
(id, mid, library, type, d_list, nsm=0.0)[source]¶ Pre-defined sections for bar elements
Attribute Description id
int
- property idmid
int
- material idlibrary
str
- the default library used to calculate the section properties ('CSLIB1'
, etc)d_list
list
- design variablestype
str
- section type ('RECT'
, etc)nsm
float
- non-structural mass in [mass unit]/[metric unit]Methods
add_dvprop
constrain_pbar
constrain_pshell
constrain_two_vars
create_dobj
create_dvars
create_topometric_data
dlinks_from_excel
merge_temp_files
nodal_displ_from_excel
pickle_dump
pickle_load
print_card
print_model
reset_newprops
set_output_file
simx_create_output_file
simx_export_nastran_file
Sizing data (feopt.genesis.sizing_data
)¶
In this module it is defined the dictionary SDATA
containing the definition
of the sizing variables for each property accordingly to GENESIS Analysis
Manual (vol01).
It should be used as SDATA[ptype][etype]
, where:
ptype
is'PSHELL'
,'PBARL'
, etcetype
for a shell is'SOLID'
,'SAND'
, etcetype
for a bar is'SQUARE'
,'TUBE'
,'Z'
, etc
The currently available values are: