How to use Matlab curve-fitting data as an input in Fluent transient model ?

5 views (last 30 days)
Hi all,
I now have plenty of X-Y coordinate Temperature data (6 data) on a plate and each value changes with time ( experiment ).
I already know how to use Matlab curve fitting tool box to help me get the curve fitting equation and then transfer the equation as UDF form, but only for intial equation. For the time scale part, I use another regression equation to make it as time-dependant. The problem is that I can only choose one data as reference for the time scale regression equation. Since each point has their individual value that changes with time, my result surely is not as same as the experimental data.
So right now what I want to do is try to introduce matlab into my simulation, my goal is that "At each timstep a new curve fitting equation is calculated in matlab then used as an input in the simulation as a boundary condition".
I've searched online but normaly people use matlab for post-process, so I am hoping that someone would be able to help me here in the community.
Or , if you're able to write curve-fitting codes in UDF form, please also contact me.
Thanks
PS : I have 6000 data for experiment (6000s), that means I need to put 6000 various of matrixs at least.

Answers (1)

Hari
Hari on 27 Oct 2023
Hi Chun,
I understand that you have temperature data with X-Y coordinates changing with time, and you want to use MATLAB to create curve-fitting equations at each time step that can be later used in a Fluent transient model.
To achieve this, you can follow the below steps:
  1. Load your experimental temperature data into MATLAB. This data should include X-Y coordinates and temperature values over time.I am assuming the data is in a CSV file and data have the columns: ‘TimeStep’, ‘X’, ‘Y’, ‘Temperature’. Use appropriate functions to load your data into MALTALB based on your data format.
% Load your experimental temperature data
data = csvread('temperature_data.csv'); % Replace 'temperature_data.csv' with your data file
2. Dynamic Curve Fitting: Create a MATLAB script that selects a subset of your data corresponding to each time step. Use MATLAB's Curve Fitting Toolbox functions to create a curve-fitting equation for that subset of data. Here is an example to do that:
% Loop over each time step
for time_step = 1:num_time_steps
% Filter data for the current time step
subset_data = data(data(:, 1) == time_step, :);
% Extract X, Y, and Temperature data
x = subset_data(:, 2);
y = subset_data(:, 3);
temperature = subset_data(:, 4);
% Fit a curve to the data for this time step (you can choose a fit type)
fitted_model = fit([x, y], temperature, 'some_fit_type');
% Store the fitted model for this time step
fitted_models{time_step} = fitted_model;
end
3. Now you have an array of fitted models, each corresponding to a time step. You can access and evaluate these models as needed in your simulation. You may save the coefficients of these equations in a structured file format, such as CSV. Now in Fluent, you can read the coefficients from the file and set the boundary conditions accordingly to your need.
By following the above procedure, you will be able to efficiently use MATLAB to dynamically generate and store curve-fitting equations for your temperature data at each time step. These fitted models can then be easily integrated into your simulation software or any other application that requires real-time updates of boundary conditions based on the changing temperature data.
For information on curve fitting functions and techniques in MATLAB, please refer to https://www.mathworks.com/help/curvefit/index.html
Refer to MATLAB Import and Export documentation to know more about loading data to MATLAB from different file formats.
Hope this helps!

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!