Swarm-NG  1.1
montecarlo_ecclimit.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 <ctime>
#include <unistd.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...
 
void print_system (const swarm::ensemble &ens, const int systemid, std::ostream &os=std::cout)
 Output the system.
 
void write_stable_systems (defaultEnsemble &ens, defaultEnsemble &ens_init)
 Output the stable systems.
 
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 replace_disabled_systems (defaultEnsemble &ens)
 ***************TODO***********
 
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_ecclimit.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_ecclimit.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 519 of file montecarlo_ecclimit.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 197 of file montecarlo_ecclimit.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 462 of file montecarlo_ecclimit.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().