Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Andres joss review #83

Merged
merged 9 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test Conda Installation

# This triggers the workflow on any push to the repository
on:
push:
branches:
- "**"
pull_request:

jobs:
test:
name: Test Conda Installation and Setup
runs-on: ubuntu-latest

# Steps to run
steps:
# Checkout the repo content to the runner
- name: Checkout repository
uses: actions/checkout@v2

# Set up Miniconda
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
channels: conda-forge, defaults
auto-update-conda: true
auto-activate-base: true

# Create the environment and install dependencies
- name: Create and activate conda environment
run: |
echo "Creating the conda environment: fenicsx-env"
conda create -n fenicsx-env -c conda-forge fenics-dolfinx=0.7.2 mpich pyvista sympy pandas pyyaml -y
echo "Activating the conda environment"
source $(conda info --base)/etc/profile.d/conda.sh # Fix to allow `conda activate`
conda activate fenicsx-env
echo "Environment created and activated. Now, verifying installation..."
conda list # Print all installed packages for verification
which python # Verify the Python interpreter being used


# Install the irrevolutions package in the conda environment
- name: Install irrevolutions
run: |
source $(conda info --base)/etc/profile.d/conda.sh # Ensure conda is properly initialized
echo "Installing irrevolutions package"
conda activate fenicsx-env
python -m pip install . # Assuming irrevolutions is in the current directory
echo "irrevolutions package installed"

# Optionally run tests within the environment
- name: Run tests
run: |
source $(conda info --base)/etc/profile.d/conda.sh # Ensure conda is properly initialized
echo "Running tests"
conda activate fenicsx-env
cd test && pytest -v . || echo "Tests failed"
49 changes: 49 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test Ubuntu Installation

# This triggers the workflow on any push to the repository
on:
push:
branches:
- "**"
pull_request:

jobs:
test:
name: Test Ubuntu/apt Installation and Setup
runs-on: ubuntu-latest

# Steps to run
steps:
# Checkout the repo content to the runner
- name: Checkout repository
uses: actions/checkout@v2

# Install Ubuntu dependencies via APT
- name: Install system dependencies via APT
run: |
echo "Installing required system dependencies via APT"
sudo apt-get update
sudo apt-get install -y software-properties-common python3-pip git libgl1-mesa-glx xvfb libglu1 libxcursor1 libxinerama1

# Add the FEniCS PPA and install fenicsx
- name: Install fenicsx
run: |
echo "Adding FEniCS PPA and installing fenicsx"
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt update
sudo apt-get install -y fenicsx

# Install irrevolutions dependencies (if any) and the package itself
- name: Install Python dependencies and irrevolutions
run: |
echo "Installing Python dependencies and irrevolutions"
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt # Adjust this if you're using a different file for dependencies
python3 -m pip install . # Install irrevolutions package

# Optionally run tests within the environment
- name: Run tests
run: |
echo "Running tests"
conda activate fenicsx-env
cd test && pytest -v . || echo "Tests failed"
6 changes: 5 additions & 1 deletion .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ jobs:

- name: Install dependencies
run: python3 -m pip install .


- name: List installed packages
run: |
pip list

- name: Test import
run: python3 -c "import irrevolutions"

Expand Down
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,30 @@ https://docs.godotengine.org/en/3.1/community/contributing/pr_workflow.html

### Installation

Before installing `irrevolutions`, ensure you have `dolfinx` and other dependencies installed. You can install `dolfinx` using one of the following methods:
Before installing `irrevolutions`, ensure you have `dolfinx` and other dependencies installed.

DOLFINx (and some other libraries like MPI and PyVista) have complex dependencies, it may be best to install them using conda from the conda-forge channel. Conda handles the environment setup and dependency conflicts well for these low-level libraries. Otherwise, you install from source using Spack or us a pre-built docker image.

Then, install your Python package dependencies with Poetry. After installing system-level dependencies with Conda (or another method), you can use Poetry to manage the Python-specific packages and virtual environment for your project. Poetry will not attempt to reinstall DOLFINx or other system-level packages.

More specifically, you can install `dolfinx` using one of the following methods:

- Using conda
```
conda create -n fenicsx-env -c conda-forge fenics-dolfinx=0.7.2 mpich pyvista
conda create -n fenicsx-env -c conda-forge fenics-dolfinx=0.7.2 mpich pyvista sympy pandas pyyaml
conda activate fenicsx-env
```

- Using Spack
see https://github.com/FEniCS/dolfinx/blob/main/README.md#spack

