Skip to content

Commit

Permalink
Refactor the code
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Nov 2, 2017
1 parent be45b12 commit fb27219
Show file tree
Hide file tree
Showing 44 changed files with 366 additions and 331 deletions.
4 changes: 4 additions & 0 deletions anphon/anphon.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<ClCompile Include="conductivity.cpp" />
<ClCompile Include="dynamical.cpp" />
<ClCompile Include="error.cpp" />
<ClCompile Include="ewald.cpp" />
<ClCompile Include="fcs_phonon.cpp" />
<ClCompile Include="gruneisen.cpp" />
<ClCompile Include="integration.cpp" />
Expand All @@ -94,6 +95,7 @@
<ClCompile Include="phonon_dos.cpp" />
<ClCompile Include="phonon_velocity.cpp" />
<ClCompile Include="relaxation.cpp" />
<ClCompile Include="scph.cpp" />
<ClCompile Include="selfenergy.cpp" />
<ClCompile Include="symmetry_core.cpp" />
<ClCompile Include="system.cpp" />
Expand All @@ -105,6 +107,7 @@
<ClInclude Include="conductivity.h" />
<ClInclude Include="dynamical.h" />
<ClInclude Include="error.h" />
<ClInclude Include="ewald.h" />
<ClInclude Include="fcs_phonon.h" />
<ClInclude Include="gruneisen.h" />
<ClInclude Include="integration.h" />
Expand All @@ -118,6 +121,7 @@
<ClInclude Include="phonon_velocity.h" />
<ClInclude Include="pointers.h" />
<ClInclude Include="relaxation.h" />
<ClInclude Include="scph.h" />
<ClInclude Include="selfenergy.h" />
<ClInclude Include="symmetry_core.h" />
<ClInclude Include="system.h" />
Expand Down
12 changes: 12 additions & 0 deletions anphon/anphon.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
<ClCompile Include="thermodynamics.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="scph.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="ewald.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="conductivity.h">
Expand Down Expand Up @@ -149,5 +155,11 @@
<ClInclude Include="thermodynamics.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="ewald.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="scph.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion anphon/conductivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void Conductivity::calc_anharmonic_imagself()

unsigned int icount = 0;

for (std::set<int>::iterator it = vks_job.begin(); it != vks_job.end(); ++it) {
for (auto it = vks_job.begin(); it != vks_job.end(); ++it) {
if (icount % mympi->nprocs == mympi->my_rank) {
vks_l.push_back(*it);
}
Expand Down
1 change: 0 additions & 1 deletion anphon/conductivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ namespace PHON_NS
const int);
};
}

29 changes: 14 additions & 15 deletions anphon/dynamical.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ namespace PHON_NS
std::vector<FcsClassExtent>,
double *, std::complex<double> **, bool);
void modify_eigenvectors();
void eval_k_ewald(double *, double *,
std::vector<FcsClassExtent>,
double *, std::complex<double> **, bool,
const int);
void eval_k_ewald(double *, double *,
std::vector<FcsClassExtent>,
double *, std::complex<double> **, bool,
const int);


double fold(double);
double freq(const double);
Expand All @@ -82,22 +82,22 @@ namespace PHON_NS
double ***);

void calc_analytic_k(double *,
std::vector<FcsClassExtent>,
std::complex<double> **);
std::vector<FcsClassExtent>,
std::complex<double> **);
void calc_nonanalytic_k(double *, double *,
std::complex<double> **);
std::complex<double> **);
void calc_nonanalytic_k2(double *, double *,
std::vector<FcsClassExtent>,
std::complex<double> **);
std::vector<FcsClassExtent>,
std::complex<double> **);

void calc_analytic_k_ewald(double *,
std::vector<FcsClassExtent>,
std::complex<double> **);
void calc_analytic_k_ewald(double *,
std::vector<FcsClassExtent>,
std::complex<double> **);

private:

void load_born();

void prepare_mindist_list(std::vector<int> **);
void calc_atomic_participation_ratio(std::complex<double> *, double *);
double distance(double *, double *);
Expand All @@ -120,4 +120,3 @@ namespace PHON_NS
std::complex<double> *beta, std::complex<double> *c, int *ldc);
}
}

9 changes: 6 additions & 3 deletions anphon/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

using namespace PHON_NS;

Error::Error(PHON *phon): Pointers(phon) {}
Error::Error(PHON *phon): Pointers(phon)
{
}

Error::~Error() {}
Error::~Error()
{
}

void Error::warn(const char *file, const char *message)
{
Expand Down Expand Up @@ -50,4 +54,3 @@ void Error::exit(const char *file, const char *message, const char *info)
std::cout << "ERROR in " << file << " MESSAGE: " << message << info << std::endl;
std::exit(EXIT_FAILURE);
}

1 change: 0 additions & 1 deletion anphon/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ namespace PHON_NS
void exit(const char *, const char *, const char *);
};
}

5 changes: 3 additions & 2 deletions anphon/ewald.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@

using namespace PHON_NS;

Ewald::Ewald(PHON *phon): Pointers(phon) {}
Ewald::Ewald(PHON *phon): Pointers(phon)
{
}

Ewald::~Ewald()
{
Expand Down Expand Up @@ -1181,4 +1183,3 @@ void Ewald::calc_anisotropic_hmat(double lambda_in, double *x, double **hmat_out
}
}
}

1 change: 0 additions & 1 deletion anphon/ewald.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,3 @@ namespace PHON_NS
void calc_anisotropic_hmat(double, double *, double **);
};
}

123 changes: 62 additions & 61 deletions anphon/fcs_phonon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ or http://opensource.org/licenses/mit-license.php for information.

using namespace PHON_NS;

Fcs_phonon::Fcs_phonon(PHON *phon): Pointers(phon) {}
Fcs_phonon::Fcs_phonon(PHON *phon): Pointers(phon)
{
}

Fcs_phonon::~Fcs_phonon()
{
Expand Down Expand Up @@ -153,30 +155,30 @@ void Fcs_phonon::load_fc2_xml()
fc2_ext.clear();

BOOST_FOREACH (const ptree::value_type& child_, pt.get_child("Data.ForceConstants.HARMONIC")) {
const ptree &child = child_.second;
const std::string str_p1 = child.get<std::string>("<xmlattr>.pair1");
const std::string str_p2 = child.get<std::string>("<xmlattr>.pair2");
const ptree &child = child_.second;
const std::string str_p1 = child.get<std::string>("<xmlattr>.pair1");
const std::string str_p2 = child.get<std::string>("<xmlattr>.pair2");

ss1.str("");
ss2.str("");
ss1.clear();
ss2.clear();
ss1.str("");
ss2.str("");
ss1.clear();
ss2.clear();

ss1 << str_p1;
ss2 << str_p2;
ss1 << str_p1;
ss2 << str_p2;

ss1 >> atm1 >> xyz1;
ss2 >> atm2 >> xyz2 >> cell_s;
ss1 >> atm1 >> xyz1;
ss2 >> atm2 >> xyz2 >> cell_s;

fcext_tmp.atm1 = atm1 - 1;
fcext_tmp.xyz1 = xyz1 - 1;
fcext_tmp.atm2 = atm2 - 1;
fcext_tmp.xyz2 = xyz2 - 1;
fcext_tmp.cell_s = cell_s - 1;
fcext_tmp.fcs_val = boost::lexical_cast<double>(child.data());
fcext_tmp.atm1 = atm1 - 1;
fcext_tmp.xyz1 = xyz1 - 1;
fcext_tmp.atm2 = atm2 - 1;
fcext_tmp.xyz2 = xyz2 - 1;
fcext_tmp.cell_s = cell_s - 1;
fcext_tmp.fcs_val = boost::lexical_cast<double>(child.data());

fc2_ext.push_back(fcext_tmp);
}
fc2_ext.push_back(fcext_tmp);
}
}

void Fcs_phonon::load_fcs_xml()
Expand Down Expand Up @@ -226,63 +228,63 @@ void Fcs_phonon::load_fcs_xml()
}

BOOST_FOREACH (const ptree::value_type& child_, pt.get_child(str_tag)) {
const ptree &child = child_.second;
const ptree &child = child_.second;

fcs_val = boost::lexical_cast<double>(child.data());
fcs_val = boost::lexical_cast<double>(child.data());

ivec_with_cell.clear();
ivec_with_cell.clear();

for (i = 0; i < order + 2; ++i) {
str_attr = "<xmlattr>.pair" + boost::lexical_cast<std::string>(i + 1);
str_pairs = child.get<std::string>(str_attr);
for (i = 0; i < order + 2; ++i) {
str_attr = "<xmlattr>.pair" + boost::lexical_cast<std::string>(i + 1);
str_pairs = child.get<std::string>(str_attr);

ss.str("");
ss.clear();
ss << str_pairs;
ss.str("");
ss.clear();
ss << str_pairs;

if (i == 0) {
if (i == 0) {

ss >> atmn >> xyz;
if (update_fc2) {
ivec_tmp.index = 3 * system->map_p2s_anharm_orig[atmn - 1][0] + xyz - 1;
ss >> atmn >> xyz;
if (update_fc2) {
ivec_tmp.index = 3 * system->map_p2s_anharm_orig[atmn - 1][0] + xyz - 1;
} else {
ivec_tmp.index = 3 * system->map_p2s_anharm[atmn - 1][0] + xyz - 1;
}
ivec_tmp.cell_s = 0;
ivec_tmp.tran = 0; // dummy
ivec_with_cell.push_back(ivec_tmp);
} else {
ivec_tmp.index = 3 * system->map_p2s_anharm[atmn - 1][0] + xyz - 1;
}
ivec_tmp.cell_s = 0;
ivec_tmp.tran = 0; // dummy
ivec_with_cell.push_back(ivec_tmp);
} else {

ss >> atmn >> xyz >> cell_s;
ss >> atmn >> xyz >> cell_s;

ivec_tmp.index = 3 * (atmn - 1) + xyz - 1;
ivec_tmp.cell_s = cell_s - 1;
ivec_tmp.tran = 0; // dummy
ivec_with_cell.push_back(ivec_tmp);
}
ivec_tmp.index = 3 * (atmn - 1) + xyz - 1;
ivec_tmp.cell_s = cell_s - 1;
ivec_tmp.tran = 0; // dummy
ivec_with_cell.push_back(ivec_tmp);
}

}
}

if (std::abs(fcs_val) > eps) {
if (std::abs(fcs_val) > eps) {

do {
do {

ivec_copy.clear();
ivec_copy.clear();

for (i = 0; i < ivec_with_cell.size(); ++i) {
atmn = ivec_with_cell[i].index / 3;
xyz = ivec_with_cell[i].index % 3;
ivec_tmp.index = 3 * system->map_s2p_anharm[atmn].atom_num + xyz;
ivec_tmp.cell_s = ivec_with_cell[i].cell_s;
ivec_tmp.tran = system->map_s2p_anharm[atmn].tran_num;
ivec_copy.push_back(ivec_tmp);
}
for (i = 0; i < ivec_with_cell.size(); ++i) {
atmn = ivec_with_cell[i].index / 3;
xyz = ivec_with_cell[i].index % 3;
ivec_tmp.index = 3 * system->map_s2p_anharm[atmn].atom_num + xyz;
ivec_tmp.cell_s = ivec_with_cell[i].cell_s;
ivec_tmp.tran = system->map_s2p_anharm[atmn].tran_num;
ivec_copy.push_back(ivec_tmp);
}

force_constant_with_cell[order].push_back(FcsArrayWithCell(fcs_val, ivec_copy));
force_constant_with_cell[order].push_back(FcsArrayWithCell(fcs_val, ivec_copy));

} while (std::next_permutation(ivec_with_cell.begin() + 1, ivec_with_cell.end()));
} while (std::next_permutation(ivec_with_cell.begin() + 1, ivec_with_cell.end()));
}
}
}
}

std::cout << "done !" << std::endl;
Expand Down Expand Up @@ -598,4 +600,3 @@ void Fcs_phonon::MPI_Bcast_fcs_array(const unsigned int N)
memory->deallocate(ind);
}
}

13 changes: 9 additions & 4 deletions anphon/fcs_phonon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ namespace PHON_NS
std::vector<Triplet> elems;
double fcs_val;

FcsClass() {};
FcsClass()
{
};

FcsClass(const FcsClass &obj)
{
Expand Down Expand Up @@ -75,7 +77,9 @@ namespace PHON_NS
unsigned int cell_s;
double fcs_val;

FcsClassExtent() {};
FcsClassExtent()
{
};

FcsClassExtent(const FcsClassExtent &obj)
{
Expand Down Expand Up @@ -113,7 +117,9 @@ namespace PHON_NS
std::vector<AtomCellSuper> pairs;
double fcs_val;

FcsArrayWithCell() {};
FcsArrayWithCell()
{
};

FcsArrayWithCell(const double fcs_in, const std::vector<AtomCellSuper> pairs_in)
{
Expand Down Expand Up @@ -178,4 +184,3 @@ namespace PHON_NS
void MPI_Bcast_fc2_ext();
};
}

0 comments on commit fb27219

Please sign in to comment.