Skip to content

Commit

Permalink
Merge pull request #334 from brucefan1983/more_elements
Browse files Browse the repository at this point in the history
allow for up to 103 elements for nep
  • Loading branch information
brucefan1983 authored Dec 1, 2022
2 parents 31be44d + 79f5c31 commit 67c5a99
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/force/nep3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ heat transport, Phys. Rev. B. 104, 104309 (2021).
#include <string>
#include <vector>

const int NUM_ELEMENTS = 103;
const std::string ELEMENTS[NUM_ELEMENTS] = {
"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P",
"S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn",
Expand Down
3 changes: 2 additions & 1 deletion src/force/nep3.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once
#include "potential.cuh"
#include "utilities/common.cuh"
#include "utilities/gpu_vector.cuh"

struct NEP3_Data {
Expand Down Expand Up @@ -74,7 +75,7 @@ public:
bool enabled = false;
float rc_inner = 1.0f;
float rc_outer = 2.0f;
float atomic_numbers[10];
float atomic_numbers[NUM_ELEMENTS];
};

struct ExpandedBox {
Expand Down
1 change: 0 additions & 1 deletion src/force/nep3_multigpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ when there is NVlink, but is also not very bad when there is only PCI-E.
#include <thrust/scan.h>
#include <vector>

const int NUM_ELEMENTS = 103;
const std::string ELEMENTS[NUM_ELEMENTS] = {
"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P",
"S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn",
Expand Down
3 changes: 2 additions & 1 deletion src/force/nep3_multigpu.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once
#include "potential.cuh"
#include "utilities/common.cuh"
#include "utilities/gpu_vector.cuh"

struct NEP3_MULTIGPU_Data {
Expand Down Expand Up @@ -106,7 +107,7 @@ public:
bool enabled = false;
float rc_inner = 1.0f;
float rc_outer = 2.0f;
float atomic_numbers[10];
float atomic_numbers[NUM_ELEMENTS];
};

NEP3_MULTIGPU(
Expand Down
3 changes: 2 additions & 1 deletion src/main_nep/dataset.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "dataset.cuh"
#include "mic.cuh"
#include "parameters.cuh"
#include "utilities/common.cuh"
#include "utilities/error.cuh"

void Dataset::copy_structures(std::vector<Structure>& structures_input, int n1, int n2)
Expand Down Expand Up @@ -143,7 +144,7 @@ void Dataset::initialize_gpu_data(Parameters& para)
}
}

type_weight_gpu.resize(MAX_NUM_TYPES);
type_weight_gpu.resize(NUM_ELEMENTS);
energy_ref_gpu.resize(Nc);
virial_ref_gpu.resize(Nc * 6);
force_ref_gpu.resize(N * 3);
Expand Down
3 changes: 2 additions & 1 deletion src/main_nep/nep3.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once
#include "potential.cuh"
#include "utilities/common.cuh"
#include "utilities/gpu_vector.cuh"
class Parameters;
class Dataset;
Expand Down Expand Up @@ -72,7 +73,7 @@ public:
bool enabled = false;
float rc_inner = 1.0f;
float rc_outer = 2.0f;
float atomic_numbers[10];
float atomic_numbers[NUM_ELEMENTS];
};

NEP3(
Expand Down
10 changes: 5 additions & 5 deletions src/main_nep/parameters.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/

#include "parameters.cuh"
#include "utilities/common.cuh"
#include "utilities/error.cuh"
#include "utilities/read_file.cuh"
#include <cmath>
#include <iostream>

const int NUM_ELEMENTS = 103;
const std::string ELEMENTS[NUM_ELEMENTS] = {
"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P",
"S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn",
Expand Down Expand Up @@ -88,8 +88,8 @@ void Parameters::set_default_parameters()
batch_size = 1000; // large enough in most cases
population_size = 50; // almost optimal
maximum_generation = 100000; // a good starting point
type_weight_cpu.resize(MAX_NUM_TYPES);
for (int n = 0; n < MAX_NUM_TYPES; ++n) {
type_weight_cpu.resize(NUM_ELEMENTS);
for (int n = 0; n < NUM_ELEMENTS; ++n) {
type_weight_cpu[n] = 1.0f; // uniform weight by default
}
enable_zbl = false; // default is not to include ZBL
Expand Down Expand Up @@ -408,8 +408,8 @@ void Parameters::parse_type(const char** param, int num_param)
PRINT_INPUT_ERROR("number of types should be integer.\n");
}

if (num_types < 1 || num_types > MAX_NUM_TYPES) {
PRINT_INPUT_ERROR("number of types should >=1 and <= MAX_NUM_TYPES.");
if (num_types < 1 || num_types > NUM_ELEMENTS) {
PRINT_INPUT_ERROR("number of types should >=1 and <= NUM_ELEMENTS.");
}
if (num_param != 2 + num_types) {
PRINT_INPUT_ERROR("number of types and the number of listed elements do not match.\n");
Expand Down
2 changes: 0 additions & 2 deletions src/main_nep/parameters.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <string>
#include <vector>

#define MAX_NUM_TYPES 10

class Parameters
{
public:
Expand Down
1 change: 1 addition & 0 deletions src/utilities/common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

const int NUM_ELEMENTS = 103;
#define PI 3.14159265358979
#define K_B 8.617343e-5 // Boltzmann's constant
#define K_C 14.399645 // 1/(4*PI*epsilon_0)
Expand Down

0 comments on commit 67c5a99

Please sign in to comment.