Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Germain Clavier
python-tools
Commits
512f5869
Commit
512f5869
authored
Jun 28, 2020
by
Germain Clavier
Browse files
Options
Downloads
Patches
Plain Diff
Suppressed plot_table for git_forces?
parent
eb85ff76
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lammps/plot_table.py
+0
-162
0 additions, 162 deletions
lammps/plot_table.py
with
0 additions
and
162 deletions
lammps/plot_table.py
deleted
100644 → 0
+
0
−
162
View file @
eb85ff76
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Plot LAMMPS forces
'''
import
argparse
import
numpy
as
np
import
os
import
logging
import
sys
import
GCcolors
from
matplotlib
import
pyplot
as
plt
def
compute_energy
(
tp
):
r
=
tp
[
0
]
fo
=
tp
[
2
]
e
=
np
.
zeros
(
r
.
shape
)
for
i
,
(
ri
,
fi
)
in
enumerate
(
zip
(
r
,
fo
)):
if
i
==
0
:
continue
dr
=
ri
-
r
[
i
-
1
]
e
[
i
]
=
e
[
i
-
1
]
-
dr
*
fo
[
i
-
1
]
e
-=
e
[
-
1
]
return
e
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"
Plots Lammps tabulated forces.
"
)
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
dest
=
"
verbosity
"
,
default
=
0
,
action
=
"
count
"
,
help
=
"
display more information
"
,
)
parser
.
add_argument
(
"
-f
"
,
"
--file
"
,
dest
=
"
infile
"
,
default
=
""
,
help
=
"
File to read
"
,
)
parser
.
add_argument
(
"
-x
"
,
dest
=
"
xrange
"
,
default
=
""
,
help
=
"
xrange : separated (for negative values: -x=-3:10)
"
,
)
parser
.
add_argument
(
"
-y
"
,
dest
=
"
yrange
"
,
default
=
""
,
help
=
"
yrange : separated
"
,
)
parser
.
add_argument
(
"
-e
"
,
dest
=
"
extract
"
,
action
=
"
store_true
"
,
help
=
"
Extract the forces in separate files
"
,
)
args
=
parser
.
parse_args
()
##########
# Manage arguments
# -v/--verbose
try
:
utilsscript
.
init_logging
(
args
.
verbosity
)
except
NameError
:
logging
.
basicConfig
(
level
=
logging
.
WARNING
)
logging
.
warning
(
"
utilsscript lib not found, using default logging at warning level.
"
)
infile
=
args
.
infile
if
not
os
.
path
.
isfile
(
infile
):
logging
.
error
(
"
Input file not found
"
)
sys
.
exit
(
1
)
toplot
=
[]
with
open
(
infile
,
'
r
'
)
as
f
:
lines
=
iter
(
f
.
readlines
())
while
True
:
try
:
r
=
[]
force
=
[]
ener
=
[]
tok
=
[]
while
not
tok
:
tok
=
next
(
lines
).
partition
(
'
#
'
)[
0
].
rstrip
()
logging
.
info
(
"
Found {} token
"
.
format
(
tok
))
infos
=
next
(
lines
).
split
()
npoints
=
int
(
infos
[
1
])
dummy
=
next
(
lines
)
for
i
in
range
(
npoints
):
line
=
next
(
lines
).
split
()
r
.
append
(
float
(
line
[
1
]))
ener
.
append
(
float
(
line
[
2
]))
force
.
append
(
float
(
line
[
3
]))
r
=
np
.
array
(
r
)
ener
=
np
.
array
(
ener
)
force
=
np
.
array
(
force
)
toplot
.
append
([
r
,
ener
,
force
,
tok
])
tok
=
[]
dummy
=
next
(
lines
)
except
StopIteration
:
break
for
tp
in
toplot
:
tp
[
1
]
=
compute_energy
(
tp
)
fig
,
axes
=
plt
.
subplots
(
1
,
2
)
for
tp
in
toplot
:
axes
[
0
].
plot
(
tp
[
0
],
tp
[
1
],
label
=
tp
[
3
],
linewidth
=
3
)
axes
[
1
].
plot
(
tp
[
0
],
tp
[
2
],
label
=
tp
[
3
],
linewidth
=
3
)
if
args
.
xrange
:
xmin
,
xmax
=
list
(
map
(
float
,
args
.
xrange
.
split
(
"
:
"
)))
axes
[
0
].
set_xlim
(
xmin
,
xmax
)
axes
[
1
].
set_xlim
(
xmin
,
xmax
)
if
args
.
yrange
:
ymin
,
ymax
=
list
(
map
(
float
,
args
.
yrange
.
split
(
"
:
"
)))
axes
[
0
].
set_ylim
(
ymin
,
ymax
)
axes
[
1
].
set_ylim
(
ymin
,
ymax
)
# Setting axes 0
axes
[
0
].
set_title
(
"
Estimated energy
"
,
fontsize
=
30
)
axes
[
0
].
legend
(
frameon
=
False
,
fontsize
=
30
)
# Fat font, no frame
axes
[
0
].
set_xlabel
(
"
r [A]
"
,
fontname
=
"
Hack
"
,
fontsize
=
30
)
# ylabel name, font is Hack, size 30pts
axes
[
0
].
set_ylabel
(
"
E [kcal/mol]
"
,
fontname
=
"
Hack
"
,
fontsize
=
30
)
# ylabel name, font is Hack, size 30pts
axes
[
0
].
tick_params
(
axis
=
'
both
'
,
which
=
'
major
'
,
labelsize
=
30
)
# Biggers ticks, bigger ticks label!
# Setting axes 1
axes
[
1
].
set_title
(
"
Tabulated force
"
,
fontsize
=
30
)
axes
[
1
].
legend
(
frameon
=
False
,
fontsize
=
30
)
# Fat font, no frame
axes
[
1
].
set_xlabel
(
"
r [A]
"
,
fontname
=
"
Hack
"
,
fontsize
=
30
)
# ylabel name, font is Hack, size 30pts
axes
[
1
].
set_ylabel
(
"
F [kcal/mol/A]
"
,
fontname
=
"
Hack
"
,
fontsize
=
30
)
# ylabel name, font is Hack, size 30pts
axes
[
1
].
tick_params
(
axis
=
'
both
'
,
which
=
'
major
'
,
labelsize
=
30
)
# Biggers ticks, bigger ticks label!
plt
.
subplots_adjust
(
wspace
=
0.3
)
plt
.
show
()
if
args
.
extract
:
for
tp
in
toplot
:
outfile
=
""
.
join
([
tp
[
3
],
'
.plot
'
])
logging
.
info
(
"
Writing file {}
"
.
format
(
outfile
))
with
open
(
outfile
,
'
w
'
)
as
f
:
f
.
write
(
"
# {} force extracted from {}
\n
"
.
format
(
tp
[
3
],
infile
))
f
.
write
(
"
# {:^20} {:^20} {:^20}
\n
"
.
format
(
'
r
'
,
'
energy
'
,
'
force
'
))
for
a
,
b
,
c
in
zip
(
tp
[
0
],
tp
[
1
],
tp
[
2
]):
f
.
write
(
"
{:>18.16e} {:>18.16e} {:>18.16e}
\n
"
.
format
(
a
,
b
,
c
))
return
if
__name__
==
"
__main__
"
:
try
:
main
()
except
KeyboardInterrupt
:
raise
SystemExit
(
"
User interruption.
"
)
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