Skip to content

Commit 3884d62

Browse files
Merge pull request #9 from StructuralPython/releases/v0.4.0
feat: implemented ability to control reaction direction reversing
2 parents 468a2a3 + b1ef5a7 commit 3884d62

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

src/loadbearing_wall/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
The wall model is parameterizable and can represent any material
66
"""
77

8-
__version__ = "0.3.1"
8+
__version__ = "0.4.0"
99

1010
from loadbearing_wall.wall_model import LinearWallModel
1111
from loadbearing_wall import *

src/loadbearing_wall/linear_reactions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class LinearReactionString:
6363
magnitude_end_key: str
6464
location_start_key: str
6565
location_end_key: str
66+
reverse_reaction_direction: bool = True
6667

6768
@classmethod
6869
def from_projected_loads(
@@ -72,28 +73,32 @@ def from_projected_loads(
7273
magnitude_end_key: str,
7374
location_start_key: str,
7475
location_end_key: str,
76+
reverse_reaction_direction: bool = True,
7577
):
7678
w0 = magnitude_start_key
7779
w1 = magnitude_end_key
7880
x0 = location_start_key
7981
x1 = location_end_key
82+
reverse_direction = -1 if reverse_reaction_direction else 1
8083
linear_reaction_components = {}
8184
for load_dir, load_cases in projected_loads.items():
8285
linear_reaction_components.setdefault(load_dir, {})
8386
for load_case, applied_loads in load_cases.items():
8487
linear_reaction_components[load_dir].setdefault(load_case, [])
8588
for applied_load in applied_loads:
8689
linear_reaction = LinearReaction(
87-
applied_load[w0],
88-
applied_load.get(w1),
90+
applied_load[w0] * reverse_direction,
91+
applied_load.get(w1) * reverse_direction,
8992
applied_load[x0],
9093
applied_load.get(x1),
9194
)
9295

9396
linear_reaction_components[load_dir][load_case].append(
9497
linear_reaction
9598
)
96-
return cls(linear_reaction_components, w0, w1, x0, x1)
99+
return cls(
100+
linear_reaction_components, w0, w1, x0, x1, reverse_reaction_direction
101+
)
97102

98103
def extract_reaction_string(self, xa: float, xb: float, case: str, dir: str):
99104
"""

src/loadbearing_wall/wall_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def get_reactions(
253253
self.magnitude_end_key,
254254
self.location_start_key,
255255
self.location_end_key,
256+
self.reverse_reaction_force_direction,
256257
)
257258
return lrs.consolidate_reactions(
258259
flatten=flattened, dir_key=direction_key, case_key=case_key

tests/test_wall_model.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,24 @@ def test_wall_model_runs(WM0, WM1):
4646

4747

4848
def test_no_spread(WM0):
49+
rxn = WM0.get_reactions(flattened=False)
50+
assert rxn["Fz"]["D"] == [
51+
{"dir": "Fz", "case": "D", "w1": -1 * 10.0, "w2": -1 * 10.0, "x1": 1.00, "x2": 1.75},
52+
{"dir": "Fz", "case": "D", "w1": -1 * 210.0, "w2": -1 * 210.0, "x1": 1.750000000001, "x2": 2.249999999999},
53+
{"dir": "Fz", "case": "D", "w1": -1 * 10.0, "w2": -1 * 10.0, "x1": 2.250000000001, "x2": 3.0},
54+
]
55+
assert rxn["Fz"]["L"] == [
56+
{"dir": "Fz", "case": "L", "w1": -1 * 15.0, "w2": -1 * 15.0, "x1": 0.00, "x2": 1.75},
57+
{"dir": "Fz", "case": "L", "w1": -1 * 215.0, "w2": -1 * 215.0, "x1": 1.750000000001, "x2": 2.00},
58+
{"dir": "Fz", "case": "L", "w1": -1 * 200.0, "w2": -1 * 200.0, "x1": 2.00, "x2": 2.249999999999},
59+
]
60+
WM0.reverse_reaction_force_direction = False
4961
rxn = WM0.get_reactions(flattened=False)
5062
assert rxn["Fz"]["D"] == [
5163
{"dir": "Fz", "case": "D", "w1": 10.0, "w2": 10.0, "x1": 1.00, "x2": 1.75},
5264
{"dir": "Fz", "case": "D", "w1": 210.0, "w2": 210.0, "x1": 1.750000000001, "x2": 2.249999999999},
5365
{"dir": "Fz", "case": "D", "w1": 10.0, "w2": 10.0, "x1": 2.250000000001, "x2": 3.0},
5466
]
55-
assert rxn["Fz"]["L"] == [
56-
{"dir": "Fz", "case": "L", "w1": 15.0, "w2": 15.0, "x1": 0.00, "x2": 1.75},
57-
{"dir": "Fz", "case": "L", "w1": 215.0, "w2": 215.0, "x1": 1.750000000001, "x2": 2.00},
58-
{"dir": "Fz", "case": "L", "w1": 200.0, "w2": 200.0, "x1": 2.00, "x2": 2.249999999999},
59-
60-
# {"dir": "Fz", "case": "L", "w1": 100.0, "x1": 0.5},
61-
# {"dir": "Fz", "case": "L", "w1": 15.0, "w2": 15.0, "x1": 0.0, "x2": 2.0},
62-
]
6367

6468

6569
def test_45_spread(WM1):
@@ -68,8 +72,8 @@ def test_45_spread(WM1):
6872
{
6973
"dir": "Fz",
7074
"case": "D",
71-
"w1": 30.0,
72-
"w2": 30.0,
75+
"w1": -1 * 30.0,
76+
"w2": -1 * 30.0,
7377
"x1": 0.0,
7478
"x2": 4.0,
7579
},
@@ -79,8 +83,8 @@ def test_45_spread(WM1):
7983
{
8084
"dir": "Fz",
8185
"case": "L",
82-
"w1": 32.5,
83-
"w2": 32.5,
86+
"w1": -1 * 32.5,
87+
"w2": -1 * 32.5,
8488
"x1": 0.0,
8589
"x2": 4.0,
8690
},

0 commit comments

Comments
 (0)