vector - Is there a function to find the divergence of a rank1 cell variable in fipy? - Stack Overflow

I am solving the poisson's equation in 2D in the absence of charge.Thus, It is written in the for

I am solving the poisson's equation in 2D in the absence of charge. Thus, It is written in the form $∇.\epsilon_0 ∇ϕ = ∇.\vec{P}$ which I call the voltage equation. where, \phi is the electric potential or the voltage and \vec{p} is the polarization vector. I am trying to solve this equation in fipy, thus it translates to DiffusionTerm(coeff=epsilon_0,var=\phi)==divergence of \vec{p} I have defined \vec{p} as a cell variable. How, do I find the divergence using the fipy functions? Looking at the fipy manpage, I couldnot exactly find how to do it. It suggests using var.faceGrad.divergence, but var.faceGrad again is shown to be a way of finding the gradient of a scalar field. I tried using u.divergence, but this doesn't work.

I am solving the poisson's equation in 2D in the absence of charge. Thus, It is written in the form $∇.\epsilon_0 ∇ϕ = ∇.\vec{P}$ which I call the voltage equation. where, \phi is the electric potential or the voltage and \vec{p} is the polarization vector. I am trying to solve this equation in fipy, thus it translates to DiffusionTerm(coeff=epsilon_0,var=\phi)==divergence of \vec{p} I have defined \vec{p} as a cell variable. How, do I find the divergence using the fipy functions? Looking at the fipy manpage, I couldnot exactly find how to do it. It suggests using var.faceGrad.divergence, but var.faceGrad again is shown to be a way of finding the gradient of a scalar field. I tried using u.divergence, but this doesn't work.

Share Improve this question asked Mar 26 at 23:47 Kritika KhanalKritika Khanal 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

FiPy has no mechanism to take the divergence of a rank-1 CellVariable. In situations like this, the polarization should be defined as a rank-1 FaceVariable. If you have some other equation to solve for the polarization on cell centers, then you will need to manually transcribe those values to the face centers after each solve, e.g.,

for step in steps:
    polarizationEq.solve(var=pCell, ...)
    p.value = pCell.arithmeticFaceValue
    voltageEq.solve(var=phi, ...)

See our Stokes flow example for an illustration of this.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744120096a4559358.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信