A PID loop needs to "follow" something called a "Process Variable" (or "PV"), maintain a "Setpoint" (or "SP"), and actuate a "Control Variable" ("CV"), while avoiding deviations, a.k.a. "errors", as much as possible. So what's you goal here? Flow rate that varies with viscosity? Pressure in a vessel? Level in a tank? You have to start with what your PV is as it relates to the SP. You cannot have "energy" as a PV, because the natural result of that would be for the PID controller to shut down since that would save the most energy! But energy savings is something that will the RESULT of using a PID controlled VFD on a centrifugal pump.
So let's say for now that your PV is to be a flow rate. You need a transducer to measure that and give you an analog signal value, that goes into your PID controller as the PV. Then you need to decide what value of flow rate that you want to maintain, that is your SP. The Speed of the VFD then becomes the CV, and will vary as necessary to maintain the SP, using the acceptable errors of the response rates, being PROPORTIONAL ("P") to the change in the PV, INTEGRAL ("I") to the rate of change in the PV, and DERIVATIVE ("D") of the number of changes in a given period of time.
A classic example I like to point out to people who think they have never used a PID loop, is that the "Cruise Control" in your car is in fact a PID loop controller! The speedometer is the PV, the speed setting button on your control button is establishing the SP, and the throttle servo that changes your engine power is the CV. In your car, you don't have access to change the P, I and D functions, that was done for you at the car factory, but they are in there, somewhere.
" We are all here on earth to help others; what on earth the others are here for I don't know." -- W. H. Auden