How to extrapolate the data while some data is already supplied on one spine?

2 ビュー (過去 30 日間)
maurits
maurits 2023 年 1 月 28 日
コメント済み: maurits 2023 年 1 月 28 日
Hello,
I'm trying to extrapolate this data, although the results are not correct. I have the following datapoints (red circles, from experimental):
When I extrapolate this with interp1 I get these results:
Apart from the 100% weight fraction ethanol spline, these results are obviously incorrect. How can I do this extrapolation succesfully so the data makes sense?
Here is the code, i commented the extrapolation part out. I feel like there are simpler methods for this extrapolation anyway.
% Solubility 3D graph for aspirin in ethanol and water at different
% temperatures
clear;clc;close all
C_water = [0 0 0 0 0 0.1 0.1 0.1 0.25 0.25 0.25 0.4 0.4 0.4 0.55 0.55 0.55 0.75 0.75 0.75]';
C_ethanol = [1 1 1 1 1 0.9 0.9 0.9 0.75 0.75 0.75 0.6 0.6 0.6 0.45 0.45 0.45 0.25 0.25 0.25]';
Temperature = [60 80 25 35 50 25 35 50 25 35 50 25 35 50 25 35 50 25 35 50]';
C_ASA_motherliquor = [900 1680 237.9 378.4 648.4 283.2 419.1 689.2 266.6 395.3 679.1 186.2 304.8 570.8 87.9 149.5 377 16.2 32.9 101.6]';
C_ethanol_percentage = C_ethanol.*100; % Percentage ethanol in outlet stream
C_ASA_ML_toGrams = C_ASA_motherliquor./1000;
% % Extrapolation
% extr1 = interp1(Temperature(1:3),C_ASA_ML_toGrams(1:3),55:5:80,'spline','extrap');
% extr2 = interp1(Temperature(4:6),C_ASA_ML_toGrams(4:6),55:5:80,'spline','extrap');
% extr3 = interp1(Temperature(7:9),C_ASA_ML_toGrams(7:9),55:5:80,'spline','extrap');
% extr4 = interp1(Temperature(10:12),C_ASA_ML_toGrams(10:12),55:5:80,'spline','extrap');
% extr5 = interp1(Temperature(13:15),C_ASA_ML_toGrams(13:15),55:5:80,'spline','extrap');
% extr6 = interp1(Temperature(16:18),C_ASA_ML_toGrams(16:18),55:5:80,'spline','extrap');
% TemperatureExtr = [55 60 65 70 75 80 55 60 65 70 75 80 55 60 65 70 75 80 55 60 65 70 75 80 55 60 65 70 75 80 55 60 65 70 75 80]';
% C_ASA_ML_toGrams_Extr = [extr1 extr2 extr3 extr4 extr5 extr6]';
% C_ethanol_Extr = [1 1 1 1 1 1 0.9 0.9 0.9 0.9 0.9 0.9 0.75 0.75 0.75 0.75 0.75 0.75 0.6 0.6 0.6 0.6 0.6 0.6 0.45 0.45 0.45 0.45 0.45 0.45 0.25 0.25 0.25 0.25 0.25 0.25]';
% C_ethanol_percentage_Extr = C_ethanol_Extr.*100;
[xq,yq] = meshgrid(0:5:100, 25:5:50);
vq = griddata(C_ethanol_percentage,Temperature,C_ASA_ML_toGrams,xq,yq);
mesh(xq,yq,vq)
hold on
plot3(C_ethanol_percentage,Temperature,C_ASA_ML_toGrams,'ro')
hold on
surf(xq,yq,vq)
% % Add extrapolated data
% hold on
% [xq2,yq2] = meshgrid(0:5:100, 55:5:80);
% vq2 = griddata(C_ethanol_percentage_Extr,TemperatureExtr,C_ASA_ML_toGrams_Extr,xq2,yq2);
% mesh(xq2,yq2,vq2)
% hold on
% plot3(C_ethanol_percentage_Extr,TemperatureExtr,C_ASA_ML_toGrams_Extr,'bo')
% hold on
% surf(xq2,yq2,vq2)
xlabel('weight fraction ethanol [%]')
ylabel('Temperature [Degrees Celsius]')
zlabel('Solubility ASA [g ASA / g solvent]')
Thanks in advance.

採用された回答

John D'Errico
John D'Errico 2023 年 1 月 28 日
編集済み: John D'Errico 2023 年 1 月 28 日
Extrapolation using a spline (in any form)? A terribly bad idea in general.
Extrapolation over a long distance? Another terribly bad idea. In this case, you are extrapolating over a distance that is roughly equal to the support of your data. A BAD idea. And using a spline to extrapolate that far out is just asking for garbage to result.
You are likely to get something virtually random as a result. And what did you get? Hey, it could have looked a lot worse. Crap. But it could have been worse.
Splines are great things IF you have information at both ends of a curve, IF you just want to find a smooth curve that connects many points together into a nice smooth cohesive curve. Great tools.
Using splines to infer what is happening outside of your data? Find a better method. What is that better method? Usually that is model based, where you would use physical properties about the sytem under study to infer the behavior in a realm where you lack data, based on a realm where you do have data. How does that system behave? What physical models of that system are appropriate? Often those models are based on differential equations. Sometimes the solutions of those differential equations are known, sometimes they are PDE models where you wil need to use a numerical solver.
If you were able to provide more information about what SHOULD be happening at the extremes of that domain (I'm a mathematician, not a chemist, so I won't try to suggest anything there) then you might have more of a chance at the necessary modeling and extrapolation. You do apparently have data along the 100% curve, so that may help. For example, could you just assume that same fundamental curve still applies for the other weight fractions? If so, then the problem would be relatively easy. At least you would get something reasonable.
Note: I am an expert on splines. I have been using them for roughly 40 years as a mathematician and consultant. Building them, writing code to create them in many applications. Yet here I am telling you to RUN away from them for this application. Should this be a hint that using splines is a bad idea here? If the guy who has been promoting splines for so many years tells you to avoid them here, maybe you should take the hint?
  1 件のコメント
maurits
maurits 2023 年 1 月 28 日
I admit that I was trying some methods out to see if the results would be any good. In hindsight, it is not a good idea. As far as I know there are models for solubility, but for this specific case, over the temperature range I need and the solvent/anti-solvent ratios, these models don't apply as it is all very emperical.
I will probably do experiments myself for 0% ethanol at the 60 and 80C and interpolate the data from there. Luckily for my project the numbers at high solubility don't need to be very exact as it is more an upper range limit.
Thanks for your input, it is very appreciated.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeChemistry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by