From bfcf0b840dcc29ffebfdc5ebe0dd6803002caa76 Mon Sep 17 00:00:00 2001 From: StudioWEngineers Date: Tue, 5 May 2026 17:03:33 +0200 Subject: [PATCH 1/4] align DataFrame column names to SOFiSTiK ones --- .../cdb_reader/_internals/spring_result.py | 36 +++++------ tests/cdb_reader/test_spring_result.py | 59 ++++++++++++------- 2 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py index 5ce8875..7a7d8c1 100644 --- a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py +++ b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py @@ -54,12 +54,12 @@ def __init__(self, dll: SofDll) -> None: "LOAD_CASE", "GROUP", "ELEM_ID", - "FORCE", - "TRANSVERSAL_FORCE", - "MOMENT", - "DISPLACEMENT", - "TRANSVERSAL_DISPLACEMENT", - "ROTATION" + "P", + "PT", + "M", + "V", + "VT", + "PHI" ] ) self._dll = dll @@ -115,12 +115,12 @@ def get( quantity : str, default "FORCE" Quantity to retrieve. Must be one of: - - ``FORCE`` - - ``TRANSVERSAL_FORCE`` - - ``MOMENT`` - - ``DISPLACEMENT`` - - ``TRANSVERSAL_DISPLACEMENT`` - - ``ROTATION`` + - ``P`` + - ``PT`` + - ``M`` + - ``V`` + - ``VT`` + - ``PHI`` default : float or None, default None Value to return if the requested quantity is not found @@ -235,12 +235,12 @@ def _load(self, load_case: int) -> list[dict[str, float | int | str]]: "LOAD_CASE": load_case, "GROUP": 0, "ELEM_ID": spri_res.m_nr, - "FORCE": spri_res.m_p, - "TRANSVERSAL_FORCE": spri_res.m_pt, - "MOMENT": spri_res.m_m, - "DISPLACEMENT": spri_res.m_v, - "TRANSVERSAL_DISPLACEMENT": spri_res.m_vt, - "ROTATION": spri_res.m_phi + "P": spri_res.m_p, + "PT": spri_res.m_pt, + "M": spri_res.m_m, + "V": spri_res.m_v, + "VT": spri_res.m_vt, + "PHI": spri_res.m_phi } ) diff --git a/tests/cdb_reader/test_spring_result.py b/tests/cdb_reader/test_spring_result.py index e104dbb..dd031e4 100644 --- a/tests/cdb_reader/test_spring_result.py +++ b/tests/cdb_reader/test_spring_result.py @@ -19,17 +19,35 @@ "LOAD_CASE", "GROUP", "ELEM_ID", - "FORCE", - "TRANSVERSAL_FORCE", - "MOMENT", - "DISPLACEMENT", - "TRANSVERSAL_DISPLACEMENT", - "ROTATION", + "P", + "PT", + "M", + "V", + "VT", + "PHI", ] _DATA = [ - (1000, 10, 102, 9.0, 0.0, 1.0000000031710769e-29, 0.09000000357627869, 0.07000000029802322, 0.0), - (1000, 11, 113, 1.0000000031710769e-29, 1.4142135381698608, 1.0000000031710769e-29, 0.11313708126544952, 0.01414213515818119, 0.0), + ( + 1000, + 10, + 102, + 9.0, + 0.0, + 1.0000000031710769e-29, + 0.09000000357627869, + 0.07000000029802322, 0.0 + ), ( + 1000, + 11, + 113, + 1.0000000031710769e-29, + 1.4142135381698608, + 1.0000000031710769e-29, + 0.11313708126544952, + 0.01414213515818119, + 0.0 + ), ] @@ -68,35 +86,32 @@ def test_data(self) -> None: def test_get(self) -> None: with self.subTest(msg="Axial force"): - self.assertEqual(self.cdb.spring.result.get(102, 1000, "FORCE"), 9) + self.assertEqual(self.cdb.spring.result.get(102, 1000, "P"), 9) with self.subTest(msg="Transversal force"): - self.assertEqual( - self.cdb.spring.result.get(102, 1000, "TRANSVERSAL_FORCE"), - 0 - ) + self.assertEqual(self.cdb.spring.result.get(102, 1000, "PT"), 0) with self.subTest(msg="Moment"): self.assertEqual( - self.cdb.spring.result.get(113, 1000, "MOMENT"), + self.cdb.spring.result.get(113, 1000, "M"), 1.0000000031710769e-29 ) with self.subTest(msg="Displacement"): self.assertEqual( - self.cdb.spring.result.get(102, 1000, "DISPLACEMENT"), + self.cdb.spring.result.get(102, 1000, "V"), 0.09000000357627869 ) with self.subTest(msg="Transversal displacement"): self.assertEqual( - self.cdb.spring.result.get(102, 1000, "TRANSVERSAL_DISPLACEMENT"), + self.cdb.spring.result.get(102, 1000, "VT"), 0.07000000029802322 ) with self.subTest(msg="Rotation"): self.assertEqual( - self.cdb.spring.result.get(113, 1000, "ROTATION"), + self.cdb.spring.result.get(113, 1000, "PHI"), 0 ) @@ -114,12 +129,12 @@ def test_get_after_clear(self) -> None: self.cdb.spring.result.clear(1000) with self.subTest(msg="Check clear method"): with self.assertRaises(LookupError): - self.cdb.spring.result.get(113, 1000, "MOMENT") + self.cdb.spring.result.get(113, 1000, "M") self.cdb.spring.result.load(1000) with self.subTest(msg="Check indexes management"): self.assertEqual( - self.cdb.spring.result.get(113, 1000, "MOMENT"), + self.cdb.spring.result.get(113, 1000, "M"), 1.0000000031710769e-29 ) @@ -127,12 +142,12 @@ def test_get_after_clear_all(self) -> None: self.cdb.spring.result.clear_all() with self.subTest(msg="Check clear_all method"): with self.assertRaises(LookupError): - self.cdb.spring.result.get(113, 1000, "MOMENT") + self.cdb.spring.result.get(113, 1000, "M") self.cdb.spring.result.load(1000) with self.subTest(msg="Check indexes management"): self.assertEqual( - self.cdb.spring.result.get(113, 1000, "MOMENT"), + self.cdb.spring.result.get(113, 1000, "M"), 1.0000000031710769e-29 ) @@ -140,6 +155,6 @@ def test_load_with_duplicated_load_cases(self) -> None: self.cdb.spring.result.clear_all() self.cdb.spring.result.load([1000] + [1000]) self.assertEqual( - self.cdb.spring.result.get(113, 1000, "MOMENT"), + self.cdb.spring.result.get(113, 1000, "M"), 1.0000000031710769e-29 ) From f14e52bc40517352da7c9f3605abc3f4834e10dd Mon Sep 17 00:00:00 2001 From: StudioWEngineers Date: Tue, 5 May 2026 17:05:24 +0200 Subject: [PATCH 2/4] align DataFrame column names to SOFiSTiK ones --- .../cdb_reader/_internals/spring_result.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py index 7a7d8c1..30e3d62 100644 --- a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py +++ b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py @@ -23,12 +23,12 @@ class _SpringResult: * ``LOAD_CASE`` load case number * ``GROUP`` element group * ``ELEM_ID`` element number - * ``FORCE`` axial force - * ``TRANSVERSAL_FORCE``: transversal force - * ``MOMENT``: axial moment - * ``DISPLACEMENT``: axial displacement - * ``TRANSVERSAL_DISPLACEMENT``: transversal displacement - * ``ROTATION``: axial rotation + * ``P`` axial force + * ``PT``: transversal force + * ``M``: axial moment + * ``V``: axial displacement + * ``VT``: transversal displacement + * ``PHI``: axial rotation The ``DataFrame`` uses a MultiIndex with levels ``ELEM_ID`` and ``LOAD_CASE`` (in this specific order) to enable fast lookups via the From 13885ca581edc25ee2935385b2b4e66a3bb655f3 Mon Sep 17 00:00:00 2001 From: StudioWEngineers Date: Tue, 5 May 2026 17:20:19 +0200 Subject: [PATCH 3/4] add force and displacements in global directions --- .../cdb_reader/_internals/spring_result.py | 27 +++++++++++-- tests/cdb_reader/test_spring_result.py | 39 +++++++++++++------ 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py index 30e3d62..2bec128 100644 --- a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py +++ b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py @@ -25,9 +25,15 @@ class _SpringResult: * ``ELEM_ID`` element number * ``P`` axial force * ``PT``: transversal force + * ``PTX``: force in global X-direction + * ``PTY``: force in global Y-direction + * ``PTZ``: force in global Z-direction * ``M``: axial moment * ``V``: axial displacement * ``VT``: transversal displacement + * ``VTX``: displacement in global X-direction + * ``VTY``: displacement in global Y-direction + * ``VTZ``: displacement in global Z-direction * ``PHI``: axial rotation The ``DataFrame`` uses a MultiIndex with levels ``ELEM_ID`` and @@ -39,9 +45,6 @@ class _SpringResult: Not all available quantities are retrieved and stored. In particular: - * the three components along the global X, Y and Z axes for: - - spring force - - spring displacement * nonlinear effects * all quantities available if a workload has beed defined @@ -56,9 +59,15 @@ def __init__(self, dll: SofDll) -> None: "ELEM_ID", "P", "PT", + "PTX", + "PTY", + "PTZ", "M", "V", "VT", + "VTX", + "VTY", + "VTZ", "PHI" ] ) @@ -117,9 +126,15 @@ def get( - ``P`` - ``PT`` + - ``PTX`` + - ``PTY`` + - ``PTZ`` - ``M`` - ``V`` - ``VT`` + - ``VTX`` + - ``VTY`` + - ``VTZ`` - ``PHI`` default : float or None, default None @@ -237,9 +252,15 @@ def _load(self, load_case: int) -> list[dict[str, float | int | str]]: "ELEM_ID": spri_res.m_nr, "P": spri_res.m_p, "PT": spri_res.m_pt, + "PTX": spri_res.m_ptx, + "PTY": spri_res.m_pty, + "PTZ": spri_res.m_ptz, "M": spri_res.m_m, "V": spri_res.m_v, "VT": spri_res.m_vt, + "VTX": spri_res.m_vtx, + "VTY": spri_res.m_vty, + "VTZ": spri_res.m_vtz, "PHI": spri_res.m_phi } ) diff --git a/tests/cdb_reader/test_spring_result.py b/tests/cdb_reader/test_spring_result.py index dd031e4..5355cc4 100644 --- a/tests/cdb_reader/test_spring_result.py +++ b/tests/cdb_reader/test_spring_result.py @@ -21,33 +21,48 @@ "ELEM_ID", "P", "PT", + "PTX", + "PTY", + "PTZ", "M", "V", "VT", + "VTX", + "VTY", + "VTZ", "PHI", ] - _DATA = [ - ( - 1000, - 10, - 102, + [ + 1000, 10, 102, 9.0, 0.0, + 0.0, + 0.0, + 0.0, 1.0000000031710769e-29, 0.09000000357627869, - 0.07000000029802322, 0.0 - ), ( - 1000, - 11, - 113, + 0.07000000029802322, + -0.07000000029802322, + 0.0, + 0.0, + 0.0, + ], + [ + 1000, 11, 113, 1.0000000031710769e-29, 1.4142135381698608, + -1.0, + -1.0, + 0.0, 1.0000000031710769e-29, 0.11313708126544952, 0.01414213515818119, - 0.0 - ), + -0.009999999776482582, + -0.009999999776482582, + 0.0, + 0.0, + ], ] From 4c5dbfa56d1bbe17f0674e9ea16ecb1928bdef71 Mon Sep 17 00:00:00 2001 From: StudioWEngineers Date: Tue, 5 May 2026 17:22:25 +0200 Subject: [PATCH 4/4] remove default value for quantity from get method --- src/py_sofistik_utils/cdb_reader/_internals/spring_result.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py index 2bec128..7be7186 100644 --- a/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py +++ b/src/py_sofistik_utils/cdb_reader/_internals/spring_result.py @@ -110,7 +110,7 @@ def get( self, element_id: int, load_case: int, - quantity: str = "FORCE", + quantity: str, default: float | None = None ) -> float: """Retrieve the requested cable result. @@ -121,7 +121,7 @@ def get( Cable element number load_case : int Load case number - quantity : str, default "FORCE" + quantity : str Quantity to retrieve. Must be one of: - ``P``