-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.0, get (JSON string) and save ThermoDataSet to file (#1)
* v0.1.0, get (JSON string) and save ThermoDataSet to file
- Loading branch information
Showing
35 changed files
with
1,335 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,14 @@ | |
*.lib | ||
|
||
# Executables | ||
*.exe | ||
#*.exe | ||
*.out | ||
*.app | ||
|
||
.vscode | ||
|
||
# Build | ||
build/ | ||
|
||
*.ipynb* | ||
environment.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: cpp | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
cache: | ||
directories: | ||
- $HOME/miniconda | ||
|
||
install: | ||
- bash ci/travis/install.sh | ||
|
||
script: | ||
- bash ci/travis/test.sh | ||
|
||
before_cache: | ||
- rm -f $HOME/miniconda/envs/thermofun/conda-meta/history* # Delete these history files to prevent a new cache upload step. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Require a certain version of cmake | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
# Set the name of the project | ||
project(ThermoHubClient VERSION 0.1.0 LANGUAGES CXX) | ||
|
||
# Set the cmake module path of the project | ||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") | ||
|
||
# Use ccache to speed up repeated compilations | ||
include(CCache) | ||
|
||
# Define variables with the GNU standard installation directories | ||
include(GNUInstallDirs) | ||
|
||
# Ensure proper configuration if in a conda environment | ||
include(CondaAware) | ||
|
||
# Define which types of libraries to build | ||
option(THERMOHUBCLIENT_BUILD_SHARED_LIBS "Build shared libraries." ON) | ||
option(THERMOHUBCLIENT_BUILD_SHARED_LIBS "Build static libraries." ON) | ||
option(THERMOHUBCLIENT_BUILD_PYTHON "Build the python wrappers and python package thermohubclient." ON) | ||
#option(REFRESH_THIRDPARTY "Refresh thirdparty libraries." OFF) | ||
|
||
# Modify the HUBCLIENT_BUILD_* variables accordingly to BUILD_ALL | ||
if(THERMOHUBCLIENT_BUILD_ALL MATCHES ON) | ||
set(THERMOHUBCLIENT_BUILD_SHARED_LIBS ON) | ||
set(THERMOHUBCLIENT_BUILD_STATIC_LIBS ON) | ||
set(THERMOHUBCLIENT_BUILD_PYTHON ON) | ||
endif() | ||
|
||
# Set the default build type to Release | ||
if(NOT CMAKE_BUILD_TYPE) | ||
# The build type selection for the project | ||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the build type for ${PROJECT_NAME}." FORCE) | ||
# The build type options for the project | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo) | ||
endif() | ||
|
||
# Define if shared library should be build instead of static. | ||
option(BUILD_SHARED_LIBS "Build shared libraries." ON) | ||
|
||
# Set libraries to be compiled with position independent code mode (i.e., fPIC option in GNU compilers) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Set the C++ standard | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Set the list of compiler flags for MSVC compiler | ||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) | ||
add_compile_options( | ||
/D_SCL_SECURE_NO_WARNINGS | ||
/D_CRT_SECURE_NO_WARNINGS=1 | ||
/MP4 | ||
/EHsc | ||
/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING | ||
/DNOMINMAX | ||
) | ||
endif() | ||
|
||
# Set the ThermoHubClient source directory path | ||
set(THERMOHUBCLIENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/ThermoHubClient) | ||
|
||
# Set the include directories | ||
include_directories(${THERMOHUBCLIENT_SOURCE_DIR}) | ||
|
||
# Find all ThermoHubClient dependencies | ||
include(ThermoHubClientFindDeps) | ||
|
||
# Build ThermoHubClient library | ||
add_subdirectory(ThermoHubClient) | ||
|
||
# Build python wraper | ||
if(THERMOHUBCLIENT_BUILD_PYTHON) | ||
add_subdirectory(python) | ||
else() | ||
# add_subdirectory(python EXCLUDE_FROM_ALL) | ||
endif() | ||
|
||
# Install the cmake config files that permit users to use find_package(ThermoHubClient) | ||
include(ThermoHubClientInstallCMakeConfigFiles) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// Copyright (C) 2019 G. Dan Miron | ||
// | ||
// thermohubclient is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// thermohubclient is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with thermohubclient. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#include <string> | ||
|
||
namespace ThermoHubClient | ||
{ | ||
const std::string aql_thermofun_database_from_thermodataset = | ||
"/* clean the result with vs code \n " | ||
"replace ^.*null.*,$\n with empty \n " | ||
" \n " | ||
"replace ,\n^.*null.*$\n with \n \n " | ||
" \n " | ||
"*/ \n " | ||
" \n " | ||
"// Query works only for GEM and GEM-LMA ThermoDataSet traversing on edge pulls \n " | ||
" \n " | ||
"/* Get Elements */ \n " | ||
"LET elements_ = ( \n " | ||
" FOR v,e IN 1..1 INBOUND @idThermoDataSet basis \n " | ||
" FILTER v._label == 'element' \n " | ||
" LET references_ = ( \n " | ||
" FOR rf IN 1..1 OUTBOUND v citing \n " | ||
" RETURN rf.properties.shortname // substances_[*][*].id \n " | ||
" ) \n " | ||
" RETURN { \n " | ||
" symbol: v.properties.symbol, \n " | ||
" class_: v.properties.class_, \n " | ||
" entropy : v.properties.entropy, \n " | ||
" atomic_mass : v.properties.atomic_mass, \n " | ||
" datasources : v.properties.datasources \n " | ||
"// _label : 'element' \n " | ||
" } \n " | ||
") \n " | ||
"/* Get Substances */ \n " | ||
"LET substances_ = ( \n " | ||
" FOR s,e IN 1..1 INBOUND @idThermoDataSet pulls \n " | ||
" FILTER s._label == 'substance' \n " | ||
" LET reaction_symbol = ( \n " | ||
" FOR r IN 1..1 INBOUND s defines \n " | ||
" RETURN r.properties.symbol \n " | ||
" ) \n " | ||
" LET references_ = ( \n " | ||
" FOR rf IN 1..1 OUTBOUND s citing \n " | ||
" RETURN rf.properties.shortname // substances_[*][*].id \n " | ||
" ) \n " | ||
" RETURN { \n " | ||
" name: s.properties.name, \n " | ||
" symbol: s.properties.symbol, \n " | ||
" formula: s.properties.formula, \n " | ||
" formula_charge: s.properties.formula_charge, \n " | ||
" reaction : reaction_symbol[0], \n " | ||
"// mass_per_mole: s.properties.mass_per_mole, \n " | ||
" aggregate_state: s.properties.aggregate_state, \n " | ||
" class_: s.properties.class_, \n " | ||
" limitsTP: s.properties.limitsTP, \n " | ||
" Tst: s.properties.Tst, \n " | ||
" Pst: s.properties.Pst, \n " | ||
" TPMethods: s.properties.TPMethods, \n " | ||
" sm_heat_capacity_p: s.properties.sm_heat_capacity_p, \n " | ||
" sm_gibbs_energy: s.properties.sm_gibbs_energy, \n " | ||
" sm_enthalpy: s.properties.sm_enthalpy, \n " | ||
" sm_entropy_abs: s.properties.sm_entropy_abs, \n " | ||
" sm_volume: s.properties.sm_volume, \n " | ||
" m_compressibility: s.properties.m_compressibility, \n " | ||
" m_expansivity: s.properties.m_expansivity, \n " | ||
" datasources : s.properties.datasources \n " | ||
"// _label : 'substance' \n " | ||
"// id: s._id \n " | ||
" } \n " | ||
") \n " | ||
"/* Get Reactions */ \n " | ||
"LET reactions_ = ( \n " | ||
" FOR s,e IN 1..1 INBOUND @idThermoDataSet pulls \n " | ||
" FILTER s._label == 'substance' \n " | ||
" FOR r IN 1..1 INBOUND s defines \n " | ||
" LET reactants_ = ( \n " | ||
" FOR ss, t IN 1..1 INBOUND r takes \n " | ||
"/* LET ids_2 = PUSH(ids_, ss._id, true) /* add substance id to idlist */ \n " | ||
" RETURN { \n " | ||
" symbol: ss.properties.symbol, \n " | ||
" coefficient: t.properties.stoi_coeff \n " | ||
"// id: ss._id \n " | ||
" } \n " | ||
" ) \n " | ||
" LET references_ = ( \n " | ||
" FOR rf IN 1..1 OUTBOUND r citing \n " | ||
" RETURN rf.properties.shortname // substances_[*][*].id \n " | ||
" ) \n " | ||
" RETURN { \n " | ||
"// name: r.properties.name, \n " | ||
" symbol: r.properties.symbol, \n " | ||
"// substance : s.properties.symbol, \n " | ||
" equation: r.properties.equation, \n " | ||
" reactants: reactants_, \n " | ||
" limitsTP: r.properties.limitsTP, \n " | ||
" Tst: r.properties.Tst, \n " | ||
" Pst: r.properties.Pst, \n " | ||
" TPMethods: r.properties.TPMethods, \n " | ||
" logKr : r.properties.logKr, \n " | ||
" drsm_heat_capacity_p : r.properties.drsm_heat_capacity_p, \n " | ||
" drsm_gibbs_energy : r.properties.drsm_gibbs_energy, \n " | ||
" drsm_enthalpy : r.properties.drsm_enthalpy, \n " | ||
" drsm_entropy : r.properties.drsm_entropy, \n " | ||
" drsm_volume : r.properties.drsm_volume, \n " | ||
" datasources : r.properties.datasources \n " | ||
"// _label : 'reaction' \n " | ||
"// id: r._id \n " | ||
" } \n " | ||
") \n " | ||
"//LET data_ = (APPEND(SORTED_UNIQUE(FLATTEN(substances_,1)), SORTED_UNIQUE(FLATTEN(reactions_,1)), true) ) \n " | ||
"//RETURN {result : APPEND(data_, SORTED_UNIQUE(FLATTEN(elements_,1)), true) } \n " | ||
"RETURN { thermodataset : 'cemdata18', datasources : ['db.thermohub.org','[2014THO/HUM]', '[2019LOT/KUL]', 'https://www.empa.ch/web/s308/thermodynamic-data'], date : DATE_FORMAT(DATE_NOW(), '%dd.%mm.%yyyy %hh:%ii:%ss'), \n " | ||
" substances : SORTED_UNIQUE(FLATTEN(substances_,1)), reactions : SORTED_UNIQUE(FLATTEN(reactions_,1)), elements : SORTED_UNIQUE(FLATTEN(elements_,1))} \n "; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Recursively collect all header files from the current directory | ||
file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.hpp *.h) | ||
|
||
# Recursively collect all source files from the current directory | ||
file(GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) | ||
|
||
# The name of the shared and static libraries | ||
set(THERMOHUBCLIENT_SHARED_LIB ${PROJECT_NAME}${SUFFIX_SHARED_LIBS}) | ||
set(THERMOHUBCLIENT_STATIC_LIB ${PROJECT_NAME}${SUFFIX_STATIC_LIBS}) | ||
|
||
# Set the list of names of the third-party targets and libraries | ||
# set(THIRDPARTY_LIBS jsonio boost_regex boost_filesystem curl velocypack) | ||
|
||
# Enable automatic creation of a module definition (.def) file for a SHARED library on Windows. | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
|
||
# Build a ThermoHubClient C++ library | ||
add_library(ThermoHubClient ${HEADER_FILES} ${SOURCE_FILES}) | ||
|
||
# Add an alias ThermoHubClient::ThermoHubClient to the target library ThermoHubClient | ||
add_library(ThermoHubClient::ThermoHubClient ALIAS ThermoHubClient) | ||
|
||
# Add the include paths to the ThermoHubClient target | ||
target_include_directories(ThermoHubClient | ||
PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
# Link ThermoHubClient library against external dependencies | ||
target_link_libraries(ThermoHubClient | ||
PRIVATE ${THIRDPARTY_LIBS} | ||
# PUBLIC ThermoFun::ThermoFun | ||
PUBLIC jsonarango | ||
PUBLIC velocypack | ||
PUBLIC Boost::regex | ||
) | ||
|
||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) | ||
# Link ThermoHubClient library against external (linked in static jsonarango) dependencies | ||
target_link_libraries(ThermoHubClient | ||
PUBLIC libcurl | ||
) | ||
else() | ||
target_link_libraries(ThermoHubClient | ||
PUBLIC curl | ||
) | ||
endif() | ||
|
||
# Set compilation features to be propagated to dependent codes. | ||
# target_compile_features(ThermoHubClient PUBLIC cxx_std_17) | ||
|
||
# Set some target properties | ||
set_target_properties(ThermoHubClient PROPERTIES | ||
POSITION_INDEPENDENT_CODE ON | ||
CXX_EXTENSIONS OFF) | ||
|
||
# Install ThermoHubClient C++ library | ||
install(TARGETS ThermoHubClient | ||
EXPORT ThermoHubClientTargets | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries) | ||
|
||
# Install debug symbols | ||
if(MSVC) | ||
install( | ||
FILES $<TARGET_PDB_FILE:ThermoHubClient> | ||
DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
COMPONENT libraries | ||
OPTIONAL | ||
) | ||
endif() | ||
|
||
# Install ThermoHubClient header files | ||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ThermoHubClient | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers | ||
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") | ||
|
||
# Install deps header files | ||
#install(DIRECTORY ${PROJECT_SOURCE_DIR}/ThermoHubClient/deps | ||
# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ThermoHubClient COMPONENT headers) |
Oops, something went wrong.