engforge.eng.geometry.ShapelySection
- class ShapelySection(*, name='shapely section', shape, coarse=False, mesh_extent_decimation=100, min_mesh_angle=20, min_mesh_size=1e-05, goal_elements=1000, material=None, failure_mode='von_mises', prediction=False, prediction_goal_error=0.025, max_records=10000)[source]
Bases:
Profile2Da 2D profile that takes a shapely section to calculate section properties, use a sectionproperties section with hidden variable _geo to bypass shape calculation
Method generated by attrs for class ShapelySection.
Methods
Overwrite this to modify logging fields
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)
run combinations of parameters and permutations of weights against the basis values to populate the stress records, by default using estimation logic to speed up the process
calculate_boundscalculate_mesh_sizecalculate_stresschange_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)
checks if the record is in bounds of the current data
recursively checks class slots for the key, and returns the slot type
checks if the section is symmetric about the x and y axis, by finding the intersection of
compiles this class, override this to compile functionality for this class
collects all the attributes for a system
collects all the attributes for a system
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 setA routine to communicate to the root of the server network that there is an issue
Writes at a low level to the log file.
determine_failure_frontuses the failure mode to compare to allowable stress
a context manager that will allow you to dynamically change any information, then will change it back in a fail safe way.
display_resultsWrites to log as a error
uses a support vector machine to estimate stresses and returns a number zero or one to indicate failure, if prediction is set to True, otherwise calculates stress
uses a support vector machine to estimate stresses and returns the ratio of the allowable stress, also known as the failure fracion if prediction is set to True, otherwise calculates stress
extract_messagefail_frac_criteriaoptimizes stress until failure, given base_kw arguments for extra parameters
This acts as the interface for logging.Filter Don't overwrite this, use add_fields instead.
from_cacheA 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
string for saving to persisting
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
init_with_materialLists all input attributes for class
no attr base types, no tuples, no lists, no dicts
We only want std logging to start
go through all attributes determining which are configuration objects additionally this skip any configuration that start with an underscore (private variable)
caches section properties and mesh
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.
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
Lists all plot attributes for class
plot_meshan overrideable classmethod that executes when compiled, however will not execute as a subclass
prediction_dataframeprediction_weightsrandom_force_inputdetermines if stress record should be added to prediction_records
reset log
resets log on all internal instance LoggingMixins
reset_predictionscores a dataframe
sets attributes from a dictionary
Lists all signals attributes for class
slack_notificationreturns all slot references in this configuration
Lists all slots attributes for class
solve_failLists all signals attributes for class
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
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.
trains the prediction models until the error is below the goal error
when training is complete save the model to a pickle with ShapelySection_<hash>.pkl
Lists all signals attributes for class
A customizeable validator at the end of class creation in forge
Writes to log as a warning
Attributes
Aoutside area, over ride for hallow sections
IxxIxyIyyJreturns values as they are in the class instance
attrs_fieldsbasiscache_namecache_pathShorthand for the classname
displaynameA nice to have, good to override
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_hashlog_fmtlog_levellog_onlog_silologgermax_marginmax_rec_parmmesh_sizemeta_namemeta_pathmin_mesh_areanear_marginrecursively gets internal components numeric_as_dict as well as its own numeric values
numeric_hashprediction_goal_errorprediction_recordssave_thresholdsection_cacheslack_webhook_urltable_hashreturns values as they would be put in a table row from this instance ignoring any sub components
train_windowtrainedunique_hashx_boundsy_boundsnameshapecoarsemin_mesh_anglemin_mesh_sizegoal_elementsmaterialpredictionmax_records- Parameters:
name (str)
shape (Polygon)
coarse (bool)
min_mesh_angle (float)
min_mesh_size (float)
goal_elements (float)
material (Material)
failure_mode (str)
prediction (bool)
prediction_goal_error (float)
max_records (list)
- property Ao
outside area, over ride for hallow sections
- add_fields(record)
Overwrite this to modify logging fields
- 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 as_dict
returns values as they are in the class instance
- basis_expand(expand_values=[0.9, 0.75, 0.5, 0.1, 0.01], Nparm=4, est=True, normalize=True)[source]
run combinations of parameters and permutations of weights against the basis values to populate the stress records, by default using estimation logic to speed up the process
- 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_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)
- check_symmetric(precision=3, Nincr=180)[source]
checks if the section is symmetric about the x and y axis, by finding the intersection of
- property classname
Shorthand for the classname
- 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_inst_attributes(**kw)
collects all the attributes for a system
- 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)
- critical(*args)
A routine to communicate to the root of the server network that there is an issue
- debug(*args)
Writes at a low level to the log file… usually this should be detailed messages about what exactly is going on
- 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
- estimate_failure(n=0, vx=0, vy=0, mxx=0, myy=0, mzz=0)[source]
uses a support vector machine to estimate stresses and returns a number zero or one to indicate failure, if prediction is set to True, otherwise calculates stress
- Return type:
float
- estimate_stress(n=0, vx=0, vy=0, mxx=0, myy=0, mzz=0, value=False, calc_margin=2, min_est_records=100, calc_every=25, pre_train_margin=2, force_calc=False)[source]
uses a support vector machine to estimate stresses and returns the ratio of the allowable stress, also known as the failure fracion if prediction is set to True, otherwise calculates stress
- Return type:
float
- fail_learning(X, parm, base_kw, mult=1)[source]
optimizes stress until failure, given base_kw arguments for extra parameters
- 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.
- 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_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
- 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
- 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
- classmethod plot_attributes()
Lists all plot attributes for class
- Return type:
Dict[str,Attribute]
- classmethod pre_compile()
an overrideable classmethod that executes when compiled, however will not execute as a subclass
- record_stress(stress_dict)[source]
determines if stress record should be added to prediction_records
- resetLog()
reset log
- resetSystemLogs(reseted=None)
resets log on all internal instance LoggingMixins
- score_data(df)
scores a dataframe
- setattrs(dict)
sets attributes from a dictionary
- classmethod signals_attributes()
Lists all signals attributes for class
- Return type:
Dict[str,Attribute]
- 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]
- classmethod solvers_attributes()
Lists all signals attributes for class
- Return type:
Dict[str,Attribute]
- 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
- 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
- train_until_valid(print_interval=50, max_iter=1000, est=False)[source]
trains the prediction models until the error is below the goal error
- training_callback(models)[source]
when training is complete save the model to a pickle with ShapelySection_<hash>.pkl
- classmethod transients_attributes()
Lists all signals attributes for class
- Return type:
Dict[str,Attribute]
- classmethod validate_class()
A customizeable validator at the end of class creation in forge
- warning(*args)
Writes to log as a warning