Esempio n. 1
0
def modifier_dipole_charge():
    doc_model_name = "The name of the frozen dipole model file."
    doc_model_charge_map = f"The charge of the WFCC. The list length should be the same as the {make_link('sel_type', 'model/fitting_net[dipole]/sel_type')}. "
    doc_sys_charge_map = f"The charge of real atoms. The list length should be the same as the {make_link('type_map', 'model/type_map')}"
    doc_ewald_h = f"The grid spacing of the FFT grid. Unit is A"
    doc_ewald_beta = f"The splitting parameter of Ewald sum. Unit is A^{-1}"

    return [
        Argument("model_name", str, optional=False, doc=doc_model_name),
        Argument("model_charge_map",
                 list,
                 optional=False,
                 doc=doc_model_charge_map),
        Argument("sys_charge_map",
                 list,
                 optional=False,
                 doc=doc_sys_charge_map),
        Argument("ewald_beta",
                 float,
                 optional=True,
                 default=0.4,
                 doc=doc_ewald_beta),
        Argument("ewald_h", float, optional=True, default=1.0,
                 doc=doc_ewald_h),
    ]
Esempio n. 2
0
def fitting_ener():
    doc_numb_fparam = 'The dimension of the frame parameter. If set to >0, file `fparam.npy` should be included to provided the input fparams.'
    doc_numb_aparam = 'The dimension of the atomic parameter. If set to >0, file `aparam.npy` should be included to provided the input aparams.'
    doc_neuron = 'The number of neurons in each hidden layers of the fitting net. When two hidden layers are of the same size, a skip connection is built.'
    doc_activation_function = f'The activation function in the fitting net. Supported activation functions are {list_to_doc(activation_fn_dict.keys())}'
    doc_precision = f'The precision of the fitting net parameters, supported options are {supported_precision()}'
    doc_resnet_dt = 'Whether to use a "Timestep" in the skip connection'
    doc_trainable = 'Whether the parameters in the fitting net are trainable. This option can be\n\n\
- bool: True if all parameters of the fitting net are trainable, False otherwise.\n\n\
- list of bool: Specifies if each layer is trainable. Since the fitting net is composed by hidden layers followed by a output layer, the length of tihs list should be equal to len(`neuron`)+1.'
    doc_rcond = 'The condition number used to determine the inital energy shift for each type of atoms.'
    doc_seed = 'Random seed for parameter initialization of the fitting net'
    doc_atom_ener = 'Specify the atomic energy in vacuum for each type'

    return [
        Argument("numb_fparam", int, optional = True, default = 0, doc = doc_numb_fparam),
        Argument("numb_aparam", int, optional = True, default = 0, doc = doc_numb_aparam),
        Argument("neuron", list, optional = True, default = [120,120,120], alias = ['n_neuron'], doc = doc_neuron),
        Argument("activation_function", str, optional = True, default = 'tanh', doc = doc_activation_function),
        Argument("precision", str, optional = True, default = 'float64', doc = doc_precision),
        Argument("resnet_dt", bool, optional = True, default = True, doc = doc_resnet_dt),
        Argument("trainable", [list,bool], optional = True, default = True, doc = doc_trainable),
        Argument("rcond", float, optional = True, default = 1e-3, doc = doc_rcond),
        Argument("seed", [int,None], optional = True, doc = doc_seed),
        Argument("atom_ener", list, optional = True, default = [], doc = doc_atom_ener)
    ]
Esempio n. 3
0
def learning_rate_args():
    doc_start_lr = 'The learning rate the start of the training.'
    doc_stop_lr = 'The desired learning rate at the end of the training.'
    doc_decay_steps = 'The learning rate is decaying every this number of training steps.'

    args = [
        Argument("start_lr",
                 float,
                 optional=True,
                 default=1e-3,
                 doc=doc_start_lr),
        Argument("stop_lr",
                 float,
                 optional=True,
                 default=1e-8,
                 doc=doc_stop_lr),
        Argument("decay_steps",
                 int,
                 optional=True,
                 default=5000,
                 doc=doc_decay_steps)
    ]

    doc_lr = "The learning rate options"
    return Argument("learning_rate", dict, args, [], doc=doc_lr)
Esempio n. 4
0
def check(data):
    ma = model_args()
    lra = learning_rate_args()
    la = loss_args()
    ta = training_args()

    base = Argument("base", dict, [ma, lra, la, ta])
    base.check_value(data)
