deepmd.nvnmd.entrypoints package

class deepmd.nvnmd.entrypoints.MapTable(config_file: str, weight_file: str, map_file: str)[source]

Bases: object

Generate the mapping table describing the relastionship of atomic distance, cutoff function, and embedding matrix.

three mapping table will be built:

\(r^2_{ji} \rightarrow s_{ji}\)
\(r^2_{ji} \rightarrow h_{ji}\)
\(r^2_{ji} \rightarrow \mathcal{G}_{ji}\)

where \(s_{ji}\) is cut-off function, \(h_{ji} = \frac{s(r_{ji})}{r_{ji}}\), and \(\mathcal{G}_{ji}\) is embedding matrix.

The mapping funciton can be define as:

\(y = f(x) = y_{k} + (x - x_{k}) * dy_{k}\)
\(y_{k} = f(x_{k})\)
\(dy_{k} = \frac{f(x_{k+1}) - f(x_{k})}{dx}\)
\(x_{k} \leq x < x_{k+1}\)
\(x_{k} = k * dx\)

where \(dx\) is interpolation interval.

Parameters
config_file

input file name an .npy file containing the configuration information of NVNMD model

weight_file

input file name an .npy file containing the weights of NVNMD model

map_file

output file name an .npy file containing the mapping tables of NVNMD model

References

DOI: 10.1038/s41524-022-00773-z

Methods

build_grad(x, y, Nr, Nc)

: Build gradient of tensor y of x.

build_map_coef(cfgs, x, ys, grads, ...)

Build mapping table coefficient cfgs: cfg list cfg = x0, x1, dx.

build_s2g(s)

Build s->G s is switch function G is embedding net output.

build_s2g_grad()

Build gradient of G with respect to s.

build_t2g()

Build t->G t is chemical species of center atom and neighbor atom G is embedding net output of type.

build_u2s(r2)

Build tensor s, s=s(r2).

build_u2s_grad()

Build gradient of s with respect to u (r^2).

cal_coef4(cfgs, x, y, dy)

Build mapping table coefficient for one line coef4: a x^3 + b x^2 + c x + d = y: / d = y0 | c = y0' | b = (3 y1 - dx dy' - 2dx y0' - 3y0) / dx^2 a = (dx y1' - 2 y1 + dx y0' + 2 y0) / dx^3.

mapping(x, dic_map, cfgs)

Evaluate value by mapping table operation of tensorflow.

mapping2(x, dic_map, cfgs)

Evaluate value by mapping table of numpy.

plot_lines(x, dic1[, dic2])

Plot lines to see accuracy.

run_s2g()

Build s-> graph and run it to get value of mapping table.

run_t2g()

Build t-> graph and run it to get value of mapping table.

run_u2s()

Build u->s graph and run it to get value of mapping table.

build_davg_dstd

build_embedding_net

build_map

build_davg_dstd()[source]
build_embedding_net(xx, wbs, activation_fn=<function tanh>)[source]
build_grad(x, y, Nr, Nc)[source]

: Build gradient of tensor y of x.

build_map()[source]
build_map_coef(cfgs, x, ys, grads, grad_grads, Nr, Nc)[source]

Build mapping table coefficient cfgs: cfg list cfg = x0, x1, dx.

coef4: a x^3 + b x^2 + c x + d = y: / d = y0 | c = y0’ | b = (3 y1 - dx dy’ - 2dx y0’ - 3y0) / dx^2 a = (dx y1’ - 2 y1 + dx y0’ + 2 y0) / dx^3

build_s2g(s)[source]

Build s->G s is switch function G is embedding net output.

build_s2g_grad()[source]

Build gradient of G with respect to s.

build_t2g()[source]

Build t->G t is chemical species of center atom and neighbor atom G is embedding net output of type.

build_u2s(r2)[source]

Build tensor s, s=s(r2).

build_u2s_grad()[source]

Build gradient of s with respect to u (r^2).

cal_coef4(cfgs, x, y, dy)[source]

Build mapping table coefficient for one line coef4: a x^3 + b x^2 + c x + d = y: / d = y0 | c = y0’ | b = (3 y1 - dx dy’ - 2dx y0’ - 3y0) / dx^2 a = (dx y1’ - 2 y1 + dx y0’ + 2 y0) / dx^3.

mapping(x, dic_map, cfgs)[source]

