Chaohong,
You can embed constant parameters in your source code. f-strings are one convenient way to do this.
For computed global parameters, there aren't any good options currently. For CPP pair potentials, you can write a custom Updater that sets `param_array` entries. However, `CPPExternalPotential` does not provide a similar `param_array`. You could modify the C++ code to add it (if you do, please submit a pull request to make this available to others in HOOMD releases).
Note that the CustomUpdater would change parameters only when your updater is triggered and not with every individual trial move. This breaks detailed balance and will impact the accuracy of your calculation. There is no way to solve this in HOOMD, which is designed around the assumption that all trial moves can be evaluated using *only* the local state.
You mention the "number of particles in the solid phase". Perhaps umbrella sampling would be a more appropriate solution? You can structure umbrella sampling to operate at the level of timesteps (accepting rejecting whole series of timesteps) thereby maintaining detailed balance and removing the need for variable parameters in an external potential.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan