src/system.cpp
/**
 * System Class
 * Contains all of the information about an Ising system. 
 * Can be fead in to the Flat Scan Sampling and Wang Landau classes. 
 * @param L        (int): Size of the lattice.
 * @param Sz       (int): Spin number in the z direction.
 * @param lattice  (string): Lattice of the system.
 *                                Options are {"SS", "SC", "BCC", "FCC", "HCP", "HEX"}
 * @param dir      (string): Directory of the normalization, sum N_pos and NN table files
 */
System Class
Contains all of the information about an Ising system.
Can be fead in to the Flat Scan Sampling and Wang Landau classes.
@param L        (int): Size of the lattice.
@param Sz       (int): Spin number in the z direction.
@param lattice  (string): Lattice of the system.
System Class Contains all of the information about an Ising system . Can be fead in to the Flat Scan Sampling and Wang Landau classes . @param L ( int ) : Size of the lattice . @param Sz ( int ) : Spin number in the z direction . @param lattice ( string ) : Lattice of the system .
System::System(int L, int Sz, std::string lattice, std::string dir) {
    this->L = L;
    this->Sz = Sz;
    this->S = (this->Sz - 1.0) / 2.0;
    this->lattice = lattice;
    if (this->lattice == "SS") {
        this->dim = 2;
        this->N_atm = L*L;
        this->NN = 4;
    } else if (this->lattice == "SC") {
        this->dim = 3;
        this->N_atm = L*L*L;
        this->NN = 6;
    } else if (this->lattice == "BCC") {
        this->dim = 3;
        this->N_atm = 2 * L*L*L;
        this->NN = 8;
    } else if (this->lattice == "FCC") {
        this->dim = 3;
        this->N_atm = 4 * L*L*L;
        this->NN = 12;
    } else if (this->lattice == "HCP") {
        this->dim = 3;
        this->N_atm = 2 * L*L*L;
        this-> NN = 12;
    } else if (this->lattice == "HEX") {
        this->dim = 3;
        this->N_atm = L*L*L;
        this->NN = 8;
    } else {
        std::printf(" -- Error invalid Lattice -- \n");
    }
    this->max_E = 4 * this->S * this->S * this->NN * this->N_atm / 2.0;
    this->max_M = 2 * this->S * N_atm;
    this->NE = 1 + (this->max_E / 2.0);
    this->NM = this->max_M + 1;
    this->energies = this->create_map(- max_E, max_E, 4);
    this->magnetizations = this->create_map(- max_M, max_M, 2);
    std::string NN_table_file_name = dir + "neighbour_tables/neighbour_table_" + std::to_string(this->dim) + "D_" + this->lattice +
    "_" + std::to_string(this->NN) + "NN_L" + std::to_string(this->L) + ".txt";
    std::string norm_factor_file_name = dir + "coefficients/coefficients_" + std::to_string(this->N_atm) + "d" + std::to_string(this->Sz) + ".txt";
    std::string Npos_file_name = dir + "sum_npos/sum_configs_Npos" + std::to_string(this->Sz) + "_N_atm" + std::to_string(this->N_atm) + ".txt";
    this->norm_factor = new long double[this->NM];
    this->NN_table = new int[this->N_atm * this->NN];
    this->read_norm_factor(norm_factor_file_name);
    this->read_NN_talbe(NN_table_file_name);
    this->read_N_pos(Npos_file_name);
    this->spins_vector = new int[this->N_atm];
    this->spins_values = new int[this->Sz];
    for (int i = 0; i < this->Sz; ++i) {
        this->spins_values[i] = 2 * this->S - 2 * i;
    }
    this->JDOS = new long double[this->NE * this->NM];
    for (int i = 0; i < this->NE * this->NM; ++i) {
        this->JDOS[i] = 0;
    }
}
System :: System ( int L , int Sz , std :: string lattice , std :: string dir ) { this -> L = L ; this -> Sz = Sz ; this -> S = ( this -> Sz - 1.0 ) / 2.0 ; this -> lattice = lattice ; if ( this -> lattice == " " ) { this -> dim = 2 ; this -> N_atm = L * L ; this -> NN = 4 ; } else if ( this -> lattice == " " ) { this -> dim = 3 ; this -> N_atm = L * L * L ; this -> NN = 6 ; } else if ( this -> lattice == " " ) { this -> dim = 3 ; this -> N_atm = 2 * L * L * L ; this -> NN = 8 ; } else if ( this -> lattice == " " ) { this -> dim = 3 ; this -> N_atm = 4 * L * L * L ; this -> NN = 12 ; } else if ( this -> lattice == " " ) { this -> dim = 3 ; this -> N_atm = 2 * L * L * L ; this -> NN = 12 ; } else if ( this -> lattice == " " ) { this -> dim = 3 ; this -> N_atm = L * L * L ; this -> NN = 8 ; } else { std :: printf ( " \n " ) ; } this -> max_E = 4 * this -> S * this -> S * this -> NN * this -> N_atm / 2.0 ; this -> max_M = 2 * this -> S * N_atm ; this -> NE = 1 + ( this -> max_E / 2.0 ) ; this -> NM = this -> max_M + 1 ; this -> energies = this -> create_map ( - max_E , max_E , 4 ) ; this -> magnetizations = this -> create_map ( - max_M , max_M , 2 ) ; std :: string NN_table_file_name = dir + " " + std :: to_string ( this -> dim ) + " " + this -> lattice + " " + std :: to_string ( this -> NN ) + " " + std :: to_string ( this -> L ) + " " ; std :: string norm_factor_file_name = dir + " " + std :: to_string ( this -> N_atm ) + " " + std :: to_string ( this -> Sz ) + " " ; std :: string Npos_file_name = dir + " " + std :: to_string ( this -> Sz ) + " " + std :: to_string ( this -> N_atm ) + " " ; this -> norm_factor = new long double [ this -> NM ] ; this -> NN_table = new int [ this -> N_atm * this -> NN ] ; this -> read_norm_factor ( norm_factor_file_name ) ; this -> read_NN_talbe ( NN_table_file_name ) ; this -> read_N_pos ( Npos_file_name ) ; this -> spins_vector = new int [ this -> N_atm ] ; this -> spins_values = new int [ this -> Sz ] ; for ( int i = 0 ; i < this -> Sz ; ++ i ) { this -> spins_values [ i ] = 2 * this -> S - 2 * i ; } this -> JDOS = new long double [ this -> NE * this -> NM ] ; for ( int i = 0 ; i < this -> NE * this -> NM ; ++ i ) { this -> JDOS [ i ] = 0 ; } }
System Class
 Contains all of the information about an Ising system.
System Class Contains all of the information about an Ising system .