Skip to content

Commit 913d0e5

Browse files
authored
V0.4.0 (#175)
* reexport Xtals; matter, box, crystal * finished (?) split of Xtals code * final source changes * won't build until Xtals v0.3.0 * re-attempt * easy access to long GCMC tests * registry lag workaround * release v0.4 * physical constants * GLOBALS, bugfixes
1 parent e4e8ea2 commit 913d0e5

30 files changed

+247
-3368
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
*.jld2
99
docs/build/
1010
docs/site/
11-
*checkpoint.ipynb
11+
*checkpoint.ipynb
12+
.vscode
13+
Manifest.toml

.travis.yml

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: julia
22

3-
coveralls: true
3+
codecov: true
44

55
julia:
6-
- 1.5
6+
- 1.6
77

88
addons:
99
apt:
@@ -13,20 +13,13 @@ addons:
1313
sudo: enabled
1414

1515
script:
16-
- julia --project --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test("PorousMaterials")'
16+
- julia --project -e 'ENV["JULIA_PKG_SERVER"] = ""; import Pkg; Pkg.update()'
17+
- julia --project --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test("PorousMaterials")'
1718

1819
after_success:
19-
- julia --project -e 'import Pkg; Pkg.add("Documenter")'
20-
- julia --project ./docs/make.jl
20+
- julia --project -e 'import Pkg; Pkg.add("Documenter"); Pkg.add("Coverage")'
21+
- julia --project -e 'using Coverage; Codecov.submit(process_folder())'
22+
- julia --project ./docs/make.jl
2123

2224
notifications:
2325
email: true
24-
slack:
25-
rooms:
26-
- secure: YydV4a8we+y26g/dlKsPFhXTOqJ7Q755YGOtGB19vo3JnG6QJ22DOQxF2+cMN3YMKRlwE1BhW6sB8Vd6BbfU4mPw8VXaSjnckLp4C48K6vxpX21gpeajFawaxAeyUPOp8KJZyKjNWGpz2UxNXv/f0V1iIGKs4ZJ0J3kg4/kMZvpOD+DiYoR6JN1xtu1yPbY67DogUB2LPfK1k/uiyaN166dzelVZtj1+bO3lKveBfB0KcI0HaUtRnnIzvZ65ZiuGJeTIFXoWl0MaKxlp4Nw5W3lz5pTbjmbBxtfpZBBz/70dNnUzbcpBzRiRRrkDu7bPT25ZgqS3ynHNaGH2LmLiv2T9/9A6Rqc6u/H8vfcBxNIbq+NHwUFQiNttLXtnsz20GOpVizfLvdM2s0/iZfP90ONtn/4o0/XGo5+dzYLMJvhh3osjKEx/O+fdNUVQJYHdg+aXnvEpcmwH7HGuDFJEIztwbjZNOoVgiDA3vf+H1bnFlKQV8mqmLygQ7k13iceQ2emEqxgaaaM52w4V3WiDDtdllILn6k3LVixERJv54OBzDjN0nvCXTYAFDnkTX8rvrZ+ieMb9CORd5ONBXl6MHWfbjFijdpQ973t2u7kxeOeggsk0S2vjSrw5IuuB+CfeyuLnKLurZ1H0fXywpUuhD22bhoSR0JZCJU3dCrjtmFc=
27-
on_success: always
28-
on_failure: always
29-
template:
30-
- "Repo `%{repository_slug}` *%{result}* build (<%{build_url}|#%{build_number}>) for commit (<%{compare_url}|%{commit}>) on branch `%{branch}`."
31-
- "Execution time: *%{duration}*"
32-
- "Message: %{message}"

Project.toml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name = "PorousMaterials"
22
uuid = "68953c7c-a3c7-538e-83d3-73516288599e"
33
authors = ["SimonEnsemble <[email protected]>"]
4-
version = "0.3.1"
4+
version = "0.4.0"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
88
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
99
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
10+
FIGlet = "3064a664-84fe-4d92-92c7-ed492f3d8fae"
1011
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
1112
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1213
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
@@ -18,13 +19,17 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1819
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
1920
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
2021
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
22+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2123
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
2224
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2325
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2426
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
2527
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
28+
Xtals = "ede5f01d-793e-4c47-9885-c447d1f18d6d"
2629

2730
[compat]
31+
FIGlet = "^0.2.1"
32+
JLD2 = "^0.4.9"
2833
CSV = "^0.8.0"
2934
DataFrames = "^0.22.1"
3035
FileIO = "1.2.0"
@@ -36,7 +41,8 @@ ProgressMeter = "1.2.0"
3641
Roots = "0.8.4"
3742
SpecialFunctions = "0.10.0"
3843
StatsBase = "0.32.0,0.33.8"
39-
julia = "1.5,1.6"
44+
Xtals = "0.3.0"
45+
julia = "1.6"
4046

4147
[extras]
4248
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

run_gcmc_long.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/env bash
2+
3+
julia -p 24 -e '
4+
using Distributed
5+
@everywhere begin
6+
import Pkg
7+
Pkg.activate(".")
8+
end
9+
#Pkg.test("PorousMaterials")
10+
@info "Running test/gcmc_long.jl on $(length(workers())) workers."
11+
@warn "This will take HOURS!"
12+
cd("test")
13+
include("gcmc_long.jl")
14+
@info "Long GCMC tests complete!"
15+
'

src/PorousMaterials.jl

+23-152
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,19 @@
11
module PorousMaterials
22

3-
using CSV
4-
using DataFrames
5-
using Roots # for fzero
6-
using OffsetArrays # used for Ewald sum
7-
using SpecialFunctions # for erfc
8-
using StatsBase
9-
using ProgressMeter
10-
using Polynomials
11-
using JLD2
12-
using Statistics
13-
using Printf
14-
using LinearAlgebra
15-
using LightGraphs
16-
using Distributed
17-
using Optim
18-
using PyCall
19-
# import Base.push!
20-
#
21-
22-
# atoms are considered to overlap if this close.
23-
const R²_OVERLAP = 0.1 # Units: Angstrom²
24-
25-
"""
26-
print_file_paths()
27-
28-
print off paths where PorousMaterials.jl looks for input files and writes output files.
29-
"""
30-
function print_file_paths()
31-
println("general data folder: ", PATH_TO_DATA)
32-
println("\tcrystal structures (.cif, .cssr): ", PATH_TO_CRYSTALS)
33-
println("\tforce field files (.csv): ", PATH_TO_FORCEFIELDS)
34-
println("\tmolecule input files: ", PATH_TO_MOLECULES)
35-
println("\tsimulation output files: ", PATH_TO_SIMS)
36-
println("\tgrids (.cube): ", PATH_TO_GRIDS)
37-
end
3+
using Roots, OffsetArrays, SpecialFunctions, StatsBase, ProgressMeter, Polynomials,
4+
JLD2, Statistics, Distributed, Optim, Printf, DataFrames, LightGraphs, CSV, LinearAlgebra
385

39-
"""
40-
set_path_to_data(path; print_paths=true)
41-
42-
Set the path variables: `PATH_TO_DATA`, `PATH_TO_CRYSTALS`, `PATH_TO_FORCEFIELDS`, `PATH_TO_MOLECULES`,
43-
`PATH_TO_GRIDS`, and `PATH_TO_SIMS`. The latter five paths are set relative to the root data path.
44-
45-
# Arguments
46-
- `path::String`: the absolute path to the root of the data directory.
47-
- `print_paths::Bool`: set false to suppress printing of path values.
48-
"""
49-
function set_path_to_data(path::String; print_paths::Bool=true)
50-
global PATH_TO_DATA = path
51-
global PATH_TO_CRYSTALS = joinpath(PATH_TO_DATA, "crystals")
52-
global PATH_TO_FORCEFIELDS = joinpath(PATH_TO_DATA, "forcefields")
53-
global PATH_TO_MOLECULES = joinpath(PATH_TO_DATA, "molecules")
54-
global PATH_TO_GRIDS = joinpath(PATH_TO_DATA, "grids")
55-
global PATH_TO_SIMS = joinpath(PATH_TO_DATA, "simulations")
56-
57-
if print_paths
58-
print_file_paths()
59-
end
60-
end
6+
# extend Xtals
7+
using Reexport
8+
@reexport using Xtals
9+
import Xtals.Cart, Xtals.Frac, Xtals.write_xyz
6110

62-
"""
63-
set_default_file_paths(print_paths=true)
64-
65-
sets the default paths for where input files and some output files are stored.
66-
to see current set up, call [`print_file_paths`](@ref)
67-
"""
68-
function set_default_file_paths(;print_paths::Bool=true)
69-
# this is the main directory where crystal structures, forcefields, and molecules data is stored
70-
global PATH_TO_DATA = joinpath(pwd(), "data")
71-
72-
global PATH_TO_CRYSTALS = joinpath(PATH_TO_DATA, "crystals")
73-
global PATH_TO_FORCEFIELDS = joinpath(PATH_TO_DATA, "forcefields")
74-
global PATH_TO_MOLECULES = joinpath(PATH_TO_DATA, "molecules")
75-
global PATH_TO_GRIDS = joinpath(PATH_TO_DATA, "grids")
76-
global PATH_TO_SIMS = joinpath(PATH_TO_DATA, "simulations")
77-
78-
if print_paths
79-
print_file_paths()
80-
end
81-
end
11+
# physical constants
12+
const UNIV_GAS_CONST = 8.3144598e-5 # m³-bar/(K-mol)
13+
const K_TO_KJ_PER_MOL = 8.3144598e-3 # kJ/(mol-K)
14+
const BOLTZMANN = 1.38064852e7 # Boltmann constant (Pa-m3/K --> Pa-A3/K)
8215

83-
# this runs everytime porousmaterials is loaded, so if the user changes directory
84-
# then the path_to_data will change as well
85-
function __init__()
86-
set_default_file_paths(print_paths=false)
87-
end
88-
89-
# """
90-
# set_tutorial_mode()
91-
#
92-
# places porousmaterials in "tutorial mode". it changes the `path_to_data` variable to
93-
# the directory where the porousmaterials test data is stored. it can be used to
94-
# follow examples shown in the readme. it displays a warning so that the user knows
95-
# they are no longer using their own data.
96-
# """
97-
# function set_tutorial_mode()
98-
# new_path = joinpath(dirname(pathof(porousmaterials)), "..", "test", "data")
99-
# if ! isdir(new_path)
100-
# @error @sprintf("directory for testing data %s does not exist.\nnot entering tutorial mode.\n", new_path)
101-
# else
102-
# global path_to_data = new_path
103-
# global path_to_crystals = joinpath(path_to_data, "crystals")
104-
# global path_to_forcefields = joinpath(path_to_data, "forcefields")
105-
# global path_to_molecules = joinpath(path_to_data, "molecules")
106-
# global path_to_grids = joinpath(path_to_data, "grids")
107-
# @warn "porousmaterials is now in tutorial mode. you have access to the testing data to experiment with porousmaterials.\nto reset to default file paths, call `set_default_file_paths()`\n"
108-
# end
109-
# end
110-
#
111-
include("matter.jl")
112-
include("box.jl")
113-
include("distance.jl")
114-
include("misc.jl")
11516
include("isotherm_fitting.jl")
116-
include("crystal.jl")
117-
include("bonds.jl")
11817
include("forcefield.jl")
11918
include("molecule.jl")
12019
include("energy_utilities.jl")
@@ -125,48 +24,23 @@ include("grid.jl")
12524
include("eos.jl")
12625
include("henry.jl")
12726
include("gcmc.jl")
128-
# include("generic_rotations.jl")
12927
include("energy_min.jl")
28+
include("atomic_masses.jl")
13029

30+
function __init__()
31+
rc[:paths][:forcefields] = joinpath(rc[:paths][:data], "forcefields")
32+
rc[:paths][:molecules] = joinpath(rc[:paths][:data], "molecules")
33+
rc[:paths][:grids] = joinpath(rc[:paths][:data], "grids")
34+
rc[:paths][:sims] = joinpath(rc[:paths][:data], "simulations")
35+
append_atomic_masses()
36+
@debug "Environment variables" rc
37+
end
13138

132-
export
133-
# porousmaterials.jl
134-
print_file_paths, set_path_to_data,
135-
136-
# matter.jl
137-
Coords, Frac, Cart, Atoms, Charges, wrap!, neutral, net_charge, translate_by!, origin,
138-
139-
# box.jl
140-
Box, replicate, unit_cube, write_vtk, inside, fractional_coords, cartesian_coords,
141-
142-
# distance.jl
143-
nearest_image!, distance, overlap, remove_duplicates,
144-
145-
# misc.jl
146-
read_xyz, read_cpk_colors, write_xyz, read_atomic_masses,
14739

40+
export
14841
# isotherm_fitting.jl
14942
fit_adsorption_isotherm,
15043

151-
# crystal.jl
152-
Crystal, strip_numbers_from_atom_labels!, assign_charges,
153-
chemical_formula, molecular_weight, crystal_density, write_cif, has_charges,
154-
apply_symmetry_operations,
155-
156-
# bonds.jl
157-
infer_bonds!, write_bond_information, BondingRule, bond_sanity_check, remove_bonds!,
158-
infer_geometry_based_bonds!, cordero_covalent_atomic_radii,
159-
160-
# construct_box,
161-
# replicate, read_atomic_masses, charged, write_cif, assign_charges,
162-
# is_symmetry_equal, apply_symmetry_rules, assert_p1_symmetry, infer_bonds!,
163-
# remove_bonds!, compare_bonds_in_framework, wrap_atoms_to_unit_cell!,
164-
# write_bond_information, is_bonded, default_bondingrules, has_same_sets_of_atoms_and_charges,
165-
# distance, bond_sanity_check,
166-
#
167-
# # FrameworkOperations.jl
168-
# partition_framework, subtract_atoms,
169-
#
17044
# molecule.jl
17145
Molecule, translate_by!, translate_to!, random_rotation!, random_rotation_matrix, ion, distortion,
17246

@@ -189,20 +63,17 @@ export
18963
# Grid.jl
19064
apply_periodic_boundary_condition!,
19165
Grid, write_cube, read_cube, energy_grid, compute_accessibility_grid, accessible,
192-
required_n_pts, xf_to_id, id_to_xf, update_density!, find_energy_minimum,
193-
#
66+
required_n_pts, xf_to_id, id_to_xf, update_density!, find_energy_minimum, origin,
67+
19468
# EOS.jl
19569
calculate_properties, PengRobinsonFluid, VdWFluid,
19670

19771
# gcmc.jl
19872
μVT_sim, adsorption_isotherm, stepwise_adsorption_isotherm,
19973
μVT_output_filename, GCMCstats, MarkovCounts, isotherm_sim_results_to_dataframe,
200-
#
74+
20175
# henry.jl
20276
henry_coefficient, henry_result_savename,
203-
#
204-
# # generic_rotations.jl
205-
# rotation_matrix
20677

20778
# energy_min.jl
20879
find_energy_minimum, find_energy_minimum_gridsearch

src/atomic_masses.jl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# add atom types to rc[:atomic_masses] for contextual LJ potentials
2+
function append_atomic_masses()
3+
rc[:atomic_masses] = merge(rc[:atomic_masses], Dict(
4+
:N_in_N2 => 14.0067,
5+
:CH2 => 14.025,
6+
:CH3 => 15.035,
7+
:CH4 => 16.04,
8+
:C_b => 12.0107,
9+
:C_tol => 12.0107,
10+
:C_ac => 12.0107,
11+
:C_RCOO => 12.0107,
12+
:C_sp2 => 12.0107,
13+
:C_sp3 => 12.0107,
14+
:C_CO2 => 12.0107,
15+
:H_H2S => 1.00794,
16+
:H_b => 1.00794,
17+
:O_RCOO => 15.9994,
18+
:O_CO2 => 15.9994,
19+
:O_zeo => 15.9994,
20+
:S_H2S => 32.065,
21+
:Si_zeo => 28.0855,
22+
:X => 1.0
23+
))
24+
end

0 commit comments

Comments
 (0)