This commit is contained in:
Joshua Coles 2023-03-14 15:05:22 +00:00
parent c4ddcd67f4
commit 18af4e5aa8
9 changed files with 68610 additions and 18 deletions

0
1.csv Normal file
View File

BIN
models/rust-3d Executable file

Binary file not shown.

262
notebooks/boxcount.ipynb Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 66, "execution_count": 2,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
@ -17,7 +17,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 67, "execution_count": 3,
"outputs": [], "outputs": [],
"source": [ "source": [
"def read_xy(path: str):\n", "def read_xy(path: str):\n",
@ -391,6 +391,47 @@
"collapsed": false "collapsed": false
} }
}, },
{
"cell_type": "code",
"execution_count": 4,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/joshuacoles/Library/Caches/pypoetry/virtualenvs/data-analysis-B4Au_hWl-py3.10/lib/python3.10/site-packages/pandas/core/arraylike.py:402: RuntimeWarning: divide by zero encountered in log\n",
" result = getattr(ufunc, method)(*inputs, **kwargs)\n"
]
}
],
"source": [
"data = read_xy(\"/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/data-analysis/data/minimal-viable-alteration/2-5000.csv\")"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"data": {
"text/plain": " x y N r cr fd\n0 0 0 1 0.000000 0.000000 -0.000000\n1 0 -1 2 1.000000 1.000000 inf\n2 -1 0 3 1.000000 1.000000 inf\n3 -1 1 4 1.414214 1.414214 4.000000\n4 0 -2 5 2.000000 2.000000 2.321928\n... ... .. ... ... ... ...\n4995 48 77 4996 90.735880 137.931142 1.728601\n4996 -12 84 4997 84.852814 137.931142 1.728642\n4997 -33 83 4998 89.319651 137.931142 1.728682\n4998 -118 20 4999 119.682914 137.931142 1.728723\n4999 132 -29 5000 135.148067 137.931142 1.728763\n\n[5000 rows x 6 columns]",
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>x</th>\n <th>y</th>\n <th>N</th>\n <th>r</th>\n <th>cr</th>\n <th>fd</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0.000000</td>\n <td>0.000000</td>\n <td>-0.000000</td>\n </tr>\n <tr>\n <th>1</th>\n <td>0</td>\n <td>-1</td>\n <td>2</td>\n <td>1.000000</td>\n <td>1.000000</td>\n <td>inf</td>\n </tr>\n <tr>\n <th>2</th>\n <td>-1</td>\n <td>0</td>\n <td>3</td>\n <td>1.000000</td>\n <td>1.000000</td>\n <td>inf</td>\n </tr>\n <tr>\n <th>3</th>\n <td>-1</td>\n <td>1</td>\n <td>4</td>\n <td>1.414214</td>\n <td>1.414214</td>\n <td>4.000000</td>\n </tr>\n <tr>\n <th>4</th>\n <td>0</td>\n <td>-2</td>\n <td>5</td>\n <td>2.000000</td>\n <td>2.000000</td>\n <td>2.321928</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n </tr>\n <tr>\n <th>4995</th>\n <td>48</td>\n <td>77</td>\n <td>4996</td>\n <td>90.735880</td>\n <td>137.931142</td>\n <td>1.728601</td>\n </tr>\n <tr>\n <th>4996</th>\n <td>-12</td>\n <td>84</td>\n <td>4997</td>\n <td>84.852814</td>\n <td>137.931142</td>\n <td>1.728642</td>\n </tr>\n <tr>\n <th>4997</th>\n <td>-33</td>\n <td>83</td>\n <td>4998</td>\n <td>89.319651</td>\n <td>137.931142</td>\n <td>1.728682</td>\n </tr>\n <tr>\n <th>4998</th>\n <td>-118</td>\n <td>20</td>\n <td>4999</td>\n <td>119.682914</td>\n <td>137.931142</td>\n <td>1.728723</td>\n </tr>\n <tr>\n <th>4999</th>\n <td>132</td>\n <td>-29</td>\n <td>5000</td>\n <td>135.148067</td>\n <td>137.931142</td>\n <td>1.728763</td>\n </tr>\n </tbody>\n</table>\n<p>5000 rows × 6 columns</p>\n</div>"
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.r"
],
"metadata": {
"collapsed": false
}
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,

1506
notebooks/r3.ipynb Normal file

File diff suppressed because one or more lines are too long

57
notebooks/rust-3d.py Normal file
View File

@ -0,0 +1,57 @@
from pathlib import Path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy
from glob import glob
def read_3d(path: str):
df = pd.read_csv(path, skipinitialspace=True)
df['N'] = df.index + 1
df['r'] = (df.x ** 2 + df.y ** 2 + df.z ** 2) ** 0.5
df['cr'] = df.r.cummax()
df['fd'] = np.log(df.N) / np.log(df.cr)
return df
def read_load_dir(load_dir: str):
paths = glob(f'{load_dir}/*.csv')
return [read_3d(path) for path in paths]
def convergent_tail_index(series, tol):
diffs = np.abs(np.ediff1d(series))
for i in range(0, len(diffs)):
if np.max(diffs[i:]) <= tol:
return i
# No convergence found
return None
def mean_of_tail(series, tol=0.05):
tail_index = convergent_tail_index(series, tol)
if tail_index is None:
raise Exception("No convergence found.")
return np.mean(series[tail_index:])
def fd_stats(dfs):
fds = [mean_of_tail(df.fd, 0.01) for df in dfs]
fds_clean = [f for f in fds if f < np.inf]
return np.mean(fds_clean), np.std(fds_clean)
df = read_3d("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/c-codebase/out-2.csv")
print(mean_of_tail(df.fd, 0.01))
df = read_3d("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/c-codebase/out-26n.csv")
print(mean_of_tail(df.fd, 0.01))
df = read_3d("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/c-codebase/out-26nn.csv")
print(mean_of_tail(df.fd, 0.01))
# dfs = read_load_dir("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/data-analysis/data/rust-3d-1/1")
# print(fd_stats(dfs))

File diff suppressed because one or more lines are too long

4
tools/3d-things.py Normal file
View File

@ -0,0 +1,4 @@
for i in [-1, 0, 1]:
for j in [-1, 0, 1]:
for k in [-1, 0, 1]:
print(f"{i}, {j}, {k},")

View File

@ -4,3 +4,5 @@ CMD="$(dirname "$(realpath "$0")")/obtain-executable.bash"
"$CMD" minimal-viable-alteration models/minimal-viable-alteration "$CMD" minimal-viable-alteration models/minimal-viable-alteration
"$CMD" stick-probability models/stick-probability "$CMD" stick-probability models/stick-probability
"$CMD" 3d-direct-neighbours models/c-3d-direct-neighbours
"$CMD" 3d-off-axis-neighbours models/c-3d-off-axis-neighbours