Skip to content
Snippets Groups Projects
Commit f40214d9 authored by Armin Damon Riess's avatar Armin Damon Riess
Browse files

tree code lookin good

parent 2d238011
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ nBodySim::nBodySim(std::string datafile) {
for (unsigned i=0; i < 3; ++i) {
for (unsigned j=0; j < nParticles_; ++j) {
file >> velocities_[i+3*j];
velocities_[i+3*j] *= 0.001;
velocities_[i+3*j] *= 0.0001;
}
}
......@@ -53,7 +53,7 @@ nBodySim::nBodySim(std::string datafile) {
softening_ = calculateMeanInterparticleDistance();
Vector center{0.0, 0.0, 0.0};
tree_ = new Tree(mass_, positions_, forces_, nParticles_, 4*maxCoord, center);
tree_ = new Tree(mass_, positions_, forces_, nParticles_, 2*maxCoord, center);
}
nBodySim::~nBodySim() {
......@@ -66,8 +66,8 @@ nBodySim::~nBodySim() {
void nBodySim::runSimulation(double dt, unsigned nSteps) {
std::ofstream file("../out/positions.dat");
for (unsigned i=0; i < nSteps; ++i) {
updateForces();
verifyForces();
treeUpdateForces();
// verifyForces();
doTimeStep(dt);
updateTree();
std::cout << std::right << "Step " << std::setw(5) << i
......
......@@ -18,42 +18,14 @@ int main(int argc, char** argv) {
return 1;
}
double dt = 0.001;
double dt = 0.0001;
unsigned nSteps = 1000;
nBodySim sim(datafile);
double* positions = sim.getPositions();
// double* positions = sim.getPositions();
unsigned N = sim.getNParticles();
std::cout << "N = " << N << std::endl;
/*
// print positions
for (unsigned i=0; i<N; ++i) {
for (unsigned j=0; j<3; ++j) {
std::cout << sim.getPositions()[3*i+j] << " ";
}
std::cout << std::endl;
}
// calculate mean interparticle distance
double meanInterparticleDistance = sim.calculateMeanInterparticleDistance();
std::cout << "Mean interparticle distance: " << meanInterparticleDistance << std::endl;
// calculate mean force magnitude
double meanForceMagnitude = sim.calculateMeanForceMagnitude();
std::cout << "Mean force magnitude: " << meanForceMagnitude << std::endl;
*/
/*
sim.updateForces();
// verify forces
sim.verifyForces();
// save forces to file
sim.write2file(sim.getForces(), "../out/forces.txt", 3);
*/
try {
auto start = std::chrono::high_resolution_clock::now();
sim.runSimulation(dt, nSteps);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment