-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathconcrete_section.py
1920 lines (1607 loc) · 69.8 KB
/
concrete_section.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import warnings
from math import inf, isinf, nan
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
import matplotlib.patches as mpatches
import numpy as np
import sectionproperties.pre.geometry as sp_geom
from rich.live import Live
from scipy.interpolate import interp1d
from scipy.optimize import brentq
import concreteproperties.results as res
import concreteproperties.utils as utils
from concreteproperties.analysis_section import AnalysisSection
from concreteproperties.material import Concrete
from concreteproperties.post import plotting_context
from concreteproperties.pre import CPGeom, CPGeomConcrete
if TYPE_CHECKING:
import matplotlib
class ConcreteSection:
"""Class for a reinforced concrete section."""
def __init__(
self,
geometry: sp_geom.CompoundGeometry,
):
"""Inits the ConcreteSection class.
:param geometry: *sectionproperties* CompoundGeometry object describing the
reinforced concrete section
"""
self.compound_geometry = geometry
# check overlapping regions
polygons = [sec_geom.geom for sec_geom in self.compound_geometry.geoms]
overlapped_regions = sp_geom.check_geometry_overlaps(polygons)
if overlapped_regions:
warnings.warn(
"The provided geometry contains overlapping regions, results may be incorrect."
)
# sort into concrete and reinforcement (meshed and lumped) geometries
self.all_geometries: List[Union[CPGeomConcrete, CPGeom]] = []
self.meshed_geometries: List[Union[CPGeomConcrete, CPGeom]] = []
self.concrete_geometries: List[CPGeomConcrete] = []
self.reinf_geometries_meshed: List[CPGeom] = []
self.reinf_geometries_lumped: List[CPGeom] = []
# sort geometry into appropriate list
for geom in self.compound_geometry.geoms:
if isinstance(geom.material, Concrete):
cp_geom = CPGeomConcrete(geom=geom.geom, material=geom.material)
self.concrete_geometries.append(cp_geom)
self.meshed_geometries.append(cp_geom)
else:
cp_geom = CPGeom(geom=geom.geom, material=geom.material) # type: ignore
if cp_geom.material.meshed:
self.reinf_geometries_meshed.append(cp_geom)
self.meshed_geometries.append(cp_geom)
elif not cp_geom.material.meshed:
self.reinf_geometries_lumped.append(cp_geom)
self.all_geometries.append(cp_geom)
# initialise gross properties results class
self.gross_properties = res.GrossProperties()
# calculate gross area properties
self.calculate_gross_area_properties()
def calculate_gross_area_properties(
self,
):
"""Calculates and stores gross section area properties."""
# loop through all geometries
for geom in self.all_geometries:
# area and centroid of geometry
area = geom.calculate_area()
centroid = geom.calculate_centroid()
self.gross_properties.total_area += area
self.gross_properties.e_a += area * geom.material.elastic_modulus
self.gross_properties.mass += area * geom.material.density
self.gross_properties.e_qx += (
area * geom.material.elastic_modulus * centroid[1]
)
self.gross_properties.e_qy += (
area * geom.material.elastic_modulus * centroid[0]
)
# sum concrete areas
for conc_geom in self.concrete_geometries:
self.gross_properties.concrete_area += conc_geom.calculate_area()
# sum reinforcement meshed areas
for meshed_geom in self.reinf_geometries_meshed:
self.gross_properties.reinf_meshed_area += meshed_geom.calculate_area()
# sum reinforcement lumped areas
for lumped_geom in self.reinf_geometries_lumped:
self.gross_properties.reinf_lumped_area += lumped_geom.calculate_area()
# perimeter
self.gross_properties.perimeter = self.compound_geometry.calculate_perimeter()
# centroids
self.gross_properties.cx = (
self.gross_properties.e_qy / self.gross_properties.e_a
)
self.gross_properties.cy = (
self.gross_properties.e_qx / self.gross_properties.e_a
)
# global second moments of area
# meshed geometries
for geom in self.meshed_geometries:
sec = AnalysisSection(geometry=geom)
for el in sec.elements:
el_e_ixx_g, el_e_iyy_g, el_e_ixy_g = el.second_moments_of_area()
self.gross_properties.e_ixx_g += el_e_ixx_g
self.gross_properties.e_iyy_g += el_e_iyy_g
self.gross_properties.e_ixy_g += el_e_ixy_g
# lumped geometries - treat as lumped circles
for geom in self.reinf_geometries_lumped:
# area, diameter and centroid of geometry
area = geom.calculate_area()
diam = np.sqrt(4 * area / np.pi)
centroid = geom.calculate_centroid()
self.gross_properties.e_ixx_g += geom.material.elastic_modulus * (
np.pi * pow(diam, 4) / 64 + area * centroid[1] * centroid[1]
)
self.gross_properties.e_iyy_g += geom.material.elastic_modulus * (
np.pi * pow(diam, 4) / 64 + area * centroid[0] * centroid[0]
)
self.gross_properties.e_ixy_g += geom.material.elastic_modulus * (
area * centroid[0] * centroid[1]
)
# centroidal second moments of area
self.gross_properties.e_ixx_c = (
self.gross_properties.e_ixx_g
- self.gross_properties.e_qx**2 / self.gross_properties.e_a
)
self.gross_properties.e_iyy_c = (
self.gross_properties.e_iyy_g
- self.gross_properties.e_qy**2 / self.gross_properties.e_a
)
self.gross_properties.e_ixy_c = (
self.gross_properties.e_ixy_g
- self.gross_properties.e_qx
* self.gross_properties.e_qy
/ self.gross_properties.e_a
)
# principal 2nd moments of area about the centroidal xy axis
Delta = (
((self.gross_properties.e_ixx_c - self.gross_properties.e_iyy_c) / 2) ** 2
+ self.gross_properties.e_ixy_c**2
) ** 0.5
self.gross_properties.e_i11 = (
self.gross_properties.e_ixx_c + self.gross_properties.e_iyy_c
) / 2 + Delta
self.gross_properties.e_i22 = (
self.gross_properties.e_ixx_c + self.gross_properties.e_iyy_c
) / 2 - Delta
# principal axis angle
if (
abs(self.gross_properties.e_ixx_c - self.gross_properties.e_i11)
< 1e-12 * self.gross_properties.e_i11
):
self.gross_properties.phi = 0
else:
self.gross_properties.phi = np.arctan2(
self.gross_properties.e_ixx_c - self.gross_properties.e_i11,
self.gross_properties.e_ixy_c,
)
# centroidal section moduli
x_min, x_max, y_min, y_max = self.compound_geometry.calculate_extents()
self.gross_properties.e_zxx_plus = self.gross_properties.e_ixx_c / abs(
y_max - self.gross_properties.cy
)
self.gross_properties.e_zxx_minus = self.gross_properties.e_ixx_c / abs(
y_min - self.gross_properties.cy
)
self.gross_properties.e_zyy_plus = self.gross_properties.e_iyy_c / abs(
x_max - self.gross_properties.cx
)
self.gross_properties.e_zyy_minus = self.gross_properties.e_iyy_c / abs(
x_min - self.gross_properties.cx
)
# principal section moduli
x11_max, x11_min, y22_max, y22_min = utils.calculate_local_extents(
geometry=self.compound_geometry,
cx=self.gross_properties.cx,
cy=self.gross_properties.cy,
theta=self.gross_properties.phi,
)
# evaluate principal section moduli
self.gross_properties.e_z11_plus = self.gross_properties.e_i11 / abs(y22_max)
self.gross_properties.e_z11_minus = self.gross_properties.e_i11 / abs(y22_min)
self.gross_properties.e_z22_plus = self.gross_properties.e_i22 / abs(x11_max)
self.gross_properties.e_z22_minus = self.gross_properties.e_i22 / abs(x11_min)
# store ultimate concrete strain (get smallest from all concrete geometries)
conc_ult_strain = 0
for idx, conc_geom in enumerate(self.concrete_geometries):
ult_strain = (
conc_geom.material.ultimate_stress_strain_profile.get_ultimate_compressive_strain()
)
if idx == 0:
conc_ult_strain = ult_strain
else:
conc_ult_strain = min(conc_ult_strain, ult_strain)
self.gross_properties.conc_ultimate_strain = conc_ult_strain
def get_gross_properties(
self,
) -> res.GrossProperties:
"""Returns the gross section properties of the reinforced concrete section.
:return: Gross concrete properties object
"""
return self.gross_properties
def get_transformed_gross_properties(
self,
elastic_modulus: float,
) -> res.TransformedGrossProperties:
"""Transforms gross section properties given a reference elastic modulus.
:param elastic_modulus: Reference elastic modulus
:return: Transformed concrete properties object
"""
return res.TransformedGrossProperties(
concrete_properties=self.gross_properties, elastic_modulus=elastic_modulus
)
def calculate_cracked_properties(
self,
theta: float = 0,
) -> res.CrackedResults:
r"""Calculates cracked section properties given a neutral axis angle ``theta``.
:param theta: Angle (in radians) the neutral axis makes with the horizontal axis
(:math:`-\pi \leq \theta \leq \pi`)
:return: Cracked results object
"""
cracked_results = res.CrackedResults(theta=theta)
cracked_results.m_cr = self.calculate_cracking_moment(theta=theta)
# set neutral axis depth limits
# depth of neutral axis at extreme tensile fibre
_, d_t = utils.calculate_extreme_fibre(
points=self.compound_geometry.points, theta=theta
)
a = 1e-6 * d_t # sufficiently small depth of compressive zone
b = d_t # neutral axis at extreme tensile fibre
# find neutral axis that gives convergence of the the cracked neutral axis
try:
(cracked_results.d_nc, r) = brentq(
f=self.cracked_neutral_axis_convergence,
a=a,
b=b,
args=(cracked_results),
xtol=1e-3,
rtol=1e-6, # type: ignore
full_output=True,
disp=False,
)
except ValueError:
warnings.warn("brentq algorithm failed.")
# calculate cracked section properties
# axial rigidity & first moments of area
for geom in cracked_results.cracked_geometries:
area = geom.calculate_area()
centroid = geom.calculate_centroid()
cracked_results.e_a_cr += area * geom.material.elastic_modulus
cracked_results.e_qx_cr += (
area * geom.material.elastic_modulus * centroid[1]
)
cracked_results.e_qy_cr += (
area * geom.material.elastic_modulus * centroid[0]
)
# centroids
cracked_results.cx = cracked_results.e_qy_cr / cracked_results.e_a_cr
cracked_results.cy = cracked_results.e_qx_cr / cracked_results.e_a_cr
# global second moments of area
for geom in cracked_results.cracked_geometries:
# if meshed
if geom.material.meshed:
sec = AnalysisSection(geometry=geom)
for el in sec.elements:
el_e_ixx_g, el_e_iyy_g, el_e_ixy_g = el.second_moments_of_area()
cracked_results.e_ixx_g_cr += el_e_ixx_g
cracked_results.e_iyy_g_cr += el_e_iyy_g
cracked_results.e_ixy_g_cr += el_e_ixy_g
# if lumped
else:
# area, diameter and centroid of geometry
area = geom.calculate_area()
diam = np.sqrt(4 * area / np.pi)
centroid = geom.calculate_centroid()
cracked_results.e_ixx_g_cr += geom.material.elastic_modulus * (
np.pi * pow(diam, 4) / 64 + area * centroid[1] * centroid[1]
)
cracked_results.e_iyy_g_cr += geom.material.elastic_modulus * (
np.pi * pow(diam, 4) / 64 + area * centroid[0] * centroid[0]
)
cracked_results.e_ixy_g_cr += geom.material.elastic_modulus * (
area * centroid[0] * centroid[1]
)
# centroidal second moments of area
cracked_results.e_ixx_c_cr = (
cracked_results.e_ixx_g_cr
- cracked_results.e_qx_cr**2 / cracked_results.e_a_cr
)
cracked_results.e_iyy_c_cr = (
cracked_results.e_iyy_g_cr
- cracked_results.e_qy_cr**2 / cracked_results.e_a_cr
)
cracked_results.e_ixy_c_cr = (
cracked_results.e_ixy_g_cr
- cracked_results.e_qx_cr * cracked_results.e_qy_cr / cracked_results.e_a_cr
)
cracked_results.e_iuu_cr = (
cracked_results.e_iyy_c_cr * (np.sin(theta)) ** 2
+ cracked_results.e_ixx_c_cr * (np.cos(theta)) ** 2
- 2 * cracked_results.e_ixy_c_cr * np.sin(theta) * np.cos(theta)
)
# principal 2nd moments of area about the centroidal xy axis
Delta = (
((cracked_results.e_ixx_c_cr - cracked_results.e_iyy_c_cr) / 2) ** 2
+ cracked_results.e_ixy_c_cr**2
) ** 0.5
cracked_results.e_i11_cr = (
cracked_results.e_ixx_c_cr + cracked_results.e_iyy_c_cr
) / 2 + Delta
cracked_results.e_i22_cr = (
cracked_results.e_ixx_c_cr + cracked_results.e_iyy_c_cr
) / 2 - Delta
# principal axis angle
if (
abs(cracked_results.e_ixx_c_cr - cracked_results.e_i11_cr)
< 1e-12 * cracked_results.e_i11_cr
):
cracked_results.phi_cr = 0
else:
cracked_results.phi_cr = np.arctan2(
cracked_results.e_ixx_c_cr - cracked_results.e_i11_cr,
cracked_results.e_ixy_c_cr,
)
return cracked_results
def calculate_cracking_moment(
self,
theta: float,
) -> float:
r"""Calculates the cracking moment given a bending angle ``theta``.
:param theta: Angle (in radians) the neutral axis makes with the
horizontal axis (:math:`-\pi \leq \theta \leq \pi`)
:return: Cracking moment
"""
# get centroidal second moments of area
e_ixx = self.gross_properties.e_ixx_c
e_iyy = self.gross_properties.e_iyy_c
e_ixy = self.gross_properties.e_ixy_c
# determine rotated second moment of area
e_iuu = (
e_iyy * (np.sin(theta)) ** 2
+ e_ixx * (np.cos(theta)) ** 2
- 2 * e_ixy * np.sin(theta) * np.cos(theta)
)
# loop through all concrete geometries to find lowest cracking moment
m_c = 0
for idx, conc_geom in enumerate(self.concrete_geometries):
# get distance from centroid to extreme tensile fibre
d = utils.calculate_max_bending_depth(
points=conc_geom.points,
c_local_v=utils.global_to_local(
theta=theta, x=self.gross_properties.cx, y=self.gross_properties.cy
)[1],
theta=theta,
)
# if no part of the section is in tension, go to next geometry
if d == 0:
continue
# cracking moment for this geometry
f_t = conc_geom.material.flexural_tensile_strength
m_c_geom = (f_t / conc_geom.material.elastic_modulus) * (e_iuu / d)
# if we are the first geometry, initialise cracking moment
if idx == 0:
m_c = m_c_geom
# otherwise take smaller cracking moment
else:
m_c = min(m_c, m_c_geom)
return m_c
def cracked_neutral_axis_convergence(
self,
d_nc: float,
cracked_results: res.CrackedResults,
) -> float:
"""Given a trial cracked neutral axis depth ``d_nc``, determines the difference
between the first moments of area above and below the trial axis.
:param d_nc: Trial cracked neutral axis
:param cracked_results: Cracked results object
:return: Cracked neutral axis convergence
"""
# calculate extreme fibre in global coordinates
extreme_fibre, d_t = utils.calculate_extreme_fibre(
points=self.compound_geometry.points, theta=cracked_results.theta
)
# validate d_nc input
if d_nc <= 0:
raise ValueError("d_nc must be positive.")
elif d_nc > d_t:
raise ValueError("d_nc must lie within the section, i.e. d_nc <= d_t")
# find point on neutral axis by shifting by d_nc
point_na = utils.point_on_neutral_axis(
extreme_fibre=extreme_fibre, d_n=d_nc, theta=cracked_results.theta
)
# get principal coordinates of neutral axis
na_local = utils.global_to_local(
theta=cracked_results.theta, x=point_na[0], y=point_na[1]
)
# split concrete geometries above and below d_nc, discard below
cracked_geoms: List[Union[CPGeomConcrete, CPGeom]] = []
for conc_geom in self.concrete_geometries:
top_geoms, _ = conc_geom.split_section(
point=point_na,
theta=cracked_results.theta,
)
# save compression geometries
cracked_geoms.extend(top_geoms)
# add reinforcement geometries to list
cracked_geoms.extend(self.reinf_geometries_meshed)
cracked_geoms.extend(self.reinf_geometries_lumped)
# determine moment of area equilibrium about neutral axis
e_qu = 0 # initialise first moment of area
for geom in cracked_geoms:
ea = geom.calculate_area() * geom.material.elastic_modulus
centroid = geom.calculate_centroid()
# convert centroid to local coordinates
_, c_v = utils.global_to_local(
theta=cracked_results.theta, x=centroid[0], y=centroid[1]
)
# calculate first moment of area
e_qu += ea * (c_v - na_local[1])
cracked_results.cracked_geometries = cracked_geoms
return e_qu
def moment_curvature_analysis(
self,
theta: float = 0,
kappa_inc: float = 1e-7,
delta_m_min: float = 0.15,
delta_m_max: float = 0.3,
) -> res.MomentCurvatureResults:
r"""Performs a moment curvature analysis given a bending angle ``theta``.
Analysis continues until a material reaches its ultimate strain.
:param: Angle (in radians) the neutral axis makes with the horizontal axis
(:math:`-\pi \leq \theta \leq \pi`)
:param kappa_inc: Initial curvature increment
:param delta_m_min: Relative change in moment at which to double step
:param delta_m_max: Relative change in moment at which to halve step
:return: Moment curvature results object
"""
# initialise variables
moment_curvature = res.MomentCurvatureResults(theta=theta)
iter = 0
# set neutral axis depth limits
# depth of neutral axis at extreme tensile fibre
_, d_t = utils.calculate_extreme_fibre(
points=self.compound_geometry.points, theta=theta
)
a = 1e-6 * d_t # sufficiently small depth of compressive zone
b = d_t # neutral axis at extreme tensile fibre
# create progress bar
progress = utils.create_unknown_progress()
with Live(progress, refresh_per_second=10) as live:
task = progress.add_task(
description="[red]Generating M-K diagram",
total=None,
)
# while there hasn't been a failure
while not moment_curvature._failure:
# calculate adaptive step size for curvature
if iter > 1:
moment_diff = (
abs(moment_curvature.kappa[-1] - moment_curvature.kappa[-2])
/ moment_curvature.kappa[-1]
)
if moment_diff <= delta_m_min:
kappa_inc *= 2
elif moment_diff >= delta_m_max:
kappa_inc *= 0.5
kappa = 0 if iter == 0 else moment_curvature.kappa[-1] + kappa_inc
# find neutral axis that gives convergence of the axial force
try:
(d_n, r) = brentq(
f=self.service_normal_force_convergence,
a=a,
b=b,
args=(kappa, moment_curvature),
xtol=1e-3,
rtol=1e-6, # type: ignore
full_output=True,
disp=False,
)
except ValueError:
warnings.warn("brentq algorithm failed.")
m_xy = np.sqrt(
moment_curvature._m_x_i**2 + moment_curvature._m_y_i**2
)
text_update = "[red]Generating M-K diagram: "
text_update += f"M={m_xy:.3e}"
progress.update(task, description=text_update)
# save results
if not moment_curvature._failure:
moment_curvature.kappa.append(kappa)
moment_curvature.n.append(moment_curvature._n_i)
moment_curvature.m_x.append(moment_curvature._m_x_i)
moment_curvature.m_y.append(moment_curvature._m_y_i)
moment_curvature.m_xy.append(m_xy)
iter += 1
progress.update(
task,
description="[bold green]:white_check_mark: M-K diagram generated",
)
live.refresh()
return moment_curvature
def service_normal_force_convergence(
self,
d_n: float,
kappa: float,
moment_curvature: res.MomentCurvatureResults,
) -> float:
"""Given a neutral axis depth ``d_n`` and curvature ``kappa``, returns the the
net axial force.
:param d_nc: Trial cracked neutral axis
:param kappa: Curvature
:param moment_curvature: Moment curvature results object
:return: Net axial force
"""
# reset failure
moment_curvature._failure = False
# calculate extreme fibre in global coordinates
extreme_fibre, d_t = utils.calculate_extreme_fibre(
points=self.compound_geometry.points, theta=moment_curvature.theta
)
# validate d_n input
if d_n <= 0:
raise ValueError("d_n must be positive.")
elif d_n > d_t:
raise ValueError("d_n must lie within the section, i.e. d_n <= d_t")
# find point on neutral axis by shifting by d_n
point_na = utils.point_on_neutral_axis(
extreme_fibre=extreme_fibre, d_n=d_n, theta=moment_curvature.theta
)
# create splits in meshed geometries at points in stress-strain profiles
meshed_split_geoms: List[Union[CPGeom, CPGeomConcrete]] = []
for meshed_geom in self.meshed_geometries:
split_geoms = utils.split_geom_at_strains(
geom=meshed_geom,
theta=moment_curvature.theta,
point_na=point_na,
ultimate=False,
kappa=kappa,
)
meshed_split_geoms.extend(split_geoms)
# initialise results
n = 0
m_x = 0
m_y = 0
# calculate meshed geometry actions
for meshed_geom in meshed_split_geoms:
sec = AnalysisSection(geometry=meshed_geom)
n_sec, m_x_sec, m_y_sec, min_strain, max_strain = sec.service_analysis(
point_na=point_na,
theta=moment_curvature.theta,
kappa=kappa,
centroid=(self.gross_properties.cx, self.gross_properties.cy),
)
n += n_sec
m_x += m_x_sec
m_y += m_y_sec
# check for failure
ult_comp_strain = (
meshed_geom.material.stress_strain_profile.get_ultimate_compressive_strain()
)
ult_tens_strain = (
meshed_geom.material.stress_strain_profile.get_ultimate_tensile_strain()
)
# don't worry about tension failure in concrete
if max_strain > ult_comp_strain or (
min_strain < ult_tens_strain
and not isinstance(meshed_geom, CPGeomConcrete)
):
moment_curvature._failure = True
moment_curvature.failure_geometry = meshed_geom
# calculate lumped geometry actions
for lumped_geom in self.reinf_geometries_lumped:
# calculate area and centroid
area = lumped_geom.calculate_area()
centroid = lumped_geom.calculate_centroid()
# get strain at centroid of lump
strain = utils.get_service_strain(
point=(centroid[0], centroid[1]),
point_na=point_na,
theta=moment_curvature.theta,
kappa=kappa,
)
# check for failure
ult_comp_strain = (
lumped_geom.material.stress_strain_profile.get_ultimate_compressive_strain()
)
ult_tens_strain = (
lumped_geom.material.stress_strain_profile.get_ultimate_tensile_strain()
)
if strain > ult_comp_strain or strain < ult_tens_strain:
moment_curvature._failure = True
moment_curvature.failure_geometry = lumped_geom
# calculate stress and force
stress = lumped_geom.material.stress_strain_profile.get_stress(
strain=strain
)
force = stress * area
n += force
# calculate moment
m_x += force * (centroid[1] - self.gross_properties.cy)
m_y += force * (centroid[0] - self.gross_properties.cx)
moment_curvature._n_i = n
moment_curvature._m_x_i = m_x
moment_curvature._m_y_i = m_y
# calculate convergence
return n
def ultimate_bending_capacity(
self,
theta: float = 0,
n: float = 0,
) -> res.UltimateBendingResults:
r"""Given a neutral axis angle ``theta`` and an axial force ``n``, calculates
the ultimate bending capacity.
Note that ``k_u`` is calculated only for lumped (non-meshed) geometries.
:param theta: Angle (in radians) the neutral axis makes with the horizontal axis
(:math:`-\pi \leq \theta \leq \pi`)
:param n: Net axial force
:return: Ultimate bending results object
"""
# set neutral axis depth limits
# depth of neutral axis at extreme tensile fibre
_, d_t = utils.calculate_extreme_fibre(
points=self.compound_geometry.points, theta=theta
)
a = 1e-6 * d_t # sufficiently small depth of compressive zone
b = 6 * d_t # neutral axis at sufficiently large tensile fibre
# initialise ultimate bending results
ultimate_results = res.UltimateBendingResults(theta=theta)
# find neutral axis that gives convergence of the axial force
try:
(d_n, r) = brentq(
f=self.ultimate_normal_force_convergence,
a=a,
b=b,
args=(n, ultimate_results),
xtol=1e-3,
rtol=1e-6, # type: ignore
full_output=True,
disp=False,
)
except ValueError:
warnings.warn("brentq algorithm failed.")
return ultimate_results
def ultimate_normal_force_convergence(
self,
d_n: float,
n: float,
ultimate_results: res.UltimateBendingResults,
) -> float:
"""Given a neutral axis depth ``d_n`` and neutral axis angle ``theta``,
calculates the difference between the target net axial force ``n`` and the
calculated axial force.
:param d_n: Depth of the neutral axis from the extreme compression fibre
:param n: Net axial force
:param ultimate_results: Ultimate bending results object
:return: Axial force convergence
"""
# calculate convergence
return (
n
- self.calculate_ultimate_section_actions(
d_n=d_n, ultimate_results=ultimate_results
).n
)
def calculate_ultimate_section_actions(
self,
d_n: float,
ultimate_results: Optional[res.UltimateBendingResults] = None,
) -> res.UltimateBendingResults:
"""Given a neutral axis depth ``d_n`` and neutral axis angle ``theta``,
calculates the resultant bending moments ``m_x``, ``m_y``, ``m_xy`` and the net
axial force ``n``.
:param d_n: Depth of the neutral axis from the extreme compression fibre
:param ultimate_results: Ultimate bending results object
:return: Ultimate bending results object
"""
if ultimate_results is None:
ultimate_results = res.UltimateBendingResults(theta=0)
# calculate extreme fibre in global coordinates
extreme_fibre, _ = utils.calculate_extreme_fibre(
points=self.compound_geometry.points, theta=ultimate_results.theta
)
# extreme fibre in local coordinates
_, ef_v = utils.global_to_local(
theta=ultimate_results.theta,
x=extreme_fibre[0],
y=extreme_fibre[1],
)
# validate d_n input
if d_n <= 0:
raise ValueError("d_n must be positive.")
# find point on neutral axis by shifting by d_n
if isinf(d_n):
point_na = (0, 0)
else:
point_na = utils.point_on_neutral_axis(
extreme_fibre=extreme_fibre, d_n=d_n, theta=ultimate_results.theta
)
# create splits in meshed geometries at points in stress-strain profiles
meshed_split_geoms: List[Union[CPGeom, CPGeomConcrete]] = []
if isinf(d_n):
meshed_split_geoms = self.meshed_geometries
else:
for meshed_geom in self.meshed_geometries:
split_geoms = utils.split_geom_at_strains(
geom=meshed_geom,
theta=ultimate_results.theta,
point_na=point_na,
ultimate=True,
ultimate_strain=self.gross_properties.conc_ultimate_strain,
d_n=d_n,
)
meshed_split_geoms.extend(split_geoms)
# initialise results
n = 0
m_x = 0
m_y = 0
k_u = []
# calculate meshed geometry actions
for meshed_geom in meshed_split_geoms:
sec = AnalysisSection(geometry=meshed_geom)
n_sec, m_x_sec, m_y_sec = sec.ultimate_analysis(
point_na=point_na,
d_n=d_n,
theta=ultimate_results.theta,
ultimate_strain=self.gross_properties.conc_ultimate_strain,
centroid=(self.gross_properties.cx, self.gross_properties.cy),
)
n += n_sec
m_x += m_x_sec
m_y += m_y_sec
# calculate lumped actions
for lumped_geom in self.reinf_geometries_lumped:
# calculate area and centroid
area = lumped_geom.calculate_area()
centroid = lumped_geom.calculate_centroid()
# get strain at centroid of lump
if isinf(d_n):
strain = self.gross_properties.conc_ultimate_strain
else:
strain = utils.get_ultimate_strain(
point=(centroid[0], centroid[1]),
point_na=point_na,
d_n=d_n,
theta=ultimate_results.theta,
ultimate_strain=self.gross_properties.conc_ultimate_strain,
)
# calculate stress and force
stress = lumped_geom.material.stress_strain_profile.get_stress(
strain=strain
)
force = stress * area
n += force
# convert centroid to local coordinates
_, c_v = utils.global_to_local(
theta=ultimate_results.theta, x=centroid[0], y=centroid[1]
)
# calculate moment
m_x += force * (centroid[1] - self.gross_properties.cy)
m_y += force * (centroid[0] - self.gross_properties.cx)
# calculate k_u
d = ef_v - c_v
k_u.append(d_n / d)
# calculate resultant moment
m_xy = np.sqrt(m_x * m_x + m_y * m_y)
# save results
ultimate_results.d_n = d_n
ultimate_results.n = n
ultimate_results.m_x = m_x
ultimate_results.m_y = m_y
ultimate_results.m_xy = m_xy
if k_u:
ultimate_results.k_u = min(k_u)
return ultimate_results
def moment_interaction_diagram(
self,
theta: float = 0,
control_points: List[Tuple[str, float]] = [
("kappa0", 0.0),
("D", 1.0),
("fy", 1.0),
("N", 0.0),
("d_n", 1e-6),
],
labels: List[Union[str, None]] = [None],
n_points: Union[int, List[int]] = [4, 12, 12, 4],
max_comp: Optional[float] = None,
max_comp_labels: List[Union[str, None]] = [None, None],
) -> res.MomentInteractionResults:
r"""Generates a moment interaction diagram given a neutral axis angle `theta`
and `n_points` calculation points between the decompression case and the pure
bending case.
:param theta: Angle (in radians) the neutral axis makes with the horizontal axis
(:math:`-\pi \leq \theta \leq \pi`)
:param control_points: List of control points over which to generate the
interaction diagram. Each entry in ``control_points`` is a ``Tuple`` with
the first item the type of control point and the second item defining the
location of the control point. Acceptable types of control points are
``"D"`` (ratio of neutral axis depth to section depth), ``"d_n"`` (neutral
axis depth), ``"fy"`` (yield ratio of the most extreme tensile bar), ``"N"``
(axial force) and ``"kappa"`` (zero curvature compression - must be at start
of list, second value in tuple is not used). Control points must be defined
in an order which results in a decreasing neutral axis depth (decreasing
axial force). The default control points define an interaction diagram from
the decompression point to the pure bending point.
:param labels: List of labels to apply to the ``control_points`` for plotting
purposes, length must be the same as the length of ``control_points``. If a
single value is provided, will apply this label to all control points.
:param n_points: Number of neutral axis depths to compute between each control
point. Length must be one less than the length of ``control_points``. If an
integer is provided this will be used between all control points.
:param max_comp: If provided, limits the maximum compressive force in the moment
interaction diagram to ``max_comp``
:param max_comp_labels: Labels to apply to the ``max_comp`` intersection points,
first value is at zero moment, second value is at the intersection with the
interaction diagram
:raises ValueError: If ``control_points``, ``labels`` or ``n_points`` is invalid
:return: Moment interaction results object
"""
# if an integer is provided for n_points, generate a list
if isinstance(n_points, int):
n_points = [n_points] * (len(control_points) - 1)
# if there are no labels provided, generate a list
if len(labels) == 1:
labels = labels * len(control_points)
# validate n_points length
if len(n_points) != len(control_points) - 1:
raise ValueError(
"Length of n_points must be one less than the length of control_points."