diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..f313a25 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + { + "lastFilter": { + "state": "OPEN", + "assignee": "janderson4" + } +} + { + "selectedUrlAndAccountId": { + "url": "https://github.com/janderson4/efficalc.git", + "accountId": "a7be60f2-e51f-4141-aa6b-ced89a97ed62" + } +} + { + "customColor": "", + "associatedIndex": 7 +} + + + + { + "keyToString": { + "Python tests.pytest in test_calculation.py.executor": "Run", + "Python.visual_test_document_wrapper.executor": "Run", + "Python.visual_test_pmm_plotter_plotly.executor": "Run", + "Python.visual_test_point_plotter.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "git-widget-placeholder": "main", + "last_opened_file_path": "C:/Users/ja299/PycharmProjects/efficalc" + } +} + + + + + + + + + + + + + + + + + + + + + 1730055042660 + + + + + + + + \ No newline at end of file diff --git a/examples/conc_col_pmm/README.md b/examples/conc_col_pmm/README.md index 74c3640..0d24760 100644 --- a/examples/conc_col_pmm/README.md +++ b/examples/conc_col_pmm/README.md @@ -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.`. 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 diff --git a/examples/conc_col_pmm/calc_document/calculation.py b/examples/conc_col_pmm/calc_document/calculation.py index e8f9dfd..6119fa9 100644 --- a/examples/conc_col_pmm/calc_document/calculation.py +++ b/examples/conc_col_pmm/calc_document/calculation.py @@ -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" @@ -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) diff --git a/examples/conc_col_pmm/calc_document/full_calc_document.py b/examples/conc_col_pmm/calc_document/full_calc_document.py index 23aaa92..afc4c01 100644 --- a/examples/conc_col_pmm/calc_document/full_calc_document.py +++ b/examples/conc_col_pmm/calc_document/full_calc_document.py @@ -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 diff --git a/examples/conc_col_pmm/calc_document/plotting/PMM.py b/examples/conc_col_pmm/calc_document/plotting/PMM.py index ead8908..ed34bff 100644 --- a/examples/conc_col_pmm/calc_document/plotting/PMM.py +++ b/examples/conc_col_pmm/calc_document/plotting/PMM.py @@ -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] \ No newline at end of file +class PMM: + X: ndarray + Y: ndarray + Z: ndarray + load_combos: list[LoadCombination] diff --git a/examples/conc_col_pmm/calc_document/plotting/get_pmm_data.py b/examples/conc_col_pmm/calc_document/plotting/get_pmm_data.py index 116528e..1c79a57 100644 --- a/examples/conc_col_pmm/calc_document/plotting/get_pmm_data.py +++ b/examples/conc_col_pmm/calc_document/plotting/get_pmm_data.py @@ -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( @@ -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) \ No newline at end of file + return PMM(X=X, Y=Y, Z=Z, load_combos=load_combos) diff --git a/examples/conc_col_pmm/calc_document/plotting/pmm_mesh.py b/examples/conc_col_pmm/calc_document/plotting/pmm_mesh.py index a066025..3e4b1c5 100644 --- a/examples/conc_col_pmm/calc_document/plotting/pmm_mesh.py +++ b/examples/conc_col_pmm/calc_document/plotting/pmm_mesh.py @@ -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 diff --git a/examples/conc_col_pmm/calc_document/plotting/pmm_plotter_plotly.py b/examples/conc_col_pmm/calc_document/plotting/pmm_plotter_plotly.py index 68ac524..4ca3c35 100644 --- a/examples/conc_col_pmm/calc_document/plotting/pmm_plotter_plotly.py +++ b/examples/conc_col_pmm/calc_document/plotting/pmm_plotter_plotly.py @@ -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 diff --git a/examples/conc_col_pmm/calc_document/plotting/point_plotter.py b/examples/conc_col_pmm/calc_document/plotting/point_plotter.py index 0988533..7e82102 100644 --- a/examples/conc_col_pmm/calc_document/plotting/point_plotter.py +++ b/examples/conc_col_pmm/calc_document/plotting/point_plotter.py @@ -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 @@ -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() diff --git a/examples/conc_col_pmm/calc_report_examples/calc_report_example1.pdf b/examples/conc_col_pmm/calc_report_examples/calc_report_example1.pdf deleted file mode 100644 index 2443ee3..0000000 Binary files a/examples/conc_col_pmm/calc_report_examples/calc_report_example1.pdf and /dev/null differ diff --git a/examples/conc_col_pmm/calc_report_examples/calc_report_example2.pdf b/examples/conc_col_pmm/calc_report_examples/calc_report_example2.pdf deleted file mode 100644 index 0b2957b..0000000 Binary files a/examples/conc_col_pmm/calc_report_examples/calc_report_example2.pdf and /dev/null differ diff --git a/examples/conc_col_pmm/col/col_canvas/draw_column_with_dimensions.py b/examples/conc_col_pmm/col/col_canvas/draw_column_with_dimensions.py index 2801b56..7e089e0 100644 --- a/examples/conc_col_pmm/col/col_canvas/draw_column_with_dimensions.py +++ b/examples/conc_col_pmm/col/col_canvas/draw_column_with_dimensions.py @@ -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 diff --git a/examples/conc_col_pmm/tests/test_pmm_plotter_plotly.py b/examples/conc_col_pmm/tests/test_pmm_plotter_plotly.py index 8649e2c..814b3f0 100644 --- a/examples/conc_col_pmm/tests/test_pmm_plotter_plotly.py +++ b/examples/conc_col_pmm/tests/test_pmm_plotter_plotly.py @@ -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) diff --git a/examples/conc_col_pmm/tests/visual_tests/visual_test_document_wrapper.py b/examples/conc_col_pmm/tests/visual_tests/visual_test_calculation_report.py similarity index 81% rename from examples/conc_col_pmm/tests/visual_tests/visual_test_document_wrapper.py rename to examples/conc_col_pmm/tests/visual_tests/visual_test_calculation_report.py index 09c0bd0..57be8f7 100644 --- a/examples/conc_col_pmm/tests/visual_tests/visual_test_document_wrapper.py +++ b/examples/conc_col_pmm/tests/visual_tests/visual_test_calculation_report.py @@ -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 diff --git a/examples/conc_col_pmm/tests/visual_tests/visual_test_pmm_plotter_plotly.py b/examples/conc_col_pmm/tests/visual_tests/visual_test_pmm.py similarity index 65% rename from examples/conc_col_pmm/tests/visual_tests/visual_test_pmm_plotter_plotly.py rename to examples/conc_col_pmm/tests/visual_tests/visual_test_pmm.py index f3ae628..edeafff 100644 --- a/examples/conc_col_pmm/tests/visual_tests/visual_test_pmm_plotter_plotly.py +++ b/examples/conc_col_pmm/tests/visual_tests/visual_test_pmm.py @@ -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 @@ -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)