PeTar
N-body code for collisional gravitational systems
GalpyManager Class Reference

A class to manager the API to Galpy. More...

#include <galpy_interface.h>

Collaboration diagram for GalpyManager:
[legend]

Public Member Functions

 GalpyManager ()
 
void printData (std::ostream &fout)
 print current potential data More...
 
void initial (const IOParamsGalpy &_input, const double _time, const std::string _conf_name, const bool _restart_flag, const bool _print_flag=false)
 initialization function More...
 
void updatePotentialSet ()
 generate potentail args More...
 
bool addPotentialFromString (const std::string &_type_args, const bool _reset_flag, const bool _print_flag)
 Update types and arguments from type-args string. More...
 
bool updateMWPotentialEvolve (const double &_system_time, const bool _print_flag, const bool _initial_flag)
 Update MWpotential evolve (Gomez et al. 2010) More...
 
bool updatePotentialFromFile (const double &_system_time, const bool _print_flag)
 Update types and arguments from configure file if update_time <= particle system time. More...
 
void updatePotential (const double &_system_time, const bool _print_flag)
 Update Potential types and arguments based on time. More...
 
void writePotentialPars (const std::string &_filename, const double &_system_time)
 write potential parameters for restart More...
 
void resetPotAcc ()
 reset acceleraltion of potential More...
 
void kickMovePot (const double dt)
 kick velocity of moving potential (mode 2) More...
 
void driftMovePot (const double dt)
 drift position of moving potential (mode 2) More...
 
void calcMovePotAccFromPot (const double _time, const double *pos_pcm)
 calculate acceleration for moving potentials from other potentials More...
 
void calcAccPot (double *acc, double &pot, const double _time, const double gm, const double *pos_g, const double *pos_l)
 calculate acceleration and potential at give position More...
 
void writeDataToFile (const std::string &_filename)
 write data for restart More...
 
void readDataFromFile (const std::string &_filename, const bool _print_flag)
 read configure data for restart More...
 
bool evolveChangingArguments (const double &_time, const bool _print_flag)
 calculate new arguments for changing potentials More...
 
void freePotentialArgs ()
 
void clear ()
 
 ~GalpyManager ()
 

Static Public Member Functions

static void printReference (std::ostream &fout, const int offset=4)
 print reference to cite More...
 

Public Attributes

std::vector< int > pot_type_offset
 
std::vector< int > pot_type
 
std::vector< int > pot_args_offset
 
std::vector< double > pot_args
 
double time
 
std::vector< ChangeArgumentchange_args
 
std::vector< int > change_args_offset
 
std::vector< PotentialSetParpot_set_pars
 
std::vector< PotentialSetpot_sets
 
double update_time
 
double rscale
 
double vscale
 
double tscale
 
double fscale
 
double pscale
 
double gmscale
 
std::ifstream fconf
 
std::string set_name
 
std::string set_parfile
 
MWPotentialEvolve mw_evolve
 

Detailed Description

A class to manager the API to Galpy.

Constructor & Destructor Documentation

◆ GalpyManager()

GalpyManager::GalpyManager ( )
inline

◆ ~GalpyManager()

GalpyManager::~GalpyManager ( )
inline
Here is the call graph for this function:

Member Function Documentation

◆ addPotentialFromString()

bool GalpyManager::addPotentialFromString ( const std::string &  _type_args,
const bool  _reset_flag,
const bool  _print_flag 
)
inline

Update types and arguments from type-args string.

Parameters
[in]_type_argspotential type and argment strings
[in]_reset_flagif true, reset potential set, otherwise add to current existing set
[in]_print_flagif true, print the read types and arguments.
Returns
initial flag: if potential is updated, return true; else return false
Here is the caller graph for this function:

◆ calcAccPot()

void GalpyManager::calcAccPot ( double *  acc,
double &  pot,
const double  _time,
const double  gm,
const double *  pos_g,
const double *  pos_l 
)
inline

calculate acceleration and potential at give position

Parameters
[out]acc[3] acceleration to return
[out]potpotential to return
[in]_timetime in input unit
[in]gmG*mass of particles [input unit]
[in]pos_gposition of particles in the galactic frame [input unit]
[in]pos_lposition of particles in the particle system frame [input unit]

◆ calcMovePotAccFromPot()

void GalpyManager::calcMovePotAccFromPot ( const double  _time,
const double *  pos_pcm 
)
inline

calculate acceleration for moving potentials from other potentials

Parameters
[in]_timecurrent time [input unit] of particle system
[in]pos_pcmposition of particle system in the galactic frame [input unit] for mode 1 potential

◆ clear()

void GalpyManager::clear ( )
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ driftMovePot()

void GalpyManager::driftMovePot ( const double  dt)
inline

drift position of moving potential (mode 2)

Parameters
[in]dttime step for kick [input unit]

◆ evolveChangingArguments()

bool GalpyManager::evolveChangingArguments ( const double &  _time,
const bool  _print_flag 
)
inline

calculate new arguments for changing potentials

Change index counts from 0 inside the local potential set If change index is -1, change the gm of potential set instead. To find the correct potential argument, the pot_args_offset is needed.

