Error using symengine Invalid Argument.

6 次查看(过去 30 天)
I am having an issue getting MatLab to "convert" my input domain for a variable into the output range that I'm trying to plot. It appears to dislike my setting of a symbol that I will be integrating, and outputs the errors below. It doesn't output the same error if I leave off the domain in the int line.
What am I doing incorrectly or is there another way I should be using commands to make Matlab do what I want?
Error using symengine
Invalid argument.
Error in sym/int (line 162)
rSym = mupadmex('symobj::intdef',f.s,x.s,a.s,b.s,options);
Here's the code: Error pops up for syms t p
clear all
clc
Pini=101325; %Initial Pressure is Pa
Tini=273; %Initial Temperature is 273 K
Vg=5.34*10^-6; Vd=3.42*10^-6; %m^3/mol, Molar volume
Ag=23.7*10^-5; Ad=3.6*10^-6; %K^-1, Coefficient of Thermal Expansion
Bg=3*10^-5; Bd=1.9*10^-6; %Pa^-1, Isothermal Compressibility
Cpg=8.53; Cpd=6.12; %J/mol K, Specific Heat capacity
Sg=5.7; Sd=2.4; %J/mol K, Molar entropy
Hg=0; Hd=1.9*10^3; %J/mol, Molar enthalpy
Tnum=11:10:4010; %Tnum is in K
Pnum=0.1:1:400; %Pnum will be in atm - need a conversion factor in calculations
Pcalc=Pnum*101325; %converts Pnum atm into Pcalc pascals
syms t p
delGtg=-(Sg.*(t-Tini)+int(Cpg.*log(t/Tini),t,Tini,Tnum));
delGpg=int(Vg.*exp(Ag.*(t-Tini)).*exp(-Bg.*(p-Pini)),p,Pini,Pcalc);
Ginig=Hg-Tini*Sg;
Gg=delGtg+DelGpg+Ginig;
delGtd=-(Sd.*(t-Tini)+int(Cpd.*log(t/Tini),t,Tini,Tnum));
delGpd=int(Vd.*exp(Ad.*(t-Tini)).*exp(-Bd.*(p-Pini)),p,Pini,Pcalc);
Ginid=Hd-Tini*Sd;
Gd=delGtd+delGpd+Ginid;
Figure
surf(Tnum,Pnum,Gg)
hold on
surf(Tnum,Pnum,Gd)
hold off
grid on
xlabel('Temperature (K)')
ylabel('Pressure (atm)')
zlabel('Molar Gibbs Free Energy (J/mol)')

回答(1 个)

Walter Roberson
Walter Roberson 2018-2-16
In one of your int() you use Pcalc as your upper bound. Pcalc is a vector. You cannot use a vector for the boundary of int()
If the function has a closed form for the integral then specify the upper bound as a symbol, and then subs() the vector for the symbol to get the vector of values.
If the function does not have a closed form for the integral you should be using vpaintegral(). To avoid redoing the integration over areas you have already done, break the range up into segments at the given boundaries, vpaintegral over just that range, and then cumsum() to get the list of results.

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by