Clear Filters
Clear Filters

Out of memory error in Matlab and How to solve it?

11 views (last 30 days)
Hello Everyone
I am trying to run a simple straightforward code in Matlab. I am having out of memory error. I am attaching the code and the error message. Can someone please point me out how can I solve this or where I am making mistakes.
Thank you.
clc
clear all
close all
T_ar=300; % Temparature of Argon
k_B=1.380649e-23; % Boltzmann's Constant in J/K
e=1.60217663e-19; % electronic charge in Coulomb
m_e=9.109e-31; % mass of an electron in kg
epsilon=8.854e-12; % permittivity of free space
A_sp=.005024; % Powered Electrode Area in m^2
A_sg=.007854; % Grounded Electrode Area in m^2
l_B=0.075; % plasma bulk length in m
n=1.96e16; % plasma density in m^-3
upsilon=0.08; % Symmetry Parameter
T_e=3; % Electron Temparature in eV
m_i=40; % Argon mass in amu for determining bohm velocity
amu=1.660539e-27; % 1 Dalton
v_B=sqrt((e*T_e)/(m_i*amu)); % Bohm velocity
v_e = sqrt(8*k_B*T_ar/(pi*m_e)); % mean thermal speed
p=1; % pressure in pascal
n_g=(p/(k_B*T_ar)); % gas density in m^-3
Km=10^-13;
v_m=Km*n_g; % momentum transfer collision frequency
v_eff=v_m+(v_e/l_B); % Effective Collision Rate in s^-1
J_e=e*n*v_e; % Coefficient of electron current
J_i=e*n*v_B; % Coefficient of ion current
Jip=J_i*A_sp; % Ion current at Powered Sheath
Jig=J_i*A_sg; % Ion current at Grounded Sheath
Jep=J_e*A_sp;
Jeg=J_e*A_sg;
L_pl=(l_B*m_e)/(e^2*n*A_sp); % Plasma Bulk Inductance
R_pl=v_eff*L_pl ; % Plasma Bulk Resistance
Lpl_inv=1/L_pl;
A=(1/(2*e*epsilon*n*A_sp^2));
xx=(e*A/(T_e))
B=(1/(2*e*epsilon*n*A_sg^2));
V0=300; % Amplitude of RF input voltage
C_B=3.34e-6; % Dc blocking capacitor
f = @(t,x) [-x(4)-Jip+Jep*exp(-(e*A/(T_e))*(x(1)^2));
x(4)-Jig+Jeg*exp(-(e*B/(T_e)).*(x(2)^2));
-(1/C_B).*x(4);
(A.*(x(1)^2)-B.*(x(2)^2)+(V0*cos(t))+x(3))-((v_eff/Lpl_inv).*x(4))];
[t,xa] = ode45(f,[0, 10],[0,0,-62,0]);
figure(1)
plot(t,xa(:,1),'Color','blue'),grid on;
title('xa1')
xlabel('t'), ylabel('Qsp (Powered Electrode Sheath Charge)')
figure(2)
hold off
plot(t,xa(:,2),'Color','blue'),grid on;
title('xa2')
xlabel('t'), ylabel('Qsp (Grounded Electrode Sheath Charge)')
figure(3)
plot(t,xa(:,3),'Color','blue')
grid on;
title('xa3')
xlabel('t'), ylabel('Self Bias Voltage')
figure(4)
plot(t,xa(:,4),'Color','blue'),grid on;
title('xa4')
xlabel('t'), ylabel('Plasma Current')
The error message is as follows:
  2 Comments
Walter Roberson
Walter Roberson on 6 Feb 2023
You can potentially run out of memory in ode45 if the ode is unusually rapidly changing or if it is stiff. Experiment with ode15s()
Md. Golam Zakaria
Md. Golam Zakaria on 6 Feb 2023
@Walter Roberson If I use a computer with higher ram capacity like 32 GB, will it solve the problem ?

Sign in to comment.

Answers (1)

Jan
Jan on 6 Feb 2023
Of course an out-of-memory problem is solved, if more RAM is available. But if the equation is stiff, this solution is of temporary nature only. Using a solver like ode15s is a better way, because ode45 will compute a huge number of steps, which let the accumulated rounding errors explode.
Use a stiff solver for stiff problems.
On the other hand it is possible, that the problem is not stiff and you simply have not enough RAM installed. A cheap (and not scientific way) to check this is using the debugger: Let the integration run a certain time and check if the time steps become tiny.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!