4. i-SAS_iFEM¶
4.1. base¶
-
class
ifem.base.Base(input_names, output_names, structural_model_name, cfg)¶ Bases:
objectAbstract class for FEM and iFEM
-
ANALYSIS_TYPE¶ the analysys type.
- Type
str
-
REQUIRED_INPUTS¶ the required inputs name.
- Type
list[str]
-
MERGE_TYPE¶ the type of matrix to be merged
- Type
list[str]
-
structural_model_name¶ structural model name.
- Type
str
-
input¶ inputs.
- Type
dict[str, DataFrame]
-
cfg¶ config.
- Type
dict[str]
-
elems¶ list of elem(solid_1, shell_iqs4 and so on) instance.
- Type
list[elem]
-
node_dof¶ node degrees of freedom (dof) per node. 1-D array of shape
(node_num)- Type
ndarray[np.int64]
-
node_dof_elem¶ node degrees of freedom (dof) per element. 1-D array of shape
(elem_num)- Type
ndarray[np.int64]
-
total_node_dof¶ the sum of all node degrees of freedom (dof).
- Type
int
-
node_id2node_idx¶ a dictionary that maps the node_id to the index after reordering the node.
- Type
dict[int, int]
-
node_idx2dof_idx¶ a dictionary that maps the index after reordering the node to an index that has a dof value of the node.
- Type
dict[int, list[int]]
-
elem_id2elem_idx¶ a dictionary that maps the elem_id to the index after reordering the elements.
- Type
dict[int, int]
-
shell_idx¶ ## to be written
-
k_matrix¶ merged Kmatrix.
- Type
csr_matrix
-
u_vector¶ the value of the node degrees of freedom (dof). 2-D array of shape
(total_node_dof, 1)- Type
csc_matrix
-
bound¶ the value of constraint.
- Type
nddarray
-
bound_idx¶ bound_idx[i] is True if i-th node degrees of freedom (dof) is bound, False otherwise.
- Type
nddarray[bool]
-
postprocess_matrix¶ dict of postprocessed matrix.
- Type
dict
-
ANALYSIS_TYPE= None¶
-
MERGE_TYPE= ['node_dof', 'node_dim', 'elem_dim']¶
-
REQUIRED_INPUTS= ['fe_node', 'fe_elem', 'fe_connection', 'fe_constraint']¶
-
CONNECTION_MAGIC_NUMBER= [0]¶
-
__init__(input_names, output_names, structural_model_name, cfg)¶ constructor
- Parameters
input_names (dict) – dict whose keys are names of input quantity and values are names of input data.
output_names (dict) – dict whose keys are names of output quantity and values are names of output data.
structural_model_name (str, optional) – structural model name.
cfg (dict) – config.
-
static
set_elems(structural_model, gcs_rotation=True)¶ Initialize elems and set variables. :param structural_model: structural model data in i-SAS format. :type structural_model: dict :param gcs_rotation: use gcs rotation or not. :type gcs_rotation: bool
- Returns
list of elem(solid_1, shell_iqs4 and so on) instance.
- Return type
elems (list[elem])
-
static
calc_node_dof(elems, node_num, node_id)¶ Calculate node degrees of freedom (dof) per node and element. :param elems: list of elem(solid_1, shell_iqs4 and so on) instance. :type elems: list[elem] :param node_num: the number of node. :type node_num: int :param node_id: the list of node_id :type node_id: list[int]
- Returns
node degrees of freedom (dof) per node. 1-D array of shape
(node_num)node_dof_elem (ndarray[np.int64]): node degrees of freedom (dof) per element.1-D array of shape
(elem_num)- Return type
node_dof (ndarray[np.int64])
-
static
calc_node_idx2dof_idx(node_dof)¶ Make a dictionary that maps the index after reordering the node to an index that has a dof value of the node. :param node_dof: node degrees of freedom (dof) per node. 1-D array of shape
(node_num):type node_dof: ndarray[np.int64]- Returns
- a dictionary that maps the index after reordering the node to an
index that has a dof value of the node.
- Return type
node_idx2dof_idx (dict[int, list[int]])
-
merge_matrix(matrices, type_row, type_col, dim=None, valid_idx=None)¶ Merge each element’s matrices according to type_name. :param matrices: list of matrix. matrices[i] contains the i-th element matrix. :type matrices: list[ndarray] :param type_row: type_name of row. Type is one of ‘node_dof’, ‘node_dim’, ‘elem_dim’. :type type_row: str :param type_col: type_name of colomn. Type is one of ‘node_dof’, ‘node_dim’, ‘elem_dim’. :type type_col: str :param dim: the dimension of each element or node.
This is used if the type_name contains ‘node_dim’ or ‘elem_dim’.
- Parameters
valid_idx (list[int]) – the index of matrices that are used to merge.
- Returns
merged matrix. Row and column lengths are calculated based on type_name.
- Return type
merged_matrix (csr_matrix)
-
get_rc_num(type_name, dim=None)¶ Get row or colomn lengths of merged matrix according to type_name. :param type_name: type_name. Type is one of ‘node_dof’, ‘node_dim’, and ‘elem_dim’. :type type_name: str :param dim: the dimension of each element or node.
This is used if the type_name contains ‘node_dim’ or ‘elem_dim’.
- Returns
row or colomn lengths of merged matrix.
- Return type
rc_num (int)
-
get_el_num(type_row, type_col, dim=None)¶ Get the number of elements in the matrix for each element :param type_row: type_name of row. Type is one of ‘node_dof’, ‘node_dim’, ‘elem_dim’. :type type_row: str :param type_col: type_name of colomn. Type is one of ‘node_dof’, ‘node_dim’, ‘elem_dim’. :type type_col: str :param dim: the dimension of each element or node.
This is used if the type_name contains ‘node_dim’ or ‘elem_dim’.
- Returns
the number of elements in the matrix for each element.
- Return type
el_num (ndarray)
-
get_rc(type_name, i, idx=None, dim=3)¶ Get the index of row or colomn of self.elements[i]. :param type_name: type_name. Type is one of ‘node_dof’, ‘node_dim’, and ‘elem_dim’. :type type_name: str :param i: index of self.elements. :type i: int :param idx: index when type_name is ‘node_dof’ :type idx: ndarray[int] :param dim: the dimension of each element or node.
This is used if the type_name contains ‘node_dim’ or ‘elem_dim’.
- Returns
the index of row or colomn of self.elements[i].
- Return type
rc (ndarray[int])
-
merge_vector(matrices, dim, valid_idx=None)¶ Merge each element’s matrices according to type_name. :param matrices: list of matrix. matrices[i] contains the i-th element matrix. :type matrices: list[ndarray] :param dim: the dimension of each element or node. :type dim: int :param valid_idx: the index of matrices that are used to merge. :type valid_idx: list[int]
- Returns
merged vector. 2-D array of shape
(node_num*dim, 1)- Return type
merged_vector (csr_matrix)
-
load_structural_model(structural_model)¶ Load structural model.
-
check_structural_model(structural_model)¶ Check that the required input is included.
-
set_bound()¶ Set the element’s constraints to the instance.
-
calc_d_matrix_elem()¶ Calculate the Dmatrix of each element.
-
calc_postprocess_matrix(result_fields=None, update=True)¶ Compute the matrix needed to obtain the result. :param result_fields: the field of results wanted to be obtained. :type result_fields: set :param update: True if self.postprocess_matrix is needed to update, False otherwise. :type update: bool
-
postprocess(u_vector, result_fields=None)¶ Compute the result. :param result_fields: the field of results wanted to be obtained. :type result_fields: set
-
set_coord_sys()¶ To create the output_metadata, set the appropriate coordinate system corresponding to the key in output_names.
-
make_structural_model_connections()¶ Make analysis_structural_model_connections.
-
load_input_info(output_metadata, structural_model_connections)¶ Load information about the data to process the data :param output_metadata: output metadata. :type output_metadata: pd.DataFrame :param structural_model_connections: connections between data and structural model. :type structural_model_connections: dict
-
get_data_name_dim()¶ Createa a dict in which the data_name is a key and the dimension is value. :returns: a dict in which the data_name is a key and the dimension is value. :rtype: data_name_dim (dict)
-
get_data_name_data_type()¶ Createa a dict in which the data_name is a key and the data type. :returns: a dict in which the data_name is a key and the data type. :rtype: data_name_data_type (dict)
-
load_info(data_name_dim, data_name_data_type, output_metadata, structural_model_connections)¶ Load information about input data. :param data_name_dim: a dict in which the data_name is a key and the dimension is value. :type data_name_dim: dict :param data_name_data_type: a dict in which the data_name is a key and the data type. :type data_name_data_type: dict :param output_metadata: output metadata. :type output_metadata: pd.DataFrame :param structural_model_connections: connections between data and structural model. :type structural_model_connections: dict
- Returns
a dict in which the data_name is a key and the information about the data.
- Return type
data_name_data_info (dict)
-
load_output_info(model_connections, data_type)¶ Load output information. :param model_connections: connections between data and structural model. :type model_connections: pd.DataFrame :param data_type: data type. :type data_type: str
-
check_connection(self_connection, connection, data_type)¶ Test whether their contents are equal when given analysis_structural_model_connection for different dimensions of the same data type. :param self_connection: analysis_structural_model_connection already set. :type self_connection: pd.DataFrame :param connection: analysis_structural_model_connection given. :type connection: pd.DataFrame :param data_type: data type. :type data_type: str
-
solve(k_matrix, f_vector)¶ Solving the linear equation of Ku = F to find the value of u vector. :param k_matrix: Kmatrix or iKmatrix. 2-D array of shape
(total_node_dof, total_node_dof):type k_matrix: csr_matrix :param f_vector: force vector or iFvector. 2-D array of shape(total_node_dof, 1):type f_vector: csc_matrix- Returns
- displacement of each degree of freedom of nodes.
2-D array of shape
(total_node_dof, 1)
f_vector (ndarray): force vector or iFvector. 2-D array of shape
(total_node_dof, 1)- Return type
u_vector (ndarray)
-
arrange_data(data)¶ Arrange the data along the time resolution. :param data: data calculated before :type data: dict
- Returns
the data along the time resolution start_time_stamps (list[int]): start time stamps used in data end_time_stamps (list[int]): end time stamps used in data
- Return type
time_data (dict)
-
set_output_transformer()¶
-
transform_output(output)¶ transform coordinate system of output :param output: The value of output where the global coordinate system is expected is also the
value of the local coordinate system
- Returns
transformed result.
- Return type
output (dict)
-
4.2. fem¶
-
class
ifem.fem.Fem(input_names, output_names, structural_model_name, cfg)¶ Bases:
ifem.base.Base-
ANALYSIS_TYPE= 'FEM'¶
-
__init__(input_names, output_names, structural_model_name, cfg)¶ constructor
- Parameters
input_names (dict) – dict whose keys are names of input quantity and values are names of input data.
output_names (dict) – dict whose keys are names of output quantity and values are names of output data.
structural_model_name (str, optional) – structural model name.
cfg (dict) – config.
-
calc_k_matrix()¶ Calculate the Kmatrix of each element and merge them.
-
calc_k_matrix_elem()¶ Calculate the Kmatrix of each element.
-
merge_k_matrix()¶ Merge the Kmatrices of each element.
-
calc_f_coef()¶ Calculate the coefficients on the surface force and the coefficients on the volume force of each element and merge them.
-
calc_f_coef_elem()¶ Calculate the coefficients on the surface force and the coefficients on the volume force of each element.
-
merge_f_coef()¶ Merge the coefficients on the surface force and the coefficients on the volume force in each element.
-
calc_f_vector(data)¶ Compute a force vector with surface loads, body loads, and point loads. :param data: information about the load at a specific time. :type data: dict
- Returns
force vector. 2-D array of shape
(total_node_dof, 1)- Return type
f_vector (csc_matrix)
-
calc_ft_vector(data)¶ Compute a force vector with surface loads. :param data: information about the load at a specific time. :type data: dict
- Returns
force vector of surface loads. 2-D array of shape
(total_node_dof, 1)- Return type
ft_vector (csc_matrix)
-
calc_fg_vector(data)¶ Compute a force vector with body loads. :param data: information about the load at a specific time. :type data: dict
- Returns
force vector of body loads. 2-D array of shape
(total_node_dof, 1)- Return type
fg_vector (csc_matrix)
-
calc_fp_vector(data)¶ Compute a force vector with point loads. :param data: information about the load at a specific time. :type data: dict
- Returns
force vector of point loads. 2-D array of shape
(total_node_dof, 1)- Return type
fp_vector (csc_matrix)
-
calc_force_t(data)¶ Compute a force vector with surface loads for each surface on elems. :param data: information about the load at a specific time. :type data: dict
- Returns
- a force vector with surface loads for each surface on elems.
each force vector is 2-D array of shape
(total_elems * 3, 1)
- Return type
force_t (dict)
-
calc_force_g(data)¶ Compute a force vector with body loads on the elements. :returns: a force with body loads on the elements. 2-D array of shape
(total_elems * 3, 1):rtype: force_g (csc_matrix)
-
set_model(output_metadata, sensors, structural_models, structural_model_connections, streaming)¶ set model and calculate intermediate values
- Parameters
output_metadata (pd.DataFrame) – output metadata.
sensors (dict) – sensors.
structural_models (dict) – structural models.
structural_model_connections (dict) – connections between data and structural model.
streaming (bool) – if true, run as structural_analysis.
-
__call__(data)¶ Calculate various values based on the data. :param data: data calculated before :type data: dict
- Returns
calculated result. used_timestamp (dict):
used timestamp for each input data. Dict has two keys, ‘s’ as strating timestamp and ‘e’ as end time stamp, and the value is 1d-array of the timestamp used to caclulate output, whose length is the same as the length of output.
- Return type
results (dict)
-
4.3. ifem¶
-
class
ifem.ifem.IFem(input_names, output_names, structural_model_name, cfg)¶ Bases:
ifem.base.Base-
ANALYSIS_TYPE= 'iFEM'¶
-
__init__(input_names, output_names, structural_model_name, cfg)¶ constructor
- Parameters
input_names (dict) – dict whose keys are names of input quantity and values are names of input data.
output_names (dict) – dict whose keys are names of output quantity and values are names of output data.
structural_model_name (str, optional) – structural model name.
cfg (dict) – config.
-
calc_i_k_matrix()¶ Calculate the iKmatrix of each element and merge them.
-
calc_i_k_matrix_elem()¶ Calculate the iKmatrix of each element.
-
merge_i_k_matrix()¶ Merge the iKmatrices of each element.
-
calc_i_f_coef()¶ Calculate the iFcoef of each element and merge them.
-
calc_i_f_coef_elem()¶ Calculate the iFcoef of each element.
-
merge_i_f_coef()¶ Merge the the iFcoef of each element.
-
calc_i_f_vector(data)¶ Compute iFvector. :param data: information about the strain at a specific time. :type data: dict
- Returns
iFvector. 2-D array of shape
(total_node_dof, 1)- Return type
i_f_vector (csr_matrix)
-
calc_strain(data)¶ Compute strain. :param data: information about the strain at a specific time. :type data: dict
- Returns
strain values on elems. 2-D array of shape
(total_elems * 6, 1)- Return type
strain (csc_matrix)
-
calc_strain_sep(data)¶ Compute strain. :param data: information about the strain at a specific time. :type data: dict
- Returns
separated strain values on elems. 1-D array of shape
(total_elems * 3)strain_sep_k (ndarray): separated strain values on elems. 1-D array of shape(total_elems * 3)strain_sep_g (ndarray): separated strain values on elems. 1-D array of shape(total_elems * 2)- Return type
strain_sep_e (ndarray)
-
load_strain_sep(data, strain_key)¶ Load strain information. :param data: information about the strain at a specific time. :type data: dict :param strain_key: the name of the key of the strain. :type strain_key: str
- Returns
strain values on elems. 2-D array of shape
(6, total_elems)r3 (ndarray): r3 values of elems. 2-D array of shape(total_elems)- Return type
strain_sep (ndarray)
-
set_model(output_metadata, sensors, structural_models, structural_model_connections, streaming)¶ set model and calculate intermediate values
- Parameters
output_metadata (pd.DataFrame) – output metadata.
sensors (dict) – sensors.
structural_models (dict) – structural models.
structural_model_connections (dict) – connections between data and structural model.
streaming (bool) – if true, run as structural_analysis.
-
set_input_transformer(data_type, elem_ids, coord_sys)¶ Set coordinate system transformer of input strain :param data_type: data type. :type data_type: str :param elem_ids: id of elements. :type elem_ids: list :param coord_sys: coordinate system. :type coord_sys: str
-
transform_input(data)¶
-
__call__(data)¶ Calculate various values based on the data. :param data: data calculated before :type data: dict
- Returns
calculated result. used_timestamp (dict):
used timestamp for each input data. Dict has two keys, ‘s’ as strating timestamp and ‘e’ as end time stamp, and the value is 1d-array of the timestamp used to caclulate output, whose length is the same as the length of output.
- Return type
results (dict)
-
4.4. interface¶
-
class
ifem.interface.Interface(instance_name, input_names, output_names, structural_model_name=None, **kwargs)¶ Bases:
objectinterface class of analysis solver
-
package_name= None¶
-
structural_model_required= False¶
-
__init__(instance_name, input_names, output_names, structural_model_name=None, **kwargs)¶ initialization of interface class of analysis solver
- Parameters
instance_name (str) – instance name.
input_names (dict) – dict whose keys are names of input quantity and values are names of input data.
output_names (dict) – dict whose keys are names of output quantity and values are names of output data.
structural_model_name (str, optional) – structural model name.
**kwargs – Arbitrary keyword arguments.
Example
>>> input_names = {'strain': ['rosette_strain_x', 'rosette_strain_y', 'rosette_strain_xy']} >>> output_names = {'displacement': ['analysis_displacement_z'], 'stress':['analysis_stress_x']} >>> interface = Interface(input_names, output_names, 'beam')
-
abstract
set_project(project_name)¶ - Parameters
project_name (str) – project name.
-
set_model(output_metadata, sensors, structural_models, structural_model_connections, streaming=False)¶ set structural model
- Parameters
output_metadata (pd.DataFrame) – output metadata.
sensors (dict) – sensors.
structural_models (dict) – structural models.
structural_model_connections (dict) – connections between data and structural model.
streaming (bool, optional) – if true, run as structural_analysis.
- Returns
containing followings
dict: information on instance of this model. pandas.DataFrame: output metadata of this model. dict: connections between output data of this model and structural model.
- Return type
tuple
-
__call__(input_data)¶ calculate quantity of state
- Parameters
input_data (dict) – data calculated before
- Returns
- containing:
dict: analysis data. pandas.DataFrame: timestamp used. The length is the same as analysis data.
- Return type
tuple
-
exit()¶ exit solver
-
4.5. interface_fem¶
-
class
ifem.interface_fem.InterfaceFem(instance_name, input_names, output_names, structural_model_name=None, **kwargs)¶ Bases:
ifem.interface.Interface-
package_name= 'fem'¶
-
__init__(instance_name, input_names, output_names, structural_model_name=None, **kwargs)¶ initialization of interface class of analysis solver
- Parameters
instance_name (str) – instance name.
input_names (dict) – dict whose keys are names of input quantity and values are names of input data.
output_names (dict) – dict whose keys are names of output quantity and values are names of output data.
structural_model_name (str, optional) – structural model name.
**kwargs – Arbitrary keyword arguments.
Example
>>> input_names = {'strain': ['rosette_strain_x', 'rosette_strain_y', 'rosette_strain_xy']} >>> output_names = {'displacement': ['analysis_displacement_z'], 'stress':['analysis_stress_x']} >>> interface = Interface(input_names, output_names, 'beam')
-
set_project(project_name)¶ - Parameters
project_name (str) – project name.
-
4.6. interface_ifem¶
-
class
ifem.interface_ifem.InterfaceIFem(instance_name, input_names, output_names, structural_model_name=None, **kwargs)¶ Bases:
ifem.interface.Interface-
package_name= 'ifem'¶
-
__init__(instance_name, input_names, output_names, structural_model_name=None, **kwargs)¶ initialization of interface class of analysis solver
- Parameters
instance_name (str) – instance name.
input_names (dict) – dict whose keys are names of input quantity and values are names of input data.
output_names (dict) – dict whose keys are names of output quantity and values are names of output data.
structural_model_name (str, optional) – structural model name.
**kwargs – Arbitrary keyword arguments.
Example
>>> input_names = {'strain': ['rosette_strain_x', 'rosette_strain_y', 'rosette_strain_xy']} >>> output_names = {'displacement': ['analysis_displacement_z'], 'stress':['analysis_stress_x']} >>> interface = Interface(input_names, output_names, 'beam')
-
set_project(project_name)¶ - Parameters
project_name (str) – project name.
-