Skip to content

Commit

Permalink
Extra error checks for X and Y setter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and ischoegl committed Jun 9, 2023
1 parent b7d4c83 commit 44c8b6d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions interfaces/matlab_experimental/Base/ThermoPhase.m
Original file line number Diff line number Diff line change
Expand Up @@ -1302,9 +1302,17 @@ function display(tp)
function set.X(tp, xx)
tol = 1e-9;

if isempty(xx)
error('Array cannot be empty');
end

if isa(xx, 'double')
nsp = tp.nSpecies;

if length(xx) ~= nsp
error('Length of array must be equal to number of species.')
end

if abs(sum(xx) - 1) <= tol
norm = 0;
else
Expand All @@ -1323,9 +1331,17 @@ function display(tp)
function set.Y(tp, yy)
tol = 1e-9;

if isempty(yy)
error('Array cannot be empty');
end

if isa(yy, 'double')
nsp = tp.nSpecies;

if length(yy) ~= nsp
error('Length of array must be equal to number of species.')
end

if abs(sum(yy) -1) <= tol
norm = 0;
else
Expand Down

0 comments on commit 44c8b6d

Please sign in to comment.