On 28 Mar 2016, at 19:19, Guyer, Jonathan E. Dr. (Fed) <[email protected]> wrote:
> > On Mar 28, 2016, at 12:20 PM, Djoeke Schoonenberg > <[email protected]> wrote: > >> So it seems that I’m implementing the variable speed in a wrong way. What I >> did was ConvectionTerm(FaceVariable(mesh=mesh, value=vgas(x)), var=S_vap), >> where vgas(x) is the speed as function of position. How should this be done >> instead? > > I think the immediate issue is that you're defining a FaceVariable in terms > of cell centers: > > x = mesh.cellCenters()[0] > > > ConvectionTerm(FaceVariable(mesh=mesh, value=vgas(x)+p*Dif/x),var=S_vap) > > > Instead, I would do: > > > xface = mesh.faceCenters[0] # note the removal of the '()' > > > ConvectionTerm(coeff=vgas(xface)+p*Dif/xface), var=S_vap) > Hmm, when I do as you suggest: xface = mesh.faceCenters[0] Eq = TransientTerm(var=S_vap) == \ ConvectionTerm(coeff=vgas(xface)+p*Dif/xface, var=S_vap)\ + ImplicitDiffusionTerm(coeff=Dif, var=S_vap)\ I get the following error: VectorCoeffError Traceback (most recent call last) /Users/Djoeke/Desktop/Planets/ice/fipy_mailinglist.py in <module>() 43 44 Eq_vap = TransientTerm(var=S_vap) == \ ---> 45 ConvectionTerm(coeff=vgas(xface)+p*Dif/xface, var=S_vap)\ 46 + ImplicitDiffusionTerm(coeff=Dif, var=S_vap)\ 47 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/fipy/terms/abstractConvectionTerm.pyc in __init__(self, coeff, var) 106 107 if isinstance(coeff, _MeshVariable) and coeff.rank < 1: --> 108 raise VectorCoeffError 109 110 if isinstance(coeff, CellVariable): VectorCoeffError: The coefficient must be a vector value. > > mesh.faceCenters[0] is a FaceVariable already, so no need to cast it, and it > has the proper shape, which x = mesh.cellCenters[0] does not. > > > > Strictly, you should not pass a scalar coefficient to a ConvectionTerm, > although it generally works in 1D. (vgas(xface)+p*Dif/xface))*[[1]] should > give you a proper vector velocity. > > > > Also, it's rank-0 which is strictly wrong, but often works, particularly in > 1D. > > > > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