Esempio n. 5
0
def descrpt_se_a_tpe_args():
    doc_type_nchanl = 'number of channels for type embedding'
    doc_type_nlayer = 'number of hidden layers of type embedding net'
    doc_numb_aparam = 'dimension of atomic parameter. if set to a value > 0, the atomic parameters are embedded.'

    return descrpt_se_a_args() + [        
        Argument("type_nchanl", int, optional = True, default = 4, doc = doc_type_nchanl),
        Argument("type_nlayer", int, optional = True, default = 2, doc = doc_type_nlayer),
        Argument("numb_aparam", int, optional = True, default = 0, doc = doc_numb_aparam)
    ]
Esempio n. 6
0
def descrpt_se_ar_args():
    link = make_link('se_a', 'model/descriptor[se_a]')
    doc_a = f'The parameters of descriptor {link}'
    link = make_link('se_r', 'model/descriptor[se_r]')
    doc_r = f'The parameters of descriptor {link}'

    return [
        Argument("a", dict, optional=False, doc=doc_a),
        Argument("r", dict, optional=False, doc=doc_r),
    ]
Esempio n. 7
0
def model_args():
    doc_type_map = 'A list of strings. Give the name to each type of atoms.'
    doc_data_stat_nbatch = 'The model determines the normalization from the statistics of the data. This key specifies the number of `frames` in each `system` used for statistics.'
    doc_descrpt = 'The descriptor of atomic environment.'
    doc_fitting = 'The fitting of physical properties.'
    doc_use_srtab = 'The table for the short-range pairwise interaction added on top of DP. The table is a text data file with (N_t + 1) * N_t / 2 + 1 columes. The first colume is the distance between atoms. The second to the last columes are energies for pairs of certain types. For example we have two atom types, 0 and 1. The columes from 2nd to 4th are for 0-0, 0-1 and 1-1 correspondingly.'
    doc_smin_alpha = 'The short-range tabulated interaction will be swithed according to the distance of the nearest neighbor. This distance is calculated by softmin. This parameter is the decaying parameter in the softmin. It is only required when `use_srtab` is provided.'
    doc_sw_rmin = 'The lower boundary of the interpolation between short-range tabulated interaction and DP. It is only required when `use_srtab` is provided.'
    doc_sw_rmax = 'The upper boundary of the interpolation between short-range tabulated interaction and DP. It is only required when `use_srtab` is provided.'

    ca = Argument("model", dict, [
        Argument("type_map", list, optional=True, doc=doc_type_map),
        Argument("data_stat_nbatch",
                 int,
                 optional=True,
                 default=10,
                 doc=doc_data_stat_nbatch),
        Argument("use_srtab", str, optional=True, doc=doc_use_srtab),
        Argument("smin_alpha", float, optional=True, doc=doc_smin_alpha),
        Argument("sw_rmin", float, optional=True, doc=doc_sw_rmin),
        Argument("sw_rmax", float, optional=True, doc=doc_sw_rmax),
        Argument("descriptor",
                 dict, [], [descrpt_variant_type_args()],
                 doc=doc_descrpt),
        Argument("fitting_net",
                 dict, [], [fitting_variant_type_args()],
                 doc=doc_fitting)
    ])
    # print(ca.gen_doc())
    return ca
Esempio n. 8
0
def normalize(data):
    ma = model_args()
    lra = learning_rate_args()
    la = loss_args()
    ta = training_args()

    base = Argument("base", dict, [ma, lra, la, ta])
    data = base.normalize_value(data, trim_pattern="_*")
    base.check_value(data)

    return data
