From 8887aecbc9df5acddaf3c12fbed1619135fa01f7 Mon Sep 17 00:00:00 2001 From: Brian Drawert Date: Tue, 10 Nov 2020 16:52:08 -0500 Subject: [PATCH] uploading more files --- examples/cdc42/cdc42.ipynb | 120 ++++++++--- examples/tests/Spatialpy_gravity.ipynb | 2 +- .../src/linked_list.c | 189 ++++++++---------- .../src/simulate_rdme.c | 48 +++-- .../src/simulate_threads.c | 4 +- 5 files changed, 207 insertions(+), 156 deletions(-) diff --git a/examples/cdc42/cdc42.ipynb b/examples/cdc42/cdc42.ipynb index bc906dca..f3058631 100644 --- a/examples/cdc42/cdc42.ipynb +++ b/examples/cdc42/cdc42.ipynb @@ -13205,7 +13205,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 65, "metadata": { "scrolled": false }, @@ -13214,40 +13214,110 @@ "name": "stdout", "output_type": "stream", "text": [ - "Volumes: DX=50\n", - "\textracellular\t2.9119999999999404 (1820 paticles)\n", - "\tmembrane\t0.608000000000001 (380 paticles) 3.23% error\n", - "\tcytoplasm\t0.479999999999998 (300 paticles) 4.51% error\n", - "Compiling Solver. Build dir: /tmp/spatialpy_build_c7a_lig9\n", - "Elapsed seconds: 0.01\n", + "Volumes: DX=10\n", + "\textracellular\t3.040000000000002 (76 paticles)\n", + "\tmembrane\t0.4799999999999999 (12 paticles) 23.61% error\n", + "\tcytoplasm\t0.4799999999999999 (12 paticles) 4.51% error\n", + "Compiling Solver. Build dir: /tmp/spatialpy_build_xei68ljy\n", + "Elapsed seconds: 0.00\n", "*************** initialize_rdme ******************\n", - "Creating thread to process 312 particles\n", - "Creating thread to process 312 particles\n", - "Creating thread to process 312 particles\n", - "[WORKER 1] waiting to begin step 0\n", + "Creating thread to process 12 particles\n", + "Creating thread to process 12 particles\n", + "Creating thread to process 12 particles\n", + "Creating thread to process 12 particles\n", "[WORKER 0] waiting to begin step 0\n", - "Creating thread to process 312 particles\n", - "[WORKER 2] waiting to begin step 0\n", - "Creating thread to process 312 particles\n", + "Creating thread to process 12 particles\n", "[WORKER 3] waiting to begin step 0\n", - "Creating thread to process 312 particles\n", - "Creating thread to process 312 particles\n", + "[WORKER 2] waiting to begin step 0\n", + "Creating thread to process 12 particles\n", + "[WORKER 1] waiting to begin step 0\n", + "Creating thread to process 12 particles\n", "[WORKER 5] waiting to begin step 0\n", + "Creating thread to process 16 particles\n", "[WORKER 4] waiting to begin step 0\n", - "Creating thread to process 316 particles\n", - "[WORKER 6] waiting to begin step 0\n", "Creating thread to update x-position index\n", "Creating thread to create output files\n", "[0] Starting the Sort Index threads\n", - "[WORKER 7] waiting to begin step 0\n", - "[SORT] begin sort\n", "[0] Starting the Output threads\n", "[OUT] start output_vtk__sync_step()\n", - "[SORT] sort complete took 473 us\n", + "[WORKER 6] waiting to begin step 0\n", + "[WORKER 7] waiting to begin step 0\n", + "[OUT] done output_vtk__sync_step()\n", + "[OUT] start output_vtk__async_step()\n", + "Writing file 'output0_boundingBox.vtk'\n", + "[0] Output threads finished\n", + "[SORT] begin sort\n", + "[SORT] sort complete 5 us\n", + "[0] Sort Index threads finished\n", + "[0] Starting the Worker threads\n", + "Writing file 'output0.vtk'\n", + "[WORKER 0] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 3] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 1] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 2] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 4] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 5] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 6] completed step 0, substep 0/3, processed 12 particles\n", + "[WORKER 7] completed step 0, substep 0/3, processed 16 particles\n", + "[0] Worker threads finished substep 0/3\n", + "[WORKER 2] completed step 0, substep 1/3, processed 12 particles\n", + "[WORKER 7] completed step 0, substep 1/3, processed 16 particles\n", + "[WORKER 6] completed step 0, substep 1/3, processed 12 particles\n", + "[WORKER 0] completed step 0, substep 1/3, processed 12 particles\n", + "[WORKER 1] completed step 0, substep 1/3, processed 12 particles\n", + "[WORKER 3] completed step 0, substep 1/3, processed 12 particles\n", + "[WORKER 4] completed step 0, substep 1/3, processed 12 particles\n", + "[WORKER 5] completed step 0, substep 1/3, processed 12 particles\n", + "[0] Worker threads finished substep 1/3\n", + "[WORKER 6] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 0] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 1] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 3] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 4] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 5] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 2] completed step 0, substep 2/3, processed 12 particles\n", + "[WORKER 7] completed step 0, substep 2/3, processed 16 particles\n", + "[0] Worker threads finished substep 2/3\n", + "[0] starting RDME simulation\n", + "\tnsm_core__initialize_rxn_propensities\n", + "[WORKER 6] waiting to begin step 1\n", + "[WORKER 0] waiting to begin step 1\n", + "[WORKER 3] waiting to begin step 1\n", + "[WORKER 5] waiting to begin step 1\n", + "[WORKER 7] waiting to begin step 1\n", + "\tnsm_core__initialize_diff_propensities\n", + "[WORKER 2] waiting to begin step 1\n", + "\tnsm_core__initialize_heap\n", + "[WORKER 1] waiting to begin step 1\n", + "[WORKER 4] waiting to begin step 1\n", + "before sort\n", + "========================================================\n", + "tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=8.651057e-07, tt=4.089383e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=6.329065e-07, tt=8.093082e-03, tt=9.483580e-03, tt=4.698511e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.220386e-06, tt=1.733538e-03, tt=2.419926e-02, tt=2.134093e-01, tt=1.120176e-03, tt=8.792504e-07, tt=inf, tt=inf, tt=inf, tt=inf, tt=3.261944e-06, tt=2.750354e-02, tt=1.076719e-01, tt=3.032052e-02, tt=4.225202e-02, tt=1.488286e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.917986e-06, tt=6.648724e-03, tt=1.578200e-04, tt=3.897571e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=5.361157e-07, tt=2.315782e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, ========================================================\n", + "after sort\n", + "========================================================\n", + "tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=8.651057e-07, tt=4.089383e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=6.329065e-07, tt=8.093082e-03, tt=9.483580e-03, tt=4.698511e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.220386e-06, tt=1.733538e-03, tt=2.419926e-02, tt=2.134093e-01, tt=1.120176e-03, tt=8.792504e-07, tt=inf, tt=inf, tt=inf, tt=inf, tt=3.261944e-06, tt=2.750354e-02, tt=1.076719e-01, tt=3.032052e-02, tt=4.225202e-02, tt=1.488286e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.917986e-06, tt=6.648724e-03, tt=1.578200e-04, tt=3.897571e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=5.361157e-07, tt=2.315782e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, ========================================================\n", + "Simulating RDME for 1.000000e+00 seconds\n", + "Error: overflow in trying to determine which destination voxel subvol=0\n", + "subvol->id=0 rand2=0.000000e+00 cum2=0.000000e+00 Current state in voxel 0:\n", + "xx[0] = 0\n", + "xx[1] = 0\n", + "xx[2] = 0\n", + "xx[3] = 0\n", + "xx[4] = 0\n", + "xx[5] = 0\n", + "xx[6] = 0\n", + "xx[7] = 0\n", + "xx[8] = 0\n", + "Neighbors:\n", + "1: nn->D_i_j=2.037652e+01 \n", + "2: nn->D_i_j=5.863151e-01 \n", + "10: nn->D_i_j=2.037652e+01 \n", + "11: nn->D_i_j=8.943732e+00 \n", + "20: nn->D_i_j=5.863151e-01 \n", "\n", "None\n", - "b'*************** initialize_rdme ******************\\nCreating thread to process 312 particles\\nCreating thread to process 312 particles\\nCreating thread to process 312 particles\\n[WORKER 1] waiting to begin step 0\\n[WORKER 0] waiting to begin step 0\\nCreating thread to process 312 particles\\n[WORKER 2] waiting to begin step 0\\nCreating thread to process 312 particles\\n[WORKER 3] waiting to begin step 0\\nCreating thread to process 312 particles\\nCreating thread to process 312 particles\\n[WORKER 5] waiting to begin step 0\\n[WORKER 4] waiting to begin step 0\\nCreating thread to process 316 particles\\n[WORKER 6] waiting to begin step 0\\nCreating thread to update x-position index\\nCreating thread to create output files\\n[0] Starting the Sort Index threads\\n[WORKER 7] waiting to begin step 0\\n[SORT] begin sort\\n[0] Starting the Output threads\\n[OUT] start output_vtk__sync_step()\\n[SORT] sort complete took 473 us\\n'\n", - "solver_cmd = cd /tmp/spatialpy_result_jkrq7w6w;/tmp/spatialpy_build_c7a_lig9/ssa_sdpd\n" + "b\"*************** initialize_rdme ******************\\nCreating thread to process 12 particles\\nCreating thread to process 12 particles\\nCreating thread to process 12 particles\\nCreating thread to process 12 particles\\n[WORKER 0] waiting to begin step 0\\nCreating thread to process 12 particles\\n[WORKER 3] waiting to begin step 0\\n[WORKER 2] waiting to begin step 0\\nCreating thread to process 12 particles\\n[WORKER 1] waiting to begin step 0\\nCreating thread to process 12 particles\\n[WORKER 5] waiting to begin step 0\\nCreating thread to process 16 particles\\n[WORKER 4] waiting to begin step 0\\nCreating thread to update x-position index\\nCreating thread to create output files\\n[0] Starting the Sort Index threads\\n[0] Starting the Output threads\\n[OUT] start output_vtk__sync_step()\\n[WORKER 6] waiting to begin step 0\\n[WORKER 7] waiting to begin step 0\\n[OUT] done output_vtk__sync_step()\\n[OUT] start output_vtk__async_step()\\nWriting file 'output0_boundingBox.vtk'\\n[0] Output threads finished\\n[SORT] begin sort\\n[SORT] sort complete 5 us\\n[0] Sort Index threads finished\\n[0] Starting the Worker threads\\nWriting file 'output0.vtk'\\n[WORKER 0] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 3] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 1] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 2] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 4] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 5] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 6] completed step 0, substep 0/3, processed 12 particles\\n[WORKER 7] completed step 0, substep 0/3, processed 16 particles\\n[0] Worker threads finished substep 0/3\\n[WORKER 2] completed step 0, substep 1/3, processed 12 particles\\n[WORKER 7] completed step 0, substep 1/3, processed 16 particles\\n[WORKER 6] completed step 0, substep 1/3, processed 12 particles\\n[WORKER 0] completed step 0, substep 1/3, processed 12 particles\\n[WORKER 1] completed step 0, substep 1/3, processed 12 particles\\n[WORKER 3] completed step 0, substep 1/3, processed 12 particles\\n[WORKER 4] completed step 0, substep 1/3, processed 12 particles\\n[WORKER 5] completed step 0, substep 1/3, processed 12 particles\\n[0] Worker threads finished substep 1/3\\n[WORKER 6] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 0] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 1] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 3] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 4] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 5] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 2] completed step 0, substep 2/3, processed 12 particles\\n[WORKER 7] completed step 0, substep 2/3, processed 16 particles\\n[0] Worker threads finished substep 2/3\\n[0] starting RDME simulation\\n\\tnsm_core__initialize_rxn_propensities\\n[WORKER 6] waiting to begin step 1\\n[WORKER 0] waiting to begin step 1\\n[WORKER 3] waiting to begin step 1\\n[WORKER 5] waiting to begin step 1\\n[WORKER 7] waiting to begin step 1\\n\\tnsm_core__initialize_diff_propensities\\n[WORKER 2] waiting to begin step 1\\n\\tnsm_core__initialize_heap\\n[WORKER 1] waiting to begin step 1\\n[WORKER 4] waiting to begin step 1\\nbefore sort\\n========================================================\\ntt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=8.651057e-07, tt=4.089383e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=6.329065e-07, tt=8.093082e-03, tt=9.483580e-03, tt=4.698511e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.220386e-06, tt=1.733538e-03, tt=2.419926e-02, tt=2.134093e-01, tt=1.120176e-03, tt=8.792504e-07, tt=inf, tt=inf, tt=inf, tt=inf, tt=3.261944e-06, tt=2.750354e-02, tt=1.076719e-01, tt=3.032052e-02, tt=4.225202e-02, tt=1.488286e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.917986e-06, tt=6.648724e-03, tt=1.578200e-04, tt=3.897571e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=5.361157e-07, tt=2.315782e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, ========================================================\\nafter sort\\n========================================================\\ntt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=8.651057e-07, tt=4.089383e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=6.329065e-07, tt=8.093082e-03, tt=9.483580e-03, tt=4.698511e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.220386e-06, tt=1.733538e-03, tt=2.419926e-02, tt=2.134093e-01, tt=1.120176e-03, tt=8.792504e-07, tt=inf, tt=inf, tt=inf, tt=inf, tt=3.261944e-06, tt=2.750354e-02, tt=1.076719e-01, tt=3.032052e-02, tt=4.225202e-02, tt=1.488286e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=2.917986e-06, tt=6.648724e-03, tt=1.578200e-04, tt=3.897571e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=5.361157e-07, tt=2.315782e-06, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, tt=inf, ========================================================\\nSimulating RDME for 1.000000e+00 seconds\\nError: overflow in trying to determine which destination voxel subvol=0\\nsubvol->id=0 rand2=0.000000e+00 cum2=0.000000e+00 Current state in voxel 0:\\nxx[0] = 0\\nxx[1] = 0\\nxx[2] = 0\\nxx[3] = 0\\nxx[4] = 0\\nxx[5] = 0\\nxx[6] = 0\\nxx[7] = 0\\nxx[8] = 0\\nNeighbors:\\n1: nn->D_i_j=2.037652e+01 \\n2: nn->D_i_j=5.863151e-01 \\n10: nn->D_i_j=2.037652e+01 \\n11: nn->D_i_j=8.943732e+00 \\n20: nn->D_i_j=5.863151e-01 \\n\"\n", + "solver_cmd = cd /tmp/spatialpy_result_imh96o5z;/tmp/spatialpy_build_xei68ljy/ssa_sdpd\n" ] }, { @@ -13257,7 +13327,7 @@ "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mSimulationError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m## sol.run()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mm_tmp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCdc42_cycle_2D_SpatialPy_SDPD\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDX\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m50\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mm_tmp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdebug_level\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m## sol.run()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mm_tmp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCdc42_cycle_2D_SpatialPy_SDPD\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDX\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mm_tmp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdebug_level\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m~/Desktop/research/SpatialPy/spatialpy/Model.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, number_of_trajectories, seed, number_of_threads, debug_level)\u001b[0m\n\u001b[1;32m 69\u001b[0m \u001b[0msol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSolver\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdebug_level\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdebug_level\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 70\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 71\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0msol\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnumber_of_trajectories\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnumber_of_trajectories\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mseed\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mseed\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumber_of_threads\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnumber_of_threads\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 72\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 73\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Desktop/research/SpatialPy/spatialpy/Solver.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, number_of_trajectories, seed, timeout, number_of_threads)\u001b[0m\n\u001b[1;32m 201\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 202\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"solver_cmd = {0}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msolver_cmd\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 203\u001b[0;31m raise SimulationError(\n\u001b[0m\u001b[1;32m 204\u001b[0m \"Solver execution failed, return code = {0}\".format(return_code))\n\u001b[1;32m 205\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mSimulationError\u001b[0m: Solver execution failed, return code = 1" @@ -13266,7 +13336,7 @@ ], "source": [ "## sol.run()\n", - "m_tmp = Cdc42_cycle_2D_SpatialPy_SDPD(DX=50)\n", + "m_tmp = Cdc42_cycle_2D_SpatialPy_SDPD(DX=10)\n", "m_tmp.run(debug_level=1)" ] }, diff --git a/examples/tests/Spatialpy_gravity.ipynb b/examples/tests/Spatialpy_gravity.ipynb index 5bfcbc4f..7dc4fd1a 100644 --- a/examples/tests/Spatialpy_gravity.ipynb +++ b/examples/tests/Spatialpy_gravity.ipynb @@ -471426,7 +471426,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.2" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/spatialpy/ssa_sdpd-c-simulation-engine/src/linked_list.c b/spatialpy/ssa_sdpd-c-simulation-engine/src/linked_list.c index 4e130a18..ee8b506f 100644 --- a/spatialpy/ssa_sdpd-c-simulation-engine/src/linked_list.c +++ b/spatialpy/ssa_sdpd-c-simulation-engine/src/linked_list.c @@ -11,7 +11,6 @@ See the file LICENSE.txt for details. #include "linked_list.h" #include "particle.h" #include -#include "dSFMT/dSFMT.h" //#define DEBUG_UPDATE @@ -298,43 +297,6 @@ static inline void linked_list_sort__swap(node_t* a, node_t* b){ b->data = a->data; a->data = tmp; } -static inline node_t* linked_list_sort__find_middle(node_t* min, node_t* max){ - node_t*left = min; - node_t*right = max; - while(left != right){ - if(left != right && left->next != NULL){ - left = left->next; - } - if(left != right && right->prev != NULL){ - right = right->prev; - } - } - return left; -} - -static inline node_t* linked_list_sort__partition_middle(node_t* min, node_t* max){ - node_t* middle = linked_list_sort__find_middle(min, max); - double partitionValue = middle->data->x[0]; - node_t*left = min; - node_t*right = max; - linked_list_sort__swap(middle,min); - while(left!=right && right->next != left){ - // from left, search for an element that is > partitionValue - while(left!=right && left->data->x[0] <= partitionValue){ - left = left->next; - } - // from right, search for an element that is < partitionValue - while(left!=right && right->data->x[0] > partitionValue){ - right = right->prev; - } - // swap elements - if(left!=right && right->next != left){ - linked_list_sort__swap(left,right); - } - } - linked_list_sort__swap(min,right); - return right; -} static inline node_t* linked_list_sort__partition_avg(node_t* min, node_t* max){ double partitionValue = (min->data->x[0] + max->data->x[0])/2.0; node_t*left = min; @@ -362,73 +324,11 @@ void linked_list_sort__quicksort(node_t* min, node_t* max){ linked_list_sort__quicksort(pivot->next, max ); } - - -static inline node_t* linked_list_sort__partition_rnd(node_t* min, node_t* max, - int size, int*left_cnt, int*right_cnt){ - - // Choose a random node in the list as the pivot - double rand = dsfmt_genrand_close_open(&dsfmt); - node_t*middle; - if(rand > 0.5){ // start from tail - int hops = size*(1.0-rand); - middle = max; - while(hops>0){ - hops--; - middle = middle->prev; - } - - }else{ // start from head - int hops = size*rand; - middle = min; - while(hops>0){ - hops--; - middle = middle->next; - } - } - // partition value is the - double partitionValue = middle->data->x[0]; - node_t*left = min; - *left_cnt=0; - *right_cnt=0; - node_t*right = max; - linked_list_sort__swap(middle,min); - while(left!=right && right->next != left){ - // from left, search for an element that is > partitionValue - while(left!=right && left->data->x[0] <= partitionValue){ - left = left->next; - (*left_cnt)++; - } - // from right, search for an element that is < partitionValue - while(left!=right && right->data->x[0] > partitionValue){ - right = right->prev; - (*right_cnt)++; - } - // swap elements - if(left!=right && right->next != left){ - linked_list_sort__swap(left,right); - } - } - linked_list_sort__swap(min,right); - return right; -} -void linked_list_sort__quicksort_rnd(node_t* min, node_t* max, int size){ - if(min==NULL||max==NULL||min==max||max->next==min) return; - int left_cnt, right_cnt; - node_t*pivot = linked_list_sort__partition_rnd(min,max,size,&left_cnt,&right_cnt); - linked_list_sort__quicksort_rnd(min, pivot->prev, left_cnt ); - linked_list_sort__quicksort_rnd(pivot->next, max, right_cnt ); -} - - void linked_list_sort(linked_list_t*ll){ - //ll->head = linked_list_sort__sub(ll->head ); - //for(ll->tail = ll->head; ll->tail->next != NULL; ll->tail=ll->tail->next){} - //linked_list_sort__quicksort(ll->head, ll->tail); - linked_list_sort__quicksort_rnd(ll->head, ll->tail, ll->count); + linked_list_sort__quicksort(ll->head, ll->tail); } -neighbor_node_t* neighbor_list_sort__sub(neighbor_node_t* head){ +/*neighbor_node_t* neighbor_list_sort__sub(neighbor_node_t* head){ neighbor_node_t* min_neighbor = head; neighbor_node_t* before = NULL; neighbor_node_t* ptr; @@ -456,14 +356,55 @@ neighbor_node_t* neighbor_list_sort__sub(neighbor_node_t* head){ head->next->prev = head; } return head; +}*/ + +static inline void neighbor_list_sort__swap(neighbor_node_t* a, neighbor_node_t* b){ + particle_t*tmp = b->data; + b->data = a->data; + a->data = tmp; + double t2; + t2= b->dist; + b->dist = a->dist; + a->dist = t2; + t2= b->dWdr; + b->dWdr = a->dWdr; + a->dWdr = t2; + t2= b->D_i_j; + b->D_i_j = a->D_i_j; + a->D_i_j = t2; +} +static inline neighbor_node_t* neighbor_list_sort__partition_avg(neighbor_node_t* min, neighbor_node_t* max){ + double partitionValue = (min->dist + max->dist)/2.0; + neighbor_node_t*left = min; + neighbor_node_t*right = max; + while(left!=right && right->next != left){ + // from left, search for an element that is > partitionValue + while(left!=right && left->dist <= partitionValue){ + left = left->next; + } + // from right, search for an element that is < partitionValue + while(left!=right && right->dist > partitionValue){ + right = right->prev; + } + // swap elements + if(left!=right && right->next != left){ + neighbor_list_sort__swap(left,right); + } + } + return right; +} +void neighbor_list_sort__quicksort(neighbor_node_t* min, neighbor_node_t* max){ + if(min==NULL||max==NULL||min==max||max->next==min) return; + neighbor_node_t*pivot = neighbor_list_sort__partition_avg(min,max); + neighbor_list_sort__quicksort(min, pivot->prev ); + neighbor_list_sort__quicksort(pivot->next, max ); } void neighbor_list_sort(neighbor_list_t*ll){ - ll->head = neighbor_list_sort__sub(ll->head); - for(ll->tail = ll->head; ll->tail->next != NULL; ll->tail=ll->tail->next){} + neighbor_list_sort__quicksort(ll->head, ll->tail->next); } -ordered_node_t* ordered_list_sort__sub(ordered_node_t* head){ +/*ordered_node_t* ordered_list_sort__sub(ordered_node_t* head){ ordered_node_t* min_ordered = head; ordered_node_t* before = NULL; ordered_node_t* ptr; @@ -491,11 +432,45 @@ ordered_node_t* ordered_list_sort__sub(ordered_node_t* head){ head->next->prev = head; } return head; +}*/ +static inline void ordered_list_sort__swap(ordered_node_t* a, ordered_node_t* b){ + particle_t*tmp = b->data; + b->data = a->data; + a->data = tmp; + double t2; + t2= b->tt; + b->tt = a->tt; + a->tt = t2; +} +static inline ordered_node_t* ordered_list_sort__partition_avg(ordered_node_t* min, ordered_node_t* max){ + double partitionValue = (min->tt + max->tt)/2.0; + ordered_node_t*left = min; + ordered_node_t*right = max; + while(left!=right && right->next != left){ + // from left, search for an element that is > partitionValue + while(left!=right && left->tt <= partitionValue){ + left = left->next; + } + // from right, search for an element that is < partitionValue + while(left!=right && right->tt > partitionValue){ + right = right->prev; + } + // swap elements + if(left!=right && right->next != left){ + ordered_list_sort__swap(left,right); + } + } + return right; +} +void ordered_list_sort__quicksort(ordered_node_t* min, ordered_node_t* max){ + if(min==NULL||max==NULL||min==max||max->next==min) return; + ordered_node_t*pivot = ordered_list_sort__partition_avg(min,max); + ordered_list_sort__quicksort(min, pivot->prev ); + ordered_list_sort__quicksort(pivot->next, max ); } void ordered_list_sort(ordered_list_t*ll){ - ll->head = ordered_list_sort__sub(ll->head); - for(ll->tail = ll->head; ll->tail->next != NULL ; ll->tail=ll->tail->next){} + ordered_list_sort__quicksort(ll->head, ll->tail); } diff --git a/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_rdme.c b/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_rdme.c index ebfb148a..6b8709a1 100644 --- a/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_rdme.c +++ b/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_rdme.c @@ -321,7 +321,12 @@ void nsm_core__initialize_heap(system_t*system){ n->tt = -log(1.0-dsfmt_genrand_close_open(&dsfmt))/(p->rdme->srrate+p->rdme->sdrate); } //initialize_heap(rdme->rtimes,rdme->node,rdme->heap,rdme->Ncells); + //HERE + printf("before sort\n"); + print_heap(system); ordered_list_sort(rdme->heap); + printf("after sort\n"); + print_heap(system); } /**************************************************************************/ @@ -496,6 +501,28 @@ void nsm_core__destroy_diffusion_matrix(rdme_t*rdme){ } +/**************************************************************************/ +void print_heap(system_t*system){ + ordered_node_t*on,*bon,*aon; + printf("========================================================\n"); + on= system->rdme->heap->head; + bon=NULL; + aon=system->rdme->heap->head->next; + while(on!=NULL){ + printf("tt=%e, ",on->tt); + if( on->prev != bon || + on->next != aon ){ + printf("next/prev mismatch\n");exit(1); + } + on = on->next; + if(bon==NULL){bon=system->rdme->heap->head;}else{bon=bon->next;} + if(aon!=NULL){aon=aon->next;} + } + if(system->rdme->heap->tail != bon){ + printf("tail mismatch\n");exit(1); + } + printf("========================================================\n"); +} /**************************************************************************/ void nsm_core__take_step(system_t*system, double current_time, double step_size){ rdme_t*rdme = system->rdme; @@ -512,26 +539,7 @@ void nsm_core__take_step(system_t*system, double current_time, double step_size) neighbor_node_t*nn; - // Check the integrety of the heap -// ordered_node_t*on,*bon,*aon; -// printf("========================================================\n"); -// on= system->rdme->heap->head; -// bon=NULL; -// aon=system->rdme->heap->head->next; -// while(on!=NULL){ -// if( on->prev != bon || -// on->next != aon ){ -// printf("next/prev mismatch\n");exit(1); -// } -// on = on->next; -// if(bon==NULL){bon=system->rdme->heap->head;}else{bon=bon->next;} -// if(aon!=NULL){aon=aon->next;} -// } -// if(system->rdme->heap->tail != bon){ -// printf("tail mismatch\n");exit(1); -// } -// printf("========================================================\n"); - + //print_heap(system); /* Main loop. */ while(tt <= end_time){ diff --git a/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_threads.c b/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_threads.c index fc27c277..88060178 100644 --- a/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_threads.c +++ b/spatialpy/ssa_sdpd-c-simulation-engine/src/simulate_threads.c @@ -64,9 +64,7 @@ void* sort_index_thread(void* targ_in){ gettimeofday(&stop, NULL); if(debug_flag){ - printf("[SORT] sort complete "); - printf("took %lu us\n", (stop.tv_sec - start.tv_sec) * 1000000 + stop.tv_usec - start.tv_usec); - exit(1); + printf("[SORT] sort complete %lu us\n", (stop.tv_sec - start.tv_sec) * 1000000 + stop.tv_usec - start.tv_usec); } pthread_barrier_wait(&end_sort_barrier); }