Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Restore old model #156

Merged
merged 8 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
with:
lfs: false

- name: set up python libraries
run: pip3 install -r requirements.txt

- name: check if artifact exists
run: echo "ARTIFACT_EXISTS=$(./tools/check_artifact.sh straka_output.nc)" >> $GITHUB_ENV

Expand Down Expand Up @@ -222,6 +225,9 @@ jobs:
with:
lfs: false

- name: set up python libraries
run: pip3 install -r requirements.txt

- name: check if artifact exists
run: echo "ARTIFACT_EXISTS=$(./tools/check_artifact.sh swxy_output.nc)" >> $GITHUB_ENV

Expand Down Expand Up @@ -338,7 +344,7 @@ jobs:
run: brew bundle

- name: install python modules
run: sudo pip3 install -r requirements.txt
run: pip3 install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down Expand Up @@ -369,6 +375,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip3 install -r requirements.txt

- name: check if artifact exists
run: echo "ARTIFACT_EXISTS=$(./tools/check_artifact.sh test_blast_output.nc)" >> $GITHUB_ENV

Expand Down
35 changes: 28 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- run: echo "🖥️ The workspace, ${{ github.workspace }}, is now ready to test your code on the runner."

- name: Install cpplint
run: sudo pip install cpplint
run: pip install cpplint

- uses: actions/checkout@v3
with:
Expand All @@ -49,6 +49,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand All @@ -73,6 +76,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down Expand Up @@ -100,6 +106,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down Expand Up @@ -146,7 +155,7 @@ jobs:
lfs: false

- name: install python modules
run: sudo pip install -r requirements.txt
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down Expand Up @@ -194,6 +203,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down Expand Up @@ -241,6 +253,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down Expand Up @@ -288,6 +303,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down Expand Up @@ -335,7 +353,7 @@ jobs:
lfs: false

- name: install python modules
run: sudo pip install -r requirements.txt
run: pip install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down Expand Up @@ -367,6 +385,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip install -r requirements.txt

- name: check if artifact exists
run: echo "ARTIFACT_EXISTS=$(./tools/check_artifact.sh robert_output.nc)" >> $GITHUB_ENV

Expand All @@ -380,9 +401,6 @@ jobs:
if: env.ARTIFACT_EXISTS == 'false'
run: git lfs pull -I examples/2019-Li-snap/straka_output.nc

- name: set up python libraries
run: pip3 install -r requirements.txt

- name: create build directory
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DTASK=straka

Expand Down Expand Up @@ -685,7 +703,7 @@ jobs:
lfs: false

- name: install python modules
run: sudo pip3 install -r requirements.txt
run: pip3 install -r requirements.txt

- name: create build directory
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down Expand Up @@ -717,6 +735,9 @@ jobs:
with:
lfs: false

- name: install python modules
run: pip3 install -r requirements.txt

- name: check if artifact exists
run: echo "ARTIFACT_EXISTS=$(./tools/check_artifact.sh test_blast_output.nc)" >> $GITHUB_ENV

Expand Down
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ endif()
message(STATUS "Include ${CMAKE_CURRENT_SOURCE_DIR}/cmake/parameters.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/parameters.cmake)
find_package(Eigen3 REQUIRED)
find_package(Cantera REQUIRED)
find_package(Torch REQUIRED)
find_package(Cantera)
#find_package(Torch)

## 3. set up project system libraries ##
message(STATUS "3. Set up system libraries")
#message(STATUS "Include ${CMAKE_SOURCE_DIR}/cmake/athena.cmake")
if (NOT ${CANTERA_FOUND} STREQUAL "TRUE")
if (NOT ${CANTERA_FOUND})
include(${CMAKE_SOURCE_DIR}/cmake/yamlpp.cmake)
endif()
include(${CMAKE_SOURCE_DIR}/cmake/gtest.cmake)
Expand Down
5 changes: 5 additions & 0 deletions cmake/modules/FindCantera.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ if(CANTERA_INCLUDE_DIR)
message(STATUS "Symbolic link created: ${LINK_PATH} -> ${SOURCE_PATH}")
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/ext1)
else()
message(STATUS "Not using Cantera library")
set(CANTERA_INCLUDE_DIR "")
set(CANTERA_LIBRARY "")
set(CANTERA_FOUND FALSE)
endif()
2 changes: 2 additions & 0 deletions cmake/yamlpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ endif()

# Where yaml-cpp's .h files can be found.
include_directories(${yaml-cpp_SOURCE_DIR}/include)

set(YAML_CPP_LIBRARIES yaml-cpp)
2 changes: 1 addition & 1 deletion examples/2023-Li-saturn-vla/saturn_radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <athena/outputs/outputs.hpp>
#include <athena/parameter_input.hpp>
#include <athena/scalars/scalars.hpp>
#include <athena/stride_iterator.hpp>

// application
#include <application/application.hpp>
Expand All @@ -32,6 +31,7 @@
#include <climath/interpolation.h>

// snap
#include <snap/stride_iterator.hpp>
#include <snap/thermodynamics/molecules.hpp>
#include <snap/thermodynamics/thermodynamics.hpp>
#include <snap/thermodynamics/vapors/sodium_vapors.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/2023-Li-uranus/uranus_mwr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <athena/outputs/outputs.hpp>
#include <athena/parameter_input.hpp>
#include <athena/scalars/scalars.hpp>
#include <athena/stride_iterator.hpp>

// application
#include <application/application.hpp>
Expand All @@ -32,6 +31,7 @@
#include <climath/interpolation.h>