Evaluate value by mapping table operation of tensorflow.

mapping2(x, dic_map, cfgs)[source]

Evaluate value by mapping table of numpy.

plot_lines(x, dic1, dic2=None)[source]

Plot lines to see accuracy.

run_s2g()[source]

Build s-> graph and run it to get value of mapping table.

run_t2g()[source]

Build t-> graph and run it to get value of mapping table.

run_u2s()[source]

Build u->s graph and run it to get value of mapping table.

class deepmd.nvnmd.entrypoints.Wrap(config_file: str, weight_file: str, map_file: str, model_file: str)[source]

Bases: object

Generate the binary model file (model.pb).

the model file can be use to run the NVNMD with lammps the pair style need set as:

pair_style nvnmd model.pb
pair_coeff * *
Parameters
config_file

input file name an .npy file containing the configuration information of NVNMD model

weight_file

input file name an .npy file containing the weights of NVNMD model

map_file

input file name an .npy file containing the mapping tables of NVNMD model

model_file

output file name an .pb file containing the model using in the NVNMD

References

DOI: 10.1038/s41524-022-00773-z

Methods

wrap_dscp()

Wrap the configuration of descriptor.

wrap_fitn()

Wrap the weights of fitting net.

wrap_head(nhs, nws)

Wrap the head information.

wrap_lut()

Wrap the LUT.

wrap_map()

Wrap the mapping table of embedding network.

wrap_weight(weight, NBIT_DISP, NBIT_WEIGHT)

weight: weights of fittingNet NBIT_DISP: nbits of exponent of weight max value NBIT_WEIGHT: nbits of mantissa of weights.

wrap

wrap_bias

wrap()[source]
wrap_bias(bias, NBIT_DATA, NBIT_DATA_FL)[source]
wrap_dscp()[source]

Wrap the configuration of descriptor.

version 0: [NBIT_IDX_S2G-1:0] SHIFT_IDX_S2G

[NBIT_NEIB*NTYPE-1:0] SELs [NBIT_FIXD*M1*NTYPE*NTYPE-1:0] GSs [NBIT_FLTE-1:0] NEXPO_DIV_NI

version 1:

[NBIT_FLTE-1:0] NEXPO_DIV_NI

wrap_fitn()[source]

Wrap the weights of fitting net.

w weight b bias

wrap_head(nhs, nws)[source]

Wrap the head information.

version nhead nheight nwidth rcut cut-off radius ntype number of atomic species nnei number of neighbors atom_ener atom bias energy

wrap_lut()[source]

Wrap the LUT.

wrap_map()[source]

Wrap the mapping table of embedding network.

wrap_weight(weight, NBIT_DISP, NBIT_WEIGHT)[source]

weight: weights of fittingNet NBIT_DISP: nbits of exponent of weight max value NBIT_WEIGHT: nbits of mantissa of weights.

deepmd.nvnmd.entrypoints.save_weight(sess, file_name: str = 'nvnmd/weight.npy')[source]

Save the dictionary of weight to a npy file.

Submodules

deepmd.nvnmd.entrypoints.freeze module

deepmd.nvnmd.entrypoints.freeze.filter_tensorVariableList(tensorVariableList) dict[source]

Get the name of variable for NVNMD.

train_attr/min_nbor_dist
descrpt_attr/t_avg:0
descrpt_attr/t_std:0
type_embed_net/matrix_{layer l}:0
type_embed_net/bias_{layer l}:0

version 0: | filter_type_{atom i}/matrix_{layer l}_{atomj}:0

filter_type_{atom i}/bias_{layer l}_{atomj}:0
layer_{layer l}_type_{atom i}/matrix:0
layer_{layer l}_type_{atom i}/bias:0
final_layer_type_{atom i}/matrix:0
final_layer_type_{atom i}/bias:0

version 1: | filter_type_all/matrix_{layer l}:0

filter_type_all/bias_{layer l}:0
filter_type_all/matrix_{layer l}_two_side_ebd:0
filter_type_all/bias_{layer l}_two_side_ebd:0
layer_{layer l}/matrix:0
layer_{layer l}/bias:0
final_layer/matrix:0
final_layer/bias:0
deepmd.nvnmd.entrypoints.freeze.save_weight(sess, file_name: str = 'nvnmd/weight.npy')[source]

Save the dictionary of weight to a npy file.

deepmd.nvnmd.entrypoints.mapt module

class deepmd.nvnmd.entrypoints.mapt.MapTable(config_file: str, weight_file: str, map_file: str)[source]

Bases: object

Generate the mapping table describing the relastionship of atomic distance, cutoff function, and embedding matrix.

three mapping table will be built:

\(r^2_{ji} \rightarrow s_{ji}\)
\(r^2_{ji} \rightarrow h_{ji}\)
\(r^2_{ji} \rightarrow \mathcal{G}_{ji}\)

where \(s_{ji}\) is cut-off function, \(h_{ji} = \frac{s(r_{ji})}{r_{ji}}\), and \(\mathcal{G}_{ji}\) is embedding matrix.

The mapping funciton can be define as:

\(y = f(x) = y_{k} + (x - x_{k}) * dy_{k}\)
\(y_{k} = f(x_{k})\)
\(dy_{k} = \frac{f(x_{k+1}) - f(x_{k})}{dx}\)
\(x_{k} \leq x < x_{k+1}\)
\(x_{k} = k * dx\)

where \(dx\) is interpolation interval.

Parameters
config_file

input file name an .npy file containing the configuration information of NVNMD model

weight_file

input file name an .npy file containing the weights of NVNMD model

map_file

output file name an .npy file containing the mapping tables of NVNMD model

References

DOI: 10.1038/s41524-022-00773-z

Methods

build_grad(x, y, Nr, Nc)

: Build gradient of tensor y of x.

build_map_coef(cfgs, x, ys, grads, ...)

Build mapping table coefficient cfgs: cfg list cfg = x0, x1, dx.

build_s2g(s)

Build s->G s is switch function G is embedding net output.

build_s2g_grad()

Build gradient of G with respect to s.

build_t2g()

Build t->G t is chemical species of center atom and neighbor atom G is embedding net output of type.

build_u2s(r2)

Build tensor s, s=s(r2).

build_u2s_grad()

Build gradient of s with respect to u (r^2).

cal_coef4(cfgs, x, y, dy)

Build mapping table coefficient for one line coef4: a x^3 + b x^2 + c x + d = y: / d = y0 | c = y0' | b = (3 y1 - dx dy' - 2dx y0' - 3y0) / dx^2 a = (dx y1' - 2 y1 + dx y0' + 2 y0) / dx^3.

mapping(x, dic_map, cfgs)

Evaluate value by mapping table operation of tensorflow.

mapping2(x, dic_map, cfgs)

Evaluate value by mapping table of numpy.

plot_lines(x, dic1[, dic2])

Plot lines to see accuracy.

run_s2g()

Build s-> graph and run it to get value of mapping table.

run_t2g()

Build t-> graph and run it to get value of mapping table.

run_u2s()

Build u->s graph and run it to get value of mapping table.

build_davg_dstd

build_embedding_net

build_map

build_davg_dstd()[source]
build_embedding_net(xx, wbs, activation_fn=<function tanh>)[source]
build_grad(x, y, Nr, Nc)[source]

: Build gradient of tensor y of x.

build_map()[source]
build_map_coef(cfgs, x, ys, grads, grad_grads, Nr, Nc)[source]

Build mapping table coefficient cfgs: cfg list cfg = x0, x1, dx.

coef4: a x^3 + b x^2 + c x + d = y: / d = y0 | c = y0’ | b = (3 y1 - dx dy’ - 2dx y0’ - 3y0) / dx^2 a = (dx y1’ - 2 y1 + dx y0’ + 2 y0) / dx^3

build_s2g(s)[source]

Build s->G s is switch function G is embedding net output.

build_s2g_grad()[source]

Build gradient of G with respect to s.

build_t2g()[source]

Build t->G t is chemical species of center atom and neighbor atom G is embedding net output of type.

build_u2s(r2)[source]

Build tensor s, s=s(r2).

build_u2s_grad()[source]

Build gradient of s with respect to u (r^2).

cal_coef4(cfgs, x, y, dy)[source]

Build mapping table coefficient for one line coef4: a x^3 + b x^2 + c x + d = y: / d = y0 | c = y0’ | b = (3 y1 - dx dy’ - 2dx y0’ - 3y0) / dx^2 a = (dx y1’ - 2 y1 + dx y0’ + 2 y0) / dx^3.

mapping(x, dic_map, cfgs)[source]

Evaluate value by mapping table operation of tensorflow.

mapping2(x, dic_map, cfgs)[source]

Evaluate value by mapping table of numpy.

plot_lines(x, dic1, dic2=None)[source]

Plot lines to see accuracy.

run_s2g()[source]

Build s-> graph and run it to get value of mapping table.

run_t2g()[source]

Build t-> graph and run it to get value of mapping table.

run_u2s()[source]

Build u->s graph and run it to get value of mapping table.

deepmd.nvnmd.entrypoints.mapt.mapt(*, nvnmd_config: Optional[str] = 'nvnmd/config.npy', nvnmd_weight: Optional[str] = 'nvnmd/weight.npy', nvnmd_map: Optional[str] = 'nvnmd/map.npy', **kwargs)[source]

deepmd.nvnmd.entrypoints.train module

deepmd.nvnmd.entrypoints.train.normalized_input(fn, PATH_CNN, CONFIG_CNN)[source]

Normalize a input script file for continuous neural network.

deepmd.nvnmd.entrypoints.train.normalized_input_qnn(jdata, PATH_QNN, CONFIG_CNN, WEIGHT_CNN, MAP_CNN)[source]

Normalize a input script file for quantize neural network.

deepmd.nvnmd.entrypoints.train.train_nvnmd(*, INPUT: str, init_model: Optional[str], restart: Optional[str], step: str, skip_neighbor_stat: bool = False, **kwargs)[source]

deepmd.nvnmd.entrypoints.wrap module

class deepmd.nvnmd.entrypoints.wrap.Wrap(config_file: str, weight_file: str, map_file: str, model_file: str)[source]

Bases: object

Generate the binary model file (model.pb).

the model file can be use to run the NVNMD with lammps the pair style need set as:

pair_style nvnmd model.pb
pair_coeff * *
Parameters
config_file

input file name an .npy file containing the configuration information of NVNMD model

weight_file

input file name an .npy file containing the weights of NVNMD model

map_file

input file name an .npy file containing the mapping tables of NVNMD model

model_file

output file name an .pb file containing the model using in the NVNMD

References

DOI: 10.1038/s41524-022-00773-z

Methods

wrap_dscp()

Wrap the configuration of descriptor.

wrap_fitn()

Wrap the weights of fitting net.

wrap_head(nhs, nws)

Wrap the head information.

wrap_lut()

Wrap the LUT.

wrap_map()

Wrap the mapping table of embedding network.

wrap_weight(weight, NBIT_DISP, NBIT_WEIGHT)

weight: weights of fittingNet NBIT_DISP: nbits of exponent of weight max value NBIT_WEIGHT: nbits of mantissa of weights.

wrap

wrap_bias

wrap()[source]
wrap_bias(bias, NBIT_DATA, NBIT_DATA_FL)[source]
wrap_dscp()[source]

Wrap the configuration of descriptor.

version 0: [NBIT_IDX_S2G-1:0] SHIFT_IDX_S2G

[NBIT_NEIB*NTYPE-1:0] SELs [NBIT_FIXD*M1*NTYPE*NTYPE-1:0] GSs [NBIT_FLTE-1:0] NEXPO_DIV_NI

version 1:

[NBIT_FLTE-1:0] NEXPO_DIV_NI

wrap_fitn()[source]

Wrap the weights of fitting net.

w weight b bias

wrap_head(nhs, nws)[source]

Wrap the head information.

version nhead nheight nwidth rcut cut-off radius ntype number of atomic species nnei number of neighbors atom_ener atom bias energy

wrap_lut()[source]

Wrap the LUT.

wrap_map()[source]

Wrap the mapping table of embedding network.

wrap_weight(weight, NBIT_DISP, NBIT_WEIGHT)[source]

weight: weights of fittingNet NBIT_DISP: nbits of exponent of weight max value NBIT_WEIGHT: nbits of mantissa of weights.

deepmd.nvnmd.entrypoints.wrap.wrap(*, nvnmd_config: Optional[str] = 'nvnmd/config.npy', nvnmd_weight: Optional[str] = 'nvnmd/weight.npy', nvnmd_map: Optional[str] = 'nvnmd/map.npy', nvnmd_model: Optional[str] = 'nvnmd/model.pb', **kwargs)[source]