Skip to content

Commit

Permalink
Merge pull request #5 from gdmiron/origin-bucket
Browse files Browse the repository at this point in the history
Origin bucket
  • Loading branch information
gdmiron authored Aug 10, 2019
2 parents 1395c7e + f9cade5 commit bf68c5e
Show file tree
Hide file tree
Showing 103 changed files with 3,160 additions and 515 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ tests/unit06/H2OZD2005-test.pro.user*
tests/gUnitTest/gUnitTest.pro.user*
tests/interfaceTest/interfaceTest.pro.user*
tests/dbclientTest/dbclientTest.pro.user*
examples/build/
src/*.autosave
tests/unit01/src/*.autosave
.directory
Expand Down Expand Up @@ -44,9 +45,12 @@ tests/interfaceTest/include/
tests/interfaceTest/install_manifest.txt
tests/interfaceTest/lib/
tests/interfaceTest/thirdparty/
temp*

.vscode/
tests/PyThermoFun.so
d-*
e-*

python/tests/H2OWP95reaktoro.csv
python/tests/PyThermoFun.cpython-36m-x86_64-linux-gnu.so
Expand All @@ -57,3 +61,4 @@ python/pyThermoFun/CMakeLists_old.txt




26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,31 @@ project(ThermoFun VERSION 0.1.10 LANGUAGES CXX)
# Set the cmake module path of the project
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

set(CMAKE_MACOSX_RPATH ON)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")

include_directories("${CMAKE_SOURCE_DIR}/../dependencies/include")

else() # build for linux

endif()

if (BUILD_WINDOWS)
set(CMAKE_CXX_STANDARD 11)
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)

# which compilers to use for C and C++
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)

# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)

include_directories("/usr/local/include")
link_directories("/usr/local/lib")

else() # build for linux
endif()

# Use ccache to speed up repeated compilations
include(CCache)
Expand Down
59 changes: 53 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ make

-DTFUN_BUILD_GUI=ON -DTFUN_BUILD_GUIDEMO=ON options trigger the compilation of ThermoFunGui library and the gui demo widget.

The build script will also copy into the build folder the necessary /Resources folder. In the Resources folder a file named "fun-dbclient-config.json" is present and contains the arangodb database connection preferences.
The build script will also copy into the build folder the necessary /Resources folder. In the Resources folder a file named "fun-hubclient-config.json" is present and contains the arangodb database connection preferences.

To run the ThermoFun GUI demo in the terminal at ```~/build$``` execute:

```
./guidemo.sh
```

You can change the arango database connection setup using the preferences icon on the start widget, or by making changes in ```Resources/fun-dbclient-config.json``` file.
You can change the arango database connection setup using the preferences icon on the start widget, or by making changes in ```Resources/fun-hubclient-config.json``` file.

* For building using Qt Creator, use the ThermoFunDemoGUI.pro project file found in ```~/thermofun/fungui```.

Expand Down Expand Up @@ -217,10 +217,57 @@ from thermofun import *

In the build folder a test file text.py can be found, this can be run by executing ```python test.py``` and ```python test-dbc.py``` . If successful in addition to on screen output, two files, results.csv and results_dbc.csv files containing calculation results will be created.

If compilation was successful the /Resources folder will be copied to the build folder. In this folder the necessary test files, connection to the arangodb database preferences, and data schemas are present. To change database connection without using the GUI, make changes in the ```Resources/fun-dbclient-config.json``` file.
If compilation was successful the /Resources folder will be copied to the build folder. In this folder the necessary test files, connection to the arangodb database preferences, and data schemas are present. To change database connection without using the GUI, make changes in the ```Resources/fun-hubclient-config.json``` file.


### Simple C++ API example
## Build and Run ThermoFun GUI on Windows 10

* Make sure you have git installed. If not, install it on Windows: https://git-scm.com/download/win.
* To download ThermoFun source code, using Windows Command Prompt go to C:/git/THERMOFUN and execute

```
git clone https://bitbucket.org/gems4/thermofun.git
```

## Prepare building tools

* ThermoFun GUI dependencies will be compiled using MSVC 2017 64 bit compiler. For this Visual Studio Community (2017) needs to be installed:
https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio?view=vs-2017
At Step 4 - Select workloads, select Desktop development with C++ to be installed. On the individual components page check that also Windows 10 SDK is selected to be installed.
* In addition to MSVC 2017, Qt needs to be installed: https://www.qt.io/download in C:/Qt folder (Qt installation folder is used in further scripts, please use C:/Qt)!
Select with Qt 5.12.0 MSVC 2017 64-bit with Qt Charts, and Qt WebEngine.

### Install Dependencies

* For compiling the libraries that ThermoFun GUI is dependent on, three .bat scripts can be found in /thermofun. The process will several minutes. In a windows Command Prompt terminal go to C:/git/THERMOFUN/thermofun and run:

```
C:\git\THERMOFUN\thermofun>a-build-win-dependencies.bat
```

* This script builds curl and velocypack libraries, copies then in the C:\git\THERMOFUN\dependencies folder, creates buil-fun-gui folder and copies there the necessary resources files

```
C:\git\THERMOFUN\thermofun>b-build-win-boost.bat
```

* This script builds the necessary boost libraries and copies then in the C:\git\THERMOFUN\dependencies folder

```
C:\git\THERMOFUN\thermofun>c-build-win-jsonio-jsonui.bat C:\Qt\5.12.3\msvc2017_64\bin
```

* This script builds jsonio and jsonui libraries, copies then in the C:\git\THERMOFUN\dependencies folder. Don't forget to use the corect Qt installation path.

### Compiling and the ThermoFun GUI demo in Qt Creator

* In Qt Creator open C:\git\THERMOFUN\thermofun\fungui\ThermoFunDemoGUI.pro
* Set the build folder to C:\git\THERMOFUN\build-fun-gui (release mode). NOT! C:\git\THERMOFUN\build-fun-gui\release
* After the successful compilation try to run ThermoFun GUI from Qt Creator. All necessary dependencies and Resources should be already set in the right place.

* Unsuccessful attempts could be due to unsuccesful compilation of dependences, missing or not correctly copied lib or Resources files, etc.

## Simple C++ API example

* Using a json database file

Expand Down Expand Up @@ -262,7 +309,7 @@ int main()
int main()
{
// Set the file path to the database connection and preferences file (provided in the Resources/ folder)
setDatabaseConnectionFilePath("fun-dbclient-config.json");
setDatabaseConnectionFilePath("fun-hubclient-config.json");
// Initialize a database client object
ThermoFun::DatabaseClient dbc;
Expand Down Expand Up @@ -351,7 +398,7 @@ batch.thermoPropertiesSubstance( [[25, 1],[40, 1],[70, 100],[90, 100],[100, 100]

```
#!Python
PyThermoDBClient.setDatabaseConnectionFilePath("Resources/fun-dbclient-config.json")
PyThermoDBClient.setDatabaseConnectionFilePath("Resources/fun-hubclient-config.json")
print("\n# Initialize a database client object\n")
dbc = PyThermoDBClient.DatabaseClient()
Expand Down
48 changes: 48 additions & 0 deletions Resources/fun-hubclient-config-win.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"jsonio" : {
"UseArangoDBInstance" : "ArangoDBRemote",
"UseVelocypackPut" : true,
"UseVelocypackGet" : true,
"ArangoDBLocal" : {
"DBName" : "userdatabase",
"DBCreate" : true,
"DB_URL" : "http://localhost:8529",
"DBUser" : "root",
"DBUserPassword" : "",
"DBAccess" : "rw",
"DBRootName" : "_system",
"DBRootUser" : "root",
"DBRootPassword" : ""
},
"ArangoDBRemote" : {
"DBName" : "hub_main",
"DBCreate" : false,
"DB_URL" : "https://db.thermohub.net",
"DBUser" : "matchrem",
"DBUserPassword" : "ThermoMatch@Remote-ThermoHub-Server",
"DBAccess" : "rw",
"DBRootName" : "_system",
"DBRootUser" : "",
"DBRootPassword" : ""
}
},
"jsonui" : {
"CurrentDBConnection" : "ArangoDBRemote",
"ViewOnlyMode" : true,
"CanEdit_id" : false,
"KeepExpanded" : true,
"ShowComments" : true,
"ShowEnumNames" : true
},
"common" : {
"UserHomeDirectoryPath" : "C:/",
"WorkDirectoryPath" : "",
"ResourcesDirectory" : "Resources",
"SchemasDirectory" : "Resources/data/schemas",
"LuaScriptsDirectory" : "Resources/lua"
},
"jsonimpex" : {
"ThriftDBSocketHost" : "",
"ThriftDBSocketPort" : 0
}
}
File renamed without changes.
12 changes: 8 additions & 4 deletions ThermoFun/Batch/OutputBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ struct Output::Impl
std::string header = "";
std::ofstream fProperties;

Impl(const ThermoBatch& interface)
: api(ThermoBatch(interface))
Impl(const ThermoBatch& batch_)
: api(ThermoBatch(batch_))
{}

};

Output::Output(const ThermoBatch& interface)
: pimpl(new Impl(interface))
Output::Output(const ThermoBatch& batch)
: pimpl(new Impl(batch))
{}

//Output::Output(const void *a)
//: pimpl(new Impl(*(ThermoBatch*)a))
//{}

auto find_and_replace(std::string source, std::string const& find, std::string const& replace) -> std::string
{
for(std::string::size_type i = 0; (i = source.find(find, i)) != std::string::npos;)
Expand Down
2 changes: 1 addition & 1 deletion ThermoFun/Batch/OutputBatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Output
/// \brief Output constructor
/// \param interface
///
Output(const ThermoBatch & interface);
Output(const ThermoBatch& batch);

auto toCSV (std::string filename) -> void;
auto toCSVTransposed (std::string filename) -> void;
Expand Down
9 changes: 7 additions & 2 deletions ThermoFun/Batch/ThermoBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#include "ThermoEngine.h"
#include "Common/Units.hpp"

#ifdef _WIN32
#include <array>
#else
#endif

namespace ThermoFun {

enum Calculation {forSUBSTANCE, forREACTION, forSOLVENT};
Expand Down Expand Up @@ -186,7 +191,7 @@ struct ThermoBatch::Impl

auto calculate(Calculation calculation) -> void
{
double T, P; string symbol; unsigned j_size, i_size;
double T, P; string symbol; size_t j_size, i_size;
auto defUnitT = defaultPropertyUnits.at("temperature");
auto unitT = givenPropertyUnits.at("temperature");
auto defUnitP = defaultPropertyUnits.at("pressure");
Expand Down Expand Up @@ -280,7 +285,7 @@ auto ThermoBatch::thermoPropertiesSubstance(double T, double P, std::string symb

pimpl->calculate(forSUBSTANCE);

return Output (*this);
return Output(*this);
}

auto ThermoBatch::thermoPropertiesSubstance(double T, double P, vstr symbols, vstr properties) -> Output
Expand Down
2 changes: 1 addition & 1 deletion ThermoFun/Batch/ThermoBatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ThermoFun {

struct Database;
class Database;
struct ThermoPropertiesSubstance;
struct ThermoPropertiesReaction;
struct PropertiesSolvent;
Expand Down
7 changes: 5 additions & 2 deletions ThermoFun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ add_library(ThermoFun ${HEADER_FILES} ${SOURCE_FILES})
# Add aliases for ThermoFun shared and static libraries
add_library(ThermoFun::ThermoFun ALIAS ThermoFun)

if( NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
#link_directories("/usr/local/lib")

else() # build for linux
# Find library and software dependencies
find_package(Boost 1.65.1 REQUIRED)
find_package(Boost 1.58.0 REQUIRED)
find_package(nlohmann_json 3.6.1 REQUIRED)


Expand Down
2 changes: 1 addition & 1 deletion ThermoFun/Common/OutputWaterSteamConventionProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ThermoFun {
auto OutputSteamConventionH2OProp (std::string filename, const WaterThermoState wt) -> void
{
std::ofstream myfile;
// filename = output_path + filename;
// filename = Outputpath + filename;
myfile.open (filename, std::ios::app);
string c=",";

Expand Down
3 changes: 3 additions & 0 deletions ThermoFun/Common/ParseJsonToData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ auto setTPMethods_old(const ReactionTPMethodType &type, Reaction &r) -> void
case ReactionTPMethodType::logk_lagrange_interp:
case ReactionTPMethodType::logk_marshall_frank78:
case ReactionTPMethodType::solute_eos_ryzhenko_gems:
case ReactionTPMethodType::logk_dolejs_manning10:
r.setMethod_T(MethodCorrT_Thrift::type(new_old_r_methodtype.at(type)));
break;
case ReactionTPMethodType::dr_volume_fpt:
Expand Down Expand Up @@ -291,6 +292,8 @@ auto thermoParamReac (const json &j, ThermoParametersReaction& pr) -> void
pr.reaction_RB_coeff = j["dr_ryzhenko_coeffs"]["values"].get<vector<double>>();
if (j.contains("dr_marshall_franck_coeffs"))
pr.reaction_FM_coeff = j["dr_marshall_franck_coeffs"]["values"].get<vector<double>>();
if (j.contains("dr_dolejs_manning10_coeffs"))
pr.reaction_DM10_coeff = j["dr_dolejs_manning10_coeffs"]["values"].get<vector<double>>();


// double lT = 0.0; double uT = 0.0;
Expand Down
6 changes: 3 additions & 3 deletions ThermoFun/Common/ParseJsonToData.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace ThermoFun {

struct Substance;
struct Reaction;
struct Element;
class Substance;
class Reaction;
class Element;

//DefinesSubstLevelOptions levelOptionsDefault;
/// Parses an element bson object and loads its data into the element structure
Expand Down
Loading

0 comments on commit bf68c5e

Please sign in to comment.