Skip to content

Instantly share code, notes, and snippets.

View jkfurtney's full-sized avatar

Jason Furtney jkfurtney

  • St. Paul, Minnesota
View GitHub Profile
from scipy.spatial import cKDTree
def show_actual_predicted(actual, predicted, target_unit=""):
assert len(actual.shape)==1
assert len(predicted.shape)==1
fig = plt.figure(constrained_layout=True, figsize=(15, 10))
gs = fig.add_gridspec(3, 5) # vert the horiz
ax1 = fig.add_subplot(gs[0:2, 0:2]) # scatter dim
ax2 = fig.add_subplot(gs[0:2, 2:4]) # scatter percent
@jkfurtney
jkfurtney / borehole_temperature.py
Created May 19, 2022 13:38
Python program to calculate fluid temperature in borehole
"""
This file is the same as borehole.py but has an non-uniform cartesian mesh
Coupled thermal flow model for brine temperature and wall
temperature. Rock is an axisymmetric 2D mesh
A two-dimensional axi-symmetric domain represents the heat in the rock
surrounding the borehole. The rock is initially at the geo-thermal
gradient and is heated as hot brine is injected. The rock is heated as
the brine cools.
@jkfurtney
jkfurtney / PFC3D_mesh_fragment.py
Created May 17, 2022 13:36
Plot PFC3D fragments as polygons
import numpy as np
import scipy.spatial
import networkx as nx
import itasca as it
from itasca import ballarray as ba
from collections import defaultdict
import itertools
def draw_fragment(points,faces,i):
gname = "tmp{}.geom".format(i)
import itasca as it
it.command("python-reset-state false")
import numpy as np
from itasca import zonearray as za
zid = za.ids()
zz_faces = set()
for i, neighbors in enumerate(za.neighbors()):
this_zone_id = zid[i]
# This file was written by Jason Furtney and Wei Fu
# This file is an example of how to generate a surface mesh from lines
# in a DXF file. A vtk file is created of the mesh.
# you may have to install some Python packages to get this to work
import numpy as np
import ezdxf
import time
@jkfurtney
jkfurtney / map_pp_positive.py
Created May 3, 2022 22:49
Map porepressure from a csv file with only positive values to FLAC3D gridpoints.
import itasca as it
from itasca import gpa
import numpy as np
from scipy.constants import foot
from collections import defaultdict
import os
from scipy.spatial import cKDTree
import scipy
if os.path.exists("data.npy"):
@jkfurtney
jkfurtney / strain_from_disp.py
Created May 25, 2021 15:29
Equivalent strain tensors from displacement field using the Strain at Stations algorithm described in the Cardozo (2009), for use with DEM PFC
import numpy as np
import pandas as pd
import matplotlib; matplotlib.rcParams["savefig.directory"] = "."
from matplotlib import pyplot as plt
from scipy.spatial import cKDTree
from numpy.linalg import lstsq
data0 = np.loadtxt("S1-1_0m.log")
data1 = np.loadtxt("S1-1_3000m.log")
assert (data0[:,0] == data1[:,0]).all()
import numpy as np
import pylab as plt
from sys import float_info
from math import sqrt
from skfmm import distance
N=11
phi = np.ones((N,N))
phi[5,5] = -1
@jkfurtney
jkfurtney / b.py
Last active August 10, 2016 18:52
Exact solution for path finding example.
import numpy as np
import pylab as plt
from skfmm import travel_time, distance
from scipy.interpolate import RectBivariateSpline
from scipy.optimize import fminbound
from math import sin
# Brachistochrone curve
# see: http://mathworld.wolfram.com/BrachistochroneProblem.html
b=1/np.pi
; call trello2org interactively
; or pragmatically like this: (trello2org "c:/Users/jfurtney/blo-up-2-7.json")
(require 'json)
(defun convert-trello-json-file-to-org (trello-json-file)
(let* ((board (json-read-file trello-json-file))
(board-name (cdr (assoc 'name (cdr board))))
(lists (cdr (assoc 'lists (cdr board))))