Initial conditions for a mixed system

Asked by Yaakoub El Khamra on 2012-10-29

Is there a neat way to set the initial conditions for a mixed system? The system is defined as follows:

solver_parameters['space']['u'] = VectorFunctionSpace #
solver_parameters['degree']['u'] = 2
solver_parameters['degree']['p'] = 1
solver_parameters['degree']['Sw'] = 1

GloalFormulation = PDESystem([['u', 'p', 'Sw']], problem, solver_parameters)

I tried variations of the following to no avail:

u0 = Expression('3.0')
p0 = Expression('3.0')
Sw0 = Expression('3.0')

maybe = Expression('3.0,3.0')

problem.q0 = {'u': [u0,u0]}
problem.q0 = {'p': p0}
problem.q0 = {'Sw': Sw0}

problem.q0 = {'u': maybe}

Many thanks in advance.
Regards
Yaakoub

Question information

Language:
English Edit question
Status:
Solved
For:
CBC.PDESys Edit question
Assignee:
No assignee Edit question
Solved by:
Mikael Mortensen
Solved:
Last query:
Last reply:

This question was reopened

Hi Yaakoub,

Den Oct 29, 2012 kl. 10:25 PM skrev Yaakoub El Khamra:

> New question #212689 on CBC.PDESys:
> https://answers.launchpad.net/cbcpdesys/+question/212689
>
>
> Is there a neat way to set the initial conditions for a mixed system? The system is defined as follows:
>
> solver_parameters['space']['u'] = VectorFunctionSpace #
> solver_parameters['degree']['u'] = 2
> solver_parameters['degree']['p'] = 1
> solver_parameters['degree']['Sw'] = 1
>
> GloalFormulation = PDESystem([['u', 'p', 'Sw']], problem, solver_parameters)
>
> I tried variations of the following to no avail:
>
> u0 = Expression('3.0')
> p0 = Expression('3.0')
> Sw0 = Expression('3.0')
>
> maybe = Expression('3.0,3.0')
>
> problem.q0 = {'u': [u0,u0]}
> problem.q0 = {'p': p0}
> problem.q0 = {'Sw': Sw0}
>
> problem.q0 = {'u': maybe}

You are constantly creating a new dictionary. Try

maybe = Expression(('3.0', 3.0))

problem.q0 = {'u': maybe, 'p':p0, 'Sw':Sw0}

Best regards

Mikael

>
>
> Many thanks in advance.
> Regards
> Yaakoub
>
> --
> You received this question notification because you are an answer
> contact for CBC.PDESys.

Yaakoub El Khamra (yelkhamra) said : #2

That did not exactly work. Everything is still initialized to 0.0

Sw0 = 0.5
p0 = 3.14159
maybe = Expression(('10.0', '10.0'))
problem.q0 = {'u': maybe, 'p':p0, 'Sw':Sw0}

anything else I can try?

Regards
Yaakoub

Ok, see if this works:

Sw0 = 0.5
p0 = 3.14159
maybe = Expression(('10.0', '10.0'))
problem.q0 = Initdict({'u': maybe, 'p':p0, 'Sw':Sw0})

Initdict is a special dictionary that should work for different compositions of mixed functionspaces. For example, one can use

q0 = Initdict(u = ('1', '0'), p= '1.')

which then should ideally work for both systems [['u', 'p']] and [['u'], ['p']]. Note that your mixed space normally would require an Expression for 'upSw'.

Best regards

Mikael

Den Oct 30, 2012 kl. 10:25 PM skrev Yaakoub El Khamra:

> Question #212689 on CBC.PDESys changed:
> https://answers.launchpad.net/cbcpdesys/+question/212689
>
> Yaakoub El Khamra posted a new comment:
>
> That did not exactly work. Everything is still initialized to 0.0
>
> Sw0 = 0.5
> p0 = 3.14159
> maybe = Expression(('10.0', '10.0'))
> problem.q0 = {'u': maybe, 'p':p0, 'Sw':Sw0}
>
> anything else I can try?
>
> Regards
> Yaakoub
>
> --
> You received this question notification because you are an answer
> contact for CBC.PDESys.

Yaakoub El Khamra (yelkhamra) said : #4

No joy with Initdict. Both
problem.q0 = Initdict({'u': maybe, 'p':p0, 'Sw':Sw0})
and
problem.q0 = Initdict(u = ('1', '0'), p= '1.', Sw = '0.5')

failed to set the initial conditions.

I did make several failed attempts at a 'upSw' expression as well.

Yaakoub El Khamra (yelkhamra) said : #5

By the way I have been trying with the flow past dolfin problem if you want to give it a try.

Regards
Yaakoub

Yaakoub El Khamra (yelkhamra) said : #6

sorry, accidentally clicked on solved.

Yaakoub El Khamra (yelkhamra) said : #7

Thanks Mikael Mortensen, that solved my question.

Hi,

Sorry about the late respons, busy.

I forgot, you cannot do these tricks with Expressions. Need to be strings
or numbers. These work for me:

GloalFormulation = PDESystem([['u', 'p', 'Sw']], problem, solver_parameters)

problem.q0 = Initdict(u = ('1', '0'), p = 0, Sw = 0)
or
problem.q0 = {'upSw': Expression(('1', '0', '1', '0'),
element=GloalFormulation.V['upSw'].ufl_element())}

problem.initialize(GloalFormulation)

Mikael

On 30 October 2012 23:05, Yaakoub El Khamra <
<email address hidden>> wrote:

> Question #212689 on CBC.PDESys changed:
> https://answers.launchpad.net/cbcpdesys/+question/212689
>
> Yaakoub El Khamra posted a new comment:
>
> No joy with Initdict. Both
> problem.q0 = Initdict({'u': maybe, 'p':p0, 'Sw':Sw0})
> and
> problem.q0 = Initdict(u = ('1', '0'), p= '1.', Sw = '0.5')
>
> failed to set the initial conditions.
>
> I did make several failed attempts at a 'upSw' expression as well.
>
> --
> You received this question notification because you are an answer
> contact for CBC.PDESys.
>

Yaakoub El Khamra (yelkhamra) said : #9

Thank you sir. I discovered the cfd/problems directory in CBC and raided it for code snippets. I got it to work. Thank you very much.

Regards
Yaakloub