Re: Diffusion-Convection-Reactive Chemisty

2016-07-13 Thread Guyer, Jonathan E. Dr. (Fed)
That should be OK. FiPy automatically maps the constraint onto the faceValue of 
a CellVariable.

> On Jul 13, 2016, at 3:26 PM, Keller, Trevor (Fed)  
> wrote:
> 
> Is the definition of C_a_BC correct? For a 1D grid, is the behavior of
> C_a.constrain(C_a_BC, where=mesh.facesRight)
> with a CellVariable instead of a scalar value
> C_a_BC= C_a_0*(1-X)
> meaningful?
> 
> Trevor
> From: fipy-boun...@nist.gov  on behalf of Daniel 
> DeSantis 
> Sent: Wednesday, July 13, 2016 4:08:50 PM
> To: FIPY
> Subject: Re: Diffusion-Convection-Reactive Chemisty
>  
> I'm sorry. I was trying to fix the problem, and forgot to put a line back in, 
> which was masked by me not clearing a variable value for V. My apologies. 
> Please try this code instead. It has the traceback I mentioned before.
> 
> 
> 
> Traceback (most recent call last):
> 
>   File "", line 1, in 
> runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
> Models/ConversionModel.py', 
> wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD Models')
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
>  line 699, in runfile
> execfile(filename, namespace)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
>  line 74, in execfile
> exec(compile(scripttext, filename, 'exec'), glob, loc)
> 
>   File "C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
> Models/ConversionModel.py", line 110, in 
> res = Eq.sweep(dt=dt, solver=solver)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
>  line 236, in sweep
> solver = self._prepareLinearSystem(var=var, solver=solver, 
> boundaryConditions=boundaryConditions, dt=dt)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
>  line 170, in _prepareLinearSystem
> buildExplicitIfOther=self._buildExplcitIfOther)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\coupledBinaryTerm.py",
>  line 122, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
>  line 68, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
>  line 68, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
>  line 68, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\unaryTerm.py",
>  line 99, in _buildAndAddMatrices
> diffusionGeomCoeff=diffusionGeomCoeff)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\abstractConvectionTerm.py",
>  line 211, in _buildMatrix
> self.constraintB =  -((1 - alpha) * var.arithmeticFaceValue * 
> constraintMask * exteriorCoeff).divergence * mesh.cellVolumes
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
>  line 1151, in __mul__
> return self._BinaryOperatorVariable(lambda a,b: a*b, other)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
>  line 1116, in _BinaryOperatorVariable
> if not v.unit.isDimensionless() or len(v.shape) > 3:
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
>  line 255, in _getUnit
> return self._extractUnit(self.value)
> 
>   File 
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
>  line 561, in _getValue
> value[..., mask] = numerix.array(constraint.value)[..., mask]
> 
> IndexError: index 100 is out of bounds for axis 0 with size 100
> 
> On Wed, Jul 13, 2016 at 3:59 PM, Daniel Wheeler  
> wrote:
> Hi Daniel,
> 
> It is giving a different error for me
> 
> Traceback (most recent call last):
>   File "ConversionModel.py", line 78, in 
> V.constrain(V0,mesh.facesLeft)
> NameError: name 'V' is not defined
> 
> Is this the correct script?
> 
> 
> 
> On Wed, Jul 13, 2016 at 3:27 PM, Daniel DeSantis  wrote:
> > Hello,
> >
> > I am having some trouble getting a workable convection coefficient on a
> > reactive chemistry model with a vector velocity. I have reviewed several
> > examples from the FiPy mailing list and tried several of the variations
> > listed there. Originally, I was receiving the error that a coefficient must
> > be a vector. Now I seem to be getting an error that says the index is 

Re: Diffusion-Convection-Reactive Chemisty

2016-07-13 Thread Keller, Trevor (Fed)
Staring at the code, it looks like you're defining initial values (C_a_0, 
C_b_0, ..., V0) as CellVariables instead of scalars (or Variables), which is 
probably not what you meant. Substituting the following seems to work better:

#%% - INITIATION VALUES
C_a_0 = 0
C_b_0 = 0
C_c_0 = 0
C_d_0 = 0
V0 = 409.5183981003883 #V_flow/A_crossSection #m/hr

#%% - VARIABLES
C_a= CellVariable(name="Concentration of A", mesh=mesh, hasOld=True)
C_b= CellVariable(name="Concentration of B", mesh=mesh, hasOld=True)
C_c= CellVariable(name="Concentration of C", mesh=mesh, hasOld=True)
C_d= CellVariable(name="Concentration of D", mesh=mesh, hasOld=True)
V  = CellVariable(name="Velocity", mesh=mesh, hasOld=True)

C_a.setValue(C_a_0)
C_b.setValue(C_b_0)
C_c.setValue(C_c_0)
C_d.setValue(C_d_0)
V.setValue(V0)

But this still gives errors relating to division by zero and singular matrices. 
I think this is because the last term in each of your equations (factor*r_a) 
needs to be an appropriate SourceTerm, since
r_a = -k1 * C_a
and you're solving for C_a. I substituted

#%% - DEFINE EQUATIONS
EqC_a = 
(TransientTerm(var=C_a)==-ExponentialConvectionTerm(coeff=V_vec,var=C_a) + 
DiffusionTerm(var=C_b,coeff=Da) + ImplicitSourceTerm(var=C_a,coeff=1))
EqC_b = 
(TransientTerm(var=C_b)==-ExponentialConvectionTerm(coeff=V_vec,var=C_b) + 
DiffusionTerm(var=C_b,coeff=Da) + ImplicitSourceTerm(var=C_a,coeff=11))
EqC_c = 
(TransientTerm(var=C_c)==-ExponentialConvectionTerm(coeff=V_vec,var=C_c) + 
DiffusionTerm(var=C_c,coeff=Da) + ImplicitSourceTerm(var=C_a,coeff=-17))
EqC_d = 
(TransientTerm(var=C_d)==-ExponentialConvectionTerm(coeff=V_vec,var=C_d) + 
DiffusionTerm(var=C_d,coeff=Da) + ImplicitSourceTerm(var=C_a,coeff=-8))

Eq = EqC_a & EqC_b & EqC_c & EqC_d

This still returns an error,

/users/tnk10/Downloads/fipy/fipy/tools/numerix.py:966: RuntimeWarning: overflow 
encountered in square
  return sqrt(add.reduce(arr**2))
/users/tnk10/Downloads/fipy/fipy/solvers/pysparse/linearLUSolver.py:93: 
RuntimeWarning: overflow encountered in square
  error0 = numerix.sqrt(numerix.sum((L * x - b)**2))
/users/tnk10/Downloads/fipy/fipy/solvers/pysparse/linearLUSolver.py:98: 
RuntimeWarning: overflow encountered in square
  if (numerix.sqrt(numerix.sum(errorVector**2)) / error0)  <= self.tolerance:
/users/tnk10/Downloads/fipy/fipy/solvers/pysparse/linearLUSolver.py:98: 
RuntimeWarning: invalid value encountered in double_scalars
  if (numerix.sqrt(numerix.sum(errorVector**2)) / error0)  <= self.tolerance:
/users/tnk10/Downloads/fipy/fipy/variables/faceGradVariable.py:158: 
RuntimeWarning: overflow encountered in divide
  N = (N2 - numerix.take(self.var,id1, axis=-1)) / dAP
/users/tnk10/Downloads/fipy/fipy/variables/variable.py:1105: RuntimeWarning: 
invalid value encountered in multiply
  return self._BinaryOperatorVariable(lambda a,b: a*b, other)

Assuming (perhaps incorrectly) that component A should be diffusing, I changed 
the DiffusionTerm
EqC_a = 
(TransientTerm(var=C_a)==-ExponentialConvectionTerm(coeff=V_vec,var=C_a) + 
DiffusionTerm(var=C_a,coeff=Da) + ImplicitSourceTerm(var=C_a,coeff=1))

That seems to work. The modified script is attached.

Trevor


From: fipy-boun...@nist.gov  on behalf of Keller, Trevor 
(Fed) 
Sent: Wednesday, July 13, 2016 4:26:38 PM
To: FIPY
Subject: Re: Diffusion-Convection-Reactive Chemisty


Is the definition of C_a_BC correct? For a 1D grid, is the behavior of

C_a.constrain(C_a_BC, where=mesh.facesRight)

with a CellVariable instead of a scalar value

C_a_BC= C_a_0*(1-X)

meaningful?


Trevor


From: fipy-boun...@nist.gov  on behalf of Daniel 
DeSantis 
Sent: Wednesday, July 13, 2016 4:08:50 PM
To: FIPY
Subject: Re: Diffusion-Convection-Reactive Chemisty

I'm sorry. I was trying to fix the problem, and forgot to put a line back in, 
which was masked by me not clearing a variable value for V. My apologies. 
Please try this code instead. It has the traceback I mentioned before.



Traceback (most recent call last):

  File "", line 1, in 
runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
Models/ConversionModel.py', wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
Models')

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
 line 699, in runfile
execfile(filename, namespace)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
 line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
Models/ConversionModel.py", line 110, in 
res = Eq.sweep(dt=dt, solver=solver)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
 line 236, in sweep
solver = self._prepareLinearSystem(var=var, solver=solver, 
boundaryConditions=

Re: Diffusion-Convection-Reactive Chemisty

2016-07-13 Thread Keller, Trevor (Fed)
Is the definition of C_a_BC correct? For a 1D grid, is the behavior of

C_a.constrain(C_a_BC, where=mesh.facesRight)

with a CellVariable instead of a scalar value

C_a_BC= C_a_0*(1-X)

meaningful?


Trevor


From: fipy-boun...@nist.gov  on behalf of Daniel 
DeSantis 
Sent: Wednesday, July 13, 2016 4:08:50 PM
To: FIPY
Subject: Re: Diffusion-Convection-Reactive Chemisty

I'm sorry. I was trying to fix the problem, and forgot to put a line back in, 
which was masked by me not clearing a variable value for V. My apologies. 
Please try this code instead. It has the traceback I mentioned before.



Traceback (most recent call last):

  File "", line 1, in 
runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
Models/ConversionModel.py', wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
Models')

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
 line 699, in runfile
execfile(filename, namespace)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
 line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/ddesantis/Dropbox/PythonScripts/CFD 
Models/ConversionModel.py", line 110, in 
res = Eq.sweep(dt=dt, solver=solver)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
 line 236, in sweep
solver = self._prepareLinearSystem(var=var, solver=solver, 
boundaryConditions=boundaryConditions, dt=dt)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
 line 170, in _prepareLinearSystem
buildExplicitIfOther=self._buildExplcitIfOther)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\coupledBinaryTerm.py",
 line 122, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
 line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
 line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
 line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\unaryTerm.py",
 line 99, in _buildAndAddMatrices
diffusionGeomCoeff=diffusionGeomCoeff)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\abstractConvectionTerm.py",
 line 211, in _buildMatrix
self.constraintB =  -((1 - alpha) * var.arithmeticFaceValue * 
constraintMask * exteriorCoeff).divergence * mesh.cellVolumes

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
 line 1151, in __mul__
return self._BinaryOperatorVariable(lambda a,b: a*b, other)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
 line 1116, in _BinaryOperatorVariable
if not v.unit.isDimensionless() or len(v.shape) > 3:

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
 line 255, in _getUnit
return self._extractUnit(self.value)

  File 
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
 line 561, in _getValue
value[..., mask] = numerix.array(constraint.value)[..., mask]

IndexError: index 100 is out of bounds for axis 0 with size 100

On Wed, Jul 13, 2016 at 3:59 PM, Daniel Wheeler 
mailto:daniel.wheel...@gmail.com>> wrote:
Hi Daniel,

It is giving a different error for me

Traceback (most recent call last):
  File "ConversionModel.py", line 78, in 
V.constrain(V0,mesh.facesLeft)
NameError: name 'V' is not defined

Is this the correct script?



On Wed, Jul 13, 2016 at 3:27 PM, Daniel DeSantis 
mailto:desan...@gmail.com>> wrote:
> Hello,
>
> I am having some trouble getting a workable convection coefficient on a
> reactive chemistry model with a vector velocity. I have reviewed several
> examples from the FiPy mailing list and tried several of the variations
> listed there. Originally, I was receiving the error that a coefficient must
> be a vector. Now I seem to be getting an error that says the index is out of
> bounds. Specific traceback is shown below, along with the code attachment.
>
> Could anyone suggest what I am doing wrong and how to fix it?
>
> I'm relatively new to Python and FiPy, specifically, so please bear with me
> as I am learning.
>
> Thank you all!
>
> --
> Daniel DeSantis
>
> Traceback (most rece

Re: Diffusion-Convection-Reactive Chemisty

2016-07-13 Thread Daniel DeSantis
I'm sorry. I was trying to fix the problem, and forgot to put a line back
in, which was masked by me not clearing a variable value for V. My
apologies. Please try this code instead. It has the traceback I mentioned
before.



Traceback (most recent call last):

  File "", line 1, in 
runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD
Models/ConversionModel.py',
wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD Models')

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 699, in runfile
execfile(filename, namespace)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/ddesantis/Dropbox/PythonScripts/CFD
Models/ConversionModel.py", line 110, in 
res = Eq.sweep(dt=dt, solver=solver)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
line 236, in sweep
solver = self._prepareLinearSystem(var=var, solver=solver,
boundaryConditions=boundaryConditions, dt=dt)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
line 170, in _prepareLinearSystem
buildExplicitIfOther=self._buildExplcitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\coupledBinaryTerm.py",
line 122, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\unaryTerm.py",
line 99, in _buildAndAddMatrices
diffusionGeomCoeff=diffusionGeomCoeff)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\abstractConvectionTerm.py",
line 211, in _buildMatrix
self.constraintB =  -((1 - alpha) * var.arithmeticFaceValue *
constraintMask * exteriorCoeff).divergence * mesh.cellVolumes

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 1151, in __mul__
return self._BinaryOperatorVariable(lambda a,b: a*b, other)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 1116, in _BinaryOperatorVariable
if not v.unit.isDimensionless() or len(v.shape) > 3:

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 255, in _getUnit
return self._extractUnit(self.value)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 561, in _getValue
value[..., mask] = numerix.array(constraint.value)[..., mask]

IndexError: index 100 is out of bounds for axis 0 with size 100

On Wed, Jul 13, 2016 at 3:59 PM, Daniel Wheeler 
wrote:

> Hi Daniel,
>
> It is giving a different error for me
>
> Traceback (most recent call last):
>   File "ConversionModel.py", line 78, in 
> V.constrain(V0,mesh.facesLeft)
> NameError: name 'V' is not defined
>
> Is this the correct script?
>
>
>
> On Wed, Jul 13, 2016 at 3:27 PM, Daniel DeSantis 
> wrote:
> > Hello,
> >
> > I am having some trouble getting a workable convection coefficient on a
> > reactive chemistry model with a vector velocity. I have reviewed several
> > examples from the FiPy mailing list and tried several of the variations
> > listed there. Originally, I was receiving the error that a coefficient
> must
> > be a vector. Now I seem to be getting an error that says the index is
> out of
> > bounds. Specific traceback is shown below, along with the code
> attachment.
> >
> > Could anyone suggest what I am doing wrong and how to fix it?
> >
> > I'm relatively new to Python and FiPy, specifically, so please bear with
> me
> > as I am learning.
> >
> > Thank you all!
> >
> > --
> > Daniel DeSantis
> >
> > Traceback (most recent call last):
> >
> >   File "", line 1, in 
> > runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD
> > Models/ConversionModel.py',
> > wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD Models')
> >
> >   File
> >
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> > line 699, in runfile
> > execfile(filename, namespace)
> >
> >   File
> >
> "C:\Us

Re: Diffusion-Convection-Reactive Chemisty

2016-07-13 Thread Daniel Wheeler
Hi Daniel,

It is giving a different error for me

Traceback (most recent call last):
  File "ConversionModel.py", line 78, in 
V.constrain(V0,mesh.facesLeft)
NameError: name 'V' is not defined

Is this the correct script?



On Wed, Jul 13, 2016 at 3:27 PM, Daniel DeSantis  wrote:
> Hello,
>
> I am having some trouble getting a workable convection coefficient on a
> reactive chemistry model with a vector velocity. I have reviewed several
> examples from the FiPy mailing list and tried several of the variations
> listed there. Originally, I was receiving the error that a coefficient must
> be a vector. Now I seem to be getting an error that says the index is out of
> bounds. Specific traceback is shown below, along with the code attachment.
>
> Could anyone suggest what I am doing wrong and how to fix it?
>
> I'm relatively new to Python and FiPy, specifically, so please bear with me
> as I am learning.
>
> Thank you all!
>
> --
> Daniel DeSantis
>
> Traceback (most recent call last):
>
>   File "", line 1, in 
> runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD
> Models/ConversionModel.py',
> wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD Models')
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> line 699, in runfile
> execfile(filename, namespace)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> line 74, in execfile
> exec(compile(scripttext, filename, 'exec'), glob, loc)
>
>   File "C:/Users/ddesantis/Dropbox/PythonScripts/CFD
> Models/ConversionModel.py", line 107, in 
> res = Eq.sweep(dt=dt, solver=solver)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
> line 236, in sweep
> solver = self._prepareLinearSystem(var=var, solver=solver,
> boundaryConditions=boundaryConditions, dt=dt)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
> line 170, in _prepareLinearSystem
> buildExplicitIfOther=self._buildExplcitIfOther)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\coupledBinaryTerm.py",
> line 122, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
> line 68, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
> line 68, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
> line 68, in _buildAndAddMatrices
> buildExplicitIfOther=buildExplicitIfOther)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\unaryTerm.py",
> line 99, in _buildAndAddMatrices
> diffusionGeomCoeff=diffusionGeomCoeff)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\abstractConvectionTerm.py",
> line 211, in _buildMatrix
> self.constraintB =  -((1 - alpha) * var.arithmeticFaceValue *
> constraintMask * exteriorCoeff).divergence * mesh.cellVolumes
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
> line 1151, in __mul__
> return self._BinaryOperatorVariable(lambda a,b: a*b, other)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
> line 1116, in _BinaryOperatorVariable
> if not v.unit.isDimensionless() or len(v.shape) > 3:
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
> line 255, in _getUnit
> return self._extractUnit(self.value)
>
>   File
> "C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
> line 561, in _getValue
> value[..., mask] = numerix.array(constraint.value)[..., mask]
>
> IndexError: index 100 is out of bounds for axis 0 with size 100
>
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>



-- 
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Diffusion-Convection-Reactive Chemisty

2016-07-13 Thread Daniel DeSantis
Hello,

I am having some trouble getting a workable convection coefficient on a
reactive chemistry model with a vector velocity. I have reviewed several
examples from the FiPy mailing list and tried several of the variations
listed there. Originally, I was receiving the error that a coefficient must
be a vector. Now I seem to be getting an error that says the index is out
of bounds. Specific traceback is shown below, along with the code
attachment.

Could anyone suggest what I am doing wrong and how to fix it?

I'm relatively new to Python and FiPy, specifically, so please bear with me
as I am learning.

Thank you all!

-- 
Daniel DeSantis

Traceback (most recent call last):

  File "", line 1, in 
runfile('C:/Users/ddesantis/Dropbox/PythonScripts/CFD
Models/ConversionModel.py',
wdir='C:/Users/ddesantis/Dropbox/PythonScripts/CFD Models')

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 699, in runfile
execfile(filename, namespace)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/ddesantis/Dropbox/PythonScripts/CFD
Models/ConversionModel.py", line 107, in 
res = Eq.sweep(dt=dt, solver=solver)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
line 236, in sweep
solver = self._prepareLinearSystem(var=var, solver=solver,
boundaryConditions=boundaryConditions, dt=dt)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\term.py",
line 170, in _prepareLinearSystem
buildExplicitIfOther=self._buildExplcitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\coupledBinaryTerm.py",
line 122, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\binaryTerm.py",
line 68, in _buildAndAddMatrices
buildExplicitIfOther=buildExplicitIfOther)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\unaryTerm.py",
line 99, in _buildAndAddMatrices
diffusionGeomCoeff=diffusionGeomCoeff)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\terms\abstractConvectionTerm.py",
line 211, in _buildMatrix
self.constraintB =  -((1 - alpha) * var.arithmeticFaceValue *
constraintMask * exteriorCoeff).divergence * mesh.cellVolumes

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 1151, in __mul__
return self._BinaryOperatorVariable(lambda a,b: a*b, other)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 1116, in _BinaryOperatorVariable
if not v.unit.isDimensionless() or len(v.shape) > 3:

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 255, in _getUnit
return self._extractUnit(self.value)

  File
"C:\Users\ddesantis\AppData\Local\Continuum\Anaconda2\lib\site-packages\fipy\variables\variable.py",
line 561, in _getValue
value[..., mask] = numerix.array(constraint.value)[..., mask]

IndexError: index 100 is out of bounds for axis 0 with size 100


ConversionModel.py
Description: Binary data
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Casting non-linear source terms in FiPy

2016-07-13 Thread Guyer, Jonathan E. Dr. (Fed)
The way you've written it is correct. There's no way to make such a term 
implicit, so just write it as it appears.

> On Jul 13, 2016, at 12:26 PM, Gopalakrishnan, Krishnakumar 
>  wrote:
> 
> 
> Hello,
>  
> I have an equation of the form:
>  
> nabla.(D grad (phi)) = exp(a*phi – K) - exp(-(b*phi – K))
>  
> The diffusion coefficient is simply ‘D’.  But how do I cast the non-linear 
> source term? i.e. what is the syntax to use in the code? In the examples, I 
> did not notice any non-linear source term.
>  
> ‘a’ and ‘b’ are just scalar coefficients of the CellVariable ‘phi’ in the 
> source term. ‘K’ is a CellVariable of another PDE, which couples this PDE.
>  
>  
> Is it enough to simply write the source term as,
>  
> ImplicitSourceTerm(coeff =  numerix.exp(a*phi – K) – numerix.exp(-(b*phi – K))
>  
>  
> Best Regards
>  
> Krishna 
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Casting non-linear source terms in FiPy

2016-07-13 Thread Gopalakrishnan, Krishnakumar

Hello,

I have an equation of the form:

nabla.(D grad (phi)) = exp(a*phi - K) - exp(-(b*phi - K))

The diffusion coefficient is simply 'D'.  But how do I cast the non-linear 
source term? i.e. what is the syntax to use in the code? In the examples, I did 
not notice any non-linear source term.

'a' and 'b' are just scalar coefficients of the CellVariable 'phi' in the 
source term. 'K' is a CellVariable of another PDE, which couples this PDE.


Is it enough to simply write the source term as,

ImplicitSourceTerm(coeff =  numerix.exp(a*phi - K) - numerix.exp(-(b*phi - K))


Best Regards

Krishna
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


RE: Possibility of setting NaN constraints for CellVariable ?

2016-07-13 Thread Gopalakrishnan, Krishnakumar
Dear Raymond, Jonathan and Dan,

Thanks a lot for all your replies.

Indeed this works !  Setting the diffusion coefficient to all interior faces 
helps a lot.

Thanks for your help once again.

Krishna 


-Original Message-
From: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of Daniel 
Wheeler
Sent: Wednesday, July 13, 2016 3:17 PM
To: Multiple recipients of list 
Subject: Re: Possibility of setting NaN constraints for CellVariable ?

On Wed, Jul 13, 2016 at 10:06 AM, Guyer, Jonathan E. Dr. (Fed) 
 wrote:
> You can't do this. NaNs immediately propagate and will break your whole 
> solution.
>
> If I had to do this, I would decouple this region from the other equations by 
> zeroing out the coefficients of those other equations in the appropriate 
> region.

Seconded, remember that the coefficients at the faces need to be zero to not 
have propagation. This will require masking the faces based on position.

--
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Possibility of setting NaN constraints for CellVariable ?

2016-07-13 Thread Daniel Wheeler
On Wed, Jul 13, 2016 at 10:06 AM, Guyer, Jonathan E. Dr. (Fed)
 wrote:
> You can't do this. NaNs immediately propagate and will break your whole 
> solution.
>
> If I had to do this, I would decouple this region from the other equations by 
> zeroing out the coefficients of those other equations in the appropriate 
> region.

Seconded, remember that the coefficients at the faces need to be zero
to not have propagation. This will require masking the faces based on
position.

-- 
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Possibility of setting NaN constraints for CellVariable ?

2016-07-13 Thread Guyer, Jonathan E. Dr. (Fed)
You can't do this. NaNs immediately propagate and will break your whole 
solution.

If I had to do this, I would decouple this region from the other equations by 
zeroing out the coefficients of those other equations in the appropriate region.

> On Jul 13, 2016, at 8:49 AM, Gopalakrishnan, Krishnakumar 
>  wrote:
> 
> 
> Hello,
>  
> I have a regular 2D Cartesian uniformly spaced mesh.
>  
> Due to some peculiarities of the physical system that I am currently working 
> with, the variable of interest in one of my PDEs, (fiPy CellVariable), is 
> undefined in certain interior node locations, i.e. we need to constrain them 
> to a value of float(‘nan’), when solving this PDE. 
>  
> It is not satisfactory to merely constrain them to have a value of 0.0 in 
> these interior co-ordinates, because a) It is physically inaccurate since the 
> values are not defined here and b) Because we need to couple this PDE to 
> other PDEs, the incorrect 0.0 values will propagate to other PDEs, thereby 
> polluting/corrupting their solutions too.  And hence, the full system of
>  
>  
> However, the following code snippet was deemed to be illegal when I tried it 
> out, since FiPy was checking for cellvariables to be strictly numeric (got a 
> value < eps error)
>  
> phi.constrain(float(‘nan’),mesh.y<=1.5)
>  
>  
>  
> How else can we enforce NaNs in these interior nodes in FiPy ?
>  
>  
>  
> Best Regards,
>  
> Krishna
>  
>  
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Possibility of setting NaN constraints for CellVariable ?

2016-07-13 Thread Raymond Smith
Hi, Krishna.

This strikes me as a strange way to go about implementing something, so it
might be helpful to have a bit more physical details about the system in
order to see if the list has proposals for alternative ways to address the
problem. The worry about 0's propagating into the rest of the system makes
me wonder how you expect the rest of the PDE to interact with the nan's. If
values of one PDE are undefined over a particular region, then perhaps the
mesh they are defined on should actually end, and boundary conditions
should be applied. If only one of the PDE's is undefined over that region,
then it would mean having multiple partially overlapping meshes, and that
leads to implementation details, but I give this just as an example
interpretation of your situation.

Ray

On Wed, Jul 13, 2016 at 9:49 AM, Gopalakrishnan, Krishnakumar <
krishnaku...@imperial.ac.uk> wrote:

> Hello,
>
>
>
> I have a regular 2D Cartesian uniformly spaced mesh.
>
>
>
> Due to some peculiarities of the physical system that I am currently
> working with, the variable of interest in one of my PDEs, (fiPy
> CellVariable), is undefined in certain interior node locations, i.e. we
> need to constrain them to a value of float(‘nan’), when solving this PDE.
>
>
>
> It is not satisfactory to merely constrain them to have a value of 0.0 in
> these interior co-ordinates, because a) It is physically inaccurate since
> the values are not defined here and b) Because we need to couple this PDE
> to other PDEs, the incorrect 0.0 values will propagate to other PDEs,
> thereby polluting/corrupting their solutions too.  And hence, the full
> system of
>
>
>
>
>
> However, the following code snippet was deemed to be illegal when I tried
> it out, since FiPy was checking for cellvariables to be strictly numeric
> (got a value < eps error)
>
>
>
> phi.constrain(float(‘nan’),mesh.y<=1.5)
>
>
>
>
>
>
>
> How else can we enforce NaNs in these interior nodes in FiPy ?
>
>
>
>
>
>
>
> Best Regards,
>
>
>
> Krishna
>
>
>
>
>
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
>
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Possibility of setting NaN constraints for CellVariable ?

2016-07-13 Thread Gopalakrishnan, Krishnakumar

Hello,

I have a regular 2D Cartesian uniformly spaced mesh.

Due to some peculiarities of the physical system that I am currently working 
with, the variable of interest in one of my PDEs, (fiPy CellVariable), is 
undefined in certain interior node locations, i.e. we need to constrain them to 
a value of float('nan'), when solving this PDE.

It is not satisfactory to merely constrain them to have a value of 0.0 in these 
interior co-ordinates, because a) It is physically inaccurate since the values 
are not defined here and b) Because we need to couple this PDE to other PDEs, 
the incorrect 0.0 values will propagate to other PDEs, thereby 
polluting/corrupting their solutions too.  And hence, the full system of


However, the following code snippet was deemed to be illegal when I tried it 
out, since FiPy was checking for cellvariables to be strictly numeric (got a 
value < eps error)

phi.constrain(float('nan'),mesh.y<=1.5)



How else can we enforce NaNs in these interior nodes in FiPy ?



Best Regards,

Krishna


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]