engforge.eng.structure.Structure
- class Structure(*, name=NOTHING, beams=NOTHING, parent=None, dynamic_input_vars=NOTHING, dynamic_state_vars=NOTHING, dynamic_output_vars=NOTHING, cost_per_item=nan, num_items=1, default_material=None, solve_method='linear', add_gravity_force=True, gravity_dir='FZ', gravity_mag=9.81, gravity_scalar=-1, gravity_name='gravity', gravity_cases=['gravity'], default_case='gravity', default_combo='gravity', check_statics=True, current_combo='gravity', iteration_combos=None, merge_nodes=True, tolerance=0.001, calculate_actual_failure=True, calculate_full_failure=False, failure_solve_method='bisect', failure_records=None, prediction=False, max_records=10000)[source]
Bases:
System,CostModel,PredictionMixinA integration between sectionproperties and Pynite, with a focus on ease of use
Right now we just need an integration between Sections+Materials and Members, to find, CG, and inertial components
Possible Future Additions: 1) Structure Motion (free body ie vehicle , multi-strucutre ie robots)
Method generated by attrs for class Structure.
Methods
adds the material to the structure and returns the pynite id
Overwrite this to modify logging fields
add_membera way to add specific beam properties to calculate stress, This way will currently not caluclate resulatant beam load.
maps to appropriate Pynite mesh generator but also applies loads
adds a record to the prediction records, and calcultes the average and variance of the data :type record: :param record: a dict of the record :type extra_add: :param extra_add: if true, the record is added to the prediction records even if the data is inbounds :returns: a boolean indicating if the record was out of bounds of current data (therefor should be added)
all_categoriesapply_gravity_to_meshcreates a dataframe entry for each beam and combo :type univ_parms:
Optional[list] :param univ_parms: keys represent the dataframe parm, and the values represent the lookup valueoverride this with a parametric model related to this systems attributes and properties
change_all_log_lvlChecks if more data than threshold to train or if error is sufficiently low to ignore retraining, or if more data already exists than window size (no training)
exposes check_est_failures
exposes check_failures
Returns the von-mises stress / allowable (failure fraction) stresses for each quad in each mesh.
checks if the record is in bounds of the current data
recursively checks class slots for the key, and returns the slot type
returns cost_property objects from this class & subclasses
returns a clone of this system, often used to iterate the system without affecting the input values at the last convergence step.
cls_all_attrs_fieldscls_all_property_keyscls_all_property_labelscompiles this class, override this to compile functionality for this class
collects all the attributes for a system
collects all the references for the system grouped by component
collects the dynamics of the systems 1.
collects all the attributes for a system
checks all methods and creates ref's to execute them later
collects all the references for the system grouped by function and prepended with the system key
checks all methods and creates ref's to execute them later
A cached set of recursive references to any slot component #FIXME: by instance recache on iterative component change or other signals
compiles all subclass functionality
copy the system at the current state recrusively to a certain level, by default copying everything :type levels_deep:
int:param levels_deep: how many levels deep to copy, -1 is all :type level: :param level: the current level, defaults to 0 if not setcost_categories_at_termreturns a dictionary of all costs at term i, with zero if the mode function returns False at that term
creates a dynamics object for the system
creates the input matrix for the system, called D
creates the input matrix for the system, called B
creates the input matrix for the system, called O
creates the input matrix for the system, called C
creates the input matrix for the system, called F
creates the state matrix for the system
Use this method to create a structure on init.
A routine to communicate to the root of the server network that there is an issue
uses the beam estimated stresses with specific adders to account for beam 2D stress concentrations and general inaccuracy as well as a fail_fraction to analyze.
Takes class costs set, and creates a copy of the class costs, then applies the cost numeric or CostMethod in the same way but only for that instance of
Writes at a low level to the log file.
Provide a default cost for Slot items that are not CostModel's.
determine_failure_loaddetermine the nearest stationary state
dict_itemized_costsa context manager that will allow you to dynamically change any information, then will change it back in a fail safe way.
Writes to log as a error
uses the beam estimated stresses with specific adders to account for beam 2D stress concentrations and general inaccuracy as well as a fail_fraction to analyze.
Evaluates the system with pre/post execute methodology :type kw: :param kw: kwargs come from sys_kw input in run ect.
wrapper allowing saving of data by load combo
extract_messagereturns or yields a set of load combo names to check failure for.
a callback that is passed the structural combo, the case results
This acts as the interface for logging.Filter Don't overwrite this, use add_fields instead.
format_columnsGet the references to system input based on the specified criteria.
A generator that will go through all internal configurations up to a certain level if levels_to_descend is less than 0 ie(-1) it will go down, if it 0, None, or False it will only go through this configuration
hash by parm or by input_kw, only input can be hashed by lookup as system properties can create a recursive loop and should be deterministic from input
hash_numeric_withGenerates a hash for the object's dictionary representation, updated with additional keyword arguments.
Writes to log but with info category, these are important typically and inform about progress of process in general
initalize_structureLists all input attributes for class
no attr base types, no tuples, no lists, no dicts
We only want std logging to start
get all the internal components
go through all attributes determining which are configuration objects additionally this skip any configuration that start with an underscore (private variable)
get references to all internal attributes and values, only saving when complete cache info is requested (vs numeric only)
get all the internal components
get all the internal tabulations
simulate the system over the course of time.
Optimal nonlinear steps
Pass a string of a relative var or property on this system or pass a callable to get a reference to a function.
makes plots and traces of all on this instance, and if a system is subsystems.
mark all components as changed, useful for forcing a re-run of the system, or for marking data as saved
return a dictionary of beam & quad mass
adds a remotely calculated displacement vector and applies to nodes ala pynite convention
mesh_extentsreturns a dataframe of each quad, its x,y,z coords, vonmises stress and other mass/cost properties in a dataframe
converts to color and string via the termcolor library :type message:
str:param message: a string convertable entity :type color: :param color: a color in [grey,red,green,yellow,blue,magenta,cyan,white]Writes to log.
simulate the system over the course of time.
Optimal nonlinear steps
no tuples,lists, dicts, strings, or attr base types
uses the existing models to predict the row and measure the error
returns all subclasses that are a Configuration
ensures correct input for simulation.
parses the simulation input
Lists all plot attributes for class
user callback for when run is complete
Kwargs comes from eval_kw in solver
an overrideable classmethod that executes when compiled, however will not execute as a subclass
user callback for when run is beginning
prediction_dataframeprediction_weightscopies Pynite analysis pre-functions
print_infosimulate the system over the course of time.
simulate the system over the course of time.
simulate the system over the course of time.
determines if stress record should be added to prediction_records
returns the reference to the time differential of the state
reset log
resets log on all internal instance LoggingMixins
reset_cls_coststhe steady state run the solver for the system.
runs a single load combo and adds 2d section failures
Failure Determination: Beam Stress Estiates are used to determine if a 2D FEA beam/combo analysis should be run.
takes estimated failures and runs 2D section FEA on those cases
runs internal systems with potentially scoped kwargs
save_datascores a dataframe
set_attrset default costs if no costs are set
sets the time of the system and context
sets attributes from a dictionary
recursively creates numeric matricies for the simulation
Lists all signals attributes for class
simulate the system over the course of time.
runs a simulation over the course of time, and returns a dataframe of the results.
slack_notificationreturns all slot references in this configuration
Lists all slots attributes for class
splits dataframe between constant values and variants
runs the system solver using the current system state and modifying it.
applies the default combo filter, and your keyword arguments to the collect_solver_refs to test the ref / vars creations
Lists all signals attributes for class
stepyours to override dataframe
yours to override to prep solver or dataframe :returns: combo to run, or None if want to continue with current iteration combos
struct_root_failuregets items from CostModel's defined in a Slot attribute or in a slot default, tolerrant to nan's in cost definitions
return all subclasses of components, including their subclasses :type out: :param out: out is to pass when the middle of a recursive operation, do not use it!
reliably compiles this method even for subclasses, override this to compile functionality for subclass interfaces & mixins
sums costs of cost_property's in this item that are present at term=0, and by category if define as input
Combine other parent-classes table properties into this one, in the case of subclassed system_properties
gather a list of references to attributes and
the table attributes corresponding to
Lists all trace attributes for class
Use the dataframe to train the models, and compare the results to the current models using train_frac to divide total samples into training and testing sets, unless train_full is set.
override to provide a callback when training is complete, such as saving the models
Lists all signals attributes for class
Kwargs comes from eval_kw in solver
updates internal default slot costs if the current component doesn't exist or isn't a cost model, this is really a component method but we will use it never the less.
Updates dynamics when nonlinear is enabled, otherwise it will do nothing
override
override
override
override
override
override
A customizeable validator at the end of class creation in forge
visulizeWrites to log as a warning
Attributes
force of gravity
Combines all the mass moments of inerita from the internal beams (and other future items!) into one for the sturcture with the parallel axis theorm
alias for input values
alias for state values
alias for output values
actual_beam_failure_countactual_failure_countactual_mesh_failure_countuse the on_setattr method to determine if anything changed, also assume that stat_tab could change without input changes
returns values as they are in the class instance
attrs_fieldsbasisbeam_cost([fget, fset, fdel, doc])A thin wrapper over system_property that will be accounted by Economics Components and apply term & categorization
Shorthand for the classname
cogcombine_cost([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
converged([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
returns itemized costs grouped by category
returns the current values of the current properties
current_failure_summarya dictionary of state var rates
Returns a pandas DataFrame based on the current context.
dataframe_constantsdataframe_variantsdisplaynamedynamic_Adynamic_Bdynamic_Cdynamic_Ddynamic_Fdynamic_Kdynamic_inputdynamic_input_varsdynamic_outputdynamic_output_varsdynamic_statedynamic_state_varsestimated_beam_failure_countestimated_failure_countestimated_mesh_failure_countA nice to have, good to override
framereturn all failure estimates for all combos
future_costs([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
A customizeable property that will be in the log by default
returns values as they are in the class instance, but converts classes inputs to their input_as_dict
input_hashitem_cost([fget, fset, fdel, doc])A thin wrapper over system_property that will be accounted by Economics Components and apply term & categorization
itemized_costs([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
get the last context run, or the parent's
log_fmtlog_levellog_onlog_silologgermass([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
max_beam_est_fail_fracestimated failure fraction for the current result
max_guessmax_marginmax_mesh_est_fail_fracmembersmin_recnear_marginnode_dataframenodesnonlinearrecursively gets internal components numeric_as_dict as well as its own numeric values
numeric_hashpanels_cost([fget, fset, fdel, doc])A thin wrapper over system_property that will be accounted by Economics Components and apply term & categorization
Checks columns for ones that only contain numeric types or haven't been explicitly skipped
prediction_goal_errorprediction_recordsreturn a dictonary of quads with their mass properties like cog, mass, area and volume
run_id([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
accesses '_skip_plot_vars' if it exists, otherwise returns empty list
slack_webhook_urlsolvedstatic_Astatic_Bstatic_Cstatic_Dstatic_Fstatic_Kstored_plotsstructure_cost([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
sum of all beams and quad cost
sum of all panels cost
sub_items_cost([fget, fset, fdel, doc])this property notifies the system this is a property to be tabulated in the dataframe output.
returns an instance unique id based on id(self)
table_hashreturns values as they would be put in a table row from this instance ignoring any sub components
timetrain_windowtrainedunique_hashupdate_intervaldefault_materialadd_gravity_forcegravity_dirgravity_maggravity_scalargravity_namegravity_casesdefault_casedefault_combocheck_staticscurrent_comboiteration_combosmerge_nodestolerancecalculate_actual_failurecalculate_full_failurefailure_recordspredictionmax_recordsparentcost_per_itemnum_itemsname- Parameters:
name (str)
beams (SlotITER_5148a1916e0b4494)
dynamic_input_vars (list)
dynamic_state_vars (list)
dynamic_output_vars (list)
cost_per_item (float)
num_items (int)
default_material (SolidMaterial)
solve_method (str)
add_gravity_force (bool)
gravity_dir (str)
gravity_mag (float)
gravity_scalar (float)
gravity_name (str)
gravity_cases (list)
default_case (str)
default_combo (str)
check_statics (bool)
current_combo (str)
iteration_combos (list)
merge_nodes (bool)
tolerance (float)
calculate_actual_failure (bool)
calculate_full_failure (bool)
failure_solve_method (str)
failure_records (list)
prediction (bool)
max_records (int)
- property Fg
force of gravity
- property INERTIA
Combines all the mass moments of inerita from the internal beams (and other future items!) into one for the sturcture with the parallel axis theorm
- property Ut_ref
alias for input values
- property Xt_ref
alias for state values
- property Yt_ref
alias for output values
- add_eng_material(material)[source]
adds the material to the structure and returns the pynite id
- Return type:
str- Parameters:
material (SolidMaterial)
- add_fields(record)
Overwrite this to modify logging fields
- add_member_with(name, node1, node2, E, G, Iy, Ix, J, A, material_rho=0, **kwargs)[source]
a way to add specific beam properties to calculate stress, This way will currently not caluclate resulatant beam load. #TOOD: Add in a mock section_properties for our own stress calcs
- add_mesh(meshtype, *args, **kwargs)[source]
maps to appropriate Pynite mesh generator but also applies loads
Currently these types are supported [‘rect’,’annulus’,’cylinder’,’triangle’]
- add_prediction_record(record, extra_add=True, mult_sigma=1, target_items=1000)
adds a record to the prediction records, and calcultes the average and variance of the data :type record: :param record: a dict of the record :type extra_add: :param extra_add: if true, the record is added to the prediction records even if the data is inbounds :returns: a boolean indicating if the record was out of bounds of current data (therefor should be added)
- property anything_changed
use the on_setattr method to determine if anything changed, also assume that stat_tab could change without input changes
- property as_dict
returns values as they are in the class instance
- beam_dataframe(univ_parms=None, add_columns=None)[source]
creates a dataframe entry for each beam and combo :type univ_parms:
Optional[list] :param univ_parms: keys represent the dataframe parm, and the values represent the lookup value- Parameters:
univ_parms (list | None)
add_columns (list | None)
- calculate_item_cost()
override this with a parametric model related to this systems attributes and properties
- Return type:
float
- check_and_retrain(records, min_rec=None)
Checks if more data than threshold to train or if error is sufficiently low to ignore retraining, or if more data already exists than window size (no training)
- check_mesh_failures(combo, run_full=False, SF=1.0, return_complete=False)[source]
Returns the von-mises stress / allowable (failure fraction) stresses for each quad in each mesh. :type run_full: :param run_full: if false will exit early on first failure :rtype:
dict:returns: a dictinary of quad names and their failure fraction- Return type:
dict
- check_out_of_domain(record, extra_margin=1, target_items=1000)
checks if the record is in bounds of the current data
- classmethod check_ref_slot_type(sys_key)
recursively checks class slots for the key, and returns the slot type
- Return type:
list- Parameters:
sys_key (str)
- classmethod class_cost_properties()
returns cost_property objects from this class & subclasses
- Return type:
dict
- property classname
Shorthand for the classname
- clone()
returns a clone of this system, often used to iterate the system without affecting the input values at the last convergence step.
- classmethod cls_compile()
compiles this class, override this to compile functionality for this class
- classmethod collect_all_attributes()
collects all the attributes for a system
- collect_comp_refs(conf=None, **kw)
collects all the references for the system grouped by component
- Parameters:
conf (Configuration | None)
- collect_dynamic_refs(conf=None, **kw)
collects the dynamics of the systems 1. Time.integrate 2. Dynamic Instances
- Return type:
dict- Parameters:
conf (Configuration | None)
- collect_inst_attributes(**kw)
collects all the attributes for a system
- collect_post_update_refs(eval_kw=None, ignore=None)
checks all methods and creates ref’s to execute them later
- collect_solver_refs(conf=None, check_atr_f=None, check_kw=None, check_dynamics=True, **kw)
collects all the references for the system grouped by function and prepended with the system key
- Parameters:
conf (Configuration | None)
- collect_update_refs(eval_kw=None, ignore=None)
checks all methods and creates ref’s to execute them later
- comp_references(ignore_none_comp=True, **kw)
A cached set of recursive references to any slot component #FIXME: by instance recache on iterative component change or other signals
- classmethod compile_classes()
compiles all subclass functionality
- copy_config_at_state(level=None, levels_deep=-1, changed=None, **kw)
copy the system at the current state recrusively to a certain level, by default copying everything :type levels_deep:
int:param levels_deep: how many levels deep to copy, -1 is all :type level: :param level: the current level, defaults to 0 if not set- Parameters:
levels_deep (int)
changed (dict | None)
- property cost_categories
returns itemized costs grouped by category
- property cost_properties: dict
returns the current values of the current properties
- costs_at_term(term, test_val=True, econ=None)
returns a dictionary of all costs at term i, with zero if the mode function returns False at that term
- Parameters:
econ – the economics component to apply “end” term mode
term (int)
- Return type:
dict
- create_dynamic_matricies(**kw)
creates a dynamics object for the system
- create_feedthrough_matrix(**kwargs)
creates the input matrix for the system, called D
- Return type:
ndarray
- create_input_matrix(**kwargs)
creates the input matrix for the system, called B
- Return type:
ndarray
- create_output_constants(**kwargs)
creates the input matrix for the system, called O
- Return type:
ndarray
- create_output_matrix(**kwargs)
creates the input matrix for the system, called C
- Return type:
ndarray
- create_state_constants(**kwargs)
creates the input matrix for the system, called F
- Return type:
ndarray
- create_state_matrix(**kwargs)
creates the state matrix for the system
- Return type:
ndarray
- create_structure()[source]
Use this method to create a structure on init.
# Example code for creating a structure frame = Structure() frame.add_material(“default_material”, 2E9, 8E8, 0.3, 7850)
# Add nodes node1 = frame.add_node(“Node1”, 0, 0, 0) node2 = frame.add_node(“Node2”, 0, 0, 10)
# Add elements element = frame.add_member(“Element1”, “Node1”, “Node2”, “default_material”)
# Add supports frame.def_support(“Node1”, True, True, True, True, True, True) frame.def_support(“Node2”, True, True, True, True, True, True)
# Add loads self.add_node_load(“Node2”, “FZ”, -100)
# Solve the structure self.run() #calls execute!
- critical(*args)
A routine to communicate to the root of the server network that there is an issue
- current_failures(concentrationFactor=1, methodFactor=1, fail_frac_criteria=0.999)[source]
uses the beam estimated stresses with specific adders to account for beam 2D stress concentrations and general inaccuracy as well as a fail_fraction to analyze. The estimated loads are very pessimistic with a 250x overestimate by default for beams. mesh stresses are more accurate and failure is determined by fail_fac (von-mises stress / allowable stress)/fail_frac_criteria
- Return type:
dict
- custom_cost(slot_name, cost, warn_on_non_costmodel=True)
Takes class costs set, and creates a copy of the class costs, then applies the cost numeric or CostMethod in the same way but only for that instance of
- Parameters:
slot_name (str)
cost (float | CostModel)
- property dXtdt_ref
a dictionary of state var rates
- property dataframe
Returns a pandas DataFrame based on the current context.
This method checks for the presence of last_context and its dataframe attribute. If they exist, it returns the dataframe from last_context. If not, it checks for the _patch_dataframe attribute and returns it if it exists. If neither condition is met, it returns an empty DataFrame.
- Returns:
A pandas DataFrame based on the current context or an empty DataFrame if no context is available.
- Return type:
pandas.DataFrame
- debug(*args)
Writes at a low level to the log file… usually this should be detailed messages about what exactly is going on
- classmethod default_cost(slot_name, cost, warn_on_non_costmodel=True)
Provide a default cost for Slot items that are not CostModel’s. Cost is applied class wide, but can be overriden with custom_cost per instance
- Parameters:
slot_name (str)
cost (float | CostModel)
- determine_nearest_stationary_state(t=0, X=None, U=None)
determine the nearest stationary state
- Return type:
ndarray
- difference(**kwargs)
a context manager that will allow you to dynamically change any information, then will change it back in a fail safe way.
- with self.difference(name=’new_name’, value = new_value) as new_config:
#do stuff with config, ok to fail
you may not access any “private” variable that starts with an _ as in _whatever
difference is useful for saving slight differences in configuration in conjunction with solve you might create wrappers for eval, or implement a strategy pattern.
only attributes may be changed.
#TODO: allow recursive operation with sub comps or systems. #TODO: make a full system copy so the system can be reverted later
- error(error, msg='')
Writes to log as a error
- estimated_failures_report(concentrationFactor=1, methodFactor=1, fail_frac_criteria=None, combos=None)[source]
uses the beam estimated stresses with specific adders to account for beam 2D stress concentrations and general inaccuracy as well as a fail_fraction to analyze. The estimated loads are very pessimistic with a 250x overestimate
- Return type:
dict- Parameters:
combos (list | None)
- eval(Xo=None, eval_kw=None, sys_kw=None, cb=None, **kw)
Evaluates the system with pre/post execute methodology :type kw: :param kw: kwargs come from sys_kw input in run ect. :type cb: :param cb: an optional callback taking the system as an argument of the form (self,eval_kw,sys_kw,**kw)
- Parameters:
eval_kw (dict | None)
sys_kw (dict | None)
- execute(combos=None, save=True, record=True, *args, **kwargs)[source]
wrapper allowing saving of data by load combo
- Parameters:
combos (list | None)
- failure_load_combos(report_info, run_full=False, remote_sync=None, **kw)[source]
returns or yields a set of load combo names to check failure for. You’re encouraged to override this for your specific cases :type report_info:
dict:param report_info: the report that is generated in run_failure_analysis which will dynamically change with :yields: the combo name :returns: None when done- Parameters:
report_info (dict)
- failure_load_exithandler(combo, res, report_info, run_full)[source]
a callback that is passed the structural combo, the case results
Override this function to provide custom exit capability :type combo: :param combo: the load combo analyzed :type res: :param res: the combo failure results :type report_info: :param report_info: the report dictionary :run_full: option to run everything
- property filename
A nice to have, good to override
- filter(record)
This acts as the interface for logging.Filter Don’t overwrite this, use add_fields instead.
- property full_failures
return all failure estimates for all combos
- get_system_input_refs(strings=False, numeric=True, misc=False, all=False, boolean=False, **kw)
Get the references to system input based on the specified criteria.
- Parameters:
strings – Include system properties of string type.
numeric – Include system properties of numeric type (float, int).
misc – Include system properties of miscellaneous type.
all – Include all system properties regardless of type.
boolean – Include system properties of boolean type.
kw – Additional keyword arguments passed to recursive config loop
- Returns:
A dictionary of system property references.
- Return type:
dict
- go_through_configurations(level=0, levels_to_descend=-1, parent_level=0, only_inst=True, **kw)
A generator that will go through all internal configurations up to a certain level if levels_to_descend is less than 0 ie(-1) it will go down, if it 0, None, or False it will only go through this configuration
- Returns:
level,config
- hash(*args, **input_kw)
hash by parm or by input_kw, only input can be hashed by lookup as system properties can create a recursive loop and should be deterministic from input
- hash_with(**input_kw)
Generates a hash for the object’s dictionary representation, updated with additional keyword arguments. :type **input_kw: :param **input_kw: Arbitrary keyword arguments to update the object’s dictionary representation.
- Returns:
The hash value of the updated dictionary.
- Raises:
Any exceptions raised by deepdiff.DeepHash if hashing fails. –
- property identity
A customizeable property that will be in the log by default
- info(*args)
Writes to log but with info category, these are important typically and inform about progress of process in general
- property input_as_dict
returns values as they are in the class instance, but converts classes inputs to their input_as_dict
- classmethod input_attrs()
Lists all input attributes for class
- classmethod input_fields(add_ign_types=None)
no attr base types, no tuples, no lists, no dicts
- Parameters:
add_ign_types (list | None)
- installSTDLogger()
We only want std logging to start
- internal_components(recache=False)
get all the internal components
- Return type:
dict
- internal_configurations(check_config=True, use_dict=True, none_ok=False)
go through all attributes determining which are configuration objects additionally this skip any configuration that start with an underscore (private variable)
- Return type:
dict
- internal_references(recache=False, numeric_only=False)
get references to all internal attributes and values, only saving when complete cache info is requested (vs numeric only)
- Return type:
dict
- internal_systems(recache=False)
get all the internal components
- Return type:
dict
- internal_tabulations(recache=False)
get all the internal tabulations
- Return type:
dict
- property last_context
get the last context run, or the parent’s
- linear_output(t, dt, X, U=None)
simulate the system over the course of time. Return time differential of the state.
- Parameters:
dt (float) – interval to integrate over in time
X (np.ndarray) – state input
U (np.ndarray) – control input
- Returns:
time differential of the state
- Return type:
np.array
- linear_step(t, dt, X, U=None, set_Y=False)
Optimal nonlinear steps
- classmethod locate(key, fail=True)
- Return type:
type- Returns:
the class or attribute by key if its in this system class or a subcomponent. If nothing is found raise an error
- locate_ref(key, fail=True, **kw)
Pass a string of a relative var or property on this system or pass a callable to get a reference to a function. If the key has a . in it the comp the lowest level component will be returned, unless a callable is passed in which case this component will be used or the comp passed in the kw will be used. :type key: :param key: the key to locate, or a callable to be used as a reference :param comp: the component to use if a callable is passed :returns: the instance assigned to this system. If the key has a . in it the comp the lowest level component will be returned
- make_plots(analysis=None, store_figures=True, pre=None)
makes plots and traces of all on this instance, and if a system is subsystems. Analysis should call make plots however it can be called on a system as well :type analysis: Analysis :param analysis: the analysis that has triggered this plot :param store_figure: a boolean or dict, if neither a dictionary will be created and returend from this function :returns: the dictionary from store_figures logic
- Parameters:
analysis (Analysis)
store_figures (bool)
- mark_all_comps_changed(inpt)
mark all components as changed, useful for forcing a re-run of the system, or for marking data as saved
- Parameters:
inpt (bool)
- property max_est_fail_frac: float
estimated failure fraction for the current result
- merge_displacement_results(combo, D)[source]
adds a remotely calculated displacement vector and applies to nodes ala pynite convention
- mesh_stress_dataframe(combo=None)[source]
returns a dataframe of each quad, its x,y,z coords, vonmises stress and other mass/cost properties in a dataframe
- message_with_identiy(message, color=None)
converts to color and string via the termcolor library :type message:
str:param message: a string convertable entity :type color: :param color: a color in [grey,red,green,yellow,blue,magenta,cyan,white]- Parameters:
message (str)
- msg(*args, lvl=5)
Writes to log… this should be for raw data or something… least priorty
- nonlinear_output(t, dt, X, U=None, update=True)
simulate the system over the course of time. Return time differential of the state.
- Parameters:
dt (float) – interval to integrate over in time
X (np.ndarray) – state input
U (np.ndarray) – control input
- Returns:
time differential of the state
- Return type:
np.array
- nonlinear_step(t, dt, X, U=None, set_Y=False)
Optimal nonlinear steps
- property numeric_as_dict
recursively gets internal components numeric_as_dict as well as its own numeric values
- classmethod numeric_fields()
no tuples,lists, dicts, strings, or attr base types
- observe_and_predict(row)
uses the existing models to predict the row and measure the error
- classmethod parent_configurations_cls()
returns all subclasses that are a Configuration
- Return type:
list
- parse_run_kwargs(**kwargs)
ensures correct input for simulation. :returns: first set of input for initalization, and all input dictionaries as tuple.
- parse_simulation_input(**kwargs)
parses the simulation input
- Parameters:
dt – timestep in s, required for transients
endtime – when to end the simulation
- classmethod plot_attributes()
Lists all plot attributes for class
- Return type:
Dict[str,Attribute]
- property plotable_variables
Checks columns for ones that only contain numeric types or haven’t been explicitly skipped
- post_run_callback(**kwargs)
user callback for when run is complete
- post_update(parent, *args, **kwargs)
Kwargs comes from eval_kw in solver
- classmethod pre_compile()
an overrideable classmethod that executes when compiled, however will not execute as a subclass
- pre_run_callback(**kwargs)
user callback for when run is beginning
- property quad_info: dict
return a dictonary of quads with their mass properties like cog, mass, area and volume
- rate(t, dt, X, U, *args, **kwargs)
simulate the system over the course of time.
- Parameters:
dt (float) – interval to integrate over in time
X (np.ndarray) – state input
U (np.ndarray) – control input
subsystems (bool, optional) – simulate subsystems. Defaults to True.
- Returns:
tabulated data
- Return type:
dataframe
- rate_linear(t, dt, X, U=None)
simulate the system over the course of time. Return time differential of the state.
- rate_nonlinear(t, dt, X, U=None, update=True)
simulate the system over the course of time. Return time differential of the state.
- Parameters:
t (float) – time
dt (float) – interval to integrate over in time
X (np.ndarray) – state input
U (np.ndarray) – control input
- Returns:
time differential of the state
- Return type:
np.array
- record_result(stress_dict)[source]
determines if stress record should be added to prediction_records
- ref_dXdt(name)
returns the reference to the time differential of the state
- Parameters:
name (str)
- resetLog()
reset log
- resetSystemLogs(reseted=None)
resets log on all internal instance LoggingMixins
- run(**kwargs)
the steady state run the solver for the system. It will run the system with the input vars and return the system with the results. Dynamics systems will be run so they are in a steady state nearest their initial position.
- run_combo_failure_analysis(combo, run_full=False, SF=1.0, run_section_failure=None, fail_fast=True, failures=None)[source]
runs a single load combo and adds 2d section failures
- Parameters:
run_full (bool)
SF (float)
- run_failure_analysis(SF=1.0, run_full=False, **kwargs)[source]
Failure Determination: Beam Stress Estiates are used to determine if a 2D FEA beam/combo analysis should be run. The maximum beam vonmises stress is compared the the beam material allowable stress / saftey factor.
Override: Depending on number of load cases, this analysis could take a while. Its encouraged to use a similar pattern of check and exit to reduce load combo size in an effort to fail early. Override this function if nessicary.
Case / Beam Ordering: runs the gravity case first and checks for failure to exit early, then all other combos are run :returns: a dictionary with 2D fea failures and estimated failures as well for each beam
- run_failure_sections(failures, run_full=False, SF=1.0, fail_fast=True)[source]
takes estimated failures and runs 2D section FEA on those cases
- Parameters:
run_full (bool)
SF (float)
- run_internal_systems(sys_kw=None)
runs internal systems with potentially scoped kwargs
- score_data(df)
scores a dataframe
- set_default_costs()
set default costs if no costs are set
- set_time(t, system=True, subcomponents=True)
sets the time of the system and context
- setattrs(dict)
sets attributes from a dictionary
- setup_global_dynamics(**kwargs)
recursively creates numeric matricies for the simulation
- classmethod signals_attributes()
Lists all signals attributes for class
- Return type:
Dict[str,Attribute]
- sim_matrix(eval_kw=None, sys_kw=None, **kwargs)
simulate the system over the course of time. return a dictionary of dataframes
- simulate(dt, endtime, X0=None, cb=None, eval_kw=None, sys_kw=None, min_kw=None, run_solver=False, return_system=False, return_data=False, return_all=False, debug_fail=False, **kwargs)
runs a simulation over the course of time, and returns a dataframe of the results.
A copy of this system is made, and the simulation is run on the copy, so as to not affect the state of the original system.
#TODO:
- Return type:
DataFrame
- property skip_plot_vars: list
accesses ‘_skip_plot_vars’ if it exists, otherwise returns empty list
- classmethod slot_refs(recache=False)
returns all slot references in this configuration
- classmethod slots_attributes(attr_type=False)
Lists all slots attributes for class
- Return type:
Dict[str,Attribute]
- smart_split_dataframe(df=None, split_groups=0, key_f=<function <lambda>>)
splits dataframe between constant values and variants
- solver(enter_refresh=True, save_on_exit=True, **kw)
runs the system solver using the current system state and modifying it. This is the default solver for the system, and it is recommended to add additional options or methods via the execute method.
- Parameters:
obj – the objective function to minimize, by default will minimize the sum of the squares of the residuals. Objective function should be a function(system,Xs,Xt) where Xs is the system state and Xt is the system transient state. The objective function will be argmin(X)|(1+custom_objective)*residual_RSS when add_obj is True in kw otherwise argmin(X)|custom_objective with constraints on the system as balances instead of first objective being included.
cons – the constraints to be used in the solver, by default will use the system’s constraints will be enabled when True. If a dictionary is passed the solver will use the dictionary as the constraints in addition to system constraints. These can be individually disabled by key=None in the dictionary.
X0 – the initial guess for the solver, by default will use the current system state. If a dictionary is passed the solver will use the dictionary as the initial guess in addition to the system state.
dXdt – can be 0 to indicate steady-state, or None to not run the transient constraints. Otherwise a partial dictionary of vars for the dynamics rates can be given, those not given will be assumed steady state or 0.
kw – additional options for the solver, such as the solver_option, or the solver method options. Described below
combos – a csv str or list of combos to include, including wildcards. the default means all combos will be run unless ign_combos or only combos alters behavior. The initial selection of combos is made by matching any case with the full name of the combo, or a parial name with a wildcard(s) in the combo name Ignore and only combos will further filter the selection. Wildcards / queries per fnmatch
ign_combos – a list of combo vars to ignore.
only_combos – a list of combo vars to include exclusively.
add_var – a csv str or variables to include, including wildcards. the default means all combos will be run unless ign_combos or only combos alters behavior. The initial selection of combos is made by matching any case with the full name of the combo, or a parial name with a wildcard(s) in the combo name Ignore and only combos will further filter the selection. Wildcards / queries per fnmatch
ign_var – a list of combo vars to ignore.
only_var – a list of combo vars to include exclusively.
add_obj – a flag to add the objective to the system constraints, by default will add the objective to the system constraints. If False the objective will be the only constraint.
only_active – default True, will only look at active variables objectives and constraints
activate – default None, a list of solver vars to activate
deactivate – default None, a list of solver vars to deactivate (if not activated above)
- solver_vars(check_dynamics=True, addable=None, **kwargs)
applies the default combo filter, and your keyword arguments to the collect_solver_refs to test the ref / vars creations
parses add_vars in kwargs to append to the collected solver vars :param add_vars: can be a str, a list or a dictionary of variables: solver_instance kwargs. If a str or list the variable will be added with positive only constraints. If a dictionary is chosen, it can have keys as parameters, and itself have a subdictionary with keys: min / max, where each respective value is placed in the constraints list, which may be a callable(sys,prob) or numeric. If nothing is specified the default is min=0,max=None, ie positive only.
- classmethod solvers_attributes()
Lists all signals attributes for class
- Return type:
Dict[str,Attribute]
- struct_pre_execute(combo=None)[source]
yours to override to prep solver or dataframe :returns: combo to run, or None if want to continue with current iteration combos
- property structure_cost_beams: float
sum of all beams and quad cost
- property structure_cost_panels: float
sum of all panels cost
- sub_costs(saved=None, categories=None, term=0, econ=None)
gets items from CostModel’s defined in a Slot attribute or in a slot default, tolerrant to nan’s in cost definitions
- Parameters:
saved (set | None)
categories (tuple | None)
- classmethod subclasses(out=None)
return all subclasses of components, including their subclasses :type out: :param out: out is to pass when the middle of a recursive operation, do not use it!
- classmethod subcls_compile()
reliably compiles this method even for subclasses, override this to compile functionality for subclass interfaces & mixins
- sum_costs(saved=None, categories=None, term=0, econ=None)
sums costs of cost_property’s in this item that are present at term=0, and by category if define as input
- Parameters:
saved (set | None)
categories (tuple | None)
- property system_id: str
returns an instance unique id based on id(self)
- classmethod system_properties_classdef(recache=False)
Combine other parent-classes table properties into this one, in the case of subclassed system_properties
- system_references(recache=False, numeric_only=False, **kw)
gather a list of references to attributes and
- classmethod table_fields()
the table attributes corresponding to
- property table_row_dict
returns values as they would be put in a table row from this instance ignoring any sub components
- classmethod trace_attributes()
Lists all trace attributes for class
- Return type:
Dict[str,Attribute]
- train_compare(df, test_frac=2, train_full=False, min_rec=250)
Use the dataframe to train the models, and compare the results to the current models using train_frac to divide total samples into training and testing sets, unless train_full is set.
- Parameters:
df – dataframe to train with
test_frac – N/train_frac will be size of the training window
train_full – boolean to use full training data
- Returns:
trained models
- training_callback(models)
override to provide a callback when training is complete, such as saving the models
- classmethod transients_attributes()
Lists all signals attributes for class
- Return type:
Dict[str,Attribute]
- update(parent, *args, **kwargs)
Kwargs comes from eval_kw in solver
- update_dflt_costs()
updates internal default slot costs if the current component doesn’t exist or isn’t a cost model, this is really a component method but we will use it never the less.
This should be called from Component.update() if default costs are used
- update_dynamics(t, X, U)
Updates dynamics when nonlinear is enabled, otherwise it will do nothing
- update_feedthrough(t, D, X, U)
override
- Return type:
ndarray
- update_input(t, B, X, U)
override
- Return type:
ndarray
- update_output_constants(t, O, X)
override
- Return type:
ndarray
- update_output_matrix(t, C, X)
override
- Return type:
ndarray
- update_state(t, A, X)
override
- Return type:
ndarray
- update_state_constants(t, F, X)
override
- Return type:
ndarray
- classmethod validate_class()
A customizeable validator at the end of class creation in forge
- warning(*args)
Writes to log as a warning