ORNL-Modelica / TRANSFORM-Library

A Modelica based library for modeling thermal hydraulic energy systems and other multi-physics systems
Apache License 2.0
60 stars 25 forks source link

Install guide for `noname` dependency #89

Closed veeshy closed 3 years ago

veeshy commented 3 years ago

Is your feature request related to a problem? Please describe.

On Windows. I'm trying to run TRANSFORM.Math.Interpolation.Models.Examples.Interpolation_2D_Test which needs noname.lib which I think is supposed to be complied from https://cloud.cees.ornl.gov/gitlab/dalg24/noname It would be nice to have transform tell people these dependencies.

FWIW, the cmake script in noname appears to target linux or perhaps needs some un-doc'd dependencies like patch and autotools. It also applies a patch to gsl then installs gsl, which is odd considering gsl is a separate dependency here. To get around autotools I just passed my complied gsl via cmake in but realized since my version is mismatch (2.7 vs 2.5) and I don't have the patch, something is likely wrong. I didn't appear to get a noname.lib either but I digress as these are probably issues for that repo.

oh one more that is more than just windows woes: noname doesn't have a license attached

Describe the solution you'd like

Some documentation for noname similar to https://github.com/ORNL-Modelica/TRANSFORM-Library/blob/master/TRANSFORM/Math/GNU_ScientificLibrary/UsersGuide/package.mo

Describe alternatives you've considered

No alts considered

Additional context

n/a

greenwoodms06 commented 3 years ago

The Interpolation_2D was an experimental feature with an intent to use on Media properties. It didn't quite pan out but the interpolation itself was working though I don't recall if it was just working on Linux. In any case, if that is a capability you are interested in having, I think the best I can do is put the source code for the poorly named "noname" work on Github so that you can try to get it working for your purposes or improve it. Would that help?

veeshy commented 3 years ago

Yeah that would work, I was gunna take a stab in a fork but happy to do it on a version you put up on GitHub

greenwoodms06 commented 3 years ago

@veeshy give this repo a go.: https://github.com/ORNL-Modelica/MediaLookupTables. It's been long enough that I don't remember much. I had a colleague help with the GSL/c coding. Anyways, hope this helps!

veeshy commented 3 years ago

So noname being on GitHub is nice, but the rest of the lookup tables repo wasn't as useful as it wasn't clear what was copy pasted from transform and what was new so I wasn't sure if making the examples there work would make transform things work.. I ended up using the interpolation test I reported originally here as my test case to see if I got noname working okay.

In terms of the build, I did fine on linux cmake works fine except for the lines https://github.com/ORNL-Modelica/MediaLookupTables/blob/a0c8c71cbd10e9759f03c9487d21dc635aba5260/noname/Spline2D.hpp#L33-L35 which I commented out knowing it might cause a performance penalty. I got compile errors saying the class wasn't fully specified.

For windows, I didn't have access to autotools (for configure, make) so I hacked the build to death (e.g., unacceptable PR) to allow cmake to do it all, which involved pointing to a different gsl distro that someone has that can build with cmake

 ExternalProject_Add(project_gsl
-  URL http://mirror.keystealth.org/gnu/gsl/gsl-2.5.tar.gz
+  URL https://github.com/ampl/gsl/archive/refs/heads/master.zip
   PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gsl
-  PATCH_COMMAND patch -p1 --verbose --directory ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl <  ${CMAKE_SOURCE_DIR}/wrong_return_gsl_interp2d_eval_e.patch
-  CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gsl
-  BUILD_COMMAND make
-  INSTALL_COMMAND make install
+  CONFIGURE_COMMAND cmake ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl/ -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/gsl -DNO_AMPL_BINDINGS=1
+  BUILD_COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl-build/ --config Release
+  INSTALL_COMMAND cmake --install  ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl-build/ --config Release
 )
-set_property(TARGET gsl PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libgsl.a)
+set_property(TARGET gsl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/gsl.lib)
-find_package(GSL 2.5 REQUIRED)
+find_package(GSL 2.7 REQUIRED)

build with

mkdir build
cd build
cmake .. -A x64  -DCMAKE_INSTALL_PREFIX=.\install
cmake --build . --config Release

And finally in the ultimate lazy step, I manually patched the gsl interpolation, removed all build files except the gsl download, then re-ran the build with the following so gsl would not re-download and override my manual patch

 ExternalProject_Add(project_gsl
-  URL http://mirror.keystealth.org/gnu/gsl/gsl-2.5.tar.gz
+  #URL https://github.com/ampl/gsl/archive/refs/heads/master.zip
   PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gsl
-  PATCH_COMMAND patch -p1 --verbose --directory ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl <  ${CMAKE_SOURCE_DIR}/wrong_return_gsl_interp2d_eval_e.patch
-  CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gsl
-  BUILD_COMMAND make
-  INSTALL_COMMAND make install
+  CONFIGURE_COMMAND cmake ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl/ -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/gsl -DNO_AMPL_BINDINGS=1
+  BUILD_COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl-build/ --config Release
+  INSTALL_COMMAND cmake --install  ${CMAKE_CURRENT_BINARY_DIR}/gsl/src/project_gsl-build/ --config Release
 )

it works^{tm}

greenwoodms06 commented 3 years ago

Glad it worked (sort of)! That repo is the original testing bit. The compiled noname object should just be able to be dropped into TRANSFORM (that is what I vaguely remember). Sorry I can't provide more specific assistance. Wish this work could have been more time and consideration to get it to a really good state. Alas it was not to be. Are we good to close this issue or do you want to see if I can wrangle the person who helped me with this work into this discussion?

veeshy commented 3 years ago

I'll leave that up to you, I'm set in terms of building but can't hurt to throw the next person some extra words in the doco for interpolation

slightly more to add on the drop-in of the libs, I had to drop in gsl.lib, gslcblas.lib, noname.lib and tell the interpolation functions to load gslcblas along with the other two to get it working