Python API

class deepmd.utils.data.DataSets(sys_path, set_prefix, seed=None, shuffle_test=True)

Outdated class for one data system. Not maintained anymore.

check_batch_size(batch_size)
check_test_size(test_size)
get_batch(batch_size)

returned property prefector [4] in order: energy, force, virial, atom_ener

get_ener()
get_natoms()
get_natoms_2(ntypes)
get_natoms_vec(ntypes)
get_numb_set()
get_set(data, idx=None)
get_sys_numb_batch(batch_size)
get_test()

returned property prefector [4] in order: energy, force, virial, atom_ener

get_type_map()
load_batch_set(set_name)
load_data(set_name, data_name, shape, is_necessary=True)
load_energy(set_name, nframes, nvalues, energy_file, atom_energy_file)

return : coeff_ener, ener, coeff_atom_ener, atom_ener

load_set(set_name, shuffle=True)
load_test_set(set_name, shuffle_test)
load_type(sys_path)
load_type_map(sys_path)
numb_aparam()
numb_fparam()
reset_iter()
set_numb_batch(batch_size)
stats_energy()
class deepmd.utils.data.DeepmdData(sys_path: str, set_prefix: str = 'set', shuffle_test: bool = True, type_map: Optional[List[str]] = None, modifier=None, trn_all_set: bool = False)

Class for a data system. It loads data from hard disk, and mantains the data as a data_dict

add(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[List[int]] = None, repeat: int = 1)

Add a data item that to be loaded

key

The key of the item. The corresponding data is stored in sys_path/set.*/key.npy

ndof

The number of dof

atomic

The item is an atomic property. If False, the size of the data should be nframes x ndof If True, the size of data should be nframes x natoms x ndof

must

The data file sys_path/set.*/key.npy must exist. If must is False and the data file does not exist, the data_dict[find_key] is set to 0.0

high_prec

Load the data and store in float64, otherwise in float32

type_sel

Select certain type of atoms

repeat

The data will be repeated repeat times.

avg(key)

Return the average value of an item.

check_batch_size(batch_size)

Check if the system can get a batch of data with batch_size frames.

check_test_size(test_size)

Check if the system can get a test dataset with test_size frames.

get_atom_type()List[int]

Get atom types

get_batch(batch_size: int)dict

Get a batch of data with batch_size frames. The frames are randomly picked from the data system.

batch_size

size of the batch

get_data_dict()dict

Get the data_dict

get_natoms()

Get number of atoms

get_natoms_vec(ntypes: int)

Get number of atoms and number of atoms in different types

ntypes

Number of types (may be larger than the actual number of types in the system).

natoms

natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

get_ntypes()int

Number of atom types in the system

get_numb_batch(batch_size: int, set_idx: int)int

Get the number of batches in a set.

get_numb_set()int

Get number of training sets

get_sys_numb_batch(batch_size: int)int

Get the number of batches in the data system.

get_test(ntests: int = - 1)dict

Get the test data with ntests frames.

ntests

Size of the test data set. If ntests is -1, all test data will be get.

get_type_map()List[str]

Get the type map

reduce(key_out: str, key_in: str)

Generate a new item from the reduction of another atom

key_out

The name of the reduced item

key_in

The name of the data item to be reduced

reset_get_batch()
class deepmd.infer.data_modifier.DipoleChargeModifier(model_name: str, model_charge_map: List[float], sys_charge_map: List[float], ewald_h: float = 1, ewald_beta: float = 1)
build_fv_graph()tensorflow.python.framework.ops.Tensor

Build the computational graph for the force and virial inference.

eval(coord: numpy.array, box: numpy.array, atype: numpy.array, eval_fv: bool = True)Tuple[numpy.array, numpy.array, numpy.array]

Evaluate the modification

coord

The coordinates of atoms

box

The simulation region. PBC is assumed

atype

The atom types

eval_fv

Evaluate force and virial

tot_e

The energy modification

tot_f

The force modification

tot_v

