Skip to content

Commit

Permalink
Merge branch 'release/v.0.9.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Sep 14, 2015
2 parents 963fbbf + c2600e3 commit 6ad6016
Show file tree
Hide file tree
Showing 48 changed files with 1,668 additions and 1,703 deletions.
25 changes: 25 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Ver. 0.9.6 (2015-09-14)

## New

- New option ICONST=11 for ALM which considers translational invariance algebraically

- FC2XML-tag for ANPHON. Using this tag, it is now possible to employ different size of
supercells for harmonic and anharmonic terms.

- qe2alm.cpp in the tools/ directory which converts Quantum-ESPRESSO fc files to ALAMODE xml files.

## Changes

- Changed the meaning of --calc=cumulative in analyze_phonons.py.
The --calc=cumulative in the previous version is now equivalent to --calc=cumulative2.

- Updated tutorial

## Fix

- Fix bugs related to memory allocation

- Fix an issue in extract.py for QE


# Ver. 0.9.5 (2015-06-28)

## New
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ALAMODE
* Version 0.9.5 (Beta)
* Version 0.9.6 (Beta)

- - -

Expand Down Expand Up @@ -33,7 +33,7 @@ http://alamode.readthedocs.org


## License
Copyright (c) 2014 Terumasa Tadano
Copyright (c) 2014, 2015 Terumasa Tadano
This software is released under the MIT license.
For license rights and limitations, see LICENSE.txt file.

