Skip to content

Commit

Permalink
remove unused code and update a readme
Browse files Browse the repository at this point in the history
  • Loading branch information
brucefan1983 committed Sep 21, 2021
1 parent a00410c commit 9433f73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 46 deletions.
2 changes: 1 addition & 1 deletion potentials/nep/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| :-------------------- | :------------------ | :----------------------------------------------------------- |
| Si_Fan_2021.txt | [1] | This is a general-purpose potential for silicon, which should be applicable to most of the phases of silicon, but this is not guaranteed. Our tests show that the phonon dispersions of 2D silicene are not well described by this potential. |
| Silicene_Fan_2021.txt | [1] | The is a special potential for 2D silicene. The potential should be applicable to study elastic and thermal properties of 2D silicene (without defects and free edges) from 0 K to about 900 K and a biaxial strain from about -1% to about 1%. |
| PbTe_Fan_2021.txt | [1] | The is a special potential for bulk PbTe. The potential should be applicable to study thermal properties of bulk PbTe (without defects and surfaces) from 0 K to about 900 K with a fixed lattice constant of about 6.57 A. |
| PbTe_Fan_2021.txt | [2] | The is a special potential for bulk PbTe. The potential should be applicable to study thermal properties of bulk PbTe (without defects and surfaces) from 0 K to about 900 K with a fixed lattice constant of about 6.57 A. |



Expand Down
53 changes: 8 additions & 45 deletions src/model/read_xyz.cu
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ void read_xyz_in_line_2(FILE* fid_xyz, Box& box)
}

void read_xyz_in_line_3(
char* input_dir,
FILE* fid_xyz,
const int N,
const int has_velocity_in_xyz,
Expand All @@ -191,7 +190,7 @@ void read_xyz_in_line_3(
cpu_mass.resize(N);
cpu_position_per_atom.resize(N * 3);
cpu_velocity_per_atom.resize(N * 3);
std::vector<int> types;
number_of_types = -1;

for (int m = 0; m < group.size(); ++m) {
group[m].cpu_label.resize(N);
Expand All @@ -203,8 +202,8 @@ void read_xyz_in_line_3(
int count = fscanf(fid_xyz, "%d%lf%lf%lf%lf", &(cpu_type[n]), &x, &y, &z, &mass);
PRINT_SCANF_ERROR(count, 5, "Reading error for xyz.in.");

if (cpu_type[n] < 0) {
PRINT_INPUT_ERROR("Atom type should >= 0.");
if (cpu_type[n] < 0 || cpu_type[n] >= N) {
PRINT_INPUT_ERROR("Atom type should >= 0 and < N.");
}

if (mass <= 0) {
Expand All @@ -216,14 +215,8 @@ void read_xyz_in_line_3(
cpu_position_per_atom[n + N] = y;
cpu_position_per_atom[n + N * 2] = z;

bool find_a_new_type = true;
for (int k = 0; k < types.size(); ++k) {
if (types[k] == cpu_type[n]) {
find_a_new_type = false;
}
}
if (find_a_new_type) {
types.emplace_back(cpu_type[n]);
if (cpu_type[n] > number_of_types) {
number_of_types = cpu_type[n];
}

if (has_velocity_in_xyz) {
Expand Down Expand Up @@ -253,37 +246,7 @@ void read_xyz_in_line_3(
group[m].number++;
}

number_of_types = types.size();

bool is_nep = true;
for (int k = 0; k < types.size(); ++k) {
if (types[k] == 0) {
is_nep = false;
}
}
if (is_nep) {
// generate a file that will be read by the NEP potential
char file_atomic_number[200];
strcpy(file_atomic_number, input_dir);
strcat(file_atomic_number, "/atomic_number.in");
FILE* fid_atomic_number = my_fopen(file_atomic_number, "w");
for (int n = 0; n < N; ++n) {
fprintf(fid_atomic_number, "%d\n", cpu_type[n]);
}
fclose(fid_atomic_number);

// to be consistent with other potentials, transform atomic numbers to types 0, 1, 2, ...
for (int n = 0; n < N; ++n) {
int index = 0;
for (int k = 0; k < types.size(); ++k) {
if (cpu_type[n] == types[k]) {
index = k;
break;
}
}
cpu_type[n] = index;
}
}
number_of_types++;
}

void find_type_size(
Expand Down Expand Up @@ -336,7 +299,7 @@ void initialize_position(
read_xyz_in_line_2(fid_xyz, box);

read_xyz_in_line_3(
input_dir, fid_xyz, N, has_velocity_in_xyz, number_of_types, atom.cpu_type, atom.cpu_mass,
fid_xyz, N, has_velocity_in_xyz, number_of_types, atom.cpu_type, atom.cpu_mass,
atom.cpu_position_per_atom, atom.cpu_velocity_per_atom, group);

fclose(fid_xyz);
Expand Down Expand Up @@ -394,4 +357,4 @@ void allocate_memory_gpu(
atom.potential_per_atom.resize(N);
atom.heat_per_atom.resize(N * 5);
thermo.resize(6);
}
}

0 comments on commit 9433f73

Please sign in to comment.