open a .prt5 file

조회 수: 11 (최근 30일)
Amila Wickramasinghe
Amila Wickramasinghe 2021년 6월 17일
댓글: Shraddha Jain 2021년 6월 21일
I have a file called 'trajectories.prt5' with some data (X,Y,Z coordinates, temperature, mass etc) of moving solid particles. This file was generated from Fire Dynamics Simulator software. I need to open this file to get the coordinates to plot the trajectories of these particles. As well as I got a common MATLAB script written by an expert, but I am not able to open this file and put it into a matrix for further analysis.
Here I put the MATLAB script and really gareful if some scholary MATLAB expert can help me to open this file.
Thank you in advanced.
MATLAB script
------------------------------------------------------------------------------------------------------------------------------
% Trettel and McDermott
% 7-5-11
% read_prt5.m
%
% This function reads the FDS 'part' file (*.prt5).
%
% Example:
%
% >> read_prt5('terminal_velocity.prt5','real*8')
%
% precision = 'real*4' if EB_PART_FILE=.FALSE. on the DUMP line
% precision = 'real*8' if EB_PART_FILE=.TRUE. on the DUMP line
%
% To read part files generated by FDS+Evac use
%
% >> read_prt5('evac_casename.prt5','real*4','evac')
function [STIME, XP, YP, ZP, QP, varargout] = read_prt5(filename,precision,varargin)
nout = max(nargout,1);
evac = false;
if size(varargin)>0
if strcmp(varargin{1},'evac') | strcmp(varargin{1},'EVAC') | strcmp(varargin{1},'Evac')
evac = true;
end
end
fid = fopen(filename);
% The DUMMY lines are 4 byte placeholders that apparently fortran puts at the
% beginning and end of all lines. I only knew of this thanks to Glenn.
DUMMY = fread(fid,1,'integer*4');
ONE_INTEGER = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
INT_VERSION = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
N_PART = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
for NPC=1:N_PART
DUMMY = fread(fid,1,'integer*4');
PC = fread(fid,2,'integer*4'); N_QUANTITIES(NPC) = PC(1);
DUMMY = fread(fid,1,'integer*4');
for NQ=1:N_QUANTITIES(NPC)
DUMMY = fread(fid,1,'integer*4');
SMOKEVIEW_LABEL{NQ} = fgets(fid,30);
DUMMY = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
UNITS{NQ} = fgets(fid,30);
DUMMY = fread(fid,1,'integer*4');
end
end
n = 0;
while ~feof(fid)
n = n + 1;
DUMMY = fread(fid,1,'integer*4');
stime_tmp = fread(fid,1,precision);
DUMMY = fread(fid,1,'integer*4');
if size(stime_tmp,1)==0
break
else
STIME(n) = stime_tmp;
end
for NPC=1:N_PART
DUMMY = fread(fid,1,'integer*4');
NPLIM = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
DUMMY = fread(fid,1,'integer*4');
xp = fread(fid,NPLIM,precision);
yp = fread(fid,NPLIM,precision);
zp = fread(fid,NPLIM,precision);
if evac
ap1 = fread(fid,NPLIM,precision);
ap2 = fread(fid,NPLIM,precision);
ap3 = fread(fid,NPLIM,precision);
ap4 = fread(fid,NPLIM,precision);
end
DUMMY = fread(fid,1,'integer*4');
for NP=1:NPLIM
XP(n,NP,NPC) = xp(NP);
YP(n,NP,NPC) = yp(NP);
ZP(n,NP,NPC) = zp(NP);
if evac & nout==6
AP(n,NP,NPC,1) = ap1(NP);
AP(n,NP,NPC,2) = ap2(NP);
AP(n,NP,NPC,3) = ap3(NP);
AP(n,NP,NPC,4) = ap4(NP);
end
end
%clear xp yp zp
DUMMY = fread(fid,1,'integer*4');
TA = fread(fid,NPLIM,'integer*4');
DUMMY = fread(fid,1,'integer*4');
if N_QUANTITIES(NPC)>0
DUMMY = fread(fid,1,'integer*4');
for NQ=1:N_QUANTITIES(NPC)
qp = fread(fid,NPLIM,precision);
for NP=1:NPLIM
QP(n,NP,NPC,NQ) = qp(NP);
end
%clear qp
end
DUMMY = fread(fid,1,'integer*4');
end
end
end
fclose(fid);
if evac & nout==6
varargout{1} = AP;
end
%display('Part file read successfully!')
% Examples for plotting position and quantities
%plot(STIME,ZP(:,1,1)) % XP(time step range, particle #, part class #)
%size(STIME)
%size(QP(:, 1, 1, 1))
%plot(STIME,QP(:,1,1,1)) % QP(time step range, particle #, part class #, quantity #)
%min(QP(:,1,1,1))
---------------------------------------------------------------------------------------------------------------------------------------------------
  댓글 수: 1
Shraddha Jain
Shraddha Jain 2021년 6월 21일
Hi, it would be helpful to reproduce the issue at our end if you could post the error that you are seeing along with the sample .prt5 file if possible.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by