diff --git a/PMlogo.png b/PMlogo.png old mode 100644 new mode 100755 index 63e44f912..13e020746 Binary files a/PMlogo.png and b/PMlogo.png differ diff --git a/src/Forcefield.jl b/src/Forcefield.jl index c42f6b4ad..ec3379a36 100644 --- a/src/Forcefield.jl +++ b/src/Forcefield.jl @@ -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 diff --git a/src/Molecules.jl b/src/Molecules.jl index 4604963fe..942b98b68 100644 --- a/src/Molecules.jl +++ b/src/Molecules.jl @@ -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 ### @@ -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 ### @@ -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) @@ -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) diff --git a/src/PorousMaterials.jl b/src/PorousMaterials.jl index 5acc38bb5..85e85adf1 100644 --- a/src/PorousMaterials.jl +++ b/src/PorousMaterials.jl @@ -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") @@ -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 diff --git a/test/gcmc_test.jl b/test/gcmc_test.jl index c7a833f39..2003698a8 100644 --- a/test/gcmc_test.jl +++ b/test/gcmc_test.jl @@ -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 diff --git a/test/path_test.jl b/test/path_test.jl new file mode 100644 index 000000000..6cf7bf8ea --- /dev/null +++ b/test/path_test.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index a6dbbc384..38debd395 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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")