Esempio n. 9
0
def descrpt_se_a_3be_args():
    doc_sel = 'A list of integers. The length of the list should be the same as the number of atom types in the system. `sel[i]` gives the selected number of type-i neighbors. `sel[i]` is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius.'
    doc_rcut = 'The cut-off radius.'
    doc_rcut_smth = 'Where to start smoothing. For example the 1/r term is smoothed from `rcut` to `rcut_smth`'
    doc_neuron = 'Number of neurons in each hidden layers of the embedding net. When two layers are of the same size or one layer is twice as large as the previous layer, a skip connection is built.'
    doc_activation_function = f'The activation function in the embedding net. Supported activation functions are {list_to_doc(ACTIVATION_FN_DICT.keys())}'
    doc_resnet_dt = 'Whether to use a "Timestep" in the skip connection'
    doc_precision = f'The precision of the embedding net parameters, supported options are {list_to_doc(PRECISION_DICT.keys())}'
    doc_trainable = 'If the parameters in the embedding net is trainable'
    doc_seed = 'Random seed for parameter initialization'
    doc_set_davg_zero = 'Set the normalization average to zero. This option should be set when `atom_ener` in the energy fitting is used'

    return [
        Argument("sel", list, optional=False, doc=doc_sel),
        Argument("rcut", float, optional=True, default=6.0, doc=doc_rcut),
        Argument("rcut_smth",
                 float,
                 optional=True,
                 default=0.5,
                 doc=doc_rcut_smth),
        Argument("neuron",
                 list,
                 optional=True,
                 default=[10, 20, 40],
                 doc=doc_neuron),
        Argument("activation_function",
                 str,
                 optional=True,
                 default='tanh',
                 doc=doc_activation_function),
        Argument("resnet_dt",
                 bool,
                 optional=True,
                 default=False,
                 doc=doc_resnet_dt),
        Argument("precision",
                 str,
                 optional=True,
                 default="float64",
                 doc=doc_precision),
        Argument("trainable",
                 bool,
                 optional=True,
                 default=True,
                 doc=doc_trainable),
        Argument("seed", [int, None], optional=True, doc=doc_seed),
        Argument("set_davg_zero",
                 bool,
                 optional=True,
                 default=False,
                 doc=doc_set_davg_zero)
    ]
Esempio n. 10
0
def descrpt_variant_type_args():
    doc_descrpt_type = 'The type of the descritpor. Valid types are `loc_frame`, `se_a`, `se_r` and `se_ar`. \n\n\
- `loc_frame`: Defines a local frame at each atom, and the compute the descriptor as local coordinates under this frame.\n\n\
- `se_a`: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor.\n\n\
- `se_r`: Used by the smooth edition of Deep Potential. Only the distance between atoms is used to construct the descriptor.\n\n\
- `se_ar`: A hybrid of `se_a` and `se_r`. Typically `se_a` has a smaller cut-off while the `se_r` has a larger cut-off.'
    
    return Variant("type", [
        Argument("loc_frame", dict, descrpt_local_frame_args()),
        Argument("se_a", dict, descrpt_se_a_args()),
        Argument("se_r", dict, descrpt_se_r_args()),
        Argument("se_ar", dict, descrpt_se_ar_args())
    ], doc = doc_descrpt_type)
Esempio n. 11
0
 def test_default(self):
     # naive
     ca = Argument("Key1", int, optional=True, default=1)
     beg = {}
     end = ca.normalize(beg)
     ref = {"Key1": 1}
     self.assertDictEqual(end, ref)
     self.assertDictEqual(beg, {})
     self.assertTrue(end is not beg)
     # inplace
     end1 = ca.normalize(beg, inplace=True)
     self.assertDictEqual(end1, ref)
     self.assertTrue(end1 is beg)
Esempio n. 12
0
 def test_alias(self):
     ca = Argument("Key1", int, alias=["Old1", "Old2"])
     beg = {"Old1": 1}
     end = ca.normalize(beg)
     ref = {"Key1": 1}
     self.assertDictEqual(end, ref)
     self.assertDictEqual(beg, {"Old1": 1})
     self.assertTrue(end is not beg)
     # inplace
     beg1 = {"Old2": 1}
     end1 = ca.normalize(beg1, inplace=True)
     self.assertDictEqual(end1, ref)
     self.assertTrue(end1 is beg1)
Esempio n. 13
0
def fitting_variant_type_args():
    doc_descrpt_type = 'The type of the fitting. Valid types are `ener`, `dipole`, `polar` and `global_polar`. \n\n\
- `ener`: Fit an energy model (potential energy surface).\n\n\
- `dipole`: Fit an atomic dipole model. Atomic dipole labels for all the selected atoms (see `sel_type`) should be provided by `dipole.npy` in each data system. The file has number of frames lines and 3 times of number of selected atoms columns.\n\n\
- `polar`: Fit an atomic polarizability model. Atomic polarizability labels for all the selected atoms (see `sel_type`) should be provided by `polarizability.npy` in each data system. The file has number of frames lines and 9 times of number of selected atoms columns.\n\n\
- `global_polar`: Fit a polarizability model. Polarizability labels should be provided by `polarizability.npy` in each data system. The file has number of frames lines and 9 columns.'
    
    return Variant("type", [Argument("ener", dict, fitting_ener()),
                            Argument("dipole", dict, fitting_dipole()),
                            Argument("polar", dict, fitting_polar()),
                            Argument("global_polar", dict, fitting_global_polar())], 
                   optional = True,
                   default_tag = 'ener',
                   doc = doc_descrpt_type)
