Skip to content

Commit

Permalink
Merge branch 'master' into henry_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEnsemble committed Sep 13, 2018
2 parents aad4667 + efb350c commit e0f39ea
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 42 deletions.
Binary file modified PMlogo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Forcefield.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function check_forcefield_coverage(f_or_m::Union{Framework, Molecule}, ljff::LJF
all_covered = true
for species in unique_species
if !(species in keys(ljff.pure_ϵ))
@warn @sprintf("\t%s in %s missing from %s force field.", species,
@warn @sprintf("\t%s in %s missing from %s force field.", species,
isa(f_or_m, Framework) ? f_or_m.name : f_or_m.species, ljff.name)
all_covered = false
end
Expand Down
8 changes: 4 additions & 4 deletions src/Molecules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Molecule(species::AbstractString; assert_charge_neutrality::Bool=true)
error(@sprintf("No directory created for %s in %s\n", species,
PATH_TO_DATA * "molecules/"))
end

###
# Read in Lennard Jones spheres
###
Expand Down Expand Up @@ -73,7 +73,7 @@ function Molecule(species::AbstractString; assert_charge_neutrality::Bool=true)
x_com /= total_mass
# construct atoms attribute of molecule
atoms = Atoms(atom_species, atom_coords)

###
# Read in point charges
###
Expand All @@ -94,7 +94,7 @@ function Molecule(species::AbstractString; assert_charge_neutrality::Bool=true)
end
# construct charges attribute of molecule
charges = Charges(charge_vals, charge_coords)

# construct molecule
molecule = Molecule(Symbol(species), atoms, charges, x_com)

Expand Down Expand Up @@ -399,5 +399,5 @@ end
Ion(q::Float64, xf::Array{Float64, 1}, species::Symbol=:ion) = Molecule(
species,
Atoms(0, Symbol[], zeros(0, 0)),
Charges(1, [q], reshape(xf, (3, 1))),
Charges(1, [q], reshape(xf, (3, 1))),
xf)
129 changes: 93 additions & 36 deletions src/PorousMaterials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,60 @@ import Base.push!
function __init__()
# this is the directory where crystal structures, forcefields, and molecules data is stored
global PATH_TO_DATA = pwd() * "/data/"
if ! isdir(PATH_TO_DATA)
@warn @sprintf("Directory for input data, \"/data/\", not found in present working directory, %s\nChange the PATH_TO_DATA variable to load input files from a different directory. See \"set_path_to_data()\".\n", pwd())
end
end

"""
set_path_to_data("user/path/to/data")
set_path_to_data()
Sets PorousMaterials PATH_TO_DATA variable which dictates where crystal, forcefield,
and molecule files are loaded from. This function allows the user to set PATH_TO_DATA
manually to any directory or to a "/data/" folder within their current directory.
This function WILL change the PATH_TO_DATA regardless of whether or not the path
exists, but will give a warning alerting the user that PorousMaterials cannot load
files from the chosen path.
# Arguments
- `new_path_to_data::String`: The desired PATH_TO_DATA in string form.
"""
function set_path_to_data(new_path_to_data::String)
if new_path_to_data[end] != '/'
new_path_to_data = new_path_to_data * "/"
end
global PATH_TO_DATA = new_path_to_data
if ! isdir(PATH_TO_DATA)
@warn @sprintf("The directory %s does not exist.\nChange the PATH_TO_DATA variable to load input files from a different directory. See \"set_path_to_data()\".\n", new_path_to_data)
end
@printf("PATH_TO_DATA set to %s\n", PATH_TO_DATA)
end

function set_path_to_data()
global PATH_TO_DATA = pwd() * "/data/"
if ! isdir(PATH_TO_DATA)
@warn @sprintf("Directory for input data, \"/data/\", not found in present working directory, %s\nChange the PATH_TO_DATA variable to load input files from a different directory. See \"set_path_to_data()\".\n", pwd())
end
@printf("PATH_TO_DATA set to %s\n", PATH_TO_DATA)
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 = 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
@warn "PorousMaterials is now in Tutorial Mode. You have access to the testing data to experiment with PorousMaterials.\nTo get access to your own data use: reset_path_to_data()\n"
end
end

include("Box.jl")
Expand All @@ -39,54 +93,57 @@ include("Henry.jl")
include("GCMC.jl")

export
# Box.jl
Box, replicate, UnitCube, write_vtk,
# PorousMaterials.jl
set_path_to_data, set_tutorial_mode,

# Box.jl
Box, replicate, UnitCube, write_vtk,

# Matter.jl
Atoms, Charges,
# Matter.jl
Atoms, Charges,

# NearestImage.jl
nearest_image!, nearest_r², nearest_r,
# NearestImage.jl
nearest_image!, nearest_r², nearest_r,

# Misc.jl
read_xyz, read_cpk_colors, read_atomic_radii, write_xyz,
# Misc.jl
read_xyz, read_cpk_colors, read_atomic_radii, write_xyz,

# Crystal.jl
Framework, read_crystal_structure_file, remove_overlapping_atoms,
strip_numbers_from_atom_labels!, chemical_formula, molecular_weight, crystal_density,
construct_box, replicate, read_atomic_masses, charged, write_cif, assign_charges,
# Crystal.jl
Framework, read_crystal_structure_file, remove_overlapping_atoms,
strip_numbers_from_atom_labels!, chemical_formula, molecular_weight, crystal_density,
construct_box, replicate, read_atomic_masses, charged, write_cif, assign_charges,

# Molecules.jl
Molecule, set_fractional_coords!, translate_by!, outside_box, set_fractional_coords_to_unit_cube!,
translate_to!, rotate!, rotation_matrix, rand_point_on_unit_sphere, charged,
pairwise_atom_distances, pairwise_charge_distances, Ion, bond_length_drift,
# Molecules.jl
Molecule, set_fractional_coords!, translate_by!, outside_box, set_fractional_coords_to_unit_cube!,
translate_to!, rotate!, rotation_matrix, rand_point_on_unit_sphere, charged,
pairwise_atom_distances, pairwise_charge_distances, Ion, bond_length_drift,

# Forcefield.jl
LJForceField, replication_factors, check_forcefield_coverage,
# Forcefield.jl
LJForceField, replication_factors, check_forcefield_coverage,

# Energetics_Util.jl
PotentialEnergy, SystemPotentialEnergy,
# Energetics_Util.jl
PotentialEnergy, SystemPotentialEnergy,

# VdWEnergetics.jl
lennard_jones, vdw_energy, vdw_energy_no_PBC,
# VdWEnergetics.jl
lennard_jones, vdw_energy, vdw_energy_no_PBC,

# ElectrostaticEnergetics.jl
electrostatic_potential, electrostatic_potential_energy, precompute_kvec_wts, setup_Ewald_sum, total, Eikr,
# ElectrostaticEnergetics.jl
electrostatic_potential, electrostatic_potential_energy, precompute_kvec_wts, setup_Ewald_sum, total, Eikr,

# MChelpers.jl
insert_molecule!, delete_molecule!, translate_molecule!, reinsert_molecule!, rotatable,
# MChelpers.jl
insert_molecule!, delete_molecule!, translate_molecule!, reinsert_molecule!, rotatable,

# Grid.jl
apply_periodic_boundary_condition!,
Grid, write_cube, read_cube, energy_grid,
# Grid.jl
apply_periodic_boundary_condition!,
Grid, write_cube, read_cube, energy_grid,

# EOS.jl
calculate_properties, PengRobinsonGas,
# EOS.jl
calculate_properties, PengRobinsonGas,

# GCMC.jl
gcmc_simulation, adsorption_isotherm, stepwise_adsorption_isotherm,
gcmc_result_savename, GCMCstats, MarkovCounts,
# GCMC.jl
gcmc_simulation, adsorption_isotherm, stepwise_adsorption_isotherm,
gcmc_result_savename, GCMCstats, MarkovCounts,

# Henry.jl
henry_coefficient, henry_result_savename
# Henry.jl
henry_coefficient, henry_result_savename
end
2 changes: 1 addition & 1 deletion test/gcmc_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ if co2_tests

# make sure bond lenghts are preserved
bls = pairwise_atom_distances(co2, UnitCube())
results, molecules = gcmc_simulation(zif71, co2, 298.0, 1.0, ff,
results, molecules = gcmc_simulation(zif71, co2, 298.0, 1.0, ff,
n_burn_cycles=25, n_sample_cycles=25, verbose=false)
@printf("Testing that bond lenghts are preserved for %d molecules.\n", length(molecules))
for m in molecules
Expand Down
19 changes: 19 additions & 0 deletions test/path_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Path_Test

using PorousMaterials
using OffsetArrays
using LinearAlgebra
using Test
using JLD2
using Statistics
using Random

@testset "Path Tests" begin
set_tutorial_mode()
@test PorousMaterials.PATH_TO_DATA == dirname(pathof(PorousMaterials)) * "/../test/data/"
set_path_to_data(pwd())
@test PorousMaterials.PATH_TO_DATA == pwd() * "/"
set_path_to_data()
@test PorousMaterials.PATH_TO_DATA == pwd() * "/data/"
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ include("guest_guest_energetics_test.jl")
include("eos_test.jl")
include("gcmc_checkpoints_test.jl")
include("grid_test.jl")
include("path_test.jl")

0 comments on commit e0f39ea

Please sign in to comment.