Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifying pydfnworks installation process #93

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ C_stor_correct/correct_stor
DFN_Mesh_Connectivity_Test/ConnectivityTest
DFNGen/DFNGen

pydfnworks/bin/ConnectivityTest
pydfnworks/bin/correct_stor
pydfnworks/bin/correct_uge
pydfnworks/bin/DFNGen
pydfnworks/bin/DFNTrans

internal/Documentation/sphinx-docs/build/*

*/build/*
*/dist/*
build/*
dist/*
*.egg

pydfnworks/pydfnworks.egg-info/*
*.egg-info

*.pdf
!dfnWorks.pdf
Expand Down Expand Up @@ -73,3 +79,6 @@ examples/TPL/output_rfram/*
.vscode
.vscode/*

# Virtual Environment
.venv
venv
2 changes: 1 addition & 1 deletion DFNTrans/ReadGridInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The memory is allocated for data structures: NODE, CELL, FRACTURE */

if (node1 != nnodes) {
printf("The number of nodes in inp file is not equal to number of nodes in stor file. \n");
return 1;
return;
}

fclose(fps);
Expand Down
1 change: 1 addition & 0 deletions DFNTrans/RotateFracture.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string.h>
#include "FuncDef.h"
#include <unistd.h>
#include <sys/stat.h>


struct posit3d
Expand Down
1 change: 1 addition & 0 deletions DFNTrans/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "FuncDef.h"
#include <unistd.h>
#include <time.h>
#include <sys/stat.h>



Expand Down
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.PHONY: C_stor_correct C_uge_correct DFN_Mesh_Connectivity_Test DFNGen DFNTrans all clean

all: C_stor_correct C_uge_correct DFN_Mesh_Connectivity_Test DFNGen DFNTrans

C_stor_correct:
$(MAKE) -C C_stor_correct

C_uge_correct:
$(MAKE) -C C_uge_correct

DFN_Mesh_Connectivity_Test:
$(MAKE) -C DFN_Mesh_Connectivity_Test

DFNGen:
$(MAKE) -C DFNGen

DFNTrans:
$(MAKE) -C DFNTrans

install: all
mkdir -p pydfnworks/pydfnworks/bin
cp C_stor_correct/correct_stor pydfnworks/bin
cp C_uge_correct/correct_uge pydfnworks/bin
cp DFN_Mesh_Connectivity_Test/ConnectivityTest pydfnworks/bin
cp DFNGen/DFNGen pydfnworks/bin
cp DFNTrans/DFNTrans pydfnworks/bin

clean:
$(MAKE) -C C_stor_correct clean
$(MAKE) -C C_uge_correct clean
$(MAKE) -C DFN_Mesh_Connectivity_Test clean
$(MAKE) -C DFNGen clean
$(MAKE) -C DFNTrans clean
rm pydfnworks/bin/correct_stor
rm pydfnworks/bin/correct_uge
rm pydfnworks/bin/ConnectivityTest
rm pydfnworks/bin/DFNGen
rm pydfnworks/bin/DFNTrans
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,52 @@ machine. To setup dfnWorks using Docker instead, see the next section.

**Before executing dfnWorks,** the following paths must be set:

- dfnWorks_PATH: the dfnWorks repository folder
- PETSC_DIR and PETSC_ARCH: PETSC environmental variables
- PFLOTRAN_EXE: Path to PFLOTRAN executable
- LAGRIT_EXE: Path to LaGriT executable
- FEHM_EXE: Path to FEHM executable

$ vi dfnWorks/pydfnworks/pydfnworks/general/paths.py
$ vi dfnWorks/pydfnworks/general/paths.py

For example:

os.environ['dfnWorks_PATH'] = '/home/<username>/dfnWorks/'
os.environ['LAGRIT_EXE'] = '/home/<username>/.local/bin/lagrit'

Alternatively, you can create a ``.dfnworksrc`` file in your home directory with the following format

