diff --git a/Equation-Chaleur/Eq-Chal-RNA.py b/Equation-Chaleur/Eq-Chal-RNA.py new file mode 100644 index 0000000..7d37872 --- /dev/null +++ b/Equation-Chaleur/Eq-Chal-RNA.py @@ -0,0 +1,34 @@ +import numpy as np +from keras.models import Sequential +from keras.layers import Dense + +# Constants +dx = 0.1 +dt = 0.01 +alpha = 0.1 + +# Initialize the temperature grid +T = np.zeros((100, 100)) +T[:, 0] = 100 # Left edge is 100 degrees +T[:, -1] = 0 # Right edge is 0 degrees + +# Build the neural network model +model = Sequential() +model.add(Dense(100, input_shape=(100,), activation='relu')) +model.add(Dense(100, activation='relu')) +model.add(Dense(100)) +model.compile(loss='mse', optimizer='adam') + +# Iterate over time steps +for t in range(100): + # Compute the new temperature grid + T_new = np.zeros_like(T) + for i in range(1, 99): + for j in range(1, 99): + T_new[i, j] = T[i, j] + alpha * dt / dx**2 * (T[i+1, j] - 2*T[i, j] + T[i-1, j] + T[i, j+1] - 2*T[i, j] + T[i, j-1]) + + # Use the neural network to predict the temperature at the next time step + predictions = model.predict(T_new) + + # Update the temperature grid with the predicted values + T = predictions diff --git a/RNA-Keras-Exemple/RNA-Keras-Ex2.py b/RNA-Keras-Exemple/RNA-Keras-Ex2.py index cec770c..4d2d611 100644 --- a/RNA-Keras-Exemple/RNA-Keras-Ex2.py +++ b/RNA-Keras-Exemple/RNA-Keras-Ex2.py @@ -9,7 +9,7 @@ # Création du modèle de réseau de neurones en utilisant la bibliothèque Keras model = Sequential() -model.add(Dense(4, input_dim=2, activation='relu')) +model.add(Dense(5, input_dim=2, activation='relu')) model.add(Dense(1, activation='sigmoid')) # Compilation et entraînement du modèle en utilisant l'algorithme de descente de gradient