Skip to content

1D Diffusion Equation: Boundary Condition #999

Answered by guyer
beantsja asked this question in Q&A
Discussion options

You must be logged in to vote

The amount of "stuff" in a cell is the value at the cell center times the volume of the cell. You need to compare the before and after amount of substance (extensive) rather than the concentration (intensive). The preferred way to do that in FiPy (which accounts for nonuniform meshes) is

Xi = (X.cellVolumeAverage * mesh.cellVolumes.sum()).value
  :
  :
Xf = (X.cellVolumeAverage * mesh.cellVolumes.sum()).value

X.cellVolumeAverage represents $\sum_\text{cells} (X V_\text{cell}) / \sum_\text{cells} V_\text{cell}$.

note: if you do not use .value, then FiPy's lazy evaluation will result in Xi having the same value as Xf. You need .value to hold the value at that time.

Replies: 1 comment 18 replies

Comment options

You must be logged in to vote
18 replies
@beantsja
Comment options

@guyer
Comment options

@beantsja
Comment options

@guyer
Comment options

Answer selected by beantsja
@beantsja
Comment options

@guyer
Comment options

@beantsja
Comment options

@guyer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants