diff --git a/cmake/poetry-install.cmake b/cmake/poetry-install.cmake index 5637462f..4120b831 100644 --- a/cmake/poetry-install.cmake +++ b/cmake/poetry-install.cmake @@ -1,9 +1,9 @@ # run 'poetry install' in python folder -macro(install_poetry) +macro(poetry_install pythonScriptDir) # execute 'poetry install' - set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python") + #set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python") if (NOT ${PROJECT_NAME}_PYTHON_SETUP) execute_process( COMMAND poetry install diff --git a/scripts/python/data_model/build_data_model.py b/scripts/python/data_model/build_data_model.py index 6a22b981..f9082596 100644 --- a/scripts/python/data_model/build_data_model.py +++ b/scripts/python/data_model/build_data_model.py @@ -24,7 +24,7 @@ def generate(repo_dir, data_model_dir, gen_out_dir): # main if __name__ == "__main__": - repo_dir = "../../" + repo_dir = "../../../" data_model_dir = "" gen_out_dir = "" n_args = len(sys.argv) - 1 diff --git a/scripts/python/poetry.lock b/scripts/python/data_model/poetry.lock similarity index 100% rename from scripts/python/poetry.lock rename to scripts/python/data_model/poetry.lock diff --git a/scripts/python/pyproject.toml b/scripts/python/data_model/pyproject.toml similarity index 100% rename from scripts/python/pyproject.toml rename to scripts/python/data_model/pyproject.toml diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4547f43e..23721551 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,12 +12,12 @@ add_custom_target(${PROJECT_NAME}_version_header set_target_properties(${PROJECT_NAME}_version_header PROPERTIES FOLDER Dependencies/HPWHsim) #generate hpwh-data-model source -set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python") +set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python/data_model") set(dataModelDir "${PROJECT_SOURCE_DIR}/vendor/hpwh_data_model") set(genCodeDir "${PROJECT_SOURCE_DIR}/src/hpwh_data_model") include(poetry-install) -install_poetry() +poetry_install(${pythonScriptDir}) execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory "${dataModelDir}" @@ -25,7 +25,7 @@ execute_process( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE GIT_SUBMOD_RESULT - COMMAND poetry run python "data_model/build_data_model.py" "${PROJECT_SOURCE_DIR}" "${dataModelDir}" "${genCodeDir}" + COMMAND poetry run python "build_data_model.py" "${PROJECT_SOURCE_DIR}" "${dataModelDir}" "${genCodeDir}" WORKING_DIRECTORY "${pythonScriptDir}" RESULT_VARIABLE result1 ERROR_VARIABLE errors1 diff --git a/src/HPWH.cc b/src/HPWH.cc index 45270720..691ccefa 100644 --- a/src/HPWH.cc +++ b/src/HPWH.cc @@ -3326,7 +3326,6 @@ void HPWH::initPreset(const std::string& modelName) #ifndef HPWH_ABRIDGED void HPWH::readFileAsJSON(string modelName, nlohmann::json& j) { - std::string configFile = modelName + ".txt"; setAllDefaults(); // reset all defaults if you're re-initializing @@ -3341,10 +3340,12 @@ void HPWH::readFileAsJSON(string modelName, nlohmann::json& j) name = modelName; nlohmann::json j_tank({}); - nlohmann::json j_heatsourceconfigs = nlohmann::json::array({}); - // some variables that will be handy - std::size_t heatsource, sourceNum, nTemps, tempInt; - std::size_t num_nodes = 0, numHeatSources = 0; + nlohmann::json j_heatsourceconfigs; + + std::size_t heatsource, sourceNum, tempInt; + std::size_t num_nodes = 0; + std::size_t numHeatSources = 0; + std::size_t nTemps = 0; string tempString, units; double tempDouble; @@ -4084,8 +4085,6 @@ void HPWH::readFileAsJSON(string modelName, nlohmann::json& j) void HPWH::initFromFileJSON(nlohmann::json& j) { - - // std::cout << j.dump(2) << "\n"; auto& j_tank = j["tank"]; auto& j_heatsourceconfigs = j["heat_source_configurations"]; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index df844d31..d4664290 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -198,8 +198,9 @@ list(REMOVE_DUPLICATES extendedModelNames) cmake_dependent_option(${PROJECT_NAME}_PYTHON_PLOTS "Generate plots using python comparing measured and simulated data" ON "${PROJECT_NAME}_IS_TOP_LEVEL" OFF) if (${PROJECT_NAME}_PYTHON_PLOTS) + set(pythonScriptDir "${PROJECT_SOURCE_DIR}/scripts/python/plotting") include(poetry-install) - install_poetry() + poetry_install(${pythonScriptDir}) endif () #Tests for successful runs