Skip to content

Commit 26e89b6

Browse files
committed
2 parents 23d8ff0 + da73a2b commit 26e89b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1012
-820
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ These variables are used to control parameters related to input files.
667667
- **Type**: String
668668
- **Description**: the name of the structure file
669669
- Containing various information about atom species, including pseudopotential files, local orbitals files, cell information, atom positions, and whether atoms should be allowed to move.
670+
- When [calculation](#calculation) is set to `md` and [md_restart](#md_restart) is set to `true`, this keyword will NOT work.
670671
- Refer to [Doc](https://github.com/deepmodeling/abacus-develop/blob/develop/docs/advanced/input_files/stru.md)
671672
- **Default**: STRU
672673

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ OBJS_IO=input_conv.o\
526526
read_input_item_other.o\
527527
read_input_item_output.o\
528528
read_set_globalv.o\
529+
orb_io.o\
529530

530531
OBJS_IO_LCAO=cal_r_overlap_R.o\
531532
write_orb_info.o\

source/driver_run.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void Driver::driver_run() {
4040

4141
// the life of ucell should begin here, mohan 2024-05-12
4242
// delete ucell as a GlobalC in near future
43-
GlobalC::ucell.setup_cell(PARAM.inp.stru_file, GlobalV::ofs_running);
43+
GlobalC::ucell.setup_cell(PARAM.globalv.global_in_stru, GlobalV::ofs_running);
4444
Check_Atomic_Stru::check_atomic_stru(GlobalC::ucell,
4545
PARAM.inp.min_dist_coef);
4646

source/module_base/global_variable.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ int GSIZE = DSIZE;
5555
//----------------------------------------------------------
5656
// EXPLAIN : The input file name and directory
5757
//----------------------------------------------------------
58-
std::string stru_file = "STRU";
59-
6058
std::ofstream ofs_running;
6159
std::ofstream ofs_warning;
6260
std::ofstream ofs_info; // output math lib info

source/module_base/global_variable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ extern int KPAR_LCAO;
8080
// NAME : ofs_running( contain information during runnnig)
8181
// NAME : ofs_warning( contain warning information, including error)
8282
//==========================================================
83-
extern std::string stru_file;
8483
// extern std::string global_pseudo_type; // mohan add 2013-05-20 (xiaohui add
8584
// 2013-06-23)
8685
extern std::ofstream ofs_running;

source/module_basis/module_nao/atomic_radials.cpp

Lines changed: 49 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
#include "module_base/math_integral.h"
44
#include "module_base/parallel_common.h"
55
#include "module_base/tool_quit.h"
6+
7+
// FIXME: should update with pyabacus
8+
// #include "module_io/orb_io.h"
9+
610
#include "projgen.h"
711

812
#include <fstream>
913
#include <iostream>
1014
#include <string>
15+
#include <numeric>
1116

1217
AtomicRadials& AtomicRadials::operator=(const AtomicRadials& rhs)
1318
{
@@ -207,7 +212,6 @@ void AtomicRadials::read_abacus_orb(std::ifstream& ifs, std::ofstream* ptr_log,
207212
{
208213
rgrid[ir] = ir * dr;
209214
}
210-
211215
chi_ = new NumericalRadial[nchi_];
212216

213217
// record whether an orbital has been read or not
@@ -269,116 +273,47 @@ void AtomicRadials::read_abacus_orb(std::ifstream& ifs, std::ofstream* ptr_log,
269273
delete[] rgrid;
270274
}
271275

272-
void AtomicRadials::read_abacus_orb(std::ifstream& ifs,
273-
std::string& elem,
274-
double& ecut,
275-
int& nr,
276-
double& dr,
277-
std::vector<int>& nzeta,
278-
std::vector<std::vector<double>>& radials,
279-
const int rank)
280-
{
281-
nr = 0; // number of grid points
282-
dr = 0; // grid spacing
283-
int lmax, nchi = 0; // number of radial functions
284-
std::vector<std::vector<int>> radial_map_; // build a map from [l][izeta] to 1-d array index
285-
std::string tmp;
286-
// first read the header
287-
if (rank == 0)
288-
{
289-
if (!ifs.is_open())
290-
{
291-
ModuleBase::WARNING_QUIT("AtomicRadials::read_abacus_orb", "Couldn't open orbital file.");
292-
}
293-
while (ifs >> tmp)
294-
{
295-
if (tmp == "Element")
296-
{
297-
ifs >> elem;
298-
}
299-
else if (tmp == "Cutoff(Ry)")
300-
{
301-
ifs >> ecut;
302-
}
303-
else if (tmp == "Lmax")
304-
{
305-
ifs >> lmax;
306-
nzeta.resize(lmax + 1);
307-
for (int l = 0; l <= lmax; ++l)
308-
{
309-
ifs >> tmp >> tmp >> tmp >> nzeta[l];
310-
}
311-
}
312-
else if (tmp == "Mesh")
313-
{
314-
ifs >> nr;
315-
continue;
316-
}
317-
else if (tmp == "dr")
318-
{
319-
ifs >> dr;
320-
break;
321-
}
322-
}
323-
radial_map_.resize(lmax + 1);
324-
for (int l = 0; l <= lmax; ++l)
325-
{
326-
radial_map_[l].resize(nzeta[l]);
327-
}
328-
int ichi = 0;
329-
for (int l = 0; l <= lmax; ++l)
330-
{
331-
for (int iz = 0; iz < nzeta[l]; ++iz)
332-
{
333-
radial_map_[l][iz] = ichi++; // return the value of ichi, then increment
334-
}
335-
}
336-
nchi = ichi; // total number of radial functions
337-
radials.resize(nchi);
338-
std::for_each(radials.begin(), radials.end(), [nr](std::vector<double>& v) { v.resize(nr); });
339-
}
340-
341-
// broadcast the header information
342-
#ifdef __MPI
343-
Parallel_Common::bcast_string(elem);
344-
Parallel_Common::bcast_double(ecut);
345-
Parallel_Common::bcast_int(lmax);
346-
Parallel_Common::bcast_int(nchi);
347-
Parallel_Common::bcast_int(nr);
348-
Parallel_Common::bcast_double(dr);
349-
#endif
350-
351-
// then adjust the size of the vectors
352-
if (rank != 0)
353-
{
354-
nzeta.resize(lmax + 1);
355-
radials.resize(nchi);
356-
std::for_each(radials.begin(), radials.end(), [nr](std::vector<double>& v) { v.resize(nr); });
357-
}
358-
// broadcast the number of zeta functions for each angular momentum
359-
#ifdef __MPI
360-
Parallel_Common::bcast_int(nzeta.data(), lmax + 1);
361-
#endif
362-
363-
// read the radial functions by rank0
364-
int ichi = 0;
365-
for (int i = 0; i != nchi; ++i)
366-
{
367-
if (rank == 0)
368-
{
369-
int l, izeta;
370-
ifs >> tmp >> tmp >> tmp;
371-
ifs >> tmp >> l >> izeta;
372-
ichi = radial_map_[l][izeta];
373-
for (int ir = 0; ir != nr; ++ir)
374-
{
375-
ifs >> radials[ichi][ir];
376-
}
377-
}
378-
// broadcast the radial functions
379-
#ifdef __MPI
380-
Parallel_Common::bcast_int(ichi); // let other ranks know where to store the radial function
381-
Parallel_Common::bcast_double(radials[ichi].data(), nr);
382-
#endif
383-
}
384-
}
276+
// FIXME: should update with pyabacus
277+
// void AtomicRadials::read_abacus_orb(std::ifstream& ifs, std::ofstream* ptr_log, const int rank)
278+
// {
279+
// /*
280+
// * Read the orbital file.
281+
// *
282+
// * For orbital file format, see
283+
// * (new) abacus-develop/tools/SIAB/PyTorchGradient/source/IO/print_orbital.py
284+
// * (old) abacus-develop/tools/SIAB/SimulatedAnnealing/source/src_spillage/Plot_Psi.cpp
285+
// * */
286+
// int ngrid = 0; // number of grid points
287+
// double dr = 0; // grid spacing
288+
// std::string tmp;
289+
290+
// int nr;
291+
// std::vector<int> nzeta;
292+
// std::vector<std::vector<double>> radials;
293+
294+
// ModuleIO::read_abacus_orb(ifs, symbol_, orb_ecut_, nr, dr, nzeta, radials, rank);
295+
296+
// lmax_ = nzeta.size() - 1;
297+
// nzeta_ = new int[lmax_ + 1];
298+
// std::copy(nzeta.begin(), nzeta.end(), nzeta_);
299+
300+
// nchi_ = std::accumulate(nzeta.begin(), nzeta.end(), 0);
301+
// nzeta_max_ = *std::max_element(nzeta.begin(), nzeta.end());
302+
303+
// indexing();
304+
305+
// std::vector<double> rgrid(nr);
306+
// std::iota(rgrid.begin(), rgrid.end(), 0);
307+
// std::for_each(rgrid.begin(), rgrid.end(), [dr](double& r) { r *= dr; });
308+
// chi_ = new NumericalRadial[nchi_];
309+
// int ichi = 0;
310+
// for (int l = 0; l <= lmax_; ++l)
311+
// {
312+
// for (int izeta = 0; izeta < nzeta[l]; ++izeta)
313+
// {
314+
// chi_[index(l, izeta)].build(l, true, nr, rgrid.data(), radials[ichi].data(), 0, izeta, symbol_, itype_, false);
315+
// chi_[index(l, izeta)].normalize();
316+
// ++ichi;
317+
// }
318+
// }
319+
// }

source/module_basis/module_nao/atomic_radials.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,6 @@ class AtomicRadials : public RadialSet
4343
//! Get the energy cutoff as given by the orbital file
4444
double orb_ecut() const { return orb_ecut_; }
4545

46-
/**
47-
* @brief static version of read_abacus_orb. A delete-new operation may cause the memory leak,
48-
* it is better to use std::vector to replace the raw pointer.
49-
*
50-
* @param ifs [in] ifstream from the orbital file, via `std::ifstream ifs(forb);`
51-
* @param elem [out] element symbol
52-
* @param ecut [out] planewave energy cutoff
53-
* @param nr [out] number of radial grid points
54-
* @param dr [out] radial grid spacing
55-
* @param nzeta [out] number of zeta functions for each angular momentum
56-
* @param radials [out] radial orbitals
57-
* @param rank [in] MPI rank
58-
*/
59-
static void read_abacus_orb(std::ifstream& ifs,
60-
std::string& elem,
61-
double& ecut,
62-
int& nr,
63-
double& dr,
64-
std::vector<int>& nzeta,
65-
std::vector<std::vector<double>>& radials,
66-
const int rank = 0);
67-
6846
private:
6947
double orb_ecut_; //!< energy cutoff as given by the orbital file
7048

source/module_basis/module_nao/radial_set.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#include "module_base/spherical_bessel_transformer.h"
99

10+
// FIXME: should update with pyabacus
11+
// #include "module_io/orb_io.h"
12+
1013
RadialSet::~RadialSet()
1114
{
1215
delete[] nzeta_;
@@ -252,3 +255,28 @@ void RadialSet::write_abacus_orb(const std::string& file_name, const int rank) c
252255
}
253256
file_to.close();
254257
}
258+
259+
// FIXME: should update with pyabacus
260+
// void RadialSet::write_abacus_orb(const std::string& forb, const int rank) const
261+
// {
262+
// std::ofstream ofs;
263+
// ofs.open(forb, std::ios::out);
264+
265+
// const double dr = 0.01;
266+
// const int nr = static_cast<int>(rcut_max_ / dr) + 1;
267+
// std::vector<int> nzeta(lmax_ + 1);
268+
// std::copy(nzeta_, nzeta_ + lmax_ + 1, nzeta.begin());
269+
// std::vector<std::vector<double>> radials(nchi_, std::vector<double>(nr, 0.0));
270+
// int ichi = 0;
271+
// for (int l = 0; l <= lmax_; l++)
272+
// {
273+
// for (int izeta = 0; izeta < nzeta[l]; izeta++)
274+
// {
275+
// std::copy(chi_[index(l, izeta)].rvalue(), chi_[index(l, izeta)].rvalue() + nr, radials[ichi].begin());
276+
// ichi++;
277+
// }
278+
// }
279+
280+
// ModuleIO::write_abacus_orb(ofs, symbol_, 100, nr, dr, nzeta, radials, rank);
281+
// ofs.close();
282+
// }

source/module_basis/module_nao/test/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AddTest(
1717
../projgen.cpp
1818
../../module_ao/ORB_atomic_lm.cpp
1919
../../module_ao/ORB_atomic.cpp
20+
../../../module_io/orb_io.cpp
2021
LIBS parameter ${math_libs} device base
2122
)
2223

@@ -29,6 +30,7 @@ AddTest(
2930
../numerical_radial.cpp
3031
../../module_ao/ORB_atomic_lm.cpp
3132
../../module_ao/ORB_atomic.cpp
33+
../../../module_io/orb_io.cpp
3234
LIBS parameter ${math_libs} device base
3335
)
3436

@@ -41,6 +43,7 @@ AddTest(
4143
../numerical_radial.cpp
4244
../../module_ao/ORB_atomic_lm.cpp
4345
../../module_ao/ORB_atomic.cpp
46+
../../../module_io/orb_io.cpp
4447
LIBS parameter ${math_libs} device base
4548
)
4649

@@ -53,6 +56,7 @@ AddTest(
5356
../numerical_radial.cpp
5457
../../module_ao/ORB_atomic_lm.cpp
5558
../../module_ao/ORB_atomic.cpp
59+
../../../module_io/orb_io.cpp
5660
LIBS parameter ${math_libs} device base
5761
)
5862

@@ -65,6 +69,7 @@ AddTest(
6569
../numerical_radial.cpp
6670
../../module_ao/ORB_atomic_lm.cpp
6771
../../module_ao/ORB_atomic.cpp
72+
../../../module_io/orb_io.cpp
6873
LIBS parameter ${math_libs} device base
6974
)
7075

@@ -83,6 +88,7 @@ AddTest(
8388
../sphbes_radials.cpp
8489
../../module_ao/ORB_atomic_lm.cpp
8590
../../module_ao/ORB_atomic.cpp
91+
../../../module_io/orb_io.cpp
8692
LIBS parameter ${math_libs} device base
8793
)
8894

@@ -103,6 +109,7 @@ AddTest(
103109
../two_center_bundle.cpp
104110
../two_center_integrator.cpp
105111
../real_gaunt_table.cpp
112+
../../../module_io/orb_io.cpp
106113
LIBS parameter ${math_libs} device base container orb
107114
)
108115

@@ -132,6 +139,7 @@ AddTest(
132139
../radial_set.cpp
133140
../numerical_radial.cpp
134141
../two_center_bundle.cpp
142+
../../../module_io/orb_io.cpp
135143
LIBS parameter ${math_libs} device base container orb
136144
)
137145

@@ -152,6 +160,7 @@ AddTest(
152160
../radial_set.cpp
153161
../projgen.cpp
154162
../numerical_radial.cpp
163+
../../../module_io/orb_io.cpp
155164
LIBS parameter ${math_libs} device base container orb
156165
)
157166

@@ -172,6 +181,7 @@ AddTest(
172181
../radial_set.cpp
173182
../projgen.cpp
174183
../numerical_radial.cpp
184+
../../../module_io/orb_io.cpp
175185
LIBS parameter ${math_libs} device base container orb
176186
)
177187

0 commit comments

Comments
 (0)