{
"dfnworks_PATH": "<your-home-directory>/src/dfnWorks/",
"PETSC_DIR": "<your-home-directory>/src/petsc",
"PETSC_ARCH": "arch-darwin-c-debug",
"PFLOTRAN_EXE": "<your-home-directory>/src/pflotran/src/pflotran/pflotran",
"LAGRIT_EXE": "<your-home-directory>/bin/lagrit",
"FEHM_EXE": "<your-home-directory>//src/xfehm_v3.3.1"
}

Note that you need to set the dfnworks_path, but the others are optional if you don't want to run those executables
Paths are optional if you don't want to run those executables

## Installing pydfnworks

Go up into the pydfnworks sub-directory:
Go to the dfnWorks directory:

$ cd dfnWorks/pydfnworks/
$ cd dfnWorks

Compile The pydfnWorks Package & Install on Your Local Machine:

$ pip install -r requirements.txt
Activate the default conda environment:

$ conda activate

Or, create a conda environment and activate it:

or
$ conda create -n dfnworks
$ conda activate dfnworks

$ pip install -r requirements.txt --user
Or, create a virtual environment and activate it:

if you don't have admin privileges.
$ python -m venv venv
$ source venv/bin/activate

Then, Compile The pydfnWorks Package & Install on Your Local Machine:

$ pip install .

**Note that the python version needs to be consistent with the current release**

Expand All @@ -75,7 +81,8 @@ dfnWorks currently runs on Macs and Unix machine running Ubuntu.

pydfnworks uses Python 3. We recommend using
the Anaconda 3 distribution of Python, available at https://www.continuum.io/.
pydfnworks requires the following python modules: ``numpy``, ``h5py``, ``scipy``, ``matplotlib``, ``multiprocessing``, ``argparse``, ``shutil``, ``os``, ``sys``, ``networkx``, ``subprocess``, ``glob``, ``mplstereonet``, ``fpdf``, and ``re``.
pydfnworks requires the following python modules: ``numpy``, ``scipy``, ``h5py``, ``pyvtk``, ``fpdf``, ``matplotlib``, ``networkx``, ``mplstereonet``, ``seaborn``, and ``mpmath``.
These packages would be installed automatically when you run `pip install .` in the dfnWorks directory.


### LaGriT
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion pydfnworks/MANIFEST.in

This file was deleted.

7 changes: 0 additions & 7 deletions pydfnworks/README.rst

This file was deleted.

12 changes: 2 additions & 10 deletions pydfnworks/pydfnworks/__init__.py → pydfnworks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,9 @@
Satish Karra < [email protected]>

