-
Notifications
You must be signed in to change notification settings - Fork 0
CodeBase :: How to Add New Forcefields, Move Types, or other Features to Classy
Classy was designed in an object oriented manner to make it easier for users to incorporate their own forcefields, Monte Carlo Moves, Sampling Methods, and other common. The code has streamlined the insertion points such that the user only needs to worry about designing the submodule of interest.
To begin writing a module, the user needs to import the base template for the type of module (I.E. MC Move, Forcefield, etc.) they are creating. This is simply done by using the "extend" flag when defining the type. For example for a new Forcefield one would use these lines
use Template_ForceField, only: ForceField
type, extends(forcefield) :: !Your Forcefield Name Here
This makes the new forcefield type polymorphic to the template class and allows the code to use this forcefield interchangeably.
Next the user must redirect the inherited routine pointers to the ones contained within this module.
type, extends(forcefield) :: YourTypeNameHere
!Forcefield specific tables and variables go here.
contains
procedure, pass :: Constructor => !Your Forcefield's constructor
procedure, pass :: DetailedECalc => !Your Forcefield's Detailed Energy Function
procedure, pass :: DiffECalc => !Your Forcefield's Difference Energy Function
procedure, pass :: ProcessIO => !Your Forcefield's Input/Output Processing Function
end type
From here the user can write their forcefield. The only thing left to get it working with the code is to simply add it to the corresponding input file so that it can be created from a Classy input script. For forcefields this would be located in Script_FieldType.f90
Use MyForcefieldsModule, only: YourTypeNameHere
case("my_new_awesome_forcefield")
allocate( YourTypeNameHere :: EnergyCalculator(FFNum) % Method)
Please note in the 'case' block the string must be lower case. The string contained in the case statement is the command used to call your forcefield from the input script. Now if someone were to write
forcefieldtype
My_New_Awesome_Forcefield
end_forcefieldtype
It would create your forcefield function and run the code contained within it. That's it!
For a list of required functions for a given object type, please see the subsections of the wiki that go into detail.