Re: Implementation of Dirichlet Boundary Condition

2020-03-12 Thread Alexander Tismer
I did a new commit where the checks run successfully. See on github.
Hope this is will help you. I did my best.

Warm regards,
Alex

Am 10.03.20 um 20:29 schrieb Guyer, Jonathan E. Dr. (Fed) via fipy:
> The change you propose is inconsistent with the convection scheme, as 
> evidenced by the large number of test failures that result.
> 
> Is there a problem for which FiPy fails to produce the correct answer?
> 
> If there is, then any solution to that problem must work for arbitrary 
> dimensions, arbitrary geometries, and arbitrary convection schemes. We will 
> not be making any changes that are only valid for central differencing in 1D.
> 
>> On Mar 10, 2020, at 12:59 PM, Alexander Tismer 
>>  wrote:
>>
>> Dear Jonathan,
>>
>> I also sent a pull request in github with a change to treat the
>> boundaries correctly.
>> Hope this help.
>>
>> Warm regards
>> Alex
>>
>> Am 08.03.20 um 11:13 schrieb Alexander Tismer:
>>> Dear Jonathan,
>>>
>>> many thanks for your quick reply.
>>>
>>> I figured out that the convective flux crossing the left side of the
>>> element W is in your equation
>>>
>>> - rho * v * (phi_W + phi(X=0))/2
>>>
>>> and in my equation
>>>
>>> - rho * v * phi(X=0)
>>>
>>> That is the difference. Why is it necessary to interpolate the value of
>>> phi at the left side between phi_W and phi(X=0)? The value of phi is
>>> known at this position, because it is the boundary condition.
>>>
>>> Warm regards,
>>> Alex
>>> Am 06.03.20 um 21:30 schrieb Guyer, Jonathan E. Dr. (Fed) via fipy:
 My guess is that you got the sign of the outward-facing normal wrong
 somewhere. I posted my derivation to
 https://gist.github.com/guyer/3b77bbf32d90ef314754f0d76a7e04cc.


> On Mar 6, 2020, at 4:09 AM, Alexander Tismer
>  > wrote:
>
> Dear Users,
>
> my question concerns the implementation of the boundary conditions in
> FiPy.
> I would like to solve a 1D Conv-Diff-Equation with 3 control volumes
> using CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.
>
> For me, it is not clear why the first row of the matrix of the linear
> equation system is
>> 9.00  -2.50  ---
> and the right hand side is
>> 6.5
>
> The case is the following. Each control volume (W, C and E) has the
> length 1/3. All coefficients (gamma, u, rho) in the equation is set to 1:
>
> o---> x
> |-D=1/3-|-D=1/3-|-D=1/3-|
>x=0 x=1
> phi=1   phi=0
> v   v
> +---+---+---+
> |   W   |   C   |   E  |
> o---x---o---x---o---x---o
> |   |   |   |
> +---+---+---+
>
> If I discretize the equation in the first control volume (W), I get
> for the matrix row
>> 10.00  -2.50  ---
> and for the right hand side
>> 7.0
>
> So this is a little bit different from FiPy. Is there any mistake from
> my side?
>
> Please find attached my notes on how calculating my matrix
> coefficients (fipy_0.png) and my python script for fipy (fipy.py).
>
> Warm regards,
> Alex
> ___
> 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 ]

>>>
>>
>> -- 
>> Alexander Tismer
>>
>> Institut für Strömungsmechanik
>> und Hydraulische Strömungsmaschinen
>> Universität Stuttgart
>> Pfaffenwaldring 10
>> 70550 Stuttgart
>>
>> Tel.:   +49 (0) 711 / 685 63007
>> Fax:+49 (0) 711 / 685 63255
>> eMail: alexander.tis...@ihs.uni-stuttgart.de
>> https://gcc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ihs.uni-stuttgart.de&data=02%7C01%7Cjonathan.guyer%40nist.gov%7C6efb1a8d58b946dad65b08d7c5149ec4%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637194564665197918&sdata=1zJ1urkF4B432%2BJGhVrVSW7tghanW3Nz3aGBPwUKjZ4%3D&reserved=0
>> ___
>> 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 ]
> 

-- 
Alexander Tismer

Institut für Strömungsmechanik
und Hydraulische Strömungsmaschinen
Universität Stuttgart
Pfaffenwaldring 10
70550 Stuttgart

Tel.:   +49 (0) 711 / 685 63007
Fax:+49 (0) 711 / 685 63255
eMail: alexander.tis...@ihs.uni-stuttgart.de
http://www.ihs.uni-stuttgart.de

Re: Implementation of Dirichlet Boundary Condition

2020-03-10 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
The change you propose is inconsistent with the convection scheme, as evidenced 
by the large number of test failures that result. 

Is there a problem for which FiPy fails to produce the correct answer?

If there is, then any solution to that problem must work for arbitrary 
dimensions, arbitrary geometries, and arbitrary convection schemes. We will not 
be making any changes that are only valid for central differencing in 1D.

> On Mar 10, 2020, at 12:59 PM, Alexander Tismer 
>  wrote:
> 
> Dear Jonathan,
> 
> I also sent a pull request in github with a change to treat the 
> boundaries correctly.
> Hope this help.
> 
> Warm regards
> Alex
> 
> Am 08.03.20 um 11:13 schrieb Alexander Tismer:
>> Dear Jonathan,
>> 
>> many thanks for your quick reply.
>> 
>> I figured out that the convective flux crossing the left side of the
>> element W is in your equation
>> 
>> - rho * v * (phi_W + phi(X=0))/2
>> 
>> and in my equation
>> 
>> - rho * v * phi(X=0)
>> 
>> That is the difference. Why is it necessary to interpolate the value of
>> phi at the left side between phi_W and phi(X=0)? The value of phi is
>> known at this position, because it is the boundary condition.
>> 
>> Warm regards,
>> Alex
>> Am 06.03.20 um 21:30 schrieb Guyer, Jonathan E. Dr. (Fed) via fipy:
>>> My guess is that you got the sign of the outward-facing normal wrong
>>> somewhere. I posted my derivation to
>>> https://gist.github.com/guyer/3b77bbf32d90ef314754f0d76a7e04cc.
>>> 
>>> 
 On Mar 6, 2020, at 4:09 AM, Alexander Tismer
 >>> > wrote:
 
 Dear Users,
 
 my question concerns the implementation of the boundary conditions in
 FiPy.
 I would like to solve a 1D Conv-Diff-Equation with 3 control volumes
 using CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.
 
 For me, it is not clear why the first row of the matrix of the linear
 equation system is
> 9.00  -2.50  ---
 and the right hand side is
> 6.5
 
 The case is the following. Each control volume (W, C and E) has the
 length 1/3. All coefficients (gamma, u, rho) in the equation is set to 1:
 
o---> x
|-D=1/3-|-D=1/3-|-D=1/3-|
   x=0 x=1
 phi=1   phi=0
v   v
+---+---+---+
|   W   |   C   |   E  |
o---x---o---x---o---x---o
|   |   |   |
+---+---+---+
 
 If I discretize the equation in the first control volume (W), I get
 for the matrix row
> 10.00  -2.50  ---
 and for the right hand side
> 7.0
 
 So this is a little bit different from FiPy. Is there any mistake from
 my side?
 
 Please find attached my notes on how calculating my matrix
 coefficients (fipy_0.png) and my python script for fipy (fipy.py).
 
 Warm regards,
 Alex
 ___
 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 ]
>>> 
>> 
> 
> -- 
> Alexander Tismer
> 
> Institut für Strömungsmechanik
> und Hydraulische Strömungsmaschinen
> Universität Stuttgart
> Pfaffenwaldring 10
> 70550 Stuttgart
> 
> Tel.:   +49 (0) 711 / 685 63007
> Fax:+49 (0) 711 / 685 63255
> eMail: alexander.tis...@ihs.uni-stuttgart.de
> https://gcc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ihs.uni-stuttgart.de&data=02%7C01%7Cjonathan.guyer%40nist.gov%7C6efb1a8d58b946dad65b08d7c5149ec4%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637194564665197918&sdata=1zJ1urkF4B432%2BJGhVrVSW7tghanW3Nz3aGBPwUKjZ4%3D&reserved=0
> ___
> 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: Implementation of Dirichlet Boundary Condition

2020-03-10 Thread Alexander Tismer
Dear Jonathan,

I also sent a pull request in github with a change to treat the 
boundaries correctly.
Hope this help.

Warm regards
Alex

