Tried to find the MN disk parameters from the particles' coordinate medians

This commit is contained in:
Yohai Meiron 2020-04-22 23:32:05 -04:00
parent c2051e9596
commit 80e6a8d635
4 changed files with 166 additions and 49 deletions

View file

@ -28,7 +28,7 @@ public:
{
acc = gsl_interp_accel_alloc();
spline = gsl_spline_alloc(gsl_interp_cspline, x.size());
gsl_spline_init(spline, x.data(), y.data(), x.size());
gsl_spline_init(spline, x.data(), y.data(), x.size());
}
Interp() {}
inline double operator()(double x) const
@ -112,40 +112,11 @@ int integrate(const double y0[], const double t_max, const double stride_size, d
}
}
double circular_energy(double(*pot)(double), double L)
{
auto effective_potential = [&](double r) { return pot(r)+0.5*(L*L)/(r*r); };
return pot(3);
}
/*def circular_energy(Phi, L, PhiPrime=None, InitialGuess=1.0, GetRadius=False):
EffectivePotential = lambda r: Phi(r) + 0.5*(L/r)**2
EffectivePotentialPrime = None
if not PhiPrime is None: EffectivePotentialPrime = lambda r: PhiPrime(r) - L**2/r**3
Minimization = scipy.optimize.minimize(EffectivePotential, InitialGuess, method='BFGS', jac=EffectivePotentialPrime, tol=1.0E-08)
# Minimization = scipy.optimize.minimize(EffectivePotential, InitialGuess, method='L-BFGS-B', bounds=[(0,None)], jac=EffectivePotentialPrime)
# There is some risk that the negative value of r will be found as the minimum. To avoid this we can either set boundary conditions which might complicate the the numerical procedure, or just accept this and return the absolute value, which we can do here.
if GetRadius: return Minimization.fun, abs(Minimization.x[0])
return Minimization.fun*/
int main()
{
std::cout << "Hi" << std::endl;
/*std::vector<double> x(500);
std::vector<double> y(500);
for (int i=0; i<500; i++) {
x[i] = i;
y[i] = 2*i;
}
// populate x, y, then:
boost::math::barycentric_rational<double> interpolant(std::move(x), std::move(y));
std::cout << interpolant(5.5) << std::endl;*/
double y[12];
double y0[] = {80,0,0,0,80,0};
for (int i=0; i<8000; i++)