usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
504 stars 148 forks source link

The coefficient must be a vector value!!! #939

Closed ghost closed 1 year ago

ghost commented 1 year ago

I'm trying to define a 2D system using Navier-Stokes equations for liquid and water, https://github.com/usnistgov/fipy/blob/master/examples/reactiveWetting/liquidVapor2D.py is a model which I've taken ispiration from but I have faced with this error "The coefficient must be a vector value" recently. Does anyone know what the exact problem is in my code? `#Import fipy from fipy import CellVariable, Grid2D, TransientTerm, VanLeerConvectionTerm, DiffusionTerm, ImplicitSourceTerm, ConvectionTerm, CentralDifferenceConvectionTerm, Viewer

Set up the domain

L1 = 20.0 #cm L2 = 5.0 #cm

x = 10.0 y = 2.0

dx = L1 / x dy = L2 / y

mesh = Grid2D(nx=x, ny=y, dx=dx, dy=dy) x, y = mesh.cellCenters

Define the initial & physical parameters

g = 981.0 #cm/s2 waterDensity = 1000.0 #g/cm3 liquidDensity = 0.85 #g/cm3

Define the fluid velocity

velocityVector = CellVariable(mesh=mesh, name='Velocity', rank=1) velocityX = CellVariable(mesh=mesh, hasOld=True, name='Velocitx') velocityY = CellVariable(mesh=mesh, hasOld=True, name='Velocity')

Define the density & pressure

density = CellVariable(mesh=mesh, hasOld=True, name='Density') pressure = CellVariable(mesh=mesh, hasOld=True, name='Pressure')

Define the Navier-Stokes equations

equ1 = TransientTerm(var=velocityX) == - ConvectionTerm(coeff=density.faceValue, var=velocityX) + pressure.grad + (waterDensity g) equ2 = TransientTerm(var=velocityY) == - ConvectionTerm(coeff=density.faceValue, var=velocityY) + pressure.grad + (liquidDensity g) equ3 = ConvectionTerm(var=velocityX) equ4 = ConvectionTerm(var=velocityY)

Solve the equations

eqns = equ1 & equ2 & equ3 & equ4 timeStepDuration = 0.1 steps = 10 for step in range(steps): eqns.solve(dt=timeStepDuration)

Visualize the results

viewer = Viewer(vars=(density, velocityX), datamin=0.0, datamax=1.0) viewer.plot()` Acid_Model_12.zip