-
Notifications
You must be signed in to change notification settings - Fork 111
Implement CompositePotential, planarCompositePotential, and linearCompositePotential classes for unified potential combination interface #794
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
Conversation
jobovy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Please also change MWPotential2014's definition to a CompositePotential and also those of all of the MW potentials in mwpotentials.py to CompositePotentials.
To support C integration, we'll also have to adjust _parse_pot in the integrateFullOrbit.py code, which now goes through a list but will have to go through the CompositePotential list as well in the future (and similarly, lists should be deprecated in versions beyond 1.13.x, maybe we can use the same decorator as mentioned in my review?)
Done in commit 1bc3edd. Changed For the |
jobovy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Also implement the handling of CompositePotential in _parse_pot in integrateFullOrbit.py, so these can be passed to C for orbit integration properly
Implemented in commit 8dea636. Added CompositePotential handling at the start of if isinstance(pot, potential.CompositePotential.CompositePotential):
pot = list(pot)This extracts the internal list from CompositePotential so the rest of the parsing logic works unchanged. Tested successfully with MWPotential2014. |
|
@copilot Please also implement the mul and div functions for CompositePotential in the way that makes sense (should apply to each component potential). And please test (maybe add a test) that all methods of Force and Potential can be called on a CompositePotential using MWPotential2014 as an example. |
Implemented in commit e6313e2. Added |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #794 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 209 213 +4
Lines 30659 30740 +81
Branches 627 627
=======================================
+ Hits 30632 30713 +81
Misses 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
04ae321 to
178674b
Compare
|
@copilot Lots of tests are failing, some at least because the new CompositePotential objects are not being converted to planarPotentials correctly. So please edit the code in planarPotential.py to also handle CompositePotential objects in the different routines to create a planarPotential (there's a routine for RZPotentials and one for general potentials I believe). In general, it may be worthwhile to see where lists are mentioned in galpy and check whether these are lists of potentials, because in that case CompositePotential objects will now also have to be handled. Also implement item assignment for CompositePotential so things like work as expected (that is, the new CompositePotential has the same components as the input MWPotential2014, but with the amplitude of the second entry raised by 50%). Remember to install pre-commit! Thanks! |
Implemented in commit 1684841: Planar/Vertical Potential Conversion:
Item Assignment:
Tests Added:
All CompositePotential tests pass (8/8). |
f3912ac to
2502279
Compare
…acing the previous list-based combinations
…nation Co-authored-by: jobovy <[email protected]>
…on baseCompositePotential base class
…nternally (#799) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jobovy <[email protected]> Co-authored-by: Jo Bovy <[email protected]>
…800) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jobovy <[email protected]> Co-authored-by: Jo Bovy <[email protected]>
…of potentials with combinations (#802) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jobovy <[email protected]> Co-authored-by: Jo Bovy <[email protected]>
…al/force __repr__method style
…onversion to planarForces when necessary (#805) Co-authored-by: Jo Bovy <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jobovy <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…ically deal with planar conversions. Abstract out the list deprecation and conversion so it can be used outside of the decorator and apply it to Orbit methods
…fallback for integration
e437b26 to
154c37b
Compare
…with the switch to CompositePotential and add some further tests
CompositePotential Implementation - Complete
This PR implements
CompositePotentialandplanarCompositePotentialclasses that allow combinations of potentials to be called with method functions like individual potentials.Final Summary of All Changes
Core CompositePotential Implementation
CompositePotentialclass inheriting fromPotential__add__,__mul__,__div__,__setitem__,__getitem__(with slicing)_roSet/_voSetfrom first potentialphysical_compatibleplanarCompositePotential Implementation
planarCompositePotentialclass ingalpy/potential/planarCompositePotential.pyplanarPotential, implements all derivative methods (_evaluate,_Rforce,_phitorque,_R2deriv,_phi2deriv,_Rphideriv)planarForce.__add__and__radd__to returnplanarCompositePotentialtoPlanarPotentialandRZToplanarPotentialto returnplanarCompositePotentialfor multiple potentials_parse_potinintegratePlanarOrbit.pyfor C orbit integrationCode Review Refinements
__add__to not support lists directlyevaluateSurfaceDensitiesandevaluaterforces# pragma: no coverto unreachable codeDecorator Refactoring
@potential_list_of_potentials_inputdecorator to:integrateFullOrbitandintegrateFullOrbit_sosepifreq,verticalfreq,flattening,omegac,rtide,ttensor,zvc,tdynKey Features
✅ 3D Addition:
pot1 + pot2returnsCompositePotential✅ 2D Addition:
planar1 + planar2returnsplanarCompositePotential✅
toPlanarPotential([pot1, pot2])returnsplanarCompositePotential✅
toPlanarPotential(MWPotential2014)returnsplanarCompositePotential✅ Method calls:
combined.Rforce(R, z)works like individual potentials✅ Multiplication/division:
combined * 2.0applies to all components✅ Item assignment:
MWPotential2014[2] *= 1.5modifies individual component✅ Slicing:
MWPotential2014[1:]returnsCompositePotential✅ Backward compatible:
combined == [pot1, pot2]returnsTrue✅ List deprecation: All functions emit
DeprecationWarningfor lists✅ C integration: Works with C orbit integration via
_parse_potTesting
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.