The virial modification

load_prefix: str
modify_data(data: dict)None

Modify data.

data

Internal data of DeepmdData. Be a dict, has the following keys - coord coordinates - box simulation box - type atom types - find_energy tells if data has energy - find_force tells if data has force - find_virial tells if data has virial - energy energy - force force - virial virial

class deepmd.utils.data_system.DataSystem(systems, set_prefix, batch_size, test_size, rcut, run_opt=None)

Outdated class for the data systems. Not maintained anymore.

check_type_map_consistency(type_map_list)
compute_energy_shift()
format_name_length(name, width)
get_batch(sys_idx=None, sys_weights=None, style='prob_sys_size')
get_batch_size()
get_nbatches()
get_nsystems()
get_ntypes()
get_sys(sys_idx)
get_test(sys_idx=None)
get_type_map()
numb_fparam()
print_summary()
process_sys_weights(sys_weights)
class deepmd.utils.data_system.DeepmdDataSystem(systems: List[str], batch_size: int, test_size: int, rcut: float, set_prefix: str = 'set', shuffle_test: bool = True, type_map: Optional[List[str]] = None, modifier=None, trn_all_set=False, sys_probs=None, auto_prob_style='prob_sys_size')

Class for manipulating many data systems. It is implemented with the help of DeepmdData

add(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[List[int]] = None, repeat: int = 1)

Add a data item that to be loaded

key

The key of the item. The corresponding data is stored in sys_path/set.*/key.npy

ndof

The number of dof

atomic

The item is an atomic property. If False, the size of the data should be nframes x ndof If True, the size of data should be nframes x natoms x ndof

must

The data file sys_path/set.*/key.npy must exist. If must is False and the data file does not exist, the data_dict[find_key] is set to 0.0

high_prec

Load the data and store in float64, otherwise in float32

type_sel

Select certain type of atoms

repeat

The data will be repeated repeat times.

add_dict(adict: dict)None

Add items to the data system by a dict. adict should have items like adict[key] = {

‘ndof’: ndof, ‘atomic’: atomic, ‘must’: must, ‘high_prec’: high_prec, ‘type_sel’: type_sel, ‘repeat’: repeat,

} For the explaination of the keys see add

compute_energy_shift(rcond=0.001, key='energy')
get_batch(sys_idx: Optional[int] = None)

Get a batch of data from the data systems

sys_idx: int

The index of system from which the batch is get. If sys_idx is not None, sys_probs and auto_prob_style are ignored If sys_idx is None, automatically determine the system according to sys_probs or auto_prob_style, see the following.

get_batch_size()int

Get the batch size

get_data_dict(ii: int = 0)dict
get_nbatches()int

Get the total number of batches

get_nsystems()int

Get the number of data systems

get_ntypes()int

Get the number of types

get_sys(idx: int)deepmd.utils.data.DeepmdData

Get a certain data system

get_sys_ntest(sys_idx=None)
Get number of tests for the currently selected system,

or one defined by sys_idx.

get_test(sys_idx: Optional[int] = None, n_test: int = - 1)

Get test data from the the data systems.

sys_idx

The test dat of system with index sys_idx will be returned. If is None, the currently selected system will be returned.

n_test

Number of test data. If set to -1 all test data will be get.

get_type_map()List[str]

Get the type map

print_summary(name)
reduce(key_out, key_in)

Generate a new item from the reduction of another atom

key_out

The name of the reduced item

key_in

The name of the data item to be reduced

set_sys_probs(sys_probs=None, auto_prob_style: str = 'prob_sys_size')
class deepmd.infer.deep_eval.DeepEval(model_file: Path, load_prefix: str = 'load', default_tf_graph: bool = False)

Common methods for DeepPot, DeepWFC, DeepPolar, …

load_prefix: str
make_natoms_vec(atom_types: numpy.ndarray)numpy.ndarray

Make the natom vector used by deepmd-kit.

atom_types

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

property model_type: str

Get type of model.

:type:str

property model_version: str

Get type of model.

:type:str

static reverse_map(vec: numpy.ndarray, imap: List[int])numpy.ndarray

Reverse mapping of a vector according to the index map

vec

Input vector. Be of shape [nframes, natoms, -1]

imap

Index map. Be of shape [natoms]

vec_out

Reverse mapped vector.

static sort_input(coord: numpy.array, atom_type: numpy.array, sel_atoms: Optional[List[int]] = None)

Sort atoms in the system according their types.

coord

The coordinates of atoms. Should be of shape [nframes, natoms, 3]

atom_type

The type of atoms Should be of shape [natoms]

sel_atom

The selected atoms by type

coord_out

The coordinates after sorting

atom_type_out

The atom types after sorting

idx_map

The index mapping from the input to the output. For example coord_out = coord[:,idx_map,:]

sel_atom_type

Only output if sel_atoms is not None The sorted selected atom types

sel_idx_map

Only output if sel_atoms is not None The index mapping from the selected atoms to sorted selected atoms.

class deepmd.infer.deep_polar.DeepGlobalPolar(model_file: str, load_prefix: str = 'load', default_tf_graph: bool = False)

Constructor.

model_filestr

The name of the frozen model file.

load_prefix: str

The prefix in the load computational graph

default_tf_graphbool

If uses the default tf graph, otherwise build a new tf graph for evaluation

eval(coords: numpy.array, cells: numpy.array, atom_types: List[int], atomic: bool = False, fparam: Optional[numpy.array] = None, aparam: Optional[numpy.array] = None, efield: Optional[numpy.array] = None)numpy.array

Evaluate the model.

coords

The coordinates of atoms. The array should be of size nframes x natoms x 3

cells

The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9

atom_types

The atom types The list should contain natoms ints

atomic

Not used in this model

fparam

Not used in this model

aparam

Not used in this model

efield

Not used in this model

tensor

The returned tensor If atomic == False then of size nframes x variable_dof else of size nframes x natoms x variable_dof

get_dim_aparam()int

Unsupported in this model.

get_dim_fparam()int

Unsupported in this model.

load_prefix: str
class deepmd.infer.deep_polar.DeepPolar(model_file: Path, load_prefix: str = 'load', default_tf_graph: bool = False)

Constructor.

model_filePath

The name of the frozen model file.

load_prefix: str

The prefix in the load computational graph

default_tf_graphbool

If uses the default tf graph, otherwise build a new tf graph for evaluation

For developers: DeepTensor initializer must be called at the end after self.tensors are modified because it uses the data in self.tensors dict. Do not chanage the order!

get_dim_aparam()int

Unsupported in this model.

get_dim_fparam()int

Unsupported in this model.

load_prefix: str
class deepmd.infer.deep_pot.DeepPot(model_file: Path, load_prefix: str = 'load', default_tf_graph: bool = False)

Constructor.

model_filePath

The name of the frozen model file.

load_prefix: str

The prefix in the load computational graph

default_tf_graphbool

If uses the default tf graph, otherwise build a new tf graph for evaluation

For developers: DeepTensor initializer must be called at the end after self.tensors are modified because it uses the data in self.tensors dict. Do not chanage the order!

eval(coords: numpy.array, cells: numpy.array, atom_types: List[int], atomic: bool = False, fparam: Optional[numpy.array] = None, aparam: Optional[numpy.array] = None, efield: Optional[numpy.array] = None)Tuple[numpy.ndarray, ...]

Evaluate the energy, force and virial by using this DP.

coords

The coordinates of atoms. The array should be of size nframes x natoms x 3

cells

The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9

atom_types

The atom types The list should contain natoms ints

atomic

Calculate the atomic energy and virial

fparam

The frame parameter. The array can be of size : - nframes x dim_fparam. - dim_fparam. Then all frames are assumed to be provided with the same fparam.

aparam

