ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
cube_io.h
Go to the documentation of this file.
1#ifndef CUBE_IO_H
2#define CUBE_IO_H
4#include "spin_tag.h"
5
6#include <fstream>
7#include <string>
8#include <vector>
9class Parallel_Grid;
10
11namespace ModuleIO
12{
24inline std::string make_data_desc(const std::string& base, const std::string& mag_base, const int is, const int nspin)
25{
26 std::string desc = base + make_spin_tag(is, nspin);
27 if (nspin == 4 && is > 0)
28 {
29 desc = mag_base;
30 if (is == 1)
31 {
32 desc += "x";
33 }
34 else if (is == 2)
35 {
36 desc += "y";
37 }
38 else if (is == 3)
39 {
40 desc += "z";
41 }
42 }
43 return desc;
44}
45
47bool read_vdata_palgrid(const Parallel_Grid& pgrid,
48 const int my_rank,
49 std::ostream& ofs_running,
50 const std::string& fn,
51 double* const data,
52 const int nat);
53
58void write_vdata_palgrid(const Parallel_Grid& pgrid,
59 const double* const data,
60 const int is,
61 const int nspin,
62 const int iter,
63 const std::string& fn,
64 const double ef,
65 const UnitCell* const ucell,
66 const int precision,
67 const int out_fermi,
68 const bool two_fermi,
69 const bool reduce_all_pool,
70 const bool append,
71 std::ofstream& ofs_running,
72 const std::string& data_desc);
73
75bool read_cube(const std::string& file,
76 std::vector<std::string>& comment,
77 int& natom,
78 std::vector<double>& origin,
79 int& nx,
80 int& ny,
81 int& nz,
82 std::vector<double>& dx,
83 std::vector<double>& dy,
84 std::vector<double>& dz,
85 std::vector<int>& atom_type,
86 std::vector<double>& atom_charge,
87 std::vector<std::vector<double>>& atom_pos,
88 std::vector<double>& data);
89
93void write_cube(const std::string& file,
94 const std::vector<std::string>& comment,
95 const int& natom,
96 const std::vector<double>& origin,
97 const int& nx,
98 const int& ny,
99 const int& nz,
100 const std::vector<double>& dx,
101 const std::vector<double>& dy,
102 const std::vector<double>& dz,
103 const std::vector<int>& atom_type,
104 const std::vector<double>& atom_charge,
105 const std::vector<std::vector<double>>& atom_pos,
106 const std::vector<double>& data,
107 const int precision,
108 const bool append,
109 const int ndata_line = 6);
110
113void write_cube_header(std::ofstream& ofs,
114 const std::vector<std::string>& comment,
115 const int& natom,
116 const std::vector<double>& origin,
117 const int& nx,
118 const int& ny,
119 const int& nz,
120 const std::vector<double>& dx,
121 const std::vector<double>& dy,
122 const std::vector<double>& dz,
123 const std::vector<int>& atom_type,
124 const std::vector<double>& atom_charge,
125 const std::vector<std::vector<double>>& atom_pos,
126 const int precision);
127
130void write_cube_header_for_cell(std::ofstream& ofs,
131 const UnitCell& ucell,
132 const int nx,
133 const int ny,
134 const int nz,
135 const std::vector<std::string>& comment,
136 const int precision);
137
168void trilinear_interpolate(const double* const data_in,
169 const int& nx_read,
170 const int& ny_read,
171 const int& nz_read,
172 const int& nx,
173 const int& ny,
174 const int& nz,
175 double* data_out);
176} // namespace ModuleIO
177
178#endif
Definition parallel_grid.h:8
Provide the basic information about unitcell.
Definition unitcell.h:16
Internal helpers shared by the R-space sparse text writers. Declared here (instead of duplicated in e...
Definition csr_reader.cpp:8
void trilinear_interpolate(const std::vector< std::vector< int > > &points, const std::vector< std::vector< double > > &shifts, const Parallel_Grid &pgrid, const std::vector< double > &data, std::vector< double > &results)
Definition cal_ldos.cpp:427
void write_cube_header(std::ofstream &ofs, const std::vector< std::string > &comment, const int &natom, const std::vector< double > &origin, const int &nx, const int &ny, const int &nz, const std::vector< double > &dx, const std::vector< double > &dy, const std::vector< double > &dz, const std::vector< int > &atom_type, const std::vector< double > &atom_charge, const std::vector< std::vector< double > > &atom_pos, const int precision)
Definition write_cube.cpp:244
void write_vdata_palgrid(const Parallel_Grid &pgrid, const double *const data, const int is, const int nspin, const int iter, const std::string &fn, const double ef, const UnitCell *const ucell, const int precision, const int out_fermi, const bool two_fermi, const bool reduce_all_pool, const bool append, std::ofstream &ofs_running, const std::string &data_desc)
Definition write_cube.cpp:16
void write_cube(const std::string &file, const std::vector< std::string > &comment, const int &natom, const std::vector< double > &origin, const int &nx, const int &ny, const int &nz, const std::vector< double > &dx, const std::vector< double > &dy, const std::vector< double > &dz, const std::vector< int > &atom_type, const std::vector< double > &atom_charge, const std::vector< std::vector< double > > &atom_pos, const std::vector< double > &data, const int precision, const bool append, const int ndata_line=6)
Definition write_cube.cpp:195
void write_cube_header_for_cell(std::ofstream &ofs, const UnitCell &ucell, const int nx, const int ny, const int nz, const std::vector< std::string > &comment, const int precision)
Definition write_cube.cpp:304
std::string make_data_desc(const std::string &base, const std::string &mag_base, const int is, const int nspin)
Definition cube_io.h:24
bool read_cube(const std::string &file, std::vector< std::string > &comment, int &natom, std::vector< double > &origin, int &nx, int &ny, int &nz, std::vector< double > &dx, std::vector< double > &dy, std::vector< double > &dz, std::vector< int > &atom_type, std::vector< double > &atom_charge, std::vector< std::vector< double > > &atom_pos, std::vector< double > &data)
read the full data from a cube file
Definition read_cube.cpp:155
std::string make_spin_tag(const int is, const int nspin)
Definition spin_tag.h:12
bool read_vdata_palgrid(const Parallel_Grid &pgrid, const int my_rank, std::ostream &ofs_running, const std::string &fn, double *const data, const int nat)
read volumetric data from .cube file into the parallel distributed grid.
Definition test_pot_grad_xc.cpp:107
Definition allocator.h:6
file(GLOB ATen_CORE_SRCS "*.cpp") set(ATen_CPU_SRCS $
Definition CMakeLists.txt:1
const ModuleBase::Vector3< double > origin(0.0, 0.0, 0.0)