Skip to content
Extraits de code Groupes Projets
Valider 02376344 rédigé par abasilavecch's avatar abasilavecch
Parcourir les fichiers

Second try for optimisation of initial conditions

parent 305594aa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -9,20 +9,22 @@ def couche_lim(eta, f):
def optim(Pr, f_2_0,th_1_0):
n = 7
sol = solve_ivp(couche_lim, (0,40), [0,0,f_2_0,1,th_1_0])
while abs(sol.y[1][-1]) > 0.001:
if n > 50 :
print("n > 50")
sol = solve_ivp(couche_lim, (0,30), [0,0,f_2_0,1,th_1_0])
while abs(sol.y[1][-1]) > 0.005 or abs(sol.y[3][-1]) > 0.005:
if n > 300 :
print("Too much iterations")
break
if sol.y[1][-1] > 0.001:
f_2_0 *= 1 - 1/(2**(n+1))
if sol.y[3][-1] > 0.005:
th_1_0 *= 1 + 1/(2**n)
elif sol.y[3][-1] < -0.005:
th_1_0 *= 1 - 1/(2**n)
elif sol.y[1][-1] < -0.001:
sol = solve_ivp(couche_lim, (0,30), [0,0,f_2_0,1,th_1_0])
if sol.y[3][-1] > 0.005:
f_2_0 *= 1 - 1/(2**(n+1))
elif sol.y[1][-1] < -0.005:
f_2_0 *= 1 + 1/(2**(n+1))
th_1_0 *= 1 + 1/(2**n)
sol = solve_ivp(couche_lim, (0,40), [0,0,f_2_0,1,th_1_0])
sol = solve_ivp(couche_lim, (0,30), [0,0,f_2_0,1,th_1_0])
n += 1
return sol
......@@ -37,4 +39,5 @@ if __name__ == "__main__":
mpl.plot(sol.t,sol.y[1], label = "f'(η)")
mpl.plot(sol.t,sol.y[3], label = "θ(η)")
mpl.legend()
mpl.show()
\ No newline at end of file
mpl.show()
print(sol.y[1][-1],sol.y[3][-1])
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter