I have this 2nd order nonlinear ODE: $$ \frac{I_0}{C} \left[ e^{\frac{1}{2nU_T} \left(U_{in}(t) - U_{out}(t) - RCU'_{out}(t) - \frac{R}{R_z} U_{out}(t) -LCU''_{out}(t) - \frac{L}{R_z} U'_{out}(t) \right)} - 1 \right] -\frac{U_{out}(t)}{CR_z} = U'_{out}(t). $$
Everything is known except function $U_{out}(t)$. To solve that ODE, I thought about Euler method. So I express $U''_{out}(t)$ as $$ U''_{out}(t) \approx \frac{U'_{out}(t+dt) - U'_{out}(t)}{dt}, $$ then plugin that in equation and express $U'_{out}(t+dt)$ to get $$ U'_{out}(t+dt) = - \frac{2\,n\,dt\,U_T}{LC} \ln \left( \frac{U_{out}(t)}{I_0 R_z} + \frac{C}{I_0}U'_{out}(t) + 1 \right) + (\text{etc, not important}) $$ Then if I express $U_{out}(t+dt)$ as $ U_{out}(t+dt) = U'_{out}(t)dt + U_{out}(t) $, I can with IC $U_{out}(0) = 0, U'_{out}(0)=0$ write a python program to calculate solution. But problem is after some iterations, the argument of $\ln$ becomes negative and program (of course) fails. So, the question is, if there is another method to solve that ODE? thank you

Given the Cauchy problem:
$$ \begin{cases} \frac{I_0}{C}\left[\exp\left(\frac{f(t) - x(t) - RC\dot{x}(t) - \frac{R}{R_z} x(t) -LC\ddot{x}(t) - \frac{L}{R_z} \dot{x}(t)}{2nU_T}\right) - 1\right] -\frac{x(t)}{CR_z} = \dot{x}(t) \\ x(t_0) = x_0 \\ \dot{x}(t_0) = \dot{x}_0 \end{cases} $$
with $t \in [t_0,t_1]$, first of all I would lead to a system of first order ODEs:
$$ \begin{cases} \dot{x}(t) = y(t) \\ \frac{I_0}{C}\left[\exp\left(\frac{f(t) - x(t) - RCy(t) - \frac{R}{R_z} x(t) -LC\dot{y}(t) - \frac{L}{R_z} y(t)}{2nU_T}\right) - 1\right] -\frac{x(t)}{CR_z} = y(t) \\ x(t_0) = x_0 \\ y(t_0) = y_0 \end{cases} $$
so I would write it in normal form:
$$ \begin{cases} \dot{x}(t) = y(t) \\ \dot{y}(t) = \frac{f(t)-2nU_T\ln\left[\frac{C}{I_0}\left(y(t)+\frac{x(t)}{CR_z}\right)+1\right]-x(t)-RCy(t)-\frac{R}{R_z}x(t)-\frac{L}{R_z}y(t)}{LC} \\ x(t_0) = x_0 \\ y(t_0) = y_0 \end{cases}\,. $$
Therefore, having decided the number of intervals $N$, we can apply Euler's method:
$$ \begin{cases} t_k = t_{k-1} + \frac{t_1-t_0}{N} \\ x_k = x_{k-1} + y_{k-1}\frac{t_1-t_0}{N} \\ y_k = y_{k-1} + \frac{f(t_{k-1})-2nU_T\ln\left[\frac{C}{I_0}\left(y_{k-1}+\frac{x_{k-1}}{CR_z}\right)+1\right]-x_{k-1}-RCy_{k-1}-\frac{R}{R_z}x_{k-1}-\frac{L}{R_z}y_{k-1}}{LC}\frac{t_1-t_0}{N} \\ \end{cases} $$
with $k = 1,2,\dots, N$.
All that remains is to draw the graph of $x(t)$ by plotting the points of coordinates $(t_k,x_k)$.
Note - The starting ODE:
$$ \frac{I_0}{C}\left[\exp\left(\frac{f(t) - x(t) - RCy(t) - \frac{R}{R_z} x(t) -LC\dot{y}(t) - \frac{L}{R_z} y(t)}{2nU_T}\right) - 1\right] -\frac{x(t)}{CR_z} = y(t) $$
is equivalent to:
$$ \exp\left(\frac{f(t) - x(t) - RCy(t) - \frac{R}{R_z} x(t) -LC\dot{y}(t) - \frac{L}{R_z} y(t)}{2nU_T}\right) = \frac{C}{I_0}\left(y(t) + \frac{x(t)}{CR_z}\right) + 1 $$
which is verified provided that:
$$ \frac{C}{I_0}\left(y(t) + \frac{x(t)}{CR_z}\right) + 1 > 0 $$
and exactly under this condition it's equivalent to writing:
$$ \frac{f(t) - x(t) - RCy(t) - \frac{R}{R_z} x(t) -LC\dot{y}(t) - \frac{L}{R_z} y(t)}{2nU_T} = \ln\left[\frac{C}{I_0}\left(y(t) + \frac{x(t)}{CR_z}\right) + 1\right] $$
i.e.
$$ \dot{y}(t) = \frac{f(t)-2nU_T\ln\left[\frac{C}{I_0}\left(y(t)+\frac{x(t)}{CR_z}\right)+1\right]-x(t)-RCy(t)-\frac{R}{R_z}x(t)-\frac{L}{R_z}y(t)}{LC}. $$
Numerical example - Writing in Mathematica:
we get:
On the other hand, setting
y0=-3doesn't get anywhere and this regardless of the method applied.Addendum - Note the OP's numerical values, I begin the investigation with Mathematica:
So, due to the intrinsic numerical difficulties, I opted for the finite difference method:
$$ \small \begin{cases} \frac{I_0}{C}\left[\exp\left(\frac{f(t) - x(t) - RC\frac{x(t)-x(t-\Delta t)}{\Delta t} - \frac{R}{R_z}x(t) -LC\frac{x(t)-2x(t-\Delta t)+x(t-2\Delta t)}{(\Delta t)^2} - \frac{L}{R_z}\frac{x(t)-x(t-\Delta t)}{\Delta t}}{2nU_T}\right) - 1\right] -\frac{x(t)}{CR_z} = \frac{x(t)-x(t-\Delta t)}{\Delta t} \\ x(t_0) = x_0 \\ \dot{x}(t_0) = \dot{x}_0 \end{cases} $$
that is, by setting:
$$ \begin{aligned} & \alpha \equiv \frac{1}{2nU_T}\left(f(t)+\frac{L\Delta t+CR_z(2L+R\Delta t)}{R_z(\Delta t)^2}x(t-\Delta t)-\frac{CL}{(\Delta t)^2}x(t-2\Delta t)\right); \\ & \beta \equiv \frac{1}{2nU_T}\left(1+\frac{(CR_z+\Delta t)(L+R\Delta t)}{R_z(\Delta t)^2}\right); \\ & \gamma \equiv 1 - \frac{C}{I_0\Delta t}x(t-\Delta t)\,; \\ & \delta \equiv \frac{CR_z+\Delta t}{I_0R_z\Delta t}\,; \\ \end{aligned} $$
it's about solving the equation:
$$ \exp\left[\alpha-\beta x(t)\right] = \gamma+\delta x(t) \quad \Leftrightarrow \quad x(t) = -\frac{\gamma}{\delta}+\frac{1}{\beta}\mathcal{W}\left[\frac{\beta}{\delta}\exp\left(\alpha+\frac{\beta}{\delta}\gamma\right)\right] $$
i.e. it's necessary to iterate:
$$ \begin{cases} t_k = t_{k-1} + \Delta t \\ x_k = -\frac{\gamma}{\delta}+\frac{1}{\beta}\mathcal{W}\left[\frac{\beta}{\delta}\exp\left(\alpha+\frac{\beta}{\delta}\gamma\right)\right] \end{cases} $$
with $\Delta t \equiv \frac{t_1-t_0}{N}$ and $k=2,3,\dots,N$.
For example, in Mathematica we have: