Skip to content

Commit

Permalink
CS454 Additions (#68)
Browse files Browse the repository at this point in the history
* Factor LM and add LoadPattern to documentation

* Update example and version number
  • Loading branch information
ccaprani authored Mar 2, 2024
1 parent 86fbc6f commit b67a9fe
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 70 deletions.
1 change: 1 addition & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Package Modules
pycba.beam
pycba.load
pycba.results
pycba.pattern
pycba.inf_lines
pycba.bridge
pycba.vehicle
Expand Down
89 changes: 21 additions & 68 deletions docs/source/notebooks/envelopes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,6 @@
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8d3e1caf-2c6b-40f4-b9a7-a62b48d5f6d1",
"metadata": {},
"outputs": [],
"source": [
"def factor_LM(LM, gamma):\n",
" \"\"\"\n",
" Applies a factor to the loads in a `LoadMatrix` object\n",
"\n",
" Parameters\n",
" ----------\n",
" LM : LoadMatrix\n",
" The `LoadMatrix` object\n",
"\n",
" gamma : float\n",
" A factor to apply to the load magnitudes\n",
"\n",
" Returns\n",
" -------\n",
" LM : LoadMatrix\n",
" The factored `LoadMatrix` object\n",
" \"\"\"\n",
" LMnew = []\n",
" for load in LM:\n",
" i_span = load[0]\n",
" l_type = load[1]\n",
" mag = gamma*load[2]\n",
" if l_type == 1: # UDL\n",
" LMnew.append([i_span,l_type,mag])\n",
" elif l_type == 2 or l_type == 4: # PL or ML\n",
" LMnew.append([i_span,l_type,mag,load[3]])\n",
" else: # PUDL\n",
" LMnew.append([i_span,l_type,mag,load[3],load[4]])\n",
"\n",
" return LMnew"
]
},
{
"cell_type": "markdown",
"id": "7ecba0f6-1ea0-43ae-8a69-99f751fbbddc",
Expand All @@ -77,7 +38,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "b8e17e72-18e0-4509-9bf6-5d29717e6a10",
"metadata": {},
"outputs": [],
Expand All @@ -98,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "b065699d-d08e-4c03-a7c7-f96bf6a73b10",
"metadata": {},
"outputs": [],
Expand All @@ -120,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "a39bc89a-5db5-49b6-8743-bb8e1fe2440b",
"metadata": {},
"outputs": [],
Expand All @@ -142,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "8254e84e-6a39-4db7-ac8e-ed27b05e8c45",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -177,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "2de6259c-35ee-4f63-b6a5-db2812f9281d",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -207,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "5605374a-3738-460b-9714-10d916dfb07a",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -244,7 +205,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "8b8fe9d5-7158-4f4a-bbb2-8731646ca278",
"metadata": {},
"outputs": [],
Expand All @@ -265,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "94100911-072d-4407-a3c1-762261aa63a7",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -297,7 +258,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "d8ac94c2-6e37-46c5-877c-7b00c35ea383",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -332,7 +293,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "1ccdcb0f-7ccc-412a-b65f-5eda6ab54336",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -517,7 +478,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 16,
"id": "76f4509d-83f8-452f-991d-d53282368706",
"metadata": {},
"outputs": [],
Expand All @@ -543,7 +504,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 17,
"id": "b0c57cd9-fefa-4ccc-aee8-db7f43dd6979",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -595,7 +556,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 18,
"id": "022225e3-8680-4ef6-b4f7-6c5ed614fb65",
"metadata": {},
"outputs": [],
Expand All @@ -622,7 +583,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 19,
"id": "cae4e522-c5be-475a-82bb-2a3b6c48690b",
"metadata": {},
"outputs": [],
Expand All @@ -645,7 +606,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 20,
"id": "fa5cf6a6-a365-482a-885b-fd97368b30a6",
"metadata": {},
"outputs": [],
Expand All @@ -670,7 +631,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 21,
"id": "6ed01184",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -705,7 +666,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 22,
"id": "fd1bd3bd",
"metadata": {},
"outputs": [],
Expand All @@ -724,17 +685,17 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 23,
"id": "fc318195-5643-46c6-88d3-d6db995cd98d",
"metadata": {},
"outputs": [],
"source": [
"beam_analysis = cba.BeamAnalysis(L, EI, R)\n",
"gLMg = factor_LM(LMg,γg)\n",
"gLMg = cba.factor_LM(LMg,γg)\n",
"\n",
"br = []\n",
"for i in range(len(LMq)):\n",
" gLMqi = factor_LM(LMq[i],γq)\n",
" gLMqi = cba.factor_LM(LMq[i],γq)\n",
" LM = cba.add_LM(gLMg,gLMqi)\n",
" beam_analysis.set_loads(LM)\n",
" beam_analysis.analyze()\n",
Expand All @@ -751,7 +712,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 24,
"id": "c0289b6b-b5c1-4972-9f38-3e13801d438d",
"metadata": {},
"outputs": [
Expand All @@ -772,14 +733,6 @@
"env = cba.Envelopes(br)\n",
"env.plot(each=True, figsize=(12,8));"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d4f4810-9574-4d80-8f85-8a4f851e99b5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion src/pycba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PyCBA - Continuous Beam Analysis in Python
"""

__version__ = "0.4.0"
__version__ = "0.4.1"

from .analysis import *
from .beam import *
Expand Down
34 changes: 33 additions & 1 deletion src/pycba/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def parse_LM(LM: LoadMatrix) -> List[Load]:
return loads


def add_LM(LM1: LoadMatrix, LM2: LoadMatrix):
def add_LM(LM1: LoadMatrix, LM2: LoadMatrix) -> LoadMatrix:
"""
Adds two load matrices and returns the sum; this enables superposition
Expand All @@ -824,3 +824,35 @@ def add_LM(LM1: LoadMatrix, LM2: LoadMatrix):
LM.append(load)

return LM


def factor_LM(LM: LoadMatrix, gamma: float) -> LoadMatrix:
"""
Applies a factor to the loads in a `LoadMatrix` object
Parameters
----------
LM : LoadMatrix
The `LoadMatrix` object
gamma : float
A factor to apply to the load magnitudes
Returns
-------
LM : LoadMatrix
The factored `LoadMatrix` object
"""
LMnew = []
for load in LM:
i_span = load[0]
l_type = load[1]
mag = gamma * load[2]
if l_type == 1: # UDL
LMnew.append([i_span, l_type, mag])
elif l_type == 2 or l_type == 4: # PL or ML
LMnew.append([i_span, l_type, mag, load[3]])
else: # PUDL
LMnew.append([i_span, l_type, mag, load[3], load[4]])

return LMnew

0 comments on commit b67a9fe

Please sign in to comment.