Skip to content

Commit

Permalink
Merge branch 'feature/merge_priv' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Sep 14, 2015
2 parents 625b1e4 + 3374cef commit 2514eb2
Show file tree
Hide file tree
Showing 30 changed files with 1,330 additions and 1,564 deletions.
4 changes: 2 additions & 2 deletions alm/Makefile.osx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# We recommend to use Intel c++ compiler.
#-----------------------------------------------

# Use gcc 4.9 to use OpenMP
# Use gcc >= 4.8 to use OpenMP
# OpenMP-enabled gcc can be installed via homebrew
CXX = g++-4.9
CXX = g++-5
CXXFLAGS = -O2 -fopenmp
INCLUDE = -I../include

Expand Down
2 changes: 1 addition & 1 deletion alm/fcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void Fcs::generate_fclists(int maxorder)
ndup[order].clear();
nmother = 0;

nxyz = static_cast<int>(pow(static_cast<long double>(3), order + 2));
nxyz = static_cast<int>(std::pow(3.0, order + 2));

memory->allocate(xyzcomponent, nxyz, order + 2);
get_xyzcomponent(order + 2, xyzcomponent);
Expand Down
6 changes: 3 additions & 3 deletions alm/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ using namespace ALM_NS;

Files::Files(ALM *alm): Pointers(alm) {}
Files::~Files() {
if (alm->mode == "fitting") {
closefiles();
if (alm->mode == "fitting" || alm->mode == "lasso") {
// closefiles();
} else if (alm->mode == "suggest") {
memory->deallocate(file_disp_pattern);
}
Expand Down Expand Up @@ -65,5 +65,5 @@ void Files::init()
{
setfilenames();

if (alm->mode == "fitting") openfiles();
// if (alm->mode == "fitting" || alm->mode == "lasso") openfiles();
}
97 changes: 35 additions & 62 deletions alm/patterndisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ or http://opensource.org/licenses/mit-license.php for information.
#include "mathfunctions.h"
#include "constraint.h"
#include <map>
#include <boost/bimap.hpp>

using namespace ALM_NS;

Expand All @@ -38,68 +39,46 @@ void Displace::gen_displacement_pattern()
std::set<ConstraintClass> *constsym;

std::vector<int> pairs;
std::vector<std::vector<int> > *constpairs;
std::set<int> *include_set;
std::set<DispAtomSet> *dispset;

std::vector<ConstraintTypeFix> *const_fix_tmp;
std::vector<ConstraintTypeRelate> *const_relate_tmp;
boost::bimap<int, int> *index_bimap_tmp;

memory->allocate(constsym, maxorder);
memory->allocate(constpairs, maxorder);
memory->allocate(const_fix_tmp, maxorder);
memory->allocate(const_relate_tmp, maxorder);
memory->allocate(index_bimap_tmp, maxorder);

constraint->constraint_from_symmetry(constsym);
constraint->get_mapping_constraint(maxorder, constsym, const_fix_tmp,
const_relate_tmp, index_bimap_tmp, true);

for (order = 0; order < maxorder; ++order) {

int nparams = fcs->ndup[order].size();

for (std::set<ConstraintClass>::const_iterator it = constsym[order].begin();
it != constsym[order].end(); ++it) {
pairs.clear();
for (i = 0; i < nparams; ++i) {
if (std::abs((*it).w_const[i])> eps12) {
pairs.push_back(i);
}
}
constpairs[order].push_back(pairs);
}
std::cout << " Number of free" << std::setw(9) << interaction->str_order[order] << " FCs : "
<< index_bimap_tmp[order].size() << std::endl;
}
std::cout << std::endl;

//
// for (order = 0; order < maxorder; ++order) {
// std::sort(constpairs[order].begin(), constpairs[order].end());
// for (i = 0; i < constpairs[order].size(); ++i) {
// for (j = 0; j < constpairs[order][i].size(); ++j) {
// std::cout << std::setw(5) << constpairs[order][i][j];
// }
// std::cout << std::endl;
// }
// std::cout << std::endl;
// }

std::set<int>::iterator iter_found;
memory->deallocate(constsym);
memory->deallocate(const_fix_tmp);
memory->deallocate(const_relate_tmp);

memory->allocate(include_set, maxorder);

for (order = 0; order < maxorder; ++order) {
include_set[order].clear();
int nparams = fcs->ndup[order].size();

for (i = 0; i < nparams; ++i) {
include_set[order].insert(i);
}

for (i = 0; i < constpairs[order].size(); ++i) {

// Is there any clever way to trim displacement patterns?
int len = constpairs[order][i].size();
// int target = constpairs[order][i][len - 1];

int target = constpairs[order][i][0];

iter_found = include_set[order].find(target);
if (iter_found != include_set[order].end()) {
include_set[order].erase(iter_found);
}
for (boost::bimap<int, int>::const_iterator it = index_bimap_tmp[order].begin();
it != index_bimap_tmp[order].end(); ++it) {
include_set[order].insert((*it).right);
}
}

memory->deallocate(index_bimap_tmp);


std::cout << " Generating displacement patterns in ";
if (disp_basis[0] == 'C') {
std::cout << "Cartesian coordinate...";
Expand Down Expand Up @@ -131,41 +110,34 @@ void Displace::gen_displacement_pattern()
dispset[order].insert(DispAtomSet(group_tmp));

}

m += fcs->ndup[order][i];
}
}
memory->deallocate(include_set);

memory->allocate(pattern_all, maxorder);

generate_pattern_all(maxorder, pattern_all);
generate_pattern_all(maxorder, pattern_all, dispset);

memory->deallocate(dispset);
memory->deallocate(constsym);
memory->deallocate(constpairs);


std::cout << " done!" << std::endl;
}

