You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.0 KiB
93 lines
2.0 KiB
# -*- coding: utf-8 -*- |
|
|
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
|
|
class Spreader_2D_adim: |
|
"""Spreader 2D adimensionné""" |
|
|
|
# Variables |
|
K = 1 |
|
S = 1 |
|
B = 1 |
|
Q = 0 |
|
|
|
# Initialisation |
|
def __init__(self, K, S, B, Q=0): |
|
"""Constructeur de Spreader_2D_adim""" |
|
self.K = K |
|
self.S = S |
|
self.B = B |
|
self.Q = Q |
|
|
|
# Accesseurs |
|
def set_K(self, K): |
|
self.K = K |
|
|
|
def set_S(self, S): |
|
self.S = S |
|
|
|
def set_B(self, B): |
|
self.B = B |
|
|
|
def set_Q(self, Q): |
|
self.Q = Q |
|
|
|
def get_K(self, K): |
|
return self.K |
|
|
|
def get_S(self, S): |
|
return self.S |
|
|
|
def get_B(self, B): |
|
return self.B |
|
|
|
def get_Q(self, Q): |
|
return self.Q |
|
|
|
# Méthodes privées |
|
def _beta_old(self, n, Y): |
|
F = self.K * self.S |
|
S = self.S |
|
B = self.B |
|
P = B/F |
|
PI = np.pi |
|
|
|
return 2*np.sinc(n/S)*((1/S - P/(n*PI))*np.exp(-(2-Y)*F*n*PI/S) |
|
+ (1/S + P/(n*PI))*np.exp(-Y*F*n*PI/S))\ |
|
/ (F*(P + n*PI*np.tanh(F*n*PI/S)/S) |
|
* (1 + np.exp(-2*F*n*PI/S))) |
|
|
|
def _beta(self, n, Y): |
|
Knpi = self.K*n*np.pi |
|
return 2*np.sinc(n/self.S)*((Knpi - self.B)*np.exp(-Knpi*(2-Y)) |
|
+ (Knpi + self.B)*np.exp(-Knpi*Y))\ |
|
/ (self.S*Knpi*(self.B + Knpi*np.tanh(Knpi)) |
|
* (1+np.exp(-2*Knpi))) |
|
|
|
# Méthodes publiques |
|
def theta_ss(self, X, Y, N=100): |
|
"""Température en régime permanent""" |
|
f = (1 - Y + 1/self.B)/self.S |
|
g = self.Q*(1/self.B + (1 - 0.5*Y**2)) |
|
return f + g + sum([self._beta_old(n, Y)*np.cos(n*np.pi*X) for n in range(1, N+1)]) |
|
|
|
|
|
# Execution en temps que main |
|
if __name__ == "__main__": |
|
|
|
K = 0.025 |
|
S = 4 |
|
B = 0.005 |
|
Q = 0 |
|
|
|
spreader = Spreader_2D_adim(K, S, B, Q) |
|
|
|
X = np.linspace(0, 1, 20) |
|
Y = np.linspace(0, 1, 20) |
|
|
|
XX, YY = np.meshgrid(X, Y) |
|
|
|
plt.figure() |
|
plt.contourf(XX, YY, spreader.theta_ss(XX, YY)) |
|
plt.colorbar()
|
|
|