diff --git a/examples/ACE-aHfO2/fit-ace-ahfo2.jl b/examples/ACE-aHfO2/fit-ace-ahfo2.jl index 67d740b0..429ffd2b 100644 --- a/examples/ACE-aHfO2/fit-ace-ahfo2.jl +++ b/examples/ACE-aHfO2/fit-ace-ahfo2.jl @@ -8,12 +8,12 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/ACE-aHfO2") -ds_path = "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" -res_path = "$path/results/"; +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" +res_path = "$base_path/examples/ACE-aHfO2/results/"; # Load utility functions. -include("$path/../utils/utils.jl") +include("$base_path/examples/utils/utils.jl") # Create experiment folder. run(`mkdir -p $res_path`); diff --git a/examples/DPP-ACE-Na/fit-dpp-ace-na.jl b/examples/DPP-ACE-Na/fit-dpp-ace-na.jl index fa7918a8..0e1c9db6 100644 --- a/examples/DPP-ACE-Na/fit-dpp-ace-na.jl +++ b/examples/DPP-ACE-Na/fit-dpp-ace-na.jl @@ -8,8 +8,8 @@ using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, Plots # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/DPP-ACE-Na") -ds_path = "$path/../data/Na/liquify_sodium.yaml"; +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/Na/liquify_sodium.yaml" # ## b. Load atomistic dataset and split it into training and test. diff --git a/examples/DPP-ACE-Si/fit-dpp-ace-si.jl b/examples/DPP-ACE-Si/fit-dpp-ace-si.jl index ed087c55..2d2e83ec 100644 --- a/examples/DPP-ACE-Si/fit-dpp-ace-si.jl +++ b/examples/DPP-ACE-Si/fit-dpp-ace-si.jl @@ -13,12 +13,12 @@ using CSV, JLD, DataFrames elname, elspec = "Si", [:Si] # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/DPP-ACE-Si") -inpath = "$path/../data/Si-3Body-LAMMPS/" -outpath = "$path/output/$elname/" +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +inpath = "$base_path/examples/data/Si-3Body-LAMMPS/" +outpath = "$base_path/examples/DPP-ACE-Si/output/$elname/"; # Load utility functions. -include("$path/subsampling_utils.jl") +include("$base_path/examples/DPP-ACE-Si/subsampling_utils.jl") # ## b. Load atomistic datasets. diff --git a/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl b/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl index 8b6f99dd..214633b5 100644 --- a/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl +++ b/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl @@ -8,12 +8,12 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/DPP-ACE-aHfO2-1") -ds_path = "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" -res_path = "$path/results/"; +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" +res_path = "$base_path/examples/DPP-ACE-aHfO2-1/results/"; # Load utility functions. -include("$path/../utils/utils.jl") +include("$base_path/examples/utils/utils.jl") # Create experiment folder. run(`mkdir -p $res_path`); diff --git a/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl b/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl index 577eb8bf..ad87cb19 100644 --- a/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl +++ b/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl @@ -1,5 +1,3 @@ -push!(Base.LOAD_PATH, "../../") - using LinearAlgebra, Random using Statistics, StatsBase, Distributions, Determinantal using Unitful, UnitfulAtomic @@ -8,11 +6,13 @@ using JLD, CairoMakie #################### Importing Data ################### -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/DPP-ACE-aHfO2") +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/a-HfO2/aHfO2_diverse_descriptors_3600.jld" +res_path = "$base_path/examples/DPP-ACE-aHfO2-2/results/"; # Import Raw Data energies, descriptors = JLD.load( - "$path/../data/aHfO2/aHfO2_diverse_descriptors_3600.jld", + ds_path, "energies", "descriptors", ) @@ -84,4 +84,4 @@ ax4 = Axis( ) scatter!(ax4, [length(c.B) - 32 for c in configs], ips, markersize = 4.0) -save("examples/aHfO2/figures/aHfO2_dpp_inclusion_probabilities.pdf", fig) +save("$res_path/figures/aHfO2_dpp_inclusion_probabilities.pdf", fig) diff --git a/examples/LJ-Ar/lennard-jones-ar.jl b/examples/LJ-Ar/lennard-jones-ar.jl index 7e5b52ec..edcc2e8f 100644 --- a/examples/LJ-Ar/lennard-jones-ar.jl +++ b/examples/LJ-Ar/lennard-jones-ar.jl @@ -8,8 +8,8 @@ using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, Plots, DisplayAs # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/LJ-Ar") -ds_path = "$path/../data/LJ-AR/lj-ar.yaml"; +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/LJ-AR/lj-ar.yaml" # ## b. Load atomistic dataset. ds, thermo = load_data(ds_path, YAML(:Ar, u"eV", u"Å")) diff --git a/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl b/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl index ee2cad43..c49bcab5 100644 --- a/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl +++ b/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl @@ -9,12 +9,12 @@ using LinearAlgebra, Random, DisplayAs using DataFrames, Hyperopt # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/Opt-ACE-aHfO2") -ds_path = "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" -res_path = "$path/results/"; +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" +res_path = "$base_path/examples/Opt-ACE-aHfO2/results/"; # Load utility functions. -include("$path/../utils/utils.jl") +include("$base_path/examples/utils/utils.jl") # Create experiment folder. run(`mkdir -p $res_path`); diff --git a/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl b/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl index 43eafca9..a7f73736 100644 --- a/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl +++ b/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl @@ -8,12 +8,12 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -path = joinpath(dirname(pathof(PotentialLearning)), "../examples/PCA-ACE-aHfO2") -ds_path = "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" -res_path = "$path/results/"; +base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" +res_path = "$base_path/examples/PCA-ACE-aHfO2/results/"; # Load utility functions. -include("$path/../utils/utils.jl") +include("$base_path/examples/utils/utils.jl") # Create experiment folder. run(`mkdir -p $res_path`); diff --git a/examples/utils/input.jl b/examples/utils/input.jl index f0400203..c042af86 100644 --- a/examples/utils/input.jl +++ b/examples/utils/input.jl @@ -1,5 +1,5 @@ # New function to read XYZ files ############################################### -include("$path/../utils/xyz.jl") +include("$base_path/examples/utils/xyz.jl") # New functions to get input parameters from OrderedDict ####################### diff --git a/examples/utils/utils.jl b/examples/utils/utils.jl index 3c9eb5ad..97265457 100644 --- a/examples/utils/utils.jl +++ b/examples/utils/utils.jl @@ -6,9 +6,9 @@ using ProgressBars using Plots using CSV -include("$path/../utils/input.jl") -include("$path/../utils/macros.jl") -include("$path/../utils/plots.jl") +include("$base_path/examples/utils/input.jl") +include("$base_path/examples/utils/macros.jl") +include("$base_path/examples/utils/plots.jl") # Missing function Base.size(fd::ForceDescriptors) = (length(fd), )