|
3 | 3 | import math |
4 | 4 |
|
5 | 5 | import pytest |
| 6 | +from sectionproperties.pre.library import concrete_rectangular_section |
6 | 7 |
|
7 | | -from concreteproperties.post import si_kn_m, si_n_mm, string_formatter |
| 8 | +from concreteproperties import ( |
| 9 | + Concrete, |
| 10 | + ConcreteLinear, |
| 11 | + ConcreteSection, |
| 12 | + RectangularStressBlock, |
| 13 | + SteelBar, |
| 14 | + SteelElasticPlastic, |
| 15 | +) |
| 16 | +from concreteproperties.post import DEFAULT_UNITS, si_kn_m, si_n_mm, string_formatter |
8 | 17 |
|
9 | 18 |
|
10 | 19 | def test_string_formatter(): |
@@ -80,3 +89,62 @@ def test_unit_display(): |
80 | 89 | assert si_kn_m.length_4_unit == " m^4" |
81 | 90 | assert si_n_mm.length_4_scale == pytest.approx(1) |
82 | 91 | assert si_kn_m.length_4_scale == pytest.approx(1e-12) |
| 92 | + |
| 93 | + |
| 94 | +def test_print(): |
| 95 | + """Tests printing results to terminal.""" |
| 96 | + concrete = Concrete( |
| 97 | + name="32 MPa Concrete", |
| 98 | + density=2.4e-6, |
| 99 | + stress_strain_profile=ConcreteLinear(elastic_modulus=30.1e3), |
| 100 | + ultimate_stress_strain_profile=RectangularStressBlock( |
| 101 | + compressive_strength=32, |
| 102 | + alpha=0.802, |
| 103 | + gamma=0.89, |
| 104 | + ultimate_strain=0.003, |
| 105 | + ), |
| 106 | + flexural_tensile_strength=3.4, |
| 107 | + colour="lightgrey", |
| 108 | + ) |
| 109 | + steel = SteelBar( |
| 110 | + name="500 MPa Steel", |
| 111 | + density=7.85e-6, |
| 112 | + stress_strain_profile=SteelElasticPlastic( |
| 113 | + yield_strength=500, |
| 114 | + elastic_modulus=200e3, |
| 115 | + fracture_strain=0.05, |
| 116 | + ), |
| 117 | + colour="grey", |
| 118 | + ) |
| 119 | + geom = concrete_rectangular_section( |
| 120 | + d=600, |
| 121 | + b=400, |
| 122 | + dia_top=20, |
| 123 | + area_top=310, |
| 124 | + n_top=3, |
| 125 | + c_top=30, |
| 126 | + dia_bot=24, |
| 127 | + area_bot=450, |
| 128 | + n_bot=3, |
| 129 | + c_bot=30, |
| 130 | + conc_mat=concrete, |
| 131 | + steel_mat=steel, |
| 132 | + ) |
| 133 | + conc_sec = ConcreteSection(geom) |
| 134 | + gross_props = conc_sec.get_gross_properties() |
| 135 | + gross_props.print_results() |
| 136 | + gross_props.print_results(units=DEFAULT_UNITS) |
| 137 | + gross_props.print_results(units=si_n_mm) |
| 138 | + gross_props.print_results(units=si_kn_m) |
| 139 | + transformed_props = conc_sec.get_transformed_gross_properties( |
| 140 | + elastic_modulus=30.1e3 |
| 141 | + ) |
| 142 | + transformed_props.print_results() |
| 143 | + cracked_res = conc_sec.calculate_cracked_properties() |
| 144 | + cracked_res.print_results() |
| 145 | + cracked_res.calculate_transformed_properties(elastic_modulus=32.8e3) |
| 146 | + cracked_res.print_results() |
| 147 | + ult_res = conc_sec.ultimate_bending_capacity() |
| 148 | + ult_res.print_results() |
| 149 | + si_n_mm.radians = False # display angles in degrees |
| 150 | + ult_res.print_results(units=si_n_mm) |
0 commit comments