limited integration with respect to x in Simulink
63 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1761554/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1761554/image.png)
0 Commenti
Risposte (2)
Shivam Gothi
il 29 Ago 2024 alle 6:18
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762004/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762009/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762014/image.jpeg)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762019/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762024/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762029/image.png)
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 Commenti
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!