The atomic parameter The array can be of size : - nframes x natoms x dim_aparam. - natoms x dim_aparam. Then all frames are assumed to be provided with the same aparam. - dim_aparam. Then all frames and atoms are provided with the same aparam.

efield

The external field on atoms. The array should be of size nframes x natoms x 3

energy

The system energy.

force

The force on each atom

virial

The virial

atom_energy

The atomic energy. Only returned when atomic == True

atom_virial

The atomic virial. Only returned when atomic == True

get_dim_aparam()int

Get the number (dimension) of atomic parameters of this DP.

get_dim_fparam()int

Get the number (dimension) of frame parameters of this DP.

get_ntypes()int

Get the number of atom types of this model.

get_rcut()float

Get the cut-off radius of this model.

get_sel_type()List[int]

Unsupported in this model.

get_type_map()List[int]

Get the type map (element name of the atom types) of this model.

load_prefix: str
class deepmd.infer.deep_wfc.DeepWFC(model_file: Path, load_prefix: str = 'load', default_tf_graph: bool = False)

Constructor.

model_filePath

The name of the frozen model file.

load_prefix: str

The prefix in the load computational graph

default_tf_graphbool

If uses the default tf graph, otherwise build a new tf graph for evaluation

For developers: DeepTensor initializer must be called at the end after self.tensors are modified because it uses the data in self.tensors dict. Do not chanage the order!

get_dim_aparam()int

Unsupported in this model.

get_dim_fparam()int

Unsupported in this model.

load_prefix: str
class deepmd.descriptor.loc_frame.DescrptLocFrame(rcut: float, sel_a: List[int], sel_r: List[int], axis_rule: List[int])
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord: list, data_box: list, data_atype: list, natoms_vec: list, mesh: list, input_dict: dict)None

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

get_dim_out()int

Returns the output dimension of this descriptor

get_nlist()Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, List[int], List[int]]
nlist

Neighbor list

rij

The relative distance between the neighbor and the center atom.

sel_a

The number of neighbors with full information

sel_r

The number of neighbors with only radial information

get_ntypes()int

Returns the number of atom types

get_rcut()float

Returns the cut-off radisu

get_rot_mat()tensorflow.python.framework.ops.Tensor

Get rotational matrix

prod_force_virial(atom_ener: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor]

Compute force and virial

atom_ener

The atomic energy

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

force

The force on atoms

virial

The total virial

atom_virial

The atomic virial

class deepmd.descriptor.se_a.DescrptSeA
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord: list, data_box: list, data_atype: list, natoms_vec: list, mesh: list, input_dict: dict)None

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

enable_compression(min_nbor_dist: float, model_file: str = 'frozon_model.pb', table_extrapolate: float = 5, table_stride_1: float = 0.01, table_stride_2: float = 0.1, check_frequency: int = - 1)None

Reveive the statisitcs (distance, max_nbor_size and env_mat_range) of the training data.

min_nbor_dist

The nearest distance between atoms

model_file

The original frozen model, which will be compressed by the program

table_extrapolate

The scale of model extrapolation

table_stride_1

The uniform stride of the first table

table_stride_2

The uniform stride of the second table

check_frequency

The overflow check frequency

get_dim_out()int

Returns the output dimension of this descriptor

get_dim_rot_mat_1()int

Returns the first dimension of the rotation matrix. The rotation is of shape dim_1 x 3

get_nlist()Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, List[int], List[int]]
nlist

Neighbor list

rij

The relative distance between the neighbor and the center atom.

sel_a

The number of neighbors with full information

sel_r

The number of neighbors with only radial information

get_ntypes()int

Returns the number of atom types

get_rcut()float

Returns the cut-off radius

get_rot_mat()tensorflow.python.framework.ops.Tensor

Get rotational matrix

prod_force_virial(atom_ener: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor]

Compute force and virial

atom_ener

The atomic energy

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

force

The force on atoms

virial

The total virial

atom_virial

The atomic virial

class deepmd.descriptor.se_r.DescrptSeR
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord, data_box, data_atype, natoms_vec, mesh, input_dict)

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

