Coverage for src/beamme/core/material.py: 100%
29 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 15:20 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 15:20 +0000
1# The MIT License (MIT)
2#
3# Copyright (c) 2018-2026 BeamMe Authors
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to deal
7# in the Software without restriction, including without limitation the rights
8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9# copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in
13# all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21# THE SOFTWARE.
22"""This file implements basic classes to manage materials."""
24import numpy as _np
26from beamme.core.base_mesh_item import BaseMeshItem as _BaseMeshItem
29class Material(_BaseMeshItem):
30 """Base class for all materials."""
32 def __init__(self, **kwargs):
33 super().__init__(**kwargs)
35 def __deepcopy__(self, memo):
36 """When deepcopy is called on a mesh, we do not want the materials to be copied,
37 as this will result in multiple equal materials in the input file."""
38 # Add this object to the memo dictionary.
39 memo[id(self)] = self
41 # Return this object again, as no copy should be created.
42 return self
45class MaterialBeamBase(Material):
46 """Base class for all beam materials."""
48 def __init__(
49 self,
50 radius=None,
51 material_string=None,
52 youngs_modulus=None,
53 nu=0.0,
54 density=0.0,
55 interaction_radius=None,
56 **kwargs,
57 ):
58 """Set the material values that all beams have."""
59 super().__init__(**kwargs)
61 self.radius = radius
62 self.material_string = material_string
63 self.youngs_modulus = youngs_modulus
64 self.nu = nu
65 self.density = density
66 self.interaction_radius = interaction_radius
67 self.area = None
68 self.mom2 = None
69 self.mom3 = None
70 self.polar = None
72 def calc_area_stiffness(self):
73 """Calculate the relevant stiffness terms and the area for the given beam."""
74 area = 4 * self.radius**2 * _np.pi * 0.25
75 mom2 = self.radius**4 * _np.pi * 0.25
76 mom3 = mom2
77 polar = mom2 + mom3
78 return area, mom2, mom3, polar
81class MaterialSolidBase(Material):
82 """Base class for all solid materials."""
84 pass