Esempio n. 14
0
def loss_variant_type_args():
    doc_loss = 'The type of the loss. For fitting type `ener`, the loss type should be set to `ener` or left unset. For tensorial fitting types `dipole`, `polar` and `global_polar`, the type should be left unset.\n\.'

    return Variant("type", [Argument("ener", dict, loss_ener())],
                   optional=True,
                   default_tag='ener',
                   doc=doc_loss)
Esempio n. 15
0
def learning_rate_variant_type_args():
    doc_lr = 'The type of the learning rate.'

    return Variant("type", [Argument("exp", dict, learning_rate_exp())],
                   optional=True,
                   default_tag='exp',
                   doc=doc_lr)
Esempio n. 16
0
def loss_variant_type_args():
    doc_loss = 'The type of the loss. \n\.'

    return Variant("type", [Argument("ener", dict, loss_ener())],
                   optional=True,
                   default_tag='ener',
                   doc=doc_loss)
Esempio n. 17
0
def loss_args():
    doc_loss = 'The definition of loss function. The type of the loss depends on the type of the fitting. For fitting type `ener`, the prefactors before energy, force, virial and atomic energy losses may be provided. For fitting type `dipole`, `polar` and `global_polar`, the loss may be an empty `dict` or unset.' 
    ca = Argument('loss', dict, [], 
                  [loss_variant_type_args()],
                  optional = True,
                  doc = doc_loss)
    return ca
Esempio n. 18
0
def fitting_polar():
    doc_neuron = 'The number of neurons in each hidden layers of the fitting net. When two hidden layers are of the same size, a skip connection is built.'
    doc_activation_function = f'The activation function in the fitting net. Supported activation functions are {list_to_doc(activation_fn_dict.keys())}'
    doc_resnet_dt = 'Whether to use a "Timestep" in the skip connection'
    doc_precision = f'The precision of the fitting net parameters, supported options are {supported_precision()}'
    doc_scale = 'The output of the fitting net (polarizability matrix) will be scaled by ``scale``'
    doc_diag_shift = 'The diagonal part of the polarizability matrix  will be shifted by ``diag_shift``. The shift operation is carried out after ``scale``.'
    doc_fit_diag = 'Fit the diagonal part of the rotational invariant polarizability matrix, which will be converted to normal polarizability matrix by contracting with the rotation matrix.'
    doc_sel_type = 'The atom types for which the atomic polarizability will be provided. If not set, all types will be selected.'
    doc_seed = 'Random seed for parameter initialization of the fitting net'

    return [
        Argument("neuron",
                 list,
                 optional=True,
                 default=[120, 120, 120],
                 doc=doc_neuron),
        Argument("activation_function",
                 str,
                 optional=True,
                 default='tanh',
                 doc=doc_activation_function),
        Argument("resnet_dt",
                 bool,
                 optional=True,
                 default=True,
                 doc=doc_resnet_dt),
        Argument("precision",
                 str,
                 optional=True,
                 default='float64',
                 doc=doc_precision),
        Argument("fit_diag",
                 bool,
                 optional=True,
                 default=True,
                 doc=doc_fit_diag),
        Argument("scale", [list, float],
                 optional=True,
                 default=1.0,
                 doc=doc_scale),
        Argument("diag_shift", [list, float],
                 optional=True,
                 default=0.0,
                 doc=doc_diag_shift),
        Argument("sel_type", [list, int, None],
                 optional=True,
                 doc=doc_sel_type),
        Argument("seed", [int, None], optional=True, doc=doc_seed)
    ]
Esempio n. 19
0
def descrpt_local_frame_args():
    doc_sel_a = 'A list of integers. The length of the list should be the same as the number of atom types in the system. `sel_a[i]` gives the selected number of type-i neighbors. The full relative coordinates of the neighbors are used by the descriptor.'
    doc_sel_r = 'A list of integers. The length of the list should be the same as the number of atom types in the system. `sel_r[i]` gives the selected number of type-i neighbors. Only relative distance of the neighbors are used by the descriptor. sel_a[i] + sel_r[i] is recommended to be larger than the maximally possible number of type-i neighbors in the cut-off radius.'
    doc_rcut = 'The cut-off radius. The default value is 6.0'
    doc_axis_rule = 'A list of integers. The length should be 6 times of the number of types. \n\n\
- axis_rule[i*6+0]: class of the atom defining the first axis of type-i atom. 0 for neighbors with full coordinates and 1 for neighbors only with relative distance.\n\n\
- axis_rule[i*6+1]: type of the atom defining the first axis of type-i atom.\n\n\
- axis_rule[i*6+2]: index of the axis atom defining the first axis. Note that the neighbors with the same class and type are sorted according to their relative distance.\n\n\
- axis_rule[i*6+3]: class of the atom defining the first axis of type-i atom. 0 for neighbors with full coordinates and 1 for neighbors only with relative distance.\n\n\
- axis_rule[i*6+4]: type of the atom defining the second axis of type-i atom.\n\n\
- axis_rule[i*6+5]: class of the atom defining the second axis of type-i atom. 0 for neighbors with full coordinates and 1 for neighbors only with relative distance.'

    return [
        Argument("sel_a", list, optional=False, doc=doc_sel_a),
        Argument("sel_r", list, optional=False, doc=doc_sel_r),
        Argument("rcut", float, optional=True, default=6.0, doc=doc_rcut),
        Argument("axis_rule", list, optional=False, doc=doc_axis_rule)
    ]
Esempio n. 20
0
def modifier_variant_type_args():
    doc_modifier_type = "The type of modifier. See explanation below.\n\n\
-`dipole_charge`: Use WFCC to model the electronic structure of the system. Correct the long-range interaction"
    return Variant("type", 
                   [
                       Argument("dipole_charge", dict, modifier_dipole_charge()),
                   ],
                   optional = False,
                   doc = doc_modifier_type)
Esempio n. 21
0
def loss_ener():
    doc_start_pref_e = start_pref('energy')
    doc_limit_pref_e = limit_pref('energy')
    doc_start_pref_f = start_pref('force')
    doc_limit_pref_f = limit_pref('force')
    doc_start_pref_v = start_pref('virial')
    doc_limit_pref_v = limit_pref('virial')
    doc_start_pref_ae = start_pref('atom_ener')
    doc_start_pref_ae = limit_pref('atom_ener')
    doc_relative_f = 'If provided, relative force error will be used in the loss. The difference of force will be normalized by the magnitude of the force in the label with a shift given by `relative_f`, i.e. DF_i / ( || F || + relative_f ) with DF denoting the difference between prediction and label and || F || denoting the L2 norm of the label.'
    return [
        Argument("start_pref_e", [float, int],
                 optional=True,
                 default=0.02,
                 doc=doc_start_pref_e),
        Argument("limit_pref_e", [float, int],
                 optional=True,
                 default=1.00,
                 doc=doc_limit_pref_e),
        Argument("start_pref_f", [float, int],
                 optional=True,
                 default=1000,
                 doc=doc_start_pref_f),
        Argument("limit_pref_f", [float, int],
                 optional=True,
                 default=1.00,
                 doc=doc_limit_pref_f),
        Argument("start_pref_v", [float, int],
                 optional=True,
                 default=0.00,
                 doc=doc_start_pref_v),
        Argument("limit_pref_v", [float, int],
                 optional=True,
                 default=0.00,
                 doc=doc_limit_pref_v),
        Argument("start_pref_ae", [float, int],
                 optional=True,
                 default=0.00,
                 doc=doc_start_pref_v),
        Argument("limit_pref_ae", [float, int],
                 optional=True,
                 default=0.00,
                 doc=doc_limit_pref_v),
        Argument("relative_f", [float, None],
                 optional=True,
                 doc=doc_relative_f)
    ]
Esempio n. 22
0
def model_args():
    doc_type_map = 'A list of strings. Give the name to each type of atoms.'
    doc_data_stat_nbatch = 'The model determines the normalization from the statistics of the data. This key specifies the number of `frames` in each `system` used for statistics.'
    doc_descrpt = 'The descriptor of atomic environment.'
    doc_fitting = 'The fitting of physical properties.'
    ca = Argument("model", dict, [
        Argument("type_map", list, optional=True, doc=doc_type_map),
        Argument("data_stat_nbatch",
                 int,
                 optional=True,
                 default=10,
                 doc=doc_data_stat_nbatch),
        Argument("descriptor",
                 dict, [], [descrpt_variant_type_args()],
                 doc=doc_descrpt),
        Argument("fitting_net",
                 dict, [], [fitting_variant_type_args()],
                 doc=doc_fitting)
    ])
    # print(ca.gen_doc())
    return ca
