diff --git a/doc/src/fix_rigid.txt b/doc/src/fix_rigid.txt
index 99105e13507249636d2c0b5118450cf9d11da040..a5a631bd382e851c60cda8bfbe17c51eb0b73d18 100644
--- a/doc/src/fix_rigid.txt
+++ b/doc/src/fix_rigid.txt
@@ -26,6 +26,9 @@ style = {rigid} or {rigid/nve} or {rigid/nvt} or {rigid/npt} or {rigid/nph} or {
 bodystyle = {single} or {molecule} or {group} :l
   {single} args = none
   {molecule} args = none
+  {custom} args = {i_propname} or {v_varname}
+    i_propname = an integer property defined via fix property/atom
+    v_varname  = an atom-style or atomfile-style variable 
   {group} args = N groupID1 groupID2 ...
     N = # of groups
     groupID1, groupID2, ... = list of N group IDs :pre
@@ -80,6 +83,16 @@ fix 1 rods rigid/npt molecule temp 300.0 300.0 100.0 iso 0.5 0.5 10.0
 fix 1 particles rigid/npt molecule temp 1.0 1.0 5.0 x 0.5 0.5 1.0 z 0.5 0.5 1.0 couple xz
 fix 1 water rigid/nph molecule iso 0.5 0.5 1.0
 fix 1 particles rigid/npt/small molecule temp 1.0 1.0 1.0 iso 0.5 0.5 1.0 :pre
+
+variable bodyid atom 1.0*gmask(clump1)+2.0*gmask(clump2)+3.0*gmask(clump3)
+fix 1 clump rigid custom v_bodyid :pre
+
+variable bodyid atomfile bodies.txt
+fix 1 clump rigid custom v_bodyid :pre
+
+fix 0 all property/atom i_bodyid
+read_restart data.rigid fix 0 NULL Bodies
+fix 1 clump rigid/small custom i_bodyid :pre
 	
 [Description:]
 
@@ -100,7 +113,7 @@ of a biomolecule such as a protein.
 
 Example of small rigid bodies are patchy nanoparticles, such as those
 modeled in "this paper"_#Zhang1 by Sharon Glotzer's group, clumps of
-granular particles, lipid molecules consiting of one or more point
+granular particles, lipid molecules consisting of one or more point
 dipoles connected to other spheroids or ellipsoids, irregular
 particles built from line segments (2d) or triangles (3d), and
 coarse-grain models of nano or colloidal particles consisting of a
@@ -203,11 +216,11 @@ most one rigid body.  Which atoms are in which bodies can be defined
 via several options.
 
 NOTE: With the {rigid/small} styles, which require that {bodystyle} be
-specified as {molecule}, you can define a system that has no rigid
-bodies initially.  This is useful when you are using the {mol} keyword
-in conjunction with another fix that is adding rigid bodies on-the-fly
-as molecules, such as "fix deposit"_fix_deposit.html or "fix
-pour"_fix_pour.html.
+specified as {molecule} or {custom}, you can define a system that has
+no rigid bodies initially.  This is useful when you are using the {mol}
+keyword in conjunction with another fix that is adding rigid bodies
+on-the-fly as molecules, such as "fix deposit"_fix_deposit.html or
+"fix pour"_fix_pour.html.
 
 For bodystyle {single} the entire fix group of atoms is treated as one
 rigid body.  This option is only allowed for the {rigid} styles.
@@ -222,6 +235,15 @@ molecule ID = 0) surrounding rigid bodies, this may not be what you
 want.  Thus you should be careful to use a fix group that only
 includes atoms you want to be part of rigid bodies.
 
+Bodystyle {custom} is similar to bodystyle {molecule}, however some
+custom properties are used to group atoms into rigid bodies. The
+special case for molecule/body ID = 0 is not available. Possible
+custom properties are an integer property associated with atoms through
+"fix property/atom"_fix_property_atom.html or an atom style variable
+or an atomfile style variable. For the latter two, the variable value
+will be rounded to an integer and then rigid bodies defined from
+those values.
+
 For bodystyle {group}, each of the listed groups is treated as a
 separate rigid body.  Only atoms that are also in the fix group are
 included in each rigid body.  This option is only allowed for the
diff --git a/examples/rigid/bodies.txt b/examples/rigid/bodies.txt
new file mode 100644
index 0000000000000000000000000000000000000000..ddca2c7539b57a1eed2109d954bd5903bc7a765d
--- /dev/null
+++ b/examples/rigid/bodies.txt
@@ -0,0 +1,83 @@
+81
+1 1
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+10 2
+11 2
+12 2
+13 2
+14 2
+15 2
+16 2
+17 2
+18 2
+19 3
+20 3
+21 3
+22 3
+23 3
+24 3
+25 3
+26 3
+27 3
+28 4
+29 4
+30 4
+31 4
+32 4
+33 4
+34 4
+35 4
+36 4
+37 5
+38 5
+39 5
+40 5
+41 5
+42 5
+43 5
+44 5
+45 5
+46 6
+47 6
+48 6
+49 6
+50 6
+51 6
+52 6
+53 6
+54 6
+55 7
+56 7
+57 7
+58 7
+59 7
+60 7
+61 7
+62 7
+63 7
+64 8
+65 8
+66 8
+67 8
+68 8
+69 8
+70 8
+71 8
+72 8
+73 9
+74 9
+75 9
+76 9
+77 9
+78 9
+79 9
+80 9
+81 9
+
diff --git a/examples/rigid/data.rigid-property b/examples/rigid/data.rigid-property
new file mode 100644
index 0000000000000000000000000000000000000000..66fc42d2d2cf6b0e27a1ca0cb4cedbac889b0d75
--- /dev/null
+++ b/examples/rigid/data.rigid-property
@@ -0,0 +1,185 @@
+# LAMMPS data file for rigid bodies
+
+81	atoms		
+1	atom types	
+
+-12 12 xlo xhi
+-12 12 ylo yhi
+-12 12 zlo zhi
+
+Masses			
+
+1 1		
+
+Pair Coeffs			
+
+1 1 1		
+
+Atoms				
+
+1	1	0	0	0
+2	1	0	1	0
+3	1	0	0.5	0
+4	1	0.5	0	0
+5	1	0.5	0.5	1
+6	1	1	0.5	0
+7	1	0.5	1	0
+8	1	1	0	0
+9	1	1	1	0
+10	1	2	1	0
+11	1	1	2	0
+12	1	1.5	2	0
+13	1	1.5	1	0
+14	1	1	1.5	0
+15	1	1.5	1.5	1
+16	1	2	1.5	0
+17	1	2	2	0
+18	1	2	3	0
+19	1	2	2.5	0
+20	1	2.5	2	0
+21	1	2.5	2.5	1
+22	1	3	2.5	0
+23	1	2.5	3	0
+24	1	3	2	0
+25	1	3	3	0
+26	1	4	3	0
+27	1	3	4	0
+28	1	3.5	4	0
+29	1	3.5	3	0
+30	1	3	3.5	0
+31	1	3.5	3.5	1
+32	1	4	3.5	0
+33	1	4	4	0
+34	1	4	5	0
+35	1	4	4.5	0
+36	1	4.5	4	0
+37	1	4.5	4.5	1
+38	1	5	4.5	0
+39	1	4.5	5	0
+40	1	5	4	0
+41	1	5	5	0
+42	1	6	5	0
+43	1	5	6	0
+44	1	5.5	6	0
+45	1	5.5	5	0
+46	1	5	5.5	0
+47	1	5.5	5.5	1
+48	1	6	5.5	0
+49	1	6	6	0
+50	1	6	7	0
+51	1	6	6.5	0
+52	1	6.5	6	0
+53	1	6.5	6.5	1
+54	1	7	6.5	0
+55	1	6.5	7	0
+56	1	7	6	0
+57	1	7	7	0
+58	1	8	7	0
+59	1	7	8	0
+60	1	7.5	8	0
+61	1	7.5	7	0
+62	1	7	7.5	0
+63	1	7.5	7.5	1
+64	1	8	7.5	0
+65	1	8	8	0
+66	1	8	9	0
+67	1	8	8.5	0
+68	1	8.5	8	0
+69	1	8.5	8.5	1
+70	1	9	8.5	0
+71	1	8.5	9	0
+72	1	9	8	0
+73	1	9	9	0
+74	1	10	9	0
+75	1	9	10	0
+76	1	9.5	10	0
+77	1	9.5	9	0
+78	1	9	9.5	0
+79	1	9.5	9.5	1
+80	1	10	9.5	0
+81	1	10	10	0
+
+Bodies
+
+1 1
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+10 2
+11 2
+12 2
+13 2
+14 2
+15 2
+16 2
+17 2
+18 2
+19 3
+20 3
+21 3
+22 3
+23 3
+24 3
+25 3
+26 3
+27 3
+28 4
+29 4
+30 4
+31 4
+32 4
+33 4
+34 4
+35 4
+36 4
+37 5
+38 5
+39 5
+40 5
+41 5
+42 5
+43 5
+44 5
+45 5
+46 6
+47 6
+48 6
+49 6
+50 6
+51 6
+52 6
+53 6
+54 6
+55 7
+56 7
+57 7
+58 7
+59 7
+60 7
+61 7
+62 7
+63 7
+64 8
+65 8
+66 8
+67 8
+68 8
+69 8
+70 8
+71 8
+72 8
+73 9
+74 9
+75 9
+76 9
+77 9
+78 9
+79 9
+80 9
+81 9
+
diff --git a/examples/rigid/in.rigid-atomfile b/examples/rigid/in.rigid-atomfile
new file mode 100644
index 0000000000000000000000000000000000000000..8817386c79f7df174b1a538b107b88da5897d5b4
--- /dev/null
+++ b/examples/rigid/in.rigid-atomfile
@@ -0,0 +1,83 @@
+# Simple rigid body system
+
+units		lj
+atom_style	atomic
+atom_modify  map array
+
+pair_style	lj/cut 2.5
+
+read_data	data.rigid
+
+velocity 	all create 100.0 4928459
+
+
+# unconnected bodies
+
+group		clump1 id <> 1 9
+group		clump2 id <> 10 18
+group		clump3 id <> 19 27
+group		clump4 id <> 28 36
+group		clump5 id <> 37 45
+group		clump6 id <> 46 54
+group		clump7 id <> 55 63
+group		clump8 id <> 64 72
+group		clump9 id <> 73 81
+
+variable bodies atomfile bodies.txt
+fix 1 all rigid custom v_bodies
+
+# 1 chain of connected bodies
+
+#group		clump1 id <> 1 9
+#group		clump2 id <> 9 18
+#group		clump3 id <> 18 27
+#group		clump4 id <> 27 36
+#group		clump5 id <> 36 45
+#group		clump6 id <> 45 54
+#group		clump7 id <> 54 63
+#group		clump8 id <> 63 72
+#group		clump9 id <> 72 81
+
+#fix 1 all poems group clump1 clump2 clump3 clump4 clump5 &
+#	  	      clump6 clump7 clump8 clump9
+
+# 2 chains of connected bodies
+
+#group		clump1 id <> 1 9
+#group		clump2 id <> 9 18
+#group		clump3 id <> 18 27
+#group		clump4 id <> 27 36
+#group		clump5 id <> 37 45
+#group		clump6 id <> 45 54
+#group		clump7 id <> 54 63
+#group		clump8 id <> 63 72
+#group		clump9 id <> 72 81
+
+#fix 1 all poems group clump1 clump2 clump3 clump4
+#fix 2 all poems group clump5 clump6 clump7 clump8 clump9
+
+neigh_modify	exclude group clump1 clump1
+neigh_modify	exclude group clump2 clump2
+neigh_modify	exclude group clump3 clump3
+neigh_modify	exclude group clump4 clump4
+neigh_modify	exclude group clump5 clump5
+neigh_modify	exclude group clump6 clump6
+neigh_modify	exclude group clump7 clump7
+neigh_modify	exclude group clump8 clump8
+neigh_modify	exclude group clump9 clump9
+
+thermo		100
+
+#dump		1 all atom 50 dump.rigid
+
+#dump		2 all image 100 image.*.jpg type type &
+#		axes yes 0.8 0.02 view 60 -30
+#dump_modify	2 pad 5
+
+#dump		3 all movie 100 movie.mpg type type &
+#		axes yes 0.8 0.02 view 60 -30
+#dump_modify	3 pad 5
+
+timestep 	0.0001
+thermo		50
+run		10000
diff --git a/examples/rigid/in.rigid-atomvar b/examples/rigid/in.rigid-atomvar
new file mode 100644
index 0000000000000000000000000000000000000000..994ab1d28432db3a934cac421f419d6d5adbf127
--- /dev/null
+++ b/examples/rigid/in.rigid-atomvar
@@ -0,0 +1,83 @@
+# Simple rigid body system
+
+units		lj
+atom_style	atomic
+atom_modify  map array
+
+pair_style	lj/cut 2.5
+
+read_data	data.rigid
+
+velocity 	all create 100.0 4928459
+
+
+# unconnected bodies
+
+group		clump1 id <> 1 9
+group		clump2 id <> 10 18
+group		clump3 id <> 19 27
+group		clump4 id <> 28 36
+group		clump5 id <> 37 45
+group		clump6 id <> 46 54
+group		clump7 id <> 55 63
+group		clump8 id <> 64 72
+group		clump9 id <> 73 81
+
+variable bodies atom 1.0*gmask(clump1)+2.0*gmask(clump2)+3.0*gmask(clump3)+4.0*gmask(clump4)+5.0*gmask(clump5)+6.0*gmask(clump6)+7.0*gmask(clump7)+8.0*gmask(clump8)+9.0*gmask(clump9)
+fix 1 all rigid custom v_bodies
+
+# 1 chain of connected bodies
+
+#group		clump1 id <> 1 9
+#group		clump2 id <> 9 18
+#group		clump3 id <> 18 27
+#group		clump4 id <> 27 36
+#group		clump5 id <> 36 45
+#group		clump6 id <> 45 54
+#group		clump7 id <> 54 63
+#group		clump8 id <> 63 72
+#group		clump9 id <> 72 81
+
+#fix 1 all poems group clump1 clump2 clump3 clump4 clump5 &
+#	  	      clump6 clump7 clump8 clump9
+
+# 2 chains of connected bodies
+
+#group		clump1 id <> 1 9
+#group		clump2 id <> 9 18
+#group		clump3 id <> 18 27
+#group		clump4 id <> 27 36
+#group		clump5 id <> 37 45
+#group		clump6 id <> 45 54
+#group		clump7 id <> 54 63
+#group		clump8 id <> 63 72
+#group		clump9 id <> 72 81
+
+#fix 1 all poems group clump1 clump2 clump3 clump4
+#fix 2 all poems group clump5 clump6 clump7 clump8 clump9
+
+neigh_modify	exclude group clump1 clump1
+neigh_modify	exclude group clump2 clump2
+neigh_modify	exclude group clump3 clump3
+neigh_modify	exclude group clump4 clump4
+neigh_modify	exclude group clump5 clump5
+neigh_modify	exclude group clump6 clump6
+neigh_modify	exclude group clump7 clump7
+neigh_modify	exclude group clump8 clump8
+neigh_modify	exclude group clump9 clump9
+
+thermo		100
+
+#dump		1 all atom 50 dump.rigid
+
+#dump		2 all image 100 image.*.jpg type type &
+#		axes yes 0.8 0.02 view 60 -30
+#dump_modify	2 pad 5
+
+#dump		3 all movie 100 movie.mpg type type &
+#		axes yes 0.8 0.02 view 60 -30
+#dump_modify	3 pad 5
+
+timestep 	0.0001
+thermo		50
+run		10000
diff --git a/examples/rigid/in.rigid-property b/examples/rigid/in.rigid-property
new file mode 100644
index 0000000000000000000000000000000000000000..53d62776e6764c4e22573324f4bc69da8cb79d7a
--- /dev/null
+++ b/examples/rigid/in.rigid-property
@@ -0,0 +1,85 @@
+# Simple rigid body system
+
+units		lj
+atom_style	atomic
+atom_modify  map array
+
+pair_style	lj/cut 2.5
+
+fix 0 all property/atom i_bodies
+
+read_data	data.rigid-property fix 0 NULL Bodies
+
+velocity 	all create 100.0 4928459
+
+
+# unconnected bodies
+
+group		clump1 id <> 1 9
+group		clump2 id <> 10 18
+group		clump3 id <> 19 27
+group		clump4 id <> 28 36
+group		clump5 id <> 37 45
+group		clump6 id <> 46 54
+group		clump7 id <> 55 63
+group		clump8 id <> 64 72
+group		clump9 id <> 73 81
+
+# assemble bodies from per-atom custom integer property bodies
+fix 1 all rigid custom i_bodies
+
+# 1 chain of connected bodies
+
+#group		clump1 id <> 1 9
+#group		clump2 id <> 9 18
+#group		clump3 id <> 18 27
+#group		clump4 id <> 27 36
+#group		clump5 id <> 36 45
+#group		clump6 id <> 45 54
+#group		clump7 id <> 54 63
+#group		clump8 id <> 63 72
+#group		clump9 id <> 72 81
+
+#fix 1 all poems group clump1 clump2 clump3 clump4 clump5 &
+#	  	      clump6 clump7 clump8 clump9
+
+# 2 chains of connected bodies
+
+#group		clump1 id <> 1 9
+#group		clump2 id <> 9 18
+#group		clump3 id <> 18 27
+#group		clump4 id <> 27 36
+#group		clump5 id <> 37 45
+#group		clump6 id <> 45 54
+#group		clump7 id <> 54 63
+#group		clump8 id <> 63 72
+#group		clump9 id <> 72 81
+
+#fix 1 all poems group clump1 clump2 clump3 clump4
+#fix 2 all poems group clump5 clump6 clump7 clump8 clump9
+
+neigh_modify	exclude group clump1 clump1
+neigh_modify	exclude group clump2 clump2
+neigh_modify	exclude group clump3 clump3
+neigh_modify	exclude group clump4 clump4
+neigh_modify	exclude group clump5 clump5
+neigh_modify	exclude group clump6 clump6
+neigh_modify	exclude group clump7 clump7
+neigh_modify	exclude group clump8 clump8
+neigh_modify	exclude group clump9 clump9
+
+thermo		100
+
+#dump		1 all atom 50 dump.rigid
+
+#dump		2 all image 100 image.*.jpg type type &
+#		axes yes 0.8 0.02 view 60 -30
+#dump_modify	2 pad 5
+
+#dump		3 all movie 100 movie.mpg type type &
+#		axes yes 0.8 0.02 view 60 -30
+#dump_modify	3 pad 5
+
+timestep 	0.0001
+thermo		50
+run		10000
diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp
index d2a770cc4712db6b48b2f18823a86a23e1b61f82..33a4b441fda4f9f3eefb3039db46c4ea2724a454 100644
--- a/src/RIGID/fix_rigid.cpp
+++ b/src/RIGID/fix_rigid.cpp
@@ -29,6 +29,8 @@
 #include "comm.h"
 #include "random_mars.h"
 #include "force.h"
+#include "input.h"
+#include "variable.h"
 #include "output.h"
 #include "math_const.h"
 #include "memory.h"
@@ -127,15 +129,60 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
   // nbody = # of non-zero ncount values
   // use nall as incremented ptr to set body[] values for each atom
 
-  } else if (strcmp(arg[3],"molecule") == 0) {
+  } else if (strcmp(arg[3],"molecule") == 0 || strcmp(arg[3],"custom") == 0) {
     rstyle = MOLECULE;
-    iarg = 4;
-    if (atom->molecule_flag == 0)
-      error->all(FLERR,"Fix rigid molecule requires atom attribute molecule");
-
+    tagint *molecule;
     int *mask = atom->mask;
-    tagint *molecule = atom->molecule;
     int nlocal = atom->nlocal;
+    int custom_flag = strcmp(arg[3],"custom") == 0;
+    if (custom_flag) {
+      if (narg < 5) error->all(FLERR,"Illegal fix rigid command");
+
+      // determine whether atom-style variable or atom property is used.
+      if (strstr(arg[4],"i_") == arg[4]) {
+        int is_double=0;
+        int custom_index = atom->find_custom(arg[4]+2,is_double);
+        if (custom_index == -1)
+          error->all(FLERR,"Fix rigid custom requires previously defined property/atom");
+        else if (is_double)
+          error->all(FLERR,"Fix rigid custom requires integer-valued property/atom");
+        int minval = INT_MAX;
+        int *value = atom->ivector[custom_index];
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit) minval = MIN(minval,value[i]);
+        int vmin = minval;
+        MPI_Allreduce(&vmin,&minval,1,MPI_INT,MPI_MIN,world);
+        molecule = new tagint[nlocal];
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit)
+            molecule[i] = (tagint)(value[i] - minval + 1);
+          else
+            molecule[i] = 0;
+
+      } else if (strstr(arg[4],"v_") == arg[4]) {
+        int ivariable = input->variable->find(arg[4]+2);
+        if (ivariable < 0)
+          error->all(FLERR,"Variable name for fix rigid custom does not exist");
+        if (input->variable->atomstyle(ivariable) == 0)
+          error->all(FLERR,"Fix rigid custom variable is no atom-style variable");
+        double *value = new double[nlocal];
+        input->variable->compute_atom(ivariable,0,value,1,0);
+        int minval = INT_MAX;
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit) minval = MIN(minval,(int)value[i]);
+        int vmin = minval;
+        MPI_Allreduce(&vmin,&minval,1,MPI_INT,MPI_MIN,world);
+        molecule = new tagint[nlocal];
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit) molecule[i] = (tagint)((tagint)value[i] - minval + 1);
+        delete[] value;
+      } else error->all(FLERR,"Unsupported fix rigid custom property");
+    } else {
+      if (atom->molecule_flag == 0)
+        error->all(FLERR,"Fix rigid molecule requires atom attribute molecule");
+      molecule = atom->molecule;
+    }
+    iarg = 4 + custom_flag;
 
     tagint maxmol_tag = -1;
     for (i = 0; i < nlocal; i++)
