limited integration with respect to x in Simulink
6 ビュー (過去 30 日間)
古いコメントを表示
i am trying to do this integration but it gives me different results from the calculator or Mathway this is my model for PEM Electrolayzer can you help
0 件のコメント
回答 (2 件)
Shivam Gothi
2024 年 8 月 29 日
Hello Amr,
I have tried to solve the above integral by using "ode45" function of MATLAB. I am attaching the matlab script (.m) file ("PEM_function.m") which solves the above integral.
NOTE : Assumptions made : Because we need to provide some initial condition for integral problem to be solved, I am assuming that . But you can change them according to your preference it the script.
The script plots the value of () for different values of membrane thickness (L) ranging from 0 to 0.0001 meters. I am attaching the output generated by the script below.
As seen in the above image, the value of is 8.1256e-7 when L = 0.0001. This agrees with the results of "Mathway" calculator. Also I have evaluated the integral for different values of (L = 45, and ) in "Mathway" calculator and compared with the plot generated by script. The results are matching for all the cases.
If you want to implement in simulink, you can refer to the same code and define a "function block" in simulink window.
I am also attaching the code of file "PEM_function.m" below, in case the file fails to open.
clc;
clear;
%define the initial condition vector
x_initial = 0; %(This is U_ohm_initial, i.e U_ohm at x = 0)
L = 0.0001;
%solve using ode45 matlab inbuilt in function
[x,U_ohm]=ode45(@(x,U_ohm) PEM(x,U_ohm),[0 L],x_initial);
%Plot the U_ohm vs x
figure;
plot(x,U_ohm,'b'); %plot the position of the mass
title('Plot of U_{ohm} vs different values of membrane thickness (L)');
xlabel('Membrane thickness (L)');
ylabel('U_{ohm}');
axx = gca;
axx.FontSize = 12;
disp("The final answer of the integration is ");
x(end)
function U_ohm_dot=PEM(x,U_ohm)
%t is from 0 to L
%Assume U_ohm initial to be 0.
T = 353;
lambda_a = 14; %WATER CONTENT AT THE ANODE MEMBRANE INTERFACE
lambda_c = 10; %WATER CONTENT AT THE CATHODE MEMBRANE INTERFACE
L = 0.000100 ; %Membrane Tickness
lambda_x = ((lambda_a-lambda_c)/L)*x + lambda_c;
sigmaPEM = (0.5139*lambda_x-0.326)*exp(1268*(1/303-1/T));
U_ohm_dot = 1/(sigmaPEM*lambda_x); %The differentiation is performed with respect to x.
end
I hope this helps !!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!