Added a new acceptor based on targets in a data file
This commit is contained in:
parent
3f4025d9fb
commit
582f1f4d8b
4 changed files with 52 additions and 16 deletions
|
|
@ -11,6 +11,8 @@
|
|||
#include <time.h> // We just want to print the timestamp
|
||||
#include <unistd.h>
|
||||
|
||||
#include "loadtxt.h"
|
||||
|
||||
using double3 = Eigen::Vector3d;
|
||||
using Generator = std::default_random_engine;
|
||||
|
||||
|
|
@ -113,6 +115,42 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class Match_data : public Acceptor {
|
||||
public:
|
||||
Match_data() :
|
||||
data(Loadtxt("Peter_7D.txt.input", {2, 3, 4, 5, 6, 7}, 3).get_cols()),
|
||||
n(data[0].size()),
|
||||
tolerance(0.1)
|
||||
{
|
||||
constexpr double kms_to_kpcGyr = 1.0226911647958985;
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
data[3][i] *= kms_to_kpcGyr;
|
||||
data[4][i] *= kms_to_kpcGyr;
|
||||
data[5][i] *= kms_to_kpcGyr;
|
||||
}
|
||||
}
|
||||
bool operator()(const double w[6]) const override
|
||||
{
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned k = 0; k < 6; k++) {
|
||||
if (abs((w[k] - data[k][i])/w[k]) > 0.1) break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void output_information(std::ostream& stream) const override
|
||||
{
|
||||
stream << "# Acceptor type: match data\n";
|
||||
stream << "# tolerance = " << std::setw(13) << tolerance << '\n';
|
||||
}
|
||||
private:
|
||||
std::vector<std::vector<double>> data;
|
||||
unsigned n;
|
||||
double tolerance;
|
||||
};
|
||||
|
||||
class Initial_conditions {
|
||||
public:
|
||||
virtual std::array<double,6> operator()(Generator& generator) const = 0;
|
||||
|
|
@ -171,14 +209,14 @@ public:
|
|||
Box_initial_conditions(double x_max, double v_max)
|
||||
: x_max(x_max), v_max(v_max)
|
||||
{
|
||||
position_distribution = std::uniform_real_distribution(-x_max, x_max);
|
||||
velocity_distribution = std::uniform_real_distribution(-v_max, v_max);
|
||||
position_distribution = std::uniform_real_distribution<double>(-x_max, x_max);
|
||||
velocity_distribution = std::uniform_real_distribution<double>(-v_max, v_max);
|
||||
}
|
||||
std::array<double,6> operator()(Generator& generator) const override
|
||||
{
|
||||
std::array<double,6> result;
|
||||
for (int i=0; i<3; i++) result[i] = position_distribution(generator);
|
||||
for (int i=3; i<6; i++) result[i] = velocity_distribution(generator);
|
||||
for (unsigned i=0; i<3; i++) result[i] = position_distribution(generator);
|
||||
for (unsigned i=3; i<6; i++) result[i] = velocity_distribution(generator);
|
||||
return result;
|
||||
}
|
||||
void output_information(std::ostream& stream) const override
|
||||
|
|
@ -191,7 +229,7 @@ public:
|
|||
}
|
||||
private:
|
||||
double x_max, v_max;
|
||||
mutable std::uniform_real_distribution<> position_distribution, velocity_distribution;
|
||||
mutable std::uniform_real_distribution<double> position_distribution, velocity_distribution;
|
||||
};
|
||||
|
||||
class Scattering_experiment {
|
||||
|
|
@ -298,17 +336,13 @@ int main()
|
|||
std::cout << "Hi\n";
|
||||
|
||||
const double t_max = 11.65551390; // Gyr
|
||||
double3 target_pos = {-9.1817914423447837E+03, -2.3161972143758221E+03, 4.2321813890923086E+03}; // pc
|
||||
double3 target_vel = { 1.6995805137819784E+02, 1.3476658021349482E+02, -1.3342192079702110E+02}; // km/s
|
||||
// Unit adjustment
|
||||
target_pos *= 0.001; // Now in kpc
|
||||
target_vel *= 1.0226911647958985; // Now in kpc/Gyr
|
||||
|
||||
In_box_cyl accept(5, 50, target_pos, target_vel);
|
||||
Uniform_sphere_escape_velocity_cutoff uniform_sphere_escape_velocity_cutoff(75, 1.82777387E+07, 9.86242602E+00);
|
||||
|
||||
Scattering_experiment scattering_experiment("results.dat", t_max, 1024*256, uniform_sphere_escape_velocity_cutoff, Accept_all());
|
||||
//scattering_experiment.set_concurrency(1);
|
||||
auto zzzzz = Match_data();
|
||||
|
||||
Scattering_experiment scattering_experiment("results.dat", t_max, 1024*1024, uniform_sphere_escape_velocity_cutoff, std::ref(zzzzz));
|
||||
scattering_experiment.set_concurrency(80);
|
||||
scattering_experiment.write_header();
|
||||
scattering_experiment.launch();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue