Sorry, its the first time that i comment here:
p1 = 5 10^5;
p2 = 8 10^5;
r = 1;
k = 10^6
NDSolve[{p'[t] == r (1 - p[t]/k) p[t], p[0] ==3 10^5, WhenEvent[p[t] == p2, p'[t] -> p'[t] - 4 10^5], WhenEvent[p[t] == p1, p'[t] -> p'[t]]}, p[t], {t, 0, 20}]
It didnt work, i have divided the problem and focused in the first part of the curve, i intend at least that when P[t]==p2, H[t]=H0:
i've tried doing that:
p1 = 5 10^5;
p2 = 8 10^5;
r = 1;
k = 10^6;
NDSolve[{p'[t] == r (1 - p[t]/k) p[t], p[0] ==3 10^5, WhenEvent[p[t] == p2, p'[t] -> p'[t] - 4 10^5]}, p[t], {t, 0, 20}]
Or that:
NDSolve[{p'[t] == r (1 - p[t]/k) p[t]-H[t], p[0] == 10^5, WhenEvent[p[t] == p2,H[t]=H0]}, p[t], {t, 0, 20}]
But it gives me error, i'm making a mistake but in the "help" of mathmatica i only see examples about product of this type:
NDSolve[{y''[t]==-9.81,y[0]==5,y'[0]==0, WheEvent[y[t]==0, y[t]->-0.95 y'[t]]}, y, {t,0,10}]
Or with "Mod"
NDSolve[{y''[t] == -9.8, y[0] == 13.5, y'[0] == 5, a[0] == 13,
WhenEvent[y[t] - a[t] == 0, y'[t] -> -c y'[t]],
WhenEvent[Mod[t, 1], a[t] -> a[t] - 1]}, {y, a}, {t, 0, 8},
DiscreteVariables -> {a}] ;