using **kwarg in an Expression

Asked by Mo

Hi folks,

I am trying to calculate an expression in a for loop. ja is a function. Part of my code is:

     for i_a in range(mesh0.size(0)):

 ga = Expression('(ja/difsa)*x[0]',
                {'ja': ja.vector()[i_a], 'difsa': difsa})

 LCSA = csa_prev*vs*dx - (difsa/rspa**2)*ga*vs*dt*ds

 bcsa = assemble(LCSA, tensor=bcsa)

 solve(ACSA, csa.vector(), bcsa)

Unfortunately, I receive this error when running:

*** Warning: Deprication warning: Use **kwargs to pass default values to member variables in an Expression.

And the result I receive is csa = nan.

How should I use **kwargs in an Expression in a for loop.

Any help is extremely appreciated.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Mo
Solved:
Last query:
Last reply:
Revision history for this message
Marie Rognes (meg-simula) said :
#1

On 09/22/11 01:25, M Hadigol wrote:
> New question #171964 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/171964
>
> Hi folks,
>
> I am trying to calculate an expression in a for loop. ja is a function. Part of my code is:
>
>
> for i_a in range(mesh0.size(0)):
>
>
>
> ga = Expression('(ja/difsa)*x[0]',
> {'ja': ja.vector()[i_a], 'difsa': difsa})
>
>
>
> LCSA = csa_prev*vs*dx - (difsa/rspa**2)*ga*vs*dt*ds
>
> bcsa = assemble(LCSA, tensor=bcsa)
>
> solve(ACSA, csa.vector(), bcsa)
>
>
>
> Unfortunately, I receive this error when running:
>
> *** Warning: Deprication warning: Use **kwargs to pass default values to member variables in an Expression.
>
>
> And the result I receive is csa = nan.
>
> How should I use **kwargs in an Expression in a for loop.
>
> Any help is extremely appreciated.
>
>

Take a look at the example provided at:

http://fenicsproject.org/releases/1.0-beta/index.html#default-arguments-required-for-expressions

--
Marie

Revision history for this message
Mo (mo-h) said :
#2

Thank you so much Marie. It works without using **kwargs. I appreciate your help.