diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a17e372126..bdfae9f8af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,14 +41,14 @@ jobs: - name: Install Apt dependencies run: | sudo apt update - sudo apt install libboost-dev gfortran libopenmpi-dev libblas-dev \ - liblapack-dev libhdf5-dev + sudo apt install libboost-dev gfortran libopenmpi-dev libopenblas-openmp-dev \ + libhdf5-dev gcc --version - name: Upgrade pip run: python3 -m pip install -U pip setuptools wheel - name: Install Python dependencies run: | - python3 -m pip install ruamel.yaml scons==3.1.2 + python3 -m pip install ruamel.yaml scons==4.0.1 packaging - name: Build Cantera run: | python3 `which scons` build env_vars=all -j4 debug=n --debug=time \ @@ -66,23 +66,25 @@ jobs: timeout-minutes: 60 strategy: matrix: - python-version: ['3.8', '3.10', '3.11', '3.12', '3.13'] - os: ['ubuntu-20.04', 'ubuntu-22.04'] + python-version: ['3.10', '3.11', '3.12', '3.13'] + os: ['ubuntu-24.04'] numpy: [''] cython: [''] include: # Keep some test cases with NumPy 1.x until we drop support - python-version: '3.12' - os: 'ubuntu-24.04' + os: 'ubuntu-22.04' numpy: "'<2.0'" # Keep some test cases with older Cython versions - python-version: '3.10' - os: 'ubuntu-24.04' + os: 'ubuntu-22.04' cython: "==0.29.31" # minimum supported version - python-version: '3.11' - os: 'ubuntu-24.04' + os: 'ubuntu-22.04' cython: "==3.0.8" # System version for Ubuntu 24.04 - + - python-version: '3.13' + os: 'ubuntu-22.04' + numpy: "'<2.2'" fail-fast: false steps: - uses: actions/checkout@v4 @@ -97,14 +99,14 @@ jobs: - name: Install Apt dependencies run: | sudo apt update - sudo apt install libboost-dev gfortran libopenmpi-dev libblas-dev \ - liblapack-dev libhdf5-dev libfmt-dev + sudo apt install libboost-dev gfortran libopenmpi-dev libopenblas-openmp-dev \ + libhdf5-dev libfmt-dev gcc --version - name: Upgrade pip run: python3 -m pip install -U pip setuptools wheel - name: Install Python dependencies run: | - python3 -m pip install ruamel.yaml scons==3.1.2 numpy${{ matrix.numpy }} \ + python3 -m pip install ruamel.yaml scons==4.0.1 numpy${{ matrix.numpy }} \ cython${{ matrix.cython }} pandas pytest \ pytest-github-actions-annotate-failures pytest-xdist pint graphviz - name: Build Cantera @@ -138,7 +140,7 @@ jobs: if-no-files-found: error clang-compiler: - name: LLVM/Clang with Python 3.8 + name: LLVM/Clang with Python 3.13 runs-on: ubuntu-22.04 timeout-minutes: 60 steps: @@ -149,12 +151,13 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: '3.13' architecture: x64 - name: Install Apt dependencies run: | sudo apt update - sudo apt install libboost-dev gfortran libomp-dev libomp5 libopenblas-dev libhdf5-dev + sudo apt install libboost-dev gfortran libomp-dev libomp5 \ + libopenblas-openmp-dev libhdf5-dev - name: Upgrade pip run: python3 -m pip install -U pip setuptools wheel - name: Install Python dependencies @@ -185,7 +188,7 @@ jobs: python-version: ['3.12', '3.13'] include: - macos-version: 'macos-13' - python-version: '3.8' + python-version: '3.11' - macos-version: 'macos-14' python-version: '3.10' extra-build-args: cxx_flags='-std=c++20' @@ -257,7 +260,8 @@ jobs: - name: Install Apt dependencies run: | sudo apt update - sudo apt install libboost-dev gfortran liblapack-dev libblas-dev libsundials-dev libhdf5-dev + sudo apt install libboost-dev gfortran libopenblas-openmp-dev libsundials-dev \ + libhdf5-dev gcc --version - name: Upgrade pip run: python3 -m pip install -U pip setuptools wheel @@ -269,7 +273,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.x' + dotnet-version: '8.x' - name: Build Cantera run: | python3 `which scons` build blas_lapack_libs=lapack,blas coverage=y \ @@ -347,7 +351,7 @@ jobs: run: | sudo apt update sudo apt install libboost-dev graphviz texlive-bibtex-extra \ - libblas-dev liblapack-dev libhdf5-dev libfmt-dev libsundials-dev + libopenblas-openmp-dev libhdf5-dev libfmt-dev libsundials-dev - name: Upgrade pip run: pip install -U pip setuptools wheel - name: Install Python dependencies @@ -460,33 +464,34 @@ jobs: matrix: # Keep some test cases with NumPy 1.x until we explicitly drop support include: - - os: "ubuntu-20.04" - python-version: "3.8" - numpy: "" - os: "ubuntu-22.04" - python-version: "3.8" + python-version: "3.10" numpy: "" - - os: "ubuntu-20.04" + libhdf5: "libhdf5-103" + - os: "ubuntu-24.04" python-version: "3.10" numpy: "==1.21.6" - - os: "ubuntu-22.04" - python-version: "3.10" - numpy: "" + libhdf5: "libhdf5-103-1t64" - os: "ubuntu-22.04" python-version: "3.11" numpy: "==1.23.5" - - os: "ubuntu-20.04" + libhdf5: "libhdf5-103" + - os: "ubuntu-24.04" python-version: "3.11" numpy: "" + libhdf5: "libhdf5-103-1t64" - os: "ubuntu-22.04" python-version: "3.12" numpy: "==1.26.4" - - os: "ubuntu-20.04" + libhdf5: "libhdf5-103" + - os: "ubuntu-24.04" python-version: "3.12" numpy: "" + libhdf5: "libhdf5-103-1t64" - os: "ubuntu-22.04" python-version: "3.13" numpy: "" + libhdf5: "libhdf5-103" fail-fast: false steps: # We're not building Cantera here, we only need the checkout for the samples @@ -501,7 +506,7 @@ jobs: - name: Install Apt dependencies run: | sudo apt update - sudo apt install graphviz libhdf5-103 libfmt-dev + sudo apt install graphviz ${{ matrix.libhdf5 }} libfmt-dev libopenblas0-openmp - name: Download the wheel artifact uses: actions/download-artifact@v4 with: @@ -554,17 +559,13 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 env: - PYTHON_VERSION: 3.8 + PYTHON_VERSION: '3.13' defaults: run: shell: bash -l {0} strategy: matrix: include: - - sundials-ver: 3 - fmt-ver: 6.1.2 - - sundials-ver: 4 - fmt-ver: 8.1 - sundials-ver: 5.8 fmt-ver: 9.1 - sundials-ver: 6.4.1 @@ -629,14 +630,14 @@ jobs: strategy: matrix: include: - - python-version: '3.8' + - python-version: '3.13' fmt-ver: '10' - python-version: '3.10' fmt-ver: '8.1' - python-version: '3.11' fmt-ver: '9.1' - python-version: '3.12' - fmt-ver: '7.1' + fmt-ver: '10.0' - python-version: '3.13' fmt-ver: '11.0' extra-build-args: cxx_flags='/EHsc /std:c++20 /utf-8' @@ -714,7 +715,7 @@ jobs: strategy: matrix: vs-toolset: ['14.2'] - python-version: ["3.8", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] fail-fast: false steps: - uses: actions/checkout@v4 @@ -760,7 +761,7 @@ jobs: # Adapted from https://www.scivision.dev/intel-oneapi-github-actions/ linux-intel-oneapi: - name: intel-oneAPI on Ubuntu, Python 3.8 + name: intel-oneAPI on Ubuntu, Python 3.12 runs-on: ubuntu-latest timeout-minutes: 60 env: @@ -787,7 +788,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: '3.12' architecture: x64 - name: Upgrade pip run: python3 -m pip install -U pip setuptools wheel @@ -912,12 +913,12 @@ jobs: - name: Install Apt dependencies (Ubuntu) run: | sudo apt update - sudo apt install libhdf5-dev libfmt-dev + sudo apt install libhdf5-dev libfmt-dev libopenblas0-openmp if: matrix.os == 'ubuntu-22.04' - name: Setup .NET Core SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.x' + dotnet-version: '8.x' - name: Download the Cantera shared library (.so) uses: actions/download-artifact@v4 with: diff --git a/README.rst b/README.rst index 86d4f4fc5d..5382020c7d 100644 --- a/README.rst +++ b/README.rst @@ -92,7 +92,7 @@ possible. Development Site ================ -The current development version is 3.1.0. The current stable version is +The current development version is 3.2.0a1. The current stable version is 3.1.0. The `latest Cantera source code `_, the `issue tracker `_ for bugs and enhancement requests, `downloads of Cantera releases and binary installers diff --git a/SConstruct b/SConstruct index bb2196ac7c..7d910dd100 100644 --- a/SConstruct +++ b/SConstruct @@ -68,16 +68,6 @@ Additional command options: # screen instead of doing , for example # 'scons build dump'. For debugging purposes. -# This f-string is deliberately here to trigger a SyntaxError when -# SConstruct is parsed by Python 2. This seems to be the most robust -# and simplest option that will reliably trigger an error in Python 2 -# and provide actionable feedback for users. -f""" -Cantera must be built using Python 3.8 or higher. You can invoke SCons by executing - python3 `which scons` -followed by any desired options. -""" - from pathlib import Path import sys import os @@ -99,8 +89,8 @@ from buildutils import (Option, PathOption, BoolOption, EnumOption, Configuratio config_error, run_preprocessor, make_relative_path_absolute) # ensure that Python and SCons versions are sufficient for the build process -EnsurePythonVersion(3, 7) -EnsureSConsVersion(3, 0, 0) +EnsurePythonVersion(3, 10) +EnsureSConsVersion(4, 0, 0) if not COMMAND_LINE_TARGETS: # Print usage help @@ -163,7 +153,7 @@ logger.info( f"SCons {SCons.__version__} is using the following Python interpreter:\n" f" {sys.executable} (Python {python_version})", print_level=False) -cantera_version = "3.1.0" +cantera_version = "3.2.0a1" # For use where pre-release tags are not permitted (MSI, sonames) cantera_pure_version = re.match(r'(\d+\.\d+\.\d+)', cantera_version).group(0) cantera_short_version = re.match(r'(\d+\.\d+)', cantera_version).group(0) @@ -180,7 +170,7 @@ else: # Python Package Settings -python_min_version = parse_version("3.8") +python_min_version = parse_version("3.10") # Newest Python version not supported/tested by Cantera python_max_version = parse_version("3.14") # The string is used to set python_requires in setup.cfg.in @@ -324,14 +314,8 @@ config_options = [ interface further requires ruamel.yaml and pytest. The default behavior is to build the full Python module for whichever version of Python is running SCons if the required prerequisites (NumPy and - Cython) are installed. Note: 'y' is a synonym for 'full' and 'n' is a - synonym for 'none'.""", - # TODO: Remove 'minimal' after Cantera 3.1 is released. Leave it here for now - # to provide migration information. - # TODO: Remove 'none' and 'full' options after Cantera 3.1 is released. Prefer - # simpler 'y' and 'n' options, since we don't need to distinguish from the - # minimal interface. - "default", ("full", "none", "n", "y", "default", "minimal")), + Cython) are installed.""", + "default", ("n", "y", "default")), PathOption( "python_cmd", """Cantera needs to know where to find the Python interpreter. If @@ -850,8 +834,6 @@ if os.name == "nt": elif windows_compiler_env["toolchain"] == "mingw": toolchain = ["mingw", "f90"] extraEnvArgs["F77"] = None - # Next line fixes https://github.com/SCons/scons/issues/2683 - extraEnvArgs["WINDOWS_INSERT_DEF"] = 1 elif windows_compiler_env["toolchain"] == "intel": toolchain = ["intelc"] # note: untested @@ -955,16 +937,6 @@ opts.AddVariables(*config.to_scons()) opts.Update(env) opts.Save('cantera.conf', env) -# TODO: Remove after Cantera 3.1, when the minimal option is removed from the -# configuration. -if env["python_package"] == "minimal": - logger.error( - "The 'minimal' option for the Python package was removed in Cantera 3.1. " - "Please build the full interface by passing 'python_package=y' or turn off the " - "interface with 'python_package=n'" - ) - sys.exit(1) - # Expand ~/ and environment variables used in cantera.conf (variables used on # the command line will be expanded by the shell) for option in opts.keys(): @@ -1255,7 +1227,7 @@ if env['system_fmt'] in ('y', 'default'): ) if retcode and fmt_version_text: fmt_lib_version = split_version(fmt_version_text) - fmt_min_version = "6.1.2" + fmt_min_version = "8.0.0" if parse_version(fmt_lib_version) < parse_version(fmt_min_version): if env['system_fmt'] == 'y': config_error( @@ -1282,10 +1254,6 @@ if env['system_fmt'] in ('n', 'default'): env['system_fmt'] = False logger.info("Using private installation of fmt library.") -if env["OS"] == "Windows" and parse_version(fmt_lib_version) < parse_version("8.0.0"): - # Workaround for symbols not exported on Windows in older fmt versions - env.Append(CPPDEFINES={"FMT_HEADER_ONLY": 1}) - logger.info(f"Using fmt version {fmt_lib_version}") # Check for yaml-cpp library and checkout submodule if needed @@ -1648,29 +1616,19 @@ debug_message = [ logger.debug("\n".join(debug_message), print_level=False) env['python_cmd_esc'] = quoted(env['python_cmd']) - -# TODO: Remove this check when 'full' and 'none' are removed -if env['python_package'] == 'full': - logger.warning("The 'full' specification is deprecated and should be replaced by 'y'") - env['python_package'] = 'y' # Allow 'full' as a synonym for 'y' -elif env['python_package'] == 'none': - logger.warning("The 'none' specification is deprecated and should be replaced by 'n'") - env['python_package'] = 'n' # Allow 'none' as a synonym for 'n' - env["python_min_version"] = python_min_version env["python_max_version"] = python_max_version env["py_requires_ver_str"] = py_requires_ver_str env["cython_version_spec"] = SpecifierSet(">=0.29.31", prereleases=True) -env["numpy_version_spec"] = SpecifierSet(">=1.12.0,<3", prereleases=True) +# When updating NumPy spec, also update interfaces/python_sdist/pyproject.toml.in. +env["numpy_version_spec"] = SpecifierSet(">=1.21.0,<3", prereleases=True) env["cython_version_spec_str"] = str(env["cython_version_spec"]) env["numpy_version_spec_str"] = str(env["numpy_version_spec"]) -# We choose ruamel.yaml 0.15.34 as the minimum version -# since it is the highest version available in the Ubuntu -# 18.04 repositories and seems to work. Older versions such as -# 0.13.14 on CentOS7 and 0.10.23 on Ubuntu 16.04 raise an exception -# that they are missing the RoundTripRepresenter -env["ruamel_version_spec"] = SpecifierSet(">=0.15.34", prereleases=True) +# We choose ruamel.yaml 0.17.16 as the minimum version since it is the highest version +# available in the Ubuntu 22.04 repositories. When updating this, also update the +# version string in interfaces/python_sdist/pyproject.toml.in. +env["ruamel_version_spec"] = SpecifierSet(">=0.17.16", prereleases=True) env["ruamel_version_spec_str"] = str(env["ruamel_version_spec"]) # Minimum pytest version assumed based on Ubuntu 20.04 diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index 7023a3eefc..e2f006a640 100644 --- a/doc/doxygen/Doxyfile +++ b/doc/doxygen/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = Cantera # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.1.0 +PROJECT_NUMBER = 3.2.0a1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/sphinx/develop/compiling/compilation-reqs.md b/doc/sphinx/develop/compiling/compilation-reqs.md index 15b4ba8de6..7f9f3f7c90 100644 --- a/doc/sphinx/develop/compiling/compilation-reqs.md +++ b/doc/sphinx/develop/compiling/compilation-reqs.md @@ -113,7 +113,7 @@ compile Cantera on your operating system. channels: - conda-forge dependencies: - - python # Cantera supports Python 3.8 and up + - python # Cantera supports Python 3.10 and up - scons # build system - boost-cpp # C++ dependency - hdf5 # optional C++ dependency @@ -224,9 +224,9 @@ Next: Download the Source Code ### Ubuntu & Debian -- Ubuntu 20.04 LTS (Focal Fossa) or newer +- Ubuntu 22.04 LTS (Focal Fossa) or newer -- Debian 11.0 (Bullseye) or newer +- Debian 12.0 (Bookworm) or newer - The following packages must be installed to build any of the Cantera modules using your choice of package manager: @@ -424,7 +424,7 @@ Next: Download the Source Code - Python - - - Cantera supports Python 3.8 and higher + - Cantera supports Python 3.10 and higher - Be sure to choose the appropriate architecture for your system - either 32-bit or 64-bit - When installing, make sure to choose the option to add to your `PATH` diff --git a/doc/sphinx/develop/compiling/dependencies.md b/doc/sphinx/develop/compiling/dependencies.md index 3bd5c438d6..9bd75f424f 100644 --- a/doc/sphinx/develop/compiling/dependencies.md +++ b/doc/sphinx/develop/compiling/dependencies.md @@ -26,8 +26,8 @@ compiler is required only if you plan to build the Fortran module. - Microsoft compilers (C/C++) - - Known to work with Visual Studio 2017 (MSVC 14.1), Visual Studio 2019 (MSVC 14.2) - and Visual Studio 2022 (MSVC 14.3). + - Known to work with Visual Studio 2019 (MSVC 14.2) and Visual Studio 2022 + (MSVC 14.3). - MinGW (C/C++/Fortran) @@ -40,14 +40,14 @@ compiler is required only if you plan to build the Fortran module. - SCons: - - - Works with versions >= 3.0.0 + - Works with versions >= 4.0.0 - On Windows, more recent SCons versions are required to support each new version of the MSVC compiler. - Python: - - - Works with versions >= 3.8. + - Works with versions >= 3.10. - Boost @@ -63,7 +63,7 @@ compiler is required only if you plan to build the Fortran module. Git, SUNDIALS will be automatically downloaded and the necessary portions will be compiled and installed with Cantera. - - - Known to work with versions >= 3.0 and \<= 7.2. + - Known to work with versions >= 5.0 and \<= 7.2. - To use SUNDIALS with Cantera on a Linux/Unix system, it must be compiled with the `-fPIC` flag. You can specify this flag when configuring SUNDIALS as `cmake -DCMAKE_C_FLAGS=-fPIC ` @@ -81,7 +81,7 @@ compiler is required only if you plan to build the Fortran module. Cantera source code using Git, fmt will be automatically downloaded and the necessary portions will be compiled and installed with Cantera. - - - Known to work with versions 6.1.2 through 11.0. + - Known to work with versions 8.0 through 11.0. - yaml-cpp @@ -97,7 +97,7 @@ compiler is required only if you plan to build the Fortran module. - Required to build the Cantera Python module, and to run significant portions of the test suite. - - Expected to work with versions >= 1.12.0. 1.16.0 or newer is recommended. + - Expected to work with versions >= 1.21.0. - [Cython](https://cython.org/) @@ -121,8 +121,7 @@ compiler is required only if you plan to build the Fortran module. - Required to convert input files from Chemkin, {term}`CTI`, and XML to the YAML format - - Known to work with versions 0.15.42, 0.15.87, and 0.16.5 - - Expected to work with versions >= 0.15.0 + - Expected to work with versions >= 0.17.16 - [libhdf5](https://www.hdfgroup.org/solutions/hdf5/) @@ -213,4 +212,4 @@ compiler is required only if you plan to build the Fortran module. - [.NET](https://dotnet.microsoft.com/) - Required for the compilation of the experimental .NET interface - - Known to work for the .NET 6.0 SDK + - Known to work for the .NET 8.0 SDK diff --git a/doc/sphinx/develop/style-guidelines.md b/doc/sphinx/develop/style-guidelines.md index 2a1aff39a3..ea2c0fed95 100644 --- a/doc/sphinx/develop/style-guidelines.md +++ b/doc/sphinx/develop/style-guidelines.md @@ -88,8 +88,8 @@ it easier for others to understand your code in the context of Cantera as a whol ### Style Guide * Style generally follows [PEP8](https://www.python.org/dev/peps/pep-0008/) -* The minimum Python version that Cantera supports is Python 3.8, so code should only - use features added in Python 3.8 or earlier +* The minimum Python version that Cantera supports is Python 3.10, so code should only + use features added in Python 3.10 or earlier * Please use double quotes in all new Python code ### Sphinx comments diff --git a/doc/sphinx/index.md b/doc/sphinx/index.md index ff94facc64..65b2a988f2 100644 --- a/doc/sphinx/index.md +++ b/doc/sphinx/index.md @@ -1,10 +1,5 @@ # Table of Contents -```{caution} -This page is a work in progress. For documentation and tutorials for Cantera 3.0, please -see this page. -``` - ```{toctree} :maxdepth: 1 diff --git a/doc/sphinx/install/conda.md b/doc/sphinx/install/conda.md index f0711df023..f4baddcfe1 100644 --- a/doc/sphinx/install/conda.md +++ b/doc/sphinx/install/conda.md @@ -58,7 +58,7 @@ name: ct-env channels: - conda-forge dependencies: -- python # Cantera supports Python 3.8 and up +- python # Cantera supports Python 3.10 and up - cantera - ipython # optional (needed for nicer interactive command line) - jupyter # optional (needed for Jupyter Notebook) diff --git a/include/cantera/base/fmt.h b/include/cantera/base/fmt.h index 6b4d734fe3..e9a0a763fb 100644 --- a/include/cantera/base/fmt.h +++ b/include/cantera/base/fmt.h @@ -7,13 +7,6 @@ //! the same name in kinetics/Group.h #define FMT_NO_FMT_STRING_ALIAS -//! Versions 6.2.0 and 6.2.1 of fmtlib do not include this define before they -//! include windows.h, breaking builds on Windows. Fixed in fmtlib 7.0.0 and -//! newer. https://github.com/fmtlib/fmt/pull/1616 -#if defined(_WIN32) && !defined(NOMINMAX) -#define NOMINMAX -#endif - #if CT_USE_SYSTEM_FMT #include #include @@ -24,23 +17,10 @@ #include "cantera/ext/fmt/ostream.h" #endif -#if FMT_VERSION < 80000 -template -void fmt_append(fmt::memory_buffer& b, const std::string& tmpl, Args... args) { - format_to(b, tmpl, args...); -} -namespace fmt { -template -T runtime(T arg) { - return arg; -} -} -#else template void fmt_append(fmt::memory_buffer& b, const std::string& tmpl, Args... args) { format_to(fmt::appender(b), fmt::runtime(tmpl), args...); } -#endif #if FMT_VERSION > 100000 #if CT_USE_SYSTEM_FMT diff --git a/include/cantera/clib/ct.h b/include/cantera/clib/ct.h index 96a950d6c1..71568070fa 100644 --- a/include/cantera/clib/ct.h +++ b/include/cantera/clib/ct.h @@ -137,7 +137,6 @@ extern "C" { CANTERA_CAPI size_t kin_nReactions(int n); CANTERA_CAPI size_t kin_nPhases(int n); CANTERA_CAPI size_t kin_phaseIndex(int n, const char* ph); - CANTERA_CAPI size_t kin_reactionPhaseIndex(int n); CANTERA_CAPI double kin_reactantStoichCoeff(int n, int i, int k); CANTERA_CAPI double kin_productStoichCoeff(int n, int i, int k); CANTERA_CAPI int kin_getReactionType(int n, int i, size_t len, char* name); diff --git a/include/cantera/clib/ctonedim.h b/include/cantera/clib/ctonedim.h index 8ae5e52904..9411f40bdb 100644 --- a/include/cantera/clib/ctonedim.h +++ b/include/cantera/clib/ctonedim.h @@ -65,7 +65,7 @@ extern "C" { CANTERA_CAPI int sim1D_setProfile(int i, int dom, int comp, size_t np, const double* pos, size_t nv, const double* v); CANTERA_CAPI int sim1D_setFlatProfile(int i, int dom, int comp, double v); - CANTERA_CAPI int sim1D_show(int i, const char* fname); + CANTERA_CAPI int sim1D_show(int i); CANTERA_CAPI int sim1D_setTimeStep(int i, double stepsize, size_t ns, const int* nsteps); CANTERA_CAPI int sim1D_getInitialSoln(int i); CANTERA_CAPI int sim1D_solve(int i, int loglevel, int refine_grid); diff --git a/include/cantera/clib/ctreactor.h b/include/cantera/clib/ctreactor.h index a874b3255c..85e5061db9 100644 --- a/include/cantera/clib/ctreactor.h +++ b/include/cantera/clib/ctreactor.h @@ -24,7 +24,7 @@ extern "C" { CANTERA_CAPI int reactor_setInitialVolume(int i, double v); CANTERA_CAPI int reactor_setChemistry(int i, int cflag); CANTERA_CAPI int reactor_setEnergy(int i, int eflag); - CANTERA_CAPI int reactor_insert(int i, int n); + CANTERA_CAPI int reactor_setSolution(int i, int n); CANTERA_CAPI double reactor_mass(int i); CANTERA_CAPI double reactor_volume(int i); CANTERA_CAPI double reactor_density(int i); diff --git a/include/cantera/kinetics/Kinetics.h b/include/cantera/kinetics/Kinetics.h index 7d81acb342..043904c29f 100644 --- a/include/cantera/kinetics/Kinetics.h +++ b/include/cantera/kinetics/Kinetics.h @@ -211,19 +211,6 @@ class Kinetics } } - /** - * Phase where the reactions occur. For heterogeneous mechanisms, one of - * the phases in the list of phases represents the 2D interface or 1D edge - * at which the reactions take place. This method returns the index of the - * phase with the smallest spatial dimension (1, 2, or 3) among the list - * of phases. If there is more than one, the index of the first one is - * returned. For homogeneous mechanisms, the value 0 is returned. - * - * @deprecated Starting in %Cantera 3.0, the reacting phase is always be the - * first phase in the InterfaceKinetics object. To be removed after %Cantera 3.1. - */ - size_t reactionPhaseIndex() const; - /** * Return pointer to phase where the reactions occur. * @since New in %Cantera 3.0 diff --git a/include/cantera/numerics/Func1.h b/include/cantera/numerics/Func1.h index 526b5c98a2..44db9f53e9 100644 --- a/include/cantera/numerics/Func1.h +++ b/include/cantera/numerics/Func1.h @@ -38,7 +38,7 @@ class TimesConstant1; //! Advanced functors implement expressions that require multiple parameters. //! The following advanced functor types are implemented: //! - @c "tabulated-linear" and @c "tabulated-previous" (class Tabulated1), -//! - @c "polynomial3" (class Poly13), +//! - @c "polynomial3" (class Poly1), //! - @c "Fourier" (class Fourier1), //! - @c "Gaussian" (class Gaussian1), //! - @c "Arrhenius" (class Arrhenius1). @@ -82,7 +82,7 @@ class Func1 virtual ~Func1() = default; - // Func1(const Func1& right) = delete; //! @todo Uncomment after %Cantera 3.1 + Func1(const Func1& right) = delete; Func1& operator=(const Func1& right) = delete; //! Returns a string describing the type of the function @@ -119,25 +119,6 @@ class Func1 */ virtual bool isIdentical(shared_ptr other) const; - //! Routine to determine if two functions are the same. - /*! - * @deprecated Deprecated in %Cantera 3.1 and removed thereafter; replaced by - * isIdentical(shared_ptr&). - * @todo Restore deleted copy constructor after removal. - */ - virtual bool isIdentical(Func1& other) const; - - /** - * @deprecated Deprecated in %Cantera 3.1 and removed thereafter; replaced by - * internal function. - */ - virtual double isProportional(TimesConstant1& other); - /** - * @deprecated Deprecated in %Cantera 3.1 and removed thereafter; replaced by - * internal function. - */ - virtual double isProportional(Func1& other); - //! Write LaTeX string describing function. virtual string write(const string& arg) const; @@ -537,22 +518,6 @@ class TimesConstant1 : public Func1 return "times-constant"; } - double isProportional(TimesConstant1& other) override { - if (func1_shared()->isIdentical(*other.func1_shared())) { - return (other.c()/c()); - } else { - return 0.0; - } - } - - double isProportional(Func1& other) override { - if (func1_shared()->isIdentical(other)) { - return 1.0/c(); - } else { - return 0.0; - } - } - double eval(double t) const override { return m_f1->eval(t) * m_c; } @@ -713,25 +678,21 @@ class Gaussian1 : public Func1 * @f] * with coefficients provided in the order @f$ [a_n, \dots, a_1, a_0] @f$ (consistent * with MATLAB and NumPy conventions). Note that %Cantera 3.1 reversed the coefficient - * order with respect to its earlier definition. A deprecation cycle is skipped as the - * functor class is not expected to be widely used; the transitional name Poly13 ensures - * that changed behavior does not go unnoticed. The class name will revert to @b Poly1 - * after %Cantera 3.1. + * order with respect to its earlier definition. * @since Changed in %Cantera 3.1. - * @todo Rename to Poly1 after %Cantera 3.1 * @ingroup func1advanced */ -class Poly13 : public Func1 +class Poly1 : public Func1 { public: - Poly13(size_t n, const double* c) { + Poly1(size_t n, const double* c) { m_cpoly.resize(n+1); std::copy(c, c+m_cpoly.size(), m_cpoly.begin()); } //! Constructor uses @f$ n + 1 @f$ parameters in the following order: //! @f$ [a_n, \dots, a_1, a_0] @f$ - Poly13(const vector& params); + Poly1(const vector& params); string type() const override { return "polynomial3"; diff --git a/include/cantera/oneD/Boundary1D.h b/include/cantera/oneD/Boundary1D.h index 060dea3fe3..64cc323986 100644 --- a/include/cantera/oneD/Boundary1D.h +++ b/include/cantera/oneD/Boundary1D.h @@ -346,15 +346,9 @@ class Surf1D : public Boundary1D } void init() override; - void eval(size_t jg, double* xg, double* rg, integer* diagg, double rdt) override; - shared_ptr asArray(const double* soln) const override; void fromArray(SolutionArray& arr, double* soln) override; - - //! @deprecated To be removed after Cantera 3.1. - void show(std::ostream& s, const double* x) override; - void show(const double* x) override; }; diff --git a/include/cantera/oneD/Domain1D.h b/include/cantera/oneD/Domain1D.h index 1fa401f48f..0b34678384 100644 --- a/include/cantera/oneD/Domain1D.h +++ b/include/cantera/oneD/Domain1D.h @@ -118,16 +118,6 @@ class Domain1D */ virtual void init() { } - //! @deprecated Unused. To be removed after Cantera 3.1. - virtual void setInitialState(double* xlocal = 0) { - warn_deprecated("Domain1D::setInitialState", "To be removed after Cantera 3.1."); - } - - //! @deprecated Unused. To be removed after Cantera 3.1. - virtual void setState(size_t point, const double* state, double* x) { - warn_deprecated("Domain1D::setState", "To be removed after Cantera 3.1."); - } - /** * When called, this function should reset "bad" values in the state vector * such as negative species concentrations. This function may be called @@ -351,11 +341,6 @@ class Domain1D return x[index(n,j)]; } - //! @deprecated To be removed after Cantera 3.1. - virtual void setJac(MultiJac* jac) { - warn_deprecated("Domain1D::setJac", "To be removed after Cantera 3.1."); - } - //! Save the state of this domain as a SolutionArray. /*! * @param soln local solution vector for this domain @@ -484,13 +469,6 @@ class Domain1D } } - //! Print the solution. - //! @deprecated Not implemented. To be removed after Cantera 3.1. - virtual void show(std::ostream& s, const double* x) { - warn_deprecated("Domain1D::show(std::ostream, double*)", - "Not implemented. To be removed after Cantera 3.1."); - } - //! Print the solution. //! @param x Pointer to the local portion of the system state vector virtual void show(const double* x); @@ -526,13 +504,6 @@ class Domain1D return m_z; } - //! @deprecated To be removed after Cantera 3.1. Use z() instead. - double grid(size_t point) const { - warn_deprecated("Domain1D::grid", - "To be removed after Cantera 3.1. Use z() instead."); - return m_z[point]; - } - //! called to set up initial grid, and after grid refinement virtual void setupGrid(size_t n, const double* z); diff --git a/include/cantera/oneD/Flow1D.h b/include/cantera/oneD/Flow1D.h index c1ee13c6d6..17c158f9df 100644 --- a/include/cantera/oneD/Flow1D.h +++ b/include/cantera/oneD/Flow1D.h @@ -608,12 +608,6 @@ class Flow1D : public Domain1D //! @} End of Governing Equations - //! Alternate version of evalContinuity with legacy signature. - //! Implemented by StFlow; included here to prevent compiler warnings about shadowed - //! virtual functions. - //! @deprecated To be removed after %Cantera 3.1. - virtual void evalContinuity(size_t j, double* x, double* r, int* diag, double rdt); - /** * Evaluate the oxidizer axial velocity equation residual. * diff --git a/include/cantera/oneD/MultiJac.h b/include/cantera/oneD/MultiJac.h index 08a848f52f..e9cd68f1ff 100644 --- a/include/cantera/oneD/MultiJac.h +++ b/include/cantera/oneD/MultiJac.h @@ -77,9 +77,6 @@ class MultiJac : public BandMatrix return m_mask; } - //! @deprecated To be removed after Cantera 3.1. - void incrementDiagonal(int j, double d); - protected: //! Residual evaluator for this Jacobian /*! diff --git a/include/cantera/oneD/Sim1D.h b/include/cantera/oneD/Sim1D.h index 2448bd5ada..b351934561 100644 --- a/include/cantera/oneD/Sim1D.h +++ b/include/cantera/oneD/Sim1D.h @@ -105,14 +105,6 @@ class Sim1D : public OneDim //! //! @{ - /** - * Output information on current solution for all domains to stream. - * @param s Output stream - * @since New in %Cantera 3.0. - * @deprecated To be removed after Cantera 3.1. - */ - void show(std::ostream& s); - /** * Show logging information on current solution for all domains. * @since New in %Cantera 3.0. diff --git a/include/cantera/oneD/StFlow.h b/include/cantera/oneD/StFlow.h deleted file mode 100644 index 268f1428bb..0000000000 --- a/include/cantera/oneD/StFlow.h +++ /dev/null @@ -1,67 +0,0 @@ -//! @file StFlow.h - -// This file is part of Cantera. See License.txt in the top-level directory or -// at https://cantera.org/license.txt for license and copyright information. - -#ifndef CT_STFLOW_H -#define CT_STFLOW_H - -#include "Flow1D.h" - -namespace Cantera -{ - -/** - * This class represents 1D flow domains that satisfy the one-dimensional - * similarity solution for chemically-reacting, axisymmetric flows. - * - * @deprecated To be removed after %Cantera 3.1; replaced by Flow1D. - * @ingroup flowGroup - */ -class StFlow : public Flow1D -{ -public: - //! Create a new flow domain. - //! @param ph Object representing the gas phase. This object will be used - //! to evaluate all thermodynamic, kinetic, and transport properties. - //! @param nsp Number of species. - //! @param points Initial number of grid points - StFlow(ThermoPhase* ph = 0, size_t nsp = 1, size_t points = 1); - - //! Delegating constructor - StFlow(shared_ptr th, size_t nsp = 1, size_t points = 1); - - //! Create a new flow domain. - //! @param sol Solution object used to evaluate all thermodynamic, kinetic, and - //! transport properties - //! @param id name of flow domain - //! @param points initial number of grid points - StFlow(shared_ptr sol, const string& id="", size_t points=1); - - void eval(size_t j, double* x, double* r, integer* mask, double rdt) override; - - //! Evaluate all residual components at the right boundary. - virtual void evalRightBoundary(double* x, double* res, int* diag, double rdt); - - void evalContinuity(size_t j, double* x, double* r, int* diag, double rdt) override; - -protected: - double wdot(size_t k, size_t j) const { - return m_wdot(k,j); - } - - //! Write the net production rates at point `j` into array `m_wdot` - void getWdot(double* x, size_t j) { - setGas(x,j); - m_kin->getNetProductionRates(&m_wdot(0,j)); - } - - //! Evaluate the residual function. This function is called in eval - //! after updateProperties is called. - virtual void evalResidual(double* x, double* rsd, int* diag, - double rdt, size_t jmin, size_t jmax); -}; - -} - -#endif diff --git a/include/cantera/oneD/refine.h b/include/cantera/oneD/refine.h index 4a9d4e7caf..d525425ba5 100644 --- a/include/cantera/oneD/refine.h +++ b/include/cantera/oneD/refine.h @@ -105,29 +105,6 @@ class Domain1D; */ int analyze(size_t n, const double* z, const double* x); - /** - * Constructs a new grid based on refinement locations determined by the analyze() - * method. - * - * This function generates a new grid by inserting additional points into the - * current grid at locations where the analyze() method has identified a need for - * refinement. The new grid points are placed midway between existing points deemed - * necessary for increased resolution. If no refinement is needed, the original - * grid is copied directly. - * - * @param[in] n The number of points in the original grid array `z`. - * @param[in] z Pointer to the array of original grid points. - * @param[in] nn The maximum number of points that the new grid array `znew` can hold. - * @param[out] znew Pointer to the array where the new grid points will be stored. - * - * @return The function returns 0 upon successful creation of the new grid. Throws - * an exception if the provided output array size is insufficient to hold - * the new grid. - * - * @deprecated Unused. To be removed after %Cantera 3.1. - */ - int getNewGrid(int n, const double* z, int nn, double* znew); - //! Returns the number of new grid points that were needed. int nNewPoints() { return static_cast(m_insertPts.size()); diff --git a/include/cantera/transport/GasTransport.h b/include/cantera/transport/GasTransport.h index e61e4cd24c..f845836de6 100644 --- a/include/cantera/transport/GasTransport.h +++ b/include/cantera/transport/GasTransport.h @@ -148,7 +148,7 @@ class GasTransport : public Transport double* bstar_coeffs, double* cstar_coeffs, bool actualT) override; - void init(ThermoPhase* thermo, int mode=0, int log_level=-7) override; + void init(ThermoPhase* thermo, int mode=0) override; bool CKMode() const override { return m_mode == CK_Mode; @@ -542,10 +542,6 @@ class GasTransport : public Transport //! Quadrupole polarizability vector m_quad_polar; - - //! Level of verbose printing during initialization. - //! @deprecated To be removed after %Cantera 3.1. - int m_log_level = 0; }; } // namespace Cantera diff --git a/include/cantera/transport/IonGasTransport.h b/include/cantera/transport/IonGasTransport.h index 63c081d409..c553d15a63 100644 --- a/include/cantera/transport/IonGasTransport.h +++ b/include/cantera/transport/IonGasTransport.h @@ -40,7 +40,7 @@ class IonGasTransport : public MixTransport return "ionized-gas"; } - void init(ThermoPhase* thermo, int mode, int log_level=-7) override; + void init(ThermoPhase* thermo, int mode) override; //! Viscosity of the mixture (kg/m/s). //! Only Neutral species contribute to Viscosity. diff --git a/include/cantera/transport/MixTransport.h b/include/cantera/transport/MixTransport.h index f881d050de..d27efd56a6 100644 --- a/include/cantera/transport/MixTransport.h +++ b/include/cantera/transport/MixTransport.h @@ -147,7 +147,7 @@ class MixTransport : public GasTransport size_t ldx, const double* const grad_X, size_t ldf, double* const fluxes) override; - void init(ThermoPhase* thermo, int mode=0, int log_level=-7) override; + void init(ThermoPhase* thermo, int mode=0) override; protected: //! Update the temperature dependent parts of the species thermal diff --git a/include/cantera/transport/MultiTransport.h b/include/cantera/transport/MultiTransport.h index ef7e348ea4..937813bf12 100644 --- a/include/cantera/transport/MultiTransport.h +++ b/include/cantera/transport/MultiTransport.h @@ -100,7 +100,7 @@ class MultiTransport : public GasTransport void getMassFluxes(const double* state1, const double* state2, double delta, double* fluxes) override; - void init(ThermoPhase* thermo, int mode=0, int log_level=-7) override; + void init(ThermoPhase* thermo, int mode=0) override; void invalidateCache() override; diff --git a/include/cantera/transport/Transport.h b/include/cantera/transport/Transport.h index 7728287c2d..b1d6cc42ae 100644 --- a/include/cantera/transport/Transport.h +++ b/include/cantera/transport/Transport.h @@ -412,11 +412,8 @@ class Transport * @param thermo Pointer to the ThermoPhase object * @param mode Chemkin compatible mode or not. This alters the * specification of the collision integrals. defaults to no. - * @param log_level Defaults to zero, no logging - * @deprecated The `log_level` parameter is deprecated and will be removed after - * %Cantera 3.1. */ - virtual void init(ThermoPhase* thermo, int mode=0, int log_level=-7) {} + virtual void init(ThermoPhase* thermo, int mode=0) {} //! Boolean indicating the form of the transport properties polynomial fits. //! Returns true if the Chemkin form is used. diff --git a/include/cantera/transport/TransportFactory.h b/include/cantera/transport/TransportFactory.h index a4dcff2d94..3e29017e0f 100644 --- a/include/cantera/transport/TransportFactory.h +++ b/include/cantera/transport/TransportFactory.h @@ -47,29 +47,17 @@ class TransportFactory : public Factory //! Deletes the statically allocated factory instance. void deleteFactory() override; - //! Build a new transport manager using a transport manager - //! that may not be the same as in the phase description - //! and return a base class pointer to it + //! Build a new transport manager using a transport manager that may not be the same + //! as in the phase description and return a base class pointer to it /*! * @param model String name for the transport manager * @param thermo ThermoPhase object - * @param log_level log level - * - * @deprecated The `log_level` parameter is deprecated and will be removed after - * %Cantera 3.1. */ - Transport* newTransport(const string& model, ThermoPhase* thermo, int log_level=-7); + Transport* newTransport(const string& model, ThermoPhase* thermo); //! Build a new transport manager using the default transport manager //! in the phase description and return a base class pointer to it - /*! - * @param thermo ThermoPhase object - * @param log_level log level - * - * @deprecated The `log_level` parameter is deprecated and will be removed after - * %Cantera 3.1. - */ - Transport* newTransport(ThermoPhase* thermo, int log_level=-7); + Transport* newTransport(ThermoPhase* thermo); private: //! Static instance of the factor -> This is the only instance of this diff --git a/include/cantera/transport/WaterTransport.h b/include/cantera/transport/WaterTransport.h index d5f3ebde95..14755fdbdd 100644 --- a/include/cantera/transport/WaterTransport.h +++ b/include/cantera/transport/WaterTransport.h @@ -57,7 +57,7 @@ class WaterTransport : public Transport */ double thermalConductivity() override; - void init(ThermoPhase* thermo, int mode=0, int log_level=-7) override; + void init(ThermoPhase* thermo, int mode=0) override; }; } #endif diff --git a/include/cantera/zeroD/FlowDeviceFactory.h b/include/cantera/zeroD/FlowDeviceFactory.h index a11ef4a976..28a01bd5f3 100644 --- a/include/cantera/zeroD/FlowDeviceFactory.h +++ b/include/cantera/zeroD/FlowDeviceFactory.h @@ -47,11 +47,6 @@ class FlowDeviceFactory : public Factory //! @since Starting in %Cantera 3.1, this method returns a `shared_ptr` shared_ptr newFlowDevice(const string& model, const string& name="(none)"); -//! Create a FlowDevice object of the specified type -//! @since New in %Cantera 3.0. -//! @deprecated Replaced by newFlowDevice. To be removed after %Cantera 3.1. -shared_ptr newFlowDevice3(const string& model); - //! @} } diff --git a/include/cantera/zeroD/Reactor.h b/include/cantera/zeroD/Reactor.h index c27e74deb6..526668745c 100644 --- a/include/cantera/zeroD/Reactor.h +++ b/include/cantera/zeroD/Reactor.h @@ -66,20 +66,6 @@ class Reactor : public ReactorBase return true; } - /** - * Insert something into the reactor. The 'something' must belong to a class - * that is a subclass of both ThermoPhase and Kinetics. - * @deprecated Unused; to be removed after %Cantera 3.1. - */ - template - void insert(G& contents) { - warn_deprecated("Reactor::insert", "Unused; to be removed after Cantera 3.1."); - setThermo(contents); - setKinetics(contents); - } - - using ReactorBase::insert; - void setChemistry(bool cflag=true) override { m_chem = cflag; } diff --git a/include/cantera/zeroD/ReactorBase.h b/include/cantera/zeroD/ReactorBase.h index 6e237f3b82..c048471276 100644 --- a/include/cantera/zeroD/ReactorBase.h +++ b/include/cantera/zeroD/ReactorBase.h @@ -90,18 +90,6 @@ class ReactorBase m_vol = vol; } - //! @deprecated To be removed after %Cantera 3.1. Superseded by setSolution. - void insert(shared_ptr sol); - - //! Specify the mixture contained in the reactor. Note that a pointer to - //! this substance is stored, and as the integration proceeds, the state of - //! the substance is modified. - //! @deprecated To be removed after %Cantera 3.1. Superseded by setSolution. - void setThermoMgr(ThermoPhase& thermo); - - //! @deprecated To be removed after %Cantera 3.1. Superseded by setSolution. - void setKineticsMgr(Kinetics& kin); - //! Enable or disable changes in reactor composition due to chemical reactions. virtual void setChemistry(bool cflag = true) { throw NotImplementedError("ReactorBase::setChemistry"); diff --git a/include/cantera/zeroD/ReactorFactory.h b/include/cantera/zeroD/ReactorFactory.h index 56c17bf67c..ef896ed571 100644 --- a/include/cantera/zeroD/ReactorFactory.h +++ b/include/cantera/zeroD/ReactorFactory.h @@ -43,21 +43,12 @@ class ReactorFactory : public Factory, const s //! @ingroup zerodGroup //! @{ -//! Create a Reactor object of the specified type -//! @since Starting in %Cantera 3.1, this method returns a `shared_ptr` -//! @deprecated Transitional method. Use newReactor() with contents instead. -shared_ptr newReactor(const string& model); - //! Create a Reactor object of the specified type and contents -//! @since New in %Cantera 3.1. +//! @since Starting in %Cantera 3.1, this method requires a valid Solution object and +//! returns a `shared_ptr` instead of a `ReactorBase*`. shared_ptr newReactor( const string& model, shared_ptr contents, const string& name="(none)"); -//! Create a Reactor object of the specified type -//! @since New in %Cantera 3.0. -//! @deprecated Transitional method. Use newReactor() instead. -shared_ptr newReactor3(const string& model); - //! @} } diff --git a/include/cantera/zeroD/Reservoir.h b/include/cantera/zeroD/Reservoir.h index 9f5063dc93..e47576a272 100644 --- a/include/cantera/zeroD/Reservoir.h +++ b/include/cantera/zeroD/Reservoir.h @@ -25,15 +25,6 @@ class Reservoir : public ReactorBase } void initialize(double t0=0.0) override {} - - //! @deprecated Unused; to be removed after %Cantera 3.1. - void insert(ThermoPhase& contents) { - warn_deprecated("Reservoir::insert", - "Unused; to be removed after Cantera 3.1."); - setThermo(contents); - } - - using ReactorBase::insert; }; } diff --git a/include/cantera/zeroD/WallFactory.h b/include/cantera/zeroD/WallFactory.h index 79850266c1..13b3c4af44 100644 --- a/include/cantera/zeroD/WallFactory.h +++ b/include/cantera/zeroD/WallFactory.h @@ -47,11 +47,6 @@ class WallFactory : public Factory //! @since Starting in %Cantera 3.1, this method returns a `shared_ptr` shared_ptr newWall(const string& model, const string& name="(none)"); -//! Create a WallBase object of the specified type -//! @since New in %Cantera 3.0. -//! @deprecated Replaced by newWall. To be removed after %Cantera 3.1. -shared_ptr newWall3(const string& model); - //! @} } diff --git a/interfaces/cython/cantera/ck2yaml.py b/interfaces/cython/cantera/ck2yaml.py index 27c61d687d..4329defeca 100644 --- a/interfaces/cython/cantera/ck2yaml.py +++ b/interfaces/cython/cantera/ck2yaml.py @@ -22,23 +22,16 @@ import textwrap from email.utils import formatdate from pathlib import Path - -try: - from ruamel import yaml -except ImportError: - import ruamel_yaml as yaml +from ruamel import yaml # yaml.version_info is a tuple with the three parts of the version yaml_version = yaml.version_info -# We choose ruamel.yaml 0.15.34 as the minimum version -# since it is the highest version available in the Ubuntu -# 18.04 repositories and seems to work. Older versions such as -# 0.13.14 on CentOS7 and 0.10.23 on Ubuntu 16.04 raise an exception -# that they are missing the RoundTripRepresenter -yaml_min_version = (0, 15, 34) +# We choose ruamel.yaml 0.17.16 as the minimum version since it is the highest version +# available in the Ubuntu 22.04 repositories. +yaml_min_version = (0, 17, 16) if yaml_version < yaml_min_version: raise RuntimeError( - "The minimum supported version of ruamel.yaml is 0.15.34. If you " + "The minimum supported version of ruamel.yaml is 0.17.16. If you " "installed ruamel.yaml from your operating system's package manager, " "please install an updated version using pip or conda." ) @@ -67,19 +60,6 @@ def FlowList(*args, **kwargs): lst.fa.set_flow_style() return lst -# Improved float formatting requires Numpy >= 1.14 -if hasattr(np, 'format_float_positional'): - def float2string(data): - if data == 0: - return '0.0' - elif 0.01 <= abs(data) < 10000: - return np.format_float_positional(data, trim='0') - else: - return np.format_float_scientific(data, trim='0') -else: - def float2string(data): - return repr(data) - def represent_float(self, data): if data != data: value = '.nan' @@ -87,8 +67,12 @@ def represent_float(self, data): value = '.inf' elif data == -self.inf_value: value = '-.inf' + elif data == 0: + value = '0.0' + elif 0.01 <= abs(data) < 10000: + value = np.format_float_positional(data, trim='0') else: - value = float2string(data) + value = np.format_float_scientific(data, trim='0') return self.represent_scalar(u'tag:yaml.org,2002:float', value) @@ -2051,7 +2035,7 @@ def write_yaml(self, name='gas', out_name='mech.yaml'): metadata = BlockMap([ ("generator", "ck2yaml"), ("input-files", FlowList(self.files)), - ("cantera-version", "3.1.0"), + ("cantera-version", "3.2.0a1"), ("date", formatdate(localtime=True)), ]) if desc.strip(): @@ -2276,23 +2260,6 @@ def convert(input_file, thermo_file=None, transport_file=None, return surface_names -def convert_mech(input_file, thermo_file=None, transport_file=None, - surface_file=None, phase_name='gas', extra_file=None, - out_name=None, single_intermediate_temperature=False, quiet=False, - permissive=None, verbose=False): - """ - .. deprecated:: 3.0 - - To be removed after Cantera 3.1; renamed to :func:`convert`. - """ - warnings.warn( - "To be removed after Cantera 3.1; renamed to 'convert'") - _, surface_names = Parser.convert_mech( - input_file, thermo_file, transport_file, surface_file, phase_name, extra_file, - out_name, single_intermediate_temperature, quiet, permissive, verbose) - return surface_names - - def main(argv=None): """Parse command line arguments and pass them to `Parser.convert_mech`.""" parser = create_argparser() diff --git a/interfaces/cython/cantera/composite.py b/interfaces/cython/cantera/composite.py index 4b45962599..cc0c7892f2 100644 --- a/interfaces/cython/cantera/composite.py +++ b/interfaces/cython/cantera/composite.py @@ -575,7 +575,7 @@ class SolutionArray(SolutionArrayBase): 'species', 'n_atoms', 'molecular_weights', 'min_temp', 'max_temp', 'reference_pressure', 'charges', # From Kinetics - 'n_total_species', 'n_reactions', 'n_phases', 'reaction_phase_index', + 'n_total_species', 'n_reactions', 'n_phases', 'kinetics_species_index', 'reaction', 'reactions', 'modify_reaction', 'multiplier', 'set_multiplier', 'reaction_equations', 'reactant_stoich_coeff', 'product_stoich_coeff', 'reactant_stoich_coeffs', 'product_stoich_coeffs', @@ -1194,21 +1194,9 @@ def read_csv(self, filename, normalize=True): pass # fall back to numpy; this works unless CSV file contains escaped entries - if np.lib.NumpyVersion(np.__version__) < "1.14.0": - # bytestring needs to be converted for columns containing strings - data = np.genfromtxt(filename, delimiter=',', deletechars='', - dtype=None, names=True) - data_dict = {} - for label in data.dtype.names: - if data[label].dtype.type == np.bytes_: - data_dict[label] = data[label].astype('U') - else: - data_dict[label] = data[label] - else: - # the 'encoding' parameter introduced with NumPy 1.14 simplifies import - data = np.genfromtxt(filename, delimiter=',', deletechars='', - dtype=None, names=True, encoding=None) - data_dict = {label: data[label] for label in data.dtype.names} + data = np.genfromtxt(filename, delimiter=',', deletechars='', + dtype=None, names=True, encoding=None) + data_dict = {label: data[label] for label in data.dtype.names} self.restore_data(data_dict, normalize) def to_pandas(self, cols=None, *args, **kwargs): diff --git a/interfaces/cython/cantera/cti2yaml.py b/interfaces/cython/cantera/cti2yaml.py index dc598ffb4b..0a85e331b8 100644 --- a/interfaces/cython/cantera/cti2yaml.py +++ b/interfaces/cython/cantera/cti2yaml.py @@ -19,23 +19,16 @@ import numpy as np from email.utils import formatdate import argparse - -try: - from ruamel import yaml -except ImportError: - import ruamel_yaml as yaml +from ruamel import yaml # yaml.version_info is a tuple with the three parts of the version yaml_version = yaml.version_info -# We choose ruamel.yaml 0.15.34 as the minimum version -# since it is the highest version available in the Ubuntu -# 18.04 repositories and seems to work. Older versions such as -# 0.13.14 on CentOS7 and 0.10.23 on Ubuntu 16.04 raise an exception -# that they are missing the RoundTripRepresenter -yaml_min_version = (0, 15, 34) +# We choose ruamel.yaml 0.17.16 as the minimum version since it is the highest version +# available in the Ubuntu 22.04 repositories. +yaml_min_version = (0, 17, 16) if yaml_version < yaml_min_version: raise RuntimeError( - "The minimum supported version of ruamel.yaml is 0.15.34. If you " + "The minimum supported version of ruamel.yaml is 0.17.16. If you " "installed ruamel.yaml from your operating system's package manager, " "please install an updated version using pip or conda." ) @@ -67,18 +60,13 @@ def FlowList(*args, **kwargs): lst.fa.set_flow_style() return lst -# Improved float formatting requires Numpy >= 1.14 -if hasattr(np, 'format_float_positional'): - def float2string(data): - if data == 0: - return '0.0' - elif 0.01 <= abs(data) < 10000: - return np.format_float_positional(data, trim='0') - else: - return np.format_float_scientific(data, trim='0') -else: - def float2string(data): - return repr(data) +def float2string(data): + if data == 0: + return '0.0' + elif 0.01 <= abs(data) < 10000: + return np.format_float_positional(data, trim='0') + else: + return np.format_float_scientific(data, trim='0') def represent_float(self, data): if data != data: @@ -1661,7 +1649,7 @@ def convert(filename=None, output_name=None, text=None, encoding="latin-1"): # information regarding conversion metadata = BlockMap([ ("generator", "cti2yaml"), - ("cantera-version", "3.1.0"), + ("cantera-version", "3.2.0a1"), ("date", formatdate(localtime=True)), ]) if filename != "": diff --git a/interfaces/cython/cantera/ctml2yaml.py b/interfaces/cython/cantera/ctml2yaml.py index 69c2e62c1b..7f64a1e8d6 100644 --- a/interfaces/cython/cantera/ctml2yaml.py +++ b/interfaces/cython/cantera/ctml2yaml.py @@ -25,27 +25,21 @@ from typing import TYPE_CHECKING import numpy as np - -try: - from ruamel import yaml -except ImportError: - import ruamel_yaml as yaml # type: ignore +from ruamel import yaml # yaml.version_info is a tuple with the three parts of the version yaml_version = yaml.version_info -# We choose ruamel.yaml 0.15.34 as the minimum version -# since it is the highest version available in the Ubuntu -# 18.04 repositories and seems to work. Older versions such as -# 0.13.14 on CentOS7 and 0.10.23 on Ubuntu 16.04 raise an exception -# that they are missing the RoundTripRepresenter -yaml_min_version = (0, 15, 34) +# We choose ruamel.yaml 0.17.16 as the minimum version since it is the highest version +# available in the Ubuntu 22.04 repositories. +yaml_min_version = (0, 17, 16) if yaml_version < yaml_min_version: raise RuntimeError( - "The minimum supported version of ruamel.yaml is 0.15.34. If you " + "The minimum supported version of ruamel.yaml is 0.17.16. If you " "installed ruamel.yaml from your operating system's package manager, " "please install an updated version using pip or conda." ) + if TYPE_CHECKING: QUANTITY = Union[float, str] @@ -160,24 +154,15 @@ def __init__(self, message: str = "", node: Optional[etree.Element] = None): super().__init__(message) -# Improved float formatting requires Numpy >= 1.14 -HAS_FMT_FLT_POS = hasattr(np, "format_float_positional") - - def float2string(data: float) -> str: """Format a float into a string. :param data: The floating point data to be formatted. - Uses *NumPy*'s ``format_float_positional()`` and ``format_float_scientific()`` if - they are is available, requires ``numpy >= 1.14``. In that case, values with - magnitude between 0.01 and 10000 are formatted using ``format_float_positional ()`` - and other values are formatted using ``format_float_scientific()``. If those *NumPy* - functions are not available, returns the ``repr`` of the input. + Values with magnitude between 0.01 and 10000 are formatted using + ``format_float_positional()`` and other values are formatted using + ``format_float_scientific()``. """ - if not HAS_FMT_FLT_POS: - return repr(data) - if data == 0: return "0.0" elif 0.01 <= abs(data) < 10000: @@ -2637,7 +2622,7 @@ def convert( metadata = BlockMap( { "generator": "ctml2yaml", - "cantera-version": "3.1.0", + "cantera-version": "3.2.0a1", "date": formatdate(localtime=True), } ) diff --git a/interfaces/cython/cantera/func1.pyx b/interfaces/cython/cantera/func1.pyx index 223f023430..1de48b66b2 100644 --- a/interfaces/cython/cantera/func1.pyx +++ b/interfaces/cython/cantera/func1.pyx @@ -220,26 +220,6 @@ cdef class Func1: out.func = out._func.get() return out - @staticmethod - def cxx_functor(functor_type, *args): - """ - Retrieve a C++ `Func1` functor (advanced feature). - - For implemented functor types, see the Cantera C++ ``Func1`` documentation. - - .. versionadded:: 3.0 - - .. deprecated:: 3.1 - - To be removed after Cantera 3.1; replaced by alternative constructor. - """ - warnings.warn( - "To be removed after Cantera 3.1; use alternative constructor instead.", - DeprecationWarning) - cdef shared_ptr[CxxFunc1] func - func = Func1._make_cxx_func1(stringify(functor_type), args) - return Func1._make_func1(func) - def __add__(self, other): if not isinstance(other, Func1): other = Func1(other) diff --git a/interfaces/cython/cantera/kinetics.pyx b/interfaces/cython/cantera/kinetics.pyx index ade71df59c..90ed837920 100644 --- a/interfaces/cython/cantera/kinetics.pyx +++ b/interfaces/cython/cantera/kinetics.pyx @@ -110,21 +110,6 @@ cdef class Kinetics(_SolutionBase): def __get__(self): return self.kinetics.nPhases() - property reaction_phase_index: - """ - The index of the phase where the reactions occur. - - .. deprecated:: 3.0 - - After Cantera 3.0, the reacting phase is always the first phase associated - with the Kinetics object. This method will be removed after Cantera 3.1. - """ - def __get__(self): - warnings.warn("Kinetics.reaction_phase_index: To be removed after " - "Cantera 3.1; The reacting phase is always index 0.", - DeprecationWarning) - return 0 - def _check_phase_index(self, n): if not 0 <= n < self.n_phases: raise ValueError("Phase index ({0}) out of range".format(n)) diff --git a/interfaces/cython/cantera/lxcat2yaml.py b/interfaces/cython/cantera/lxcat2yaml.py index 8e5f263d51..5433d4944c 100644 --- a/interfaces/cython/cantera/lxcat2yaml.py +++ b/interfaces/cython/cantera/lxcat2yaml.py @@ -28,10 +28,7 @@ import xml.etree.ElementTree as etree from typing import Union, Optional, List import sys -try: - import ruamel_yaml as yaml -except ImportError: - from ruamel import yaml +from ruamel import yaml try: import cantera as ct Solution = ct.Solution diff --git a/interfaces/cython/cantera/reactor.pyx b/interfaces/cython/cantera/reactor.pyx index 841dc2d741..39a05f19d4 100644 --- a/interfaces/cython/cantera/reactor.pyx +++ b/interfaces/cython/cantera/reactor.pyx @@ -16,14 +16,9 @@ cdef class ReactorBase: Common base class for reactors and reservoirs. """ reactor_type = "none" - def __cinit__(self, _SolutionBase contents=None, *, name="(none)", **kwargs): - if isinstance(contents, _SolutionBase): - self._reactor = newReactor(stringify(self.reactor_type), - contents._base, stringify(name)) - else: - # deprecated: will raise warnings in C++ layer - self._reactor = newReactor(stringify(self.reactor_type)) - self._reactor.get().setName(stringify(name)) + def __cinit__(self, _SolutionBase contents, *, name="(none)", **kwargs): + self._reactor = newReactor(stringify(self.reactor_type), + contents._base, stringify(name)) self.rbase = self._reactor.get() def __init__(self, _SolutionBase contents=None, *, @@ -198,13 +193,11 @@ cdef class Reactor(ReactorBase): def __cinit__(self, *args, **kwargs): self.reactor = (self.rbase) - def __init__(self, contents=None, *, + def __init__(self, contents, *, name="(none)", energy='on', group_name="", **kwargs): """ :param contents: - Reactor contents. If not specified, the reactor is initially empty. - In this case, call `insert` to specify the contents. Providing valid - contents will become mandatory after Cantera 3.1. + A `Solution` object representing the Reactor contents :param name: Name string. If not specified, the name initially defaults to ``'(none)'`` and changes to ``'_n'`` when `Reactor` objects are installed diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 20c2507b47..7974eab1c5 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -2146,9 +2146,8 @@ cdef class PureFluid(ThermoPhase): def __get__(self): return self.s, self.v, self.Q -# TODO: Remove these helper methods when support for Python 3.8 is dropped. Python 3.9 -# allows the classmethod and property decorators to be chained, so these can be -# implemented as properties in the Element class. +# Helper methods for the implementation of properties of class Element. +# @todo These can be inlined once Support for Cython 0.29 is dropped. def _element_symbols(): syms = elementSymbols() return tuple(pystr(s) for s in syms) @@ -2203,12 +2202,10 @@ class Element: #: The number of named elements (not isotopes) defined in Cantera num_elements_defined = numElementsDefined() - #: A list of the symbols of all the elements (not isotopes) defined - #: in Cantera + #: A list of the symbols of all the elements (not isotopes) defined in Cantera element_symbols = _element_symbols() - #: A list of the names of all the elements (not isotopes) defined - #: in Cantera + #: A list of the names of all the elements (not isotopes) defined in Cantera element_names = _element_names() def __init__(self, arg): diff --git a/interfaces/cython/setup.cfg.in b/interfaces/cython/setup.cfg.in index 089164d407..a27a34c749 100644 --- a/interfaces/cython/setup.cfg.in +++ b/interfaces/cython/setup.cfg.in @@ -23,11 +23,10 @@ classifiers = Programming Language :: Cython Programming Language :: Fortran Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 Programming Language :: Python :: Implementation :: CPython Topic :: Scientific/Engineering :: Chemistry Topic :: Scientific/Engineering :: Physics @@ -65,7 +64,6 @@ cantera.examples = *.txt pandas = pandas units = pint - numpy<2.0; python_version <= '3.9' graphviz = graphviz [options.entry_points] diff --git a/interfaces/dotnet/Cantera.Tests/Cantera.Tests.csproj b/interfaces/dotnet/Cantera.Tests/Cantera.Tests.csproj index c8f3dcba48..c58e2bfbe5 100644 --- a/interfaces/dotnet/Cantera.Tests/Cantera.Tests.csproj +++ b/interfaces/dotnet/Cantera.Tests/Cantera.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable true diff --git a/interfaces/dotnet/Cantera/Cantera.csproj b/interfaces/dotnet/Cantera/Cantera.csproj index 574e8a5111..17761cbdc6 100644 --- a/interfaces/dotnet/Cantera/Cantera.csproj +++ b/interfaces/dotnet/Cantera/Cantera.csproj @@ -2,7 +2,7 @@ 10 - net6.0;netstandard2.0 + net8.0;netstandard2.0 enable enable true diff --git a/interfaces/dotnet/README.md b/interfaces/dotnet/README.md index 300acca19d..6c369fdac3 100644 --- a/interfaces/dotnet/README.md +++ b/interfaces/dotnet/README.md @@ -2,9 +2,9 @@ This directory and its children contain the interface to Cantera for .NET languages such as C# and F#. It is written in C# and supports .NET Standard 2.0 -(for the primary project) and .NET 6 (and newer) on all platforms that support both +(for the primary project) and .NET 8 (and newer) on all platforms that support both .NET and the Cantera C++ library. The .NET interface requires an installation of the -.NET 6.0 SDK. +.NET 8.0 SDK. ## Project Layout @@ -14,11 +14,11 @@ interfaces with classes and concepts familiar to a .NET developer. As part of th process, it invokes [sourcegen](/interfaces/sourcegen) to scaffold the interop code and some of the code for the wrapper objects, such as simple properties which can mapped directly to CLib getter and setter functions. -`Cantera.csproj` targets .NET Standard 2.0 and .NET 6. This project will be released as +`Cantera.csproj` targets .NET Standard 2.0 and .NET 8. This project will be released as a NuGet package. `Cantera.Tests.csproj` contains the unit tests for the Cantera .NET library and targets -.Net 6. +.Net 8. The examples directory contains separate projects for each Cantera example. These will be packaged as a template for use with the .NET CLI, allowing developers to create a diff --git a/interfaces/dotnet/examples/Application/Application.csproj b/interfaces/dotnet/examples/Application/Application.csproj index 4b955b061b..3d41130ef1 100644 --- a/interfaces/dotnet/examples/Application/Application.csproj +++ b/interfaces/dotnet/examples/Application/Application.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 enable enable true diff --git a/interfaces/dotnet/examples/SoundSpeed/SoundSpeed.csproj b/interfaces/dotnet/examples/SoundSpeed/SoundSpeed.csproj index 4b955b061b..3d41130ef1 100644 --- a/interfaces/dotnet/examples/SoundSpeed/SoundSpeed.csproj +++ b/interfaces/dotnet/examples/SoundSpeed/SoundSpeed.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 enable enable true diff --git a/interfaces/python_sdist/pyproject.toml.in b/interfaces/python_sdist/pyproject.toml.in index e4f5f2a1f0..cbf2f5c450 100644 --- a/interfaces/python_sdist/pyproject.toml.in +++ b/interfaces/python_sdist/pyproject.toml.in @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core", "cython", "numpy>=2.0; python_version >= '3.9'", "oldest-supported-numpy; python_version == '3.8'"] +requires = ["scikit-build-core", "cython", "numpy>=2.0"] build-backend = "scikit_build_core.build" [project] @@ -22,19 +22,18 @@ classifiers = [ "Programming Language :: Cython", "Programming Language :: Fortran", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Scientific/Engineering :: Chemistry", "Topic :: Scientific/Engineering :: Physics", ] requires-python = "@py_requires_ver_str@" dependencies = [ - "numpy >= 1.12.0,<3", - "ruamel.yaml >= 0.15.34", + "numpy >= 1.21.0,<3", + "ruamel.yaml >= 0.17.16", ] [project.readme] diff --git a/interfaces/sourcegen/sourcegen/_helpers.py b/interfaces/sourcegen/sourcegen/_helpers.py index 84071829ce..901dc1cf10 100644 --- a/interfaces/sourcegen/sourcegen/_helpers.py +++ b/interfaces/sourcegen/sourcegen/_helpers.py @@ -3,11 +3,7 @@ from dataclasses import fields from pathlib import Path -try: - from ruamel import yaml -except ImportError: - import ruamel_yaml as yaml - +from ruamel import yaml def read_config(config_file: Path) -> dict: """Read YAML configuration file.""" diff --git a/samples/python/thermo/vapordome.py b/samples/python/thermo/vapordome.py index 10c40d8ffc..ba2aa8c436 100644 --- a/samples/python/thermo/vapordome.py +++ b/samples/python/thermo/vapordome.py @@ -6,7 +6,7 @@ steam table corresponds to data typically found in thermodynamic text books and uses the same customary units. -Requires: Cantera >= 2.5.0, matplotlib >= 2.0, pandas >= 1.1.0, numpy >= 1.12 +Requires: Cantera >= 2.5.0, matplotlib >= 2.0, pandas >= 1.1.0 .. tags:: Python, thermodynamics, non-ideal fluid, plotting """ diff --git a/site_scons/buildutils.py b/site_scons/buildutils.py index bec84c9160..be968817af 100644 --- a/site_scons/buildutils.py +++ b/site_scons/buildutils.py @@ -1309,7 +1309,6 @@ def setup_python_env(env): _python_info = json.loads(get_command_output(env["python_cmd"], "-c", script)) info = _python_info - module_ext = info["EXT_SUFFIX"] inc = info["INCLUDEPY"] pylib = info.get("LDLIBRARY") prefix = info["prefix"] @@ -1325,16 +1324,7 @@ def setup_python_env(env): add_system_include(env, (inc, numpy_include), 'prepend') env.Prepend(LIBS=env['cantera_shared_libs']) - # Fix the module extension for Windows from the sysconfig library. - # See https://github.com/python/cpython/pull/22088 and - # https://bugs.python.org/issue39825 - if (py_version_full < parse_version("3.8.7") - and env["OS"] == "Windows" - and module_ext == ".pyd" - ): - module_ext = f".cp{py_version_nodot}-{info['plat'].replace('-', '_')}.pyd" - - env["py_module_ext"] = module_ext + env["py_module_ext"] = info["EXT_SUFFIX"] env["py_version_nodot"] = py_version_nodot env["py_version_short"] = info["py_version_short"] env["py_plat"] = plat @@ -1350,13 +1340,6 @@ def setup_python_env(env): env["py_libs"] = [py_lib] + [lib[2:] for lib in info.get("LIBS", "").split() if lib.startswith("-l")] - # Don't print deprecation warnings for internal Python changes. - # Only applies to Python 3.8. The field that is deprecated in Python 3.8 - # and causes the warnings to appear will be removed in Python 3.9 so no - # further warnings should be issued. - if env["HAS_CLANG"] and py_version_short == parse_version("3.8"): - env.Append(CXXFLAGS='-Wno-deprecated-declarations') - if env['OS'] == 'Darwin': env.Append(LINKFLAGS='-undefined dynamic_lookup') elif env['OS'] == 'Windows': @@ -1492,12 +1475,7 @@ def check_module(name): from ruamel import yaml versions["ruamel.yaml"] = yaml.__version__ except ImportError as ru_err: - try: - import ruamel_yaml as yaml - versions["ruamel.yaml"] = yaml.__version__ - except ImportError as ru_err_2: - err += str(ru_err) + "\\n" - err += str(ru_err_2) + "\\n" + err += str(ru_err) + "\\n" """) if check_for_pytest: script += check_module("pytest") @@ -1760,16 +1738,15 @@ def check_sundials(conf: "SConfigure", sundials_version: str) -> Dict[str, Union ".".join(sundials_version.strip().replace('"', "").split()) ) should_exit_with_error = conf.env["system_sundials"] == "y" - if sundials_ver < parse_version("3.0") or sundials_ver >= parse_version("8.0"): + if sundials_ver < parse_version("5.0") or sundials_ver >= parse_version("8.0"): if should_exit_with_error: - config_error(f"Sundials version must be >=3.0,<8.0. Found {sundials_ver}.") + config_error(f"Sundials version must be >=5.0,<8.0. Found {sundials_ver}.") return {"system_sundials": "n", "sundials_version": "", "has_sundials_lapack": 0} elif sundials_ver > parse_version("7.2.0"): logger.warning(f"Sundials version {sundials_ver} has not been tested.") cvode_checks = { - SpecifierSet(">=3.0,<4.0"): ("CVodeCreate(CV_BDF, CV_NEWTON);", ["sundials_cvodes"]), - SpecifierSet(">=4.0,<6.0"): ("CVodeCreate(CV_BDF);", ["sundials_cvodes"]), + SpecifierSet(">=5.0,<6.0"): ("CVodeCreate(CV_BDF);", ["sundials_cvodes"]), SpecifierSet(">=6.0,<7.0"): ( "SUNContext ctx; SUNContext_Create(0, &ctx);", ["sundials_cvodes"] ), diff --git a/src/SConscript b/src/SConscript index b7f6652850..004180aac3 100644 --- a/src/SConscript +++ b/src/SConscript @@ -83,8 +83,6 @@ if env["python_package"] == "y": if env["OS"] == "Windows": escaped_home = '\\"' + pyenv["py_base"].replace("\\", "\\\\") + '\\"' pyenv.Append(CPPDEFINES={"CT_PYTHONHOME": escaped_home}) - # Workaround for a problem with Boost, Python 3.8 and MSVC - pyenv.Append(CPPDEFINES={"HAVE_SNPRINTF": None}) pyenv.Append(LIBS=pyenv["py_libs"], LIBPATH=pyenv["py_libpath"]) shim = pyenv.SharedObject("extensions/pythonShim.cpp") diff --git a/src/base/application.h b/src/base/application.h index 767fb095f0..5c26ac9baa 100644 --- a/src/base/application.h +++ b/src/base/application.h @@ -434,8 +434,7 @@ class Application vector inputDirs; //! Versions of Python to consider when attempting to load user extensions - vector m_pythonSearchVersions = {"3.14", "3.13", "3.12", "3.11", "3.10", - "3.9", "3.8"}; + vector m_pythonSearchVersions = {"3.14", "3.13", "3.12", "3.11", "3.10"}; //! Set of deprecation warnings that have been emitted (to suppress duplicates) set warnings; diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 6de2cd932a..32bd8fa053 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -1191,15 +1191,6 @@ extern "C" { } } - size_t kin_reactionPhaseIndex(int n) - { - try { - return KineticsCabinet::at(n)->reactionPhaseIndex(); - } catch (...) { - return handleAllExceptions(npos, npos); - } - } - double kin_reactantStoichCoeff(int n, int k, int i) { try { diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index cc53c4074f..102cf206d3 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -482,16 +482,10 @@ extern "C" { } } - int sim1D_show(int i, const char* fname) + int sim1D_show(int i) { try { - string fn = string(fname); - if (fn == "-") { - SimCabinet::at(i)->show(); - } else { - ofstream fout(fname); - SimCabinet::at(i)->show(fout); - } + SimCabinet::at(i)->show(); return 0; } catch (...) { return handleAllExceptions(-1, ERR); diff --git a/src/clib/ctreactor.cpp b/src/clib/ctreactor.cpp index 2b066fd51d..493b459b02 100644 --- a/src/clib/ctreactor.cpp +++ b/src/clib/ctreactor.cpp @@ -90,30 +90,10 @@ extern "C" { } } - int reactor_setThermoMgr(int i, int n) + int reactor_setSolution(int i, int n) { try { - ReactorCabinet::at(i)->setThermoMgr(*ThermoCabinet::at(n)); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int reactor_setKineticsMgr(int i, int n) - { - try { - ReactorCabinet::at(i)->setKineticsMgr(*KineticsCabinet::at(n)); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int reactor_insert(int i, int n) - { - try { - ReactorCabinet::as(i)->insert(SolutionCabinet::at(n)); + ReactorCabinet::as(i)->setSolution(SolutionCabinet::at(n)); return 0; } catch (...) { return handleAllExceptions(-1, ERR); diff --git a/src/kinetics/Kinetics.cpp b/src/kinetics/Kinetics.cpp index 6298f8ff25..9bb2896a3a 100644 --- a/src/kinetics/Kinetics.cpp +++ b/src/kinetics/Kinetics.cpp @@ -73,13 +73,6 @@ void Kinetics::checkPhaseArraySize(size_t mm) const } } -size_t Kinetics::reactionPhaseIndex() const -{ - warn_deprecated("Kinetics::reactionPhaseIndex", "The reacting phase is always " - "the first phase. To be removed after Cantera 3.1."); - return 0; -} - shared_ptr Kinetics::reactionPhase() const { return m_thermo[0]; diff --git a/src/numerics/CVodesIntegrator.cpp b/src/numerics/CVodesIntegrator.cpp index afb2bb4aa7..2b958731ac 100644 --- a/src/numerics/CVodesIntegrator.cpp +++ b/src/numerics/CVodesIntegrator.cpp @@ -283,9 +283,7 @@ void CVodesIntegrator::initialize(double t0, FuncEval& func) //! Specify the method and the iteration type. Cantera Defaults: //! CV_BDF - Use BDF methods //! CV_NEWTON - use Newton's method - #if SUNDIALS_VERSION_MAJOR < 4 - m_cvode_mem = CVodeCreate(m_method, CV_NEWTON); - #elif SUNDIALS_VERSION_MAJOR < 6 + #if SUNDIALS_VERSION_MAJOR < 6 m_cvode_mem = CVodeCreate(m_method); #else m_cvode_mem = CVodeCreate(m_method, m_sundials_ctx.get()); @@ -412,29 +410,17 @@ void CVodesIntegrator::applyOptions() #if SUNDIALS_VERSION_MAJOR >= 6 m_linsol = SUNLinSol_SPGMR(m_y, SUN_PREC_NONE, 0, m_sundials_ctx.get()); CVodeSetLinearSolver(m_cvode_mem, (SUNLinearSolver) m_linsol, nullptr); - #elif SUNDIALS_VERSION_MAJOR >= 4 + #else m_linsol = SUNLinSol_SPGMR(m_y, PREC_NONE, 0); CVSpilsSetLinearSolver(m_cvode_mem, (SUNLinearSolver) m_linsol); - # else - m_linsol = SUNSPGMR(m_y, PREC_NONE, 0); - CVSpilsSetLinearSolver(m_cvode_mem, (SUNLinearSolver) m_linsol); #endif // set preconditioner if used - #if SUNDIALS_VERSION_MAJOR >= 4 - if (m_prec_side != PreconditionerSide::NO_PRECONDITION) { - SUNLinSol_SPGMRSetPrecType((SUNLinearSolver) m_linsol, - static_cast(m_prec_side)); - CVodeSetPreconditioner(m_cvode_mem, cvodes_prec_setup, - cvodes_prec_solve); - } - #else - if (m_prec_side != PreconditionerSide::NO_PRECONDITION) { - SUNSPGMRSetPrecType((SUNLinearSolver) m_linsol, - static_cast(m_prec_side)); - CVSpilsSetPreconditioner(m_cvode_mem, cvodes_prec_setup, - cvodes_prec_solve); - } - #endif + if (m_prec_side != PreconditionerSide::NO_PRECONDITION) { + SUNLinSol_SPGMRSetPrecType((SUNLinearSolver) m_linsol, + static_cast(m_prec_side)); + CVodeSetPreconditioner(m_cvode_mem, cvodes_prec_setup, + cvodes_prec_solve); + } } else if (m_type == "BAND") { sd_size_t N = static_cast(m_neq); sd_size_t nu = m_mupper; @@ -443,10 +429,8 @@ void CVodesIntegrator::applyOptions() SUNMatDestroy((SUNMatrix) m_linsol_matrix); #if SUNDIALS_VERSION_MAJOR >= 6 m_linsol_matrix = SUNBandMatrix(N, nu, nl, m_sundials_ctx.get()); - #elif SUNDIALS_VERSION_MAJOR >= 4 - m_linsol_matrix = SUNBandMatrix(N, nu, nl); #else - m_linsol_matrix = SUNBandMatrix(N, nu, nl, nu+nl); + m_linsol_matrix = SUNBandMatrix(N, nu, nl); #endif if (m_linsol_matrix == nullptr) { throw CanteraError("CVodesIntegrator::applyOptions", @@ -590,26 +574,22 @@ AnyMap CVodesIntegrator::solverStats() const nonlinConvFails = 0, orderReductions = 0; int lastOrder = 0; ; - #if SUNDIALS_VERSION_MAJOR >= 4 - CVodeGetNumSteps(m_cvode_mem, &steps); - CVodeGetNumRhsEvals(m_cvode_mem, &rhsEvals); - CVodeGetNonlinSolvStats(m_cvode_mem, &nonlinIters, &nonlinConvFails); - CVodeGetNumErrTestFails(m_cvode_mem, &errTestFails); - CVodeGetLastOrder(m_cvode_mem, &lastOrder); - CVodeGetNumStabLimOrderReds(m_cvode_mem, &orderReductions); - CVodeGetNumJacEvals(m_cvode_mem, &jacEvals); - CVodeGetNumLinRhsEvals(m_cvode_mem, &linRhsEvals); - CVodeGetNumLinSolvSetups(m_cvode_mem, &linSetup); - CVodeGetNumLinIters(m_cvode_mem, &linIters); - CVodeGetNumLinConvFails(m_cvode_mem, &linConvFails); - CVodeGetNumPrecEvals(m_cvode_mem, &precEvals); - CVodeGetNumPrecSolves(m_cvode_mem, &precSolves); - CVodeGetNumJTSetupEvals(m_cvode_mem, &jtSetupEvals); - CVodeGetNumJtimesEvals(m_cvode_mem, &jTimesEvals); - #else - warn_user("CVodesIntegrator::solverStats", "Function not" - "supported with sundials versions less than 4."); - #endif + + CVodeGetNumSteps(m_cvode_mem, &steps); + CVodeGetNumRhsEvals(m_cvode_mem, &rhsEvals); + CVodeGetNonlinSolvStats(m_cvode_mem, &nonlinIters, &nonlinConvFails); + CVodeGetNumErrTestFails(m_cvode_mem, &errTestFails); + CVodeGetLastOrder(m_cvode_mem, &lastOrder); + CVodeGetNumStabLimOrderReds(m_cvode_mem, &orderReductions); + CVodeGetNumJacEvals(m_cvode_mem, &jacEvals); + CVodeGetNumLinRhsEvals(m_cvode_mem, &linRhsEvals); + CVodeGetNumLinSolvSetups(m_cvode_mem, &linSetup); + CVodeGetNumLinIters(m_cvode_mem, &linIters); + CVodeGetNumLinConvFails(m_cvode_mem, &linConvFails); + CVodeGetNumPrecEvals(m_cvode_mem, &precEvals); + CVodeGetNumPrecSolves(m_cvode_mem, &precSolves); + CVodeGetNumJTSetupEvals(m_cvode_mem, &jtSetupEvals); + CVodeGetNumJtimesEvals(m_cvode_mem, &jTimesEvals); #if SUNDIALS_VERSION_MAJOR >= 7 || (SUNDIALS_VERSION_MAJOR == 6 && SUNDIALS_VERSION_MINOR >= 2) long int stepSolveFails = 0; diff --git a/src/numerics/Func1.cpp b/src/numerics/Func1.cpp index 5ea7596187..d4b93e146b 100644 --- a/src/numerics/Func1.cpp +++ b/src/numerics/Func1.cpp @@ -60,14 +60,6 @@ bool Func1::isIdentical(shared_ptr other) const return true; } -bool Func1::isIdentical(Func1& other) const -{ - warn_deprecated( - "Func1::isIdentical", - "Deprecated in Cantera 3.1; replaced by version using shared_ptr."); - return isIdentical(std::make_shared(Func1(other))); -} - //! accessor function for the returned constant double Func1::c() const { @@ -220,10 +212,10 @@ Const1::Const1(const vector& params) m_c = params[0]; } -Poly13::Poly13(const vector& params) +Poly1::Poly1(const vector& params) { if (params.size() == 0) { - throw CanteraError("Poly13::Poly13", + throw CanteraError("Poly1::Poly1", "Constructor needs an array that is not empty."); } size_t n = params.size() - 1; @@ -231,7 +223,7 @@ Poly13::Poly13(const vector& params) copy(params.data(), params.data() + m_cpoly.size(), m_cpoly.begin()); } -string Poly13::write(const string& arg) const +string Poly1::write(const string& arg) const { // write terms in reverse order string out = ""; @@ -544,29 +536,6 @@ string PlusConstant1::write(const string& arg) const return fmt::format("{} + {}", m_f1->write(arg), m_c); } -double Func1::isProportional(TimesConstant1& other) -{ - warn_deprecated( - "Func1::isProportional", - "Deprecated in Cantera 3.1; replaced by internal function."); - if (isIdentical(other.func1_shared())) { - return other.c(); - } - return 0.0; -} - -double Func1::isProportional(Func1& other) -{ - warn_deprecated( - "Func1::isProportional", - "Deprecated in Cantera 3.1; replaced by internal function."); - if (isIdentical(other)) { - return 1.0; - } else { - return 0.0; - } -} - namespace { // restrict scope of helper functions to local translation unit bool isConstant(const shared_ptr& f) diff --git a/src/numerics/Func1Factory.cpp b/src/numerics/Func1Factory.cpp index 7a30245dc0..88a6c2f1a9 100644 --- a/src/numerics/Func1Factory.cpp +++ b/src/numerics/Func1Factory.cpp @@ -35,7 +35,7 @@ Func1Factory::Func1Factory() return new Const1(params); }); reg("polynomial3", [](const vector& params) { - return new Poly13(params); + return new Poly1(params); }); reg("Fourier", [](const vector& params) { return new Fourier1(params); diff --git a/src/numerics/IdasIntegrator.cpp b/src/numerics/IdasIntegrator.cpp index 0ca0febb17..9f383172dc 100644 --- a/src/numerics/IdasIntegrator.cpp +++ b/src/numerics/IdasIntegrator.cpp @@ -350,11 +350,6 @@ void IdasIntegrator::applyOptions() #else m_linsol_matrix = SUNDenseMatrix(N, N); #endif - #if SUNDIALS_VERSION_MAJOR >= 6 - m_linsol_matrix = SUNDenseMatrix(N, N, m_sundials_ctx.get()); - #else - m_linsol_matrix = SUNDenseMatrix(N, N); - #endif #if CT_SUNDIALS_USE_LAPACK #if SUNDIALS_VERSION_MAJOR >= 6 m_linsol = SUNLinSol_LapackDense(m_y, (SUNMatrix) m_linsol_matrix, @@ -382,11 +377,8 @@ void IdasIntegrator::applyOptions() #if SUNDIALS_VERSION_MAJOR >= 6 m_linsol = SUNLinSol_SPGMR(m_y, SUN_PREC_NONE, 0, m_sundials_ctx.get()); IDASetLinearSolver(m_ida_mem, (SUNLinearSolver) m_linsol, nullptr); - #elif SUNDIALS_VERSION_MAJOR >= 4 - m_linsol = SUNLinSol_SPGMR(m_y, PREC_NONE, 0); - IDASpilsSetLinearSolver(m_ida_mem, (SUNLinearSolver) m_linsol); #else - m_linsol = SUNSPGMR(m_y, PREC_NONE, 0); + m_linsol = SUNLinSol_SPGMR(m_y, PREC_NONE, 0); IDASpilsSetLinearSolver(m_ida_mem, (SUNLinearSolver) m_linsol); #endif } else { diff --git a/src/oneD/Boundary1D.cpp b/src/oneD/Boundary1D.cpp index d6395a7da5..b4a41b3976 100644 --- a/src/oneD/Boundary1D.cpp +++ b/src/oneD/Boundary1D.cpp @@ -585,12 +585,6 @@ void Surf1D::fromArray(SolutionArray& arr, double* soln) Boundary1D::setMeta(meta); } -void Surf1D::show(std::ostream& s, const double* x) -{ - s << "------------------- Surface " << domainIndex() << " ------------------- " << std::endl; - s << " temperature: " << m_temp << " K" << std::endl; -} - void Surf1D::show(const double* x) { writelog(" Temperature: {:10.4g} K \n\n", m_temp); diff --git a/src/oneD/DomainFactory.cpp b/src/oneD/DomainFactory.cpp index de164e3a32..593c4ddc05 100644 --- a/src/oneD/DomainFactory.cpp +++ b/src/oneD/DomainFactory.cpp @@ -7,7 +7,6 @@ #include "cantera/oneD/Boundary1D.h" #include "cantera/oneD/Flow1D.h" #include "cantera/oneD/IonFlow.h" -#include "cantera/oneD/StFlow.h" #include "cantera/transport/Transport.h" namespace Cantera @@ -42,9 +41,6 @@ DomainFactory::DomainFactory() reg("gas-flow", [](shared_ptr solution, const string& id) { return new Flow1D(solution, id); }); - reg("legacy-flow", [](shared_ptr solution, const string& id) { - return new StFlow(solution, id); - }); reg("ion-flow", [](shared_ptr solution, const string& id) { return new IonFlow(solution, id); }); diff --git a/src/oneD/Flow1D.cpp b/src/oneD/Flow1D.cpp index 720a772431..4f07a6986c 100644 --- a/src/oneD/Flow1D.cpp +++ b/src/oneD/Flow1D.cpp @@ -773,12 +773,6 @@ void Flow1D::evalElectricField(double* x, double* rsd, int* diag, } } -void Flow1D::evalContinuity(size_t j, double* x, double* rsd, int* diag, double rdt) -{ - throw CanteraError("Flow1D::evalContinuity", - "Overloaded by StFlow; to be removed after Cantera 3.1"); -} - void Flow1D::show(const double* x) { writelog(" Pressure: {:10.4g} Pa\n", m_press); diff --git a/src/oneD/MultiJac.cpp b/src/oneD/MultiJac.cpp index 8aad78f0eb..0c4965146b 100644 --- a/src/oneD/MultiJac.cpp +++ b/src/oneD/MultiJac.cpp @@ -25,13 +25,6 @@ void MultiJac::updateTransient(double rdt, integer* mask) } } -void MultiJac::incrementDiagonal(int j, double d) -{ - warn_deprecated("MultiJac::incrementDiagonal", "To be removed after Cantera 3.1."); - m_ssdiag[j] += d; - value(j,j) = m_ssdiag[j]; -} - void MultiJac::eval(double* x0, double* resid0, double rdt) { m_nevals++; diff --git a/src/oneD/Sim1D.cpp b/src/oneD/Sim1D.cpp index ec3f184120..4ef88354ca 100644 --- a/src/oneD/Sim1D.cpp +++ b/src/oneD/Sim1D.cpp @@ -328,16 +328,6 @@ void Sim1D::setFlatProfile(size_t dom, size_t comp, double v) } } -void Sim1D::show(ostream& s) -{ - warn_deprecated("Sim1D::show(ostream&)", "To be removed after Cantera 3.1."); - for (size_t n = 0; n < nDomains(); n++) { - if (domain(n).type() != "empty") { - domain(n).show(s, m_state->data() + start(n)); - } - } -} - void Sim1D::show() { for (size_t n = 0; n < nDomains(); n++) { diff --git a/src/oneD/StFlow.cpp b/src/oneD/StFlow.cpp deleted file mode 100644 index 3d69ca8038..0000000000 --- a/src/oneD/StFlow.cpp +++ /dev/null @@ -1,315 +0,0 @@ -//! @file StFlow.cpp - -// This file is part of Cantera. See License.txt in the top-level directory or -// at https://cantera.org/license.txt for license and copyright information. - -#include "cantera/oneD/StFlow.h" -#include "cantera/base/global.h" - -using namespace std; - -namespace Cantera -{ - -StFlow::StFlow(ThermoPhase* ph, size_t nsp, size_t points) : - Flow1D(ph, nsp, points) -{ - warn_deprecated("StFlow::StFlow", - "To be removed after Cantera 3.1. Class replaced by Flow1D."); -} - -StFlow::StFlow(shared_ptr th, size_t nsp, size_t points) - : Flow1D(th, nsp, points) -{ - warn_deprecated("StFlow::StFlow", - "To be removed after Cantera 3.1. Class replaced by Flow1D."); -} - -StFlow::StFlow(shared_ptr sol, const string& id, size_t points) - : Flow1D(sol, id, points) -{ - warn_deprecated("StFlow::StFlow", - "To be removed after Cantera 3.1. Class replaced by Flow1D."); -} - -void StFlow::eval(size_t jg, double* xg, double* rg, integer* diagg, double rdt) -{ - // if evaluating a Jacobian, and the global point is outside the domain of - // influence for this domain, then skip evaluating the residual - if (jg != npos && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) { - return; - } - - // start of local part of global arrays - double* x = xg + loc(); - double* rsd = rg + loc(); - integer* diag = diagg + loc(); - - size_t jmin, jmax; - if (jg == npos) { // evaluate all points - jmin = 0; - jmax = m_points - 1; - } else { // evaluate points for Jacobian - size_t jpt = (jg == 0) ? 0 : jg - firstPoint(); - jmin = std::max(jpt, 1) - 1; - jmax = std::min(jpt+1,m_points-1); - } - - updateProperties(jg, x, jmin, jmax); - evalResidual(x, rsd, diag, rdt, jmin, jmax); - evalUo(x, rsd, diag, rdt, jmin, jmax); -} - -void StFlow::evalResidual(double* x, double* rsd, int* diag, - double rdt, size_t jmin, size_t jmax) -{ - //---------------------------------------------------- - // evaluate the residual equations at all required - // grid points - //---------------------------------------------------- - - // calculation of qdotRadiation (see docstring of enableRadiation) - if (m_do_radiation) { - // variable definitions for the Planck absorption coefficient and the - // radiation calculation: - double k_P_ref = 1.0*OneAtm; - - // polynomial coefficients: - const double c_H2O[6] = {-0.23093, -1.12390, 9.41530, -2.99880, - 0.51382, -1.86840e-5}; - const double c_CO2[6] = {18.741, -121.310, 273.500, -194.050, - 56.310, -5.8169}; - - // calculation of the two boundary values - double boundary_Rad_left = m_epsilon_left * StefanBoltz * pow(T(x, 0), 4); - double boundary_Rad_right = m_epsilon_right * StefanBoltz * pow(T(x, m_points - 1), 4); - - // loop over all grid points - for (size_t j = jmin; j < jmax; j++) { - // helping variable for the calculation - double radiative_heat_loss = 0; - - // calculation of the mean Planck absorption coefficient - double k_P = 0; - // absorption coefficient for H2O - if (m_kRadiating[1] != npos) { - double k_P_H2O = 0; - for (size_t n = 0; n <= 5; n++) { - k_P_H2O += c_H2O[n] * pow(1000 / T(x, j), (double) n); - } - k_P_H2O /= k_P_ref; - k_P += m_press * X(x, m_kRadiating[1], j) * k_P_H2O; - } - // absorption coefficient for CO2 - if (m_kRadiating[0] != npos) { - double k_P_CO2 = 0; - for (size_t n = 0; n <= 5; n++) { - k_P_CO2 += c_CO2[n] * pow(1000 / T(x, j), (double) n); - } - k_P_CO2 /= k_P_ref; - k_P += m_press * X(x, m_kRadiating[0], j) * k_P_CO2; - } - - // calculation of the radiative heat loss term - radiative_heat_loss = 2 * k_P *(2 * StefanBoltz * pow(T(x, j), 4) - - boundary_Rad_left - boundary_Rad_right); - - // set the radiative heat loss vector - m_qdotRadiation[j] = radiative_heat_loss; - } - } - - for (size_t j = jmin; j <= jmax; j++) { - //---------------------------------------------- - // left boundary - //---------------------------------------------- - - if (j == 0) { - // these may be modified by a boundary object - - // Continuity. This propagates information right-to-left, since - // rho_u at point 0 is dependent on rho_u at point 1, but not on - // mdot from the inlet. - rsd[index(c_offset_U,0)] = - -(rho_u(x,1) - rho_u(x,0))/m_dz[0] - -(density(1)*V(x,1) + density(0)*V(x,0)); - - // the inlet (or other) object connected to this one will modify - // these equations by subtracting its values for V, T, and mdot. As - // a result, these residual equations will force the solution - // variables to the values for the boundary object - rsd[index(c_offset_V,0)] = V(x,0); - rsd[index(c_offset_T,0)] = T(x,0); - if (m_usesLambda) { - rsd[index(c_offset_L, 0)] = -rho_u(x, 0); - } else { - rsd[index(c_offset_L, 0)] = lambda(x, 0); - diag[index(c_offset_L, 0)] = 0; - } - - // The default boundary condition for species is zero flux. However, - // the boundary object may modify this. - double sum = 0.0; - for (size_t k = 0; k < m_nsp; k++) { - sum += Y(x,k,0); - rsd[index(c_offset_Y + k, 0)] = - -(m_flux(k,0) + rho_u(x,0)* Y(x,k,0)); - } - rsd[index(c_offset_Y + leftExcessSpecies(), 0)] = 1.0 - sum; - - // set residual of poisson's equ to zero - rsd[index(c_offset_E, 0)] = x[index(c_offset_E, j)]; - } else if (j == m_points - 1) { - evalRightBoundary(x, rsd, diag, rdt); - } else { // interior points - evalContinuity(j, x, rsd, diag, rdt); - // set residual of poisson's equ to zero - rsd[index(c_offset_E, j)] = x[index(c_offset_E, j)]; - - //------------------------------------------------ - // Radial momentum equation - // - // \rho dV/dt + \rho u dV/dz + \rho V^2 - // = d(\mu dV/dz)/dz - lambda - //------------------------------------------------- - if (m_usesLambda) { - rsd[index(c_offset_V,j)] = - (shear(x, j) - lambda(x, j) - rho_u(x, j) * dVdz(x, j) - - m_rho[j] * V(x, j) * V(x, j)) / m_rho[j] - - rdt * (V(x, j) - V_prev(j)); - diag[index(c_offset_V, j)] = 1; - } else { - rsd[index(c_offset_V, j)] = V(x, j); - diag[index(c_offset_V, j)] = 0; - } - - //------------------------------------------------- - // Species equations - // - // \rho dY_k/dt + \rho u dY_k/dz + dJ_k/dz - // = M_k\omega_k - //------------------------------------------------- - getWdot(x,j); - for (size_t k = 0; k < m_nsp; k++) { - double convec = rho_u(x,j)*dYdz(x,k,j); - double diffus = 2.0*(m_flux(k,j) - m_flux(k,j-1)) - / (z(j+1) - z(j-1)); - rsd[index(c_offset_Y + k, j)] - = (m_wt[k]*(wdot(k,j)) - - convec - diffus)/m_rho[j] - - rdt*(Y(x,k,j) - Y_prev(k,j)); - diag[index(c_offset_Y + k, j)] = 1; - } - - //----------------------------------------------- - // energy equation - // - // \rho c_p dT/dt + \rho c_p u dT/dz - // = d(k dT/dz)/dz - // - sum_k(\omega_k h_k_ref) - // - sum_k(J_k c_p_k / M_k) dT/dz - //----------------------------------------------- - if (m_do_energy[j]) { - - setGas(x,j); - double dtdzj = dTdz(x,j); - double sum = 0.0; - - grad_hk(x, j); - for (size_t k = 0; k < m_nsp; k++) { - double flxk = 0.5*(m_flux(k,j-1) + m_flux(k,j)); - sum += wdot(k,j)*m_hk(k,j); - sum += flxk * m_dhk_dz(k,j) / m_wt[k]; - } - - rsd[index(c_offset_T, j)] = - m_cp[j]*rho_u(x,j)*dtdzj - - conduction(x,j) - sum; - rsd[index(c_offset_T, j)] /= (m_rho[j]*m_cp[j]); - rsd[index(c_offset_T, j)] -= rdt*(T(x,j) - T_prev(j)); - rsd[index(c_offset_T, j)] -= (m_qdotRadiation[j] / (m_rho[j] * m_cp[j])); - diag[index(c_offset_T, j)] = 1; - } else { - // residual equations if the energy equation is disabled - rsd[index(c_offset_T, j)] = T(x,j) - T_fixed(j); - diag[index(c_offset_T, j)] = 0; - } - - if (m_usesLambda) { - rsd[index(c_offset_L, j)] = lambda(x, j) - lambda(x, j - 1); - } else { - rsd[index(c_offset_L, j)] = lambda(x, j); - } - diag[index(c_offset_L, j)] = 0; - } - } -} - -void StFlow::evalRightBoundary(double* x, double* rsd, int* diag, double rdt) -{ - size_t j = m_points - 1; - - // the boundary object connected to the right of this one may modify or - // replace these equations. The default boundary conditions are zero u, V, - // and T, and zero diffusive flux for all species. - - rsd[index(c_offset_V,j)] = V(x,j); - diag[index(c_offset_V,j)] = 0; - double sum = 0.0; - // set residual of poisson's equ to zero - rsd[index(c_offset_E, j)] = x[index(c_offset_E, j)]; - for (size_t k = 0; k < m_nsp; k++) { - sum += Y(x,k,j); - rsd[index(k+c_offset_Y,j)] = m_flux(k,j-1) + rho_u(x,j)*Y(x,k,j); - } - rsd[index(c_offset_Y + rightExcessSpecies(), j)] = 1.0 - sum; - diag[index(c_offset_Y + rightExcessSpecies(), j)] = 0; - if (m_usesLambda) { - rsd[index(c_offset_U, j)] = rho_u(x, j); - } else { - rsd[index(c_offset_U, j)] = rho_u(x, j) - rho_u(x, j-1); - } - - rsd[index(c_offset_L, j)] = lambda(x, j) - lambda(x, j-1); - diag[index(c_offset_L, j)] = 0; - rsd[index(c_offset_T, j)] = T(x, j); -} - -void StFlow::evalContinuity(size_t j, double* x, double* rsd, int* diag, double rdt) -{ - //algebraic constraint - diag[index(c_offset_U, j)] = 0; - //---------------------------------------------- - // Continuity equation - // - // d(\rho u)/dz + 2\rho V = 0 - //---------------------------------------------- - if (m_usesLambda) { - // Note that this propagates the mass flow rate information to the left - // (j+1 -> j) from the value specified at the right boundary. The - // lambda information propagates in the opposite direction. - rsd[index(c_offset_U,j)] = - -(rho_u(x,j+1) - rho_u(x,j))/m_dz[j] - -(density(j+1)*V(x,j+1) + density(j)*V(x,j)); - } else if (m_isFree) { - // terms involving V are zero as V=0 by definition - if (z(j) > m_zfixed) { - rsd[index(c_offset_U,j)] = - - (rho_u(x,j) - rho_u(x,j-1))/m_dz[j-1]; - } else if (z(j) == m_zfixed) { - if (m_do_energy[j]) { - rsd[index(c_offset_U,j)] = (T(x,j) - m_tfixed); - } else { - rsd[index(c_offset_U,j)] = (rho_u(x,j) - - m_rho[0]*0.3); // why 0.3? - } - } else if (z(j) < m_zfixed) { - rsd[index(c_offset_U,j)] = - - (rho_u(x,j+1) - rho_u(x,j))/m_dz[j]; - } - } else { - // unstrained with fixed mass flow rate - rsd[index(c_offset_U, j)] = rho_u(x, j) - rho_u(x, j - 1); - } -} - -} // namespace diff --git a/src/oneD/refine.cpp b/src/oneD/refine.cpp index 95b1ae3806..28f6b9ccf2 100644 --- a/src/oneD/refine.cpp +++ b/src/oneD/refine.cpp @@ -235,32 +235,4 @@ void Refiner::show() } } -int Refiner::getNewGrid(int n, const double* z, int nn, double* zn) -{ - warn_deprecated( - "Refiner::getNewGrid", - "Deprecated in Cantera 3.1; unused function that will be removed."); - - int nnew = static_cast(m_insertPts.size()); - if (nnew + n > nn) { - throw CanteraError("Refine::getNewGrid", "array size too small."); - } - - if (m_insertPts.empty()) { - copy(z, z + n, zn); - return 0; - } - - int jn = 0; - for (int j = 0; j < n - 1; j++) { - zn[jn] = z[j]; - jn++; - if (m_insertPts.count(j)) { - zn[jn] = 0.5*(z[j] + z[j+1]); - jn++; - } - } - zn[jn] = z[n-1]; - return 0; -} } diff --git a/src/transport/GasTransport.cpp b/src/transport/GasTransport.cpp index acf540b8e8..02e0f705aa 100644 --- a/src/transport/GasTransport.cpp +++ b/src/transport/GasTransport.cpp @@ -29,7 +29,7 @@ void GasTransport::update_T() { if (m_thermo->nSpecies() != m_nsp) { // Rebuild data structures if number of species has changed - init(m_thermo, m_mode, m_log_level != 0 ? m_log_level : -7); + init(m_thermo, m_mode); } double T = m_thermo->temperature(); @@ -258,18 +258,11 @@ void GasTransport::getMixDiffCoeffsMass(double* const d) } } -void GasTransport::init(ThermoPhase* thermo, int mode, int log_level) +void GasTransport::init(ThermoPhase* thermo, int mode) { m_thermo = thermo; m_nsp = m_thermo->nSpecies(); m_mode = mode; - if (log_level == -7) { - log_level = 0; - } else { - warn_deprecated("Transport::init", "The log_level parameter " - "is deprecated and will be removed after Cantera 3.1."); - } - m_log_level = log_level; // set up Monchick and Mason collision integrals setupCollisionParameters(); @@ -386,15 +379,11 @@ void GasTransport::setupCollisionIntegral() } // initialize the collision integral calculator for the desired T* range - debuglog("*** collision_integrals ***\n", m_log_level); MMCollisionInt integrals; - integrals.init(tstar_min, tstar_max, m_log_level != 0 ? m_log_level : -7); + integrals.init(tstar_min, tstar_max); fitCollisionIntegrals(integrals); - debuglog("*** end of collision_integrals ***\n", m_log_level); // make polynomial fits - debuglog("*** property fits ***\n", m_log_level); fitProperties(integrals); - debuglog("*** end of property fits ***\n", m_log_level); } void GasTransport::getTransportData() @@ -463,14 +452,6 @@ void GasTransport::fitCollisionIntegrals(MMCollisionInt& integrals) { // Chemkin fits to sixth order polynomials int degree = (m_mode == CK_Mode ? 6 : COLL_INT_POLY_DEGREE); - if (m_log_level) { - writelog("tstar_fits\n" - "fits to A*, B*, and C* vs. log(T*).\n" - "These are done only for the required dstar(j,k) values.\n\n"); - if (m_log_level < 3) { - writelog("*** polynomial coefficients not printed (log_level < 3) ***\n"); - } - } vector fitlist; m_omega22_poly.clear(); m_astar_poly.clear(); @@ -532,22 +513,8 @@ void GasTransport::fitProperties(MMCollisionInt& integrals) vector c(degree + 1), c2(degree + 1); // fit the pure-species viscosity and thermal conductivity for each species - if (m_log_level && m_log_level < 2) { - writelog("*** polynomial coefficients not printed (log_level < 2) ***\n"); - } double visc, err, relerr, mxerr = 0.0, mxrelerr = 0.0, mxerr_cond = 0.0, mxrelerr_cond = 0.0; - - if (m_log_level) { - writelog("Polynomial fits for viscosity:\n"); - if (m_mode == CK_Mode) { - writelog("log(viscosity) fit to cubic polynomial in log(T)\n"); - } else { - writelogf("viscosity/sqrt(T) fit to polynomial of degree " - "%d in log(T)", degree); - } - } - double T_save = m_thermo->temperature(); const vector& mw = m_thermo->molecularWeights(); for (size_t k = 0; k < m_nsp; k++) { @@ -655,41 +622,8 @@ void GasTransport::fitProperties(MMCollisionInt& integrals) m_condcoeffs.push_back(c2); m_fittingErrors["conductivity-max-abs-error"] = mxerr_cond; m_fittingErrors["conductivity-max-rel-error"] = mxrelerr_cond; - - if (m_log_level >= 2) { - writelog(m_thermo->speciesName(k) + ": [" + vec2str(c) + "]\n"); - } } m_thermo->setTemperature(T_save); - - if (m_log_level) { - writelogf("Maximum viscosity absolute error: %12.6g\n", mxerr); - writelogf("Maximum viscosity relative error: %12.6g\n", mxrelerr); - writelog("\nPolynomial fits for conductivity:\n"); - if (m_mode == CK_Mode) { - writelog("log(conductivity) fit to cubic polynomial in log(T)"); - } else { - writelogf("conductivity/sqrt(T) fit to " - "polynomial of degree %d in log(T)", degree); - } - if (m_log_level >= 2) { - for (size_t k = 0; k < m_nsp; k++) { - writelog(m_thermo->speciesName(k) + ": [" + - vec2str(m_condcoeffs[k]) + "]\n"); - } - } - writelogf("Maximum conductivity absolute error: %12.6g\n", mxerr_cond); - writelogf("Maximum conductivity relative error: %12.6g\n", mxrelerr_cond); - - // fit the binary diffusion coefficients for each species pair - writelogf("\nbinary diffusion coefficients:\n"); - if (m_mode == CK_Mode) { - writelog("log(D) fit to cubic polynomial in log(T)"); - } else { - writelogf("D/T**(3/2) fit to polynomial of degree %d in log(T)",degree); - } - } - fitDiffCoeffs(integrals); } @@ -757,21 +691,11 @@ void GasTransport::fitDiffCoeffs(MMCollisionInt& integrals) mxrelerr = std::max(mxrelerr, fabs(relerr)); } m_diffcoeffs.push_back(c); - if (m_log_level >= 2) { - writelog(m_thermo->speciesName(k) + "__" + - m_thermo->speciesName(j) + ": [" + vec2str(c) + "]\n"); - } } } m_fittingErrors["diff-coeff-max-abs-error"] = mxerr; m_fittingErrors["diff-coeff-max-rel-error"] = mxrelerr; - if (m_log_level) { - writelogf("Maximum binary diffusion coefficient absolute error:" - " %12.6g\n", mxerr); - writelogf("Maximum binary diffusion coefficient relative error:" - "%12.6g", mxrelerr); - } } void GasTransport::getBinDiffCorrection(double t, MMCollisionInt& integrals, diff --git a/src/transport/IonGasTransport.cpp b/src/transport/IonGasTransport.cpp index 5867cd870a..0f54a42bde 100644 --- a/src/transport/IonGasTransport.cpp +++ b/src/transport/IonGasTransport.cpp @@ -14,7 +14,7 @@ namespace Cantera { -void IonGasTransport::init(ThermoPhase* thermo, int mode, int log_level) +void IonGasTransport::init(ThermoPhase* thermo, int mode) { m_thermo = thermo; m_nsp = m_thermo->nSpecies(); @@ -23,13 +23,6 @@ void IonGasTransport::init(ThermoPhase* thermo, int mode, int log_level) throw CanteraError("IonGasTransport::init", "mode = CK_Mode, which is an outdated lower-order fit."); } - if (log_level == -7) { - log_level = 0; - } else { - warn_deprecated("Transport::init", "The log_level parameter " - "is deprecated and will be removed after Cantera 3.1."); - } - m_log_level = log_level; // make a local copy of species charge for (size_t k = 0; k < m_nsp; k++) { m_speciesCharge.push_back(m_thermo->charge(k)); @@ -235,10 +228,6 @@ void IonGasTransport::fitDiffCoeffs(MMCollisionInt& integrals) } size_t sum = k * (k + 1) / 2; m_diffcoeffs[k*m_nsp+j-sum] = c; - if (m_log_level >= 2) { - writelog(m_thermo->speciesName(k) + "__" + - m_thermo->speciesName(j) + ": [" + vec2str(c) + "]\n"); - } } } m_fittingErrors["diff-coeff-max-abs-error"] = @@ -247,13 +236,6 @@ void IonGasTransport::fitDiffCoeffs(MMCollisionInt& integrals) m_fittingErrors["diff-coeff-max-rel-error"] = std::max(m_fittingErrors.getDouble("diff-coeff-max-rel-error", 0.0), mxrelerr); - - if (m_log_level) { - writelogf("Maximum binary diffusion coefficient absolute error:" - " %12.6g\n", mxerr); - writelogf("Maximum binary diffusion coefficient relative error:" - "%12.6g", mxrelerr); - } } void IonGasTransport::setupN64() diff --git a/src/transport/MMCollisionInt.cpp b/src/transport/MMCollisionInt.cpp index ae4a21a38d..8387c5e261 100644 --- a/src/transport/MMCollisionInt.cpp +++ b/src/transport/MMCollisionInt.cpp @@ -213,16 +213,8 @@ double MMCollisionInt::cstar_table[39*8] = { 0.94444, 0.94444,0.94444,0.94444,0.94444,0.94444,0.94444,0.94444 }; -void MMCollisionInt::init(double tsmin, double tsmax, int log_level) +void MMCollisionInt::init(double tsmin, double tsmax) { - if (log_level == -7) { - log_level = 0; - } else { - warn_deprecated("MMCollisionInt::init", "The log_level parameter " - "is deprecated and will be removed after Cantera 3.1."); - } - m_loglevel = log_level; - debuglog("Collision Integral Polynomial Fits\n", m_loglevel > 0); m_nmin = -1; m_nmax = -1; @@ -238,63 +230,23 @@ void MMCollisionInt::init(double tsmin, double tsmax, int log_level) m_nmin = 0; m_nmax = 36; } - if (m_loglevel > 0) { - writelogf("T*_min = %g\n", tstar[m_nmin + 1]); - writelogf("T*_max = %g\n", tstar[m_nmax + 1]); - } m_logTemp.resize(37); - double e22 = 0.0, ea = 0.0, eb = 0.0, ec = 0.0; - - if (m_loglevel > 0) { - writelog("Collision integral fits at each tabulated T* vs. delta*.\n" - "These polynomial fits are used to interpolate between " - "columns (delta*)\n in the Monchick and Mason tables." - " They are only used for nonzero delta*.\n"); - if (log_level < 4) { - writelog("polynomial coefficients not printed (log_level < 4)\n"); - } - } for (int i = 0; i < 37; i++) { m_logTemp[i] = log(tstar[i+1]); vector c(DeltaDegree+1); - double rmserr = fitDelta(0, i, DeltaDegree, c.data()); - if (log_level > 3) { - writelogf("\ndelta* fit at T* = %.6g\n", tstar[i+1]); - writelog("omega22 = [" + vec2str(c) + "]\n"); - } + fitDelta(0, i, DeltaDegree, c.data()); m_o22poly.push_back(c); - e22 = std::max(e22, rmserr); - rmserr = fitDelta(1, i, DeltaDegree, c.data()); + fitDelta(1, i, DeltaDegree, c.data()); m_apoly.push_back(c); - if (log_level > 3) { - writelog("A* = [" + vec2str(c) + "]\n"); - } - ea = std::max(ea, rmserr); - rmserr = fitDelta(2, i, DeltaDegree, c.data()); + fitDelta(2, i, DeltaDegree, c.data()); m_bpoly.push_back(c); - if (log_level > 3) { - writelog("B* = [" + vec2str(c) + "]\n"); - } - eb = std::max(eb, rmserr); - rmserr = fitDelta(3, i, DeltaDegree, c.data()); + fitDelta(3, i, DeltaDegree, c.data()); m_cpoly.push_back(c); - if (log_level > 3) { - writelog("C* = [" + vec2str(c) + "]\n"); - } - ec = std::max(ec, rmserr); - - if (log_level > 0) { - writelogf("max RMS errors in fits vs. delta*:\n" - " omega_22 = %12.6g \n" - " A* = %12.6g \n" - " B* = %12.6g \n" - " C* = %12.6g \n", e22, ea, eb, ec); - } } } @@ -430,12 +382,7 @@ void MMCollisionInt::fit_omega22(int degree, double deltastar, double* o22) } } w[0]= -1.0; - double rmserr = polyfit(n, degree, logT, values.data(), w.data(), o22); - if (m_loglevel > 0 && rmserr > 0.01) { - warn_user("MMCollisionInt::fit_omega22", - "RMS error = {:12.6g} in omega_22 fit " - "with delta* = {:12.6g}", rmserr, deltastar); - } + polyfit(n, degree, logT, values.data(), w.data(), o22); } void MMCollisionInt::fit(int degree, double deltastar, double* a, double* b, double* c) @@ -452,7 +399,7 @@ void MMCollisionInt::fit(int degree, double deltastar, double* a, double* b, dou } } w[0]= -1.0; - double rmserr = polyfit(n, degree, logT, values.data(), w.data(), a); + polyfit(n, degree, logT, values.data(), w.data(), a); for (int i = 0; i < n; i++) { if (deltastar == 0.0) { @@ -462,7 +409,7 @@ void MMCollisionInt::fit(int degree, double deltastar, double* a, double* b, dou } } w[0]= -1.0; - rmserr = polyfit(n, degree, logT, values.data(), w.data(), b); + polyfit(n, degree, logT, values.data(), w.data(), b); for (int i = 0; i < n; i++) { if (deltastar == 0.0) { @@ -472,28 +419,7 @@ void MMCollisionInt::fit(int degree, double deltastar, double* a, double* b, dou } } w[0]= -1.0; - rmserr = polyfit(n, degree, logT, values.data(), w.data(), c); - if (m_loglevel > 2) { - writelogf("\nT* fit at delta* = %.6g\n", deltastar); - - writelog("astar = [" + vec2str(vector(a, a+degree+1))+ "]\n"); - if (rmserr > 0.01) { - warn_user("MMCollisionInt::fit", - "RMS error = {:12.6g} for A* fit", rmserr); - } - - writelog("bstar = [" + vec2str(vector(b, b+degree+1))+ "]\n"); - if (rmserr > 0.01) { - warn_user("MMCollisionInt::fit", - "RMS error = {:12.6g} for B* fit", rmserr); - } - - writelog("cstar = [" + vec2str(vector(c, c+degree+1))+ "]\n"); - if (rmserr > 0.01) { - warn_user("MMCollisionInt::fit", - "RMS error = {:12.6g} for C* fit", rmserr); - } - } + polyfit(n, degree, logT, values.data(), w.data(), c); } } // namespace diff --git a/src/transport/MMCollisionInt.h b/src/transport/MMCollisionInt.h index 00f87bfe18..eaf8380266 100644 --- a/src/transport/MMCollisionInt.h +++ b/src/transport/MMCollisionInt.h @@ -31,12 +31,8 @@ class MMCollisionInt /*! * @param tsmin Minimum value of Tstar to carry out the fitting * @param tsmax Maximum value of Tstar to carry out the fitting - * @param loglevel Set the loglevel for the object. The default - * loglevel is zero, indicating no output. - * @deprecated The `log_level` parameter is deprecated and will be removed after - * %Cantera 3.1. */ - void init(double tsmin, double tsmax, int loglevel = -7); + void init(double tsmin, double tsmax); double omega22(double ts, double deltastar); double astar(double ts, double deltastar); @@ -79,9 +75,7 @@ class MMCollisionInt int m_nmin; int m_nmax; - - //! loglevel - int m_loglevel; }; + } #endif diff --git a/src/transport/MixTransport.cpp b/src/transport/MixTransport.cpp index 192e18ecfe..0aeafff05d 100644 --- a/src/transport/MixTransport.cpp +++ b/src/transport/MixTransport.cpp @@ -14,9 +14,9 @@ namespace Cantera { -void MixTransport::init(ThermoPhase* thermo, int mode, int log_level) +void MixTransport::init(ThermoPhase* thermo, int mode) { - GasTransport::init(thermo, mode, log_level); + GasTransport::init(thermo, mode); m_cond.resize(m_nsp); } diff --git a/src/transport/MultiTransport.cpp b/src/transport/MultiTransport.cpp index 71d30b424e..fb98f4eb5b 100644 --- a/src/transport/MultiTransport.cpp +++ b/src/transport/MultiTransport.cpp @@ -34,9 +34,9 @@ double Frot(double tr, double sqtr) //////////////////// class MultiTransport methods ////////////// -void MultiTransport::init(ThermoPhase* thermo, int mode, int log_level) +void MultiTransport::init(ThermoPhase* thermo, int mode) { - GasTransport::init(thermo, mode, log_level); + GasTransport::init(thermo, mode); // the L matrix m_Lmatrix.resize(3*m_nsp, 3*m_nsp); diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index 2589697261..1320f659c6 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -66,12 +66,8 @@ void TransportFactory::deleteFactory() } Transport* TransportFactory::newTransport(const string& transportModel, - ThermoPhase* phase, int log_level) + ThermoPhase* phase) { - if (log_level != -7) { - warn_deprecated("TransportFactory::newTransport", "The log_level parameter " - "is deprecated and will be removed after Cantera 3.1."); - } if (transportModel != "DustyGas" && canonicalize(transportModel) == "none") { return create(transportModel); } @@ -88,30 +84,26 @@ Transport* TransportFactory::newTransport(const string& transportModel, if (transportModel == "DustyGas") { tr = new DustyGasTransport; Transport* gastr = new MultiTransport; - gastr->init(phase, 0, log_level); + gastr->init(phase, 0); DustyGasTransport* dtr = (DustyGasTransport*)tr; dtr->initialize(phase, gastr); } else { tr = create(transportModel); int mode = m_CK_mode[transportModel] ? CK_Mode : 0; - tr->init(phase, mode, log_level); + tr->init(phase, mode); } phase->restoreState(state); return tr; } -Transport* TransportFactory::newTransport(ThermoPhase* phase, int log_level) +Transport* TransportFactory::newTransport(ThermoPhase* phase) { - if (log_level != -7) { - warn_deprecated("TransportFactory::newTransport", "The log_level parameter " - "is deprecated and will be removed after Cantera 3.1."); - } string transportModel = "none"; AnyMap& input = phase->input(); if (input.hasKey("transport")) { transportModel = input["transport"].asString(); } - return newTransport(transportModel, phase,log_level); + return newTransport(transportModel, phase); } shared_ptr newTransport(shared_ptr thermo, const string& model) diff --git a/src/transport/WaterTransport.cpp b/src/transport/WaterTransport.cpp index 160ee5661e..90ba2838f6 100644 --- a/src/transport/WaterTransport.cpp +++ b/src/transport/WaterTransport.cpp @@ -31,12 +31,8 @@ const double Hij[6][7] = { namespace Cantera { -void WaterTransport::init(ThermoPhase* thermo, int mode, int log_level) +void WaterTransport::init(ThermoPhase* thermo, int mode) { - if (log_level != -7) { - warn_deprecated("Transport::init", "The log_level parameter " - "is deprecated and will be removed after Cantera 3.1."); - } m_thermo = thermo; } diff --git a/src/zeroD/FlowDeviceFactory.cpp b/src/zeroD/FlowDeviceFactory.cpp index 013178a21f..9d58a25c30 100644 --- a/src/zeroD/FlowDeviceFactory.cpp +++ b/src/zeroD/FlowDeviceFactory.cpp @@ -44,11 +44,4 @@ shared_ptr newFlowDevice(const string& model, const string& name) return shared_ptr(FlowDeviceFactory::factory()->create(model, name)); } -shared_ptr newFlowDevice3(const string& model) -{ - warn_deprecated("newFlowDevice3", - "Use newFlowDevice instead; to be removed after Cantera 3.1."); - return newFlowDevice(model); -} - } diff --git a/src/zeroD/Reactor.cpp b/src/zeroD/Reactor.cpp index 28f4ce7f8b..8777010d94 100644 --- a/src/zeroD/Reactor.cpp +++ b/src/zeroD/Reactor.cpp @@ -26,11 +26,8 @@ Reactor::Reactor(shared_ptr sol, const string& name) : ReactorBase(name) { if (!sol || !(sol->thermo())) { - warn_deprecated("Reactor::Reactor", - "Creation of empty reactor objects is deprecated in Cantera 3.1 and will " - "raise\nexceptions thereafter; reactor contents should be provided in the " - "constructor."); - return; + throw CanteraError("Reactor::Reactor", + "Reactor contents must be provided as constructor arguments"); } setSolution(sol); setThermo(*sol->thermo()); diff --git a/src/zeroD/ReactorBase.cpp b/src/zeroD/ReactorBase.cpp index 4c5ced8393..45d4a86ca6 100644 --- a/src/zeroD/ReactorBase.cpp +++ b/src/zeroD/ReactorBase.cpp @@ -21,11 +21,8 @@ ReactorBase::ReactorBase(shared_ptr sol, const string& name) : ReactorBase(name) { if (!sol || !(sol->thermo())) { - warn_deprecated("ReactorBase::ReactorBase", - "Creation of empty reactor objects is deprecated in Cantera 3.1 and will " - "raise\nexceptions thereafter; reactor contents should be provided in the " - "constructor."); - return; + throw CanteraError("ReactorBase::ReactorBase", + "Missing or incomplete Solution object."); } setSolution(sol); } @@ -68,13 +65,6 @@ void ReactorBase::setSolution(shared_ptr sol) { m_solution->thermo()->addSpeciesLock(); } -void ReactorBase::insert(shared_ptr sol) -{ - warn_deprecated("ReactorBase::insert", - "To be removed after Cantera 3.1. Superseded by 'setSolution'."); - setSolution(sol); -} - void ReactorBase::setThermo(ThermoPhase& thermo) { m_thermo = &thermo; @@ -85,20 +75,6 @@ void ReactorBase::setThermo(ThermoPhase& thermo) m_pressure = m_thermo->pressure(); } -void ReactorBase::setThermoMgr(ThermoPhase& thermo) -{ - warn_deprecated("ReactorBase::setThermoMgr", - "To be removed after Cantera 3.1. Superseded by 'setSolution'."); - setThermo(thermo); -} - -void ReactorBase::setKineticsMgr(Kinetics& kin) -{ - warn_deprecated("ReactorBase::setKineticsMgr", - "To be removed after Cantera 3.1. Superseded by 'setSolution'."); - setKinetics(kin); -} - void ReactorBase::syncState() { m_thermo->saveState(m_state); diff --git a/src/zeroD/ReactorFactory.cpp b/src/zeroD/ReactorFactory.cpp index 4642e22009..db6a0706a1 100644 --- a/src/zeroD/ReactorFactory.cpp +++ b/src/zeroD/ReactorFactory.cpp @@ -107,10 +107,4 @@ shared_ptr newReactor( ReactorFactory::factory()->create(model, contents, name)); } -shared_ptr newReactor3(const string& model) -{ - warn_deprecated("newReactor3", "To be removed after Cantera 3.1."); - return newReactor(model); -} - } diff --git a/src/zeroD/WallFactory.cpp b/src/zeroD/WallFactory.cpp index 4acf2c0578..1c2b0ac068 100644 --- a/src/zeroD/WallFactory.cpp +++ b/src/zeroD/WallFactory.cpp @@ -36,11 +36,4 @@ shared_ptr newWall(const string& model, const string& name) return shared_ptr(WallFactory::factory()->create(model, name)); } -shared_ptr newWall3(const string& model) -{ - warn_deprecated("newWall3", - "Use newWall instead; to be removed after Cantera 3.1."); - return newWall(model); -} - } diff --git a/test/oneD/test_oneD.cpp b/test/oneD/test_oneD.cpp index 02194ab688..8e938426db 100644 --- a/test/oneD/test_oneD.cpp +++ b/test/oneD/test_oneD.cpp @@ -5,7 +5,6 @@ #include "cantera/core.h" #include "cantera/onedim.h" #include "cantera/oneD/DomainFactory.h" -#include "cantera/oneD/StFlow.h" #include "cantera/oneD/IonFlow.h" using namespace Cantera; @@ -103,98 +102,6 @@ TEST(onedim, freeflame) } } -TEST(onedim, legacy) -{ - //! @todo: Remove after Cantera 3.1 - auto sol = newSolution("h2o2.yaml", "ohmech", "mixture-averaged"); - auto gas = sol->thermo(); - size_t nsp = gas->nSpecies(); - - // reactants - double uin = .3; - double T = 300; - double P = 101325; - string X = "H2:0.65, O2:0.5, AR:2"; - gas->setState_TPX(T, P, X); - double rho_in = gas->density(); - vector yin(nsp); - gas->getMassFractions(&yin[0]); - - // product estimate - gas->equilibrate("HP"); - vector yout(nsp); - gas->getMassFractions(&yout[0]); - double rho_out = gas->density(); - double Tad = gas->temperature(); - - // flow - suppress_deprecation_warnings(); - auto flow = newDomain("legacy-flow", sol); - make_deprecation_warnings_fatal(); - flow->setID("flow"); - flow->setFreeFlow(); - - // grid - int nz = 21; - double lz = 0.02; - vector z(nz); - double dz = lz; - dz /= (double)(nz - 1); - for (int iz = 0; iz < nz; iz++) { - z[iz] = iz * dz; - } - flow->setupGrid(nz, &z[0]); - - // inlet - auto inlet = newDomain("inlet", sol); - inlet->setMoleFractions(X); - inlet->setMdot(uin * rho_in); - inlet->setTemperature(T); - - // outlet - auto outlet = newDomain("outlet", sol); - double uout = inlet->mdot() / rho_out; - - // set up simulation - vector> domains { inlet, flow, outlet }; - Sim1D flame(domains); - int dom = static_cast(flame.domainIndex("flow")); - ASSERT_EQ(dom, 1); - - // set up initial guess - vector locs{0.0, 0.3, 0.7, 1.0}; - vector value{uin, uin, uout, uout}; - flame.setInitialGuess("velocity", locs, value); - value = {T, T, Tad, Tad}; - flame.setInitialGuess("T", locs, value); - for (size_t i = 0; i < nsp; i++) { - value = {yin[i], yin[i], yout[i], yout[i]}; - flame.setInitialGuess(gas->speciesName(i), locs, value); - } - - // simulation settings - double ratio = 15.0; - double slope = 0.3; - double curve = 0.5; - flame.setRefineCriteria(dom, ratio, slope, curve); - flame.setFixedTemperature(0.85 * T + .15 * Tad); - - // solve - flow->solveEnergyEqn(); - bool refine_grid = false; - int loglevel = 0; - flame.solve(loglevel, refine_grid); - - ASSERT_EQ(flow->nPoints(), static_cast(nz + 1)); - size_t comp = flow->componentIndex("T"); - double Tprev = flame.value(dom, comp, 0); - for (size_t n = 0; n < flow->nPoints(); n++) { - T = flame.value(dom, comp, n); - ASSERT_GE(T, Tprev); - Tprev = T; - } -} - TEST(onedim, flame_types) { auto sol = newSolution("h2o2.yaml", "ohmech", "mixture-averaged"); diff --git a/test/python/conftest.py b/test/python/conftest.py index 9453760d56..31b804f261 100644 --- a/test/python/conftest.py +++ b/test/python/conftest.py @@ -4,11 +4,8 @@ from pathlib import Path import pytest import tempfile +from ruamel import yaml -try: - from ruamel import yaml -except ImportError: - import ruamel_yaml as yaml pytest.register_assert_rewrite("pint.testing") diff --git a/test/python/test_convert.py b/test/python/test_convert.py index 2998987f8c..b99f6d9ab0 100644 --- a/test/python/test_convert.py +++ b/test/python/test_convert.py @@ -31,9 +31,7 @@ def convert(self, inputFile, thermo=None, transport=None, if extra is not None: extra = self.test_data_path / extra output = self.test_work_path / (output + "-from-ck.yaml") - # In Python >= 3.8, this can be replaced by the missing_ok argument - if output.is_file(): - output.unlink() + output.unlink(missing_ok=True) ck2yaml.convert(inputFile, thermo_file=thermo, transport_file=transport, surface_file=surface, out_name=output, extra_file=extra, quiet=quiet, **kwargs) diff --git a/test/python/test_func1.py b/test/python/test_func1.py index da98c0c80e..4d5792f989 100644 --- a/test/python/test_func1.py +++ b/test/python/test_func1.py @@ -96,10 +96,6 @@ def test_simple(self): assert name in func.write() assert func(val) == approx(fcn(coeff * val)) - def test_deprecated(self): - with pytest.warns(DeprecationWarning, match="use alternative constructor"): - ct.Func1.cxx_functor("cos") - def test_compound(self): functors = { 'sum': lambda x, y: x + y, diff --git a/test/python/test_kinetics.py b/test/python/test_kinetics.py index 52af7b2f52..2b6c8bcb75 100644 --- a/test/python/test_kinetics.py +++ b/test/python/test_kinetics.py @@ -28,12 +28,10 @@ def phase(self): phase.TPX = 800, 2 * ct.one_atm, [0.1, 1e-4, 1e-5, 0.2, 2e-4, 0.3, 1e-6, 5e-5, 0.4, 0] return phase - @pytest.mark.usefixtures("allow_deprecated") def test_counts(self, phase): assert phase.n_reactions == 29 assert phase.n_total_species == 10 assert phase.n_phases == 1 - assert phase.reaction_phase_index == 0 # deprecated def test_is_reversible(self, phase): for i in range(phase.n_reactions): diff --git a/test/python/test_onedim.py b/test/python/test_onedim.py index c886c1e789..f0dffaaed8 100644 --- a/test/python/test_onedim.py +++ b/test/python/test_onedim.py @@ -687,9 +687,6 @@ def run_fixed_restore(self, mode): return filename, "test" - # @pytest.mark.filterwarnings("ignore:.*reaction_phase_index.*:DeprecationWarning") - # TODO: remove fixture after Cantera 3.1; @pytest.mark.filterwarnings does not work - @pytest.mark.usefixtures("allow_deprecated") # to ignore reaction_phase_index def test_array_properties(self): self.create_sim(ct.one_atm, 300, 'H2:1.1, O2:1, AR:5') grid_shape = self.sim.grid.shape @@ -732,10 +729,7 @@ def test_save_restore_add_species_yaml(self): Tin = 400 filename = self.test_work_path / "onedim-add-species.yaml" - # In Python >= 3.8, this can be replaced by the missing_ok argument - if filename.is_file(): - filename.unlink() - + filename.unlink(missing_ok=True) self.create_sim(p, Tin, reactants, mech="h2o2.yaml") gas1 = self.gas self.sim.max_grid_points = 234 @@ -767,10 +761,7 @@ def test_save_restore_remove_species_yaml(self): Tin = 400 filename = self.test_work_path / "onedim-remove-species.yaml" - # In Python >= 3.8, this can be replaced by the missing_ok argument - if filename.is_file(): - filename.unlink() - + filename.unlink(missing_ok=True) self.create_sim(p, Tin, reactants, mech="h2o2-plus.yaml") gas1 = self.gas self.solve_fixed_T() @@ -1126,10 +1117,7 @@ def test_mixture_averaged_rad(self, request, test_data_path): assert not bad, bad filename = self.test_work_path / "DiffusionFlameTest-h2-mix-rad.csv" - # In Python >= 3.8, this can be replaced by the missing_ok argument - if filename.is_file(): - filename.unlink() - + filename.unlink(missing_ok=True) self.sim.save(filename, basis="mole") # check output assert filename.is_file() csv_data = np.genfromtxt(filename, dtype=float, delimiter=',', names=True) diff --git a/test/python/test_reactor.py b/test/python/test_reactor.py index be9df18e52..15de152b7a 100644 --- a/test/python/test_reactor.py +++ b/test/python/test_reactor.py @@ -52,21 +52,6 @@ def test_verbose(self): self.net.verbose = True assert self.net.verbose - @pytest.mark.usefixtures("allow_deprecated") - def test_insert(self): - R = self.reactorClass() # warning raised from C++ code - with pytest.raises(ct.CanteraError, match='No phase'): - R.T - with pytest.raises(ct.CanteraError, match='No phase'): - R.kinetics.net_production_rates - - g = ct.Solution('h2o2.yaml', transport_model=None) - g.TP = 300, 101325 - R.insert(g) - - assert R.T == approx(300) - assert len(R.kinetics.net_production_rates) == g.n_species - def test_volume(self): g = ct.Solution('h2o2.yaml', transport_model=None) R = self.reactorClass(g, volume=11) @@ -743,15 +728,8 @@ def test_valve_type2(self): assert self.r1.name.startswith(f"{self.r1.type}_") # default name assert res.name.startswith(f"{res.type}_") # default name - @pytest.mark.usefixtures("allow_deprecated") def test_valve_errors(self): self.make_reactors() - res = ct.Reservoir() # warning raised from C++ code - - with pytest.raises(ct.CanteraError, match='contents not defined'): - # Must assign contents of both reactors before creating Valve - v = ct.Valve(self.r1, res) - v = ct.Valve(self.r1, self.r2) with pytest.raises(ct.CanteraError, match='Already installed'): # inlet and outlet cannot be reassigned @@ -920,8 +898,8 @@ def test_invalid_property(self): def test_bad_kwarg(self): g = ct.Solution('h2o2.yaml', transport_model=None) self.reactorClass(g, name='ok') - with pytest.raises(ct.CanteraError): - self.reactorClass(foobar=3.14) + with pytest.raises(TypeError): + self.reactorClass(g, foobar=3.14) def test_preconditioner_unsupported(self): self.make_reactors() diff --git a/test/python/utilities.py b/test/python/utilities.py index 3554971f03..3cc1c37e23 100644 --- a/test/python/utilities.py +++ b/test/python/utilities.py @@ -2,26 +2,16 @@ from pathlib import Path, PurePath from pytest import approx import warnings - -try: - from ruamel import yaml -except ImportError: - import ruamel_yaml as yaml +from ruamel import yaml def load_yaml(yml_file): """ Load YAML data from file using the "safe" loading option. """ - try: - yaml_parser = yaml.YAML(typ="safe") - with open(yml_file, "rt", encoding="utf-8") as stream: - return yaml_parser.load(stream) - except yaml.constructor.ConstructorError: - with open(yml_file, "rt", encoding="utf-8") as stream: - # Ensure that the loader remains backward-compatible with legacy - # ruamel.yaml versions (prior to 0.17.0). - return yaml.safe_load(stream) + yaml_parser = yaml.YAML(typ="safe") + with open(yml_file, "rt", encoding="utf-8") as stream: + return yaml_parser.load(stream) def compare(data, reference_file, rtol=1e-8, atol=1e-12): """