19 MY_HEADING(
"Initializing a box configuration");
20 if (referenceAndFinal)
21 std::cout <<
"Creating a configuration of " << numberOfParticles <<
" particles" <<
22 " along with reference coordinates in a box of size zero" << std::endl;
24 std::cout <<
"Creating a configuration of " << numberOfParticles <<
" particles" <<
25 " in a box of size zero" << std::endl;
36 std::cout <<
"Reading the box configuration from file " << configFileName << std::endl;
37 std::ifstream file(configFileName);
41 std::cerr <<
"ERROR: " << configFileName <<
" could not be opened for reading!" << std::endl;
45 int numberOfParticlesInFile;
46 file >> numberOfParticlesInFile;
48 MY_ERROR(
"Error: Number of particles in file does not equal to that of BoxConfiguration");
52 for(
int i=0;i<DIM*
DIM;++i)
54 for(
int i=0;i<
DIM;++i)
58 std::string speciesTemp;
61 if(!(file >> speciesTemp))
MY_ERROR(
"ERROR: Species code of particle " + std::to_string(i));
63 for(
int j=0;j<
DIM;++j)
65 for(
int j=0;j<
DIM;++j)
66 if(!(file >>
velocities(i,j)))
MY_ERROR(
"ERROR: Velocity of particle " + std::to_string(i));
67 if (referenceAndFinal ==
true)
69 for(
int j=0;j<
DIM;++j)
71 MY_ERROR(
"ERROR: Reference coordinate of particle " + std::to_string(i) +
"\n");
75 file.ignore(32767,
'\n');
78 std::cout << std::endl;
79 std::cout <<
"Box size = " << std::endl;
80 std::cout <<
box << std::endl;
81 std::cout << std::endl;
82 std::cout <<
"Reference box size = " << std::endl;
84 std::cout << std::endl;
85 std::cout <<
"Periodic boundary conditions = " <<
pbc << std::endl;
93 int numberOfPaddings{0};
94 std::vector<double> reference_coordinatesOfPaddings,coordinatesOfPaddings;
95 std::vector<std::string> speciesOfPaddings;
96 std::vector<int> masterOfPaddings;
108 reference_coordinatesOfPaddings,
109 coordinatesOfPaddings,
123 config_ptr->species.push_back(*it);
125 if (numberOfPaddings)
127 if (referenceAndFinal) config_ptr->coordinates.at(
Reference).bottomRows(numberOfPaddings)=
128 *
new Eigen::Map<MatrixXd> (reference_coordinatesOfPaddings.data(),numberOfPaddings,
DIM);
129 config_ptr->coordinates.at(
Current).bottomRows(numberOfPaddings)=
130 *
new Eigen::Map<MatrixXd> (coordinatesOfPaddings.data(),numberOfPaddings,
DIM);
131 for (
auto it= speciesOfPaddings.begin();it!= speciesOfPaddings.end();it++)
132 config_ptr->species.push_back(*it);
#define MY_HEADING(heading)
std::map< ConfigType, MatrixXd > coordinates
Configuration * getConfiguration(double) const
BoxConfiguration(int, int)
void read(std::string, int)
#define MY_ERROR(message)
std::vector< std::string > species
virtual ~BoxConfiguration()
int nbl_create_paddings(int const numberOfParticles, double const cutoff, double const *reference_cell, double const *cell, int const *PBC, double const *reference_coordinates, double const *coordinates, const std::vector< std::string > &speciesCode, int &numberOfPaddings, std::vector< double > &reference_coordinatesOfPaddings, std::vector< double > &coordinatesOfPaddings, std::vector< std::string > &speciesCodeOfPaddings, std::vector< int > &masterOfPaddings, int referenceAndFinal)