Structure Gene#
- class sgio.StructureGene(name: str = '', sgdim: int | None = None, smdim: int | None = None, spdim: int | None = None)#
Bases:
objectA finite element level structure gene model in the theory of MSG.
- name#
Name of the SG.
- Type:
str
- sgdim#
Dimension of the SG.
- Type:
int or None
- smdim#
Dimension of the material/structural model.
- Type:
int or None
- spdim#
Dimension of the space containing SG.
- Type:
int or None
- analysis#
Analysis configurations. * 0 - homogenization (default) * 1 - dehomogenization/localization/recover * 2 - failure (SwiftComp only)
- Type:
int
- fn_gmsh_msh#
File name of the Gmsh mesh file.
- Type:
str
- physics#
Physics included in the analysis. * 0 - elastic (default) * 1 - thermoelastic * 2 - conduction * 3 - piezoelectric/piezomagnetic * 4 - thermopiezoelectric/thermopiezomagnetic * 5 - piezoelectromagnetic * 6 - thermopiezoelectromagnetic
- Type:
int
- model#
Macroscopic structural model. * 0 - classical (default) * 1 - refined (e.g., generalized Timoshenko) * 2 - Vlasov model (beam only) * 3 - trapeze effect (beam only)
- Type:
int
- geo_correct#
Flag of geometrically corrected shell model.
- Type:
bool
- do_damping#
Flag of damping computation.
- Type:
int
- is_temp_nonuniform#
Flag of uniform temperature.
- Type:
int
- force_flag#
Force flag.
- Type:
int
- steer_flag#
Steer flag.
- Type:
int
- initial_twist#
Initial twist (beam only).
- Type:
float
- initial_curvature#
Initial curvature.
- Type:
list of float
- oblique#
Oblique (beam only).
- Type:
list of float
- lame_params#
Lame parameters for geometrically corrected shell model.
- Type:
list of float
- materials#
Dictionary of materials indexed by material name.
- Type:
dict[str, MaterialModel]
- mocombos#
Dictionary of material-orientation combinations. Maps property_id to (material_name, orientation_angle).
- Type:
dict[int, tuple[str, float]]
- ndim_degen_elem#
Number of degenerate elements.
- Type:
int
- num_slavenodes#
Number of slave nodes.
- Type:
int
- omega#
Omega (see SwiftComp manual).
- Type:
float
- itf_pairs#
Interface pairs.
- Type:
list
- itf_nodes#
Interface nodes.
- Type:
list
- node_elements#
Node elements.
- Type:
list
- add_material(material, name: str | None = None) str#
Add a material to the structure gene.
- Parameters:
material (MaterialModel) – Material object to add.
name (str, optional) – Material name. If not provided, uses material.name attribute.
- Returns:
Material name used as key.
- Return type:
str
- Raises:
ValueError – If material name is empty or None.
- add_material_name_id_pair(name: str, mat_id: int) None#
Add a material name-ID pair.
- Parameters:
name (str) – Material name.
mat_id (int) – Material numeric ID (1-based).
- Raises:
ValueError – If pair already exists with different ID or name already exists.
- copy() StructureGene#
Create a deep copy of the StructureGene.
- Returns:
Deep copy of the current instance.
- Return type:
- findComboByMaterialOrientation(name: str, angle: float) int#
Find material-orientation combination.
Deprecated since version Use:
find_combo_by_material_orientation()instead.- Parameters:
name (str) – Material name.
angle (float) – Orientation angle.
- Returns:
Combination id. 0 if not found.
- Return type:
int
- findMaterialByName(name: str) int#
Find material by name (deprecated - returns pseudo-ID).
Deprecated since version Material: storage now uses name-based indexing. Use get_material(name) to retrieve material directly, or name in sg.materials to check existence.
- Parameters:
name (str) – Material name.
- Returns:
1 if material exists, 0 if not found. Note: Return value is no longer a meaningful ID.
- Return type:
int
- find_combo_by_material_orientation(name: str, angle: float) int | None#
Find material-orientation combination by material name and angle.
- Parameters:
name (str) – Material name.
angle (float) – Orientation angle.
- Returns:
Property/combo id if found, None otherwise.
- Return type:
int or None
- find_material_by_name(name: str) str | None#
Find material by name (returns material name if exists).
- Parameters:
name (str) – Material name.
- Returns:
Material name if found, None otherwise.
- Return type:
str or None
Notes
This method is kept for API compatibility. For direct access, use get_material(name) or check name in sg.materials.
- get_export_material_ids() dict[str, int]#
Generate material name to numeric ID mapping for export.
Uses material_name_id_pairs if available, otherwise generates consecutive IDs based on materials dictionary order.
- Returns:
Mapping from material name to export ID (1-based).
- Return type:
dict[str, int]
Examples
>>> sg = StructureGene() >>> sg.materials['Steel'] = steel_mat >>> sg.material_name_id_pairs = [['Steel', 1]] >>> sg.get_export_material_ids() {'Steel': 1}
- get_material(name: str)#
Get material by name.
- Parameters:
name (str) – Material name.
- Returns:
Material object if found, None otherwise.
- Return type:
MaterialModel or None
- get_material_id_by_name(name: str) int | None#
Get material numeric ID by name from name-ID pairs.
- Parameters:
name (str) – Material name.
- Returns:
Material numeric ID (1-based) if found, None otherwise.
- Return type:
int or None
- get_material_name_by_id(mat_id: int) str | None#
Get material name by numeric ID from name-ID pairs.
- Parameters:
mat_id (int) – Material numeric ID (1-based).
- Returns:
Material name if found, None otherwise.
- Return type:
str or None
- sync_material_name_id_pairs() None#
Synchronize material_name_id_pairs with current materials dictionary.
Creates consecutive 1-based IDs for all materials in self.materials that don’t already have an ID in material_name_id_pairs. Removes pairs for materials that no longer exist.
- translate(v: np.ndarray | list) None#
Translate the mesh.
- Parameters:
v (array_like) – Translation vector.
- Raises:
ValueError – If mesh is not defined.
- property nelems: int#
Number of elements in the mesh.
- Returns:
Number of elements.
- Return type:
int
- Raises:
ValueError – If mesh is not defined.
- property nma_combs: int#
Number of material-orientation combinations.
- Returns:
Number of material-orientation combinations.
- Return type:
int
- property nmates: int#
Number of materials.
- Returns:
Number of materials.
- Return type:
int
- property nnodes: int#
Number of nodes in the mesh.
- Returns:
Number of nodes.
- Return type:
int
- Raises:
ValueError – If mesh is not defined.
- property use_elem_local_orient: int#
Flag of using element local orientation.
- Returns:
1 if using element local orientation, 0 otherwise.
- Return type:
int
- Raises:
ValueError – If mesh is not defined.