diff --git a/README.rst b/README.rst index 5296f8ebca..39dac8105b 100644 --- a/README.rst +++ b/README.rst @@ -99,13 +99,8 @@ in this guide: #. you have acquired the Cycamore source code from the `Cycamore repo`_ #. you have placed the Cycamore repository in .../cyclus/cycamore - #. you have a directory named .../cyclus/cycamore/build in which - you plan to encapsulate all build-related files (they get in the - way otherwise) - #. you have installed Cyclopts using the CMAKE_INSTALL_PREFIX - variable set to ../cyclus/install (see the `Cyclopts readme`_) - #. you have installed Cyclus using the CMAKE_INSTALL_PREFIX - variable set to ../cyclus/install (see the `Cyclus readme`_) + #. you have installed Cyclopts in .../cyclus/install (see the `Cyclopts readme`_) + #. you have installed Cyclus in .../cyclus/install (see the `Cyclus readme`_) Under these assumptions **and** if you used a package manager to install coin-Cbc (i.e. it's installed in a standard location), the @@ -113,20 +108,26 @@ Cyclus building and installation process will look like: .. code-block:: bash - .../cyclus/cycamore$ cd build - .../cyclus/cycamore/build$ cmake ../src -DCMAKE_INSTALL_PREFIX=../../install -DCYCLOPTS_ROOT_DIR=../../install -DCYCLUS_ROOT_DIR=../../install - .../cyclus/cycamore/build$ make && make install + .../cyclus/cycamore$ python setup.py --prefix=../install --cyclus_root=../install --cyclopts_root=../install If you have installed coin-Cbc from source or otherwise have it -installed in a non-standard location, you should make use of the CMake -COIN_ROOT_DIR variable. The otherwise identical process would look +installed in a non-standard location, you should make use of the +``coinRoot`` flag. The otherwise identical process would look like: .. code-block:: bash - .../cyclus/cycamore$ cd build - .../cyclus/cycamore/build$ cmake ../src -DCMAKE_INSTALL_PREFIX=../../install -DCYCLOPTS_ROOT_DIR=../../install -DCYCLUS_ROOT_DIR=../../install -DCOIN_ROOT_DIR=/the/path/to/coin/install - .../cyclus/cycamore/build$ make && make install + .../cyclus/cycamore$ python setup.py --prefix=../install --coin_root=/path/to/coin --cyclus_root=../install --cyclopts_root=../install + +Additionally, if you have installed Boost from source or otherwise have it +installed in a non-standard location, you should make use of the +``boostRoot`` flag. The otherwise identical process would look +like: + +.. code-block:: bash + + .../cyclus/cycamore$ python setup.py --prefix=../install --coin_root=/path/to/coin --cyclus_root=../install --cyclopts_root=../install --boost_root=/path/to/boost + .. _`CMake`: http://www.cmake.org .. _`apt-get`: http://linux.die.net/man/8/apt-get @@ -200,12 +201,8 @@ Workflow Notes branch and then run the CycamoreUnitTestDriver (at the moment, ```make test``` is insufficient). For example :: - mkdir build mkdir install - cd build - cmake ../src -DCMAKE_INSTALL_PREFIX=../install - make - make install + python setup.py --prefix=../install ... ../install/cycamore/bin/CycamoreUnitTestDriver - There are also a suite of sample input files diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..c3cf028930 --- /dev/null +++ b/setup.py @@ -0,0 +1,99 @@ +import os +import subprocess +import shutil + +try: + import argparse as ap +except ImportError: + import pyne._argparse as ap + +absexpanduser = lambda x: os.path.abspath(os.path.expanduser(x)) + +def check_windows_cmake(cmake_cmd): + if os.name == 'nt': + files_on_path = set() + for p in os.environ['PATH'].split(';')[::-1]: + if os.path.exists(p): + files_on_path.update(os.listdir(p)) + if 'cl.exe' in files_on_path: + pass + elif 'sh.exe' in files_on_path: + cmake_cmd += ['-G "MSYS Makefiles"'] + elif 'gcc.exe' in files_on_path: + cmake_cmd += ['-G "MinGW Makefiles"'] + cmake_cmd = ' '.join(cmake_cmd) + +def install_cycamore(args): + if not os.path.exists(args.build_dir): + os.mkdir(args.build_dir) + elif args.replace: + shutil.rmtree(args.build_dir) + os.mkdir(args.build_dir) + + root_dir = os.path.split(__file__)[0] + src_dir = os.path.join(root_dir, 'src') + makefile = os.path.join(args.build_dir, 'Makefile') + + if not os.path.exists(makefile): + cmake_cmd = ['cmake', absexpanduser(src_dir)] + if args.prefix: + cmake_cmd += ['-DCMAKE_INSTALL_PREFIX=' + absexpanduser(args.prefix)] + if args.cmake_prefix_path: + cmake_cmd += ['-DCMAKE_PREFIX_PATH=' + absexpanduser(args.cmake_prefix_path)] + if args.coin_root: + cmake_cmd += ['-DCOIN_ROOT_DIR=' + absexpanduser(args.coin_root)] + if args.boost_root: + cmake_cmd += ['-DBOOST_ROOT=' + absexpanduser(args.boost_root)] + if args.cyclopts_root: + cmake_cmd += ['-DCYCLOPTS_ROOT_DIR='+absexpanduser(args.cyclopts_root)] + if args.cyclus_root: + cmake_cmd += ['-DCYCLUS_ROOT_DIR='+absexpanduser(args.cyclus_root)] + check_windows_cmake(cmake_cmd) + rtn = subprocess.check_call(cmake_cmd, cwd=absexpanduser(args.build_dir), shell=(os.name=='nt')) + + make_cmd = ['make'] + if args.threads: + make_cmd += ['-j' + str(args.threads)] + make_cmd += ['install'] + rtn = subprocess.check_call(make_cmd, cwd=absexpanduser(args.build_dir), shell=(os.name=='nt')) + +def main(): + + description = "A Cycamore installation helper script. "+\ + "For more information, please see cyclus.github.com." + + parser = ap.ArgumentParser(description=description) + + build_dir = 'where to place the build directory' + parser.add_argument('--build_dir', help=build_dir, default='build') + + replace = 'whether or not to remove the build directory if it exists' + parser.add_argument('--replace', type=bool, help=replace, default=True) + + threads = "the number of threads to use in the make step" + parser.add_argument('-j', '--threads', type=int, help=threads) + + install = "the relative path to the installation directory" + parser.add_argument('--prefix', help=install) + + coin = "the relative path to the Coin-OR libraries directory" + parser.add_argument('--coin_root', help=coin) + + cyclopts = "the relative path to Cyclopts installation directory" + parser.add_argument('--cyclopts_root',help=cyclopts) + + cyclus = "the relative path to Cyclus installation directory" + parser.add_argument('--cyclus_root',help=cyclus) + + boost = "the relative path to the Boost libraries directory" + parser.add_argument('--boost_root', help=boost) + + cmake_prefix_path = "the cmake prefix path for use with FIND_PACKAGE, " + \ + "FIND_PATH, FIND_PROGRAM, or FIND_LIBRARY macros" + parser.add_argument('--cmake_prefix_path', help=cmake_prefix_path) + + + install_cycamore(parser.parse_args()) + +if __name__ == "__main__": + main() diff --git a/src/Models/Facility/BatchReactor/BatchReactorTests.cpp b/src/Models/Facility/BatchReactor/BatchReactorTests.cpp index 1d459afa22..bf74b1ef0a 100644 --- a/src/Models/Facility/BatchReactor/BatchReactorTests.cpp +++ b/src/Models/Facility/BatchReactor/BatchReactorTests.cpp @@ -61,7 +61,8 @@ void BatchReactorTest::initSrcFacility() << " " << ""; - XMLParser parser(ss); + XMLParser parser; + parser.init(ss); XMLQueryEngine* engine = new XMLQueryEngine(parser); src_facility = new BatchReactor(); src_facility->initModuleMembers(engine); diff --git a/src/Models/Facility/EnrichmentFacility/EnrichmentFacilityTests.cpp b/src/Models/Facility/EnrichmentFacility/EnrichmentFacilityTests.cpp index 5467d9907c..0faea72849 100644 --- a/src/Models/Facility/EnrichmentFacility/EnrichmentFacilityTests.cpp +++ b/src/Models/Facility/EnrichmentFacility/EnrichmentFacilityTests.cpp @@ -71,7 +71,8 @@ void EnrichmentFacilityTest::initFacility() << " " << ""; - XMLParser parser(ss); + XMLParser parser; + parser.init(ss); XMLQueryEngine* engine = new XMLQueryEngine(parser); EXPECT_NO_THROW(src_facility->initModuleMembers(engine)); diff --git a/src/Models/Facility/SinkFacility/SinkFacility.rng b/src/Models/Facility/SinkFacility/SinkFacility.rng index a394d6021f..7d55249403 100644 --- a/src/Models/Facility/SinkFacility/SinkFacility.rng +++ b/src/Models/Facility/SinkFacility/SinkFacility.rng @@ -5,7 +5,9 @@ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - + + + diff --git a/src/Models/Facility/SourceFacility/SourceFacility.cpp b/src/Models/Facility/SourceFacility/SourceFacility.cpp index d0365d22eb..52aba51bc0 100644 --- a/src/Models/Facility/SourceFacility/SourceFacility.cpp +++ b/src/Models/Facility/SourceFacility/SourceFacility.cpp @@ -42,10 +42,16 @@ void SourceFacility::initModuleMembers(QueryEngine* qe) { setCommodity(data); Commodity commod(data); CommodityProducer::addCommodity(commod); - - data = output->getElementContent("output_capacity"); - CommodityProducer::setCapacity(commod,lexical_cast(data)); - setCapacity(lexical_cast(data)); + + double val = numeric_limits::max(); + try + { + data = output->getElementContent("output_capacity"); + val = lexical_cast(data); // overwrite default if given a value + } + catch (CycNullQueryException e) {} + CommodityProducer::setCapacity(commod, val); + setCapacity(val); try { diff --git a/src/Models/Facility/SourceFacility/SourceFacility.rng b/src/Models/Facility/SourceFacility/SourceFacility.rng index 829ed07836..ebddaea6a2 100644 --- a/src/Models/Facility/SourceFacility/SourceFacility.rng +++ b/src/Models/Facility/SourceFacility/SourceFacility.rng @@ -5,7 +5,9 @@ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - + + + diff --git a/src/Models/Facility/RecipeReactor/CMakeLists.txt b/src/Models/Facility/deprecated/RecipeReactor/CMakeLists.txt similarity index 100% rename from src/Models/Facility/RecipeReactor/CMakeLists.txt rename to src/Models/Facility/deprecated/RecipeReactor/CMakeLists.txt diff --git a/src/Models/Facility/RecipeReactor/RecipeReactor.cpp b/src/Models/Facility/deprecated/RecipeReactor/RecipeReactor.cpp similarity index 100% rename from src/Models/Facility/RecipeReactor/RecipeReactor.cpp rename to src/Models/Facility/deprecated/RecipeReactor/RecipeReactor.cpp diff --git a/src/Models/Facility/RecipeReactor/RecipeReactor.h b/src/Models/Facility/deprecated/RecipeReactor/RecipeReactor.h similarity index 100% rename from src/Models/Facility/RecipeReactor/RecipeReactor.h rename to src/Models/Facility/deprecated/RecipeReactor/RecipeReactor.h diff --git a/src/Models/Facility/RecipeReactor/RecipeReactor.rng b/src/Models/Facility/deprecated/RecipeReactor/RecipeReactor.rng similarity index 100% rename from src/Models/Facility/RecipeReactor/RecipeReactor.rng rename to src/Models/Facility/deprecated/RecipeReactor/RecipeReactor.rng diff --git a/src/Models/Facility/RecipeReactor/RecipeReactorTests.cpp b/src/Models/Facility/deprecated/RecipeReactor/RecipeReactorTests.cpp similarity index 100% rename from src/Models/Facility/RecipeReactor/RecipeReactorTests.cpp rename to src/Models/Facility/deprecated/RecipeReactor/RecipeReactorTests.cpp diff --git a/src/Models/Facility/StorageFacility/CMakeLists.txt b/src/Models/Facility/deprecated/StorageFacility/CMakeLists.txt similarity index 100% rename from src/Models/Facility/StorageFacility/CMakeLists.txt rename to src/Models/Facility/deprecated/StorageFacility/CMakeLists.txt diff --git a/src/Models/Facility/StorageFacility/StorageFacility.cpp b/src/Models/Facility/deprecated/StorageFacility/StorageFacility.cpp similarity index 100% rename from src/Models/Facility/StorageFacility/StorageFacility.cpp rename to src/Models/Facility/deprecated/StorageFacility/StorageFacility.cpp diff --git a/src/Models/Facility/StorageFacility/StorageFacility.h b/src/Models/Facility/deprecated/StorageFacility/StorageFacility.h similarity index 96% rename from src/Models/Facility/StorageFacility/StorageFacility.h rename to src/Models/Facility/deprecated/StorageFacility/StorageFacility.h index 697253a4fc..756312cdf2 100644 --- a/src/Models/Facility/StorageFacility/StorageFacility.h +++ b/src/Models/Facility/deprecated/StorageFacility/StorageFacility.h @@ -87,6 +87,7 @@ class StorageFacility : public FacilityModel /* --- */ /* --- Transaction Methods --- */ + /** Transacted resources are extracted through this method @@ -109,6 +110,17 @@ class StorageFacility : public FacilityModel When the facility receives a message, execute any transaction */ virtual void receiveMessage(msg_ptr msg); + + protected: + /** + builds a transaction + */ + Transaction buildTransaction(); + + /** + sends a transaction as an offer + */ + void sendOffer(Transaction trans); /* --- */ /* --- StorageFacility Methods --- */ diff --git a/src/Models/Facility/StorageFacility/StorageFacility.rng b/src/Models/Facility/deprecated/StorageFacility/StorageFacility.rng similarity index 100% rename from src/Models/Facility/StorageFacility/StorageFacility.rng rename to src/Models/Facility/deprecated/StorageFacility/StorageFacility.rng diff --git a/src/Models/Inst/ManagerInst/ManagerInst.h b/src/Models/Inst/ManagerInst/ManagerInst.h index 6d0437f589..2be114080a 100644 --- a/src/Models/Inst/ManagerInst/ManagerInst.h +++ b/src/Models/Inst/ManagerInst/ManagerInst.h @@ -53,7 +53,6 @@ class ManagerInst : public InstModel, /** write information about a commodity producer to a stream @param producer the producer - @param stream the stream */ void writeProducerInformation(SupplyDemand::CommodityProducer* producer); }; diff --git a/src/Models/Region/GrowthRegion/GrowthRegionTests.cpp b/src/Models/Region/GrowthRegion/GrowthRegionTests.cpp index 6002f00028..2857b12cd3 100644 --- a/src/Models/Region/GrowthRegion/GrowthRegionTests.cpp +++ b/src/Models/Region/GrowthRegion/GrowthRegionTests.cpp @@ -5,6 +5,7 @@ #include "Commodity.h" #include "XMLQueryEngine.h" +#include "XMLParser.h" #include @@ -53,7 +54,8 @@ void GrowthRegionTests::initRegion() << " " << ""; - XMLParser parser(ss); + XMLParser parser; + parser.init(ss); XMLQueryEngine* engine = new XMLQueryEngine(parser); region->initModuleMembers(engine); delete engine; diff --git a/src/Models/Converter/CMakeLists.txt b/src/Models/deprecated/Converter/CMakeLists.txt similarity index 100% rename from src/Models/Converter/CMakeLists.txt rename to src/Models/deprecated/Converter/CMakeLists.txt diff --git a/src/Models/Converter/README b/src/Models/deprecated/Converter/README similarity index 100% rename from src/Models/Converter/README rename to src/Models/deprecated/Converter/README diff --git a/src/Models/Converter/SWUeUF6Converter/CMakeLists.txt b/src/Models/deprecated/Converter/SWUeUF6Converter/CMakeLists.txt similarity index 100% rename from src/Models/Converter/SWUeUF6Converter/CMakeLists.txt rename to src/Models/deprecated/Converter/SWUeUF6Converter/CMakeLists.txt diff --git a/src/Models/Converter/SWUeUF6Converter/SWUeUF6Converter.cpp b/src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6Converter.cpp similarity index 100% rename from src/Models/Converter/SWUeUF6Converter/SWUeUF6Converter.cpp rename to src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6Converter.cpp diff --git a/src/Models/Converter/SWUeUF6Converter/SWUeUF6Converter.h b/src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6Converter.h similarity index 100% rename from src/Models/Converter/SWUeUF6Converter/SWUeUF6Converter.h rename to src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6Converter.h diff --git a/src/Models/Converter/SWUeUF6Converter/SWUeUF6Converter.rng b/src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6Converter.rng similarity index 100% rename from src/Models/Converter/SWUeUF6Converter/SWUeUF6Converter.rng rename to src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6Converter.rng diff --git a/src/Models/Converter/SWUeUF6Converter/SWUeUF6ConverterTests.cpp b/src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6ConverterTests.cpp similarity index 100% rename from src/Models/Converter/SWUeUF6Converter/SWUeUF6ConverterTests.cpp rename to src/Models/deprecated/Converter/SWUeUF6Converter/SWUeUF6ConverterTests.cpp diff --git a/src/Models/Converter/StubConverter/CMakeLists.txt b/src/Models/deprecated/Converter/StubConverter/CMakeLists.txt similarity index 100% rename from src/Models/Converter/StubConverter/CMakeLists.txt rename to src/Models/deprecated/Converter/StubConverter/CMakeLists.txt diff --git a/src/Models/Converter/StubConverter/StubConverter.cpp b/src/Models/deprecated/Converter/StubConverter/StubConverter.cpp similarity index 100% rename from src/Models/Converter/StubConverter/StubConverter.cpp rename to src/Models/deprecated/Converter/StubConverter/StubConverter.cpp diff --git a/src/Models/Converter/StubConverter/StubConverter.h b/src/Models/deprecated/Converter/StubConverter/StubConverter.h similarity index 100% rename from src/Models/Converter/StubConverter/StubConverter.h rename to src/Models/deprecated/Converter/StubConverter/StubConverter.h diff --git a/src/Models/Converter/StubConverter/StubConverter.rng b/src/Models/deprecated/Converter/StubConverter/StubConverter.rng similarity index 100% rename from src/Models/Converter/StubConverter/StubConverter.rng rename to src/Models/deprecated/Converter/StubConverter/StubConverter.rng diff --git a/src/Models/Converter/StubConverter/StubConverterTests.cpp b/src/Models/deprecated/Converter/StubConverter/StubConverterTests.cpp similarity index 100% rename from src/Models/Converter/StubConverter/StubConverterTests.cpp rename to src/Models/deprecated/Converter/StubConverter/StubConverterTests.cpp