"""
from pydfnworks import release
__date__ = "4 Decemeber 2024"

__author__ = '%s <%s>\n%s <%s>\n%s <%s>' % \
(release.authors['Hyman'] + release.authors['Livingston'] +
release.authors['Karra'])

__license__ = release.license

__date__ = release.date

__version__ = release.version
__version__ = "2.9.1"

__bibtex__ = """@article{hyman2015dfnworks,
title={dfnWorks: A discrete fracture network framework for modeling subsurface flow and transport},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
from time import time
import numpy as np
import importlib.resources
"""
Functions for using FEHM in dfnWorks
"""
Expand Down Expand Up @@ -44,7 +45,8 @@ def correct_stor_file(self):
f.write("%s\n" % self.aper_file)

t = time()
cmd = os.environ['CORRECT_STOR_EXE'] + ' convert_stor_params.txt'
correct_stor_exe = importlib.resources.files("pydfnworks") / "bin" / "correct_stor"
cmd = f'{correct_stor_exe} convert_stor_params.txt'
failure = subprocess.call(cmd, shell=True)
if failure > 0:
error = 'Erro: stor conversion failed\nExiting Program\n'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ntpath
from time import time
import numpy as np
import importlib.resources


def lagrit2pflotran(self, boundary_cell_area = None):
Expand Down Expand Up @@ -246,7 +247,8 @@ def write_perms_and_correct_volumes_areas(self):
## dump aperture file
self.dump_aperture(self.aper_file, format='fehm')
## execute convert uge C code
cmd = os.environ['CORRECT_UGE_EXE'] + ' convert_uge_params.txt'
correct_uge_exe = importlib.resources.files("pydfnworks") / "bin" / "correct_uge"
cmd = f'{correct_uge_exe} convert_uge_params.txt'
self.print_log(f">> {cmd}")
failure = subprocess.call(cmd, shell=True)
if failure > 0:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
from time import time
import subprocess
import importlib.resources


def dfn_gen(self, output=True):
Expand Down Expand Up @@ -138,9 +139,8 @@ def create_network(self):
'''
self.print_log('--> Running DFNGEN')
os.chdir(self.jobname)
cmd = os.environ[
'DFNGEN_EXE'] + ' ' + 'dfnGen_output/' + self.local_dfnGen_file[:
-4] + '_clean.dat' + ' ' + self.jobname
dfngen_exe = importlib.resources.files("pydfnworks") / "bin" / "DFNGen"
cmd = f'{dfngen_exe} dfnGen_output/{self.local_dfnGen_file[:-4]}_clean.dat {self.jobname}'

self.print_log(f"Running: >> {cmd}")
subprocess.call(cmd, shell=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import timeit
import glob
import importlib.resources

import numpy as np
import multiprocessing as mp
Expand Down Expand Up @@ -235,7 +236,8 @@ def mesh_fracture(fracture_id, visual_mode, num_frac, r_fram, quiet):

## Once meshing is complete, check if the lines of intersection are in the final mesh
if not visual_mode:
cmd_check = f"{os.environ['CONNECT_TEST_EXE']} \
connect_test_exe = importlib.resources.files("pydfnworks") / "bin" / "ConnectivityTest"
cmd_check = f"{connect_test_exe} \
intersections_{fracture_id}.inp \
id_tri_node_{fracture_id:0{digits}d}.list \
mesh_{fracture_id:0{digits}d}.inp \
Expand Down Expand Up @@ -638,4 +640,4 @@ def merge_network(self):
merge_the_fractures(self.ncpu)
merge_final_mesh()
check_for_final_mesh(self.visual_mode)
self.print_log("Merging the mesh: Complete")
self.print_log("Merging the mesh: Complete")
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
from time import time
import subprocess
import importlib.resources


def dfn_trans(self):
Expand Down Expand Up @@ -71,7 +72,8 @@ def run_dfn_trans(self):
None
"""
tic = time()
cmd = os.environ['DFNTRANS_EXE'] + ' ' + self.local_dfnTrans_file
dfntrans_exe = importlib.resources.files("pydfnworks") / "bin" / "DFNTrans"
cmd = f'{dfntrans_exe} {self.local_dfnTrans_file}'
self.call_executable(cmd)
self.dump_time("Function: DFNTrans ", time() - tic)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ def __init__(self,
statement = f"Starting at {now}"
self.print_log(statement )

## check is define_paths has been run yet
if not 'dfnworks_PATH' in os.environ:
self.legal()
self.print_log("--> Creating DFN Object: Starting" )
self.define_paths()

if pickle_file:
self.print_log(f"--> Loading DFN from pickled object file {pickle_file}" )
self.from_pickle(pickle_file)
Expand Down Expand Up @@ -391,4 +385,4 @@ def create_dfn():
prune_file=options.prune_file,
path=options.path,
cell_based_aperture=options.cell)
return DFN
return DFN
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def print_paths(self):

self.print_log("dfnWorks paths:")
self.print_log("---------------")
self.print_log(f"* dfnworks_PATH: {os.environ['dfnworks_PATH']}")
self.print_log(f"* LAGRIT_EXE: {os.environ['LAGRIT_EXE']}")
self.print_log(f"* PETSC_DIR: {os.environ['PETSC_DIR']}")
self.print_log(f"* PETSC_ARCH: {os.environ['PETSC_ARCH']}")
Expand Down Expand Up @@ -121,7 +120,6 @@ def define_paths(self):
# Or, change the paths here
else:
env_paths = {
'dfnworks_PATH': None,
'PETSC_DIR': None,
'PETSC_ARCH': None,
'PFLOTRAN_EXE': None,
Expand All @@ -134,13 +132,6 @@ def define_paths(self):
if env_paths[envVar] == '':
env_paths[envVar] = os.environ.get(envVar, '')

# the dfnworks repository
if env_paths['dfnworks_PATH']:
os.environ['dfnworks_PATH'] = env_paths['dfnworks_PATH']
self.valid("dfnworks_PATH", os.environ['dfnworks_PATH'], "directory")
else:
error = f"Error. dfnWorks path not provided. Must be set to the github cloned repo.\nExiting\n"
self.print_log(error, 'critical')
# PETSC paths
if env_paths['PETSC_DIR']:
os.environ['PETSC_DIR'] = env_paths['PETSC_DIR']
Expand Down Expand Up @@ -172,40 +163,5 @@ def define_paths(self):
else:
self.print_log("--> Warning. No LaGriT path provided.", 'warning')

# ===================================================
# THESE PATHS ARE AUTOMATICALLY SET. DO NOT CHANGE.
# ====================================================

# Directories
os.environ['DFNGEN_EXE'] = os.environ['dfnworks_PATH'] + 'DFNGen/DFNGen'
if not os.path.isfile(os.environ['DFNGEN_EXE']):
self.compile_dfn_exe(os.environ['dfnworks_PATH'] + 'DFNGen/')
self.valid('DFNGen', os.environ['DFNGEN_EXE'], "executable")

os.environ[
'DFNTRANS_EXE'] = os.environ['dfnworks_PATH'] + 'DFNTrans/DFNTrans'
if not os.path.isfile(os.environ['DFNTRANS_EXE']):
self.compile_dfn_exe(os.environ['dfnworks_PATH'] + 'DFNTrans/')
self.valid('DFNTrans', os.environ['DFNTRANS_EXE'], "executable")

os.environ['CORRECT_UGE_EXE'] = os.environ[
'dfnworks_PATH'] + 'C_uge_correct/correct_uge'
if not os.path.isfile(os.environ['CORRECT_UGE_EXE']):
self.compile_dfn_exe(os.environ['dfnworks_PATH'] + 'C_uge_correct/')
self.valid('CORRECT_UGE_EXE', os.environ['CORRECT_UGE_EXE'], "executable")

os.environ['CORRECT_STOR_EXE'] = os.environ[
'dfnworks_PATH'] + 'C_stor_correct/correct_stor'
if not os.path.isfile(os.environ['CORRECT_STOR_EXE']):
self.compile_dfn_exe(os.environ['dfnworks_PATH'] + 'C_stor_correct/')
self.valid('CORRECT_STOR_EXE', os.environ['CORRECT_STOR_EXE'], "executable")

os.environ['CONNECT_TEST_EXE'] = os.environ[
'dfnworks_PATH'] + 'DFN_Mesh_Connectivity_Test/ConnectivityTest'
if not os.path.isfile(os.environ['CONNECT_TEST_EXE']):
self.compile_dfn_exe(os.environ['dfnworks_PATH'] +
'DFN_Mesh_Connectivity_Test/')
self.valid('CONNECT_TEST_EXE', os.environ['CONNECT_TEST_EXE'], "executable")

self.print_paths()
self.print_log("--> Loading and checking dfnWorks dependency paths successful")
self.print_log("--> Loading and checking dfnWorks dependency paths successful")
Empty file removed pydfnworks/pydfnworks/README.txt
Empty file.
Loading