Skip to content

Commit

Permalink
Rename svZeroDPlus to svZeroDSolver (SimVascular#91)
Browse files Browse the repository at this point in the history
Co-authored-by: Karthik Menon <[email protected]>
  • Loading branch information
menon-karthik and Karthik Menon authored Jan 4, 2024
1 parent 62253b9 commit 46e08d6
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow builds and deploys the html documentation for svZeroDPlus.
# This workflow builds and deploys the html documentation for svZeroDSolver.
name: Documentation
on: [push, pull_request]
permissions:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow builds and tests svZeroDPlus. It is built and tested on
# This workflow builds and tests svZeroDSolver. It is built and tested on
# different versions of ubuntu and macOS.
name: Build and test
on: [push, pull_request]
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Install ubuntu dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt update && sudo apt install build-essential cmake lcov
- name: Install svZeroDPlus
- name: Install svZeroDSolver
run: |
conda create -n zerod python=3.11.4
conda run -n zerod pip install -e ".[dev]"
Expand Down Expand Up @@ -59,10 +59,10 @@ jobs:
run: |
cd Release
cpack
cp distribution/svZeroDPlus_* ..
cp distribution/svZeroDSolver_* ..
- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }} installer
path: svZeroDPlus_*
if-no-files-found: error
path: svZeroDSolver_*
if-no-files-found: error
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ add_executable(svzerodcalibrator applications/svzerodcalibrator.cpp
)

# -----------------------------------------------------------------------------
# Setup building of the svzerodplus Python extension module.
# Setup building of the pysvzerod Python extension module.
# -----------------------------------------------------------------------------
# Replace EXCLUDE_FROM_ALL with SHARED to test building the Python
# shared library.
pybind11_add_module(svzerodplus EXCLUDE_FROM_ALL applications/svzerodplus.cpp)
pybind11_add_module(pysvzerod EXCLUDE_FROM_ALL applications/pysvzerod.cpp)

# -----------------------------------------------------------------------------
# Add source sub-directories.
Expand Down Expand Up @@ -185,7 +185,7 @@ target_include_directories(svzerodcalibrator PUBLIC
${CMAKE_SOURCE_DIR}/src/solve
)

target_include_directories(svzerodplus PUBLIC
target_include_directories(pysvzerod PUBLIC
${CMAKE_SOURCE_DIR}/src/algebra
${CMAKE_SOURCE_DIR}/src/model
${CMAKE_SOURCE_DIR}/src/optimize
Expand All @@ -203,13 +203,13 @@ target_link_libraries(svzerodsolver PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(svzerodcalibrator PRIVATE Eigen3::Eigen)
target_link_libraries(svzerodcalibrator PRIVATE nlohmann_json::nlohmann_json)

target_link_libraries(svzerodplus PRIVATE Eigen3::Eigen)
target_link_libraries(svzerodplus PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(svzerodplus PRIVATE pybind11_json)
target_link_libraries(svzerodplus PRIVATE svzero_algebra_library)
target_link_libraries(svzerodplus PRIVATE svzero_model_library)
target_link_libraries(svzerodplus PRIVATE svzero_optimize_library)
target_link_libraries(svzerodplus PRIVATE svzero_solve_library)
target_link_libraries(pysvzerod PRIVATE Eigen3::Eigen)
target_link_libraries(pysvzerod PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(pysvzerod PRIVATE pybind11_json)
target_link_libraries(pysvzerod PRIVATE svzero_algebra_library)
target_link_libraries(pysvzerod PRIVATE svzero_model_library)
target_link_libraries(pysvzerod PRIVATE svzero_optimize_library)
target_link_libraries(pysvzerod PRIVATE svzero_solve_library)


# Create distribution
Expand Down
4 changes: 2 additions & 2 deletions applications/svzerodplus.cpp → applications/pysvzerod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
* @file svzerodplus.cpp
* @file pysvzerod.cpp
* @brief Python interface for svZeroDSolver
*/
#include <pybind11/eigen.h>
Expand All @@ -42,7 +42,7 @@

namespace py = pybind11;

PYBIND11_MODULE(svzerodplus, m) {
PYBIND11_MODULE(pysvzerod, m) {
using Solver = Solver;
py::class_<Solver>(m, "Solver")
.def(py::init([](py::dict& config) {
Expand Down
12 changes: 6 additions & 6 deletions container/profiling/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ RUN apt-get -q update && \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY . /opt/svzerodplus
COPY . /opt/pysvzerod

RUN mkdir -p /opt/svzerodplus-build/relwithdebinfo && \
cd /opt/svzerodplus-build/relwithdebinfo && \
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo /opt/svzerodplus && \
RUN mkdir -p /opt/pysvzerod-build/relwithdebinfo && \
cd /opt/pysvzerod-build/relwithdebinfo && \
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo /opt/pysvzerod && \
cmake --build . --target svzerodsolver

WORKDIR /opt/data
RUN chmod +x /opt/svzerodplus/container/profiling/entrypoint.sh
ENTRYPOINT ["/opt/svzerodplus/container/profiling/entrypoint.sh"]
RUN chmod +x /opt/pysvzerod/container/profiling/entrypoint.sh
ENTRYPOINT ["/opt/pysvzerod/container/profiling/entrypoint.sh"]
4 changes: 2 additions & 2 deletions container/profiling/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash

export LIBPROFILER=$(find /usr/lib -name "libprofiler.so")
LD_PRELOAD=$LIBPROFILER CPUPROFILE=/opt/main.prof CPUPROFILE_FREQUENCY=100000 /opt/svzerodplus-build/relwithdebinfo/svzerodsolver $@ /opt/output.csv
google-pprof --pdf /opt/svzerodplus-build/relwithdebinfo/svzerodsolver /opt/main.prof > profiling_report.pdf
LD_PRELOAD=$LIBPROFILER CPUPROFILE=/opt/main.prof CPUPROFILE_FREQUENCY=100000 /opt/pysvzerod-build/relwithdebinfo/svzerodsolver $@ /opt/output.csv
google-pprof --pdf /opt/pysvzerod-build/relwithdebinfo/svzerodsolver /opt/main.prof > profiling_report.pdf
6 changes: 3 additions & 3 deletions distribution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ if(ENABLE_DISTRIBUTION)

# add description (shown in installer)
set(CPACK_PACKAGE_VERSION "${TODAY}")
set(CPACK_PACKAGE_NAME "svZeroDPlus")
set(CPACK_PACKAGE_NAME "svZeroDSolver")
set(CPACK_PACKAGE_VENDOR "SimVascular.org")
set(CPACK_PACKAGE_CONTACT "SimVascular <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "svZeroDPlus is a fast lumped-parameter solver for blood flow and pressure in hemodynamic networks")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "svZeroDSolver is a fast lumped-parameter solver for blood flow and pressure in hemodynamic networks")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.txt")

Expand Down Expand Up @@ -48,4 +48,4 @@ if(ENABLE_DISTRIBUTION)
set(CPACK_COMPONENTS_ALL applications libraries headers)

include(CPack)
endif()
endif()
2 changes: 1 addition & 1 deletion distribution/readme.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
svZeroDPlus is a fast lumped-parameter solver for blood flow and pressure in hemodynamic networks.
svZeroDSolver is a fast lumped-parameter solver for blood flow and pressure in hemodynamic networks.
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = svZeroDPlus
PROJECT_NAME = svZeroDSolver
PROJECT_NUMBER =
PROJECT_BRIEF =
PROJECT_LOGO =
Expand Down
14 changes: 7 additions & 7 deletions docs/pages/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

# Architecture

svZeroDPlus is written in a highly modular manner to enable reuse of code
svZeroDSolver is written in a highly modular manner to enable reuse of code
for many different applications. It is divided into a header based library
in the `src` directory and a collection of different applications in the
`applications` folder. Each application is written for a different use-case
of svZeroDPlus, namely:
of svZeroDSolver, namely:

* svZeroDCalibrator in `svzerodcalibrator.cpp`
* svZerodSolver in `svzerodsolver.cpp`
* Python API in `svzerodplus.cpp`
* Python API in `pysvzerod.cpp`

The header-based library in the `src` folder contains classes and functions that are collectively used by
all applications. A good overview over the general architecture can be found in the
Expand All @@ -21,7 +21,7 @@ all applications. A good overview over the general architecture can be found in

## Build in debug mode

For debug purposes it is recommended to build svZeroDPlus in Debug mode.
For debug purposes it is recommended to build svZeroDSolver in Debug mode.

```bash
mkdir Debug
Expand Down Expand Up @@ -69,7 +69,7 @@ make codecheck
```

If the above commands do not work on your platform (it does not work on Sherlock at Stanford)
you can run the following command **from the svZeroDPlus folder** to format all your files:
you can run the following command **from the svZeroDSolver folder** to format all your files:

```bash
find src/**/*.h src/**/*.cpp | xargs clang-format -style=Google -i
Expand Down Expand Up @@ -142,8 +142,8 @@ to create a profiling report. The generation of profiling reports requires
[Docker](https://docs.docker.com/get-docker/) to be installed on your machine.

```docker
docker build -t profile_svzerodplus -f container/profiling/Dockerfile .
docker run -it -v $(PWD):/opt/data --rm profile_svzerodplus path/to/simulation_config.json
docker build -t profile_svzerodsolver -f container/profiling/Dockerfile .
docker run -it -v $(PWD):/opt/data --rm profile_svzerodsolver path/to/simulation_config.json
```

This will generate a file called `profiling_report.pdf` in your current working directory.
46 changes: 23 additions & 23 deletions docs/pages/main.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@mainpage svZeroDPlus
@mainpage svZeroDSolver

[TOC]

svZeroDPlus is an application for performing simulations with 0D/lumped-parameter
svZeroDSolver is an application for performing simulations with 0D/lumped-parameter
computer models for cardiovascular flows.

Some noteworthy features of svZeroDPlus are:
Some noteworthy features of svZeroDSolver are:
* It is completely modular. Users can create custom flow models by arranging
blocks corresponding to blood vessels, junctions, different types of
boundary conditions, etc.
* It is written in C++ to enable high-performance applications.
* svZeroDPlus offers both a Python API and a C++ shared library to interface with other
* svZeroDSolver offers both a Python API and a C++ shared library to interface with other
Python or C++-based applications. This allows it to be used in a fully coupled manner
with other multi-physics solvers, and for parameter estimation, uncertainty
quantification, etc.
* The svZeroDCalibrator application, which is included in svZeroDPlus, optimizes 0D
* The svZeroDCalibrator application, which is included in svZeroDSolver, optimizes 0D
blood vessel parameters to recapitulate given time-varying flow and pressure measurements
(for example, from a high-fidelity 3D simulation). This allows users to build accurate
0D models that reflect observed hemodynamics.
Expand Down Expand Up @@ -44,13 +44,13 @@ You can find more details about governing equations in individual blocks, for ex
- BloodVesselJunction
- WindkesselBC

For implementation details, have a look at the [source code](https://github.com/StanfordCBCL/svZeroDPlus).
For implementation details, have a look at the [source code](https://github.com/simvascular/svZeroDSolver).

[About SimVascular](https://simvascular.github.io)

# Installation

svZeroDPlus can be installed in two different ways. For using the Python
svZeroDSolver can be installed in two different ways. For using the Python
API, an installation via pip is recommended.

## Using pip
Expand All @@ -59,12 +59,12 @@ For a pip installation, simply run the following command
(cloning of the repository is not required):

```bash
pip install git+https://github.com/StanfordCBCL/svZeroDPlus.git
pip install git+https://github.com/simvascular/svZeroDSolver.git
```

## Using CMake

If you want to build svZeroDPlus manually from source, clone the repository
If you want to build svZeroDSolver manually from source, clone the repository
and run the following commands from the top directory of the project:

```bash
Expand Down Expand Up @@ -115,38 +115,38 @@ For some applications it is beneficial to run svZeroDSolver directly
from within another program. For example, this can be
useful when many simulations need to be performed (e.g. for
calibration, uncertainty quantification, ...). It is also allows using
svZeroDPlus with other solvers, for example as boundary conditions or
svZeroDSolver with other solvers, for example as boundary conditions or
forcing terms.

### In C++

SvZeroDPlus needs to be built using CMake to use the shared library interface.
SvZeroDSolver needs to be built using CMake to use the shared library interface.

Detailed examples of interfacing with svZeroDPlus from C++ codes are available
in the test cases at `svZeroDPlus/tests/test_interface`.
Detailed examples of interfacing with svZeroDSolver from C++ codes are available
in the test cases at `svZeroDSolver/tests/test_interface`.

### In Python

Please make sure that
you installed svZerodPlus via pip to enable this feature. We start by
importing svzerodplus:
you installed svZerodSolver via pip to enable this feature. We start by
importing pysvzerod:

```python
>>> import svzerodplus
>>> import pysvzerod
```

Next, we create a solver from our configuration. The configuration can
be specified by either a path to a JSON file:

```python
>>> solver = svzerodplus.Solver("tests/cases/steadyFlow_RLC_R.json")
>>> solver = pysvzerod.Solver("tests/cases/steadyFlow_RLC_R.json")
```

or as a Python dictionary:

```python
>>> my_config = {...}
>>> solver = svzerodplus.Solver(my_config)
>>> solver = pysvzerod.Solver(my_config)
```

To run the simulation we add:
Expand Down Expand Up @@ -202,7 +202,7 @@ There is also a function to retrieve the full result directly based on a given c
```python

>>> my_config = {...}
>>> svzerodplus.simulate(my_config)
>>> pysvzerod.simulate(my_config)

name time flow_in flow_out pressure_in pressure_out
0 branch0_seg0 0.00 5.0 5.0 1100.0 600.0
Expand Down Expand Up @@ -342,14 +342,14 @@ The result will be written to a JSON file.
### In Python

svZeroDCalibrator can also be called directly from Python.
Please make sure that you installed svZerodPlus via pip to enable this feature. We start by
importing svzerodplus:
Please make sure that you installed svZerodSolver via pip to enable this feature. We start by
importing pysvzerod:

```python
import svzerodplus
import pysvzerod

my_unoptimized_config = {...}
my_optimized_config = svzerodplus.calibrate(my_unoptimized_config)
my_optimized_config = pysvzerod.calibrate(my_unoptimized_config)
```

## Configuration (file)
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
name = svzerodplus
name = pysvzerod
version = 2.0
description = A fast C++ application for working with 0D models.
long_description = file: README.md
Expand All @@ -18,5 +18,5 @@ dev =

[options.entry_points]
console_scripts =
svzerodsolver = svzerodplus:run_simulation_cli
svzerodcalibrator = svzerodplus:run_calibration_cli
svzerodsolver = pysvzerod:run_simulation_cli
svzerodcalibrator = pysvzerod:run_calibration_cli
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from cmake_setuptools import CMakeExtension, CMakeBuildExt

setup(
ext_modules=[CMakeExtension("svzerodplus")],
ext_modules=[CMakeExtension("pysvzerod")],
cmdclass={"build_ext": CMakeBuildExt},
)
8 changes: 5 additions & 3 deletions src/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,13 @@ void initialize(std::string input_file_arg, int& problem_id, int& pts_per_cycle,
num_output_steps = 1;
throw std::runtime_error(
"ERROR: Option output_mean_only has not been implemented when "
"using the svZeroDPlus interface library.");
"using the svZeroDSolver interface library.");
} else if (!simparams.output_all_cycles) {
num_output_steps = interface->pts_per_cycle_;
throw std::runtime_error(
"ERROR: Option output_last_cycle_only has been implemented but not "
"tested when using the svZeroDPlus interface library. Please test this "
"tested when using the svZeroDSolver interface library. Please test "
"this "
"functionality before removing this message.");
} else {
num_output_steps = interface->num_time_steps_;
Expand Down Expand Up @@ -510,7 +511,8 @@ void run_simulation(int problem_id, const double external_time,
start_time = interface->times_[start_idx];
throw std::runtime_error(
"ERROR: Option output_last_cycle_only has been implemented but not "
"tested when using the svZeroDPlus interface library. Please test this "
"tested when using the svZeroDSolver interface library. Please test "
"this "
"functionality before removing this message.");
}
for (int t = start_idx; t < num_output_steps; t++) {
Expand Down
4 changes: 2 additions & 2 deletions svzerodplus.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file contains the stubs for the public Python interface of svZeroDPlus.
# This file contains the stubs for the public Python interface of svZeroDSolver.
# This is necessary for supporting auto-completion in Visual Studio Code or
# PyCharm.
"""svZeroDPlus Python interface."""
"""svZeroDSolver Python interface."""
from __future__ import annotations
import numpy
import typing
Expand Down
Loading

0 comments on commit 46e08d6

Please sign in to comment.