Re: Spline interpolation and fipy variable

2018-01-12 Thread Daniel Wheeler
On Fri, Jan 12, 2018 at 12:42 PM, Clara Maurel  wrote:
> Hi Daniel,
>
> Thank you very much! The code runs for me as well: fantastic!
>
> I have to admit that the distinction between cell and face variables remains
> a bit obscure to me…

The domain is divided into cells or boxes in 2D. The faces are where
the boxes meet and the cell centers are located at the center of the
boxes. FiPy calculates/resolves fluxes between the boxes.

> The cell variable X_var is the composition of the
> system I am modelling. Then "G" in d2G is the Gibbs free energy (called f
> here
> https://www.ctcms.nist.gov/fipy/examples/cahnHilliard/generated/examples.cahnHilliard.mesh2DCoupled.html#module-examples.cahnHilliard.mesh2DCoupled),
> which is itself a function of the composition X_var (the spline function).
> I don’t know if these info are more useful to figure out if d2G should be
> cell or face variable? As I understood it, because I want to solve for
> X_var, this should be a cell variable and nothing else.

X_var is a cell variable but the diffusion coefficient can either be a
cell variable or a face variable in FiPy. FiPy converts the diffusion
coefficient to a face variable if it's defined as a cell variable in
the input file. FiPy calculates the flux between cells so the
diffusion coefficient is only used at the faces where the flux is
calculated. d2G has values which are defined over the domain. How do
those values correspond to a location in that domain? Why does d2G
have a shape of (1001,) when there are only 1000 cells?

> By higher dimension do you also mean 2D? I know 2D requires a lot of
> changes, but I thought 2D required only a change of grid. In any case, 2D is
> not my top priority at the moment.

Ok, this is only being used for 1D right now so you're fine.

> Thank you again very much for your help!

Good luck with it.

-- 
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: Spline interpolation and fipy variable

2018-01-12 Thread Clara Maurel
Hi Daniel,

Thank you very much! The code runs for me as well: fantastic!

I have to admit that the distinction between cell and face variables remains a 
bit obscure to me… The cell variable X_var is the composition of the system I 
am modelling. Then "G" in d2G is the Gibbs free energy (called f here 
https://www.ctcms.nist.gov/fipy/examples/cahnHilliard/generated/examples.cahnHilliard.mesh2DCoupled.html#module-examples.cahnHilliard.mesh2DCoupled
 
),
 which is itself a function of the composition X_var (the spline function).
I don’t know if these info are more useful to figure out if d2G should be cell 
or face variable? As I understood it, because I want to solve for X_var, this 
should be a cell variable and nothing else.

By higher dimension do you also mean 2D? I know 2D requires a lot of changes, 
but I thought 2D required only a change of grid. In any case, 2D is not my top 
priority at the moment.

Thank you again very much for your help!
Clara


> On 12 Jan 2018, at 12:04, Daniel Wheeler  wrote:
> 
> Hi Clara,
> 
> The following changes made it run for me. I turned d2G into a face
> variable and K into a variable that is updated in the sweep loop. I
> also removed redefining the equation. FiPy's designed so you only need
> to to create the equation once. I'm not sure what the values of d2G
> correspond to. Which spatial location do they correspond to? Faces or
> Cells. I'm assuming faces since there are 1001 of them. Also, this
> might need to be adjusted for higher dimensions.
> 
> Cheers,
> 
> Daniel
> 
> 
> $ git diff
> diff --git a/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
> b/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
> index 715e79b..a82387e 100644
> --- a/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
> +++ b/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
> @@ -289,20 +289,21 @@ def
> Get_spline_Chebnodes(X,N,T0,R,RefFe,RefNi,L0ex,L1ex,L2ex,Tmag,Bmag,p_fcc,A_f
> return d2G
> 
> 
> +
> ## THIS IS WHERE I WOULD LIKE TO HAVE A FIPY VARIABLE TYPE FOR d2G.
> d2G = 
> Get_spline_Chebnodes(Xf,100,T0,R,RefFe,RefNi,L0ex,L1ex,L2ex,Tmag,Bmag,p_fcc,A_fcc,Nv,Na)*1.0e-9
> -
> +d2G_var = FaceVariable(mesh=mesh, value=d2G)
> 
> ## Initial diffusion coefficient
> -Diff = Mob*d2G
> +Diff = Mob*d2G_var
> 
> 
> ## Initial gradient energy (depending on the interfacial energy we want)
> K = 2.0*kappa[id_mean_spino]
> -
> +K_var = Variable(K)
> 
> ## Initial equation
> -eq = TransientTerm(coeff=1.) == DiffusionTerm(Diff) -
> DiffusionTerm(coeff=(Mob, K))
> +eq = TransientTerm(coeff=1.) == DiffusionTerm(Diff) -
> DiffusionTerm(coeff=(Mob, K_var))
> 
> 
> plt.figure(figsize=(8,6))
> @@ -390,16 +391,16 @@ while time < duration:
> Mob = M[step_T][id_mean_T]
> 
> d2G = 
> Get_spline_Chebnodes(Xf,100,T_spino[step_T],R,RefFe,RefNi,L0ex,L1ex,L2ex,Tmag,Bmag,p_fcc,A_fcc,Nv,Na)*1.0e-9
> -
> -Diff = Mob*d2G
> +d2G_var[:] = d2G
> 
> K = 2.0*kappa[step_T]
> +K_var.setValue(K)
> print 'Mob, Diff, K'
> print Mob, Diff, K
> print 'MAX CONCENTRATION'
> print max(X_var)
> 
> -eq = TransientTerm(coeff=1.) == DiffusionTerm(Diff) -
> DiffusionTerm(coeff=(Mob, K))
> +
> 
> 
> print datetime.now() - startTime
> (END)
> 
> 
> On Thu, Jan 11, 2018 at 2:35 PM, Clara Maurel  wrote:
>> Hi Daniel,
>> 
>> Thank you for taking the time to look at this! My main code calls several
>> text files and subroutine. I attach everything that is needed to run the
>> code:
> 
> -- 
> Daniel Wheeler
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]



smime.p7s
Description: S/MIME cryptographic signature
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Spline interpolation and fipy variable

2018-01-12 Thread Daniel Wheeler
Hi Clara,

The following changes made it run for me. I turned d2G into a face
variable and K into a variable that is updated in the sweep loop. I
also removed redefining the equation. FiPy's designed so you only need
to to create the equation once. I'm not sure what the values of d2G
correspond to. Which spatial location do they correspond to? Faces or
Cells. I'm assuming faces since there are 1001 of them. Also, this
might need to be adjusted for higher dimensions.

Cheers,

Daniel


$ git diff
diff --git a/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
b/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
index 715e79b..a82387e 100644
--- a/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
+++ b/Spinodal_fipy_FeNi_varT_runs_DEBUG.py
@@ -289,20 +289,21 @@ def
Get_spline_Chebnodes(X,N,T0,R,RefFe,RefNi,L0ex,L1ex,L2ex,Tmag,Bmag,p_fcc,A_f
 return d2G


+
 ## THIS IS WHERE I WOULD LIKE TO HAVE A FIPY VARIABLE TYPE FOR d2G.
 d2G = 
Get_spline_Chebnodes(Xf,100,T0,R,RefFe,RefNi,L0ex,L1ex,L2ex,Tmag,Bmag,p_fcc,A_fcc,Nv,Na)*1.0e-9
-
+d2G_var = FaceVariable(mesh=mesh, value=d2G)

 ## Initial diffusion coefficient
-Diff = Mob*d2G
+Diff = Mob*d2G_var


 ## Initial gradient energy (depending on the interfacial energy we want)
 K = 2.0*kappa[id_mean_spino]
-
+K_var = Variable(K)

 ## Initial equation
-eq = TransientTerm(coeff=1.) == DiffusionTerm(Diff) -
DiffusionTerm(coeff=(Mob, K))
+eq = TransientTerm(coeff=1.) == DiffusionTerm(Diff) -
DiffusionTerm(coeff=(Mob, K_var))


 plt.figure(figsize=(8,6))
@@ -390,16 +391,16 @@ while time < duration:
 Mob = M[step_T][id_mean_T]

 d2G = 
Get_spline_Chebnodes(Xf,100,T_spino[step_T],R,RefFe,RefNi,L0ex,L1ex,L2ex,Tmag,Bmag,p_fcc,A_fcc,Nv,Na)*1.0e-9
-
-Diff = Mob*d2G
+d2G_var[:] = d2G

 K = 2.0*kappa[step_T]
+K_var.setValue(K)
 print 'Mob, Diff, K'
 print Mob, Diff, K
 print 'MAX CONCENTRATION'
 print max(X_var)

-eq = TransientTerm(coeff=1.) == DiffusionTerm(Diff) -
DiffusionTerm(coeff=(Mob, K))
+


 print datetime.now() - startTime
(END)


On Thu, Jan 11, 2018 at 2:35 PM, Clara Maurel  wrote:
> Hi Daniel,
>
> Thank you for taking the time to look at this! My main code calls several
> text files and subroutine. I attach everything that is needed to run the
> code:

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