get_dim_out()

Returns the output dimension of this descriptor

get_nlist()
nlist

Neighbor list

rij

The relative distance between the neighbor and the center atom.

sel_a

The number of neighbors with full information

sel_r

The number of neighbors with only radial information

get_ntypes()

Returns the number of atom types

get_rcut()

Returns the cut-off radisu

prod_force_virial(atom_ener: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor]

Compute force and virial

atom_ener

The atomic energy

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

force

The force on atoms

virial

The total virial

atom_virial

The atomic virial

class deepmd.descriptor.se_ar.DescrptSeAR(jdata)
build(coord_, atype_, natoms, box, mesh, input_dict, suffix='', reuse=None)
compute_input_stats(data_coord, data_box, data_atype, natoms_vec, mesh, input_dict)
get_dim_out()
get_nlist_a()
get_nlist_r()
get_ntypes()
get_rcut()
prod_force_virial(atom_ener, natoms)
class deepmd.descriptor.se_a_ebd.DescrptSeAEbd(rcut: float, rcut_smth: float, sel: List[str], neuron: List[int] = [24, 48, 96], axis_neuron: int = 8, resnet_dt: bool = False, trainable: bool = True, seed: Optional[int] = None, type_one_side: bool = True, type_nchanl: int = 2, type_nlayer: int = 1, numb_aparam: int = 0, set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'default', exclude_types: List[int] = [])
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

class deepmd.descriptor.se_t.DescrptSeT
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord: list, data_box: list, data_atype: list, natoms_vec: list, mesh: list, input_dict: dict)None

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

get_dim_out()int

Returns the output dimension of this descriptor

get_nlist()Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, List[int], List[int]]
nlist

Neighbor list

rij

The relative distance between the neighbor and the center atom.

sel_a

The number of neighbors with full information

sel_r

The number of neighbors with only radial information

get_ntypes()int

Returns the number of atom types

get_rcut()float

Returns the cut-off radisu

prod_force_virial(atom_ener: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor]

Compute force and virial

atom_ener

The atomic energy

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

force

The force on atoms

virial

The total virial

atom_virial

The atomic virial

class deepmd.descriptor.se_a_ef.DescrptSeAEf
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs. Should have ‘efield’.

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord: list, data_box: list, data_atype: list, natoms_vec: list, mesh: list, input_dict: dict)None

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

get_dim_out()int

Returns the output dimension of this descriptor

get_dim_rot_mat_1()int

Returns the first dimension of the rotation matrix. The rotation is of shape dim_1 x 3

get_nlist()Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, List[int], List[int]]
nlist

Neighbor list

rij

The relative distance between the neighbor and the center atom.

sel_a

The number of neighbors with full information

sel_r

The number of neighbors with only radial information

get_ntypes()int

Returns the number of atom types

get_rcut()float

Returns the cut-off radisu

get_rot_mat()tensorflow.python.framework.ops.Tensor

Get rotational matrix

prod_force_virial(atom_ener: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor]

Compute force and virial

atom_ener

The atomic energy

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

force

The force on atoms

virial

The total virial

atom_virial

The atomic virial

class deepmd.descriptor.se_a_ef.DescrptSeAEfLower(op, rcut: float, rcut_smth: float, sel: List[str], neuron: List[int] = [24, 48, 96], axis_neuron: int = 8, resnet_dt: bool = False, trainable: bool = True, seed: Optional[int] = None, type_one_side: bool = True, exclude_types: List[int] = [], set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'default', uniform_seed: bool = False)

Helper class for implementing DescrptSeAEf

build(coord_, atype_, natoms, box_, mesh, input_dict, suffix='', reuse=None)

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord, data_box, data_atype, natoms_vec, mesh, input_dict)

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

class deepmd.descriptor.hybrid.DescrptHybrid(descrpt_list: list)
build(coord_: tensorflow.python.framework.ops.Tensor, atype_: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, box_: tensorflow.python.framework.ops.Tensor, mesh: tensorflow.python.framework.ops.Tensor, input_dict: dict, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for the descriptor

coord_

The coordinate of atoms

atype_

The type of atoms

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

mesh

For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.

input_dict

Dictionary for additional inputs

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

descriptor

The output descriptor

compute_input_stats(data_coord: list, data_box: list, data_atype: list, natoms_vec: list, mesh: list, input_dict: dict)None

Compute the statisitcs (avg and std) of the training data. The input will be normalized by the statistics.

data_coord

The coordinates. Can be generated by deepmd.model.make_stat_input

data_box

The box. Can be generated by deepmd.model.make_stat_input

data_atype

The atom types. Can be generated by deepmd.model.make_stat_input

natoms_vec

The vector for the number of atoms of the system and different types of atoms. Can be generated by deepmd.model.make_stat_input

mesh

The mesh for neighbor searching. Can be generated by deepmd.model.make_stat_input

input_dict

Dictionary for additional input

get_dim_out()int

Returns the output dimension of this descriptor

get_nlist_i(ii: int)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, List[int], List[int]]
iiint

Get the neighbor information of the ii-th descriptor

nlist

Neighbor list

rij

The relative distance between the neighbor and the center atom.

sel_a

The number of neighbors with full information

sel_r

The number of neighbors with only radial information

get_ntypes()int

Returns the number of atom types

get_rcut()float

Returns the cut-off radius

prod_force_virial(atom_ener: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor]

Compute force and virial

atom_ener

The atomic energy

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

force

The force on atoms

virial

The total virial

atom_virial

The atomic virial

class deepmd.infer.ewald_recp.EwaldRecp(hh, beta)

Evaluate the reciprocal part of the Ewald sum

eval(coord: numpy.array, charge: numpy.array, box: numpy.array)Tuple[numpy.array, numpy.array, numpy.array]

Evaluate

coord

The coordinates of atoms

charge

The atomic charge

box

The simulation region. PBC is assumed

e

The energy

f

The force

v

The virial