Parameters
[in]_timenew time (Galpy Unit)
[in]_print_flagif true, print updated argument
Returns
if changed, return true
Here is the caller graph for this function:

◆ freePotentialArgs()

void GalpyManager::freePotentialArgs ( )
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initial()

void GalpyManager::initial ( const IOParamsGalpy _input,
const double  _time,
const std::string  _conf_name,
const bool  _restart_flag,
const bool  _print_flag = false 
)
inline

initialization function

Parameters
[in]_inputinput parameters
[in]_timecurrent system time
[in]_conf_namegalpy configure file name for restart
[in]_restart_flagif true, read the configure file for restart
[in]_print_flagif true, printing information to std::cout
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kickMovePot()

void GalpyManager::kickMovePot ( const double  dt)
inline

kick velocity of moving potential (mode 2)

Parameters
[in]dttime step for kick [input unit]

◆ printData()

void GalpyManager::printData ( std::ostream &  fout)
inline

print current potential data

Here is the caller graph for this function:

◆ printReference()

static void GalpyManager::printReference ( std::ostream &  fout,
const int  offset = 4 
)
inlinestatic

print reference to cite

◆ readDataFromFile()

void GalpyManager::readDataFromFile ( const std::string &  _filename,
const bool  _print_flag 
)
inline

read configure data for restart

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetPotAcc()

void GalpyManager::resetPotAcc ( )
inline

reset acceleraltion of potential

◆ updateMWPotentialEvolve()

bool GalpyManager::updateMWPotentialEvolve ( const double &  _system_time,
const bool  _print_flag,
const bool  _initial_flag 
)
inline

Update MWpotential evolve (Gomez et al. 2010)

Assume time unit is Myr!

Parameters
[in]_system_timethe time of globular particley system in PeTar. The time is transferred based on the time scaling factor
[in]_print_flagif true, print the read types and arguments.
[in]_initial_flagif true, this is the first time, potential parameter array will be generated.
Returns
true if potential is updated (always) else false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePotential()

void GalpyManager::updatePotential ( const double &  _system_time,
const bool  _print_flag 
)
inline

Update Potential types and arguments based on time.

Parameters
[in]_system_timethe time of globular particley system in PeTar. The time is transferred based on the time scaling factor
[in]_print_flagif true, print the read types and arguments.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePotentialFromFile()

bool GalpyManager::updatePotentialFromFile ( const double &  _system_time,
const bool  _print_flag 
)
inline

Update types and arguments from configure file if update_time <= particle system time.

Parameters
[in]_system_timethe time of globular particley system in PeTar. The time is transferred based on the time scaling factor
[in]_print_flagif true, print the read types and arguments.
Returns
true if potential is updated; else false
Here is the caller graph for this function:

◆ updatePotentialSet()

void GalpyManager::updatePotentialSet ( )
inline

generate potentail args

clear the old potentialset first

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDataToFile()

void GalpyManager::writeDataToFile ( const std::string &  _filename)
inline

write data for restart

Write data sctructure: Time N_set Mode[:] # N_set: set mode After first line, the format is (size, array) pot_set_par: # mode, gm, pos, vel per line pot_type_offset # N_set+1: number of pots per set pot_type # N_pot: pot type list pot_args_offset # N_set+1: number of arguments per set pot_args # N_pot_arg pot argument list change_args_offset # N_set+1: number of changing arguments per set change_args # N_change: changing arg index, mode, rate

Parameters
[in]_filenamefile to save data
Here is the caller graph for this function:

◆ writePotentialPars()

void GalpyManager::writePotentialPars ( const std::string &  _filename,
const double &  _system_time 
)
inline

write potential parameters for restart

Precision is set to 14

Parameters
[out]_filenamefile to save data
[in]_timecurrent time
Here is the call graph for this function:

Member Data Documentation

◆ change_args

std::vector<ChangeArgument> GalpyManager::change_args

◆ change_args_offset

std::vector<int> GalpyManager::change_args_offset

◆ fconf

std::ifstream GalpyManager::fconf

◆ fscale

double GalpyManager::fscale

◆ gmscale

double GalpyManager::gmscale

◆ mw_evolve

MWPotentialEvolve GalpyManager::mw_evolve

◆ pot_args

std::vector<double> GalpyManager::pot_args

◆ pot_args_offset

std::vector<int> GalpyManager::pot_args_offset

◆ pot_set_pars

std::vector<PotentialSetPar> GalpyManager::pot_set_pars

◆ pot_sets

std::vector<PotentialSet> GalpyManager::pot_sets

◆ pot_type

std::vector<int> GalpyManager::pot_type

◆ pot_type_offset

std::vector<int> GalpyManager::pot_type_offset

◆ pscale

double GalpyManager::pscale

◆ rscale

double GalpyManager::rscale

◆ set_name

std::string GalpyManager::set_name

◆ set_parfile

std::string GalpyManager::set_parfile

◆ time

double GalpyManager::time

◆ tscale

double GalpyManager::tscale

◆ update_time

double GalpyManager::update_time

◆ vscale

double GalpyManager::vscale

The documentation for this class was generated from the following file: