Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gyacomo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Cyril David Hoffmann
Gyacomo
Commits
4ea93148
Commit
4ea93148
authored
1 year ago
by
Antoine Cyril David Hoffmann
Browse files
Options
Downloads
Patches
Plain Diff
new matlab to plot transport from out_XX.txt files
parent
52e22443
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/read_flux_out_XX.m
+89
-0
89 additions, 0 deletions
matlab/read_flux_out_XX.m
with
89 additions
and
0 deletions
matlab/read_flux_out_XX.m
0 → 100644
+
89
−
0
View file @
4ea93148
function
[
t_all
,
Pxi_all
,
Qxi_all
]
=
read_flux_out_XX
(
folderPath
,
PLOT
)
% Check if the prompt_string is provided as an argument
if
nargin
<
1
% If not provided, prompt the user for input
prompt_string
=
'Enter the path to the simulation dir: '
;
% Get the input from the user
folderPath
=
input
(
prompt_string
,
's'
);
PLOT
=
1
;
else
if
nargin
==
1
PLOT
=
0
;
end
% Initialize empty arrays to store the values
t_all
=
[];
Pxi_all
=
[];
Qxi_all
=
[];
Pxe_all
=
[];
Qxe_all
=
[];
% List all files in the folder with the pattern out_XX.txt
filePattern
=
fullfile
(
folderPath
,
'out_*.txt'
);
files
=
dir
(
filePattern
);
% Regular expression pattern to match numerical values
pattern
=
'[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?'
;
% Loop through each file
for
i
=
1
:
length
(
files
)
filename
=
fullfile
(
folderPath
,
files
(
i
)
.
name
);
fid
=
fopen
(
filename
,
'r'
);
if
fid
==
-
1
fprintf
(
'Error opening file: %s\n'
,
filename
);
continue
;
end
% Loop through each line of the file
while
~
feof
(
fid
)
line
=
fgetl
(
fid
);
% Check if the line starts with "|t"
if
startsWith
(
line
,
'|t'
)
% Check if the line contains numerical values
matches
=
regexp
(
line
,
pattern
,
'match'
);
% Convert the matched strings to numerical values
values
=
str2double
(
matches
);
% If matches are found, extract the numerical values and store them in the arrays
if
~
isempty
(
matches
)
values
=
str2double
(
matches
);
if
numel
(
values
)
==
4
t_all
=
[
t_all
,
values
(
1
)];
Pxi_all
=
[
Pxi_all
,
values
(
3
)];
Qxi_all
=
[
Qxi_all
,
values
(
4
)];
elseif
numel
(
values
)
==
3
t_all
=
[
t_all
,
values
(
1
)];
Pxi_all
=
[
Pxi_all
,
values
(
2
)];
Qxi_all
=
[
Qxi_all
,
values
(
3
)];
elseif
numel
(
values
)
==
5
t_all
=
[
t_all
,
values
(
1
)];
Pxi_all
=
[
Pxi_all
,
values
(
2
)];
Qxi_all
=
[
Qxi_all
,
values
(
3
)];
Pxe_all
=
[
Pxe_all
,
values
(
4
)];
Qxe_all
=
[
Qxe_all
,
values
(
5
)];
end
end
end
end
% Close the file
fclose
(
fid
);
end
if
PLOT
figure
subplot
(
211
)
plot
(
t_all
,
Pxi_all
,
'r'
,
'DisplayName'
,
'$\Gamma_{xi}$'
);
hold
on
;
if
(
numel
(
t_all
)
==
numel
(
Pxe_all
))
plot
(
t_all
,
Pxe_all
,
'b'
,
'DisplayName'
,
'$\Gamma_{xe}$'
);
hold
on
;
end
title
(
'Particle flux'
)
subplot
(
212
)
plot
(
t_all
,
Qxi_all
,
'r'
,
'DisplayName'
,
'$Q_{xi}$'
);
hold
on
;
if
(
numel
(
t_all
)
==
numel
(
Qxe_all
))
plot
(
t_all
,
Qxe_all
,
'b'
,
'DisplayName'
,
'$Q_{xe}$'
);
hold
on
;
end
title
(
'Heat flux'
)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment