Adding New Projector Functions to Potfit

This document tells you how to implement new projector functions for the projection program. It's rather simple if you know what part of the code you have to look at. And that's exactly what this document tells you.

General comment: If in doubt, draw inspiration from the code for the projector functions that are already implemented.

Input Parser

The parsing of the projector function is done in projfuncparse in source/potfit/peinproj.F . The parser looks at the function name, converts it to an internal function index (stored in array projifunc), parses the function parameters, and stores them in array projipar, etc.

Code for parsing a new function label should be added near the bottom of projfuncparse (just before the comment that says so) in a new elseif-branch.

Variables that can be used:

Variables that must be set:

Function Evaluation

The numerical evaluation of the projector function happens in calcprjf in source/potfit/projcalc.F . To add code for evaluating your new projector function, do the following:

  1. Near the top of calcprjf, add the new function index (which was assigned in projlabparse to projifunc(p,q)) to the computed-goto statement.
  2. Near the bottom of calcprjf, add the evaluation code (before the comment that says so). The first line of this code must, of course, have the function index as jump-label. The last line must be "goto 100". The coordinate value is in the variable x, and the result must be stored in the variable y.

Technical sidenote: your code will be inside a loop that runs over all DVR grid points for the DOF in question. If your function evaluation contains parts that only need to be done once (like calculating the normalization factor) and that are costly, you should take care that this part is only run once. Look at the code for evaluating nf for ifunc=1 to see how this can be accomplished. However, the projector functions are only calculated once (for each projector), so this is probably not time-critical.

Documentation

Don't forget to add documentation for the new projector function!