|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "metadata": { |
| 5 | + "collapsed": false, |
| 6 | + "ExecuteTime": { |
| 7 | + "end_time": "2025-01-23T23:01:54.750649Z", |
| 8 | + "start_time": "2025-01-23T23:01:53.532205Z" |
| 9 | + } |
| 10 | + }, |
| 11 | + "cell_type": "code", |
| 12 | + "source": [ |
| 13 | + "import tempfile\n", |
| 14 | + "import os\n", |
| 15 | + "import requests\n", |
| 16 | + "import tarfile\n", |
| 17 | + "\n", |
| 18 | + "temp_dir = tempfile.mkdtemp(prefix='pyvcell_test_data_')\n", |
| 19 | + "filename = os.path.join(temp_dir, 'SimID_946368938_simdata.tgz')\n", |
| 20 | + "url = 'https://github.com/virtualcell/pyvcell/blob/main/tests/test_data/SimID_946368938_simdata.tgz?raw=true'\n", |
| 21 | + "response = requests.get(url)\n", |
| 22 | + "\n", |
| 23 | + "with open(filename, 'wb') as f:\n", |
| 24 | + " f.write(response.content)\n", |
| 25 | + "\n", |
| 26 | + "with tarfile.open(filename, 'r:gz') as tar:\n", |
| 27 | + " tar.extractall(temp_dir)\n", |
| 28 | + "print(f\"Files extracted to {temp_dir}\")" |
| 29 | + ], |
| 30 | + "id": "5e183b4a68315dfe", |
| 31 | + "outputs": [ |
| 32 | + { |
| 33 | + "name": "stdout", |
| 34 | + "output_type": "stream", |
| 35 | + "text": [ |
| 36 | + "Files extracted to /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/pyvcell_test_data_i35r8_br\n" |
| 37 | + ] |
| 38 | + } |
| 39 | + ], |
| 40 | + "execution_count": 1 |
| 41 | + }, |
| 42 | + { |
| 43 | + "cell_type": "code", |
| 44 | + "source": [ |
| 45 | + "import shutil\n", |
| 46 | + "from pathlib import Path\n", |
| 47 | + "\n", |
| 48 | + "test_data_dir = Path(temp_dir)\n", |
| 49 | + "fv_input_file = test_data_dir / \"SimID_946368938_0_.fvinput\"\n", |
| 50 | + "vcg_file = test_data_dir / \"SimID_946368938_0_.vcg\"\n", |
| 51 | + "functions_file = test_data_dir / \"SimID_946368938_0_.functions\"\n", |
| 52 | + "test_output_dir = Path(os.getcwd()) / \"test_output\"\n", |
| 53 | + "\n", |
| 54 | + "shutil.copy(functions_file, test_output_dir)\n", |
| 55 | + "\n", |
| 56 | + "from pyvcell.solvers.fvsolver import solve\n", |
| 57 | + "try:\n", |
| 58 | + " ret_code = solve(input_file=fv_input_file, vcg_file=vcg_file, output_dir=test_output_dir)\n", |
| 59 | + " print(f\"Return code: {ret_code}\")\n", |
| 60 | + "except ValueError as e:\n", |
| 61 | + " print(f\"Error: {e}\")\n", |
| 62 | + "\n" |
| 63 | + ], |
| 64 | + "metadata": { |
| 65 | + "collapsed": false, |
| 66 | + "ExecuteTime": { |
| 67 | + "end_time": "2025-01-23T23:19:41.486252Z", |
| 68 | + "start_time": "2025-01-23T23:19:40.386826Z" |
| 69 | + } |
| 70 | + }, |
| 71 | + "id": "902c6d3a8dc70af", |
| 72 | + "outputs": [ |
| 73 | + { |
| 74 | + "name": "stdout", |
| 75 | + "output_type": "stream", |
| 76 | + "text": [ |
| 77 | + "initializing mesh\n", |
| 78 | + "Return code: 0\n" |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + "name": "stderr", |
| 83 | + "output_type": "stream", |
| 84 | + "text": [ |
| 85 | + "Simulation Complete in Main() ... \n" |
| 86 | + ] |
| 87 | + }, |
| 88 | + { |
| 89 | + "name": "stdout", |
| 90 | + "output_type": "stream", |
| 91 | + "text": [ |
| 92 | + "numVolume=126025\n", |
| 93 | + "\n", |
| 94 | + "CartesianMesh::computeNormalsFromNeighbors(), compute normals from neighbors\n", |
| 95 | + "Membrane Elements -> N=7817\n", |
| 96 | + "==============================================\n", |
| 97 | + "--------Num of points that have zero neighbors 0\n", |
| 98 | + "--------Num Neighbors before symmetrize 46161\n", |
| 99 | + "--------Num Neighbors after symmetrize 51016\n", |
| 100 | + "Total volume=5824.650822\n", |
| 101 | + "Total FluxArea =36.79383373\n", |
| 102 | + "Total FluxAreaXM =0\n", |
| 103 | + "Total FluxAreaXP =0\n", |
| 104 | + "Total FluxAreaYM =21.43445916\n", |
| 105 | + "Total FluxAreaYP =15.35937457\n", |
| 106 | + "Total FluxAreaZM =0\n", |
| 107 | + "Total FluxAreaZP =0\n", |
| 108 | + "mesh initialized\n", |
| 109 | + "preprocessing finished\n", |
| 110 | + "pdeCount=4, odeCount=0\n", |
| 111 | + "error opening log file </Users/jimschaff/Documents/workspace/pyvcell/examples/test_output/SimID_946368938_0_.log>\n", |
| 112 | + "simulation [SimID_946368938_0_] started\n", |
| 113 | + "temporary directory used is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/\n", |
| 114 | + "sim file name is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/SimID_946368938_0_0000.sim\n", |
| 115 | + "**This is a little endian machine.**\n", |
| 116 | + "[[[data:0]]]\n", |
| 117 | + "numVolRegions=6\n", |
| 118 | + "Region 0: size=110800, offset=0\n", |
| 119 | + "Region 1: size=12207, offset=110800\n", |
| 120 | + "Region 2: size=1, offset=123007\n", |
| 121 | + "Region 3: size=1, offset=123008\n", |
| 122 | + "Region 4: size=1, offset=123009\n", |
| 123 | + "Region 5: size=3015, offset=123010\n", |
| 124 | + "# of active points = 126025\n", |
| 125 | + "Constant diffusion/advection in region cytosol1\n", |
| 126 | + "Constant diffusion/advection in region cytosol2\n", |
| 127 | + "Constant diffusion/advection in region cytosol3\n", |
| 128 | + "Constant diffusion/advection in region cytosol4\n", |
| 129 | + "Constant diffusion/advection in region Nucleus5\n", |
| 130 | + "numUnknowns = 39645\n", |
| 131 | + "\n", |
| 132 | + "****** using Sundials CVode with PREC_LEFT, relTol=1e-07, absTol=1e-09, maxStep=0.1\n", |
| 133 | + "\n", |
| 134 | + "----------------------------------\n", |
| 135 | + "sundials pde solver is starting from time 0\n", |
| 136 | + "----------------------------------\n", |
| 137 | + "temporary directory used is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/\n", |
| 138 | + "sim file name is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/SimID_946368938_0_0001.sim\n", |
| 139 | + "[[[data:0.25]]]temporary directory used is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/\n", |
| 140 | + "sim file name is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/SimID_946368938_0_0002.sim\n", |
| 141 | + "[[[data:0.5]]]temporary directory used is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/\n", |
| 142 | + "sim file name is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/SimID_946368938_0_0003.sim\n", |
| 143 | + "[[[data:0.75]]]\n", |
| 144 | + "Final Statistics.. \n", |
| 145 | + "\n", |
| 146 | + "lenrw = 396539 leniw = 50\n", |
| 147 | + "lenrwLS = 396496 leniwLS = 10\n", |
| 148 | + "nst = 63\n", |
| 149 | + "nfe = 76 nfeLS = 87\n", |
| 150 | + "nni = 72 nli = 87\n", |
| 151 | + "nsetups = 22 netf = 0\n", |
| 152 | + "npe = 2 nps = 147\n", |
| 153 | + "ncfn = 0 ncfl = 0\n", |
| 154 | + "last step = 0.017509\n", |
| 155 | + "\n", |
| 156 | + "temporary directory used is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/\n", |
| 157 | + "sim file name is /var/folders/zz/gcfcvgtd5v1cdgj2sw4bjzdr0000gr/T/SimID_946368938_0_0004.sim\n", |
| 158 | + "[[[data:1]]][[[progress:100%]]]" |
| 159 | + ] |
| 160 | + } |
| 161 | + ], |
| 162 | + "execution_count": 4 |
| 163 | + }, |
| 164 | + { |
| 165 | + "cell_type": "code", |
| 166 | + "id": "ed266f9194abb748", |
| 167 | + "metadata": { |
| 168 | + "collapsed": false, |
| 169 | + "ExecuteTime": { |
| 170 | + "end_time": "2025-01-23T23:22:08.523252Z", |
| 171 | + "start_time": "2025-01-23T23:22:08.520883Z" |
| 172 | + } |
| 173 | + }, |
| 174 | + "source": [ |
| 175 | + "import os\n", |
| 176 | + "with os.scandir(test_output_dir) as entries:\n", |
| 177 | + " for entry in entries:\n", |
| 178 | + " print(entry.name)" |
| 179 | + ], |
| 180 | + "outputs": [ |
| 181 | + { |
| 182 | + "name": "stdout", |
| 183 | + "output_type": "stream", |
| 184 | + "text": [ |
| 185 | + ".placeholder\n", |
| 186 | + "SimID_946368938_0_.hdf5\n", |
| 187 | + "SimID_946368938_0_.mesh\n", |
| 188 | + "SimID_946368938_0_.log\n", |
| 189 | + "SimID_946368938_0_.meshmetrics\n", |
| 190 | + "SimID_946368938_0_00.zip\n", |
| 191 | + "SimID_946368938_0_.functions\n" |
| 192 | + ] |
| 193 | + } |
| 194 | + ], |
| 195 | + "execution_count": 7 |
| 196 | + } |
| 197 | + ], |
| 198 | + "metadata": { |
| 199 | + "kernelspec": { |
| 200 | + "display_name": "Python 3 (ipykernel)", |
| 201 | + "language": "python", |
| 202 | + "name": "python3" |
| 203 | + }, |
| 204 | + "language_info": { |
| 205 | + "codemirror_mode": { |
| 206 | + "name": "ipython", |
| 207 | + "version": 3 |
| 208 | + }, |
| 209 | + "file_extension": ".py", |
| 210 | + "mimetype": "text/x-python", |
| 211 | + "name": "python", |
| 212 | + "nbconvert_exporter": "python", |
| 213 | + "pygments_lexer": "ipython3", |
| 214 | + "version": "3.12.2" |
| 215 | + } |
| 216 | + }, |
| 217 | + "nbformat": 4, |
| 218 | + "nbformat_minor": 5 |
| 219 | +} |
0 commit comments