Trying to display a plot of navier stokes shock structure, It says error at position(55) "options = optimoptions('fsolve' etc)". Saying " Undefined function or method 'optimoptions' for input arguments of type 'char'." Please, need urgent help?!
8 views (last 30 days)
Show older comments
function shock
%%%%%%%%%%%%%%%
declare certain variables global (i.e. common to other subroutines)
global m1 h0 p0 pr g s u1 t1 u2 t2 mesh mid umid tmid
% clear what is in the figure window
hold off, clf
%Mach number of shock wave
m1= 5
% Set no. of numerical points in shock domain
np = 151;
% Upstream x-boundary
xup = 0;
% Downstream x-boundary
xdown = 20;
% Temperature/viscosity exponent
s = 0.76;
% Set gamma
g = 5/3;
% Set Prandtl number
pr = 2/3;
% Total pressure, enthalpy
p0 = (1 + g*m1*m1)/(g*m1);
h0 = 1 + (g-1)*m1*m1/2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% UPSTREAM (1) AND DOWNSTREAM (2) POINTS %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u1 = m1;
t1 = 1/g;
r1 = g;
aa = 1 + (g-1)/2;
bb = -g*p0;
cc = h0;
u2 = (-bb-sqrt(bb*bb-4*aa*cc))/(2*aa);
t2 = u2*(p0-u2);
r2 = r1*u1/u2;
% Straight line initial solution (option)
u = linspace(u1,u2,np);
t = linspace(t1,t2,np);
% Linearly spaced mesh
mesh = linspace(xup,xdown,np).';
% Midpoint values (if needed)
mid = max(find(u>=(u1+u2)/2));
umid = u(mid);
tmid = t(mid);
% set initial solution vector
xs = [u ; t];
%%%%%%%%%%%%%%%%%%%%%%%
% Solve Shock problem %
%%%%%%%%%%%%%%%%%%%%%%%
% accuracy of numerical solution
tol = 1e-6;
% set options for the non-linear equations solver 'fsolve'
options = optimoptions('fsolve',...
'TolX',tol,...
'TolFun',tol,...
'Display','iter-detailed',...
'Algorithm','trust-region-dogleg',...
'FinDiffType','central'...
);
% run solver
[xs,fval,exitflag] = fsolve('ns',xs,options); exitflag
% extract solutions for velocity, temperature, and density
u = xs(1:np);
t = xs(np+1:np*2);
r = (r1*m1)./u;
mesh = mesh(:);
% calculate Maxwellian-mfp equivalent Inverse Density Gradient
mg = max(gradient(r,mesh));
idg = 0.903*mg/(r2-r1);
disp('NS inverse density thickness'), disp(idg)
% plot normalised profiles of velocity and temperature
plot(mesh,(u-u2)./(u1-u2),':',mesh,(t-t1)./(t2-t1),':'); drawnow, hold on
4 Comments
Geoff Hayes
on 20 Jun 2014
Nawaz - try these lines again from the Command Window, do not include them in your program, just try them outside of the program/function
which optimoptions
which fsolve
ver
They will return something.
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!