My problem is stationary combustion equations (BVP) with temperature and concentration-dependent equations with a form similar to that:
d(Lambda(C_i, T)dT/dx)/dx-C_eff(C_i, T)*dT/dx+Q(C_i,T)=0,
d(D(C_i, T)dC_i/dx)/dx-u*dC_i/dx+G(C_i,T)=0
i=1
These equations are pretty stiff and very non-linear because the source term exponentially depends on T.
Is there a Python or MATLAB package or solver or something that could help me? Standard MATLAB solvers are not suitable for such tasks. I have not tried Python yet, but I think it should be the same.
Related
I am trying to numerically solve a continuous replicator partial differential equation in order to model evolution in a competitive system. The equation takes the form of a second-order nonlinear integral PDE, with the specific PDE in the attached image.
Do you know of any tools in MATLAB or Python that can help in solving these forms of equations? I've looked at MATLAB's built-in solver and PDE toolbox, but neither can do second-order integral PDEs.
How can I solve a system of k differential equations with derivatives appearing in every equation? I am trying to use Scipy's solve_ivp.
All the equations are of the following form:
equations
How can this system of equations be numerically solved using any solver? using solve_ivp, it seems you should be able to write every equation independent of the other ones, which seems not possible in this case when we have more than 2 equations.
If you set C[i]=B[i,i] then you can transform the equations to the linear system B*z'=A. This can be solved as
zdot = numpy.linalg.solve(B,A)
so that the derivative is this constant solution of a constant linear system, and the resulting solution for z is linear, z(t)=z(0)+zdot*t.
I'm trying to solve an order minimization problem with python. Therefore I distribute M orders over N workers. Every worker has a basic energy-level X_i which is gathered in the vector X. Also, every order has a specific energy consumption E_j which is gathered in E. With that being said I'm trying to solve the following problem
where Y is some optimal energy level, with the norm beeing the 2-norm. Under the constraints, that any column adds up to exactly one, since an order should be done and could only be done by one worker. I looked at scipy.optimize but it doesn't seem to support this sort of optimization as far as I can tell.
Does one know any tools in Python for this sort of discrete optimization problem?
The answer depends on the norm. If you want the 2-norm, this is a MIQP (Mixed Integer Quadratic Programming) problem. It is convex, so there are quite a number of solvers around (e.g. Cplex, Gurobi, Xpress -- these are commercial solvers). It can also be handled by an MINLP solver such as BonMin (open source). Some modeling tools that can help are Pyomo and CVXPY.
If you want the 1-norm, this can be formulated as a linear MIP (Mixed Integer Programming) model. There are quite a few MIP solvers such as Cplex, Gurobi, Xpress (commercial) and CBC, GLPK (open source). Some modeling tools are Pyomo, CVXPY, and PuLP.
I'm on the lookout for a numerical method that can solve both a deterministic and stochastic equation. In the deterministic case, I know that a fourth order RK method is a valuable one, very effective. Unfortunately, there has not been applied to stochastic equations successfully (at least as far as I know).
Now what I want to know is if a numerical method that can solve both equations (roughly I mean, in comparison to the analytic solutions) exists and, in that case, what would be. A stochastic equation analytically solvable would be the Black-Scholes one, for instance.
There are methods for solving these kinds of equations in DifferentialEquations.jl. Stochastic differential equations are a form of mixed deterministic and stochastic equation and solving them is shown in the SDE tutorial. Mixing discrete stochasticity with deterministic equations is shown in the jump equation tutorial. While written naively in Julia, it is accessible in Python via the package diffeqpy. Notice that this has some example stochastic differential equations in the README.
I have a system of stochastic differential equations that I would like to solve. I was hoping that this issue was already address. I am a bit concerned about constructing my own solver because I fear my solver would be too slow, and there could be the issues with numerical stability.
Is there a python module for such problems?
If not, is there a standard approach for solving such systems.
There is one: http://diffusion.cgu.edu.tw/ftp/sde/
Example from the site:
""" add required Python packages """
from pysde import *
from sympy import *
""" Variables acclaimed """
x,dx=symbols('x dx')
r,G,e,d=symbols('r G epsilon delta')
""" Solve Kolmogorov Forward Equation """
l=sde.KolmogorovFE_Spdf(r*(G-x),e*x*(1-x),0,1)
sol=l.subs({e:r*d})
pprint(sol)
The link in the accepted answer no longer functions. There is also sdeint:
https://pypi.org/project/sdeint/#description
Which was released a few years after the accepted answer and looks to be in semi-active development. A second example in the documentation has a system of SDE with constant coefficients. I am unsure if they have support for more complex SDE systems.
The package diffeqpy brings Julia's DifferentialEquations.jl to Python. This is capable of doing a lot of things, including stochastic differential equations.