Am 08.03.20 um 11:13 schrieb Alexander Tismer:
> Dear Jonathan,
> 
> many thanks for your quick reply.
> 
> I figured out that the convective flux crossing the left side of the
> element W is in your equation
> 
> - rho * v * (phi_W + phi(X=0))/2
> 
> and in my equation
> 
> - rho * v * phi(X=0)
> 
> That is the difference. Why is it necessary to interpolate the value of
> phi at the left side between phi_W and phi(X=0)? The value of phi is
> known at this position, because it is the boundary condition.
> 
> Warm regards,
> Alex
> Am 06.03.20 um 21:30 schrieb Guyer, Jonathan E. Dr. (Fed) via fipy:
>> My guess is that you got the sign of the outward-facing normal wrong
>> somewhere. I posted my derivation to
>> https://gist.github.com/guyer/3b77bbf32d90ef314754f0d76a7e04cc.
>>
>>
>>> On Mar 6, 2020, at 4:09 AM, Alexander Tismer
>>> >> > wrote:
>>>
>>> Dear Users,
>>>
>>> my question concerns the implementation of the boundary conditions in
>>> FiPy.
>>> I would like to solve a 1D Conv-Diff-Equation with 3 control volumes
>>> using CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.
>>>
>>> For me, it is not clear why the first row of the matrix of the linear
>>> equation system is
 9.00  -2.50  ---
>>> and the right hand side is
 6.5
>>>
>>> The case is the following. Each control volume (W, C and E) has the
>>> length 1/3. All coefficients (gamma, u, rho) in the equation is set to 1:
>>>
>>>     o---> x
>>>     |-D=1/3-|-D=1/3-|-D=1/3-|
>>>    x=0 x=1
>>> phi=1   phi=0
>>>     v   v
>>>     +---+---+---+
>>>     |   W   |   C   |   E  |
>>>     o---x---o---x---o---x---o
>>>     |   |   |   |
>>>     +---+---+---+
>>>
>>> If I discretize the equation in the first control volume (W), I get
>>> for the matrix row
 10.00  -2.50  ---
>>> and for the right hand side
 7.0
>>>
>>> So this is a little bit different from FiPy. Is there any mistake from
>>> my side?
>>>
>>> Please find attached my notes on how calculating my matrix
>>> coefficients (fipy_0.png) and my python script for fipy (fipy.py).
>>>
>>> Warm regards,
>>> Alex
>>> ___
>>> 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 ]
>>
> 

-- 
Alexander Tismer

Institut für Strömungsmechanik
und Hydraulische Strömungsmaschinen
Universität Stuttgart
Pfaffenwaldring 10
70550 Stuttgart

Tel.:   +49 (0) 711 / 685 63007
Fax:+49 (0) 711 / 685 63255
eMail: alexander.tis...@ihs.uni-stuttgart.de
http://www.ihs.uni-stuttgart.de
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Implementation of Dirichlet Boundary Condition

2020-03-08 Thread Alexander Tismer
Dear Jonathan,

many thanks for your quick reply.

I figured out that the convective flux crossing the left side of the 
element W is in your equation

- rho * v * (phi_W + phi(X=0))/2

and in my equation

- rho * v * phi(X=0)

That is the difference. Why is it necessary to interpolate the value of 
phi at the left side between phi_W and phi(X=0)? The value of phi is 
known at this position, because it is the boundary condition.

Warm regards,
Alex
Am 06.03.20 um 21:30 schrieb Guyer, Jonathan E. Dr. (Fed) via fipy:
> My guess is that you got the sign of the outward-facing normal wrong 
> somewhere. I posted my derivation to 
> https://gist.github.com/guyer/3b77bbf32d90ef314754f0d76a7e04cc.
> 
> 
>> On Mar 6, 2020, at 4:09 AM, Alexander Tismer 
>> > > wrote:
>>
>> Dear Users,
>>
>> my question concerns the implementation of the boundary conditions in 
>> FiPy.
>> I would like to solve a 1D Conv-Diff-Equation with 3 control volumes 
>> using CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.
>>
>> For me, it is not clear why the first row of the matrix of the linear 
>> equation system is
>> > 9.00  -2.50  ---
>> and the right hand side is
>> > 6.5
>>
>> The case is the following. Each control volume (W, C and E) has the 
>> length 1/3. All coefficients (gamma, u, rho) in the equation is set to 1:
>>
>>    o---> x
>>    |-D=1/3-|-D=1/3-|-D=1/3-|
>>   x=0 x=1
>> phi=1   phi=0
>>    v   v
>>    +---+---+---+
>>    |   W   |   C   |   E  |
>>    o---x---o---x---o---x---o
>>    |   |   |   |
>>    +---+---+---+
>>
>> If I discretize the equation in the first control volume (W), I get 
>> for the matrix row
>> > 10.00  -2.50  ---
>> and for the right hand side
>> > 7.0
>>
>> So this is a little bit different from FiPy. Is there any mistake from 
>> my side?
>>
>> Please find attached my notes on how calculating my matrix 
>> coefficients (fipy_0.png) and my python script for fipy (fipy.py).
>>
>> Warm regards,
>> Alex
>> ___
>> 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 ]
> 

