Calculating the feedback capacitor:
1. The pole introduced by the limited drive capability. The gate resistor is 300Ohm + 1K. The 300Ohm is taken from an LM324 data sheet. That's the open loop output resistance of the op amp. (we can't supply more current)
What do we get: Ciss of the IRF240 increases with decreasing drain voltage. This causes the phase shift being introduced into the feedback loop to shift left and right. (The gain and phase is measured across R2 because that's what's being fed back into the op amp.)
As shown the phase shift occurs well below where the op reaches unity gain. The total phase shift at the unity gain frequency is now >>180°. Or, an oscillator.
2. Compensating the op amp:
With a 10K feedback resistor and 1K3 gate drive resistance and drain voltages being taken as low as 1V (Ciss increases with decreasing drain voltage), the minimum feedback capacitor to compensate for the pole must be 1 / (2 * 3.14 r * f)= 1 / (2 * 3.14 * 10K * 50K)= 318pF
This results is a load with sloppy response.
3. Decreasing the gate resistor in order to improve the step response:
nice idea. But op amps aren't ideal. When driving a capacitive load, something called gain peaking occurs. More on that in this app note:
https://ww1.microchip.com/downloads/en/Appnotes/00884b.pdfThe app note doesn't show the phase shift at this gain peak. But the circuit, being an imaginary inductor driving a capacitor will change it's phase above resonance. The bandwidth and maximum phase shift are determined by the network Q factor. Low resistance, or low gate resistors imply a larger phase shift. I didn't bother to calculator the inductor value based on the app note. But one can see that this will happen way before the op amp reaches unity gain.
An extra buffer amplifier:
An extra buffer isolates the MOSFET capacitance from the op amp and places the pole introduced by the low output impedance driver well above the unity gain bandwidth of the op amp.
I'm not going to investigate if the OPA172 will work properly because at first glance, the open loop output impedance is not defined.