Expand Down
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/alamode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ALM::ALM(int narg, char **arg)
{
std::cout << " +------------------------------------------------------------+" << std::endl;
std::cout << " + Program ALM +" << std::endl;
std::cout << " + Ver. 0.9.5 +" << std::endl;
std::cout << " + Ver. 0.9.6 +" << std::endl;
std::cout << " +------------------------------------------------------------+" << std::endl;
std::cout << std::endl;

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();
}
21 changes: 13 additions & 8 deletions alm/fitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ void Fitting::data_multiplier(const int nat, const int ndata, const int nstart,

void Fitting::fit_without_constraints(int N, int M_Start, int M_End, double **amat, double *bvec)
{
int i, j, k;
int i, j;
unsigned long k;
int nrhs = 1, nrank, INFO, LWORK;
double *WORK, *S, *amat_mod;
double rcond = -1.0;
Expand Down Expand Up @@ -425,7 +426,8 @@ void Fitting::fit_without_constraints(int N, int M_Start, int M_End, double **am
void Fitting::fit_with_constraints(int N, int M_Start, int M_End, int P,
double **amat, double *bvec, double **cmat, double *dvec)
{
int i, j, k;
int i, j;
unsigned long k;
int nrank;
double f_square, f_residual;
double *fsum2;
Expand Down Expand Up @@ -500,13 +502,13 @@ void Fitting::fit_with_constraints(int N, int M_Start, int M_End, int P,
fsum2[j++] = bvec[i];
f_square += std::pow(bvec[i], 2);
}

std::cout << " QR-Decomposition has started ...";

double *amat_mod, *cmat_mod;
memory->allocate(amat_mod, M * N);
memory->allocate(cmat_mod, P * N);


// transpose matrix A and C
k = 0;
for (j = 0; j < N; ++j) {
Expand All @@ -523,7 +525,7 @@ void Fitting::fit_with_constraints(int N, int M_Start, int M_End, int P,

// Fitting

int LWORK = P + std::min<int>(M, N) + 100 * std::max<int>(M, N);
int LWORK = P + std::min<int>(M, N) + 10 * std::max<int>(M, N);
int INFO;
double *WORK, *x;
memory->allocate(WORK, LWORK);
Expand Down Expand Up @@ -557,7 +559,8 @@ void Fitting::fit_with_constraints(int N, int M_Start, int M_End, int P,
void Fitting::fit_algebraic_constraints(int N, int M_Start, int M_End, double **amat, double *bvec, double *bvec_orig,
const int maxorder)
{
int i, j, k;
int i, j;
unsigned long k;
int nrhs = 1, nrank, INFO, LWORK;
double *WORK, *S, *amat_mod;
double rcond = -1.0;
Expand Down Expand Up @@ -653,7 +656,8 @@ void Fitting::fit_algebraic_constraints(int N, int M_Start, int M_End, double **
void Fitting::fit_bootstrap(int N, int P, int natmin, int ndata_used, int nmulti,
double **amat, double *bvec, double **cmat, double *dvec)
{
int i, j, k, l;
int i, j;
unsigned long k, l;
int M_Start, M_End;
int mset;
unsigned int iboot;
Expand Down Expand Up @@ -780,7 +784,8 @@ void Fitting::fit_bootstrap(int N, int P, int natmin, int ndata_used, int nmulti
void Fitting::fit_consecutively(int N, int P, const int natmin, const int ndata_used, const int nmulti, const int nskip,
double **amat, double *bvec, double **cmat, double *dvec)
{
int i, j, k;
int i, j;
unsigned long k;
int iend;
int M_Start, M_End;
int mset;
Expand Down Expand Up @@ -1246,7 +1251,7 @@ int Fitting::rankQRD(const int m, const int n, double *mat, const double toleran
double **mat_tmp;
memory->allocate(mat_tmp, m_, n_);

int k = 0;
unsigned long k = 0;

for (int j = 0; j < n_; ++j) {
for (int i = 0; i < m_; ++i) {
Expand Down
50 changes: 27 additions & 23 deletions alm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,88 @@ namespace ALM_NS {
Memory(class ALM *);
~Memory();

// allocator (need to be improved)
// allocator

template <typename T>
T *allocate(T *&arr, int n1){
T *allocate(T *&arr, const unsigned int n1){
try{
arr = new T [n1];
}
catch (std::bad_alloc &ba)
{
std::cout << "Caught an exception when trying to allocate 1-dimensional array" << std::endl;
std::cout << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1) << std::endl;
std::cout << " Caught an exception when trying to allocate 1-dimensional array" << std::endl;
std::cout << " " << ba.what() << " : Array shape = " << n1 << std::endl;
std::cout << " " << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1) << std::endl;
exit(EXIT_FAILURE);
}
return arr;
}

template <typename T>
T **allocate(T **&arr, int n1, int n2){
T **allocate(T **&arr, const unsigned int n1, const unsigned int n2){
try{
arr = new T *[n1];
arr[0] = new T [n1 * n2];
for (int i = 1; i < n1; ++i){
for (unsigned int i = 1; i < n1; ++i){
arr[i] = arr[0] + i * n2;
}
}
catch (std::bad_alloc &ba)
{
std::cout << "Caught an exception when trying to allocate 2-dimensional array" << std::endl;
std::cout << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1, n2) << std::endl;
std::cout << " Caught an exception when trying to allocate 2-dimensional array" << std::endl;
std::cout << " " << ba.what() << " : Array shape = " << n1 << "x" << n2 << std::endl;
std::cout << " " << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1, n2) << std::endl;
exit(EXIT_FAILURE);
}
return arr;
}

template <typename T>
T ***allocate(T ***&arr, int n1, int n2, int n3){
T ***allocate(T ***&arr, const unsigned int n1, const unsigned int n2, const unsigned int n3){
try{
arr = new T **[n1];
arr[0] = new T *[n1 * n2];
arr[0][0] = new T [n1 * n2 * n3];
for (int i = 0; i < n1; ++i){
for (unsigned int i = 0; i < n1; ++i){
arr[i] = arr[0] + i * n2;
for (int j = 0; j < n2; ++j){
for (unsigned int j = 0; j < n2; ++j){
arr[i][j] = arr[0][0] + i * n2 * n3 + j * n3;
}
}
}
catch(std::bad_alloc &ba)
{
std::cout << "Caught an exception when trying to allocate 3-dimensional array" << std::endl;
std::cout << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1, n2, n3) << std::endl;
std::cout << " Caught an exception when trying to allocate 3-dimensional array" << std::endl;
std::cout << " " << ba.what() << " : Array shape = " << n1 << "x" << n2 << "x" << n3 << std::endl;
std::cout << " " << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1, n2, n3) << std::endl;
exit(EXIT_FAILURE);
}
return arr;
}

template <typename T>
T ****allocate(T ****&arr, int n1, int n2, int n3, int n4){
T ****allocate(T ****&arr, const unsigned int n1, const unsigned int n2, const unsigned int n3, const unsigned int n4){
try{
arr = new T ***[n1];
arr[0] = new T **[n1 * n2];
arr[0][0] = new T *[n1 * n2 * n3];
arr[0][0][0] = new T [n1 * n2 * n3 * n4];

for (int i = 0; i < n1; ++i){
for (unsigned int i = 0; i < n1; ++i){
arr[i] = arr[0] + i * n2;
for (int j = 0; j < n2; ++j){
for (unsigned int j = 0; j < n2; ++j){
arr[i][j] = arr[0][0] + i * n2 * n3 + j * n3;
for (int k = 0; k < n3; ++k){
for (unsigned int k = 0; k < n3; ++k){
arr[i][j][k] = arr[0][0][0] + i * n2 * n3 * n4 + j * n3 * n4 + k * n4;
}
}
}
}
catch(std::bad_alloc &ba)
{
std::cout << "Caught an exception when trying to allocate 3-dimensional array" << std::endl;
std::cout << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1, n2, n3, n4) << std::endl;
std::cout << " Caught an exception when trying to allocate 4-dimensional array" << std::endl;
std::cout << " " << ba.what() << " : Array shape = " << n1 << "x" << n2 << "x" << n3 << "x" << n4 << std::endl;
std::cout << " " << ba.what() << " : Array size (MB) = " << memsize_in_MB(sizeof(T), n1, n2, n3, n4) << std::endl;
exit(EXIT_FAILURE);
}
return arr;
Expand Down Expand Up @@ -134,19 +138,19 @@ namespace ALM_NS {

// memsize calculator

int memsize_in_MB(int size_of_one, int n1){
unsigned long memsize_in_MB(const int size_of_one, const unsigned int n1){
unsigned long n = n1 * size_of_one;
return n / 1000000;
}
int memsize_in_MB(int size_of_one, int n1, int n2){
unsigned long memsize_in_MB(const int size_of_one, const unsigned int n1, const unsigned int n2){
unsigned long n = n1 * n2 * size_of_one;
return n / 1000000;
}
int memsize_in_MB(int size_of_one, int n1, int n2, int n3){
unsigned long memsize_in_MB(const int size_of_one, const unsigned int n1, const unsigned int n2, const unsigned int n3){
unsigned long n = n1 * n2 * n3 * size_of_one;
return n / 1000000;
}
int memsize_in_MB(int size_of_one, int n1, int n2, int n3, int n4){
unsigned long memsize_in_MB(const int size_of_one, const unsigned int n1, const unsigned int n2, const unsigned int n3, const unsigned int n4){
unsigned long n = n1 * n2 * n3 * n4 * size_of_one;
return n / 1000000;
}
Expand Down

0 comments on commit 6ad6016

Please sign in to comment.