class deepmd.fit.ener.EnerFitting
build(inputs: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, input_dict: dict = {}, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for fitting net

inputs

The input descriptor

input_dict

Additional dict for inputs. if numb_fparam > 0, should have input_dict[‘fparam’] if numb_aparam > 0, should have input_dict[‘aparam’]

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

ener

The system energy

compute_input_stats(all_stat: dict, protection: float = 0.01)None

Compute the input statistics

Parameters: all_stat

if numb_fparam > 0 must have all_stat[‘fparam’] if numb_aparam > 0 must have all_stat[‘aparam’] can be prepared by model.make_stat_input

protection

Divided-by-zero protection

compute_output_stats(all_stat: dict)None

Compute the ouput statistics

all_stat

must have the following components: all_stat[‘energy’] of shape n_sys x n_batch x n_frame can be prepared by model.make_stat_input

get_numb_aparam()int

Get the number of atomic parameters

get_numb_fparam()int

Get the number of frame parameters

class deepmd.fit.dipole.DipoleFittingSeA

Fit the atomic dipole with descriptor se_a

build(input_d: tensorflow.python.framework.ops.Tensor, rot_mat: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, reuse: Optional[bool] = None, suffix: str = '')tensorflow.python.framework.ops.Tensor

Build the computational graph for fitting net

input_d

The input descriptor

rot_mat

The rotation matrix from the descriptor.

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

dipole

The atomic dipole.

get_out_size()int

Get the output size. Should be 3

get_sel_type()int

Get selected type

class deepmd.fit.polar.GlobalPolarFittingSeA

Fit the system polarizability with descriptor se_a

build(input_d, rot_mat, natoms, reuse=None, suffix='')tensorflow.python.framework.ops.Tensor

Build the computational graph for fitting net

input_d

The input descriptor

rot_mat

The rotation matrix from the descriptor.

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

polar

The system polarizability

get_out_size()int

Get the output size. Should be 9

get_sel_type()int

Get selected atom types

class deepmd.fit.polar.PolarFittingLocFrame(jdata, descrpt)

Fitting polarizability with local frame descriptor. not supported anymore.

build(input_d, rot_mat, natoms, reuse=None, suffix='')
get_out_size()
get_sel_type()
class deepmd.fit.polar.PolarFittingSeA

Fit the atomic polarizability with descriptor se_a

build(input_d: tensorflow.python.framework.ops.Tensor, rot_mat: tensorflow.python.framework.ops.Tensor, natoms: tensorflow.python.framework.ops.Tensor, reuse: Optional[bool] = None, suffix: str = '')

Build the computational graph for fitting net

input_d

The input descriptor

rot_mat

The rotation matrix from the descriptor.

natoms

The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

reuse

The weights in the networks should be reused when get the variable.

suffix

Name suffix to identify this descriptor

atomic_polar

The atomic polarizability

compute_input_stats(all_stat, protection=0.01)

Compute the input statistics

Parameters: all_stat

Dictionary of inputs. can be prepared by model.make_stat_input

protection

Divided-by-zero protection

get_out_size()int

Get the output size. Should be 9

get_sel_type()List[int]

Get selected atom types

class deepmd.fit.wfc.WFCFitting(jdata, descrpt)

Fitting Wannier function centers (WFCs) with local frame descriptor. Not supported anymore.

build(input_d, rot_mat, natoms, reuse=None, suffix='')
get_out_size()
get_sel_type()
get_wfc_numb()
deepmd.utils.network.embedding_net(xx, network_size, precision, activation_fn=<function tanh>, resnet_dt=False, name_suffix='', stddev=1.0, bavg=0.0, seed=None, trainable=True, uniform_seed=False)
xxTensor

Input tensor of shape [-1,1]

network_size: list of int

Size of the embedding network. For example [16,32,64]

precision:

Precision of network weights. For example, tf.float64

activation_fn:

Activation function

resnet_dt: boolean

Using time-step in the ResNet construction

name_suffix: str

The name suffix append to each variable.

stddev: float

Standard deviation of initializing network parameters

bavg: float

Mean of network intial bias

seed: int

Random seed for initializing network parameters

trainable: boolean

If the netowk is trainable

deepmd.utils.network.embedding_net_rand_seed_shift(network_size)
deepmd.utils.network.one_layer(inputs, outputs_size, activation_fn=<function tanh>, precision=tf.float64, stddev=1.0, bavg=0.0, name='linear', reuse=None, seed=None, use_timestep=False, trainable=True, useBN=False, uniform_seed=False)
deepmd.utils.network.one_layer_rand_seed_shift()
deepmd.utils.network.variable_summaries(var: tensorflow.python.ops.variables.VariableV1, name: str)

Attach a lot of summaries to a Tensor (for TensorBoard visualization).

vartf.Variable

[description]

namestr

variable name

class deepmd.utils.learning_rate.LearningRateExp(start_lr: float, stop_lr: float = 5e-08, decay_steps: int = 5000, decay_rate: float = 0.95)

The exponentially decaying learning rate.

The learning rate at step t is given by

lr(t) = start_lr * decay_rate ^ ( t / decay_steps )

build(global_step: tensorflow.python.framework.ops.Tensor, stop_step: Optional[int] = None)tensorflow.python.framework.ops.Tensor

Build the learning rate

global_step

The tf Tensor prividing the global training step

stop_step

The stop step. If provided, the decay_rate will be determined automatically and overwritten.

learning_rate

The learning rate

start_lr()float

Get the start lr

value(step: int)float

Get the lr at a certain step

Get local GPU resources.

deepmd.cluster.local.get_gpus()

Get available IDs of GPU cards at local. These IDs are valid when used as the TensorFlow device ID.

Optional[List[int]]

List of available GPU IDs. Otherwise, None.

deepmd.cluster.local.get_resource()Tuple[str, List[str], Optional[List[int]]]

Get local resources: nodename, nodelist, and gpus.

Tuple[str, List[str], Optional[List[int]]]

nodename, nodelist, and gpus

MOdule to get resources on SLURM cluster.

References

https://github.com/deepsense-ai/tensorflow_on_slurm ####

deepmd.cluster.slurm.get_resource()Tuple[str, List[str], Optional[List[int]]]

Get SLURM resources: nodename, nodelist, and gpus.

Tuple[str, List[str], Optional[List[int]]]

nodename, nodelist, and gpus

RuntimeError

if number of nodes could not be retrieved

ValueError

list of nodes is not of the same length sa number of nodes

ValueError

if current nodename is not found in node list

class deepmd.loss.ener.EnerDipoleLoss(starter_learning_rate: float, start_pref_e: float = 0.1, limit_pref_e: float = 1.0, start_pref_ed: float = 1.0, limit_pref_ed: float = 1.0)
build(learning_rate, natoms, model_dict, label_dict, suffix)
eval(sess, feed_dict, natoms)
static print_header()
print_on_training(tb_writer, cur_batch, sess, natoms, feed_dict_test, feed_dict_batch)
class deepmd.loss.ener.EnerStdLoss(starter_learning_rate: float, start_pref_e: float = 0.02, limit_pref_e: float = 1.0, start_pref_f: float = 1000, limit_pref_f: float = 1.0, start_pref_v: float = 0.0, limit_pref_v: float = 0.0, start_pref_ae: float = 0.0, limit_pref_ae: float = 0.0, start_pref_pf: float = 0.0, limit_pref_pf: float = 0.0, relative_f: Optional[float] = None)

Standard loss function for DP models

build(learning_rate, natoms, model_dict, label_dict, suffix)
eval(sess, feed_dict, natoms)
print_header()
print_on_training(tb_writer, cur_batch, sess, natoms, feed_dict_test, feed_dict_batch)
class deepmd.loss.tensor.TensorLoss(jdata, **kwarg)

Loss function for tensorial properties.

build(learning_rate, natoms, model_dict, label_dict, suffix)
eval(sess, feed_dict, natoms)
print_header()
print_on_training(tb_writer, cur_batch, sess, natoms, feed_dict_test, feed_dict_batch)
class deepmd.model.ener.EnerModel(descrpt, fitting, typeebd=None, type_map: Optional[List[str]] = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01, use_srtab: Optional[str] = None, smin_alpha: Optional[float] = None, sw_rmin: Optional[float] = None, sw_rmax: Optional[float] = None)
build(coord_, atype_, natoms, box, mesh, input_dict, suffix='', reuse=None)
data_stat(data)
get_ntypes()
get_rcut()
get_type_map()
model_type = 'ener'
class deepmd.model.tensor.DipoleModel(descrpt, fitting, type_map: Optional[List[str]] = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01)
class deepmd.model.tensor.GlobalPolarModel(descrpt, fitting, type_map: Optional[List[str]] = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01)
class deepmd.model.tensor.PolarModel(descrpt, fitting, type_map: Optional[List[str]] = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01)
class deepmd.model.tensor.TensorModel(tensor_name: str, descrpt, fitting, type_map: Optional[List[str]] = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01)
build(coord_, atype_, natoms, box, mesh, input_dict, suffix='', reuse=None)
data_stat(data)
get_ntypes()
get_out_size()
get_rcut()
get_sel_type()
get_type_map()
class deepmd.model.tensor.WFCModel(descrpt, fitting, type_map: Optional[List[str]] = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01)
class deepmd.train.trainer.DPTrainer(jdata, run_opt)
build(data, stop_batch=0)
get_evaluation_results(batch_list)
get_feed_dict(batch, is_training)
get_global_step()
static print_header(fp, train_results, valid_results)
static print_on_training(fp, train_results, valid_results, cur_batch, cur_lr)
train(train_data, valid_data=None)
valid_on_the_fly(fp, train_batches, valid_batches, print_header=False)