@@ -174,6 +221,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
     }
 
     memory->destroy(ncount);
+    if (custom_flag) delete [] molecule;
 
   // each listed group is a rigid body
   // check if all listed groups exist
diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp
index 1404c3bf58da22f20739dbf521c8aa2adcfea723..13208d4c4c434f4be2602a1447650dced9dca3f2 100644
--- a/src/RIGID/fix_rigid_small.cpp
+++ b/src/RIGID/fix_rigid_small.cpp
@@ -29,7 +29,9 @@
 #include "group.h"
 #include "comm.h"
 #include "force.h"
+#include "input.h"
 #include "output.h"
+#include "variable.h"
 #include "random_mars.h"
 #include "math_const.h"
 #include "memory.h"
@@ -64,11 +66,12 @@ enum{FULL_BODY,INITIAL,FINAL,FORCE_TORQUE,VCM_ANGMOM,XCM_MASS,ITENSOR,DOF};
 
 FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
   Fix(lmp, narg, arg), step_respa(NULL), 
-  infile(NULL), body(NULL), bodyown(NULL), bodytag(NULL), atom2body(NULL), 
-  xcmimage(NULL), displace(NULL), eflags(NULL), orient(NULL), dorient(NULL), 
-  avec_ellipsoid(NULL), avec_line(NULL), avec_tri(NULL), counts(NULL), 
-  itensor(NULL), mass_body(NULL), langextra(NULL), random(NULL), id_dilate(NULL), 
-  onemols(NULL), hash(NULL), bbox(NULL), ctr(NULL), idclose(NULL), rsqclose(NULL)
+  infile(NULL), body(NULL), bodyown(NULL), bodytag(NULL), atom2body(NULL),
+  xcmimage(NULL), displace(NULL), eflags(NULL), orient(NULL), dorient(NULL),
+  avec_ellipsoid(NULL), avec_line(NULL), avec_tri(NULL), counts(NULL),
+  itensor(NULL), mass_body(NULL), langextra(NULL), random(NULL),
+  id_dilate(NULL), onemols(NULL), hash(NULL), bbox(NULL), ctr(NULL),
+  idclose(NULL), rsqclose(NULL)
 {
   int i;
 
@@ -89,7 +92,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
   // perform initial allocation of atom-based arrays
   // register with Atom class
 
-  extended = orientflag = dorientflag = 0;
+  extended = orientflag = dorientflag = customflag = 0;
   bodyown = NULL;
   bodytag = NULL;
   atom2body = NULL;
@@ -103,24 +106,70 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
 
   // parse args for rigid body specification
 
+  int *mask = atom->mask;
+  tagint *bodyid = NULL;
+  int nlocal = atom->nlocal;
+
   if (narg < 4) error->all(FLERR,"Illegal fix rigid/small command");
-  if (strcmp(arg[3],"molecule") != 0)
-    error->all(FLERR,"Illegal fix rigid/small command");
+  if (strcmp(arg[3],"molecule") == 0) {
+    if (atom->molecule_flag == 0)
+      error->all(FLERR,"Fix rigid/small requires atom attribute molecule");
+
+  } else if (strcmp(arg[3],"custom") == 0) {
+    if (narg < 5) error->all(FLERR,"Illegal fix rigid/small command");
+      bodyid = new tagint[nlocal];
+      customflag = 1;
+
+      // determine whether atom-style variable or atom property is used.
+      if (strstr(arg[4],"i_") == arg[4]) {
+        int is_double=0;
+        int custom_index = atom->find_custom(arg[4]+2,is_double);
+        if (custom_index == -1)
+          error->all(FLERR,"Fix rigid/small custom requires previously defined property/atom");
+        else if (is_double)
+          error->all(FLERR,"Fix rigid/small custom requires integer-valued property/atom");
+
+        int minval = INT_MAX;
+        int *value = atom->ivector[custom_index];
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit) minval = MIN(minval,value[i]);
+        int vmin = minval;
+        MPI_Allreduce(&vmin,&minval,1,MPI_INT,MPI_MIN,world);
+
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit) 
+            bodyid[i] = (tagint)(value[i] - minval + 1);
+          else bodyid[i] = 0;
+
+      } else if (strstr(arg[4],"v_") == arg[4]) {
+        int ivariable = input->variable->find(arg[4]+2);
+        if (ivariable < 0)
+          error->all(FLERR,"Variable name for fix rigid/small custom does not exist");
+        if (input->variable->atomstyle(ivariable) == 0)
+          error->all(FLERR,"Fix rigid/small custom variable is no atom-style variable");
+        double *value = new double[nlocal];
+        input->variable->compute_atom(ivariable,0,value,1,0);
+        int minval = INT_MAX;
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit) minval = MIN(minval,(int)value[i]);
+        int vmin = minval;
+        MPI_Allreduce(&vmin,&minval,1,MPI_INT,MPI_MIN,world);
+
+        for (i = 0; i < nlocal; i++)
+          if (mask[i] & groupbit)
+            bodyid[i] = (tagint)((tagint)value[i] - minval + 1);
+          else bodyid[0] = 0;
+        delete[] value;
+      } else error->all(FLERR,"Unsupported fix rigid custom property");
+  } else error->all(FLERR,"Illegal fix rigid/small command");
 
