Skip to content

Commit

Permalink
V0.4.0 (#175)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eahenle authored Jun 11, 2021
1 parent e4e8ea2 commit 913d0e5
Show file tree
Hide file tree
Showing 30 changed files with 247 additions and 3,368 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
*.jld2
docs/build/
docs/site/
*checkpoint.ipynb
*checkpoint.ipynb
.vscode
Manifest.toml
21 changes: 7 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: julia

coveralls: true
codecov: true

julia:
- 1.5
- 1.6

addons:
apt:
Expand All @@ -13,20 +13,13 @@ addons:
sudo: enabled

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

after_success:
- julia --project -e 'import Pkg; Pkg.add("Documenter")'
- julia --project ./docs/make.jl
- julia --project -e 'import Pkg; Pkg.add("Documenter"); Pkg.add("Coverage")'
- julia --project -e 'using Coverage; Codecov.submit(process_folder())'
- julia --project ./docs/make.jl

notifications:
email: true
slack:
rooms:
- secure: YydV4a8we+y26g/dlKsPFhXTOqJ7Q755YGOtGB19vo3JnG6QJ22DOQxF2+cMN3YMKRlwE1BhW6sB8Vd6BbfU4mPw8VXaSjnckLp4C48K6vxpX21gpeajFawaxAeyUPOp8KJZyKjNWGpz2UxNXv/f0V1iIGKs4ZJ0J3kg4/kMZvpOD+DiYoR6JN1xtu1yPbY67DogUB2LPfK1k/uiyaN166dzelVZtj1+bO3lKveBfB0KcI0HaUtRnnIzvZ65ZiuGJeTIFXoWl0MaKxlp4Nw5W3lz5pTbjmbBxtfpZBBz/70dNnUzbcpBzRiRRrkDu7bPT25ZgqS3ynHNaGH2LmLiv2T9/9A6Rqc6u/H8vfcBxNIbq+NHwUFQiNttLXtnsz20GOpVizfLvdM2s0/iZfP90ONtn/4o0/XGo5+dzYLMJvhh3osjKEx/O+fdNUVQJYHdg+aXnvEpcmwH7HGuDFJEIztwbjZNOoVgiDA3vf+H1bnFlKQV8mqmLygQ7k13iceQ2emEqxgaaaM52w4V3WiDDtdllILn6k3LVixERJv54OBzDjN0nvCXTYAFDnkTX8rvrZ+ieMb9CORd5ONBXl6MHWfbjFijdpQ973t2u7kxeOeggsk0S2vjSrw5IuuB+CfeyuLnKLurZ1H0fXywpUuhD22bhoSR0JZCJU3dCrjtmFc=
on_success: always
on_failure: always
template:
- "Repo `%{repository_slug}` *%{result}* build (<%{build_url}|#%{build_number}>) for commit (<%{compare_url}|%{commit}>) on branch `%{branch}`."
- "Execution time: *%{duration}*"
- "Message: %{message}"
10 changes: 8 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name = "PorousMaterials"
uuid = "68953c7c-a3c7-538e-83d3-73516288599e"
authors = ["SimonEnsemble <[email protected]>"]
version = "0.3.1"
version = "0.4.0"

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

[compat]
FIGlet = "^0.2.1"
JLD2 = "^0.4.9"
CSV = "^0.8.0"
DataFrames = "^0.22.1"
FileIO = "1.2.0"
Expand All @@ -36,7 +41,8 @@ ProgressMeter = "1.2.0"
Roots = "0.8.4"
SpecialFunctions = "0.10.0"
StatsBase = "0.32.0,0.33.8"
julia = "1.5,1.6"
Xtals = "0.3.0"
julia = "1.6"

[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
15 changes: 15 additions & 0 deletions run_gcmc_long.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/env bash

julia -p 24 -e '
using Distributed
@everywhere begin
import Pkg
Pkg.activate(".")
end
#Pkg.test("PorousMaterials")
@info "Running test/gcmc_long.jl on $(length(workers())) workers."
@warn "This will take HOURS!"
cd("test")
include("gcmc_long.jl")
@info "Long GCMC tests complete!"
'
175 changes: 23 additions & 152 deletions src/PorousMaterials.jl
Original file line number Diff line number Diff line change
@@ -1,120 +1,19 @@
module PorousMaterials

using CSV
using DataFrames
using Roots # for fzero
using OffsetArrays # used for Ewald sum
using SpecialFunctions # for erfc
using StatsBase
using ProgressMeter
using Polynomials
using JLD2
using Statistics
using Printf
using LinearAlgebra
using LightGraphs
using Distributed
using Optim
using PyCall
# import Base.push!
#

# atoms are considered to overlap if this close.
const R²_OVERLAP = 0.1 # Units: Angstrom²

"""
print_file_paths()
print off paths where PorousMaterials.jl looks for input files and writes output files.
"""
function print_file_paths()
println("general data folder: ", PATH_TO_DATA)
println("\tcrystal structures (.cif, .cssr): ", PATH_TO_CRYSTALS)
println("\tforce field files (.csv): ", PATH_TO_FORCEFIELDS)
println("\tmolecule input files: ", PATH_TO_MOLECULES)
println("\tsimulation output files: ", PATH_TO_SIMS)
println("\tgrids (.cube): ", PATH_TO_GRIDS)
end
using Roots, OffsetArrays, SpecialFunctions, StatsBase, ProgressMeter, Polynomials,
JLD2, Statistics, Distributed, Optim, Printf, DataFrames, LightGraphs, CSV, LinearAlgebra

"""
set_path_to_data(path; print_paths=true)
Set the path variables: `PATH_TO_DATA`, `PATH_TO_CRYSTALS`, `PATH_TO_FORCEFIELDS`, `PATH_TO_MOLECULES`,
`PATH_TO_GRIDS`, and `PATH_TO_SIMS`. The latter five paths are set relative to the root data path.
# Arguments
- `path::String`: the absolute path to the root of the data directory.
- `print_paths::Bool`: set false to suppress printing of path values.
"""
function set_path_to_data(path::String; print_paths::Bool=true)
global PATH_TO_DATA = path
global PATH_TO_CRYSTALS = joinpath(PATH_TO_DATA, "crystals")
global PATH_TO_FORCEFIELDS = joinpath(PATH_TO_DATA, "forcefields")
global PATH_TO_MOLECULES = joinpath(PATH_TO_DATA, "molecules")
global PATH_TO_GRIDS = joinpath(PATH_TO_DATA, "grids")
global PATH_TO_SIMS = joinpath(PATH_TO_DATA, "simulations")

if print_paths
print_file_paths()
end
end
# extend Xtals
using Reexport
@reexport using Xtals
import Xtals.Cart, Xtals.Frac, Xtals.write_xyz

"""
set_default_file_paths(print_paths=true)
sets the default paths for where input files and some output files are stored.
to see current set up, call [`print_file_paths`](@ref)
"""
function set_default_file_paths(;print_paths::Bool=true)
# this is the main directory where crystal structures, forcefields, and molecules data is stored
global PATH_TO_DATA = joinpath(pwd(), "data")

global PATH_TO_CRYSTALS = joinpath(PATH_TO_DATA, "crystals")
global PATH_TO_FORCEFIELDS = joinpath(PATH_TO_DATA, "forcefields")
global PATH_TO_MOLECULES = joinpath(PATH_TO_DATA, "molecules")
global PATH_TO_GRIDS = joinpath(PATH_TO_DATA, "grids")
global PATH_TO_SIMS = joinpath(PATH_TO_DATA, "simulations")

if print_paths
print_file_paths()
end
end
# physical constants
const UNIV_GAS_CONST = 8.3144598e-5 # m³-bar/(K-mol)
const K_TO_KJ_PER_MOL = 8.3144598e-3 # kJ/(mol-K)
const BOLTZMANN = 1.38064852e7 # Boltmann constant (Pa-m3/K --> Pa-A3/K)

# this runs everytime porousmaterials is loaded, so if the user changes directory
# then the path_to_data will change as well
function __init__()
set_default_file_paths(print_paths=false)
end

# """
# set_tutorial_mode()
#
# places porousmaterials in "tutorial mode". it changes the `path_to_data` variable to
# the directory where the porousmaterials test data is stored. it can be used to
# follow examples shown in the readme. it displays a warning so that the user knows
# they are no longer using their own data.
# """
# function set_tutorial_mode()
# new_path = joinpath(dirname(pathof(porousmaterials)), "..", "test", "data")
# if ! isdir(new_path)
# @error @sprintf("directory for testing data %s does not exist.\nnot entering tutorial mode.\n", new_path)
# else
# global path_to_data = new_path
# global path_to_crystals = joinpath(path_to_data, "crystals")
# global path_to_forcefields = joinpath(path_to_data, "forcefields")
# global path_to_molecules = joinpath(path_to_data, "molecules")
# global path_to_grids = joinpath(path_to_data, "grids")
# @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"
# end
# end
#
include("matter.jl")
include("box.jl")
include("distance.jl")
include("misc.jl")
include("isotherm_fitting.jl")
include("crystal.jl")
include("bonds.jl")
include("forcefield.jl")
include("molecule.jl")
include("energy_utilities.jl")
Expand All @@ -125,48 +24,23 @@ include("grid.jl")
include("eos.jl")
include("henry.jl")
include("gcmc.jl")
# include("generic_rotations.jl")
include("energy_min.jl")
include("atomic_masses.jl")

function __init__()
rc[:paths][:forcefields] = joinpath(rc[:paths][:data], "forcefields")
rc[:paths][:molecules] = joinpath(rc[:paths][:data], "molecules")
rc[:paths][:grids] = joinpath(rc[:paths][:data], "grids")
rc[:paths][:sims] = joinpath(rc[:paths][:data], "simulations")
append_atomic_masses()
@debug "Environment variables" rc
end

export
# porousmaterials.jl
print_file_paths, set_path_to_data,

# matter.jl
Coords, Frac, Cart, Atoms, Charges, wrap!, neutral, net_charge, translate_by!, origin,

# box.jl
Box, replicate, unit_cube, write_vtk, inside, fractional_coords, cartesian_coords,

# distance.jl
nearest_image!, distance, overlap, remove_duplicates,

# misc.jl
read_xyz, read_cpk_colors, write_xyz, read_atomic_masses,

export
# isotherm_fitting.jl
fit_adsorption_isotherm,

# crystal.jl
Crystal, strip_numbers_from_atom_labels!, assign_charges,
chemical_formula, molecular_weight, crystal_density, write_cif, has_charges,
apply_symmetry_operations,

# bonds.jl
infer_bonds!, write_bond_information, BondingRule, bond_sanity_check, remove_bonds!,
infer_geometry_based_bonds!, cordero_covalent_atomic_radii,

# construct_box,
# replicate, read_atomic_masses, charged, write_cif, assign_charges,
# is_symmetry_equal, apply_symmetry_rules, assert_p1_symmetry, infer_bonds!,
# remove_bonds!, compare_bonds_in_framework, wrap_atoms_to_unit_cell!,
# write_bond_information, is_bonded, default_bondingrules, has_same_sets_of_atoms_and_charges,
# distance, bond_sanity_check,
#
# # FrameworkOperations.jl
# partition_framework, subtract_atoms,
#
# molecule.jl
Molecule, translate_by!, translate_to!, random_rotation!, random_rotation_matrix, ion, distortion,

Expand All @@ -189,20 +63,17 @@ export
# Grid.jl
apply_periodic_boundary_condition!,
Grid, write_cube, read_cube, energy_grid, compute_accessibility_grid, accessible,
required_n_pts, xf_to_id, id_to_xf, update_density!, find_energy_minimum,
#
required_n_pts, xf_to_id, id_to_xf, update_density!, find_energy_minimum, origin,

# EOS.jl
calculate_properties, PengRobinsonFluid, VdWFluid,

# gcmc.jl
μVT_sim, adsorption_isotherm, stepwise_adsorption_isotherm,
μVT_output_filename, GCMCstats, MarkovCounts, isotherm_sim_results_to_dataframe,
#

# henry.jl
henry_coefficient, henry_result_savename,
#
# # generic_rotations.jl
# rotation_matrix

# energy_min.jl
find_energy_minimum, find_energy_minimum_gridsearch
Expand Down
24 changes: 24 additions & 0 deletions src/atomic_masses.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# add atom types to rc[:atomic_masses] for contextual LJ potentials
function append_atomic_masses()
rc[:atomic_masses] = merge(rc[:atomic_masses], Dict(
:N_in_N2 => 14.0067,
:CH2 => 14.025,
:CH3 => 15.035,
:CH4 => 16.04,
:C_b => 12.0107,
:C_tol => 12.0107,
:C_ac => 12.0107,
:C_RCOO => 12.0107,
:C_sp2 => 12.0107,
:C_sp3 => 12.0107,
:C_CO2 => 12.0107,
:H_H2S => 1.00794,
:H_b => 1.00794,
:O_RCOO => 15.9994,
:O_CO2 => 15.9994,
:O_zeo => 15.9994,
:S_H2S => 32.065,
:Si_zeo => 28.0855,
:X => 1.0
))
end
Loading

0 comments on commit 913d0e5

Please sign in to comment.