Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change labels in point_plotter.py #32

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/conc_col_pmm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ The `conc_col_pmm` folder is meant to be a standalone design tool. To get set up
## Designing a column
The `conc_col_pmm/tests/visual_tests` folder has examples for running various parts of the concrete column tool including

* `visual_test_document_wrapper.py` for viewing a complete calculation report
* `visual_test_pmm_plotter_plotly.py` for viewing a 3D PMM plot
* `visual_test_calculation_report.py` for viewing a complete calculation report
* `visual_test_pmm.py` for viewing a 3D PMM plot
* `visual_test_point_plotter.py` for viewing 2D PM plots for specific load cases

These example files can be run and viewed with `python -m conc_col_pmm.tests.visual_tests.<file name>`. For example:
`python -m conc_col_pmm.tests.visual_tests.visual_test_document_wrapper`
`python -m conc_col_pmm.tests.visual_tests.visual_test_calculation_report`


# Program Features
Expand Down
7 changes: 4 additions & 3 deletions examples/conc_col_pmm/calc_document/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from ..pmm_search.load_combo import LoadCombination, is_yes
from .column_inputs import ColumnInputs
from .full_calc_document import calculation as full_calc

# TODO: this should return all info needed to plot visual tests, possibly take input params for defaults
from .plotting.get_pmm_data import get_pmm_data


# this function accepts inputs from the user and passes them to "full_calc_document"
Expand Down Expand Up @@ -154,4 +153,6 @@ def calculation(
e_c,
)

full_calc(column, load_combos)
axial_limits = full_calc(column, load_combos)

