solve_ivp gets “stuck” at incredibly small “time” step

I’m trying to solve a problem of filling and emptying of a retention behind a dam. What I’ve got are: 1) a function that relates the elevation of the water in the retention with the volume of the water, V(h); 2) a function that relates the discharge through the dam outlet with the water elevation, q(h); and 3) a function of water inflow given the duration of rain, Vr(tr).
For the case when I ignore the third function, i.e. I assume that V0 appears instantly in the reservoir, I managed to get the solution as:

def dtdh(h, y):
    t = y[0]
    dVdh = misc.derivative(V_h_fun, h, dx=0.1, args=(aCV, bCV, cCV))
    return (- dVdh * 1e3 / Q_h_fun(h, aCQ, bCQ, cCQ)) # V_h_fun relates h[m] to V[dam^3], so 1e3 is to get [m^3]
                                                      # as Q_h_fun gives q[m^3/s] from h[m]

elevs = np.linspace(235,231,100) # initial elev. 235, to final elev. 231 m
sol = integrate.solve_ivp(dtdh, t_span=(235,231), y0=[0], t_eval=elevs) # y0 = t0

V_h_fun and Q_h_fun are the first two functions I mentioned previously, and aCV, bCV, cCV, aCQ, bCQ, cCQ are the coefficients from fitting the curves to some data.
This works great, it gives me the time required to empty the reservoir, given an initial elevation, which is indirectly given through the elevs and t_span.

When I try to expand this to also consider the increase of the volume in the retention with time (due to rain), then the new diff. eq. looks like:

def dtdh2(h, y):
    t = y[0]
    dVdh = misc.derivative(V_h_fun, h, dx=0.1, args=(aCV, bCV, cCV))
    dVrdt = misc.derivative(initial_volume, t, dx=0.1, args=(V0, t_rain))
    dVrdt.clip(min=0, out=dVrdt) # the derivative goes to a large negative value before going back to 0
    return (- dVdh * 1e3 / (Q_h_fun(h, aCQ, bCQ, cCQ)  - dVrdt))

So, I only subtracted the inflow due to the rain, from the outflow. The inflow function is defined as:

def initial_volume(t, V0, t_rain):
    # V0 in [m3]
    # t_rain in [s]
    if type(t) != np.ndarray:
        t = np.array([t])
    
    f = np.zeros_like(t)
    c1 = (t < 0)
    c2 = (t >= 0) & (t <= t_rain)
    c3 = (t > t_rain)
    f[c1] = 0
    f[c2] = V0 / t_rain * t[c2] # straight line within the duration of the rain, and 0 otherwise
    f[c3] = 0
    return f

What happens is that when I set the rain duration (t_rain) in dtdh2 to some large number, >9500, the solver converges and gives me the time required to empty the retention. However, when the time is smaller than that, is starts having problems at the beginning (near initial elevations), where the elevation (“time”) step becomes incredibly small, and the elevation values start to look like this: 234.99999996789282. I found this out by including a print(h) in dtdh2. The solver doesn’t terminate, instead it continues solving with the small “time” step, and thus never finishes (I interrupt it manually after some time). What can cause this problem, and what could I do to fix it?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật