Page MenuHomec4science

pair_cneuronet.h
No OneTemporary

File Metadata

Created
Tue, Aug 6, 14:10

pair_cneuronet.h

/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
This file is written by Till Junge <till.junge@epfl.ch>
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(cneuronet,PairCNeuroNet)
#else
#ifndef LMP_PAIR_CNEURO_NET_H
#define LMP_PAIR_CNEURO_NET_H
#include "pair.h"
#include <vector>
#include <map>
#include "CNEURONET/neigh_container.hh"
#include "CNEURONET/weigh_container.hh"
namespace LAMMPS_NS {
class PairCNeuroNet : public Pair {
public:
enum class SymFunType: int;
using uint = unsigned int;
using i_iterator = NeighContainer::iterator;
using ij_iterator = NeighContainer::iterator::jterator;
using param_ptr = std::vector<std::pair<const double *, int> >;
using param_map = std::map<SymFunType, param_ptr>;
using index_pair = std::array<int,2>;
using dfun_ret = std::array<double,2>;
using param_container = std::map<const index_pair, param_map>;
using WeightType = DimNumArray<2, double>;
using W_col_it = WeightType::iterator<1>;
using W_row_it = WeightType::iterator<0>;
PairCNeuroNet(class LAMMPS *);
virtual ~PairCNeuroNet();
virtual void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
void init_style();
double init_one(int, int);
void write_restart(FILE *);
void read_restart(FILE *);
void write_restart_settings(FILE *);
void read_restart_settings(FILE *);
protected:
/** Methods **/
// interatomic distance
inline double comp_r_ij(const double * pos_i, const double * pos_j);
// cut-off function and derivative
inline double comp_fc_ij(const double & r_ij);
inline double comp_Dfc_ij(const double & r_ij);
// symmetry function and derivative
template<SymFunType func_type>
inline double comp_fs_nij(const double * const param, const double & r_ij);
template<SymFunType func_type>
inline double comp_Dfs_nij(const double * const param, const double & r_ij);
// Sigmoid function and derivative
inline double comp_f_a(const double & x);
inline double comp_Df_a(const double & x);
// G_im,j and DG_im,j evaluator
template<SymFunType func_type>
inline void comp_G_imj(const ij_iterator & ij, const param_ptr& param_vec);
template<int vflag_at>
inline void comp_roll_um_sums();
template<int vflag_at, int eflag_at>
inline void comp_roll_um_sums_inner();
double comp_phi (W_row_it & w_it,
const i_iterator & at_i,
const size_t layer);
dfun_ret comp_Dphi(W_row_it & w_it,
const i_iterator & at_i,
const ij_iterator & at_j,
const size_t layer);
inline
double comp_ymm (W_row_it & w_it,
const i_iterator & at_i,
const size_t layer);
inline
dfun_ret comp_Dymm(W_row_it & w_it,
const i_iterator & at_i,
const ij_iterator & at_j,
const size_t layer);
/** Members **/
// weights vector (contigous dim of weights are nb_input)
std::vector<WeightType> weights;
// size values
uint nl; //number of layers
uint nsp; // number of species
std::vector<uint> nhl; // number of nodes per hidden layer
std::vector<SymFunType> itype; // array of symmetry function ids
// contains beginnings and ends of symmetry function id to consider for each species pair: iaddr2(i, j, k) i: 1 for start, 2 for end; j, k pair of species
std::vector<uint> iaddr2; // for 2-body potential
std::vector<uint> iaddr3; // for 3-body potential
// alternative storage to iaddr:
// param_container[species1][species2] is a map linking symmetry fun types to parameter sets
param_container sym_fun_params;
// parameters of the symmetry functions
// eta = cnst(1, isf) // isf is symmetry function id
// alpha = cnst(2, isf)
std::vector<double> cnst;
// cutoff radii for 2 and 3 body potentials
double rcin, rc3;
/** pair interaction containers **/
// main iterator and lammps fields accessor
NeighContainer neighs;
template<typename T>
using i_container = i_iterator::i_container<T>;
using j_iterator = i_iterator::jterator;
template<typename T>
using ij_container = j_iterator::ij_container<T>;
// interatomic distances
ij_container<double> r_ij;
// cut_off function values and derivatives
ij_container<double> fc_ij;
ij_container<double> Dfc_ij;
// symmetry function values and derivatives
//ij_container<double> fs_nij;
//ij_container<double> fs_Dnij;
i_container<double> G_im;
ij_container<double> DG_imj;
// nb of parameters per symmetry function type
constexpr static uint get_ncnst(const SymFunType & func_type);
// n in n-body potential per symmetry function type
constexpr static uint get_ncomb(const SymFunType & func_type);
constexpr static uint max_ncnst = 2;//hardcoded because of poor code design
//cutoff region width ratio to rc (hardcoded in Ryo's potential
constexpr static double alpha = 0.9;
};
}
#endif
#endif

Event Timeline