From 468105838e3f57fbe40bcc69da2b325d875cbdf5 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 27 Feb 2015 12:44:22 -0500 Subject: [PATCH 1/2] added .rng files using trang --- src/relaxng/cmfd.rng | 230 +++++++++++ src/relaxng/cross_sections.rng | 132 +++++++ src/relaxng/geometry.rng | 345 ++++++++++++++++ src/relaxng/materials.rng | 184 +++++++++ src/relaxng/plots.rng | 295 ++++++++++++++ src/relaxng/settings.rng | 704 +++++++++++++++++++++++++++++++++ src/relaxng/tallies.rng | 216 ++++++++++ 7 files changed, 2106 insertions(+) create mode 100644 src/relaxng/cmfd.rng create mode 100644 src/relaxng/cross_sections.rng create mode 100644 src/relaxng/geometry.rng create mode 100644 src/relaxng/materials.rng create mode 100644 src/relaxng/plots.rng create mode 100644 src/relaxng/settings.rng create mode 100644 src/relaxng/tallies.rng diff --git a/src/relaxng/cmfd.rng b/src/relaxng/cmfd.rng new file mode 100644 index 0000000000..1060fcbf3e --- /dev/null +++ b/src/relaxng/cmfd.rng @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/relaxng/cross_sections.rng b/src/relaxng/cross_sections.rng new file mode 100644 index 0000000000..5e531e0132 --- /dev/null +++ b/src/relaxng/cross_sections.rng @@ -0,0 +1,132 @@ + + + + + + + + + + 15 + + + + + 15 + + + + + + + + 15 + + + + + 15 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 255 + + + + + 255 + + + + + + + + + + + + + + + + + + ascii + binary + + + + + ascii + binary + + + + + + + + + + + 255 + + + + + + ascii + binary + + + + + + + + + + + + + + diff --git a/src/relaxng/geometry.rng b/src/relaxng/geometry.rng new file mode 100644 index 0000000000..9ac3c9c598 --- /dev/null +++ b/src/relaxng/geometry.rng @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + void + + + + + + void + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15 + + + + + 15 + + + + + + + + + + + + + + + + + + + + + + + + transmit + reflective + vacuum + + + + + transmit + reflective + vacuum + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/relaxng/materials.rng b/src/relaxng/materials.rng new file mode 100644 index 0000000000..4c9496eae4 --- /dev/null +++ b/src/relaxng/materials.rng @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + 10 + + + + + + + + + + + + 7 + + + + + 7 + + + + + + + + 3 + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + 2 + + + + + + + + 3 + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7 + + + + + 7 + + + + + + + + 3 + + + + + 3 + + + + + + + + + + + + + + 3 + + + + + diff --git a/src/relaxng/plots.rng b/src/relaxng/plots.rng new file mode 100644 index 0000000000..a21f4d141e --- /dev/null +++ b/src/relaxng/plots.rng @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + 50 + + + + + 50 + + + + + + + + + slice + voxel + + + + + slice + voxel + + + + + + + + + cell + mat + material + + + + + cell + mat + material + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + xy + yz + xz + + + + + xy + yz + xz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + tally + entropy + ufs + cmfd + + + + + tally + entropy + ufs + cmfd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng new file mode 100644 index 0000000000..02dba3688e --- /dev/null +++ b/src/relaxng/settings.rng @@ -0,0 +1,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 255 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nuclide + log + logarithm + logarithmic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 255 + + + + + + + + + + + + + + + + + + + + + + + + + 255 + + + + + + + + + + 16 + + + + + 16 + + + + + + + + + + + + + + + + + + 10 + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16 + + + + + 16 + + + + + + + + + + + + + + + + + + 10 + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16 + + + + + 16 + + + + + + + + + + + + + + + + + + 10 + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 + + + + + 12 + + + + + + + 16 + + + + + 16 + + + + + + + 12 + + + + + 12 + + + + + + + 12 + + + + + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/relaxng/tallies.rng b/src/relaxng/tallies.rng new file mode 100644 index 0000000000..60263676be --- /dev/null +++ b/src/relaxng/tallies.rng @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + rectangular + hexagonal + + + + + rectangular + hexagonal + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 52 + + + + + 52 + + + + + + + + + analog + tracklength + + + + + analog + tracklength + + + + + + + + + + + cell + cellborn + material + universe + surface + mesh + energy + energyout + + + + + cell + cellborn + material + universe + surface + mesh + energy + energyout + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 + + + + + + + + + + 20 + + + + + + + + + + + + + + From 2bfd9ed05104eb2475a04a75ad8c45d40904c4a4 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 27 Feb 2015 12:54:05 -0500 Subject: [PATCH 2/2] removed trang from xml validate script and updated documentation --- docs/source/usersguide/input.rst | 11 +------ src/relaxng/readme.rst | 19 ++++++++++++ src/utils/xml_validate.py | 50 ++++++++++++-------------------- 3 files changed, 38 insertions(+), 42 deletions(-) create mode 100644 src/relaxng/readme.rst diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index cb1a577039..79d66d2869 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -57,13 +57,7 @@ Validating XML Files Input files can be checked before executing OpenMC using the ``xml_validate`` script. It is located in ``src/utils/xml_validate.py`` in the source code or in -``bin/xml_validate`` in the install directory. Before use, the third party -package TRANG_ must be installed and in your ``PATH`` to convert the compact -RelaxNG schema to standard RelaxNG format. For Ubuntu, you can install with: - -.. code-block:: bash - - sudo apt-get install trang +``bin/xml_validate`` in the install directory. Two command line arguments can be set when running ``xml_validate``: @@ -84,7 +78,6 @@ Message Description ======================== =================================== [XML ERROR] Cannot parse XML file. [NO RELAXNG FOUND] No RelaxNG file found for XML file. -[TRANG FAILED] TRANG not installed properly. [NOT VALID] XML file does not match RelaxNG. [VALID] XML file matches RelaxNG. ======================== =================================== @@ -98,8 +91,6 @@ the following command: /opt/openmc/0.6.2/bin/xml_validate -.. _TRANG: http://www.thaiopensource.com/relaxng/trang.html - -------------------------------------- Settings Specification -- settings.xml -------------------------------------- diff --git a/src/relaxng/readme.rst b/src/relaxng/readme.rst new file mode 100644 index 0000000000..9660e3f8ce --- /dev/null +++ b/src/relaxng/readme.rst @@ -0,0 +1,19 @@ +===================== +Editing RelaxNG files +===================== + +All direct edits to RelaxNG files should be in the .rnc files. The program +TRANG_ should be used to generate a correcsponding .rng file. For Ubuntu, you +can install with: + +.. code-block:: bash + + sudo apt-get install trang + +To convert the .rnc file to .rng, use the following syntax: + +.. code-block:: bash + + trang {filename}.rnc {filename}.rng + +.. _TRANG: http://www.thaiopensource.com/relaxng/trang.html diff --git a/src/utils/xml_validate.py b/src/utils/xml_validate.py index aa56e6e0cf..e5a45f4691 100755 --- a/src/utils/xml_validate.py +++ b/src/utils/xml_validate.py @@ -50,10 +50,10 @@ if not os.path.exists(relaxng_path): raise Exception("RelaxNG path: {0} does not exist, set with -r " "command line option.".format(relaxng_path)) -# Make sure there are .rnc files in RelaxNG path -rnc_files = glob.glob(os.path.join(relaxng_path, "*.rnc")) -if len(rnc_files) == 0: - raise Exception("No .rnc files found in RelaxNG " +# Make sure there are .rng files in RelaxNG path +rng_files = glob.glob(os.path.join(relaxng_path, "*.rng")) +if len(rng_files) == 0: + raise Exception("No .rng files found in RelaxNG " "path: {0}.".format(relaxng_path)) # Get list of xml input files @@ -80,36 +80,22 @@ for xml_file in xml_files: xml_prefix = os.path.basename(xml_file) xml_prefix = xml_prefix.split(".")[0] - # Search for rnc file - rnc_file = os.path.join(relaxng_path, xml_prefix + ".rnc") - rng_file = xml_prefix + ".rng" - if rnc_file in rnc_files: + # Search for rng file + rng_file = os.path.join(relaxng_path, xml_prefix + ".rng") + if rng_file in rng_files: - # convert RNC to RNG file - rc = call("trang {0} {1}".format(rnc_file, rng_file), shell=True) + # read in RelaxNG + relaxng_doc = etree.parse(rng_file) + relaxng = etree.RelaxNG(relaxng_doc) - # check return code - if rc == 0: + # validate xml file again RelaxNG + try: + relaxng.assertValid(xml_tree) + print(BOLD + OK + '[VALID]' + ENDC) + except (etree.DocumentInvalid, TypeError) as e: + print(BOLD + FAIL + '[NOT VALID]' + ENDC) + print(" {0}".format(e)) - # read in RelaxNG - relaxng_doc = etree.parse(rng_file) - relaxng = etree.RelaxNG(relaxng_doc) - - # validate xml file again RelaxNG - try: - relaxng.assertValid(xml_tree) - print(BOLD + OK + '[VALID]' + ENDC) - except (etree.DocumentInvalid, TypeError) as e: - print(BOLD + FAIL + '[NOT VALID]' + ENDC) - print(" {0}".format(e)) - - # remove rng file - os.remove(rng_file) - - # trang command failed - else: - print(BOLD + FAIL + '[TRANG FAILED]' + ENDC) - - # RNC file does not exist + # RNG file does not exist else: print(BOLD + NOT_FOUND + '[NO RELAXNG FOUND]' + ENDC)