From b36d8a748d3a8e61b67e8dd874a7286ae6d353a3 Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Fri, 8 Mar 2024 17:04:58 +0100 Subject: [PATCH] Check in stuff --- experiments/batch/julian-animation | 24 ++ experiments/batch/measurements/.gitkeep | 0 experiments/configs/julian-animation.json | 330 ++++++++++++++++++++++ experiments/scripts/gen/weak.py | 107 +++++++ experiments/scripts/timing.py | 14 + experiments/templates/spheroid_weak.json | 100 +++++++ 6 files changed, 575 insertions(+) create mode 100644 experiments/batch/julian-animation create mode 100644 experiments/batch/measurements/.gitkeep create mode 100644 experiments/configs/julian-animation.json create mode 100644 experiments/scripts/gen/weak.py create mode 100644 experiments/templates/spheroid_weak.json diff --git a/experiments/batch/julian-animation b/experiments/batch/julian-animation new file mode 100644 index 0000000..eddb902 --- /dev/null +++ b/experiments/batch/julian-animation @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +#SBATCH --job-name=julian-animation +#SBATCH --account=hkf6 +#SBATCH --partition=booster +#SBATCH --nodes=8 +#SBATCH --ntasks=32 +# Counted per node +#SBATCH --gres=gpu:4 +#SBATCH --time=03:30:00 +#SBATCH --output=logs/%x-%A_%a.log +#SBATCH --error=logs/%x-%A_%a.log + +SOURCE_DIR=/p/project/cellsinsilico/paulslustigebude +OUTPUT_DIR="/p/scratch/cellsinsilico/paul/nastja-out/${SLURM_JOB_NAME}" + +echo "outdir is ${OUTPUT_DIR}" + +mkdir -p "${OUTPUT_DIR}" +source "${SOURCE_DIR}/activate-nastja-modules" + +srun --unbuffered "${SOURCE_DIR}/nastja/build-cuda/nastja" \ + -c "${SOURCE_DIR}/ma/experiments/configs/${SLURM_JOB_NAME}.json" \ + -o "${OUTPUT_DIR}" diff --git a/experiments/batch/measurements/.gitkeep b/experiments/batch/measurements/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/experiments/configs/julian-animation.json b/experiments/configs/julian-animation.json new file mode 100644 index 0000000..228749a --- /dev/null +++ b/experiments/configs/julian-animation.json @@ -0,0 +1,330 @@ +{ + "Comments": [ + "Celltype Usage", + "0 Dynamic ECM", + "1-5 Not Used", + "6 Liquid ", + "7 Apoptotic cell Type ", + "8 Basic Non Dividing Cell type (surrounding)", + "9 Cancer" + ], + "Application": "Cells", + "CellsInSilico": { + "ecmdegradation": { + "enabled": "false", + "steps": 99999, + "stochastic": "true", + "probability": 0.5 + }, + "energyfunctions": [ + "Volume00", + "Surface01", + "Motility00", + "Adhesion01", + "DynamicECM00" + ], + "liquid": 6, + "volume": { + "default": { + "storage": "const", + "value": 500 + }, + "lambda": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 7.5, + 7.5, + 7.5 + ], + "sizechange": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -0.05, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "surface": { + "default": { + "storage": "const", + "value": 400 + }, + "lambda": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 5.625, + 5.625, + 1 + ], + "sizechange": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -0.05, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "adhesion": { + "matrix": [ + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 450 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + 0, + 450, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 50 + ] + ] + }, + "temperature": 50, + "division": { + "enabled": "true", + "condition": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "( volume >= 0.9 * volume0 ) & ( rnd() <= 0.00001 ) & generation < 1" + ] + }, + "centerofmass": { + "steps": 1 + }, + "signaling": { + "enabled": false + }, + "orientation": { + "enabled": true, + "motility": "persistentRandomWalk", + "persistenceMagnitude": 0.0, + "recalculationtime": 200, + "motilityamount": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "visitor": { + "stepwidth": 10, + "checkerboard": "01" + }, + "cleaner": { + "killDistance": 20 + }, + "dynamicecm": { + "enabled": true, + "stepsPerMcs": 100, + "pushSteps": 10, + "pushWeight": 2, + "ecmCellID": 0, + "deltat": 0.1, + "eta": 0.25, + "k0": 0.1, + "k1": 0.1, + "c": 4, + "alpha": 2, + "d": 0.3, + "phi": 1 + } + }, + "Geometry": { + "blockcount": [ + 2, + 4, + 4 + ], + "blocksize": [ + 200, + 100, + 100 + ] + }, + "Settings": { + "randomseed": 0, + "timesteps": 5000, + "statusoutput": 1 + }, + "WriteActions": ["ParallelVTK_Cells", "ParallelVTK_Displacement"], + "Writers": { + "CellInfo": { + "field": "", + "groupsize": 0, + "steps": 1, + "writer": "CellInfo" + }, + "ParallelVTK_Cells": { + "field": "cells", + "outputtype": "UInt32", + "printhints": false, + "steps": 100, + "writer": "ParallelVtkImage" + }, + "ParallelVTK_Displacement": { + "writer": "ParallelVtkImage", + "outputtype": "Float32", + "field": "dynamicecm", + "components": [ + 0, + 1, + 2 + ], + "steps": 100 + } + }, + "Include": "measurements/strong/config_filling_1.json" +} diff --git a/experiments/scripts/gen/weak.py b/experiments/scripts/gen/weak.py new file mode 100644 index 0000000..cfa7180 --- /dev/null +++ b/experiments/scripts/gen/weak.py @@ -0,0 +1,107 @@ +import copy +import json + +from dataclasses import dataclass + +configurations = [ + (1, 1, 1), + (1, 1, 2), + (1, 2, 2), + (2, 2, 2), + (2, 2, 4), + (2, 4, 4), + (4, 4, 4), + (4, 4, 8), + (4, 8, 8), + (8, 8, 8) +] + +with open("templates/spheroid_weak.json") as template_file: + template = json.load(template_file) + +SIZE_X = 400 +SIZE_Y = 400 +SIZE_Z = 400 + +for bx, by, bz in configurations: + nastja_config = copy.deepcopy(template) + nastja_config["Geometry"]["blockcount"] = [bx, by, bz] + nastja_config["Geometry"]["blocksize"] = [SIZE_X, SIZE_Y, SIZE_Z] + + # Fill the whole domain with ECM + cells_filling = [ + { + "shape": "cube", + "box": [ + [0, 0, 0], + [bx * SIZE_X, by * SIZE_Y, bz * SIZE_Z] + ], + "value": 0, + "celltype": 0 + } + ] + + # Place a bunch of cells in each block to keep each rank busy + for z in range(bz): + for y in range(by): + for x in range(bx): + sx = x * SIZE_X + sy = y * SIZE_Y + sz = z * SIZE_Z + cells_filling.append({ + "shape": "sphere", + "pattern": "voronoi", + "count": 5500, + "radius": 75, + "center": [sx + 200, sy + 200, sz + 200], + "box": [ + [sx + 110, sy + 110, sz + 110], + [sx + 290, sy + 290, sz + 290] + ], + "celltype": 9 + }) + nastja_config["Filling"]["cells"] = cells_filling + + ntasks = bx * by * bz + if ntasks < 4: + nodes = 1 + gpus_per_node = ntasks + else: + assert ntasks % 4 == 0 + nodes = ntasks // 4 + gpus_per_node = 4 + + label = f"weak400-t{ntasks:04}n{nodes:03}g{gpus_per_node}x{bx}y{by}z{bz}" + + with open(f"configs/measurements/weak/spheroid_{label}.json", "w") as config_file: + json.dump(nastja_config, config_file, indent=2) + + batch_config = f"""#!/usr/bin/env bash + +#SBATCH --job-name={label} +#SBATCH --account=hkf6 +#SBATCH --partition=booster +#SBATCH --nodes={nodes} +#SBATCH --ntasks={ntasks} +# Counted per node +#SBATCH --gres=gpu:{gpus_per_node} +#SBATCH --time=00:15:00 +#SBATCH --output=logs/{label}-%A_%a.log +#SBATCH --error=logs/{label}-%A_%a.log +#SBATCH --array=1-5 + +SOURCE_DIR=/p/project/cellsinsilico/paulslustigebude +OUTPUT_DIR="/p/scratch/cellsinsilico/paul/nastja-out/{label}-${{SLURM_ARRAY_TASK_ID}}" + +echo "outdir is ${{OUTPUT_DIR}}" + +mkdir -p "${{OUTPUT_DIR}}" +source "${{SOURCE_DIR}}/activate-nastja-modules" + +srun --unbuffered "${{SOURCE_DIR}}/nastja/build-cuda/nastja" \\ + -c "${{SOURCE_DIR}}/ma/experiments/configs/measurements/weak/spheroid_{label}.json" \\ + -o "${{OUTPUT_DIR}}" +""" + + with open(f"batch/measurements/weak/{label}", "w", encoding="utf8") as batch_config_file: + batch_config_file.write(batch_config) diff --git a/experiments/scripts/timing.py b/experiments/scripts/timing.py index 2ac7c96..1c5cc5b 100644 --- a/experiments/scripts/timing.py +++ b/experiments/scripts/timing.py @@ -128,5 +128,19 @@ def strong_dat(db, time): for tasks, time in values: print(f"{tasks}\t{time}") +@timing.command() +@click.option("--db", default="timings.db", help="Path of sqlite database file") +def weak_dat(db): + db = sqlite3.connect(db) + c = db.cursor() + res = c.execute(""" + select tasks, avg(averagetime) as mean from timings group by tasks order by tasks asc + """) + values = res.fetchall() + + print("gpus\tefficiency") + for tasks, mean in values: + print(f"{tasks}\t{values[0][1] / mean}") + if __name__ == "__main__": timing() diff --git a/experiments/templates/spheroid_weak.json b/experiments/templates/spheroid_weak.json new file mode 100644 index 0000000..c132bf9 --- /dev/null +++ b/experiments/templates/spheroid_weak.json @@ -0,0 +1,100 @@ +{ + "Comments": ["Celltype Usage", "0 Dynamic ECM", "1-5 Not Used", "6 Liquid ", "7 Apoptotic cell Type ", "8 Basic Non Dividing Cell type (surrounding)", "9 Cancer"], + "Application": "Cells", + "CellsInSilico": { + "ecmdegradation": { + "enabled": "false", + "steps": 99999, + "stochastic": "true", + "probability": 0.5 + }, + "energyfunctions": ["Volume00", "Surface01", "Motility00", "Adhesion01", "DynamicECM00"], + "liquid": 6, + "volume": { + "default": { + "storage": "const", + "value": 500 + }, + "lambda": [0, 0, 0, 0, 0, 0, 0, 7.5, 7.5, 7.5], + "sizechange": [0, 0, 0, 0, 0, 0, 0, -0.05, 0, 0, 0, 0, 0, 0, 0] + }, + "surface": { + "default": { + "storage": "const", + "value": 400 + }, + "lambda": [0, 0, 0, 0, 0, 0, 0, 5.625, 5.625, 1], + "sizechange": [0, 0, 0, 0, 0, 0, 0, -0.05, 0, 0, 0, 0, 0, 0, 0, 0] + }, + "adhesion": { + "matrix": [ + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 450], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 450, 0, 0, 0, 0, 0, 0, 0, 50] + ] + }, + "temperature": 50, + "division": { + "enabled": "true", + "condition": ["", "", "", "", "", "", "", "", "", "( volume >= 0.9 * volume0 ) & ( rnd() <= 0.00001 ) & generation < 1"] + }, + "centerofmass": { + "steps": 1 + }, + "signaling": { + "enabled": false + }, + "orientation": { + "enabled": true, + "motility": "persistentRandomWalk", + "persistenceMagnitude": 0.0, + "recalculationtime": 200, + "motilityamount": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + }, + "visitor": { + "stepwidth": 10, + "checkerboard": "01" + }, + "cleaner": { + "killDistance": 20 + }, + "dynamicecm": { + "enabled": true, + "stepsPerMcs": 100, + "pushSteps": 10, + "pushWeight": 2, + "ecmCellID": 0, + "deltat": 0.1, + "eta": 0.25, + "k0": 0.1, + "k1": 0.1, + "c": 4, + "alpha": 2, + "d": 0.3, + "phi": 1 + } + }, + "Geometry": { + "blockcount": null, + "blocksize": null + }, + "Settings": { + "randomseed": 0, + "timesteps": 20, + "statusoutput": 1 + }, + "DefineFunctions": [ + "r_angle()=360*rnd()", + "r_size()=400*rnd()" + ], + "Filling": { + "cells": null + } +}