return get_pmm_data(column, 36, 12, load_combos, axial_limits)
2 changes: 2 additions & 0 deletions examples/conc_col_pmm/calc_document/full_calc_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ def calculation(
dcr_results = calc_dcrs(load_combos, mesh, col, axial_limits)

results_summarizer(load_combos, dcr_results)

return axial_limits
15 changes: 9 additions & 6 deletions examples/conc_col_pmm/calc_document/plotting/PMM.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from ...pmm_search.load_combo import LoadCombination
import dataclasses

from numpy import ndarray

from ...pmm_search.load_combo import LoadCombination


@dataclasses.dataclass
class PMM():
X: list[float]
Y: list[float]
Z: list[float]
load_combos: list[LoadCombination]
class PMM:
X: ndarray
Y: ndarray
Z: ndarray
load_combos: list[LoadCombination]
8 changes: 4 additions & 4 deletions examples/conc_col_pmm/calc_document/plotting/get_pmm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from ...col.axial_limits import AxialLimits
from ...col.column import Column
from ...pmm_search.load_combo import LoadCombination
from .pmm_mesh import get_mesh
from .PMM import PMM
from .pmm_mesh import get_mesh

'''
"""
This function takes inputs for a column and creates a
dataclass instance containing all the information for the
PMM diagram for the given column. That information is used
for plotting the PMM diagram.
'''
"""


def get_pmm_data(
Expand All @@ -30,4 +30,4 @@ def get_pmm_data(
Y = np.array(y)
Z = np.array(z)

return PMM(X=X, Y=Y, Z=Z, load_combos=load_combos)
return PMM(X=X, Y=Y, Z=Z, load_combos=load_combos)
10 changes: 6 additions & 4 deletions examples/conc_col_pmm/calc_document/plotting/pmm_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
from ...pmm_search.load_search.point_search_load import search


def get_mesh(col: Column, intervals, load_spaces, axial_limits: AxialLimits):
def get_mesh(
col: Column, intervals, load_spaces, axial_limits: AxialLimits
) -> tuple[list[list[int]], list[list[int]], list[list[int]], list[list[float]]]:
# "intervals" is the number of spaces in the angle of eccentricity,
# "load_spaces" is the number of vertical spaces in the PMM diagram
# Returns a mesh containing all the points of the PMM diagram, plus
# a quarter of that mesh

# vectors containing the points to plot
x = []
y = []
z = []
x: list[list[int]] = []
y: list[list[int]] = []
z: list[list[int]] = []

# the bottom point must be added intervals+1 times because each level of
# the mesh needs intervals+1 points in order to form a closed surface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import numpy as np
import plotly.graph_objects as go

from .PMM import PMM

"""
This function plots the factored load capacity diagram for the column
"""


def plot(pmm_data):
def plot(pmm_data: PMM):
X = pmm_data.X
Y = pmm_data.Y
Z = pmm_data.Z
Expand Down
11 changes: 8 additions & 3 deletions examples/conc_col_pmm/calc_document/plotting/point_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ def plot(capacity_pts, point: LoadCombination | None, only_Mx):
ax.set_axisbelow(True)

load_span = phi_Pn[-1] - phi_Pn[0]
label_offsets = (max(phi_Mn) * 0.008, load_span * 0.02)

# define offset distances for axis labels depending on point
label_offset_x = max(phi_Mn) * 0.008
label_offsets_y=-load_span * 0.05, load_span * 0.02
# label the intersections with the y-axis
for i in (0, pt_count - 1):
pos = (phi_Mn[i], phi_Pn[i])
label = str(round(phi_Pn[i], 1))
plt.plot(pos[0], pos[1], marker="+", ms=12, mew=1.2, c="black", zorder=3)
plt.text(pos[0] + label_offsets[0], pos[1] + label_offsets[1], label, zorder=3)
label_offset_y=label_offsets_y[0] if i==0 else label_offsets_y[1]
plt.text(pos[0] + label_offset_x, pos[1] + label_offset_y, label, zorder=3)

if point:
Muxy = math.sqrt(point.mx**2 + point.my**2) # the biaxial moment
Expand All @@ -78,7 +82,8 @@ def plot(capacity_pts, point: LoadCombination | None, only_Mx):
label = moment_label + "\n" + axial_label

plt.plot(pos[0], pos[1], marker="+", ms=12, mew=1.2, c="red", zorder=4)
plt.text(pos[0] + label_offsets[0], pos[1] + label_offsets[1], label, zorder=5)
label_offset_y=label_offsets_y[0] if i==0 else label_offsets_y[1]
plt.text(pos[0] + label_offset_x, pos[1] + label_offset_y, label, zorder=5)

fig = ax.get_figure()

Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

def draw(col: Column, caption_input: str, unit: str = '"') -> Canvas:
canvas = draw_base(col)
canvas.display_type = "report-input"
canvas.caption = caption_input
scale_factor = 0.37817187 * math.log((col.w + col.h) / 2) + 0.03808133

Expand Down
17 changes: 7 additions & 10 deletions examples/conc_col_pmm/tests/test_pmm_plotter_plotly.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
from ..calc_document.calculation import calculation
from ..calc_document.plotting import get_pmm_data, pmm_plotter_plotly
from ..col import assign_max_min
from ..pmm_search.load_combo import LoadCombination


# This test checks for runtime errors
def test_pmm_plotter_plotly(example_col, loads):
axial_limits = assign_max_min.calculate_axial_load_limits(example_col)

def test_pmm_plotter_plotly(example_col):
# for each load case: P, Mx, My, and whether the calc should be shown
load_data = [
[300, 100, 200, True],
[-100, 50, -60, False],
[1500, 300, -300, False],
loads = [
[300, 100, 200, "yes"],
[-100, 50, -60, "no"],
[1500, 300, -300, "no"],
]
loads = [LoadCombination(i, *load) for i, load in enumerate(load_data)]

pmm_data = get_pmm_data.get_pmm_data(example_col, 36, 12, loads, axial_limits)
pmm_data = calculation(default_loads=loads, col=example_col)

_ = pmm_plotter_plotly.plot(pmm_data)
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import os
import sys

# Now you can import from conc_col_pmm
from ...calc_document.document_wrapper import run

# "w", "h", "bar_size", "bar_cover", "bars_x", "bars_y", "fc", "fy", "cover_type", "transverse_type",
col_data = [24, 18, "#6", 2, 5, 2, 8000, 60, "Edge", "Spiral"]
col_data = [18, 24, "#6", 2, 5, 2, 8000, 60, "Edge", "Tied"]

# for each load case: P, Mx, My, and whether the calc should be shown
# Note that these load cases currently do not override the defaults
loads = [
[300, 100, 200, "yes"],
[500, 200, 100, "yes"],
[-100, 50, -60, "no"],
[11500, 300, -300, "no"],
[0, 200, 0, "yes"],
[0, 0, 200, "yes"],
]

# calc_report_example1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from efficalc import Input

from ...calc_document.plotting import get_pmm_data, pmm_plotter_plotly
from ...col import assign_max_min
from ...calc_document.calculation import calculation
from ...calc_document.plotting import pmm_plotter_plotly
from ...col.column import Column
from ...constants.rebar_data import BarSize
from ...pmm_search.load_combo import LoadCombination
from ...tests.conftest import getCalculatedColumnProps

# TODO: make this use the main calc callsite and get the plotly data from there
Expand Down Expand Up @@ -33,17 +32,15 @@ def example_col():

if __name__ == "__main__":
col = example_col()
axial_limits = assign_max_min.calculate_axial_load_limits(col)

# for each load case: P, Mx, My, and whether the calc should be shown
load_data = [
[300, 100, 200, True],
[-100, 50, -60, False],
[1500, 300, -300, False],
[300, 100, 200, "yes"],
[-100, 50, -60, "no"],
[1500, 300, -300, "no"],
]
loads = [LoadCombination(i, *load) for i, load in enumerate(load_data)]

pmm_data = get_pmm_data.get_pmm_data(col, 36, 12, loads, axial_limits)
pmm_data = calculation(default_loads=load_data, col=col)

fig = pmm_plotter_plotly.plot(pmm_data)

Expand Down
Loading