-  if (atom->molecule_flag == 0)
-    error->all(FLERR,"Fix rigid/small requires atom attribute molecule");
   if (atom->map_style == 0)
     error->all(FLERR,"Fix rigid/small requires an atom map, see atom_modify");
 
-  // maxmol = largest molecule #
-
-  int *mask = atom->mask;
-  tagint *molecule = atom->molecule;
-  int nlocal = atom->nlocal;
-
+  // maxmol = largest bodyid #
   maxmol = -1;
   for (i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit) maxmol = MAX(maxmol,molecule[i]);
+    if (mask[i] & groupbit) maxmol = MAX(maxmol,bodyid[i]);
 
   tagint itmp;
   MPI_Allreduce(&maxmol,&itmp,1,MPI_LMP_TAGINT,MPI_MAX,world);
@@ -155,6 +204,8 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
   }
 
   int iarg = 4;
+  if (customflag) ++iarg;
+
   while (iarg < narg) {
     if (strcmp(arg[iarg],"langevin") == 0) {
       if (iarg+5 > narg) error->all(FLERR,"Illegal fix rigid/small command");
@@ -344,11 +395,12 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
   if (pcouple == XYZ || (domain->dimension == 2 && pcouple == XY)) pstyle = ISO;
   else pstyle = ANISO;
 
-  // create rigid bodies based on molecule ID
+  // create rigid bodies based on molecule or custom ID
   // sets bodytag for owned atoms
   // body attributes are computed later by setup_bodies()
 
-  create_bodies();
+  create_bodies(bodyid);
+  if (customflag) delete [] bodyid;
 
   // set nlocal_body and allocate bodies I own
 
@@ -1424,7 +1476,7 @@ void FixRigidSmall::set_v()
    set bodytag for all owned atoms
 ------------------------------------------------------------------------- */
 
-void FixRigidSmall::create_bodies()
+void FixRigidSmall::create_bodies(tagint *bodyid)
 {
   int i,m,n;
   double unwrap[3];
@@ -1464,8 +1516,8 @@ void FixRigidSmall::create_bodies()
   double *buf;
   memory->create(buf,ncount*percount,"rigid/small:buf");
 
-  // create map hash for storing unique molecule IDs of my atoms
-  // key = molecule ID
+  // create map hash for storing unique body IDs of my atoms
+  // key = body ID
   // value = index into per-body data structure
   // n = # of entries in hash
 
@@ -1477,12 +1529,10 @@ void FixRigidSmall::create_bodies()
   // value = index into N-length data structure
   // n = count of unique bodies my atoms are part of
 
-  tagint *molecule = atom->molecule;
-
   n = 0;
   for (i = 0; i < nlocal; i++) {
     if (!(mask[i] & groupbit)) continue;
-    if (hash->find(molecule[i]) == hash->end()) (*hash)[molecule[i]] = n++;
+    if (hash->find(bodyid[i]) == hash->end()) (*hash)[bodyid[i]] = n++;
   }
 
   // bbox = bounding box of each rigid body my atoms are part of
@@ -1494,7 +1544,7 @@ void FixRigidSmall::create_bodies()
     bbox[i][1] = bbox[i][3] = bbox[i][5] = -BIG;
   }
 
-  // pack my atoms into buffer as molecule ID, unwrapped coords
+  // pack my atoms into buffer as body ID, unwrapped coords
 
   double **x = atom->x;
 
@@ -1502,7 +1552,7 @@ void FixRigidSmall::create_bodies()
   for (i = 0; i < nlocal; i++) {
     if (!(mask[i] & groupbit)) continue;
     domain->unmap(x[i],image[i],unwrap);
-    buf[m++] = molecule[i];
+    buf[m++] = bodyid[i];
     buf[m++] = unwrap[0];
     buf[m++] = unwrap[1];
     buf[m++] = unwrap[2];
@@ -1542,7 +1592,7 @@ void FixRigidSmall::create_bodies()
 
   for (i = 0; i < n; i++) rsqclose[i] = BIG;
 
-  // pack my atoms into buffer as molecule ID, atom ID, unwrapped coords
+  // pack my atoms into buffer as body ID, atom ID, unwrapped coords
 
   tagint *tag = atom->tag;
 
@@ -1550,7 +1600,7 @@ void FixRigidSmall::create_bodies()
   for (i = 0; i < nlocal; i++) {
     if (!(mask[i] & groupbit)) continue;
     domain->unmap(x[i],image[i],unwrap);
-    buf[m++] = molecule[i];
+    buf[m++] = bodyid[i];
     buf[m++] = ubuf(tag[i]).d;
     buf[m++] = unwrap[0];
     buf[m++] = unwrap[1];
@@ -1570,7 +1620,7 @@ void FixRigidSmall::create_bodies()
   for (i = 0; i < nlocal; i++) {
     bodytag[i] = 0;
     if (!(mask[i] & groupbit)) continue;
-    m = hash->find(molecule[i])->second;
+    m = hash->find(bodyid[i])->second;
     bodytag[i] = idclose[m];
     rsqmax = MAX(rsqmax,rsqclose[m]);
   }
diff --git a/src/RIGID/fix_rigid_small.h b/src/RIGID/fix_rigid_small.h
index b07dea4f333ea3f27b7919fb74a4b2c52fc9585e..22f9b0c16c31e7ba8910a558dc1802fff6d4b128 100644
--- a/src/RIGID/fix_rigid_small.h
+++ b/src/RIGID/fix_rigid_small.h
@@ -79,6 +79,7 @@ class FixRigidSmall : public Fix {
   char *infile;             // file to read rigid body attributes from
   int setupflag;            // 1 if body properties are setup, else 0
   int commflag;             // various modes of forward/reverse comm
+  int customflag;           // 1 if custom property/variable define bodies
   int nbody;                // total # of rigid bodies
   int nlinear;              // total # of linear rigid bodies
   tagint maxmol;            // max mol-ID
@@ -187,7 +188,7 @@ class FixRigidSmall : public Fix {
   void image_shift();
   void set_xv();
   void set_v();
-  void create_bodies();
+  void create_bodies(tagint *);
   void setup_bodies_static();
   void setup_bodies_dynamic();
   void readfile(int, double **, int *);