Skip to content

Commit

Permalink
Tools/Matlab: Allow to read LAMPPS output field
Browse files Browse the repository at this point in the history
Some output fields have attributes attached on the same
line. e.g. "ITEM: BOX BOUNDS pp pp pp". This patch replaced all
the strcmpi to strncmpi in order to limit the number of character
compared with LAMPPS outputs.

Signed-off-by: Yossi Eliaz <[email protected]>
  • Loading branch information
zozo123 committed Mar 12, 2018
1 parent 35abbab commit 9c3296a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tools/matlab/readdump_all.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
i=1;
while feof(dump) == 0
id = fgetl(dump);
if (strcmpi(id,'ITEM: TIMESTEP'))
if (strncmpi(id,'ITEM: TIMESTEP',numel('ITEM: TIMESTEP')))
timestep(i) = str2num(fgetl(dump));
else
if (strcmpi(id,'ITEM: NUMBER OF ATOMS'))
if (strncmpi(id,'ITEM: NUMBER OF ATOMS',numel('ITEM: NUMBER OF ATOMS')))
Natoms(i) = str2num(fgetl(dump));
else
if (strcmpi(id,'ITEM: BOX BOUNDS'))
if (strncmpi(id,'ITEM: BOX BOUNDS',numel('ITEM: BOX BOUNDS')))
x_bound(i,:) = str2num(fgetl(dump));
y_bound(i,:) = str2num(fgetl(dump));
z_bound(i,:) = str2num(fgetl(dump));
Expand Down
8 changes: 4 additions & 4 deletions tools/matlab/readdump_one.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@
end
while done == 0 & last_status == 0
id = fgetl(dump);
if (strcmpi(id,'ITEM: TIMESTEP'))
if (strncmpi(id,'ITEM: TIMESTEP',numel('ITEM: TIMESTEP')))
if t == 0
timestep(i) = str2num(fgetl(dump));
t=1;
end
else
if (strcmpi(id,'ITEM: NUMBER OF ATOMS'))
if (strcmpi(id,'ITEM: NUMBER OF ATOMS',numel('ITEM: NUMBER OF ATOMS')))
Natoms = str2num(fgetl(dump));
else
if (strcmpi(id,'ITEM: BOX BOUNDS'))
if (strcmpi(id,'ITEM: BOX BOUNDS',numel('ITEM: BOX BOUNDS')))
x_bound(1,:) = str2num(fgetl(dump));
y_bound(1,:) = str2num(fgetl(dump));
z_bound(1,:) = str2num(fgetl(dump));
else
if (strcmpi(id(1:11),'ITEM: ATOMS'))
if (strncmpi('ITEM: ATOMS',numel('ITEM: ATOMS')))
atom_data = zeros(Natoms,ncol);%Allocate memory for atom data
for j = 1 : 1: Natoms
atom_data(j,:) = str2num(fgetl(dump));
Expand Down

0 comments on commit 9c3296a

Please sign in to comment.