- Using Apt (ubuntu)
- Using Apt (ubuntu 23.04 build)
```
apt-get install -y software-properties-common python3-pip git libgl1-mesa-glx xvfb libglu1 libxcursor1 libxinerama1

add-apt-repository ppa:fenics-packages/fenics
apt update
apt install fenicsx=1:0.7.3-3~ppa1~lunar1
apt-install fenicsx
```

For detailed instructions, see https://github.com/FEniCS/dolfinx/blob/main/README.md#installation
Expand All @@ -63,8 +71,26 @@ For a windows box:
docker run --rm -ti -v "C:/...":/home/numerix" -w /home/numerix kumiori3\numerix:stable-amd64
```

Finally, to install `irrevolutions` head to the package root directory and run

We recommend using Poetry to manage Python dependencies and the virtual environment for the project. Follow the instructions below to install Poetry and set up the environment.

```
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
```

Clone this repository:

```
git clone https://github.com/kumiori/irrevolutions.git
cd irrevolutions
```


Finally, to install `irrevolutions` with poetry run
```poetry install```

Alternatively, `irrevolutions` can be installed using setuptools from the root directory
```python3 -m pip install .```


Expand All @@ -77,7 +103,6 @@ This code was initially conceived as a support for the teaching course MEC647,

### Acknowledgements


To all the students for their effort, participation, and motivation.

This project contains code from the DOLFINy project (https://github.com/fenics-dolfiny/dolfiny), which is licensed under the LGPLv3 license. We acknowledge and thank the DOLFINy contributors for their work.
Expand Down
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["Your Name <[email protected]>"]

# Optional dependencies are specified in this section
[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
pandas = "^1.2"
sympy = "^1.8"
pytest = "^6.0"
Expand All @@ -26,3 +26,17 @@ dolfinx_support = []

[tool.poetry.scripts]
irrevolutions = 'irrevolutions:main'

# Ensure that non-code files (e.g., default_parameters.yml) are included in the package
[tool.poetry.include]
irrevolutions = ["src/irrevolutions/models/default_parameters.yml"]

# Additional files to include (e.g., readme, licenses, configs)
include = [
"README.md",
"LICENSE",
"src/irrevolutions/models/default_parameters.yml"
]

[tool.poetry.packages]
irrevolutions = { from = "src/irrevolutions" }
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
package_dir={"": "src"}, # The root package is under the 'src' directory
packages=find_packages("src"), # Find packages under the 'src' directory
include_package_data=True,
description="A Python package for solving nonlinear and nonconvex evolutionary problems using a general energetic notion of stability and dolfinx.",
author="Andrés A León Baldelli",
author_email="[email protected]",
url="https://github.com/kumiori3/irrevolutions", # Replace with your repo

package_data={
"irrevolutions.models": ["default_parameters.yml"],
},
python_requires=">=3.9",

)
24 changes: 24 additions & 0 deletions src/irrevolutions/solvers/slepcblockproblem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@

from .function import vec_to_functions

# -----------------------------------------------------------------------------
# License
# The code is based on dolfiny, by Michal Habera and Andreas Zilian.
# dolfiny is free software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# dolfiny is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along with
# dolfiny. If not, see http://www.gnu.org/licenses/.
#
# The original code can be found at:
# https://github.com/fenics-dolfiny/dolfiny
#
# Original Authors:
# Michal Habera, Rafinex, Luxembourg.
# Andreas Zilian, University of Luxembourg, Luxembourg.
#
# Modifications and contributions:
# Andrés A León Baldelli, CNRS.
# -----------------------------------------------------------------------------

class SLEPcBlockProblem:
def __init__(
Expand Down
24 changes: 24 additions & 0 deletions src/irrevolutions/solvers/snesblockproblem.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@

from .function import functions_to_vec, vec_to_functions

# -----------------------------------------------------------------------------
# License
# The code is based on dolfiny, by Michal Habera and Andreas Zilian.
# dolfiny is free software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# dolfiny is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along with
# dolfiny. If not, see http://www.gnu.org/licenses/.
#
# The original code can be found at:
# https://github.com/fenics-dolfiny/dolfiny
#
# Original Authors:
# Michal Habera, Rafinex, Luxembourg.
# Andreas Zilian, University of Luxembourg, Luxembourg.
#
# Modifications and contributions:
# Andrés A León Baldelli, CNRS.
# -----------------------------------------------------------------------------

class SNESBlockProblem:
def __init__(
Expand Down
Loading