Improved printing of external potential
This commit is contained in:
parent
8adb4ac813
commit
dd31b63215
3 changed files with 57 additions and 35 deletions
39
external.h
39
external.h
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "double3.h"
|
||||
|
||||
|
|
@ -15,11 +16,17 @@ public:
|
|||
}
|
||||
}
|
||||
virtual void calc_gravity() = 0;
|
||||
bool is_active;
|
||||
virtual void print_info() {}
|
||||
void set_name(const std::string &name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
bool is_active = false;
|
||||
protected:
|
||||
double potential;
|
||||
double3 acceleration, jerk;
|
||||
double3 x, v;
|
||||
std::string name = "ext";
|
||||
void set_coordinates(double3 x, double3 v)
|
||||
{
|
||||
this->x = x;
|
||||
|
|
@ -30,23 +37,38 @@ protected:
|
|||
class Plummer : public External_gravity {
|
||||
public:
|
||||
Plummer(double m, double b) : m(m), b(b) {is_active=(m>0);}
|
||||
void calc_gravity();
|
||||
void calc_gravity() override;
|
||||
void print_info() override
|
||||
{
|
||||
if (!is_active) return;
|
||||
printf("m_%-5s = %.4E b_%-5s = %.4E\n", name.c_str(), m, name.c_str(), b);
|
||||
}
|
||||
private:
|
||||
double m, b;
|
||||
};
|
||||
|
||||
class Miyamoto_Nagai : public External_gravity {
|
||||
public:
|
||||
Miyamoto_Nagai(double m, double a, double b) : m(m), a(a), b(b) {is_active=(m>0);}
|
||||
Miyamoto_Nagai(double m, double a, double b) : m(m), a(a), b(b) {is_active=(m>0); this->set_name("disk");}
|
||||
void calc_gravity();
|
||||
void print_info() override
|
||||
{
|
||||
if (!is_active) return;
|
||||
printf("m_%-5s = %.4E a_%-5s = %.4E b_%-5s = %.4E\n", name.c_str(), m, name.c_str(), a, name.c_str(), b);
|
||||
}
|
||||
private:
|
||||
double m, a, b;
|
||||
};
|
||||
|
||||
class Logarithmic_halo : public External_gravity {
|
||||
public:
|
||||
Logarithmic_halo(double v_halo, double r_halo) : v2_halo(v_halo*v_halo), r2_halo(r_halo*r_halo) {is_active=(r_halo>0);}
|
||||
void calc_gravity();
|
||||
Logarithmic_halo(double v_halo, double r_halo) : v2_halo(v_halo*v_halo), r2_halo(r_halo*r_halo) {is_active=(r_halo>0); this->set_name("halo");}
|
||||
void calc_gravity() override;
|
||||
void print_info() override
|
||||
{
|
||||
if (!is_active) return;
|
||||
printf("v_%-4s = %.6E r_%-4s = %.4E\n", name.c_str(), sqrt(v2_halo), name.c_str(), sqrt(r2_halo));
|
||||
}
|
||||
private:
|
||||
double v2_halo, r2_halo;
|
||||
};
|
||||
|
|
@ -54,7 +76,12 @@ private:
|
|||
class Dehnen : public External_gravity {
|
||||
public:
|
||||
Dehnen(double m, double r, double gamma) : m(m), r(r), gamma(gamma) {is_active=(m>0);}
|
||||
void calc_gravity();
|
||||
void calc_gravity() override;
|
||||
void print_info() override
|
||||
{
|
||||
if (!is_active) return;
|
||||
printf("m_%-5s = %.4E r_%-5s = %.4E g_%-5s = %.4E\n", name.c_str(), m, name.c_str(), r, name.c_str(), gamma);
|
||||
}
|
||||
private:
|
||||
double m, r, gamma;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue