structuralcodes 0.1.1__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of structuralcodes might be problematic. Click here for more details.
- structuralcodes/__init__.py +1 -1
- structuralcodes/codes/ec2_2004/__init__.py +43 -11
- structuralcodes/codes/ec2_2004/_concrete_creep_and_shrinkage.py +529 -0
- structuralcodes/codes/mc2010/_concrete_creep_and_shrinkage.py +105 -73
- structuralcodes/core/_section_results.py +5 -19
- structuralcodes/core/base.py +42 -15
- structuralcodes/geometry/__init__.py +10 -1
- structuralcodes/geometry/_circular.py +81 -0
- structuralcodes/geometry/_geometry.py +4 -2
- structuralcodes/geometry/_rectangular.py +83 -0
- structuralcodes/geometry/_reinforcement.py +132 -5
- structuralcodes/materials/constitutive_laws/__init__.py +84 -0
- structuralcodes/materials/constitutive_laws/_bilinearcompression.py +183 -0
- structuralcodes/materials/constitutive_laws/_elastic.py +133 -0
- structuralcodes/materials/constitutive_laws/_elasticplastic.py +227 -0
- structuralcodes/materials/constitutive_laws/_parabolarectangle.py +255 -0
- structuralcodes/materials/constitutive_laws/_popovics.py +133 -0
- structuralcodes/materials/constitutive_laws/_sargin.py +115 -0
- structuralcodes/materials/constitutive_laws/_userdefined.py +262 -0
- structuralcodes/sections/__init__.py +2 -0
- structuralcodes/sections/_generic.py +174 -27
- structuralcodes/sections/_rc_utils.py +114 -0
- structuralcodes/sections/section_integrators/_fiber_integrator.py +204 -110
- structuralcodes/sections/section_integrators/_marin_integrator.py +273 -102
- structuralcodes/sections/section_integrators/_section_integrator.py +28 -4
- {structuralcodes-0.1.1.dist-info → structuralcodes-0.3.0.dist-info}/METADATA +2 -2
- {structuralcodes-0.1.1.dist-info → structuralcodes-0.3.0.dist-info}/RECORD +28 -18
- {structuralcodes-0.1.1.dist-info → structuralcodes-0.3.0.dist-info}/WHEEL +1 -1
- structuralcodes/codes/ec2_2004/annex_b_shrink_and_creep.py +0 -257
- structuralcodes/materials/constitutive_laws.py +0 -981
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Sargin constitutive law."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations # To have clean hints of ArrayLike in docs
|
|
4
|
+
|
|
5
|
+
import typing as t
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
from numpy.typing import ArrayLike
|
|
9
|
+
|
|
10
|
+
from ...core.base import ConstitutiveLaw
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Sargin(ConstitutiveLaw):
|
|
14
|
+
"""Class for Sargin constitutive law.
|
|
15
|
+
|
|
16
|
+
The stresses and strains are assumed negative in compression and positive
|
|
17
|
+
in tension.
|
|
18
|
+
|
|
19
|
+
References:
|
|
20
|
+
Sargin, M. (1971), "Stress-strain relationship for concrete and the
|
|
21
|
+
analysis of structural concrete section, Study No. 4,
|
|
22
|
+
Solid Mechanics Division, University of Waterloo, Ontario, Canada
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__materials__: t.Tuple[str] = ('concrete',)
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
fc: float,
|
|
30
|
+
eps_c1: float = -0.0023,
|
|
31
|
+
eps_cu1: float = -0.0035,
|
|
32
|
+
k: float = 2.04,
|
|
33
|
+
name: t.Optional[str] = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
"""Initialize a Sargin Material.
|
|
36
|
+
|
|
37
|
+
Arguments:
|
|
38
|
+
fc (float): The strength of concrete in compression
|
|
39
|
+
|
|
40
|
+
Keyword Arguments:
|
|
41
|
+
eps_c1 (float): Peak strain of concrete in compression. Default
|
|
42
|
+
value = -0.0023.
|
|
43
|
+
eps_u (float): Ultimate strain of concrete in compression. Default
|
|
44
|
+
value = -0.0035.
|
|
45
|
+
k (float): Plasticity number. Default value = 2.04.
|
|
46
|
+
name (str): A name for the constitutive law.
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
ValueError: If k is less or equal to 0.
|
|
50
|
+
|
|
51
|
+
Note:
|
|
52
|
+
If positive values are input for fc, eps_c1 and eps_cu1 are input,
|
|
53
|
+
they will be assumed negative.
|
|
54
|
+
"""
|
|
55
|
+
name = name if name is not None else 'SarginLaw'
|
|
56
|
+
super().__init__(name=name)
|
|
57
|
+
self._fc = -abs(fc)
|
|
58
|
+
self._eps_c1 = -abs(eps_c1)
|
|
59
|
+
self._eps_cu1 = -abs(eps_cu1)
|
|
60
|
+
self._k = k
|
|
61
|
+
|
|
62
|
+
def get_stress(
|
|
63
|
+
self, eps: t.Union[float, ArrayLike]
|
|
64
|
+
) -> t.Union[float, ArrayLike]:
|
|
65
|
+
"""Return the stress given the strain."""
|
|
66
|
+
eps = eps if np.isscalar(eps) else np.atleast_1d(eps)
|
|
67
|
+
# Preprocess eps array in order
|
|
68
|
+
eps = self.preprocess_strains_with_limits(eps=eps)
|
|
69
|
+
# Compute stress
|
|
70
|
+
# Polynomial branch
|
|
71
|
+
eta = eps / self._eps_c1
|
|
72
|
+
|
|
73
|
+
sig = self._fc * (self._k * eta - eta**2) / (1 + (self._k - 2) * eta)
|
|
74
|
+
|
|
75
|
+
# Elsewhere stress is 0.0
|
|
76
|
+
if np.isscalar(eps):
|
|
77
|
+
if eps < self._eps_cu1 or eps > 0:
|
|
78
|
+
return 0.0
|
|
79
|
+
else:
|
|
80
|
+
sig[eps < self._eps_cu1] = 0.0
|
|
81
|
+
sig[eps > 0] = 0.0
|
|
82
|
+
|
|
83
|
+
return sig
|
|
84
|
+
|
|
85
|
+
def get_tangent(
|
|
86
|
+
self, eps: t.Union[float, ArrayLike]
|
|
87
|
+
) -> t.Union[float, ArrayLike]:
|
|
88
|
+
"""Return the tangent given strain."""
|
|
89
|
+
eps = eps if np.isscalar(eps) else np.atleast_1d(eps)
|
|
90
|
+
# polynomial branch
|
|
91
|
+
eta = eps / self._eps_c1
|
|
92
|
+
|
|
93
|
+
tangent = (
|
|
94
|
+
self._fc
|
|
95
|
+
/ self._eps_c1
|
|
96
|
+
* ((2 - self._k) * eta**2 - 2 * eta + self._k)
|
|
97
|
+
/ (1 + (self._k - 2) * eta) ** 2
|
|
98
|
+
)
|
|
99
|
+
# Elsewhere tangent is zero
|
|
100
|
+
if np.isscalar(eps):
|
|
101
|
+
if eps < self._eps_cu1 or eps > 0:
|
|
102
|
+
return 0
|
|
103
|
+
else:
|
|
104
|
+
tangent[eps < self._eps_cu1] = 0.0
|
|
105
|
+
tangent[eps > 0] = 0.0
|
|
106
|
+
|
|
107
|
+
return tangent
|
|
108
|
+
|
|
109
|
+
def get_ultimate_strain(
|
|
110
|
+
self, yielding: bool = False
|
|
111
|
+
) -> t.Tuple[float, float]:
|
|
112
|
+
"""Return the ultimate strain (negative and positive)."""
|
|
113
|
+
if yielding:
|
|
114
|
+
return (self._eps_c1, 100)
|
|
115
|
+
return (self._eps_cu1, 100)
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"""User defined constitutive law."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations # To have clean hints of ArrayLike in docs
|
|
4
|
+
|
|
5
|
+
import typing as t
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
from numpy.typing import ArrayLike
|
|
9
|
+
|
|
10
|
+
from ...core.base import ConstitutiveLaw
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class UserDefined(ConstitutiveLaw):
|
|
14
|
+
"""Class for a user defined constitutive law.
|
|
15
|
+
|
|
16
|
+
The curve is defined with positive and optionally negative values. After
|
|
17
|
+
the last value, the stress can go to zero to simulate failure (default), or
|
|
18
|
+
be maintained constante, or the last tanget or secant values may be
|
|
19
|
+
maintained indefinetely. The flag parameter controls this behavior.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
__materials__: t.Tuple[str] = ('concrete', 'steel', 'rebars')
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
x: ArrayLike,
|
|
27
|
+
y: ArrayLike,
|
|
28
|
+
name: t.Optional[str] = None,
|
|
29
|
+
flag: int = 0,
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Initialize a UserDefined constitutive law.
|
|
32
|
+
|
|
33
|
+
Arguments:
|
|
34
|
+
x (ArrayLike): Data for strains.
|
|
35
|
+
y (ArrayLike): Data for stresses. Must be of same length as x.
|
|
36
|
+
|
|
37
|
+
Keyword Arguments:
|
|
38
|
+
name (Optional, str): A name for the constitutive law.
|
|
39
|
+
flag (Optional): A flag specifying the behavior after the last
|
|
40
|
+
point. Admissible values: 0 (default): stress drops to zero
|
|
41
|
+
after ultimate strain, 1: stress is mantained constant, 2:
|
|
42
|
+
last tangent is used, 3: last secant is used.
|
|
43
|
+
"""
|
|
44
|
+
name = name if name is not None else 'UserDefinedLaw'
|
|
45
|
+
super().__init__(name=name)
|
|
46
|
+
x = np.atleast_1d(np.asarray(x))
|
|
47
|
+
y = np.atleast_1d(np.asarray(y))
|
|
48
|
+
if len(x) != len(y):
|
|
49
|
+
raise ValueError('The two arrays should have the same length')
|
|
50
|
+
if not np.any(x < 0):
|
|
51
|
+
# User provided only positive part, reflect in negative
|
|
52
|
+
self._x = np.concatenate((-np.flip(x)[:-1], x))
|
|
53
|
+
self._y = np.concatenate((-np.flip(y)[:-1], y))
|
|
54
|
+
else:
|
|
55
|
+
# User gave both positive and negative parts
|
|
56
|
+
self._x = x
|
|
57
|
+
self._y = y
|
|
58
|
+
# Define what happens after last strain
|
|
59
|
+
if flag not in (0, 1, 2, 3):
|
|
60
|
+
raise ValueError('Flag can assume values 0, 1, 2 or 3.')
|
|
61
|
+
self._ultimate_strain_p = self._x[-1]
|
|
62
|
+
self._ultimate_strain_n = self._x[0]
|
|
63
|
+
if flag in (1, 2, 3):
|
|
64
|
+
x = np.insert(self._x, 0, self._x[0] * 100)
|
|
65
|
+
x = np.append(x, self._x[-1] * 100)
|
|
66
|
+
if flag == 1:
|
|
67
|
+
y = np.insert(self._y, 0, self._y[0])
|
|
68
|
+
y = np.append(y, self._y[-1])
|
|
69
|
+
elif flag == 2:
|
|
70
|
+
tangent_p = (self._y[-1] - self._y[-2]) / (
|
|
71
|
+
self._x[-1] - self._x[-2]
|
|
72
|
+
)
|
|
73
|
+
tangent_n = (self._y[1] - self._y[0]) / (
|
|
74
|
+
self._x[1] - self._x[0]
|
|
75
|
+
)
|
|
76
|
+
y = np.insert(
|
|
77
|
+
self._y, 0, (x[0] - x[1]) * tangent_n + self._y[0]
|
|
78
|
+
)
|
|
79
|
+
y = np.append(y, (x[-1] - x[-2]) * tangent_p + self._y[-1])
|
|
80
|
+
elif flag == 3:
|
|
81
|
+
secant_p = self._y[-1] / self._x[-1]
|
|
82
|
+
secant_n = self._y[0] / self._x[0]
|
|
83
|
+
y = np.insert(
|
|
84
|
+
self._y, 0, (x[0] - x[1]) * secant_n + self._y[0]
|
|
85
|
+
)
|
|
86
|
+
y = np.append(y, (x[-1] - x[-2]) * secant_p + self._y[-1])
|
|
87
|
+
self._x = x
|
|
88
|
+
self._y = y
|
|
89
|
+
|
|
90
|
+
# Compute slope of each segment
|
|
91
|
+
self._slopes = np.diff(self._y) / np.diff(self._x)
|
|
92
|
+
|
|
93
|
+
def get_stress(
|
|
94
|
+
self, eps: t.Union[float, ArrayLike]
|
|
95
|
+
) -> t.Union[float, ArrayLike]:
|
|
96
|
+
"""Return the stress given strain."""
|
|
97
|
+
eps = eps if np.isscalar(eps) else np.atleast_1d(eps)
|
|
98
|
+
# Preprocess eps array in order
|
|
99
|
+
eps = self.preprocess_strains_with_limits(eps=eps)
|
|
100
|
+
# Compute stress
|
|
101
|
+
return np.interp(eps, self._x, self._y, left=0, right=0)
|
|
102
|
+
|
|
103
|
+
def get_tangent(
|
|
104
|
+
self, eps: t.Union[float, ArrayLike]
|
|
105
|
+
) -> t.Union[float, ArrayLike]:
|
|
106
|
+
"""Return the tangent given strain."""
|
|
107
|
+
eps = eps if np.isscalar(eps) else np.atleast_1d(eps)
|
|
108
|
+
|
|
109
|
+
# Find the segment index for each x value
|
|
110
|
+
indices = np.searchsorted(self._x, eps) - 1
|
|
111
|
+
|
|
112
|
+
# Check that indices are within vlaid range
|
|
113
|
+
indices = np.clip(indices, 0, len(self._slopes) - 1)
|
|
114
|
+
|
|
115
|
+
# Get the corresponding slopes
|
|
116
|
+
tangent = self._slopes[indices]
|
|
117
|
+
|
|
118
|
+
# Elsewhere tangent is zero
|
|
119
|
+
if np.isscalar(eps):
|
|
120
|
+
if eps < self._x[0] or eps > self._x[-1]:
|
|
121
|
+
tangent = 0
|
|
122
|
+
else:
|
|
123
|
+
tangent[eps < self._x[0]] = 0.0
|
|
124
|
+
tangent[eps > self._x[-1]] = 0.0
|
|
125
|
+
|
|
126
|
+
return tangent
|
|
127
|
+
|
|
128
|
+
def __marin__(
|
|
129
|
+
self, strain: t.Tuple[float, float]
|
|
130
|
+
) -> t.Tuple[t.List[t.Tuple], t.List[t.Tuple]]:
|
|
131
|
+
"""Returns coefficients and strain limits for Marin integration in a
|
|
132
|
+
simply formatted way.
|
|
133
|
+
|
|
134
|
+
Arguments:
|
|
135
|
+
strain (float, float): Tuple defining the strain profile: eps =
|
|
136
|
+
strain[0] + strain[1]*y.
|
|
137
|
+
|
|
138
|
+
Example:
|
|
139
|
+
[(0, -0.002), (-0.002, -0.003)]
|
|
140
|
+
[(a0, a1, a2), (a0)]
|
|
141
|
+
"""
|
|
142
|
+
strains = []
|
|
143
|
+
coeff = []
|
|
144
|
+
if strain[1] == 0:
|
|
145
|
+
# Uniform strain equal to strain[0]
|
|
146
|
+
# understand in which branch are we
|
|
147
|
+
strain[0] = self.preprocess_strains_with_limits(strain[0])
|
|
148
|
+
found = False
|
|
149
|
+
for i in range(len(self._x) - 1):
|
|
150
|
+
if self._x[i] <= strain[0] and self._x[i + 1] >= strain[0]:
|
|
151
|
+
strains = None
|
|
152
|
+
stiffness = (self._y[i + 1] - self._y[i]) / (
|
|
153
|
+
self._x[i + 1] - self._x[i]
|
|
154
|
+
)
|
|
155
|
+
a0 = stiffness * (strain[0] - self._x[i]) + self._y[i]
|
|
156
|
+
a1 = stiffness * strain[1]
|
|
157
|
+
coeff.append((a0, a1))
|
|
158
|
+
found = True
|
|
159
|
+
break
|
|
160
|
+
if not found:
|
|
161
|
+
strains = None
|
|
162
|
+
coeff.append((0.0,))
|
|
163
|
+
else:
|
|
164
|
+
for i in range(len(self._x) - 1):
|
|
165
|
+
# For each branch of the linear piecewise function
|
|
166
|
+
stiffness = (self._y[i + 1] - self._y[i]) / (
|
|
167
|
+
self._x[i + 1] - self._x[i]
|
|
168
|
+
)
|
|
169
|
+
strains.append((self._x[i], self._x[i + 1]))
|
|
170
|
+
a0 = stiffness * (strain[0] - self._x[i]) + self._y[i]
|
|
171
|
+
a1 = stiffness * strain[1]
|
|
172
|
+
coeff.append((a0, a1))
|
|
173
|
+
|
|
174
|
+
return strains, coeff
|
|
175
|
+
|
|
176
|
+
def __marin_tangent__(
|
|
177
|
+
self, strain: t.Tuple[float, float]
|
|
178
|
+
) -> t.Tuple[t.List[t.Tuple], t.List[t.Tuple]]:
|
|
179
|
+
"""Returns coefficients and strain limits for Marin integration of
|
|
180
|
+
tangent in a simply formatted way.
|
|
181
|
+
|
|
182
|
+
Arguments:
|
|
183
|
+
strain (float, float): Tuple defining the strain profile: eps =
|
|
184
|
+
strain[0] + strain[1]*y.
|
|
185
|
+
|
|
186
|
+
Example:
|
|
187
|
+
[(0, -0.002), (-0.002, -0.003)]
|
|
188
|
+
[(a0, a1, a2), (a0)]
|
|
189
|
+
"""
|
|
190
|
+
strains = []
|
|
191
|
+
coeff = []
|
|
192
|
+
if strain[1] == 0:
|
|
193
|
+
# Uniform strain equal to strain[0]
|
|
194
|
+
# understand in which branch are we
|
|
195
|
+
strain[0] = self.preprocess_strains_with_limits(strain[0])
|
|
196
|
+
found = False
|
|
197
|
+
for i in range(len(self._x) - 1):
|
|
198
|
+
if self._x[i] <= strain[0] and self._x[i + 1] >= strain[0]:
|
|
199
|
+
strains = None
|
|
200
|
+
stiffness = (self._y[i + 1] - self._y[i]) / (
|
|
201
|
+
self._x[i + 1] - self._x[i]
|
|
202
|
+
)
|
|
203
|
+
coeff.append((stiffness,))
|
|
204
|
+
found = True
|
|
205
|
+
break
|
|
206
|
+
if not found:
|
|
207
|
+
strains = None
|
|
208
|
+
coeff.append((0.0,))
|
|
209
|
+
else:
|
|
210
|
+
for i in range(len(self._x) - 1):
|
|
211
|
+
# For each branch of the linear piecewise function
|
|
212
|
+
stiffness = (self._y[i + 1] - self._y[i]) / (
|
|
213
|
+
self._x[i + 1] - self._x[i]
|
|
214
|
+
)
|
|
215
|
+
strains.append((self._x[i], self._x[i + 1]))
|
|
216
|
+
coeff.append((stiffness,))
|
|
217
|
+
|
|
218
|
+
return strains, coeff
|
|
219
|
+
|
|
220
|
+
def get_ultimate_strain(self, **kwargs) -> t.Tuple[float, float]:
|
|
221
|
+
"""Return the ultimate strain (negative and positive)."""
|
|
222
|
+
del kwargs
|
|
223
|
+
return (self._ultimate_strain_n, self._ultimate_strain_p)
|
|
224
|
+
|
|
225
|
+
def set_ultimate_strain(
|
|
226
|
+
self, eps_su=t.Union[float, t.Tuple[float, float]]
|
|
227
|
+
) -> None:
|
|
228
|
+
"""Set ultimate strains for Elastic Material if needed.
|
|
229
|
+
|
|
230
|
+
Arguments:
|
|
231
|
+
eps_su (float or (float, float)): Defining ultimate strain. If a
|
|
232
|
+
single value is provided the same is adopted for both negative
|
|
233
|
+
and positive strains. If a tuple is provided, it should be
|
|
234
|
+
given as (negative, positive).
|
|
235
|
+
"""
|
|
236
|
+
if isinstance(eps_su, float):
|
|
237
|
+
self._ultimate_strain_p = abs(eps_su)
|
|
238
|
+
self._ultimate_strain_n = -abs(eps_su)
|
|
239
|
+
elif isinstance(eps_su, tuple):
|
|
240
|
+
if len(eps_su) < 2:
|
|
241
|
+
raise ValueError(
|
|
242
|
+
'Two values need to be provided when setting the tuple'
|
|
243
|
+
)
|
|
244
|
+
eps_su_n = eps_su[0]
|
|
245
|
+
eps_su_p = eps_su[1]
|
|
246
|
+
if eps_su_p < eps_su_n:
|
|
247
|
+
eps_su_p, eps_su_n = eps_su_n, eps_su_p
|
|
248
|
+
if eps_su_p < 0:
|
|
249
|
+
raise ValueError(
|
|
250
|
+
'Positive ultimate strain should be non-negative'
|
|
251
|
+
)
|
|
252
|
+
if eps_su_n > 0:
|
|
253
|
+
raise ValueError(
|
|
254
|
+
'Negative utimate strain should be non-positive'
|
|
255
|
+
)
|
|
256
|
+
self._ultimate_strain_p = eps_su_p
|
|
257
|
+
self._ultimate_strain_n = eps_su_n
|
|
258
|
+
else:
|
|
259
|
+
raise ValueError(
|
|
260
|
+
'set_ultimate_strain requires a single value or a tuple \
|
|
261
|
+
with two values'
|
|
262
|
+
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Main entry point for sections."""
|
|
2
2
|
|
|
3
3
|
from ._generic import GenericSection, GenericSectionCalculator
|
|
4
|
+
from ._rc_utils import calculate_elastic_cracked_properties
|
|
4
5
|
from .section_integrators import (
|
|
5
6
|
FiberIntegrator,
|
|
6
7
|
MarinIntegrator,
|
|
@@ -17,4 +18,5 @@ __all__ = [
|
|
|
17
18
|
'MarinIntegrator',
|
|
18
19
|
'integrator_factory',
|
|
19
20
|
'marin_integration',
|
|
21
|
+
'calculate_elastic_cracked_properties',
|
|
20
22
|
]
|