Skip to content

Instantly share code, notes, and snippets.

@n7275
Created September 7, 2021 21:20
Show Gist options
  • Save n7275/b0bb17cf1a8c5d0853c3c6b4d306ec2c to your computer and use it in GitHub Desktop.
Save n7275/b0bb17cf1a8c5d0853c3c6b4d306ec2c to your computer and use it in GitHub Desktop.
VDW Systems Test for NASSP
clear;
clc;
Temp = linspace(0,200,20);
R_CONST = 8314.4621;
MMASS = 31.998;
vapor_mass = linspace(0,300,20);
air_volume = 0.5;
a = 1.382/101300;
b = 0.03186;
p_ideal = zeros(length(Temp),length(vapor_mass));
p_vdw = zeros(length(Temp),length(vapor_mass));
ii = 1;
jj = 1;
for ii = 1:length(Temp)
for jj = 1:length(vapor_mass)
p_ideal(ii,jj) = R_CONST * Temp(ii) * (vapor_mass(jj) / MMASS) / air_volume;
p_vdw(ii,jj) = ((R_CONST * Temp(ii))/((MMASS/(vapor_mass(jj)/air_volume))-b))-a/((MMASS/(vapor_mass(jj)/air_volume))^2);
end
end
[TEMP,VAP] = meshgrid(Temp,vapor_mass);
surf(TEMP,VAP./air_volume,p_ideal/101300);
hold on;
surf(TEMP,VAP./air_volume,p_vdw/101300);
hold off
xlabel("Temperature [K]");
ylabel("Density [g/l]");
zlabel("Pressure [bar]");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment