Swarm-NG  1.1
montecarlo.cpp File Reference

Implement Monte Carlo simulation to find planetary systems and generate ensemble. More...

#include <iostream>
#include <fstream>
#include <math.h>
#include <signal.h>
#include "swarm/swarm.h"
#include "swarm/snapshot.hpp"
#include "swarm/log/log.hpp"
#include "random.hpp"
#include "kepler.hpp"

Go to the source code of this file.

Macros

#define SYNC   cudaThreadSynchronize()
 In writing this monte carlo simulation which is supposed to find planetary systems using Monte Carlo simulations, I used the old monte carlo code. More...
 

Functions

defaultEnsemble generate_ensemble_with_randomized_initial_conditions (const config &cfg)
 This procedure was copied from the other Monte Carlo simulation code. More...
 
std::vector< std::vector
< double > > 
calc_semimajor_axes (defaultEnsemble &ens)
 Calculate teh semi-major axes.
 
void save_snapshot (defaultEnsemble &ens)
 Save a periodical snapshot if one is defined in the config file Snapshot is usually saved as binary file, because it happens very frequently and text files take very long time to generate.
 
defaultEnsemble trim_disabled_systems (const defaultEnsemble &ens)
 This is a very crucial part of the Monte Carlo simulation We remove the disabled ones and make a smaller ensemble. More...
 
void ctrl_c_trap (int)
 We can use this signal handler function to detect Ctrl-C and save the last snapshot and leave in a clean way. More...
 

Detailed Description

Implement Monte Carlo simulation to find planetary systems and generate ensemble.

Definition in file montecarlo.cpp.

Macro Definition Documentation

#define SYNC   cudaThreadSynchronize()

In writing this monte carlo simulation which is supposed to find planetary systems using Monte Carlo simulations, I used the old monte carlo code.

It is useful, the tricky part is generating the ensemble.

Definition at line 43 of file montecarlo.cpp.

Function Documentation

void ctrl_c_trap ( int  )

We can use this signal handler function to detect Ctrl-C and save the last snapshot and leave in a clean way.

Definition at line 493 of file montecarlo.cpp.

defaultEnsemble generate_ensemble_with_randomized_initial_conditions ( const config cfg)

This procedure was copied from the other Monte Carlo simulation code.

I had to change all the floats to double because in the new swarm we use double for masses. Also, our ensemble classes now use reference counted pointers and we create them in a functional way than old fill-this-for-me-please pointers(references). The generate name makes more sense that the set_initial_conditions. I only added one line for generating the ensemble. In the other monte carlo, the ensemble is generated first and then passed to this function to fill it in.

Definition at line 189 of file montecarlo.cpp.

References swarm::EnsembleAlloc< W, _Allocator >::create(), swarm::EnsembleBase< _CHUNK_SIZE, _NUM_BODY_ATTRIBUTES, _NUM_SYS_ATTRIBUTES >::nbod(), swarm::EnsembleBase< _CHUNK_SIZE, _NUM_BODY_ATTRIBUTES, _NUM_SYS_ATTRIBUTES >::nsys(), swarm::config::optional(), and swarm::config::require().

defaultEnsemble trim_disabled_systems ( const defaultEnsemble ens)

This is a very crucial part of the Monte Carlo simulation We remove the disabled ones and make a smaller ensemble.

We don't really need to make another ensemble. But keeping the same ensemble is a lot of trouble.

Definition at line 453 of file montecarlo.cpp.

References swarm::EnsembleAlloc< W, _Allocator >::copyTo(), swarm::EnsembleAlloc< W, _Allocator >::create(), swarm::EnsembleBase< _CHUNK_SIZE, _NUM_BODY_ATTRIBUTES, _NUM_SYS_ATTRIBUTES >::nbod(), swarm::EnsembleBase< _CHUNK_SIZE, _NUM_BODY_ATTRIBUTES, _NUM_SYS_ATTRIBUTES >::nsys(), and number_of_disabled_systems().

Referenced by main().