-- 
Alexander Tismer

Institut für Strömungsmechanik
und Hydraulische Strömungsmaschinen
Universität Stuttgart
Pfaffenwaldring 10
70550 Stuttgart

Tel.:   +49 (0) 711 / 685 63007
Fax:+49 (0) 711 / 685 63255
eMail: alexander.tis...@ihs.uni-stuttgart.de
http://www.ihs.uni-stuttgart.de
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Implementation of Dirichlet Boundary Condition

2020-03-06 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
My guess is that you got the sign of the outward-facing normal wrong somewhere. 
I posted my derivation to 
https://gist.github.com/guyer/3b77bbf32d90ef314754f0d76a7e04cc.


On Mar 6, 2020, at 4:09 AM, Alexander Tismer 
mailto:alexander.tis...@ihs.uni-stuttgart.de>>
 wrote:

Dear Users,

my question concerns the implementation of the boundary conditions in FiPy.
I would like to solve a 1D Conv-Diff-Equation with 3 control volumes using 
CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.

For me, it is not clear why the first row of the matrix of the linear equation 
system is
> 9.00  -2.50  ---
and the right hand side is
> 6.5

The case is the following. Each control volume (W, C and E) has the length 1/3. 
All coefficients (gamma, u, rho) in the equation is set to 1:

   o---> x
   |-D=1/3-|-D=1/3-|-D=1/3-|
  x=0 x=1
phi=1   phi=0
   v   v
   +---+---+---+
   |   W   |   C   |   E  |
   o---x---o---x---o---x---o
   |   |   |   |
   +---+---+---+

If I discretize the equation in the first control volume (W), I get for the 
matrix row
> 10.00  -2.50  ---
and for the right hand side
> 7.0

So this is a little bit different from FiPy. Is there any mistake from my side?

Please find attached my notes on how calculating my matrix coefficients 
(fipy_0.png) and my python script for fipy (fipy.py).

Warm regards,
Alex
___
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 ]


Implementation of Dirichlet Boundary Condition

2020-03-06 Thread Alexander Tismer

Dear Users,

my question concerns the implementation of the boundary conditions in FiPy.
I would like to solve a 1D Conv-Diff-Equation with 3 control volumes 
using CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.


For me, it is not clear why the first row of the matrix of the linear 
equation system is

> 9.00  -2.50  ---
and the right hand side is
> 6.5

The case is the following. Each control volume (W, C and E) has the 
length 1/3. All coefficients (gamma, u, rho) in the equation is set to 1:


o---> x
|-D=1/3-|-D=1/3-|-D=1/3-|
   x=0 x=1
 phi=1   phi=0
v   v
+---+---+---+
|   W   |   C   |   E  |
o---x---o---x---o---x---o
|   |   |   |
+---+---+---+

If I discretize the equation in the first control volume (W), I get for 
the matrix row

> 10.00  -2.50  ---
and for the right hand side
> 7.0

So this is a little bit different from FiPy. Is there any mistake from 
my side?


Please find attached my notes on how calculating my matrix coefficients 
(fipy_0.png) and my python script for fipy (fipy.py).


Warm regards,
Alex
import fipy as fp

nx = 3
dx = 1./nx
k = 0

U = 1.0
Gamma = 1.0
rho = 1.0

mesh = fp.Grid1D(nx=nx, dx=dx)  
   
phi = fp.CellVariable(name="phi", mesh=mesh, value=0.)
phi.constrain( 1.0, mesh.facesLeft() )
phi.constrain( 0.0, mesh.facesRight() )   

eq = fp.CentralDifferenceConvectionTerm(coeff=(rho * U,)) - fp.DiffusionTerm(coeff=Gamma) == 0.

eq.cacheMatrix()
eq.cacheRHSvector()
eq.solve( var=phi )

print( eq.matrix )
print( eq.RHSvector )
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]