Closed AlChen94 closed 1 year ago
Can you let me know which code you are referring to exactly. In principle applying N/P/K happens here: https://github.com/ajwdewit/pcse/blob/master/pcse/soil/npk_soil_dynamics.py#L264
The N/P/K amounts are first copied to a temporary variable and then inserted into the rate variable at the proper moment in the cycle. It might be that you are referring to an older version of WOFOST8.
Sorry, I just noticed that the version of pcse I used is 5.5.0.But unfortunately, this problem still exists after I updated pcse to 5.5.4.
The problem is at where you mentioned:pcse/soil/npk_soil_dynamics.py line 264.
I don't know the exact cause of this problem, but after making similar modifications, the problem can be solved superficially.
I changed "_on_APPLY_NPK" function , adding several lines of code to update the rates.RNAVAIL when "apply_npk" signal is received.
def _on_APPLY_NPK(self, N_amount=None, P_amount=None, K_amount=None, N_recovery=None, P_recovery=None, K_recovery=None): r = self.rates self._FERT_N_SUPPLY = N_amount * N_recovery self._FERT_P_SUPPLY = P_amount * P_recovery self._FERT_K_SUPPLY = K_amount * K_recovery r.RNAVAIL = self._FERT_N_SUPPLY r.RPAVAIL = self._FERT_P_SUPPLY r.RKAVAIL = self._FERT_K_SUPPLY
When "apply_npk" signal is sent, the content of nitrogen, phosphorus and potassium in Wofost80_NWLP_FD_beta model will not change.This problem seems to be related to the RateVariables class.
I modified the code as below, and the problem seems to be solved. ` def _on_APPLY_NPK(self, N_amount=None, P_amount=None, K_amount=None, N_recovery=None, P_recovery=None, K_recovery=None):
`