Giter Site home page Giter Site logo

Logarithmic potential energy about agama HOT 7 CLOSED

adrn avatar adrn commented on June 26, 2024
Logarithmic potential energy

from agama.

Comments (7)

eugvas avatar eugvas commented on June 26, 2024 1

ok, it turned out to be not such a big deal to add an extra dimensional parameter (length unit) to the Logarithmic potential, and restore the invariance of its zero-point w.r.t. the choice of units (available in the latest commit).

from agama.

adrn avatar adrn commented on June 26, 2024

BTW: I'm assuming, based on this code in the potential factory that what is input to agama.Potential(..., scaleradius) actually becomes the coreradius in the defined logarithmic potential..

from agama.

eugvas avatar eugvas commented on June 26, 2024

hmm, when I run the first snippet of your code, it prints out 0.0172100968809 – same as the analytic expression..
Did I say that it uses "sigma" anywhere? if so, this must be a mistake; sigma (the velocity dispersion in a self-consistent isothermal model) is \sqrt{2} v0, but the parameters passed to the potential constructor are indeed v0 and scaleRadius (= core radius).

from agama.

adrn avatar adrn commented on June 26, 2024

Oh, sorry, I forgot something in the snippet -- I had also used:

import astropy.units as u
agama.setUnits(length=u.kpc, time=u.Myr, mass=u.Msun)

I agree -- if I don't do the setUnits, I get what you see. But not after setUnits.

from agama.

adrn avatar adrn commented on June 26, 2024

Did I say that it uses "sigma" anywhere?

The variable names and comment reference sigma here:

\f$ \Phi(r) = (1/2) \sigma^2 \ln[ r_c^2 + x^2 + (y/p)^2 + (z/q)^2 ] \f$. */

from agama.

eugvas avatar eugvas commented on June 26, 2024

ah, I see.
the problem is actually in the definition of the logarithmic potential:
$\Phi = 0.5 v_0^2 \ln(r_c^2+r^2)$
clearly, a dimensional quantity under the logarithm paves a pathway to nasty surprises! it should be understood (implicitly) as taking $\ln([r_c^2+r^2]/L^2)$, where $L$ is the length unit. Since only the potential difference between two points is important in practice, the choice of $L$ rarely matters – unless, of course, you just want to compute the value of the potential for some reason. By calling setUnits(...), you change the value of $L$ expressed in some fixed internal code units, so the potential gets a constant offset. You may verify that the potential difference between any two points remains unchanged.
I don't know what is the best way to proceed here: one could redefine $\Phi = 0.5 v_0^2 \ln(1 + r^2/r_c^2)$, but this would not work if $r_c=0$ (which is allowed). And since the unit conversion occurs at a higher level than the potential evaluation itself, there isn't really any way to make the potential instance aware of the units choice (quite the opposite – the whole code is designed to be agnostic to units, and this works fine everywhere except this peculiar case).

Thanks for catching the wrong usage of sigma – it is indeed intended to be v0, I will update the code shortly. The docs (reference.pdf) are correct though.

from agama.

adrn avatar adrn commented on June 26, 2024

Ah, of course - that makes sense.

from agama.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.