I found several problems with paraview. It came as a package with openFOAM installation but didn’t work when i execute “paraFoam” command. Hence, I find solution to install paraview separately from paraview.org/download.

Another problem occurs, when it’s loaded, the paraview window was to large for my laptop screen. After searching, I found solution:

  • Right click on paraview executable -> Properties -> Compatibilities -> Change high DPI settings
  • Check “Override high DPI scaling behavior” and select “System (enhanced)”
  • Press Ok.
  • (Re)start ParaView

So now it works. A little hassle is that I have to create .foam file for every simulation, then open it from paraview. As a default setting it didn’t show the path of linux sistem at the search bar. So needs to go to the foam file, right click -properties, copy path. Example from one of the case simulation:

\\wsl.localhost\Ubuntu-22.04\home\beny\OpenFOAM\beny-13\run\pitzDailySteady

Now that we have successfully installed OpenFOAM at our machine. It’s the most anticipated moment to run first simulation. To avoid the hassle of simulation setup for beginners, tutorials are provided at the installation folder. Systematically can be seen at the explorer window as follows:

tutorials folder located at /opt and the running will be at /home.

Basically some steps to run the tutorial simulation are like this:

  • copy the case folder from /opt/tutorials to /home
  • copy required geometry (format of *.obj) to the ~/geometry folder which located at /home/<user>/OpenFOAM/<user>/run/
  • meshing
  • running using simpleFoam

If we want to install OpenFOAM on Windows system, we can follow this step by step tutorial on this link:

Installation on Windows

  1. Install WSL: since OpenFOAM run on linux, we need to install WSL (windows subsystem for linux),
  2. Ubuntu installation: after WSL, we install ubuntu as the OS, if successful we can see at the windows explorer as below.
  • OpenFOAM installation
  • User Configuration with gedit ,link
  • Create Directory for running OpenFOAM, it will look like this on terminal and the hierarchy on the explorer can be seen at the subsequent image. All of the simulation will run from here.

The installation procedure is quite easy to follow. However in some machine maybe problems and errors occur.

  • Gedit is not running. Not sure what was the cause. If the problem persist, just use vi or nano to edit the bashrc
  • other…

Once it’s up and running, we can try running our first case simulation…. check out the next post!

Day 2 – May 4, 2025:

Implementing ML in predicting the optimum NACA Airfoil parameters.

  1. Prepare dataset in excel file
  2. Load and inspect the data in python
  3. Preprocess the data & normalize
  4. Choose and train ML Model
  5. Evaluate the Model & save
  6. Optimization with Genetic Algorithm
  7. Output

import pandas as pd
import numpy as np
import joblib
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score, mean_squared_error
from scipy.optimize import differential_evolution

=== Step 1: Load Excel Data ===

df = pd.read_excel(“airfoil_data.xlsx”)

Features and target

X = df[[‘m’, ‘p’, ‘t’]]
y = df[‘L/D’]

=== Step 2: Scale Data ===

scaler_X = StandardScaler()
scaler_y = StandardScaler()

X_scaled = scaler_X.fit_transform(X)
y_scaled = scaler_y.fit_transform(y.values.reshape(-1, 1)).ravel()

=== Step 3: Train Surrogate Model ===

model = RandomForestRegressor(n_estimators=200, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y_scaled, test_size=0.2, random_state=42)

model.fit(X_train, y_train)
y_pred_test = model.predict(X_test)

Evaluate model

print(“R² Score:”, r2_score(y_test, y_pred_test))
print(“MSE:”, mean_squared_error(y_test, y_pred_test))

=== Step 4: Save Model and Scalers (Optional) ===

joblib.dump(model, “surrogate_model.pkl”)
joblib.dump(scaler_X, “scaler_X.pkl”)
joblib.dump(scaler_y, “scaler_y.pkl”)

=== Step 5: Define Optimization Objective ===

def objective_function(x):
# x = [m, p, t]
x_scaled = scaler_X.transform([x])
y_pred_scaled = model.predict(x_scaled)
y_pred = scaler_y.inverse_transform(y_pred_scaled.reshape(-1, 1))[0][0]
return -y_pred # Negative because we minimize

=== Step 6: Define Parameter Bounds ===

bounds = [
(0.00, 0.09), # m: max camber
(0.10, 0.90), # p: camber position
(0.06, 0.18) # t: thickness
]

=== Step 7: Run Optimization ===

result = differential_evolution(
objective_function,
bounds,
strategy=’best1bin’,
maxiter=100,
popsize=15,
tol=1e-6,
seed=42
)

best_x = result.x
best_LD = -result.fun # Convert back to positive

print(“\n Optimal NACA Parameters:”)
print(f”m (max camber): {best_x[0]:.4f}”)
print(f”p (camber location): {best_x[1]:.4f}”)
print(f”t (thickness): {best_x[2]:.4f}”)
print(f”Predicted L/D: {best_LD:.2f}”)

Some problems still occur on the geometry. Cleanup in Space Claim.

Meshing parameter:

element size 700mm

Initial named selection only inlet, outlet, wall and plane

curvature normal angle, change from 18 to 10 degree.

The other paremeters were set to default.

Problem occurs: intersection faces on the vertical stabilize on the joint to fuselage, results in small faces

Countermeasure: cleanup the excess faces at base of the vertical stabilizer. Delete adjoining faces at the fuselage – repair with missing faces on space claim.

Meshing faces reduced from 602 to 587. Initializing meshing

  • Enclosure distance from plane (plane length is B) : 15B=255m and 30B=510m
Rancang situs seperti ini dengan WordPress.com
Mulai