parameters: (coord,
                      box,
                      atype,
                      models,
                      fname=None,
                      frequency=1, 
                      nopbc=True)
return_statement: return devi
docstring: Python interface to calculate model deviation
  
      Parameters
      -----------
      coord : numpy.ndarray, `n_frames x n_atoms x 3`
          Coordinates of system to calculate
      box : numpy.ndarray or None, `n_frames x 3 x 3`
          Box to specify periodic boundary condition. If None, no pbc will be used
      atype : numpy.ndarray, `n_atoms x 1`
          Atom types
      models : list of DeepPot models
          Models used to evaluate deviation
      fname : str or None
          File to dump results, default None
      frequency : int
          Steps between frames (if the system is given by molecular dynamics engine), default 1
      nopbc : bool
          Whether to use pbc conditions
      
      Returns
      -------
      model_devi : numpy.ndarray, `n_frames x 7`
          Model deviation results. The first column is index of steps, the other 6 columns are
          max_devi_v, min_devi_v, avg_devi_v, max_devi_f, min_devi_f, avg_devi_f.
      
      Examples
      --------
      >>> from deepmd.infer import calc_model_devi
      >>> from deepmd.infer import DeepPot as DP
      >>> import numpy as np
      >>> coord = np.array([[1,0,0], [0,0,1.5], [1,0,3]]).reshape([1, -1])
      >>> cell = np.diag(10 * np.ones(3)).reshape([1, -1])
      >>> atype = [1,0,1]
      >>> graphs = [DP("graph.000.pb"), DP("graph.001.pb")]
      >>> model_devi = calc_model_devi(coord, cell, atype, graphs)
docstring_summary: Python interface to calculate model deviation
docstring_tokens: Python interface to calculate model deviation
function: def calc_model_devi(coord,
                      box,
                      atype,
                      models,
                      fname=None,
                      frequency=1, 
                      nopbc=True):
      '''
      Python interface to calculate model deviation
  
      Parameters
      -----------
      coord : numpy.ndarray, `n_frames x n_atoms x 3`
          Coordinates of system to calculate
      box : numpy.ndarray or None, `n_frames x 3 x 3`
          Box to specify periodic boundary condition. If None, no pbc will be used
      atype : numpy.ndarray, `n_atoms x 1`
          Atom types
      models : list of DeepPot models
          Models used to evaluate deviation
      fname : str or None
          File to dump results, default None
      frequency : int
          Steps between frames (if the system is given by molecular dynamics engine), default 1
      nopbc : bool
          Whether to use pbc conditions
      
      Returns
      -------
      model_devi : numpy.ndarray, `n_frames x 7`
          Model deviation results. The first column is index of steps, the other 6 columns are
          max_devi_v, min_devi_v, avg_devi_v, max_devi_f, min_devi_f, avg_devi_f.
      
      Examples
      --------
      >>> from deepmd.infer import calc_model_devi
      >>> from deepmd.infer import DeepPot as DP
      >>> import numpy as np
      >>> coord = np.array([[1,0,0], [0,0,1.5], [1,0,3]]).reshape([1, -1])
      >>> cell = np.diag(10 * np.ones(3)).reshape([1, -1])
      >>> atype = [1,0,1]
      >>> graphs = [DP("graph.000.pb"), DP("graph.001.pb")]
      >>> model_devi = calc_model_devi(coord, cell, atype, graphs)
      '''
      if nopbc:
          box = None
  
      forces = []
      virials = []
      for dp in models:
          ret = dp.eval(
              coord,
              box,
              atype,
          )
          forces.append(ret[1])
          virials.append(ret[2] / len(atype))
      
      forces = np.array(forces)
      virials = np.array(virials)
      
      devi = [np.arange(coord.shape[0]) * frequency]
      devi += list(calc_model_devi_v(virials))
      devi += list(calc_model_devi_f(forces))
      devi = np.vstack(devi).T
      if fname:
          write_model_devi_out(devi, fname)
      return devi
function_tokens: def calc_model_devi ( coord , box , atype , models , fname = None , frequency = 1 , nopbc = True ) : if nopbc : box = None forces = [ ] virials = [ ] for dp in models : ret = dp . eval ( coord , box , atype , ) forces . append ( ret [ 1 ] ) virials . append ( ret [ 2 ] / len ( atype ) ) forces = np . array ( forces ) virials = np . array ( virials ) devi = [ np . arange ( coord . shape [ 0 ] ) * frequency ] devi += list ( calc_model_devi_v ( virials ) ) devi += list ( calc_model_devi_f ( forces ) ) devi = np . vstack ( devi ) . T if fname : write_model_devi_out ( devi , fname ) return devi