&GLOBAL
  ECHO_INPUT
  PRINT_LEVEL MEDIUM
  PROGRAM CP2K
  PROJECT h2po4
  RUN_TYPE md
  TRACE OFF
&END GLOBAL

&MOTION
  &CONSTRAINT
    &COLLECTIVE
      COLVAR 1
      INTERMOLECULAR T
      TARGET 2.0
      &RESTRAINT
        K 0.005
      &END RESTRAINT
    &END COLLECTIVE
    &FIXED_ATOMS
      LIST 1 4
      &RESTRAINT
        K 9.0E-04
      &END RESTRAINT
    &END FIXED_ATOMS
  &END CONSTRAINT
  &MD
    ENSEMBLE NVT
    STEPS 10
    TEMPERATURE 300
    TIMESTEP 0.3
    &PRINT
      &ENERGY
      &END ENERGY
    &END PRINT
    !TEMP_TOL 50
    &THERMOSTAT
      REGION MASSIVE
      TYPE NOSE
      &NOSE
        LENGTH 5
        MTS 2
        TIMECON [wavenumber_t] 2000
        YOSHIDA 3
      &END NOSE
    &END THERMOSTAT
  &END MD
&END MOTION

&FORCE_EVAL
  METHOD Quickstep
  &DFT
    CHARGE -1
    &QS
      METHOD PM3
      &SE
        ANALYTICAL_GRADIENTS F
      &END SE
    &END QS
    &SCF
      EPS_SCF 1.0E-7
      MAX_SCF 50
      SCF_GUESS ATOMIC
      &OT ON
        MINIMIZER DIIS
        N_DIIS 7
        PRECONDITIONER NONE
      &END OT
      &OUTER_SCF
        EPS_SCF 1.0E-7
      &END OUTER_SCF
      &PRINT SILENT
        &PROGRAM_RUN_INFO SILENT
        &END PROGRAM_RUN_INFO
        &RESTART
          &EACH
            __ROOT__  1
            MD 1
            QS_SCF 50
          &END EACH
        &END RESTART
      &END PRINT
    &END SCF
  &END DFT
  &SUBSYS
    &CELL
      ABC 15.0 15.0 15.0
      PERIODIC NONE
    &END CELL
    &COLVAR
      &COORDINATION
        # phosphate
        ATOMS_FROM 1
        # 2 water oxygens
        ATOMS_TO 14 17
        ND 32
        NN 16
        R0 5.5
      &END COORDINATION
    &END COLVAR
    &COLVAR
      &DISTANCE_FUNCTION
        # PO - OH distance
        ATOMS 1 3 3 7
        COEFFICIENT -1.0000
      &END DISTANCE_FUNCTION
      &PRINT
        &PROGRAM_RUN_INFO LOW
          ADD_LAST NUMERIC
          COMMON_ITERATION_LEVELS 0
          FILENAME diff-dist
          &EACH
            MD 1000
          &END EACH
        &END PROGRAM_RUN_INFO
      &END PRINT
    &END COLVAR
    &COLVAR
      &COORDINATION
        #phosphate
        ATOMS_FROM 1
        # 2 water oxygens
        ATOMS_TO 14 17
        ND 24
        NN 12
        R0 3.5
      &END COORDINATION
      &PRINT
        &PROGRAM_RUN_INFO LOW
          ADD_LAST NUMERIC
          COMMON_ITERATION_LEVELS 0
          FILENAME P-watO
          &EACH
            MD 1000
          &END EACH
        &END PROGRAM_RUN_INFO
      &END PRINT
    &END COLVAR
    &COORD
      P         3.987000        1.531000        0.800000
      O         3.932000        2.722000       -0.053000
      O         3.579000        2.055000        2.143000
      O         3.038000        0.367000        0.259000
      O         5.394000        0.986000        0.848000
      H         2.050000        0.354000        0.617000
      H         3.196000        1.408000        2.846000
      O         2.918000        0.008000        3.653000
      H         3.222000        0.145000        4.552000
      H         3.345000       -0.907000        3.514000
      O         5.524000       -1.714000        0.987000
      H         5.295000       -1.995000        1.910000
      H         5.367000       -0.730000        0.960000
      O         5.595000        4.437000        2.482000
      H         5.376000        5.246000        1.935000
      H         5.410000        3.734000        1.832000
      O         6.221000        3.439000       -0.461000
      H         6.801000        2.946000        0.142000
      H         5.352000        3.000000       -0.270000
    &END COORD
  &END SUBSYS
&END FORCE_EVAL
