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: Profile2D

a 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

add_fields

Overwrite this to modify logging fields

add_prediction_record

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)

basis_expand

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_bounds

calculate_mesh_size

calculate_stress

change_all_log_lvl

check_and_retrain

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

checks if the record is in bounds of the current data

check_ref_slot_type

recursively checks class slots for the key, and returns the slot type

check_symmetric

checks if the section is symmetric about the x and y axis, by finding the intersection of

cls_compile

compiles this class, override this to compile functionality for this class

collect_all_attributes

collects all the attributes for a system

collect_inst_attributes

collects all the attributes for a system

compile_classes

compiles all subclass functionality

copy_config_at_state

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

critical

A routine to communicate to the root of the server network that there is an issue

debug

Writes at a low level to the log file.

determine_failure_front

determine_failure_stress

uses the failure mode to compare to allowable stress

difference

a context manager that will allow you to dynamically change any information, then will change it back in a fail safe way.

display_results

error

Writes to log as a error

estimate_failure

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

estimate_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_message

fail_frac_criteria

fail_learning

optimizes stress until failure, given base_kw arguments for extra parameters

filter

This acts as the interface for logging.Filter Don't overwrite this, use add_fields instead.

from_cache

go_through_configurations

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

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_id

string for saving to persisting

hash_numeric_with

hash_with

Generates a hash for the object's dictionary representation, updated with additional keyword arguments.

info

Writes to log but with info category, these are important typically and inform about progress of process in general

init_with_material

input_attrs

Lists all input attributes for class

input_fields

no attr base types, no tuples, no lists, no dicts

installSTDLogger

We only want std logging to start

internal_configurations

go through all attributes determining which are configuration objects additionally this skip any configuration that start with an underscore (private variable)

mesh_section

caches section properties and mesh

message_with_identiy

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]

msg

Writes to log.

numeric_fields

no tuples,lists, dicts, strings, or attr base types

observe_and_predict

uses the existing models to predict the row and measure the error

parent_configurations_cls

returns all subclasses that are a Configuration

plot_attributes

Lists all plot attributes for class

plot_mesh

pre_compile

an overrideable classmethod that executes when compiled, however will not execute as a subclass

prediction_dataframe

prediction_weights

random_force_input

record_stress

determines if stress record should be added to prediction_records

resetLog

reset log

resetSystemLogs

resets log on all internal instance LoggingMixins

reset_prediction

score_data

scores a dataframe

setattrs

sets attributes from a dictionary

signals_attributes

Lists all signals attributes for class

slack_notification

slot_refs

returns all slot references in this configuration

slots_attributes

Lists all slots attributes for class

solve_fail

solvers_attributes

Lists all signals attributes for class

subclasses

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!

subcls_compile

reliably compiles this method even for subclasses, override this to compile functionality for subclass interfaces & mixins

table_fields

the table attributes corresponding to

trace_attributes

Lists all trace attributes for class

train_compare

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.

train_until_valid

trains the prediction models until the error is below the goal error

training_callback

when training is complete save the model to a pickle with ShapelySection_<hash>.pkl

transients_attributes

Lists all signals attributes for class

validate_class

A customizeable validator at the end of class creation in forge

warning

Writes to log as a warning

Attributes

A

Ao

outside area, over ride for hallow sections

Ixx

Ixy

Iyy

J

as_dict

returns values as they are in the class instance

attrs_fields

basis

cache_name

cache_path

classname

Shorthand for the classname

displayname

filename

A nice to have, good to override

identity

A customizeable property that will be in the log by default

input_as_dict

returns values as they are in the class instance, but converts classes inputs to their input_as_dict

input_hash

log_fmt

log_level

log_on

log_silo

logger

max_margin

max_rec_parm

mesh_size

meta_name

meta_path

min_mesh_area

near_margin

numeric_as_dict

recursively gets internal components numeric_as_dict as well as its own numeric values

numeric_hash

prediction_goal_error

prediction_records

save_threshold

section_cache

slack_webhook_url

table_hash

table_row_dict

returns values as they would be put in a table row from this instance ignoring any sub components

train_window

trained

unique_hash

x_bounds

y_bounds

name

shape

coarse

min_mesh_angle

min_mesh_size

goal_elements

material

prediction

max_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

determine_failure_stress(stress_obj)[source]

uses the failure mode to compare to allowable stress

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_id()[source]

string for saving to persisting

Return type:

str

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

mesh_section()[source]

caches section properties and mesh

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