Esempio n. 23
0
def fitting_dipole():
    doc_neuron = 'The number of neurons in each hidden layers of the fitting net. When two hidden layers are of the same size, a skip connection is built.'
    doc_activation_function = f'The activation function in the fitting net. Supported activation functions are {list_to_doc(activation_fn_dict.keys())}'
    doc_resnet_dt = 'Whether to use a "Timestep" in the skip connection'
    doc_precision = f'The precision of the fitting net parameters, supported options are {supported_precision()}'
    doc_sel_type = 'The atom types for which the atomic dipole will be provided. If not set, all types will be selected.'
    doc_seed = 'Random seed for parameter initialization of the fitting net'
    return [
        Argument("neuron",
                 list,
                 optional=True,
                 default=[120, 120, 120],
                 doc=doc_neuron),
        Argument("activation_function",
                 str,
                 optional=True,
                 default='tanh',
                 doc=doc_activation_function),
        Argument("resnet_dt",
                 bool,
                 optional=True,
                 default=True,
                 doc=doc_resnet_dt),
        Argument("precision",
                 str,
                 optional=True,
                 default='float64',
                 doc=doc_precision),
        Argument("sel_type", [list, int, None],
                 optional=True,
                 doc=doc_sel_type),
        Argument("seed", [int, None], optional=True, doc=doc_seed)
    ]
Esempio n. 24
0
    def arginfo():
        # TODO: change the possible value of batch and context types after we refactor the code
        doc_batch_type = 'The batch job system type. Option: Slurm, PBS, LSF, Shell, DpCloudServer'
        doc_context_type = 'The connection used to remote machine. Option: LocalContext, LazyLocalContext, SSHContext, DpCloudServerContext'
        doc_local_root = 'The dir where the tasks and relating files locate. Typically the project dir.'
        doc_remote_root = 'The dir where the tasks are executed on the remote machine. Only needed when context is not lazy-local.'
        doc_remote_profile = 'The information used to maintain the connection with remote machine. Only needed when context is ssh.'
        doc_clean_asynchronously = 'Clean the remote directory asynchronously after the job finishes.'

        remote_profile_format = SSHSession.arginfo()
        remote_profile_format.name = "remote_profile"
        remote_profile_format.doc = doc_remote_profile
        machine_args = [
            Argument("batch_type", str, optional=False, doc=doc_batch_type),
            Argument("context_type", str, optional=False,
                     doc=doc_context_type),
            # TODO: add default to local_root and remote_root after refactor the code
            Argument("local_root", str, optional=False, doc=doc_local_root),
            Argument("remote_root", str, optional=True, doc=doc_remote_root),
            remote_profile_format,
            Argument("clean_asynchronously",
                     bool,
                     optional=True,
                     default=False,
                     doc=doc_clean_asynchronously),
        ]

        machine_format = Argument("machine", dict, machine_args)
        return machine_format
Esempio n. 25
0
def descrpt_hybrid_args():
    doc_list = f'A list of descriptor definitions'

    return [
        Argument(
            "list",
            list, [], [
                Variant("type", [
                    Argument("loc_frame", dict, descrpt_local_frame_args()),
                    Argument("se_a", dict, descrpt_se_a_args()),
                    Argument("se_r", dict, descrpt_se_r_args()),
                    Argument("se_a_3be",
                             dict,
                             descrpt_se_a_3be_args(),
                             alias=['se_at']),
                    Argument("se_a_tpe",
                             dict,
                             descrpt_se_a_tpe_args(),
                             alias=['se_a_ebd'])
                ])
            ],
            repeat=True,
            optional=False,
            doc=doc_list,
            fold_subdoc=True)
    ]
