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

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

Hi Andrei,

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.

Yours
Wan

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));

Hi Dzanic

Thank you. It works.

1.jpg