Defining Rules in EMC Force Field Files

Hi,

I’m having trouble defining force-field rules for specific compounds. For example, I have types “o” and an “h” in my force field. I would like to ensure that they are bonded to each other, so I think I should write something like:

ITEM	RULES

# id	type	element	index	charge	rule

0	h	    H	      1	    0	      H(O(H))
1	o	    O	      2	    0	      [O](H)(H)


ITEM	END

in the .top file. However, when I do this, I get an error:

Warning: missing rules for field './water.prm'.
Warning: missing rule for {group, site} = {wat, 1}.
Warning: missing rule for {group, site} = {wat, 2}.
Error: core/fields.c:432 FieldsApply:
       Missing rules.
       Program aborted.

It appears that EMC is unable to build a water molecule which satisfies my rules. I’m including my .top, .prm and .esh file for this, so it may be reproduced (both adapted from the field/user example included with EMC).
water.esh (696 Bytes)
water.prm (983 Bytes)
water.top (361 Bytes)

Update I figured this out. From the manual:

FFDepth - Sets the maximum recursive with which to trace the chemical surrounding
of a site during typing; this depth should equal the maximum depth of the
provided rules

I changed this from 1 to 2 and it works.

FFDepth indeed controls how deep EMC will follow the chemical tree to match a type. I looked over the included files and would like to point a few EMC idiosyncrasies:

  1. EMC is a little finicky when tabs and white-spaces are concerned: one is advised not to mix them, esp. when force field formats are concerned.
  2. One can include the force field definitions directly into EMC Setup scripts, of which I pasted an example below. This approach has the added benefit, that white-space formatting of the force field files is taken care of by the EMC Script field module.
  3. I took the liberty of adding the SPC/E water parameters to the example below.
  4. You can use the ‘field_debug reduced’ setting to see how EMC interprets rules
#!/usr/bin/env emc_setup.pl
#
#  file:	water.esh
#  author:	Pieter J. in 't Veld
#  date:	September 27, 2018
#  purpose:	Example for user-defined force fields using standard force
#    		field
#

ITEM	OPTIONS

replace		true
field_name	water
field_location	.
#field_debug	reduced
density		0.998
temperature	298.15
pressure	1
ntotal		10000
emc_execute	true

ITEM	END	# OPTIONS

# Groups

ITEM	SHORTHAND

wat		O(H)(H),1.0

ITEM	END	# SHORTHAND

# Field

ITEM	FIELD

ITEM	DEFINE

ffmode		standard
fftype		united
ffdepth		4
cutoff		10
nbonded		3
angle		error
torsion		error

ITEM	END	# DEFINE

ITEM	MASS

# type	mass	element	ncons	charge	comment

hw	1.0079	H	1	0	SPCE water H
ow	15.9994	O	2	0	SPCE water O
	
ITEM	END	# MASS

ITEM	RULES

# type	charge	rule(s)

hw	0.4238	H(O(H))
ow	-0.8476	O(H)(H)

ITEM	END	# RULES

ITEM	NONBOND

# type1	type2	sigma	epsilon

hw	hw	1.0	0
ow	ow	3.16556	0.155394

ITEM	END	# NONBOND

ITEM	BOND

# type1	type2	k	l0

hw	ow	600	1

ITEM	END	# BOND

ITEM	ANGLE

# type1	type2	type3	k	theta0

hw	ow	hw	75	109.47

ITEM	END	# ANGLE

ITEM	END	# FIELD