Skip to content

Commit

Permalink
Merge branch 'pybamm-team:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cringeyburger authored Aug 8, 2024
2 parents 055ace0 + fa68ddc commit 2fc1911
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/periodic_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
LD_LIBRARY_PATH: $HOME/.local/lib

- name: Upload results as artifact
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: asv_periodic_results
path: results
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
CIBW_TEST_COMMAND: python -c "import pybamm; print(pybamm.IDAKLUSolver())"

- name: Upload Windows wheels
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: wheels_windows
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
- name: Upload wheels for Linux
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: wheels_manylinux
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
- name: Upload wheels for macOS (amd64, arm64)
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: wheels_${{ matrix.os }}
path: ./wheelhouse/*.whl
Expand All @@ -274,7 +274,7 @@ jobs:
run: pipx run build --sdist

- name: Upload SDist
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: sdist
path: ./dist/*.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_benchmarks_over_history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
${{ github.event.inputs.commit_start }}..${{ github.event.inputs.commit_end }}
- name: Upload results as artifact
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: asv_over_history_results
path: results
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: SARIF file
path: results.sarif
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.5"
rev: "v0.5.6"
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
4 changes: 2 additions & 2 deletions docs/source/user_guide/installation/install-from-docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ If you want to build the PyBaMM Docker image locally from the PyBaMM source code
docker run -it pybamm
5. Activate PyBaMM development environment inside docker container using:
5. Activate PyBaMM development virtual environment inside docker container using:

.. code-block:: bash
conda activate pybamm
source /home/pybamm/venv/bin/activate
.. note::

Expand Down
40 changes: 20 additions & 20 deletions pybamm/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def set_parameters(self):
A method to set the parameters in the model and the associated geometry.
"""

if self.model_with_set_params:
if self._model_with_set_params:
return

self._model_with_set_params = self._parameter_values.process_model(
Expand All @@ -235,7 +235,7 @@ def set_initial_soc(self, initial_soc, inputs=None):
self.steps_to_built_models = None
self.steps_to_built_solvers = None

options = self.model.options
options = self._model.options
param = self._model.param
if options["open-circuit potential"] == "MSMR":
self._parameter_values = (
Expand Down Expand Up @@ -287,7 +287,7 @@ def build(self, initial_soc=None, inputs=None):
if initial_soc is not None:
self.set_initial_soc(initial_soc, inputs=inputs)

if self.built_model:
if self._built_model:
return
elif self._model.is_discretised:
self._model_with_set_params = self._model
Expand Down Expand Up @@ -486,7 +486,7 @@ def solve(
)

self._solution = solver.solve(
self.built_model, t_eval, inputs=inputs, **kwargs
self._built_model, t_eval, inputs=inputs, **kwargs
)

elif self.operating_mode == "with experiment":
Expand Down Expand Up @@ -875,17 +875,17 @@ def solve(
if feasible is False:
break

if self.solution is not None and len(all_cycle_solutions) > 0:
self.solution.cycles = all_cycle_solutions
self.solution.set_summary_variables(all_summary_variables)
self.solution.all_first_states = all_first_states
if self._solution is not None and len(all_cycle_solutions) > 0:
self._solution.cycles = all_cycle_solutions
self._solution.set_summary_variables(all_summary_variables)
self._solution.all_first_states = all_first_states

callbacks.on_experiment_end(logs)

# record initial_start_time of the solution
self.solution.initial_start_time = initial_start_time
self._solution.initial_start_time = initial_start_time

return self.solution
return self._solution

def run_padding_rest(self, kwargs, rest_time, step_solution, inputs):
model = self.steps_to_built_models["Rest for padding"]
Expand Down Expand Up @@ -951,15 +951,15 @@ def step(

self._solution = solver.step(
starting_solution,
self.built_model,
self._built_model,
dt,
t_eval=t_eval,
save=save,
inputs=inputs,
**kwargs,
)

return self.solution
return self._solution

def _get_esoh_solver(self, calc_esoh):
if (
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def create_gif(self, number_of_images=80, duration=0.1, output_filename="plot.gi
Name of the generated GIF file.
"""
if self.solution is None:
if self._solution is None:
raise ValueError("The simulation has not been solved yet.")
if self.quick_plot is None:
self.quick_plot = pybamm.QuickPlot(self._solution)
Expand Down Expand Up @@ -1128,14 +1128,14 @@ def save_model(
be available when the model is read back in and solved.
variables: bool
The discretised variables. Not required to solve a model, but if false
tools will not be availble. Will automatically save meshes as well, required
tools will not be available. Will automatically save meshes as well, required
for plotting tools.
filename: str, optional
The desired name of the JSON file. If no name is provided, one will be
created based on the model name, and the current datetime.
"""
mesh = self.mesh if (mesh or variables) else None
variables = self.built_model.variables if variables else None
mesh = self._mesh if (mesh or variables) else None
variables = self._built_model.variables if variables else None

if self.operating_mode == "with experiment":
raise NotImplementedError(
Expand All @@ -1144,9 +1144,9 @@ def save_model(
"""
)

if self.built_model:
if self._built_model:
Serialise().save_model(
self.built_model, filename=filename, mesh=mesh, variables=variables
self._built_model, filename=filename, mesh=mesh, variables=variables
)
else:
raise NotImplementedError(
Expand Down Expand Up @@ -1183,11 +1183,11 @@ def plot_voltage_components(
Keyword arguments, passed to ax.fill_between.
"""
if self.solution is None:
if self._solution is None:
raise ValueError("The simulation has not been solved yet.")

return pybamm.plot_voltage_components(
self.solution,
self._solution,
ax=ax,
show_legend=show_legend,
split_by_electrode=split_by_electrode,
Expand Down
21 changes: 11 additions & 10 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM continuumio/miniconda3:latest
FROM python:3.12-slim-bullseye
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

WORKDIR /

Expand All @@ -21,17 +22,17 @@ ENV CMAKE_CXX_COMPILER=/usr/bin/g++
ENV CMAKE_MAKE_PROGRAM=/usr/bin/make
ENV LD_LIBRARY_PATH=/home/pybamm/.local/lib

RUN conda create -n pybamm python=3.11
RUN conda init --all
SHELL ["conda", "run", "-n", "pybamm", "/bin/bash", "-c"]
RUN conda install -y pip
# Create a virtual environment
ENV VIRTUAL_ENV=/home/pybamm/venv
RUN uv venv $VIRTUAL_ENV
RUN #!/bin/bash && source /home/pybamm/venv/bin/activate;
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN pip install --upgrade --user pip setuptools wheel wget
RUN pip install cmake
RUN uv pip install --upgrade setuptools wheel wget cmake

RUN python scripts/install_KLU_Sundials.py && \
rm -rf pybind11 && \
git clone https://github.com/pybind/pybind11.git && \
pip install --user -e ".[all,dev,docs,jax]";
rm -rf pybind11 && \
git clone https://github.com/pybind/pybind11.git && \
uv pip install -e ".[all,dev,docs,jax]";

ENTRYPOINT ["/bin/bash"]

0 comments on commit 2fc1911

Please sign in to comment.