From 8d83c024db5f802833eb599170dc5508892a59d7 Mon Sep 17 00:00:00 2001 From: jthomas475 Date: Mon, 8 Jun 2026 10:33:39 -0400 Subject: [PATCH 1/3] ChamberSphere Periodicity Fix Updated phase_tsys and phase_tdias calculations for elastance values in ChamberSphere --- src/model/ChamberSphere.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/model/ChamberSphere.cpp b/src/model/ChamberSphere.cpp index 6971e7713..b3a086c72 100644 --- a/src/model/ChamberSphere.cpp +++ b/src/model/ChamberSphere.cpp @@ -119,8 +119,16 @@ void ChamberSphere::get_elastance_values(std::vector& parameters) { const auto T_cardiac = model->cardiac_cycle_period; const auto t_in_cycle = fmod(model->time, T_cardiac); - const double S_plus = 0.5 * (1.0 + tanh((t_in_cycle - tsys) / steepness)); - const double S_minus = 0.5 * (1.0 - tanh((t_in_cycle - tdias) / steepness)); + + auto warp_signed = [T_cardiac](double dt){ + return fmod(dt + 1.5 * T_cardiac, T_cardiac) - 0.5 * T_cardiac; + }; + + const double phase_tsys = warp_signed(t_in_cycle - tsys); + const double phase_tdias = warp_signed(t_in_cycle - tdias); + + const double S_plus = 0.5 * (1.0 + tanh((phase_tsys) / steepness)); + const double S_minus = 0.5 * (1.0 - tanh((phase_tdias - tdias) / steepness)); // indicator function const double f = S_plus * S_minus; From 9eedbf2e7ac18b9bab704d98fa74ae645820be57 Mon Sep 17 00:00:00 2001 From: jthomas475 Date: Wed, 10 Jun 2026 14:48:45 -0400 Subject: [PATCH 2/3] Periodic ChamberSphere Logic Fix Corrected calculation of S_minus variable in ChamberSphere.cpp (removed "- tdias" shift that was a remnant of original calculation of S_minus) After correcting, plotted ChamberSphere outputs with and without periodic fix. --- package.json | 2 +- src/model/ChamberSphere.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 01e9f537a..48e7f2969 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "prettier": "^3.6.2" + "prettier": "3.8.4" }, "scripts": { "format": "prettier --write \"**/*.json\"", diff --git a/src/model/ChamberSphere.cpp b/src/model/ChamberSphere.cpp index b3a086c72..8071b61de 100644 --- a/src/model/ChamberSphere.cpp +++ b/src/model/ChamberSphere.cpp @@ -127,8 +127,8 @@ void ChamberSphere::get_elastance_values(std::vector& parameters) { const double phase_tsys = warp_signed(t_in_cycle - tsys); const double phase_tdias = warp_signed(t_in_cycle - tdias); - const double S_plus = 0.5 * (1.0 + tanh((phase_tsys) / steepness)); - const double S_minus = 0.5 * (1.0 - tanh((phase_tdias - tdias) / steepness)); + const double S_plus = 0.5 * (1.0 + tanh(phase_tsys / steepness)); + const double S_minus = 0.5 * (1.0 - tanh(phase_tdias / steepness)); // indicator function const double f = S_plus * S_minus; From 7ffbc075318bb01bcb391a2e21537ca20e32cb4c Mon Sep 17 00:00:00 2001 From: jthomas475 Date: Thu, 11 Jun 2026 12:12:00 -0400 Subject: [PATCH 3/3] Codeformat and codecheck fixes Prettier binary in node_modules was not executable on Windows filesystem (/mnt/c), so npm run format/check would fail with a shell syntax error. Thus, installed prettier globally and replaced local binary with script that points to global install. Similar fix for clang-format --- CMakeLists.txt | 2 +- package.json | 2 +- src/model/Block.h | 4 ++-- src/model/ChamberSphere.cpp | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e0468eed..8476c5acf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,7 @@ add_subdirectory("distribution") # Enforce and check code format # ----------------------------------------------------------------------------- # set paths of files to format -set(SDIR ${PROJECT_SOURCE_DIR}/src/**/) +set(SDIR ${PROJECT_SOURCE_DIR}/src) # format the code add_custom_target(codeformat diff --git a/package.json b/package.json index 48e7f2969..a23ff14d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "prettier": "3.8.4" + "prettier": "^3.8.4" }, "scripts": { "format": "prettier --write \"**/*.json\"", diff --git a/src/model/Block.h b/src/model/Block.h index 849aeb956..752a5c0c0 100644 --- a/src/model/Block.h +++ b/src/model/Block.h @@ -25,7 +25,7 @@ * to the global system. */ struct TripletsContributions { - TripletsContributions() {}; + TripletsContributions(){}; /** * @brief Set the number of triplets that the element contributes * to the global system. @@ -33,7 +33,7 @@ struct TripletsContributions { * @param E Contributions to E matrix * @param D Contributions to dC/dy matrix */ - TripletsContributions(int F, int E, int D) : F(F), E(E), D(D) {}; + TripletsContributions(int F, int E, int D) : F(F), E(E), D(D){}; /** * @brief Set the number of triplets that the element contributes * to the global system. diff --git a/src/model/ChamberSphere.cpp b/src/model/ChamberSphere.cpp index 8071b61de..645a7089d 100644 --- a/src/model/ChamberSphere.cpp +++ b/src/model/ChamberSphere.cpp @@ -119,8 +119,7 @@ void ChamberSphere::get_elastance_values(std::vector& parameters) { const auto T_cardiac = model->cardiac_cycle_period; const auto t_in_cycle = fmod(model->time, T_cardiac); - - auto warp_signed = [T_cardiac](double dt){ + auto warp_signed = [T_cardiac](double dt) { return fmod(dt + 1.5 * T_cardiac, T_cardiac) - 0.5 * T_cardiac; };