void Displace::generate_pattern_all(const int N, std::vector<AtomWithDirection> *pattern)
void Displace::generate_pattern_all(const int N, std::vector<AtomWithDirection> *pattern,
std::set<DispAtomSet> *dispset_in)
{
int i, j;
int order;
int atom_tmp;
int atom_tmp, natom_disp;
double sign_double;
double disp_tmp[3];
double norm;
double *direc_tmp;

std::vector<int> atoms;
std::vector<double> directions;
std::vector<int> atoms, vec_tmp, nums;
std::vector<double> directions, directions_copy;
std::vector<std::vector<int> > *sign_prod, sign_reduced;
std::vector<int> vec_tmp;

int natom_disp;
double sign_double;
std::vector<int> nums;
std::vector<double> directions_copy;

memory->allocate(sign_prod, N);

Expand All @@ -178,7 +150,8 @@ void Displace::generate_pattern_all(const int N, std::vector<AtomWithDirection>

pattern[order].clear();

for (std::set<DispAtomSet>::iterator it = dispset[order].begin(); it != dispset[order].end(); ++it) {
for (std::set<DispAtomSet>::iterator it = dispset_in[order].begin();
it != dispset_in[order].end(); ++it) {

atoms.clear();
directions.clear();
Expand Down
6 changes: 3 additions & 3 deletions alm/patterndisp.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ namespace ALM_NS {
void gen_displacement_pattern();

private:
std::set<DispAtomSet> *dispset;
// std::set<DispAtomSet> *dispset;
std::vector<DispDirectionHarmonic> disp_harm, disp_harm_best;
void generate_pattern_all(const int, std::vector<AtomWithDirection> *);
void generate_pattern_all(const int, std::vector<AtomWithDirection> *, std::set<DispAtomSet> *);

void generate_signvecs(const int, std::vector<std::vector <int> > &, std::vector<int>);
void find_unique_sign_pairs(const int, std::vector<std::vector<int> >,
std::vector<int>, std::vector<std::vector<int> > &);
};
}
}
5 changes: 1 addition & 4 deletions alm/writes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void Writes::write_force_constants()
}

for (icell = 0; icell < nneib; ++icell) system->frac2cart(xcrd[icell]);


for (order = 0; order < maxorder; ++order) {
str_fcs[order] = "*FC" + boost::lexical_cast<std::string>(order + 2);
Expand All @@ -178,16 +179,12 @@ void Writes::write_force_constants()


atom_tmp.clear();

for (l = 1; l < order + 2; ++l) {
atom_tmp.push_back(fcs->fc_set[order][m].elems[l] / 3);
}

j = symmetry->map_s2p[fcs->fc_set[order][m].elems[0]/3].atom_num;

std::sort(atom_tmp.begin(), atom_tmp.end());


iter_cluster = interaction->mindist_cluster[order][j].find(MinimumDistanceCluster(atom_tmp, cell_dummy));

if (iter_cluster != interaction->mindist_cluster[order][j].end()) {
Expand Down

0 comments on commit 2514eb2

Please sign in to comment.