Skip to content

Commit 6ac5482

Browse files
committed
simplify part 2 of tutorial 2
1 parent 282061c commit 6ac5482

23 files changed

Lines changed: 1898 additions & 456 deletions

files/tutorial2/.manifest

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,28 @@
66
# the first file will be automatically loaded
77
unbreakable.lmp
88
unbreakable.data
9+
unbreakable.inc
910
breakable.lmp
1011
breakable.data
11-
parameters.inc
1212

1313
# 2) solution files
1414
# only downloaded on request
15-
solution/parameters.inc
1615
solution/unbreakable.lmp
1716
solution/unbreakable.data
1817
solution/unbreakable.yaml
1918
solution/unbreakable.log
20-
solution/stress-strain.dat
19+
solution/unbreakable.inc
20+
solution/unbreakable.png
21+
solution/unbreakable.dat
22+
solution/unbreakable-yaml-reader.py
23+
solution/breakable.lmp
24+
solution/breakable.data
25+
solution/breakable.yaml
26+
solution/breakable.log
27+
solution/breakable.png
28+
solution/breakable.dat
29+
solution/breakable-yaml-reader.py
2130

2231
# 3) support files
23-
yaml-reader.py
32+
unbreakable-yaml-reader.py
2433
CH.airebo

files/tutorial2/breakable.lmp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ group rdel region rdel
2626
delete_atoms random fraction 0.02 no rdel NULL 482793
2727

2828
reset_atoms id sort yes
29-
velocity cnt_mid create ${T} 48455 mom yes rot yes
30-
fix mynve all nve
31-
compute Tmid cnt_mid temp
32-
fix myber cnt_mid temp/berendsen ${T} ${T} 0.1
33-
fix_modify myber temp Tmid
29+
velocity cnt_mid create 300 48455 mom yes rot yes
30+
31+
fix mynve1 cnt_top nve
32+
fix mynve2 cnt_bot nve
33+
fix mynvt cnt_mid nvt temp 300 300 0.1
3434

3535
run 0 post no
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
units metal
3+
atom_style molecular
4+
boundary f f f
5+
pair_style lj/cut 14
6+
bond_style harmonic
7+
angle_style harmonic
8+
dihedral_style opls
9+
improper_style harmonic
10+
read_data unbreakable.data extra/bond/per/atom 10 extra/special/per/atom 10
11+
include parameters.inc
12+
13+
pair_style airebo 3.0 1 1
14+
pair_coeff * * CH.airebo C
15+
bond_style zero
16+
bond_coeff 1 1.4
17+
delete_bonds all angle 1
18+
delete_bonds all dihedral 1
19+
delete_bonds all improper 1 remove special
20+
21+
angle_style none
22+
dihedral_style none
23+
improper_style none
24+
25+
special_bonds lj/coul 1.0 1.0 1.0
26+
group carbon_atoms type 1
27+
28+
variable xmax equal bound(carbon_atoms,xmax)-0.5
29+
variable xmin equal bound(carbon_atoms,xmin)+0.5
30+
region rtop block ${xmax} INF INF INF INF INF
31+
region rbot block INF ${xmin} INF INF INF INF
32+
region rmid block ${xmin} ${xmax} INF INF INF INF
33+
34+
group cnt_top region rtop
35+
group cnt_bot region rbot
36+
group cnt_mid region rmid
37+
38+
velocity cnt_mid create 300 48455 mom yes rot yes
39+
40+
fix mynve1 cnt_top nve
41+
fix mynve2 cnt_bot nve
42+
fix mynvt cnt_mid nvt temp 300 300 0.1
43+
44+
fix mysf1 cnt_bot setforce 0 0 0
45+
fix mysf2 cnt_top setforce 0 0 0
46+
velocity cnt_bot set 0 0 0
47+
velocity cnt_top set 0 0 0
48+
49+
variable Lcnt equal xcm(cnt_top,x)-xcm(cnt_bot,x)
50+
variable Fcnt equal f_mysf1[1]-f_mysf2[1]
51+
52+
dump viz all image 500 myimage-*.ppm element type size 1000 400 zoom 4 shiny 0.3 fsaa yes bond atom 0.8 view 0 90 box no 0.0 axes no 0.0 0.0
53+
dump_modify viz pad 9 backcolor white element C adiam 1 0.85 bdiam 1 1.0
54+
55+
fix break all bond/break 1000 1 2.5
56+
fix form all bond/create/angle 1000 1 1 2.0 1 aconstrain 90.0 180
57+
58+
compute Tmid cnt_mid temp
59+
thermo 100
60+
thermo_style custom step temp etotal v_Lcnt v_Fcnt
61+
thermo_modify temp Tmid line yaml
62+
63+
timestep 0.0005
64+
run 10000
65+
66+
velocity cnt_top set 0.75 0 0
67+
velocity cnt_bot set -0.75 0 0
68+
69+
run 30000
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
import re
3+
import yaml
4+
5+
# Import the data from the yaml file
6+
pattern = r"^(keywords:.*$|data:$|---$|\.\.\.$| - \[.*\]$)"
7+
docs = ""
8+
with open("breakable.yaml") as f:
9+
for line in f:
10+
m = re.search(pattern, line)
11+
if m:
12+
docs += m.group(0) + "\n"
13+
thermo = list(yaml.load_all(docs, Loader=yaml.CSafeLoader))
14+
15+
# Read basic information
16+
print("Number of runs: ", len(thermo))
17+
print("All info:", thermo[1]['keywords'])
18+
19+
# Read the data from the second run, and save it.
20+
Force = []
21+
Length = []
22+
for line in thermo[1]["data"]:
23+
_, _, _, L, F = line
24+
Force.append(F)
25+
Length.append(L)
26+
Force = np.array(Force)
27+
Length = np.array(Length)
28+
29+
# Calculate the stress and the strain from the Force and Length
30+
Area = np.pi*5.2**2 # Angstrom^2
31+
Stress = Force/Area # eV/Angstrom^3
32+
Strain = 100*(Length-Length[0])/Length[0] # in percents
33+
34+
np.savetxt("breakable.dat", np.vstack([Strain, Stress]).T)

0 commit comments

Comments
 (0)