Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions source/source_cell/module_symmetry/symm_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,14 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,

assert(ntype>0);

this->na = new int[ntype];
this->istart = new int[ntype]; // start number of atom.
this->index = new int [nat + 2]; // index of atoms

ModuleBase::GlobalFunc::ZEROS(na, ntype);
ModuleBase::GlobalFunc::ZEROS(istart, ntype);
ModuleBase::GlobalFunc::ZEROS(index, nat+2);
this->na.assign(ntype, 0);
this->istart.assign(ntype, 0); // start number of atom.
this->index.assign(nat + 2, 0); // index of atoms

// atom positions
// used in checksym.
newpos = new double[3*nat]; // positions of atoms before rotation
rotpos = new double[3*nat]; // positions of atoms after rotation
ModuleBase::GlobalFunc::ZEROS(newpos, 3*nat);
ModuleBase::GlobalFunc::ZEROS(rotpos, 3*nat);
newpos.assign(3 * nat, 0.0); // positions of atoms before rotation
rotpos.assign(3 * nat, 0.0); // positions of atoms after rotation

this->a1 = lat.a1;
this->a2 = lat.a2;
Expand Down Expand Up @@ -91,7 +85,7 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
// s: the input lattice vectors, input
// find the real_brav type accordiing to lattice vectors.
this->lattice_type(this->a1, this->a2, this->a3, this->s1, this->s2, this->s3,
this->cel_const, this->pre_const, this->real_brav, ilattname, atoms, true, this->newpos, symmetry_prec);
this->cel_const, this->pre_const, this->real_brav, ilattname, atoms, true, this->newpos.data(), symmetry_prec);

ofs_running << " For optimal symmetric configuration:" << std::endl;
ModuleBase::GlobalFunc::OUT(ofs_running, "BRAVAIS TYPE", real_brav);
Expand All @@ -104,7 +98,7 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
optlat.e31 = a3.x; optlat.e32 = a3.y; optlat.e33 = a3.z;

// count the number of primitive cells in the supercell
this->pricell(this->newpos, atoms);
this->pricell(this->newpos.data(), atoms);

test_brav = true; // output the real ibrav and point group

Expand All @@ -129,9 +123,9 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
// get the real symmetry operations according to the input structure
// nrot_out: the number of pure point group rotations
// nrotk_out: the number of all space group operations
this->getgroup(nrot_out, nrotk_out, ofs_running, this->nop, this->symop,
this->gmatrix, this->gtrans, this->newpos, this->rotpos, this->index,
this->ntype, this->itmin_type, this->itmin_start, this->istart, this->na);
this->getgroup(nrot_out, nrotk_out, ofs_running, this->nop, this->symop,
this->gmatrix, this->gtrans, this->newpos.data(), this->rotpos.data(), this->index.data(),
this->ntype, this->itmin_type, this->itmin_start, this->istart.data(), this->na.data());
}
};

Expand Down Expand Up @@ -309,11 +303,6 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
}
}

delete[] newpos;
delete[] na;
delete[] rotpos;
delete[] index;
delete[] istart;
ModuleBase::timer::end("Symmetry","analy_sys");
return;
}
Expand Down
8 changes: 4 additions & 4 deletions source/source_cell/module_symmetry/symm_magnetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ void Symmetry::analyze_magnetic_group(const Atom* atoms, const Statistics& st, i
}

// 3. analyze the effective structure
this->getgroup(nrot_out, nrotk_out, GlobalV::ofs_running,
this->nop, this->symop, this->gmatrix,
this->gtrans, mag_pos.data(), this->rotpos,
this->index, mag_type_atoms.size(), mag_itmin_type,
this->getgroup(nrot_out, nrotk_out, GlobalV::ofs_running,
this->nop, this->symop, this->gmatrix,
this->gtrans, mag_pos.data(), this->rotpos.data(),
this->index.data(), mag_type_atoms.size(), mag_itmin_type,
mag_itmin_start, mag_istart.data(), mag_na.data());

}
Expand Down
6 changes: 3 additions & 3 deletions source/source_cell/module_symmetry/symm_pricell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Symmetry::pricell(double* pos, const Atom* atoms)
}

//order original atomic positions for current species
this->atom_ordering_new(pos + istart[it] * 3, na[it], index + istart[it]);
this->atom_ordering_new(pos + istart[it] * 3, na[it], index.data() + istart[it]);
//copy pos to rotpos
for (int j = istart[it]; j < istart[it] + na[it]; ++j)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ void Symmetry::pricell(double* pos, const Atom* atoms)
this->check_boundary( rotpos[ia*3+2] );
}
//order translated atomic positions for current species
this->atom_ordering_new(rotpos + istart[it] * 3, na[it], index + istart[it]);
this->atom_ordering_new(rotpos.data() + istart[it] * 3, na[it], index.data() + istart[it]);
}

no_diff = true;
Expand Down Expand Up @@ -130,7 +130,7 @@ void Symmetry::pricell(double* pos, const Atom* atoms)
ptrans_array[i*3+1]=ptrans[i].y;
ptrans_array[i*3+2]=ptrans[i].z;
}
this->atom_ordering_new(ptrans_array, ntrans, index);
this->atom_ordering_new(ptrans_array, ntrans, index.data());
// std::cout<<"final ptrans:"<<std::endl;
for(int i=0;i<ntrans;++i)
{
Expand Down
6 changes: 3 additions & 3 deletions source/source_cell/module_symmetry/symmetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ void Symmetry::set_atom_map(const Atom* atoms)
this->isym_rotiat_[i].resize(this->nat, -1);
}

double* pos = this->newpos;
double* rotpos = this->rotpos;
ModuleBase::GlobalFunc::ZEROS(pos, this->nat * 3);
std::fill(this->newpos.begin(), this->newpos.end(), 0.0);
double* pos = this->newpos.data();
double* rotpos = this->rotpos.data();
int iat = 0;
for (int it = 0; it < this->ntype; it++)
{
Expand Down
12 changes: 7 additions & 5 deletions source/source_cell/module_symmetry/symmetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "source_base/constants.h"
#include "symm_basic.h"

#include <vector>

namespace ModuleSymmetry
{

Expand Down Expand Up @@ -57,20 +59,20 @@ class Symmetry : public Symmetry_Basic

int ntype=0; ///< the number of atomic species
int nat =0; ///< the number of all atoms
int *na =nullptr;///< number of atoms for each species
int *istart=nullptr; ///< start number of atom
std::vector<int> na; ///< number of atoms for each species
std::vector<int> istart; ///< start number of atom
int itmin_type=0; ///< the type has smallest number of atoms
int itmin_start=0;

/// @brief direct coordinates of atoms
double *newpos=nullptr;
std::vector<double> newpos;
/// @brief positions of atoms after rotation
double *rotpos=nullptr;
std::vector<double> rotpos;


std::vector<ModuleBase::Vector3<double>> ptrans; ///< the translation vectors of the primitive cell in the input structure
int ncell=1; ///< the number of primitive cells within one supercell
int *index=nullptr;
std::vector<int> index;

double cel_const[6]={0.0};
double pcel_const[6]={0.0}; ///< cel_const of primitive cell
Expand Down
Loading