Home >Backend Development >Python Tutorial >Can Python solve partial differential equations?

Can Python solve partial differential equations?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-18 15:43:019101browse

fipy

Fick's law refers to the relationship between mass transfer flux and concentration gradient in the molecular diffusion process when the mass transfer phenomenon occurs without relying on macroscopic mixing. law. Fick's law was proposed by Adolf Fick in 1855.

Can Python solve partial differential equations?

The partial differential equation of dynamic diffusion can be obtained from Fick's second law. Solving can obtain the concentration distribution and outflow curve.

I am not sure if there is an analytical solution to this problem, but numerical solution is a more general solution.

fipy is a rare PDE solution python package that is still alive. The author adapted this program based on the official example.

Related recommendations: "Python Video Tutorial"

Question

A two-dimensional flat plate, the top is 1 degree Celsius (100 is also Yes, it’s just a coefficient), the other three edges are 0 degrees Celsius, and the entire board is 0 degrees Celsius at the initial moment. As time goes by, heat is transferred on the board, and finally reaches an equilibrium state. We not only want to know the temperature distribution of the equilibrium state, Also want to know how the temperature changes over time. The transfer of heat is given by a differential equation, which can be simply understood as heat is transferred in the direction in which the temperature decreases the fastest.

Can Python solve partial differential equations?

The right side of the formula is the gradient of temperature, and the left side is the change of temperature with time

Can Python solve partial differential equations?

Finally, the temperature distribution of the entire board Roughly show how

Can Python solve partial differential equations?

Only one package needs to be imported

import fipy as fp

Determine the solution area, a 20*20 grid point

#Solve area nx = 20ny = 20dx = 1.dy = dxL = dx * nxmesh = fp.Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)

phi = fp.CellVariable(name = "solution variable",                         mesh =                                                                   

Can Python solve partial differential equations?

Establish boundary conditions

Can Python solve partial differential equations?

Create drawing

Can Python solve partial differential equations?

Solution

Can Python solve partial differential equations?

It is recommended to run it in the command line, where you can get animated images, ipython There is only the last picture in it

Can Python solve partial differential equations?There is only the last picture in spyder’s ipython

The above is the detailed content of Can Python solve partial differential equations?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn