define 'if' and 'else' statemets in [soln-ics] section

77 views
Skip to first unread message

AC

unread,
Aug 13, 2018, 11:47:40 AM8/13/18
to PyFR Mailing List
Hi guys,

I am trying to define some velocity profiles in [soln-ics]  using the expressions below. I think that it doesn't pass the 'if' and 'else' statements to the solver. 
Do you have some suggestions please? Any help would be much appreciated. 

Cheers, Andrei 



if y<1.:
        yplus = y * u_tau / nu_inf
else:
       yplus = ((2-y)) * u_tau / nu_inf

Freddie Witherden

unread,
Aug 14, 2018, 9:47:48 AM8/14/18
to pyfrmai...@googlegroups.com
Hi Andrei,

On 13/08/2018 16:47, AC wrote:
> I am trying to define some velocity profiles in [soln-ics]  using the
> expressions below. I think that it doesn't pass the 'if' and 'else'
> statements to the solver.
> Do you have some suggestions please? Any help would be much appreciated.
You can accomplish this by using an expression with a hyperbolic tangent
(tanh) function. This provides a smooth means of transitioning between
one function and another.

Regards, Freddie.

Kiny Wan

unread,
Oct 22, 2019, 3:12:15 AM10/22/19
to PyFR Mailing List


Hi Freddie,
         The hyperbolic tangent (tanh) function is difficult to initiate a shock wave. The following is a matlab code and its related picture:

        r=-5:0.0001:5;
        aaa=1.34161*tanh(500000000*(1-tanh(500000000*(r))))+(1-0.2*1.0*1.0*exp(1-(r-4).*(r-4))).^2.5.*tanh(500000000*(1+tanh(500000000*(r)))/2);
        plot(r,aaa)

        A peak value is generated near x=0.

untitled.jpg


Yours 
Wan

Tarik Dzanic

unread,
Oct 22, 2019, 11:31:29 AM10/22/19
to PyFR Mailing List
Hi Wan,

Try this:
aaa = 1.34161*(0.5*(tanh(500000000*(1-r)) +1))   +   (1-0.2*1.0*1.0*exp(1-(r-4).*(r-4))).^2.5.*(1 - 0.5*(tanh(500000000*(1-r)) + 1));

Kiny Wan

unread,
Oct 23, 2019, 8:22:14 AM10/23/19
to PyFR Mailing List

Hi Dzanic

        Thank you. It works.

1.jpg


Reply all
Reply to author
Forward
0 new messages