Esempio n. 26
0
def descrpt_variant_type_args():
    link_lf = make_link('loc_frame', 'model/descriptor[loc_frame]')
    link_se_a = make_link('se_a', 'model/descriptor[se_a]')
    link_se_r = make_link('se_r', 'model/descriptor[se_r]')
    link_se_a_3be = make_link('se_a_3be', 'model/descriptor[se_a_3be]')
    link_se_a_tpe = make_link('se_a_tpe', 'model/descriptor[se_a_tpe]')
    link_hybrid = make_link('hybrid', 'model/descriptor[hybrid]')
    doc_descrpt_type = f'The type of the descritpor. See explanation below. \n\n\
- `loc_frame`: Defines a local frame at each atom, and the compute the descriptor as local coordinates under this frame.\n\n\
- `se_a`: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor.\n\n\
- `se_r`: Used by the smooth edition of Deep Potential. Only the distance between atoms is used to construct the descriptor.\n\n\
- `se_a_3be`: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Three-body embedding will be used by this descriptor.\n\n\
- `se_a_tpe`: Used by the smooth edition of Deep Potential. The full relative coordinates are used to construct the descriptor. Type embedding will be used by this descriptor.\n\n\
- `hybrid`: Concatenate of a list of descriptors as a new descriptor.'

    return Variant("type", [
        Argument("loc_frame", dict, descrpt_local_frame_args()),
        Argument("se_a", dict, descrpt_se_a_args()),
        Argument("se_r", dict, descrpt_se_r_args()),
        Argument("se_a_3be", dict, descrpt_se_a_3be_args(), alias=['se_at']),
        Argument("se_a_tpe", dict, descrpt_se_a_tpe_args(), alias=['se_a_ebd'
                                                                   ]),
        Argument("hybrid", dict, descrpt_hybrid_args()),
    ],
                   doc=doc_descrpt_type)
Esempio n. 27
0
 def test_combined(self):
     ca = Argument("base", dict, [
         Argument("sub1", int, optional=True, default=1, alias=["sub1a"]),
         Argument(
             "sub2", str, optional=True, default="haha", alias=["sub2a"])
     ])
     beg1 = {"base": {}}
     ref1 = {"base": {"sub1": 1, "sub2": "haha"}}
     self.assertDictEqual(ca.normalize(beg1), ref1)
     self.assertDictEqual(ca.normalize_value(beg1["base"]), ref1["base"])
     beg2 = {"base": {"sub1a": 2, "sub2a": "hoho", "_comment": None}}
     ref2 = {"base": {"sub1": 2, "sub2": "hoho"}}
     self.assertDictEqual(ca.normalize(beg2, trim_pattern="_*"), ref2)
     self.assertDictEqual(
         ca.normalize_value(beg2["base"], trim_pattern="_*"), ref2["base"])
Esempio n. 28
0
 def test_idx_variants(self):
     vt1 = Argument("type1", dict, [
                 Argument("shared", int),
                 Argument("vnt1_1", int),
                 Argument("vnt1_2", dict, [
                     Argument("vnt1_1_1", int)
                 ])
             ])
     vt2 = Argument("type2", dict, [
                 Argument("shared", int),
                 Argument("vnt2_1", int),
             ])
     vnt = Variant("vnt_flag", [vt1, vt2])
     self.assertTrue(vnt["type1"] is vt1)
     self.assertTrue(vnt["type2"] is vt2)
     with self.assertRaises(KeyError):
         vnt["type3"]
Esempio n. 29
0
 def test_sub_fields(self):
     ca = Argument(
         "base",
         dict, [
             Argument("sub1", int, doc="sub doc." * 5),
             Argument("sub2", [str, dict], [
                 Argument("subsub1", int, doc="subsub doc." * 5),
                 Argument(
                     "subsub2",
                     dict, [
                         Argument(
                             "subsubsub1", int, doc="subsubsub doc." * 5)
                     ],
                     doc="subsub doc." * 5)
             ],
                      doc="sub doc." * 5)
         ],
         doc="Base doc. " * 10)
     docstr = ca.gen_doc()
Esempio n. 30
0
 def test_sub_fields(self):
     ca = Argument(
         "base",
         dict, [
             Argument("sub1", int, doc="sub doc." * 5),
             Argument("sub2", [str, dict], [
                 Argument("subsub1", int, doc="subsub doc." * 5),
                 Argument(
                     "subsub2",
                     dict, [
                         Argument(
                             "subsubsub1", int, doc="subsubsub doc." * 5)
                     ],
                     doc="subsub doc." * 5)
             ],
                      doc="sub doc." * 5)
         ],
         doc="Base doc. " * 10)
     docstr = ca.gen_doc()
     jsonstr = json.dumps(ca, cls=ArgumentEncoder)