From 92564410e0a1c63790612430e796e0d8f79cd85b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 15:44:11 +0000 Subject: [PATCH 1/4] Initial plan From b4470e1ca88f9334ca979fa5e93c78b90a342b5b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 15:47:41 +0000 Subject: [PATCH 2/4] Apply coefrot in computeAccel implementations --- expui/BiorthBasis.cc | 84 ++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/expui/BiorthBasis.cc b/expui/BiorthBasis.cc index e9c4e4536..acc7aa79b 100644 --- a/expui/BiorthBasis.cc +++ b/expui/BiorthBasis.cc @@ -818,10 +818,12 @@ namespace BasisClasses void Spherical::computeAccel(double x, double y, double z, Eigen::Ref acc) { - // Shift to center - x -= coefctr(0); - y -= coefctr(1); - z -= coefctr(2); + // Shift and rotate to expansion frame + Eigen::Vector3d pos {x, y, z}; + pos = coefrot * (pos - coefctr); + x = pos(0); + y = pos(1); + z = pos(2); // Get polar coordinates double R2 = x*x + y*y; @@ -925,9 +927,9 @@ namespace BasisClasses double tpoty = (potr - pott*costh/r)*y/r + potp*x/R2; double tpotz = potr*costh + pott*sinth*sinth/r; - // Return force not potential gradient + // Return force not potential gradient and rotate to caller frame // - acc << tpotx, tpoty, tpotz; + acc = coefrot.transpose() * Eigen::Vector3d(tpotx, tpoty, tpotz); } @@ -1813,10 +1815,12 @@ namespace BasisClasses void Cylindrical::computeAccel(double x, double y, double z, Eigen::Ref acc) { - // Shift to center - x -= coefctr(0); - y -= coefctr(1); - z -= coefctr(2); + // Shift and rotate to expansion frame + Eigen::Vector3d pos {x, y, z}; + pos = coefrot * (pos - coefctr); + x = pos(0); + y = pos(1); + z = pos(2); double R = sqrt(x*x + y*y); double phi = atan2(y, x); @@ -1834,8 +1838,8 @@ namespace BasisClasses tpoty = tpotR*y/R + tpotp*x/R; } - // Apply G to forces on return - acc << tpotx*G, tpoty*G, tpotz*G; + // Apply G and rotate forces on return + acc = coefrot.transpose() * Eigen::Vector3d(tpotx*G, tpoty*G, tpotz*G); } // Evaluate in cylindrical coordinates @@ -2499,10 +2503,12 @@ namespace BasisClasses void FlatDisk::computeAccel(double x, double y, double z, Eigen::Ref acc) { - // Shift to center - x -= coefctr(0); - y -= coefctr(1); - z -= coefctr(2); + // Shift and rotate to expansion frame + Eigen::Vector3d pos {x, y, z}; + pos = coefrot * (pos - coefctr); + x = pos(0); + y = pos(1); + z = pos(2); // Get thread id int tid = omp_get_thread_num(); @@ -2527,7 +2533,7 @@ namespace BasisClasses rpot = -G*totalMass*R/(r*r2 + 10.0*std::numeric_limits::min()); zpot = -G*totalMass*z/(r*r2 + 10.0*std::numeric_limits::min()); - acc << rpot, zpot, ppot; + acc = coefrot.transpose() * Eigen::Vector3d(rpot, zpot, ppot); } // Get the basis fields @@ -2595,7 +2601,7 @@ namespace BasisClasses poty = rpot*y/R + ppot*x/R; } - acc << potx, poty, zpot; + acc = coefrot.transpose() * Eigen::Vector3d(potx, poty, zpot); } @@ -3297,10 +3303,12 @@ namespace BasisClasses void CBDisk::computeAccel(double x, double y, double z, Eigen::Ref acc) { - // Shift to center - x -= coefctr(0); - y -= coefctr(1); - z -= coefctr(2); + // Shift and rotate to expansion frame + Eigen::Vector3d pos {x, y, z}; + pos = coefrot * (pos - coefctr); + x = pos(0); + y = pos(1); + z = pos(2); // Get thread id int tid = omp_get_thread_num(); @@ -3369,7 +3377,7 @@ namespace BasisClasses poty = rpot*y/R + ppot*x/R; } - acc << potx, poty, zpot; + acc = coefrot.transpose() * Eigen::Vector3d(potx, poty, zpot); } @@ -3792,10 +3800,12 @@ namespace BasisClasses void Slab::computeAccel(double x, double y, double z, Eigen::Ref acc) { - // Shift to center - x -= coefctr(0); - y -= coefctr(1); - z -= coefctr(2); + // Shift and rotate to expansion frame + Eigen::Vector3d pos {x, y, z}; + pos = coefrot * (pos - coefctr); + x = pos(0); + y = pos(1); + z = pos(2); // Loop indices // @@ -3868,8 +3878,9 @@ namespace BasisClasses } } - // Apply G to forces on return - acc << G*accx.real(), G*accy.real(), G*accz.real(); + // Apply G to forces on return and rotate to caller frame + acc = coefrot.transpose() * + Eigen::Vector3d(G*accx.real(), G*accy.real(), G*accz.real()); } @@ -4369,10 +4380,12 @@ namespace BasisClasses void Cube::computeAccel(double x, double y, double z, Eigen::Ref acc) { - // Shift to center - x -= coefctr(0); - y -= coefctr(1); - z -= coefctr(2); + // Shift and rotate to expansion frame + Eigen::Vector3d pos {x, y, z}; + pos = coefrot * (pos - coefctr); + x = pos(0); + y = pos(1); + z = pos(2); // Get thread id int tid = omp_get_thread_num(); @@ -4383,8 +4396,9 @@ namespace BasisClasses // Get the basis fields auto frc = ortho->get_force(expcoef, pos); - // Apply G to forces on return - acc << -G*frc(0).real(), -G*frc(1).real(), -G*frc(2).real(); + // Apply G to forces on return and rotate to caller frame + acc = coefrot.transpose() * + Eigen::Vector3d(-G*frc(0).real(), -G*frc(1).real(), -G*frc(2).real()); } std::vector Cube::cyl_eval(double R, double z, double phi) From 19f61d3cba9826fbeebd3c0104b8f777ca03d6b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 15:51:29 +0000 Subject: [PATCH 3/4] Fix FlatDisk off-grid component order in rotated accel --- expui/BiorthBasis.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expui/BiorthBasis.cc b/expui/BiorthBasis.cc index acc7aa79b..6131319eb 100644 --- a/expui/BiorthBasis.cc +++ b/expui/BiorthBasis.cc @@ -2533,7 +2533,7 @@ namespace BasisClasses rpot = -G*totalMass*R/(r*r2 + 10.0*std::numeric_limits::min()); zpot = -G*totalMass*z/(r*r2 + 10.0*std::numeric_limits::min()); - acc = coefrot.transpose() * Eigen::Vector3d(rpot, zpot, ppot); + acc = coefrot.transpose() * Eigen::Vector3d(rpot, ppot, zpot); } // Get the basis fields From a935940f994a266dd79ece3720906acd3af91401 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 20:46:32 +0000 Subject: [PATCH 4/4] Fix Cube::computeAccel redeclaration from coefficient rotation change --- expui/BiorthBasis.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/expui/BiorthBasis.cc b/expui/BiorthBasis.cc index 7930087a8..2efbb628b 100644 --- a/expui/BiorthBasis.cc +++ b/expui/BiorthBasis.cc @@ -4391,9 +4391,6 @@ namespace BasisClasses // Get thread id int tid = omp_get_thread_num(); - // Position vector - Eigen::Vector3d pos {x, y, z}; - // Get the basis fields auto frc = ortho->get_force(expcoef, pos);