// snap
#include <snap/stride_iterator.hpp>
#include <snap/thermodynamics/molecules.hpp>
#include <snap/thermodynamics/thermodynamics.hpp>
#include <snap/thermodynamics/vapors/sodium_vapors.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/2024-JHu-juno-mwr/juno_mwr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <athena/outputs/outputs.hpp>
#include <athena/parameter_input.hpp>
#include <athena/scalars/scalars.hpp>
#include <athena/stride_iterator.hpp>

// application
#include <application/application.hpp>
Expand All @@ -32,6 +31,7 @@
#include <climath/interpolation.h>

// snap
#include <snap/stride_iterator.hpp>
#include <snap/thermodynamics/atm_thermodynamics.hpp>
#include <snap/thermodynamics/vapors/sodium_vapors.hpp>

Expand Down
20 changes: 17 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ add_library(${namel}_${buildl}
${src_files}
)

target_include_directories(${namel}_${buildl}
PRIVATE
${EIGEN3_INCLUDE_DIR}
)

set_target_properties(${namel}_${buildl}
PROPERTIES
COMPILE_FLAGS ${CMAKE_CXX_FLAGS_${buildu}}
Expand All @@ -56,9 +61,17 @@ add_subdirectory(special)
add_subdirectory(single_column)
add_subdirectory(diagnostics)
add_subdirectory(forcing)
add_subdirectory(modules)

if (${Torch_FOUND})
add_subdirectory(torch)
add_subdirectory(modules)
endif()
#add_subdirectory(nbody)

if(UNIX AND NOT APPLE)
set(EXTRA_LIBS dl stdc++fs)
endif()

set(CANOE_LIBRARY_${buildu}
"canoe_${buildl}"
"athenapp_${buildl}"
Expand All @@ -81,8 +94,8 @@ set(CANOE_LIBRARY_${buildu}
"scm_${buildl}"
"diagnostics_${buildl}"
"forcing_${buildl}"
"modules_${buildl}"
#"yaml-cpp"
#"modules_${buildl}"
${YAML_CPP_LIBRARIES}
${CPPDISORT_LIBRARY_${buildu}}
${PYTHON_LIBRARY_RELEASE}
${NETCDF_LIBRARIES}
Expand All @@ -94,6 +107,7 @@ set(CANOE_LIBRARY_${buildu}
${TORCH_LIBRARY}
${TORCH_CPU_LIBRARY}
${C10_LIBRARY}
${EXTRA_LIBS}
CACHE INTERNAL "canoe library")

set(CANOE_INCLUDE_DIR
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics/todo/convective_heat_flx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <athena/athena_arrays.hpp>
#include <athena/coordinates/coordinates.hpp>
#include <athena/reconstruct/interpolation.hpp>
#include <athena/stride_iterator.hpp>

// snap
#include <snap/stride_iterator.hpp>
#include <snap/thermodynamics/thermodynamics.hpp>

// canoe
Expand Down
4 changes: 4 additions & 0 deletions src/exchanger/exchanger.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef SRC_EXCHANGER_EXCHANGER_HPP_
#define SRC_EXCHANGER_EXCHANGER_HPP_

// C/C++
#include <array>
#include <vector>

// Athena++
#include <athena/athena.hpp>
#include <athena/bvals/bvals.hpp>
Expand Down
76 changes: 76 additions & 0 deletions src/modules/eos_equilibrate_tp.cpp_
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// cantera
#include <cantera/kinetics.h>
#include <cantera/kinetics/Condensation.h>
#include <cantera/thermo.h>

// canoe
#include <air_parcel.hpp>

// snap
#include "atm_thermodynamics.hpp"

void Thermodynamics::EquilibrateTP(AirParcel* air) const {
air->ToMassFraction();
Real pres = air->w[IPR];
for (int n = IVX; n < IVX + NCLOUD; ++n) air->w[n] = air->c[n - IVX];
auto& thermo = kinetics_->thermo();
thermo.setMassFractionsPartial(&air->w[1]);
thermo.setDensity(air->w[IDN]);
thermo.setPressure(air->w[IPR]);

EquilibrateTP();

for (int n = 0; n < NCLOUD; ++n) air->c[n] = air->w[IVX + n];
air->w[IPR] = pres;
air->ToMoleFraction();
}

void Thermodynamics::EquilibrateTP() const {
std::static_pointer_cast<Cantera::Condensation>(kinetics_)
->setQuantityMoleFraction();

std::vector<Real> rates(kinetics_->nTotalSpecies());
std::vector<Real> mfrac(kinetics_->nTotalSpecies());

auto& thermo = kinetics_->thermo();
Real temp = thermo.temperature();
Real pres = thermo.pressure();

int iter = 0, max_iter = 3;

while (iter++ < max_iter) {
// std::cout << "Iteration " << iter << std::endl;

// get mole fraction
kinetics_->getActivityConcentrations(mfrac.data());

/* print initial conditions
std::cout << "Mole fractions" << std::endl;
for (size_t i = 0; i < mfrac.size(); ++i) {
std::cout << "Mole fraction " << i << ": " << mfrac[i] << std::endl;
}*/

kinetics_->getNetProductionRates(rates.data());
/*for (size_t i = 0; i < rates.size(); ++i) {
std::cout << "NET Production " << i << ": " << rates[i] << std::endl;
}*/

// update mole fraction
for (size_t i = 1; i < rates.size(); ++i) {
mfrac[i] += rates[i];
}

thermo.setMoleFractions(mfrac.data());
thermo.setTemperature(temp);
thermo.setPressure(pres);

/* print again
std::cout << "After Mole fractions" << std::endl;
for (size_t i = 0; i < mfrac.size(); ++i) {
std::cout << "Mole fraction " << i << ": " << mfrac[i] << std::endl;
}
std::cout << "T = " << thermo.temperature() << std::endl;
std::cout << "P = " << thermo.pressure() << std::endl;
std::cout << "D = " << thermo.density() << std::endl;*/
}
}
Loading
Loading