mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Merge branch 'master' of https://github.com/CoolProp/CoolProp
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import json as pyjson
|
||||
from datetime import datetime
|
||||
import struct
|
||||
import os
|
||||
import argparse, textwrap
|
||||
import sys
|
||||
import generate_headers
|
||||
|
||||
# 0: Input file path relative to dev folder
|
||||
# 1: Output file path relative to include folder
|
||||
# 2: Name of variable
|
||||
values = [
|
||||
('all_fluids.json','all_fluids_JSON.h','all_fluids_JSON'),
|
||||
('all_incompressibles.json','all_incompressibles_JSON.h','all_incompressibles_JSON'),
|
||||
('mixtures/mixture_excess_term.json', 'mixture_excess_term_JSON.h', 'mixture_excess_term_JSON'),
|
||||
('mixtures/mixture_reducing_parameters.json', 'mixture_reducing_parameters_JSON.h', 'mixture_reducing_parameters_JSON')
|
||||
]
|
||||
|
||||
def TO_CPP(root_dir, hashes):
|
||||
def to_chunks(l, n):
|
||||
if n<1:
|
||||
n=1
|
||||
return [l[i:i+n] for i in range(0, len(l), n)]
|
||||
|
||||
# Normalise path name
|
||||
root_dir = os.path.normpath(root_dir)
|
||||
|
||||
# First we package up the JSON files
|
||||
import package_json
|
||||
package_json.combine_json(root_dir)
|
||||
|
||||
for infile,outfile,variable in values:
|
||||
|
||||
json = open(os.path.join(root_dir,'dev',infile),'r').read()
|
||||
|
||||
# convert each character to hex and add a terminating NULL character to end the
|
||||
# string, join into a comma separated string
|
||||
if sys.version_info[0] == 2:
|
||||
h = [hex(struct.unpack("b",b)[0]) for b in json] + ['0x00']
|
||||
else:
|
||||
# Encode as ASCII characters
|
||||
json = json.encode('ascii')
|
||||
h = [str(hex(b)) for b in json] + [str('0x00')]
|
||||
|
||||
# Break up the file into lines of 16 hex characters
|
||||
chunks = to_chunks(h, 16)
|
||||
|
||||
# Put the lines back together again
|
||||
# The chunks are joined together with commas, and then EOL are used to join the rest
|
||||
hex_string = ',\n'.join([', '.join(chunk) for chunk in chunks])
|
||||
|
||||
# Check if hash is up to date based on using variable as key
|
||||
if variable not in hashes or (variable in hashes and hashes[variable] != generate_headers.get_hash(hex_string)):
|
||||
|
||||
# Generate the output string
|
||||
output = '// File generated by the script dev/JSON_to_CPP.py on '+ str(datetime.now()) + '\n\n'
|
||||
output += '// JSON file encoded in binary form\n'
|
||||
output += 'const unsigned char '+variable+'_binary[] = {\n' + hex_string + '\n};'+'\n\n'
|
||||
output += '// Combined into a single std::string \n'
|
||||
output += 'std::string {v:s}({v:s}_binary, {v:s}_binary + sizeof({v:s}_binary)/sizeof({v:s}_binary[0]));'.format(v = variable)
|
||||
|
||||
# Write it to file
|
||||
f = open(os.path.join(root_dir,'include',outfile), 'w')
|
||||
f.write(output)
|
||||
f.close()
|
||||
|
||||
# Store the hash of the data that was written to file (not including the header)
|
||||
hashes[variable] = generate_headers.get_hash(hex_string)
|
||||
else:
|
||||
print(outfile + ' is up to date')
|
||||
|
||||
if __name__=='__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
description=textwrap.dedent("""CoolProp
|
||||
This program converts the JSON files from dev/fluid etc
|
||||
to header files. It is necessary to give this program the
|
||||
value for --path, this is the root directory where
|
||||
dev/ can be found.""")
|
||||
)
|
||||
|
||||
parser.add_argument('--path', required=False,
|
||||
help='Location of the root folder',
|
||||
default=None)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
TO_CPP(args.path)
|
||||
@@ -266,25 +266,103 @@ def cmake_slave(mod_name, platform, git_mode = 'incremental', install = True, cm
|
||||
factory.addStep(DirectoryUpload(slavesrc="install_root",masterdest="public_html/binaries",url="binaries",compress="bz2"))
|
||||
return factory
|
||||
|
||||
def swig_matlab_pre(git_mode = 'incremental'):
|
||||
"""
|
||||
Download SWIG+MATLAB version, use it to build _wrap file for MATLAB builder, upload back to master
|
||||
|
||||
The generated _wrap file is not platform dependent
|
||||
"""
|
||||
factory = BuildFactory()
|
||||
working_folder = "build/build"
|
||||
|
||||
factory.addStep(ShellCommand(command=cleanCommand, description='fullclean?', workdir=""))
|
||||
# Download files from nightly build for swig
|
||||
factory.addStep(FileDownload(mastersrc = 'public_html/nightly/swig/swig_MATLAB.tar.gz', slavedest = 'swig_MATLAB.tar.gz', haltOnFailure = True))
|
||||
# Directory for incompressible files
|
||||
factory.addStep(MakeDirectory(dir='build/Web/_static/fluid_properties/incompressible', haltOnFailure = True))
|
||||
# Untar
|
||||
factory.addStep(ShellCommand(command = 'tar -C Web/_static/fluid_properties/incompressible -xzvf swig_MATLAB.tar.gz', workdir = 'build', haltOnFailure = True))
|
||||
|
||||
|
||||
# check out the source
|
||||
factory.addStep(Git(repourl='git://github.com/CoolProp/CoolProp', mode=git_mode, submodules = True, progress=True, haltOnFailure = True))
|
||||
factory.addStep(MakeDirectory(dir=working_folder+'/32bitDLL', haltOnFailure = True))
|
||||
factory.addStep(MakeDirectory(dir=working_folder+'/64bitDLL', haltOnFailure = True))
|
||||
factory.addStep(RemoveDirectory(dir="build/install_root", haltOnFailure = True))
|
||||
# Make 32-bit __stdcall DLL
|
||||
factory.addStep(ShellCommand(command=["cmake", "../..", "-DCOOLPROP_32BIT_STDCALL_SHARED_LIBRARY=ON","-G", "Visual Studio 10"],
|
||||
workdir= working_folder+'/32bitDLL',
|
||||
haltOnFailure = True))
|
||||
factory.addStep(ShellCommand(command=["cmake", "--build", ".", "--target", "install"], workdir = working_folder+'/32bitDLL', haltOnFailure = True))
|
||||
# Make 64-bit DLL
|
||||
factory.addStep(ShellCommand(command=["cmake", "../..", "-DCOOLPROP_64BIT_SHARED_LIBRARY=ON","-G", "Visual Studio 10 Win64"],
|
||||
workdir= working_folder+'/64bitDLL',
|
||||
haltOnFailure = True))
|
||||
factory.addStep(ShellCommand(command=["cmake", "--build", ".", "--target", "install"], workdir = working_folder+'/64bitDLL', haltOnFailure = True))
|
||||
|
||||
factory.addStep(MakeDirectory(dir='build\\bin\\MicrosoftExcel', haltOnFailure = True))
|
||||
# Copy the created DLL
|
||||
factory.addStep(ShellCommand(command=' '.join(["copy", "/Y", "install_root\\shared_library\\Windows\\32bit__stdcall_calling_convention\\*.dll", "bin\\MicrosoftExcel"]), workdir = 'build', haltOnFailure = True))
|
||||
factory.addStep(ShellCommand(command=' '.join(["move", "CoolProp.dll", "CoolProp_x64.dll"]), workdir = 'build/install_root/shared_library/Windows/64bit', haltOnFailure = True))
|
||||
factory.addStep(ShellCommand(command=' '.join(["copy", "/Y", "install_root\\shared_library\\Windows\\64bit\\*.dll", "bin\\MicrosoftExcel"]), workdir = 'build', haltOnFailure = True))
|
||||
# Copy other files
|
||||
factory.addStep(ShellCommand(command=["copy", "wrappers\Excel\CoolProp.xlam", "bin\MicrosoftExcel"], workdir = 'build', haltOnFailure = True))
|
||||
factory.addStep(ShellCommand(command=["copy", "wrappers\Excel\CoolProp.xla", "bin\MicrosoftExcel"], workdir = 'build', haltOnFailure = True))
|
||||
factory.addStep(ShellCommand(command=["copy", "wrappers\Excel\TestExcel.xlsx", "bin\MicrosoftExcel"], workdir = 'build', haltOnFailure = True))
|
||||
# Upload the files
|
||||
factory.addStep(DirectoryUpload(slavesrc="bin",masterdest="public_html/binaries",url="MicrosoftExcel",compress="bz2"))
|
||||
return factory
|
||||
|
||||
def SWIG_MATLAB_bin_builder():
|
||||
factory = BuildFactory()
|
||||
|
||||
factory.addStep(ShellCommand(command=cleanCommand, description='fullclean?', workdir=""))
|
||||
|
||||
# Check out the source
|
||||
factory.addStep(Git(repourl='git://github.com/CoolProp/CoolProp', mode='incremental', submodules = False, progress=True, haltOnFailure = True))
|
||||
|
||||
# Build SWIG with MATLAB
|
||||
factory.addStep(ShellCommand(command=' '.join(["python","build_swig_matlab.py"]),
|
||||
workdir= "build/dev/scripts",
|
||||
haltOnFailure = True))
|
||||
factory.addStep(MakeDirectory(dir='build/dev/scripts/swig-MATLAB', haltOnFailure = True))
|
||||
# Zip up the directory that was generated
|
||||
factory.addStep(ShellCommand(command=' '.join(["tar","-cf","swig-MATLAB/swig_MATLAB.tar.gz","swig-matlab/swig-matlab-bin"]),
|
||||
workdir= "build/dev/scripts",
|
||||
haltOnFailure = True))
|
||||
|
||||
# Upload swig+MATLAB
|
||||
factory.addStep(DirectoryUpload(slavesrc="dev/scripts/swig-MATLAB",
|
||||
masterdest="public_html/nightly/swig-MATLAB",
|
||||
url="nightly/swig-MATLAB",
|
||||
compress="bz2"))
|
||||
|
||||
def nightly_builder():
|
||||
factory = BuildFactory()
|
||||
|
||||
factory.addStep(ShellCommand(command=cleanCommand, description='fullclean?', workdir=""))
|
||||
|
||||
# check out the source
|
||||
# Check out the source
|
||||
factory.addStep(Git(repourl='git://github.com/CoolProp/CoolProp', mode='incremental', submodules = False, progress=True, haltOnFailure = True))
|
||||
# Build the incompressible files
|
||||
factory.addStep(ShellCommand(command=' '.join(["chmod", "+x", "nightly_build.bsh","&&","./nightly_build.bsh"]),
|
||||
workdir= "build/dev/incompressible_liquids",
|
||||
haltOnFailure = True))
|
||||
# Upload the incompressible data
|
||||
factory.addStep(DirectoryUpload(slavesrc="Web/_static/fluid_properties",
|
||||
masterdest="public_html/nightly/fluid_properties",
|
||||
url="nightly/fluid_properties",
|
||||
compress="bz2"))
|
||||
|
||||
# Build SWIG with MATLAB
|
||||
|
||||
# factory.addStep(ShellCommand(command=' '.join(["python", "all_incompressibles.py"]),
|
||||
# workdir= "build/dev/incompressibles",
|
||||
# haltOnFailure = True))
|
||||
return factory
|
||||
|
||||
|
||||
|
||||
|
||||
from buildbot.config import BuilderConfig
|
||||
|
||||
@@ -417,6 +495,14 @@ c['builders'].append(
|
||||
)
|
||||
)
|
||||
|
||||
c['builders'].append(
|
||||
BuilderConfig(name="SWIG-MATLAB-bin",
|
||||
#branch = 'master',
|
||||
slavenames=["linux-slave"],
|
||||
factory = SWIG_MATLAB_bin_builder()
|
||||
)
|
||||
)
|
||||
|
||||
####### SCHEDULERS
|
||||
|
||||
from buildbot.schedulers.basic import SingleBranchScheduler
|
||||
@@ -438,10 +524,15 @@ c['schedulers'].append(ForceScheduler(
|
||||
label="Do a full clean", default=False)]))
|
||||
|
||||
c['schedulers'].append(Nightly(name='nightly',
|
||||
branch='master',
|
||||
builderNames=['nightly-build'],
|
||||
hour=3,
|
||||
branch='master',
|
||||
builderNames=['nightly-build','SWIG-MATLAB-bin],
|
||||
hour=[3, 15]
|
||||
minute=0))
|
||||
|
||||
swig_matlab_dependent_scheduler = basic.Dependent(name="build-package",
|
||||
upstream=swig_matlab_pre, # <- no quotes!
|
||||
builderNames=["swig_matlab"])
|
||||
c['schedulers'] = [swig_matlab_pre, swig_matlab_scheduler]
|
||||
|
||||
####### STATUS TARGETS
|
||||
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="coolprop" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/coolprop" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../include" />
|
||||
<Add directory="../../externals/Eigen" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin/Release/coolprop" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="msvc10" />
|
||||
<Compiler>
|
||||
<Add option="/arch:SSE2" />
|
||||
<Add option="/W3" />
|
||||
<Add directory="../../include" />
|
||||
<Add directory="../../externals/Eigen" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-fexceptions" />
|
||||
</Compiler>
|
||||
<Unit filename="../../include/AbstractState.h" />
|
||||
<Unit filename="../../include/CachedElement.h" />
|
||||
<Unit filename="../../include/CoolProp.h" />
|
||||
<Unit filename="../../include/CoolPropFluid.h" />
|
||||
<Unit filename="../../include/CoolPropLib.h" />
|
||||
<Unit filename="../../include/CoolPropTools.h" />
|
||||
<Unit filename="../../include/DataStructures.h" />
|
||||
<Unit filename="../../include/Exceptions.h" />
|
||||
<Unit filename="../../include/Helmholtz.h" />
|
||||
<Unit filename="../../include/HumidAirProp.h" />
|
||||
<Unit filename="../../include/Ice.h" />
|
||||
<Unit filename="../../include/IncompressibleFluid.h" />
|
||||
<Unit filename="../../include/MatrixMath.h" />
|
||||
<Unit filename="../../include/PlatformDetermination.h" />
|
||||
<Unit filename="../../include/PolyMath.h" />
|
||||
<Unit filename="../../include/Solvers.h" />
|
||||
<Unit filename="../../include/SpeedTest.h" />
|
||||
<Unit filename="../../include/Tests.h" />
|
||||
<Unit filename="../../include/all_fluids_JSON.h" />
|
||||
<Unit filename="../../include/catch.hpp" />
|
||||
<Unit filename="../../include/cpversion.h" />
|
||||
<Unit filename="../../include/crossplatform_shared_ptr.h" />
|
||||
<Unit filename="../../include/gitrevision.h" />
|
||||
<Unit filename="../../include/mixture_excess_term_JSON.h" />
|
||||
<Unit filename="../../include/mixture_reducing_parameters_JSON.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/document.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/filestream.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/internal/pow10.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/internal/stack.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/internal/strfunc.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/prettywriter.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/rapidjson.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/reader.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/stringbuffer.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson/writer.h" />
|
||||
<Unit filename="../../include/rapidjson/rapidjson_include.h" />
|
||||
<Unit filename="../../src/AbstractState.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/ExcessHEFunction.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/ExcessHEFunction.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/FlashRoutines.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/FlashRoutines.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/Fluids/FluidLibrary.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/Fluids/FluidLibrary.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/Fluids/Incompressible.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/HelmholtzEOSBackend.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/HelmholtzEOSBackend.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/ReducingFunctions.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/ReducingFunctions.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/TransportRoutines.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/TransportRoutines.h" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/VLERoutines.cpp" />
|
||||
<Unit filename="../../src/Backends/Helmholtz/VLERoutines.h" />
|
||||
<Unit filename="../../src/Backends/Incompressible/IncompressibleBackend.cpp" />
|
||||
<Unit filename="../../src/Backends/Incompressible/IncompressibleBackend.h" />
|
||||
<Unit filename="../../src/Backends/Incompressible/IncompressibleFluid.cpp" />
|
||||
<Unit filename="../../src/Backends/Incompressible/IncompressibleLibrary.cpp" />
|
||||
<Unit filename="../../src/Backends/Incompressible/IncompressibleLibrary.h" />
|
||||
<Unit filename="../../src/Backends/REFPROP/REFPROPBackend.cpp" />
|
||||
<Unit filename="../../src/Backends/REFPROP/REFPROPBackend.h" />
|
||||
<Unit filename="../../src/Backends/REFPROP/REFPROPMixtureBackend.cpp" />
|
||||
<Unit filename="../../src/Backends/REFPROP/REFPROPMixtureBackend.h" />
|
||||
<Unit filename="../../src/Backends/REFPROP/REFPROP_lib.h" />
|
||||
<Unit filename="../../src/CoolProp.cpp" />
|
||||
<Unit filename="../../src/CoolPropLIB.cpp" />
|
||||
<Unit filename="../../src/CoolPropTools.cpp" />
|
||||
<Unit filename="../../src/DataStructures.cpp" />
|
||||
<Unit filename="../../src/Helmholtz.cpp" />
|
||||
<Unit filename="../../src/HumidAirProp.cpp" />
|
||||
<Unit filename="../../src/Ice.cpp" />
|
||||
<Unit filename="../../src/MatrixMath.cpp" />
|
||||
<Unit filename="../../src/PolyMath.cpp" />
|
||||
<Unit filename="../../src/Solvers.cpp" />
|
||||
<Unit filename="../../src/SpeedTest.cpp" />
|
||||
<Unit filename="../../src/Tests/CoolProp-Tests.cpp" />
|
||||
<Unit filename="../../src/Tests/Tests.cpp" />
|
||||
<Unit filename="../../src/l10n/english.h" />
|
||||
<Unit filename="../../src/main.cxx" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
@@ -38,7 +38,8 @@ values = [
|
||||
('all_fluids.json','all_fluids_JSON.h','all_fluids_JSON'),
|
||||
('all_incompressibles.json','all_incompressibles_JSON.h','all_incompressibles_JSON'),
|
||||
('mixtures/mixture_departure_functions.json', 'mixture_departure_functions_JSON.h', 'mixture_departure_functions_JSON'),
|
||||
('mixtures/mixture_binary_pairs.json', 'mixture_binary_pairs_JSON.h', 'mixture_binary_pairs_JSON')
|
||||
('mixtures/mixture_binary_pairs.json', 'mixture_binary_pairs_JSON.h', 'mixture_binary_pairs_JSON'),
|
||||
('mixtures/predefined_mixtures.json', 'predefined_mixtures_JSON.h', 'predefined_mixtures_JSON')
|
||||
]
|
||||
|
||||
def TO_CPP(root_dir, hashes):
|
||||
@@ -67,8 +68,6 @@ def TO_CPP(root_dir, hashes):
|
||||
subprocess.call('python -mjson.tool '+file, shell = True)
|
||||
raise ValueError('unable to decode file %s' % file)
|
||||
|
||||
|
||||
|
||||
json = open(os.path.join(root_dir,'dev',infile),'r').read().encode('ascii')
|
||||
|
||||
# convert each character to hex and add a terminating NULL character to end the
|
||||
@@ -90,7 +89,7 @@ def TO_CPP(root_dir, hashes):
|
||||
if variable not in hashes or (variable in hashes and hashes[variable] != get_hash(hex_string.encode('ascii'))):
|
||||
|
||||
# Generate the output string
|
||||
output = '// File generated by the script dev/JSON_to_CPP.py on '+ str(datetime.now()) + '\n\n'
|
||||
output = '// File generated by the script dev/generate_headers.py on '+ str(datetime.now()) + '\n\n'
|
||||
output += '// JSON file encoded in binary form\n'
|
||||
output += 'const unsigned char '+variable+'_binary[] = {\n' + hex_string + '\n};'+'\n\n'
|
||||
output += '// Combined into a single std::string \n'
|
||||
|
||||
1077
dev/mixtures/predefined_mixtures.json
Normal file
1077
dev/mixtures/predefined_mixtures.json
Normal file
File diff suppressed because it is too large
Load Diff
21
dev/scripts/build_swig_matlab.py
Normal file
21
dev/scripts/build_swig_matlab.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import subprocess, wget, os, shutil, sys, glob
|
||||
|
||||
if not os.path.exists('swig-matlab'):
|
||||
subprocess.call('git clone https://github.com/KrisThielemans/swig swig-matlab', shell = True, stdout = sys.stdout, stderr = sys.stderr)
|
||||
else:
|
||||
subprocess.call('git pull', shell = True, cwd = 'swig-matlab', stdout = sys.stdout, stderr = sys.stderr)
|
||||
|
||||
os.chdir('swig-matlab')
|
||||
if not glob.glob('pcre-*.tar.gz'):
|
||||
for rev in ['8.34','8.35','8.36']:
|
||||
try:
|
||||
wget.download('ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-'+rev+'.tar.gz'); break
|
||||
except:
|
||||
pass
|
||||
|
||||
subprocess.check_call('Tools/pcre-build.sh', shell = True, stdout = sys.stdout, stderr = sys.stderr)
|
||||
subprocess.check_call('./autogen.sh', shell = True, stdout = sys.stdout, stderr = sys.stderr)
|
||||
subprocess.check_call('./configure --disable-ccache --with-matlab=/usr/local/MATLAB/R2014a --prefix=${PWD}/swig-matlab-bin', shell = True, stdout = sys.stdout, stderr = sys.stderr)
|
||||
subprocess.check_call('make', shell = True, stdout = sys.stdout, stderr = sys.stderr)
|
||||
subprocess.check_call('make install', shell = True, stdout = sys.stdout, stderr = sys.stderr)
|
||||
subprocess.check_call('cp swig swig3.0', shell = True, stdout = sys.stdout, stderr = sys.stderr, cwd='swig-matlab-bin/bin')
|
||||
@@ -22,7 +22,7 @@ AbstractState * AbstractState::factory(const std::string &backend, const std::st
|
||||
if (!backend.compare("HEOS"))
|
||||
{
|
||||
if (fluid_string.find('&') == std::string::npos){
|
||||
return new HelmholtzEOSBackend(&get_fluid(fluid_string));
|
||||
return new HelmholtzEOSBackend(fluid_string);
|
||||
}
|
||||
else{
|
||||
// Split at the '&'
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
#include "HelmholtzEOSMixtureBackend.h"
|
||||
#include "Fluids/FluidLibrary.h"
|
||||
#include "MixtureParameters.h"
|
||||
|
||||
namespace CoolProp {
|
||||
|
||||
@@ -18,7 +19,28 @@ class HelmholtzEOSBackend : public HelmholtzEOSMixtureBackend {
|
||||
public:
|
||||
HelmholtzEOSBackend();
|
||||
HelmholtzEOSBackend(CoolPropFluid *pFluid){set_components(std::vector<CoolPropFluid*>(1,pFluid));};
|
||||
HelmholtzEOSBackend(const std::string &name){set_components(std::vector<CoolPropFluid*>(1,&(get_library().get(name))));};
|
||||
HelmholtzEOSBackend(const std::string &name){
|
||||
Dictionary dict;
|
||||
std::vector<double> mole_fractions;
|
||||
std::vector<CoolPropFluid*> components;
|
||||
if (is_predefined_mixture(name, dict)){
|
||||
std::vector<std::string> fluids = dict.get_string_vector("fluids");
|
||||
mole_fractions = dict.get_double_vector("mole_fractions");
|
||||
|
||||
components.resize(fluids.size());
|
||||
for (unsigned int i = 0; i < components.size(); ++i){
|
||||
components[i] = &(get_library().get(fluids[i]));
|
||||
}
|
||||
}
|
||||
else{
|
||||
components = std::vector<CoolPropFluid*>(1,&(get_library().get(name)));
|
||||
mole_fractions = std::vector<double>(1,1);
|
||||
}
|
||||
// Set the components
|
||||
set_components(components);
|
||||
// Set the mole fractions
|
||||
set_mole_fractions(std::vector<long double>(mole_fractions.begin(), mole_fractions.end()));
|
||||
};
|
||||
virtual ~HelmholtzEOSBackend(){};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,51 @@
|
||||
#include "MixtureParameters.h"
|
||||
#include "mixture_departure_functions_JSON.h" // Creates the variable mixture_departure_functions_JSON
|
||||
#include "mixture_binary_pairs_JSON.h" // Creates the variable mixture_binary_pairs_JSON
|
||||
#include "predefined_mixtures_JSON.h" // Makes a std::string variable called predefined_mixtures_JSON
|
||||
|
||||
namespace CoolProp{
|
||||
|
||||
/** \brief A library of predefined mixtures
|
||||
*
|
||||
* Each entry in the predefined mixture library contains the names and mole fractions for the binary pairs
|
||||
*/
|
||||
class PredefinedMixturesLibrary{
|
||||
public:
|
||||
std::map<std::string, Dictionary> predefined_mixture_map;
|
||||
|
||||
PredefinedMixturesLibrary(){
|
||||
rapidjson::Document doc;
|
||||
|
||||
doc.Parse<0>(predefined_mixtures_JSON.c_str());
|
||||
if (doc.HasParseError()){throw ValueError();}
|
||||
|
||||
// Iterate over the papers in the listing
|
||||
for (rapidjson::Value::ValueIterator itr = doc.Begin(); itr != doc.End(); ++itr)
|
||||
{
|
||||
// Instantiate the empty dictionary to be filled
|
||||
Dictionary dict;
|
||||
// Get the name
|
||||
std::string name = cpjson::get_string(*itr, "name")+".mix";
|
||||
// Get the fluid names
|
||||
dict.add_string_vector("fluids", cpjson::get_string_array(*itr, "fluids"));
|
||||
// Get the mole fractions
|
||||
dict.add_double_vector("mole_fractions", cpjson::get_double_array(*itr,"mole_fractions"));
|
||||
|
||||
predefined_mixture_map.insert(std::pair<std::string, Dictionary >(name, dict));
|
||||
}
|
||||
}
|
||||
};
|
||||
static PredefinedMixturesLibrary predefined_mixtures_library;
|
||||
|
||||
bool is_predefined_mixture(const std::string name, Dictionary &dict){
|
||||
if (predefined_mixtures_library.predefined_mixture_map.find(name) != predefined_mixtures_library.predefined_mixture_map.end()){
|
||||
dict = predefined_mixtures_library.predefined_mixture_map[name];
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief A library of binary pair parameters for the mixture
|
||||
*
|
||||
|
||||
@@ -11,6 +11,11 @@ namespace CoolProp{
|
||||
*/
|
||||
std::string get_csv_mixture_binary_pairs();
|
||||
|
||||
/** \brief Get the parameters for a predefined mixture - R410A, R404A, etc.
|
||||
*
|
||||
*/
|
||||
bool is_predefined_mixture(const std::string name, Dictionary &dict);
|
||||
|
||||
/** \brief Get a string for the given binary pair
|
||||
*
|
||||
*
|
||||
|
||||
@@ -21,9 +21,11 @@ def collect(tmp):
|
||||
|
||||
if __name__=='__main__':
|
||||
|
||||
import shutil, os, sys, subprocess
|
||||
import shutil, os, sys, subprocess, glob
|
||||
|
||||
subprocess.check_call('python generate_headers.py', shell = True, cwd = os.path.join('..','..','..','dev'), stdout = sys.stdout, stderr = sys.stderr)
|
||||
for pyx in ['CoolProp.pyx','constants.pyx']:
|
||||
subprocess.check_call('cython --cplus '+os.path.split(pyx)[1], shell = True, cwd = os.path.join('..','CoolProp'), stdout = sys.stdout, stderr = sys.stderr)
|
||||
name = 'CoolProp'
|
||||
|
||||
# Make a temporary directory in this folder
|
||||
|
||||
Reference in New Issue
Block a user