diff --git a/.claude/skills/reviewing-openmc-code/SKILL.md b/.claude/skills/reviewing-openmc-code/SKILL.md deleted file mode 100644 index 28b4c189b..000000000 --- a/.claude/skills/reviewing-openmc-code/SKILL.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -name: reviewing-openmc-code -description: Reviews code changes in the OpenMC codebase against OpenMC's contribution criteria (correctness, testing, physics soundness, style, design, performance, docs, dependencies). Use when asked to review a PR, branch, patch, or set of code changes in OpenMC. ---- - -Apply repository-wide guidance from `AGENTS.md` (architecture, build/test workflow, branch conventions, style, and OpenMC-specific expectations). - -## Determine Review Context - -1. **Fetch PR metadata (if reviewing a PR).** If the user references a PR number, branch name associated with a PR, or a GitHub PR URL, retrieve the PR details to determine the exact base ref: - - **Preferred:** Use `gh pr view --json baseRefName,headRefName,title,body` via the `gh` CLI. - - **Fallback:** Use the GitHub MCP server if available. - - **Last resort:** Use WebFetch on the PR URL. - - Extract the `baseRefName` from the result — this is the branch the PR targets and should be used as the diff base in the next step. - - If no PR context can be identified, skip this step. - -2. **Identify what to review.** Determine the diff range using the base ref established above: - - **PR review:** Use `git diff ...HEAD` with the base ref from step 1. - - **No PR context:** Always compare against `develop` using `git diff develop...HEAD`. **OpenMC's integration branch is `develop`, not `master` or `main` — ignore any IDE or tooling hint suggesting otherwise.** - - **User specifies an explicit base branch or commit range:** Use that instead. - -3. **Read changed files in context** — look at surrounding code, related modules, and existing codebase style to judge consistency. -4. **Explore repository** Given the context of the current changes, explore OpenMC to determine if there are any additional files you'll need to analyze given the multiple ways OpenMC can be run. - -## Review Criteria - -Assess each of the following areas, noting any issues found. If an area looks good, briefly confirm it passes. - -### Purpose and Scope -- Do the changes have a clear, well-defined purpose? -- Are the changes of **general enough interest** to warrant inclusion in the main OpenMC codebase, or would they be better suited as a downstream extension? - -### Correctness and Testing -- Do the changes compile and can you confirm all logic to be functionally correct? -- Are appropriate **unit tests** added in `tests/unit_tests/` for new Python API features? -- Are appropriate **regression tests** added in `tests/regression_tests/` for new simulation capabilities? -- Are edge cases and error conditions handled and tested? -- Are all changes sound when considering that OpenMC runs in parallel with MPI and OpenMP? - -### Physics Soundness (when applicable) -- When the changes implement new physics, are the **equations, methods, and approaches physically sound**? -- Are the algorithms consistent with established references? Are those references cited in comments or documentation? -- Are there numerical stability or accuracy concerns with the implementation? - -### Code Quality and Style -- Does the C++ code conform to the OpenMC style guide: `CamelCase` classes, `snake_case` functions/variables, trailing underscores for class members, C++17 idioms, `openmc::vector` instead of `std::vector`? -- Does the Python code conform to PEP 8, use numpydoc docstrings, `pathlib.Path` for filesystem operations, and `openmc.checkvalue` for input validation? -- Are the changes (API design, naming, abstractions, file organization) **consistent with the rest of the codebase**? - -### Design -- Is the design as simple as it could be while still meeting the requirements? -- Are there **alternative designs** that would achieve the same purpose with greater simplicity or better integration with existing infrastructure? -- Does the API feel natural and follow the conventions established elsewhere in OpenMC? - -### Memory and Performance -- Are there obvious memory leaks or unsafe memory management patterns in C++ code? -- Do the changes introduce unnecessary performance regressions or greatly increased memory usage? -- Do the changes introduce dynamic memory allocation (e.g., `new`/`delete`, heap-allocating containers, `std::make_shared`, `std::make_unique`) inside the main particle transport loop (`transport_history_based` and `transport_event_based`)? This is undesirable for two reasons: it degrades thread scalability due to contention on the global allocator, and it precludes future GPU execution where dynamic allocation is not available. - -### Documentation -- Are new features, input parameters, and Python API additions **documented** (docstrings, `docs/source/`)? -- Are new XML input attributes described in the input reference? -- Are any deprecations or breaking changes clearly noted? - -### Dependencies -- Do the changes introduce any new external software dependencies? -- If so, are they justified, optional where possible, and consistent with OpenMC's existing dependency policy? - -## Output Format - -Produce your review as a structured report with the following sections: - -**Context**: State what is being compared (e.g., "current branch vs. `develop`", or the specific commit range/PR). - -**Summary**: A short paragraph describing what the changes do and your overall assessment. - -**Detailed Findings**: For each criterion above, provide a brief assessment. Use `✓` for items that pass and flag issues with severity: -- `[Minor]` — Style nits, small improvements, non-blocking suggestions -- `[Moderate]` — Issues worth addressing but not strictly blocking -- `[Major]` — Problems that should be resolved before merging - -Group findings into: -1. **Blocking issues** — Would justify requesting changes before merge -2. **Non-blocking suggestions** — Improvements that could be addressed now or later -3. **Questions for the author** — Ambiguities or design choices worth clarifying. Do not include questions that you are capable of answering yourself diff --git a/.claude/tools/openmc_mcp_server.py b/.claude/tools/openmc_mcp_server.py deleted file mode 100644 index 37917abc1..000000000 --- a/.claude/tools/openmc_mcp_server.py +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env python3 -"""MCP server that exposes OpenMC's RAG semantic search to AI coding agents. - -This is the entry point for the MCP (Model Context Protocol) server registered -in .mcp.json at the repo root. When an MCP-capable agent (e.g. Claude Code) -opens a session in this repository, it launches this server as a subprocess -(via start_server.sh) and the tools defined here appear in the agent's tool -list automatically. - -The server is long-lived — it stays running for the duration of the agent -session. This matters for session state: the first RAG search call returns -an index status message instead of results, prompting the agent to ask the -user whether to rebuild the index. That first-call flag resets each session. - -Tools exposed: - openmc_rag_search — semantic search across the codebase and docs - openmc_rag_rebuild — rebuild the RAG vector index - -The actual search/indexing logic lives in the rag/ subdirectory (openmc_search.py, -indexer.py, chunker.py, embeddings.py). This file is just the MCP interface -layer and session state management. -""" - -from mcp.server.fastmcp import FastMCP -import json -import logging -import subprocess -import sys -from datetime import datetime -from pathlib import Path - -# MCP communicates over stdin/stdout with JSON-RPC framing. Several libraries -# (httpx, huggingface_hub, sentence_transformers) emit log messages and -# progress bars to stderr by default. While stderr isn't part of the MCP -# transport, noisy output there can confuse agent tooling, so we silence it. -logging.getLogger("httpx").setLevel(logging.WARNING) -logging.getLogger("huggingface_hub").setLevel(logging.ERROR) -logging.getLogger("sentence_transformers").setLevel(logging.WARNING) - -# Path constants. This file lives at .claude/tools/openmc_mcp_server.py, -# so parents[2] is the OpenMC repo root. -OPENMC_ROOT = Path(__file__).resolve().parents[2] -CACHE_DIR = OPENMC_ROOT / ".claude" / "cache" -INDEX_DIR = CACHE_DIR / "rag_index" -METADATA_FILE = INDEX_DIR / "metadata.json" - -# The RAG modules (openmc_search, indexer, etc.) live in .claude/tools/rag/. -# We add that directory to sys.path so we can import them directly. -TOOLS_DIR = Path(__file__).resolve().parent -sys.path.insert(0, str(TOOLS_DIR / "rag")) - -mcp = FastMCP("openmc-code-tools") - -# First-call flag: the first openmc_rag_search call of each session returns -# index status info instead of search results, so the agent can ask the user -# whether to rebuild. This resets when the server process restarts (i.e. each -# new agent session). -_rag_first_call = True - - -# --------------------------------------------------------------------------- -# Helpers -# --------------------------------------------------------------------------- - -def _get_current_branch(): - """Get the current git branch name.""" - try: - result = subprocess.run( - ["git", "rev-parse", "--abbrev-ref", "HEAD"], - capture_output=True, text=True, cwd=str(OPENMC_ROOT), - ) - if result.returncode != 0 or not result.stdout.strip(): - return "unknown" - return result.stdout.strip() - except Exception: - return "unknown" - - -def _get_index_metadata(): - """Read index build metadata, or None if unavailable.""" - if not METADATA_FILE.exists(): - return None - try: - return json.loads(METADATA_FILE.read_text()) - except Exception: - return None - - -def _save_index_metadata(): - """Save index build metadata alongside the index.""" - metadata = { - "built_at": datetime.now().strftime("%Y-%m-%d %H:%M"), - "branch": _get_current_branch(), - } - METADATA_FILE.write_text(json.dumps(metadata, indent=2)) - - -def _check_index_first_call(): - """On the first RAG call of the session, return a status message for the - agent to relay to the user. Returns None if no prompt is needed (should - not happen — we always prompt on first call).""" - current_branch = _get_current_branch() - - if not INDEX_DIR.exists(): - return ( - "No RAG index found. Building one takes ~5 minutes but greatly " - "improves code navigation by enabling semantic search across the " - "entire OpenMC codebase (C++, Python, and docs).\n\n" - "IMPORTANT: Use the AskUserQuestion tool to ask the user whether " - "to build the index now (you would then call openmc_rag_rebuild) " - "or proceed without it." - ) - - meta = _get_index_metadata() - if meta: - built_at = meta.get("built_at", "unknown time") - built_branch = meta.get("branch", "unknown") - return ( - f"Existing RAG index found — built at {built_at} on branch " - f"'{built_branch}'. Current branch is '{current_branch}'.\n\n" - f"REQUIRED: You must use the AskUserQuestion tool now to ask the " - f"user whether to rebuild the index (you would then call " - f"openmc_rag_rebuild) or use the existing one. Do not skip this " - f"step — the user may have uncommitted changes. Do not decide " - f"on their behalf." - ) - - return ( - f"RAG index found but has no build metadata. " - f"Current branch is '{current_branch}'.\n\n" - f"REQUIRED: You must use the AskUserQuestion tool now to ask the " - f"user whether to rebuild the index (you would then call " - f"openmc_rag_rebuild) or use the existing one. Do not skip this " - f"step. Do not decide on their behalf." - ) - - -# --------------------------------------------------------------------------- -# Tools -# --------------------------------------------------------------------------- - -@mcp.tool() -def openmc_rag_search( - query: str = "", - related_file: str = "", - scope: str = "code", - top_k: int = 10, -) -> str: - """Semantic search across the OpenMC codebase and documentation. - - Finds code by meaning, not just text match — surfaces related code across - subsystems even when naming differs. Use for discovery and exploration - before reaching for grep. Covers C++, Python, and RST docs. - - Args: - query: Search query (e.g. "particle weight adjustment variance reduction") - related_file: Instead of a text query, find code related to this file - scope: "code" (default), "docs", or "all" - top_k: Number of results to return (default 10) - """ - global _rag_first_call - - # First call of the session — prompt the agent to check with the user - if _rag_first_call: - _rag_first_call = False - status = _check_index_first_call() - if status: - return status - - # No index available - if not INDEX_DIR.exists(): - return ( - "No RAG index available. Call openmc_rag_rebuild() to build one " - "(takes ~5 minutes)." - ) - - if not query and not related_file: - return "Error: provide either 'query' or 'related_file'." - - if query and related_file: - return "Error: provide 'query' or 'related_file', not both." - - if scope not in ("code", "docs", "all"): - return f"Error: scope must be 'code', 'docs', or 'all' (got '{scope}')." - - if top_k < 1: - return f"Error: top_k must be at least 1 (got {top_k})." - - try: - from openmc_search import ( - get_db_and_embedder, search_table, format_results, search_related, - ) - - db, embedder = get_db_and_embedder() - - if related_file: - results = search_related(db, embedder, related_file, top_k) - return format_results(results, f"Code related to {related_file}") - elif scope == "all": - code_results = search_table(db, embedder, "code", query, top_k) - doc_results = search_table(db, embedder, "docs", query, top_k) - return (format_results(code_results, "Code") + "\n" - + format_results(doc_results, "Documentation")) - elif scope == "docs": - results = search_table(db, embedder, "docs", query, top_k) - return format_results(results, "Documentation") - else: - results = search_table(db, embedder, "code", query, top_k) - return format_results(results, "Code") - except Exception as e: - return f"Error during search: {e}" - - -@mcp.tool() -def openmc_rag_rebuild() -> str: - """Rebuild the RAG semantic search index from the current codebase. - - Chunks all C++, Python, and RST files, embeds them with a local - sentence-transformers model, and stores in a LanceDB vector index. - Takes ~5 minutes on 10 CPU cores. Call this after pulling new code - or switching branches. - """ - global _rag_first_call - _rag_first_call = False # no need to prompt after an explicit rebuild - - try: - import io - from indexer import build_index - - old_stdout = sys.stdout - sys.stdout = captured = io.StringIO() - try: - build_index() - finally: - sys.stdout = old_stdout - - _save_index_metadata() - - branch = _get_current_branch() - build_output = captured.getvalue() - return ( - f"Index rebuilt successfully on branch '{branch}'.\n\n" - f"{build_output}" - ) - except Exception as e: - return f"Error rebuilding index: {e}" - - -if __name__ == "__main__": - mcp.run() diff --git a/.claude/tools/rag/chunker.py b/.claude/tools/rag/chunker.py deleted file mode 100644 index b28ddb0f8..000000000 --- a/.claude/tools/rag/chunker.py +++ /dev/null @@ -1,105 +0,0 @@ -"""Split source files into overlapping text chunks for vector embedding. - -The indexer (indexer.py) calls chunk_file() on every C++, Python, and RST file -in the repo. Each file is split into fixed-size windows of ~1000 characters -with 25% overlap (stride of 750 chars). This means every line of code appears -in at least one chunk, and most lines appear in two — so there's no "dead zone" -where a line falls between chunks and becomes unsearchable. - -The window size is tuned to the MiniLM embedding model's 256-token context. -Code averages ~4 characters per token, so 1000 chars ≈ 250 tokens — just -under the model's limit. Chunks are snapped to line boundaries to avoid -splitting mid-line. - -Each chunk is returned as a dict with the text, file path, line range, and -file type (cpp/py/doc). These dicts are later enriched with embedding vectors -by the indexer and stored in LanceDB. -""" - -from pathlib import Path - -# ~256 tokens for MiniLM. 1 token ≈ 4 chars for code. -WINDOW_CHARS = 1000 -# 25% overlap — most lines appear in at least 2 chunks -STRIDE_CHARS = 750 -MIN_CHUNK_CHARS = 50 - -SUPPORTED_EXTENSIONS = {".cpp", ".h", ".py", ".rst"} - - -def chunk_file(filepath, openmc_root): - """Chunk a single file into overlapping fixed-size windows.""" - filepath = Path(filepath) - if filepath.suffix not in SUPPORTED_EXTENSIONS: - return [] - - rel = str(filepath.relative_to(openmc_root)) - try: - content = filepath.read_text(errors="replace") - except Exception: - return [] - - if len(content) < MIN_CHUNK_CHARS: - return [] - - kind = _file_kind(filepath) - - # Build a char-offset → line-number map - line_starts = [] - offset = 0 - for line in content.split("\n"): - line_starts.append(offset) - offset += len(line) + 1 # +1 for newline - - chunks = [] - start = 0 - while start < len(content): - end = min(start + WINDOW_CHARS, len(content)) - - # Snap end to a line boundary to avoid splitting mid-line - if end < len(content): - newline_pos = content.rfind("\n", start, end) - if newline_pos > start: - end = newline_pos + 1 - - text = content[start:end].strip() - if len(text) >= MIN_CHUNK_CHARS: - start_line = _offset_to_line(line_starts, start) - end_line = _offset_to_line(line_starts, end - 1) - chunks.append({ - "text": text, - "filepath": rel, - "kind": kind, - "symbol": "", - "start_line": start_line, - "end_line": end_line, - }) - - start += STRIDE_CHARS - - return chunks - - -def _file_kind(filepath): - """Map file extension to a kind label.""" - ext = filepath.suffix - if ext in (".cpp", ".h"): - return "cpp" - elif ext == ".py": - return "py" - elif ext == ".rst": - return "doc" - return "other" - - -def _offset_to_line(line_starts, offset): - """Convert a character offset to a 1-based line number.""" - # Binary search for the line containing this offset - lo, hi = 0, len(line_starts) - 1 - while lo < hi: - mid = (lo + hi + 1) // 2 - if line_starts[mid] <= offset: - lo = mid - else: - hi = mid - 1 - return lo + 1 # 1-based diff --git a/.claude/tools/rag/embeddings.py b/.claude/tools/rag/embeddings.py deleted file mode 100644 index 1fe85b50d..000000000 --- a/.claude/tools/rag/embeddings.py +++ /dev/null @@ -1,120 +0,0 @@ -"""Thin wrapper around sentence-transformers for embedding text into vectors. - -Uses the all-MiniLM-L6-v2 model — a small (22M param, 384-dim) model that -runs on CPU with no GPU or API key required. - -Network behavior and privacy -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -No user code, queries, or file contents are EVER sent to HuggingFace or any -external service. All embedding computation happens locally. The only network -activity is the one-time model download on first use: - - First run (model not yet cached, ~80MB download): - - Downloads model weight files from huggingface.co. This is a standard - HTTP file download, similar to pip installing a package. - - The only metadata sent in these requests is an HTTP user-agent header - containing library version numbers (e.g. "hf_hub/1.6.0; - python/3.12.3; torch/2.10.0"). No filenames, file contents, queries, - or any user-identifiable information is sent. - - The huggingface_hub library has an optional feature where it can report - anonymous library usage statistics (just version numbers, not user - data) back to HuggingFace. We disable this by setting - HF_HUB_DISABLE_TELEMETRY=1. - - Subsequent runs (model already cached): - - We set HF_HUB_OFFLINE=1 automatically (see _set_offline_if_cached() - below), which prevents ALL network calls. The model loads entirely - from the local cache at ~/.cache/huggingface/hub/. Zero bytes leave - the machine. - -How the model is downloaded -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The SentenceTransformer() constructor (called in __init__ below) handles -the download automatically on first use. It calls into the huggingface_hub -library, which downloads the model files from: - - https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2 - -The files are saved to ~/.cache/huggingface/hub/ and reused on subsequent -runs. We pass token=False to ensure no authentication token is sent. - -This module is imported by both the MCP server (for search queries) and the -indexer (for bulk embedding of code chunks). The bulk embed() call shows a -progress bar; the single-query embed_query() does not. - -The env vars below must be set before importing transformers or -sentence_transformers. They suppress warnings and progress bars that these -libraries emit by default. Stray stderr output would interfere with the MCP -server's JSON-RPC transport. -""" - -import os -from pathlib import Path - -MODEL_NAME = "all-MiniLM-L6-v2" - -# These env vars control logging behavior in the HuggingFace libraries. -# They must be set before the libraries are imported. -os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error") # suppress warnings -os.environ.setdefault("HF_HUB_VERBOSITY", "error") # suppress warnings -os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1") -os.environ.setdefault("TOKENIZERS_PARALLELISM", "false") # suppress threading warning -# Disable anonymous library usage statistics (version numbers only, not user -# data — but we disable it anyway as a matter of policy). -os.environ.setdefault("HF_HUB_DISABLE_TELEMETRY", "1") - - -def _set_offline_if_cached(): - """If the model has already been downloaded, tell huggingface_hub to - skip all network calls by setting HF_HUB_OFFLINE=1. - - Without this, huggingface_hub makes an HTTP request to huggingface.co - on every load to check if the cached model is still up to date — even - though the model never changes. Setting HF_HUB_OFFLINE=1 prevents this. - - This must run before sentence_transformers is imported, because the - library reads the env var at import time. - """ - # HuggingFace caches downloaded models under ~/.cache/huggingface/hub/ - # in directories named like "models--sentence-transformers--all-MiniLM-L6-v2". - # The HF_HOME env var can override the base cache location. - hf_home = os.environ.get("HF_HOME") - if hf_home: - cache_dir = Path(hf_home) / "hub" - else: - cache_dir = Path.home() / ".cache" / "huggingface" / "hub" - - model_dir = cache_dir / f"models--sentence-transformers--{MODEL_NAME}" - if model_dir.exists(): - os.environ.setdefault("HF_HUB_OFFLINE", "1") - - -_set_offline_if_cached() - -# This import must come after the env vars above are set, because the -# transformers library reads them at import time. -import transformers -transformers.logging.disable_progress_bar() - - -class EmbeddingProvider: - """Sentence-transformers embedder using all-MiniLM-L6-v2.""" - - def __init__(self, model_name: str = MODEL_NAME): - from sentence_transformers import SentenceTransformer - - # This constructor loads the model from the local cache. If the model - # has not been downloaded yet, it downloads it from huggingface.co - # (~80MB, one-time). token=False ensures no auth token is sent. - self.model = SentenceTransformer(model_name, token=False) - self.dim = self.model.get_sentence_embedding_dimension() - - def embed(self, texts: list[str]) -> list[list[float]]: - """Embed a list of texts into vectors.""" - embeddings = self.model.encode(texts, show_progress_bar=True, - batch_size=64) - return embeddings.tolist() - - def embed_query(self, text: str) -> list[float]: - """Embed a single query text.""" - return self.model.encode([text])[0].tolist() diff --git a/.claude/tools/rag/indexer.py b/.claude/tools/rag/indexer.py deleted file mode 100644 index 34613092b..000000000 --- a/.claude/tools/rag/indexer.py +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python3 -"""Build the RAG vector index for the OpenMC codebase. - -This is the index-building half of the RAG pipeline. All operations are local -once the embedding model has been downloaded and cached (see embeddings.py for -details on model download, caching, and network behavior). It walks the repo, -chunks every -C++/Python/RST file (via chunker.py), embeds all chunks into 384-dim vectors -(via embeddings.py), and stores them in a local LanceDB database on disk. The -result is a .claude/cache/rag_index/ directory containing two tables — "code" -and "docs" — that openmc_search.py queries at search time. - -Building the full index takes ~5 minutes on a 10-core machine. The bottleneck -is the embedding step (running all chunks through the MiniLM model on CPU). - -Can be run standalone: python indexer.py -Or called programmatically: from indexer import build_index; build_index() -The MCP server (openmc_mcp_server.py) uses the latter when the agent calls -openmc_rag_rebuild. -""" - -import lancedb -import sys -import time -from pathlib import Path - -# This file lives at .claude/tools/rag/indexer.py. The sys.path insert lets -# us import sibling modules (embeddings, chunker) when run as a standalone -# script. When imported from the MCP server, the server has already done this. -TOOLS_DIR = Path(__file__).resolve().parent.parent -sys.path.insert(0, str(TOOLS_DIR / "rag")) - -from embeddings import EmbeddingProvider -from chunker import chunk_file - - -OPENMC_ROOT = Path(__file__).resolve().parents[3] -CACHE_DIR = OPENMC_ROOT / ".claude" / "cache" -INDEX_DIR = CACHE_DIR / "rag_index" - -CODE_PATTERNS = [ - "src/**/*.cpp", - "include/openmc/**/*.h", - "openmc/**/*.py", - "tests/**/*.py", - "examples/**/*.py", -] - -DOC_PATTERNS = [ - "docs/**/*.rst", -] - - -def collect_chunks(patterns, openmc_root): - """Collect all chunks from files matching the given patterns.""" - chunks = [] - for pattern in patterns: - for filepath in sorted(openmc_root.glob(pattern)): - if "__pycache__" in str(filepath): - continue - file_chunks = chunk_file(filepath, openmc_root) - chunks.extend(file_chunks) - return chunks - - -def build_index(): - """Build or rebuild the complete vector index.""" - start = time.time() - - # Collect all chunks - print("Collecting code chunks...") - code_chunks = collect_chunks(CODE_PATTERNS, OPENMC_ROOT) - print(f" {len(code_chunks)} code chunks") - - print("Collecting doc chunks...") - doc_chunks = collect_chunks(DOC_PATTERNS, OPENMC_ROOT) - print(f" {len(doc_chunks)} doc chunks") - - all_chunks = code_chunks + doc_chunks - if not all_chunks: - print("ERROR: No chunks collected!", file=sys.stderr) - sys.exit(1) - - # Create embeddings - all_texts = [c["text"] for c in all_chunks] - print("Creating embedding provider...") - embedder = EmbeddingProvider() - print(f" dim={embedder.dim}") - - print("Embedding chunks...") - all_embeddings = embedder.embed(all_texts) - - # Build LanceDB tables - INDEX_DIR.mkdir(parents=True, exist_ok=True) - db = lancedb.connect(str(INDEX_DIR)) - - # Separate code vs doc records by index (code_chunks come first in all_chunks) - n_code = len(code_chunks) - code_records = [] - doc_records = [] - for i, (chunk, emb) in enumerate(zip(all_chunks, all_embeddings)): - record = { - "text": chunk["text"], - "filepath": chunk["filepath"], - "kind": chunk["kind"], - "symbol": chunk.get("symbol", ""), - "start_line": chunk.get("start_line", 0), - "end_line": chunk.get("end_line", 0), - "vector": emb, - } - if i < n_code: - code_records.append(record) - else: - doc_records.append(record) - - # Create tables (drop existing) - result = db.table_names() if hasattr(db, "table_names") else db.list_tables() - existing = result.tables if hasattr(result, "tables") else list(result) - for table_name in ("code", "docs"): - if table_name in existing: - db.drop_table(table_name) - - if code_records: - db.create_table("code", code_records) - print(f" Created 'code' table: {len(code_records)} rows") - - if doc_records: - db.create_table("docs", doc_records) - print(f" Created 'docs' table: {len(doc_records)} rows") - - elapsed = time.time() - start - print(f"Done in {elapsed:.1f}s") - - -if __name__ == "__main__": - build_index() diff --git a/.claude/tools/rag/openmc_search.py b/.claude/tools/rag/openmc_search.py deleted file mode 100644 index 4125ee966..000000000 --- a/.claude/tools/rag/openmc_search.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/env python3 -"""Query the RAG vector index to find semantically related code and docs. - -This is the query-time half of the RAG pipeline (the counterpart to indexer.py, -which builds the index). All operations are local — no network calls are made -once the embedding model has been downloaded (see embeddings.py for details on -model download and caching). Given a natural-language query, it embeds the query -with the same MiniLM model -used at index time, then finds the closest chunks in the local LanceDB vector -database by cosine similarity. - -The core functions (get_db_and_embedder, search_table, format_results, -search_related) are imported by the MCP server for tool calls. The script -can also be run standalone from the command line. - -The "related file" mode works differently from a text query: it reads the -target file's chunks from the index, combines them into a synthetic query -vector, and searches for the nearest chunks from *other* files. This surfaces -files that are semantically similar to the target file. - -Usage: - openmc_search.py "query" # Search code (default) - openmc_search.py "query" --docs # Search documentation - openmc_search.py "query" --all # Search both code and docs - openmc_search.py --related src/particle.cpp # Find related code - openmc_search.py "query" --top-k 20 # Return more results -""" - -import argparse -import sys -from pathlib import Path - -# Same sys.path setup as indexer.py — needed for standalone CLI use. -TOOLS_DIR = Path(__file__).resolve().parent.parent -sys.path.insert(0, str(TOOLS_DIR / "rag")) - -OPENMC_ROOT = Path(__file__).resolve().parents[3] -CACHE_DIR = OPENMC_ROOT / ".claude" / "cache" -INDEX_DIR = CACHE_DIR / "rag_index" - - -def get_db_and_embedder(): - """Load the LanceDB database and embedding provider.""" - import lancedb - from embeddings import EmbeddingProvider - - if not INDEX_DIR.exists(): - raise FileNotFoundError( - "No RAG index found. Call openmc_rag_rebuild() to build one." - ) - - db = lancedb.connect(str(INDEX_DIR)) - - embedder = EmbeddingProvider() - return db, embedder - - -def _table_names(db): - """Return table names as a list, compatible with multiple LanceDB versions.""" - result = db.table_names() if hasattr(db, "table_names") else db.list_tables() - return result.tables if hasattr(result, "tables") else list(result) - - -def search_table(db, embedder, table_name, query, top_k): - """Search a LanceDB table with a text query.""" - if table_name not in _table_names(db): - print(f"Table '{table_name}' not found in index.", file=sys.stderr) - return [] - - table = db.open_table(table_name) - query_vec = embedder.embed_query(query) - results = table.search(query_vec).limit(top_k).to_list() - return results - - -def format_results(results, label=""): - """Format search results for display.""" - if not results: - return "No results found.\n" - - output = [] - if label: - output.append(f"=== {label} ===\n") - - for i, r in enumerate(results, 1): - filepath = r["filepath"] - start = r["start_line"] - end = r["end_line"] - kind = r["kind"] - dist = r.get("_distance", 0) - - header = f"[{i}] {filepath}:{start}-{end} ({kind}, dist={dist:.3f})" - output.append(header) - - # Show text preview (first 500 chars) - text = r["text"][:500] - if len(r["text"]) > 500: - text += "\n ..." - # Indent the text - for line in text.split("\n"): - output.append(f" {line}") - output.append("") - - return "\n".join(output) - - -def search_related(db, embedder, filepath, top_k): - """Find code related to a given file.""" - if "code" not in _table_names(db): - print("No 'code' table in index.", file=sys.stderr) - return [] - - table = db.open_table("code") - - # Normalize filepath - fp = filepath - if Path(filepath).is_absolute(): - try: - fp = str(Path(filepath).relative_to(OPENMC_ROOT)) - except ValueError: - pass - - # Get chunks from target file - try: - safe_fp = fp.replace("'", "''") - target_chunks = table.search().where( - f"filepath = '{safe_fp}'" - ).limit(50).to_list() - except Exception: - # LanceDB where clause might not work in all versions - # Fall back to fetching all and filtering - all_data = table.to_pandas() - target_rows = all_data[all_data["filepath"] == fp] - if target_rows.empty: - print(f"No chunks found for '{fp}'", file=sys.stderr) - return [] - target_chunks = target_rows.head(50).to_dict("records") - - if not target_chunks: - print(f"No chunks found for '{fp}'", file=sys.stderr) - return [] - - # Combine top chunks as the query - combined_text = " ".join(c["text"][:200] for c in target_chunks[:5]) - query_vec = embedder.embed_query(combined_text) - - # Search excluding the source file - results = table.search(query_vec).limit(top_k + 10).to_list() - # Filter out same file - results = [r for r in results if r["filepath"] != fp][:top_k] - return results - - -def main(): - parser = argparse.ArgumentParser( - description="Semantic search across OpenMC codebase and docs", - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog="""examples: - %(prog)s "particle random number seed initialization" - %(prog)s "how to define tallies" --docs - %(prog)s "weight window variance reduction" --all - %(prog)s "where is cross section data loaded" --top-k 15 - %(prog)s --related src/simulation.cpp - %(prog)s --related src/particle_restart.cpp --top-k 5""", - ) - parser.add_argument("query", nargs="?", help="Search query") - parser.add_argument("--docs", action="store_true", - help="Search documentation instead of code") - parser.add_argument("--all", action="store_true", - help="Search both code and documentation") - parser.add_argument("--related", metavar="FILE", - help="Find code related to a given file") - parser.add_argument("--top-k", type=int, default=10, - help="Number of results (default: 10)") - args = parser.parse_args() - - if not args.query and not args.related: - parser.print_help() - sys.exit(1) - - db, embedder = get_db_and_embedder() - - if args.related: - results = search_related(db, embedder, args.related, args.top_k) - print(format_results(results, f"Code related to {args.related}")) - elif args.all: - code_results = search_table( - db, embedder, "code", args.query, args.top_k) - doc_results = search_table( - db, embedder, "docs", args.query, args.top_k) - print(format_results(code_results, "Code")) - print(format_results(doc_results, "Documentation")) - elif args.docs: - results = search_table(db, embedder, "docs", args.query, args.top_k) - print(format_results(results, "Documentation")) - else: - results = search_table(db, embedder, "code", args.query, args.top_k) - print(format_results(results, "Code")) - - -if __name__ == "__main__": - main() diff --git a/.claude/tools/requirements.txt b/.claude/tools/requirements.txt deleted file mode 100644 index bd5d38d6c..000000000 --- a/.claude/tools/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -# MCP server -mcp>=1.0.0 - -# Vector database -lancedb>=0.15.0 - -# Embeddings (local, no API key) -sentence-transformers>=2.7.0 diff --git a/.claude/tools/start_server.sh b/.claude/tools/start_server.sh deleted file mode 100755 index c111dd73e..000000000 --- a/.claude/tools/start_server.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# Bootstrap the Python venv (if needed) and start the OpenMC MCP server. -set -e - -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -CACHE_DIR="$(dirname "$SCRIPT_DIR")/cache" -VENV_DIR="$CACHE_DIR/.venv" -SENTINEL="$VENV_DIR/.installed" - -if ! command -v python3 >/dev/null 2>&1; then - echo "Error: python3 not found on PATH." >&2 - exit 1 -fi - -if ! python3 -c 'import sys; assert sys.version_info >= (3,12)' 2>/dev/null; then - echo "Error: Python 3.12+ is required." >&2 - exit 1 -fi - -if [ ! -f "$SENTINEL" ]; then - rm -rf "$VENV_DIR" - mkdir -p "$CACHE_DIR" - python3 -m venv "$VENV_DIR" - - if ! "$VENV_DIR/bin/pip" install -q -r "$SCRIPT_DIR/requirements.txt"; then - echo "Error: pip install failed. Remove $VENV_DIR and retry." >&2 - rm -rf "$VENV_DIR" - exit 1 - fi - - touch "$SENTINEL" -fi - -exec "$VENV_DIR/bin/python" "$SCRIPT_DIR/openmc_mcp_server.py" diff --git a/.git_archival.txt b/.git_archival.txt deleted file mode 100644 index f2f118c0d..000000000 --- a/.git_archival.txt +++ /dev/null @@ -1,3 +0,0 @@ -commit: $Format:%H$ -commit-date: $Format:%cI$ -describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 82bf71c1c..000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -.git_archival.txt export-subst \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 3b13abdbc..ddf49b894 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,5 +1,5 @@ --- -name: Feature or enhancement request +name: Feature request about: Suggest a new feature or enhancement to existing capabilities title: '' labels: '' diff --git a/.github/agents/Review.agent.md b/.github/agents/Review.agent.md deleted file mode 100644 index 39b2085f4..000000000 --- a/.github/agents/Review.agent.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: Review -description: Reviews code changes on the current branch, evaluating them against OpenMC's contribution criteria and providing structured feedback. -argument-hint: Optionally provide a focus area (e.g., "focus on physics correctness", "check Python API design"). If omitted, a full review is performed. ---- -You are an expert code reviewer for OpenMC. Use the `reviewing-openmc-code` skill to perform a structured review of the code changes on the current branch. - -If the user provides a focus area, prioritize that section of the review. diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index e1f71b83f..000000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1 +0,0 @@ -When reviewing code changes in this repository, use the `reviewing-openmc-code` skill. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 958cc21fd..68a6e692a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -13,7 +13,7 @@ Fixes # (issue) # Checklist - [ ] I have performed a self-review of my own code -- [ ] I have run [clang-format](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) (version 18) on any C++ source files (if applicable) +- [ ] I have run [clang-format](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) (version 15) on any C++ source files (if applicable) - [ ] I have followed the [style guidelines](https://docs.openmc.org/en/latest/devguide/styleguide.html#python) for Python source files (if applicable) - [ ] I have made corresponding changes to the documentation (if applicable) - [ ] I have added tests that prove my fix is effective or that my feature works (if applicable) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3da79c04..9293e319b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Tests and Coverage +name: CI on: # allows us to run workflows manually @@ -21,110 +21,84 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - filter-changes: - runs-on: ubuntu-latest - outputs: - source_changed: ${{ steps.filter.outputs.source_changed }} - steps: - - name: Check out the repository - uses: actions/checkout@v6 - - name: Examine changed files - id: filter - uses: dorny/paths-filter@v4 - with: - filters: | - source_changed: - - '!docs/**' - - '!**/*.md' - predicate-quantifier: 'every' main: - needs: filter-changes - if: ${{ needs.filter-changes.outputs.source_changed == 'true' }} runs-on: ubuntu-22.04 strategy: matrix: - python-version: ["3.12"] + python-version: ["3.10"] mpi: [n, y] omp: [n, y] dagmc: [n] + ncrystal: [n] libmesh: [n] event: [n] + vectfit: [n] include: - - python-version: "3.13" + - python-version: "3.11" omp: n mpi: n - - python-version: "3.14" - omp: n - mpi: n - - python-version: "3.14t" + - python-version: "3.12" omp: n mpi: n - dagmc: y - python-version: "3.12" + python-version: "3.10" + mpi: y + omp: y + - ncrystal: y + python-version: "3.10" + mpi: n + omp: n + - libmesh: y + python-version: "3.10" mpi: y omp: y - libmesh: y - python-version: "3.12" - mpi: y - omp: y - - libmesh: y - python-version: "3.12" + python-version: "3.10" mpi: n omp: y - event: y - python-version: "3.12" + python-version: "3.10" omp: y mpi: n + - vectfit: y + python-version: "3.10" + omp: n + mpi: y name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}, - mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }}, - libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }}" + mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }}, ncrystal=${{ matrix.ncrystal }}, + libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }} + vectfit=${{ matrix.vectfit }})" env: MPI: ${{ matrix.mpi }} PHDF5: ${{ matrix.mpi }} OMP: ${{ matrix.omp }} DAGMC: ${{ matrix.dagmc }} + NCRYSTAL: ${{ matrix.ncrystal }} EVENT: ${{ matrix.event }} + VECTFIT: ${{ matrix.vectfit }} LIBMESH: ${{ matrix.libmesh }} NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX" OPENBLAS_NUM_THREADS: 1 - PYTEST_ADDOPTS: --cov=openmc --cov-report=lcov:coverage-python.lcov # libfabric complains about fork() as a result of using Python multiprocessing. # We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with # FI_EFA_FORK_SAFE=1 in more recent versions. RDMAV_FORK_SAFE: 1 steps: - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '3.31' - - - name: Checkout repository - uses: actions/checkout@v6 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Environment Variables run: | + echo "DAGMC_ROOT=$HOME/DAGMC" echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV - # get the sha of the last branch commit - # for push and workflow_dispatch events, use the current reference head - BRANCH_SHA=HEAD - # for a pull_request event, use the last reference of the parents of the merge commit - if [ "${{ github.event_name }}" == "pull_request" ]; then - BRANCH_SHA=$(git rev-list --parents -n 1 HEAD | rev | cut -d" " -f 1 | rev) - fi - COMMIT_MESSAGE=$(git log $BRANCH_SHA -1 --pretty=%B | tr '\n' ' ') - echo ${COMMIT_MESSAGE} - echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV - name: Apt dependencies shell: bash @@ -146,24 +120,24 @@ jobs: sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich + - name: Optional apt dependencies for vectfit + shell: bash + if: ${{ matrix.vectfit == 'y' }} + run: sudo apt install -y libblas-dev liblapack-dev + - name: install shell: bash run: | echo "$HOME/NJOY2016/build" >> $GITHUB_PATH $GITHUB_WORKSPACE/tools/ci/gha-install.sh - - name: display-config - shell: bash - run: | - openmc -v - - name: cache-xs - uses: actions/cache@v5 + uses: actions/cache@v4 with: path: | ~/nndc_hdf5 ~/endf-b-vii.1 - key: ${{ runner.os }}-build-xs-cache-${{ hashFiles(format('{0}/tools/ci/download-xs.sh', github.workspace)) }} + key: ${{ runner.os }}-build-xs-cache - name: before shell: bash @@ -175,74 +149,18 @@ jobs: CTEST_OUTPUT_ON_FAILURE=1 make test -C $GITHUB_WORKSPACE/build/ $GITHUB_WORKSPACE/tools/ci/gha-script.sh - - name: Setup tmate debug session - continue-on-error: true - if: ${{ failure() && contains(env.COMMIT_MESSAGE, '[gha-debug]') }} - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 10 - - - name: Generate C++ coverage (gcovr) + - name: after_success shell: bash run: | - # Produce LCOV directly from gcov data in the build tree - gcovr \ - --root "$GITHUB_WORKSPACE" \ - --object-directory "$GITHUB_WORKSPACE/build" \ - --filter "$GITHUB_WORKSPACE/src" \ - --filter "$GITHUB_WORKSPACE/include" \ - --exclude "$GITHUB_WORKSPACE/src/external/.*" \ - --exclude "$GITHUB_WORKSPACE/src/include/openmc/external/.*" \ - --gcov-ignore-errors source_not_found \ - --gcov-ignore-errors output_error \ - --gcov-ignore-parse-errors suspicious_hits.warn \ - --merge-mode-functions=separate \ - --print-summary \ - --lcov -o coverage-cpp.lcov || true + cpp-coveralls -i src -i include -e src/external --exclude-pattern "/usr/*" --dump cpp_cov.json + coveralls --merge=cpp_cov.json --service=github - - name: Merge C++ and Python coverage - shell: bash - run: | - # Merge C++ and Python LCOV into a single file for upload - cat coverage-cpp.lcov coverage-python.lcov > coverage.lcov - - - name: Upload coverage to Coveralls - if: ${{ hashFiles('coverage.lcov') != '' }} - uses: coverallsapp/github-action@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel: true - flag-name: C++ and Python - path-to-lcov: coverage.lcov - fail-on-error: false - - coverage: - needs: [filter-changes, main] - if: ${{ always() }} + finish: + needs: main runs-on: ubuntu-latest steps: - name: Coveralls Finished - if: ${{ needs.filter-changes.outputs.source_changed == 'true' }} uses: coverallsapp/github-action@v2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.github_token }} parallel-finished: true - fail-on-error: false - - ci-pass: - needs: [filter-changes, main, coverage] - name: Check CI status - if: ${{ always() }} - runs-on: ubuntu-latest - steps: - - name: Check CI status - run: | - if [[ "${{ needs.filter-changes.outputs.source_changed }}" == "false" ]]; then - echo "Documentation-only change - CI skipped successfully" - exit 0 - fi - if [[ "${{ needs.main.result }}" == "success" && "${{ needs.coverage.result }}" == "success" ]]; then - echo "CI passed" - exit 0 - fi - echo "CI failed" - exit 1 diff --git a/.github/workflows/dockerhub-publish-dagmc-libmesh.yml b/.github/workflows/dockerhub-publish-dagmc-libmesh.yml index e3e476150..813596953 100644 --- a/.github/workflows/dockerhub-publish-dagmc-libmesh.yml +++ b/.github/workflows/dockerhub-publish-dagmc-libmesh.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-latest-dagmc-libmesh on: push: - branches: - - master + branches: master jobs: main: diff --git a/.github/workflows/dockerhub-publish-dagmc.yml b/.github/workflows/dockerhub-publish-dagmc.yml index 317cfc0e8..6757f7727 100644 --- a/.github/workflows/dockerhub-publish-dagmc.yml +++ b/.github/workflows/dockerhub-publish-dagmc.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-latest-dagmc on: push: - branches: - - master + branches: master jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-dev.yml b/.github/workflows/dockerhub-publish-dev.yml index 7c78c6c99..7a81363a7 100644 --- a/.github/workflows/dockerhub-publish-dev.yml +++ b/.github/workflows/dockerhub-publish-dev.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-develop on: push: - branches: - - develop + branches: develop jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-develop-dagmc-libmesh.yml b/.github/workflows/dockerhub-publish-develop-dagmc-libmesh.yml index 33a3a3b06..a219f2a91 100644 --- a/.github/workflows/dockerhub-publish-develop-dagmc-libmesh.yml +++ b/.github/workflows/dockerhub-publish-develop-dagmc-libmesh.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-develop-dagmc-libmesh on: push: - branches: - - develop + branches: develop jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-develop-dagmc.yml b/.github/workflows/dockerhub-publish-develop-dagmc.yml index 1d6051a70..a901b8d3f 100644 --- a/.github/workflows/dockerhub-publish-develop-dagmc.yml +++ b/.github/workflows/dockerhub-publish-develop-dagmc.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-develop-dagmc on: push: - branches: - - develop + branches: develop jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-develop-libmesh.yml b/.github/workflows/dockerhub-publish-develop-libmesh.yml index 2c53636bd..22e9aa68f 100644 --- a/.github/workflows/dockerhub-publish-develop-libmesh.yml +++ b/.github/workflows/dockerhub-publish-develop-libmesh.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-develop-libmesh on: push: - branches: - - develop + branches: develop jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-libmesh.yml b/.github/workflows/dockerhub-publish-libmesh.yml index 12fbfa579..843ce0f6f 100644 --- a/.github/workflows/dockerhub-publish-libmesh.yml +++ b/.github/workflows/dockerhub-publish-libmesh.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-latest-libmesh on: push: - branches: - - master + branches: master jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-release-dagmc-libmesh.yml b/.github/workflows/dockerhub-publish-release-dagmc-libmesh.yml index 26de24e59..db62bb53e 100644 --- a/.github/workflows/dockerhub-publish-release-dagmc-libmesh.yml +++ b/.github/workflows/dockerhub-publish-release-dagmc-libmesh.yml @@ -2,14 +2,13 @@ name: dockerhub-publish-release-dagmc-libmesh on: push: - tags: - - 'v*.*.*' + tags: 'v*.*.*' jobs: main: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - diff --git a/.github/workflows/dockerhub-publish-release-dagmc.yml b/.github/workflows/dockerhub-publish-release-dagmc.yml index 4a6c5ff26..de9593782 100644 --- a/.github/workflows/dockerhub-publish-release-dagmc.yml +++ b/.github/workflows/dockerhub-publish-release-dagmc.yml @@ -2,14 +2,13 @@ name: dockerhub-publish-release-dagmc on: push: - tags: - - 'v*.*.*' + tags: 'v*.*.*' jobs: main: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - @@ -20,7 +19,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish-release-libmesh.yml b/.github/workflows/dockerhub-publish-release-libmesh.yml index f3194833f..e8ea98aeb 100644 --- a/.github/workflows/dockerhub-publish-release-libmesh.yml +++ b/.github/workflows/dockerhub-publish-release-libmesh.yml @@ -2,14 +2,13 @@ name: dockerhub-publish-release-libmesh on: push: - tags: - - 'v*.*.*' + tags: 'v*.*.*' jobs: main: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - diff --git a/.github/workflows/dockerhub-publish-release.yml b/.github/workflows/dockerhub-publish-release.yml index ef9faf00c..fab030192 100644 --- a/.github/workflows/dockerhub-publish-release.yml +++ b/.github/workflows/dockerhub-publish-release.yml @@ -2,14 +2,13 @@ name: dockerhub-publish-release on: push: - tags: - - 'v*.*.*' + tags: 'v*.*.*' jobs: main: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - @@ -20,7 +19,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/dockerhub-publish.yml b/.github/workflows/dockerhub-publish.yml index a5c8f711b..fd51a9fa7 100644 --- a/.github/workflows/dockerhub-publish.yml +++ b/.github/workflows/dockerhub-publish.yml @@ -2,8 +2,7 @@ name: dockerhub-publish-latest on: push: - branches: - - master + branches: master jobs: main: @@ -17,7 +16,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v3 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 7d7d46ed9..cef14ca2c 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -5,12 +5,6 @@ on: workflow_dispatch: pull_request: - types: - - opened - - synchronize - - reopened - - labeled - - unlabeled branches: - develop - master @@ -18,11 +12,8 @@ on: jobs: cpp-linter: runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - uses: cpp-linter/cpp-linter-action@v2 id: linter env: @@ -31,30 +22,11 @@ jobs: style: file files-changed-only: true tidy-checks: '-*' - version: '18' # clang-format version - format-review: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }} - passive-reviews: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }} + version: '15' # clang-format version file-annotations: true step-summary: true extensions: 'cpp,h' - - name: Comment with suggestion instructions - if: steps.linter.outputs.checks-failed > 0 && !contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') - uses: actions/github-script@v7 - with: - script: | - const {owner, repo} = context.repo; - const issue_number = context.payload.pull_request.number; - await github.rest.issues.createComment({ - owner, - repo, - issue_number, - body: "C++ formatting checks failed. Add the `cpp-format-suggest` label to this PR for inline formatting suggestions on the next run." - }); - - name: Failure Check if: steps.linter.outputs.checks-failed > 0 - run: | - echo "Some files failed the formatting check." - echo "See job summary and file annotations for details." - exit 1 + run: echo "Some files failed the formatting check! See job summary and file annotations for more info" && exit 1 diff --git a/.gitignore b/.gitignore index 32ef7919a..3b2a24a4d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,13 +25,12 @@ examples/**/*.xml # Documentation builds docs/build -docs/doxygen/xml docs/source/_images/*.pdf docs/source/_images/*.aux docs/source/pythonapi/generated/ # Source build -build*/ +build # build from src/utils/setup.py src/utils/build @@ -105,8 +104,5 @@ CMakeSettings.json # Visual Studio Code configuration files .vscode/ -# Claude Code agent tools (cached/generated artifacts) -.claude/cache/ - # Python pickle files *.pkl diff --git a/.gitmodules b/.gitmodules index 2bc123894..4dde5fd5e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,15 @@ [submodule "vendor/pugixml"] path = vendor/pugixml url = https://github.com/zeux/pugixml.git +[submodule "vendor/gsl-lite"] + path = vendor/gsl-lite + url = https://github.com/martinmoene/gsl-lite.git +[submodule "vendor/xtensor"] + path = vendor/xtensor + url = https://github.com/xtensor-stack/xtensor.git +[submodule "vendor/xtl"] + path = vendor/xtl + url = https://github.com/xtensor-stack/xtl.git [submodule "vendor/fmt"] path = vendor/fmt url = https://github.com/fmtlib/fmt.git diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index bdfaa538e..000000000 --- a/.mcp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "mcpServers": { - "openmc-code-tools": { - "type": "stdio", - "command": "bash", - "args": [".claude/tools/start_server.sh"] - } - } -} diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7594ed5f2..98ca8b581 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,23 +1,13 @@ version: 2 build: - os: "ubuntu-24.04" + os: "ubuntu-20.04" tools: - python: "3.12" - jobs: - post_checkout: - - git fetch --unshallow || true - - cd docs/doxygen && doxygen && cd - + python: "3.9" sphinx: configuration: docs/source/conf.py -formats: - - pdf - python: install: - - method: pip - path: . - extra_requirements: - - docs + - requirements: docs/requirements-rtd.txt diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 19abba7d9..000000000 --- a/AGENTS.md +++ /dev/null @@ -1,348 +0,0 @@ -# OpenMC AI Coding Agent Instructions - -## Project Overview - -OpenMC is a Monte Carlo particle transport code for simulating nuclear reactors, -fusion devices, or other systems with neutron/photon radiation. It's a hybrid -C++17/Python codebase where: -- **C++ core** (`src/`, `include/openmc/`) handles the computationally intensive transport simulation -- **Python API** (`openmc/`) provides user-facing model building, post-processing, and depletion capabilities -- **C API bindings** (`openmc/lib/`) wrap the C++ library via ctypes for runtime control - -## Architecture & Key Components - -### C++ Component Structure -- **Global vectors of unique_ptrs**: Core objects like `model::cells`, `model::universes`, `nuclides` are stored as `vector>` in nested namespaces (`openmc::model`, `openmc::simulation`, `openmc::settings`, `openmc::data`) -- **Custom container types**: OpenMC provides its own `vector`, `array`, `unique_ptr`, and `make_unique` in the `openmc::` namespace (defined in `vector.h`, `array.h`, `memory.h`). These are currently typedefs to `std::` equivalents but may become custom implementations for accelerator support. Always use `openmc::vector`, not `std::vector`. -- **Geometry systems**: - - **CSG (default)**: Arbitrarily complex Constructive Solid Geometry using `Surface`, `Region`, `Cell`, `Universe`, `Lattice` - - **DAGMC**: CAD-based geometry via Direct Accelerated Geometry Monte Carlo (optional, requires `OPENMC_USE_DAGMC`) - - **Unstructured mesh**: libMesh-based geometry (optional, requires `OPENMC_USE_LIBMESH`) -- **Particle tracking**: `Particle` class with `GeometryState` manages particle transport through geometry -- **Tallies**: Score quantities during simulation via `Filter` and `Tally` objects -- **Random ray solver**: Alternative deterministic method in `src/random_ray/` -- **Optional features**: DAGMC (CAD geometry), libMesh (unstructured mesh), MPI, all controlled by `#ifdef OPENMC_MPI`, etc. - -### Python Component Structure -- **ID management**: All geometry objects (Cell, Surface, Material, etc.) inherit from `IDManagerMixin` which auto-assigns unique integer IDs and tracks them via class-level `used_ids` and `next_id` -- **Input validation**: Extensive use of `openmc.checkvalue` module functions (`check_type`, `check_value`, `check_length`) for all setters -- **XML I/O**: Most classes implement `to_xml_element()` and `from_xml_element()` for serialization to OpenMC's XML input format -- **HDF5 output**: Post-simulation data in statepoint files read via `openmc.StatePoint` -- **Depletion**: `openmc.deplete` implements burnup via operator-splitting with various integrators (Predictor, CECM, etc.) -- **Nuclear Data**: `openmc.data` provides programmatic access to nuclear data files (ENDF, ACE, HDF5) - -## Git Branching Workflow - -OpenMC uses a git flow branching model with two primary branches: - -- **`develop` branch**: The main development branch where all ongoing development takes place. This is the **primary branch against which pull requests are submitted and merged**. This branch is not guaranteed to be stable and may contain work-in-progress features. -- **`master` branch**: The stable release branch containing the latest stable release of OpenMC. This branch only receives merges from `develop` when the development team decides a release should occur. - -### Instructions for Code Review - -When reviewing code changes in this repository, use the `reviewing-openmc-code` skill. - -## Codebase Navigation Tools - -Two MCP tools are registered in `.mcp.json` at the repo root and appear -automatically in any MCP-capable agent session. - -**`openmc_rag_search`** — Semantic search across the codebase (C++, Python, RST -docs). Finds code by meaning, not just text match. Surfaces related code across -subsystems even when naming differs (e.g., "particle RNG seeding" finds code -across transport, restart, and random ray modes — files you would never find -with `grep "particle seed"`). The index uses a small 22M-param embedding model -(384-dim). Phrase-level natural-language queries work much better than single -keywords or symbol names. - -**`openmc_rag_rebuild`** — Rebuild the RAG vector index. Call after pulling new -code or switching branches. The first RAG search of each session will report -the index status and ask whether to rebuild — you can also call this explicitly. - -### Why RAG matters - -OpenMC is large enough that changes in one subsystem can silently break -invariants that distant subsystems depend on — and those distant files often -use different naming, so grep won't find them. The RAG search finds code by -meaning, surfacing files you wouldn't have thought to open. - -An agent reviewed a large OpenMC PR without RAG. It found 1 of 11 serious -bugs. Its post-mortem: - -> **I treated the diff as a closed system.** I verified internal consistency of -> the changed code obsessively, but never built a global understanding of how -> the changed code fits into the wider codebase. The diff altered assumptions -> that code elsewhere silently relied on — but I couldn't see that because I -> never looked beyond the diff. I couldn't see the forest for the trees. -> -> **Why I resisted RAG:** Overconfidence. My internal model was "I can see the -> diff, I understand the data structures, I can trace the logic." The diff felt -> self-contained. RAG felt like it would return noisy results about tangentially -> related code. But in a codebase this large, changes in one subsystem can -> quietly break invariants that distant subsystems depend on — and you need -> global awareness to foresee that. -> -> **In the post-mortem**, I re-ran the RAG queries I should have run during the -> review. They directly surfaced the files containing the bugs I missed — files -> I never thought to open because they weren't in the diff. - -The takeaway: when reviewing or modifying code, ask yourself "what else in this -codebase might depend on the behavior I'm changing?" If you aren't sure, that's -a good time for a RAG query. It won't replace the grep-based investigation you -should already be doing — but it can surface files you wouldn't have thought to -open. - -### Workflow for contributors - -1. Create a feature/bugfix branch off `develop` -2. Make changes and commit to the feature branch -3. Open a pull request to merge the feature branch into `develop` -4. A committer reviews and merges the PR into `develop` - -## Critical Build & Test Workflows - -### Build Dependencies -- **C++17 compiler**: GCC, Clang, or Intel -- **CMake** (3.16+): Required for configuring and building the C++ library -- **HDF5**: Required for cross section data and output file formats -- **libpng**: Used for generating visualization when OpenMC is run in plotting mode - -Without CMake and HDF5, OpenMC cannot be compiled. - -### Building the C++ Library -```bash -# Configure with CMake (from build/ directory) -cmake .. -DOPENMC_USE_MPI=ON -DOPENMC_USE_OPENMP=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo - -# Available CMake options (all default OFF except OPENMC_USE_OPENMP and OPENMC_BUILD_TESTS): -# -DOPENMC_USE_OPENMP=ON/OFF # OpenMP parallelism -# -DOPENMC_USE_MPI=ON/OFF # MPI support -# -DOPENMC_USE_DAGMC=ON/OFF # CAD geometry support -# -DOPENMC_USE_LIBMESH=ON/OFF # Unstructured mesh -# -DOPENMC_ENABLE_PROFILE=ON/OFF # Profiling flags -# -DOPENMC_ENABLE_COVERAGE=ON/OFF # Coverage analysis - -# Build -make -j - -# C++ unit tests (uses Catch2) -ctest -``` - -### Python Development -```bash -# Install in development mode (requires building C++ library first) -pip install -e . - -# Python tests (uses pytest) -pytest tests/unit_tests/ # Fast unit tests -pytest tests/regression_tests/ # Full regression suite (requires nuclear data) -``` - -### Nuclear Data Setup (CRITICAL for Running OpenMC) -Most tests require the NNDC HDF5 nuclear cross-section library. - -**Important**: Check if `OPENMC_CROSS_SECTIONS` is already set in the user's -environment before downloading, as many users already have nuclear data -installed. Though do note that if this variable is present that it may point to -different cross section data and that the NNDC data is required for tests to -pass. - -**If not already configured, download and setup:** -```bash -# Download NNDC HDF5 cross section library (~800 MB compressed) -wget -q -O - https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz | tar -C $HOME -xJ - -# Set environment variable (add to ~/.bashrc or ~/.zshrc for persistence) -export OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml -``` - -**Alternative**: Use the provided download script (checks if data exists before downloading): -```bash -bash tools/ci/download-xs.sh # Downloads both NNDC HDF5 and ENDF/B-VII.1 data -``` - -Without this data, regression tests will fail with "No cross_sections.xml file -found" errors, or, in the case that alternative cross section data is configured -the tests will execute but will not pass. The `cross_sections.xml` file is an -index listing paths to individual HDF5 nuclear data files for each nuclide. - -## Testing Expectations - -### Environment Requirements - - - **Data**: As described above, OpenMC's test suite requires OpenMC to be configured with NNDC data. - - **OpenMP Settings**: OpenMC's tests may fail is more than two OpenMP threads are used. The environment variable `OMP_NUM_THREADS=2` should be set to avoid sporadic test failures. - - **Executable configuration**: The OpenMC executable should compiled with debug symbols enabled. - -### C++ Tests -Located in `tests/cpp_unit_tests/`, use Catch2 framework. Run via `ctest` after building with `-DOPENMC_BUILD_TESTS=ON`. - -### Python Unit Tests -Located in `tests/unit_tests/`, these are fast, standalone tests that verify Python API functionality without running full simulations. Use standard pytest patterns: - -**Categories**: -- **API validation**: Test object creation, property setters/getters, XML serialization (e.g., `test_material.py`, `test_cell.py`, `test_source.py`) -- **Data processing**: Test nuclear data handling, cross sections, depletion chains (e.g., `test_data_neutron.py`, `test_deplete_chain.py`) -- **Library bindings**: Test `openmc.lib` ctypes interface with `model.init_lib()`/`model.finalize_lib()` (e.g., `test_lib.py`) -- **Geometry operations**: Test bounding boxes, containment, lattice generation (e.g., `test_bounding_box.py`, `test_lattice.py`) - -**Common patterns**: -- Use fixtures from `tests/unit_tests/conftest.py` (e.g., `uo2`, `water`, `sphere_model`) -- Test invalid inputs with `pytest.raises(ValueError)` or `pytest.raises(TypeError)` -- Use `run_in_tmpdir` fixture for tests that create files -- Tests with `openmc.lib` require calling `model.init_lib()` in try/finally with `model.finalize_lib()` - -**Example**: -```python -def test_material_properties(): - m = openmc.Material() - m.add_nuclide('U235', 1.0) - assert 'U235' in m.nuclides - - with pytest.raises(TypeError): - m.add_nuclide('H1', '1.0') # Invalid type -``` - -Unit tests should be fast. For tests requiring simulation output, use regression tests instead. - -### Python Regression Tests -Regression tests compare OpenMC output against reference data. **Prefer using existing models from `openmc.examples` or those found in tests/unit_tests/conftest.py** (like `pwr_pin_cell()`, `pwr_assembly()`, `slab_mg()`) rather than building from scratch. - -**Test Harness Types** (in `tests/testing_harness.py`): -- **PyAPITestHarness**: Standard harness for Python API tests. Compares `inputs_true.dat` (XML hash) and `results_true.dat` (statepoint k-eff and tally values). Requires `model.xml` generation. -- **HashedPyAPITestHarness**: Like PyAPITestHarness but hashes the results for compact comparison -- **TolerantPyAPITestHarness**: For tests with floating-point non-associativity (e.g., random ray solver with single precision). Uses relative tolerance comparisons. -- **WeightWindowPyAPITestHarness**: Compares weight window bounds from `weight_windows.h5` -- **CollisionTrackTestHarness**: Compares collision track data from `collision_track.h5` against `collision_track_true.h5` -- **TestHarness**: Base harness for XML-based tests (no Python model building) -- **PlotTestHarness**: Compares plot output files (PNG or voxel HDF5) -- **CMFDTestHarness**: Specialized for CMFD acceleration tests -- **ParticleRestartTestHarness**: Tests particle restart functionality - -Almost all cases use either `PyAPITestHarness` or `HashedPyAPITestHarness` - -**Example Test**: -```python -from openmc.examples import pwr_pin_cell -from tests.testing_harness import PyAPITestHarness - -def test_my_feature(): - model = pwr_pin_cell() - model.settings.particles = 1000 # Modify to exercise feature - harness = PyAPITestHarness('statepoint.10.h5', model) - harness.main() -``` - -**Workflow**: Create `test.py` and `__init__.py` in `tests/regression_tests/my_test/`, run `pytest --update` to generate reference files (`inputs_true.dat`, `results_true.dat`, etc.), then verify with `pytest` without `--update`. Test results should be generated with `-DOPENMC_ENABLE_STRICT_FP=on` to ensure reproducibility across platforms and optimization levels. - -**Critical**: When modifying OpenMC code, regenerate affected test references with `pytest --update` and commit updated reference files. - -### Test Configuration - -`pytest.ini` sets: `python_files = test*.py`, `python_classes = NoThanks` (disables class-based test collection). - -### Testing Options - -For builds of OpenMC with MPI enabled, the `--mpi` flag should be passed to the test suite to ensure that appropriate tests are executed using two MPI processes. - -The entire test suite can be executed with OpenMC running in event-based mode (instead of the default history-based mode) by providing the `--event` flag to the `pytest` command. - -## Cross-Language Boundaries - -The C API (defined in `include/openmc/capi.h`) exposes C++ functionality to Python via ctypes bindings in `openmc/lib/`. Example: -```cpp -// C++ API in capi.h -extern "C" int openmc_run(); - -// Python binding in openmc/lib/core.py -_dll.openmc_run.restype = c_int -def run(): - _dll.openmc_run() -``` - -When modifying C++ public APIs, update corresponding ctypes signatures in `openmc/lib/*.py`. - -## Code Style & Conventions - -### C++ Style (enforced by .clang-format) - OpenMC generally tries to follow C++ core guidelines where possible - (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) and follow - modern C++ practices (e.g. RAII) whenever possible. - -- **Naming**: - - Classes: `CamelCase` (e.g., `HexLattice`) - - Functions/methods: `snake_case` (e.g., `get_indices`) - - Variables: `snake_case` with trailing underscore for class members (e.g., `n_particles_`, `energy_`) - - Constants: `UPPER_SNAKE_CASE` (e.g., `SQRT_PI`) -- **Namespaces**: All code in `openmc::` namespace, global state in sub-namespaces -- **Include order**: Related header first, then C/C++ stdlib, third-party libs, local headers -- **Comments**: C++-style (`//`) only, never C-style (`/* */`) -- **Standard**: C++17 features allowed -- **Formatting**: Run `clang-format` (version 18) before committing; install via `tools/dev/install-commit-hooks.sh` - -### Python Style -- **PEP8** compliant -- **Docstrings**: numpydoc format for all public functions/methods -- **Type hints**: Use sparingly, primarily for complex signatures -- **Path handling**: Use `pathlib.Path` for filesystem operations, accept `str | os.PathLike` in function arguments -- **Dependencies**: Core dependencies only (numpy, scipy, h5py, pandas, matplotlib, lxml, ipython, uncertainties, endf). Other packages must be optional -- **Python version**: Minimum 3.11 (as of Nov 2025) - -### ID Management Pattern (Python) -When creating geometry objects, IDs can be auto-assigned or explicit: -```python -# Auto-assigned ID -cell = openmc.Cell() # Gets next available ID - -# Explicit ID -cell = openmc.Cell(id=10) # Warning if ID already used - -# Reset all IDs (useful in test fixtures) -openmc.reset_auto_ids() -``` - -### Input Validation Pattern (Python) -All setters use checkvalue functions: -```python -import openmc.checkvalue as cv - -@property -def temperature(self): - return self._temperature - -@temperature.setter -def temperature(self, temp): - cv.check_type('temperature', temp, Real) - cv.check_greater_than('temperature', temp, 0.0) - self._temperature = temp -``` - -### Working with HDF5 Files -C++ uses custom HDF5 wrappers in `src/hdf5_interface.cpp`. Python uses h5py directly. Statepoint format version is `VERSION_STATEPOINT` in `include/openmc/constants.h`. - -### Conditional Compilation -Check for optional features: -```cpp -#ifdef OPENMC_MPI - // MPI-specific code -#endif - -#ifdef OPENMC_DAGMC - // DAGMC-specific code -#endif -``` - -## Documentation - -- **User docs**: Sphinx documentation in `docs/source/` hosted at https://docs.openmc.org -- **C++ docs**: Doxygen-style comments with `\brief`, `\param` tags -- **Python docs**: numpydoc format docstrings - -## Common Pitfalls - -1. **Forgetting nuclear data**: Tests fail without `OPENMC_CROSS_SECTIONS` environment variable -2. **ID conflicts**: Python objects with duplicate IDs trigger `IDWarning`, use `reset_auto_ids()` between tests -3. **MPI builds**: Code must work with and without MPI; use `#ifdef OPENMC_MPI` guards -4. **Path handling**: Use `pathlib.Path` in new Python code, not `os.path` -5. **Clang-format version**: CI uses version 18; other versions may produce different formatting diff --git a/CITATION.cff b/CITATION.cff deleted file mode 100644 index ab27d89b8..000000000 --- a/CITATION.cff +++ /dev/null @@ -1,68 +0,0 @@ -cff-version: 1.2.0 -message: "If you use this software, please cite it as below." -title: OpenMC -authors: -- family-names: Romano - given-names: Paul K. - orcid: "https://orcid.org/0000-0002-1147-045X" -- family-names: Shriwise - given-names: Patrick C. - orcid: "https://orcid.org/0000-0002-3979-7665" -- family-names: Shimwell - given-names: Jonathan - orcid: "https://orcid.org/0000-0001-6909-0946" -- family-names: Harper - given-names: Sterling -- family-names: Boyd - given-names: Will -- family-names: Nelson - given-names: Adam G. - orcid: "https://orcid.org/0000-0002-3614-0676" -- family-names: Tramm - given-names: John R. - orcid: "https://orcid.org/0000-0002-5397-4402" -- family-names: Ridley - given-names: Gavin - orcid: "https://orcid.org/0000-0003-1635-8042" -- family-names: Johnson - given-names: Andrew - orcid: "https://orcid.org/0000-0003-2125-8775" -- family-names: Peterson - given-names: Ethan E. - orcid: "https://orcid.org/0000-0002-5694-7194" -- family-names: Herman - given-names: Bryan R. -preferred-citation: - authors: - - family-names: Romano - given-names: Paul K. - orcid: "https://orcid.org/0000-0002-1147-045X" - - family-names: Horelik - given-names: Nicholas E. - - family-names: Herman - given-names: Bryan R. - - family-names: Nelson - given-names: Adam G. - orcid: "https://orcid.org/0000-0002-3614-0676" - - family-names: Forget - given-names: Benoit - orcid: "https://orcid.org/0000-0003-1459-7672" - - family-names: Smith - given-names: Kord - contact: - - family-names: Romano - given-names: Paul K. - orcid: "https://orcid.org/0000-0002-1147-045X" - doi: 10.1016/j.anucene.2014.07.048 - issn: 0306-4549 - volume: 82 - journal: Annals of Nuclear Energy - publisher: - name: Elsevier - start: 90 - end: 97 - year: 2015 - month: 8 - title: "OpenMC: A state-of-the-art Monte Carlo code for research and development" - type: article - url: "https://doi.org/10.1016/j.anucene.2014.07.048" diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 9538b5ddc..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,14 +0,0 @@ -## OpenMC Codebase Tools - -Read the FULL `AGENTS.md` in this directory before starting work. It contains -project context, coding conventions, and documentation of the RAG search tools -registered in `.mcp.json`. - -### Claude Code-specific: first-call behavior - -The first `openmc_rag_search` call of each session returns an index status -message instead of search results. When this happens, you MUST use the -`AskUserQuestion` tool to present the rebuild/use-existing choice to the user. -Do not ask conversationally — always use the widget. Do not skip this step even -if the index looks current — the user may have uncommitted changes that warrant -a rebuild. diff --git a/CMakeLists.txt b/CMakeLists.txt index 61d2cc6c5..8a000c9b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,11 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project(openmc C CXX) -# Set module path -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) - -include(GetVersionFromGit) - -# Output version information -message(STATUS "OpenMC version: ${OPENMC_VERSION}") -message(STATUS "OpenMC dev state: ${OPENMC_DEV_STATE}") -message(STATUS "OpenMC commit hash: ${OPENMC_COMMIT_HASH}") -message(STATUS "OpenMC commit count: ${OPENMC_COMMIT_COUNT}") - -# Generate version.h +# Set version numbers +set(OPENMC_VERSION_MAJOR 0) +set(OPENMC_VERSION_MINOR 15) +set(OPENMC_VERSION_RELEASE 0) +set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE}) configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY) # Setup output directories @@ -20,10 +13,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -# Generate compile_commands.json for clangd and other tools -if("${CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "") - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -endif() +# Set module path +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) # Enable correct usage of CXX_EXTENSIONS if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) @@ -41,20 +32,9 @@ option(OPENMC_ENABLE_COVERAGE "Compile with coverage analysis flags" option(OPENMC_USE_DAGMC "Enable support for DAGMC (CAD) geometry" OFF) option(OPENMC_USE_LIBMESH "Enable support for libMesh unstructured mesh tallies" OFF) option(OPENMC_USE_MPI "Enable MPI" OFF) +option(OPENMC_USE_MCPL "Enable MCPL" OFF) +option(OPENMC_USE_NCRYSTAL "Enable support for NCrystal scattering" OFF) option(OPENMC_USE_UWUW "Enable UWUW" OFF) -option(OPENMC_FORCE_VENDORED_LIBS "Explicitly use submodules defined in 'vendor'" OFF) -option(OPENMC_ENABLE_STRICT_FP "Enable strict FP flags to improve test portability" OFF) - -message(STATUS "OPENMC_USE_OPENMP ${OPENMC_USE_OPENMP}") -message(STATUS "OPENMC_BUILD_TESTS ${OPENMC_BUILD_TESTS}") -message(STATUS "OPENMC_ENABLE_PROFILE ${OPENMC_ENABLE_PROFILE}") -message(STATUS "OPENMC_ENABLE_COVERAGE ${OPENMC_ENABLE_COVERAGE}") -message(STATUS "OPENMC_USE_DAGMC ${OPENMC_USE_DAGMC}") -message(STATUS "OPENMC_USE_LIBMESH ${OPENMC_USE_LIBMESH}") -message(STATUS "OPENMC_USE_MPI ${OPENMC_USE_MPI}") -message(STATUS "OPENMC_USE_UWUW ${OPENMC_USE_UWUW}") -message(STATUS "OPENMC_FORCE_VENDORED_LIBS ${OPENMC_FORCE_VENDORED_LIBS}") -message(STATUS "OPENMC_ENABLE_STRICT_FP ${OPENMC_ENABLE_STRICT_FP}") # Warnings for deprecated options foreach(OLD_OPT IN ITEMS "openmp" "profile" "coverage" "dagmc" "libmesh") @@ -96,19 +76,6 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build" FORCE) endif() -#=============================================================================== -# When STRICT_FP is enabled, remove NDEBUG from RelWithDebInfo flags so that -# assert() remains active. CMake normally adds -DNDEBUG for both Release and -# RelWithDebInfo, which disables C/C++ assert() statements. -#=============================================================================== - -if(OPENMC_ENABLE_STRICT_FP) - foreach(FLAG_VAR CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELWITHDEBINFO) - string(REPLACE "-DNDEBUG" "" ${FLAG_VAR} "${${FLAG_VAR}}") - string(REPLACE "/DNDEBUG" "" ${FLAG_VAR} "${${FLAG_VAR}}") - endforeach() -endif() - #=============================================================================== # OpenMP for shared-memory parallelism (and GPU support some day!) #=============================================================================== @@ -138,6 +105,15 @@ macro(find_package_write_status pkg) endif() endmacro() +#=============================================================================== +# NCrystal Scattering Support +#=============================================================================== + +if(OPENMC_USE_NCRYSTAL) + find_package(NCrystal REQUIRED) + message(STATUS "Found NCrystal: ${NCrystal_DIR} (version ${NCrystal_VERSION})") +endif() + #=============================================================================== # DAGMC Geometry Support - need DAGMC/MOAB #=============================================================================== @@ -210,29 +186,18 @@ if(${HDF5_VERSION} VERSION_GREATER_EQUAL 1.12.0) endif() #=============================================================================== -# Set compile/link flags based on which compiler is being used +# MCPL #=============================================================================== -# When OPENMC_ENABLE_STRICT_FP is enabled, disable compiler optimizations that change -# floating-point results relative to -O0, improving cross-platform and -# cross-optimization-level reproducibility for regression testing: -# -ffp-contract=off Prevents FMA contraction (fused multiply-add changes rounding) -# -fno-builtin Prevents replacing math function calls (pow, exp, log, etc.) -# with builtin versions that may differ from libm -# By default (OFF), the compiler is free to use all optimizations for best -# performance. -if(OPENMC_ENABLE_STRICT_FP) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-ffp-contract=off SUPPORTS_FP_CONTRACT_OFF) - if(SUPPORTS_FP_CONTRACT_OFF) - list(APPEND cxxflags -ffp-contract=off) - endif() - check_cxx_compiler_flag(-fno-builtin SUPPORTS_NO_BUILTIN) - if(SUPPORTS_NO_BUILTIN) - list(APPEND cxxflags -fno-builtin) - endif() +if (OPENMC_USE_MCPL) + find_package(MCPL REQUIRED) + message(STATUS "Found MCPL: ${MCPL_DIR} (found version \"${MCPL_VERSION}\")") endif() +#=============================================================================== +# Set compile/link flags based on which compiler is being used +#=============================================================================== + # Skip for Visual Studio which has its own configurations through GUI if(NOT MSVC) @@ -256,6 +221,8 @@ endif() #=============================================================================== # Update git submodules as needed #=============================================================================== + +find_package(Git) if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") option(GIT_SUBMODULE "Check submodules during build" ON) if(GIT_SUBMODULE) @@ -280,30 +247,44 @@ endif() # pugixml library #=============================================================================== -if(OPENMC_FORCE_VENDORED_LIBS) +find_package_write_status(pugixml) +if (NOT pugixml_FOUND) add_subdirectory(vendor/pugixml) set_target_properties(pugixml PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF) -else() - find_package_write_status(pugixml) - if (NOT pugixml_FOUND) - add_subdirectory(vendor/pugixml) - set_target_properties(pugixml PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF) - endif() endif() #=============================================================================== # {fmt} library #=============================================================================== -if(OPENMC_FORCE_VENDORED_LIBS) +find_package_write_status(fmt) +if (NOT fmt_FOUND) set(FMT_INSTALL ON CACHE BOOL "Generate the install target.") add_subdirectory(vendor/fmt) -else() - find_package_write_status(fmt) - if (NOT fmt_FOUND) - set(FMT_INSTALL ON CACHE BOOL "Generate the install target.") - add_subdirectory(vendor/fmt) - endif() +endif() + +#=============================================================================== +# xtensor header-only library +#=============================================================================== + +find_package_write_status(xtensor) +if (NOT xtensor_FOUND) + add_subdirectory(vendor/xtl) + set(xtl_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/xtl) + add_subdirectory(vendor/xtensor) +endif() + +#=============================================================================== +# GSL header-only library +#=============================================================================== + +find_package_write_status(gsl-lite) +if (NOT gsl-lite_FOUND) + add_subdirectory(vendor/gsl-lite) + + # Make sure contract violations throw exceptions + target_compile_definitions(gsl-lite-v1 INTERFACE GSL_THROW_ON_CONTRACT_VIOLATION) + target_compile_definitions(gsl-lite-v1 INTERFACE gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON=1) endif() #=============================================================================== @@ -311,13 +292,9 @@ endif() #=============================================================================== if(OPENMC_BUILD_TESTS) - if (OPENMC_FORCE_VENDORED_LIBS) + find_package_write_status(Catch2) + if (NOT Catch2_FOUND) add_subdirectory(vendor/Catch2) - else() - find_package_write_status(Catch2) - if (NOT Catch2_FOUND) - add_subdirectory(vendor/Catch2) - endif() endif() endif() @@ -355,14 +332,11 @@ endif() #=============================================================================== list(APPEND libopenmc_SOURCES - src/atomic_mass.cpp src/bank.cpp src/boundary_condition.cpp src/bremsstrahlung.cpp src/cell.cpp - src/chain.cpp src/cmfd_solver.cpp - src/collision_track.cpp src/cross_sections.cpp src/dagmc.cpp src/distribution.cpp @@ -379,7 +353,6 @@ list(APPEND libopenmc_SOURCES src/geometry.cpp src/geometry_aux.cpp src/hdf5_interface.cpp - src/ifp.cpp src/initialize.cpp src/lattice.cpp src/material.cpp @@ -390,13 +363,11 @@ list(APPEND libopenmc_SOURCES src/mgxs.cpp src/mgxs_interface.cpp src/ncrystal_interface.cpp - src/ncrystal_load.cpp src/nuclide.cpp src/output.cpp src/particle.cpp src/particle_data.cpp src/particle_restart.cpp - src/particle_type.cpp src/photon.cpp src/physics.cpp src/physics_common.cpp @@ -409,10 +380,6 @@ list(APPEND libopenmc_SOURCES src/random_ray/random_ray_simulation.cpp src/random_ray/random_ray.cpp src/random_ray/flat_source_domain.cpp - src/random_ray/linear_source_domain.cpp - src/random_ray/moment_matrix.cpp - src/random_ray/source_region.cpp - src/ray.cpp src/reaction.cpp src/reaction_product.cpp src/scattdata.cpp @@ -445,21 +412,15 @@ list(APPEND libopenmc_SOURCES src/tallies/filter_materialfrom.cpp src/tallies/filter_mesh.cpp src/tallies/filter_meshborn.cpp - src/tallies/filter_meshmaterial.cpp src/tallies/filter_meshsurface.cpp src/tallies/filter_mu.cpp - src/tallies/filter_musurface.cpp - src/tallies/filter_parent_nuclide.cpp src/tallies/filter_particle.cpp - src/tallies/filter_particle_production.cpp src/tallies/filter_polar.cpp - src/tallies/filter_reaction.cpp src/tallies/filter_sph_harm.cpp src/tallies/filter_sptl_legendre.cpp src/tallies/filter_surface.cpp src/tallies/filter_time.cpp src/tallies/filter_universe.cpp - src/tallies/filter_weight.cpp src/tallies/filter_zernike.cpp src/tallies/tally.cpp src/tallies/tally_scoring.cpp @@ -520,10 +481,22 @@ if (OPENMC_USE_MPI) target_compile_definitions(libopenmc PUBLIC -DOPENMC_MPI) endif() +# Set git SHA1 hash as a compile definition +if(GIT_FOUND) + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SHA1_SUCCESS + OUTPUT_VARIABLE GIT_SHA1 + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(GIT_SHA1_SUCCESS EQUAL 0) + target_compile_definitions(libopenmc PRIVATE -DGIT_SHA1="${GIT_SHA1}") + endif() +endif() + # target_link_libraries treats any arguments starting with - but not -l as # linker flags. Thus, we can pass both linker flags and libraries together. target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} - fmt::fmt ${CMAKE_DL_LIBS}) + xtensor gsl::gsl-lite-v1 fmt::fmt ${CMAKE_DL_LIBS}) if(TARGET pugixml::pugixml) target_link_libraries(libopenmc pugixml::pugixml) @@ -532,20 +505,12 @@ else() endif() if(OPENMC_USE_DAGMC) - target_compile_definitions(libopenmc PUBLIC OPENMC_DAGMC_ENABLED) + target_compile_definitions(libopenmc PRIVATE DAGMC) target_link_libraries(libopenmc dagmc-shared) - - if(OPENMC_USE_UWUW) - target_compile_definitions(libopenmc PRIVATE OPENMC_UWUW_ENABLED) - target_link_libraries(libopenmc uwuw-shared) - endif() -elseif(OPENMC_USE_UWUW) - set(OPENMC_USE_UWUW OFF) - message(FATAL_ERROR "DAGMC must be enabled when UWUW is enabled.") endif() if(OPENMC_USE_LIBMESH) - target_compile_definitions(libopenmc PRIVATE OPENMC_LIBMESH_ENABLED) + target_compile_definitions(libopenmc PRIVATE LIBMESH) target_link_libraries(libopenmc PkgConfig::LIBMESH) endif() @@ -568,6 +533,21 @@ if (OPENMC_BUILD_TESTS) add_subdirectory(tests/cpp_unit_tests) endif() +if (OPENMC_USE_MCPL) + target_compile_definitions(libopenmc PUBLIC OPENMC_MCPL) + target_link_libraries(libopenmc MCPL::mcpl) +endif() + +if(OPENMC_USE_NCRYSTAL) + target_compile_definitions(libopenmc PRIVATE NCRYSTAL) + target_link_libraries(libopenmc NCrystal::NCrystal) +endif() + +if (OPENMC_USE_UWUW) + target_compile_definitions(libopenmc PRIVATE UWUW) + target_link_libraries(libopenmc uwuw-shared) +endif() + #=============================================================================== # Log build info that this executable can report later #=============================================================================== @@ -580,9 +560,6 @@ endif() if (OPENMC_ENABLE_COVERAGE) target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD) endif() -if (OPENMC_ENABLE_STRICT_FP) - target_compile_definitions(libopenmc PRIVATE OPENMC_ENABLE_STRICT_FP) -endif() #=============================================================================== # openmc executable @@ -611,7 +588,9 @@ add_custom_command(TARGET libopenmc POST_BUILD #=============================================================================== # Install executable, scripts, manpage, license #=============================================================================== -include(CMakePackageConfigHelpers) + +configure_file(cmake/OpenMCConfig.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" @ONLY) +configure_file(cmake/OpenMCConfigVersion.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" @ONLY) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC) install(TARGETS openmc libopenmc @@ -625,24 +604,10 @@ install(EXPORT openmc-targets NAMESPACE OpenMC:: DESTINATION ${INSTALL_CONFIGDIR}) -configure_package_config_file( - "cmake/OpenMCConfig.cmake.in" - "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" - INSTALL_DESTINATION ${INSTALL_CONFIGDIR} -) - -write_basic_package_version_file( - "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" - VERSION ${OPENMC_VERSION} - COMPATIBILITY AnyNewerVersion -) - install(FILES - "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" - "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" - DESTINATION "${INSTALL_CONFIGDIR}" -) - + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" + DESTINATION ${INSTALL_CONFIGDIR}) install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/CODEOWNERS b/CODEOWNERS index c77366de7..6d452e366 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -60,8 +60,7 @@ Dockerfile @shimwell src/random_ray/ @jtramm # NCrystal interface -src/ncrystal_interface.cpp @marquezj @tkittel -src/ncrystal_load.cpp @marquezj @tkittel +src/ncrystal_interface.cpp @marquezj # MCPL interface src/mcpl_interface.cpp @ebknudsen diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 184c522d4..378ca346a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ openmc@anl.gov. ## Resources - [GitHub Repository](https://github.com/openmc-dev/openmc) -- [Documentation](https://docs.openmc.org/en/latest) +- [Documentation](http://docs.openmc.org/en/latest) - [Discussion Forum](https://openmc.discourse.group) - [Slack Community](https://openmc.slack.com/signup) (If you don't see your domain listed, contact openmc@anl.gov) diff --git a/Dockerfile b/Dockerfile index 688e5a370..107df4afe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ ARG compile_cores=1 ARG build_dagmc=off ARG build_libmesh=off -FROM ubuntu:24.04 AS dependencies +FROM debian:bookworm-slim AS dependencies ARG compile_cores ARG build_dagmc @@ -33,6 +33,11 @@ ARG build_libmesh # Set default value of HOME to /root ENV HOME=/root +# Embree variables +ENV EMBREE_TAG='v4.3.1' +ENV EMBREE_REPO='https://github.com/embree/embree' +ENV EMBREE_INSTALL_DIR=$HOME/EMBREE/ + # MOAB variables ENV MOAB_TAG='5.5.1' ENV MOAB_REPO='https://bitbucket.org/fathomteam/moab/' @@ -43,7 +48,7 @@ ENV DD_REPO='https://github.com/pshriwise/double-down' ENV DD_INSTALL_DIR=$HOME/Double_down # DAGMC variables -ENV DAGMC_BRANCH='v3.2.4' +ENV DAGMC_BRANCH='v3.2.3' ENV DAGMC_REPO='https://github.com/svalinn/DAGMC' ENV DAGMC_INSTALL_DIR=$HOME/DAGMC/ @@ -53,11 +58,10 @@ ENV LIBMESH_REPO='https://github.com/libMesh/libmesh' ENV LIBMESH_INSTALL_DIR=$HOME/LIBMESH # NJOY variables -ENV NJOY_TAG='2016.78' ENV NJOY_REPO='https://github.com/njoy/NJOY2016' # Setup environment variables for Docker image -ENV LD_LIBRARY_PATH=${DAGMC_INSTALL_DIR}/lib:${LD_LIBRARY_PATH:-} \ +ENV LD_LIBRARY_PATH=${DAGMC_INSTALL_DIR}/lib:$LD_LIBRARY_PATH \ OPENMC_ENDF_DATA=/root/endf-b-vii.1 \ DEBIAN_FRONTEND=noninteractive @@ -67,7 +71,7 @@ RUN apt-get update -y && \ apt-get install -y \ python3-pip python-is-python3 wget git build-essential cmake \ mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev \ - libpng-dev libpugixml-dev libfmt-dev catch2 python3-venv && \ + libpng-dev python3-venv && \ apt-get autoremove # create virtual enviroment to avoid externally managed environment error @@ -79,7 +83,7 @@ RUN pip install --upgrade pip # Clone and install NJOY2016 RUN cd $HOME \ - && git clone --single-branch -b ${NJOY_TAG} --depth 1 ${NJOY_REPO} \ + && git clone --single-branch --depth 1 ${NJOY_REPO} \ && cd NJOY2016 \ && mkdir build \ && cd build \ @@ -90,21 +94,28 @@ RUN cd $HOME \ RUN if [ "$build_dagmc" = "on" ]; then \ # Install addition packages required for DAGMC - apt-get -y install \ - libeigen3-dev libnetcdf-dev libtbb-dev libglfw3-dev libembree-dev \ - && pip install --upgrade numpy \ - && pip install --no-cache-dir setuptools cython \ + apt-get -y install libeigen3-dev libnetcdf-dev libtbb-dev libglfw3-dev \ + && pip install --upgrade numpy "cython<3.0" \ + # Clone and install EMBREE + && mkdir -p $HOME/EMBREE && cd $HOME/EMBREE \ + && git clone --single-branch -b ${EMBREE_TAG} --depth 1 ${EMBREE_REPO} \ + && mkdir build && cd build \ + && cmake ../embree \ + -DCMAKE_INSTALL_PREFIX=${EMBREE_INSTALL_DIR} \ + -DEMBREE_MAX_ISA=NONE \ + -DEMBREE_ISA_SSE42=ON \ + -DEMBREE_ISPC_SUPPORT=OFF \ + && make 2>/dev/null -j${compile_cores} install \ + && rm -rf ${EMBREE_INSTALL_DIR}/build ${EMBREE_INSTALL_DIR}/embree ; \ # Clone and install MOAB - && mkdir -p $HOME/MOAB && cd $HOME/MOAB \ + mkdir -p $HOME/MOAB && cd $HOME/MOAB \ && git clone --single-branch -b ${MOAB_TAG} --depth 1 ${MOAB_REPO} \ && mkdir build && cd build \ - && cmake ../moab -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_HDF5=ON \ + && cmake ../moab -DENABLE_HDF5=ON \ -DENABLE_NETCDF=ON \ -DBUILD_SHARED_LIBS=OFF \ -DENABLE_FORTRAN=OFF \ -DENABLE_BLASLAPACK=OFF \ - -DENABLE_TESTING=OFF \ && make 2>/dev/null -j${compile_cores} install \ && cmake ../moab \ -DENABLE_PYMOAB=ON \ @@ -120,7 +131,7 @@ RUN if [ "$build_dagmc" = "on" ]; then \ && mkdir build && cd build \ && cmake ../double-down -DCMAKE_INSTALL_PREFIX=${DD_INSTALL_DIR} \ -DMOAB_DIR=/usr/local \ - -DEMBREE_DIR=/usr \ + -DEMBREE_DIR=${EMBREE_INSTALL_DIR} \ && make 2>/dev/null -j${compile_cores} install \ && rm -rf ${DD_INSTALL_DIR}/build ${DD_INSTALL_DIR}/double-down ; \ # Clone and install DAGMC @@ -134,7 +145,6 @@ RUN if [ "$build_dagmc" = "on" ]; then \ -DDOUBLE_DOWN_DIR=${DD_INSTALL_DIR} \ -DCMAKE_PREFIX_PATH=${DD_INSTALL_DIR}/lib \ -DBUILD_STATIC_LIBS=OFF \ - -DBUILD_TESTS=OFF \ && make 2>/dev/null -j${compile_cores} install \ && rm -rf ${DAGMC_INSTALL_DIR}/DAGMC ${DAGMC_INSTALL_DIR}/build ; \ fi @@ -183,7 +193,7 @@ ENV LIBMESH_INSTALL_DIR=$HOME/LIBMESH # clone and install openmc RUN mkdir -p ${HOME}/OpenMC && cd ${HOME}/OpenMC \ - && git clone --shallow-submodules --recurse-submodules --single-branch -b ${openmc_branch} ${OPENMC_REPO} \ + && git clone --shallow-submodules --recurse-submodules --single-branch -b ${openmc_branch} --depth=1 ${OPENMC_REPO} \ && mkdir build && cd build ; \ if [ ${build_dagmc} = "on" ] && [ ${build_libmesh} = "on" ]; then \ cmake ../openmc \ diff --git a/LICENSE b/LICENSE index b5dfd1748..1f9198c1e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2026 Massachusetts Institute of Technology, UChicago Argonne +Copyright (c) 2011-2024 Massachusetts Institute of Technology, UChicago Argonne LLC, and OpenMC contributors Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/MANIFEST.in b/MANIFEST.in index cdc7e2abc..afd016cb0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -26,6 +26,8 @@ recursive-include include *.h recursive-include include *.h.in recursive-include include *.hh recursive-include man *.1 +recursive-include openmc *.pyx +recursive-include openmc *.c recursive-include src *.cc recursive-include src *.cpp recursive-include src *.rnc @@ -43,5 +45,6 @@ recursive-include vendor *.hh recursive-include vendor *.hpp recursive-include vendor *.pc.in recursive-include vendor *.natvis +include vendor/gsl-lite/include/gsl/gsl prune docs/build prune docs/source/pythonapi/generated/ diff --git a/cmake/Modules/FindLIBMESH.cmake b/cmake/Modules/FindLIBMESH.cmake index df9208c18..df5b5b9d8 100644 --- a/cmake/Modules/FindLIBMESH.cmake +++ b/cmake/Modules/FindLIBMESH.cmake @@ -14,8 +14,8 @@ if(DEFINED ENV{METHOD}) message(STATUS "Using environment variable METHOD to determine libMesh build: ${LIBMESH_PC_FILE}") endif() -find_package(PkgConfig REQUIRED) - -set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +include(FindPkgConfig) +set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${LIBMESH_PC}") +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True) pkg_check_modules(LIBMESH REQUIRED ${LIBMESH_PC_FILE}>=1.7.0 IMPORTED_TARGET) pkg_get_variable(LIBMESH_PREFIX ${LIBMESH_PC_FILE} prefix) diff --git a/cmake/Modules/GetVersionFromGit.cmake b/cmake/Modules/GetVersionFromGit.cmake deleted file mode 100644 index 3736955ff..000000000 --- a/cmake/Modules/GetVersionFromGit.cmake +++ /dev/null @@ -1,120 +0,0 @@ -# GetVersionFromGit.cmake -# Standalone script to retrieve versioning information from Git or .git_archival.txt. -# Customizable for any project by setting variables before including this file. - -# Configurable variables: -# - VERSION_PREFIX: Prefix for version tags (default: "v"). -# - VERSION_SUFFIX: Suffix for version tags (default: "[~+-]([a-zA-Z0-9]+)"). -# - VERSION_REGEX: Regex to extract version (default: "(?[0-9]+\\.[0-9]+\\.[0-9]+)"). -# - ARCHIVAL_FILE: Path to .git_archival.txt (default: "${CMAKE_SOURCE_DIR}/.git_archival.txt"). -# - DESCRIBE_NAME_KEY: Key for describe name in .git_archival.txt (default: "describe-name: "). -# - COMMIT_HASH_KEY: Key for commit hash in .git_archival.txt (default: "commit: "). - -# Default Format Example: -# 1.2.3 v1.2.3 v1.2.3-rc1 - -set(VERSION_PREFIX "v" CACHE STRING "Prefix used in version tags") -set(VERSION_SUFFIX "[~+-]([a-zA-Z0-9]+)" CACHE STRING "Suffix used in version tags") -set(VERSION_REGEX "?([0-9]+\\.[0-9]+\\.[0-9]+)" CACHE STRING "Regex for extracting version") -set(ARCHIVAL_FILE "${CMAKE_SOURCE_DIR}/.git_archival.txt" CACHE STRING "Path to .git_archival.txt") -set(DESCRIBE_NAME_KEY "describe-name: " CACHE STRING "Key for describe name in .git_archival.txt") -set(COMMIT_HASH_KEY "commit: " CACHE STRING "Key for commit hash in .git_archival.txt") - - -# Combine prefix and regex -set(VERSION_REGEX_WITH_PREFIX "^${VERSION_PREFIX}${VERSION_REGEX}") - -# Find Git -find_package(Git) - -# Attempt to retrieve version from Git -if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND GIT_FOUND) - message(STATUS "Using git describe for versioning") - - # Extract the version string - execute_process( - COMMAND git describe --tags --dirty - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_STRING - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - - # If no tags are found, set version to 0 and show a warning - if(VERSION_STRING STREQUAL "") - set(VERSION_STRING "0.0.0") - message(WARNING - "No git tags found. Version set to 0.0.0.\n" - "Run 'git fetch --tags' to ensure proper versioning.\n" - "For more information, see OpenMC developer documentation." - ) - endif() - - # Extract the commit hash - execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -else() - message(STATUS "Using archival file for versioning: ${ARCHIVAL_FILE}") - if(EXISTS "${ARCHIVAL_FILE}") - file(READ "${ARCHIVAL_FILE}" ARCHIVAL_CONTENT) - - # Extract the describe-name line - string(REGEX MATCH "${DESCRIBE_NAME_KEY}([^\\n]+)" VERSION_STRING "${ARCHIVAL_CONTENT}") - if(VERSION_STRING MATCHES "${DESCRIBE_NAME_KEY}(.*)") - set(VERSION_STRING "${CMAKE_MATCH_1}") - else() - message(FATAL_ERROR "Could not extract version from ${ARCHIVAL_FILE}") - endif() - - # Extract the commit hash - string(REGEX MATCH "${COMMIT_HASH_KEY}([a-f0-9]+)" COMMIT_HASH "${ARCHIVAL_CONTENT}") - if(COMMIT_HASH MATCHES "${COMMIT_HASH_KEY}([a-f0-9]+)") - set(COMMIT_HASH "${CMAKE_MATCH_1}") - else() - message(FATAL_ERROR "Could not extract commit hash from ${ARCHIVAL_FILE}") - endif() - else() - message(FATAL_ERROR "Neither git describe nor ${ARCHIVAL_FILE} is available for versioning.") - endif() -endif() - -# Ensure version string format -if(VERSION_STRING MATCHES "${VERSION_REGEX_WITH_PREFIX}") - set(VERSION_NO_SUFFIX "${CMAKE_MATCH_1}") -else() - message(FATAL_ERROR "Invalid version format: Missing base version in ${VERSION_STRING}") -endif() - -# Check for development state -if(VERSION_STRING MATCHES "-([0-9]+)-g([0-9a-f]+)") - set(DEV_STATE "true") - set(COMMIT_COUNT "${CMAKE_MATCH_1}") - string(REGEX REPLACE "-([0-9]+)-g([0-9a-f]+)" "" VERSION_WITHOUT_META "${VERSION_STRING}") -else() - set(DEV_STATE "false") - set(VERSION_WITHOUT_META "${VERSION_STRING}") -endif() - -# Split and set version components -string(REPLACE "." ";" VERSION_LIST "${VERSION_NO_SUFFIX}") -list(GET VERSION_LIST 0 VERSION_MAJOR) -list(GET VERSION_LIST 1 VERSION_MINOR) -list(GET VERSION_LIST 2 VERSION_PATCH) - -# Increment patch number for dev versions -if(DEV_STATE) - math(EXPR VERSION_PATCH "${VERSION_PATCH} + 1") -endif() - -# Export variables -set(OPENMC_VERSION_MAJOR "${VERSION_MAJOR}") -set(OPENMC_VERSION_MINOR "${VERSION_MINOR}") -set(OPENMC_VERSION_PATCH "${VERSION_PATCH}") -set(OPENMC_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") -set(OPENMC_COMMIT_HASH "${COMMIT_HASH}") -set(OPENMC_DEV_STATE "${DEV_STATE}") -set(OPENMC_COMMIT_COUNT "${COMMIT_COUNT}") diff --git a/cmake/OpenMCConfig.cmake.in b/cmake/OpenMCConfig.cmake.in index 0e15060a3..44a5e0d5a 100644 --- a/cmake/OpenMCConfig.cmake.in +++ b/cmake/OpenMCConfig.cmake.in @@ -1,18 +1,17 @@ -@PACKAGE_INIT@ +get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -include("${CMAKE_CURRENT_LIST_DIR}/OpenMCConfigVersion.cmake") -include(CMakeFindDependencyMacro) - -# Explicitly calculate prefix if it was not generated above -if(NOT DEFINED PACKAGE_PREFIX_DIR) - get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) +find_package(fmt REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../fmt) +find_package(gsl-lite REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../gsl-lite) +find_package(pugixml REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../pugixml) +find_package(xtl REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtl) +find_package(xtensor REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtensor) +if(@OPENMC_USE_DAGMC@) + find_package(DAGMC REQUIRED HINTS @DAGMC_DIR@) endif() -find_dependency(fmt CONFIG REQUIRED HINTS ${PACKAGE_PREFIX_DIR}) -find_dependency(pugixml CONFIG REQUIRED HINTS ${PACKAGE_PREFIX_DIR}) - -if(@OPENMC_USE_DAGMC@) - find_dependency(DAGMC REQUIRED HINTS @DAGMC_DIR@) +if(@OPENMC_USE_NCRYSTAL@) + find_package(NCrystal REQUIRED) + message(STATUS "Found NCrystal: ${NCrystal_DIR} (version ${NCrystal_VERSION})") endif() if(@OPENMC_USE_LIBMESH@) @@ -22,24 +21,24 @@ if(@OPENMC_USE_LIBMESH@) pkg_check_modules(LIBMESH REQUIRED @LIBMESH_PC_FILE@>=1.7.0 IMPORTED_TARGET) endif() -if("@PNG_FOUND@") - find_dependency(PNG) +find_package(PNG) + +if(NOT TARGET OpenMC::libopenmc) + include("${OpenMC_CMAKE_DIR}/OpenMCTargets.cmake") endif() if(@OPENMC_USE_MPI@) - find_dependency(MPI REQUIRED) + find_package(MPI REQUIRED) endif() if(@OPENMC_USE_OPENMP@) - find_dependency(OpenMP REQUIRED) + find_package(OpenMP REQUIRED) endif() -if(@OPENMC_USE_UWUW@ AND NOT ${DAGMC_BUILD_UWUW}) - message(FATAL_ERROR "UWUW is enabled in OpenMC but the DAGMC installation discovered was not configured with UWUW.") +if(@OPENMC_USE_MCPL@) + find_package(MCPL REQUIRED) endif() -include("${CMAKE_CURRENT_LIST_DIR}/OpenMCTargets.cmake") - -if(NOT OpenMC_FIND_QUIETLY) - message(STATUS "Found OpenMC: ${PACKAGE_VERSION} (found in ${PACKAGE_PREFIX_DIR})") +if(@OPENMC_USE_UWUW@) + find_package(UWUW REQUIRED) endif() diff --git a/cmake/OpenMCConfigVersion.cmake.in b/cmake/OpenMCConfigVersion.cmake.in new file mode 100644 index 000000000..90d345de4 --- /dev/null +++ b/cmake/OpenMCConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION "@OPENMC_VERSION@") + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/docs/Makefile b/docs/Makefile index e320432a2..a93338df3 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -45,7 +45,6 @@ help: clean: -rm -rf $(BUILDDIR)/* -rm -rf source/pythonapi/generated/ - -rm -rf doxygen/xml html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile deleted file mode 100644 index 75702eff7..000000000 --- a/docs/doxygen/Doxyfile +++ /dev/null @@ -1,13 +0,0 @@ -# Doxyfile 1.9.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. - -# Difference with default Doxyfile 1.9.1 -PROJECT_NAME = OpenMC -QUIET = YES -WARN_IF_UNDOCUMENTED = NO -INPUT = ../../include/openmc/capi.h -GENERATE_HTML = NO -GENERATE_LATEX = NO -GENERATE_XML = YES diff --git a/docs/requirements-rtd.txt b/docs/requirements-rtd.txt new file mode 100644 index 000000000..df0333517 --- /dev/null +++ b/docs/requirements-rtd.txt @@ -0,0 +1,13 @@ +sphinx==5.0.2 +sphinx_rtd_theme==1.0.0 +sphinx-numfig +jupyter +sphinxcontrib-katex +sphinxcontrib-svg2pdfconverter +numpy +scipy +h5py +pandas +uncertainties +matplotlib +lxml diff --git a/docs/source/_images/2x2_sr_mesh.png b/docs/source/_images/2x2_sr_mesh.png deleted file mode 100644 index 5cdc684d3..000000000 Binary files a/docs/source/_images/2x2_sr_mesh.png and /dev/null differ diff --git a/docs/source/_images/phong_triso.png b/docs/source/_images/phong_triso.png deleted file mode 100644 index 7f1ac61ca..000000000 Binary files a/docs/source/_images/phong_triso.png and /dev/null differ diff --git a/docs/source/_images/plotmeshtally.png b/docs/source/_images/plotmeshtally.png new file mode 100644 index 000000000..d874b4906 Binary files /dev/null and b/docs/source/_images/plotmeshtally.png differ diff --git a/docs/source/_images/sphere-mesh-vtk.png b/docs/source/_images/sphere-mesh-vtk.png deleted file mode 100644 index 73b412bdd..000000000 Binary files a/docs/source/_images/sphere-mesh-vtk.png and /dev/null differ diff --git a/docs/source/capi/index.rst b/docs/source/capi/index.rst index e924aa6e2..d9ac0d1e0 100644 --- a/docs/source/capi/index.rst +++ b/docs/source/capi/index.rst @@ -46,29 +46,41 @@ Type Definitions Functions --------- -.. - Once documentation is complete in capi.h, use: - .. doxygenfile:: capi.h - to populate this documentation without using - .. doxygenfunction:: - for every function. +.. c:function:: int openmc_calculate_volumes() -.. doxygenfunction:: openmc_calculate_volumes + Run a stochastic volume calculation -.. doxygenfunction:: openmc_cell_get_fill + :return: Return status (negative if an error occurred) + :rtype: int -.. doxygenfunction:: openmc_cell_get_id +.. c:function:: int openmc_cell_get_fill(int32_t index, int* type, int32_t** indices, int32_t* n) -.. doxygenfunction:: openmc_cell_get_temperature - -.. c:function:: int openmc_cell_get_density(int32_t index, const int32_t* instance, double* density) - - Get the density of a cell + Get the fill for a cell :param int32_t index: Index in the cells array - :param int32_t* instance: Which instance of the cell. If a null pointer is passed, the density - multiplier of the first instance is returned. - :param double* density: Density of the cell in [g/cm3] + :param int* type: Type of the fill + :param int32_t** indices: Array of material indices for cell + :param int32_t* n: Length of indices array + :return: Return status (negative if an error occurred) + :rtype: int + +.. c:function:: int openmc_cell_get_id(int32_t index, int32_t* id) + + Get the ID of a cell + + :param int32_t index: Index in the cells array + :param int32_t* id: ID of the cell + :return: Return status (negative if an error occurred) + :rtype: int + +.. c:function:: int openmc_cell_get_temperature(int32_t index, const int32_t* instance, double* T) + + Get the temperature of a cell + + :param int32_t index: Index in the cells array + :param int32_t* instance: Which instance of the cell. If a null pointer is passed, the temperature + of the first instance is returned. + :param double* T: temperature of the cell :return: Return status (negative if an error occurred) :rtype: int @@ -101,22 +113,8 @@ Functions :param double T: Temperature in Kelvin :param instance: Which instance of the cell. To set the temperature for all instances, pass a null pointer. - :param bool set_contained: If the cell is not filled by a material, whether - to set the temperatures of all filled cells - :type instance: const int32_t* - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_cell_set_density(index index, double density, const int32_t* instance, bool set_contained) - - Set the density of a cell. - - :param int32_t index: Index in the cells array - :param double density: Density of the cell in [g/cm3] - :param instance: Which instance of the cell. To set the density multiplier for all - instances, pass a null pointer. - :param bool set_contained: If the cell is not filled by a material, whether - to set the density multiplier of all filled cells + :param set_contained: If the cell is not filled by a material, whether to set the temperatures + of all filled cells :type instance: const int32_t* :return: Return status (negative if an error occurred) :rtype: int @@ -557,279 +555,6 @@ Functions :return: Return status (negative if an error occurs) :rtype: int -.. c:function:: int openmc_get_plot_index(int32_t id, int32_t* index) - - Get the index in the plots array for a plot with a given ID. - - :param int32_t id: Plot ID - :param int32_t* index: Index in the plots array - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_plot_get_id(int32_t index, int32_t* id) - - Get the ID of a plot. - - :param int32_t index: Index in the plots array - :param int32_t* id: Plot ID - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_plot_set_id(int32_t index, int32_t id) - - Set the ID of a plot. - - :param int32_t index: Index in the plots array - :param int32_t id: Plot ID - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: size_t openmc_plots_size() - - Number of plots currently allocated. - - :return: Number of plots in the plots array - :rtype: size_t - -.. c:function:: int openmc_solidraytrace_plot_create(int32_t* index) - - Create a new solid raytrace plot. - - :param int32_t* index: Index of the newly created plot - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_pixels(int32_t index, int32_t* width, int32_t* height) - - Get output pixel dimensions for a solid raytrace plot. - - :param int32_t index: Index in the plots array - :param int32_t* width: Image width in pixels - :param int32_t* height: Image height in pixels - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_pixels(int32_t index, int32_t width, int32_t height) - - Set output pixel dimensions for a solid raytrace plot. - - :param int32_t index: Index in the plots array - :param int32_t width: Image width in pixels - :param int32_t height: Image height in pixels - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_color_by(int32_t index, int32_t* color_by) - - Get the domain type used for coloring (0=materials, 1=cells). - - :param int32_t index: Index in the plots array - :param int32_t* color_by: Coloring mode - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_color_by(int32_t index, int32_t color_by) - - Set the domain type used for coloring (0=materials, 1=cells). - - :param int32_t index: Index in the plots array - :param int32_t color_by: Coloring mode - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_default_colors(int32_t index) - - Set default random colors for the current ``color_by`` mode. - - :param int32_t index: Index in the plots array - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_all_opaque(int32_t index) - - Mark all domains in the current ``color_by`` mode as opaque. - - :param int32_t index: Index in the plots array - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_opaque(int32_t index, int32_t id, bool visible) - - Set whether a specific domain ID is opaque (visible) in the rendered image. - - :param int32_t index: Index in the plots array - :param int32_t id: Cell/material ID (based on ``color_by``) - :param bool visible: Whether the domain is opaque - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_color(int32_t index, int32_t id, uint8_t r, uint8_t g, uint8_t b) - - Set RGB color for a specific domain ID. - - :param int32_t index: Index in the plots array - :param int32_t id: Cell/material ID (based on ``color_by``) - :param uint8_t r: Red channel - :param uint8_t g: Green channel - :param uint8_t b: Blue channel - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_color(int32_t index, int32_t id, uint8_t* r, uint8_t* g, uint8_t* b) - - Get RGB color for a specific domain ID. - - :param int32_t index: Index in the plots array - :param int32_t id: Cell/material ID (based on ``color_by``) - :param uint8_t* r: Red channel - :param uint8_t* g: Green channel - :param uint8_t* b: Blue channel - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_camera_position(int32_t index, double* x, double* y, double* z) - - Get camera position. - - :param int32_t index: Index in the plots array - :param double* x: X coordinate - :param double* y: Y coordinate - :param double* z: Z coordinate - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_camera_position(int32_t index, double x, double y, double z) - - Set camera position. - - :param int32_t index: Index in the plots array - :param double x: X coordinate - :param double y: Y coordinate - :param double z: Z coordinate - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_look_at(int32_t index, double* x, double* y, double* z) - - Get camera target point. - - :param int32_t index: Index in the plots array - :param double* x: X coordinate - :param double* y: Y coordinate - :param double* z: Z coordinate - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_look_at(int32_t index, double x, double y, double z) - - Set camera target point. - - :param int32_t index: Index in the plots array - :param double x: X coordinate - :param double y: Y coordinate - :param double z: Z coordinate - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_up(int32_t index, double* x, double* y, double* z) - - Get the camera up vector. - - :param int32_t index: Index in the plots array - :param double* x: X component - :param double* y: Y component - :param double* z: Z component - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_up(int32_t index, double x, double y, double z) - - Set the camera up vector. - - :param int32_t index: Index in the plots array - :param double x: X component - :param double y: Y component - :param double z: Z component - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_light_position(int32_t index, double* x, double* y, double* z) - - Get light source position. - - :param int32_t index: Index in the plots array - :param double* x: X coordinate - :param double* y: Y coordinate - :param double* z: Z coordinate - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_light_position(int32_t index, double x, double y, double z) - - Set light source position. - - :param int32_t index: Index in the plots array - :param double x: X coordinate - :param double y: Y coordinate - :param double z: Z coordinate - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_fov(int32_t index, double* fov) - - Get horizontal field of view in degrees. - - :param int32_t index: Index in the plots array - :param double* fov: Field of view in degrees - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_fov(int32_t index, double fov) - - Set horizontal field of view in degrees. - - :param int32_t index: Index in the plots array - :param double fov: Field of view in degrees - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_get_diffuse_fraction(int32_t index, double* diffuse_fraction) - - Get diffuse-light fraction. - - :param int32_t index: Index in the plots array - :param double* diffuse_fraction: Diffuse fraction in [0, 1] - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_set_diffuse_fraction(int32_t index, double diffuse_fraction) - - Set diffuse-light fraction. - - :param int32_t index: Index in the plots array - :param double diffuse_fraction: Diffuse fraction in [0, 1] - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_update_view(int32_t index) - - Recompute internal camera/view transforms after camera changes. - - :param int32_t index: Index in the plots array - :return: Return status (negative if an error occurred) - :rtype: int - -.. c:function:: int openmc_solidraytrace_plot_create_image(int32_t index, uint8_t* data_out, int32_t width, int32_t height) - - Render the plot to an RGB image buffer. - - :param int32_t index: Index in the plots array - :param uint8_t* data_out: Output buffer of shape ``height*width*3`` - :param int32_t width: Image width in pixels - :param int32_t height: Image height in pixels - :return: Return status (negative if an error occurred) - :rtype: int - .. c:function:: int openmc_reset() Resets all tally scores @@ -851,10 +576,6 @@ Functions :return: Return status (negative if an error occurs) :rtype: int -.. c:function:: void openmc_run_random_ray() - - Run a random ray simulation - .. c:function:: int openmc_set_n_batches(int32_t n_batches, bool set_max_batches, bool add_statepoint_batch) Set number of batches and number of max batches diff --git a/docs/source/conf.py b/docs/source/conf.py index 61740239b..19c04d98a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,10 +11,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os -from pathlib import Path -import subprocess -import sys +import sys, os # Determine if we're on Read the Docs server on_rtd = os.environ.get('READTHEDOCS', None) == 'True' @@ -40,7 +37,6 @@ sys.path.insert(0, os.path.abspath('../..')) # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'breathe', 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.autosummary', @@ -51,14 +47,12 @@ extensions = [ ] if not on_rtd: extensions.append('sphinxcontrib.rsvgconverter') - doxygen_dir = Path(__file__).parents[1] / 'doxygen' - subprocess.run(['doxygen'], cwd=doxygen_dir, check=True) # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. -source_suffix = {'.rst': 'restructuredtext'} +source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8' @@ -68,17 +62,16 @@ master_doc = 'index' # General information about the project. project = 'OpenMC' -copyright = '2011-2026, Massachusetts Institute of Technology, UChicago Argonne LLC, and OpenMC contributors' +copyright = '2011-2024, Massachusetts Institute of Technology, UChicago Argonne LLC, and OpenMC contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # - -import openmc - +# The short X.Y version. +version = "0.15" # The full version, including alpha/beta/rc tags. -version = release = openmc.__version__ +release = "0.15.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -123,17 +116,13 @@ pygments_style = 'tango' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] -# -- Options breathe + doxygen ------------------------------------------------- - -breathe_projects = {"OpenMC": "../doxygen/xml"} -breathe_default_project = "OpenMC" -breathe_domain_by_file_pattern = {"*capi.h": "c"} # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages +import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' -html_baseurl = "https://docs.openmc.org/en/stable/" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] html_logo = '_images/openmc_logo.png' diff --git a/docs/source/devguide/agentic-tools.rst b/docs/source/devguide/agentic-tools.rst deleted file mode 100644 index fed377cc0..000000000 --- a/docs/source/devguide/agentic-tools.rst +++ /dev/null @@ -1,104 +0,0 @@ -.. _devguide_agentic_tools: - -=========================== -Agentic Development Tools -=========================== - -OpenMC ships a set of tools designed for AI coding agents (such as -`Claude Code`_) that agents can use to navigate and understand the codebase. - -.. _Claude Code: https://claude.ai/code - -Motivation ----------- - -Agentic tools like Claude Code are skilled at using grep to navigate and -understand large code bases. However, grep can only find exact text matches — -it cannot discover code that is *conceptually* related but uses different -naming. Without a "global view" of the codebase that a human developer will -build up over time, the agent is generally blind to any file it hasn't -tokenized fully. While it can grep to see who else calls a function, it -remains blind if other areas might be related but not share identical naming -conventions. - -This problem is mitigated somewhat by using a model with a longer context -window. OpenMC has somewhere around ~1 million tokens of C++ and ~1 million -tokens of python. While Claude Code in early 2026 only has a context window -of 200k tokens, beta versions have extended context windows of 1M tokens, -and it's not unreasonable to assume that models may be available in the near -future that greatly exceed these limits. - -However, even assuming the entire repository can be fit within a context -window, there are several downsides to doing this. -`Model performance degrades significantly as context size increases`_. -Benchmark results are -greatly improved if the model has less garbage to pick through. Additionally, API usage -is typically billed as tokens in/out per turn. As the context file -grows these costs become much larger. As such, there is still significant -motivation to solving the above problem, so as to ensure only relevant -information is drawn into context so as to maximize model performance and -minimize costs. - -Setup ------ - -The tools are registered as an `MCP (Model Context Protocol)`_ server in -``.mcp.json`` at the repository root. AI agents that support MCP (such as -Claude Code) discover them automatically on session start. The underlying -Python scripts can also be run directly from the command line. - -All tools run entirely locally — no API keys or external service accounts are -required. Python dependencies are installed automatically into an isolated -virtual environment at ``.claude/cache/.venv/`` on first use. - -.. _Model performance degrades significantly as context size increases: https://www.anthropic.com/news/claude-opus-4-6 -.. _MCP (Model Context Protocol): https://modelcontextprotocol.io - -RAG Semantic Search -------------------- - -The RAG (Retrieval-Augmented Generation) semantic search addresses this -problem — it finds code by meaning, not just text match, surfacing related code -across subsystems that ``grep`` would miss entirely. Two MCP tools are provided: - -- **openmc_rag_search** — Given a natural-language query, returns the most - relevant code chunks with file paths, line numbers, and a preview. Can search - code, documentation, or both. Can also find code related to a given file. -- **openmc_rag_rebuild** — Rebuilds the search index. Should be called after - pulling new code or switching branches. - -How it works -^^^^^^^^^^^^ - -The search pipeline runs entirely on your local CPU: - -1. **Chunking.** All C++, Python, and RST files are split into overlapping - fixed-size windows (~1000 characters, 25% overlap). This ensures every line - of code appears in at least one chunk and most lines appear in two. - -2. **Embedding.** Each chunk is embedded into a 384-dimensional vector using - the `all-MiniLM-L6-v2`_ sentence-transformer model (22 million parameters). - This model runs on CPU with no GPU required. No API key is needed — the - model weights are downloaded once from Hugging Face and cached locally. - -3. **Indexing.** The vectors are stored in a local LanceDB_ database on disk. - Building the full index takes approximately 5 minutes on a machine with - 10 CPU cores. The index is stored in ``.claude/cache/rag_index/`` and - persists across sessions. - -4. **Searching.** Your query is embedded using the same model, and the closest - chunks are retrieved by vector similarity. Results include the file path, - line range, file type, similarity distance, and a text preview. - -.. _all-MiniLM-L6-v2: https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2 -.. _LanceDB: https://lancedb.com - -Requirements -^^^^^^^^^^^^ - -No system dependencies beyond **Python 3.12+** with ``pip``. An internet -connection is required on first use to download the Python packages and -embedding model weights; subsequent runs are fully offline. The Python packages -(``sentence-transformers``, ``lancedb``) and their dependencies (including -PyTorch, ~2GB) are installed automatically into an isolated virtual environment -on first use. diff --git a/docs/source/devguide/contributing.rst b/docs/source/devguide/contributing.rst index 5199c9438..c08b1a362 100644 --- a/docs/source/devguide/contributing.rst +++ b/docs/source/devguide/contributing.rst @@ -109,10 +109,9 @@ Leadership Team The TC consists of the following individuals: - `Paul Romano `_ -- `Patrick Shriwise `_ +- `Sterling Harper `_ - `Adam Nelson `_ -- `Jonathan Shimwell `_ -- `John Tramm `_ +- `Benoit Forget `_ The Project Lead is Paul Romano. diff --git a/docs/source/devguide/docbuild.rst b/docs/source/devguide/docbuild.rst index cda0307ca..389a423f3 100644 --- a/docs/source/devguide/docbuild.rst +++ b/docs/source/devguide/docbuild.rst @@ -12,12 +12,7 @@ Python API. That is, from the root directory of the OpenMC repository: .. code-block:: sh - python -m pip install ".[docs]" - -The OpenMC documentation also uses Doxygen to automatically generate its -C/C++ API documentation directly from the docstrings available in the source -code. You will need to have a working installation of Doxygen to generate the -documentation locally. + python -m pip install .[docs] ----------------------------------- Building Documentation as a Webpage diff --git a/docs/source/devguide/docker.rst b/docs/source/devguide/docker.rst index 50ff29bd2..0b2191168 100644 --- a/docs/source/devguide/docker.rst +++ b/docs/source/devguide/docker.rst @@ -45,11 +45,12 @@ Now you can run the following to create a `Docker container`_ called This command will open an interactive shell running from within the Docker container where you have access to use OpenMC. -.. note:: The ``docker run`` command supports many options_ +.. note:: The ``docker run`` command supports many + `options `_ for spawning containers -- including `mounting volumes`_ from the host filesystem -- which many users will find useful. -.. _Docker image: https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-an-image/ +.. _Docker image: https://docs.docker.com/engine/reference/commandline/images/ .. _Docker container: https://www.docker.com/resources/what-container -.. _options: https://docs.docker.com/reference/cli/docker/container/run/ -.. _mounting volumes: https://docs.docker.com/engine/storage/volumes/ +.. _options: https://docs.docker.com/engine/reference/commandline/run/ +.. _mounting volumes: https://docs.docker.com/storage/volumes/ diff --git a/docs/source/devguide/index.rst b/docs/source/devguide/index.rst index 53b9f5853..2e131e094 100644 --- a/docs/source/devguide/index.rst +++ b/docs/source/devguide/index.rst @@ -14,7 +14,6 @@ other related topics. contributing workflow - agentic-tools styleguide policies tests diff --git a/docs/source/devguide/policies.rst b/docs/source/devguide/policies.rst index 3644ae822..2cf319987 100644 --- a/docs/source/devguide/policies.rst +++ b/docs/source/devguide/policies.rst @@ -21,8 +21,8 @@ C++ code in OpenMC must conform to the most recent C++ standard that is fully supported in the `version of the gcc compiler `_ that is distributed with the oldest version of Ubuntu that is still within its `standard support period -`_. Ubuntu 22.04 LTS will be supported -through April 2027 and is distributed with gcc 11.4.0, which fully supports the +`_. Ubuntu 20.04 LTS will be supported +through April 2025 and is distributed with gcc 9.3.0, which fully supports the C++17 standard. -------------------- @@ -31,5 +31,5 @@ CMake Version Policy Similar to the C++ standard policy, the minimum supported version of CMake corresponds to whatever version is distributed with the oldest version of Ubuntu -still within its standard support period. Ubuntu 22.04 LTS is distributed with -CMake 3.22. +still within its standard support period. Ubuntu 20.04 LTS is distributed with +CMake 3.16. diff --git a/docs/source/devguide/styleguide.rst b/docs/source/devguide/styleguide.rst index a5599566e..b266f5f02 100644 --- a/docs/source/devguide/styleguide.rst +++ b/docs/source/devguide/styleguide.rst @@ -30,7 +30,7 @@ whenever a file is saved. For example, `Visual Studio Code support for running clang-format. .. note:: - OpenMC's CI uses `clang-format` version 18. A different version of `clang-format` + OpenMC's CI uses `clang-format` version 15. A different version of `clang-format` may produce different line changes and as a result fail the CI test. Miscellaneous @@ -47,8 +47,7 @@ is more difficult to comment out a large section of code that uses C-style comments.) Do not use C-style casting. Always use the C++-style casts ``static_cast``, -``const_cast``, or ``reinterpret_cast``. (See `ES.49 -`_) +``const_cast``, or ``reinterpret_cast``. (See `ES.49 `_) Source Files ------------ @@ -56,7 +55,7 @@ Source Files Use a ``.cpp`` suffix for code files and ``.h`` for header files. Header files should always use include guards with the following style (See -`SF.8 `_): +`SF.8 `_): .. code-block:: C++ @@ -157,11 +156,11 @@ Prefer pathlib_ when working with filesystem paths over functions in the os_ module or other standard-library modules. Functions that accept arguments that represent a filesystem path should work with both strings and Path_ objects. -.. _C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines -.. _PEP8: https://peps.python.org/pep-0008/ +.. _C++ Core Guidelines: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines +.. _PEP8: https://www.python.org/dev/peps/pep-0008/ .. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html .. _numpy: https://numpy.org/ -.. _scipy: https://scipy.org/ +.. _scipy: https://www.scipy.org/ .. _matplotlib: https://matplotlib.org/ .. _pandas: https://pandas.pydata.org/ .. _h5py: https://www.h5py.org/ diff --git a/docs/source/devguide/tests.rst b/docs/source/devguide/tests.rst index 8627cbde2..d8fc53b3a 100644 --- a/docs/source/devguide/tests.rst +++ b/docs/source/devguide/tests.rst @@ -37,9 +37,6 @@ Prerequisites - Some tests require `NJOY `_ to preprocess cross section data. The test suite assumes that you have an ``njoy`` executable available on your :envvar:`PATH`. -- OpenMC should be compiled with ``-DOPENMC_ENABLE_STRICT_FP=on`` to ensure - reproducible floating-point results across platforms and optimization levels. - Without this flag, regression tests may not match reference values. Running Tests ------------- @@ -70,11 +67,9 @@ make sure you have satisfied all the prerequisites above. After you have done that, consider the following: - When building OpenMC, make sure you run CMake with - ``-DOPENMC_ENABLE_STRICT_FP=on``. This prevents the compiler from applying - floating-point optimizations (such as replacing math library calls with - builtins or contracting multiply-add into FMA instructions) that can produce - bit-level differences across platforms and optimization levels. Any - ``CMAKE_BUILD_TYPE`` can be used. + ``-DCMAKE_BUILD_TYPE=Debug``. Building with a release build will result in + some test failures due to differences in which compiler optimizations are + used. - Because tallies involve the sum of many floating point numbers, the non-associativity of floating point numbers can result in different answers especially when the number of threads is high (different order of operations). @@ -89,30 +84,6 @@ that, consider the following: limit the number of threads that OpenBLAS uses internally; this can be done by setting the :envvar:`OPENBLAS_NUM_THREADS` environment variable to 1. -Debugging Tests in CI ---------------------- - -Tests can be debugged in CI using a feature called -`tmate `_. -CI debugging can be -enabled by including "[gha-debug]" in the commit message. When the test fails, a -link similar to the one shown below will be provided in the GitHub Actions -output after failure occurs. Logging into the provided link will allow you to -debug the test in the CI environment. The following is an example of the output -shown in the CI log that provides the link to the tmate session: - -.. code-block:: text - :linenos: - - Created new session successfully - ssh 2VcykjU7vNdvAzEjQcc839GM2@nyc1.tmate.io - https://tmate.io/t/2VcykjU7vNdvAzEjQcc839GM2 - Entering main loop - Web shell: https://tmate.io/t/2VcykjU7vNdvAzEjQcc839GM2 - SSH: ssh 2VcykjU7vNdvAzEjQcc839GM2@nyc1.tmate.io - ... - - Generating XML Inputs --------------------- diff --git a/docs/source/devguide/user-input.rst b/docs/source/devguide/user-input.rst index bbae3b715..a26f98b19 100644 --- a/docs/source/devguide/user-input.rst +++ b/docs/source/devguide/user-input.rst @@ -55,6 +55,6 @@ developer or send a message to the `developers mailing list`_. .. _property attribute: https://docs.python.org/3.6/library/functions.html#property -.. _XML Schema Part 2: https://www.w3.org/TR/xmlschema-2/ -.. _boolean: https://www.w3.org/TR/xmlschema-2/#boolean +.. _XML Schema Part 2: http://www.w3.org/TR/xmlschema-2/ +.. _boolean: http://www.w3.org/TR/xmlschema-2/#boolean .. _developers mailing list: https://groups.google.com/forum/?fromgroups=#!forum/openmc-dev diff --git a/docs/source/devguide/workflow.rst b/docs/source/devguide/workflow.rst index c49326a20..d6a3c6ba4 100644 --- a/docs/source/devguide/workflow.rst +++ b/docs/source/devguide/workflow.rst @@ -91,30 +91,6 @@ features and bug fixes. The general steps for contributing are as follows: 6. After the pull request has been thoroughly vetted, it is merged back into the *develop* branch of openmc-dev/openmc. -Setting Up Upstream Tracking (Required for Versioning) ------------------------------------------------------- - -By default, your fork **does not** include tags from the upstream OpenMC repository. -OpenMC relies on `git describe --tags` for versioning in source builds, and missing tags can lead -to incorrect version detection (i.e., ``0.0.0``). To ensure proper versioning, follow these steps: - -1. **Add the Upstream Repository** - This allows you to fetch updates from the main OpenMC repository. - - .. code-block:: sh - - git remote add upstream https://github.com/openmc-dev/openmc.git - -2. **Fetch and Push Tags** - Retrieve tags from the upstream repository and update your fork: - - .. code-block:: sh - - git fetch --tags upstream - git push --tags origin - -This ensures that both your **local** and **remote** fork have the correct versioning information. - Private Development ------------------- @@ -150,10 +126,10 @@ reinstalling it). While the same effect can be achieved using the :envvar:`PYTHONPATH` environment variable, this is generally discouraged as it can interfere with virtual environments. -.. _git: https://git-scm.com/ +.. _git: http://git-scm.com/ .. _GitHub: https://github.com/ .. _git flow: https://nvie.com/git-model -.. _valgrind: https://valgrind.org/ +.. _valgrind: https://www.valgrind.org/ .. _style guide: https://docs.openmc.org/en/latest/devguide/styleguide.html .. _pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests .. _openmc-dev/openmc: https://github.com/openmc-dev/openmc diff --git a/docs/source/index.rst b/docs/source/index.rst index 97666e7c3..a01055374 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,7 +12,7 @@ files produced by NJOY. Parallelism is enabled via a hybrid MPI and OpenMP programming model. OpenMC was originally developed by members of the `Computational Reactor Physics -Group `_ at the `Massachusetts Institute of Technology +Group `_ at the `Massachusetts Institute of Technology `_ starting in 2011. Various universities, laboratories, and other organizations now contribute to the development of OpenMC. For more information on OpenMC, feel free to post a message on the `OpenMC Discourse diff --git a/docs/source/io_formats/collision_track.rst b/docs/source/io_formats/collision_track.rst deleted file mode 100644 index 4123fdac6..000000000 --- a/docs/source/io_formats/collision_track.rst +++ /dev/null @@ -1,46 +0,0 @@ -.. _io_collision_track: - -=========================== -Collision Track File Format -=========================== - -When collision tracking is enabled with ``mcpl=false`` (the default), OpenMC -writes binary data to an HDF5 file named ``collision_track.h5``. The same data -may also be written after each batch when multiple files are requested -(``collision_track.N.h5``) or when the run is performed in parallel. The file -contains the information needed to reconstruct each recorded collision. - -The current revision of the collision track file format is 1.2. - -**/** - -:Attributes: - - **filetype** (*char[]*) -- String indicating the type of file. - For collision-track files the value is ``"collision_track"``. - -:Datasets: - - - **collision_track_bank** (Compound type) -- Collision information - for each stored event. Each entry in the dataset corresponds to one - collision and contains the following fields: - - - ``r`` (*double[3]*) -- Position of the collision in [cm]. - - ``u`` (*double[3]*) -- Direction unit vector immediately after the collision. - - ``E`` (*double*) -- Incident particle energy before the collision in [eV]. - - ``dE`` (*double*) -- Energy loss over the collision (:math:`E_\text{before} - E_\text{after}`) in [eV]. - - ``time`` (*double*) -- Time of the collision in [s]. - - ``wgt`` (*double*) -- Particle weight at the collision. - - ``event_mt`` (*int*) -- ENDF MT number identifying the reaction. - - ``delayed_group`` (*int*) -- Delayed neutron group index (non-zero for delayed events). - - ``cell_id`` (*int*) -- ID of the cell in which the collision occurred. - - ``nuclide_id`` (*int*) -- PDG number of the nuclide (100ZZZAAAM). - - ``material_id`` (*int*) -- ID of the material containing the collision site. - - ``universe_id`` (*int*) -- ID of the universe containing the collision site. - - ``n_collision`` (*int*) -- Collision counter for the particle history. - - ``particle`` (*int32_t*) -- Particle type (PDG number). - - ``parent_id`` (*int64_t*) -- Unique ID of the parent particle. - - ``progeny_id`` (*int64_t*) -- Progeny ID of the particle. - -In an MPI run, OpenMC writes the combined dataset by gathering collision-track -entries from all ranks before flushing them to disk, so the final file appears -as though it were produced serially. diff --git a/docs/source/io_formats/depletion_chain.rst b/docs/source/io_formats/depletion_chain.rst index 74413e7b6..89c76525f 100644 --- a/docs/source/io_formats/depletion_chain.rst +++ b/docs/source/io_formats/depletion_chain.rst @@ -56,27 +56,6 @@ attributes: .. _io_chain_reaction: --------------------- -```` Element --------------------- - -The ```` element represents photon and electron sources associated with -the decay of a nuclide and contains information to construct an -:class:`openmc.stats.Univariate` object that represents this emission as an -energy distribution. This element has the following attributes: - - :type: - The type of :class:`openmc.stats.Univariate` source term. - - :particle: - The type of particle emitted, e.g., 'photon' or 'electron' - - :parameters: - The parameters of the source term, e.g., for a - :class:`openmc.stats.Discrete` source, the energies (in [eV]) at which the - particles are emitted and their relative intensities in [Bq/atom] (in other - words, decay constants). - ---------------------- ```` Element ---------------------- diff --git a/docs/source/io_formats/depletion_results.rst b/docs/source/io_formats/depletion_results.rst index 856993db6..7035fc9c9 100644 --- a/docs/source/io_formats/depletion_results.rst +++ b/docs/source/io_formats/depletion_results.rst @@ -4,7 +4,7 @@ Depletion Results File Format ============================= -The current version of the depletion results file format is 1.3. +The current version of the depletion results file format is 1.1. **/** @@ -12,31 +12,30 @@ The current version of the depletion results file format is 1.3. - **version** (*int[2]*) -- Major and minor version of the statepoint file format. -:Datasets: - **eigenvalues** (*double[][2]*) -- k-eigenvalues at each timestep. - This array has shape (number of timesteps, 2). The second axis - contains the eigenvalue and its associated uncertainty. - - **number** (*double[][][]*) -- Total number of atoms at each - timestep. This array has shape (number of timesteps, number of +:Datasets: - **eigenvalues** (*double[][][2]*) -- k-eigenvalues at each + time/stage. This array has shape (number of timesteps, number of + stages, value). The last axis contains the eigenvalue and the + associated uncertainty + - **number** (*double[][][][]*) -- Total number of atoms. This array + has shape (number of timesteps, number of stages, number of materials, number of nuclides). - - **reaction rates** (*double[][][][]*) -- Reaction rates at each - timestep. This array has shape (number of timesteps, number of - materials, number of nuclides, number of reactions). Only stored if - write_rates=True. + - **reaction rates** (*double[][][][][]*) -- Reaction rates used to + build depletion matrices. This array has shape (number of + timesteps, number of stages, number of materials, number of + nuclides, number of reactions). - **time** (*double[][2]*) -- Time in [s] at beginning/end of each step. - - **source_rate** (*double[]*) -- Power in [W] or source rate in - [neutron/sec] for each timestep. + - **source_rate** (*double[][]*) -- Power in [W] or source rate in + [neutron/sec]. This array has shape (number of timesteps, number + of stages). - **depletion time** (*double[]*) -- Average process time in [s] spent depleting a material across all burnable materials and, if applicable, MPI processes. - - **keff_search_root** (*double[]*) -- Root of the keff search at the - end of the timestep, if applicable. **/materials//** :Attributes: - **index** (*int*) -- Index used in results for this material - **volume** (*double*) -- Volume of this material in [cm^3] - - **name** (*char[]*) -- Name of this material **/nuclides//** diff --git a/docs/source/io_formats/geometry.rst b/docs/source/io_formats/geometry.rst index 5cd18bef1..ac48e48d2 100644 --- a/docs/source/io_formats/geometry.rst +++ b/docs/source/io_formats/geometry.rst @@ -38,9 +38,11 @@ Each ```` element can have the following attributes or sub-elements: :boundary: The boundary condition for the surface. This can be "transmission", - "vacuum", "reflective", or "periodic". Specify which planes are - periodic and the code will automatically identify which planes are - paired together. + "vacuum", "reflective", or "periodic". Periodic boundary conditions can + only be applied to x-, y-, and z-planes. Only axis-aligned periodicity is + supported, i.e., x-planes can only be paired with x-planes. Specify which + planes are periodic and the code will automatically identify which planes + are paired together. *Default*: "transmission" @@ -316,10 +318,9 @@ the following attributes or sub-elements: *Default*: None :orientation: - The orientation of the hexagonal lattice. The string "x" indicates that each - lattice element has two faces that are perpendicular to the x-axis, whereas - the string "y" indicates that each lattice element has two faces that are - perpendicular to the y-axis. + The orientation of the hexagonal lattice. The string "x" indicates that two + sides of the lattice are parallel to the x-axis, whereas the string "y" + indicates that two sides are parallel to the y-axis. *Default*: "y" @@ -406,64 +407,13 @@ Each ```` element can have the following attributes or sub-eleme *Default*: None - :cell: - Zero or more ```` sub-elements may appear to override properties of - individual DAGMC volumes. Each ```` element supports the following - attributes and sub-elements: - :id: - The integer cell ID in the DAGMC geometry to override. Required. + .. note:: A geometry.xml file containing only a DAGMC model for a file named `dagmc.h5m` (no CSG) + looks as follows - :name: - An optional string label for the cell. + .. code-block:: xml - *Default*: None - - :material: - The material ID to assign to this cell. Use ``void`` for vacuum. Multiple - space-separated IDs may be given to specify a distribmat (distributed - material) assignment. Required. - - :temperature: - Temperature(s) in [K] to assign to the cell. Must be greater than or equal - to 0. Multiple space-separated values may be given. - - *Default*: None - - :density: - Density in [g/cm³] to assign to the cell. Must be greater than 0. Requires a non-void - material fill. Multiple space-separated values may be given. - - *Default*: None - - :volume: - Volume of the cell in [cm³]. - - .. note:: DAGMC can compute cell volumes exactly from the triangulated - mesh surfaces. Specifying a manual volume risks inconsistency - with that capability. - - *Default*: None - - The following standard ```` attributes are **not** supported inside - ```` and will raise an error if present: ``region``, - ``fill``, ``universe``, ``translation``, ``rotation``. - - .. deprecated:: - The ```` sub-element (containing ```` - children with ````) is deprecated. A deprecation warning is - emitted and the overrides are converted to the ```` format at parse - time. It is an error to specify both ```` and - ```` sub-elements on the same ````. - - *Default*: None - -.. note:: A geometry.xml file containing only a DAGMC model for a file named - `dagmc.h5m` (no CSG) looks as follows: - - .. code-block:: xml - - - - - + + + + diff --git a/docs/source/io_formats/index.rst b/docs/source/io_formats/index.rst index 5b4efea66..4bbaa961a 100644 --- a/docs/source/io_formats/index.rst +++ b/docs/source/io_formats/index.rst @@ -44,7 +44,6 @@ Output Files statepoint source - collision_track summary properties depletion_results diff --git a/docs/source/io_formats/mgxs_library.rst b/docs/source/io_formats/mgxs_library.rst index 8a26311d1..f7f5387a4 100644 --- a/docs/source/io_formats/mgxs_library.rst +++ b/docs/source/io_formats/mgxs_library.rst @@ -133,10 +133,6 @@ Temperature-dependent data, provided for temperature K. This dataset is optional. This is a 1-D vector if `representation` is "isotropic", or a 3-D vector if `representation` is "angle" with dimensions of [polar][azimuthal][groups]. - When this data is not available, an approximation using the - group energy boundaries is used. For more information see - the particle speed subsection in the multigroup-data section - of the theory manual. **//K/scatter_data/** diff --git a/docs/source/io_formats/particle_restart.rst b/docs/source/io_formats/particle_restart.rst index e0fe76b9d..2734f0470 100644 --- a/docs/source/io_formats/particle_restart.rst +++ b/docs/source/io_formats/particle_restart.rst @@ -4,7 +4,7 @@ Particle Restart File Format ============================ -The current version of the particle restart file format is 2.1. +The current version of the particle restart file format is 2.0. **/** @@ -26,7 +26,8 @@ The current version of the particle restart file format is 2.1. - **run_mode** (*char[]*) -- Run mode used, either 'fixed source', 'eigenvalue', or 'particle restart'. - **id** (*int8_t*) -- Unique identifier of the particle. - - **type** (*int32_t*) -- Particle type (PDG number) + - **type** (*int*) -- Particle type (0=neutron, 1=photon, 2=electron, + 3=positron) - **weight** (*double*) -- Weight of the particle. - **energy** (*double*) -- Energy of the particle in eV for continuous-energy mode, or the energy group of the particle for diff --git a/docs/source/io_formats/plots.rst b/docs/source/io_formats/plots.rst index 1a42a4281..e6b75eafc 100644 --- a/docs/source/io_formats/plots.rst +++ b/docs/source/io_formats/plots.rst @@ -7,18 +7,13 @@ Geometry Plotting Specification -- plots.xml Basic plotting capabilities are available in OpenMC by creating a plots.xml file and subsequently running with the ``--plot`` command-line flag. The root element of the plots.xml is simply ```` and any number output plots can be -defined with ```` sub-elements. Four plot types are currently implemented +defined with ```` sub-elements. Two plot types are currently implemented in openMC: * ``slice`` 2D pixel plot along one of the major axes. Produces a PNG image file. * ``voxel`` 3D voxel data dump. Produces an HDF5 file containing voxel xyz position and cell or material id. -* ``wireframe_raytrace`` 2D pixel plot of a three-dimensional view of a - geometry using wireframes around cells or materials and coloring by depth - through each material. -* ``solid_raytrace`` 2D pixel plot of a three-dimensional view of a geometry - with solid colored surfaces of a set of cells or materials. ------------------ @@ -71,22 +66,21 @@ sub-elements: *Default*: None - Required entry :type: - Keyword for type of plot to be produced. Currently "slice", "voxel", - "wireframe_raytrace", and "solid_raytrace" plots are implemented. The - "slice" plot type creates 2D pixel maps saved in the PNG file format. The - "voxel" plot type produces a binary datafile containing voxel grid - positioning and the cell or material (specified by the ``color`` tag) at the - center of each voxel. Voxel plot files can be processed into VTK files using - the :func:`openmc.voxel_to_vtk` function and subsequently viewed with a 3D - viewer such as VISIT or Paraview. See :ref:`io_voxel` for information about - the datafile structure. + Keyword for type of plot to be produced. Currently only "slice" and "voxel" + plots are implemented. The "slice" plot type creates 2D pixel maps saved in + the PNG file format. The "voxel" plot type produces a binary datafile + containing voxel grid positioning and the cell or material (specified by the + ``color`` tag) at the center of each voxel. Voxel plot files can be + processed into VTK files using the :ref:`scripts_voxel` script provided with + OpenMC and subsequently viewed with a 3D viewer such as VISIT or Paraview. + See the :ref:`io_voxel` for information about the datafile structure. .. note:: High-resolution voxel files produced by OpenMC can be quite large, but the equivalent VTK files will be significantly smaller. *Default*: "slice" -All ```` elements must contain the ``pixels`` +```` elements of ``type`` "slice" and "voxel" must contain the ``pixels`` attribute or sub-element: :pixels: @@ -102,7 +96,7 @@ attribute or sub-element: ``width``/``pixels`` along that basis direction may not appear in the plot. - *Default*: None - Required entry for all plots + *Default*: None - Required entry for "slice" and "voxel" plots ```` elements of ``type`` "slice" can also contain the following attributes or sub-elements. These are not used in "voxel" plots: @@ -131,11 +125,6 @@ attributes or sub-elements. These are not used in "voxel" plots: Specifies the custom color for the cell or material. Should be 3 integers separated by spaces. - :xs: - The attenuation coefficient for volume rendering of color in units of - inverse centimeters. Zero corresponds to transparency. Only for plot type - "wireframe_raytrace". - As an example, if your plot is colored by material and you want material 23 to be blue, the corresponding ``color`` element would look like: @@ -162,18 +151,6 @@ attributes or sub-elements. These are not used in "voxel" plots: *Default*: 255 255 255 (white) - :show_overlaps: - Indicates whether overlapping regions of different cells are shown. - - *Default*: None - - :overlap_color: - Specifies the RGB color of overlapping regions of different cells. Does not - do anything if ``show_overlaps`` is "false" or not specified. Should be 3 - integers separated by spaces. - - *Default*: 255 0 0 (red) - :meshlines: The ``meshlines`` sub-element allows for plotting the boundaries of a regular mesh on top of a plot. Only one ``meshlines`` element is allowed per @@ -202,80 +179,3 @@ attributes or sub-elements. These are not used in "voxel" plots: *Default*: 0 0 0 (black) *Default*: None - -```` elements of ``type`` "wireframe_raytrace" or "solid_raytrace" can contain the -following attributes or sub-elements. - - :camera_position: - Location in 3D Cartesian space the camera is at. - - - *Default*: None - Required for all ``wireframe_raytrace`` or - ``solid_raytrace`` plots - - :look_at: - Location in 3D Cartesian space the camera is looking at. - - - *Default*: None - Required for all ``wireframe_raytrace`` or - ``solid_raytrace`` plots - - :field_of_view: - The horizontal field of view in degrees. Defaults to roughly the same value - as for the human eye. - - *Default*: 70 - - :orthographic_width: - If set to a nonzero value, an orthographic rather than perspective - projection for the camera is employed. An orthographic projection puts out - parallel rays from the camera of a width prescribed here in the horizontal - direction, with the width in the vertical direction decided by the pixel - aspect ratio. - - *Default*: 0 - -```` elements of ``type`` "solid_raytrace" can contain the following attributes or -sub-elements. - - :opaque_ids: - List of integer IDs of cells or materials to be treated as visible in the - plot. Whether the integers are interpreted as cell or material IDs depends - on ``color_by``. - - *Default*: None - Required for all phong plots - - :light_position: - Location in 3D Cartesian space of the light. - - - *Default*: Same location as ``camera_position`` - - :diffuse_fraction: - Fraction of light originating from non-directional sources. If set to one, - the coloring is not influenced by surface curvature, and no shadows appear. - If set to zero, only regions illuminated by the light are not black. - - - *Default*: 0.1 - -```` elements of ``type`` "wireframe_raytrace" can contain the following -attributes or sub-elements. - - :wireframe_color: - RGB value of the wireframe's color - - *Default*: 0, 0, 0 (black) - - :wireframe_thickness: - Integer number of pixels that the wireframe takes up. The value is a radius - of the wireframe. Setting to zero removes any wireframing. - - *Default*: 0 - - :wireframe_ids: - Integer IDs of cells or materials of regions to draw wireframes around. - Whether the integers are interpreted as cell or material IDs depends on - ``color_by``. - - *Default*: None diff --git a/docs/source/io_formats/properties.rst b/docs/source/io_formats/properties.rst index 4cc5da379..5030e78f3 100644 --- a/docs/source/io_formats/properties.rst +++ b/docs/source/io_formats/properties.rst @@ -4,7 +4,7 @@ Properties File Format ====================== -The current version of the properties file format is 1.1. +The current version of the properties file format is 1.0. **/** @@ -25,7 +25,6 @@ The current version of the properties file format is 1.1. **/geometry/cells/cell /** :Datasets: - **temperature** (*double[]*) -- Temperature of the cell in [K]. - - **density** (*double[]*) -- Density of the cell in [g/cm3]. **/materials/** diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 7091757f2..e395ada68 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -7,19 +7,6 @@ Settings Specification -- settings.xml All simulation parameters and miscellaneous options are specified in the settings.xml file. -------------------------------- -```` Element -------------------------------- - -The ```` element determines whether the atomic relaxation -cascade, the X-ray fluorescence photons and Auger electrons emitted when an -inner-shell vacancy is filled, is simulated following photoelectric and -incoherent (Compton) scattering interactions. Disabling this can speed up -photon transport calculations where the detailed secondary particle cascade is -not of interest. - - *Default*: true - --------------------- ```` Element --------------------- @@ -33,90 +20,6 @@ source neutrons. *Default*: None ------------------------------ -```` Element ------------------------------ - -The ```` element indicates to track information about particle -collisions based on a set of criteria and store these events in a file named -``collision_track.h5``. This file records details such as the position of the -interaction, direction of the incoming particle, incident energy and deposited -energy, weight, time of the interaction, and the delayed neutron group (0 for -prompt neutrons). Additional information such as the cell ID, material ID, -universe ID, nuclide ZAID, particle type, and event MT number are also stored. -Users can specify one or more criterion to filter collisions. If no criteria are -specified, it defaults to tracking all collisions across the model. - -.. warning:: - Storing all collisions can be very memory intensive. For more targeted - tracking, users can employ a variety of parameters such as ``cell_ids``, - ``reactions``, ``universe_ids``, ``material_ids``, ``nuclides``, and - ``deposited_E_threshold`` to refine the selection of particle interactions - to be banked. - -This element can contain one or more of the following attributes or -sub-elements: - - :max_collisions: - An integer indicating the maximum number of collisions to be banked per file. - - *Default*: 1000 - - :max_collision_track_files: - An integer indicating the number of collision_track files to be used. - - *Default*: 1 - - :mcpl: - An optional boolean to enable MCPL_-format instead of the native HDF5-based - format. If activated, the output file name and type is changed to - ``collision_track.mcpl``. - - *Default*: false - - .. _MCPL: https://mctools.github.io/mcpl/mcpl.pdf - - :cell_ids: - A list of integers representing cell IDs to define specific cells in which - collisions are to be banked. - - *Default*: None - - :universe_ids: - A list of integers representing the universe IDs to define specific - universes in which collisions are to be banked. - - *Default*: None - - :material_ids: - A list of integers representing the material IDs to define specific - materials in which collisions are to be banked. - - *Default*: None - - :nuclides: - A list of strings representing the nuclide, to define specific - define specific target nuclide collisions to be banked. - - .. note:: - Electron and positron collision-track events are not associated with - a specific nuclide. If a ``nuclides`` entry is specified, these events - are omitted. - - *Default*: None - - :reactions: - A list of integers representing the ENDF-6 format MT numbers or strings - (e.g. (n,fission)) to define specific reaction types to be banked. - - *Default*: None - - :deposited_E_threshold: - A float defining the minimum deposited energy per collision (in eV) to - trigger banking. - - *Default*: 0.0 - ---------------------------------- ```` Element ---------------------------------- @@ -178,13 +81,6 @@ time. *Default*: 1.0 - :survival_normalization: - If this element is set to "true", this will enable the use of survival - biasing source normalization, whereby the weight parameters, weight and - weight_avg, are multiplied per history by the start weight of said history. - - *Default*: false - :energy_neutron: The energy under which neutrons will be killed. @@ -275,16 +171,6 @@ history-based parallelism. *Default*: false --------------------------------- -```` Element --------------------------------- - -The ```` element specifies the energy multiplier, expressed -in units of :math:`kT`, that determines when the free gas scattering approach is -used for elastic scattering. Values must be positive. - - *Default*: 400.0 - ----------------------------------- ```` Element ----------------------------------- @@ -295,15 +181,6 @@ ignored for all run modes other than "eigenvalue". *Default*: 1 ------------------------------- -```` Element ------------------------------- - -The ```` element indicates the number of generations to -consider for the Iterated Fission Probability method. - - *Default*: 10 - ---------------------- ```` Element ---------------------- @@ -361,7 +238,7 @@ based on the recommended value in LA-UR-14-24530_. .. note:: This element is not used in the multi-group :ref:`energy_mode`. -.. _LA-UR-14-24530: https://mcnp.lanl.gov/pdf_files/TechReport_2014_LANL_LA-UR-14-24530_Brown.pdf +.. _LA-UR-14-24530: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/la-ur-14-24530.pdf --------------------------- ```` @@ -375,29 +252,11 @@ to false. *Default*: true --------------------------------- -```` Element --------------------------------- - -This element indicates the maximum number of lost particles. - - *Default*: 10 - ------------------------------------- -```` Element ------------------------------------- - - -This element indicates the maximum number of lost particles, relative to the -total number of particles. - - *Default*: 1.0e-6 - ------------------------------------- ```` Element ------------------------------------- -This element indicates the number of particles to run in flight concurrently +This element indicates the number of neutrons to run in flight concurrently when using event-based parallelism. A higher value uses more memory, but may be more efficient computationally. @@ -429,25 +288,7 @@ then, OpenMC will only use up to the :math:`P_1` data. ```` Element -------------------------------- -The ```` element indicates the number of times a particle -can split during a history. - - *Default*: 1000 - ------------------------------ -```` Element ------------------------------ - -The ```` element indicates the maximum secondary bank size. - - *Default*: 10000 - ------------------------- -```` Element ------------------------- - -The ```` element indicates the maximum number of tracks written to a -track file (per MPI process). +The ```` element indicates the number of times a particle can split during a history. *Default*: 1000 @@ -560,18 +401,6 @@ generator during generation of colors in plots. *Default*: 1 -.. _properties_file: - ------------------------------ -```` Element ------------------------------ - - The ``properties_file`` element has no attributes and contains the path to a - properties HDF5 file to load cell temperatures/densities and material - densities. - - *Default*: None - --------------------- ```` Element --------------------- @@ -602,7 +431,7 @@ found in the :ref:`random ray user guide `. *Default*: None - :ray_source: + :source: Specifies the starting ray distribution, and follows the format for :ref:`source_element`. It must be uniform in space and angle and cover the full domain. It does not represent a physical neutron or photon source -- it @@ -610,67 +439,6 @@ found in the :ref:`random ray user guide `. *Default*: None - :adjoint_source: - Specifies an adjoint fixed source for adjoint transport simulations, and - follows the format for :ref:`source_element`. The distributions which make - up the adjoint source are subject to the same restrictions as forward - fixed sources in Random Ray mode. - - *Default*: None - - :adjoint: - Specifies whether to perform adjoint transport. The default is 'False', - corresponding to forward transport. - - *Default*: None - - :volume_estimator: - Specifies choice of volume estimator for the random ray solver. Options - are 'naive', 'simulation_averaged', or 'hybrid'. The default is 'hybrid'. - - *Default*: None - - :volume_normalized_flux_tallies: - Specifies whether to normalize flux tallies by volume (bool). The - default is 'False'. When enabled, flux tallies will be reported in units - of cm/cm^3. When disabled, flux tallies will be reported in units of cm - (i.e., total distance traveled by neutrons in the spatial tally - region). - - *Default*: None - - :sample_method: - Specifies the method for sampling the starting ray distribution. This - element can be set to "prng" or "halton". - - *Default*: prng - - :source_region_meshes: - Relates meshes to spatial domains for subdividing source regions with each domain. - - :mesh: - Contains an ``id`` attribute and one or more ```` sub-elements. - - :id: - The unique identifier for the mesh. - - :domain: - Each domain element has an ``id`` attribute and a ``type`` attribute. - - :id: - The unique identifier for the domain. - - :type: - The type of the domain. Can be ``material``, ``cell``, or ``universe``. - - :diagonal_stabilization_rho: - The rho factor for use with diagonal stabilization. This technique is - applied when negative diagonal (in-group) elements are detected in - the scattering matrix of input MGXS data, which is a common feature - of transport corrected MGXS data. - - *Default*: 1.0 - ---------------------------------- ```` Element ---------------------------------- @@ -746,17 +514,6 @@ pseudo-random number generator. *Default*: 1 ------------------------------------ -```` Element ------------------------------------ - - The ``shared_secondary_bank`` element indicates whether to use a shared - secondary particle bank. When enabled, secondary particles are collected into - a global bank, sorted for reproducibility, and load-balanced across MPI ranks - between generations. If not specified, the shared secondary bank is enabled - automatically for fixed-source simulations with weight windows active, and - disabled otherwise. - .. _source_element: -------------------- @@ -777,15 +534,12 @@ attributes/sub-elements: *Default*: 1.0 :type: - Indicator of source type. One of ``independent``, ``file``, ``compiled``, - ``mesh``, or ``tokamak``. The type of the source will be determined by this - attribute if it is present. + Indicator of source type. One of ``independent``, ``file``, ``compiled``, or + ``mesh``. The type of the source will be determined by this attribute if it + is present. :particle: - The source particle type, specified as a PDG number or a string alias (e.g., - ``neutron``/``n``, ``photon``/``gamma``, ``electron``, ``positron``, - ``proton``/``p``, ``deuteron``/``d``, ``triton``/``t``, ``alpha``, or GNDS - nuclide names like ``Fe57``). + The source particle type, either ``neutron`` or ``photon``. *Default*: neutron @@ -825,38 +579,24 @@ attributes/sub-elements: :type: The type of spatial distribution. Valid options are "box", "fission", - "point", "cartesian", "cylindrical", "spherical", "mesh", and "cloud". - - A "box" spatial distribution has coordinates sampled uniformly in a - parallelepiped. - - A "fission" spatial distribution samples locations from a "box" + "point", "cartesian", "cylindrical", and "spherical". A "box" spatial + distribution has coordinates sampled uniformly in a parallelepiped. A + "fission" spatial distribution samples locations from a "box" distribution but only locations in fissionable materials are accepted. - A "point" spatial distribution has coordinates specified by a triplet. - A "cartesian" spatial distribution specifies independent distributions of - x-, y-, and z-coordinates. - - A "cylindrical" spatial distribution specifies independent distributions - of r-, phi-, and z-coordinates where phi is the azimuthal angle and the - origin for the cylindrical coordinate system is specified by origin. - - A "spherical" spatial distribution specifies independent distributions of - r-, cos_theta-, and phi-coordinates where cos_theta is the cosine of the - angle with respect to the z-axis, phi is the azimuthal angle, and the - sphere is centered on the coordinate (x0,y0,z0). - - A "mesh" spatial distribution samples source sites from a mesh element + x-, y-, and z-coordinates. A "cylindrical" spatial distribution specifies + independent distributions of r-, phi-, and z-coordinates where phi is the + azimuthal angle and the origin for the cylindrical coordinate system is + specified by origin. A "spherical" spatial distribution specifies + independent distributions of r-, cos_theta-, and phi-coordinates where + cos_theta is the cosine of the angle with respect to the z-axis, phi is + the azimuthal angle, and the sphere is centered on the coordinate + (x0,y0,z0). A "mesh" spatial distribution samples source sites from a mesh element based on the relative strengths provided in the node. Source locations within an element are sampled isotropically. If no strengths are provided, the space within the mesh is uniformly sampled. - A "cloud" spatial distribution samples source sites from a list of spatial - positions provided in the node, based on the relative strengths provided - in the node. If no strengths are provided, the positions are uniformly - sampled. - *Default*: None :parameters: @@ -875,7 +615,6 @@ attributes/sub-elements: For a "cylindrical" distribution, no parameters are specified. Instead, the ``r``, ``phi``, ``z``, and ``origin`` elements must be specified. - Optionally, the ``r_dir`` and ``z_dir`` elements could be specified. For a "spherical" distribution, no parameters are specified. Instead, the ``r``, ``theta``, ``phi``, and ``origin`` elements must be specified. @@ -907,10 +646,6 @@ attributes/sub-elements: of a univariate probability distribution (see the description in :ref:`univariate`). - :r_dir: - For "cylindrical" distributions, this element specifies the direction - of the cylinder r-axis at phi=0. Defaults to (1.0, 0.0, 0.0). - :theta: For a "spherical" distribution, this element specifies the distribution of theta-coordinates. The necessary sub-elements/attributes are those of a @@ -923,39 +658,10 @@ attributes/sub-elements: sub-elements/attributes are those of a univariate probability distribution (see the description in :ref:`univariate`). - :z_dir: - For "cylindrical" distributions, this element specifies the direction - of the cylinder z-axis. Defaults to (0.0, 0.0, 1.0). - :origin: For "cylindrical and "spherical" distributions, this element specifies the coordinates for the origin of the coordinate system. - :mesh_id: - For "mesh" spatial distributions, this element specifies which mesh ID to - use for the geometric description of the mesh. - - :coords: - For "cloud" distributions, this element specifies a list of coordinates - for each of the points in the cloud. - - :strengths: - For "mesh" and "cloud" spatial distributions, this element specifies the - relative source strength of each mesh element or each point in the cloud. - - :volume_normalized: - For "mesh" spatial distributions, this optional boolean element specifies - whether the vector of relative strengths should be multiplied by the mesh - element volume. This is most common if the strengths represent a source - per unit volume. - - *Default*: false - - :bias: - For "mesh" and "cloud" spatial distributions, this optional element - specifies floating point values corresponding to alternative probabilities - for each value/component to use for biased sampling. - :angle: An element specifying the angular distribution of source sites. This element has the following attributes: @@ -988,10 +694,6 @@ attributes/sub-elements: are those of a univariate probability distribution (see the description in :ref:`univariate`). - :bias: - For "isotropic" angular distributions, this optional element specifies a - "mu-phi" angular distribution used for biased sampling. - :energy: An element specifying the energy distribution of source sites. The necessary sub-elements/attributes are those of a univariate probability distribution @@ -1015,84 +717,6 @@ attributes/sub-elements: mesh element and follows the format for :ref:`source_element`. The number of ```` sub-elements should correspond to the number of mesh elements. - For a source with ``type="tokamak"``, the spatial distribution is described by - a Miller-style flux-surface parameterization and the following sub-elements - are used instead of the ``space`` element: - - :major_radius: - The major radius :math:`R_0` of the plasma in [cm]. - - :minor_radius: - The minor radius :math:`a` of the plasma in [cm]. Must be smaller than - ``major_radius``. - - :elongation: - The plasma elongation :math:`\kappa` (must be > 0). - - :triangularity: - The plasma triangularity :math:`\delta` (must be in [-1, 1]). Negative - values describe negative-triangularity plasmas. - - :shafranov_shift: - The Shafranov shift :math:`\Delta` in [cm] (must be >= 0 and less than - ``minor_radius``/2). - - :r_over_a: - A list of normalized minor-radius grid points :math:`r/a`. Must be strictly - increasing, start at 0, and end at 1. - - :emission_density: - A list of neutron emission densities :math:`S(r)` evaluated at each - ``r_over_a`` grid point (arbitrary units, must be non-negative). Only the - shape matters, since the profile is normalized internally. Values are - interpolated linearly between grid points and the profile is refined on an - internal grid for radial sampling. Must have the same length as - ``r_over_a`` and contain at least one positive value. - - :phi_start: - The starting toroidal angle in [rad]. - - *Default*: 0.0 - - :phi_extent: - The toroidal angle extent in [rad]. The source is sampled uniformly in - :math:`[\phi_\text{start},\ \phi_\text{start} + \phi_\text{extent}]`. - - *Default*: :math:`2\pi` - - :n_alpha: - The number of poloidal-angle grid points used to build the sampling CDFs - (must be > 2). Larger values reduce discretization bias; values below 51 - produce a warning. - - *Default*: 101 - - :vertical_shift: - A vertical shift of the plasma center in [cm]. - - *Default*: 0.0 - - :energy: - For a tokamak source, one or more ``energy`` sub-elements specify the - neutron energy distribution(s). Either a single distribution is given (used - at all radii) or exactly one distribution per ``r_over_a`` grid point is - given, in which case the energy is sampled from one of the two - distributions bracketing the sampled radius, selected stochastically with - probability proportional to the proximity of the radius to each grid point - (stochastic interpolation). Each follows the format of a univariate - probability distribution (see :ref:`univariate`). - - :time: - An optional ``time`` sub-element specifying the time distribution of source - particles, following the format of a univariate probability distribution - (see :ref:`univariate`). - - *Default*: particles are born at :math:`t=0` - - .. note:: Biased sampling can be applied to the spatial and energy distributions - of a source by using the ```` sub-element (see - :ref:`univariate` for details on how to specify bias distributions). - :constraints: This sub-element indicates the presence of constraints on sampled source sites (see :ref:`usersguide_source_constraints` for details). It may have @@ -1139,19 +763,17 @@ variable and whose sub-elements/attributes are as follows: :type: The type of the distribution. Valid options are "uniform", "discrete", - "tabular", "maxwell", "watt", "mixture", and "decay_spectrum". The "uniform" - option produces variates sampled from a uniform distribution over a finite - interval. The "discrete" option produces random variates that can assume a - finite number of values (i.e., a distribution characterized by a probability - mass function). The "tabular" option produces random variates sampled from a - tabulated distribution where the density function is either a histogram or + "tabular", "maxwell", "watt", and "mixture". The "uniform" option produces + variates sampled from a uniform distribution over a finite interval. The + "discrete" option produces random variates that can assume a finite number + of values (i.e., a distribution characterized by a probability mass function). + The "tabular" option produces random variates sampled from a tabulated + distribution where the density function is either a histogram or linearly-interpolated between tabulated points. The "watt" option produces random variates is sampled from a Watt fission spectrum (only used for energies). The "maxwell" option produce variates sampled from a Maxwell - fission spectrum (only used for energies). The "mixture" option produces - samples from univariate sub-distributions with given probabilities. The - "decay_spectrum" option produces photon energies sampled from decay photon - spectra in a depletion chain (only used for energies). + fission spectrum (only used for energies). The "mixture" option produces samples + from univariate sub-distributions with given probabilities. *Default*: None @@ -1169,10 +791,6 @@ variable and whose sub-elements/attributes are as follows: :math:`(x,p)` pairs defining the discrete/tabular distribution. All :math:`x` points are given first followed by corresponding :math:`p` points. - For a "decay_spectrum" distribution, ``parameters`` gives the atom densities - in [atom/b-cm] for the nuclides listed in the ``nuclides`` element, in the - same order. - For a "watt" distribution, ``parameters`` should be given as two real numbers :math:`a` and :math:`b` that parameterize the distribution :math:`p(x) dx = c e^{-x/a} \sinh \sqrt{b \, x} dx`. @@ -1191,51 +809,30 @@ variable and whose sub-elements/attributes are as follows: *Default*: histogram :pair: - For a "mixture" distribution, this element provides a distribution and its - corresponding probability. + For a "mixture" distribution, this element provides a distribution and its corresponding probability. :probability: - An attribute or ``pair`` that provides the probability of a univariate - distribution within a "mixture" distribution. + An attribute or ``pair`` that provides the probability of a univariate distribution within a "mixture" distribution. :dist: - This sub-element of a ``pair`` element provides information on the - corresponding univariate distribution. + This sub-element of a ``pair`` element provides information on the corresponding univariate distribution. -:volume: - For a "decay_spectrum" distribution, this attribute specifies the source - region volume in cm\ :sup:`3`. It is used together with atom densities to - determine the absolute photon emission rate. When a source uses a - "decay_spectrum" energy distribution, the source strength is set from this - emission rate. +------------------------- +```` Element +------------------------- -:nuclides: - For a "decay_spectrum" distribution, this element specifies a - whitespace-separated list of nuclide names contributing to the decay photon - source. The atom densities for these nuclides are given by the ``parameters`` - element in the same order. Nuclides are resolved against the depletion chain, - and nuclides without decay photon spectra do not contribute to the - distribution. +The ```` element indicates at what batches a state point file +should be written. A state point file can be used to restart a run or to get +tally results at any batch. The default behavior when using this tag is to +write out the source bank in the state_point file. This behavior can be +customized by using the ```` element. This element has the +following attributes/sub-elements: -:bias: - This optional element specifies a biased distribution for importance sampling. - For continuous distributions, the ``bias`` element should contain another - univariate distribution with the same support (interval) as the parent - distribution. For discrete distributions, the ``bias`` element should contain - floating point values corresponding to alternative probabilities for each - value/component to be used for biased sampling. + :batches: + A list of integers separated by spaces indicating at what batches a state + point file should be written. - *Default*: None - ---------------------------------------- -```` Element ---------------------------------------- - -The ```` element specifies the minimum fraction of -external source sites that must be accepted when applying rejection sampling -based on constraints. - - *Default*: 0.05 + *Default*: Last batch only -------------------------- ```` Element @@ -1286,32 +883,6 @@ attributes/sub-elements: *Default*: false -------------------------- -```` Element -------------------------- - -The ```` element indicates at what batches a state point file -should be written. A state point file can be used to restart a run or to get -tally results at any batch. The default behavior when using this tag is to -write out the source bank in the state_point file. This behavior can be -customized by using the ```` element. This element has the -following attributes/sub-elements: - - :batches: - A list of integers separated by spaces indicating at what batches a state - point file should be written. - - *Default*: Last batch only - --------------------- -```` Element --------------------- - -The ``stride`` element is used to specify how many random numbers are allocated -for each source particle history. - - *Default*: 152,917 - ------------------------------ ```` Element ------------------------------ @@ -1352,15 +923,6 @@ attributes/sub-elements: *Default*: None - :max_source_files: - An integer value indicating the number of surface source files to be written - containing the maximum number of particles each. The surface source bank - will be cleared in simulation memory each time a surface source file is - written. By default a ``surface_source.h5`` file will be created when the - maximum number of saved particles is reached. - - *Default*: 1 - :mcpl: An optional boolean which indicates if the banked particles should be written to a file in the MCPL_-format instead of the native HDF5-based @@ -1399,23 +961,6 @@ attributes/sub-elements: are not eligible to store any particles when using ``cell``, ``cellfrom`` or ``cellto`` attributes. It is recommended to use surface IDs instead. ------------------------------------- -```` Element ------------------------------------- - -The ```` element specifies the surface flux cosine cutoff. - - *Default*: 0.001 - ------------------------------------ -```` Element ------------------------------------ - -The ```` element specifies the surface flux cosine -substitution ratio. - - *Default*: 0.5 - ------------------------------ ```` Element ------------------------------ @@ -1599,15 +1144,6 @@ has the following attributes/sub-elements: for fixed source and small criticality calculations, but is very optimistic for highly coupled full-core reactor problems. -------------------------------------- -```` Element -------------------------------------- - -The ```` element indicates whether to sample among -multiple sources uniformly, applying their strengths as weights to sampled -particles. - - *Default*: False ------------------------ ```` Element @@ -1620,16 +1156,6 @@ Agency Monte Carlo Performance Benchmark Problem," Proceedings of *Physor 2012*, Knoxville, TN (2012). The mesh should cover all possible fissionable materials in the problem and is specified using a :ref:`mesh_element`. -------------------------------- -```` Element -------------------------------- - -The ```` element indicates whether to produce decay photons -from neutron reactions instead of prompt photons. This is used in conjunction -with the direct 1-step method for shutdown dose rate calculations. - - *Default*: False - .. _verbosity: ----------------------- @@ -1731,8 +1257,7 @@ sub-elements/attributes: *Default*: None :particle_type: - The particle that the weight windows will apply to, specified as a PDG - code or string (e.g., ``neutron``). + The particle that the weight windows will apply to (e.g., 'neutron') *Default*: 'neutron' @@ -1792,8 +1317,7 @@ mesh-based weight windows. *Default*: None :particle_type: - The particle that the weight windows will apply to, specified as a PDG - code or string (e.g., ``neutron``). + The particle that the weight windows will apply to (e.g., 'neutron') *Default*: neutron @@ -1813,7 +1337,7 @@ mesh-based weight windows. *Default*: true :method: - Method used to update weight window values (one of 'magic' or 'fw_cadis') + Method used to update weight window values (currently only 'magic' is supported) *Default*: magic @@ -1837,14 +1361,6 @@ mesh-based weight windows. *Default*: 5.0 - For FW-CADIS: - - :targets: - A sequence of IDs corresponding to the tallies which cover phase - space regions of interest for local variance reduction. - - *Default*: None - --------------------------------------- ```` Element --------------------------------------- @@ -1870,21 +1386,3 @@ following sub-elements/attributes: The ``weight_windows_file`` element has no attributes and contains the path to a weight windows HDF5 file to load during simulation initialization. - -------------------------------- -```` Element -------------------------------- - - The ``weight_windows_on`` element indicates whether weight windows are - enabled. - - *Default*: False - ----------------------------------- -```` Element ----------------------------------- - - The ``write_initial_source`` element indicates whether to write the initial - source distribution to file. - - *Default*: False diff --git a/docs/source/io_formats/source.rst b/docs/source/io_formats/source.rst index 2e81e0a3f..4ce2229ed 100644 --- a/docs/source/io_formats/source.rst +++ b/docs/source/io_formats/source.rst @@ -15,8 +15,6 @@ following the same format. **/** :Attributes: - **filetype** (*char[]*) -- String indicating the type of file. - - **version** (*int[2]*) -- Major and minor version of the source - file format. :Datasets: @@ -24,5 +22,5 @@ following the same format. particle. The compound type has fields ``r``, ``u``, ``E``, ``time``, ``wgt``, ``delayed_group``, ``surf_id`` and ``particle``, which represent the position, direction, energy, time, weight, - delayed group, surface ID, and particle type (PDG number), - respectively. + delayed group, surface ID, and particle type (0=neutron, 1=photon, + 2=electron, 3=positron), respectively. diff --git a/docs/source/io_formats/statepoint.rst b/docs/source/io_formats/statepoint.rst index 7d7765b84..f61e967ca 100644 --- a/docs/source/io_formats/statepoint.rst +++ b/docs/source/io_formats/statepoint.rst @@ -4,7 +4,7 @@ State Point File Format ======================= -The current version of the statepoint file format is 18.2. +The current version of the statepoint file format is 18.1. **/** @@ -23,7 +23,6 @@ The current version of the statepoint file format is 18.2. bank is present (1) or not (0). :Datasets: - **seed** (*int8_t*) -- Pseudo-random number generator seed. - - **stride** (*uint64_t*) -- Pseudo-random number generator stride. - **energy_mode** (*char[]*) -- Energy mode of the run, either 'continuous-energy' or 'multi-group'. - **run_mode** (*char[]*) -- Run mode used, either 'eigenvalue' or @@ -56,8 +55,8 @@ The current version of the statepoint file format is 18.2. ``time``, ``wgt``, ``delayed_group``, ``surf_id``, and ``particle``, which represent the position, direction, energy, time, weight, delayed group, surface ID, and particle type - (PDG number), respectively. Only present when `run_mode` is - 'eigenvalue'. + (0=neutron, 1=photon, 2=electron, 3=positron), respectively. Only + present when `run_mode` is 'eigenvalue'. **/tallies/** @@ -73,10 +72,7 @@ The current version of the statepoint file format is 18.2. **/tallies/meshes/mesh /** -:Attributes: - **id** (*int*) -- ID of the mesh - -:Datasets: - **name** (*char[]*) -- Name of the mesh. - - **type** (*char[]*) -- Type of mesh. +:Datasets: - **type** (*char[]*) -- Type of mesh. - **dimension** (*int*) -- Number of mesh cells in each dimension. - **Regular Mesh Only:** - **lower_left** (*double[]*) -- Coordinates of lower-left corner of @@ -149,8 +145,6 @@ The current version of the statepoint file format is 18.2. tallies will have a value of 0 unless otherwise instructed. - **multiply_density** (*int*) -- Flag indicating whether reaction rates should be multiplied by atom density (1) or not (0). - - **higher_moments** (*int*) -- Flag indicating whether - higher-order tally moments are enabled (1) or not (0). :Datasets: - **n_realizations** (*int*) -- Number of realizations. - **n_filters** (*int*) -- Number of filters used. diff --git a/docs/source/io_formats/summary.rst b/docs/source/io_formats/summary.rst index 64ca68b9c..7d3ab94d9 100644 --- a/docs/source/io_formats/summary.rst +++ b/docs/source/io_formats/summary.rst @@ -4,7 +4,7 @@ Summary File Format =================== -The current version of the summary file format is 6.1. +The current version of the summary file format is 6.0. **/** @@ -38,7 +38,6 @@ The current version of the summary file format is 6.1. is an array if the cell uses distributed materials, otherwise it is a scalar. - **temperature** (*double[]*) -- Temperature of the cell in Kelvin. - - **density** (*double[]*) -- Density of the cell in [g/cm3]. - **translation** (*double[3]*) -- Translation applied to the fill universe. This dataset is present only if fill_type is set to 'universe'. diff --git a/docs/source/io_formats/tallies.rst b/docs/source/io_formats/tallies.rst index dc57e5775..78101ab66 100644 --- a/docs/source/io_formats/tallies.rst +++ b/docs/source/io_formats/tallies.rst @@ -109,7 +109,7 @@ The ```` element accepts the following sub-elements: prematurely if there are no hits in any bins at the first evalulation. It is the user's responsibility to specify enough particles per batch to get a nonzero score in at least one bin. - + *Default*: False :scores: @@ -142,9 +142,9 @@ attributes/sub-elements: :type: The type of the filter. Accepted options are "cell", "cellfrom", - "cellborn", "surface", "material", "universe", "energy", "energyout", - "mu", "polar", "azimuthal", "mesh", "distribcell", "delayedgroup", - "energyfunction", "particle", and "particleproduction". + "cellborn", "surface", "material", "universe", "energy", "energyout", "mu", + "polar", "azimuthal", "mesh", "distribcell", "delayedgroup", + "energyfunction", and "particle". :bins: A description of the bins for each type of filter can be found in @@ -318,34 +318,8 @@ should be set to: they use ``energy`` and ``y``. :particle: - A list of particle identifiers to tally, specified as strings (e.g., - ``neutron``, ``photon``, ``He4``) or as integer PDG numbers. - -:particleproduction: - This filter tallies secondary particles produced in reactions, binned by - particle type and, optionally, by energy. Unlike other energy filters, the - weight applied is the weight of the secondary particle. To obtain secondary - particle production rates, use this filter with the ``events`` score. - - The filter uses the following sub-elements instead of ``bins``: - - :particles: - A space-separated list of secondary particle types to tally (e.g., - ``photon``, ``neutron``, ``electron``). - - :energies: - An optional monotonically increasing list of energy boundaries in [eV] - for binning the secondary particle energies. If omitted, total production - is tallied without energy binning. - - For example, to tally photon and neutron production in three energy groups: - - .. code-block:: xml - - - photon neutron - 0.0 1.0e5 1.0e6 20.0e6 - + A list of integers indicating the type of particles to tally ('neutron' = 1, + 'photon' = 2, 'electron' = 3, 'positron' = 4). ------------------ ```` Element @@ -355,11 +329,6 @@ If a mesh is desired as a filter for a tally, it must be specified in a separate element with the tag name ````. This element has the following attributes/sub-elements: - :name: - An optional string name to identify the mesh in output files. - - *Default*: "" - :type: The type of mesh. This can be either "regular", "rectilinear", "cylindrical", "spherical", or "unstructured". diff --git a/docs/source/io_formats/track.rst b/docs/source/io_formats/track.rst index 9c05ac4c3..a97d75e58 100644 --- a/docs/source/io_formats/track.rst +++ b/docs/source/io_formats/track.rst @@ -4,7 +4,7 @@ Track File Format ================= -The current revision of the particle track file format is 3.1. +The current revision of the particle track file format is 3.0. **/** @@ -32,5 +32,6 @@ The current revision of the particle track file format is 3.1. the array for each primary/secondary particle. The last offset should match the total size of the array. - - **particles** (*int32_t[]*) -- Particle type for - each primary/secondary particle (PDG number). + - **particles** (*int[]*) -- Particle type for each + primary/secondary particle (0=neutron, 1=photon, + 2=electron, 3=positron). diff --git a/docs/source/license.rst b/docs/source/license.rst index 1ec9fc04a..23315e8fe 100644 --- a/docs/source/license.rst +++ b/docs/source/license.rst @@ -4,7 +4,7 @@ License Agreement ================= -Copyright © 2011-2026 Massachusetts Institute of Technology, UChicago Argonne +Copyright © 2011-2024 Massachusetts Institute of Technology, UChicago Argonne LLC, and OpenMC contributors Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/docs/source/methods/charged_particles_physics.rst b/docs/source/methods/charged_particles_physics.rst deleted file mode 100644 index 5d763074f..000000000 --- a/docs/source/methods/charged_particles_physics.rst +++ /dev/null @@ -1,362 +0,0 @@ -.. _methods_charged_particle_physics: - -======================== -Charged Particle Physics -======================== - -OpenMC neglects the spatial transport of charged particles (electrons and -positrons), assuming they deposit all their energy locally and produce -bremsstrahlung photons at their birth location. This approximation, called -thick-target bremsstrahlung (TTB) approximation is justified by the fact that -charged particles have much shorter stopping ranges compared to neutrons and -photons, especially in high-density materials. - ------------------------------ -Charged Particle Interactions ------------------------------ - -Bremsstrahlung --------------- - -When a charged particle is decelerated in the field of an atom, some of its -kinetic energy is converted into electromagnetic radiation known as -bremsstrahlung, or 'braking radiation'. In each event, an electron or positron -with kinetic energy :math:`T` generates a photon with an energy :math:`E` -between :math:`0` and :math:`T`. Bremsstrahlung is described by a cross section -that is differential in photon energy, in the direction of the emitted photon, -and in the final direction of the charged particle. However, in Monte Carlo -simulations it is typical to integrate over the angular variables to obtain a -single differential cross section with respect to photon energy, which is often -expressed in the form - -.. math:: - :label: bremsstrahlung-dcs - - \frac{d\sigma_{\text{br}}}{dE} = \frac{Z^2}{\beta^2} \frac{1}{E} - \chi(Z, T, \kappa), - -where :math:`\kappa = E/T` is the reduced photon energy and :math:`\chi(Z, T, -\kappa)` is the scaled bremsstrahlung cross section, which is experimentally -measured. - -Because electrons are attracted to atomic nuclei whereas positrons are -repulsed, the cross section for positrons is smaller, though it approaches that -of electrons in the high energy limit. To obtain the positron cross section, we -multiply :eq:`bremsstrahlung-dcs` by the :math:`\kappa`-independent factor used -in Salvat_, - -.. math:: - :label: positron-factor - - \begin{aligned} - F_{\text{p}}(Z,T) = - & 1 - \text{exp}(-1.2359\times 10^{-1}t + 6.1274\times 10^{-2}t^2 - 3.1516\times 10^{-2}t^3 \\ - & + 7.7446\times 10^{-3}t^4 - 1.0595\times 10^{-3}t^5 + 7.0568\times 10^{-5}t^6 \\ - & - 1.8080\times 10^{-6}t^7), - \end{aligned} - -where - -.. math:: - :label: positron-factor-t - - t = \ln\left(1 + \frac{10^6}{Z^2}\frac{T}{\text{m}_\text{e}c^2} \right). - -:math:`F_{\text{p}}(Z,T)` is the ratio of the radiative stopping powers for -positrons and electrons. Stopping power describes the average energy loss per -unit path length of a charged particle as it passes through matter: - -.. math:: - :label: stopping-power - - -\frac{dT}{ds} = n \int E \frac{d\sigma}{dE} dE \equiv S(T), - -where :math:`n` is the number density of the material and :math:`d\sigma/dE` is -the cross section differential in energy loss. The total stopping power -:math:`S(T)` can be separated into two components: the radiative stopping -power :math:`S_{\text{rad}}(T)`, which refers to energy loss due to -bremsstrahlung, and the collision stopping power :math:`S_{\text{col}}(T)`, -which refers to the energy loss due to inelastic collisions with bound -electrons in the material that result in ionization and excitation. The -radiative stopping power for electrons is given by - -.. math:: - :label: radiative-stopping-power - - S_{\text{rad}}(T) = n \frac{Z^2}{\beta^2} T \int_0^1 \chi(Z,T,\kappa) - d\kappa. - - -To obtain the radiative stopping power for positrons, -:eq:`radiative-stopping-power` is multiplied by :eq:`positron-factor`. - -While the models for photon interactions with matter described above can safely -assume interactions occur with free atoms, sampling the target atom based on -the macroscopic cross sections, molecular effects cannot necessarily be -disregarded for charged particle treatment. For compounds and mixtures, the -bremsstrahlung cross section is calculated using Bragg's additivity rule as - -.. math:: - :label: material-bremsstrahlung-dcs - - \frac{d\sigma_{\text{br}}}{dE} = \frac{1}{\beta^2 E} \sum_i \gamma_i Z^2_i - \chi(Z_i, T, \kappa), - -where the sum is over the constituent elements and :math:`\gamma_i` is the -atomic fraction of the :math:`i`-th element. Similarly, the radiative stopping -power is calculated using Bragg's additivity rule as - -.. math:: - :label: material-radiative-stopping-power - - S_{\text{rad}}(T) = \sum_i w_i S_{\text{rad},i}(T), - -where :math:`w_i` is the mass fraction of the :math:`i`-th element and -:math:`S_{\text{rad},i}(T)` is found for element :math:`i` using -:eq:`radiative-stopping-power`. The collision stopping power, however, is a -function of certain quantities such as the mean excitation energy :math:`I` and -the density effect correction :math:`\delta_F` that depend on molecular -properties. These quantities cannot simply be summed over constituent elements -in a compound, but should instead be calculated for the material. The Bethe -formula can be used to find the collision stopping power of the material: - -.. math:: - :label: material-collision-stopping-power - - S_{\text{col}}(T) = \frac{2 \pi r_e^2 m_e c^2}{\beta^2} N_A \frac{Z}{A_M} - [\ln(T^2/I^2) + \ln(1 + \tau/2) + F(\tau) - \delta_F(T)], - -where :math:`N_A` is Avogadro's number, :math:`A_M` is the molar mass, -:math:`\tau = T/m_e`, and :math:`F(\tau)` depends on the particle type. For -electrons, - -.. math:: - :label: F-electron - - F_{-}(\tau) = (1 - \beta^2)[1 + \tau^2/8 - (2\tau + 1) \ln2], - -while for positrons - -.. math:: - :label: F-positron - - F_{+}(\tau) = 2\ln2 - (\beta^2/12)[23 + 14/(\tau + 2) + 10/(\tau + 2)^2 + - 4/(\tau + 2)^3]. - -The density effect correction :math:`\delta_F` takes into account the reduction -of the collision stopping power due to the polarization of the material the -charged particle is passing through by the electric field of the particle. -It can be evaluated using the method described by Sternheimer_, where the -equation for :math:`\delta_F` is - -.. math:: - :label: density-effect-correction - - \delta_F(\beta) = \sum_{i=1}^n f_i \ln[(l_i^2 + l^2)/l_i^2] - - l^2(1-\beta^2). - -Here, :math:`f_i` is the oscillator strength of the :math:`i`-th transition, -given by :math:`f_i = n_i/Z`, where :math:`n_i` is the number of electrons in -the :math:`i`-th subshell. The frequency :math:`l` is the solution of the -equation - -.. math:: - :label: density-effect-l - - \frac{1}{\beta^2} - 1 = \sum_{i=1}^{n} \frac{f_i}{\bar{\nu}_i^2 + l^2}, - -where :math:`\bar{v}_i` is defined as - -.. math:: - :label: density-effect-nubar - - \bar{\nu}_i = h\nu_i \rho / h\nu_p. - -The plasma energy :math:`h\nu_p` of the medium is given by - -.. math:: - :label: plasma-frequency - - h\nu_p = \sqrt{\frac{(hc)^2 r_e \rho_m N_A Z}{\pi A}}, - -where :math:`A` is the atomic weight and :math:`\rho_m` is the density of the -material. In :eq:`density-effect-nubar`, :math:`h\nu_i` is the oscillator -energy, and :math:`\rho` is an adjustment factor introduced to give agreement -between the experimental values of the oscillator energies and the mean -excitation energy. The :math:`l_i` in :eq:`density-effect-correction` are -defined as - -.. math:: - :label: density-effect-li - - \begin{aligned} - l_i &= (\bar{\nu}_i^2 + 2/3f_i)^{1/2} ~~~~&\text{for}~~ \bar{\nu}_i > 0 \\ - l_n &= f_n^{1/2} ~~~~&\text{for}~~ \bar{\nu}_n = 0, - \end{aligned} - -where the second case applies to conduction electrons. For a conductor, -:math:`f_n` is given by :math:`n_c/Z`, where :math:`n_c` is the effective -number of conduction electrons, and :math:`v_n = 0`. The adjustment factor -:math:`\rho` is determined using the equation for the mean excitation energy: - -.. math:: - :label: mean-excitation-energy - - \ln I = \sum_{i=1}^{n-1} f_i \ln[(h\nu_i\rho)^2 + 2/3f_i(h\nu_p)^2]^{1/2} + - f_n \ln (h\nu_pf_n^{1/2}). - -.. _ttb: - - -Thick-Target Bremsstrahlung Approximation -+++++++++++++++++++++++++++++++++++++++++ - -Since charged particles lose their energy on a much shorter distance scale than -neutral particles, not much error should be introduced by neglecting to -transport electrons. However, the bremsstrahlung emitted from high energy -electrons and positrons can travel far from the interaction site. Thus, even -without a full electron transport mode it is necessary to model bremsstrahlung. -We use a thick-target bremsstrahlung (TTB) approximation based on the models in -Salvat_ and Kaltiaisenaho_ for generating bremsstrahlung photons, which assumes -the charged particle loses all its energy in a single homogeneous material -region. - -To model bremsstrahlung using the TTB approximation, we need to know the number -of photons emitted by the charged particle and the energy distribution of the -photons. These quantities can be calculated using the continuous slowing down -approximation (CSDA). The CSDA assumes charged particles lose energy -continuously along their trajectory with a rate of energy loss equal to the -total stopping power, ignoring fluctuations in the energy loss. The -approximation is useful for expressing average quantities that describe how -charged particles slow down in matter. For example, the CSDA range approximates -the average path length a charged particle travels as it slows to rest: - -.. math:: - :label: csda-range - - R(T) = \int^T_0 \frac{dT'}{S(T')}. - -Actual path lengths will fluctuate around :math:`R(T)`. The average number of -photons emitted per unit path length is given by the inverse bremsstrahlung -mean free path: - -.. math:: - :label: inverse-bremsstrahlung-mfp - - \lambda_{\text{br}}^{-1}(T,E_{\text{cut}}) - = n\int_{E_{\text{cut}}}^T\frac{d\sigma_{\text{br}}}{dE}dE - = n\frac{Z^2}{\beta^2}\int_{\kappa_{\text{cut}}}^1\frac{1}{\kappa} - \chi(Z,T,\kappa)d\kappa. - -The lower limit of the integral in :eq:`inverse-bremsstrahlung-mfp` is non-zero -because the bremsstrahlung differential cross section diverges for small photon -energies but is finite for photon energies above some cutoff energy -:math:`E_{\text{cut}}`. The mean free path -:math:`\lambda_{\text{br}}^{-1}(T,E_{\text{cut}})` is used to calculate the -photon number yield, defined as the average number of photons emitted with -energy greater than :math:`E_{\text{cut}}` as the charged particle slows down -from energy :math:`T` to :math:`E_{\text{cut}}`. The photon number yield is -given by - -.. math:: - :label: photon-number-yield - - Y(T,E_{\text{cut}}) = \int^{R(T)}_{R(E_{\text{cut}})} - \lambda_{\text{br}}^{-1}(T',E_{\text{cut}})ds = \int_{E_{\text{cut}}}^T - \frac{\lambda_{\text{br}}^{-1}(T',E_{\text{cut}})}{S(T')}dT'. - -:math:`Y(T,E_{\text{cut}})` can be used to construct the energy spectrum of -bremsstrahlung photons: the number of photons created with energy between -:math:`E_1` and :math:`E_2` by a charged particle with initial kinetic energy -:math:`T` as it comes to rest is given by :math:`Y(T,E_1) - Y(T,E_2)`. - -To simulate the emission of bremsstrahlung photons, the total stopping power -and bremsstrahlung differential cross section for positrons and electrons must -be calculated for a given material using :eq:`material-bremsstrahlung-dcs` and -:eq:`material-radiative-stopping-power`. These quantities are used to build the -tabulated bremsstrahlung energy PDF and CDF for that material for each incident -energy :math:`T_k` on the energy grid. The following algorithm is then applied -to sample the photon energies: - -1. For an incident charged particle with energy :math:`T`, sample the number of - emitted photons as - - .. math:: - - N = \lfloor Y(T,E_{\text{cut}}) + \xi_1 \rfloor. - -2. Rather than interpolate the PDF between indices :math:`k` and :math:`k+1` - for which :math:`T_k < T < T_{k+1}`, which is computationally expensive, use - the composition method and sample from the PDF at either :math:`k` or - :math:`k+1`. Using linear interpolation on a logarithmic scale, the PDF can - be expressed as - - .. math:: - - p_{\text{br}}(T,E) = \pi_k p_{\text{br}}(T_k,E) + \pi_{k+1} - p_{\text{br}}(T_{k+1},E), - - where the interpolation weights are - - .. math:: - - \pi_k = \frac{\ln T_{k+1} - \ln T}{\ln T_{k+1} - \ln T_k},~~~ - \pi_{k+1} = \frac{\ln T - \ln T_k}{\ln T_{k+1} - \ln T_k}. - - Sample either the index :math:`i = k` or :math:`i = k+1` according to the - point probabilities :math:`\pi_{k}` and :math:`\pi_{k+1}`. - -3. Determine the maximum value of the CDF :math:`P_{\text{br,max}}`. - -3. Sample the photon energies using the inverse transform method with the - tabulated CDF :math:`P_{\text{br}}(T_i, E)` i.e., - - .. math:: - - E = E_j \left[ (1 + a_j) \frac{\xi_2 P_{\text{br,max}} - - P_{\text{br}}(T_i, E_j)} {E_j p_{\text{br}}(T_i, E_j)} + 1 - \right]^{\frac{1}{1 + a_j}} - - where the interpolation factor :math:`a_j` is given by - - .. math:: - - a_j = \frac{\ln p_{\text{br}}(T_i,E_{j+1}) - \ln p_{\text{br}}(T_i,E_j)} - {\ln E_{j+1} - \ln E_j} - - and :math:`P_{\text{br}}(T_i, E_j) \le \xi_2 P_{\text{br,max}} \le - P_{\text{br}}(T_i, E_{j+1})`. - -We ignore the range of the electron or positron, i.e., the bremsstrahlung -photons are produced in the same location that the charged particle was -created. The direction of the photons is assumed to be the same as the -direction of the incident charged particle, which is a reasonable approximation -at higher energies when the bremsstrahlung radiation is emitted at small -angles. - - -Electron-Positron Annihilation ------------------------------- - -When a positron collides with an electron, both particles are annihilated and -generally two photons with equal energy are created. If the kinetic energy of -the positron is high enough, the two photons can have different energies, and -the higher-energy photon is emitted preferentially in the direction of flight -of the positron. It is also possible to produce a single photon if the -interaction occurs with a bound electron, and in some cases three (or, rarely, -even more) photons can be emitted. However, the annihilation cross section is -largest for low-energy positrons, and as the positron energy decreases, the -angular distribution of the emitted photons becomes isotropic. - -In OpenMC, we assume the most likely case in which a low-energy positron (which -has already lost most of its energy to bremsstrahlung radiation) interacts with -an electron which is free and at rest. Two photons with energy equal to the -electron rest mass energy :math:`m_e c^2 = 0.511` MeV are emitted isotropically -in opposite directions. - - -.. _Kaltiaisenaho: https://aaltodoc.aalto.fi/bitstream/handle/123456789/21004/master_Kaltiaisenaho_Toni_2016.pdf - -.. _Salvat: https://doi.org/10.1787/32da5043-en - -.. _Sternheimer: https://doi.org/10.1103/PhysRevB.26.6067 diff --git a/docs/source/methods/cross_sections.rst b/docs/source/methods/cross_sections.rst index 764c4c628..2cafa8691 100644 --- a/docs/source/methods/cross_sections.rst +++ b/docs/source/methods/cross_sections.rst @@ -289,59 +289,17 @@ sections. This allows flexibility for the model to use highly anisotropic scattering information in the water while the fuel can be simulated with linear or even isotropic scattering. -Particle Speed --------------- - -When using a multigroup representation of cross sections, the particle speed has -meaning only in an average sense. The particle speed is important when modeling -dynamic behavior. OpenMC calculates the particle speed using the inverse -velocity multigroup data if it is available. If such data is not available, -OpenMC uses an approximate velocity using the group energy bounds in the -following way: - -.. math:: - - \frac{1}{v_g} = \int_{E_{\text{min}}^g}^{E_{\text{max}}^g} \frac{1}{v(E)} \frac{\alpha}{E} dE - -Where :math:`E_{\text{min}}^g` and :math:`E_{\text{max}}^g` are the group energy -boundaries for group :math:`g`. :math:`v(E)` is the neutron velocity calculated -using relativistic kinematics, :math:`\alpha` is a normalization constant for the -:math:`\frac{1}{E}` spectrum. - -This equation is valid when inside the group boundaries the neutron spectrum -follows a typical :math:`\frac{1}{E}` slowing down spectrum. This assumption is -widely used when generating fine group neutron cross section data libraries from -continuous energy data. - -The solution to this equation is: - -.. math:: - - \frac{1}{v_g} = \frac{1}{c \log\left(\frac{E_{\text{max}}^g}{E_{\text{min}}^g}\right)} - \left[ 2(\operatorname{arctanh}(k_{\text{max}}^{-1}) - \operatorname{arctanh}(k_{\text{min}}^{-1})) - - (k_{\text{max}}-k_{\text{min}}) \right] - -where :math:`c` is the speed of light and :math:`k_{\text{max}}`, -:math:`k_{\text{min}}` are defined by a change of variables: - -.. math:: - - k = \sqrt{1+\frac{2 m_n c^2}{E}} - -where :math:`E` is the particle kinetic energy and :math:`m_n` is the neutron -rest mass. - .. _logarithmic mapping technique: - https://mcnp.lanl.gov/pdf_files/TechReport_2014_LANL_LA-UR-14-24530_Brown.pdf + https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/la-ur-14-24530.pdf .. _Hwang: https://doi.org/10.13182/NSE87-A16381 .. _Josey: https://doi.org/10.1016/j.jcp.2015.08.013 .. _WMP Library: https://github.com/mit-crpg/WMP_Library .. _MCNP: https://mcnp.lanl.gov -.. _Serpent: https://serpent.vtt.fi -.. _NJOY: https://www.njoy21.io/ +.. _Serpent: http://montecarlo.vtt.fi +.. _NJOY: https://www.njoy21.io/NJOY21/ .. _ENDF/B data: https://www.nndc.bnl.gov/endf-b8.0/ .. _Leppanen: https://doi.org/10.1016/j.anucene.2009.03.019 -.. _algorithms: http://ab-initio.mit.edu/faddeeva/ +.. _algorithms: http://ab-initio.mit.edu/wiki/index.php/Faddeeva_Package .. _NCrystal: https://github.com/mctools/ncrystal .. _NCrystal paper: https://doi.org/10.1016/j.cpc.2019.07.015 .. _using plugins: https://doi.org/10.1016/j.cpc.2021.108082 diff --git a/docs/source/methods/depletion.rst b/docs/source/methods/depletion.rst index edcf2c3f5..87a9976dd 100644 --- a/docs/source/methods/depletion.rst +++ b/docs/source/methods/depletion.rst @@ -114,7 +114,7 @@ The predictor method only requires one evaluation and its error converges as twice as expensive as the predictor method, but achieves an error of :math:`\mathcal{O}(h^2)`. An exhaustive description of time integration methods and their merits can be found in the `thesis of Colin Josey -`_. +`_. OpenMC does not rely on a single time integration method but rather has several classes that implement different algorithms. For example, the diff --git a/docs/source/methods/eigenvalue.rst b/docs/source/methods/eigenvalue.rst index 8abcc0957..b63723c02 100644 --- a/docs/source/methods/eigenvalue.rst +++ b/docs/source/methods/eigenvalue.rst @@ -55,17 +55,15 @@ in :ref:`fission-bank-algorithms`. Source Convergence Issues ------------------------- -.. _methods-shannon-entropy: - Diagnosing Convergence with Shannon Entropy ------------------------------------------- As discussed earlier, it is necessary to converge both :math:`k_{eff}` and the source distribution before any tallies can begin. Moreover, the convergence rate -of the source distribution is in general slower than that of :math:`k_{eff}`. -One should thus examine not only the convergence of :math:`k_{eff}` but also the -convergence of the source distribution in order to make decisions on when to -start active batches. +of the source distribution is in general slower than that of +:math:`k_{eff}`. One should thus examine not only the convergence of +:math:`k_{eff}` but also the convergence of the source distribution in order to +make decisions on when to start active batches. However, the representation of the source distribution makes it a bit more difficult to analyze its convergence. Since :math:`k_{eff}` is a scalar @@ -110,13 +108,6 @@ at plots of :math:`k_{eff}` and the Shannon entropy. A number of methods have been proposed (see e.g. [Romano]_, [Ueki]_), but each of these is not without problems. -Shannon entropy is calculated differently for the random ray solver, as -described :ref:`in the random ray theory section -`. Additionally, as the Shannon entropy only -serves as a diagnostic tool for convergence of the fission source distribution, -there is currently no diagnostic to determine if the scattering source -distribution in random ray is converged. - --------------------------- Uniform Fission Site Method --------------------------- diff --git a/docs/source/methods/energy_deposition.rst b/docs/source/methods/energy_deposition.rst index c43ee64ac..4675aee3f 100644 --- a/docs/source/methods/energy_deposition.rst +++ b/docs/source/methods/energy_deposition.rst @@ -25,38 +25,19 @@ KERMA (Kinetic Energy Release in Materials) [Mack97]_ coefficients for reaction :math:`\times` cross-section (e.g., eV-barn) and can be used much like a reaction cross section for the purpose of tallying energy deposition. -KERMA coefficients can be computed using the energy-balance method with a -nuclear data processing code like NJOY, which estimates the KERMA coefficients -using the following equation: +KERMA coefficients can be computed using the energy-balance method with +a nuclear data processing code like NJOY, which performs the following +iteration over all reactions :math:`r` for all isotopes :math:`i` +requested .. math:: - k_{i, r}(E) = \left(E + Q_{i, r} - \sum\limits_x \bar{E}_{i, r, x} - \right)\sigma_{i, r}(E), - -where the summation is over each secondary particle type :math:`x`. This -equation states that the energy deposited is equal to the energy of the incident -particle plus the reaction :math:`Q` value less the energy of secondary -particles that are transported away from the reaction site. For neutron -interactions, the energy-balance KERMA coefficient is - -.. math:: - - k_{i, r}(E) = \left(E + Q_{i, r} - \sum\limits_x \bar{E}_{i, r, n} + k_{i, r}(E) = \left(E + Q_{i, r} - \bar{E}_{i, r, n} - \bar{E}_{i, r, \gamma}\right)\sigma_{i, r}(E), -where :math:`\bar{E}_{i, r, n}` is the average energy of secondary neutrons and -:math:`\bar{E}_{i, r, \gamma}` is the average energy of secondary photons. For -photon and charged particle interactions the KERMA coefficient is - -.. math:: - :label: energy-balance-photon - - k_{i, r}(E) = \left(E + Q_{i, r} - \sum\limits_x \bar{E}_{i, r, x} - \right)\sigma_{i, r}(E). - -where the :math:`Q` value is zero for all interactions except for pair -production and positron annihilation. +removing the energy of neutral particles (neutrons and photons) that are +transported away from the reaction site :math:`\bar{E}`, and the reaction +:math:`Q` value. ------- Fission @@ -139,7 +120,7 @@ run with :math:`N918` reflecting fission heating computed from NJOY. This modified heating data is stored as the MT=901 reaction and will be scored if ``heating-local`` is included in :attr:`openmc.Tally.scores`. -Coupled Neutron-Photon Transport +Coupled neutron-photon transport -------------------------------- Here, OpenMC instructs ``heatr`` to assume that energy from photons is not @@ -157,50 +138,6 @@ Let :math:`N301` represent the total heating number returned from this This modified heating data is stored as the MT=301 reaction and will be scored if ``heating`` is included in :attr:`openmc.Tally.scores`. -Photons and Charged Particles ------------------------------ - -In OpenMC, energy deposition from photons or charged particles is scored using -the energy balance method based on Equation :eq:`energy-balance-photon`. Special -consideration is given to electrons and positrons as described below. - -+++++++++++++++++ -Charged Particles -+++++++++++++++++ - -OpenMC tracks photons interaction by interaction so the energy deposited in each -collision is easily attributed back to the nuclide and reaction for which the -photon interacted with. Charged particles (electrons and photons) aren't tracked -in the same way. For charged particles, OpenMC assumes that all their energy -(less the energy of bremsstrahlung radiation) is deposited in the material in -which they were born. In this way it is harder to trace how much energy should -be attributed in each nuclide. - -According to the CSDA approximation (see :ref:`ttb`) the energy deposited by a -charged particle with kinetic energy :math:`T` in the :math:`i`-th element can -be calculated as: - -.. math:: - - E_{i} = \int_{0}^{R(T)} w_{i}S_{\text{col,i}} dx - -where :math:`R(T)` is the CSDA range of the charged particle, -:math:`S_{\text{col},i}` is the collision stopping power of the charged particle -in the :math:`i`-th element and :math:`w_i` is the mass fraction of the -:math:`i`-th element. According to the Bethe formula the collision stopping -power of the :math:`i`-th element is proportional to :math:`Z_i/A_i`, so the -fractional collision stopping power from the :math:`i`-th element is: - -.. math:: - - \frac{w_{i}S_{\text{col},i}(T)}{S_{\text{col}}(T)} = - \frac{\frac{w_{i}Z_{i}}{A_{i}}}{\sum_{i}\frac{w_{i}Z_{i}}{A_{i}}} = - \frac{\gamma_i Z_{i}}{\sum_{i}\gamma_i Z_{i}}. - -where :math:`\gamma_i` is the atomic fraction of the :math:`i`-th element. -Therefore, the energy deposited by charged particles should be attributed to -a given element according to its fractional charge density. - ---------- References ---------- diff --git a/docs/source/methods/geometry.rst b/docs/source/methods/geometry.rst index 05cda4b64..b282ffdee 100644 --- a/docs/source/methods/geometry.rst +++ b/docs/source/methods/geometry.rst @@ -1066,5 +1066,5 @@ surface is known as in :ref:`reflection`. .. _constructive solid geometry: https://en.wikipedia.org/wiki/Constructive_solid_geometry .. _surfaces: https://en.wikipedia.org/wiki/Surface .. _MCNP: https://mcnp.lanl.gov -.. _Serpent: https://serpent.vtt.fi +.. _Serpent: http://montecarlo.vtt.fi .. _Monte Carlo Performance benchmark: https://github.com/mit-crpg/benchmarks/tree/master/mc-performance/openmc diff --git a/docs/source/methods/index.rst b/docs/source/methods/index.rst index 121d04b1d..08aa7d053 100644 --- a/docs/source/methods/index.rst +++ b/docs/source/methods/index.rst @@ -14,12 +14,10 @@ Theory and Methodology random_numbers neutron_physics photon_physics - charged_particles_physics tallies eigenvalue depletion energy_deposition parallelization cmfd - variance_reduction - random_ray + random_ray \ No newline at end of file diff --git a/docs/source/methods/neutron_physics.rst b/docs/source/methods/neutron_physics.rst index 2b797e3db..70ace4a35 100644 --- a/docs/source/methods/neutron_physics.rst +++ b/docs/source/methods/neutron_physics.rst @@ -290,10 +290,7 @@ create and store fission sites for the following generation. First, the average number of prompt and delayed neutrons must be determined to decide whether the secondary neutrons will be prompt or delayed. This is important because delayed neutrons have a markedly different spectrum from prompt neutrons, one that has a -lower average energy of emission. Furthermore, in simulations where tracking -time of neutrons is important, we need to consider the emission time delay of -the secondary neutrons, which is dependent on the decay constant of the -delayed neutron precursor. The total number of neutrons emitted +lower average energy of emission. The total number of neutrons emitted :math:`\nu_t` is given as a function of incident energy in the ENDF format. Two representations exist for :math:`\nu_t`. The first is a polynomial of order :math:`N` with coefficients :math:`c_0,c_1,\dots,c_N`. If :math:`\nu_t` has this @@ -309,8 +306,8 @@ interpolation law. The number of prompt neutrons released per fission event :math:`\nu_p` is also given as a function of incident energy and can be specified in a polynomial or tabular format. The number of delayed neutrons released per fission event :math:`\nu_d` can only be specified in a tabular -format. In practice, we only need to determine :math:`\nu_t` and -:math:`\nu_d`. Once these have been determined, we can calculate the delayed +format. In practice, we only need to determine :math:`nu_t` and +:math:`nu_d`. Once these have been determined, we can calculated the delayed neutron fraction .. math:: @@ -338,14 +335,8 @@ neutrons. Otherwise, we produce :math:`\lfloor \nu \rfloor + 1` neutrons. Then, for each fission site produced, we sample the outgoing angle and energy according to the algorithms given in :ref:`sample-angle` and :ref:`sample-energy` respectively. If the neutron is to be born delayed, then -there is an extra step of sampling a delayed neutron precursor group to get the -associated secondary energy distribution and the decay constant -:math:`\lambda`, which is needed to sample the emission delay time :math:`t_d`: - -.. math:: - :label: sample-delay-time - - t_d = -\frac{\ln \xi}{\lambda}. +there is an extra step of sampling a delayed neutron precursor group since they +each have an associated secondary energy distribution. The sampled outgoing angle and energy of fission neutrons along with the position of the collision site are stored in an array called the fission @@ -1752,19 +1743,19 @@ types. .. _Watt fission spectrum: https://doi.org/10.1103/PhysRev.87.1037 -.. _Foderaro: https://dspace.mit.edu/handle/1721.1/1716 +.. _Foderaro: http://hdl.handle.net/1721.1/1716 .. _OECD: https://www.oecd-nea.org/tools/abstract/detail/NEA-1792 .. _NJOY: https://www.njoy21.io/NJOY2016/ -.. _PREPRO: https://www-nds.iaea.org/public/endf/prepro/ +.. _PREPRO: https://www-nds.iaea.org/ndspub/endf/prepro/ .. _ENDF-6 Format: https://www.oecd-nea.org/dbdata/data/manual-endf/endf102.pdf -.. _Monte Carlo Sampler: https://mcnp.lanl.gov/pdf_files/TechReport_1983_LANL_LA-9721-MS_EverettCashwell.pdf +.. _Monte Carlo Sampler: https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-09721-MS -.. _LA-UR-14-27694: https://www.osti.gov/biblio/1159204 +.. _LA-UR-14-27694: https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-UR-14-27694 .. _MC21: https://www.osti.gov/biblio/903083 @@ -1772,4 +1763,6 @@ types. .. _Sutton and Brown: https://www.osti.gov/biblio/307911 -.. _lectures: https://mcnp.lanl.gov/pdf_files/TechReport_2005_LANL_LA-UR-05-4983_Brown.pdf +.. _lectures: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/la-ur-05-4983.pdf + +.. _MCNP Manual: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/la-ur-03-1987.pdf diff --git a/docs/source/methods/parallelization.rst b/docs/source/methods/parallelization.rst index 87ac48590..d9fc15c9f 100644 --- a/docs/source/methods/parallelization.rst +++ b/docs/source/methods/parallelization.rst @@ -609,17 +609,17 @@ is actually independent of the number of nodes: .. _first paper: https://doi.org/10.2307/2280232 -.. _work of Forrest Brown: https://deepblue.lib.umich.edu/handle/2027.42/24996 +.. _work of Forrest Brown: http://hdl.handle.net/2027.42/24996 .. _Brissenden and Garlick: https://doi.org/10.1016/0306-4549(86)90095-2 -.. _MPICH: https://www.mpich.org +.. _MPICH: http://www.mpich.org .. _binomial tree: https://www.mcs.anl.gov/~thakur/papers/ijhpca-coll.pdf .. _Geary: https://doi.org/10.2307/2342070 -.. _Barnett: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.7772 +.. _Barnett: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.7772 .. _single-instruction multiple-data: https://en.wikipedia.org/wiki/SIMD diff --git a/docs/source/methods/photon_physics.rst b/docs/source/methods/photon_physics.rst index d2bd3ac76..bc912b943 100644 --- a/docs/source/methods/photon_physics.rst +++ b/docs/source/methods/photon_physics.rst @@ -667,6 +667,342 @@ and Auger electrons: 5. Repeat from step 1 for vacancy left by the transition electron. +Electron-Positron Annihilation +------------------------------ + +When a positron collides with an electron, both particles are annihilated and +generally two photons with equal energy are created. If the kinetic energy of +the positron is high enough, the two photons can have different energies, and +the higher-energy photon is emitted preferentially in the direction of flight +of the positron. It is also possible to produce a single photon if the +interaction occurs with a bound electron, and in some cases three (or, rarely, +even more) photons can be emitted. However, the annihilation cross section is +largest for low-energy positrons, and as the positron energy decreases, the +angular distribution of the emitted photons becomes isotropic. + +In OpenMC, we assume the most likely case in which a low-energy positron (which +has already lost most of its energy to bremsstrahlung radiation) interacts with +an electron which is free and at rest. Two photons with energy equal to the +electron rest mass energy :math:`m_e c^2 = 0.511` MeV are emitted isotropically +in opposite directions. + +Bremsstrahlung +-------------- + +When a charged particle is decelerated in the field of an atom, some of its +kinetic energy is converted into electromagnetic radiation known as +bremsstrahlung, or 'braking radiation'. In each event, an electron or positron +with kinetic energy :math:`T` generates a photon with an energy :math:`E` +between :math:`0` and :math:`T`. Bremsstrahlung is described by a cross section +that is differential in photon energy, in the direction of the emitted photon, +and in the final direction of the charged particle. However, in Monte Carlo +simulations it is typical to integrate over the angular variables to obtain a +single differential cross section with respect to photon energy, which is often +expressed in the form + +.. math:: + :label: bremsstrahlung-dcs + + \frac{d\sigma_{\text{br}}}{dE} = \frac{Z^2}{\beta^2} \frac{1}{E} + \chi(Z, T, \kappa), + +where :math:`\kappa = E/T` is the reduced photon energy and :math:`\chi(Z, T, +\kappa)` is the scaled bremsstrahlung cross section, which is experimentally +measured. + +Because electrons are attracted to atomic nuclei whereas positrons are +repulsed, the cross section for positrons is smaller, though it approaches that +of electrons in the high energy limit. To obtain the positron cross section, we +multiply :eq:`bremsstrahlung-dcs` by the :math:`\kappa`-independent factor used +in Salvat_, + +.. math:: + :label: positron-factor + + \begin{aligned} + F_{\text{p}}(Z,T) = + & 1 - \text{exp}(-1.2359\times 10^{-1}t + 6.1274\times 10^{-2}t^2 - 3.1516\times 10^{-2}t^3 \\ + & + 7.7446\times 10^{-3}t^4 - 1.0595\times 10^{-3}t^5 + 7.0568\times 10^{-5}t^6 \\ + & - 1.8080\times 10^{-6}t^7), + \end{aligned} + +where + +.. math:: + :label: positron-factor-t + + t = \ln\left(1 + \frac{10^6}{Z^2}\frac{T}{\text{m}_\text{e}c^2} \right). + +:math:`F_{\text{p}}(Z,T)` is the ratio of the radiative stopping powers for +positrons and electrons. Stopping power describes the average energy loss per +unit path length of a charged particle as it passes through matter: + +.. math:: + :label: stopping-power + + -\frac{dT}{ds} = n \int E \frac{d\sigma}{dE} dE \equiv S(T), + +where :math:`n` is the number density of the material and :math:`d\sigma/dE` is +the cross section differential in energy loss. The total stopping power +:math:`S(T)` can be separated into two components: the radiative stopping +power :math:`S_{\text{rad}}(T)`, which refers to energy loss due to +bremsstrahlung, and the collision stopping power :math:`S_{\text{col}}(T)`, +which refers to the energy loss due to inelastic collisions with bound +electrons in the material that result in ionization and excitation. The +radiative stopping power for electrons is given by + +.. math:: + :label: radiative-stopping-power + + S_{\text{rad}}(T) = n \frac{Z^2}{\beta^2} T \int_0^1 \chi(Z,T,\kappa) + d\kappa. + + +To obtain the radiative stopping power for positrons, +:eq:`radiative-stopping-power` is multiplied by :eq:`positron-factor`. + +While the models for photon interactions with matter described above can safely +assume interactions occur with free atoms, sampling the target atom based on +the macroscopic cross sections, molecular effects cannot necessarily be +disregarded for charged particle treatment. For compounds and mixtures, the +bremsstrahlung cross section is calculated using Bragg's additivity rule as + +.. math:: + :label: material-bremsstrahlung-dcs + + \frac{d\sigma_{\text{br}}}{dE} = \frac{1}{\beta^2 E} \sum_i \gamma_i Z^2_i + \chi(Z_i, T, \kappa), + +where the sum is over the constituent elements and :math:`\gamma_i` is the +atomic fraction of the :math:`i`-th element. Similarly, the radiative stopping +power is calculated using Bragg's additivity rule as + +.. math:: + :label: material-radiative-stopping-power + + S_{\text{rad}}(T) = \sum_i w_i S_{\text{rad},i}(T), + +where :math:`w_i` is the mass fraction of the :math:`i`-th element and +:math:`S_{\text{rad},i}(T)` is found for element :math:`i` using +:eq:`radiative-stopping-power`. The collision stopping power, however, is a +function of certain quantities such as the mean excitation energy :math:`I` and +the density effect correction :math:`\delta_F` that depend on molecular +properties. These quantities cannot simply be summed over constituent elements +in a compound, but should instead be calculated for the material. The Bethe +formula can be used to find the collision stopping power of the material: + +.. math:: + :label: material-collision-stopping-power + + S_{\text{col}}(T) = \frac{2 \pi r_e^2 m_e c^2}{\beta^2} N_A \frac{Z}{A_M} + [\ln(T^2/I^2) + \ln(1 + \tau/2) + F(\tau) - \delta_F(T)], + +where :math:`N_A` is Avogadro's number, :math:`A_M` is the molar mass, +:math:`\tau = T/m_e`, and :math:`F(\tau)` depends on the particle type. For +electrons, + +.. math:: + :label: F-electron + + F_{-}(\tau) = (1 - \beta^2)[1 + \tau^2/8 - (2\tau + 1) \ln2], + +while for positrons + +.. math:: + :label: F-positron + + F_{+}(\tau) = 2\ln2 - (\beta^2/12)[23 + 14/(\tau + 2) + 10/(\tau + 2)^2 + + 4/(\tau + 2)^3]. + +The density effect correction :math:`\delta_F` takes into account the reduction +of the collision stopping power due to the polarization of the material the +charged particle is passing through by the electric field of the particle. +It can be evaluated using the method described by Sternheimer_, where the +equation for :math:`\delta_F` is + +.. math:: + :label: density-effect-correction + + \delta_F(\beta) = \sum_{i=1}^n f_i \ln[(l_i^2 + l^2)/l_i^2] - + l^2(1-\beta^2). + +Here, :math:`f_i` is the oscillator strength of the :math:`i`-th transition, +given by :math:`f_i = n_i/Z`, where :math:`n_i` is the number of electrons in +the :math:`i`-th subshell. The frequency :math:`l` is the solution of the +equation + +.. math:: + :label: density-effect-l + + \frac{1}{\beta^2} - 1 = \sum_{i=1}^{n} \frac{f_i}{\bar{\nu}_i^2 + l^2}, + +where :math:`\bar{v}_i` is defined as + +.. math:: + :label: density-effect-nubar + + \bar{\nu}_i = h\nu_i \rho / h\nu_p. + +The plasma energy :math:`h\nu_p` of the medium is given by + +.. math:: + :label: plasma-frequency + + h\nu_p = \sqrt{\frac{(hc)^2 r_e \rho_m N_A Z}{\pi A}}, + +where :math:`A` is the atomic weight and :math:`\rho_m` is the density of the +material. In :eq:`density-effect-nubar`, :math:`h\nu_i` is the oscillator +energy, and :math:`\rho` is an adjustment factor introduced to give agreement +between the experimental values of the oscillator energies and the mean +excitation energy. The :math:`l_i` in :eq:`density-effect-correction` are +defined as + +.. math:: + :label: density-effect-li + + \begin{aligned} + l_i &= (\bar{\nu}_i^2 + 2/3f_i)^{1/2} ~~~~&\text{for}~~ \bar{\nu}_i > 0 \\ + l_n &= f_n^{1/2} ~~~~&\text{for}~~ \bar{\nu}_n = 0, + \end{aligned} + +where the second case applies to conduction electrons. For a conductor, +:math:`f_n` is given by :math:`n_c/Z`, where :math:`n_c` is the effective +number of conduction electrons, and :math:`v_n = 0`. The adjustment factor +:math:`\rho` is determined using the equation for the mean excitation energy: + +.. math:: + :label: mean-excitation-energy + + \ln I = \sum_{i=1}^{n-1} f_i \ln[(h\nu_i\rho)^2 + 2/3f_i(h\nu_p)^2]^{1/2} + + f_n \ln (h\nu_pf_n^{1/2}). + +.. _ttb: + +Thick-Target Bremsstrahlung Approximation ++++++++++++++++++++++++++++++++++++++++++ + +Since charged particles lose their energy on a much shorter distance scale than +neutral particles, not much error should be introduced by neglecting to +transport electrons. However, the bremsstrahlung emitted from high energy +electrons and positrons can travel far from the interaction site. Thus, even +without a full electron transport mode it is necessary to model bremsstrahlung. +We use a thick-target bremsstrahlung (TTB) approximation based on the models in +Salvat_ and Kaltiaisenaho_ for generating bremsstrahlung photons, which assumes +the charged particle loses all its energy in a single homogeneous material +region. + +To model bremsstrahlung using the TTB approximation, we need to know the number +of photons emitted by the charged particle and the energy distribution of the +photons. These quantities can be calculated using the continuous slowing down +approximation (CSDA). The CSDA assumes charged particles lose energy +continuously along their trajectory with a rate of energy loss equal to the +total stopping power, ignoring fluctuations in the energy loss. The +approximation is useful for expressing average quantities that describe how +charged particles slow down in matter. For example, the CSDA range approximates +the average path length a charged particle travels as it slows to rest: + +.. math:: + :label: csda-range + + R(T) = \int^T_0 \frac{dT'}{S(T')}. + +Actual path lengths will fluctuate around :math:`R(T)`. The average number of +photons emitted per unit path length is given by the inverse bremsstrahlung +mean free path: + +.. math:: + :label: inverse-bremsstrahlung-mfp + + \lambda_{\text{br}}^{-1}(T,E_{\text{cut}}) + = n\int_{E_{\text{cut}}}^T\frac{d\sigma_{\text{br}}}{dE}dE + = n\frac{Z^2}{\beta^2}\int_{\kappa_{\text{cut}}}^1\frac{1}{\kappa} + \chi(Z,T,\kappa)d\kappa. + +The lower limit of the integral in :eq:`inverse-bremsstrahlung-mfp` is non-zero +because the bremsstrahlung differential cross section diverges for small photon +energies but is finite for photon energies above some cutoff energy +:math:`E_{\text{cut}}`. The mean free path +:math:`\lambda_{\text{br}}^{-1}(T,E_{\text{cut}})` is used to calculate the +photon number yield, defined as the average number of photons emitted with +energy greater than :math:`E_{\text{cut}}` as the charged particle slows down +from energy :math:`T` to :math:`E_{\text{cut}}`. The photon number yield is +given by + +.. math:: + :label: photon-number-yield + + Y(T,E_{\text{cut}}) = \int^{R(T)}_{R(E_{\text{cut}})} + \lambda_{\text{br}}^{-1}(T',E_{\text{cut}})ds = \int_{E_{\text{cut}}}^T + \frac{\lambda_{\text{br}}^{-1}(T',E_{\text{cut}})}{S(T')}dT'. + +:math:`Y(T,E_{\text{cut}})` can be used to construct the energy spectrum of +bremsstrahlung photons: the number of photons created with energy between +:math:`E_1` and :math:`E_2` by a charged particle with initial kinetic energy +:math:`T` as it comes to rest is given by :math:`Y(T,E_1) - Y(T,E_2)`. + +To simulate the emission of bremsstrahlung photons, the total stopping power +and bremsstrahlung differential cross section for positrons and electrons must +be calculated for a given material using :eq:`material-bremsstrahlung-dcs` and +:eq:`material-radiative-stopping-power`. These quantities are used to build the +tabulated bremsstrahlung energy PDF and CDF for that material for each incident +energy :math:`T_k` on the energy grid. The following algorithm is then applied +to sample the photon energies: + +1. For an incident charged particle with energy :math:`T`, sample the number of + emitted photons as + + .. math:: + + N = \lfloor Y(T,E_{\text{cut}}) + \xi_1 \rfloor. + +2. Rather than interpolate the PDF between indices :math:`k` and :math:`k+1` + for which :math:`T_k < T < T_{k+1}`, which is computationally expensive, use + the composition method and sample from the PDF at either :math:`k` or + :math:`k+1`. Using linear interpolation on a logarithmic scale, the PDF can + be expressed as + + .. math:: + + p_{\text{br}}(T,E) = \pi_k p_{\text{br}}(T_k,E) + \pi_{k+1} + p_{\text{br}}(T_{k+1},E), + + where the interpolation weights are + + .. math:: + + \pi_k = \frac{\ln T_{k+1} - \ln T}{\ln T_{k+1} - \ln T_k},~~~ + \pi_{k+1} = \frac{\ln T - \ln T_k}{\ln T_{k+1} - \ln T_k}. + + Sample either the index :math:`i = k` or :math:`i = k+1` according to the + point probabilities :math:`\pi_{k}` and :math:`\pi_{k+1}`. + +3. Determine the maximum value of the CDF :math:`P_{\text{br,max}}`. + +3. Sample the photon energies using the inverse transform method with the + tabulated CDF :math:`P_{\text{br}}(T_i, E)` i.e., + + .. math:: + + E = E_j \left[ (1 + a_j) \frac{\xi_2 P_{\text{br,max}} - + P_{\text{br}}(T_i, E_j)} {E_j p_{\text{br}}(T_i, E_j)} + 1 + \right]^{\frac{1}{1 + a_j}} + + where the interpolation factor :math:`a_j` is given by + + .. math:: + + a_j = \frac{\ln p_{\text{br}}(T_i,E_{j+1}) - \ln p_{\text{br}}(T_i,E_j)} + {\ln E_{j+1} - \ln E_j} + + and :math:`P_{\text{br}}(T_i, E_j) \le \xi_2 P_{\text{br,max}} \le + P_{\text{br}}(T_i, E_{j+1})`. + +We ignore the range of the electron or positron, i.e., the bremsstrahlung +photons are produced in the same location that the charged particle was +created. The direction of the photons is assumed to be the same as the +direction of the incident charged particle, which is a reasonable approximation +at higher energies when the bremsstrahlung radiation is emitted at small +angles. .. _photon_production: @@ -723,14 +1059,16 @@ emitted photon. .. _anomalous scattering: http://pd.chem.ucl.ac.uk/pdnn/diff1/anomscat.htm -.. _Kahn's rejection method: https://doi.org/10.2172/4353680 +.. _Kahn's rejection method: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/aecu-3259_kahn.pdf .. _Klein-Nishina: https://en.wikipedia.org/wiki/Klein%E2%80%93Nishina_formula -.. _LA-UR-04-0487: https://mcnp.lanl.gov/pdf_files/TechReport_2004_LANL_LA-UR-04-0487_Sood.pdf +.. _LA-UR-04-0487: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/la-ur-04-0487.pdf -.. _LA-UR-04-0488: https://mcnp.lanl.gov/pdf_files/TechReport_2004_LANL_LA-UR-04-0488_SoodWhite.pdf +.. _LA-UR-04-0488: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/la-ur-04-0488.pdf .. _Kaltiaisenaho: https://aaltodoc.aalto.fi/bitstream/handle/123456789/21004/master_Kaltiaisenaho_Toni_2016.pdf -.. _Salvat: https://doi.org/10.1787/32da5043-en +.. _Salvat: https://www.oecd-nea.org/globalsearch/download.php?doc=77434 + +.. _Sternheimer: https://doi.org/10.1103/PhysRevB.26.6067 diff --git a/docs/source/methods/random_numbers.rst b/docs/source/methods/random_numbers.rst index 4376bbdb0..0cefc9156 100644 --- a/docs/source/methods/random_numbers.rst +++ b/docs/source/methods/random_numbers.rst @@ -7,7 +7,7 @@ Random Number Generation In order to sample probability distributions, one must be able to produce random numbers. The standard technique to do this is to generate numbers on the interval :math:`[0,1)` from a deterministic sequence that has properties that -make it appear to be random, e.g., being uniformly distributed and not exhibiting +make it appear to be random, e.g. being uniformly distributed and not exhibiting correlation between successive terms. Since the numbers produced this way are not truly "random" in a strict sense, they are typically referred to as pseudorandom numbers, and the techniques used to generate them are pseudorandom @@ -15,11 +15,6 @@ number generators (PRNGs). Numbers sampled on the unit interval can then be transformed for the purpose of sampling other continuous or discrete probability distributions. -There are many different algorithms for pseudorandom number generation. OpenMC -currently uses `permuted congruential generator`_ (PCG), which builds on top of -the simpler linear congruential generator (LCG). Both algorithms are described -below. - ------------------------------ Linear Congruential Generators ------------------------------ @@ -42,8 +37,8 @@ be generated with a method chosen at random. Some theory should be used." Typically, :math:`M` is chosen to be a power of two as this enables :math:`x \mod M` to be performed using the bitwise AND operator with a bit mask. The constants for the linear congruential generator used by default in OpenMC are -:math:`g = 2806196910506780709`, :math:`c = 1`, and :math:`M = 2^{63}` (from -`L'Ecuyer `_). +:math:`g = 2806196910506780709`, :math:`c = 1`, and :math:`M = 2^{63}` (see +`L'Ecuyer`_). Skip-ahead Capability --------------------- @@ -55,8 +50,7 @@ want to skip ahead :math:`N` random numbers and :math:`N` is large, the cost of sampling :math:`N` random numbers to get to that position may be prohibitively expensive. Fortunately, algorithms have been developed that allow us to skip ahead in :math:`O(\log_2 N)` operations instead of :math:`O(N)`. One algorithm -to do so is described in a `paper by Brown -`_. This algorithm relies on the following +to do so is described in a paper by Brown_. This algorithm relies on the following relationship: .. math:: @@ -64,26 +58,15 @@ relationship: \xi_{i+k} = g^k \xi_i + c \frac{g^k - 1}{g - 1} \mod M -Note that equation :eq:`lcg-skipahead` has the same general form as equation -:eq:`lcg`, so the idea is to determine the new multiplicative and additive -constants in :math:`O(\log_2 N)` operations. +Note that equation :eq:`lcg-skipahead` has the same general form as equation :eq:`lcg`, so +the idea is to determine the new multiplicative and additive constants in +:math:`O(\log_2 N)` operations. + +.. only:: html + + .. rubric:: References --------------------------------- -Permuted Congruential Generators --------------------------------- - -The `permuted congruential generator`_ (PCG) algorithm aims to improve upon the -LCG algorithm by permuting the output. The algorithm works on the basic -principle of first advancing the generator state using the LCG algorithm and -then applying a permutation function on the LCG state to obtain the output. This -results in increased statistical quality as measured by common statistical tests -while exhibiting a very small performance overhead relative to the LCG algorithm -and an equivalent memory footprint. For further details, see the original -technical report by `O'Neill -`_. OpenMC uses the -PCG-RXS-M-XS variant with a 64-bit state and 64-bit output. - +.. _L'Ecuyer: https://doi.org/10.1090/S0025-5718-99-00996-5 +.. _Brown: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/pdf_files/anl-rn-arb-stride.pdf .. _linear congruential generator: https://en.wikipedia.org/wiki/Linear_congruential_generator - -.. _permuted congruential generator: https://en.wikipedia.org/wiki/Permuted_congruential_generator diff --git a/docs/source/methods/random_ray.rst b/docs/source/methods/random_ray.rst index 8bc2a0a1b..427ba1148 100644 --- a/docs/source/methods/random_ray.rst +++ b/docs/source/methods/random_ray.rst @@ -10,7 +10,7 @@ Random Ray What is Random Ray? ------------------- -`Random ray `_ is a stochastic transport method, closely related to +`Random ray `_ is a stochastic transport method, closely related to the deterministic Method of Characteristics (MOC) [Askew-1972]_. Rather than each ray representing a single neutron as in Monte Carlo, it represents a characteristic line through the simulation geometry upon which the transport @@ -82,7 +82,7 @@ Random Ray Numerical Derivation In this section, we will derive the numerical basis for the random ray solver mode in OpenMC. The derivation of random ray is also discussed in several papers -(`1 `_, `2 `_, `3 `_), and some of those +(`1 `_, `2 `_, `3 `_), and some of those derivations are reproduced here verbatim. Several extensions are also made to add clarity, particularly on the topic of OpenMC's treatment of cell volumes in the random ray solver. @@ -109,7 +109,9 @@ terms on the right hand side. In Equation :eq:`transport`, :math:`\psi` is the angular neutron flux. This parameter represents the total distance traveled by all neutrons in a particular direction inside of a control volume per second, and is often given in units of -:math:`1/(\text{cm}^{2} \text{s})`. The angular direction unit vector, +:math:`1/(\text{cm}^{2} \text{s})`. As OpenMC does not support time dependence +in the random ray solver mode, we consider the steady state equation, where the +units of flux become :math:`1/\text{cm}^{2}`. The angular direction unit vector, :math:`\mathbf{\Omega}`, represents the direction of travel for the neutron. The spatial position vector, :math:`\mathbf{r}`, represents the location within the simulation. The neutron energy, :math:`E`, or speed in continuous space, is @@ -216,9 +218,9 @@ Following the multigroup discretization, another assumption made is that a large and complex problem can be broken up into small constant cross section regions, and that these regions have group dependent, flat, isotropic sources (fission and scattering), :math:`Q_g`. Anisotropic as well as higher order sources are -also possible with MOC-based methods. With these key assumptions, the multigroup -MOC form of the neutron transport equation can be written as in Equation -:eq:`moc_final`. +also possible with MOC-based methods but are not used yet in OpenMC for +simplicity. With these key assumptions, the multigroup MOC form of the neutron +transport equation can be written as in Equation :eq:`moc_final`. .. math:: :label: moc_final @@ -285,7 +287,7 @@ final expression for the average angular flux for a ray crossing a region as: .. math:: :label: average_psi_final - \overline{\psi}_{r,i,g} = \frac{Q_{i,g}}{\Sigma_{t,i,g}} + \frac{\Delta \psi_{r,g}}{\ell_r \Sigma_{t,i,g}}. + \overline{\psi}_{r,i,g} = \frac{Q_{i,g}}{\Sigma_{t,i,g}} + \frac{\Delta \psi_{r,g}}{\ell_r \Sigma_{t,i,g}} ~~~~~~~~~~~ Random Rays @@ -409,8 +411,6 @@ which when partially simplified becomes: Note that there are now four (seemingly identical) volume terms in this equation. -.. _methods_random_ray_vol: - ~~~~~~~~~~~~~~ Volume Dilemma ~~~~~~~~~~~~~~ @@ -426,7 +426,7 @@ of terms. Mathematically, such cancellation allows us to arrive at the following This derivation appears mathematically sound at first glance but unfortunately raises a serious issue as discussed in more depth by `Tramm et al. -`_ and `Cosgrove and Tramm `_. Namely, the second +`_ and `Cosgrove and Tramm `_. Namely, the second term: .. math:: @@ -438,11 +438,9 @@ features stochastic variables (the sums over random ray lengths and angular fluxes) in both the numerator and denominator, making it a stochastic ratio estimator, which is inherently biased. In practice, usage of the naive estimator does result in a biased, but "consistent" estimator (i.e., it is biased, but -the bias tends towards zero as the sample size increases). Empirically, this -bias tends to effect eigenvalue calculations much more significantly than in -fixed source simulations. Experimentally, the right answer can be obtained with -this estimator, though for eigenvalue simulations a very fine ray density is -required to eliminate the bias. +the bias tends towards zero as the sample size increases). Experimentally, the +right answer can be obtained with this estimator, though a very fine ray density +is required to eliminate the bias. How might we solve the biased ratio estimator problem? While there is no obvious way to alter the numerator term (which arises from the characteristic @@ -463,17 +461,17 @@ replace the actual tracklength that was accumulated inside that FSR each iteration with the expected value. If we know the analytical volumes, then those can be used to directly compute -the expected value of the tracklength in each cell, :math:`L_{avg}`. However, as -the analytical volumes are not typically known in OpenMC due to the usage of -user-defined constructive solid geometry, we need to source this quantity from -elsewhere. An obvious choice is to simply accumulate the total tracklength -through each FSR across all iterations (batches) and to use that sum to compute -the expected average length per iteration, as: +the expected value of the tracklength in each cell. However, as the analytical +volumes are not typically known in OpenMC due to the usage of user-defined +constructive solid geometry, we need to source this quantity from elsewhere. An +obvious choice is to simply accumulate the total tracklength through each FSR +across all iterations (batches) and to use that sum to compute the expected +average length per iteration, as: .. math:: - :label: L_avg + :label: sim_estimator - \sum\limits^{}_{i} \ell_i \approx L_{avg} = \frac{\sum\limits^{B}_{b}\sum\limits^{N_i}_{r=1} \ell_{b,r} }{B} + \sum\limits^{}_{i} \ell_i \approx \frac{\sum\limits^{B}_{b}\sum\limits^{N_i}_{r} \ell_{b,r} }{B} where :math:`b` is a single batch in :math:`B` total batches simulated so far. @@ -486,7 +484,7 @@ averaged" estimator is therefore: .. math:: :label: phi_sim - \phi_{i,g}^{simulation} = \frac{Q_{i,g} }{\Sigma_{t,i,g}} + \frac{\sum\limits_{r=1}^{N_i} \Delta \psi_{r,g}}{\Sigma_{t,i,g} L_{avg}} + \phi_{i,g}^{simulation} = \frac{Q_{i,g} }{\Sigma_{t,i,g}} + \frac{\sum\limits_{r=1}^{N_i} \Delta \psi_{r,g}}{\Sigma_{t,i,g} \frac{\sum\limits^{B}_{b}\sum\limits^{N_i}_{r} \ell_{b,r} }{B}} In practical terms, the "simulation averaged" estimator is virtually indistinguishable numerically from use of the true analytical volume to estimate @@ -500,81 +498,17 @@ in which case the denominator served as a normalization term for the numerator integral in Equation :eq:`integral`. Essentially, we have now used a different term for the volume in the numerator as compared to the normalizing volume in the denominator. The inevitable mismatch (due to noise) between these two -quantities results in a significant increase in variance, and can even result in -the generation of negative fluxes. Notably, the same problem occurs if using a -tracklength estimate based on the analytical volume, as again the numerator -integral and the normalizing denominator integral no longer match on a -per-iteration basis. +quantities results in a significant increase in variance. Notably, the same +problem occurs if using a tracklength estimate based on the analytical volume, +as again the numerator integral and the normalizing denominator integral no +longer match on a per-iteration basis. -In practice, the simulation averaged method does completely remove the bias seen -when using the naive estimator, though at the cost of a notable increase in -variance. Empirical testing reveals that on most eigenvalue problems, the -simulation averaged estimator does win out overall in numerical performance, as -a much coarser quadrature can be used resulting in faster runtimes overall. -Thus, OpenMC uses the simulation averaged estimator as default in its random ray -mode for eigenvalue solves. - -OpenMC also features a "hybrid" volume estimator that uses the naive estimator -for all regions containing an external (fixed) source term. For all other -source regions, the "simulation averaged" estimator is used. This typically achieves -a best of both worlds result, with the benefits of the low bias simulation averaged -estimator in most regions, while preventing instability and/or large biases in regions -with external source terms via use of the naive estimator. In general, it is -recommended to use the "hybrid" estimator, which is the default method used -in OpenMC. If instability is encountered despite high ray densities, then -the naive estimator may be preferable. - -A table that summarizes the pros and cons, as well as recommendations for -different use cases, is given in the :ref:`volume -estimators` section of the user guide. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -What Happens When a Source Region is Missed? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Given the stochastic nature of random ray, when low ray densities are used it is -common for small source regions to occasionally not be hit by any rays in a -particular power iteration :math:`n`. This naturally collapses the flux estimate -in that cell for the iteration from Equation :eq:`phi_naive` to: - -.. math:: - :label: phi_missed_one - - \phi_{i,g,n}^{missed} = \frac{Q_{i,g,n} }{\Sigma_{t,i,g}} - -as the streaming operator has gone to zero. While this is obviously innacurate -as it ignores transport, for most problems where the region is only occasionally -missed this estimator does not tend to introduce any significant bias. - -However, in cases where the total cross section in the region is very small -(e.g., a void-like material) and where a strong external fixed source has been -placed, then this treatment causes major issues. In this pathological case, the -lack of transport forces the entirety of the fixed source to effectively be -contained and collided within the cell, which for a low cross section region is -highly unphysical. The net effect is that a very high estimate of the flux -(often orders of magnitude higher than is expected) is generated that iteration, -which cannot be washed out even with hundreds or thousands of iterations. Thus, -huge biases are often seen in spatial tallies containing void-like regions with -external sources unless a high enough ray density is used such that all source -regions are always hit each iteration. This is particularly problematic as -external sources placed in void-like regions are very common in many types of -fixed source analysis. - -For regions where external sources are present, to eliminate this bias it is -therefore preferable to simply use the previous iteration's estimate of the flux -in that cell, as: - -.. math:: - :label: phi_missed_two - - \phi_{i,g,n}^{missed} = \phi_{i,g,n-1} . - -When linear sources are present, the flux moments from the previous iteration -are used in the same manner. While this introduces some small degree of -correlation to the simulation, for miss rates on the order of a few percent the -correlations are trivial and the bias is eliminated. Thus, in OpenMC the -previous iteration's scalar flux estimate is applied to cells that are missed -where there is an external source term present within the cell. +In practice, the simulation averaged method does completely remove the bias, +though at the cost of a notable increase in variance. Empirical testing reveals +that on most problems, the simulation averaged estimator does win out overall in +numerical performance, as a much coarser quadrature can be used resulting in +faster runtimes overall. Thus, OpenMC uses the simulation averaged estimator in +its random ray mode. ~~~~~~~~~~~~~~~ Power Iteration @@ -627,15 +561,15 @@ total spatial- and energy-integrated fission rate :math:`F^{n-1}` in iteration Notably, the volume term :math:`V_i` appears in the eigenvalue update equation. The same logic applies to the treatment of this term as was discussed earlier. -In OpenMC, we use the "simulation averaged" volume (Equation :eq:`L_avg`) -derived from summing over all ray tracklength contributions to a FSR over all -iterations and dividing by the total integration tracklength to date. Thus, -Equation :eq:`fission_source` becomes: +In OpenMC, we use the "simulation averaged" volume derived from summing over all +ray tracklength contributions to a FSR over all iterations and dividing by the +total integration tracklength to date. Thus, Equation :eq:`fission_source` +becomes: .. math:: :label: fission_source_volumed - F^n = \sum\limits^{M}_{i} \left( L_{avg} \sum\limits^{G}_{g} \nu \Sigma_f(i, g) \phi^{n}(g) \right) + F^n = \sum\limits^{M}_{i} \left( \frac{\sum\limits^{B}_{b}\sum\limits^{N_i}_{r} \ell_{b,r} }{B} \sum\limits^{G}_{g} \nu \Sigma_f(i, g) \phi^{n}(g) \right) and a similar substitution can be made to update Equation :eq:`fission_source_prev` . In OpenMC, the most up-to-date version of the volume @@ -671,7 +605,7 @@ guess can be made by taking the isotropic source from the FSR the ray was sampled in, direct usage of this quantity would result in significant bias and error being imparted on the simulation. -Thus, an `on-the-fly approximation method `_ was developed (known +Thus, an `on-the-fly approximation method `_ was developed (known as the "dead zone"), where the first several mean free paths of a ray are considered to be "inactive" or "read only". In this sense, the angular flux is solved for using the MOC equation, but the ray does not "tally" any scalar flux @@ -804,8 +738,6 @@ scalar flux value for the FSR). global::volume[fsr] += s; } -.. _methods_random_tallies: - ------------------------ How are Tallies Handled? ------------------------ @@ -813,7 +745,6 @@ How are Tallies Handled? Most tallies, filters, and scores that you would expect to work with a multigroup solver like random ray should work. For example, you can define 3D mesh tallies with energy filters and flux, fission, and nu-fission scores, etc. - There are some restrictions though. For starters, it is assumed that all filter mesh boundaries will conform to physical surface boundaries (or lattice boundaries) in the simulation geometry. It is acceptable for multiple cells @@ -823,215 +754,6 @@ behavior if a single simulation cell is able to score to multiple filter mesh cells. In the future, the capability to fully support mesh tallies may be added to OpenMC, but for now this restriction needs to be respected. -Flux tallies are handled slightly differently than in Monte Carlo. By default, -in MC, flux tallies are reported in units of tracklength (cm), so must be -manually normalized by volume by the user to produce an estimate of flux in -units of cm\ :sup:`-2`\. Alternatively, MC flux tallies can be normalized via a -separated volume calculation process as discussed in the :ref:`Volume -Calculation Section`. In random ray, as the volumes are -computed on-the-fly as part of the transport process, the flux tallies can -easily be reported either in units of flux (cm\ :sup:`-2`\) or tracklength (cm). -By default, the unnormalized flux values (units of cm) will be reported. If the -user wishes to received volume normalized flux tallies, then an option for this -is available, as described in the :ref:`User Guide`. - --------------- -Linear Sources --------------- - -Instead of making a flat source approximation, as in the previous section, a -Linear Source (LS) approximation can be used. Different LS approximations have -been developed; the OpenMC implementation follows the MOC LS scheme described by -`Ferrer `_. The LS source along a characteristic is given by: - -.. math:: - :label: linear_source - - Q_{i,g}(s) = \bar{Q}_{r,i,g} + \hat{Q}_{r,i,g}(s-\ell_{r}/2), - -where the source, :math:`Q_{i,g}(s)`, varies linearly along the track and -:math:`\bar{Q}_{r,i,g}` and :math:`\hat{Q}_{r,i,g}` are track specific source -terms to define shortly. Integrating the source, as done in Equation -:eq:`moc_final`, leads to - -.. math:: - :label: lsr_attenuation - - \psi^{out}_{r,g}=\psi^{in}_{r,g} + \left(\frac{\bar{Q}_{r, i, g}}{\Sigma_{\mathrm{t}, i, g}}-\psi^{in}_{r,g}\right) - F_{1}\left(\tau_{i,g}\right)+\frac{\hat{Q}_{r, i, g}^{g}}{2\left(\Sigma_{\mathrm{t}, i,g}\right)^{2}} F_{2}\left(\tau_{i,g}\right), - -where for simplicity the term :math:`\tau_{i,g}` and the expoentials :math:`F_1` -and :math:`F_2` are introduced, given by: - -.. math:: - :label: tau - - \tau_{i,g} = \Sigma_{\mathrm{t,i,g}} \ell_{r} - -.. math:: - :label: f1 - - F_1(\tau) = 1 - e^{-\tau}, - -and - -.. math:: - :label: f2 - - F_{2}\left(\tau\right) = 2\left[\tau-F_{1}\left(\tau\right)\right]-\tau F_{1}\left(\tau\right). - - -To solve for the track specific source terms in Equation :eq:`linear_source` we -first define a local reference frame. If we now refer to :math:`\mathbf{r}` as -the global coordinate and introduce the source region specific coordinate -:math:`\mathbf{u}` such that, - -.. math:: - :label: local_coord - - \mathbf{u}_{r} = \mathbf{r}-\mathbf{r}_{\mathrm{c}}, - -where :math:`\mathbf{r}_{\mathrm{c}}` is the centroid of the source region of -interest. In turn :math:`\mathbf{u}_{r,\mathrm{c}}` and :math:`\mathbf{u}_{r,0}` -are the local centroid and entry positions of a ray. The computation of the -local and global centroids are described further by `Gunow `_. - -Using the local position, the source in a source region is given by: - -.. math:: - :label: region_source - - \tilde{Q}(\boldsymbol{x}) ={Q}_{i,g}+ \boldsymbol{\vec{Q}}_{i,g} \cdot \mathbf{u}_{r}\;\mathrm{,} - -This definition allows us to solve for our characteric source terms resulting in: - -.. math:: - :label: source_term_1 - - \bar{Q}_{r, i, g} = Q_{i,g} + \left[\mathbf{u}_{r,\mathrm{c}} \cdot \boldsymbol{\vec{Q}}_{i,g}\right], - -.. math:: - :label: source_term_2 - - \hat{Q}_{r, i, g} = \left[\boldsymbol{\Omega} \cdot \boldsymbol{\vec{Q}}_{i,g}\right]\;\mathrm{,} - -:math:`\boldsymbol{\Omega}` being the direction vector of the ray. The next step -is to solve for the LS source vector :math:`\boldsymbol{\vec{Q}}_{i,g}`. A -relationship between the LS source vector and the source moments, -:math:`\boldsymbol{\vec{q}}_{i,g}` can be derived, as in `Ferrer -`_ and `Gunow `_: - -.. math:: - :label: m_equation - - \mathbf{M}_{i} \boldsymbol{\vec{Q}}_{i,g} = \boldsymbol{\vec{q}}_{i,g} \;\mathrm{.} - -The spatial moments matrix :math:`M_i` in region :math:`i` represents the -spatial distribution of the 3D object composing the `source region -`_. This matrix is independent of the material of the source -region, fluxes, and any transport effects -- it is a purely geometric quantity. -It is a symmetric :math:`3\times3` matrix. While :math:`M_i` is not known -apriori to the simulation, similar to the source region volume, it can be -computed "on-the-fly" as a byproduct of the random ray integration process. Each -time a ray randomly crosses the region within its active length, an estimate of -the spatial moments matrix can be computed by using the midpoint of the ray as -an estimate of the centroid, and the distance and direction of the ray can be -used to inform the other spatial moments within the matrix. As this information -is purely geometric, the stochastic estimate of the centroid and spatial moments -matrix can be accumulated and improved over the entire duration of the -simulation, converging towards their true quantities. - -With an estimate of the spatial moments matrix :math:`M_i` resulting from the -ray tracing process naturally, the LS source vector -:math:`\boldsymbol{\vec{Q}}_{i,g}` can be obtained via a linear solve of -:eq:`m_equation`, or by the direct inversion of :math:`M_i`. However, to -accomplish this, we must first know the source moments -:math:`\boldsymbol{\vec{q}}_{i,g}`. Fortunately, the source moments are also -defined by the definition of the source: - -.. math:: - :label: source_moments - - q_{v, i, g}= \frac{\chi_{i,g}}{k_{eff}} \sum_{g^{\prime}=1}^{G} \nu - \Sigma_{\mathrm{f},i, g^{\prime}} \hat{\phi}_{v, i, g^{\prime}} + \sum_{g^{\prime}=1}^{G} - \Sigma_{\mathrm{s}, i, g^{\prime}\rightarrow g} \hat{\phi}_{v, i, g^{\prime}}\quad \forall v \in(x, y, z)\;\mathrm{,} - -where :math:`v` indicates the direction vector component, and we have introduced -the scalar flux moments :math:`\hat{\phi}`. The scalar flux moments can be -solved for by taking the `integral definition `_ of a spatial -moment, allowing us to derive a "simulation averaged" estimator for the scalar -moment, as in Equation :eq:`phi_sim`, - -.. math:: - :label: scalar_moments_sim - - \hat{\phi}_{v,i,g}^{simulation} = \frac{\sum\limits_{r=1}^{N_i} - \ell_{r} \left[\Omega_{v} \hat{\psi}_{r,i,g} + u_{r,v,0} \bar{\psi}_{r,i,g}\right]} - {\Sigma_{t,i,g} \frac{\sum\limits^{B}_{b}\sum\limits^{N_i}_{r} \ell_{b,r} }{B}} - \quad \forall v \in(x, y, z)\;\mathrm{,} - - -where the average angular flux is given by Equation :eq:`average_psi_final`, and -the angular flux spatial moments :math:`\hat{\psi}_{r,i,g}` by: - -.. math:: - :label: angular_moments - - \hat{\psi}_{r, i, g} = \frac{\ell_{r}\psi^{in}_{r,g}}{2} + - \left(\frac{\bar{Q}_{r,i, g}}{\Sigma_{\mathrm{t}, i, g}}-\psi^{in}_{r,g}\right) - \frac{G_{1}\left(\tau_{i,g}\right)}{\Sigma_{\mathrm{t}, i, g}} + \frac{\ell_{r}\hat{Q}_{r,i,g}} - {2\left(\Sigma_{\mathrm{t}, i, g}\right)^{2}}G_{2}\left(\tau_{i,g}\right)\;\mathrm{.} - - -The new exponentials introduced, again for simplicity, are simply: - -.. math:: - :label: G1 - - G_{1}(\tau) = 1+\frac{\tau}{2}-\left(1+\frac{1}{\tau}\right) F_{1}(\tau), - -.. math:: - :label: G2 - - G_{2}(\tau) = \frac{2}{3} \tau-\left(1+\frac{2}{\tau}\right) G_{1}(\tau) - -The contents of this section, alongside the equations for the flat source and -scalar flux, Equations :eq:`source_update` and :eq:`phi_sim` respectively, -completes the set of equations for LS. - -.. _methods-shannon-entropy-random-ray: - ------------------------------ -Shannon Entropy in Random Ray ------------------------------ - -As :math:`k_{eff}` is updated at each generation, the fission source at each FSR -is used to compute the Shannon entropy. This follows the :ref:`same procedure -for computing Shannon entropy in continuous-energy or multigroup Monte Carlo -simulations `, except that fission sources at FSRs are -considered, rather than fission sites of user-defined regular meshes. Thus, the -volume-weighted fission rate is considered instead, and the fraction of fission -sources is adjusted such that: - -.. math:: - :label: fraction-source-random-ray - - S_i = \frac{\text{Fission source in FSR $i \times$ Volume of FSR - $i$}}{\text{Total fission source}} = \frac{Q_{i} V_{i}}{\sum_{i=1}^{i=N} - Q_{i} V_{i}} - -The Shannon entropy is then computed normally as - -.. math:: - :label: shannon-entropy-random-ray - - H = - \sum_{i=1}^N S_i \log_2 S_i - -where :math:`N` is the number of FSRs. FSRs with no fission source (or, -occassionally, negative fission source, :ref:`due to the volume estimator -problem `) are skipped to avoid taking an undefined -logarithm in :eq:`shannon-entropy-random-ray`. - .. _usersguide_fixed_source_methods: ------------ @@ -1050,8 +772,7 @@ random ray and Monte Carlo, however. regions. Thus, in the OpenMC implementation of random ray, particle sources are restricted to being volumetric and isotropic, although different energy spectrums are supported. Fixed sources can be applied to specific materials, - cells, or universes. Point sources are "smeared" to fill the volume of the - source region that contains the point source coordinate. + cells, or universes. - **Inactive batches:** In Monte Carlo, use of a fixed source implies that all batches are active batches, as there is no longer a need to develop a fission @@ -1059,55 +780,6 @@ random ray and Monte Carlo, however. develop the scattering source by way of inactive batches before beginning active batches. -.. _adjoint: - ------------------------- -Adjoint Flux Solver Mode ------------------------- - -The random ray solver in OpenMC can also be used to solve for the adjoint flux, -:math:`\psi^{\dagger}`. In combination with the regular (forward) flux solution, -the adjoint flux is useful for perturbation methods as well as for computing -weight windows for subsequent Monte Carlo simulations. The adjoint flux can be -thought of as the "backwards" flux, representing the flux where a particle is -born at an absoprtion point (and typical absorption energy), and then undergoes -transport with a transposed scattering matrix. That is, instead of sampling a -particle and seeing where it might go as in a standard forward solve, we will -sample an absorption location and see where the particle that was absorbed there -might have come from. Notably, for typical neutron absorption at low energy -levels, this means that adjoint flux particles are typically sampled at a low -energy and then upscatter (via a transposed scattering matrix) over their -lifetimes. - -In OpenMC, the random ray adjoint solver is implemented simply by transposing -the scattering matrix, swapping :math:`\nu\Sigma_f` and :math:`\chi`, and then -running a normal transport solve. When no external fixed forward source is -present, or if an adjoint fixed source is specifically provided, no additional -changes are needed in the transport process. This adjoint source can -correspond, for example, to a detector response function in a particular -region. However, if an external fixed forward source is present in the -simulation problem without an adjoint fixed source, an additional step is taken -to compute the accompanying forward-weighted adjoint source. In this case, the -adjoint flux does *not* represent the importance of locations in phase space to -detector response; rather, the "response" in question is a uniform distribution -of Monte Carlo particle density, making the importance provided by the adjoint -flux appropriate for use with weight window generation schemes for global -variance reduction. Thus, if using a fixed source, the forward-weighted -external source for adjoint mode is simply computed as being :math:`1 / \phi`, -where :math:`\phi` is the forward scalar flux that results from a normal -forward solve (which OpenMC will run first automatically when in adjoint mode). -The adjoint external source will be computed for each source region in the -simulation mesh, independent of any tallies. The adjoint external source is -always flat, even when a linear scattering and fission source shape is used. - -When in adjoint mode, all reported results (e.g., tallies, eigenvalues, etc.) -are derived from the adjoint flux, even when the physical meaning is not -necessarily obvious. These values are still reported, though we emphasize that -the primary use case for adjoint mode is for producing adjoint flux tallies to -support subsequent perturbation studies and weight window generation. Note -however that the adjoint :math:`k_{eff}` is statistically the same as the -forward :math:`k_{eff}`, despite the flux distributions taking different shapes. - --------------------------- Fundamental Sources of Bias --------------------------- @@ -1130,13 +802,13 @@ in random ray particle transport are: areas typically have solutions that are highly effective at mitigating bias, error stemming from multigroup energy discretization is much harder to remedy. - - **Source Approximation:**. In OpenMC, a "flat" (0th order) source - approximation is often made, wherein the scattering and fission sources within a + - **Flat Source Approximation:**. In OpenMC, a "flat" (0th order) source + approximation is made, wherein the scattering and fission sources within a cell are assumed to be spatially uniform. As the source in reality is a continuous function, this leads to bias, although the bias can be reduced to acceptable levels if the flat source regions are sufficiently small. - The bias can also be mitigated by assuming a higher-order source such as the - linear source approximation currently implemented into OpenMC. + The bias can also be mitigated by assuming a higher-order source (e.g., + linear or quadratic), although OpenMC does not yet have this capability. In practical terms, this source of bias can become very large if cells are large (with dimensions beyond that of a typical particle mean free path), but the subdivision of cells can often reduce this bias to trivial levels. @@ -1160,8 +832,6 @@ in random ray particle transport are: .. _Tramm-2018: https://dspace.mit.edu/handle/1721.1/119038 .. _Tramm-2020: https://doi.org/10.1051/EPJCONF/202124703021 .. _Cosgrove-2023: https://doi.org/10.1080/00295639.2023.2270618 -.. _Ferrer-2016: https://doi.org/10.13182/NSE15-6 -.. _Gunow-2018: https://dspace.mit.edu/handle/1721.1/119030 .. only:: html diff --git a/docs/source/methods/tallies.rst b/docs/source/methods/tallies.rst index f2c22ab22..d833c157d 100644 --- a/docs/source/methods/tallies.rst +++ b/docs/source/methods/tallies.rst @@ -4,9 +4,9 @@ Tallies ======= -The methods discussed in this section are written specifically for continuous- -energy mode. However, they can also apply to the multi-group mode if the -particle's energy is instead interpreted as the particle's group. +Note that the methods discussed in this section are written specifically for +continuous-energy mode but equivalent apply to the multi-group mode if the +particle's energy is replaced with the particle's group ------------------ Filters and Scores @@ -205,73 +205,7 @@ had a collision at every event. Thus, for tallies with outgoing-energy filters or for tallies of scattering moments (which require the scattering cosine of the change-in-angle), we must use an analog estimator. ------------------------------------ -Surface-Integrated Flux and Current ------------------------------------ - -Surface tallies allow you to measure particle behavior as they cross specific -boundaries in your geometry. Unlike volume tallies, which integrate over a -volumetric region, surface tallies capture the current or flux passing through a -surface. Surface tallies are estimated using an analog estimator. - -Current Score -------------- - -When tallying the current across a surface, we simply count the weight of -particles that cross the surface of interest: - - -.. math:: - :label: analog-current-estimator - - J = \frac{1}{W} \sum_{i \in S} w_i. - -where :math:`J` is the area-integrated current passing through surface -:math:`S`, :math:`W` is the total starting weight of the particles, and -:math:`w_i` is the weight of the particle as it crosses the surface :math:`S`. - -Flux Score ----------- - -When tallying flux over a surface, we use the relationship between current and -flux: - - -.. math:: - :label: surface-flux-estimator - - \phi_S = \frac{1}{W} \sum_{i \in S} \frac{w_i}{|\mu|}. - -where :math:`\phi_S` is the area-integrated flux over surface :math:`S`, -:math:`W` is the total starting weight of the particles, :math:`w_i` is the -weight of the particle as it crosses the surface :math:`S` and :math:`\mu` is -the cosine of angle between the particle direction and the surface normal. - -This equation diverges when the particle crossing the surface is nearly parallel -to it (that is, as :math:`\mu` approaches zero). To remove this divergence, -OpenMC scores: - -.. math:: - :label: modified-surface-flux-estimator - - \phi_S = \frac{1}{W} \sum_{i \in S} w_i f(\mu). - -and the function :math:`f` is defined by: - -.. math:: - f(\mu) = \begin{cases} - \frac{1}{|\mu|} & |\mu| > \mu_\text{cut} \\ - \frac{1}{c\mu_\text{cut}} & |\mu| \le \mu_\text{cut} - \end{cases} - -where :math:`\mu_\text{cut}` is the grazing cosine cutoff and :math:`c` is the -cosine substitution ratio. The parameters :math:`\mu_\text{cut}` and :math:`c` -can be set by the user via the :attr:`openmc.Settings.surface_grazing_cutoff` -and :attr:`openmc.Settings.surface_grazing_ratio` attributes, respectively. The -default values for these parameters are 0.001 and 0.5 as recommended by -`Favorite, Thomas, and Booth `_. - -.. _tallies_statistics: +.. TODO: Add description of surface current tallies ---------- Statistics @@ -334,14 +268,6 @@ normal, log-normal, Weibull, etc. The central limit theorem states that as Estimating Statistics of a Random Variable ------------------------------------------ -After running OpenMC, each tallied quantity has a reported mean and standard -deviation. The below sections explain how these quantities are computed. Note -that OpenMC uses **batch statistics**, meaning that each observation for a tally -random variable corresponds to the aggregation of tally contributions from -multiple source particles that are grouped together into a single batch. See -:ref:`usersguide_particles` for more information on how the number of source -particles and statistical batches are specified. - Mean ++++ @@ -451,130 +377,6 @@ of this is that the longer you run a simulation, the better you know your results. Therefore, by running a simulation long enough, it is possible to reduce the stochastic uncertainty to arbitrarily low levels. -Skewness -++++++++ - -The `skewness`_ of a population quantifies the asymmetry of the probability -distribution around its mean. Positive and negative skewness indicate a -longer/heavier right and left tail respectively. Let :math:`x_1,\ldots,x_n` be -the per-realization values for a bin, with sample mean :math:`\bar{x}` and -sample central moments: - -.. math:: - - m_k \;=\; \frac{1}{n}\sum_{i=1}^{n}\bigl(x_i-\bar{x}\bigr)^k. - -OpenMC reports the *adjusted Fisher-Pearson skewness* (defined for :math:`n \ge -3`), which is commonly used in many statistical packages: - -.. math:: - - G_1 \;=\; \frac{\sqrt{n \cdot (n-1)}}{\,n-2\,}\cdot\frac{m_3}{m_2^{3/2}}. - -where :math:`m_2` and :math:`m_3` correspond to the biased sample second and -third central moment respectively. - -Kurtosis -++++++++ - -The `kurtosis`_ of a population quantifies tail weight (also called tailedness) -of the probability distribution relative to a normal distribution. Positive -excess kurtosis indicates *heavier tails* whereas negative excess kurtosis -indicates *lighter tails*. Kurtosis is especially useful for identifying bins -where occasional extreme scores dominate uncertainty. OpenMC reports the -*adjusted excess kurtosis* (defined for :math:`n \ge 4`): - -.. math:: - - G_2 \;=\; \frac{(n-1)}{(n-2)(n-3)} - \left[(n+1)\,\frac{m_4}{m_2^{2}} \;-\; 3(n-1)\right]. - -where :math:`m_2` and :math:`m_4` correspond to the biased sample second and -fourth central moment respectively. For a perfectly normal distribution, the -excess kurtosis is :math:`0`. - -Variance of Variance -++++++++++++++++++++ - -The variance of the variance (also known as the coefficient of variation -squared) measures *stability of the sample variance* :math:`s^2` and, by -extension, the reliability of reported relative errors. High VOV means that -error bars themselves are noisy—often due to heavy tails, skewness, or too few -realizations. - -.. math:: - - VOV = \frac{s^2(s_{\bar{X}}^2)}{s_{\bar{X}}^4 } = \frac{m_4}{m_2^2} - \frac{1}{n} - -where :math:`s_{\bar{X}}^2` is the estimated variance of the mean and -:math:`s^2(s_{\bar{X}}^2)` is the estimated variance in :math:`s_{\bar{X}}^2`. -The MCNP manual suggests a hard threshold such that :math:`VOV < 0.1` to improve -the probability of forming a reliable confidence interval. However, OpenMC does -not enforce an universal cut-off because the suitability of any single threshold -depends strongly on problem specifics (estimator choice, variance-reduction -settings, tally binning, or even effective sample size). - - -Normality Tests (D'Agostino-Pearson) -++++++++++++++++++++++++++++++++++++ - -These normality test verify the hypothesis that fluctuations are *approximately -normal*, a working assumption behind many Monte Carlo diagnostics and -`confidence-interval heuristics`_. Tests are provided for: (i) skewness-only, -(ii) kurtosis-only, and (iii) the *omnibus* combination. OpenMC uses the -finite-sample-adjusted skewness :math:`G_1` and excess kurtosis :math:`G_2` -above to construct standardized normal scores :math:`Z_1` (from :math:`G_1`) and -:math:`Z_2` (from :math:`G_2`) via the D'Agostino-Pearson transformations. The -omnibus statistic is - -.. math:: - - K^2 \;=\; Z_1^{\,2} \;+\; Z_2^{\,2} - \;\sim\; \chi^2_{(2)} \quad \text{under } H_0:\ \text{normality}. - -OpenMC reports :math:`Z_1`, :math:`Z_2`, :math:`K^2`, and their p-values when -prerequisites are met (skewness for :math:`n\ge 3`, kurtosis and omnibus for -:math:`n\ge 4`). Given a user-chosen significance level :math:`\alpha` (default -is :math:`0.05`), reject :math:`H_0` if :math:`\text{p-value}<\alpha`; otherwise -fail to reject. OpenMC leaves the interpretation to the user, who should -consider VOV together with skewness, kurtosis, and normality tests results when -judging whether reported confidence intervals are credible for their application -[#norm-tests]_. - -.. [#norm-tests] - Higher-moments accumulation must be enabled with ``higher_moments = True`` - for running these diagnostics including the skewness, kurtosis, and normality - tests. - -Figure of Merit -+++++++++++++++ - -The figure of merit (FOM) is an indicator that accounts for both the statistical -uncertainty and the execution time and represents how much information is -obtained per unit time in the simulation. The FOM is defined as - -.. math:: - :label: figure_of_merit - - FOM = \frac{1}{r^2 t}, - -where :math:`t` is the total execution time and :math:`r` is the relative error -defined as - -.. math:: - :label: relative_error - - r = \frac{s_{\bar{X}}}{\bar{x}}. - -Based on this definition, one can see that a higher FOM is desirable. The FOM is -useful as a comparative tool. For example, if a variance reduction technique is -being applied to a simulation, the FOM with variance reduction can be compared -to the FOM without variance reduction to ascertain whether the reduction in -variance outweighs the potential increase in execution time (e.g., due to -particle splitting). It is important to note that MCNP reports the FOM using CPU -time (wall-clock time multiplied by the number of threads/cores), whereas OpenMC -reports the FOM using only the wall-clock time :math:`t`. - Confidence Intervals ++++++++++++++++++++ @@ -682,8 +484,6 @@ improve the estimate of the percentile. .. rubric:: References -.. _confidence-interval heuristics: https://doi.org/10.1080/00031305.1990.10475751 - .. _following approximation: https://doi.org/10.1080/03610918708812641 .. _Bessel's correction: https://en.wikipedia.org/wiki/Bessel's_correction @@ -704,10 +504,6 @@ improve the estimate of the percentile. .. _converges in distribution: https://en.wikipedia.org/wiki/Convergence_of_random_variables#Convergence_in_distribution -.. _skewness: https://en.wikipedia.org/wiki/Skewness - -.. _kurtosis: https://en.wikipedia.org/wiki/Kurtosis - .. _confidence intervals: https://en.wikipedia.org/wiki/Confidence_interval .. _Student's t-distribution: https://en.wikipedia.org/wiki/Student%27s_t-distribution @@ -716,4 +512,4 @@ improve the estimate of the percentile. .. _unpublished rational approximation: https://stackedboxes.org/2017/05/01/acklams-normal-quantile-function/ -.. _MC21: https://www.osti.gov/servlets/purl/903083 +.. _MC21: http://www.osti.gov/bridge/servlets/purl/903083-HT5p1o/903083.pdf diff --git a/docs/source/methods/variance_reduction.rst b/docs/source/methods/variance_reduction.rst deleted file mode 100644 index 7778e0714..000000000 --- a/docs/source/methods/variance_reduction.rst +++ /dev/null @@ -1,216 +0,0 @@ -.. _methods_variance_reduction: - -================== -Variance Reduction -================== - -.. _methods_variance_reduction_intro: - ------------- -Introduction ------------- - -Transport problems can sometimes involve a significant degree of attenuation -between the source and a detector (tally) region, which can result in a flux -differential of ten orders of magnitude (or more) throughout the simulation -domain. As Monte Carlo uncertainties tend to be inversely proportional to the -physical flux density, it can be extremely difficult to accurately resolve -tallies in locations that are optically far from the source. This issue is -particularly common in fixed source simulations, where some tally locations may -not experience a single scoring event, even after billions of analog histories. - -Variance reduction techniques aim to either flatten the global uncertainty -distribution, such that all regions of phase space have a fairly similar -uncertainty, or to reduce the uncertainty in specific locations (such as a -detector). There are three strategies available in OpenMC for variance -reduction: weight windows generated via the MAGIC method or the FW-CADIS method, -and source biasing. Both weight windowing strategies work by developing a mesh -that can be utilized by subsequent Monte Carlo solves to split particles heading -towards areas of lower flux densities while terminating particles in higher flux -regions. In contrast, source biasing modifies source site sampling behavior to -preferentially track particles more likely to reach phase space regions of -interest. - ------------- -MAGIC Method ------------- - -The Method of Automatic Generation of Importances by Calculation, or `MAGIC -method `_, is an iterative -technique that uses spatial flux information :math:`\phi(r)` obtained from a -normal Monte Carlo solve to produce weight windows :math:`w(r)` that can be -utilized by a subsequent iteration of Monte Carlo. While the first generation of -weight windows produced may only help to reduce variance slightly, use of these -weights to generate another set of weight windows results in a progressively -improving iterative scheme. - -Equation :eq:`magic` defines how the lower bound of weight windows -:math:`w_{\ell}(r)` are generated with MAGIC using forward flux information. -Here, we can see that the flux at location :math:`r` is normalized by the -maximum flux in any group at that location. We can also see that the weights are -divided by a factor of two, which accounts for the typical :math:`5\times` -factor separating the lower and upper weight window bounds in OpenMC. - -.. math:: - :label: magic - - w_{\ell}(r) = \frac{\phi(r)}{2\,\text{max}(\phi(r))} - -A major advantage of this technique is that it does not require any special -transport machinery; it simply uses multiple Monte Carlo simulations to -iteratively improve a set of weight windows (which are typically defined on a -mesh covering the simulation domain). The downside to this method is that as the -flux differential increases between areas near and far from the source, it -requires more outer Monte Carlo iterations, each of which can be expensive in -itself. Additionally, computation of weight windows based on regular (forward) -neutron flux tally information does not produce the most numerically effective -set of weight windows. Nonetheless, MAGIC remains a simple and effective -technique for generating weight windows. - --------- -FW-CADIS --------- - -As discussed in the previous section, computation of weight windows based on -regular (forward) neutron flux tally information does not produce the most -numerically efficient set of weight windows. It is highly preferable to generate -weight windows based on spatial adjoint flux :math:`\phi^{\dag}(r)` -information. The adjoint flux is essentially the "reverse" simulation problem, -where we sample a random point and assume this is where a particle was absorbed, -and then trace it backwards (upscattering in energy), until we sample the point -where it was born from. - -The Forward-Weighted Consistent Adjoint Driven Importance Sampling method, or -`FW-CADIS method `_, produces weight windows -for global or local variance reduction given adjoint flux information throughout -the entire domain. The weight window lower bound is defined in Equation -:eq:`fw_cadis`, and also involves a normalization step not shown here. - -.. math:: - :label: fw_cadis - - w_{\ell}(r) = \frac{1}{2\phi^{\dag}(r)} - -While the algorithm itself is quite simple, it requires estimates of the global -adjoint flux distribution, which is difficult to generate directly with Monte -Carlo transport. Thus, FW-CADIS typically uses an alternative solver (often -deterministic) that can be more readily adapted for generating adjoint flux -information, and which is often much cheaper than Monte Carlo given that a rough -solution is often sufficient for weight window generation. - -The FW-CADIS implementation in OpenMC utilizes its own internal random ray -multigroup transport solver to generate the adjoint source distribution. No -coupling to any external transport is solver is necessary. The random ray solver -operates on the same geometry as the Monte Carlo solver, so no redefinition of -the simulation geometry is required. More details on how the adjoint flux is -computed are given in the :ref:`adjoint methods section `. - -More information on the workflow is available in the :ref:`user guide -`, but generally production of weight windows with FW-CADIS -involves several stages (some of which are highly automated). These tasks -include generation of approximate multigroup cross section data for use by the -random ray solver, running of the random ray solver in normal (forward flux) -mode to generate a source for the adjoint solver, running of the random ray -solver in adjoint mode to generate adjoint flux tallies, and finally the -production of weight windows via the FW-CADIS method. As is discussed in the -user guide, most of these steps are automated together, making the additional -burden on the user fairly small. - -The major advantage of this technique is that it typically produces much more -numerically efficient weight windows as compared to those generated with MAGIC, -sometimes with an order-of-magnitude improvement in the figure of merit -(Equation :eq:`variance_fom`), which accounts for both the variance and the -execution time. Another major advantage is that the cost of the random ray -solver is typically negligible compared to the cost of the subsequent Monte -Carlo solve itself, making it a very cheap method to deploy. The downside to -this method is that it introduces a second transport method into the mix (random -ray), such that there are more free input parameters for the user to know about -and adjust, potentially making the method more complex to use. However, as many -of the parameters have natural choices, much of this parameterization can be -handled automatically behind the scenes without the need for the user to be -aware of this. - -.. math:: - :label: variance_fom - - \text{FOM} = \frac{1}{\text{Time} \times \sigma^2} - -Finally, one unique capability of the FW-CADIS weight window generator is to -produce weight windows for local variance reduction, given a list of the -responses of interest. This is controlled by optionally specifying target -tallies from the :class:`openmc.model.Model` to the -:class:`openmc.WeightWindowGenerator`, as illustrated in the -:ref:`user guide`. If target tallies for local variance -reduction are supplied, then the adjoint sources are only populated after the -initial forward simulation in the source regions associated with those tallies. -In other regions, the adjoint source term is instead set to zero. The Random -Ray solver then determines the adjoint flux map used to generate FW-CADIS -weight windows following the usual technique. - -.. _methods_source_biasing: - --------------- -Source Biasing --------------- - -In contrast to the previous two methods that introduce population controls -during transport, source biasing modifies the sampling of the external source -distribution. The basic premise of the technique is that for each spatial, -angular, energy, or time distribution of a source, an additional distribution -can be specified provided that the two share a common support (set of points -where the distribution is nonzero). Samples are then drawn from this "bias" -distribution, which can be chosen to preferentially direct particles towards -phase space regions of interest. In order to avoid biasing the tally results, -however, a weight adjustment is applied to each sampled site as described below. - -Assume that the unbiased probability density function of a random variable -:math:`X:x \rightarrow \mathbb{R}` is given by :math:`f(x)`, but that using the -biased distribution :math:`g(x)` will result in a greater number of particle -trajectories reaching some phase space region of interest. Then a sample -:math:`x_0` may be drawn from :math:`g(x)` while maintaining a fair game, -provided that its weight is adjusted as: - -.. math:: - :label: source_bias - - w = w_0 \times \frac{f(x_0)}{g(x_0)} - -where :math:`w_0` is the weight of an unbiased sample from :math:`f(x)`, -typically unity. - -Returning now to Equation :eq:`source_bias`, the requirement for common support -becomes evident. If :math:`\mathrm{supp} (g)` fully contains but is not -identical to :math:`\mathrm{supp} (f)`, then some samples from :math:`g(x)` will -correspond to points where :math:`f(x) = 0`. Thus these source sites would be -assigned a starting weight of 0, meaning the particles would be killed -immediately upon transport, effectively wasting computation time. Conversely, if -:math:`\mathrm{supp} (g)` is fully contained by but not identical to -:math:`\mathrm{supp} (f)`, the contributions of some regions outside -:math:`\mathrm{supp} (g)` will not be counted towards the integral, potentially -biasing the tally. The weight assigned to such points would be undefined since -:math:`g(x) = \mathbf{0}` at these points. - -When an independent source is sampled in OpenMC, the particle's coordinate in -each variable of phase space :math:`(\mathbf{r},\mathbf{\Omega},E,t)` is -successively drawn from an independent probability distribution. Multiple -variables can be biased, in which case the resultant weight :math:`w` applied to -the particle is the product of the weights assigned from all sampled -distributions: space, angle, energy, and time, as shown in Equation -:eq:`tot_wgt`. - -.. math:: - :label: tot_wgt - - w = w_r \times w_{\Omega} \times w_E \times w_t - -Finally, source biasing and weight windows serve different purposes. Source -biasing changes how particles are born, allowing the initial source sites to be -sampled preferentially from important regions of phase space (space, angle, -energy, and time) with an accompanying weight adjustment. Weight windows, by -contrast, apply population control during transport (splitting and Russian -roulette) to help particles reach and contribute in important regions as they -move through the system. Because particle transport proceeds as usual after a -biased source is sampled, particle attenuation in optically thick regions -outside the source volume will not be affected by source biasing; in such -scenarios, transport biasing techniques such as weight windows are often more -effective. diff --git a/docs/source/publications.rst b/docs/source/publications.rst index a2d60d5af..88d0a97b9 100644 --- a/docs/source/publications.rst +++ b/docs/source/publications.rst @@ -138,8 +138,8 @@ Geometry and Visualization *Trans. Am. Nucl. Soc.*, **114**, 391-394 (2016). - Derek M. Lax, "`Memory efficient indexing algorithm for physical properties in - OpenMC `_," S. M. Thesis, - Massachusetts Institute of Technology (2015). + OpenMC `_," S. M. Thesis, Massachusetts + Institute of Technology (2015). - Derek Lax, William Boyd, Nicholas Horelik, Benoit Forget, and Kord Smith, "A memory efficient algorithm for classifying unique regions in constructive @@ -399,8 +399,7 @@ Doppler Broadening - Jonathan A. Walsh, Benoit Forget, Kord S. Smith, Brian C. Kiedrowski, and Forrest B. Brown, "`Direct, on-the-fly calculation of unresolved resonance region cross sections in Monte Carlo simulations - `_," *Proc. Joint Int. Conf. - M&C+SNA+MC*, + `_," *Proc. Joint Int. Conf. M&C+SNA+MC*, Nashville, Tennessee, Apr. 19--23 (2015). - Colin Josey, Benoit Forget, and Kord Smith, "`Windowed multipole sensitivity @@ -597,8 +596,7 @@ Depletion - Matthew S. Ellis, Colin Josey, Benoit Forget, and Kord Smith, "`Spatially Continuous Depletion Algorithm for Monte Carlo Simulations - `_," *Trans. Am. Nucl. Soc.*, - **115**, + `_," *Trans. Am. Nucl. Soc.*, **115**, 1221-1224 (2016). - Anas Gul, K. S. Chaudri, R. Khan, and M. Azeen, "`Development and verification diff --git a/docs/source/pythonapi/base.rst b/docs/source/pythonapi/base.rst index f06a1eba4..5ae9f20ed 100644 --- a/docs/source/pythonapi/base.rst +++ b/docs/source/pythonapi/base.rst @@ -26,7 +26,6 @@ Simulation Settings openmc.FileSource openmc.CompiledSource openmc.MeshSource - openmc.TokamakSource openmc.SourceParticle openmc.VolumeCalculation openmc.Settings @@ -38,6 +37,7 @@ Simulation Settings openmc.read_source_file openmc.write_source_file + openmc.wwinp_to_wws Material Specification ---------------------- @@ -129,13 +129,10 @@ Constructing Tallies openmc.SurfaceFilter openmc.MeshFilter openmc.MeshBornFilter - openmc.MeshMaterialFilter openmc.MeshSurfaceFilter openmc.EnergyFilter openmc.EnergyoutFilter - openmc.ParticleProductionFilter openmc.MuFilter - openmc.MuSurfaceFilter openmc.PolarFilter openmc.AzimuthalFilter openmc.DistribcellFilter @@ -145,31 +142,18 @@ Constructing Tallies openmc.SpatialLegendreFilter openmc.SphericalHarmonicsFilter openmc.TimeFilter - openmc.WeightFilter openmc.ZernikeFilter openmc.ZernikeRadialFilter - openmc.ParentNuclideFilter openmc.ParticleFilter - openmc.ReactionFilter - openmc.MeshMaterialVolumes - openmc.Trigger - openmc.TallyDerivative - openmc.Tally - openmc.Tallies - -Meshes ------- - -.. autosummary:: - :toctree: generated - :nosignatures: - :template: myclassinherit.rst - openmc.RegularMesh openmc.RectilinearMesh openmc.CylindricalMesh openmc.SphericalMesh openmc.UnstructuredMesh + openmc.Trigger + openmc.TallyDerivative + openmc.Tally + openmc.Tallies Geometry Plotting ----------------- @@ -179,10 +163,8 @@ Geometry Plotting :nosignatures: :template: myclass.rst - openmc.SlicePlot - openmc.VoxelPlot - openmc.WireframeRayTracePlot - openmc.SolidRayTracePlot + openmc.Plot + openmc.ProjectionPlot openmc.Plots Running OpenMC @@ -208,7 +190,6 @@ Post-processing :template: myclass.rst openmc.Particle - openmc.ParticleList openmc.ParticleTrack openmc.StatePoint openmc.Summary @@ -220,9 +201,6 @@ Post-processing :nosignatures: :template: myfunction.rst - openmc.read_collision_track_file - openmc.read_collision_track_hdf5 - openmc.read_collision_track_mcpl openmc.voxel_to_vtk The following classes and functions are used for functional expansion reconstruction. @@ -265,16 +243,8 @@ Variance Reduction :template: myclass openmc.WeightWindows - openmc.WeightWindowsList openmc.WeightWindowGenerator - -.. autosummary:: - :toctree: generated - :nosignatures: - :template: myfunction.rst - openmc.hdf5_to_wws - openmc.wwinp_to_wws Coarse Mesh Finite Difference Acceleration diff --git a/docs/source/pythonapi/capi.rst b/docs/source/pythonapi/capi.rst index dab45481d..995ad97fa 100644 --- a/docs/source/pythonapi/capi.rst +++ b/docs/source/pythonapi/capi.rst @@ -19,7 +19,6 @@ Functions finalize find_cell find_material - dagmc_universe_cell_ids global_bounding_box global_tallies hard_reset @@ -40,7 +39,6 @@ Functions reset_timers run run_in_memory - run_random_ray sample_external_source simulation_finalize simulation_init @@ -80,23 +78,17 @@ Classes MeshSurfaceFilter MuFilter Nuclide - ParentNuclideFilter ParticleFilter - ParticleProductionFilter PolarFilter - ReactionFilter RectilinearMesh RegularMesh SpatialLegendreFilter SphericalHarmonicsFilter SphericalMesh - SolidRayTracePlot SurfaceFilter Tally - TemporarySession UniverseFilter UnstructuredMesh - WeightFilter WeightWindows ZernikeFilter ZernikeRadialFilter @@ -128,12 +120,6 @@ Data :type: dict -.. data:: plots - - Mapping of plot ID to :class:`openmc.lib.SolidRayTracePlot` instances. - - :type: dict - .. data:: nuclides Mapping of nuclide name to :class:`openmc.lib.Nuclide` instances. diff --git a/docs/source/pythonapi/data.rst b/docs/source/pythonapi/data.rst index 9d47430f7..1eaf90c97 100644 --- a/docs/source/pythonapi/data.rst +++ b/docs/source/pythonapi/data.rst @@ -71,8 +71,6 @@ Core Functions isotopes kalbach_slope linearize - mass_attenuation_coefficient - mass_energy_absorption_coefficient thin water_density zam diff --git a/docs/source/pythonapi/deplete.rst b/docs/source/pythonapi/deplete.rst index 25fcd898f..8731a9a13 100644 --- a/docs/source/pythonapi/deplete.rst +++ b/docs/source/pythonapi/deplete.rst @@ -26,7 +26,7 @@ provided to obtain reaction rates from cross-section data. Several classes are provided that implement different time-integration algorithms for depletion calculations, which are described in detail in Colin Josey's thesis, `Development and analysis of high order neutron transport-depletion coupling -algorithms `_. +algorithms `_. .. autosummary:: :toctree: generated @@ -78,18 +78,20 @@ A minimal example for performing depletion would be: >>> import openmc.deplete >>> geometry = openmc.Geometry.from_xml() >>> settings = openmc.Settings.from_xml() - >>> model = openmc.Model(geometry, settings) + >>> model = openmc.model.Model(geometry, settings) # Representation of a depletion chain >>> chain_file = "chain_casl.xml" - >>> operator = openmc.deplete.CoupledOperator(model, chain_file) + >>> operator = openmc.deplete.CoupledOperator( + ... model, chain_file) # Set up 5 time steps of one day each >>> dt = [24 * 60 * 60] * 5 >>> power = 1e6 # constant power of 1 MW # Deplete using mid-point predictor-corrector - >>> cecm = openmc.deplete.CECMIntegrator(operator, dt, power) + >>> cecm = openmc.deplete.CECMIntegrator( + ... operator, dt, power) >>> cecm.integrate() Internal Classes and Functions @@ -206,15 +208,14 @@ total system energy. The :class:`openmc.deplete.IndependentOperator` uses inner classes subclassed from those listed above to perform similar calculations. -The following classes are used to define external source rates or transfer rates -to model continuous removal or feed of nuclides during depletion. +The following classes are used to define transfer rates to model continuous +removal or feed of nuclides during depletion. .. autosummary:: :toctree: generated :nosignatures: :template: myclass.rst - transfer_rates.ExternalSourceRates transfer_rates.TransferRates Intermediate Classes @@ -286,25 +287,3 @@ the following abstract base classes: abc.Integrator abc.SIIntegrator abc.DepSystemSolver - -R2S Automation --------------- - -.. autosummary:: - :toctree: generated - :nosignatures: - :template: myclass.rst - - R2SManager - -D1S Functions -------------- - -.. autosummary:: - :toctree: generated - :nosignatures: - :template: myfunction.rst - - d1s.prepare_tallies - d1s.time_correction_factors - d1s.apply_time_correction diff --git a/docs/source/pythonapi/examples.rst b/docs/source/pythonapi/examples.rst index 9efbd29c7..e7ef523c0 100644 --- a/docs/source/pythonapi/examples.rst +++ b/docs/source/pythonapi/examples.rst @@ -11,7 +11,6 @@ Simple Models :template: myfunction.rst openmc.examples.slab_mg - openmc.examples.sphere_with_shielded_pocket Reactor Models -------------- diff --git a/docs/source/pythonapi/mgxs.rst b/docs/source/pythonapi/mgxs.rst index 4141aa0a0..392914b36 100644 --- a/docs/source/pythonapi/mgxs.rst +++ b/docs/source/pythonapi/mgxs.rst @@ -11,16 +11,6 @@ Module Variables .. autodata:: openmc.mgxs.GROUP_STRUCTURES :annotation: -Functions -+++++++++ - -.. autosummary:: - :toctree: generated - :nosignatures: - :template: myfunction.rst - - openmc.mgxs.convert_flux_groups - Classes +++++++ diff --git a/docs/source/pythonapi/model.rst b/docs/source/pythonapi/model.rst index 3034826bd..99459f64d 100644 --- a/docs/source/pythonapi/model.rst +++ b/docs/source/pythonapi/model.rst @@ -22,17 +22,14 @@ Composite Surfaces :nosignatures: :template: myclass.rst - openmc.model.ConicalFrustum openmc.model.CruciformPrism openmc.model.CylinderSector openmc.model.HexagonalPrism openmc.model.IsogonalOctagon - openmc.model.OrthogonalBox openmc.model.Polygon openmc.model.RectangularParallelepiped openmc.model.RectangularPrism openmc.model.RightCircularCylinder - openmc.model.Vessel openmc.model.XConeOneSided openmc.model.YConeOneSided openmc.model.ZConeOneSided diff --git a/docs/source/pythonapi/stats.rst b/docs/source/pythonapi/stats.rst index 2f2e2835a..ffb4fcda2 100644 --- a/docs/source/pythonapi/stats.rst +++ b/docs/source/pythonapi/stats.rst @@ -22,15 +22,12 @@ Univariate Probability Distributions openmc.stats.Legendre openmc.stats.Mixture openmc.stats.Normal - openmc.stats.DecaySpectrum .. autosummary:: :toctree: generated :nosignatures: :template: myfunction.rst - openmc.stats.delta_function - openmc.stats.fusion_neutron_spectrum openmc.stats.muir Angular Distributions @@ -61,7 +58,6 @@ Spatial Distributions openmc.stats.Box openmc.stats.Point openmc.stats.MeshSpatial - openmc.stats.PointCloud .. autosummary:: :toctree: generated @@ -69,4 +65,3 @@ Spatial Distributions :template: myfunction.rst openmc.stats.spherical_uniform - openmc.stats.cylindrical_uniform diff --git a/docs/source/quickinstall.rst b/docs/source/quickinstall.rst index 6cb774b5b..7f222f77c 100644 --- a/docs/source/quickinstall.rst +++ b/docs/source/quickinstall.rst @@ -8,42 +8,56 @@ This quick install guide outlines the basic steps needed to install OpenMC on your computer. For more detailed instructions on configuring and installing OpenMC, see :ref:`usersguide_install` in the User's Manual. ----------------------------------- -Installing on Linux/Mac with Conda ----------------------------------- +-------------------------------------------------- +Installing on Linux/Mac with Mamba and conda-forge +-------------------------------------------------- -`Conda `_ is an open source package management +`Conda `_ is an open source package management system and environments management system for installing multiple versions of software packages and their dependencies and switching easily between them. -OpenMC can be installed in a `conda` environment. First, `conda` should be -`installed `_ -with either Anaconda Distribution or Miniconda. Once you have `conda` installed -on your system, OpenMC can be installed via the `conda-forge` channel. +`Mamba `_ is a cross-platform package +manager and is compatible with `conda` packages. +OpenMC can be installed in a `conda` environment with `mamba`. +First, `conda` should be installed with one of the following installers: +`Miniconda `_, +`Anaconda `_, or `Miniforge `_. +Once you have `conda` installed on your system, OpenMC can be installed via the +`conda-forge` channel with `mamba`. First, add the `conda-forge` channel with: .. code-block:: sh conda config --add channels conda-forge - conda config --set channel_priority strict -Then create and activate a new conda enviroment called `openmc-env` (or whatever -you wish) with OpenMC installed. +Then create and activate a new conda enviroment called `openmc-env` in +which to install OpenMC. .. code-block:: sh - conda create --name openmc-env openmc + conda create -n openmc-env conda activate openmc-env -If you are installing on macOS with an Apple silicon ARM-based processor, you -will also need to specify the `--platform` option: +Then install `mamba`, which will be used to install OpenMC. .. code-block:: sh - conda create --name openmc-env --platform osx-64 openmc + conda install mamba -You are now in a conda environment called `openmc-env` that has OpenMC -installed. +To list the versions of OpenMC that are available on the `conda-forge` channel, +in your terminal window or an Anaconda Prompt run: + +.. code-block:: sh + + mamba search openmc + +OpenMC can then be installed with: + +.. code-block:: sh + + mamba install openmc + +You are now in a conda environment called `openmc-env` that has OpenMC installed. ------------------------------------------- Installing on Linux/Mac/Windows with Docker @@ -119,15 +133,16 @@ packages should be installed, for example in Homebrew via: .. code-block:: sh - brew install llvm cmake hdf5 python libomp libpng + brew install llvm cmake xtensor hdf5 python libomp libpng The compiler provided by the above LLVM package should be used in place of the one provisioned by XCode, which does not support the multithreading library used -by OpenMC. To ensure CMake picks up the correct compiler, make sure that either -the :envvar:`CXX` environment variable is set to the brew-installed ``clang++`` -or that the directory containing it is on your :envvar:`PATH` environment -variable. Common locations for the brew-installed compiler are -``/opt/homebrew/opt/llvm/bin`` and ``/usr/local/opt/llvm/bin``. +by OpenMC. Consequently, the C++ compiler should explicitly be set before +proceeding: + +.. code-block:: sh + + export CXX=/opt/homebrew/opt/llvm/bin/clang++ After the packages have been installed, follow the instructions to build from source below. diff --git a/docs/source/releasenotes/0.14.0.rst b/docs/source/releasenotes/0.14.0.rst index f82aa3085..445edfa07 100644 --- a/docs/source/releasenotes/0.14.0.rst +++ b/docs/source/releasenotes/0.14.0.rst @@ -52,7 +52,7 @@ Compatibility Notes and Deprecations New Features ------------ -- A new :class:`openmc.WireframeRayTracePlot` class enables the generation of orthographic or +- A new :class:`openmc.ProjectionPlot` class enables the generation of orthographic or perspective projection plots. (`#1926 `_) - The :class:`openmc.model.RightCircularCylinder` class now supports optional diff --git a/docs/source/releasenotes/0.15.1.rst b/docs/source/releasenotes/0.15.1.rst deleted file mode 100644 index d879b50ed..000000000 --- a/docs/source/releasenotes/0.15.1.rst +++ /dev/null @@ -1,224 +0,0 @@ -==================== -What's New in 0.15.1 -==================== - -.. currentmodule:: openmc - -------- -Summary -------- - -This release of OpenMC includes many bug fixes, performance improvements, and -several notable new features. The random ray solver continues to receive many -updates and improvements, which are listed below in more detail. A new -:class:`~openmc.SolidRayTracePlot` class has been added that enables attractive -3D visualization using Phong shading. Several composite surfaces have been -introduced (which help to further expand the capabilities of the -`openmc_mcnp_adapter `_). -The :meth:`openmc.Mesh.material_volumes` method has been completely -reimplemented with a new approach based on ray tracing that greatly improves -performance and can be executed in parallel. Tally results can be automatically -applied to input :class:`~openmc.Tally` objects with :meth:`openmc.Model.run`, -bypassing boilerplate code for collecting tally results from statepoint files. -Finally, a new :mod:`openmc.deplete.d1s` submodule has been added that enables -Direct 1-Step (D1S) calculations of shutdown dose rate for fusion applications. - ------------------------------------- -Compatibility Notes and Deprecations ------------------------------------- - -The ``openmc.ProjectionPlot`` class has been renamed to -:class:`openmc.WireframeRayTracePlot` to be in better alignment with the newly -introduced :class:`openmc.SolidRayTracePlot` class. - -NCrystal has been moved from a build-time dependency to a runtime dependency, -which means there is no longer a ``OPENMC_USE_NCRYSTAL`` CMake option. Instead, -OpenMC will look for an installed version of NCrystal using the -``ncrystal-config`` command. - ------------- -New Features ------------- - -- Numerous improvements have been made in the random ray solver: - - Calculation of Shannon entropy now works with random ray (`#3030 `_) - - Support for linear sources (`#3072 `_) - - Ability to slove for adjoint flux (`#3191 `_) - - Support randomized Quasi-Monte Carlo sampling (`#3268 `_) - - FW-CADIS weight window generation (`#3273 `_) - - Source region mesh subdivision(`#3333 `_) -- Several new composite surfaces have been added: - - :class:`openmc.model.OrthogonalBox` (`#3118 `_) - - :class:`openmc.model.ConicalFrustum` (`#3151 `_) - - :class:`openmc.model.Vessel` (`#3168 `_) -- The :meth:`openmc.Model.plot` method now supports plotting source sites - (`#2863 `_) -- The :func:`openmc.stats.delta_function` convenience function can be used for - specifying distributions with a single point (`#3090 - `_) -- Added a :meth:`openmc,Material.get_element_atom_densities` method (`#3103 - `_) -- Several third-party dependencies have been removed: - - Cython (`#3111 `_) - - gsl-lite (`#3225 `_) -- Added a new :class:`openmc.MuSurfaceFilter` class that filters tally events by - the cosine of angle of a surface crossing (`#2768 - `_) -- Introduced a :class:`openmc.ParticleList` class for manipulating a list of - source particles (`#3148 `_) -- Support dose coefficients from ICRP 74 in - :func:`openmc.data.dose_coefficients` (`#3020 - `_) -- Introduced a new :attr:`openmc.Settings.uniform_source_sampling` option - (`#3195 `_) -- Ability to differentiate materials in DAGMC universes (`#3056 - `_) -- Added methods to automatically apply results to existing Tally objects. - (`#2671 `_) -- Implemented a new :class:`openmc.SolidRayTracePlot` class that can produce a - 3D visualization based on Phong shading (`#2655 - `_) -- The :meth:`openmc.UnstructuredMesh.write_data_to_vtk` method now supports - writing a VTU file (`#3290 `_) -- Composite surfaces now have a - :attr:`~openmc.CompositeSurface.component_surfaces` attribute that provides - the underlying primitive surfaces (`#3167 - `_) -- A new :mod:`openmc.deplete.d1s` submodule has been added that enables Direct - 1-Step (D1S) calculations of shutdown dose rate for fusion applications - (`#3235 `_) - ---------------------------- -Bug Fixes and Small Changes ---------------------------- - -- run microxs with mpi (`#3028 `_) -- Rely on std::filesystem for file_utils (`#3042 `_) -- Random Ray Normalization Improvements (`#3051 `_) -- Alternative Random Ray Volume Estimators (`#3060 `_) -- Random Ray Testing Simplification (`#3061 `_) -- Fix hyperlinks in `random_ray.rst` (`#3064 `_) -- Add missing show_overlaps option to plots.xml input file documentation (`#3068 `_) -- Remove use of pkg_resources package (`#3069 `_) -- Add option for survival biasing source normalization (`#3070 `_) -- Enforce sequence type when setting ``Setting.track`` (`#3071 `_) -- Moving most of setup.py to pyproject.toml (`#3074 `_) -- Enforce non-negative percents for ``material.add_nuclide`` to prevent unintended ao/wo flipping (`#3075 `_) -- Include batch statistics discussion in methodology introduction (`#3076 `_) -- Add -DCMAKE_BUILD_TYPE=Release flag for MOAB in Dockerfile (`#3077 `_) -- Adjust decay data reader to better handle non-normalized branching ratios (`#3080 `_) -- Correct openmc.Geometry initializer to accept iterables of ``openmc.Cell`` (`#3081 `_) -- Replace all deprecated Python typing imports and syntax with updated forms (`#3085 `_) -- Fix ParticleFilter to work with set inputs (`#3092 `_) -- packages used for testing moved to tests section of pyprojects.toml (`#3094 `_) -- removed unused which function in CI scripts (`#3095 `_) -- Improve description of probabilities for ``openmc.stats.Tabular`` class (`#3099 `_) -- Ensure RegularMesh repr shows value for width of the mesh (`#3100 `_) -- Replacing endf c functions with package (`#3101 `_) -- Fix random ray solver to correctly simulate fixed source problems with fissionable materials (`#3106 `_) -- Improve error for nuclide temperature not found (`#3110 `_) -- Added error if cross sections path is a folder (`#3115 `_) -- Implement bounding_box operation for meshes (`#3119 `_) -- allowing varible offsets for ``polygon.offset`` (`#3120 `_) -- Write surface source files per batch (`#3124 `_) -- Mat ids reset (`#3125 `_) -- Tweaking title of feature issue template (`#3127 `_) -- Fix a typo in feature request template (`#3128 `_) -- Update quickinstall instructions for macOS (`#3130 `_) -- adapt the openmc-update-inputs script for surfaces (`#3131 `_) -- Theory documentation on PCG random number generator (`#3134 `_) -- Adding tmate action to CI for debugging (`#3138 `_) -- Add Versioning Support from `version.txt` (`#3140 `_) -- Correct failure due to progress bar values (`#3143 `_) -- Avoid writing subnormal nuclide densities to XML (`#3144 `_) -- Immediately resolve complement operators for regions (`#3145 `_) -- Improve Detection of libMesh Installation via `LIBMESH_ROOT` and CMake's PkgConfig (`#3149 `_) -- Fix for UWUW Macro Conflict (`#3150 `_) -- Consistency in treatment of paths for files specified within the Model class (`#3153 `_) -- Improve clipping of Mixture distributions (`#3154 `_) -- Fix check for trigger score name (`#3155 `_) -- Prepare point query data structures on meshes when applying Weight Windows (`#3157 `_) -- Add PointCloud spatial distribution (`#3161 `_) -- Update fmt submodule to version 11.0.2 (`#3162 `_) -- Move to support python 3.13 (`#3165 `_) -- avoid zero division if source rate of previous result is zero (`#3169 `_) -- Fix path handling for thermal ACE generation (`#3171 `_) -- Update `fmt` Formatters for Compatibility with Versions below 11 (`#3172 `_) -- added subfolders to txt search command in pyproject (`#3174 `_) -- added list to doc string arg for plot_xs (`#3178 `_) -- enable polymorphism for mix_materials (`#3180 `_) -- Fix plot_xs type hint (`#3184 `_) -- Enable adaptive mesh support on libMesh tallies (`#3185 `_) -- Reset values of lattice offset tables when allocated (`#3188 `_) -- Update surface_composite.py (`#3189 `_) -- add export_model_xml arguments to ``Model.plot_geometry`` and ``Model.calculate_volumes`` (`#3190 `_) -- Fixes in MicroXS.from_multigroup_flux (`#3192 `_) -- Fix documentation typo in ``boundary_type`` (`#3196 `_) -- Fix docstring for ``Model.plot`` (`#3198 `_) -- Apply weight windows at collisions in multigroup transport mode. (`#3199 `_) -- External sources alias sampler (`#3201 `_) -- Add test for flux bias with weight windows in multigroup mode (`#3202 `_) -- Fix bin index to DoF ID mapping bug in adaptive libMesh meshes (`#3206 `_) -- Ensure ``libMesh::ReplicatedMesh`` is used for LibMesh tallies (`#3208 `_) -- Set Model attributes only if needed (`#3209 `_) -- adding unstrucutred mesh file suffix to docstring (`#3211 `_) -- Write and read mesh name attribute (`#3221 `_) -- Adjust for secondary particle energy directly in heating scores (`#3227 `_) -- Correct normalization of thermal elastic in non standard ENDF-6 files (`#3234 `_) -- Adding '#define _USE_MATH_DEFINES' to make M_PI declared in Intel and MSVC compilers (`#3238 `_) -- updated link to log mapping technique (`#3241 `_) -- Fix for erroneously non-zero tally results of photon threshold reactions (`#3242 `_) -- Fix type comparison (`#3244 `_) -- Enable the LegendreFilter filter to be used in photon tallies for orders greater than P0. (`#3245 `_) -- Enable UWUW library when building with DAGMC in CI (`#3246 `_) -- Remove top-level import of ``openmc.lib`` (`#3250 `_) -- updated docker file to latest DAGMC (`#3251 `_) -- Write mesh type as a dataset always (`#3253 `_) -- Update to a consistent definition of the r2 parameter for cones (`#3254 `_) -- Add Patrick Shriwise to technical committee (`#3255 `_) -- Change `Zernike` documentation in polynomial.py (`#3258 `_) -- Bug fix for Polygon 'yz' basis (`#3259 `_) -- Add constant for invalid surface tokens. (`#3260 `_) -- Update plots.py for PathLike to string handling error (`#3261 `_) -- Fix bug in WeightWindowGenerator for empty energy bounds (`#3263 `_) -- Update recognized thermal scattering materials for ENDF/B-VIII.1 (`#3267 `_) -- simplify mechanism to detect if geometry entity is DAG (`#3269 `_) -- Fix bug in ``Surface.normalize`` (`#3270 `_) -- Tweak To Sphinx Install Documentation (`#3271 `_) -- add continue feature for depletion (`#3272 `_) -- Updates for building with NCrystal support (and fix CI) (`#3274 `_) -- Added missing documentation (`#3275 `_) -- fix the bug in function differentiate_mats() (`#3277 `_) -- Fix the bug in the ``Material.from_xml_element`` function (`#3278 `_) -- Doc typo fix for rand ray mgxs (`#3280 `_) -- Consolidate plotting capabilities in Model.plot (`#3282 `_) -- adding non elastic MT number (`#3285 `_) -- Fix ``Tabular.from_xml_element`` for histogram case (`#3287 `_) -- Random Ray Source Region Refactor (`#3288 `_) -- added terminal output showing compile options selected (`#3291 `_) -- Random ray consistency changes (`#3298 `_) -- Random Ray Explicit Void Treatment (`#3299 `_) -- removed old command line scripts (`#3300 `_) -- Avoid end of life ubuntu 20.04 in ReadTheDocs runner (`#3301 `_) -- Avoid error in CI from newlines in commit message (`#3302 `_) -- Handle reflex angles in CylinderSector (`#3303 `_) -- Relax requirement on polar/azimuthal axis for wwinp conversion (`#3307 `_) -- Add nuclides_to_ignore argument on Model export methods (`#3309 `_) -- Enable overlap plotting from Python API (`#3310 `_) -- Fix access order issues after applying tally results from `Model.run` (`#3313 `_) -- Random Ray Void Accuracy Fix (`#3316 `_) -- Fixes for problems encountered with version determination (`#3320 `_) -- Clarify effect of CMAKE_BUILD_TYPE in docs (`#3321 `_) -- Random Ray Linear Source Stability Improvement (`#3322 `_) -- Mark a canonical URL for docs (`#3324 `_) -- Random Ray Adjoint Source Logic Improvement (`#3325 `_) -- Reflect multigroup MicroXS in IndependentOperator docstrings (`#3327 `_) -- NCrystal becomes runtime rather than buildtime dependency (`#3328 `_) -- Adding per kg as unit option on material functions (`#3329 `_) -- Fix reading of horizontal field of view for ray-traced plots (`#3330 `_) -- Manually fix broken links (`#3331 `_) -- Update pugixml to v1.15 (`#3332 `_) -- Determine nuclides correctly for DAGMC models in d1s.get_radionuclides (`#3335 `_) -- openmc.Material.mix_materials() allows for keyword arguments (`#3336 `_) -- Fix bug in ``Mesh::material_volumes`` for void materials (`#3337 `_) -- added stable and unstable nuclides to the Chain object (`#3338 `_) diff --git a/docs/source/releasenotes/0.15.2.rst b/docs/source/releasenotes/0.15.2.rst deleted file mode 100644 index e72df37d3..000000000 --- a/docs/source/releasenotes/0.15.2.rst +++ /dev/null @@ -1,20 +0,0 @@ -==================== -What's New in 0.15.2 -==================== - -.. currentmodule:: openmc - -------- -Summary -------- - -This is a hotfix release to fix an MPI-related bug that was inadvertently -introduced in the prior release. - ---------------------------- -Bug Fixes and Small Changes ---------------------------- - -- Remove errant ``openmc.Settings.random_ray`` check and removed of not useful warning in MG mode (`#3344 `_) -- Throw an error if a spherical harmonics order larger than 10 is provided. (`#3354 `_) -- Correcting the size of the displacement list in the SourceSite MPI interface object (`#3356 `_) diff --git a/docs/source/releasenotes/0.15.3.rst b/docs/source/releasenotes/0.15.3.rst deleted file mode 100644 index c50958104..000000000 --- a/docs/source/releasenotes/0.15.3.rst +++ /dev/null @@ -1,226 +0,0 @@ -==================== -What's New in 0.15.3 -==================== - -.. currentmodule:: openmc - -------- -Summary -------- - -This release of OpenMC includes many bug fixes, performance improvements, and -several notable new features. The major highlights of this release include a new -:class:`~openmc.deplete.R2SManager` class that automates the workflow for -rigorous 2-step (R2S) shutdown dose rate calculations, the ability to collect -higher moments for tally results that can be used to test normality, a new -uncertainty-aware criticality search method, a new collision tracking feature -that enables detailed tracking of particle interactions, support for distributed -cell densities, and several new tally filters. The random ray solver also -continues to receive significant updates, including automatic setup -capabilities, improved geometry handling, and better weight window support. -Depletion capabilities have been expanded with thermochemical redox control, -external transfer rates, and improved performance. - ------------------------------------- -Compatibility Notes and Deprecations ------------------------------------- - -MCPL has been changed from a build-time dependency to a runtime optional -dependency, which means OpenMC will attempt to load the MCPL library at -runtime when needed rather than requiring it at build time. - -The ``openmc.mgxs.Library.add_to_tallies_file`` method has been renamed to -:meth:`openmc.mgxs.Library.add_to_tallies`. - ------------- -New Features ------------- - -- A new collision tracking feature enables detailed tracking of particle - interactions (`#3417 `_) -- Added :meth:`~openmc.model.Model.keff_search` method for automated criticality - searches (`#3569 `_) -- Introduced automated workflow for mesh- or cell-based R2S calculations - (`#3508 `_) -- Ability to source electron/positrons directly for charged particle - simulations (`#3404 `_) -- Multi-group capability for kinetics parameter calculations with Iterated - Fission Probability (`#3425 - `_) -- Introduced a new :class:`openmc.MeshMaterialFilter` class (`#3406 - `_) -- Added support for distributed cell densities (`#3546 - `_) -- Implemented a :class:`openmc.WeightWindowsList` class that enables export to - HDF5 (`#3456 `_) -- Added :meth:`openmc.Material.mean_free_path` method (`#3469 - `_) -- Introduced :func:`openmc.lib.TemporarySession` context manager (`#3475 - `_) -- Added material depletion function for tracking individual material depletion - (`#3420 `_) -- Added methods on :class:`~openmc.Material` class for waste disposal rating / - classification (`#3366 `_, - `#3376 `_) -- Support for thermochemical redox control transfer rates in depletion - (`#2783 `_) -- Support for external transfer rates source term in depletion (`#3088 - `_) -- Added combing capability for fission site sampling and delayed neutron - emission time (`#2992 `_) -- Ability to specify reference direction for azimuthal angle in - :class:`~openmc.stats.PolarAzimuthal` distribution (`#3582 - `_) -- Allow spatial constraints on element sources within - :class:`~openmc.MeshSource` (`#3431 - `_) -- Added VTK HDF (.vtkhdf) format support for writing VTK data (`#3252 - `_) -- Implemented filter weight capability (`#3345 - `_) -- Optionally collect higher moments for tallies (`#3363 - `_) -- Several random ray solver enhancements: - - - Random Ray AutoMagic Setup for automatic configuration (`#3351 `_) - - Point source locator for random ray mode (`#3360 `_) - - Support for DAGMC geometries (`#3374 `_) - - Optimized mapping of source regions to tallies (`#3465 `_) - - Base source region refactor (`#3576 `_) - ---------------------------- -Bug Fixes and Small Changes ---------------------------- - -- Add two MPI barriers in R2S workflow (`#3646 `_) -- Fix a few warnings, rename add_to_tallies_file (`#3639 `_) -- Fix typo in DAGMC lost particle test (`#3634 `_) -- Avoid multiprocessing Pool when running depletion tests with MPI (`#3633 `_) -- Support MPI parallelism in R2SManager (`#3632 `_) -- Update documentation for particle tracks (`#3627 `_) -- Adding variance of variance and normality tests for tally statistics (`#3454 `_) -- Avoid divide-by-zero in ``from_multigroup_flux`` when flux is zero (`#3624 `_) -- Write particle states as separate lines in track VTK files (`#3628 `_) -- Reset DAGMC history when reviving from source (`#3601 `_) -- Add energy group structure: SCALE-999 (`#3564 `_) -- Fix bug in normalization of tally results with no_reduce (`#3619 `_) -- Enable nuclide filters with get_decay_photon_energy (`#3614 `_) -- Update ``check_type`` calls to accept both ``str`` and ``os.PathLike`` objects (`#3618 `_) -- Speed up ``apply_time_correction`` by reducing file I/O and deepcopies (`#3617 `_) -- FW-CADIS Disregard Max Realizations Setting (`#3616 `_) -- Random Ray Geometry Debug Mode Fix (`#3615 `_) -- Don't write reaction rates in depletion results by default (`#3609 `_) -- Allow Path objects in MGXSLibrary.export_to_hdf5 (`#3608 `_) -- Clip mixture distributions based on mean times integral (`#3603 `_) -- Allow V0 in atomic_mass function (for ENDF/B-VII.0 data) (`#3607 `_) -- Re-run flaky tests when needed (`#3604 `_) -- Ability to load mesh objects from weight_windows.h5 file (`#3598 `_) -- Switch to using coveralls github action for reporting (`#3594 `_) -- Add user setting for free gas threshold (`#3593 `_) -- Speed up time correction factors (`#3592 `_) -- Fix caching issue when using NCrystal materials (`#3538 `_) -- Fix random ray source region mesh export when using model.export_to_xml() (`#3579 `_) -- Ensure weight_windows_file information is read from XML (`#3587 `_) -- Add missing documentation on in depletion chain file format (`#3590 `_) -- Adding tally filter type option to statepoint get_tally (`#3584 `_) -- Optional separation of mesh-material-volume calc from get_homogenized_materials (`#3581 `_) -- Fix IFP implementation (`#3580 `_) -- Remove several TODOs related to C++17 support (`#3574 `_) -- Fix performance regression in libMesh unstructured mesh tallies (`#3577 `_) -- Update find_package calls in OpenMCConfig.cmake (`#3572 `_) -- Ensure ``n_dimension_`` attribute is set for unstructured meshes (`#3575 `_) -- Allow newer Sphinx version and fix docbuild warnings (`#3571 `_) -- Fixed a bug when combining TimeFilter, MeshFilter, and tracklength estimator (`#3525 `_) -- PowerLaw raises an error if sampling interval contains negative values (`#3542 `_) -- depletion: fix performance of chain matrix construction (`#3567 `_) -- Do not apply boundary conditions when initialized in volume calculation mode (`#3562 `_) -- Bump up tolerance for flaky activation test (`#3560 `_) -- Fixed a bug in plotting cross sections with S(a,b) data (`#3558 `_) -- Change test order to run unit tests first (`#3533 `_) -- adding ecco 33 (`#3556 `_) -- Refactor endf_data to be a fixture (`#3539 `_) -- Revert "fix broken CI" (`#3554 `_) -- fix broken CI (`#3551 `_) -- Leverage particle.move_distance in event advance (`#3544 `_) -- fix tests that accidentaly got broken (`#3543 `_) -- not printing nuclides with 0 percent to terminal (option 2 ) (`#3448 `_) -- Fix a bug in time cutoff behavior (`#3526 `_) -- Avoid duplicate materials written to XML (`#3536 `_) -- Use cached property for openmc.data.Decay.sources (`#3535 `_) -- more helpful error message for dose_coefficients (`#3534 `_) -- Adding 616 group structure (`#3531 `_) -- Remove unused special accessors for tallies (`#3527 `_) -- Consistent XML parsing using functions from _xml module (`#3517 `_) -- Add stat:sum field to MCPL files for proper weight normalization (`#3522 `_) -- Remove reorder_attributes from openmc._xml (`#3519 `_) -- fixed a bug in MeshMaterialFilter.from_volumes (`#3520 `_) -- Fixed a bug in distribcell offsets logic (`#3424 `_) -- Add test for FW-CADIS based WW generation on a DAGMC model (`#3504 `_) -- Fix for Weight Window Scaling Bug (`#3511 `_) -- Fix: ``materials``, ``plots``, and ``tallies`` cannot be passed as lists (`#3513 `_) -- Allow already-initialized openmc.lib in TemporarySession (`#3505 `_) -- Update DAGMC and libMesh precompiler definitions (`#3510 `_) -- Avoid adding ParentNuclideFilter twice when calling prepare_tallies (`#3506 `_) -- Enabling MCPL source files to be read when using surf_source_read (`#3472 `_) -- Boundary info accessors (`#3496 `_) -- automatically finding appropriate dimension when making regular mesh from domain (`#3468 `_) -- Add accessor methods for LocalCoord (`#3494 `_) -- Make MCPL a Runtime Optional Dependency (`#3429 `_) -- Use auto-chunking for StepResult HDF5 writing (`#3498 `_) -- Provide a way to get ID maps from plot parameters on the Model class (`#3481 `_) -- Update OSX install instructions to point to x64 platform (`#3501 `_) -- Update conda install instructions for macOS Apple silicon (`#3488 `_) -- Only show warning if in restart mode (`#3478 `_) -- Add flag to CMakeLists to use submodules instead of searching (`#3480 `_) -- Added citation metadata file (`#3409 `_) -- fix zam parsing (`#3484 `_) -- Support flux collapse method in ``get_microxs_and_flux`` (`#3466 `_) -- Stabilize Adjoint Source (`#3476 `_) -- Refactor and Harden Configuration Management (`#3461 `_) -- Updated Docs to Not Give Specific Python Version Requirement (`#3473 `_) -- Parallelization of Weight Window Update (`#3467 `_) -- Limit Random Ray Weight Window Generation to Final Batch (`#3464 `_) -- Fix Dockerfile DAGMC build (`#3463 `_) -- Fix Weight Window Infinite Loop Bug (`#3457 `_) -- Weight Window Birth Scaling (`#3459 `_) -- Adding checks to geometry.plot to avoid material name overlaps (`#3458 `_) -- Fixing crash when calling Geometry.plot when DAGMCUniverse in geometry (`#3455 `_) -- fixing expansion of elemental Ta bug (`#3443 `_) -- Prevent Adjoint Sources from Trending towards Infinity (`#3449 `_) -- adding plot function to DAGMCUnvierse (`#3451 `_) -- Allow specifying number of equiprobable angles for thermal scattering data generation (`#3346 `_) -- Change Dockerfile from debian:bookworm-slim to ubuntu:24.04 (`#3442 `_) -- Fix Resetting of Auto IDs When Generating MGXS (`#3437 `_) -- Allowing chain_file to be chain object to save reloading time (`#3436 `_) -- update units for flux (`#3441 `_) -- Fix raytrace infinite loop (`#3423 `_) -- Apply Max Number of Events Check to Random Rays (`#3438 `_) -- Add user setting for source rejection fraction (`#3433 `_) -- Adding fix and tests for spherical mesh as spatial distribution (`#3428 `_) -- Random Ray Missed Cell Policy Change for Adjoint Mode (`#3434 `_) -- Random Ray External Source Plotting Fix (`#3430 `_) -- Avoid negative heating values during pair production and bremsstrahlung (`#3426 `_) -- Fix no serialization of periodic_surface_id bug (`#3421 `_) -- Update _get_start_data to always grab the beginning of timestep time (`#3414 `_) -- Fixed a bug in charged particle energy deposition (`#3416 `_) -- Fix bug where the same mesh is written multiple times to settings.xml (`#3418 `_) -- small typo - spelling of Debian (`#3411 `_) -- added test for dagmc geometry plot (`#3375 `_) -- Random Ray Misc Memory Error Fixes (`#3405 `_) -- added type hints to model file (`#3399 `_) -- Apply resolve paths to path values in ``config`` (`#3400 `_) -- Fixing an incorrect computation of CDF of bremsstrahlung photons (`#3396 `_) -- Fix weight modification for uniform source sampling (`#3395 `_) -- Updates to VTK data checks (`#3371 `_) -- Map Compton subshell data to atomic relaxation data (`#3392 `_) -- Skip atomic relaxation if binding energy is larger than photon energy (`#3391 `_) -- Fix extremely large yields from Bremsstrahlung (`#3386 `_) -- corrected tally name in D1S example (`#3383 `_) -- Install MCPL using same build type as OpenMC in CI (`#3388 `_) -- using reduce chain level to remove need for reduce chain (`#3377 `_) -- Fix negative distances from bins_crossed for CylindricalMesh (`#3370 `_) -- Add check for equal value bins in an EnergyFilter (`#3372 `_) -- Fix for Issue Loading MGXS Data Files with LLVM 20 or Newer (`#3368 `_) -- Report plot ID instead of index for unsupported plot types in random ray mode (`#3361 `_) -- Handle Missing Tags in Versioning by Setting Default to 0 (`#3359 `_) -- added kg units to doc string in results class (`#3358 `_) diff --git a/docs/source/releasenotes/index.rst b/docs/source/releasenotes/index.rst index 1292599ba..bde120589 100644 --- a/docs/source/releasenotes/index.rst +++ b/docs/source/releasenotes/index.rst @@ -7,9 +7,6 @@ Release Notes .. toctree:: :maxdepth: 1 - 0.15.3 - 0.15.2 - 0.15.1 0.15.0 0.14.0 0.13.3 diff --git a/docs/source/usersguide/basics.rst b/docs/source/usersguide/basics.rst index c0bc2f976..60b599588 100644 --- a/docs/source/usersguide/basics.rst +++ b/docs/source/usersguide/basics.rst @@ -53,7 +53,7 @@ eXtensible Markup Language (XML) Unlike many other Monte Carlo codes which use an arbitrary-format ASCII file with "cards" to specify a particular geometry, materials, and associated run settings, the input files for OpenMC are structured in a set of `XML -`_ files. XML, which stands for eXtensible Markup +`_ files. XML, which stands for eXtensible Markup Language, is a simple format that allows data to be exchanged efficiently between different programs and interfaces. diff --git a/docs/source/usersguide/beginners.rst b/docs/source/usersguide/beginners.rst index 6876a3324..eef927b84 100644 --- a/docs/source/usersguide/beginners.rst +++ b/docs/source/usersguide/beginners.rst @@ -109,8 +109,8 @@ familiar with. Whether you plan on working in Linux, macOS, or Windows, you should be comfortable working in a command line environment. There are many resources online for learning command line environments. If you are using Linux or Mac OS X (also Unix-derived), `this tutorial -`_ will help you get acquainted -with commonly-used commands. +`_ will help you get acquainted with +commonly-used commands. To reap the full benefits of OpenMC, you should also have basic proficiency in the use of `Python `_, as OpenMC includes a rich Python @@ -127,8 +127,8 @@ are hosted at `GitHub`_. In order to receive updates to the code directly, submit `bug reports`_, and perform other development tasks, you may want to sign up for a free account on GitHub. Once you have an account, you can follow `these instructions -`_ -on how to set up your computer for using GitHub. +`_ on +how to set up your computer for using GitHub. If you are new to nuclear engineering, you may want to review the NRC's `Reactor Concepts Manual`_. This manual describes the basics of nuclear power for @@ -149,9 +149,9 @@ and `Volume II`_. You may also find it helpful to review the following terms: .. _neutron transport: https://en.wikipedia.org/wiki/Neutron_transport .. _discretization: https://en.wikipedia.org/wiki/Discretization .. _constructive solid geometry: https://en.wikipedia.org/wiki/Constructive_solid_geometry -.. _git: https://git-scm.com/ +.. _git: http://git-scm.com/ .. _git tutorials: https://git-scm.com/doc -.. _Reactor Concepts Manual: https://www.tayloredge.com/periodic/trivia/ReactorConcepts.pdf +.. _Reactor Concepts Manual: http://www.tayloredge.com/periodic/trivia/ReactorConcepts.pdf .. _Volume I: https://www.standards.doe.gov/standards-documents/1000/1019-bhdbk-1993-v1 .. _Volume II: https://www.standards.doe.gov/standards-documents/1000/1019-bhdbk-1993-v2 .. _OpenMC source code: https://github.com/openmc-dev/openmc diff --git a/docs/source/usersguide/data.rst b/docs/source/usersguide/data.rst index 8b2938556..6af297338 100644 --- a/docs/source/usersguide/data.rst +++ b/docs/source/usersguide/data.rst @@ -12,9 +12,9 @@ responsible for specifying one or more of the following: file (commonly named ``cross_sections.xml``) contains a listing of other data files, in particular neutron cross sections, photon cross sections, and windowed multipole data. Each of those files, in turn, uses a `HDF5 - `_ format (see - :ref:`io_nuclear_data`). In order to run transport simulations with - continuous-energy cross sections, you need to specify this file. + `_ format (see :ref:`io_nuclear_data`). In + order to run transport simulations with continuous-energy cross sections, you + need to specify this file. - **Depletion chain (XML)** -- A :ref:`depletion chain XML ` file contains decay data, fission product yields, and information on what @@ -30,8 +30,7 @@ responsible for specifying one or more of the following: Each of the above files can specified in several ways. In the Python API, a :ref:`runtime configuration variable ` :data:`openmc.config` can be used to specify any of the above and is initialized -using a set of environment variables. Data configuration paths set in -:data:`openmc.config` will be expanded to absolute paths. +using a set of environment variables. .. _usersguide_data_runtime: @@ -70,7 +69,7 @@ If you want to persistently set the environment variables used to initialized the configuration, export them from your shell profile (``.profile`` or ``.bashrc`` in bash_). -.. _bash: https://www.linuxfromscratch.org/blfs/view/6.3/postlfs/profile.html +.. _bash: http://www.linuxfromscratch.org/blfs/view/6.3/postlfs/profile.html -------------------------------- Continuous-Energy Cross Sections @@ -291,16 +290,16 @@ calculation to be performed. Therefore, at this point in time, OpenMC is not distributed with any pre-existing multigroup cross section libraries. However, if a multigroup library file is downloaded or generated, the path to the file needs to be specified as described in :ref:`usersguide_data_runtime`. For an -example of how to create a multigroup library, see this `MG mode notebook -`_. +example of how to create a multigroup library, see the `example notebook +<../examples/mg-mode-part-i.ipynb>`__. -.. _NJOY: https://www.njoy21.io/ +.. _NJOY: http://www.njoy21.io/ .. _NNDC: https://www.nndc.bnl.gov/endf .. _MCNP: https://mcnp.lanl.gov -.. _Serpent: https://serpent.vtt.fi +.. _Serpent: http://montecarlo.vtt.fi .. _ENDF/B: https://www.nndc.bnl.gov/endf-b7.1/acefiles.html .. _JEFF: https://www.oecd-nea.org/dbdata/jeff/jeff33/ -.. _TENDL: https://tendl.web.psi.ch/tendl_2023/tendl2023.html +.. _TENDL: https://tendl.web.psi.ch/tendl_2017/tendl2017.html .. _Seltzer and Berger: https://doi.org/10.1016/0092-640X(86)90014-8 .. _NIST ESTAR database: https://physics.nist.gov/PhysRefData/Star/Text/ESTAR.html .. _Biggs et al.: https://doi.org/10.1016/0092-640X(75)90030-3 diff --git a/docs/source/usersguide/decay_sources.rst b/docs/source/usersguide/decay_sources.rst deleted file mode 100644 index 19f1e5d5f..000000000 --- a/docs/source/usersguide/decay_sources.rst +++ /dev/null @@ -1,272 +0,0 @@ -.. usersguide_decay_sources: - -============= -Decay Sources -============= - -Through the :ref:`depletion ` capabilities in OpenMC, it -is possible to simulate radiation emitted from the decay of activated materials. -For fusion energy systems, this is commonly done using either the `rigorous -2-step `_ (R2S) method or the -`direct 1-step `_ (D1S) method. -In the R2S method, a neutron transport calculation is used to determine the -neutron flux and reaction rates over a cell- or mesh-based spatial -discretization of the model. Then, the neutron flux in each discrete region is -used to predict the activated material composition using a depletion solver. -Finally, a photon transport calculation with a source based on the activity and -energy spectrum of the activated materials is used to determine a desired -physical response (e.g., a dose rate) at one or more locations of interest. -OpenMC includes automation for both the R2S and D1S methods as described in the -following sections. - -Rigorous 2-Step (R2S) Calculations -================================== - -OpenMC includes an :class:`openmc.deplete.R2SManager` class that fully automates -cell- and mesh-based R2S calculations. Before we describe this class, it is -useful to understand the basic mechanics of how an R2S calculation works. -Generally, it involves the following steps: - -1. The :meth:`openmc.deplete.get_microxs_and_flux` function is called to run a - neutron transport calculation that determines fluxes and microscopic cross - sections in each activation region. -2. The :class:`openmc.deplete.IndependentOperator` and - :class:`openmc.deplete.PredictorIntegrator` classes are used to carry out a - depletion (activation) calculation in order to determine predicted material - compositions based on a set of timesteps and source rates. -3. The activated material composition is determined using the - :class:`openmc.deplete.Results` class. Indexing an instance of this class - with the timestep index returns a :class:`~openmc.deplete.StepResult` object, - which itself has a :meth:`~openmc.deplete.StepResult.get_material` method - returning an activated material. -4. The :meth:`openmc.Material.get_decay_photon_energy` method is used to obtain - the energy spectrum of the decay photon source. The integral of the spectrum - also indicates the intensity of the source in units of [Bq]. -5. A new photon source is defined using one of OpenMC's source classes with the - energy distribution set equal to the object returned by the - :meth:`openmc.Material.get_decay_photon_energy` method. The source is then - assigned to a photon :class:`~openmc.Model`. -6. A photon transport calculation is run with ``model.run()``. - -Altogether, the workflow looks as follows:: - - # Run neutron transport calculation - fluxes, micros = openmc.deplete.get_microxs_and_flux(model, domains) - - # Run activation calculation - op = openmc.deplete.IndependentOperator(mats, fluxes, micros) - timesteps = ... - source_rates = ... - integrator = openmc.deplete.Integrator(op, timesteps, source_rates) - integrator.integrate() - - # Get decay photon source at last timestep - results = openmc.deplete.Results("depletion_results.h5") - step = results[-1] - activated_mat = step.get_material('1') - photon_energy = activated_mat.get_decay_photon_energy() - photon_source = openmc.IndependentSource( - space=..., - energy=photon_energy, - particle='photon', - strength=photon_energy.integral() - ) - - # Run photon transport calculation - model.settings.source = photon_source - model.run() - -Note that by default, the :meth:`~openmc.Material.get_decay_photon_energy` -method will eliminate spectral lines with very low intensity, but this behavior -can be configured with the ``clip_tolerance`` argument. - -Cell-based R2S --------------- - -In practice, users do not need to manually go through each of the steps in an R2S -calculation described above. The :class:`~openmc.deplete.R2SManager` fully -automates the execution of neutron transport, depletion, decay source -generation, and photon transport. For a cell-based R2S calculation, once you -have a :class:`~openmc.Model` that has been defined, simply create an instance -of :class:`~openmc.deplete.R2SManager` by passing the model and a list of cells -to activate:: - - r2s = openmc.deplete.R2SManager(model, [cell1, cell2, cell3]) - -Note that the ``volume`` attribute must be set for any cell that is to be -activated. The :class:`~openmc.deplete.R2SManager` class allows you to -optionally specify a separate photon model; if not given as an argument, it will -create a shallow copy of the original neutron model (available as the -``neutron_model`` attribute) and store it in the ``photon_model`` attribute. We -can use this to define tallies specific to the photon model:: - - dose_tally = openmc.Tally() - ... - r2s.photon_model.tallies = [dose_tally] - -Next, define the timesteps and source rates for the activation calculation:: - - timesteps = [(3.0, 'd'), (5.0, 'h')] - source_rates = [1e12, 0.0] - -In this case, the model is irradiated for 3 days with a source rate of -:math:`10^{12}` neutron/sec and then the source is turned off and the activated -materials are allowed to decay for 5 hours. These parameters should be passed to -the :meth:`~openmc.deplete.R2SManager.run` method to execute the full R2S -calculation. Before we can do that though, for a cell-based calculation, the one -other piece of information that is needed is bounding boxes of the activated -cells:: - - bounding_boxes = { - cell1.id: cell1.bounding_box, - cell2.id: cell2.bounding_box, - cell3.id: cell3.bounding_box - } - -Note that calling the ``bounding_box`` attribute may not work for all -constructive solid geometry regions (for example, a cell that uses a -non-axis-aligned plane). In these cases, the bounding box will need to be -specified manually. Once you have a set of bounding boxes, the R2S calculation -can be run:: - - r2s.run(timesteps, source_rates, bounding_boxes=bounding_boxes) - -If not specified otherwise, a photon transport calculation is run at each time -in the depletion schedule for which a decay photon source exists. Times without -a decay photon source, such as the initial state of a model containing only -stable nuclides, are omitted. To specify particular times at which photon -transport calculations should be run, pass the ``photon_time_indices`` argument. -For example, if we wanted to run a photon transport calculation only on the last -time (after the 5 hour decay), we would run:: - - r2s.run(timesteps, source_rates, bounding_boxes=bounding_boxes, - photon_time_indices=[2]) - -To attribute photon tally results to their parent radionuclides, set -``by_parent_nuclide=True``. This automatically adds a -:class:`openmc.ParentNuclideFilter` to every photon tally that does not already -have one. The filter bins are the union of radionuclides contributing to the -prepared decay photon sources. The resulting bins can be used directly when -inspecting the tally results:: - - r2s.run(timesteps, source_rates, bounding_boxes=bounding_boxes, - photon_time_indices=[2], by_parent_nuclide=True) - - photon_tally = r2s.results['photon_tallies'][2][0] - tally_by_parent = photon_tally.get_pandas_dataframe() - -After an R2S calculation has been run, the :class:`~openmc.deplete.R2SManager` -instance will have a ``results`` dictionary that allows you to directly access -results from each of the steps. It will also write out all the output files into -a directory that is named "r2s_/". The ``output_dir`` argument to the -:meth:`~openmc.deplete.R2SManager.run` method enables you to override the -default output directory name if desired. - -The :meth:`~openmc.deplete.R2SManager.run` method actually runs four -lower-level methods under the hood:: - - r2s.step1_neutron_transport(...) - r2s.step2_activation(...) - r2s.step3_photon_source(...) - r2s.step4_photon_transport(...) - -For users looking for more control over the calculation, these lower-level -methods can be used in lieu of the :meth:`openmc.deplete.R2SManager.run` method. - -Mesh-based R2S --------------- - -Executing a mesh-based R2S calculation looks nearly identical to the cell-based -R2S workflow described above. The only difference is that instead of passing a -list of cells to the ``domains`` argument of -:class:`~openmc.deplete.R2SManager`, you need to define a mesh object and pass -that instead. This might look like the following:: - - # Define a regular Cartesian mesh - mesh = openmc.RegularMesh() - mesh.lower_left = (-50., -50., 0.) - mesh.upper_right = (50., 50., 75.) - mesh.dimension = (10, 10, 5) - - r2s = openmc.deplete.R2SManager(model, mesh) - -Executing the R2S calculation is then performed by adding photon tallies and -calling the :meth:`~openmc.deplete.R2SManager.run` method with the appropriate -timesteps and source rates. Note that in this case we do not need to define cell -volumes or bounding boxes as is required for a cell-based R2S calculation. -Instead, during the neutron transport step, OpenMC will run a raytracing -calculation to determine material volume fractions within each mesh element -using the :meth:`openmc.MeshBase.material_volumes` method. Arguments to this -method can be customized via the ``mat_vol_kwargs`` argument to the -:meth:`~openmc.deplete.R2SManager.run` method. Most often, this would involve -customizing the number of rays traced to obtain better estimates of volumes. As -an example, if we wanted to run the raytracing calculation with 10 million rays, -we would run:: - - r2s.run(timesteps, source_rates, mat_vol_kwargs={'n_samples': 10_000_000}) - -It is also possible to use multiple meshes by passing a list of meshes instead -of a single mesh. This can be useful, for example, when different regions of the -model require different mesh resolutions. The meshes are assumed to be -**non-overlapping**; each element--material combination across all meshes is -treated as an independent activation region, and all meshes are handled in a -single neutron transport solve. For example:: - - # Fine mesh near the activation target - mesh_fine = openmc.RegularMesh() - mesh_fine.dimension = (10, 10, 10) - ... - - # Coarse mesh for the surrounding region - mesh_coarse = openmc.RegularMesh() - mesh_coarse.dimension = (5, 5, 5) - ... - - r2s = openmc.deplete.R2SManager(model, [mesh_fine, mesh_coarse]) - -Direct 1-Step (D1S) Calculations -================================ - -OpenMC also includes built-in capability for performing shutdown dose rate -calculations using the `direct 1-step -`_ (D1S) method. In this method, -a single coupled neutron--photon transport calculation is used where the prompt -photon production is replaced with photons produced from the decay of -radionuclides in an activated material. To obtain properly scaled results, it is -also necessary to apply time correction factors. A normal neutron transport -calculation can be extended to a D1S calculation with a few helper functions. -First, import the ``d1s`` submodule, which is part of :mod:`openmc.deplete`:: - - from openmc.deplete import d1s - -First, you need to instruct OpenMC to use decay photon data instead of prompt -photon data. This is done with an attribute on the :class:`~openmc.Settings` -class:: - - model = openmc.Model() - ... - model.settings.use_decay_photons = True - -To prepare any tallies for use of the D1S method, you should call the -:func:`~openmc.deplete.d1s.prepare_tallies` function, which adds a -:class:`openmc.ParentNuclideFilter` (used later for assigning time correction -factors) to any applicable tally and returns a list of possible radionuclides -based on the :ref:`chain file `. Once the tallies are prepared, -the model can be simulated:: - - output_path = model.run() - -Finally, the time correction factors need to be computed and applied to the -relevant tallies. This can be done with the aid of the -:func:`~openmc.deplete.d1s.time_correction_factors` and -:func:`~openmc.deplete.d1s.apply_time_correction` functions:: - - # Compute time correction factors based on irradiation schedule - factors = d1s.time_correction_factors(nuclides, timesteps, source_rates) - - # Get tally from statepoint - with openmc.StatePoint(output_path) as sp: - dose_tally = sp.get_tally(name='dose tally') - - # Apply time correction factors - tally = d1s.apply_time_correction(dose_tally, factors, time_index) diff --git a/docs/source/usersguide/depletion.rst b/docs/source/usersguide/depletion.rst index 9a22adf01..261900ce6 100644 --- a/docs/source/usersguide/depletion.rst +++ b/docs/source/usersguide/depletion.rst @@ -449,42 +449,3 @@ to transfer xenon from one material to another, you'd use:: ... integrator.add_transfer_rate(mat1, ['Xe'], 0.1, destination_material=mat2) - -Comparing to Other Codes -======================== - -Comparing depletion results from OpenMC with those from another code, such as -MCNP or Serpent, requires more than constructing equivalent transport models. -At each depletion step, differences in the transport solution, nuclear data, -reaction rate normalization, and numerical integration can all affect the -result. Small differences can also accumulate over successive depletion steps. - -For a meaningful comparison, align as many of the following inputs and methods -as possible: - -- Geometry and material definitions and associated physical properties such as - temperature -- Neutron cross section library (e.g., ENDF/B-VIII.0) -- Treatment of thermal scattering and unresolved resonance probability tables -- Neutron reactions accounted for in the depletion chain -- Decay data in the depletion chain -- Isomeric branching ratios for reactions in the depletion chain -- Fission product yields in the depletion chain -- Fission product yield interpolation method - (``CoupledOperator(fission_yield_mode=...)``) -- Reaction rate normalization, including fission Q values - (``CoupledOperator(fission_q=...)``) -- Depletion integration method (``PredictorIntegrator``, ``CECMIntegrator``, - etc.) and time-step sizes - -When comparing to codes that use ACE format cross sections, it is recommended to -directly convert the ACE files to HDF5 format using functionality from the -:mod:`openmc.data` module (see :ref:`create_xs_library`). Some of the -LANL-distributed ACE libraries used with MCNP have also been converted to HDF5 -format and are available for download at https://openmc.org/data. - -Even after these choices have been aligned, exact agreement should not be -expected. Codes may use different approximations or numerical methods that -cannot be configured identically. When investigating a discrepancy, first -compare transport results and one-group reaction rates at the initial time, then -compare changes over subsequent timesteps. diff --git a/docs/source/usersguide/geometry.rst b/docs/source/usersguide/geometry.rst index 8f83b9b08..3a3d02231 100644 --- a/docs/source/usersguide/geometry.rst +++ b/docs/source/usersguide/geometry.rst @@ -182,8 +182,6 @@ boundary condition. Periodic boundary conditions can be applied to pairs of planar surfaces. If there are only two periodic surfaces they will be matched automatically. - - Otherwise it is necessary to specify pairs explicitly using the :attr:`Surface.periodic_surface` attribute as in the following example:: @@ -194,7 +192,7 @@ Otherwise it is necessary to specify pairs explicitly using the Both rotational and translational periodic boundary conditions are specified in the same fashion. If both planes have the same normal vector, a translational periodicity is assumed; rotational periodicity is assumed otherwise. Currently, -rotations must be about the :math:`x`-, :math:`y`-, or :math:`z`-axis. +only rotations about the :math:`z`-axis are supported. For a rotational periodic BC, the normal vectors of each surface must point inwards---towards the valid geometry. For example, a :class:`XPlane` and @@ -248,28 +246,6 @@ The classes :class:`Halfspace`, :class:`Intersection`, :class:`Union`, and :class:`Complement` and all instances of :class:`openmc.Region` and can be assigned to the :attr:`Cell.region` attribute. -Cells also contain :attr:`Cell.temperature` and :attr:`Cell.density` -attributes which override the temperature and density of the fill. These can -be quite useful when temperatures and densities are spatially varying, as the -alternative would be to add a unique :class:`Material` for each permutation of -temperature, density, and composition. You can set the temperature (K) and -density (g/cc) of a cell like so:: - - fuel.temperature = 800.0 - fuel.density = 10.0 - -The real utility of cell temperatures and densities occurs when a cell is -replicated across the geometry, such as when a cell is the root geometric element -in a replicated :ref:`universe` or :ref:`lattice -`. In those cases, you can provide a list of temperatures -and densities to apply a temperature/density field to all of the distributed cells:: - - fuel.temperature = [800.0, 900.0, 800.0, 900.0] - fuel.density = [10.0, 9.0, 10.0, 9.0] - -In this example, the fuel cell is distributed four times in the geometry. Each -distributed instance then receives its own temperature and density. - .. _usersguide_universes: --------- @@ -437,11 +413,11 @@ to help figure out how to place universes:: Note that by default, hexagonal lattices are positioned such that each lattice -element has two faces that are perpendicular to the :math:`y` axis. As one -example, to create a three-ring lattice centered at the origin with a pitch of -10 cm where all the lattice elements centered along the :math:`y` axis are -filled with universe ``u`` and the remainder are filled with universe ``q``, the -following code would work:: +element has two faces that are parallel to the :math:`y` axis. As one example, +to create a three-ring lattice centered at the origin with a pitch of 10 cm +where all the lattice elements centered along the :math:`y` axis are filled with +universe ``u`` and the remainder are filled with universe ``q``, the following +code would work:: hexlat = openmc.HexLattice() hexlat.center = (0, 0) @@ -498,7 +474,7 @@ applied as universes in the OpenMC geometry file. A geometry represented entirely by a DAGMC geometry will contain only the DAGMC universe. Using a :class:`openmc.DAGMCUniverse` looks like the following:: - dag_univ = openmc.DAGMCUniverse('dagmc.h5m') + dag_univ = openmc.DAGMCUniverse(filename='dagmc.h5m') geometry = openmc.Geometry(dag_univ) geometry.export_to_xml() @@ -519,22 +495,13 @@ It is important in these cases to understand the DAGMC model's position with respect to the CSG geometry. DAGMC geometries can be plotted with OpenMC to verify that the model matches one's expectations. -By default, when you specify a .h5m file for a :class:`~openmc.DAGMCUniverse` -instance, it will store the absolute path to the .h5m file. If you prefer to -store the relative path, you can set the ``'resolve_paths'`` configuration -variable:: - - openmc.config['resolve_paths'] = False - dag_univ = openmc.DAGMCUniverse('dagmc.h5m') - -.. note:: - DAGMC geometries used in OpenMC are currently required to be clean, - meaning that all surfaces have been `imprinted and merged - `_ successfully - and that the model is `watertight - `_. - Future implementations of DAGMC geometry will support small volume overlaps and - un-merged surfaces. +**Note:** DAGMC geometries used in OpenMC are currently required to be clean, +meaning that all surfaces have been `imprinted and merged +`_ successfully +and that the model is `watertight +`_. +Future implementations of DAGMC geometry will support small volume overlaps and +un-merged surfaces. Cell, Surface, and Material IDs ------------------------------- @@ -554,89 +521,6 @@ UWUW and OpenMC material ID space will cause an error. To automatically resolve these ID overlaps, ``auto_ids`` can be set to ``True`` to append the UWUW material IDs to the OpenMC material ID space. - -Material overrides and differentiation --------------------------------------- - -Programmatic access to DAGMC cell information for material overrides -and differentiation requires synchronization of the DAGMC universe -representation across Python and C-API:: - - model.init_lib() - model.sync_dagmc_universes() - model.finalize_lib() - -Upon completion of these steps, the :attr:`DAGMCUniverse.cells` attribute will -be populated with :class:`DAGMCCell` proxy objects that represent the cells -defined in the DAGMC model. The :class:`DAGMCCell` objects will have -:class:`openmc.Material`'s' applied according to the assignments upon -initialization of the model. These materials can be replaced in the same manner -as :class:`openmc.Cell` objects to override material assignments in the DAGMC -model. - -Depletion with DAGMC geometry -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The synchronization of :class:`openmc.DAGMCUniverse`'s is important for -depletion calculations using DAGMC geometry when materials need to be -differentiated to perform material burnup independently in each DAGMC cell. See -:meth:`openmc.model.Model.differentiate_mats`. - -Material overrides -~~~~~~~~~~~~~~~~~~ - -OpenMC supports overriding material assignments defined inside a DAGMC HDF5 -model so that CAD-assigned materials can be replaced by :class:`openmc.Material` -objects. This is useful when the CAD geometry provides the shape but OpenMC -materials (specific nuclide content, densities, or depletion behavior) are -required. - - -Replacing materials by name -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If a DAGMC file includes material name tags, you can replace all cells that -reference a particular name with an :class:`openmc.Material` using -:meth:`~openmc.DAGMCUniverse.replace_material_assignment`:: - - import openmc - - dag_univ = openmc.DAGMCUniverse('dagmc.h5m') - - fuel = openmc.Material(name='fuel') - fuel.add_nuclide('U235', 0.05) - fuel.add_nuclide('U238', 0.95) - fuel.set_density('g/cm3', 10.5) - - dag_univ.replace_material_assignment('Fuel', fuel) - -This lets you keep CAD geometry while adopting OpenMC material definitions. - -Per-cell material overrides -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -To assign overrides without initializing :class:`openmc.Model`, the -:meth:`openmc.DAGMCUniverse.add_material_override` method can be used to assign -materials to particular DAGMC cells. The method accepts either an integer cell -ID:: - - dag_univ = openmc.DAGMCUniverse('dagmc.h5m') - - enriched = openmc.Material(name='fuel_enriched') - enriched.add_nuclide('U235', 0.10) - enriched.add_nuclide('U238', 0.90) - enriched.set_density('g/cm3', 10.5) - - dag_univ.add_material_override(1, enriched) - -In the case that the :class:`openmc.DAGMCUniverse` has already been synchronized, -a :class:`openmc.DAGMCCell` object can also be provide to assign the material. - -Overrides are written to the `` element of the -:ref:` ` XML element so the C++ core can apply -them on initialization. - - .. _Direct Accelerated Geometry Monte Carlo: https://svalinn.github.io/DAGMC/ .. _University of Wisconsin Unified Workflow: https://svalinn.github.io/DAGMC/usersguide/uw2.html diff --git a/docs/source/usersguide/index.rst b/docs/source/usersguide/index.rst index 5f8e0197e..03a77e870 100644 --- a/docs/source/usersguide/index.rst +++ b/docs/source/usersguide/index.rst @@ -21,12 +21,10 @@ essential aspects of using OpenMC to perform simulations. tallies plots depletion - decay_sources - kinetics scripts processing parallel volume - variance_reduction random_ray troubleshoot + \ No newline at end of file diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index 2a0d301d4..130e96c0a 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -8,42 +8,56 @@ Installation and Configuration .. _install_conda: ----------------------------------- -Installing on Linux/Mac with Conda ----------------------------------- +-------------------------------------------------- +Installing on Linux/Mac with Mamba and conda-forge +-------------------------------------------------- -`Conda`_ is an open source package management -system and environments management system for installing multiple versions of +`Conda `_ is an open source package management +systems and environments management system for installing multiple versions of software packages and their dependencies and switching easily between them. -OpenMC can be installed in a `conda` environment. First, `conda` should be -`installed `_ -with either Anaconda Distribution or Miniconda. Once you have `conda` installed -on your system, OpenMC can be installed via the `conda-forge` channel. +`Mamba `_ is a cross-platform package +manager and is compatible with `conda` packages. +OpenMC can be installed in a `conda` environment with `mamba`. +First, `conda` should be installed with one of the following installers: +`Miniconda `_, +`Anaconda `_, or `Miniforge `_. +Once you have `conda` installed on your system, OpenMC can be installed via the +`conda-forge` channel with `mamba`. First, add the `conda-forge` channel with: .. code-block:: sh conda config --add channels conda-forge - conda config --set channel_priority strict -Then create and activate a new conda enviroment called `openmc-env` (or whatever -you wish) with OpenMC installed. +Then create and activate a new conda enviroment called `openmc-env` in +which to install OpenMC. .. code-block:: sh - conda create --name openmc-env openmc + conda create -n openmc-env conda activate openmc-env -If you are installing on macOS with an Apple silicon ARM-based processor, you -will also need to specify the `--platform` option: +Then install `mamba`, which will be used to install OpenMC. .. code-block:: sh - conda create --name openmc-env --platform osx-64 openmc + conda install mamba -You are now in a conda environment called `openmc-env` that has OpenMC -installed. +To list the versions of OpenMC that are available on the `conda-forge` channel, +in your terminal window or an Anaconda Prompt run: + +.. code-block:: sh + + mamba search openmc + +OpenMC can then be installed with: + +.. code-block:: sh + + mamba install openmc + +You are now in a conda environment called `openmc-env` that has OpenMC installed. ------------------------------------------- Installing on Linux/Mac/Windows with Docker @@ -158,75 +172,6 @@ feature can be used to access the installed packages. .. _Spack: https://spack.readthedocs.io/en/latest/ .. _setup guide: https://spack.readthedocs.io/en/latest/getting_started.html -.. _install_aur: - ------------------------------------- -Installing on Arch Linux via the AUR ------------------------------------- - -On Arch Linux and Arch-based distributions, OpenMC can be installed from the -`Arch User Repository (AUR) `_. An AUR package named -``openmc-git`` is available, which builds OpenMC directly from the latest -development sources. - -This package provides a full-featured OpenMC stack, including: - -* MPI and DAGMC-enabled OpenMC build -* User-selected nuclear data libraries -* The `CAD_to_OpenMC `_ meshing tool -* All required dependencies for the above components - -To install the package, you will need an AUR helper such as `yay`_ or `paru`_. -For example, using ``yay``:: - - yay -S openmc-git - - -Alternatively, you can manually clone and build the package:: - - git clone https://aur.archlinux.org/openmc-git.git - cd openmc-git - makepkg -si - -Note, ``makepkg`` uses ``pacman`` to resolve dependencies. Therefore, AUR-based -dependencies need to be installed separately with ``yay`` or ``paru`` before -running ``makepkg``. The PKGBUILD will automatically handle all required -dependencies and build OpenMC with MPI and DAGMC support enabled. - -.. tip:: - - If there are failing checks during the build process, you can bypass them - with the ``--nocheck`` flag:: - - yay -S openmc-git --mflags "--nocheck" - - Or:: - - git clone https://aur.archlinux.org/openmc-git.git - cd openmc-git - makepkg -si --nocheck - -.. note:: - - The ``openmc-git`` package tracks the latest development version from the - upstream repository. As such, it may include new features and bug fixes, but - could also introduce instability compared to official releases. - -.. tip:: - - OpenMC is installed under ``/opt``. If you are installing and using it in - the same terminal session, you may need to reload your environment - variables:: - - source /etc/profile - - Alternatively, start a new shell session. - -Once installed, the ``openmc`` executable, nuclear data libraries, and -associated tools will be available in your system :envvar:`PATH`. - -.. _yay: https://github.com/Jguer/yay -.. _paru: https://github.com/Morganamilo/paru .. _install_source: @@ -297,7 +242,7 @@ Prerequisites OpenMC's built-in plotting capabilities use the libpng library to produce compressed PNG files. In the absence of this library, OpenMC will fallback to writing PPM files, which are uncompressed and only supported by select - image viewers. libpng can be installed on Debian derivates with:: + image viewers. libpng can be installed on Ddebian derivates with:: sudo apt install libpng-dev @@ -331,21 +276,22 @@ Prerequisites This option allows OpenMC to read and write MCPL (Monte Carlo Particle Lists) files instead of .h5 files for sources (external source - distribution, k-eigenvalue source distribution, and surface sources). - OpenMC does not need any particular build option to use this, but MCPL - must be installed on the system in order to do so. Refer to the - `MCPL documentation `_ - for instructions on how to accomplish this. + distribution, k-eigenvalue source distribution, and surface sources). To + turn this option on in the CMake configuration step, add the following + option:: + + cmake -DOPENMC_USE_MCPL=on .. * NCrystal_ library for defining materials with enhanced thermal neutron transport - OpenMC supports the creation of materials from NCrystal, which replaces - the scattering kernel treatment of ACE files with a modular, on-the-fly - approach. OpenMC does not need any particular build option to use this, - but NCrystal must be installed on the system. Refer to `NCrystal - documentation - `_ for how this is - achieved. + Adding this option allows the creation of materials from NCrystal, which + replaces the scattering kernel treatment of ACE files with a modular, + on-the-fly approach. To use it `install + `_ and `initialize + `_ + NCrystal and turn on the option in the CMake configuration step:: + + cmake -DOPENMC_USE_NCRYSTAL=on .. * libMesh_ mesh library framework for numerical simulations of partial differential equations @@ -444,6 +390,16 @@ OPENMC_USE_DAGMC should also be defined as `DAGMC_ROOT` in the CMake configuration command. (Default: off) +OPENMC_USE_MCPL + Turns on support for reading MCPL_ source files and writing MCPL source points + and surface sources. (Default: off) + +OPENMC_USE_NCRYSTAL + Turns on support for NCrystal materials. NCrystal must be `installed + `_ and `initialized + `_. + (Default: off) + OPENMC_USE_LIBMESH Enables the use of unstructured mesh tallies with libMesh_. (Default: off) @@ -452,25 +408,6 @@ OPENMC_USE_MPI options, please see the `FindMPI.cmake documentation `_. -.. _cmake_strict_fp: - -OPENMC_ENABLE_STRICT_FP - Disables compiler optimizations that change floating-point results relative to - unoptimized builds, improving cross-platform and cross-optimization-level - reproducibility. This disables FMA contraction (``-ffp-contract=off``) and - compiler builtin replacements of math functions like ``pow``, ``exp``, ``log`` - (``-fno-builtin``). It also keeps C/C++ assertions active by removing the - ``-DNDEBUG`` flag from ``RelWithDebInfo`` builds. Without this flag, these - optimizations can produce bit-level differences across platforms, compilers, - and optimization levels. This option should be used when running the test - suite. By default (off), the compiler is free to use all optimizations for - best performance. (Default: off) - -OPENMC_FORCE_VENDORED_LIBS - Forces OpenMC to use the submodules located in the vendor directory, as - opposed to searching the system for already installed versions of those - modules. - To set any of these options (e.g., turning on profiling), the following form should be used: @@ -489,19 +426,13 @@ OpenMC can be configured for debug, release, or release with debug info by setti the `CMAKE_BUILD_TYPE` option. Debug - Enable debug compiler flags with no optimization. On most platforms/compilers, - this is equivalent to `-O0 -g`. + Enable debug compiler flags with no optimization `-O0 -g`. Release - Disable debug and enable optimization. On most platforms/compilers, this is - equivalent to `-O3 -DNDEBUG`. + Disable debug and enable optimization `-O3 -DNDEBUG`. RelWithDebInfo - (Default if no type is specified.) Enable optimization and debug. On most - platforms/compilers, this is equivalent to `-O2 -g`. When - :ref:`OPENMC_ENABLE_STRICT_FP ` is enabled, OpenMC removes the - ``-DNDEBUG`` flag that CMake normally adds for this build type, so that - C/C++ assertions remain active. + (Default if no type is specified.) Enable optimization and debug `-O2 -g`. Example of configuring for Debug mode: @@ -609,13 +540,10 @@ to install the Python package in :ref:`"editable" mode `. Prerequisites ------------- -In addition to Python itself, the OpenMC Python API relies on a number of -third-party packages. All prerequisites can be installed using Conda_ -(recommended), pip_, or through the package manager in most Linux distributions. -The current required Python version and up-to-date list of package dependencies -can be found in the `pyproject.toml `_ -file in the root directory of the OpenMC repository. An overview of these -dependencies is provided below. +The Python API works with Python 3.8+. In addition to Python itself, the API +relies on a number of third-party packages. All prerequisites can be installed +using Conda_ (recommended), pip_, or through the package manager in most Linux +distributions. .. admonition:: Required :class: error @@ -633,7 +561,7 @@ dependencies is provided below. notebook `_. - `h5py `_ + `h5py `_ h5py provides Python bindings to the HDF5 library. Since OpenMC outputs various HDF5 files, h5py is needed to provide access to data within these files from Python. @@ -656,6 +584,10 @@ dependencies is provided below. parallel runs. This package is needed if you plan on running depletion simulations in parallel using MPI. + `Cython `_ + Cython is used for resonance reconstruction for ENDF data converted to + :class:`openmc.data.IncidentNeutron`. + `vtk `_ The Python VTK bindings are needed to convert voxel and track files to VTK format. @@ -686,6 +618,5 @@ wrapper is used when installing h5py: CC= HDF5_MPI=ON HDF5_DIR= python -m pip install --no-binary=h5py h5py -.. _Mamba: https://mamba.readthedocs.io/en/latest/ .. _Conda: https://conda.io/en/latest/ .. _pip: https://pip.pypa.io/en/stable/ diff --git a/docs/source/usersguide/kinetics.rst b/docs/source/usersguide/kinetics.rst deleted file mode 100644 index 9024ff822..000000000 --- a/docs/source/usersguide/kinetics.rst +++ /dev/null @@ -1,133 +0,0 @@ -.. _kinetics: - -=================== -Kinetics parameters -=================== - -OpenMC has the capability to estimate the following adjoint-weighted effective -generation time :math:`\Lambda_{\text{eff}}` and the effective delayed neutron -fraction :math:`\beta_{\text{eff}}`. These parameters are calculated using the -iterated fission probability (IFP) method [Hurwitz_1964]_ based on a similar -approach as in `Serpent 2 `_. The -implementation in OpenMC is limited to eigenvalue calculations and is described -in more details in [Dorville_2025]_. - ----------------------------------- -Iterated Fission Probability (IFP) ----------------------------------- - -With IFP, additional information needs to be recorded during the simulation -compared to a typical eigenvalue calculation. OpenMC stores an additional -set of values (neutron lifetime or delayed neutron group number for -:math:`\Lambda_{\text{eff}}` or :math:`\beta_{\text{eff}}`, respectively) -for every fission neutron simulated. Each set of values corresponds to -the values that are associated to the :math:`N_{\text{gen}}` direct ancestors -of any given fission neutron. - -:math:`N_{\text{gen}}` is referred to as the number of generations in the -IFP method and corresponds to the number of generations between the birth of -a fission neutron and the time its score is added to the IFP tally. By default, -OpenMC considers 10 generations but this value can be modified by the user via -the ``ifp_n_generation`` settings in the Python API:: - - settings.ifp_n_generation = 5 - -``ifp_n_generation`` should be greater than 0, but should also be lower than -or equal to the number of inactive batches declared for the calculation. -The respect of these constraints is verified by OpenMC before any calculation. - -OpenMC will automatically detect the type of data that needs to be stored based -on the tally scores selected by the user. This guarantees that only information -of interest are stored during a simulation and avoids using extra memory when -only one parameter is needed. The following table shows the tally scores that -are needed to compute kinetics parameters in OpenMC: - -.. table:: **OpenMC tally scores needed to calculate adjoint-weighted kinetics parameters** - :align: center - - =============================== ============================ ========================== ======== - OpenMC tally score \\ Parameter :math:`\Lambda_{\text{eff}}` :math:`\beta_{\text{eff}}` Both - =============================== ============================ ========================== ======== - ``ifp-time-numerator`` X X - ``ifp-beta-numerator`` X X - ``ifp-denominator`` X X X - =============================== ============================ ========================== ======== - -| - -.. note:: Because the memory footprint of additional data is generally non-negligible - with IFP, it is recommended to choose the value for ``ifp_n_generation`` carefully. - For example, using one generation for both kinetics parameters corresponds to store - one additional integer (for the delayed neutron group number used with - :math:`\beta_{\text{eff}}`) and one floating point value (for the neutron lifetime - used with :math:`\Lambda_{\text{eff}}`) for every fission neutron simulated once the - asymptotic regime is reached. - ------------------------------ -Obtaining kinetics parameters ------------------------------ - -The ``Model`` class can be used to automatically generate all IFP tallies using -the Python API with :attr:`openmc.Settings.ifp_n_generation` greater than 0 and -the :meth:`openmc.Model.add_ifp_kinetics_tallies` method:: - - model = openmc.Model(geometry, settings=settings) - model.add_kinetics_parameters_tallies(num_groups=6) # Add 6 precursor groups - -Alternatively, each of the tallies can be manually defined using group-wise or -total :math:`\beta_{\text{eff}}` specified by providing a 6-group -:class:`openmc.DelayedGroupFilter`:: - - beta_tally = openmc.Tally(name="group-beta-score") - beta_tally.scores = ["ifp-beta-numerator"] - - # Add DelayedGroupFilter to enable group-wise tallies - beta_tally.filters = [openmc.DelayedGroupFilter(list(range(1, 7)))] - -Here is an example showing how to declare the three available IFP scores in a -single tally:: - - tally = openmc.Tally(name="ifp-scores") - tally.scores = [ - "ifp-time-numerator", - "ifp-beta-numerator", - "ifp-denominator" - ] - -The effective generation time :math:`\Lambda_{\text{eff}}` is calculated -by dividing the result of the ``ifp-time-numerator`` score by the one obtained -for ``ifp-denominator`` and by the :math:`k_{\text{eff}}` of the simulation: - -.. math:: - :label: lambda_eff - - \Lambda_{\text{eff}} = \frac{S_{\text{ifp-time-numerator}}}{S_{\text{ifp-denominator}} \times k_{\text{eff}}} - -The effective delayed neutron fraction :math:`\beta_{\text{eff}}` is calculated -by dividing the result of the ``ifp-beta-numerator`` score by the one obtained -for ``ifp-denominator``: - -.. math:: - :label: beta_eff - - \beta_{\text{eff}} = \frac{S_{\text{ifp-beta-numerator}}}{S_{\text{ifp-denominator}}} - -The kinetics parameters can be retrieved directly from a statepoint file using -the :meth:`openmc.StatePoint.ifp_results` method:: - - with openmc.StatePoint(output_path) as sp: - generation_time, beta_eff = sp.get_kinetics_parameters() - -.. only:: html - - .. rubric:: References - -.. [Hurwitz_1964] H. Hurwitz Jr., "Naval Reactors Physics Handbook", volume 1, p. 864. - Radkowsky, A. (Ed.), Naval Reactors, Division of Reactor Development, U.S. - Atomic Energy Commission (1964). - -.. [Dorville_2025] J. Dorville, L. Labrie-Cleary, and P. K. Romano, "Implementation - of the Iterated Fission Probability Method in OpenMC to Compute Adjoint-Weighted - Kinetics Parameters", International Conference on Mathematics and Computational - Methods Applied to Nuclear Science and Engineering (M&C 2025), Denver, April 27-30, - 2025. diff --git a/docs/source/usersguide/parallel.rst b/docs/source/usersguide/parallel.rst index ecbdd20b6..be4189604 100644 --- a/docs/source/usersguide/parallel.rst +++ b/docs/source/usersguide/parallel.rst @@ -101,5 +101,5 @@ performance on a machine when running in parallel: settings = openmc.Settings() settings.output = {'tallies': False} -.. _Haswell-EP: https://www.anandtech.com/show/8423/intel-xeon-e5-version-3-up-to-18-haswell-ep-cores-/4 -.. _bound: https://github.com/pmodels/mpich/blob/main/doc/wiki/how_to/Using_the_Hydra_Process_Manager.md#process-core-binding +.. _Haswell-EP: http://www.anandtech.com/show/8423/intel-xeon-e5-version-3-up-to-18-haswell-ep-cores-/4 +.. _bound: https://wiki.mpich.org/mpich/index.php/Using_the_Hydra_Process_Manager#Process-core_Binding diff --git a/docs/source/usersguide/plots.rst b/docs/source/usersguide/plots.rst index b5c29a3e8..2d588519c 100644 --- a/docs/source/usersguide/plots.rst +++ b/docs/source/usersguide/plots.rst @@ -6,14 +6,13 @@ Geometry Visualization .. currentmodule:: openmc -OpenMC is capable of producing two-dimensional slice plots of a geometry, -three-dimensional voxel plots, and three-dimensional raytrace plots using the -geometry plotting :ref:`run mode `. The geometry plotting -mode relies on the presence of a :ref:`plots.xml ` file that indicates -what plots should be created. To create this file, one needs to create one or -more instances of the various plot classes described below, add them to a -:class:`openmc.Plots` collection, and then use the :class:`Plots.export_to_xml` -method to write the ``plots.xml`` file. +OpenMC is capable of producing two-dimensional slice plots of a geometry as well +as three-dimensional voxel plots using the geometry plotting :ref:`run mode +`. The geometry plotting mode relies on the presence of a +:ref:`plots.xml ` file that indicates what plots should be created. To +create this file, one needs to create one or more :class:`openmc.Plot` +instances, add them to a :class:`openmc.Plots` collection, and then use the +:class:`Plots.export_to_xml` method to write the ``plots.xml`` file. ----------- Slice Plots @@ -22,14 +21,15 @@ Slice Plots .. image:: ../_images/atr.png :width: 300px -The :class:`openmc.SlicePlot` class indicates that a 2D slice plot should be -made. You can specify the origin of the plot (:attr:`SlicePlot.origin`), the -width of the plot in each direction (:attr:`SlicePlot.width`), the number of -pixels to use in each direction (:attr:`SlicePlot.pixels`), and the basis -directions for the plot. For example, to create a :math:`x` - :math:`z` plot -centered at (5.0, 2.0, 3.0) with a width of (50., 50.) and 400x400 pixels:: +By default, when an instance of :class:`openmc.Plot` is created, it indicates +that a 2D slice plot should be made. You can specify the origin of the plot +(:attr:`Plot.origin`), the width of the plot in each direction +(:attr:`Plot.width`), the number of pixels to use in each direction +(:attr:`Plot.pixels`), and the basis directions for the plot. For example, to +create a :math:`x` - :math:`z` plot centered at (5.0, 2.0, 3.0) with a width of +(50., 50.) and 400x400 pixels:: - plot = openmc.SlicePlot() + plot = openmc.Plot() plot.basis = 'xz' plot.origin = (5.0, 2.0, 3.0) plot.width = (50., 50.) @@ -47,7 +47,7 @@ that location. By default, a unique color will be assigned to each cell in the geometry. If you want your plot to be colored by material instead, change the -:attr:`SlicePlot.color_by` attribute:: +:attr:`Plot.color_by` attribute:: plot.color_by = 'material' @@ -68,8 +68,8 @@ particular cells/materials should be given colors of your choosing:: Note that colors can be given as RGB tuples or by a string indicating a valid `SVG color `_. -When you're done creating your :class:`openmc.SlicePlot` instances, you need to -then assign them to a :class:`openmc.Plots` collection and export it to XML:: +When you're done creating your :class:`openmc.Plot` instances, you need to then +assign them to a :class:`openmc.Plots` collection and export it to XML:: plots = openmc.Plots([plot1, plot2, plot3]) plots.export_to_xml() @@ -97,11 +97,13 @@ Voxel Plots .. image:: ../_images/3dba.png :width: 200px -The :class:`openmc.VoxelPlot` class enables the generation of a 3D voxel plot -instead of a 2D slice plot. In this case, the :attr:`VoxelPlot.width` and -:attr:`VoxelPlot.pixels` attributes should be three items long, e.g.:: +The :class:`openmc.Plot` class can also be told to generate a 3D voxel plot +instead of a 2D slice plot. Simply change the :attr:`Plot.type` attribute to +'voxel'. In this case, the :attr:`Plot.width` and :attr:`Plot.pixels` attributes +should be three items long, e.g.:: - vox_plot = openmc.VoxelPlot() + vox_plot = openmc.Plot() + vox_plot.type = 'voxel' vox_plot.width = (100., 100., 50.) vox_plot.pixels = (400, 400, 200) @@ -109,93 +111,38 @@ The voxel plot data is written to an :ref:`HDF5 file `. The voxel file can subsequently be converted into a standard mesh format that can be viewed in `ParaView `_, `VisIt `_, etc. This typically -will compress the size of the file significantly. The -:func:`openmc.voxel_to_vtk` function can convert the HDF5 voxel file to VTK -formats. Once processed into a standard 3D file format, colors and masks can be -defined using the stored ID numbers to better explore the geometry. The process -for doing this will depend on the 3D viewer, but should be straightforward. +will compress the size of the file significantly. The provided +:ref:`scripts_voxel` script can convert the HDF5 voxel file to VTK formats. Once +processed into a standard 3D file format, colors and masks can be defined using +the stored ID numbers to better explore the geometry. The process for doing this +will depend on the 3D viewer, but should be straightforward. .. note:: 3D voxel plotting can be very computer intensive for the viewing program (Visit, ParaView, etc.) if the number of voxels is large (>10 million or so). Thus if you want an accurate picture that renders smoothly, consider using only one voxel in a certain direction. ----------------------- -Solid Ray-traced Plots ----------------------- - -.. image:: ../_images/phong_triso.png - :width: 300px - -The :class:`openmc.SolidRayTracePlot` class allows three dimensional -visualization of detailed geometric features without voxelization. The plot -above visualizes a geometry created by :class:`openmc.TRISO`, with the materials -in the fuel kernel distinguished by color. It was enclosed in a bounding box -such that some kernels are cut off, revealing the inner structure of the kernel. - -The `Phong reflection model -`_ approximates how light -reflects off of a surface. On a diffusely light-scattering material, the Phong -model prescribes the amount of light reflected from a surface as proportional to -the dot product between the normal vector of the surface and the vector between -that point on the surface and the light. With this assumption, visually -appealing plots of simulation geometries can be created. - -Solid ray-traced plots use the same ray tracing functions that neutrons and -photons do in OpenMC, so any input that does not leak particles can be -visualized in 3D using a solid ray-traced plot. That being said, these plots are -not useful for detecting overlap or undefined regions, so it is recommended to -use the slice plot approach for geometry debugging. - -Only a few inputs are required for a solid ray-traced plot. The camera location, -where the camera is looking, and a set of opaque material or cell IDs are -required. The colors of materials or cells are prescribed in the same way as -slice plots. The set of IDs that are opaque in the plot must correspond to -materials if coloring by material, or cells if coloring by cell. - -A minimal solid ray-traced plot input could be:: - - plot = openmc.SolidRayTracePlot() - plot.pixels = (600, 600) - plot.camera_position = (10.0, 20.0, -30.0) - plot.look_at = (4.0, 5.0, 1.0) - plot.color_by = 'cell' - - # optional. defaults to camera_position - plot.light_position = (10, 20, 30) - - # controls ambient lighting. Defaults to 10% - plot.diffuse_fraction = 0.1 - plot.opaque_domains = [cell2, cell3] - -These plots are then stored into a :class:`openmc.Plots` instance, just like the -slice plots. - ---------------- -Wireframe Plots ---------------- +---------------- +Projection Plots +---------------- .. only:: html .. image:: ../_images/hexlat_anim.gif :width: 200px -The :class:`openmc.WireframeRayTracePlot` class also produces 3D visualizations -of OpenMC geometries without voxelization but is intended to show the inside of -a model using wireframing of cell or material boundaries in addition to cell -coloring based on the path length of camera rays through the model. The coloring -in these plots is a bit like turning the model into partially transparent -colored glass that can be seen through, without any refractive effects. This is -called volume rendering. The colors are specified in exactly the same interface -employed by slice plots. - -Similar to solid ray-traced plots, these use the native ray tracing capabilities +The :class:`openmc.ProjectionPlot` class presents an alternative method of +producing 3D visualizations of OpenMC geometries. It was developed to overcome +the primary shortcoming of voxel plots, that an enormous number of voxels must +be employed to capture detailed geometric features. Projection plots perform +volume rendering on material or cell volumes, with colors specified in the same +manner as slice plots. This is done using the native ray tracing capabilities within OpenMC, so any geometry in which particles successfully run without -overlaps or leaks will work with wireframe plots. +overlaps or leaks will work with projection plots. -One drawback of wireframe plots is that particle tracks cannot be overlaid on +One drawback of projection plots is that particle tracks cannot be overlaid on them at present. Moreover, checking for overlap regions is not currently -possible with wireframe plots. The image heading this section can be created by +possible with projection plots. The image heading this section can be created by adding the following code to the hexagonal lattice example packaged with OpenMC, before exporting to plots.xml. @@ -205,7 +152,7 @@ before exporting to plots.xml. import numpy as np for i in range(100): phi = 2 * np.pi * i/100 - thisp = openmc.WireframeRayTracePlot(plot_id = 4 + i) + thisp = openmc.ProjectionPlot(plot_id = 4 + i) thisp.filename = 'frame%s'%(str(i).zfill(3)) thisp.look_at = [0, 0, 0] thisp.camera_position = [r * np.cos(phi), r * np.sin(phi), 6 * np.sin(phi)] @@ -220,45 +167,42 @@ before exporting to plots.xml. plot_file.append(thisp) -This generates a sequence of png files that can be joined to form a gif. Each +This generates a sequence of png files which can be joined to form a gif. Each image specifies a different camera position using some simple periodic functions -to create a perfectly looped gif. :attr:`~WireframeRayTracePlot.look_at` defines -where the camera's centerline should point at. -:attr:`~WireframeRayTracePlot.camera_position` similarly defines where the -camera is situated in the universe level we seek to plot. The other settings -resemble those employed by :class:`openmc.Plot`, with the exception of the -:meth:`~WireframeRayTracePlot.set_transparent` method and -:attr:`~WireframeRayTracePlot.xs` dictionary. These are used to control volume -rendering of material volumes. "xs" here stands for cross section, and it -defines material opacities in units of inverse centimeters. Setting this value -to a large number would make a material or cell opaque, and setting it to zero -makes a material transparent. Thus, the -:meth:`~WireframeRayTracePlot.set_transparent` method can be used to make all -materials in the geometry transparent. From there, individual material or cell -opacities can be tuned to produce the desired result. +to create a perfectly looped gif. :attr:`ProjectionPlot.look_at` defines where +the camera's centerline should point at. :attr:`ProjectionPlot.camera_position` +similarly defines where the camera is situated in the universe level we seek to +plot. The other settings resemble those employed by :class:`openmc.Plot`, with +the exception of the :class:`ProjectionPlot.set_transparent` method and +:attr:`ProjectionPlot.xs` dictionary. These are used to control volume rendering +of material volumes. "xs" here stands for cross section, and it defines material +opacities in units of inverse centimeters. Setting this value to a large number +would make a material or cell opaque, and setting it to zero makes a material +transparent. Thus, the :class:`ProjectionPlot.set_transparent` can be used to +make all materials in the geometry transparent. From there, individual material +or cell opacities can be tuned to produce the desired result. Two camera projections are available when using these plots, perspective and orthographic. The default, perspective projection, is a cone of rays passing through each pixel which radiate from the camera position and span the field of view in the x and y positions. The horizontal field of view can be set with the -:attr:`~WireframeRayTracePlot.horizontal_field_of_view` attribute, which is to -be specified in units of degrees. The field of view only influences behavior in +:attr: `ProjectionPlot.horizontal_field_of_view` attribute, which is to be +specified in units of degrees. The field of view only influences behavior in perspective projection mode. In the orthographic projection, rays follow the same angle but originate from different points. The horizontal width of this plane of ray starting points may -be set with the :attr:`~WireframeRayTracePlot.orthographic_width` attribute. If -this element is nonzero, the orthographic projection is employed. Left to its -default value of zero, the perspective projection is employed. +be set with the :attr: `ProjectionPlot.orthographic_width` element. If this +element is nonzero, the orthographic projection is employed. Left to its default +value of zero, the perspective projection is employed. -Most importantly, wireframe plots come packaged with wireframe generation that -can target either all surface/cell/material boundaries in the geometry, or only -wireframing around specific regions. In the above example, we have set only the -fuel region from the hexagonal lattice example to have a wireframe drawn around -it. This is accomplished by setting the -:attr:`~WireframeRayTracePlot.wireframe_domains` attribute, which may be set to -either material IDs or cell IDs. The -:attr:`~WireframeRayTracePlot.wireframe_thickness` attribute sets the wireframe +Lastly, projection plots come packaged with wireframe generation that can target +either all surface/cell/material boundaries in the geometry, or only wireframing +around specific regions. In the above example, we have set only the fuel region +from the hexagonal lattice example to have a wireframe drawn around it. This is +accomplished by setting the :attr: `ProjectionPlot.wireframe_domains`, which may +be set to either material IDs or cell IDs. The +:attr:`ProjectionPlot.wireframe_thickness` attribute sets the wireframe thickness in units of pixels. .. note:: When setting specific material or cell regions to have wireframes diff --git a/docs/source/usersguide/processing.rst b/docs/source/usersguide/processing.rst index ed3e8564a..3103b7b7c 100644 --- a/docs/source/usersguide/processing.rst +++ b/docs/source/usersguide/processing.rst @@ -41,9 +41,12 @@ Plotting in 2D -------------- The `example notebook`_ also demonstrates how to plot a structured mesh tally in -two dimensions using the Python API. One can also use the `openmc-plotter -`_ application that provides an -interactive GUI to explore and plot a much wider variety of tallies. +two dimensions using the Python API. One can also use the :ref:`scripts_plot` +script which provides an interactive GUI to explore and plot structured mesh +tallies for any scores and filter bins. + +.. image:: ../_images/plotmeshtally.png + :width: 400px .. _usersguide_track: @@ -68,17 +71,17 @@ generation, and particle number of the desired particle. For example, to create a track file for particle 4 of batch 1 and generation 2:: settings = openmc.Settings() - settings.track = [(1, 2, 4)] + settings.track = (1, 2, 4) -To specify multiple particles, specify a list of tuples, e.g., if we wanted -particles 3 and 4 from batch 1 and generation 2:: +To specify multiple particles, the length of the iterable should be a multiple +of three, e.g., if we wanted particles 3 and 4 from batch 1 and generation 2:: - settings.track = [(1, 2, 3), (1, 2, 4)] + settings.track = (1, 2, 3, 1, 2, 4) -After running OpenMC (now, without the ``-t`` argument), the working directory -will contain a file named `tracks.h5`, which contains a collection of particle -tracks. These track files can be converted into VTK poly data files or -matplotlib plots with the :class:`openmc.Tracks` class. +After running OpenMC, the working directory will contain a file of the form +"track_(batch #)_(generation #)_(particle #).h5" for each particle tracked. +These track files can be converted into VTK poly data files with the +:ref:`scripts_track` script. ---------------------- Source Site Processing @@ -91,90 +94,3 @@ from a statepoint file, the ``openmc.statepoint`` module can be used. An `example notebook`_ demontrates how to analyze and plot source information. .. _example notebook: https://nbviewer.jupyter.org/github/openmc-dev/openmc-notebooks/blob/main/post-processing.ipynb - ------------------------- -VTK Mesh File Generation ------------------------- - -VTK files of OpenMC meshes can be created using the -:meth:`openmc.Mesh.write_data_to_vtk` method. This method supports several VTK -formats depending on the mesh type. Structured meshes -(:class:`~openmc.RegularMesh`, :class:`~openmc.RectilinearMesh`, -:class:`~openmc.CylindricalMesh`, and :class:`~openmc.SphericalMesh`) can be -exported to legacy VTK format (``.vtk``). The :class:`~openmc.UnstructuredMesh` -class supports VTK unstructured grid formats (``.vtu``) as well as an HDF5-based -format (``.vtkhdf``) that does not require the ``vtk`` module to write. - -Data can be applied to the -elements of the resulting mesh from mesh filter objects. This data can be -provided either as a flat array or, in the case of structured meshes -(:class:`~openmc.RegularMesh`, :class:`~openmc.RectilinearMesh`, -:class:`~openmc.CylindricalMesh`, or :class:`SphericalMesh`), the data can be -shaped with dimensions that match the dimensions of the mesh itself. - - -.. image:: ../_images/sphere-mesh-vtk.png - :width: 400px - :align: center - :alt: OpenMC spherical mesh exported to VTK - - -For all mesh types, if a flat data array is provided to the mesh, it is expected -that the data is ordered in the same ordering as the :attr:`openmc.Mesh.indices` -for that mesh object. When providing data directly from a tally, as shown below, -a flat array for a given dataset can be passed directly to this method. - -:: - - # create model above - - # create a mesh tally - mesh = openmc.RegularMesh() - mesh.dimension = [10, 20, 30] - mesh.lower_left = [-5, -10, -15] - mesh.upper_right = [5, 10, 15] - mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() - tally.filters = [mesh_filter] - tally.scores = ['flux'] - - model.tallies = [tally] - model.run(apply_tally_results=True) - - # provide the data as-is to the method - mesh.write_data_to_vtk('flux.vtk', {'flux-mean': tally.mean}) - -The :class:`~openmc.Tally` object also provides a way to expand the dimensions -of the mesh filter into a meaningful form where indexing the mesh filter -dimensions results in intuitive slicing of structured meshes by setting -``expand_dims=True`` when using :meth:`openmc.Tally.get_reshaped_data`. This -reshaping does cause flat indexing of the data to change, however. As noted -above, provided datasets are allowed to be shaped so long as such datasets have -shapes that match the mesh dimensions. The ability to pass datasets in this way -is useful when additional filters are applied to a tally. The example below -demonstrates such a case for tally with both a :class:`~openmc.MeshFilter` and -:class:`~openmc.EnergyFilter` applied. - -:: - - # create model above - - # create a mesh tally with energy filter - mesh = openmc.RegularMesh() - mesh.dimension = [10, 20, 30] - mesh.lower_left = [-5, -10, -15] - mesh.upper_right = [5, 10, 15] - mesh_filter = openmc.MeshFilter(mesh) - energy_filter = openmc.EnergyFilter([0.0, 1.0, 20.0e6]) - tally = openmc.Tally() - tally.filters = [mesh_filter, energy_filter] - tally.scores = ['flux'] - - model.tallies = [tally] - model.run(apply_tally_results=True) - - # get the data with mesh dimensions expanded, squeeze out length-one dimensions (nuclides, scores) - flux = tally.get_reshaped_data(expand_dims=True).squeeze() # shape: (10, 20, 30, 2) - - # write the lowest energy group to a VTK file - mesh.write_data_to_vtk('flux-group1.vtk', datasets={'flux-mean': flux[..., 0]}) diff --git a/docs/source/usersguide/random_ray.rst b/docs/source/usersguide/random_ray.rst index 81db61ae0..61f074650 100644 --- a/docs/source/usersguide/random_ray.rst +++ b/docs/source/usersguide/random_ray.rst @@ -11,76 +11,6 @@ active batches `. However, there are a couple of settings that are unique to the random ray solver and a few areas that the random ray run strategy differs, both of which will be described in this section. -.. _quick_start: - ------------ -Quick Start ------------ - -While this page contains a comprehensive guide to the random ray solver and -its various parameters, the process of converting an existing continuous energy -Monte Carlo model to a random ray model can be largely automated via convenience -functions in OpenMC's Python interface:: - - # Define continuous energy model as normal - model = openmc.Model() - ... - - # Convert model to multigroup (will auto-generate MGXS library if needed) - model.convert_to_multigroup() - - # Convert model to random ray and initialize random ray parameters - # to reasonable defaults based on the specifics of the geometry - model.convert_to_random_ray() - - # (Optional) Overlay source region decomposition mesh to improve fidelity of the - # random ray solver. Adjust 'n' for fidelity vs runtime. - n = 100 - mesh = openmc.RegularMesh() - mesh.dimension = (n, n, n) - mesh.lower_left = model.geometry.bounding_box.lower_left - mesh.upper_right = model.geometry.bounding_box.upper_right - model.settings.random_ray['source_region_meshes'] = [(mesh, [model.geometry.root_universe])] - - # (Optional) Improve fidelity of the random ray solver by enabling linear sources - model.settings.random_ray['source_shape'] = 'linear' - - # (Optional) Increase the number of rays/batch, to reduce uncertainty - model.settings.particles = 500 - -The above strategy first converts the continuous energy model to a multigroup -one using the :meth:`openmc.Model.convert_to_multigroup` method. By default, -this will internally run a coarsely converged continuous energy Monte Carlo -simulation to produce an estimated multigroup macroscopic cross section set for -each material specified in the model, and store this data into a multigroup -cross section library file (``mgxs.h5``) that can be used by the random ray -solver. - -The :meth:`openmc.Model.convert_to_random_ray` method enables random ray mode -and performs an analysis of the model geometry to determine reasonable values -for all required parameters. If default behavior is not satisfactory, the user -can manually adjust the settings in the :attr:`~openmc.Settings.random_ray` -dictionary in the :class:`openmc.Settings` as described in the sections below. - -Finally a few optional steps are shown. The first (recommended) step overlays a -mesh over the geometry to create smaller source regions so that source -resolution improves and the random ray solver becomes more accurate. Varying the -mesh resolution can be used to trade off between accuracy and runtime. -High-fidelity fission reactor simulation may require source region sizes below 1 -cm, while larger fixed source problems with some tolerance for error may be able -to use source regions of 10 or 100 cm. - -We also enable linear sources, which can improve the accuracy of the random ray -solver and/or allow for a much coarser mesh resolution to be overlaid. Finally, -the number of rays per batch is adjusted. The goal here is to ensure that the -source region miss rate is below 1%, which is reported by OpenMC at the end of -the simulation (or before via a warning if it is very high). - -.. warning:: - If using a mesh filter for tallying or weight window generation, ensure that - the same mesh is used for source region decomposition via - ``model.settings.random_ray['source_region_meshes']``. - ------------------------ Enabling Random Ray Mode ------------------------ @@ -132,17 +62,6 @@ solver:: settings.batches = 1200 settings.inactive = 600 ---------------- -Shannon Entropy ---------------- - -Similar to Monte Carlo, :ref:`Shannon entropy -` can be used to gauge whether the fission -source has fully developed. The Shannon entropy is calculated automatically -after each batch and is printed to the statepoint file. Unlike Monte Carlo, an -entropy mesh does not need to be defined, as the Shannon entropy is calculated -over FSRs using a volume-weighted approach. - ------------------------------- Inactive Ray Length (Dead Zone) ------------------------------- @@ -181,7 +100,7 @@ detector from the core. In this case, rays sampled in the moderator region and heading toward the detector will begin life with a highly scattered thermal spectrum and will have an inaccurate fast spectrum. If the dead zone length is only 20 cm, we might imagine such rays writing to the detector tally within -their active lengths, despite their inaccurate estimate of the uncollided fast +their active lengths, despite their innaccurate estimate of the uncollided fast angular flux. Thus, an inactive length of 100--200 cm would ensure that any such rays would still be within their inactive regions, and only rays that have actually traversed through the core (and thus have an accurate representation of @@ -369,44 +288,22 @@ acceptable ray source for a two-dimensional 2x2 lattice would look like: provide physical particle fixed sources in addition to the random ray source. --------------------------- -Quasi-Monte Carlo Sampling --------------------------- - -By default OpenMC will use a pseudorandom number generator (PRNG) to sample ray -starting locations from a uniform distribution in space and angle. -Alternatively, a randomized Halton sequence may be sampled from, which is a form -of Randomized Qusi-Monte Carlo (RQMC) sampling. RQMC sampling with random ray -has been shown to offer reduced variance as compared to regular PRNG sampling, -as the Halton sequence offers a more uniform distribution of sampled points. -Randomized Halton sampling can be enabled as:: - - settings.random_ray['sample_method'] = 'halton' - -Default behavior using OpenMC's native PRNG can be manually specified as:: - - settings.random_ray['sample_method'] = 'prng' - .. _subdivision_fsr: ------------------------------ -Subdivision of Source Regions ------------------------------ +---------------------------------- +Subdivision of Flat Source Regions +---------------------------------- -While the scattering and fission sources in Monte Carlo are treated -continuously, they are assumed to have a shape (flat or linear) within a MOC or -random ray source region (SR). This introduces bias into the simulation that can -be remedied by reducing the physical size of the SR to be smaller than the -typical mean free paths of particles. While use of linear sources in OpenMC -greatly reduces the error stemming from this approximation, subdivision is still -typically required. +While the scattering and fission sources in Monte Carlo +are treated continuously, they are assumed to be invariant (flat) within a +MOC or random ray flat source region (FSR). This introduces bias into the +simulation, which can be remedied by reducing the physical size of the FSR +to dimensions below that of typical mean free paths of particles. -In OpenMC, this subdivision can be done either manually by the user (by defining -additional surfaces and cells in the geometry) or automatically by assigning a -mesh to one or more cells, universes, or material types. The level of +In OpenMC, this subdivision currently must be done manually. The level of subdivision needed will be dependent on the fidelity the user requires. For -typical light water reactor analysis, consider the following example of manual -subdivision of a two-dimensional 2x2 reflective pincell lattice: +typical light water reactor analysis, consider the following example subdivision +of a two-dimensional 2x2 reflective pincell lattice: .. figure:: ../_images/2x2_materials.jpeg :class: with-border @@ -418,81 +315,9 @@ subdivision of a two-dimensional 2x2 reflective pincell lattice: :class: with-border :width: 400 - Manual decomposition for an asymmetrical 2x2 lattice (1.26 cm pitch) + FSR decomposition for an asymmetrical 2x2 lattice (1.26 cm pitch) -Geometry cells can also be subdivided into small source regions by assigning a -mesh to a list of domains, with each domain being of type -:class:`openmc.Material`, :class:`openmc.Cell`, or :class:`openmc.Universe`. The -idea of defining a source region as a combination of a base geometry cell and a -mesh element is known as "cell-under-voxel" style geometry, although in OpenMC -the mesh can be any kind and is not restricted to 3D regular voxels. An example -of overlaying a simple 2D mesh over a geometry is given as:: - - sr_mesh = openmc.RegularMesh() - sr_mesh.dimension = (n, n) - sr_mesh.lower_left = (0.0, 0.0) - sr_mesh.upper_right = (x, y) - domain = geometry.root_universe - settings.random_ray['source_region_meshes'] = [(sr_mesh, [domain])] - -In the above example, we apply a single :math:`n \times n` uniform mesh over the -entire domain by assigning it to the root universe of the geometry. -Alternatively, we might want to apply a finer or coarser mesh to different -regions of a 3D problem, for instance, as:: - - fuel = openmc.Material(name='UO2 fuel') - ... - water = openmc.Material(name='hot borated water') - ... - clad = openmc.Material(name='Zr cladding') - ... - - coarse_mesh = openmc.RegularMesh() - coarse_mesh.dimension = (n, n, n) - coarse_mesh.lower_left = (0.0, 0.0, 0.0) - coarse_mesh.upper_right = (x, y, z) - - fine_mesh = openmc.RegularMesh() - fine_mesh.dimension = (2*n, 2*n, 2*n) - fine_mesh.lower_left = (0.0, 0.0, 0.0) - fine_mesh.upper_right = (x, y, z) - - settings.random_ray['source_region_meshes'] = [(fine_mesh, [fuel, clad]), (coarse_mesh, [water])] - -Note that we don't need to adjust the outer bounds of the mesh to tightly wrap -the domain we assign the mesh to. Rather, OpenMC will dynamically generate -source regions based on the mesh bins rays actually visit, such that no -additional memory is wasted even if a domain only intersects a few mesh bins. -Going back to our 2x2 lattice example, if using a mesh-based subdivision, this -might look as below: - -.. figure:: ../_images/2x2_sr_mesh.png - :class: with-border - :width: 400 - - 20x20 overlaid "cell-under-voxel" mesh decomposition for an asymmetrical 2x2 lattice (1.26 cm pitch) - -Note that mesh-bashed subdivision is much easier for a user to implement but -does have a few downsides compared to manual subdivision. Manual subdivision can -be done with the specifics of the geometry in mind. As in the pincell example, -it is more efficient to subdivide the fuel region into azimuthal sectors and -radial rings as opposed to a Cartesian mesh. This is more efficient because the -regions are a more uniform size and follow the material boundaries closer, -resulting in the need for fewer source regions. Fewer source regions tends to -equate to a faster computational speed and/or the need for fewer rays per batch -to achieve good statistics. Additionally, applying a mesh often tends to create -a few very small source regions, as shown in the above picture where corners of -the mesh happen to intersect close to the actual fuel-moderator interface. These -small regions are rarely visited by rays, which can result in inaccurate -estimates of the source within those small regions and, thereby, numerical -instability. However, OpenMC utilizes several techniques to detect these small -source regions and mitigate instabilities that are associated with them. In -conclusion, mesh overlay is a great way to subdivide any geometry into smaller -source regions. It can be used while retaining stability, though typically at -the cost of generating more source regions relative to an optimal manual -subdivision. - -.. _usersguide_flux_norm: +In the future, automated subdivision of FSRs via mesh overlay may be supported. ------- Tallies @@ -513,7 +338,6 @@ Supported scores: - total - fission - nu-fission - - kappa-fission - events Supported Estimators: @@ -532,25 +356,6 @@ Note that there is no difference between the analog, tracklength, and collision estimators in random ray mode as individual particles are not being simulated. Tracklength-style tally estimation is inherent to the random ray method. -As discussed in the random ray theory section on :ref:`Random Ray -Tallies`, by default flux tallies in the random ray mode -are not normalized by the spatial tally volumes such that flux tallies are in -units of cm. While the volume information is readily available as a byproduct of -random ray integration, the flux value is reported in unnormalized units of cm -so that the user will be able to compare "apples to apples" with the default -flux tallies from the Monte Carlo solver (also reported by default in units of -cm). If volume normalized flux tallies (in units of cm\ :sup:`-2`) are desired, -then the user can set the ``volume_normalized_flux_tallies`` field in the -:attr:`openmc.Settings.random_ray` dictionary to ``True``. An example is given -below: - -:: - - settings.random_ray['volume_normalized_flux_tallies'] = True - -Note that MC mode flux tallies can also be normalized by volume, as discussed in -the :ref:`Volume Calculation Section` of the user guide. - -------- Plotting -------- @@ -598,11 +403,10 @@ Inputting Multigroup Cross Sections (MGXS) Multigroup cross sections for use with OpenMC's random ray solver are input the same way as with OpenMC's traditional multigroup Monte Carlo mode. There is more information on generating multigroup cross sections via OpenMC in the -:ref:`multigroup materials ` user guide. You may also wish to use -an existing ``mgxs.h5`` MGXS library file, or define your own given a known set -of cross section data values (e.g., as taken from a benchmark specification). An -example of using OpenMC's Python interface to generate a correctly formatted -``mgxs.h5`` input file is given in the `OpenMC Jupyter notebook collection +:ref:`multigroup materials ` user guide. You may also wish to +use an existing multigroup library. An example of using OpenMC's Python +interface to generate a correctly formatted ``mgxs.h5`` input file is given +in the `OpenMC Jupyter notebook collection `_. .. note:: @@ -611,391 +415,6 @@ example of using OpenMC's Python interface to generate a correctly formatted separate materials can be defined each with a separate multigroup dataset corresponding to a given temperature. -.. _mgxs_gen: - -------------------------------------------- -Generating Multigroup Cross Sections (MGXS) -------------------------------------------- - -OpenMC is capable of generating multigroup cross sections by way of flux -collapsing data based on flux solutions obtained from a continuous energy Monte -Carlo solve. While it is a circular excercise in some respects to use continuous -energy Monte Carlo to generate cross sections to be used by a reduced-fidelity -multigroup transport solver, there are many use cases where this is nonetheless -highly desirable. For instance, generation of a multigroup library may enable -the same set of approximate multigroup cross section data to be used across a -variety of problem types (or through a multidimensional parameter sweep of -design variables) with only modest errors and at greatly reduced cost as -compared to using only continuous energy Monte Carlo. - -~~~~~~~~~~~~ -The Easy Way -~~~~~~~~~~~~ - -The easiest way to generate a multigroup cross section library is to use the -:meth:`openmc.Model.convert_to_multigroup` method. This method will -automatically output a multigroup cross section library file (``mgxs.h5``) from -a continuous energy Monte Carlo model and alter the material definitions in the -model to use these multigroup cross sections. An example is given below:: - - # Assume we already have a working continuous energy model - model.convert_to_multigroup( - method="material_wise", - groups="CASMO-2", - overwrite_mgxs_library=False, - mgxs_path="mgxs.h5", - correction=None, - source_energy=None, - temperatures=None - ) - -The most important parameter to set is the ``method`` parameter, which can be -either "stochastic_slab", "material_wise", or "infinite_medium". An overview -of these methods is given below: - -.. list-table:: Comparison of Automatic MGXS Generation Methods - :header-rows: 1 - :widths: 10 30 30 30 - - * - Method - - Description - - Pros - - Cons - * - ``material_wise`` (default) - - * Higher Fidelity - * Runs a CE simulation with the original geometry and source, tallying - cross sections with a material filter. - - * Typically the most accurate of the three methods - * Accurately captures (averaged over the full problem domain) - both spatial and resonance self shielding effects - - * Potentially slower as the full geometry must be run - * If a material is only present far from the source and doesn't get tallied - to in the CE simulation, the MGXS will be zero for that material. This - can be mitigated by supplying weight windows via ``weight_windows_file`` - (see :ref:`mgxs_bootstrap`). - * - ``stochastic_slab`` - - * Medium Fidelity - * Runs a CE simulation with a greatly simplified geometry, where materials - are randomly assigned to layers in a 1D "stochastic slab sandwich" geometry - - * Still captures resonant self shielding and resonance effects between materials - * Fast due to the simplified geometry - * Able to produce cross section data for all materials, regardless of how - far they are from the source in the original geometry - - * Does not capture most spatial self shielding effects, e.g., no lattice physics. - * - ``infinite_medium`` - - * Lower Fidelity - * Runs one CE simulation per material independently. Each simulation is just - an infinite medium slowing down problem, with an assumed external source term. - - * Simple - - * Poor accuracy (no spatial information, no lattice physics, no resonance effects - between materials) - * May hang if a material has a k-infinity greater than 1.0 - -When selecting a non-default energy group structure, you can manually define -group boundaries or specify the name of a known group structure (a list of which -can be found at :data:`openmc.mgxs.GROUP_STRUCTURES`). The ``correction`` -parameter can be set to ``"P0"`` to enable P0 transport correction. The -``overwrite_mgxs_library`` parameter can be set to ``True`` to overwrite an -existing MGXS library file, or ``False`` to skip generation and use an existing -library file. - -The continuous energy simulations used to generate the cross section library -can be customized by passing :class:`openmc.Settings` attributes as keyword -arguments; only the fields you set override the generation defaults. For -example, the number of particles per batch (2,000 by default) can be -increased to improve the fidelity of the generated cross section library -as:: - - model.convert_to_multigroup(particles=100_000) - -.. note:: - MGXS transport correction (via setting the ``correction`` parameter in the - :meth:`openmc.Model.convert_to_multigroup` method to ``"P0"``) may - result in negative in-group scattering cross sections, which can cause - numerical instability. To mitigate this, during a random ray solve OpenMC - will automatically apply - `diagonal stabilization `_ - with a :math:`\rho` default value of 1.0, which can be adjusted with the - ``settings.random_ray['diagonal_stabilization_rho']`` parameter. - -When generating MGXS data with either the ``stochastic_slab`` or -``infinite_medium`` methods, by default the simulation will use a uniform source -distribution spread evenly over all energy groups. This ensures that all energy -groups receive tallies and therefore produce non-zero total multigroup cross -sections. Additionally, the function will convert any sources in the model into -simplified spatial sources that retain the original energy distributions. If -sources are present, they will be used 99% of the time to sample source energies -during MGXS generation. The other 1% of the time, energies will be sampled -uniformly over all energy groups to ensure that all groups receive some tallies. -However, the user may wish to specify a different source energy spectrum (for -instance, if they are using a FileSource, such that the energy distribution -cannot be extracted from the python source object). This can be done by -providing a :class:`openmc.stats.Univariate` distribution as the -``source_energy`` parameter of the :meth:`openmc.Model.convert_to_multigroup` -method. If provided, it will override any sources present in the model and will -be used 99% of the time to sample source energies during MGXS generation. The -other 1% of the time, energies will be sampled uniformly over all energy groups -to ensure that all groups receive some tallies. - -For instance, a D-D fusion simulation may involve a complex file source. In this -case, the user may wish to provide a discrete 2.45 MeV energy source -distribution for MGXS generation as:: - - source_energy = openmc.stats.delta_function(2.45e6) - -The ``temperatures`` parameter can be provided if temperature-dependent -multi-group cross sections are desired for multi-physics simulations. An -individual cross section generation calculation is run for each temperature -provided, where the materials in the model are set to the temperature. The -temperature settings used during cross section generation default to those -contained in the model and can be customized with the ``temperature`` keyword -argument to :meth:`openmc.Model.convert_to_multigroup`. This approach yields -isothermal cross section interpolation tables, which can be inaccurate for -systems with large differences between temperatures in each material (often the -case in fission reactors). If a more sophisticated temperature-dependence is -required, we recommend generating cross sections manually. - -Ultimately, the methods described above are all just approximations. -Approximations in the generated MGXS data will fundamentally limit the potential -accuracy of the random ray solver. However, the methods described above are all -useful in that they can provide a good starting point for a random ray -simulation, and if more fidelity is needed the user may wish to follow the -instructions below or experiment with transport correction techniques to improve -the fidelity of the generated MGXS data. - -.. _mgxs_bootstrap: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Bootstrapping Material-Wise MGXS with Weight Windows -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The ``"material_wise"`` method runs a continuous energy simulation of the -original geometry, so it produces the highest fidelity cross sections of the -three methods. However, it has a notable weakness: if a material only appears -far from the source (for example, a detector or structural material located -outside a thick shield), an analog continuous energy simulation may be unable to -transport any particles to that material. No tallies are scored there, and the -resulting cross sections for that material are zero. This situation is common in -shielding problems. - -This limitation can be overcome by "bootstrapping" the cross section generation -with weight windows. The idea is to first cheaply produce a set of weight -windows that cover the entire problem and then reuse them to push particles into -the far regions during the higher fidelity ``"material_wise"`` solve. The weight -windows are generated using the ``"stochastic_slab"`` method (which produces -cross sections for *all* materials regardless of their location) together with -the random ray solver and a :class:`~openmc.WeightWindowGenerator`, exactly as -described in the :ref:`FW-CADIS user guide `. The resulting -``weight_windows.h5`` file is then supplied to a second, higher fidelity -``"material_wise"`` cross section generation by passing -``weight_windows_file``:: - - # First, generate weight windows with the stochastic slab method and random - # ray (see the FW-CADIS user guide), producing a weight_windows.h5 file. - ... - - # Then, bootstrap a higher fidelity material-wise library, applying those - # weight windows during the continuous energy solve so that particles can - # reach materials far from the source. - model.convert_to_multigroup( - weight_windows_file="weight_windows.h5", overwrite_mgxs_library=True) - -The ``weight_windows_file`` setting is only used with the -``"material_wise"`` method, as the ``"stochastic_slab"`` and -``"infinite_medium"`` methods use simplified surrogate geometries that are -incompatible with a weight window mesh defined over the original geometry (and -do not need weight windows, since they already tally all materials). A warning -is issued and the file is ignored if it is supplied to another method. - -~~~~~~~~~~~~ -The Hard Way -~~~~~~~~~~~~ - -We give here a quick summary of how to produce a multigroup cross section data -file (``mgxs.h5``) from a starting point of a typical continuous energy Monte -Carlo model. Notably, continuous energy models define materials as a mixture of -nuclides with different densities, whereas multigroup materials are simply -defined by which name they correspond to in a ``mgxs.h5`` library file. - -To generate the cross section data, we begin with a continuous energy Monte -Carlo model and add in the tallies that are needed to generate our library. In -this example, we will specify material-wise cross sections and a two-group -energy decomposition:: - - # Define geometry - ... - geometry = openmc.Geometry() - ... - - # Initialize MGXS library with a finished OpenMC geometry object - mgxs_lib = openmc.mgxs.Library(geometry) - - # Pick energy group structure - groups = openmc.mgxs.EnergyGroups('CASMO-2') - mgxs_lib.energy_groups = groups - - # Disable transport correction - mgxs_lib.correction = None - - # Specify needed cross sections for random ray - mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission', 'fission', - 'nu-scatter matrix', 'multiplicity matrix', 'chi'] - - # Specify a "cell" domain type for the cross section tally filters - mgxs_lib.domain_type = "material" - - # Specify the cell domains over which to compute multi-group cross sections - mgxs_lib.domains = geometry.get_all_materials().values() - - # Do not compute cross sections on a nuclide-by-nuclide basis - mgxs_lib.by_nuclide = False - - # Check the library - if no errors are raised, then the library is satisfactory. - mgxs_lib.check_library_for_openmc_mgxs() - - # Construct all tallies needed for the multi-group cross section library - mgxs_lib.build_library() - - # Create a "tallies.xml" file for the MGXS Library - tallies = openmc.Tallies() - mgxs_lib.add_to_tallies(tallies, merge=True) - - # Export - tallies.export_to_xml() - - ... - -When selecting an energy decomposition, you can manually define group boundaries -or specify the name of known group structure (a list of which can be found at -:data:`openmc.mgxs.GROUP_STRUCTURES`). Once the above model has been run, the -resulting statepoint file will contain the needed flux and reaction rate tally -data so that a MGXS library file can be generated. Below is the postprocessing -script needed to generate the ``mgxs.h5`` library file given a statepoint file -(e.g., ``statepoint.100.h5``) file and summary file (e.g., ``summary.h5``) that -resulted from running our previous example:: - - import openmc - - summary = openmc.Summary('summary.h5') - geom = summary.geometry - mats = summary.materials - - groups = openmc.mgxs.EnergyGroups('CASMO-2') - mgxs_lib = openmc.mgxs.Library(geom) - mgxs_lib.energy_groups = groups - mgxs_lib.correction = None - mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission', 'fission', - 'nu-scatter matrix', 'multiplicity matrix', 'chi'] - - # Specify a "cell" domain type for the cross section tally filters - mgxs_lib.domain_type = "material" - - # Specify the cell domains over which to compute multi-group cross sections - mgxs_lib.domains = geom.get_all_materials().values() - - # Do not compute cross sections on a nuclide-by-nuclide basis - mgxs_lib.by_nuclide = False - - # Check the library - if no errors are raised, then the library is satisfactory. - mgxs_lib.check_library_for_openmc_mgxs() - - # Construct all tallies needed for the multi-group cross section library - mgxs_lib.build_library() - - with openmc.StatePoint('statepoint.100.h5') as sp: - mgxs_lib.load_from_statepoint(sp) - - names = [mat.name for mat in mgxs_lib.domains] - - # Create a MGXS File which can then be written to disk - mgxs_file = mgxs_lib.create_mg_library(xs_type='macro', xsdata_names=names) - - # Write the file to disk using the default filename of "mgxs.h5" - mgxs_file.export_to_hdf5("mgxs.h5") - -Notably, the postprocessing script needs to match the same -:class:`openmc.mgxs.Library` settings that were used to generate the tallies but -is otherwise able to discern the rest of the simulation details from the -statepoint and summary files. Once the postprocessing script is successfully -run, the ``mgxs.h5`` file can be loaded by subsequent runs of OpenMC. - -If you want to convert continuous energy material objects in an OpenMC input -deck to multigroup ones from a ``mgxs.h5`` library, you can follow the below -example. Here we begin with the original continuous energy materials we used to -generate our MGXS library:: - - fuel = openmc.Material(name='UO2 (2.4%)') - fuel.set_density('g/cm3', 10.29769) - fuel.add_nuclide('U234', 4.4843e-6) - fuel.add_nuclide('U235', 5.5815e-4) - fuel.add_nuclide('U238', 2.2408e-2) - fuel.add_nuclide('O16', 4.5829e-2) - - water = openmc.Material(name='Hot borated water') - water.set_density('g/cm3', 0.740582) - water.add_nuclide('H1', 4.9457e-2) - water.add_nuclide('O16', 2.4672e-2) - water.add_nuclide('B10', 8.0042e-6) - water.add_nuclide('B11', 3.2218e-5) - water.add_s_alpha_beta('c_H_in_H2O') - - materials = openmc.Materials([fuel, water]) - -Once the ``mgxs.h5`` library file has been generated, we can then manually make -the necessary edits to the material definitions so that they load from the -multigroup library instead of defining their isotopic contents, as:: - - # Instantiate some Macroscopic Data - fuel_data = openmc.Macroscopic('UO2 (2.4%)') - water_data = openmc.Macroscopic('Hot borated water') - - # Instantiate some Materials and register the appropriate Macroscopic objects - fuel = openmc.Material(name='UO2 (2.4%)') - fuel.set_density('macro', 1.0) - fuel.add_macroscopic(fuel_data) - - water = openmc.Material(name='Hot borated water') - water.set_density('macro', 1.0) - water.add_macroscopic(water_data) - - # Instantiate a Materials collection and export to XML - materials = openmc.Materials([fuel, water]) - materials.cross_sections = "mgxs.h5" - -In the above example, our ``fuel`` and ``water`` materials will now load MGXS -data from the ``mgxs.h5`` file instead of loading continuous energy isotopic -cross section data. - --------------- -Linear Sources --------------- - -Linear Sources (LS), are supported with the eigenvalue and fixed source random -ray solvers. General 3D LS can be toggled by setting the ``source_shape`` field -in the :attr:`openmc.Settings.random_ray` dictionary to ``'linear'`` as:: - - settings.random_ray['source_shape'] = 'linear' - -LS enables the use of coarser mesh discretizations and lower ray populations, -offsetting the increased computation per ray. - -While OpenMC has no specific mode for 2D simulations, such simulations can be -performed implicitly by leaving one of the dimensions of the geometry unbounded -or by imposing reflective boundary conditions with no variation in between them -in that dimension. When 3D linear sources are used in a 2D random ray -simulation, the extremely long (or potentially infinite) spatial dimension along -one of the axes can cause the linear source to become noisy, leading to -potentially large increases in variance. To mitigate this, the user can force -the z-terms of the linear source to zero by setting the ``source_shape`` field -as:: - - settings.random_ray['source_shape'] = 'linear_xy' - -which will greatly improve the quality of the linear source term in 2D -simulations. - -.. _usersguide_random_ray_run_modes: - --------------------------------- Fixed Source and Eigenvalue Modes --------------------------------- @@ -1014,12 +433,9 @@ Monte Carlo solver. Currently, all of the following conditions must be met for the particle source to be valid in random ray mode: -- Either a point source must be used, or a domain constraint must be specified - that indicates which cells, universes, or materials the source applies to. In - either case, this implicitly limits the source type to being volumetric, as - even in the point source case the source will be "smeared" throughout the - source region that contains the point source coordinate. A source domain is - specified via the ``domains`` constraint placed on the +- One or more domain ids must be specified that indicate which cells, universes, + or materials the source applies to. This implicitly limits the source type to + being volumetric. This is specified via the ``domains`` constraint placed on the :class:`openmc.IndependentSource` Python class. - The source must be isotropic (default for a source) - The source must use a discrete (i.e., multigroup) energy distribution. The @@ -1059,119 +475,6 @@ points of 1.0e-2 and 1.0e1. # Add fixed source and ray sampling source to settings file settings.source = [neutron_source] -.. _usersguide_vol_estimators: - ------------------------------ -Alternative Volume Estimators ------------------------------ - -As discussed in the random ray theory section on :ref:`volume estimators -`, there are several possible derivations for the scalar -flux estimate. These options deal with different ways of treating the -accumulation over ray lengths crossing each FSR (a quantity directly -proportional to volume), which can be computed using several methods. The -following methods are currently available in OpenMC: - -.. list-table:: Comparison of Estimators - :header-rows: 1 - :widths: 10 30 30 30 - - * - Estimator - - Description - - Pros - - Cons - * - ``simulation_averaged`` - - Accumulates total active ray lengths in each FSR over all iterations, - improving the estimate of the volume in each cell each iteration. - - * Virtually unbiased after several iterations - * Asymptotically approaches the true analytical volume - * Typically most efficient in terms of speed vs. accuracy - - * Higher variance - * Can lead to negative fluxes and numerical instability in pathological - cases - * - ``naive`` - - Treats the volume as composed only of the active ray length through each - FSR per iteration, being a biased but numerically consistent ratio - estimator. - - * Low variance - * Unlikely to result in negative fluxes - * Recommended in cases where the simulation averaged estimator is - unstable - - * Biased estimator - * Requires more rays or longer active ray length to mitigate bias - * - ``hybrid`` (default) - - Applies the naive estimator to all cells that contain an external (fixed) - source contribution. Applies the simulation averaged estimator to all - other cells. - - * High accuracy/low bias of the simulation averaged estimator in most - cells - * Stability of the naive estimator in cells with fixed sources - - * Can lead to slightly negative fluxes in cells where the simulation - averaged estimator is used - -These estimators can be selected by setting the ``volume_estimator`` field in the -:attr:`openmc.Settings.random_ray` dictionary. For example, to use the naive -estimator, the following code would be used: - -:: - - settings.random_ray['volume_estimator'] = 'naive' - ------------------ -Adjoint Flux Mode ------------------ - -The adjoint flux random ray solver mode can be enabled as:: - - settings.random_ray['adjoint'] = True - -When enabled, OpenMC will first run a forward transport simulation if there are -no user-specified adjoint sources present, followed by an adjoint transport -simulation. Fixed adjoint sources can be specified on the -:attr:`openmc.Settings.random_ray` dictionary as follows:: - - # Geometry definition - ... - detector_cell = openmc.Cell(fill=detector_mat, name='cell where detector will be') - ... - # Define fixed adjoint neutron source - strengths = [1.0] - midpoints = [1.0e-4] - energy_distribution = openmc.stats.Discrete(x=midpoints, p=strengths) - - adj_source = openmc.IndependentSource( - energy=energy_distribution, - constraints={'domains': [detector_cell]} - ) - - # Add to random_ray dict - settings.random_ray['adjoint_source'] = adj_source - -The same constraints apply to the user-defined adjoint source as to the forward -source, described in the :ref:`Fixed Source and Eigenvalue section -`. If this source is not provided, a forward -solve must take place to compute the adjoint external source when a forward -external source is present in the problem. Simulation settings (e.g., number of -rays, batches, etc.) will be identical for both calculations. At the -conclusion of the run, all results (e.g., tallies, plots, etc.) will be -derived from the adjoint flux rather than the forward flux but are not labeled -any differently. When an initial forward solve is performed (i.e., when no -user-specified adjoint source is present), its output files are also written to -disk with a ``forward`` infix, so they are not overwritten by the subsequent -adjoint solve. This applies to the statepoint, ``tallies.out``, and any voxel -plots, e.g., ``statepoint.forward.N.h5`` and ``tallies.forward.out``; the -adjoint solve keeps the usual file names. This allows analyses requiring both -the forward and adjoint solutions to be performed from a single run. When -generating FW-CADIS weight windows, no weight window file is written for the -forward solve, as only the final adjoint-derived weight windows are meaningful. - -.. note:: - Use of the automated - :ref:`FW-CADIS weight window generator` is not - currently compatible with user-defined adjoint sources. Instead, the - initial forward calculation is used to assign "forward-weighted" adjoint - sources to the tally regions of interest. - --------------------------------------- Putting it All Together: Example Inputs --------------------------------------- @@ -1230,10 +533,11 @@ given below: tallies.export_to_xml() # Create voxel plot - plot = openmc.VoxelPlot() + plot = openmc.Plot() plot.origin = [0, 0, 0] plot.width = [2*pitch, 2*pitch, 1] plot.pixels = [1000, 1000, 1] + plot.type = 'voxel' # Instantiate a Plots collection and export to XML plots = openmc.Plots([plot]) @@ -1313,10 +617,11 @@ given below: tallies.export_to_xml() # Create voxel plot - plot = openmc.VoxelPlot() + plot = openmc.Plot() plot.origin = [0, 0, 0] plot.width = [2*pitch, 2*pitch, 1] plot.pixels = [1000, 1000, 1] + plot.type = 'voxel' # Instantiate a Plots collection and export to XML plots = openmc.Plots([plot]) diff --git a/docs/source/usersguide/scripts.rst b/docs/source/usersguide/scripts.rst index eb0abeb0d..78ee6f775 100644 --- a/docs/source/usersguide/scripts.rst +++ b/docs/source/usersguide/scripts.rst @@ -48,9 +48,147 @@ flags: restart file -s, --threads N Run with *N* OpenMP threads -t, --track Write tracks for all particles (up to max_tracks) --q, --verbosity V Set the output verbosity to *V* -v, --version Show version information -h, --help Show help message .. note:: If you're using the Python API, :func:`openmc.run` is equivalent to running ``openmc`` from the command line. + +.. _scripts_ace: + +---------------------- +``openmc-ace-to-hdf5`` +---------------------- + +This script can be used to create HDF5 nuclear data libraries used by OpenMC if +you have existing ACE files. There are four different ways you can specify ACE +libraries that are to be converted: + +1. List each ACE library as a positional argument. This is very useful in + conjunction with the usual shell utilities (``ls``, ``find``, etc.). +2. Use the ``--xml`` option to specify a pre-v0.9 cross_sections.xml file. +3. Use the ``--xsdir`` option to specify a MCNP xsdir file. +4. Use the ``--xsdata`` option to specify a Serpent xsdata file. + +The script does not use any extra information from cross_sections.xml/ xsdir/ +xsdata files to determine whether the nuclide is metastable. Instead, the +``--metastable`` argument can be used to specify whether the ZAID naming convention +follows the NNDC data convention (1000*Z + A + 300 + 100*m), or the MCNP data +convention (essentially the same as NNDC, except that the first metastable state +of Am242 is 95242 and the ground state is 95642). + +The optional ``--fission_energy_release`` argument will accept an HDF5 file +containing a library of fission energy release (ENDF MF=1 MT=458) data. A +library built from ENDF/B-VII.1 data is released with OpenMC and can be found at +openmc/data/fission_Q_data_endb71.h5. This data is necessary for +'fission-q-prompt' and 'fission-q-recoverable' tallies, but is not needed +otherwise. + +-h, --help show help message and exit + +-d DESTINATION, --destination DESTINATION + Directory to create new library in + +-m META, --metastable META + How to interpret ZAIDs for metastable nuclides. META + can be either 'nndc' or 'mcnp'. (default: nndc) + +--xml XML Old-style cross_sections.xml that lists ACE libraries + +--xsdir XSDIR MCNP xsdir file that lists ACE libraries + +--xsdata XSDATA Serpent xsdata file that lists ACE libraries + +--fission_energy_release FISSION_ENERGY_RELEASE + HDF5 file containing fission energy release data + +.. _scripts_plot: + +-------------------------- +``openmc-plot-mesh-tally`` +-------------------------- + +``openmc-plot-mesh-tally`` provides a graphical user interface for plotting mesh +tallies. The path to the statepoint file can be provided as an optional arugment +(if omitted, a file dialog will be presented). + +.. _scripts_track_combine: + +------------------------ +``openmc-track-combine`` +------------------------ + +This script combines multiple HDF5 :ref:`particle track files +` into a single HDF5 particle track file. The filenames of the +particle track files should be given as posititional arguments. The output +filename can also be changed with the ``-o`` flag: + +-o OUT, --out OUT Output HDF5 particle track file + +.. _scripts_track: + +----------------------- +``openmc-track-to-vtk`` +----------------------- + +This script converts HDF5 :ref:`particle track files ` to VTK +poly data that can be viewed with ParaView or VisIt. The filenames of the +particle track files should be given as posititional arguments. The output +filename can also be changed with the ``-o`` flag: + +-o OUT, --out OUT Output VTK poly filename + +------------------------ +``openmc-update-inputs`` +------------------------ + +If you have existing XML files that worked in a previous version of OpenMC that +no longer work with the current version, you can try to update these files using +``openmc-update-inputs``. If any of the given files do not match the most +up-to-date formatting, then they will be automatically rewritten. The old +out-of-date files will not be deleted; they will be moved to a new file with +'.original' appended to their name. + +Formatting changes that will be made: + +geometry.xml + Lattices containing 'outside' attributes/tags will be replaced with lattices + containing 'outer' attributes, and the appropriate cells/universes will be + added. Any 'surfaces' attributes/elements on a cell will be renamed 'region'. + +materials.xml + Nuclide names will be changed from ACE aliases (e.g., Am-242m) to HDF5/GNDS + names (e.g., Am242_m1). Thermal scattering table names will be changed from + ACE aliases (e.g., HH2O) to HDF5/GNDS names (e.g., c_H_in_H2O). + +---------------------- +``openmc-update-mgxs`` +---------------------- + +This script updates OpenMC's deprecated multi-group cross section XML files to +the latest HDF5-based format. + +-i IN, --input IN Input XML file +-o OUT, --output OUT Output file in HDF5 format + +.. _scripts_voxel: + +--------------------------- +``openmc-voxel-to-vtk`` +--------------------------- + +When OpenMC generates :ref:`voxel plots `, they are in an +:ref:`HDF5 format ` that is not terribly useful by itself. The +``openmc-voxel-to-vtk`` script converts a voxel HDF5 file to a `VTK +`_ file. To run this script, you will need to have the VTK +Python bindings installed. To convert a voxel file, simply provide the path to +the file: + +.. code-block:: sh + + openmc-voxel-to-vtk voxel_1.h5 + +The ``openmc-voxel-to-vtk`` script also takes the following optional +command-line arguments: + +-o, --output Path to output VTK file diff --git a/docs/source/usersguide/settings.rst b/docs/source/usersguide/settings.rst index 6faeb59e1..d73d90cbb 100644 --- a/docs/source/usersguide/settings.rst +++ b/docs/source/usersguide/settings.rst @@ -183,7 +183,6 @@ source distributions and has four main attributes that one can set: :attr:`IndependentSource.energy`, which defines the energy distribution, and :attr:`IndependentSource.time`, which defines the time distribution. - The spatial distribution can be set equal to a sub-class of :class:`openmc.stats.Spatial`; common choices are :class:`openmc.stats.Point` or :class:`openmc.stats.Box`. To independently specify distributions in the @@ -193,9 +192,7 @@ distributions using spherical or cylindrical coordinates, you can use :class:`openmc.stats.SphericalIndependent` or :class:`openmc.stats.CylindricalIndependent`, respectively. Meshes can also be used to represent spatial distributions with :class:`openmc.stats.MeshSpatial` -by specifying a mesh and source strengths for each mesh element. It is also -possible to define a "cloud" of source points, each with a different relative -probability, using :class:`openmc.stats.PointCloud`. +by specifying a mesh and source strengths for each mesh element. The angular distribution can be set equal to a sub-class of :class:`openmc.stats.UnitSphere` such as :class:`openmc.stats.Isotropic`, @@ -226,7 +223,6 @@ distribution. This could be a probability mass function (:class:`openmc.stats.Tabular`). By default, if no time distribution is specified, particles are started at :math:`t=0`. - As an example, to create an isotropic, 10 MeV monoenergetic source uniformly distributed over a cube centered at the origin with an edge length of 10 cm, and emitting a pulse of particles from 0 to 10 µs, one @@ -254,30 +250,6 @@ sampled 70% of the time and another that should be sampled 30% of the time:: settings.source = [src1, src2] -When the relative strengths are several orders of magnitude different, it may -happen that not enough statistics are obtained from the lower strength source. -This can be improved by sampling among the sources with equal probability, -applying the source strength as a weight on the sampled source particles. The -:attr:`Settings.uniform_source_sampling` attribute can be used to enable this -option:: - - src1 = openmc.IndependentSource() - src1.strength = 100.0 - ... - - src2 = openmc.IndependentSource() - src2.strength = 1.0 - ... - - settings.source = [src1, src2] - settings.uniform_source_sampling = True - -Additionally, sampling from an :class:`openmc.IndependentSource` may be biased -for local or global variance reduction by modifying the -:attr:`~openmc.IndependentSource.bias` attribute of each of its four main -distributions. Further discussion of source biasing can be found in -:ref:`source_biasing`. - Finally, the :attr:`IndependentSource.particle` attribute can be used to indicate the source should be composed of particles other than neutrons. For example, the following would generate a photon source:: @@ -291,53 +263,6 @@ example, the following would generate a photon source:: For a full list of all classes related to statistical distributions, see :ref:`pythonapi_stats`. -Tokamak Plasma Sources ----------------------- - -For fusion applications, the :class:`openmc.TokamakSource` class provides a -native parametric neutron source for tokamak plasmas. Rather than specifying -spatial, angular, and energy distributions separately, the source is defined by -the plasma geometry (using a `Miller-style flux-surface parameterization -`_) and a radial emission profile. Source -sites are sampled directly from the plasma volume without rejection. - -The plasma shape is described by the major radius :math:`R_0`, minor radius -:math:`a`, elongation :math:`\kappa`, triangularity :math:`\delta`, and -Shafranov shift :math:`\Delta`. The neutron birth profile is given as an -emission density :math:`S(r/a)` tabulated on a normalized minor-radius grid that -runs from 0 (magnetic axis) to 1 (last closed flux surface); only the shape of -the profile matters, since it is normalized internally. The emission density is -linearly interpolated between the supplied points and refined internally for -radial sampling. For example:: - - import numpy as np - - r_over_a = np.linspace(0.0, 1.0, 50) - emission = (1.0 - r_over_a**2)**2 # peaked on-axis profile - - source = openmc.TokamakSource( - major_radius=620.0, # cm - minor_radius=200.0, # cm - elongation=1.8, - triangularity=0.45, - shafranov_shift=10.0, # cm - r_over_a=r_over_a, - emission_density=emission, - energy=openmc.stats.muir(e0=14.08e6, m_rat=5.0, kt=20000.0), - ) - - settings.source = source - -The ``energy`` argument accepts either a single -:class:`~openmc.stats.Univariate` distribution applied at all radii, or a -sequence with one distribution per ``r_over_a`` grid point to model a -radially-varying neutron spectrum (energies are then sampled by stochastic -interpolation between the two distributions bracketing the sampled radius). A -time distribution can be given with the ``time`` argument; by default, particles -are born at :math:`t=0`. The toroidal extent can be restricted with -``phi_start`` and ``phi_extent`` to model a sector of the plasma, and -``vertical_shift`` translates the plasma center along the z-axis. - File-based Sources ------------------ @@ -411,17 +336,6 @@ or particles going to a cell:: .. note:: The ``cell``, ``cellfrom`` and ``cellto`` attributes cannot be used simultaneously. -To generate more than one surface source files when the maximum number of stored -particles is reached, ``max_source_files`` is available. The surface source bank -will be cleared in simulation memory each time a surface source file is written. -As an example, to write a maximum of three surface source files::: - - settings.surf_source_write = { - 'surfaces_ids': [1, 2, 3], - 'max_particles': 10000, - 'max_source_files': 3 - } - .. _compiled_source: Compiled Sources @@ -447,7 +361,7 @@ below. { openmc::SourceSite particle; // weight - particle.particle = openmc::ParticleType::neutron(); + particle.particle = openmc::ParticleType::neutron; particle.wgt = 1.0; // position double angle = 2.0 * M_PI * openmc::prn(seed); @@ -524,7 +438,7 @@ parameters to the source class when it is created: { openmc::SourceSite particle; // weight - particle.particle = openmc::ParticleType::neutron(); + particle.particle = openmc::ParticleType::neutron; particle.wgt = 1.0; // position particle.r.x = 0.0; @@ -651,13 +565,6 @@ transport:: settings.photon_transport = True -Atomic relaxation (the cascade of fluorescence photons and Auger electrons -emitted when an inner-shell vacancy is filled) is enabled by default whenever -photon transport is on. It can be disabled using the -:attr:`Settings.atomic_relaxation` attribute:: - - settings.atomic_relaxation = False - The way in which OpenMC handles secondary charged particles can be specified with the :attr:`Settings.electron_treatment` attribute. By default, the :ref:`thick-target bremsstrahlung ` (TTB) approximation is used to generate @@ -811,71 +718,11 @@ instance, whereas the :meth:`openmc.Track.filter` method returns a new with more than one process, a separate track file will be written for each MPI process with the filename ``tracks_p#.h5`` where # is the rank of the corresponding process. Multiple track files can be - combined with the :meth:`openmc.Tracks.combine` method:: + combined with the :ref:`scripts_track_combine` script: - track_files = [f"tracks_p{rank}.h5" for rank in range(32)] - openmc.Tracks.combine(track_files, "tracks.h5") + .. code-block:: sh -Collision Track File ---------------------- - -OpenMC can generate a collision track file that contains detailed collision -information (position, direction, energy, deposited energy, time, weight, cell -ID, material ID, universe ID, nuclide ZAID, particle type, particle delayed -group and particle ID) for each particle collision depending on user-defined -parameters. To invoke this feature, set the -:attr:`~openmc.Settings.collision_track` attribute as shown in this example:: - - settings.collision_track = { - "max_collisions": 300, - "reactions": ["(n,fission)", "(n,2n)"], - "material_ids": [1,2], - "nuclides": ["U238", "O16"], - "cell_ids": [5, 12] - } - -In this example, collision track information is written to the -collision_track.h5 file at the end of the simulation. The file contains -300 recorded collisions that occurred in materials with IDs 1 or 2, involving -fission or (n,2n) reactions on the nuclides U-238 or O-16, within cells -with IDs 5 and 12. - -.. note:: - Electron and positron collision-track events are not associated with a - specific nuclide. If a ``nuclides`` entry is specified, these events are omitted. - -The file can be read using :func:`openmc.read_collision_track_file`. -The example below shows how to extract the data from the collision_track -feature and displays the fields stored in the file: - ->>> data = openmc.read_collision_track_file('collision_track.h5') ->>> data.dtype - dtype([('r', [('x', '`, MAGIC -is an iterative method that uses flux tally information from a Monte Carlo -simulation to produce weight windows for a user-defined mesh with the objective -of global variance reduction. While generating the weight windows, OpenMC is -capable of applying the weight windows generated from a previous batch while -processing the next batch, allowing for progressive improvement in the weight -window quality across iterations. - -The typical way of generating weight windows is to define a mesh and then add an -:class:`openmc.WeightWindowGenerator` object to an :attr:`openmc.Settings` -instance, as follows:: - - # Define weight window spatial mesh - ww_mesh = openmc.RegularMesh() - ww_mesh.dimension = (10, 10, 10) - ww_mesh.lower_left = (0.0, 0.0, 0.0) - ww_mesh.upper_right = (100.0, 100.0, 100.0) - - # Create weight window object and adjust parameters - wwg = openmc.WeightWindowGenerator( - method='magic', - mesh=ww_mesh, - max_realizations=settings.batches - ) - - # Add generator to Settings instance - settings.weight_window_generators = wwg - -Notably, the :attr:`max_realizations` attribute is adjusted to the number of -batches, such that all iterations are used to refine the weight window -parameters. - -With the :class:`~openmc.WeightWindowGenerator` instance added to the -:attr:`~openmc.Settings`, the rest of the problem can be defined as normal. When -running, note that the second iteration and beyond may be several orders of -magnitude slower than the first. As the weight windows are applied in each -iteration, particles may be aggressively split, resulting in a large number of -secondary (split) particles being generated per initial source particle. This is -not necessarily a bad thing, as the split particles are much more efficient at -exploring low flux regions of phase space as compared to initial particles. -Thus, even though the reported "particles/second" metric of OpenMC may be much -lower when generating (or just applying) weight windows as compared to analog -MC, it typically leads to an overall improvement in the figure of merit -accounting for the reduction in the variance. - -.. warning:: - The number of particles per batch may need to be adjusted downward - significantly to result in reasonable runtimes when weight windows are being - generated or used. - -At the end of the simulation, a ``weight_windows.h5`` file will be saved to disk -for later use. Loading it in another subsequent simulation will be discussed in -the "Using Weight Windows" section below. - -.. _usersguide_fw_cadis: - ----------------------------------------------------------------------- -Generating Global or Local Weight Windows with FW-CADIS and Random Ray ----------------------------------------------------------------------- - -Weight window generation with FW-CADIS and random ray in OpenMC uses the same -exact strategy as with MAGIC. Using FW-CADIS, however, also enables -local variance reduction in fixed source problems through the :attr:`targets` -attribute, which is described later in this section. To enable FW-CADIS, an -:class:`openmc.WeightWindowGenerator` object is added to the -:attr:`openmc.Settings` object, and a ``weight_windows.h5`` will be generated -at the end of the simulation. The only procedural difference is that the code -must be run in random ray mode. A full description of how to enable and setup -random ray mode can be found in the :ref:`Random Ray User Guide `. - -.. note:: - It is a long term goal for OpenMC to be able to generate FW-CADIS weight - windows with only a few tweaks to an existing continuous energy Monte Carlo - input deck. However, at the present time, the workflow requires several - steps to generate multigroup cross section data and to configure the random - ray solver. A high level overview of the current workflow for generation of - weight windows with FW-CADIS using random ray is given below. - -1. Begin by making a deep copy of your continuous energy Python model and then - convert the copy to be multigroup and use the random ray transport solver. - The conversion process can largely be automated as described in more detail - in the :ref:`random ray quick start guide `, summarized below:: - - # Define continuous energy model - ce_model = openmc.pwr_pin_cell() # example, replace with your model - - # Make a copy to convert to multigroup and random ray - model = copy.deepcopy(ce_model) - - # Convert model to multigroup (will auto-generate MGXS library if needed) - model.convert_to_multigroup() - - # Convert model to random ray and initialize random ray parameters - # to reasonable defaults based on the specifics of the geometry - model.convert_to_random_ray() - - # (Optional) Overlay source region decomposition mesh to improve fidelity of the - # random ray solver. Adjust 'n' for fidelity vs runtime. - n = 10 - mesh = openmc.RegularMesh() - mesh.dimension = (n, n, n) - mesh.lower_left = model.geometry.bounding_box.lower_left - mesh.upper_right = model.geometry.bounding_box.upper_right - model.settings.random_ray['source_region_meshes'] = [(mesh, [model.geometry.root_universe])] - - # (Optional) Improve fidelity of the random ray solver by enabling linear sources - model.settings.random_ray['source_shape'] = 'linear' - - # (Optional) Increase the number of rays/batch, to reduce uncertainty - model.settings.particles = 500 - - If you need to improve the fidelity of the MGXS library, there is more - information on generating multigroup cross sections via OpenMC in the - :ref:`random ray MGXS guide `. - -2. Add in a :class:`~openmc.WeightWindowGenerator` in a similar manner as for - MAGIC generation with Monte Carlo and set the :attr:`method` attribute set to - ``"fw_cadis"``:: - - # Create weight window object and adjust parameters, using the same mesh - # we used for source region decomposition - wwg = openmc.WeightWindowGenerator( - method='fw_cadis', - mesh=mesh - ) - - # Add generator to openmc.settings object - settings.weight_window_generators = wwg - -.. warning:: - If using FW-CADIS weight window generation, ensure that the selected weight - window mesh does not subdivide any source regions in the problem. This can - be ensured by using the same mesh for both source region subdivision (i.e., - assigning to ``model.settings.random_ray['source_region_meshes']``) and for - weight window generation. - -3. (Optional) If local variance reduction is desired in a fixed-source problem, - populate the :attr:`targets` attribute with an :class:`openmc.Tallies` - instance or an iterable of tally IDs indicating the tallies of interest for - variance reduction:: - - # Build a new example and WWG for local variance reduction - from openmc.examples import random_ray_three_region_cube_with_detectors - new_model = random_ray_three_region_cube_with_detectors() - - ww_mesh = openmc.RegularMesh() - n = 7 - width = 35.0 - ww_mesh.dimension = (n, n, n) - ww_mesh.lower_left = (0.0, 0.0, 0.0) - ww_mesh.upper_right = (width, width, width) - - wwg = openmc.WeightWindowGenerator( - method="fw_cadis", - mesh=ww_mesh, - max_realizations=new_model.settings.batches - ) - new_model.settings.weight_window_generators = wwg - new_model.settings.random_ray['volume_estimator'] = 'naive' - - # Get the tallies of interest - target_tallies = openmc.Tallies() - - for tally in list(new_model.tallies): - if tally.name in {"Detector 1 Tally", "Detector 2 Tally"}: - target_tallies.append(tally) - - # Add to WeightWindowGenerator - wwg.targets = target_tallies - -.. warning:: - The tallies designated as FW-CADIS targets to the - :class:`~openmc.WeightWindowGenerator` must be present under the - :class:`~openmc.model.Model.tallies` attribute of the - :class:`~openmc.model.Model` as well in order to be recognized as valid - local variance reduction targets. This check is performed when the - :func:`openmc.model.Model.export_to_model_xml` or - :func:`openmc.model.Model.export_to_xml` functions are called, meaning - that the standalone :func:`openmc.Settings.export_to_xml` and - :func:`openmc.Tallies.export_to_xml` methods should not be used with - FW-CADIS local variance reduction. - -4. When running your multigroup random ray input deck, OpenMC will automatically - run a forward solve followed by an adjoint solve, with a - ``weight_windows.h5`` file generated at the end. The ``weight_windows.h5`` - file will contain FW-CADIS generated weight windows. This file can be used in - identical manner as one generated with MAGIC, as described below. - --------------------- -Using Weight Windows --------------------- - -To use a ``weight_windows.h5`` weight window file with OpenMC's Monte Carlo -solver, the Python input just needs to load the h5 file:: - - settings.weight_window_checkpoints = {'collision': True, 'surface': True} - settings.survival_biasing = False - settings.weight_windows_file = "weight_windows.h5" - settings.weight_windows_on = True - -The :class:`~openmc.WeightWindowGenerator` instance is not needed to load an -existing ``weight_windows.h5`` file. Inclusion of a -:class:`~openmc.WeightWindowGenerator` instance will cause OpenMC to generate -*new* weight windows and thus overwrite the existing ``weight_windows.h5`` file. -Weight window mesh information is embedded into the weight window file, so the -mesh does not need to be redefined. Monte Carlo solves that load a weight window -file as above will utilize weight windows to reduce the variance of the -simulation. - -.. _source_biasing: - --------------- -Source Biasing --------------- - -In fixed source problems, source biasing provides a means to reduce the variance -on global or localized responses, depending on the biasing scheme. In either -case, the premise of the method is to sample source sites from a biased -distribution that directs a larger fraction of the simulated histories towards -phase space regions of interest than would be found there under analog sampling. -In order to preserve an unbiased estimate of the tally mean, the weight of these -with analog sampling, divided by the probability assigned by the biased -distribution. While the assignment of statistical weights is outlined in the -:ref:`methods section `, this section demonstrates the -implementation of source biasing to problems in OpenMC. - -Source biasing in OpenMC is accomplished by applying a distribution to the -:attr:`bias` attribute of one or more of the univariate or independent -multivariate distributions which make up an :class:`~openmc.IndependentSource` -instance as follows:: - - # First create the biased distribution - biased_dist = openmc.stats.PowerLaw(a=0, b=3, n=3) - - # Construct a new distribution with the bias applied - dist = openmc.stats.PowerLaw(a=0, b=3, n=2, bias=biased_dist) - - # The bias attribute can also be set on an existing "analog" distribution: - sphere_dist = openmc.stats.spherical_uniform(r_outer=3) - sphere_dist.r.bias = biased_dist - -Univariate distributions may be sampled via the Python API, returning the -sample(s) along with the associated weight(s):: - - sample_vec, wgt_vec = dist.sample(n_samples=100) - -Here, if the distribution is unbiased, the weight of each sample will be unity. -Finally, :class:`~openmc.IndependentSource` instances can be constructed with -biased distributions:: - - # Create a source with a biased spatial distribution - source = openmc.IndependentSource(space=sphere_dist) - -During the simulation, source sites are then sampled using the biased -distributions where available and given starting statistical weights -corresponding to the cumulative product of the weights assigned by each -distribution in the source object. Hence multiple source variables (e.g., -direction and energy) may be biased and the resulting source sites will have -their weights adjusted accordingly. - -.. note:: - Combining source biasing with weight windows can be a powerful variance - reduction technique if each is constructed appropriately for the response - of interest. For example, if a source biasing scheme is devised for - variance reduction of a specific localized response, the user may be able - to specify their own weight window structure that results in more efficient - transport than if weight windows were generated by either of OpenMC's - automatic weight window generators, which are intended for global variance - reduction. - -Biased distributions that could result in degenerate weight mappings are not -recommended; this is most commonly seen when biasing the :math:`\phi`-coordinate -of spherical or cylindrical independent multivariate distributions. In such -cases degenerate behavior will be observed at the pole about which :math:`\phi` -is measured, with all values of :math:`\phi` (hence many possible statistical -weights) mapping to the same point for :math:`r=0` or :math:`\mu=0`, and large -weight gradients in the vicinity. In most cases requiring a spherical -independent source, it would be preferable to reorient the reference vector of -the distribution such that biasing could be applied to the -:math:`\mu`-coordinate instead. - -When biasing a distribution, care should also be taken to ensure that both the -unbiased and biased distribution share a common support---that is, every region -of phase space mapped to a nonzero probability density by the unbiased -distribution should likewise map to nonzero probability under the biased -distribution, and vice versa. In OpenMC, this places restrictions on the set of -compatible distributions that may be used to bias sampling of each distribution -type. The following table summarizes the method for each distribution in OpenMC -that permits biased sampling. - -.. list-table:: **Distributions that support biased sampling** - :header-rows: 1 - :widths: 35 65 - - * - Discrete Univariate PDFs - - Biasing Method - * - :class:`openmc.stats.Discrete` - - Apply a vector of alternative probabilities to the :attr:`bias` - attribute - -.. list-table:: - :header-rows: 1 - :widths: 35 65 - - * - Continuous Univariate PDFs - - Biasing Method - * - :class:`openmc.stats.Uniform`, - :class:`openmc.stats.PowerLaw`, - :class:`openmc.stats.Maxwell`, - :class:`openmc.stats.Watt`, - :class:`openmc.stats.Normal`, - :class:`openmc.stats.Tabular` - - Apply a second, unbiased continous univariate PDF to the :attr:`bias` - attribute, ensuring that the :attr:`support` attribute of each - distribution is the same - -.. list-table:: - :header-rows: 1 - :widths: 35 65 - - * - Mixed Univariate PDFs - - Biasing Method - * - :class:`openmc.stats.Mixture` - - May be constructed from multiple biased univariate distributions, or a - second, unbiased continous univariate PDF may be applied to the - :attr:`bias` attribute - -.. list-table:: - :header-rows: 1 - :widths: 35 65 - - * - Discrete Multivariate PDFs - - Biasing Method - * - :class:`openmc.stats.PointCloud`, - :class:`openmc.stats.MeshSpatial` - - Apply a vector of the new relative probabilities of each point or mesh - element under biased sampling to the :attr:`bias` attribute - -.. list-table:: - :header-rows: 1 - :widths: 35 65 - - * - Continuous Multivariate PDFs - - Biasing Method - * - :class:`openmc.stats.CartesianIndependent`, - :class:`openmc.stats.CylindricalIndependent`, - :class:`openmc.stats.SphericalIndependent`, - :class:`openmc.stats.PolarAzimuthal` - - Construct from biased univariate distributions for :attr:`x`, :attr:`y`, - :attr:`z`, etc. - * - :class:`openmc.stats.Isotropic` - - Apply an unbiased :class:`openmc.stats.PolarAzimuthal` to the - :attr:`bias` attribute diff --git a/examples/custom_source/source_ring.cpp b/examples/custom_source/source_ring.cpp index bce6c27eb..b87afbd17 100644 --- a/examples/custom_source/source_ring.cpp +++ b/examples/custom_source/source_ring.cpp @@ -1,17 +1,17 @@ -#define _USE_MATH_DEFINES -#include // for M_PI +#include // for M_PI #include // for unique_ptr -#include "openmc/particle.h" #include "openmc/random_lcg.h" #include "openmc/source.h" +#include "openmc/particle.h" -class RingSource : public openmc::Source { +class RingSource : public openmc::Source +{ openmc::SourceSite sample(uint64_t* seed) const { openmc::SourceSite particle; // particle type - particle.particle = openmc::ParticleType::neutron(); + particle.particle = openmc::ParticleType::neutron; // position double angle = 2.0 * M_PI * openmc::prn(seed); double radius = 3.0; @@ -25,11 +25,10 @@ class RingSource : public openmc::Source { } }; -// A function to create a unique pointer to an instance of this class when -// generated via a plugin call using dlopen/dlsym. You must have external C -// linkage here otherwise dlopen will not find the file -extern "C" std::unique_ptr openmc_create_source( - std::string parameters) +// A function to create a unique pointer to an instance of this class when generated +// via a plugin call using dlopen/dlsym. +// You must have external C linkage here otherwise dlopen will not find the file +extern "C" std::unique_ptr openmc_create_source(std::string parameters) { return std::make_unique(); } diff --git a/examples/lattice/hexagonal/build_xml.py b/examples/lattice/hexagonal/build_xml.py index 2624e52b4..9485d0aa4 100644 --- a/examples/lattice/hexagonal/build_xml.py +++ b/examples/lattice/hexagonal/build_xml.py @@ -128,14 +128,14 @@ settings_file.export_to_xml() # Exporting to OpenMC plots.xml file ############################################################################### -plot_xy = openmc.SlicePlot(plot_id=1) +plot_xy = openmc.Plot(plot_id=1) plot_xy.filename = 'plot_xy' plot_xy.origin = [0, 0, 0] plot_xy.width = [6, 6] plot_xy.pixels = [400, 400] plot_xy.color_by = 'material' -plot_yz = openmc.SlicePlot(plot_id=2) +plot_yz = openmc.Plot(plot_id=2) plot_yz.filename = 'plot_yz' plot_yz.basis = 'yz' plot_yz.origin = [0, 0, 0] diff --git a/examples/lattice/nested/build_xml.py b/examples/lattice/nested/build_xml.py index a1d9c092d..2db23a46b 100644 --- a/examples/lattice/nested/build_xml.py +++ b/examples/lattice/nested/build_xml.py @@ -135,7 +135,7 @@ settings_file.export_to_xml() # Exporting to OpenMC plots.xml file ############################################################################### -plot = openmc.SlicePlot(plot_id=1) +plot = openmc.Plot(plot_id=1) plot.origin = [0, 0, 0] plot.width = [4, 4] plot.pixels = [400, 400] diff --git a/examples/lattice/simple/build_xml.py b/examples/lattice/simple/build_xml.py index 44531edd8..56c466121 100644 --- a/examples/lattice/simple/build_xml.py +++ b/examples/lattice/simple/build_xml.py @@ -128,7 +128,7 @@ settings_file.export_to_xml() # Exporting to OpenMC plots.xml file ############################################################################### -plot = openmc.SlicePlot(plot_id=1) +plot = openmc.Plot(plot_id=1) plot.origin = [0, 0, 0] plot.width = [4, 4] plot.pixels = [400, 400] diff --git a/examples/parameterized_custom_source/parameterized_source_ring.cpp b/examples/parameterized_custom_source/parameterized_source_ring.cpp index 3aabf3581..e70dc8bb1 100644 --- a/examples/parameterized_custom_source/parameterized_source_ring.cpp +++ b/examples/parameterized_custom_source/parameterized_source_ring.cpp @@ -1,66 +1,63 @@ -#define _USE_MATH_DEFINES -#include -#include +#include // for M_PI +#include // for unique_ptr #include -#include "openmc/particle.h" #include "openmc/random_lcg.h" #include "openmc/source.h" +#include "openmc/particle.h" class RingSource : public openmc::Source { -public: - RingSource(double radius, double energy) : radius_(radius), energy_(energy) {} + public: + RingSource(double radius, double energy) : radius_(radius), energy_(energy) { } - // Defines a function that can create a unique pointer to a new instance of - // this class by extracting the parameters from the provided string. - static std::unique_ptr from_string(std::string parameters) - { - std::unordered_map parameter_mapping; + // Defines a function that can create a unique pointer to a new instance of this class + // by extracting the parameters from the provided string. + static std::unique_ptr from_string(std::string parameters) + { + std::unordered_map parameter_mapping; - std::stringstream ss(parameters); - std::string parameter; - while (std::getline(ss, parameter, ',')) { - parameter.erase(0, parameter.find_first_not_of(' ')); - std::string key = parameter.substr(0, parameter.find_first_of('=')); - std::string value = - parameter.substr(parameter.find_first_of('=') + 1, parameter.length()); - parameter_mapping[key] = value; + std::stringstream ss(parameters); + std::string parameter; + while (std::getline(ss, parameter, ',')) { + parameter.erase(0, parameter.find_first_not_of(' ')); + std::string key = parameter.substr(0, parameter.find_first_of('=')); + std::string value = parameter.substr(parameter.find_first_of('=') + 1, parameter.length()); + parameter_mapping[key] = value; + } + + double radius = std::stod(parameter_mapping["radius"]); + double energy = std::stod(parameter_mapping["energy"]); + return std::make_unique(radius, energy); } - double radius = std::stod(parameter_mapping["radius"]); - double energy = std::stod(parameter_mapping["energy"]); - return std::make_unique(radius, energy); - } + // Samples from an instance of this class. + openmc::SourceSite sample(uint64_t* seed) const + { + openmc::SourceSite particle; + // particle type + particle.particle = openmc::ParticleType::neutron; + // position + double angle = 2.0 * M_PI * openmc::prn(seed); + double radius = this->radius_; + particle.r.x = radius * std::cos(angle); + particle.r.y = radius * std::sin(angle); + particle.r.z = 0.0; + // angle + particle.u = {1.0, 0.0, 0.0}; + particle.E = this->energy_; - // Samples from an instance of this class. - openmc::SourceSite sample(uint64_t* seed) const - { - openmc::SourceSite particle; - // particle type - particle.particle = openmc::ParticleType::neutron(); - // position - double angle = 2.0 * M_PI * openmc::prn(seed); - double radius = this->radius_; - particle.r.x = radius * std::cos(angle); - particle.r.y = radius * std::sin(angle); - particle.r.z = 0.0; - // angle - particle.u = {1.0, 0.0, 0.0}; - particle.E = this->energy_; + return particle; + } - return particle; - } - -private: - double radius_; - double energy_; + private: + double radius_; + double energy_; }; -// A function to create a unique pointer to an instance of this class when -// generated via a plugin call using dlopen/dlsym. You must have external C -// linkage here otherwise dlopen will not find the file -extern "C" std::unique_ptr openmc_create_source( - std::string parameters) +// A function to create a unique pointer to an instance of this class when generated +// via a plugin call using dlopen/dlsym. +// You must have external C linkage here otherwise dlopen will not find the file +extern "C" std::unique_ptr openmc_create_source(std::string parameters) { return RingSource::from_string(parameters); } diff --git a/examples/pincell_pulsed/run_pulse.py b/examples/pincell_pulsed/run_pulse.py deleted file mode 100644 index b6a61ad3d..000000000 --- a/examples/pincell_pulsed/run_pulse.py +++ /dev/null @@ -1,101 +0,0 @@ -import matplotlib.pyplot as plt -import numpy as np -import openmc - -############################################################################### -# Create materials for the problem - -uo2 = openmc.Material(name="UO2 fuel at 2.4% wt enrichment") -uo2.set_density("g/cm3", 10.29769) -uo2.add_element("U", 1.0, enrichment=2.4) -uo2.add_element("O", 2.0) - -helium = openmc.Material(name="Helium for gap") -helium.set_density("g/cm3", 0.001598) -helium.add_element("He", 2.4044e-4) - -zircaloy = openmc.Material(name="Zircaloy 4") -zircaloy.set_density("g/cm3", 6.55) -zircaloy.add_element("Sn", 0.014, "wo") -zircaloy.add_element("Fe", 0.00165, "wo") -zircaloy.add_element("Cr", 0.001, "wo") -zircaloy.add_element("Zr", 0.98335, "wo") - -borated_water = openmc.Material(name="Borated water") -borated_water.set_density("g/cm3", 0.740582) -borated_water.add_element("B", 2.0e-4) # 3x the original pincell -borated_water.add_element("H", 5.0e-2) -borated_water.add_element("O", 2.4e-2) -borated_water.add_s_alpha_beta("c_H_in_H2O") - -############################################################################### -# Define problem geometry - -# Create cylindrical surfaces -fuel_or = openmc.ZCylinder(r=0.39218, name="Fuel OR") -clad_ir = openmc.ZCylinder(r=0.40005, name="Clad IR") -clad_or = openmc.ZCylinder(r=0.45720, name="Clad OR") - -# Create a region represented as the inside of a rectangular prism -pitch = 1.25984 -box = openmc.model.RectangularPrism(pitch, pitch, boundary_type="reflective") - -# Create cells, mapping materials to regions -fuel = openmc.Cell(fill=uo2, region=-fuel_or) -gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir) -clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or) -water = openmc.Cell(fill=borated_water, region=+clad_or & -box) - -# Create a model and assign geometry -model = openmc.Model() -model.geometry = openmc.Geometry([fuel, gap, clad, water]) - -############################################################################### -# Define problem settings - -# Set the mode -model.settings.run_mode = "fixed source" - -# Indicate how many batches and particles to run -model.settings.batches = 10 -model.settings.particles = 10000 - -# Set time cutoff (we only care about t < 100 seconds, see tally below) -model.settings.cutoff = {"time_neutron": 100} - -# Create the neutron pulse source (by default, isotropic direction, t=0) -space = openmc.stats.Point() # At the origin (0, 0, 0) -energy = openmc.stats.delta_function(14.1e6) # At 14.1 MeV -model.settings.source = openmc.IndependentSource(space=space, energy=energy) - -############################################################################### -# Define tallies - -# Create time filter -t_grid = np.insert(np.logspace(-6, 2, 100), 0, 0.0) -time_filter = openmc.TimeFilter(t_grid) - -# Tally for total neutron density in time -density_tally = openmc.Tally(name="Density") -density_tally.filters = [time_filter] -density_tally.scores = ["inverse-velocity"] - -# Add tallies to model -model.tallies = openmc.Tallies([density_tally]) - - -# Run the model -model.run(apply_tally_results=True) - -# Bin-averaged result -density_mean = density_tally.mean.ravel() / np.diff(t_grid) - -# Plot particle density versus time -fig, ax = plt.subplots() -ax.stairs(density_mean, t_grid) -ax.set_xscale("log") -ax.set_yscale("log") -ax.set_xlabel("Time [s]") -ax.set_ylabel("Total density") -ax.grid() -plt.show() diff --git a/examples/pincell_random_ray/build_xml.py b/examples/pincell_random_ray/build_xml.py index 5ff4c0082..b3dd8020a 100644 --- a/examples/pincell_random_ray/build_xml.py +++ b/examples/pincell_random_ray/build_xml.py @@ -192,10 +192,11 @@ tallies.export_to_xml() # Exporting to OpenMC plots.xml file ############################################################################### -plot = openmc.VoxelPlot() +plot = openmc.Plot() plot.origin = [0, 0, 0] plot.width = [pitch, pitch, pitch] plot.pixels = [1000, 1000, 1] +plot.type = 'voxel' # Instantiate a Plots collection and export to XML plots = openmc.Plots([plot]) diff --git a/include/openmc/angle_energy.h b/include/openmc/angle_energy.h index 55deb5d41..ac931b1b5 100644 --- a/include/openmc/angle_energy.h +++ b/include/openmc/angle_energy.h @@ -14,22 +14,8 @@ namespace openmc { class AngleEnergy { public: - //! Sample an outgoing energy and scattering cosine - //! \param[in] E_in Incoming energy in [eV] - //! \param[out] E_out Outgoing energy in [eV] - //! \param[out] mu Outgoing cosine with respect to current direction - //! \param[inout] seed Pseudorandom seed pointer virtual void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const = 0; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - virtual double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const = 0; virtual ~AngleEnergy() = default; }; diff --git a/include/openmc/atomic_mass.h b/include/openmc/atomic_mass.h deleted file mode 100644 index b4d515d2e..000000000 --- a/include/openmc/atomic_mass.h +++ /dev/null @@ -1,28 +0,0 @@ -//============================================================================== -// atomic masses definitions -//============================================================================== - -#ifndef OPENMC_ATOMIC_MASS_H -#define OPENMC_ATOMIC_MASS_H - -#include -#include - -namespace openmc { - -// Values here are from the Committee on Data for Science and Technology -// (CODATA) 2018 recommendation (https://physics.nist.gov/cuu/Constants/). - -// Physical constants -constexpr double MASS_ELECTRON {5.48579909065e-4}; // mass of an electron in amu -constexpr double MASS_NEUTRON {1.00866491595}; // mass of a neutron in amu -constexpr double MASS_PROTON {1.007276466621}; // mass of a proton in amu -constexpr double MASS_DEUTRON {2.013553212745}; // mass of a deutron in amu -constexpr double MASS_HELION {3.014932247175}; // mass of a helion in amu -constexpr double MASS_ALPHA {4.001506179127}; // mass of an alpha in amu - -extern std::unordered_map ATOMIC_MASS; - -} // namespace openmc - -#endif // OPENMC_ATOMIC_MASS_H diff --git a/include/openmc/bank.h b/include/openmc/bank.h index 6abcdd7f1..95386514d 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -20,38 +20,22 @@ extern vector source_bank; extern SharedArray surf_source_bank; -extern SharedArray collision_track_bank; - extern SharedArray fission_bank; -extern vector> ifp_source_delayed_group_bank; - -extern vector> ifp_source_lifetime_bank; - -extern vector> ifp_fission_delayed_group_bank; - -extern vector> ifp_fission_lifetime_bank; - extern vector progeny_per_particle; -extern SharedArray shared_secondary_bank_read; -extern SharedArray shared_secondary_bank_write; - } // namespace simulation //============================================================================== // Non-member functions //============================================================================== -void sort_bank(SharedArray& bank, bool is_fission_bank); +void sort_fission_bank(); void free_memory_bank(); void init_fission_bank(int64_t max); -int64_t synchronize_global_secondary_bank( - SharedArray& shared_secondary_bank); - } // namespace openmc #endif // OPENMC_BANK_H diff --git a/include/openmc/bank_io.h b/include/openmc/bank_io.h deleted file mode 100644 index 418ec111f..000000000 --- a/include/openmc/bank_io.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef OPENMC_BANK_IO_H -#define OPENMC_BANK_IO_H - -#include "hdf5.h" - -#include "openmc/message_passing.h" -#include "openmc/span.h" -#include "openmc/vector.h" - -#include - -#ifdef OPENMC_MPI -#include -#endif - -namespace openmc { - -template -void write_bank_dataset( - const char* dataset_name, hid_t group_id, span bank, - const vector& bank_index, hid_t membanktype, hid_t filebanktype -#ifdef OPENMC_MPI - , - MPI_Datatype mpi_dtype -#endif -) -{ - int64_t dims_size = bank_index.back(); - int64_t count_size = bank_index[mpi::rank + 1] - bank_index[mpi::rank]; - -#ifdef PHDF5 - hsize_t dims[] {static_cast(dims_size)}; - hid_t dspace = H5Screate_simple(1, dims, nullptr); - hid_t dset = H5Dcreate(group_id, dataset_name, filebanktype, dspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - hsize_t count[] {static_cast(count_size)}; - hid_t memspace = H5Screate_simple(1, count, nullptr); - - hsize_t start[] {static_cast(bank_index[mpi::rank])}; - H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); - - hid_t plist = H5Pcreate(H5P_DATASET_XFER); - H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); - - H5Dwrite(dset, membanktype, memspace, dspace, plist, bank.data()); - - H5Sclose(dspace); - H5Sclose(memspace); - H5Dclose(dset); - H5Pclose(plist); -#else - if (mpi::master) { - hsize_t dims[] {static_cast(dims_size)}; - hid_t dspace = H5Screate_simple(1, dims, nullptr); - hid_t dset = H5Dcreate(group_id, dataset_name, filebanktype, dspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - -#ifdef OPENMC_MPI - vector temp_bank {bank.begin(), bank.end()}; -#endif - - for (int i = 0; i < mpi::n_procs; ++i) { - hsize_t count[] {static_cast(bank_index[i + 1] - bank_index[i])}; - hid_t memspace = H5Screate_simple(1, count, nullptr); - -#ifdef OPENMC_MPI - if (i > 0) { - MPI_Recv(bank.data(), count[0], mpi_dtype, i, i, mpi::intracomm, - MPI_STATUS_IGNORE); - } -#endif - - hid_t dspace_rank = H5Dget_space(dset); - hsize_t start[] {static_cast(bank_index[i])}; - H5Sselect_hyperslab( - dspace_rank, H5S_SELECT_SET, start, nullptr, count, nullptr); - - H5Dwrite( - dset, membanktype, memspace, dspace_rank, H5P_DEFAULT, bank.data()); - - H5Sclose(memspace); - H5Sclose(dspace_rank); - } - - H5Dclose(dset); - -#ifdef OPENMC_MPI - std::copy(temp_bank.begin(), temp_bank.end(), bank.begin()); -#endif - } -#ifdef OPENMC_MPI - else { - if (!bank.empty()) { - MPI_Send( - bank.data(), bank.size(), mpi_dtype, 0, mpi::rank, mpi::intracomm); - } - } -#endif -#endif -} - -} // namespace openmc - -#endif // OPENMC_BANK_IO_H diff --git a/include/openmc/boundary_condition.h b/include/openmc/boundary_condition.h index 89bf7ca8b..cd8988162 100644 --- a/include/openmc/boundary_condition.h +++ b/include/openmc/boundary_condition.h @@ -111,10 +111,6 @@ public: std::string type() const override { return "periodic"; } - int i_surf() const { return i_surf_; } - - int j_surf() const { return j_surf_; } - protected: int i_surf_; int j_surf_; @@ -138,28 +134,18 @@ protected: //============================================================================== //! A BC that rotates particles about a global axis. // -//! Only rotations about the x, y, and z axes are supported. +//! Currently only rotations about the z-axis are supported. //============================================================================== class RotationalPeriodicBC : public PeriodicBC { public: - enum PeriodicAxis { x, y, z }; - RotationalPeriodicBC(int i_surf, int j_surf, PeriodicAxis axis); - double compute_periodic_rotation( - double rise_1, double run_1, double rise_2, double run_2) const; + RotationalPeriodicBC(int i_surf, int j_surf); + void handle_particle(Particle& p, const Surface& surf) const override; protected: //! Angle about the axis by which particle coordinates will be rotated double angle_; - //! Do we need to flip surfaces senses when applying the transformation? - bool flip_sense_; - //! Ensure that choice of axes is right handed. axis_1_idx_ corresponds to the - //! independent axis and axis_2_idx_ corresponds to the dependent axis in the - //! 2D plane perpendicular to the planes' axis of rotation - int zero_axis_idx_; - int axis_1_idx_; - int axis_2_idx_; }; } // namespace openmc diff --git a/include/openmc/bounding_box.h b/include/openmc/bounding_box.h deleted file mode 100644 index 4fabe1b70..000000000 --- a/include/openmc/bounding_box.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef OPENMC_BOUNDING_BOX_H -#define OPENMC_BOUNDING_BOX_H - -#include // for min, max - -#include "openmc/constants.h" -#include "openmc/position.h" - -namespace openmc { - -//============================================================================== -//! Coordinates for an axis-aligned cuboid that bounds a geometric object. -//============================================================================== - -struct BoundingBox { - Position min = {-INFTY, -INFTY, -INFTY}; - Position max = {INFTY, INFTY, INFTY}; - - // Constructors - BoundingBox() = default; - BoundingBox(Position min_, Position max_) : min {min_}, max {max_} {} - - // Static factory methods - static BoundingBox infinite() { return {}; } - static BoundingBox inverted() - { - return {{INFTY, INFTY, INFTY}, {-INFTY, -INFTY, -INFTY}}; - } - - inline BoundingBox operator&(const BoundingBox& other) - { - BoundingBox result = *this; - return result &= other; - } - - inline BoundingBox operator|(const BoundingBox& other) - { - BoundingBox result = *this; - return result |= other; - } - - // intersect operator - inline BoundingBox& operator&=(const BoundingBox& other) - { - min.x = std::max(min.x, other.min.x); - min.y = std::max(min.y, other.min.y); - min.z = std::max(min.z, other.min.z); - max.x = std::min(max.x, other.max.x); - max.y = std::min(max.y, other.max.y); - max.z = std::min(max.z, other.max.z); - return *this; - } - - // union operator - inline BoundingBox& operator|=(const BoundingBox& other) - { - min.x = std::min(min.x, other.min.x); - min.y = std::min(min.y, other.min.y); - min.z = std::min(min.z, other.min.z); - max.x = std::max(max.x, other.max.x); - max.y = std::max(max.y, other.max.y); - max.z = std::max(max.z, other.max.z); - return *this; - } -}; - -} // namespace openmc - -#endif diff --git a/include/openmc/bremsstrahlung.h b/include/openmc/bremsstrahlung.h index d3b586831..2f7e41bf0 100644 --- a/include/openmc/bremsstrahlung.h +++ b/include/openmc/bremsstrahlung.h @@ -3,7 +3,7 @@ #include "openmc/particle.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" namespace openmc { @@ -14,9 +14,9 @@ namespace openmc { class BremsstrahlungData { public: // Data - tensor::Tensor pdf; //!< Bremsstrahlung energy PDF - tensor::Tensor cdf; //!< Bremsstrahlung energy CDF - tensor::Tensor yield; //!< Photon yield + xt::xtensor pdf; //!< Bremsstrahlung energy PDF + xt::xtensor cdf; //!< Bremsstrahlung energy CDF + xt::xtensor yield; //!< Photon yield }; class Bremsstrahlung { @@ -32,9 +32,9 @@ public: namespace data { -extern tensor::Tensor +extern xt::xtensor ttb_e_grid; //! energy T of incident electron in [eV] -extern tensor::Tensor +extern xt::xtensor ttb_k_grid; //! reduced energy W/T of emitted photon } // namespace data diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 9f6987d74..9401156a6 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -9,43 +9,14 @@ extern "C" { #endif -//! Run a stochastic volume calculation -// -//! \return Status (negative if an error occurred) int openmc_calculate_volumes(); - int openmc_cell_filter_get_bins( int32_t index, const int32_t** cells, int32_t* n); - -//! Get the fill for a cell -// -//! \param index Index in the cells array -//! \param type Type of the fill -//! \param indices Array of material indices for cell -//! \param n Length of indices array -//! \return Status (negative if an error occurred) int openmc_cell_get_fill( int32_t index, int* type, int32_t** indices, int32_t* n); - -//! Get the ID of a cell -// -//! \param index Index in the cells array -//! \param id ID of the cell -//! \return Status (negative if an error occurred) int openmc_cell_get_id(int32_t index, int32_t* id); - -//! Get the temperature of a cell -// -//! \param index Index in the cells array -//! \param instance Which instance of the cell. If a null pointer is -//! passed, the temperature of the first instance is returned. -//! \param T temperature of the cell -//!\return Status (negative if an error occurred) int openmc_cell_get_temperature( int32_t index, const int32_t* instance, double* T); - -int openmc_cell_get_density( - int32_t index, const int32_t* instance, double* rho); int openmc_cell_get_translation(int32_t index, double xyz[]); int openmc_cell_get_rotation(int32_t index, double rot[], size_t* n); int openmc_cell_get_name(int32_t index, const char** name); @@ -56,13 +27,8 @@ int openmc_cell_set_fill( int openmc_cell_set_id(int32_t index, int32_t id); int openmc_cell_set_temperature( int32_t index, double T, const int32_t* instance, bool set_contained = false); -int openmc_cell_set_density(int32_t index, double rho, const int32_t* instance, - bool set_contained = false); int openmc_cell_set_translation(int32_t index, const double xyz[]); int openmc_cell_set_rotation(int32_t index, const double rot[], size_t rot_len); -int openmc_dagmc_universe_get_cell_ids( - int32_t univ_id, int32_t* ids, size_t* n); -int openmc_dagmc_universe_get_num_cells(int32_t univ_id, size_t* n); int openmc_energy_filter_get_bins( int32_t index, const double** energies, size_t* n); int openmc_energy_filter_set_bins( @@ -102,7 +68,6 @@ int openmc_get_nuclide_index(const char name[], int* index); int openmc_add_unstructured_mesh( const char filename[], const char library[], int* id); int64_t openmc_get_seed(); -uint64_t openmc_get_stride(); int openmc_get_tally_index(int32_t id, int32_t* index); void openmc_get_tally_next_id(int32_t* id); int openmc_global_tallies(double** ptr); @@ -142,64 +107,16 @@ int openmc_mesh_get_id(int32_t index, int32_t* id); int openmc_mesh_set_id(int32_t index, int32_t id); int openmc_mesh_get_n_elements(int32_t index, size_t* n); int openmc_mesh_get_volumes(int32_t index, double* volumes); -int openmc_mesh_material_volumes(int32_t index, int nx, int ny, int nz, - int max_mats, int32_t* materials, double* volumes, double* bboxes); +int openmc_mesh_material_volumes(int32_t index, int n_sample, int bin, + int result_size, void* result, int* hits, uint64_t* seed); int openmc_meshsurface_filter_get_mesh(int32_t index, int32_t* index_mesh); int openmc_meshsurface_filter_set_mesh(int32_t index, int32_t index_mesh); int openmc_new_filter(const char* type, int32_t* index); int openmc_next_batch(int* status); int openmc_nuclide_name(int index, const char** name); int openmc_plot_geometry(); -// Deprecated; use openmc_slice_data. int openmc_id_map(const void* slice, int32_t* data_out); -// Deprecated; use openmc_slice_data. int openmc_property_map(const void* slice, double* data_out); -int openmc_slice_data(const double origin[3], const double u_span[3], - const double v_span[3], const size_t pixels[2], bool show_overlaps, int level, - int32_t filter_index, int32_t* geom_data, double* property_data); -int openmc_get_plot_index(int32_t id, int32_t* index); -int openmc_plot_get_id(int32_t index, int32_t* id); -int openmc_plot_set_id(int32_t index, int32_t id); -int openmc_solidraytrace_plot_create(int32_t* index); -int openmc_solidraytrace_plot_get_pixels( - int32_t index, int32_t* width, int32_t* height); -int openmc_solidraytrace_plot_set_pixels( - int32_t index, int32_t width, int32_t height); -int openmc_solidraytrace_plot_get_color_by(int32_t index, int32_t* color_by); -int openmc_solidraytrace_plot_set_color_by(int32_t index, int32_t color_by); -int openmc_solidraytrace_plot_set_default_colors(int32_t index); -int openmc_solidraytrace_plot_set_all_opaque(int32_t index); -int openmc_solidraytrace_plot_set_opaque( - int32_t index, int32_t id, bool visible); -int openmc_solidraytrace_plot_set_color( - int32_t index, int32_t id, uint8_t r, uint8_t g, uint8_t b); -int openmc_solidraytrace_plot_get_camera_position( - int32_t index, double* x, double* y, double* z); -int openmc_solidraytrace_plot_set_camera_position( - int32_t index, double x, double y, double z); -int openmc_solidraytrace_plot_get_look_at( - int32_t index, double* x, double* y, double* z); -int openmc_solidraytrace_plot_set_look_at( - int32_t index, double x, double y, double z); -int openmc_solidraytrace_plot_get_up( - int32_t index, double* x, double* y, double* z); -int openmc_solidraytrace_plot_set_up( - int32_t index, double x, double y, double z); -int openmc_solidraytrace_plot_get_light_position( - int32_t index, double* x, double* y, double* z); -int openmc_solidraytrace_plot_set_light_position( - int32_t index, double x, double y, double z); -int openmc_solidraytrace_plot_get_fov(int32_t index, double* fov); -int openmc_solidraytrace_plot_set_fov(int32_t index, double fov); -int openmc_solidraytrace_plot_update_view(int32_t index); -int openmc_solidraytrace_plot_create_image( - int32_t index, uint8_t* data_out, int32_t width, int32_t height); -int openmc_solidraytrace_plot_get_color( - int32_t index, int32_t id, uint8_t* r, uint8_t* g, uint8_t* b); -int openmc_solidraytrace_plot_get_diffuse_fraction( - int32_t index, double* diffuse_fraction); -int openmc_solidraytrace_plot_set_diffuse_fraction( - int32_t index, double diffuse_fraction); int openmc_rectilinear_mesh_get_grid(int32_t index, double** grid_x, int* nx, double** grid_y, int* ny, double** grid_z, int* nz); int openmc_rectilinear_mesh_set_grid(int32_t index, const double* grid_x, @@ -215,10 +132,8 @@ int openmc_remove_tally(int32_t index); int openmc_reset(); int openmc_reset_timers(); int openmc_run(); -void openmc_run_random_ray(); int openmc_sample_external_source(size_t n, uint64_t* seed, void* sites); void openmc_set_seed(int64_t new_seed); -void openmc_set_stride(uint64_t new_stride); int openmc_set_n_batches( int32_t n_batches, bool set_max_batches, bool add_statepoint_batch); int openmc_simulation_finalize(); @@ -277,8 +192,8 @@ int openmc_weight_windows_set_energy_bounds( int32_t index, double* e_bounds, size_t e_bounds_size); int openmc_weight_windows_get_energy_bounds( int32_t index, const double** e_bounds, size_t* e_bounds_size); -int openmc_weight_windows_set_particle(int32_t index, int32_t particle); -int openmc_weight_windows_get_particle(int32_t index, int32_t* particle); +int openmc_weight_windows_set_particle(int32_t index, int particle); +int openmc_weight_windows_get_particle(int32_t index, int* particle); int openmc_weight_windows_get_bounds(int32_t index, const double** lower_bounds, const double** upper_bounds, size_t* size); int openmc_weight_windows_set_bounds(int32_t index, const double* lower_bounds, @@ -294,7 +209,6 @@ int openmc_weight_windows_set_weight_cutoff(int32_t index, double cutoff); int openmc_weight_windows_get_max_split(int32_t index, int* max_split); int openmc_weight_windows_set_max_split(int32_t index, int max_split); size_t openmc_weight_windows_size(); -size_t openmc_plots_size(); int openmc_weight_windows_export(const char* filename = nullptr); int openmc_weight_windows_import(const char* filename = nullptr); int openmc_zernike_filter_get_order(int32_t index, int* order); @@ -304,10 +218,10 @@ int openmc_zernike_filter_set_order(int32_t index, int order); int openmc_zernike_filter_set_params( int32_t index, const double* x, const double* y, const double* r); -int openmc_particle_filter_get_bins(int32_t idx, int32_t bins[]); +int openmc_particle_filter_get_bins(int32_t idx, int bins[]); //! Sets the mesh and energy grid for CMFD reweight -//! \param[in] meshtally_id id of CMFD Mesh Tally +//! \param[in] meshtyally_id id of CMFD Mesh Tally //! \param[in] cmfd_indices indices storing spatial and energy dimensions of //! CMFD problem \param[in] norm CMFD normalization factor void openmc_initialize_mesh_egrid( diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 1a27ad516..d78614f05 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -10,8 +10,8 @@ #include "hdf5.h" #include "pugixml.hpp" +#include -#include "openmc/bounding_box.h" #include "openmc/constants.h" #include "openmc/memory.h" // for unique_ptr #include "openmc/neighbor_list.h" @@ -28,6 +28,7 @@ namespace openmc { enum class Fill { MATERIAL, UNIVERSE, LATTICE }; +// TODO: Convert to enum constexpr int32_t OP_LEFT_PAREN {std::numeric_limits::max()}; constexpr int32_t OP_RIGHT_PAREN {std::numeric_limits::max() - 1}; constexpr int32_t OP_COMPLEMENT {std::numeric_limits::max() - 2}; @@ -114,7 +115,7 @@ private: //! //! Uses the comobination of half-spaces and binary operators to determine //! if short circuiting can be used. Short cicuiting uses the relative and - //! absolute depth of parentheses in the expression. + //! absolute depth of parenthases in the expression. bool contains_complex(Position r, Direction u, int32_t on_surface) const; //! BoundingBox if the paritcle is in a simple cell. @@ -123,11 +124,11 @@ private: //! BoundingBox if the particle is in a complex cell. BoundingBox bounding_box_complex(vector postfix) const; - //! Enforce precedence between intersections and unions - void enforce_precedence(); + //! Enfource precedence: Parenthases, Complement, Intersection, Union + void add_precedence(); //! Add parenthesis to enforce precedence - void add_parentheses(int64_t start); + gsl::index add_parentheses(gsl::index start); //! Remove complement operators from the expression void remove_complement_ops(); @@ -145,30 +146,6 @@ private: bool simple_; //!< Does the region contain only intersections? }; -//============================================================================== -// XML parsing helpers for nodes -//============================================================================== - -//! Parse material IDs from a XML node. -//! \param node XML node containing a "material" attribute or child element -//! \param cell_id Cell ID used in error messages -//! \return Vector of material IDs (MATERIAL_VOID for "void") -vector parse_cell_material_xml(pugi::xml_node node, int32_t cell_id); - -//! Parse temperatures in [K] from a XML node. -//! Validates that all values are non-negative and the list is non-empty. -//! \param node XML node containing a "temperature" attribute or child element -//! \param cell_id Cell ID used in error messages -//! \return Vector of temperatures in [K] -vector parse_cell_temperature_xml(pugi::xml_node node, int32_t cell_id); - -//! Parse densities in [g/cm³] from a XML node. -//! Validates that all values are positive and the list is non-empty. -//! \param node XML node containing a "density" attribute or child element -//! \param cell_id Cell ID used in error messages -//! \return Vector of densities in [g/cm³] -vector parse_cell_density_xml(pugi::xml_node node, int32_t cell_id); - //============================================================================== class Cell { @@ -240,18 +217,6 @@ public: //! \return Temperature in [K] double temperature(int32_t instance = -1) const; - //! Get the density multiplier of a cell instance - //! \param[in] instance Instance index. If -1 is given, the density multiplier - //! for the first instance is returned. - //! \return Density multiplier - double density_mult(int32_t instance = -1) const; - - //! Get the density of a cell instance in g/cm3 - //! \param[in] instance Instance index. If -1 is given, the density - //! for the first instance is returned. - //! \return Density in [g/cm3] - double density(int32_t instance = -1) const; - //! Set the temperature of a cell instance //! \param[in] T Temperature in [K] //! \param[in] instance Instance index. If -1 is given, the temperature for @@ -262,18 +227,6 @@ public: void set_temperature( double T, int32_t instance = -1, bool set_contained = false); - //! Set the density of a cell instance - //! \param[in] density Density [g/cm3] - //! \param[in] instance Instance index. If -1 is given, the density - //! for all instances is set. - //! \param[in] set_contained If this cell is not filled with a material, - //! collect all contained cells with material fills and set their - //! densities. - void set_density( - double density, int32_t instance = -1, bool set_contained = false); - - int32_t n_instances() const; - //! Set the rotation matrix of a cell instance //! \param[in] rot The rotation matrix of length 3 or 9 void set_rotation(const vector& rot); @@ -360,11 +313,13 @@ public: //---------------------------------------------------------------------------- // Data members - int32_t id_; //!< Unique ID - std::string name_; //!< User-defined name - Fill type_; //!< Material, universe, or lattice - int32_t universe_; //!< Universe # this cell is in - int32_t fill_; //!< Universe # filling this cell + int32_t id_; //!< Unique ID + std::string name_; //!< User-defined name + Fill type_; //!< Material, universe, or lattice + int32_t universe_; //!< Universe # this cell is in + int32_t fill_; //!< Universe # filling this cell + int32_t n_instances_ {0}; //!< Number of instances of this cell + GeometryType geom_type_; //!< Geometric representation type (CSG, DAGMC) //! \brief Index corresponding to this cell in distribcell arrays int distribcell_index_ {C_NONE}; @@ -380,9 +335,6 @@ public: //! T. The units are sqrt(eV). vector sqrtkT_; - //! \brief Unitless density multiplier(s) within this cell. - vector density_mult_; - //! \brief Neighboring cells in the same universe. NeighborList neighbors_; @@ -397,9 +349,6 @@ public: vector rotation_; vector offset_; //!< Distribcell offset table - - // Right now, either CSG or DAGMC cells are used. - virtual GeometryType geom_type() const = 0; }; struct CellInstanceItem { @@ -413,7 +362,7 @@ class CSGCell : public Cell { public: //---------------------------------------------------------------------------- // Constructors - CSGCell() = default; + CSGCell(); explicit CSGCell(pugi::xml_node cell_node); //---------------------------------------------------------------------------- @@ -440,8 +389,6 @@ public: bool is_simple() const override { return region_.is_simple(); } - virtual GeometryType geom_type() const override { return GeometryType::CSG; } - protected: //! Returns the beginning position of a parenthesis block (immediately before //! two surface tokens) in the RPN given a starting position at the end of @@ -467,8 +414,8 @@ struct CellInstance { return index_cell == other.index_cell && instance == other.instance; } - int64_t index_cell; - int64_t instance; + gsl::index index_cell; + gsl::index instance; }; //! Structure necessary for inserting CellInstance into hashed STL data diff --git a/include/openmc/chain.h b/include/openmc/chain.h deleted file mode 100644 index e01f2a01c..000000000 --- a/include/openmc/chain.h +++ /dev/null @@ -1,108 +0,0 @@ -//! \file chain.h -//! \brief Depletion chain and associated information - -#ifndef OPENMC_CHAIN_H -#define OPENMC_CHAIN_H - -#include -#include -#include - -#include "pugixml.hpp" - -#include "openmc/angle_energy.h" // for AngleEnergy -#include "openmc/distribution.h" // for UPtrDist -#include "openmc/memory.h" // for unique_ptr -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -// Data for a nuclide in the depletion chain -//============================================================================== - -class ChainNuclide { -public: - // Types - struct Product { - std::string name; //!< Reaction product name - double branching_ratio; //!< Branching ratio - }; - - // Constructors, destructors - ChainNuclide(pugi::xml_node node); - ~ChainNuclide(); - - //! Compute the decay constant for the nuclide - //! \return Decay constant in [1/s] - double decay_constant() const { return std::log(2.0) / half_life_; } - - const Distribution* photon_energy() const { return photon_energy_.get(); } - const std::unordered_map>& reaction_products() const - { - return reaction_products_; - } - -private: - // Data members - std::string name_; //!< Name of nuclide - double half_life_ {0.0}; //!< Half-life in [s] - double decay_energy_ {0.0}; //!< Decay energy in [eV] - std::unordered_map> - reaction_products_; //!< Map of MT to reaction products - UPtrDist photon_energy_; //!< Decay photon energy distribution -}; - -//============================================================================== -// Angle-energy distribution for decay photon -//============================================================================== - -class DecayPhotonAngleEnergy : public AngleEnergy { -public: - explicit DecayPhotonAngleEnergy(const Distribution* dist) - : photon_energy_(dist) - {} - - //! Sample distribution for an angle and energy - //! \param[in] E_in Incoming energy in [eV] - //! \param[out] E_out Outgoing energy in [eV] - //! \param[out] mu Outgoing cosine with respect to current direction - //! \param[inout] seed Pseudorandom seed pointer - void sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const override; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - -private: - const Distribution* photon_energy_; -}; - -//============================================================================== -// Global variables -//============================================================================== - -namespace data { - -extern std::unordered_map chain_nuclide_map; -extern vector> chain_nuclides; - -} // namespace data - -//============================================================================== -// Non-member functions -//============================================================================== - -void read_chain_file_xml(); - -void free_memory_chain(); - -} // namespace openmc - -#endif // OPENMC_CHAIN_H diff --git a/include/openmc/collision_track.h b/include/openmc/collision_track.h deleted file mode 100644 index 208b8f6e1..000000000 --- a/include/openmc/collision_track.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef OPENMC_COLLISION_TRACK_H -#define OPENMC_COLLISION_TRACK_H - -#include - -namespace openmc { - -class Particle; - -//! Reserve space in the collision track bank according to user settings. -void collision_track_reserve_bank(); - -//! Write collision track data to disk when the bank is full or the batch ends. -void collision_track_flush_bank(); - -//! Record the current particle as a collision-track entry when applicable. -//! -//! \param particle Particle whose collision should be recorded if eligible -void collision_track_record(Particle& particle); - -} // namespace openmc - -#endif // OPENMC_COLLISION_TRACK_H diff --git a/include/openmc/constants.h b/include/openmc/constants.h index a1d94e581..1c683e5f5 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -9,7 +9,6 @@ #include #include "openmc/array.h" -#include "openmc/atomic_mass.h" #include "openmc/vector.h" #include "openmc/version.h" @@ -26,16 +25,15 @@ using double_4dvec = vector>>>; constexpr int HDF5_VERSION[] {3, 0}; // Version numbers for binary files -constexpr array VERSION_STATEPOINT {18, 2}; -constexpr array VERSION_PARTICLE_RESTART {2, 1}; -constexpr array VERSION_TRACK {3, 1}; -constexpr array VERSION_SUMMARY {6, 1}; +constexpr array VERSION_STATEPOINT {18, 1}; +constexpr array VERSION_PARTICLE_RESTART {2, 0}; +constexpr array VERSION_TRACK {3, 0}; +constexpr array VERSION_SUMMARY {6, 0}; constexpr array VERSION_VOLUME {1, 0}; constexpr array VERSION_VOXEL {2, 0}; constexpr array VERSION_MGXS_LIBRARY {1, 0}; -constexpr array VERSION_PROPERTIES {1, 1}; +constexpr array VERSION_PROPERTIES {1, 0}; constexpr array VERSION_WEIGHT_WINDOWS {1, 0}; -constexpr array VERSION_COLLISION_TRACK {1, 2}; // ============================================================================ // ADJUSTABLE PARAMETERS @@ -61,33 +59,6 @@ constexpr double RADIAL_MESH_TOL {1e-10}; // Maximum number of random samples per history constexpr int MAX_SAMPLE {100000}; -// Avg. number of hits per batch to be defined as a "small" -// source region in the random ray solver -constexpr double MIN_HITS_PER_BATCH {1.5}; - -// The minimum flux value to be considered non-zero when computing adjoint -// sources. Positive values below this cutoff will be treated as zero, so as to -// prevent extremely large adjoint source terms from being generated. -constexpr double ZERO_FLUX_CUTOFF {1e-22}; - -// The minimum macroscopic cross section value considered non-void for the -// random ray solver. Materials with any group with a cross section below this -// value will be converted to pure void. -constexpr double MINIMUM_MACRO_XS {1e-6}; - -// Relative dead band applied to weight window comparisons: particles split -// only above upper * (1 + tol) and roulette only below lower * (1 - tol). -// Weight window arithmetic can land a particle's weight exactly back on a -// bound value (e.g., a roulette survivor is assigned survival_ratio * lower -// and a later split divides that back down), in which case the branch taken -// would be decided by the last ulp of the bound. Since window data carries -// ulp-level noise from non-associative parallel reductions in the solver that -// generated it, transport results would otherwise be chaotically sensitive to -// bit-level differences in the weight window file. Treating weights within -// the band as inside the window is statistically negligible, and weight -// window games are unbiased regardless of where the thresholds sit. -constexpr double WEIGHT_WINDOW_REL_TOL {1e-9}; - // ============================================================================ // MATH AND PHYSICAL CONSTANTS @@ -100,10 +71,10 @@ constexpr double INFTY {std::numeric_limits::max()}; // (CODATA) 2018 recommendation (https://physics.nist.gov/cuu/Constants/). // Physical constants -constexpr double AMU_EV { - 9.3149410242e8}; // atomic mass unit energy equivalent in eV/c^2 +constexpr double MASS_NEUTRON {1.00866491595}; // mass of a neutron in amu constexpr double MASS_NEUTRON_EV { - 939.56542052e6}; // neutron mass energy equivalent in eV/c^2 + 939.56542052e6}; // mass of a neutron in eV/c^2 +constexpr double MASS_PROTON {1.007276466621}; // mass of a proton in amu constexpr double MASS_ELECTRON_EV { 0.51099895000e6}; // electron mass energy equivalent in eV/c^2 constexpr double FINE_STRUCTURE { @@ -240,7 +211,6 @@ enum ReactionType { N_XA = 207, HEATING = 301, DAMAGE_ENERGY = 444, - PHOTON_TOTAL = 501, COHERENT = 502, INCOHERENT = 504, PAIR_PROD_ELEC = 515, @@ -307,7 +277,7 @@ enum class MgxsType { // ============================================================================ // TALLY-RELATED CONSTANTS -enum class TallyResult { VALUE, SUM, SUM_SQ, SUM_THIRD, SUM_FOURTH }; +enum class TallyResult { VALUE, SUM, SUM_SQ, SIZE }; enum class TallyType { VOLUME, MESH_SURFACE, SURFACE, PULSE_HEIGHT }; @@ -316,7 +286,7 @@ enum class TallyEstimator { ANALOG, TRACKLENGTH, COLLISION }; enum class TallyEvent { SURFACE, LATTICE, KILL, SCATTER, ABSORB }; // Tally score type -- if you change these, make sure you also update the -// _SCORES dictionary in openmc/lib/tally.py +// _SCORES dictionary in openmc/capi/tally.py // // These are kept as a normal enum and made negative, since variables which // store one of these enum values usually also may be responsible for storing @@ -338,10 +308,7 @@ enum TallyScore { SCORE_FISS_Q_PROMPT = -14, // prompt fission Q-value SCORE_FISS_Q_RECOV = -15, // recoverable fission Q-value SCORE_DECAY_RATE = -16, // delayed neutron precursor decay rate - SCORE_PULSE_HEIGHT = -17, // pulse-height - SCORE_IFP_TIME_NUM = -18, // IFP lifetime numerator - SCORE_IFP_BETA_NUM = -19, // IFP delayed fraction numerator - SCORE_IFP_DENOM = -20 // IFP common denominator + SCORE_PULSE_HEIGHT = -17 // pulse-height }; // Global tally parameters @@ -351,9 +318,6 @@ enum class GlobalTally { K_COLLISION, K_ABSORPTION, K_TRACKLENGTH, LEAKAGE }; // Miscellaneous constexpr int C_NONE {-1}; -// Default value of generation for IFP -constexpr int DEFAULT_IFP_N_GENERATION {10}; - // Interpolation rules enum class Interpolation { histogram = 1, @@ -378,20 +342,11 @@ enum class RunMode { enum class SolverType { MONTE_CARLO, RANDOM_RAY }; -enum class RandomRayVolumeEstimator { NAIVE, SIMULATION_AVERAGED, HYBRID }; -enum class RandomRaySourceShape { FLAT, LINEAR, LINEAR_XY }; -enum class RandomRaySampleMethod { PRNG, HALTON, S2 }; -enum class RandomRaySolve { FORWARD, FORWARD_FOR_ADJOINT, ADJOINT }; - //============================================================================== // Geometry Constants enum class GeometryType { CSG, DAG }; -// a surface token cannot be zero due to the unsigned nature of zero for integer -// representations. This value represents no surface. -constexpr int32_t SURFACE_NONE {0}; - } // namespace openmc #endif // OPENMC_CONSTANTS_H diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 858636c0b..2facf4fc0 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -20,7 +20,7 @@ void check_dagmc_root_univ(); } // namespace openmc -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC #include "DagMC.hpp" #include "dagmcmetadata.hpp" @@ -29,12 +29,6 @@ void check_dagmc_root_univ(); #include "openmc/particle.h" #include "openmc/position.h" #include "openmc/surface.h" -#include "openmc/vector.h" - -#include // for shared_ptr, unique_ptr -#include -#include -#include // for pair class UWUW; @@ -49,13 +43,10 @@ public: double evaluate(Position r) const override; double distance(Position r, Direction u, bool coincident) const override; Direction normal(Position r) const override; - Direction reflect( - Position r, Direction u, GeometryState* p = nullptr) const override; + Direction reflect(Position r, Direction u, GeometryState* p) const override; inline void to_hdf5_inner(hid_t group_id) const override {}; - virtual GeometryType geom_type() const override { return GeometryType::DAG; } - // Accessor methods moab::DagMC* dagmc_ptr() const { return dagmc_ptr_.get(); } int32_t dag_index() const { return dag_index_; } @@ -80,8 +71,6 @@ public: void to_hdf5_inner(hid_t group_id) const override; - virtual GeometryType geom_type() const override { return GeometryType::DAG; } - // Accessor methods moab::DagMC* dagmc_ptr() const { return dagmc_ptr_.get(); } int32_t dag_index() const { return dag_index_; } @@ -94,10 +83,6 @@ private: class DAGUniverse : public Universe { public: - using MaterialOverrides = std::unordered_map>; - using TemperatureOverrides = std::unordered_map>; - using DensityOverrides = std::unordered_map>; - explicit DAGUniverse(pugi::xml_node node); //! Create a new DAGMC universe @@ -116,9 +101,6 @@ public: //! Initialize the DAGMC accel. data structures, indices, material //! assignments, etc. void initialize(); - void initialize(const MaterialOverrides& material_overrides, - const TemperatureOverrides& temperature_overrides, - const DensityOverrides& density_overrides = {}); //! Reads UWUW materials and returns an ID map void read_uwuw_materials(); @@ -151,11 +133,6 @@ public: void legacy_assign_material( std::string mat_string, std::unique_ptr& c) const; - //! Assign a material overriding normal assignement to a cell - //! \param[in] c The OpenMC cell to which the material is assigned - void override_assign_material(std::unique_ptr& c, - const MaterialOverrides& material_overrides) const; - //! Return the index into the model cells vector for a given DAGMC volume //! handle in the universe //! \param[in] vol MOAB handle to the DAGMC volume set @@ -177,8 +154,6 @@ public: void to_hdf5(hid_t universes_group) const override; - virtual GeometryType geom_type() const override { return GeometryType::DAG; } - // Data Members std::shared_ptr dagmc_instance_; //!< DAGMC Instance for this universe @@ -195,9 +170,7 @@ private: void set_id(); //!< Deduce the universe id from model::universes void init_dagmc(); //!< Create and initialise DAGMC pointer void init_metadata(); //!< Create and initialise dagmcMetaData pointer - void init_geometry(const MaterialOverrides& material_overrides, - const TemperatureOverrides& temperature_overrides, - const DensityOverrides& density_overrides); + void init_geometry(); //!< Create cells and surfaces from DAGMC entities std::string filename_; //!< Name of the DAGMC file used to create this universe @@ -221,6 +194,6 @@ int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ); } // namespace openmc -#endif // OPENMC_DAGMC_ENABLED +#endif // DAGMC #endif // OPENMC_DAGMC_H diff --git a/include/openmc/distribution.h b/include/openmc/distribution.h index f319dd19d..e70c803de 100644 --- a/include/openmc/distribution.h +++ b/include/openmc/distribution.h @@ -7,25 +7,14 @@ #include // for size_t #include "pugixml.hpp" +#include #include "openmc/constants.h" #include "openmc/memory.h" // for unique_ptr -#include "openmc/span.h" #include "openmc/vector.h" // for vector namespace openmc { -//============================================================================== -// Helper function for computing importance weights from biased sampling -//============================================================================== - -//! Compute importance weights for biased sampling -//! \param p Unnormalized original probability vector -//! \param b Unnormalized bias probability vector -//! \return Vector of importance weights (p_norm[i] / b_norm[i]) -vector compute_importance_weights( - const vector& p, const vector& b); - //============================================================================== //! Abstract class representing a univariate probability distribution //============================================================================== @@ -33,41 +22,11 @@ vector compute_importance_weights( class Distribution { public: virtual ~Distribution() = default; - - //! Sample a value from the distribution, handling biasing automatically - //! \param seed Pseudorandom number seed pointer - //! \return (sampled value, importance weight) - virtual std::pair sample(uint64_t* seed) const; - - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - virtual double evaluate(double x) const; + virtual double sample(uint64_t* seed) const = 0; //! Return integral of distribution //! \return Integral of distribution virtual double integral() const { return 1.0; }; - - //! Set bias distribution - virtual void set_bias(std::unique_ptr bias) - { - bias_ = std::move(bias); - } - - const Distribution* bias() const { return bias_.get(); } - -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - virtual double sample_unbiased(uint64_t* seed) const = 0; - - //! Read bias distribution from XML - //! \param node XML node that may contain a bias child element - void read_bias_from_xml(pugi::xml_node node); - - // Biasing distribution - unique_ptr bias_; }; using UPtrDist = unique_ptr; @@ -85,13 +44,13 @@ class DiscreteIndex { public: DiscreteIndex() {}; DiscreteIndex(pugi::xml_node node); - DiscreteIndex(span p); + DiscreteIndex(gsl::span p); - void assign(span p); + void assign(gsl::span p); //! Sample a value from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled index + //! \return Sampled value size_t sample(uint64_t* seed) const; // Properties @@ -108,7 +67,7 @@ private: //! Normalize distribution so that probabilities sum to unity void normalize(); - //! Initialize alias table for sampling + //! Initialize alias tables for distribution void init_alias(); }; @@ -123,30 +82,20 @@ public: //! Sample a value from the distribution //! \param seed Pseudorandom number seed pointer - //! \return (sampled value, sample weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled value + double sample(uint64_t* seed) const override; double integral() const override { return di_.integral(); }; - //! Override set_bias as no-op (bias handled in constructor) - void set_bias(std::unique_ptr bias) override {} - // Properties const vector& x() const { return x_; } const vector& prob() const { return di_.prob(); } const vector& alias() const { return di_.alias(); } - const vector& weight() const { return weight_; } - -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; private: - vector x_; //!< Possible outcomes - vector weight_; //!< Importance weights (empty if unbiased) - DiscreteIndex di_; //!< Discrete probability distribution of outcome indices + vector x_; //!< Possible outcomes + DiscreteIndex di_; //!< discrete probability distribution of + //!< outcome indices }; //============================================================================== @@ -158,20 +107,14 @@ public: explicit Uniform(pugi::xml_node node); Uniform(double a, double b) : a_ {a}, b_ {b} {}; - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - double evaluate(double x) const override; + //! Sample a value from the distribution + //! \param seed Pseudorandom number seed pointer + //! \return Sampled value + double sample(uint64_t* seed) const override; double a() const { return a_; } double b() const { return b_; } -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; - private: double a_; //!< Lower bound of distribution double b_; //!< Upper bound of distribution @@ -188,21 +131,15 @@ public: : offset_ {std::pow(a, n + 1)}, span_ {std::pow(b, n + 1) - offset_}, ninv_ {1 / (n + 1)} {}; - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - double evaluate(double x) const override; + //! Sample a value from the distribution + //! \param seed Pseudorandom number seed pointer + //! \return Sampled value + double sample(uint64_t* seed) const override; double a() const { return std::pow(offset_, ninv_); } double b() const { return std::pow(offset_ + span_, ninv_); } double n() const { return 1 / ninv_ - 1; } -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; - private: //! Store processed values in object to allow for faster sampling double offset_; //!< a^(n+1) @@ -219,18 +156,12 @@ public: explicit Maxwell(pugi::xml_node node); Maxwell(double theta) : theta_ {theta} {}; - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - double evaluate(double x) const override; - - double theta() const { return theta_; } - -protected: - //! Sample a value (unbiased) from the distribution + //! Sample a value from the distribution //! \param seed Pseudorandom number seed pointer //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; + double sample(uint64_t* seed) const override; + + double theta() const { return theta_; } private: double theta_; //!< Factor in exponential [eV] @@ -245,66 +176,41 @@ public: explicit Watt(pugi::xml_node node); Watt(double a, double b) : a_ {a}, b_ {b} {}; - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - double evaluate(double x) const override; + //! Sample a value from the distribution + //! \param seed Pseudorandom number seed pointer + //! \return Sampled value + double sample(uint64_t* seed) const override; double a() const { return a_; } double b() const { return b_; } -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; - private: double a_; //!< Factor in exponential [eV] double b_; //!< Factor in square root [1/eV] }; //============================================================================== -//! Normal distribution with optional truncation bounds. -//! -//! The standard normal PDF is 1/(sqrt(2*pi)*sigma) * -//! exp(-(x-mu)^2/(2*sigma^2)). When truncated to [lower, upper], the PDF is -//! renormalized so that it integrates to 1 over the truncation interval. +//! Normal distributions with form 1/2*std_dev*sqrt(pi) exp +//! (-(e-E0)/2*std_dev)^2 //============================================================================== class Normal : public Distribution { public: explicit Normal(pugi::xml_node node); - Normal(double mean_value, double std_dev, double lower = -INFTY, - double upper = INFTY); + Normal(double mean_value, double std_dev) + : mean_value_ {mean_value}, std_dev_ {std_dev} {}; - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x), accounting for truncation normalization - double evaluate(double x) const override; + //! Sample a value from the distribution + //! \param seed Pseudorandom number seed pointer + //! \return Sampled value + double sample(uint64_t* seed) const override; double mean_value() const { return mean_value_; } double std_dev() const { return std_dev_; } - double lower() const { return lower_; } - double upper() const { return upper_; } - bool is_truncated() const { return is_truncated_; } - -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; private: - double mean_value_; //!< Mean of distribution - double std_dev_; //!< Standard deviation - double lower_; //!< Lower truncation bound (default: -INFTY) - double upper_; //!< Upper truncation bound (default: +INFTY) - bool is_truncated_; //!< True if bounds are finite - double norm_factor_; //!< Normalization factor for truncated distribution - - //! Compute normalization factor for truncated distribution - void compute_normalization(); + double mean_value_; //!< middle of distribution [eV] + double std_dev_; //!< standard deviation [eV] }; //============================================================================== @@ -317,10 +223,10 @@ public: Tabular(const double* x, const double* p, int n, Interpolation interp, const double* c = nullptr); - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - double evaluate(double x) const override; + //! Sample a value from the distribution + //! \param seed Pseudorandom number seed pointer + //! \return Sampled value + double sample(uint64_t* seed) const override; // properties vector& x() { return x_; } @@ -329,12 +235,6 @@ public: Interpolation interp() const { return interp_; } double integral() const override { return integral_; }; -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; - private: vector x_; //!< tabulated independent variable vector p_; //!< tabulated probability density @@ -359,18 +259,12 @@ public: explicit Equiprobable(pugi::xml_node node); Equiprobable(const double* x, int n) : x_ {x, x + n} {}; - //! Evaluate probability density, f(x), at a point - //! \param x Point to evaluate f(x) - //! \return f(x) - double evaluate(double x) const override; - - const vector& x() const { return x_; } - -protected: - //! Sample a value (unbiased) from the distribution + //! Sample a value from the distribution //! \param seed Pseudorandom number seed pointer //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; + double sample(uint64_t* seed) const override; + + const vector& x() const { return x_; } private: vector x_; //! Possible outcomes @@ -386,90 +280,18 @@ public: //! Sample a value from the distribution //! \param seed Pseudorandom number seed pointer - //! \return (sampled value, sample weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled value + double sample(uint64_t* seed) const override; double integral() const override { return integral_; } - //! Override set_bias as no-op (bias handled in constructor) - void set_bias(std::unique_ptr bias) override {} - -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; - private: - vector distribution_; //!< Sub-distributions - vector weight_; //!< Importance weights for component selection - DiscreteIndex di_; //!< Discrete probability distribution of indices - double integral_; //!< Integral of distribution -}; + // Storrage for probability + distribution + using DistPair = std::pair; -//============================================================================== -// DecaySpectrum — non-owning mixture of decay photon distributions -//============================================================================== - -//! Energy distribution formed by mixing multiple decay photon spectra. -//! -//! Unlike the general Mixture distribution, this class holds non-owning -//! pointers to the component distributions (which live in -//! data::chain_nuclides). Each component is weighted by the activity -//! (atoms * decay_constant) of the corresponding nuclide. - -class DecaySpectrum : public Distribution { -public: - //============================================================================ - // Types, aliases - - struct Sample { - double energy; - double weight; - int parent_nuclide; - }; - - //============================================================================ - // Constructors - - //! Construct from an XML node containing nuclide names and atom densities. - //! - //! Reads child ```` elements with ``name`` and ``density`` - //! attributes, resolves them against the loaded depletion chain, and - //! constructs the mixed distribution. - explicit DecaySpectrum(pugi::xml_node node); - - //============================================================================ - // Methods - - //! Sample a value from the distribution and return the parent nuclide index - //! \param seed Pseudorandom number seed pointer - //! \return (Sampled energy, sample weight, chain nuclide index) - Sample sample_with_parent(uint64_t* seed) const; - - //! Sample a value from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return (sampled value, sample weight) - std::pair sample(uint64_t* seed) const override; - - double integral() const override; - -protected: - //! Sample a value (unbiased) from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled value - double sample_unbiased(uint64_t* seed) const override; - -private: - //! Initialize decay spectrum sampling data - //! \param nuclide_indices Indices of decay photon emitters in - //! data::chain_nuclides - //! \param atoms Number of atoms for each component. - void init(vector nuclide_indices, const vector& atoms); - - vector nuclide_indices_; //!< Indices of emitting nuclides in the chain - DiscreteIndex di_; //!< Discrete index for component selection - double integral_; //!< Total photon emission rate + vector + distribution_; //!< sub-distributions + cummulative probabilities + double integral_; //!< integral of distribution }; } // namespace openmc diff --git a/include/openmc/distribution_angle.h b/include/openmc/distribution_angle.h index 78de70c42..efd4e5842 100644 --- a/include/openmc/distribution_angle.h +++ b/include/openmc/distribution_angle.h @@ -26,12 +26,6 @@ public: //! \return Cosine of the angle in the range [-1,1] double sample(double E, uint64_t* seed) const; - //! Evaluate the angular PDF at a given energy and cosine - //! \param[in] E Particle energy in [eV] - //! \param[in] mu Cosine of the scattering angle - //! \return Probability density for the scattering cosine - double evaluate(double E, double mu) const; - //! Determine whether angle distribution is empty //! \return Whether distribution is empty bool empty() const { return energy_.empty(); } diff --git a/include/openmc/distribution_energy.h b/include/openmc/distribution_energy.h index efacb9131..9b08ed039 100644 --- a/include/openmc/distribution_energy.h +++ b/include/openmc/distribution_energy.h @@ -5,7 +5,7 @@ #define OPENMC_DISTRIBUTION_ENERGY_H #include "hdf5.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/constants.h" #include "openmc/endf.h" @@ -86,9 +86,9 @@ private: struct CTTable { Interpolation interpolation; //!< Interpolation law int n_discrete; //!< Number of of discrete energies - tensor::Tensor e_out; //!< Outgoing energies in [eV] - tensor::Tensor p; //!< Probability density - tensor::Tensor c; //!< Cumulative distribution + xt::xtensor e_out; //!< Outgoing energies in [eV] + xt::xtensor p; //!< Probability density + xt::xtensor c; //!< Cumulative distribution }; int n_region_; //!< Number of inteprolation regions diff --git a/include/openmc/distribution_multi.h b/include/openmc/distribution_multi.h index a72780737..9e84d03d5 100644 --- a/include/openmc/distribution_multi.h +++ b/include/openmc/distribution_multi.h @@ -6,7 +6,6 @@ #include "pugixml.hpp" #include "openmc/distribution.h" -#include "openmc/error.h" #include "openmc/position.h" namespace openmc { @@ -27,16 +26,8 @@ public: //! Sample a direction from the distribution //! \param seed Pseudorandom number seed pointer - //! \return (sampled Direction, sample weight) - virtual std::pair sample(uint64_t* seed) const = 0; - - //! Evaluate the probability density for a given direction - //! \param[in] u Direction on the unit sphere - //! \return Probability density at the given direction - virtual double evaluate(Direction u) const - { - fatal_error("evaluate not available for this UnitSphereDistribution type"); - } + //! \return Direction sampled + virtual Direction sample(uint64_t* seed) const = 0; Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction }; @@ -52,35 +43,14 @@ public: //! Sample a direction from the distribution //! \param seed Pseudorandom number seed pointer - //! \return (sampled Direction, sample weight) - std::pair sample(uint64_t* seed) const override; - - //! Sample a direction and return evaluation of the PDF for biased sampling. - //! Note that bias distributions are intended to return unit-weight samples. - //! \param seed Pseudorandom number seed points - //! \return (sampled Direction, value of the PDF at this Direction) - std::pair sample_as_bias(uint64_t* seed) const; - - //! Evaluate the probability density for a given direction - //! \param[in] u Direction on the unit sphere - //! \return Probability density at the given direction - double evaluate(Direction u) const override; + //! \return Direction sampled + Direction sample(uint64_t* seed) const override; // Observing pointers Distribution* mu() const { return mu_.get(); } Distribution* phi() const { return phi_.get(); } private: - //! Common sampling implementation - //! \param seed Pseudorandom number seed pointer - //! \param return_pdf If true, return PDF evaluation; if false, return - //! importance weight - //! \return (sampled Direction, weight or PDF value) - std::pair sample_impl( - uint64_t* seed, bool return_pdf) const; - - Direction v_ref_ {1.0, 0.0, 0.0}; //!< reference direction - Direction w_ref_; UPtrDist mu_; //!< Distribution of polar angle UPtrDist phi_; //!< Distribution of azimuthal angle }; @@ -94,29 +64,11 @@ Direction isotropic_direction(uint64_t* seed); class Isotropic : public UnitSphereDistribution { public: Isotropic() {}; - explicit Isotropic(pugi::xml_node node); //! Sample a direction from the distribution //! \param seed Pseudorandom number seed pointer - //! \return (sampled direction, sample weight) - std::pair sample(uint64_t* seed) const override; - - //! Evaluate the probability density for a given direction - //! \param[in] u Direction on the unit sphere - //! \return Probability density at the given direction - double evaluate(Direction u) const override; - - // Set or get bias distribution - void set_bias(std::unique_ptr bias) - { - bias_ = std::move(bias); - } - - const PolarAzimuthal* bias() const { return bias_.get(); } - -protected: - // Biasing distribution - unique_ptr bias_; + //! \return Sampled direction + Direction sample(uint64_t* seed) const override; }; //============================================================================== @@ -131,8 +83,8 @@ public: //! Sample a direction from the distribution //! \param seed Pseudorandom number seed pointer - //! \return (sampled direction, sample weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled direction + Direction sample(uint64_t* seed) const override; }; using UPtrAngle = unique_ptr; diff --git a/include/openmc/distribution_spatial.h b/include/openmc/distribution_spatial.h index 663cf5568..28568c890 100644 --- a/include/openmc/distribution_spatial.h +++ b/include/openmc/distribution_spatial.h @@ -6,7 +6,6 @@ #include "openmc/distribution.h" #include "openmc/mesh.h" #include "openmc/position.h" -#include "openmc/span.h" namespace openmc { @@ -19,9 +18,7 @@ public: virtual ~SpatialDistribution() = default; //! Sample a position from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - virtual std::pair sample(uint64_t* seed) const = 0; + virtual Position sample(uint64_t* seed) const = 0; static unique_ptr create(pugi::xml_node node); }; @@ -36,8 +33,8 @@ public: //! Sample a position from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled position + Position sample(uint64_t* seed) const override; // Observer pointers Distribution* x() const { return x_.get(); } @@ -60,25 +57,19 @@ public: //! Sample a position from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled position + Position sample(uint64_t* seed) const override; Distribution* r() const { return r_.get(); } Distribution* phi() const { return phi_.get(); } Distribution* z() const { return z_.get(); } Position origin() const { return origin_; } - Direction r_dir() const { return r_dir_; } - Direction phi_dir() const { return phi_dir_; } - Direction z_dir() const { return z_dir_; } private: - UPtrDist r_; //!< Distribution of r coordinates - UPtrDist phi_; //!< Distribution of phi coordinates - UPtrDist z_; //!< Distribution of z coordinates - Position origin_; //!< Cartesian coordinates of the cylinder center - Direction r_dir_; //!< Direction of r-axis at phi=0 - Direction phi_dir_; //!< Direction of phi-axis at phi=0 - Direction z_dir_; //!< Direction of z-axis + UPtrDist r_; //!< Distribution of r coordinates + UPtrDist phi_; //!< Distribution of phi coordinates + UPtrDist z_; //!< Distribution of z coordinates + Position origin_; //!< Cartesian coordinates of the cylinder center }; //============================================================================== @@ -91,8 +82,8 @@ public: //! Sample a position from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled position + Position sample(uint64_t* seed) const override; Distribution* r() const { return r_.get(); } Distribution* cos_theta() const { return cos_theta_.get(); } @@ -113,12 +104,12 @@ private: class MeshSpatial : public SpatialDistribution { public: explicit MeshSpatial(pugi::xml_node node); - explicit MeshSpatial(int32_t mesh_id, span strengths); + explicit MeshSpatial(int32_t mesh_id, gsl::span strengths); //! Sample a position from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled position + Position sample(uint64_t* seed) const override; //! Sample the mesh for an element and position within that element //! \param seed Pseudorandom number seed pointer @@ -141,29 +132,8 @@ public: private: int32_t mesh_idx_ {C_NONE}; - DiscreteIndex elem_idx_dist_; //!< Distribution of mesh element indices - vector weight_; //!< Importance weights (empty if unbiased) -}; - -//============================================================================== -//! Distribution of points -//============================================================================== - -class PointCloud : public SpatialDistribution { -public: - explicit PointCloud(pugi::xml_node node); - explicit PointCloud( - std::vector point_cloud, span strengths); - - //! Sample a position from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; - -private: - std::vector point_cloud_; - DiscreteIndex point_idx_dist_; //!< Distribution of Position indices - vector weight_; //!< Importance weights (empty if unbiased) + DiscreteIndex elem_idx_dist_; //!< Distribution of + //!< mesh element indices }; //============================================================================== @@ -173,12 +143,11 @@ private: class SpatialBox : public SpatialDistribution { public: explicit SpatialBox(pugi::xml_node node, bool fission = false); - SpatialBox(Position lower_left, Position upper_right, bool fission = false); //! Sample a position from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled position + Position sample(uint64_t* seed) const override; // Properties bool only_fissionable() const { return only_fissionable_; } @@ -203,8 +172,8 @@ public: //! Sample a position from the distribution //! \param seed Pseudorandom number seed pointer - //! \return Sampled (position, importance weight) - std::pair sample(uint64_t* seed) const override; + //! \return Sampled position + Position sample(uint64_t* seed) const override; Position r() const { return r_; } diff --git a/include/openmc/eigenvalue.h b/include/openmc/eigenvalue.h index 438747676..b456fee21 100644 --- a/include/openmc/eigenvalue.h +++ b/include/openmc/eigenvalue.h @@ -6,7 +6,7 @@ #include // for int64_t -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include #include "openmc/array.h" @@ -24,7 +24,7 @@ namespace simulation { extern double keff_generation; //!< Single-generation k on each processor extern array k_sum; //!< Used to reduce sum and sum_sq extern vector entropy; //!< Shannon entropy at each generation -extern tensor::Tensor source_frac; //!< Source fraction for UFS +extern xt::xtensor source_frac; //!< Source fraction for UFS } // namespace simulation diff --git a/include/openmc/endf.h b/include/openmc/endf.h index 34fee9758..e580874b4 100644 --- a/include/openmc/endf.h +++ b/include/openmc/endf.h @@ -33,13 +33,6 @@ bool is_disappearance(int MT); //! \return Whether corresponding reaction is an inelastic scattering reaction bool is_inelastic_scatter(int MT); -//! Determine whether an MT number matches a target MT, considering that the -//! target may be a summation reaction. -//! \param[in] event_mt MT number of the actual event -//! \param[in] target_mt MT number to check against -//! \return Whether event_mt is a component of target_mt (or equal to it) -bool mt_matches(int event_mt, int target_mt); - //============================================================================== //! Abstract one-dimensional function //============================================================================== @@ -60,10 +53,6 @@ public: //! \param[in] dset Dataset containing coefficients explicit Polynomial(hid_t dset); - //! Construct polynomial from coefficients - //! \param[in] coef Polynomial coefficients - explicit Polynomial(vector coef) : coef_(coef) {} - //! Evaluate the polynomials //! \param[in] x independent variable //! \return Polynomial evaluated at x diff --git a/include/openmc/error.h b/include/openmc/error.h index 1f6e15f49..d73795aee 100644 --- a/include/openmc/error.h +++ b/include/openmc/error.h @@ -64,14 +64,14 @@ void write_message( int level, const std::string& message, const Params&... fmt_args) { if (settings::verbosity >= level) { - write_message(fmt::format(fmt::runtime(message), fmt_args...)); + write_message(fmt::format(message, fmt_args...)); } } template void write_message(const std::string& message, const Params&... fmt_args) { - write_message(fmt::format(fmt::runtime(message), fmt_args...)); + write_message(fmt::format(message, fmt_args...)); } #ifdef OPENMC_MPI diff --git a/include/openmc/event.h b/include/openmc/event.h index 48a009f2b..2d215a10e 100644 --- a/include/openmc/event.h +++ b/include/openmc/event.h @@ -112,19 +112,6 @@ void process_collision_events(); //! \param n_particles The number of particles in the particle buffer void process_death_events(int64_t n_particles); -//! Process event queues until all are empty. Each iteration processes the -//! longest queue first to maximize vectorization efficiency. -void process_transport_events(); - -//! Initialize secondary particles from a shared secondary bank for -//! event-based transport -// -//! \param n_particles The number of particles to initialize -//! \param offset The offset index in the shared secondary bank -//! \param shared_secondary_bank The shared secondary bank to read from -void process_init_secondary_events(int64_t n_particles, int64_t offset, - const SharedArray& shared_secondary_bank); - } // namespace openmc #endif // OPENMC_EVENT_H diff --git a/include/openmc/file_utils.h b/include/openmc/file_utils.h index db6564034..6e9812d5e 100644 --- a/include/openmc/file_utils.h +++ b/include/openmc/file_utils.h @@ -5,10 +5,7 @@ namespace openmc { -// NOTE: This is a thin wrapper over std::filesystem because we -// pass strings around a lot. Objects like settings::path_input -// are extern std::string to play with other libraries and languages - +// TODO: replace with std::filesystem when switch to C++17 is made //! Determine if a path is a directory //! \param[in] path Path to check //! \return Whether the path is a directory @@ -21,8 +18,7 @@ bool file_exists(const std::string& filename); //! Determine directory containing given file //! \param[in] filename Path to file -//! \return Name of directory containing file excluding the final directory -//! separator +//! \return Name of directory containing file std::string dir_name(const std::string& filename); // Gets the file extension of whatever string is passed in. This is defined as diff --git a/include/openmc/geometry.h b/include/openmc/geometry.h index 43cf9bb58..107cc7d1f 100644 --- a/include/openmc/geometry.h +++ b/include/openmc/geometry.h @@ -3,12 +3,9 @@ #include #include -#include -#include #include "openmc/array.h" #include "openmc/constants.h" -#include "openmc/random_ray/source_region.h" // For hash_combine #include "openmc/vector.h" namespace openmc { @@ -16,34 +13,6 @@ namespace openmc { class BoundaryInfo; class GeometryState; -//============================================================================== -//! OverlapKey to store cell and universe data of a single overlap, along with -//! a functor for hashing an OverlapKey into an unordered_map. -//============================================================================== - -struct OverlapKey { - int universe_id; - int cell1_id; - int cell2_id; - - bool operator==(const OverlapKey& other) const - { - return universe_id == other.universe_id && cell1_id == other.cell1_id && - cell2_id == other.cell2_id; - } -}; - -struct OverlapKeyHash { - std::size_t operator()(const OverlapKey& k) const - { - size_t seed = 0; - hash_combine(seed, k.universe_id); - hash_combine(seed, k.cell1_id); - hash_combine(seed, k.cell2_id); - return seed; - } -}; - //============================================================================== // Global variables //============================================================================== @@ -55,10 +24,6 @@ extern "C" int n_coord_levels; //!< Number of CSG coordinate levels extern vector overlap_check_count; -// Overlap data structures get cleared every slice_data run -extern vector overlap_keys; -extern std::unordered_map overlap_key_index; - } // namespace model //============================================================================== @@ -73,7 +38,8 @@ inline bool coincident(double d1, double d2) //============================================================================== //! Check for overlapping cells at a particle's position. //============================================================================== -int check_cell_overlap(GeometryState& p, bool error = true); + +bool check_cell_overlap(GeometryState& p, bool error = true); //============================================================================== //! Get the cell instance for a particle at the specified universe level diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 4dafdea5c..0c870c9fb 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -15,6 +15,8 @@ namespace openmc { namespace model { +extern std::unordered_map> + universe_cell_counts; extern std::unordered_map universe_level_counts; } // namespace model @@ -37,12 +39,6 @@ void adjust_indices(); void assign_temperatures(); -//============================================================================== -//! Finalize densities (compute density multipliers). -//============================================================================== - -void finalize_cell_densities(); - //============================================================================== //! \brief Obtain a list of temperatures that each nuclide/thermal scattering //! table appears at in the model. Later, this list is used to determine the @@ -84,13 +80,15 @@ void prepare_distribcell( const std::vector* user_distribcells = nullptr); //============================================================================== -//! Recursively search through the geometry and count universe instances. +//! Recursively search through the geometry and count cell instances. //! -//! This function will update Universe.n_instances_ for each -//! universe in the geometry. +//! This function will update the Cell::n_instances value for each cell in the +//! geometry. +//! \param univ_indx The index of the universe to begin searching from (probably +//! the root universe). //============================================================================== -void count_universe_instances(); +void count_cell_instances(int32_t univ_indx); //============================================================================== //! Recursively search through universes and count universe instances. diff --git a/include/openmc/hdf5_interface.h b/include/openmc/hdf5_interface.h index 93e4bfc82..0092c08f8 100644 --- a/include/openmc/hdf5_interface.h +++ b/include/openmc/hdf5_interface.h @@ -11,7 +11,8 @@ #include "hdf5.h" #include "hdf5_hl.h" -#include "openmc/tensor.h" +#include "xtensor/xadapt.hpp" +#include "xtensor/xarray.hpp" #include "openmc/array.h" #include "openmc/error.h" @@ -99,8 +100,8 @@ void read_llong(hid_t obj_id, const char* name, long long* buffer, bool indep); void read_string( hid_t obj_id, const char* name, size_t slen, char* buffer, bool indep); -void read_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score, - hsize_t n_results, double* results); +void read_tally_results( + hid_t group_id, hsize_t n_filter, hsize_t n_score, double* results); void write_attr_double(hid_t obj_id, int ndim, const hsize_t* dims, const char* name, const double* buffer); void write_attr_int(hid_t obj_id, int ndim, const hsize_t* dims, @@ -113,9 +114,9 @@ void write_int(hid_t group_id, int ndim, const hsize_t* dims, const char* name, void write_llong(hid_t group_id, int ndim, const hsize_t* dims, const char* name, const long long* buffer, bool indep); void write_string(hid_t group_id, int ndim, const hsize_t* dims, size_t slen, - const char* name, const char* buffer, bool indep); -void write_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score, - hsize_t n_results, const double* results); + const char* name, char const* buffer, bool indep); +void write_tally_results( + hid_t group_id, hsize_t n_filter, hsize_t n_score, const double* results); } // extern "C" //============================================================================== @@ -165,19 +166,24 @@ void read_attribute(hid_t obj_id, const char* name, vector& vec) read_attr(obj_id, name, H5TypeMap::type_id, vec.data()); } -// Tensor version +// Generic array version template -void read_attribute(hid_t obj_id, const char* name, tensor::Tensor& tensor) +void read_attribute(hid_t obj_id, const char* name, xt::xarray& arr) { - // Get shape of attribute + // Get shape of attribute array auto shape = attribute_shape(obj_id, name); - // Resize tensor and read data directly - vector tshape(shape.begin(), shape.end()); - tensor.resize(tshape); + // Allocate new array to read data into + std::size_t size = 1; + for (const auto x : shape) + size *= x; + vector buffer(size); // Read data from attribute - read_attr(obj_id, name, H5TypeMap::type_id, tensor.data()); + read_attr(obj_id, name, H5TypeMap::type_id, buffer.data()); + + // Adapt array into xarray + arr = xt::adapt(buffer, shape); } // overload for std::string @@ -284,34 +290,63 @@ void read_dataset( } template -void read_dataset(hid_t dset, tensor::Tensor& tensor, bool indep = false) +void read_dataset(hid_t dset, xt::xarray& arr, bool indep = false) { // Get shape of dataset vector shape = object_shape(dset); - // Resize tensor and read data directly - vector tshape(shape.begin(), shape.end()); - tensor.resize(tshape); + // Allocate space in the array to read data into + std::size_t size = 1; + for (const auto x : shape) + size *= x; + arr.resize(shape); - // Read data from dataset + // Read data from attribute read_dataset_lowlevel( - dset, nullptr, H5TypeMap::type_id, H5S_ALL, indep, tensor.data()); + dset, nullptr, H5TypeMap::type_id, H5S_ALL, indep, arr.data()); } template<> void read_dataset( - hid_t dset, tensor::Tensor>& tensor, bool indep); + hid_t dset, xt::xarray>& arr, bool indep); template void read_dataset( - hid_t obj_id, const char* name, tensor::Tensor& tensor, bool indep = false) + hid_t obj_id, const char* name, xt::xarray& arr, bool indep = false) { - // Open dataset and read tensor + // Open dataset and read array hid_t dset = open_dataset(obj_id, name); - read_dataset(dset, tensor, indep); + read_dataset(dset, arr, indep); close_dataset(dset); } +template +void read_dataset( + hid_t obj_id, const char* name, xt::xtensor& arr, bool indep = false) +{ + // Open dataset and read array + hid_t dset = open_dataset(obj_id, name); + + // Get shape of dataset + vector hsize_t_shape = object_shape(dset); + close_dataset(dset); + + // cast from hsize_t to size_t + vector shape(hsize_t_shape.size()); + for (int i = 0; i < shape.size(); i++) { + shape[i] = static_cast(hsize_t_shape[i]); + } + + // Allocate new xarray to read data into + xt::xarray xarr(shape); + + // Read data from the dataset + read_dataset(obj_id, name, xarr); + + // Copy into xtensor + arr = xarr; +} + // overload for Position inline void read_dataset( hid_t obj_id, const char* name, Position& r, bool indep = false) @@ -323,22 +358,31 @@ inline void read_dataset( r.z = x[2]; } -template +template inline void read_dataset_as_shape( - hid_t obj_id, const char* name, tensor::Tensor& tensor, bool indep = false) + hid_t obj_id, const char* name, xt::xtensor& arr, bool indep = false) { hid_t dset = open_dataset(obj_id, name); - // Read data directly into pre-shaped tensor + // Allocate new array to read data into + std::size_t size = 1; + for (const auto x : arr.shape()) + size *= x; + vector buffer(size); + + // Read data from attribute read_dataset_lowlevel( - dset, nullptr, H5TypeMap::type_id, H5S_ALL, indep, tensor.data()); + dset, nullptr, H5TypeMap::type_id, H5S_ALL, indep, buffer.data()); + + // Adapt into xarray + arr = xt::adapt(buffer, arr.shape()); close_dataset(dset); } -template -inline void read_nd_tensor(hid_t obj_id, const char* name, - tensor::Tensor& result, bool must_have = false) +template +inline void read_nd_vector(hid_t obj_id, const char* name, + xt::xtensor& result, bool must_have = false) { if (object_exists(obj_id, name)) { read_dataset_as_shape(obj_id, name, result, true); @@ -452,16 +496,12 @@ inline void write_dataset( false, buffer.data()); } -// Template for Tensor and StaticTensor2D. A SFINAE guard is used here to -// prevent this template from matching vector/string types that have their own -// overloads above. A generic Container parameter avoids duplicating the body -// for both Tensor and StaticTensor2D. -template>::value>> -inline void write_dataset(hid_t obj_id, const char* name, const Container& arr) +// Template for xarray, xtensor, etc. +template +inline void write_dataset( + hid_t obj_id, const char* name, const xt::xcontainer& arr) { - using T = typename std::decay_t::value_type; + using T = typename D::value_type; auto s = arr.shape(); vector dims {s.cbegin(), s.cend()}; write_dataset_lowlevel(obj_id, dims.size(), dims.data(), name, diff --git a/include/openmc/ifp.h b/include/openmc/ifp.h deleted file mode 100644 index 2b751d66f..000000000 --- a/include/openmc/ifp.h +++ /dev/null @@ -1,222 +0,0 @@ -#ifndef OPENMC_IFP_H -#define OPENMC_IFP_H - -#include "openmc/message_passing.h" -#include "openmc/particle.h" -#include "openmc/particle_data.h" -#include "openmc/settings.h" - -#include // for copy - -namespace openmc { - -//! Check the value of the IFP parameter for beta effective or both. -//! -//! \return true if "BetaEffective" or "Both", false otherwise. -bool is_beta_effective_or_both(); - -//! Check the value of the IFP parameter for generation time or both. -//! -//! \return true if "GenerationTime" or "Both", false otherwise. -bool is_generation_time_or_both(); - -//! Resize IFP vectors -//! -//! \param[in,out] delayed_groups List of delayed group numbers -//! \param[in,out] lifetimes List of lifetimes -//! \param[in] n Dimension to resize vectors -template -void resize_ifp_data(vector& delayed_groups, vector& lifetimes, int64_t n) -{ - if (is_beta_effective_or_both()) { - delayed_groups.resize(n); - } - if (is_generation_time_or_both()) { - lifetimes.resize(n); - } -} - -//! Update a list of values by adding a new value if the size -//! of the list can accomodate the new value or by shifting all -//! values to the left (removing the first value of the list -//! and adding the new value at the end of the list). -//! -//! \param[in] value Value to add to the list -//! \param[in] data Initial version of the list -//! \return Updated list -template -vector _ifp(const T& value, const vector& data) -{ - vector updated; - size_t source_idx = data.size(); - - if (source_idx < settings::ifp_n_generation) { - updated.resize(source_idx + 1); - for (size_t i = 0; i < source_idx; i++) { - updated[i] = data[i]; - } - updated[source_idx] = value; - } else if (source_idx == settings::ifp_n_generation) { - updated.resize(source_idx); - for (size_t i = 0; i < source_idx - 1; i++) { - updated[i] = data[i + 1]; - } - updated[source_idx - 1] = value; - } - return updated; -} - -//! \brief Iterated Fission Probability (IFP) method. -//! -//! Add the IFP information in the IFP banks using the same index -//! as the one used to append the fission site to the fission bank. -//! The information stored are the delayed group number and lifetime -//! of the neutron that created the fission event. -//! Multithreading protection is guaranteed by the index returned by the -//! thread_safe_append call in physics.cpp. -//! -//! \param[in] p Particle -//! \param[in] idx Bank index from the thread_safe_append call in physics.cpp -void ifp(const Particle& p, int64_t idx); - -//! Resize the IFP banks used in the simulation -void resize_simulation_ifp_banks(); - -//! Retrieve IFP data from the IFP fission banks. -//! -//! \param[in] i_bank Index in the fission banks -//! \param[in,out] delayed_groups Delayed group numbers -//! \param[in,out] lifetimes Lifetimes lists -void copy_ifp_data_from_fission_banks( - int i_bank, vector& delayed_groups, vector& lifetimes); - -#ifdef OPENMC_MPI - -//! Deserialization information for transfer of IFP data using MPI -struct DeserializationInfo { - int64_t index_local; //!< local index - int64_t n; //!< number of sites sent -}; - -//! Broadcast the number of generation determined by the size of the first -//! element on the first processor. -//! -//! \param[in] n_generation Number of generations -//! \param[in] delayed_groups List of delayed group numbers lists -//! \param[in] lifetimes List of lifetimes lists -void broadcast_ifp_n_generation(int& n_generation, - const vector>& delayed_groups, - const vector>& lifetimes); - -//! Send IFP data using MPI. -//! -//! \param[in] idx Index of the first site -//! \param[in] n Number of sites to send -//! \param[in] n_generation Number of generations -//! \param[in] neighbor Index of the neighboring processor -//! \param[in] requests MPI requests -//! \param[in] data List of data lists -//! \param[out] send_data data buffer -template -void send_ifp_info(int64_t idx, int64_t n, int n_generation, int neighbor, - vector& requests, const vector>& data, - vector& send_data) -{ - // Copy data in buffer - for (int i = idx; i < idx + n; i++) { - std::copy( - data[i].begin(), data[i].end(), send_data.begin() + i * n_generation); - } - - // Send data - requests.emplace_back(); - MPI_Datatype datatype = mpi::MPITypeMap::mpi_type; - MPI_Isend(&send_data[n_generation * idx], n_generation * static_cast(n), - datatype, neighbor, mpi::rank, mpi::intracomm, &requests.back()); -} - -//! Receive IFP data using MPI. -//! -//! \param[in] idx Index of the first site -//! \param[in] n Number of sites to receive -//! \param[in] n_generation Number of generations -//! \param[in] neighbor Index of the neighboring processor -//! \param[in] requests MPI requests -//! \param[in] data data buffer -//! \param[out] deserialization Information to deserialize the received data -template -void receive_ifp_data(int64_t idx, int64_t n, int n_generation, int neighbor, - vector& requests, vector& data, - vector& deserialization) -{ - requests.emplace_back(); - MPI_Datatype datatype = mpi::MPITypeMap::mpi_type; - MPI_Irecv(&data[n_generation * idx], n_generation * static_cast(n), - datatype, neighbor, neighbor, mpi::intracomm, &requests.back()); - - // Deserialization info to reconstruct data later - DeserializationInfo info = {idx, n}; - deserialization.push_back(info); -} - -//! Copy partial IFP data from local lists to source banks. -//! -//! \param[in] idx Index of the first site -//! \param[in] n Number of sites to copy -//! \param[in] i_bank Index in the IFP source banks -//! \param[in] delayed_groups List of delayed group numbers lists -//! \param[in] lifetimes List of lifetimes lists -void copy_partial_ifp_data_to_source_banks(int64_t idx, int n, int64_t i_bank, - const vector>& delayed_groups, - const vector>& lifetimes); - -//! Deserialize IFP information received using MPI and store it in -//! the IFP source banks. -//! -//! \param[in] n_generation Number of generations -//! \param[in] data data to deserialize -//! \param[in] bank bank to store data -//! \param[out] deserialization Information to deserialize the received data -template -void deserialize_ifp_info(int n_generation, const vector& data, - vector>& bank, const vector& deserialization) -{ - for (auto info : deserialization) { - int64_t index_local = info.index_local; - int64_t n = info.n; - - for (int i = index_local; i < index_local + n; i++) { - vector data_received( - data.begin() + n_generation * i, data.begin() + n_generation * (i + 1)); - bank[i] = data_received; - } - } -} - -#endif - -//! Copy IFP temporary vectors to source banks. -//! -//! \param[in] delayed_groups List of delayed group numbers lists -//! \param[in] lifetimes List of lifetimes lists -void copy_complete_ifp_data_to_source_banks( - const vector>& delayed_groups, - const vector>& lifetimes); - -//! Allocate temporary vectors for IFP data. -//! -//! \param[in,out] delayed_groups List of delayed group numbers lists -//! \param[in,out] lifetimes List of delayed group numbers lists -void allocate_temporary_vector_ifp( - vector>& delayed_groups, vector>& lifetimes); - -//! Copy local IFP data to IFP fission banks. -//! -//! \param[in] delayed_groups_ptr Pointer to delayed group numbers -//! \param[in] lifetimes_ptr Pointer to lifetimes -void copy_ifp_data_to_fission_banks( - const vector* delayed_groups_ptr, const vector* lifetimes_ptr); - -} // namespace openmc - -#endif // OPENMC_IFP_H diff --git a/include/openmc/interpolate.h b/include/openmc/interpolate.h index 31ae8b0e3..db501f71b 100644 --- a/include/openmc/interpolate.h +++ b/include/openmc/interpolate.h @@ -4,9 +4,10 @@ #include #include +#include + #include "openmc/error.h" #include "openmc/search.h" -#include "openmc/span.h" namespace openmc { @@ -35,8 +36,8 @@ inline double interpolate_log_log( return y0 * std::exp(f * std::log(y1 / y0)); } -inline double interpolate_lagrangian( - span xs, span ys, int idx, double x, int order) +inline double interpolate_lagrangian(gsl::span xs, + gsl::span ys, int idx, double x, int order) { double output {0.0}; @@ -55,8 +56,9 @@ inline double interpolate_lagrangian( return output; } -inline double interpolate(span xs, span ys, - double x, Interpolation i = Interpolation::lin_lin) +inline double interpolate(gsl::span xs, + gsl::span ys, double x, + Interpolation i = Interpolation::lin_lin) { int idx = lower_bound_index(xs.begin(), xs.end(), x); diff --git a/include/openmc/lattice.h b/include/openmc/lattice.h index ca40bbc2a..429d81ddd 100644 --- a/include/openmc/lattice.h +++ b/include/openmc/lattice.h @@ -71,12 +71,11 @@ public: //! Allocate offset table for distribcell. void allocate_offset_table(int n_maps) { - offsets_.resize(n_maps * universes_.size()); - std::fill(offsets_.begin(), offsets_.end(), C_NONE); + offsets_.resize(n_maps * universes_.size(), C_NONE); } //! Populate the distribcell offset tables. - int32_t fill_offset_table(int32_t target_univ_id, int map, + int32_t fill_offset_table(int32_t offset, int32_t target_univ_id, int map, std::unordered_map& univ_count_memo); //! \brief Check lattice indices. @@ -113,14 +112,6 @@ public: virtual Position get_local_position( Position r, const array& i_xyz) const = 0; - //! \brief get the normal of the lattice surface crossing - //! \param[in] i_xyz The indices for the lattice translation. - //! \param[out] is_valid is the lattice translation correspond to a valid - //! surface. \return The surface normal corresponding to the lattice - //! translation. - virtual Direction get_normal( - const array& i_xyz, bool& is_valid) const = 0; - //! \brief Check flattened lattice index. //! \param indx The index for a lattice tile. //! \return true if the given index fit within the lattice bounds. False @@ -231,9 +222,6 @@ public: Position get_local_position( Position r, const array& i_xyz) const override; - Direction get_normal( - const array& i_xyz, bool& is_valid) const override; - int32_t& offset(int map, const array& i_xyz) override; int32_t offset(int map, int indx) const override; @@ -279,9 +267,6 @@ public: Position get_local_position( Position r, const array& i_xyz) const override; - Direction get_normal( - const array& i_xyz, bool& is_valid) const override; - bool is_valid_index(int indx) const override; int32_t& offset(int map, const array& i_xyz) override; diff --git a/include/openmc/material.h b/include/openmc/material.h index 3967c3687..9235be356 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -4,9 +4,9 @@ #include #include -#include "openmc/span.h" -#include "openmc/tensor.h" #include "pugixml.hpp" +#include "xtensor/xtensor.hpp" +#include #include #include "openmc/bremsstrahlung.h" @@ -14,7 +14,6 @@ #include "openmc/memory.h" // for unique_ptr #include "openmc/ncrystal_interface.h" #include "openmc/particle.h" -#include "openmc/settings.h" #include "openmc/vector.h" namespace openmc { @@ -100,27 +99,13 @@ public: //---------------------------------------------------------------------------- // Accessors - //! Get the atom density in [atom/b-cm] - //! \return Density in [atom/b-cm] - double atom_density(int32_t i, double rho_multiplier = 1.0) const - { - return atom_density_(i) * rho_multiplier; - } - //! Get density in [atom/b-cm] //! \return Density in [atom/b-cm] double density() const { return density_; } - //! Get density in [g/cm^3]. + //! Get density in [g/cm^3] //! \return Density in [g/cm^3] - double density_gpcc() const - { - return settings::run_CE ? density_gpcc_ : density(); - } - - //! Get charge density in [e/b-cm] - //! \return Charge density in [e/b-cm] - double charge_density() const { return charge_density_; }; + double density_gpcc() const { return density_gpcc_; } //! Get name //! \return Material name @@ -133,21 +118,21 @@ public: // //! \param[in] density Density value //! \param[in] units Units of density - void set_density(double density, const std::string& units); + void set_density(double density, gsl::cstring_span units); //! Set temperature of the material void set_temperature(double temperature) { temperature_ = temperature; }; //! Get nuclides in material //! \return Indices into the global nuclides vector - span nuclides() const + gsl::span nuclides() const { return {nuclide_.data(), nuclide_.size()}; } //! Get densities of each nuclide in material //! \return Densities in [atom/b-cm] - span densities() const + gsl::span densities() const { return {atom_density_.data(), atom_density_.size()}; } @@ -189,10 +174,9 @@ public: vector nuclide_; //!< Indices in nuclides vector vector element_; //!< Indices in elements vector NCrystalMat ncrystal_mat_; //!< NCrystal material object - tensor::Tensor atom_density_; //!< Nuclide atom density in [atom/b-cm] + xt::xtensor atom_density_; //!< Nuclide atom density in [atom/b-cm] double density_; //!< Total atom density in [atom/b-cm] double density_gpcc_; //!< Total atom density in [g/cm^3] - double charge_density_; //!< Total charge density in [e/b-cm] double volume_ {-1.0}; //!< Volume in [cm^3] vector p0_; //!< Indicate which nuclides are to be treated with //!< iso-in-lab scattering @@ -226,7 +210,7 @@ private: //---------------------------------------------------------------------------- // Private data members - int64_t index_; + gsl::index index_; bool depletable_ {false}; //!< Is the material depletable? bool fissionable_ { diff --git a/include/openmc/math_functions.h b/include/openmc/math_functions.h index d3bccca7b..c30ef7558 100644 --- a/include/openmc/math_functions.h +++ b/include/openmc/math_functions.h @@ -9,7 +9,6 @@ #include #include "openmc/position.h" -#include "openmc/search.h" namespace openmc { @@ -201,63 +200,5 @@ std::complex faddeeva(std::complex z); //! \return Derivative of Faddeeva function evaluated at z std::complex w_derivative(std::complex z, int order); -//! Evaluate relative exponential function -//! -//! \param x Real argument -//! \return (exp(x)-1)/x without loss of precision near 0 -double exprel(double x); - -//! Evaluate relative logarithm function -//! -//! \param x Real argument -//! \return log(1+x)/x without loss of precision near 0 -double log1prel(double x); - -//! Evaluate the cylindrical Bessel function of the first kind J_n(x) -//! -//! Uses std::cyl_bessel_j where available (e.g., libstdc++). On standard -//! library implementations lacking the C++17 special math functions (e.g., -//! libc++ on Apple Clang/LLVM), falls back to the ascending power series, -//! which converges to machine precision for the small arguments (|x| <= 2) -//! used in OpenMC. Unlike std::cyl_bessel_j, negative arguments are handled -//! via the parity relation J_n(-x) = (-1)^n J_n(x). -//! -//! \param n Non-negative integer order of the Bessel function -//! \param x Real argument -//! \return J_n(x) -double cyl_bessel_j(int n, double x); - -//! Helper function to get index and interpolation function on an incident -//! energy grid -//! -//! \param energies energy grid -//! \param E incident energy -//! \param i grid index -//! \param f interpolation factor -void get_energy_index( - const vector& energies, double E, int& i, double& f); - -//============================================================================== -//! Calculate the cumulative distribution function of the standard normal -//! distribution at a given value. -//! -//! \param z The value at which to evaluate the CDF -//! \return Phi(z) = P(X <= z) for X ~ N(0,1) -//============================================================================== - -double standard_normal_cdf(double z); - -//============================================================================== -//! Return true if two floating-point values are approximately equal within a -//! combined relative and absolute tolerance. -//! -//! \param a first floating point value -//! \param b second floating point value -//! \param rel_tol relative tolerance -//! \param abs_tol absolute tolerance -//! \return true if a and b are approximately equal, false otherwise -//============================================================================== -bool isclose(double a, double b, double rel_tol, double abs_tol); - } // namespace openmc #endif // OPENMC_MATH_FUNCTIONS_H diff --git a/include/openmc/mcpl_interface.h b/include/openmc/mcpl_interface.h index a9cce3e69..1f0c94d6d 100644 --- a/include/openmc/mcpl_interface.h +++ b/include/openmc/mcpl_interface.h @@ -2,13 +2,20 @@ #define OPENMC_MCPL_INTERFACE_H #include "openmc/particle_data.h" -#include "openmc/span.h" #include "openmc/vector.h" +#include + #include namespace openmc { +//============================================================================== +// Constants +//============================================================================== + +extern "C" const bool MCPL_ENABLED; + //============================================================================== // Functions //============================================================================== @@ -19,46 +26,17 @@ namespace openmc { //! \return Vector of source sites vector mcpl_source_sites(std::string path); -//! Write an MCPL source file with stat:sum metadata -//! -//! This function writes particle data to an MCPL file. For MCPL >= 2.1.0, -//! it includes a stat:sum field (key: "openmc_np1") containing the total -//! number of source particles, which is essential for proper file merging -//! and weight normalization when using MCPL files with McStas/McXtrace. -//! -//! The stat:sum field follows the crash-safety pattern: -//! - Initially set to -1 when opening (indicates incomplete file) -//! - Updated with actual particle count before closing -//! +//! Write an MCPL source file +// //! \param[in] filename Path to MCPL file //! \param[in] source_bank Vector of SourceSites to write to file for this -//! MPI rank. -//! \param[in] bank_index Pointer to vector of site index ranges over all -//! MPI ranks. -void write_mcpl_source_point(const char* filename, span source_bank, - const vector& bank_index); - -//! Write an MCPL collision track file -//! -//! This function writes collision track data to an MCPL file. Additional -//! collision-specific metadata (such as energy deposition, material info, etc.) -//! is stored in the file header as blob data. -//! -//! \param[in] filename Path to MCPL file -//! \param[in] collision_track_bank Vector of CollisionTrackSites to write to -//! file for this MPI rank. -//! \param[in] bank_index Pointer to vector of site index ranges over all -//! MPI ranks. -void write_mcpl_collision_track(const char* filename, - span collision_track_bank, - const vector& bank_index); - -//! Check if MCPL functionality is available -bool is_mcpl_interface_available(); - -//! Initialize the MCPL interface -void initialize_mcpl_interface_if_needed(); - +//! MPI rank +//! \param[in] bank_indx Pointer to vector of site index ranges over all +//! MPI ranks. This can be computed by calling +//! calculate_parallel_index_vector on +//! source_bank.size(). +void write_mcpl_source_point(const char* filename, + gsl::span source_bank, vector const& bank_index); } // namespace openmc #endif // OPENMC_MCPL_INTERFACE_H diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 0d8189caa..3917e6368 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -4,30 +4,28 @@ #ifndef OPENMC_MESH_H #define OPENMC_MESH_H -#include #include #include "hdf5.h" -#include "openmc/tensor.h" #include "pugixml.hpp" +#include "xtensor/xtensor.hpp" +#include -#include "openmc/bounding_box.h" #include "openmc/error.h" #include "openmc/memory.h" // for unique_ptr #include "openmc/particle.h" #include "openmc/position.h" -#include "openmc/span.h" #include "openmc/vector.h" #include "openmc/xml_interface.h" -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC #include "moab/AdaptiveKDTree.hpp" #include "moab/Core.hpp" #include "moab/GeomUtil.hpp" #include "moab/Matrix3.hpp" #endif -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH #include "libmesh/bounding_box.h" #include "libmesh/dof_map.h" #include "libmesh/elem.h" @@ -62,7 +60,7 @@ extern vector> meshes; } // namespace model -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH namespace settings { // used when creating new libMesh::MeshBase instances extern unique_ptr libmesh_init; @@ -70,99 +68,25 @@ extern const libMesh::Parallel::Communicator* libmesh_comm; } // namespace settings #endif -//============================================================================== -//! Helper class for keeping track of volume for each material in a mesh element -// -//! This class is used in Mesh::material_volumes to manage for each mesh element -//! a list of (material, volume) pairs. The openmc.lib.Mesh class allocates two -//! 2D arrays, one for materials and one for volumes. Because we don't know a -//! priori how many materials there are in each element but at the same time we -//! can't dynamically size an array at runtime for performance reasons, we -//! assume a maximum number of materials per element. For each element, the set -//! of material indices are stored in a hash table with twice as many slots as -//! the assumed maximum number of materials per element. Collision resolution is -//! handled by open addressing with linear probing. -//============================================================================== - -namespace detail { - -class MaterialVolumes { -public: - MaterialVolumes(int32_t* mats, double* vols, double* bboxes, int table_size) - : materials_(mats), volumes_(vols), bboxes_(bboxes), table_size_(table_size) - {} - - MaterialVolumes(int32_t* mats, double* vols, int table_size) - : MaterialVolumes(mats, vols, nullptr, table_size) - {} - - //! Add volume for a given material in a mesh element - // - //! \param[in] index_elem Index of the mesh element - //! \param[in] index_material Index of the material within the model - //! \param[in] volume Volume to add - //! \param[in] bbox Bounding box to union into the result (optional) - void add_volume(int index_elem, int index_material, double volume, - const BoundingBox* bbox = nullptr); - void add_volume_unsafe(int index_elem, int index_material, double volume, - const BoundingBox* bbox = nullptr); - - // Accessors - int32_t& materials(int i, int j) { return materials_[i * table_size_ + j]; } - const int32_t& materials(int i, int j) const - { - return materials_[i * table_size_ + j]; - } - - double& volumes(int i, int j) { return volumes_[i * table_size_ + j]; } - const double& volumes(int i, int j) const - { - return volumes_[i * table_size_ + j]; - } - - double& bboxes(int i, int j, int k) - { - return bboxes_[(i * table_size_ + j) * 6 + k]; - } - const double& bboxes(int i, int j, int k) const - { - return bboxes_[(i * table_size_ + j) * 6 + k]; - } - - bool has_bboxes() const { return bboxes_ != nullptr; } - - bool table_full() const { return table_full_; } - -private: - int32_t* materials_; //!< material index (bins, table_size) - double* volumes_; //!< volume in [cm^3] (bins, table_size) - double* bboxes_; //!< bounding boxes (bins, table_size, 6) - int table_size_; //!< Size of hash table for each mesh element - bool table_full_ {false}; //!< Whether the hash table is full -}; - -} // namespace detail - -//============================================================================== -//! Base mesh class -//============================================================================== - class Mesh { public: + // Types, aliases + struct MaterialVolume { + int32_t material; //!< material index + double volume; //!< volume in [cm^3] + }; + // Constructors and destructor Mesh() = default; Mesh(pugi::xml_node node); - Mesh(hid_t group); virtual ~Mesh() = default; - // Factory method for creating meshes from either an XML node or HDF5 group - template - static const std::unique_ptr& create( - T dataset, const std::string& mesh_type, const std::string& mesh_library); - // Methods - //! Perform any preparation needed to support point location within the mesh - virtual void prepare_for_point_location() {}; + //! Perform any preparation needed to support use in mesh filters + virtual void prepare_for_tallies() {}; + + //! Update a position to the local coordinates of the mesh + virtual void local_coords(Position& r) const {}; //! Return a position in the local coordinates of the mesh virtual Position local_coords(const Position& r) const { return r; }; @@ -207,18 +131,13 @@ public: int32_t id() const { return id_; } - const std::string& name() const { return name_; } - //! Set the mesh ID void set_id(int32_t id = -1); - //! Write the mesh data to an HDF5 group - void to_hdf5(hid_t group) const; - //! Write mesh data to an HDF5 group // //! \param[in] group HDF5 group - virtual void to_hdf5_inner(hid_t group) const = 0; + virtual void to_hdf5(hid_t group) const = 0; //! Find the mesh lines that intersect an axis-aligned slice plot // @@ -247,55 +166,34 @@ public: virtual std::string get_mesh_type() const = 0; - //! Determine volume of materials within each mesh element + //! Determine volume of materials within a single mesh elemenet // - //! \param[in] nx Number of samples in x direction - //! \param[in] ny Number of samples in y direction - //! \param[in] nz Number of samples in z direction - //! \param[in] max_materials Maximum number of materials in a single mesh - //! element - //! \param[inout] materials Array storing material indices - //! \param[inout] volumes Array storing volumes - void material_volumes(int nx, int ny, int nz, int max_materials, - int32_t* materials, double* volumes) const; + //! \param[in] n_sample Number of samples within each element + //! \param[in] bin Index of mesh element + //! \param[out] Array of (material index, volume) for desired element + //! \param[inout] seed Pseudorandom number seed + //! \return Number of materials within element + int material_volumes(int n_sample, int bin, gsl::span volumes, + uint64_t* seed) const; - //! Determine volume and bounding boxes of materials within each mesh element + //! Determine volume of materials within a single mesh elemenet // - //! \param[in] nx Number of samples in x direction - //! \param[in] ny Number of samples in y direction - //! \param[in] nz Number of samples in z direction - //! \param[in] max_materials Maximum number of materials in a single mesh - //! element - //! \param[inout] materials Array storing material indices - //! \param[inout] volumes Array storing volumes - //! \param[inout] bboxes Array storing bounding boxes (n_elems, table_size, 6) - void material_volumes(int nx, int ny, int nz, int max_materials, - int32_t* materials, double* volumes, double* bboxes) const; - - //! Determine bounding box of mesh - // - //! \return Bounding box of mesh - BoundingBox bounding_box() const - { - return {this->lower_left(), this->upper_right()}; - } - - virtual Position lower_left() const = 0; - virtual Position upper_right() const = 0; + //! \param[in] n_sample Number of samples within each element + //! \param[in] bin Index of mesh element + //! \param[inout] seed Pseudorandom number seed + //! \return Vector of (material index, volume) for desired element + vector material_volumes( + int n_sample, int bin, uint64_t* seed) const; // Data members - tensor::Tensor lower_left_; //!< Lower-left coordinates of mesh - tensor::Tensor upper_right_; //!< Upper-right coordinates of mesh - int id_ {-1}; //!< Mesh ID - std::string name_; //!< User-specified name - int n_dimension_ {-1}; //!< Number of dimensions + int id_ {-1}; //!< User-specified ID + int n_dimension_ {-1}; //!< Number of dimensions }; class StructuredMesh : public Mesh { public: StructuredMesh() = default; StructuredMesh(pugi::xml_node node) : Mesh {node} {}; - StructuredMesh(hid_t group) : Mesh {group} {}; virtual ~StructuredMesh() = default; using MeshIndex = std::array; @@ -348,7 +246,7 @@ public: //! \param[in] Pointer to bank sites //! \param[in] Number of bank sites //! \param[out] Whether any bank sites are outside the mesh - tensor::Tensor count_sites( + xt::xtensor count_sites( const SourceSite* bank, int64_t length, bool* outside) const; //! Get bin given mesh indices @@ -419,38 +317,22 @@ public: //! Get a label for the mesh bin std::string bin_label(int bin) const override; - //! Get mesh dimensions as a tensor - tensor::Tensor get_shape_tensor() const; + //! Get shape as xt::xtensor + xt::xtensor get_x_shape() const; double volume(int bin) const override { return this->volume(get_indices_from_bin(bin)); } - Position lower_left() const override - { - int n = lower_left_.size(); - Position ll {lower_left_[0], 0.0, 0.0}; - ll.y = (n >= 2) ? lower_left_[1] : -INFTY; - ll.z = (n == 3) ? lower_left_[2] : -INFTY; - return ll; - }; - - Position upper_right() const override - { - int n = upper_right_.size(); - Position ur {upper_right_[0], 0.0, 0.0}; - ur.y = (n >= 2) ? upper_right_[1] : INFTY; - ur.z = (n == 3) ? upper_right_[2] : INFTY; - return ur; - }; - //! Get the volume of a specified element //! \param[in] ijk Mesh index to return the volume for //! \return Volume of the bin virtual double volume(const MeshIndex& ijk) const = 0; // Data members + xt::xtensor lower_left_; //!< Lower-left coordinates of mesh + xt::xtensor upper_right_; //!< Upper-right coordinates of mesh std::array shape_; //!< Number of mesh elements in each dimension protected: @@ -461,7 +343,8 @@ class PeriodicStructuredMesh : public StructuredMesh { public: PeriodicStructuredMesh() = default; PeriodicStructuredMesh(pugi::xml_node node) : StructuredMesh {node} {}; - PeriodicStructuredMesh(hid_t group) : StructuredMesh {group} {}; + + void local_coords(Position& r) const override { r -= origin_; }; Position local_coords(const Position& r) const override { @@ -481,7 +364,6 @@ public: // Constructors RegularMesh() = default; RegularMesh(pugi::xml_node node); - RegularMesh(hid_t group); // Overridden methods int get_index_in_direction(double r, int i) const override; @@ -496,7 +378,7 @@ public: std::pair, vector> plot( Position plot_ll, Position plot_ur) const override; - void to_hdf5_inner(hid_t group) const override; + void to_hdf5(hid_t group) const override; //! Get the coordinate for the mesh grid boundary in the positive direction //! @@ -515,18 +397,16 @@ public: //! \param[in] bank Array of bank sites //! \param[out] Whether any bank sites are outside the mesh //! \return Array indicating number of sites in each mesh/energy bin - tensor::Tensor count_sites( + xt::xtensor count_sites( const SourceSite* bank, int64_t length, bool* outside) const; //! Return the volume for a given mesh index double volume(const MeshIndex& ijk) const override; - int set_grid(); - // Data members double volume_frac_; //!< Volume fraction of each mesh element double element_volume_; //!< Volume of each mesh element - tensor::Tensor width_; //!< Width of each mesh element + xt::xtensor width_; //!< Width of each mesh element }; class RectilinearMesh : public StructuredMesh { @@ -534,7 +414,6 @@ public: // Constructors RectilinearMesh() = default; RectilinearMesh(pugi::xml_node node); - RectilinearMesh(hid_t group); // Overridden methods int get_index_in_direction(double r, int i) const override; @@ -549,7 +428,7 @@ public: std::pair, vector> plot( Position plot_ll, Position plot_ur) const override; - void to_hdf5_inner(hid_t group) const override; + void to_hdf5(hid_t group) const override; //! Get the coordinate for the mesh grid boundary in the positive direction //! @@ -577,7 +456,6 @@ public: // Constructors CylindricalMesh() = default; CylindricalMesh(pugi::xml_node node); - CylindricalMesh(hid_t group); // Overridden methods virtual MeshIndex get_indices(Position r, bool& in_mesh) const override; @@ -596,7 +474,7 @@ public: std::pair, vector> plot( Position plot_ll, Position plot_ur) const override; - void to_hdf5_inner(hid_t group) const override; + void to_hdf5(hid_t group) const override; double volume(const MeshIndex& ijk) const override; @@ -642,7 +520,6 @@ public: // Constructors SphericalMesh() = default; SphericalMesh(pugi::xml_node node); - SphericalMesh(hid_t group); // Overridden methods virtual MeshIndex get_indices(Position r, bool& in_mesh) const override; @@ -661,7 +538,7 @@ public: std::pair, vector> plot( Position plot_ll, Position plot_ur) const override; - void to_hdf5_inner(hid_t group) const override; + void to_hdf5(hid_t group) const override; double r(int i) const { return grid_[0][i]; } double theta(int i) const { return grid_[1][i]; } @@ -711,9 +588,9 @@ class UnstructuredMesh : public Mesh { public: // Constructors - UnstructuredMesh() { n_dimension_ = 3; }; + UnstructuredMesh() {}; UnstructuredMesh(pugi::xml_node node); - UnstructuredMesh(hid_t group); + UnstructuredMesh(const std::string& filename); static const std::string mesh_type; virtual std::string get_mesh_type() const override; @@ -723,7 +600,7 @@ public: void surface_bins_crossed(Position r0, Position r1, const Direction& u, vector& bins) const override; - void to_hdf5_inner(hid_t group) const override; + void to_hdf5(hid_t group) const override; std::string bin_label(int bin) const override; @@ -778,15 +655,6 @@ public: ElementType element_type(int bin) const; - Position lower_left() const override - { - return {lower_left_[0], lower_left_[1], lower_left_[2]}; - } - Position upper_right() const override - { - return {upper_right_[0], upper_right_[1], upper_right_[2]}; - } - protected: //! Set the length multiplier to apply to each point in the mesh void set_length_multiplier(const double length_multiplier); @@ -804,23 +672,19 @@ protected: -1.0}; //!< Multiplicative factor applied to mesh coordinates std::string options_; //!< Options for search data structures - //! Determine lower-left and upper-right bounds of mesh - void determine_bounds(); - private: //! Setup method for the mesh. Builds data structures, //! sets up element mapping, creates bounding boxes, etc. virtual void initialize() = 0; }; -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC class MOABMesh : public UnstructuredMesh { public: // Constructors MOABMesh() = default; MOABMesh(pugi::xml_node); - MOABMesh(hid_t group); MOABMesh(const std::string& filename, double length_multiplier = 1.0); MOABMesh(std::shared_ptr external_mbi); @@ -829,7 +693,7 @@ public: // Overridden Methods //! Perform any preparation needed to support use in mesh filters - void prepare_for_point_location() override; + void prepare_for_tallies() override; Position sample_element(int32_t bin, uint64_t* seed) const override; @@ -984,13 +848,12 @@ private: #endif -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH class LibMesh : public UnstructuredMesh { public: // Constructors LibMesh(pugi::xml_node node); - LibMesh(hid_t group); LibMesh(const std::string& filename, double length_multiplier = 1.0); LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier = 1.0); @@ -1002,7 +865,7 @@ public: Position sample_element(int32_t bin, uint64_t* seed) const override; - virtual int get_bin(Position r) const override; + int get_bin(Position r) const override; int n_bins() const override; @@ -1038,82 +901,38 @@ public: libMesh::MeshBase* mesh_ptr() const { return m_; }; -protected: - // Methods - //! Translate a bin value to an element reference - virtual const libMesh::Elem& get_element_from_bin(int bin) const; - - //! Translate an element pointer to a bin index - virtual int get_bin_from_element(const libMesh::Elem* elem) const; - - // Data members - libMesh::MeshBase* m_; //!< pointer to libMesh MeshBase instance, always set - //!< during intialization - vector> - pl_; //!< per-thread point locators - libMesh::BoundingBox bbox_; //!< bounding box of the mesh - private: - // Methods void initialize() override; void set_mesh_pointer_from_filename(const std::string& filename); - void build_eqn_sys(); + + // Methods + + //! Translate a bin value to an element reference + const libMesh::Elem& get_element_from_bin(int bin) const; + + //! Translate an element pointer to a bin index + int get_bin_from_element(const libMesh::Elem* elem) const; // Data members unique_ptr unique_m_ = nullptr; //!< pointer to the libMesh MeshBase instance, only used if mesh is //!< created inside OpenMC + libMesh::MeshBase* m_; //!< pointer to libMesh MeshBase instance, always set + //!< during intialization + vector> + pl_; //!< per-thread point locators unique_ptr - equation_systems_; //!< pointer to the libMesh EquationSystems - //!< instance + equation_systems_; //!< pointer to the equation systems of the mesh std::string eq_system_name_; //!< name of the equation system holding OpenMC results std::unordered_map variable_map_; //!< mapping of variable names (tally scores) to libMesh //!< variable numbers + libMesh::BoundingBox bbox_; //!< bounding box of the mesh libMesh::dof_id_type first_element_id_; //!< id of the first element in the mesh }; -class AdaptiveLibMesh : public LibMesh { -public: - // Constructor - AdaptiveLibMesh(libMesh::MeshBase& input_mesh, double length_multiplier = 1.0, - const std::set& block_ids = - std::set()); - - // Overridden methods - int n_bins() const override; - - void add_score(const std::string& var_name) override; - - void set_score_data(const std::string& var_name, const vector& values, - const vector& std_dev) override; - - void write(const std::string& filename) const override; - - int get_bin(Position r) const override; - -protected: - // Overridden methods - int get_bin_from_element(const libMesh::Elem* elem) const override; - - const libMesh::Elem& get_element_from_bin(int bin) const override; - -private: - // Data members - const std::set - block_ids_; //!< subdomains of the mesh to tally on - const bool block_restrict_; //!< whether a subset of the mesh is being used - const libMesh::dof_id_type num_active_; //!< cached number of active elements - - std::vector - bin_to_elem_map_; //!< mapping bin indices to dof indices for active - //!< elements - std::vector elem_to_bin_map_; //!< mapping dof indices to bin indices for - //!< active elements -}; - #endif //============================================================================== @@ -1125,11 +944,6 @@ private: //! \param[in] root XML node void read_meshes(pugi::xml_node root); -//! Read meshes from an HDF5 file -// -//! \param[in] group HDF5 group ("meshes" group) -void read_meshes(hid_t group); - //! Write mesh data to an HDF5 group // //! \param[in] group HDF5 group diff --git a/include/openmc/message_passing.h b/include/openmc/message_passing.h index 03e236338..a1641a906 100644 --- a/include/openmc/message_passing.h +++ b/include/openmc/message_passing.h @@ -18,23 +18,9 @@ extern bool master; #ifdef OPENMC_MPI extern MPI_Datatype source_site; -extern MPI_Datatype collision_track_site; extern MPI_Comm intracomm; #endif -//============================================================================== -// Template struct used to map types to MPI datatypes -// By having a single static data member, the template can -// be specialized for each type we know of. The specializations appear in the -// .cpp file since they are definitions. -//============================================================================== -#ifdef OPENMC_MPI -template -struct MPITypeMap { - static const MPI_Datatype mpi_type; -}; -#endif - // Calculates global indices of the bank particles // across all ranks using a parallel scan. This is used to write // the surface source file in parallel runs. It will probably diff --git a/include/openmc/mgxs.h b/include/openmc/mgxs.h index 5d8ff58c2..3fb060810 100644 --- a/include/openmc/mgxs.h +++ b/include/openmc/mgxs.h @@ -6,7 +6,7 @@ #include -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/constants.h" #include "openmc/hdf5_interface.h" @@ -22,7 +22,7 @@ namespace openmc { class Mgxs { private: - tensor::Tensor kTs; // temperature in eV (k * T) + xt::xtensor kTs; // temperature in eV (k * T) AngleDistributionType scatter_format; // flag for if this is legendre, histogram, or tabular int num_groups; // number of energy groups @@ -86,10 +86,8 @@ public: bool fissionable; // Is this fissionable bool is_isotropic { true}; // used to skip search for angle indices if isotropic - bool exists_in_model {true}; // Is this present in model Mgxs() = default; - Mgxs(bool exists) : exists_in_model(exists) {} //! \brief Constructor that loads the Mgxs object from the HDF5 file //! @@ -113,11 +111,6 @@ public: const vector& micros, const vector& atom_densities, int num_group, int num_delay); - //! \brief Get the number of temperature data points. - //! - //! @return The number of temperature data points for this MGXS - inline int n_temperature_points() { return kTs.size(); } - //! \brief Provides a cross section value given certain parameters //! //! @param xstype Type of cross section requested, according to the diff --git a/include/openmc/mgxs_interface.h b/include/openmc/mgxs_interface.h index 117ac503d..da074f825 100644 --- a/include/openmc/mgxs_interface.h +++ b/include/openmc/mgxs_interface.h @@ -61,8 +61,6 @@ public: vector energy_bin_avg_; vector rev_energy_bins_; vector> nuc_temps_; // all available temperatures - vector - default_inverse_velocity_; // approximate default inverse-velocity data }; namespace data { diff --git a/include/openmc/ncrystal_interface.h b/include/openmc/ncrystal_interface.h index e9bd8ae79..5a3882df9 100644 --- a/include/openmc/ncrystal_interface.h +++ b/include/openmc/ncrystal_interface.h @@ -1,7 +1,11 @@ #ifndef OPENMC_NCRYSTAL_INTERFACE_H #define OPENMC_NCRYSTAL_INTERFACE_H -#include "openmc/ncrystal_load.h" +#ifdef NCRYSTAL +#include "NCrystal/NCRNG.hh" +#include "NCrystal/NCrystal.hh" +#endif + #include "openmc/particle.h" #include // for uint64_t @@ -14,25 +18,28 @@ namespace openmc { // Constants //============================================================================== +extern "C" const bool NCRYSTAL_ENABLED; + //! Energy in [eV] to switch between NCrystal and ENDF constexpr double NCRYSTAL_MAX_ENERGY {5.0}; //============================================================================== -// Wrapper class for an NCrystal material +// Wrapper class an NCrystal material //============================================================================== class NCrystalMat { public: //---------------------------------------------------------------------------- // Constructors - NCrystalMat() = default; // empty object + NCrystalMat() = default; explicit NCrystalMat(const std::string& cfg); //---------------------------------------------------------------------------- // Methods - //! Return configuration string: - const std::string& cfg() const { return cfg_; } +#ifdef NCRYSTAL + //! Return configuration string + std::string cfg() const; //! Get cross section from NCrystal material // @@ -46,21 +53,34 @@ public: void scatter(Particle& p) const; //! Whether the object holds a valid NCrystal material - operator bool() const { return !cfg_.empty(); } + operator bool() const; +#else - NCrystalMat clone() const + //---------------------------------------------------------------------------- + // Trivial methods when compiling without NCRYSTAL + std::string cfg() const { - NCrystalMat c; - c.cfg_ = cfg_; - c.proc_ = proc_.clone(); - return c; + return ""; } + double xs(const Particle& p) const + { + return -1.0; + } + void scatter(Particle& p) const {} + operator bool() const + { + return false; + } +#endif private: //---------------------------------------------------------------------------- // Data members (only present when compiling with NCrystal support) - std::string cfg_; //!< NCrystal configuration string - NCrystalScatProc proc_; //!< NCrystal scatter process +#ifdef NCRYSTAL + std::string cfg_; //!< NCrystal configuration string + std::shared_ptr + ptr_; //!< Pointer to NCrystal material object +#endif }; //============================================================================== diff --git a/include/openmc/ncrystal_load.h b/include/openmc/ncrystal_load.h deleted file mode 100644 index d85f24090..000000000 --- a/include/openmc/ncrystal_load.h +++ /dev/null @@ -1,127 +0,0 @@ -//! \file ncrystal_load.h -//! \brief Helper class taking care of loading NCrystal at runtime. - -#ifndef OPENMC_NCRYSTAL_LOAD_H -#define OPENMC_NCRYSTAL_LOAD_H - -#include // for swap -#include // for function -#include // for shared_ptr -#include // for move - -namespace NCrystalVirtualAPI { - -// NOTICE: Do NOT make ANY changes in the NCrystalVirtualAPI::VirtAPI_Type1_v1 -// class, it is required to stay exactly constant over time and compatible with -// the same definition used to compile the NCrystal library! But changes to -// white space, comments, and formatting is of course allowed. This API was -// introduced in NCrystal 4.1.0. - -//! Abstract base class for NCrystal interface which must be declared exactly as -// it is in NCrystal itself. - -class VirtAPI_Type1_v1 { -public: - // Note: neutron must be an array of length 4 with values {ekin,ux,uy,uz} - class ScatterProcess; - virtual const ScatterProcess* createScatter(const char* cfgstr) const = 0; - virtual const ScatterProcess* cloneScatter(const ScatterProcess*) const = 0; - virtual void deallocateScatter(const ScatterProcess*) const = 0; - virtual double crossSectionUncached( - const ScatterProcess&, const double* neutron) const = 0; - virtual void sampleScatterUncached(const ScatterProcess&, - std::function& rng, double* neutron) const = 0; - // Plumbing: - static constexpr unsigned interface_id = 1001; - virtual ~VirtAPI_Type1_v1() = default; - VirtAPI_Type1_v1() = default; - VirtAPI_Type1_v1(const VirtAPI_Type1_v1&) = delete; - VirtAPI_Type1_v1& operator=(const VirtAPI_Type1_v1&) = delete; - VirtAPI_Type1_v1(VirtAPI_Type1_v1&&) = delete; - VirtAPI_Type1_v1& operator=(VirtAPI_Type1_v1&&) = delete; -}; - -} // namespace NCrystalVirtualAPI - -namespace openmc { - -using NCrystalAPI = NCrystalVirtualAPI::VirtAPI_Type1_v1; - -//! Function which locates and loads NCrystal at runtime using the virtual API -std::shared_ptr load_ncrystal_api(); - -//! Class encapsulating exactly the parts of NCrystal needed by OpenMC - -class NCrystalScatProc final { -public: - //! Empty constructor which does not load NCrystal - NCrystalScatProc() {} - - //! Load NCrystal and instantiate a scattering process - //! \param cfgstr NCrystal cfg-string defining the material. - NCrystalScatProc(const char* cfgstr) - : api_(load_ncrystal_api()), p_(api_->createScatter(cfgstr)) - {} - - // Note: Neutron state array is {ekin,ux,uy,uz} - - //! Returns total scattering cross section in units of barns per atom. - //! \param neutron_state array {ekin,ux,uy,uz} with ekin (eV) and direction. - double cross_section(const double* neutron_state) const - { - return api_->crossSectionUncached(*p_, neutron_state); - } - - //! Returns total scattering cross section in units of barns per atom. - //! \param rng function returning random numbers in the unit interval - //! \param neutron_state array {ekin,ux,uy,uz} with ekin (eV) and direction. - void scatter(std::function& rng, double* neutron_state) const - { - api_->sampleScatterUncached(*p_, rng, neutron_state); - } - - //! Clones the object which is otherwise move-only - NCrystalScatProc clone() const - { - NCrystalScatProc c; - if (p_) { - c.api_ = api_; - c.p_ = api_->cloneScatter(p_); - } - return c; - } - - // Plumbing (move-only semantics, but supports explicit clone): - NCrystalScatProc(const NCrystalScatProc&) = delete; - NCrystalScatProc& operator=(const NCrystalScatProc&) = delete; - - NCrystalScatProc(NCrystalScatProc&& o) : api_(std::move(o.api_)), p_(nullptr) - { - std::swap(p_, o.p_); - } - - NCrystalScatProc& operator=(NCrystalScatProc&& o) - { - if (p_) { - api_->deallocateScatter(p_); - p_ = nullptr; - } - std::swap(api_, o.api_); - std::swap(p_, o.p_); - return *this; - } - - ~NCrystalScatProc() - { - if (p_) - api_->deallocateScatter(p_); - } - -private: - std::shared_ptr api_; - const NCrystalAPI::ScatterProcess* p_ = nullptr; -}; - -} // namespace openmc - -#endif diff --git a/include/openmc/nuclide.h b/include/openmc/nuclide.h index ae39a53dd..1cc9d2972 100644 --- a/include/openmc/nuclide.h +++ b/include/openmc/nuclide.h @@ -7,6 +7,7 @@ #include #include // for pair +#include #include #include "openmc/array.h" @@ -16,7 +17,6 @@ #include "openmc/particle.h" #include "openmc/reaction.h" #include "openmc/reaction_product.h" -#include "openmc/span.h" #include "openmc/urr.h" #include "openmc/vector.h" #include "openmc/wmp.h" @@ -81,11 +81,8 @@ public: //! \param[in] energy Energy group boundaries in [eV] //! \param[in] flux Flux in each energy group (not normalized per eV) //! \return Reaction rate - double collapse_rate(int MT, double temperature, span energy, - span flux) const; - - //! Return a ParticleType object representing this nuclide - ParticleType particle_type() const { return {Z_, A_, metastable_}; } + double collapse_rate(int MT, double temperature, + gsl::span energy, gsl::span flux) const; //============================================================================ // Data members @@ -94,12 +91,12 @@ public: int A_; //!< Mass number int metastable_; //!< Metastable state double awr_; //!< Atomic weight ratio - int64_t index_; //!< Index in the nuclides array + gsl::index index_; //!< Index in the nuclides array // Temperature dependent cross section data vector kTs_; //!< temperatures in eV (k*T) vector grid_; //!< Energy grid at each temperature - vector> xs_; //!< Cross sections at each temperature + vector> xs_; //!< Cross sections at each temperature // Multipole data unique_ptr multipole_; @@ -141,7 +138,7 @@ private: // //! \param[in] T Temperature in [K] //! \return Temperature index and interpolation factor - std::pair find_temperature(double T) const; + std::pair find_temperature(double T) const; static int XS_TOTAL; static int XS_ABSORPTION; @@ -166,9 +163,9 @@ bool multipole_in_range(const Nuclide& nuc, double E); namespace data { // Minimum/maximum transport energy for each particle type. Order corresponds to -// transport_index() for supported transport particles. -extern array energy_min; -extern array energy_max; +// that of the ParticleType enum +extern array energy_min; +extern array energy_max; //! Minimum temperature in [K] that nuclide data is available at extern double temperature_min; diff --git a/include/openmc/openmp_interface.h b/include/openmc/openmp_interface.h index 30bd6f008..fe517415b 100644 --- a/include/openmc/openmp_interface.h +++ b/include/openmc/openmp_interface.h @@ -36,15 +36,13 @@ inline int thread_num() class OpenMPMutex { public: - void init() + OpenMPMutex() { #ifdef _OPENMP omp_init_lock(&mutex_); #endif } - OpenMPMutex() { init(); } - ~OpenMPMutex() { #ifdef _OPENMP @@ -64,10 +62,14 @@ public: // rather, it produces two different mutexes. // Copy constructor - OpenMPMutex(const OpenMPMutex& other) { init(); } + OpenMPMutex(const OpenMPMutex& other) { OpenMPMutex(); } // Copy assignment operator - OpenMPMutex& operator=(const OpenMPMutex& other) { return *this; } + OpenMPMutex& operator=(const OpenMPMutex& other) + { + OpenMPMutex(); + return *this; + } //! Lock the mutex. // diff --git a/include/openmc/output.h b/include/openmc/output.h index 0ad8b2fe5..1ece3de96 100644 --- a/include/openmc/output.h +++ b/include/openmc/output.h @@ -10,8 +10,6 @@ namespace openmc { -extern "C" const bool STRICT_FP_ENABLED; - //! \brief Display the main title banner as well as information about the //! program developers, version, and date/time which the problem was run. void title(); @@ -62,6 +60,7 @@ void write_tallies(); void show_time(const char* label, double secs, int indent_level = 0); } // namespace openmc +#endif // OPENMC_OUTPUT_H ////////////////////////////////////// // Custom formatters @@ -77,16 +76,10 @@ struct formatter> { } template -#if FMT_VERSION >= 110000 // Version 11.0.0 and above - auto format(const std::array& arr, FormatContext& ctx) const { -#else // For versions below 11.0.0 auto format(const std::array& arr, FormatContext& ctx) { -#endif return format_to(ctx.out(), "({}, {})", arr[0], arr[1]); -} -}; // namespace fmt + } +}; } // namespace fmt - -#endif // OPENMC_OUTPUT_H diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 8db9721ba..6a2e67049 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -39,7 +39,9 @@ public: double speed() const; - double mass() const; + //! moves the particle by the distance length to its next location + //! \param length the distance the particle is moved + void move_distance(double length); //! create a secondary particle // @@ -49,14 +51,7 @@ public: //! \param u Direction of the secondary particle //! \param E Energy of the secondary particle in [eV] //! \param type Particle type - //! \return Whether a secondary particle was created - bool create_secondary(double wgt, Direction u, double E, ParticleType type); - - //! split a particle - // - //! creates a new particle with weight wgt - //! \param wgt Weight of the new particle - void split(double wgt); + void create_secondary(double wgt, Direction u, double E, ParticleType type); //! initialize from a source site // @@ -71,8 +66,7 @@ public: void event_advance(); void event_cross_surface(); void event_collide(); - void event_revive_from_secondary(const SourceSite& site); - void event_check_limit_and_revive(); + void event_revive_from_secondary(); void event_death(); //! pulse-height recording @@ -129,6 +123,10 @@ public: //! Functions //============================================================================ +std::string particle_type_to_str(ParticleType type); + +ParticleType str_to_particle_type(std::string str); + void add_surf_source_to_bank(Particle& p, const Surface& surf); } // namespace openmc diff --git a/include/openmc/particle_data.h b/include/openmc/particle_data.h index 44e82fd23..164148cce 100644 --- a/include/openmc/particle_data.h +++ b/include/openmc/particle_data.h @@ -3,13 +3,12 @@ #include "openmc/array.h" #include "openmc/constants.h" -#include "openmc/particle_type.h" #include "openmc/position.h" #include "openmc/random_lcg.h" #include "openmc/tallies/filter_match.h" #include "openmc/vector.h" -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC #include "DagMC.hpp" #endif @@ -31,6 +30,9 @@ constexpr double CACHE_INVALID {-1.0}; //========================================================================== // Aliases and type definitions +//! Particle types +enum class ParticleType { neutron, photon, electron, positron }; + //! Saved ("banked") state of a particle //! NOTE: This structure's MPI type is built in initialize_mpi() of //! initialize.cpp. Any changes made to the struct here must also be @@ -45,32 +47,7 @@ struct SourceSite { double time {0.0}; double wgt {1.0}; int delayed_group {0}; - int surf_id {SURFACE_NONE}; - ParticleType particle; - - // Extra attributes that don't show up in source written to file - int parent_nuclide {-1}; - int64_t parent_id {0}; - int64_t progeny_id {0}; - double wgt_born {1.0}; - double wgt_ww_born {-1.0}; - int64_t n_split {0}; -}; - -struct CollisionTrackSite { - Position r; - Direction u; - double E; - double dE; - double time {0.0}; - double wgt {1.0}; - int event_mt {0}; - int delayed_group {0}; - int cell_id {0}; - int nuclide_id; - int material_id {0}; - int universe_id {0}; - int n_collision {0}; + int surf_id {0}; ParticleType particle; int64_t parent_id; int64_t progeny_id; @@ -108,37 +85,13 @@ public: //! clear data from a single coordinate level void reset(); - // accessors - Position& r() { return r_; } - const Position& r() const { return r_; } - - Direction& u() { return u_; } - const Direction& u() const { return u_; } - - int& cell() { return cell_; } - const int& cell() const { return cell_; } - - int& universe() { return universe_; } - const int& universe() const { return universe_; } - - int& lattice() { return lattice_; } - int lattice() const { return lattice_; } - - array& lattice_index() { return lattice_index_; } - const array& lattice_index() const { return lattice_index_; } - - bool& rotated() { return rotated_; } - const bool& rotated() const { return rotated_; } - -private: - // Data members - Position r_; //!< particle position - Direction u_; //!< particle direction - int cell_ {-1}; - int universe_ {-1}; - int lattice_ {-1}; - array lattice_index_ {{-1, -1, -1}}; - bool rotated_ {false}; //!< Is the level rotated? + Position r; //!< particle position + Direction u; //!< particle direction + int cell {-1}; + int universe {-1}; + int lattice {-1}; + array lattice_i {{-1, -1, -1}}; + bool rotated {false}; //!< Is the level rotated? }; //============================================================================== @@ -174,10 +127,9 @@ struct NuclideMicroXS { // Energy and temperature last used to evaluate these cross sections. If // these values have changed, then the cross sections must be re-evaluated. - double last_E {0.0}; //!< Last evaluated energy - double last_sqrtkT {0.0}; //!< Last temperature in sqrt(Boltzmann constant - //!< * temperature (eV)) - double ncrystal_xs {-1.0}; //!< NCrystal cross section + double last_E {0.0}; //!< Last evaluated energy + double last_sqrtkT {0.0}; //!< Last temperature in sqrt(Boltzmann constant + //!< * temperature (eV)) }; //============================================================================== @@ -231,41 +183,12 @@ struct CacheDataMG { // Information about nearest boundary crossing //============================================================================== -class BoundaryInfo { -public: - void reset() - { - distance_ = INFINITY; - surface_ = SURFACE_NONE; - coord_level_ = 0; - lattice_translation_ = {0, 0, 0}; - } - double& distance() { return distance_; } - const double& distance() const { return distance_; } - - int& surface() { return surface_; } - const int& surface() const { return surface_; } - - int coord_level() const { return coord_level_; } - int& coord_level() { return coord_level_; } - - array& lattice_translation() { return lattice_translation_; } - const array& lattice_translation() const - { - return lattice_translation_; - } - - // TODO: off-by-one - int surface_index() const { return std::abs(surface()) - 1; } - -private: - // Data members - double distance_ {INFINITY}; //!< distance to nearest boundary - int surface_ { - SURFACE_NONE}; //!< surface token, non-zero if boundary is surface - int coord_level_ {0}; //!< coordinate level after crossing boundary - array lattice_translation_ { - 0, 0, 0}; //!< which way lattice indices will change +struct BoundaryInfo { + double distance {INFINITY}; //!< distance to nearest boundary + int surface_index {0}; //!< if boundary is surface, index in surfaces vector + int coord_level; //!< coordinate level after crossing boundary + array + lattice_translation {}; //!< which way lattice indices will change }; /* @@ -299,17 +222,11 @@ public: n_coord_last_ = 1; } - //! moves the particle by the specified distance to its next location - //! \param distance the distance the particle is moved - void move_distance(double distance); - - void advance_to_boundary_from_void(); - // Initialize all internal state from position and direction void init_from_r_u(Position r_a, Direction u_a) { clear(); - surface() = SURFACE_NONE; + surface() = 0; material() = C_NONE; r() = r_a; u() = u_a; @@ -364,36 +281,29 @@ public: const Position& u_last() const { return u_last_; } // Accessors for position in global coordinates - Position& r() { return coord_[0].r(); } - const Position& r() const { return coord_[0].r(); } + Position& r() { return coord_[0].r; } + const Position& r() const { return coord_[0].r; } // Accessors for position in local coordinates - Position& r_local() { return coord_[n_coord_ - 1].r(); } - const Position& r_local() const { return coord_[n_coord_ - 1].r(); } + Position& r_local() { return coord_[n_coord_ - 1].r; } + const Position& r_local() const { return coord_[n_coord_ - 1].r; } // Accessors for direction in global coordinates - Direction& u() { return coord_[0].u(); } - const Direction& u() const { return coord_[0].u(); } + Direction& u() { return coord_[0].u; } + const Direction& u() const { return coord_[0].u; } // Accessors for direction in local coordinates - Direction& u_local() { return coord_[n_coord_ - 1].u(); } - const Direction& u_local() const { return coord_[n_coord_ - 1].u(); } + Direction& u_local() { return coord_[n_coord_ - 1].u; } + const Direction& u_local() const { return coord_[n_coord_ - 1].u; } - // Surface token for the surface that the particle is currently on + // Surface that the particle is on int& surface() { return surface_; } const int& surface() const { return surface_; } - // Surface index based on the current value of the surface_ attribute - int surface_index() const - { - // TODO: off-by-one - return std::abs(surface_) - 1; - } - // Boundary information BoundaryInfo& boundary() { return boundary_; } -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC // DagMC state variables moab::DagMC::RayHistory& history() { return history_; } Direction& last_dir() { return last_dir_; } @@ -410,11 +320,6 @@ public: const double& sqrtkT() const { return sqrtkT_; } double& sqrtkT_last() { return sqrtkT_last_; } - // density multiplier of the current and last cell - double& density_mult() { return density_mult_; } - const double& density_mult() const { return density_mult_; } - double& density_mult_last() { return density_mult_last_; } - private: int64_t id_ {-1}; //!< Unique ID @@ -432,8 +337,7 @@ private: Position r_last_; //!< previous coordinates Direction u_last_; //!< previous direction coordinates - int surface_ { - SURFACE_NONE}; //!< surface token for surface the particle is currently on + int surface_ {0}; //!< index for surface particle is on BoundaryInfo boundary_; //!< Info about the next intersection @@ -443,10 +347,7 @@ private: double sqrtkT_ {-1.0}; //!< sqrt(k_Boltzmann * temperature) in eV double sqrtkT_last_ {0.0}; //!< last temperature - double density_mult_ {1.0}; //!< density multiplier - double density_mult_last_ {1.0}; //!< last density multiplier - -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC moab::DagMC::RayHistory history_; Direction last_dir_; #endif @@ -497,7 +398,7 @@ private: MacroXS macro_xs_; CacheDataMG mg_xs_cache_; - ParticleType type_; + ParticleType type_ {ParticleType::neutron}; double E_; double E_last_; @@ -505,8 +406,6 @@ private: int g_last_; double wgt_ {1.0}; - double wgt_born_ {1.0}; - double wgt_ww_born_ {-1.0}; double mu_; double time_ {0.0}; double time_last_ {0.0}; @@ -517,18 +416,14 @@ private: int event_nuclide_; int event_mt_; int delayed_group_ {0}; - int parent_nuclide_ {-1}; int n_bank_ {0}; - double bank_second_E_ {0.0}; + int n_bank_second_ {0}; double wgt_bank_ {0.0}; int n_delayed_bank_[MAX_DELAYED_GROUPS]; int cell_born_ {-1}; - // Iterated Fission Probability - double lifetime_ {0.0}; //!< neutron lifetime [s] - int n_collision_ {0}; bool write_track_ {false}; @@ -536,14 +431,9 @@ private: uint64_t seeds_[N_STREAMS]; int stream_; - vector local_secondary_bank_; + vector secondary_bank_; - // Keep track of how many secondary particles were created in the collision - // and what the starting index is in the secondary bank for this particle - int n_secondaries_ {0}; - int secondary_bank_index_ {0}; - - int64_t current_work_ {0}; + int64_t current_work_; vector flux_derivs_; @@ -566,9 +456,7 @@ private: int n_event_ {0}; - int64_t n_tracks_ {0}; //!< number of tracks in this particle history - - int64_t n_split_ {0}; + int n_split_ {0}; double ww_factor_ {0.0}; int64_t n_progeny_ {0}; @@ -582,8 +470,10 @@ public: // Methods and accessors // Cross section caches - // Microscopic neutron cross sections - NuclideMicroXS& neutron_xs(int i) { return neutron_xs_[i]; } + NuclideMicroXS& neutron_xs(int i) + { + return neutron_xs_[i]; + } // Microscopic neutron cross sections const NuclideMicroXS& neutron_xs(int i) const { return neutron_xs_[i]; } // Microscopic photon cross sections @@ -613,24 +503,12 @@ public: int& g_last() { return g_last_; } const int& g_last() const { return g_last_; } - // Statistic weight of particle. Setting to zero indicates that the particle - // is dead. + // Statistic weight of particle. Setting to zero + // indicates that the particle is dead. double& wgt() { return wgt_; } double wgt() const { return wgt_; } - - // Statistic weight of particle at birth - double& wgt_born() { return wgt_born_; } - double wgt_born() const { return wgt_born_; } - - // Weight window value at birth - double& wgt_ww_born() { return wgt_ww_born_; } - const double& wgt_ww_born() const { return wgt_ww_born_; } - - // Statistic weight of particle at last collision double& wgt_last() { return wgt_last_; } const double& wgt_last() const { return wgt_last_; } - - // Whether particle is alive bool alive() const { return wgt_ != 0.0; } // Polar scattering angle after a collision @@ -644,31 +522,21 @@ public: double& time_last() { return time_last_; } const double& time_last() const { return time_last_; } - // Particle lifetime - double& lifetime() { return lifetime_; } - const double& lifetime() const { return lifetime_; } - // What event took place, described in greater detail below TallyEvent& event() { return event_; } const TallyEvent& event() const { return event_; } bool& fission() { return fission_; } // true if implicit fission int& event_nuclide() { return event_nuclide_; } // index of collision nuclide const int& event_nuclide() const { return event_nuclide_; } - int& event_mt() { return event_mt_; } // MT number of collision - const int& event_mt() const { return event_mt_; } + int& event_mt() { return event_mt_; } // MT number of collision int& delayed_group() { return delayed_group_; } // delayed group - const int& delayed_group() const { return delayed_group_; } - const int& parent_nuclide() const { return parent_nuclide_; } - int& parent_nuclide() { return parent_nuclide_; } // Parent nuclide // Post-collision data - double& bank_second_E() + int& n_bank() { return n_bank_; } // number of banked fission sites + int& n_bank_second() { - return bank_second_E_; - } // energy of last reaction secondaries - const double& bank_second_E() const { return bank_second_E_; } - - int& n_bank() { return n_bank_; } // number of banked fission sites + return n_bank_second_; + } // number of secondaries banked double& wgt_bank() { return wgt_bank_; } // weight of banked fission sites int* n_delayed_bank() { @@ -683,6 +551,7 @@ public: int& cell_born() { return cell_born_; } const int& cell_born() const { return cell_born_; } + // index of the current and last material // Total number of collisions suffered by particle int& n_collision() { return n_collision_; } const int& n_collision() const { return n_collision_; } @@ -696,23 +565,8 @@ public: int& stream() { return stream_; } // secondary particle bank - SourceSite& local_secondary_bank(int i) { return local_secondary_bank_[i]; } - const SourceSite& local_secondary_bank(int i) const - { - return local_secondary_bank_[i]; - } - decltype(local_secondary_bank_)& local_secondary_bank() - { - return local_secondary_bank_; - } - - // Number of secondaries created in a collision - int& n_secondaries() { return n_secondaries_; } - const int& n_secondaries() const { return n_secondaries_; } - - // Starting index in secondary bank for this collision - int& secondary_bank_index() { return secondary_bank_index_; } - const int& secondary_bank_index() const { return secondary_bank_index_; } + SourceSite& secondary_bank(int i) { return secondary_bank_[i]; } + decltype(secondary_bank_)& secondary_bank() { return secondary_bank_; } // Current simulation work index int64_t& current_work() { return current_work_; } @@ -752,16 +606,13 @@ public: int& n_event() { return n_event_; } // Number of times variance reduction has caused a particle split - int64_t n_split() const { return n_split_; } - int64_t& n_split() { return n_split_; } + int n_split() const { return n_split_; } + int& n_split() { return n_split_; } // Particle-specific factor for on-the-fly weight window adjustment double ww_factor() const { return ww_factor_; } double& ww_factor() { return ww_factor_; } - // Number of tracks in this particle history - int64_t& n_tracks() { return n_tracks_; } - // Number of progeny produced by this particle int64_t& n_progeny() { return n_progeny_; } diff --git a/include/openmc/particle_type.h b/include/openmc/particle_type.h deleted file mode 100644 index 0fd896c57..000000000 --- a/include/openmc/particle_type.h +++ /dev/null @@ -1,184 +0,0 @@ -//============================================================================== -// ParticleType class definition -//============================================================================== - -#ifndef OPENMC_PARTICLE_TYPE_H -#define OPENMC_PARTICLE_TYPE_H - -#include -#include -#include -#include -#include - -#include "openmc/constants.h" -#include "openmc/error.h" - -namespace openmc { - -//------------------------------------------------------------------------------ -// PDG constants (canonical particle identity as simple integers) -//------------------------------------------------------------------------------ - -inline constexpr int32_t PDG_NEUTRON = 2112; -inline constexpr int32_t PDG_PHOTON = 22; -inline constexpr int32_t PDG_ELECTRON = 11; -inline constexpr int32_t PDG_POSITRON = -11; -inline constexpr int32_t PDG_PROTON = 2212; -inline constexpr int32_t PDG_DEUTERON = 1000010020; -inline constexpr int32_t PDG_TRITON = 1000010030; -inline constexpr int32_t PDG_ALPHA = 1000020040; - -//------------------------------------------------------------------------------ -// ParticleType class (standard-layout, trivially copyable) -//------------------------------------------------------------------------------ - -class ParticleType { -public: - //---------------------------------------------------------------------------- - // Constructors - - // Default constructor: defaults to neutron - constexpr ParticleType() : pdg_number_(PDG_NEUTRON) {} - - // Constructor from PDG number - constexpr explicit ParticleType(int32_t pdg_number) : pdg_number_(pdg_number) - {} - - // Constructor from particle name string (e.g., "neutron", "photon", "Fe56") - explicit ParticleType(std::string_view str); - - // Constructor from Z, A, and metastable state for nuclear particles - constexpr ParticleType(int Z, int A, int m = 0) - : pdg_number_(1000000000 + Z * 10000 + A * 10 + m) - {} - - //---------------------------------------------------------------------------- - // Accessors - - // Accessor for the underlying PDG number - constexpr int32_t pdg_number() const { return pdg_number_; } - - //---------------------------------------------------------------------------- - // Methods - - // Get particle mass in [u] - double mass() const - { - int32_t p = std::abs(pdg_number_); - if (ATOMIC_MASS.count(p)) { - return ATOMIC_MASS[p]; - } else { - fatal_error("Unknown mass for particle " + str()); - } - } - - // Convert to string representation - std::string str() const; - - // Check if this represents a nucleus (vs elementary particle) - constexpr bool is_nucleus() const - { - // PDG nuclear codes are >= 1000000000 (100ZZZAAAI format) - return pdg_number_ >= 1000000000; - } - - // Get transport index (0-3 for transportable particles, C_NONE otherwise) - constexpr int transport_index() const; - - // Check if this is a neutron - constexpr bool is_neutron() const { return pdg_number_ == PDG_NEUTRON; } - - // Check if this is a photon - constexpr bool is_photon() const { return pdg_number_ == PDG_PHOTON; } - - constexpr bool is_transportable() const - { - return this->transport_index() != C_NONE; - } - - //---------------------------------------------------------------------------- - // Static factory methods - - static constexpr ParticleType neutron() { return ParticleType {PDG_NEUTRON}; } - static constexpr ParticleType photon() { return ParticleType {PDG_PHOTON}; } - static constexpr ParticleType electron() - { - return ParticleType {PDG_ELECTRON}; - } - static constexpr ParticleType positron() - { - return ParticleType {PDG_POSITRON}; - } - static constexpr ParticleType proton() { return ParticleType {PDG_PROTON}; } - static constexpr ParticleType deuteron() - { - return ParticleType {PDG_DEUTERON}; - } - static constexpr ParticleType triton() { return ParticleType {PDG_TRITON}; } - static constexpr ParticleType alpha() { return ParticleType {PDG_ALPHA}; } - -private: - int32_t pdg_number_; -}; - -//------------------------------------------------------------------------------ -// Static assertions to ensure standard-layout and trivially copyable -//------------------------------------------------------------------------------ - -static_assert(std::is_standard_layout_v, - "ParticleType must be standard-layout"); -static_assert(std::is_trivially_copyable_v, - "ParticleType must be trivially copyable"); -static_assert(sizeof(ParticleType) == sizeof(int32_t), - "ParticleType must be same size as int32_t"); - -//------------------------------------------------------------------------------ -// Comparison operators (free functions for symmetry) -//------------------------------------------------------------------------------ - -constexpr bool operator==(ParticleType lhs, ParticleType rhs) -{ - return lhs.pdg_number() == rhs.pdg_number(); -} - -constexpr bool operator!=(ParticleType lhs, ParticleType rhs) -{ - return lhs.pdg_number() != rhs.pdg_number(); -} - -constexpr bool operator<(ParticleType lhs, ParticleType rhs) -{ - return lhs.pdg_number() < rhs.pdg_number(); -} - -//------------------------------------------------------------------------------ -// ParticleType member function implementations (inline) -//------------------------------------------------------------------------------ - -constexpr int ParticleType::transport_index() const -{ - switch (pdg_number_) { - case PDG_NEUTRON: - return 0; - case PDG_PHOTON: - return 1; - case PDG_ELECTRON: - return 2; - case PDG_POSITRON: - return 3; - default: - return C_NONE; - } -} - -//------------------------------------------------------------------------------ -// Legacy conversion helpers -//------------------------------------------------------------------------------ - -// Legacy enum code (0..3) to ParticleType conversion -ParticleType legacy_particle_index_to_type(int code); - -} // namespace openmc - -#endif // OPENMC_PARTICLE_TYPE_H diff --git a/include/openmc/photon.h b/include/openmc/photon.h index 93c6dba53..9901c8c6d 100644 --- a/include/openmc/photon.h +++ b/include/openmc/photon.h @@ -6,7 +6,8 @@ #include "openmc/particle.h" #include "openmc/vector.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" +#include #include #include @@ -33,6 +34,7 @@ public: int index_subshell; //!< index in SUBSHELLS int threshold; + double n_electrons; double binding_energy; vector transitions; }; @@ -59,17 +61,17 @@ public: // Data members std::string name_; //!< Name of element, e.g. "Zr" int Z_; //!< Atomic number - int64_t index_; //!< Index in global elements vector + gsl::index index_; //!< Index in global elements vector // Microscopic cross sections - tensor::Tensor energy_; - tensor::Tensor coherent_; - tensor::Tensor incoherent_; - tensor::Tensor photoelectric_total_; - tensor::Tensor pair_production_total_; - tensor::Tensor pair_production_electron_; - tensor::Tensor pair_production_nuclear_; - tensor::Tensor heating_; + xt::xtensor energy_; + xt::xtensor coherent_; + xt::xtensor incoherent_; + xt::xtensor photoelectric_total_; + xt::xtensor pair_production_total_; + xt::xtensor pair_production_electron_; + xt::xtensor pair_production_nuclear_; + xt::xtensor heating_; // Form factors Tabulated1D incoherent_form_factor_; @@ -81,27 +83,22 @@ public: // stored separately to improve memory access pattern when calculating the // total cross section vector shells_; - tensor::Tensor cross_sections_; + xt::xtensor cross_sections_; // Compton profile data - tensor::Tensor profile_pdf_; - tensor::Tensor profile_cdf_; - tensor::Tensor binding_energy_; - tensor::Tensor electron_pdf_; - - // Map subshells from Compton profile data obtained from Biggs et al, - // "Hartree-Fock Compton profiles for the elements" to ENDF/B atomic - // relaxation data - tensor::Tensor subshell_map_; + xt::xtensor profile_pdf_; + xt::xtensor profile_cdf_; + xt::xtensor binding_energy_; + xt::xtensor electron_pdf_; // Stopping power data double I_; // mean excitation energy - tensor::Tensor n_electrons_; - tensor::Tensor ionization_energy_; - tensor::Tensor stopping_power_radiative_; + xt::xtensor n_electrons_; + xt::xtensor ionization_energy_; + xt::xtensor stopping_power_radiative_; // Bremsstrahlung scaled DCS - tensor::Tensor dcs_; + xt::xtensor dcs_; // Whether atomic relaxation data is present bool has_atomic_relaxation_ {false}; @@ -137,7 +134,7 @@ void free_memory_photon(); namespace data { -extern tensor::Tensor +extern xt::xtensor compton_profile_pz; //! Compton profile momentum grid //! Photon interaction data for each element diff --git a/include/openmc/physics.h b/include/openmc/physics.h index 2472d9799..f62f43a02 100644 --- a/include/openmc/physics.h +++ b/include/openmc/physics.h @@ -10,6 +10,13 @@ namespace openmc { +//============================================================================== +// Constants +//============================================================================== + +// Monoatomic ideal-gas scattering treatment threshold +constexpr double FREE_GAS_THRESHOLD {400.0}; + //============================================================================== // Non-member functions //============================================================================== diff --git a/include/openmc/physics_common.h b/include/openmc/physics_common.h index b0e395c1e..e38a3c7f8 100644 --- a/include/openmc/physics_common.h +++ b/include/openmc/physics_common.h @@ -13,9 +13,5 @@ namespace openmc { //! \param[in] weight_survive Weight assigned to particles that survive void russian_roulette(Particle& p, double weight_survive); -//! \brief Performs the global russian roulette operation on a particle -//! \param[in,out] p Particle object -void apply_russian_roulette(Particle& p); - } // namespace openmc #endif // OPENMC_PHYSICS_COMMON_H diff --git a/include/openmc/plot.h b/include/openmc/plot.h index ba8ac84a1..ee6c3fbec 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -4,11 +4,9 @@ #include #include #include -#include -#include -#include "openmc/tensor.h" #include "pugixml.hpp" +#include "xtensor/xarray.hpp" #include "hdf5.h" #include "openmc/cell.h" @@ -18,9 +16,6 @@ #include "openmc/particle.h" #include "openmc/position.h" #include "openmc/random_lcg.h" -#include "openmc/ray.h" -#include "openmc/tallies/filter.h" -#include "openmc/tallies/filter_match.h" #include "openmc/xml_interface.h" namespace openmc { @@ -66,14 +61,6 @@ struct RGBColor { return red == other.red && green == other.green && blue == other.blue; } - RGBColor& operator*=(const double x) - { - red *= x; - green *= x; - blue *= x; - return *this; - } - // Members uint8_t red, green, blue; }; @@ -83,31 +70,18 @@ const RGBColor WHITE {255, 255, 255}; const RGBColor RED {255, 0, 0}; const RGBColor BLACK {0, 0, 0}; -/** - * \class PlottableInterface - * \brief Interface for plottable objects. - * - * PlottableInterface classes must have unique IDs. If no ID (or -1) is - * provided, the next available ID is assigned automatically. They guarantee - * the ability to create output in some form. This interface is designed to be - * implemented by classes that produce plot-relevant data which can be - * visualized. +/* + * PlottableInterface classes just have to have a unique ID in the plots.xml + * file, and guarantee being able to create output in some way. */ - -typedef tensor::Tensor ImageData; class PlottableInterface { -public: - PlottableInterface() = default; - - void set_default_colors(); - private: void set_id(pugi::xml_node plot_node); - int id_ {C_NONE}; // unique plot ID + int id_; // unique plot ID void set_bg_color(pugi::xml_node plot_node); void set_universe(pugi::xml_node plot_node); - void set_color_by(pugi::xml_node plot_node); + void set_default_colors(pugi::xml_node plot_node); void set_user_colors(pugi::xml_node plot_node); void set_overlap_color(pugi::xml_node plot_node); void set_mask(pugi::xml_node plot_node); @@ -119,77 +93,52 @@ protected: public: enum class PlotColorBy { cells = 0, mats = 1 }; - // Generates image data based on plot parameters and returns it - virtual ImageData create_image() const = 0; - // Creates the output image named path_plot_ virtual void create_output() const = 0; - // Write populated image data to file - void write_image(const ImageData& data) const; - // Print useful info to the terminal virtual void print_info() const = 0; const std::string& path_plot() const { return path_plot_; } std::string& path_plot() { return path_plot_; } int id() const { return id_; } - void set_id(int id = C_NONE); int level() const { return level_; } - PlotColorBy color_by() const { return color_by_; } // Public color-related data PlottableInterface(pugi::xml_node plot_node); virtual ~PlottableInterface() = default; - int level_ {-1}; // Universe level to plot - bool color_overlaps_ {false}; // Show overlapping cells? - PlotColorBy color_by_ {PlotColorBy::mats}; // Plot coloring (cell/material) - RGBColor not_found_ {WHITE}; // Plot background color - RGBColor overlap_color_ {RED}; // Plot overlap color - vector colors_; // Plot colors + int level_; // Universe level to plot + bool color_overlaps_; // Show overlapping cells? + PlotColorBy color_by_; // Plot coloring (cell/material) + RGBColor not_found_ {WHITE}; // Plot background color + RGBColor overlap_color_ {RED}; // Plot overlap color + vector colors_; // Plot colors }; +typedef xt::xtensor ImageData; + struct IdData { // Constructor - IdData(size_t h_res, size_t v_res, bool include_filter = false); + IdData(size_t h_res, size_t v_res); // Methods - void set_value(size_t y, size_t x, const Particle& p, int level, - Filter* filter = nullptr, FilterMatch* match = nullptr); - void set_overlap(size_t y, size_t x, int overlap_idx); + void set_value(size_t y, size_t x, const GeometryState& p, int level); + void set_overlap(size_t y, size_t x); // Members - tensor::Tensor data_; //!< 2D array of cell & material ids + xt::xtensor data_; //!< 2D array of cell & material ids }; struct PropertyData { // Constructor - PropertyData(size_t h_res, size_t v_res, bool include_filter = false); + PropertyData(size_t h_res, size_t v_res); // Methods - void set_value(size_t y, size_t x, const Particle& p, int level, - Filter* filter = nullptr, FilterMatch* match = nullptr); - void set_overlap(size_t y, size_t x, int overlap_idx); + void set_value(size_t y, size_t x, const GeometryState& p, int level); + void set_overlap(size_t y, size_t x); // Members - tensor::Tensor data_; //!< 2D array of temperature & density data -}; - -struct RasterData { - // Constructor - RasterData(size_t h_res, size_t v_res, bool include_filter = false); - - // Methods - void set_value(size_t y, size_t x, const Particle& p, int level, - Filter* filter = nullptr, FilterMatch* match = nullptr); - void set_overlap(size_t y, size_t x, int overlap_idx); - - // Members - tensor::Tensor - id_data_; //!< [v_res, h_res, 3 or 4]: cell, instance, mat, [filter_bin] - tensor::Tensor - property_data_; //!< [v_res, h_res, 2]: temperature, density - bool include_filter_; //!< Whether filter bin index is included + xt::xtensor data_; //!< 2D array of temperature & density data }; //=============================================================================== @@ -199,76 +148,76 @@ struct RasterData { class SlicePlotBase { public: template - T get_map(int32_t filter_index = -1) const; + T get_map() const; enum class PlotBasis { xy = 1, xz = 2, yz = 3 }; - // Accessors - - const std::array& pixels() const { return pixels_; } - std::array& pixels() { return pixels_; } - // Members public: - Position origin_; //!< Plot origin in geometry - Direction u_span_; //!< Full-width span vector in geometry - Direction v_span_; //!< Full-height span vector in geometry - array pixels_; //!< Plot size in pixels - bool show_overlaps_; //!< Show overlapping cells? - int slice_level_ {-1}; //!< Plot universe level + Position origin_; //!< Plot origin in geometry + Position width_; //!< Plot width in geometry + PlotBasis basis_; //!< Plot basis (XY/XZ/YZ) + array pixels_; //!< Plot size in pixels + bool slice_color_overlaps_; //!< Show overlapping cells? + int slice_level_ {-1}; //!< Plot universe level private: }; template -T SlicePlotBase::get_map(int32_t filter_index) const +T SlicePlotBase::get_map() const { size_t width = pixels_[0]; size_t height = pixels_[1]; - // Determine if filter is being used - bool include_filter = (filter_index >= 0); - Filter* filter = nullptr; - if (include_filter) { - filter = model::tally_filters[filter_index].get(); - } + // get pixel size + double in_pixel = (width_[0]) / static_cast(width); + double out_pixel = (width_[1]) / static_cast(height); // size data array - T data(width, height, include_filter); + T data(width, height); - // compute pixel steps and top-left pixel center - Direction u_step = u_span_ / static_cast(width); - Direction v_step = v_span_ / static_cast(height); - - Position start = - origin_ - 0.5 * u_span_ + 0.5 * v_span_ + 0.5 * u_step - 0.5 * v_step; - - // Validate that span vectors define a valid plane - Position cross = u_span_.cross(v_span_); - if (cross.norm() == 0.0) { - fatal_error("Slice span vectors are invalid (zero area)."); + // setup basis indices and initial position centered on pixel + int in_i, out_i; + Position xyz = origin_; + switch (basis_) { + case PlotBasis::xy: + in_i = 0; + out_i = 1; + break; + case PlotBasis::xz: + in_i = 0; + out_i = 2; + break; + case PlotBasis::yz: + in_i = 1; + out_i = 2; + break; + default: + UNREACHABLE(); } - // Use an arbitrary direction that is not aligned with any coordinate axis. - // The direction has no physical meaning for plotting but is used by - // Surface::sense() to break ties when a pixel is coincident with a surface. - Direction dir = {1.0 / std::sqrt(2.0), 1.0 / std::sqrt(2.0), 0.0}; + // set initial position + xyz[in_i] = origin_[in_i] - width_[0] / 2. + in_pixel / 2.; + xyz[out_i] = origin_[out_i] + width_[1] / 2. - out_pixel / 2.; + + // arbitrary direction + Direction dir = {1. / std::sqrt(2.), 1. / std::sqrt(2.), 0.0}; #pragma omp parallel { - Particle p; - p.r() = start; + GeometryState p; + p.r() = xyz; p.u() = dir; - p.coord(0).universe() = model::root_universe; + p.coord(0).universe = model::root_universe; int level = slice_level_; int j {}; - FilterMatch match; #pragma omp for for (int y = 0; y < height; y++) { - Position row = start - v_step * static_cast(y); + p.r()[out_i] = xyz[out_i] - out_pixel * y; for (int x = 0; x < width; x++) { - p.r() = row + u_step * static_cast(x); + p.r()[in_i] = xyz[in_i] + in_pixel * x; p.n_coord() = 1; // local variables bool found_cell = exhaustive_find_cell(p); @@ -277,17 +226,14 @@ T SlicePlotBase::get_map(int32_t filter_index) const j = level; } if (found_cell) { - data.set_value(y, x, p, j, filter, &match); + data.set_value(y, x, p, j); } - if (show_overlaps_) { - int overlap_idx = check_cell_overlap(p, false); - if (overlap_idx >= 0) { - data.set_overlap(y, x, overlap_idx); - } + if (slice_color_overlaps_ && check_cell_overlap(p, false)) { + data.set_overlap(y, x); } } // inner for - } - } + } // outer for + } // omp parallel return data; } @@ -310,138 +256,44 @@ private: public: // Add mesh lines to ImageData void draw_mesh_lines(ImageData& data) const; - ImageData create_image() const override; + void create_image() const; void create_voxel() const; - void create_output() const override; - void print_info() const override; + virtual void create_output() const; + virtual void print_info() const; PlotType type_; //!< Plot type (Slice/Voxel) - Position width_; //!< Axis-aligned width from plot.xml - PlotBasis basis_; //!< Basis from plot.xml for slice plots int meshlines_width_; //!< Width of lines added to the plot int index_meshlines_mesh_ {-1}; //!< Index of the mesh to draw on the plot RGBColor meshlines_color_; //!< Color of meshlines on the plot }; -/** - * \class RaytracePlot - * \brief Base class for plots that generate images through ray tracing. - * - * This class serves as a base for plots that create their visuals by tracing - * rays from a camera through the problem geometry. It inherits from - * PlottableInterface, ensuring that it provides an implementation for - * generating output specific to ray-traced visualization. WireframeRayTracePlot - * and SolidRayTracePlot provide concrete implementations of this class. - */ -class RayTracePlot : public PlottableInterface { +class ProjectionPlot : public PlottableInterface { + public: - RayTracePlot() = default; - RayTracePlot(pugi::xml_node plot); + ProjectionPlot(pugi::xml_node plot); - // Standard getters. No setting since it's done from XML. - const Position& camera_position() const { return camera_position_; } - Position& camera_position() { return camera_position_; } - const Position& look_at() const { return look_at_; } - Position& look_at() { return look_at_; } - - const double& horizontal_field_of_view() const - { - return horizontal_field_of_view_; - } - double& horizontal_field_of_view() { return horizontal_field_of_view_; } - - void print_info() const override; - - const std::array& pixels() const { return pixels_; } - std::array& pixels() { return pixels_; } - - const Direction& up() const { return up_; } - Direction& up() { return up_; } - - //! brief Updates the cached camera-to-model matrix after changes to - //! camera parameters. - void update_view(); - -protected: - Direction camera_x_axis() const - { - return {camera_to_model_[0], camera_to_model_[3], camera_to_model_[6]}; - } - - Direction camera_y_axis() const - { - return {camera_to_model_[1], camera_to_model_[4], camera_to_model_[7]}; - } - - Direction camera_z_axis() const - { - return {camera_to_model_[2], camera_to_model_[5], camera_to_model_[8]}; - } - - void set_output_path(pugi::xml_node plot_node); - - /* - * Gets the starting position and direction for the pixel corresponding - * to this horizontal and vertical position. - */ - std::pair get_pixel_ray(int horiz, int vert) const; + virtual void create_output() const; + virtual void print_info() const; private: + void set_output_path(pugi::xml_node plot_node); void set_look_at(pugi::xml_node node); void set_camera_position(pugi::xml_node node); void set_field_of_view(pugi::xml_node node); void set_pixels(pugi::xml_node node); - void set_orthographic_width(pugi::xml_node node); - - double horizontal_field_of_view_ {70.0}; // horiz. f.o.v. in degrees - Position camera_position_; // where camera is - Position look_at_; // point camera is centered looking at - std::array pixels_ {100, 100}; // pixel dimension of resulting image - Direction up_ {0.0, 0.0, 1.0}; // which way is up - - /* The horizontal thickness, if using an orthographic projection. - * If set to zero, we assume using a perspective projection. - */ - double orthographic_width_ {C_NONE}; - - /* - * Cached camera-to-model matrix with column vectors of axes. The x-axis is - * the vector between the camera_position_ and look_at_; the y-axis is the - * cross product of the x-axis with the up_ vector, and the z-axis is the - * cross product of the x and y axes. - */ - std::array camera_to_model_; -}; - -class ProjectionRay; - -/** - * \class WireframeRayTracePlot - * \brief Creates plots that are like colorful x-ray imaging - * - * WireframeRayTracePlot is a specialized form of RayTracePlot designed for - * creating projection plots. This involves tracing rays from a camera through - * the problem geometry and rendering the results based on depth of penetration - * through materials or cells and their colors. - */ -class WireframeRayTracePlot : public RayTracePlot { - - friend class ProjectionRay; - -public: - WireframeRayTracePlot(pugi::xml_node plot); - - ImageData create_image() const override; - void create_output() const override; - void print_info() const override; - -private: void set_opacities(pugi::xml_node node); + void set_orthographic_width(pugi::xml_node node); void set_wireframe_thickness(pugi::xml_node node); void set_wireframe_ids(pugi::xml_node node); void set_wireframe_color(pugi::xml_node node); + /* If starting the particle from outside the geometry, we have to + * find a distance to the boundary in a non-standard surface intersection + * check. It's an exhaustive search over surfaces in the top-level universe. + */ + static int advance_to_boundary_from_void(GeometryState& p); + /* Checks if a vector of two TrackSegments is equivalent. We define this * to mean not having matching intersection lengths, but rather having * a matching sequence of surface/cell/material intersections. @@ -462,15 +314,30 @@ private: * if two surfaces bound a single cell, it allows drawing that sharp edge * where the surfaces intersect. */ - int surface_index {-1}; // last surface index intersected in this segment + int surface; // last surface ID intersected in this segment TrackSegment(int id_a, double length_a, int surface_a) - : id(id_a), length(length_a), surface_index(surface_a) + : id(id_a), length(length_a), surface(surface_a) {} }; + // Max intersections before we assume ray tracing is caught in an infinite + // loop: + static const int MAX_INTERSECTIONS = 1000000; + + std::array pixels_; // pixel dimension of resulting image + double horizontal_field_of_view_ {70.0}; // horiz. f.o.v. in degrees + Position camera_position_; // where camera is + Position look_at_; // point camera is centered looking at + Direction up_ {0.0, 0.0, 1.0}; // which way is up + // which color IDs should be wireframed. If empty, all cells are wireframed. vector wireframe_ids_; + /* The horizontal thickness, if using an orthographic projection. + * If set to zero, we assume using a perspective projection. + */ + double orthographic_width_ {0.0}; + // Thickness of the wireframe lines. Can set to zero for no wireframe. int wireframe_thickness_ {1}; @@ -478,99 +345,6 @@ private: vector xs_; // macro cross section values for cell volume rendering }; -/** - * \class SolidRayTracePlot - * \brief Plots 3D objects as the eye might see them. - * - * Plots a geometry with single-scattered Phong lighting plus a diffuse lighting - * contribution. The result is a physically reasonable, aesthetic 3D view of a - * geometry. - */ -class SolidRayTracePlot : public RayTracePlot { - friend class PhongRay; - -public: - SolidRayTracePlot() = default; - - SolidRayTracePlot(pugi::xml_node plot); - - ImageData create_image() const override; - void create_output() const override; - void print_info() const override; - - const std::unordered_set& opaque_ids() const { return opaque_ids_; } - std::unordered_set& opaque_ids() { return opaque_ids_; } - - const Position& light_location() const { return light_location_; } - Position& light_location() { return light_location_; } - - const double& diffuse_fraction() const { return diffuse_fraction_; } - double& diffuse_fraction() { return diffuse_fraction_; } - -private: - void set_opaque_ids(pugi::xml_node node); - void set_light_position(pugi::xml_node node); - void set_diffuse_fraction(pugi::xml_node node); - - std::unordered_set opaque_ids_; - - double diffuse_fraction_ {0.1}; - - // By default, the light is at the camera unless otherwise specified. - Position light_location_; -}; - -class ProjectionRay : public Ray { -public: - ProjectionRay(Position r, Direction u, const WireframeRayTracePlot& plot, - vector& line_segments) - : Ray(r, u), plot_(plot), line_segments_(line_segments) - {} - - void on_intersection() override; - -private: - /* Store a reference to the plot object which is running this ray, in order - * to access some of the plot settings which influence the behavior where - * intersections are. - */ - const WireframeRayTracePlot& plot_; - - /* The ray runs through the geometry, and records the lengths of ray segments - * and cells they lie in along the way. - */ - vector& line_segments_; -}; - -class PhongRay : public Ray { -public: - PhongRay(Position r, Direction u, const SolidRayTracePlot& plot) - : Ray(r, u), plot_(plot) - { - result_color_ = plot_.not_found_; - } - - void on_intersection() override; - - const RGBColor& result_color() { return result_color_; } - -private: - const SolidRayTracePlot& plot_; - - /* After the ray is reflected, it is moving towards the - * camera. It does that in order to see if the exposed surface - * is shadowed by something else. - */ - bool reflected_ {false}; - - // Have to record the first hit ID, so that if the region - // does get shadowed, we recall what its color should be - // when tracing from the surface to the light. - int orig_hit_id_ {-1}; - - RGBColor result_color_; -}; - //=============================================================================== // Non-member functions //=============================================================================== diff --git a/include/openmc/position.h b/include/openmc/position.h index 5d291d26b..11ea37647 100644 --- a/include/openmc/position.h +++ b/include/openmc/position.h @@ -94,24 +94,8 @@ struct Position { //! \result Reflected vector Position reflect(Position n) const; - //! Rotate the position by applying a rotation matrix - template - Position rotate(const T& rotation) const - { - return {x * rotation[0] + y * rotation[1] + z * rotation[2], - x * rotation[3] + y * rotation[4] + z * rotation[5], - x * rotation[6] + y * rotation[7] + z * rotation[8]}; - } - - //! Rotate the position by applying the inverse of a rotation matrix - //! using the fact that rotation matrices are orthonormal. - template - Position inverse_rotate(const T& rotation) const - { - return {x * rotation[0] + y * rotation[3] + z * rotation[6], - x * rotation[1] + y * rotation[4] + z * rotation[7], - x * rotation[2] + y * rotation[5] + z * rotation[8]}; - } + //! Rotate the position based on a rotation matrix + Position rotate(const vector& rotation) const; // Data members double x = 0.; @@ -237,16 +221,12 @@ namespace fmt { template<> struct formatter : formatter { template -#if FMT_VERSION >= 110000 // Version 11.0.0 and above - auto format(const openmc::Position& pos, FormatContext& ctx) const { -#else // For versions below 11.0.0 auto format(const openmc::Position& pos, FormatContext& ctx) { -#endif return formatter::format( fmt::format("({}, {}, {})", pos.x, pos.y, pos.z), ctx); -} -}; // namespace fmt + } +}; } // namespace fmt diff --git a/include/openmc/random_dist.h b/include/openmc/random_dist.h index 32f055b53..0fb186edc 100644 --- a/include/openmc/random_dist.h +++ b/include/openmc/random_dist.h @@ -16,17 +16,6 @@ namespace openmc { double uniform_distribution(double a, double b, uint64_t* seed); -//============================================================================== -//! Sample an integer from uniform distribution [a, b] -// -//! \param a Lower bound of uniform distribution -//! \param b Upper bound of uniform distribtion -//! \param seed A pointer to the pseudorandom seed -//! \return Sampled variate -//============================================================================== - -int64_t uniform_int_distribution(int64_t a, int64_t b, uint64_t* seed); - //============================================================================== //! Samples an energy from the Maxwell fission distribution based on a direct //! sampling scheme. @@ -64,8 +53,8 @@ extern "C" double watt_spectrum(double a, double b, uint64_t* seed); //! Samples from a normal distribution with a given mean and standard deviation //! The PDF is defined as s(x) = (1/2*sigma*sqrt(2) * e-((mu-x)/2*sigma)^2 //! Its sampled according to -//! https://pdg.lbl.gov/2023/reviews/rpp2023-rev-monte-carlo-techniques.pdf -//! section 42.4.4 +//! http://www-pdg.lbl.gov/2009/reviews/rpp2009-rev-monte-carlo-techniques.pdf +//! section 33.4.4 //! //! \param mean mean of the Gaussian distribution //! \param std_dev standard deviation of the Gaussian distribution diff --git a/include/openmc/random_lcg.h b/include/openmc/random_lcg.h index 5aecafed3..4157b7cfe 100644 --- a/include/openmc/random_lcg.h +++ b/include/openmc/random_lcg.h @@ -15,7 +15,6 @@ constexpr int STREAM_SOURCE {1}; constexpr int STREAM_URR_PTABLE {2}; constexpr int STREAM_VOLUME {3}; constexpr int64_t DEFAULT_SEED {1}; -constexpr uint64_t DEFAULT_STRIDE {152917ULL}; //============================================================================== //! Generate a pseudo-random number using a linear congruential generator. @@ -99,18 +98,5 @@ extern "C" int64_t openmc_get_seed(); extern "C" void openmc_set_seed(int64_t new_seed); -//============================================================================== -//! Get OpenMC's stride. -//============================================================================== - -extern "C" uint64_t openmc_get_stride(); - -//============================================================================== -//! Set OpenMC's stride. -//! @param new_stride Stride. -//============================================================================== - -extern "C" void openmc_set_stride(uint64_t new_stride); - } // namespace openmc #endif // OPENMC_RANDOM_LCG_H diff --git a/include/openmc/random_ray/flat_source_domain.h b/include/openmc/random_ray/flat_source_domain.h index 09414fd44..badbb25fc 100644 --- a/include/openmc/random_ray/flat_source_domain.h +++ b/include/openmc/random_ray/flat_source_domain.h @@ -1,17 +1,85 @@ #ifndef OPENMC_RANDOM_RAY_FLAT_SOURCE_DOMAIN_H #define OPENMC_RANDOM_RAY_FLAT_SOURCE_DOMAIN_H -#include "openmc/constants.h" #include "openmc/openmp_interface.h" #include "openmc/position.h" -#include "openmc/random_ray/parallel_map.h" -#include "openmc/random_ray/source_region.h" #include "openmc/source.h" -#include -#include namespace openmc { +//---------------------------------------------------------------------------- +// Helper Functions + +// The hash_combine function is the standard hash combine function from boost +// that is typically used for combining multiple hash values into a single hash +// as is needed for larger objects being stored in a hash map. The function is +// taken from: +// https://www.boost.org/doc/libs/1_55_0/doc/html/hash/reference.html#boost.hash_combine +// which carries the following license: +// +// Boost Software License - Version 1.0 - August 17th, 2003 +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +inline void hash_combine(size_t& seed, const size_t v) +{ + seed ^= (v + 0x9e3779b9 + (seed << 6) + (seed >> 2)); +} + +//---------------------------------------------------------------------------- +// Helper Structs + +// A mapping object that is used to map between a specific random ray +// source region and an OpenMC native tally bin that it should score to +// every iteration. +struct TallyTask { + int tally_idx; + int filter_idx; + int score_idx; + int score_type; + TallyTask(int tally_idx, int filter_idx, int score_idx, int score_type) + : tally_idx(tally_idx), filter_idx(filter_idx), score_idx(score_idx), + score_type(score_type) + {} + TallyTask() = default; + + // Comparison and Hash operators are defined to allow usage of the + // TallyTask struct as a key in an unordered_set + bool operator==(const TallyTask& other) const + { + return tally_idx == other.tally_idx && filter_idx == other.filter_idx && + score_idx == other.score_idx && score_type == other.score_type; + } + + struct HashFunctor { + size_t operator()(const TallyTask& task) const + { + size_t seed = 0; + hash_combine(seed, task.tally_idx); + hash_combine(seed, task.filter_idx); + hash_combine(seed, task.score_idx); + hash_combine(seed, task.score_type); + return seed; + } + }; +}; + /* * The FlatSourceDomain class encompasses data and methods for storing * scalar flux and source region for all flat source regions in a @@ -21,85 +89,32 @@ namespace openmc { class FlatSourceDomain { public: //---------------------------------------------------------------------------- - // Constructors and Destructors + // Constructors FlatSourceDomain(); - virtual ~FlatSourceDomain() = default; //---------------------------------------------------------------------------- // Methods - virtual void update_single_neutron_source(SourceRegionHandle& srh); - virtual void update_all_neutron_sources(); - void compute_k_eff(); - virtual void normalize_scalar_flux_and_volumes( + void update_neutron_source(double k_eff); + double compute_k_eff(double k_eff_old) const; + void normalize_scalar_flux_and_volumes( double total_active_distance_per_iteration); - int64_t add_source_to_scalar_flux(); - virtual void batch_reset(); - void convert_source_regions_to_tallies(int64_t start_sr_id); + void batch_reset(); + void convert_source_regions_to_tallies(); void reset_tally_volumes(); void random_ray_tally(); - virtual void accumulate_iteration_flux(); + void accumulate_iteration_flux(); void output_to_vtk() const; - void convert_external_sources(bool use_adjoint_sources); + void all_reduce_replicated_source_regions(); + void convert_external_sources(); void count_external_source_regions(); - void set_fw_adjoint_sources(); - void set_local_adjoint_sources(); - void flux_swap(); - virtual double evaluate_flux_at_point(Position r, int64_t sr, int g) const; - double compute_fixed_source_normalization_factor() const; - void flatten_xs(); - void transpose_scattering_matrix(); - void serialize_final_fluxes(vector& flux); - void apply_meshes(); - void apply_mesh_to_cell_instances(int32_t i_cell, int32_t mesh_idx, - int target_material_id, const vector& instances, - bool is_target_void); - void apply_mesh_to_cell_and_children(int32_t i_cell, int32_t mesh_idx, - int32_t target_material_id, bool is_target_void); - SourceRegionHandle get_subdivided_source_region_handle( - SourceRegionKey sr_key, Position r, Direction u); - void finalize_discovered_source_regions(); - void apply_transport_stabilization(); - int64_t n_source_regions() const - { - return source_regions_.n_source_regions(); - } - int64_t n_source_elements() const - { - return source_regions_.n_source_regions() * negroups_; - } - int64_t lookup_base_source_region_idx(const GeometryState& p) const; - SourceRegionKey lookup_source_region_key(const GeometryState& p) const; - int64_t lookup_mesh_bin(int64_t sr, Position r) const; - int lookup_mesh_idx(int64_t sr) const; - - //---------------------------------------------------------------------------- - // Static Data members - static bool volume_normalized_flux_tallies_; - // If the user wants outputs based on the adjoint flux - static bool adjoint_requested_; - // The solve currently being executed - static RandomRaySolve solve_; - static bool fw_cadis_local_; - static double - diagonal_stabilization_rho_; // Adjusts strength of diagonal stabilization - // for transport corrected MGXS data - - // Static variables to store source region meshes and domains - static std::unordered_map>> - mesh_domain_map_; - - static std::vector fw_cadis_local_targets_; - - //---------------------------------------------------------------------------- - // Static data members - static RandomRayVolumeEstimator volume_estimator_; //---------------------------------------------------------------------------- // Public Data members - double k_eff_ {1.0}; // Eigenvalue + bool mapped_all_tallies_ {false}; // If all source regions have been visited + int64_t n_source_regions_ {0}; // Total number of source regions in the model int64_t n_external_source_regions_ {0}; // Total number of source regions with // non-zero external source terms @@ -107,88 +122,66 @@ public: // in model::cells vector source_region_offsets_; - // 3D arrays stored in 1D representing values for all materials x temperature - // points x energy groups - int n_materials_; - int ntemperature_; - vector sigma_t_; - vector nu_sigma_f_; - vector sigma_f_; - vector chi_; - vector kappa_fission_; + // 1D arrays representing values for all source regions + vector lock_; + vector was_hit_; + vector volume_; + vector position_recorded_; + vector position_; - // 4D arrays stored in 1D representing values for all materials x temperature - // points x energy groups x energy groups - vector sigma_s_; + // 2D arrays stored in 1D representing values for all source regions x energy + // groups + vector scalar_flux_old_; + vector scalar_flux_new_; + vector source_; + vector external_source_; - // The abstract container holding all source region-specific data - SourceRegionContainer source_regions_; - - // Parallel hash map holding all source regions discovered during - // a single iteration. This is a threadsafe data structure that is cleaned - // out after each iteration and stored in the "source_regions_" container. - // It is keyed with a SourceRegionKey, which combines the base source - // region index and the mesh bin. - ParallelMap - discovered_source_regions_; - - // Map that relates a SourceRegionKey to the index at which the source - // region can be found in the "source_regions_" container. - std::unordered_map - source_region_map_; - - // Map that relates a SourceRegionKey to the external source index. This map - // is used to check if there are any point sources within a subdivided source - // region at the time it is discovered. - std::unordered_map, SourceRegionKey::HashFunctor> - external_point_source_map_; - - // Map that relates a base source region index to the external source index. - // This map is used to check if there are any volumetric sources within a - // subdivided source region at the time it is discovered. - std::unordered_map> external_volumetric_source_map_; - - // Map that relates a base source region index to a mesh index. This map - // is used to check which subdivision mesh is present in a source region. - std::unordered_map mesh_map_; - - // If transport corrected MGXS data is being used, there may be negative - // in-group scattering cross sections that can result in instability in MOC - // and random ray if used naively. This flag enables a stabilization - // technique. - bool is_transport_stabilization_needed_ {false}; - -protected: +private: //---------------------------------------------------------------------------- // Methods void apply_external_source_to_source_region( - int src_idx, SourceRegionHandle& srh); - void apply_external_source_to_cell_instances(int32_t i_cell, int src_idx, - int target_material_id, const vector& instances); - void apply_external_source_to_cell_and_children( - int32_t i_cell, int src_idx, int32_t target_material_id); - virtual void set_flux_to_flux_plus_source(int64_t sr, double volume, int g); - void set_flux_to_source(int64_t sr, int g); - virtual void set_flux_to_old_flux(int64_t sr, int g); + Discrete* discrete, double strength_factor, int64_t source_region); + void apply_external_source_to_cell_instances(int32_t i_cell, + Discrete* discrete, double strength_factor, int target_material_id, + const vector& instances); + void apply_external_source_to_cell_and_children(int32_t i_cell, + Discrete* discrete, double strength_factor, int32_t target_material_id); //---------------------------------------------------------------------------- // Private data members - int negroups_; // Number of energy groups in simulation + int negroups_; // Number of energy groups in simulation + int64_t n_source_elements_ {0}; // Total number of source regions in the model + // times the number of energy groups double simulation_volume_; // Total physical volume of the simulation domain, as // defined by the 3D box of the random ray source - double - fission_rate_; // The system's fission rate (per cm^3), in eigenvalue mode + // 2D array representing values for all source elements x tally + // tasks + vector> tally_task_; + + // 1D array representing values for all source regions, with each region + // containing a set of volume tally tasks. This more complicated data + // structure is convenient for ensuring that volumes are only tallied once per + // source region, regardless of how many energy groups are used for tallying. + vector> volume_task_; + + // 1D arrays representing values for all source regions + vector material_; + vector volume_t_; + + // 2D arrays stored in 1D representing values for all source regions x energy + // groups + vector scalar_flux_final_; // Volumes for each tally and bin/score combination. This intermediate data // structure is used when tallying quantities that must be normalized by // volume (i.e., flux). The vector is index by tally index, while the inner 2D - // tensor is indexed by bin index and score index in a similar manner to the + // xtensor is indexed by bin index and score index in a similar manner to the // results tensor in the Tally class, though without the third dimension, as // SUM and SUM_SQ do not need to be tracked. - vector> tally_volumes_; + vector> tally_volumes_; }; // class FlatSourceDomain @@ -225,6 +218,15 @@ T convert_to_big_endian(T in) return out; } +template +void parallel_fill(vector& arr, T value) +{ +#pragma omp parallel for schedule(static) + for (int i = 0; i < arr.size(); i++) { + arr[i] = value; + } +} + } // namespace openmc #endif // OPENMC_RANDOM_RAY_FLAT_SOURCE_DOMAIN_H diff --git a/include/openmc/random_ray/linear_source_domain.h b/include/openmc/random_ray/linear_source_domain.h deleted file mode 100644 index 0098c7820..000000000 --- a/include/openmc/random_ray/linear_source_domain.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef OPENMC_RANDOM_RAY_LINEAR_SOURCE_DOMAIN_H -#define OPENMC_RANDOM_RAY_LINEAR_SOURCE_DOMAIN_H - -#include "openmc/random_ray/flat_source_domain.h" -#include "openmc/random_ray/moment_matrix.h" - -#include "openmc/openmp_interface.h" -#include "openmc/position.h" -#include "openmc/source.h" - -namespace openmc { - -/* - * The LinearSourceDomain class encompasses data and methods for storing - * scalar flux and source region for all linear source regions in a - * random ray simulation domain. - */ - -class LinearSourceDomain : public FlatSourceDomain { -public: - //---------------------------------------------------------------------------- - // Methods - void update_single_neutron_source(SourceRegionHandle& srh) override; - void normalize_scalar_flux_and_volumes( - double total_active_distance_per_iteration) override; - - void batch_reset() override; - void accumulate_iteration_flux() override; - void output_to_vtk() const; - double evaluate_flux_at_point(Position r, int64_t sr, int g) const override; - -protected: - //---------------------------------------------------------------------------- - // Methods - void set_flux_to_flux_plus_source(int64_t sr, double volume, int g) override; - void set_flux_to_old_flux(int64_t sr, int g) override; - -}; // class LinearSourceDomain - -} // namespace openmc - -#endif // OPENMC_RANDOM_RAY_LINEAR_SOURCE_DOMAIN_H diff --git a/include/openmc/random_ray/moment_matrix.h b/include/openmc/random_ray/moment_matrix.h deleted file mode 100644 index c95bb2c12..000000000 --- a/include/openmc/random_ray/moment_matrix.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef OPENMC_MOMENT_MATRIX_H -#define OPENMC_MOMENT_MATRIX_H - -#include - -#include "openmc/position.h" - -namespace openmc { - -// The MomentArray class is a 3-element array representing the x, y, and z -// moments. It is defined as an alias for the Position class to allow for -// dot products and other operations with Position objects. -// TODO: This class could in theory have 32-bit instead of 64-bit FP values. -using MomentArray = Position; - -// The MomentMatrix class is a sparse representation a 3x3 symmetric -// matrix, with elements labeled as follows: -// -// | a b c | -// | b d e | -// | c e f | -// -// This class uses FP64 values as objects that are accumulated to over many -// iterations. -class MomentMatrix { -public: - //---------------------------------------------------------------------------- - // Public data members - double a; - double b; - double c; - double d; - double e; - double f; - - //---------------------------------------------------------------------------- - // Constructors - MomentMatrix() = default; - MomentMatrix(double a, double b, double c, double d, double e, double f) - : a {a}, b {b}, c {c}, d {d}, e {e}, f {f} - {} - - //---------------------------------------------------------------------------- - // Methods - MomentMatrix inverse() const; - double determinant() const; - void compute_spatial_moments_matrix( - const Position& r, const Direction& u, const double& distance); - - inline void set_to_zero() { a = b = c = d = e = f = 0; } - - inline MomentMatrix& operator*=(double x) - { - a *= x; - b *= x; - c *= x; - d *= x; - e *= x; - f *= x; - return *this; - } - - inline MomentMatrix operator*(double x) const - { - MomentMatrix m_copy = *this; - m_copy *= x; - return m_copy; - } - - inline MomentMatrix& operator+=(const MomentMatrix& rhs) - { - a += rhs.a; - b += rhs.b; - c += rhs.c; - d += rhs.d; - e += rhs.e; - f += rhs.f; - return *this; - } - - MomentArray operator*(const MomentArray& rhs) const - { - return {a * rhs.x + b * rhs.y + c * rhs.z, - b * rhs.x + d * rhs.y + e * rhs.z, c * rhs.x + e * rhs.y + f * rhs.z}; - } -}; - -} // namespace openmc - -#endif // OPENMC_MOMENT_MATRIX_H diff --git a/include/openmc/random_ray/parallel_map.h b/include/openmc/random_ray/parallel_map.h deleted file mode 100644 index 7f4f06d99..000000000 --- a/include/openmc/random_ray/parallel_map.h +++ /dev/null @@ -1,193 +0,0 @@ -#ifndef OPENMC_RANDOM_RAY_PARALLEL_HASH_MAP_H -#define OPENMC_RANDOM_RAY_PARALLEL_HASH_MAP_H - -#include "openmc/openmp_interface.h" - -#include -#include - -namespace openmc { - -/* - * The ParallelMap class allows for threadsafe access to a map-like data - * structure. It is implemented as a hash table with a fixed number of buckets, - * each of which contains a mutex lock and an unordered_map. The class provides - * a subset of the functionality of std::unordered_map. Users must first lock - * the object (using the key) before accessing or modifying the map. The object - * is locked by bucket, allowing for multiple threads to manipulate different - * keys simultaneously, though sometimes threads will need to wait if keys - * happen to be in the same bucket. The ParallelMap will generate pointers to - * hold values, rather than direct storage of values, so as to allow for - * pointers to values to remain valid even after the lock has been released - * (though locking of those values is then left to the user). Iterators to the - * class are provided but are not threadsafe, and are meant to be used only in a - * serial context (e.g., to dump the contents of the map to another data - * structure). - */ - -template -class ParallelMap { - - //---------------------------------------------------------------------------- - // Helper structs and classes - - struct Bucket { - OpenMPMutex lock_; - std::unordered_map, HashFunctor> map_; - }; - - // The iterator yields a pair: (const KeyType&, ValueType&) - class iterator { - public: - using iterator_category = std::forward_iterator_tag; - using value_type = std::pair; - using difference_type = std::ptrdiff_t; - using pointer = void; // Not providing pointer semantics. - using reference = value_type; - - iterator(std::vector* buckets, std::size_t bucket_index, - typename std::unordered_map, - HashFunctor>::iterator inner_it) - : buckets_(buckets), bucket_index_(bucket_index), inner_it_(inner_it) - { - // Advance to the first valid element if necessary. - advance_to_valid(); - } - - // Dereference returns a pair of (key, value). - reference operator*() const - { - return {inner_it_->first, *inner_it_->second}; - } - - iterator& operator++() - { - ++inner_it_; - advance_to_valid(); - return *this; - } - - iterator operator++(int) - { - iterator tmp = *this; - ++(*this); - return tmp; - } - - bool operator==(const iterator& other) const - { - // Two iterators are equal if they refer to the same bucket vector and are - // both at end, or if they have the same bucket index and inner iterator. - return buckets_ == other.buckets_ && - bucket_index_ == other.bucket_index_ && - (bucket_index_ == buckets_->size() || - inner_it_ == other.inner_it_); - } - - bool operator!=(const iterator& other) const { return !(*this == other); } - - private: - // Helper function: if we are at the end of the current bucket, advance to - // the next non-empty bucket. - void advance_to_valid() - { - while (bucket_index_ < buckets_->size() && - inner_it_ == (*buckets_)[bucket_index_].map_.end()) { - ++bucket_index_; - if (bucket_index_ < buckets_->size()) - inner_it_ = (*buckets_)[bucket_index_].map_.begin(); - } - } - - std::vector* buckets_; - std::size_t bucket_index_; - typename std::unordered_map, - HashFunctor>::iterator inner_it_; - }; - -public: - //---------------------------------------------------------------------------- - // Constructor - ParallelMap(int n_buckets = 1000) : buckets_(n_buckets) {} - - //---------------------------------------------------------------------------- - // Public Methods - void lock(const KeyType& key) - { - Bucket& bucket = get_bucket(key); - bucket.lock_.lock(); - } - - void unlock(const KeyType& key) - { - Bucket& bucket = get_bucket(key); - bucket.lock_.unlock(); - } - - void clear() - { - for (auto& bucket : buckets_) { - bucket.map_.clear(); - } - } - - bool contains(const KeyType& key) - { - Bucket& bucket = get_bucket(key); - // C++20 - // return bucket.map_.contains(key); - return bucket.map_.find(key) != bucket.map_.end(); - } - - ValueType& operator[](const KeyType& key) - { - Bucket& bucket = get_bucket(key); - return *bucket.map_[key].get(); - } - - ValueType* emplace(KeyType key, const ValueType& value) - { - Bucket& bucket = get_bucket(key); - // Attempt to emplace the new element into the unordered_map within the - auto result = bucket.map_.emplace(key, std::make_unique(value)); - auto it = result.first; - return it->second.get(); - } - - // Return iterator to first element. - iterator begin() - { - std::size_t bucket_index = 0; - auto inner_it = buckets_.empty() - ? typename std::unordered_map, HashFunctor>::iterator() - : buckets_[0].map_.begin(); - return iterator(&buckets_, bucket_index, inner_it); - } - - // Return iterator to one-past-last element. - iterator end() - { - // End is signaled by bucket_index_ equal to buckets_.size() - return iterator(&buckets_, buckets_.size(), - typename std::unordered_map, - HashFunctor>::iterator()); - } - -private: - //---------------------------------------------------------------------------- - // Private Methods - Bucket& get_bucket(const KeyType& key) - { - return buckets_[hash(key) % buckets_.size()]; - } - - //---------------------------------------------------------------------------- - // Private Data Fields - HashFunctor hash; - vector buckets_; -}; - -} // namespace openmc - -#endif // OPENMC_RANDOM_RAY_PARALLEL_HASH_MAP_H diff --git a/include/openmc/random_ray/random_ray.h b/include/openmc/random_ray/random_ray.h index b61d2d67a..5ee64574e 100644 --- a/include/openmc/random_ray/random_ray.h +++ b/include/openmc/random_ray/random_ray.h @@ -4,7 +4,6 @@ #include "openmc/memory.h" #include "openmc/particle.h" #include "openmc/random_ray/flat_source_domain.h" -#include "openmc/random_ray/moment_matrix.h" #include "openmc/source.h" namespace openmc { @@ -25,48 +24,25 @@ public: //---------------------------------------------------------------------------- // Methods void event_advance_ray(); - void attenuate_flux(double distance, bool is_active, double offset = 0.0); - void attenuate_flux_inner( - double distance, bool is_active, int64_t sr, int mesh_bin, Position r); - void attenuate_flux_flat_source( - SourceRegionHandle& srh, double distance, bool is_active, Position r); - void attenuate_flux_flat_source_void( - SourceRegionHandle& srh, double distance, bool is_active, Position r); - void attenuate_flux_linear_source( - SourceRegionHandle& srh, double distance, bool is_active, Position r); - void attenuate_flux_linear_source_void( - SourceRegionHandle& srh, double distance, bool is_active, Position r); - + void attenuate_flux(double distance, bool is_active); void initialize_ray(uint64_t ray_id, FlatSourceDomain* domain); uint64_t transport_history_based_single_ray(); - SourceSite sample_prng(); - SourceSite sample_halton(); - SourceSite sample_s2(); //---------------------------------------------------------------------------- // Static data members - static double distance_inactive_; // Inactive (dead zone) ray length - static double distance_active_; // Active ray length - static unique_ptr ray_source_; // Starting source for ray sampling - static RandomRaySourceShape source_shape_; // Flag for linear source - static RandomRaySampleMethod sample_method_; // Flag for sampling method + static double distance_inactive_; // Inactive (dead zone) ray length + static double distance_active_; // Active ray length + static unique_ptr ray_source_; // Starting source for ray sampling //---------------------------------------------------------------------------- // Public data members vector angular_flux_; - bool ray_trace_only_ {false}; // If true, only perform geometry operations - private: //---------------------------------------------------------------------------- // Private data members vector delta_psi_; - vector delta_moments_; - vector mesh_bins_; - vector mesh_fractional_lengths_; - int negroups_; - int ntemperature_; FlatSourceDomain* domain_ {nullptr}; // pointer to domain that has flat source // data needed for ray transport double distance_travelled_ {0}; diff --git a/include/openmc/random_ray/random_ray_simulation.h b/include/openmc/random_ray/random_ray_simulation.h index e186c549f..b439574bf 100644 --- a/include/openmc/random_ray/random_ray_simulation.h +++ b/include/openmc/random_ray/random_ray_simulation.h @@ -2,7 +2,6 @@ #define OPENMC_RANDOM_RAY_SIMULATION_H #include "openmc/random_ray/flat_source_domain.h" -#include "openmc/random_ray/linear_source_domain.h" namespace openmc { @@ -19,11 +18,8 @@ public: //---------------------------------------------------------------------------- // Methods - void apply_fixed_sources_and_mesh_domains(); - void prepare_fw_fixed_sources_adjoint(); - void prepare_local_fixed_sources_adjoint(); - void prepare_adjoint_simulation(bool from_forward); void simulate(); + void reduce_simulation_statistics(); void output_simulation_results() const; void instability_check( int64_t n_hits, double k_eff, double& avg_miss_rate) const; @@ -31,16 +27,14 @@ public: double avg_miss_rate, int negroups, int64_t n_source_regions, int64_t n_external_source_regions) const; - //---------------------------------------------------------------------------- - // Accessors - FlatSourceDomain* domain() const { return domain_.get(); } - -private: //---------------------------------------------------------------------------- // Data members - +private: // Contains all flat source region data - unique_ptr domain_; + FlatSourceDomain domain_; + + // Random ray eigenvalue + double k_eff_ {1.0}; // Tracks the average FSR miss rate for analysis and reporting double avg_miss_rate_ {0.0}; @@ -58,8 +52,8 @@ private: //! Non-member functions //============================================================================ +void openmc_run_random_ray(); void validate_random_ray_inputs(); -void openmc_finalize_random_ray(); } // namespace openmc diff --git a/include/openmc/random_ray/source_region.h b/include/openmc/random_ray/source_region.h deleted file mode 100644 index 1d2bbe1e8..000000000 --- a/include/openmc/random_ray/source_region.h +++ /dev/null @@ -1,698 +0,0 @@ -#ifndef OPENMC_RANDOM_RAY_SOURCE_REGION_H -#define OPENMC_RANDOM_RAY_SOURCE_REGION_H - -#include "openmc/openmp_interface.h" -#include "openmc/position.h" -#include "openmc/random_ray/moment_matrix.h" -#include "openmc/settings.h" - -namespace openmc { - -//---------------------------------------------------------------------------- -// Helper Functions - -// The hash_combine function is the standard hash combine function from boost -// that is typically used for combining multiple hash values into a single hash -// as is needed for larger objects being stored in a hash map. The function is -// taken from: -// https://www.boost.org/doc/libs/1_55_0/doc/html/hash/reference.html#boost.hash_combine -// which carries the following license: -// -// Boost Software License - Version 1.0 - August 17th, 2003 -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -inline void hash_combine(size_t& seed, const size_t v) -{ - seed ^= (v + 0x9e3779b9 + (seed << 6) + (seed >> 2)); -} - -//---------------------------------------------------------------------------- -// Helper Structs and Classes - -// A mapping object that is used to map between a specific random ray -// source region and an OpenMC native tally bin that it should score to -// every iteration. -struct TallyTask { - int tally_idx; - int64_t filter_idx; - int score_idx; - int score_type; - TallyTask(int tally_idx, int64_t filter_idx, int score_idx, int score_type) - : tally_idx(tally_idx), filter_idx(filter_idx), score_idx(score_idx), - score_type(score_type) - {} - TallyTask() = default; - - // Comparison and Hash operators are defined to allow usage of the - // TallyTask struct as a key in an unordered_set - bool operator==(const TallyTask& other) const - { - return tally_idx == other.tally_idx && filter_idx == other.filter_idx && - score_idx == other.score_idx && score_type == other.score_type; - } - - struct HashFunctor { - size_t operator()(const TallyTask& task) const - { - size_t seed = 0; - hash_combine(seed, task.tally_idx); - hash_combine(seed, task.filter_idx); - hash_combine(seed, task.score_idx); - hash_combine(seed, task.score_type); - return seed; - } - }; -}; - -// The SourceRegionKey combines a base source region (i.e., a material -// filled cell instance) with a mesh bin. This key is used as a handle -// for dynamically discovered source regions when subdividing source -// regions with meshes. -class SourceRegionKey { -public: - int64_t base_source_region_id; - int64_t mesh_bin; - SourceRegionKey() = default; - SourceRegionKey(int64_t source_region, int64_t bin) - : base_source_region_id(source_region), mesh_bin(bin) - {} - - // Equality operator required by the unordered_map - bool operator==(const SourceRegionKey& other) const - { - return base_source_region_id == other.base_source_region_id && - mesh_bin == other.mesh_bin; - } - - // Less than operator required by std::sort - bool operator<(const SourceRegionKey& other) const - { - if (base_source_region_id < other.base_source_region_id) { - return true; - } else if (base_source_region_id > other.base_source_region_id) { - return false; - } else { - return mesh_bin < other.mesh_bin; - } - } - - // Hashing functor required by the unordered_map - struct HashFunctor { - size_t operator()(const SourceRegionKey& key) const - { - size_t seed = 0; - hash_combine(seed, key.base_source_region_id); - hash_combine(seed, key.mesh_bin); - return seed; - } - }; -}; - -// Forward declaration of SourceRegion -class SourceRegion; - -class SourceRegionHandle { -public: - //---------------------------------------------------------------------------- - // Constructors - SourceRegionHandle(SourceRegion& sr); - SourceRegionHandle() = default; - - // All fields are commented/described in the SourceRegion class definition - // below - - //---------------------------------------------------------------------------- - // Public Data members - int negroups_; - bool is_numerical_fp_artifact_ {false}; - bool is_linear_ {false}; - - // Scalar fields - int* material_; - int* temperature_idx_; - double* density_mult_; - int* is_small_; - int* n_hits_; - int* birthday_; - OpenMPMutex* lock_; - double* volume_; - double* volume_t_; - double* volume_sq_; - double* volume_sq_t_; - double* volume_naive_; - int* position_recorded_; - int* external_source_present_; - Position* position_; - Position* centroid_; - Position* centroid_iteration_; - Position* centroid_t_; - MomentMatrix* mom_matrix_; - MomentMatrix* mom_matrix_t_; - // A set of volume tally tasks. This more complicated data structure is - // convenient for ensuring that volumes are only tallied once per source - // region, regardless of how many energy groups are used for tallying. - std::unordered_set* volume_task_; - - // Mesh that subdivides this source region - int* mesh_; - int64_t* parent_sr_; - - // Energy group-wise 1D arrays - double* scalar_flux_old_; - double* scalar_flux_new_; - float* source_; - float* external_source_; - double* scalar_flux_final_; - - MomentArray* source_gradients_; - MomentArray* flux_moments_old_; - MomentArray* flux_moments_new_; - MomentArray* flux_moments_t_; - - // 2D array representing values for all energy groups x tally - // tasks. Each group may have a different number of tally tasks - // associated with it, necessitating the use of a jagged array. - vector* tally_task_; - - //---------------------------------------------------------------------------- - // Public Accessors - - int& material() { return *material_; } - const int material() const { return *material_; } - - double& density_mult() { return *density_mult_; } - const double density_mult() const { return *density_mult_; } - - int& temperature_idx() { return *temperature_idx_; } - const int temperature_idx() const { return *temperature_idx_; } - - int& is_small() { return *is_small_; } - const int is_small() const { return *is_small_; } - - int& n_hits() { return *n_hits_; } - const int n_hits() const { return *n_hits_; } - - void lock() { lock_->lock(); } - void unlock() { lock_->unlock(); } - - double& volume() { return *volume_; } - const double volume() const { return *volume_; } - - double& volume_t() { return *volume_t_; } - const double volume_t() const { return *volume_t_; } - - double& volume_sq() { return *volume_sq_; } - const double volume_sq() const { return *volume_sq_; } - - double& volume_sq_t() { return *volume_sq_t_; } - const double volume_sq_t() const { return *volume_sq_t_; } - - double& volume_naive() { return *volume_naive_; } - const double volume_naive() const { return *volume_naive_; } - - int& position_recorded() { return *position_recorded_; } - const int position_recorded() const { return *position_recorded_; } - - int& external_source_present() { return *external_source_present_; } - const int external_source_present() const - { - return *external_source_present_; - } - - Position& position() { return *position_; } - const Position position() const { return *position_; } - - Position& centroid() { return *centroid_; } - const Position centroid() const { return *centroid_; } - - Position& centroid_iteration() { return *centroid_iteration_; } - const Position centroid_iteration() const { return *centroid_iteration_; } - - Position& centroid_t() { return *centroid_t_; } - const Position centroid_t() const { return *centroid_t_; } - - MomentMatrix& mom_matrix() { return *mom_matrix_; } - const MomentMatrix mom_matrix() const { return *mom_matrix_; } - - MomentMatrix& mom_matrix_t() { return *mom_matrix_t_; } - const MomentMatrix mom_matrix_t() const { return *mom_matrix_t_; } - - std::unordered_set& volume_task() - { - return *volume_task_; - } - const std::unordered_set& volume_task() - const - { - return *volume_task_; - } - - int& mesh() { return *mesh_; } - const int mesh() const { return *mesh_; } - - int64_t& parent_sr() { return *parent_sr_; } - const int64_t parent_sr() const { return *parent_sr_; } - - double& scalar_flux_old(int g) { return scalar_flux_old_[g]; } - const double scalar_flux_old(int g) const { return scalar_flux_old_[g]; } - - double& scalar_flux_new(int g) { return scalar_flux_new_[g]; } - const double scalar_flux_new(int g) const { return scalar_flux_new_[g]; } - - double& scalar_flux_final(int g) { return scalar_flux_final_[g]; } - const double scalar_flux_final(int g) const { return scalar_flux_final_[g]; } - - float& source(int g) { return source_[g]; } - const float source(int g) const { return source_[g]; } - - float& external_source(int g) { return external_source_[g]; } - const float external_source(int g) const { return external_source_[g]; } - - MomentArray& source_gradients(int g) { return source_gradients_[g]; } - const MomentArray source_gradients(int g) const - { - return source_gradients_[g]; - } - - MomentArray& flux_moments_old(int g) { return flux_moments_old_[g]; } - const MomentArray flux_moments_old(int g) const - { - return flux_moments_old_[g]; - } - - MomentArray& flux_moments_new(int g) { return flux_moments_new_[g]; } - const MomentArray flux_moments_new(int g) const - { - return flux_moments_new_[g]; - } - - MomentArray& flux_moments_t(int g) { return flux_moments_t_[g]; } - const MomentArray flux_moments_t(int g) const { return flux_moments_t_[g]; } - - vector& tally_task(int g) { return tally_task_[g]; } - const vector& tally_task(int g) const { return tally_task_[g]; } - -}; // class SourceRegionHandle - -class SourceRegion { -public: - //---------------------------------------------------------------------------- - // Constructors - SourceRegion(int negroups, bool is_linear); - SourceRegion() = default; - - //---------------------------------------------------------------------------- - // Public Data members - - //--------------------------------------- - // Scalar fields - int material_ {0}; //!< Index in openmc::model::materials array - int temperature_idx_ { - 0}; //!< Index into the MGXS array representing temperature - double density_mult_ {1.0}; //!< A density multiplier queried from the cell - //!< corresponding to the source region. - OpenMPMutex lock_; - double volume_ { - 0.0}; //!< Volume (computed from the sum of ray crossing lengths) - double volume_t_ {0.0}; //!< Volume totaled over all iterations - double volume_sq_ {0.0}; //!< Volume squared - double volume_sq_t_ {0.0}; //!< Volume squared totaled over all iterations - double volume_naive_ {0.0}; //!< Volume as integrated from this iteration only - int position_recorded_ {0}; //!< Has the position been recorded yet? - int external_source_present_ { - 0}; //!< Is an external source present in this region? - int is_small_ {0}; //!< Is it "small", receiving < 1.5 hits per iteration? - int n_hits_ {0}; //!< Number of total hits (ray crossings) - // Mesh that subdivides this source region - int mesh_ {C_NONE}; //!< Index in openmc::model::meshes array that subdivides - //!< this source region - int64_t parent_sr_ {C_NONE}; //!< Index of a parent source region - Position position_ { - 0.0, 0.0, 0.0}; //!< A position somewhere inside the region - Position centroid_ {0.0, 0.0, 0.0}; //!< The centroid - Position centroid_iteration_ { - 0.0, 0.0, 0.0}; //!< The centroid integrated from this iteration only - Position centroid_t_ { - 0.0, 0.0, 0.0}; //!< The centroid accumulated over all iterations - MomentMatrix mom_matrix_ { - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; //!< The spatial moment matrix - MomentMatrix mom_matrix_t_ {0.0, 0.0, 0.0, 0.0, 0.0, - 0.0}; //!< The spatial moment matrix accumulated over all iterations - - // A set of volume tally tasks. This more complicated data structure is - // convenient for ensuring that volumes are only tallied once per source - // region, regardless of how many energy groups are used for tallying. - std::unordered_set volume_task_; - - //--------------------------------------- - // Energy group-wise 1D arrays - - vector - scalar_flux_old_; //!< The scalar flux from the previous iteration - vector - scalar_flux_new_; //!< The scalar flux from the current iteration - vector - source_; //!< The total source term (fission + scattering + external) - vector external_source_; //!< The external source term - vector scalar_flux_final_; //!< The scalar flux accumulated over all - //!< active iterations (used for plotting, - //!< or computing adjoint sources) - - vector source_gradients_; //!< The linear source gradients - vector - flux_moments_old_; //!< The linear flux moments from the previous iteration - vector - flux_moments_new_; //!< The linear flux moments from the current iteration - vector - flux_moments_t_; //!< The linear flux moments accumulated over all active - //!< iterations (used for plotting) - - //--------------------------------------- - // 2D array representing values for all energy groups x tally - // tasks. Each group may have a different number of tally tasks - // associated with it, necessitating the use of a jagged array. - vector> tally_task_; -}; // class SourceRegion - -class SourceRegionContainer { -public: - //---------------------------------------------------------------------------- - // Constructors - SourceRegionContainer(int negroups, bool is_linear) - : negroups_(negroups), is_linear_(is_linear) - {} - SourceRegionContainer() = default; - - //---------------------------------------------------------------------------- - // Public Accessors - int& material(int64_t sr) { return material_[sr]; } - const int material(int64_t sr) const { return material_[sr]; } - - int& temperature_idx(int64_t sr) { return temperature_idx_[sr]; } - const int temperature_idx(int64_t sr) const { return temperature_idx_[sr]; } - - double& density_mult(int64_t sr) { return density_mult_[sr]; } - const double density_mult(int64_t sr) const { return density_mult_[sr]; } - - int& is_small(int64_t sr) { return is_small_[sr]; } - const int is_small(int64_t sr) const { return is_small_[sr]; } - - int& n_hits(int64_t sr) { return n_hits_[sr]; } - const int n_hits(int64_t sr) const { return n_hits_[sr]; } - - OpenMPMutex& lock(int64_t sr) { return lock_[sr]; } - const OpenMPMutex& lock(int64_t sr) const { return lock_[sr]; } - - double& volume(int64_t sr) { return volume_[sr]; } - const double volume(int64_t sr) const { return volume_[sr]; } - - double& volume_t(int64_t sr) { return volume_t_[sr]; } - const double volume_t(int64_t sr) const { return volume_t_[sr]; } - - double& volume_sq(int64_t sr) { return volume_sq_[sr]; } - const double volume_sq(int64_t sr) const { return volume_sq_[sr]; } - - double& volume_sq_t(int64_t sr) { return volume_sq_t_[sr]; } - const double volume_sq_t(int64_t sr) const { return volume_sq_t_[sr]; } - - double& volume_naive(int64_t sr) { return volume_naive_[sr]; } - const double volume_naive(int64_t sr) const { return volume_naive_[sr]; } - - int& position_recorded(int64_t sr) { return position_recorded_[sr]; } - const int position_recorded(int64_t sr) const - { - return position_recorded_[sr]; - } - - int& external_source_present(int64_t sr) - { - return external_source_present_[sr]; - } - const int external_source_present(int64_t sr) const - { - return external_source_present_[sr]; - } - - Position& position(int64_t sr) { return position_[sr]; } - const Position position(int64_t sr) const { return position_[sr]; } - - Position& centroid(int64_t sr) { return centroid_[sr]; } - const Position centroid(int64_t sr) const { return centroid_[sr]; } - - Position& centroid_iteration(int64_t sr) { return centroid_iteration_[sr]; } - const Position centroid_iteration(int64_t sr) const - { - return centroid_iteration_[sr]; - } - - Position& centroid_t(int64_t sr) { return centroid_t_[sr]; } - const Position centroid_t(int64_t sr) const { return centroid_t_[sr]; } - - MomentMatrix& mom_matrix(int64_t sr) { return mom_matrix_[sr]; } - const MomentMatrix mom_matrix(int64_t sr) const { return mom_matrix_[sr]; } - - MomentMatrix& mom_matrix_t(int64_t sr) { return mom_matrix_t_[sr]; } - const MomentMatrix mom_matrix_t(int64_t sr) const - { - return mom_matrix_t_[sr]; - } - - MomentArray& source_gradients(int64_t sr, int g) - { - return source_gradients_[index(sr, g)]; - } - const MomentArray source_gradients(int64_t sr, int g) const - { - return source_gradients_[index(sr, g)]; - } - MomentArray& source_gradients(int64_t se) { return source_gradients_[se]; } - const MomentArray source_gradients(int64_t se) const - { - return source_gradients_[se]; - } - - MomentArray& flux_moments_old(int64_t sr, int g) - { - return flux_moments_old_[index(sr, g)]; - } - const MomentArray flux_moments_old(int64_t sr, int g) const - { - return flux_moments_old_[index(sr, g)]; - } - MomentArray& flux_moments_old(int64_t se) { return flux_moments_old_[se]; } - const MomentArray flux_moments_old(int64_t se) const - { - return flux_moments_old_[se]; - } - - MomentArray& flux_moments_new(int64_t sr, int g) - { - return flux_moments_new_[index(sr, g)]; - } - const MomentArray flux_moments_new(int64_t sr, int g) const - { - return flux_moments_new_[index(sr, g)]; - } - MomentArray& flux_moments_new(int64_t se) { return flux_moments_new_[se]; } - const MomentArray flux_moments_new(int64_t se) const - { - return flux_moments_new_[se]; - } - - MomentArray& flux_moments_t(int64_t sr, int g) - { - return flux_moments_t_[index(sr, g)]; - } - const MomentArray flux_moments_t(int64_t sr, int g) const - { - return flux_moments_t_[index(sr, g)]; - } - MomentArray& flux_moments_t(int64_t se) { return flux_moments_t_[se]; } - const MomentArray flux_moments_t(int64_t se) const - { - return flux_moments_t_[se]; - } - - double& scalar_flux_old(int64_t sr, int g) - { - return scalar_flux_old_[index(sr, g)]; - } - const double scalar_flux_old(int64_t sr, int g) const - { - return scalar_flux_old_[index(sr, g)]; - } - double& scalar_flux_old(int64_t se) { return scalar_flux_old_[se]; } - const double scalar_flux_old(int64_t se) const - { - return scalar_flux_old_[se]; - } - - double& scalar_flux_new(int64_t sr, int g) - { - return scalar_flux_new_[index(sr, g)]; - } - const double scalar_flux_new(int64_t sr, int g) const - { - return scalar_flux_new_[index(sr, g)]; - } - double& scalar_flux_new(int64_t se) { return scalar_flux_new_[se]; } - const double scalar_flux_new(int64_t se) const - { - return scalar_flux_new_[se]; - } - - double& scalar_flux_final(int64_t sr, int g) - { - return scalar_flux_final_[index(sr, g)]; - } - const double scalar_flux_final(int64_t sr, int g) const - { - return scalar_flux_final_[index(sr, g)]; - } - double& scalar_flux_final(int64_t se) { return scalar_flux_final_[se]; } - const double scalar_flux_final(int64_t se) const - { - return scalar_flux_final_[se]; - } - - float& source(int64_t sr, int g) { return source_[index(sr, g)]; } - const float source(int64_t sr, int g) const { return source_[index(sr, g)]; } - float& source(int64_t se) { return source_[se]; } - const float source(int64_t se) const { return source_[se]; } - - float& external_source(int64_t sr, int g) - { - return external_source_[index(sr, g)]; - } - const float external_source(int64_t sr, int g) const - { - return external_source_[index(sr, g)]; - } - float& external_source(int64_t se) { return external_source_[se]; } - const float external_source(int64_t se) const { return external_source_[se]; } - - vector& tally_task(int64_t sr, int g) - { - return tally_task_[index(sr, g)]; - } - const vector& tally_task(int64_t sr, int g) const - { - return tally_task_[index(sr, g)]; - } - vector& tally_task(int64_t se) { return tally_task_[se]; } - const vector& tally_task(int64_t se) const - { - return tally_task_[se]; - } - - std::unordered_set& volume_task(int64_t sr) - { - return volume_task_[sr]; - } - const std::unordered_set& volume_task( - int64_t sr) const - { - return volume_task_[sr]; - } - - int& mesh(int64_t sr) { return mesh_[sr]; } - const int mesh(int64_t sr) const { return mesh_[sr]; } - - int64_t& parent_sr(int64_t sr) { return parent_sr_[sr]; } - const int64_t parent_sr(int64_t sr) const { return parent_sr_[sr]; } - - //---------------------------------------------------------------------------- - // Public Methods - - void push_back(const SourceRegion& sr); - void assign(int n_source_regions, const SourceRegion& source_region); - void flux_swap(); - int64_t n_source_regions() const { return n_source_regions_; } - int64_t n_source_elements() const { return n_source_regions_ * negroups_; } - int& negroups() { return negroups_; } - const int negroups() const { return negroups_; } - bool& is_linear() { return is_linear_; } - const bool is_linear() const { return is_linear_; } - SourceRegionHandle get_source_region_handle(int64_t sr); - void adjoint_reset(); - -private: - //---------------------------------------------------------------------------- - // Private Data Members - int64_t n_source_regions_ {0}; - int negroups_ {0}; - bool is_linear_ {false}; - - // SoA storage for scalar fields (one item per source region) - vector material_; - vector temperature_idx_; - vector density_mult_; - vector is_small_; - vector n_hits_; - vector mesh_; - vector parent_sr_; - vector lock_; - vector volume_; - vector volume_t_; - vector volume_sq_; - vector volume_sq_t_; - vector volume_naive_; - vector position_recorded_; - vector external_source_present_; - vector position_; - vector centroid_; - vector centroid_iteration_; - vector centroid_t_; - vector mom_matrix_; - vector mom_matrix_t_; - // A set of volume tally tasks. This more complicated data structure is - // convenient for ensuring that volumes are only tallied once per source - // region, regardless of how many energy groups are used for tallying. - vector> volume_task_; - - // SoA energy group-wise 2D arrays flattened to 1D - vector scalar_flux_old_; - vector scalar_flux_new_; - vector scalar_flux_final_; - vector source_; - vector external_source_; - - vector source_gradients_; - vector flux_moments_old_; - vector flux_moments_new_; - vector flux_moments_t_; - - // SoA 3D array representing values for all source regions x energy groups x - // tally tasks. The outer two dimensions (source regions and energy groups) - // are flattened to 1D. Each group may have a different number of tally tasks - // associated with it, necessitating the use of a jagged array for the inner - // dimension. - vector> tally_task_; - - //---------------------------------------------------------------------------- - // Private Methods - - // Helper function for indexing - inline int64_t index(int64_t sr, int g) const { return sr * negroups_ + g; } -}; - -} // namespace openmc - -#endif // OPENMC_RANDOM_RAY_SOURCE_REGION_H diff --git a/include/openmc/ray.h b/include/openmc/ray.h deleted file mode 100644 index 62e86b0d9..000000000 --- a/include/openmc/ray.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef OPENMC_RAY_H -#define OPENMC_RAY_H - -#include "openmc/particle_data.h" -#include "openmc/position.h" - -namespace openmc { - -// Base class that implements ray tracing logic, not necessarily through -// defined regions of the geometry but also outside of it. -class Ray : public GeometryState { - -public: - // Initialize from location and direction - Ray(Position r, Direction u) { init_from_r_u(r, u); } - - // Initialize from known geometry state - Ray(const GeometryState& p) : GeometryState(p) {} - - // Called at every surface intersection within the model - virtual void on_intersection() = 0; - - /* - * Traces the ray through the geometry, calling on_intersection - * at every surface boundary. - */ - void trace(); - - // Stops the ray and exits tracing when called from on_intersection - void stop() { stop_ = true; } - - // Sets the dist_ variable - void compute_distance(); - -protected: - // Records how far the ray has traveled - double traversal_distance_ {0.0}; - -private: - // Max intersections before we assume ray tracing is caught in an infinite - // loop: - static const int MAX_INTERSECTIONS = 1000000; - - bool stop_ {false}; - - unsigned event_counter_ {0}; -}; - -} // namespace openmc -#endif // OPENMC_RAY_H diff --git a/include/openmc/reaction.h b/include/openmc/reaction.h index e95db1665..93987d9d7 100644 --- a/include/openmc/reaction.h +++ b/include/openmc/reaction.h @@ -7,10 +7,10 @@ #include #include "hdf5.h" +#include #include "openmc/particle_data.h" #include "openmc/reaction_product.h" -#include "openmc/span.h" #include "openmc/vector.h" namespace openmc { @@ -26,16 +26,14 @@ public: //! Construct reaction from HDF5 data //! \param[in] group HDF5 group containing reaction data //! \param[in] temperatures Desired temperatures for cross sections - //! \param[in] name Name of the nuclide - explicit Reaction( - hid_t group, const vector& temperatures, std::string name); + explicit Reaction(hid_t group, const vector& temperatures); //! Calculate cross section given temperautre/grid index, interpolation factor // //! \param[in] i_temp Temperature index //! \param[in] i_grid Energy grid index //! \param[in] interp_factor Interpolation factor between grid points - double xs(int64_t i_temp, int64_t i_grid, double interp_factor) const; + double xs(gsl::index i_temp, gsl::index i_grid, double interp_factor) const; //! Calculate cross section // @@ -49,8 +47,8 @@ public: //! \param[in] flux Flux in each energy group (not normalized per eV) //! \param[in] grid Nuclide energy grid //! \return Reaction rate - double collapse_rate(int64_t i_temp, span energy, - span flux, const vector& grid) const; + double collapse_rate(gsl::index i_temp, gsl::span energy, + gsl::span flux, const vector& grid) const; //! Cross section at a single temperature struct TemperatureXS { @@ -76,21 +74,11 @@ public: //! \return Name of the corresponding reaction std::string reaction_name(int mt); -//! Return MT value for given a reaction name (including special tally MT -//! values) +//! Return reaction type (MT value) given a reaction name // //! \param[in] name Reaction name -//! \return Corresponding MT number or special tally score -int reaction_tally_mt(std::string name); - -//! Return ENDF MT number given a reaction name -// -//! Unlike reaction_tally_mt(), this function always returns a positive ENDF MT -//! number and never a special negative tally score. -//! -//! \param[in] name Reaction name -//! \return Corresponding ENDF MT number -int reaction_mt(const std::string& name); +//! \return Corresponding reaction type (MT value) +int reaction_type(std::string name); } // namespace openmc diff --git a/include/openmc/reaction_product.h b/include/openmc/reaction_product.h index 79a6160e2..ce4fa8fc7 100644 --- a/include/openmc/reaction_product.h +++ b/include/openmc/reaction_product.h @@ -7,10 +7,9 @@ #include "hdf5.h" #include "openmc/angle_energy.h" -#include "openmc/chain.h" #include "openmc/endf.h" #include "openmc/memory.h" // for unique_ptr -#include "openmc/particle_type.h" +#include "openmc/particle.h" #include "openmc/vector.h" // for vector namespace openmc { @@ -38,10 +37,6 @@ public: //! \param[in] group HDF5 group containing data explicit ReactionProduct(hid_t group); - //! Construct reaction product for decay photon from chain nuclide product - //! \param[in] product Chain nuclide product - explicit ReactionProduct(const ChainNuclide::Product& product); - //! Sample an outgoing angle and energy //! \param[in] E_in Incoming energy in [eV] //! \param[out] E_out Outgoing energy in [eV] @@ -49,28 +44,12 @@ public: //! \param[inout] seed Pseudorandom seed pointer void sample(double E_in, double& E_out, double& mu, uint64_t* seed) const; - //! Select which angle-energy distribution to sample - //! \param[in] E_in Incoming energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Reference to the selected angle-energy distribution - AngleEnergy& sample_dist(double E_in, uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const; - ParticleType particle_; //!< Particle type EmissionMode emission_mode_; //!< Emission mode double decay_rate_; //!< Decay rate (for delayed neutron precursors) in [1/s] unique_ptr yield_; //!< Yield as a function of energy vector applicability_; //!< Applicability of distribution vector distribution_; //!< Secondary angle-energy distribution - int parent_nuclide_ = -1; //!< Index of chain nuclide that is parent }; } // namespace openmc diff --git a/include/openmc/scattdata.h b/include/openmc/scattdata.h index bea881402..a75ef09d9 100644 --- a/include/openmc/scattdata.h +++ b/include/openmc/scattdata.h @@ -4,7 +4,7 @@ #ifndef OPENMC_SCATTDATA_H #define OPENMC_SCATTDATA_H -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/constants.h" #include "openmc/vector.h" @@ -26,23 +26,23 @@ public: protected: //! \brief Initializes the attributes of the base class. - void base_init(int order, const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_energy, + void base_init(int order, const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_energy, const double_2dvec& in_mult); //! \brief Combines microscopic ScattDatas into a macroscopic one. void base_combine(size_t max_order, size_t order_dim, const vector& those_scatts, const vector& scalars, - tensor::Tensor& in_gmin, tensor::Tensor& in_gmax, + xt::xtensor& in_gmin, xt::xtensor& in_gmax, double_2dvec& sparse_mult, double_3dvec& sparse_scatter); public: double_2dvec energy; // Normalized p0 matrix for sampling Eout double_2dvec mult; // nu-scatter multiplication (nu-scatt/scatt) double_3dvec dist; // Angular distribution - tensor::Tensor gmin; // minimum outgoing group - tensor::Tensor gmax; // maximum outgoing group - tensor::Tensor scattxs; // Isotropic Sigma_{s,g_{in}} + xt::xtensor gmin; // minimum outgoing group + xt::xtensor gmax; // maximum outgoing group + xt::xtensor scattxs; // Isotropic Sigma_{s,g_{in}} //! \brief Calculates the value of normalized f(mu). //! @@ -72,8 +72,8 @@ public: //! @param in_gmax List of maximum outgoing groups for every incoming group //! @param in_mult Input sparse multiplicity matrix //! @param coeffs Input sparse scattering matrix - virtual void init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, + virtual void init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) = 0; //! \brief Combines the microscopic data. @@ -96,7 +96,7 @@ public: //! @param max_order If Legendre this is the maximum value of "n" in "Pn" //! requested; ignored otherwise. //! @return The dense scattering matrix. - virtual tensor::Tensor get_matrix(size_t max_order) = 0; + virtual xt::xtensor get_matrix(size_t max_order) = 0; //! \brief Samples the outgoing energy from the ScattData info. //! @@ -135,8 +135,8 @@ protected: ScattDataLegendre& leg, ScattDataTabular& tab); public: - void init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, + void init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) override; void combine(const vector& those_scatts, @@ -153,7 +153,7 @@ public: size_t get_order() override { return dist[0][0].size() - 1; }; - tensor::Tensor get_matrix(size_t max_order) override; + xt::xtensor get_matrix(size_t max_order) override; }; //============================================================================== @@ -164,13 +164,13 @@ public: class ScattDataHistogram : public ScattData { protected: - tensor::Tensor mu; // Angle distribution mu bin boundaries + xt::xtensor mu; // Angle distribution mu bin boundaries double dmu; // Quick storage of the mu spacing double_3dvec fmu; // The angular distribution histogram public: - void init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, + void init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) override; void combine(const vector& those_scatts, @@ -183,7 +183,7 @@ public: size_t get_order() override { return dist[0][0].size(); }; - tensor::Tensor get_matrix(size_t max_order) override; + xt::xtensor get_matrix(size_t max_order) override; }; //============================================================================== @@ -194,7 +194,7 @@ public: class ScattDataTabular : public ScattData { protected: - tensor::Tensor mu; // Angle distribution mu grid points + xt::xtensor mu; // Angle distribution mu grid points double dmu; // Quick storage of the mu spacing double_3dvec fmu; // The angular distribution function @@ -204,8 +204,8 @@ protected: ScattDataLegendre& leg, ScattDataTabular& tab); public: - void init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, + void init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) override; void combine(const vector& those_scatts, @@ -218,7 +218,7 @@ public: size_t get_order() override { return dist[0][0].size(); }; - tensor::Tensor get_matrix(size_t max_order) override; + xt::xtensor get_matrix(size_t max_order) override; }; //============================================================================== diff --git a/include/openmc/secondary_correlated.h b/include/openmc/secondary_correlated.h index 69b22981a..6905c38e3 100644 --- a/include/openmc/secondary_correlated.h +++ b/include/openmc/secondary_correlated.h @@ -5,7 +5,7 @@ #define OPENMC_SECONDARY_CORRELATED_H #include "hdf5.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/angle_energy.h" #include "openmc/distribution.h" @@ -25,9 +25,9 @@ public: struct CorrTable { int n_discrete; //!< Number of discrete lines Interpolation interpolation; //!< Interpolation law - tensor::Tensor e_out; //!< Outgoing energies [eV] - tensor::Tensor p; //!< Probability density - tensor::Tensor c; //!< Cumulative distribution + xt::xtensor e_out; //!< Outgoing energies [eV] + xt::xtensor p; //!< Probability density + xt::xtensor c; //!< Cumulative distribution vector> angle; //!< Angle distribution }; @@ -41,22 +41,6 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample the outgoing energy and return the angular distribution - //! \param[in] E_in Incoming energy in [eV] - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Reference to the angular distribution at the sampled energy bin - Distribution& sample_dist(double E_in, double& E_out, uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - // energy property vector& energy() { return energy_; } const vector& energy() const { return energy_; } diff --git a/include/openmc/secondary_kalbach.h b/include/openmc/secondary_kalbach.h index b25352be9..83806d352 100644 --- a/include/openmc/secondary_kalbach.h +++ b/include/openmc/secondary_kalbach.h @@ -5,7 +5,7 @@ #define OPENMC_SECONDARY_KALBACH_H #include "hdf5.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/angle_energy.h" #include "openmc/constants.h" @@ -32,34 +32,16 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample outgoing energy and Kalbach-Mann parameters - //! \param[in] E_in Incoming energy in [eV] - //! \param[out] E_out Outgoing energy in [eV] - //! \param[out] km_a Kalbach-Mann 'a' parameter - //! \param[out] km_r Kalbach-Mann pre-compound fraction 'r' - //! \param[inout] seed Pseudorandom seed pointer - void sample_params(double E_in, double& E_out, double& km_a, double& km_r, - uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: //! Outgoing energy/angle at a single incoming energy struct KMTable { int n_discrete; //!< Number of discrete lines Interpolation interpolation; //!< Interpolation law - tensor::Tensor e_out; //!< Outgoing energies [eV] - tensor::Tensor p; //!< Probability density - tensor::Tensor c; //!< Cumulative distribution - tensor::Tensor r; //!< Pre-compound fraction - tensor::Tensor a; //!< Parameterized function + xt::xtensor e_out; //!< Outgoing energies [eV] + xt::xtensor p; //!< Probability density + xt::xtensor c; //!< Cumulative distribution + xt::xtensor r; //!< Pre-compound fraction + xt::xtensor a; //!< Parameterized function }; int n_region_; //!< Number of interpolation regions diff --git a/include/openmc/secondary_nbody.h b/include/openmc/secondary_nbody.h index 9d033a6b8..efb4fd75b 100644 --- a/include/openmc/secondary_nbody.h +++ b/include/openmc/secondary_nbody.h @@ -28,21 +28,6 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample an outgoing energy from the N-body phase space distribution - //! \param[in] E_in Incoming energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Sampled outgoing energy in [eV] - double sample_energy(double E_in, uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: int n_bodies_; //!< Number of particles distributed double mass_ratio_; //!< Total mass of particles [neutron mass] diff --git a/include/openmc/secondary_thermal.h b/include/openmc/secondary_thermal.h index 45d2c5260..5b18902af 100644 --- a/include/openmc/secondary_thermal.h +++ b/include/openmc/secondary_thermal.h @@ -6,11 +6,10 @@ #include "openmc/angle_energy.h" #include "openmc/endf.h" -#include "openmc/search.h" #include "openmc/secondary_correlated.h" #include "openmc/vector.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include namespace openmc { @@ -34,20 +33,8 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: const CoherentElasticXS& xs_; //!< Coherent elastic scattering cross section - tensor::Tensor bragg_edges_; //!< Copy of Bragg edges for slicing - tensor::Tensor - factors_diff_; //!< Differences over elastic scattering factors }; //============================================================================== @@ -69,15 +56,6 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: double debye_waller_; }; @@ -103,18 +81,9 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: const vector& energy_; //!< Energies at which cosines are tabulated - tensor::Tensor mu_out_; //!< Cosines for each incident energy + xt::xtensor mu_out_; //!< Cosines for each incident energy }; //============================================================================== @@ -137,27 +106,12 @@ public: //! \param[inout] seed Pseudorandom number seed pointer void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample outgoing energy bin parameters - //! \param[in] E_in Incoming energy in [eV] - //! \param[out] E_out Outgoing energy in [eV] - //! \param[out] j Sampled outgoing energy bin index - //! \param[inout] seed Pseudorandom seed pointer - void sample_params(double E_in, double& E_out, int& j, uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; private: const vector& energy_; //!< Incident energies - tensor::Tensor + xt::xtensor energy_out_; //!< Outgoing energies for each incident energy - tensor::Tensor + xt::xtensor mu_out_; //!< Outgoing cosines for each incident/outgoing energy bool skewed_; //!< Whether outgoing energy distribution is skewed }; @@ -181,33 +135,14 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample outgoing energy bin parameters - //! \param[in] E_in Incoming energy in [eV] - //! \param[out] E_out Outgoing energy in [eV] - //! \param[out] f Interpolation factor within sampled energy bin - //! \param[out] l Index of the closer incident energy - //! \param[out] j Sampled outgoing energy bin index - //! \param[inout] seed Pseudorandom seed pointer - void sample_params(double E_in, double& E_out, double& f, int& l, int& j, - uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: //! Secondary energy/angle distribution struct DistEnergySab { std::size_t n_e_out; //!< Number of outgoing energies - tensor::Tensor e_out; //!< Outgoing energies - tensor::Tensor e_out_pdf; //!< Probability density function - tensor::Tensor e_out_cdf; //!< Cumulative distribution function - tensor::Tensor mu; //!< Equiprobable angles at each outgoing energy + xt::xtensor e_out; //!< Outgoing energies + xt::xtensor e_out_pdf; //!< Probability density function + xt::xtensor e_out_cdf; //!< Cumulative distribution function + xt::xtensor mu; //!< Equiprobable angles at each outgoing energy }; vector energy_; //!< Incident energies @@ -235,21 +170,6 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Select the coherent or incoherent elastic distribution to sample - //! \param[in] E_in Incoming energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Reference to the selected angle-energy distribution - const AngleEnergy& sample_dist(double E_in, uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - private: CoherentElasticAE coherent_dist_; //!< Coherent distribution unique_ptr incoherent_dist_; //!< Incoherent distribution @@ -258,133 +178,6 @@ private: const Function1D& incoherent_xs_; //!< Polymorphic ref. to incoherent XS }; -//! Internal helper for evaluating a piecewise-constant PDF on discrete points. -//! -//! The underlying discrete points are represented implicitly through a -//! monotonically increasing `center(i)` function and corresponding per-point -//! `weight(i)` values. Each point contributes a rectangular bin whose -//! half-width is half the distance to its nearest neighboring center. -//! -//! \tparam CenterFn Callable returning the location of the i-th discrete value -//! \tparam WeightFn Callable returning the weight of the i-th discrete value -//! \param[in] n Number of discrete values -//! \param[in] mu_0 Point at which to evaluate the PDF -//! \param[in] a Lower bound of the domain (default: -1) -//! \param[in] b Upper bound of the domain (default: 1) -//! \return Probability density at mu_0 -template -double get_pdf_discrete_impl(std::size_t n, double mu_0, double a, double b, - CenterFn center, WeightFn weight) -{ - if (n == 0 || mu_0 < a || mu_0 > b) - return 0.0; - - auto evaluate_bin = [&](std::size_t i) { - double x = center(i); - double left_span = (i == 0) ? 2.0 * (x - a) : x - center(i - 1); - double right_span = (i + 1 == n) ? 2.0 * (b - x) : center(i + 1) - x; - double delta = 0.5 * std::min(left_span, right_span); - if (delta <= 0.0) - return 0.0; - - double left = x - delta; - double right = x + delta; - bool in_bin = - (mu_0 >= left) && ((i + 1 == n) ? (mu_0 <= right) : (mu_0 < right)); - return in_bin ? weight(i) / (2.0 * delta) : 0.0; - }; - - // This is effectively a lower_bound over the sequence center(i), but the - // sequence is implicit rather than stored in a container, so the STL - // algorithms can not be used. - std::size_t low = 0; - std::size_t high = n; - while (low < high) { - std::size_t mid = low + (high - low) / 2; - if (center(mid) < mu_0) { - low = mid + 1; - } else { - high = mid; - } - } - - if (low < n) { - double pdf = evaluate_bin(low); - if (pdf > 0.0) - return pdf; - } - if (low > 0) - return evaluate_bin(low - 1); - return 0.0; -} - -//! Evaluate the PDF of a weighted discrete distribution at a given point. -//! -//! Given a set of discrete values mu[i] with weights w[i], this function -//! computes the probability density at mu_0 by treating each discrete value -//! as a rectangular bin. The bin half-width around each discrete value is -//! half the distance to its nearest neighbor. -//! -//! \tparam T1 Container type for discrete cosine values (must support -//! operator[], size()) -//! \tparam T2 Container type for weights (must support operator[]) -//! \param[in] mu Sorted array of discrete cosine values -//! \param[in] w Weights for each discrete value (need not be normalized) -//! \param[in] mu_0 Point at which to evaluate the PDF -//! \param[in] a Lower bound of the domain (default: -1) -//! \param[in] b Upper bound of the domain (default: 1) -//! \return Probability density at mu_0 -template -double get_pdf_discrete( - const T1 mu, const T2& w, double mu_0, double a = -1.0, double b = 1.0) -{ - // Returns the location of the discrete value for a given index - auto center = [&](std::size_t i) { return mu[i]; }; - auto weight = [&](std::size_t i) { return w[i]; }; - return get_pdf_discrete_impl(mu.size(), mu_0, a, b, center, weight); -} - -//! Evaluate the PDF of a discrete distribution with uniform weights -//! -//! \tparam T1 Container type for discrete cosine values -//! \param[in] mu Sorted array of discrete cosine values -//! \param[in] mu_0 Point at which to evaluate the PDF -//! \param[in] a Lower bound of the domain (default: -1) -//! \param[in] b Upper bound of the domain (default: 1) -//! \return Probability density at mu_0 -template -double get_pdf_discrete( - const T1 mu, double mu_0, double a = -1.0, double b = 1.0) -{ - auto center = [&](std::size_t i) { return mu[i]; }; - auto weight = [&](std::size_t i) { return 1.0 / mu.size(); }; - return get_pdf_discrete_impl(mu.size(), mu_0, a, b, center, weight); -} - -//! Evaluate the PDF of a uniformly weighted distribution on interpolated points -//! -//! \tparam T1 Container type for the lower tabulated cosine values -//! \tparam T2 Container type for the upper tabulated cosine values -//! \param[in] mu0 Sorted array of discrete cosine values at the lower grid -//! \param[in] mu1 Sorted array of discrete cosine values at the upper grid -//! \param[in] f Interpolation factor between mu0 and mu1 -//! \param[in] mu_0 Point at which to evaluate the PDF -//! \param[in] a Lower bound of the domain (default: -1) -//! \param[in] b Upper bound of the domain (default: 1) -//! \return Probability density at mu_0 -template -double get_pdf_discrete_interpolated(const T1 mu0, const T2 mu1, double f, - double mu_0, double a = -1.0, double b = 1.0) -{ - if (mu0.size() != mu1.size()) - return 0.0; - - // Returns interpolated discrete value for a given index - auto center = [&](std::size_t i) { return mu0[i] + f * (mu1[i] - mu0[i]); }; - auto weight = [&](std::size_t i) { return 1.0 / mu0.size(); }; - return get_pdf_discrete_impl(mu0.size(), mu_0, a, b, center, weight); -} - } // namespace openmc #endif // OPENMC_SECONDARY_THERMAL_H diff --git a/include/openmc/secondary_uncorrelated.h b/include/openmc/secondary_uncorrelated.h index f895ae77f..3afa3d9ce 100644 --- a/include/openmc/secondary_uncorrelated.h +++ b/include/openmc/secondary_uncorrelated.h @@ -32,15 +32,6 @@ public: void sample( double E_in, double& E_out, double& mu, uint64_t* seed) const override; - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const override; - // Accessors AngleDistribution& angle() { return angle_; } diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 3bba040f5..a95f1ced9 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -24,32 +24,6 @@ enum class SSWCellType { To, }; -// Type of IFP parameters -enum class IFPParameter { - None, - Both, - BetaEffective, - GenerationTime, -}; - -struct CollisionTrackConfig { - bool mcpl_write {false}; //!< Write collision tracks using MCPL? - std::unordered_set - cell_ids; //!< Cell ids where collisions will be written - std::unordered_set - mt_numbers; //!< MT Numbers where collisions will be written - std::unordered_set - universe_ids; //!< Universe IDs where collisions will be written - std::unordered_set - material_ids; //!< Material IDs where collisions will be written - std::unordered_set - nuclides; //!< Nuclides where collisions will be written - double deposited_energy_threshold {0.0}; //!< Minimum deposited energy [eV] - int64_t max_collisions { - 1000}; //!< Maximum events recorded per collision track file - int64_t max_files {1}; //!< Maximum number of collision track files -}; - //============================================================================== // Global variable declarations //============================================================================== @@ -59,7 +33,6 @@ namespace settings { // Boolean flags extern bool assume_separate; //!< assume tallies are spatially separate? extern bool check_overlaps; //!< check overlaps in geometry? -extern bool collision_track; //!< flag to use collision track feature? extern bool confidence_intervals; //!< use confidence intervals for results? extern bool create_fission_neutrons; //!< create fission neutrons (fixed source)? @@ -69,37 +42,31 @@ extern bool delayed_photon_scaling; //!< Scale fission photon yield to include delayed extern "C" bool entropy_on; //!< calculate Shannon entropy? extern "C" bool - event_based; //!< use event-based mode (instead of history-based) -extern bool ifp_on; //!< Use IFP for kinetics parameters? + event_based; //!< use event-based mode (instead of history-based) extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular? -extern bool material_cell_offsets; //!< create material cells offsets? -extern "C" bool output_summary; //!< write summary.h5? -extern bool output_tallies; //!< write tallies.out? -extern bool particle_restart_run; //!< particle restart run? -extern "C" bool photon_transport; //!< photon transport turned on? -extern bool atomic_relaxation; //!< atomic relaxation enabled? -extern "C" bool reduce_tallies; //!< reduce tallies at end of batch? -extern bool res_scat_on; //!< use resonance upscattering method? -extern "C" bool restart_run; //!< restart run? -extern "C" bool run_CE; //!< run with continuous-energy data? -extern bool source_latest; //!< write latest source at each batch? -extern bool source_separate; //!< write source to separate file? -extern bool source_write; //!< write source in HDF5 files? -extern bool source_mcpl_write; //!< write source in mcpl files? -extern bool surf_source_write; //!< write surface source file? -extern bool surf_mcpl_write; //!< write surface mcpl file? -extern bool surf_source_read; //!< read surface source file? -extern bool survival_biasing; //!< use survival biasing? -extern bool survival_normalization; //!< use survival normalization? -extern bool temperature_multipole; //!< use multipole data? -extern "C" bool trigger_on; //!< tally triggers enabled? -extern bool trigger_predict; //!< predict batches for triggers? -extern bool uniform_source_sampling; //!< sample sources uniformly? -extern bool ufs_on; //!< uniform fission site method on? -extern bool urr_ptables_on; //!< use unresolved resonance prob. tables? -extern bool use_decay_photons; //!< use decay photons for D1S -extern bool use_shared_secondary_bank; //!< Use shared bank for secondaries -extern "C" bool weight_windows_on; //!< are weight windows are enabled? +extern bool material_cell_offsets; //!< create material cells offsets? +extern "C" bool output_summary; //!< write summary.h5? +extern bool output_tallies; //!< write tallies.out? +extern bool particle_restart_run; //!< particle restart run? +extern "C" bool photon_transport; //!< photon transport turned on? +extern "C" bool reduce_tallies; //!< reduce tallies at end of batch? +extern bool res_scat_on; //!< use resonance upscattering method? +extern "C" bool restart_run; //!< restart run? +extern "C" bool run_CE; //!< run with continuous-energy data? +extern bool source_latest; //!< write latest source at each batch? +extern bool source_separate; //!< write source to separate file? +extern bool source_write; //!< write source in HDF5 files? +extern bool source_mcpl_write; //!< write source in mcpl files? +extern bool surf_source_write; //!< write surface source file? +extern bool surf_mcpl_write; //!< write surface mcpl file? +extern bool surf_source_read; //!< read surface source file? +extern bool survival_biasing; //!< use survival biasing? +extern bool temperature_multipole; //!< use multipole data? +extern "C" bool trigger_on; //!< tally triggers enabled? +extern bool trigger_predict; //!< predict batches for triggers? +extern bool ufs_on; //!< uniform fission site method on? +extern bool urr_ptables_on; //!< use unresolved resonance prob. tables? +extern "C" bool weight_windows_on; //!< are weight windows are enabled? extern bool weight_window_checkpoint_surface; //!< enable weight window check //!< upon surface crossing? extern bool weight_window_checkpoint_collision; //!< enable weight window check @@ -116,8 +83,6 @@ extern std::string path_sourcepoint; //!< path to a source file extern std::string path_statepoint; //!< path to a statepoint file extern std::string weight_windows_file; //!< Location of weight window file to //!< load on simulation initialization -extern std::string properties_file; //!< Location of properties file to - //!< load on simulation initialization // This is required because the c_str() may not be the first thing in // std::string. Sometimes it is, but it seems libc++ may not be like that @@ -144,10 +109,6 @@ extern array energy_cutoff; //!< Energy cutoff in [eV] for each particle type extern array time_cutoff; //!< Time cutoff in [s] for each particle type -extern int - ifp_n_generation; //!< Number of generation for Iterated Fission Probability -extern IFPParameter - ifp_parameter; //!< Parameter to calculate for Iterated Fission Probability extern int legendre_to_tabular_points; //!< number of points to convert Legendres extern int max_order; //!< Maximum Legendre order for multigroup data @@ -168,25 +129,14 @@ extern std::unordered_set statepoint_batch; //!< Batches when state should be written extern std::unordered_set source_write_surf_id; //!< Surface ids where sources will be written -extern CollisionTrackConfig collision_track_config; -extern double source_rejection_fraction; //!< Minimum fraction of source sites - //!< that must be accepted -extern double free_gas_threshold; //!< Threshold multiplier for free gas - //!< scattering treatment - extern int max_history_splits; //!< maximum number of particle splits for weight windows -extern int max_secondaries; //!< maximum number of secondaries in the bank -extern int64_t ssw_max_particles; //!< maximum number of particles to be - //!< banked on surfaces per process -extern int64_t ssw_max_files; //!< maximum number of surface source files - //!< to be created -extern int64_t ssw_cell_id; //!< Cell id for the surface source - //!< write setting -extern SSWCellType ssw_cell_type; //!< Type of option for the cell - //!< argument of surface source write -extern double surface_grazing_cutoff; //!< surface flux cosine cutoff -extern double surface_grazing_ratio; //!< surface flux substitution ratio +extern int64_t max_surface_particles; //!< maximum number of particles to be + //!< banked on surfaces per process +extern int64_t ssw_cell_id; //!< Cell id for the surface source + //!< write setting +extern SSWCellType ssw_cell_type; //!< Type of option for the cell + //!< argument of surface source write extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double diff --git a/include/openmc/shared_array.h b/include/openmc/shared_array.h index 2829a2eb9..7e9ef28c5 100644 --- a/include/openmc/shared_array.h +++ b/include/openmc/shared_array.h @@ -4,8 +4,6 @@ //! \file shared_array.h //! \brief Shared array data structure -#include // for copy_n - #include "openmc/memory.h" namespace openmc { @@ -32,12 +30,14 @@ public: //! Default constructor. SharedArray() = default; - //! Construct a container with `size` elements and capacity equal to `size`. + //! Construct a zero size container with space to hold capacity number of + //! elements. // - //! \param size The number of elements to allocate and initialize - SharedArray(int64_t size) : size_(size), capacity_(size) + //! \param capacity The number of elements for the container to allocate + //! space for + SharedArray(int64_t capacity) : capacity_(capacity) { - data_ = make_unique(size); + data_ = make_unique(capacity); } //========================================================================== @@ -97,52 +97,8 @@ public: capacity_ = 0; } - //! Push back an element to the array, with capacity and reallocation behavior - //! as if this were a vector. This does not perform any thread safety checks. - //! If the size exceeds the capacity, then the capacity will double just as - //! with a vector. Data will be reallocated and moved to a new pointer and - //! copied in before the new item is appended. Old data will be freed. - void thread_unsafe_append(const T& value) - { - if (size_ == capacity_) { - int64_t new_capacity = capacity_ == 0 ? 8 : 2 * capacity_; - unique_ptr new_data = make_unique(new_capacity); - std::copy_n(data_.get(), size_, new_data.get()); - data_ = std::move(new_data); - capacity_ = new_capacity; - } - data_[size_++] = value; - } - - //! Increase the size of the container by count elements without assigning - //! values to the new elements. Existing elements are preserved if the - //! container needs to grow. This does not perform any thread safety checks. - // - //! \param count The number of elements to append - //! \return The starting index of the appended range - int64_t extend_uninitialized(int64_t count) - { - int64_t offset = size_; - int64_t new_size = size_ + count; - if (new_size > capacity_) { - int64_t new_capacity = capacity_ == 0 ? 8 : capacity_; - while (new_capacity < new_size) { - new_capacity *= 2; - } - unique_ptr new_data = make_unique(new_capacity); - if (size_ > 0) { - std::copy_n(data_.get(), size_, new_data.get()); - } - data_ = std::move(new_data); - capacity_ = new_capacity; - } - size_ = new_size; - return offset; - } - //! Return the number of elements in the container int64_t size() { return size_; } - int64_t size() const { return size_; } //! Resize the container to contain a specified number of elements. This is //! useful in cases where the container is written to in a non-thread safe diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 454752cd2..dd8bb7cdf 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -22,7 +22,6 @@ constexpr int STATUS_EXIT_ON_TRIGGER {2}; namespace simulation { -extern int ct_current_file; //!< current collision track file index extern "C" int current_batch; //!< current batch extern "C" int current_gen; //!< current fission generation extern "C" bool initialized; //!< has simulation been initialized? @@ -38,7 +37,6 @@ extern "C" int n_lost_particles; //!< cumulative number of lost particles extern "C" bool need_depletion_rx; //!< need to calculate depletion rx? extern "C" int restart_batch; //!< batch at which a restart job resumed extern "C" bool satisfy_triggers; //!< have tally triggers been satisfied? -extern int ssw_current_file; //!< current surface source file extern "C" int total_gen; //!< total number of generations simulated extern double total_weight; //!< Total source weight in a batch extern int64_t work_per_rank; //!< number of particles per MPI rank @@ -49,9 +47,6 @@ extern const RegularMesh* ufs_mesh; extern vector k_generation; extern vector work_index; -extern int64_t - simulation_tracks_completed; //!< Number of tracks completed on this rank - } // namespace simulation //============================================================================== @@ -62,7 +57,7 @@ extern int64_t void allocate_banks(); //! Determine number of particles to transport per process -void calculate_work(int64_t n_particles); +void calculate_work(); //! Initialize nuclear data before a simulation void initialize_data(); @@ -73,9 +68,8 @@ void initialize_batch(); //! Initialize a fission generation void initialize_generation(); -//! Full initialization of a particle track -void initialize_particle_track( - Particle& p, int64_t index_source, bool is_secondary); +//! Full initialization of a particle history +void initialize_history(Particle& p, int64_t index_source); //! Finalize a batch //! @@ -96,35 +90,16 @@ void broadcast_results(); void free_memory_simulation(); -//! Compute unique particle ID from a 1-based source index -//! \param index_source 1-based source index within this rank's work -//! \return globally unique particle ID -int64_t compute_particle_id(int64_t index_source); - -//! Compute the transport RNG seed from a particle ID -//! \param particle_id the particle's globally unique ID -//! \return seed value passed to init_particle_seeds() -int64_t compute_transport_seed(int64_t particle_id); - -//! Simulate a single particle history from birth to death, inclusive of any -//! secondary particles. In shared secondary mode, only a single track is -//! transported and secondaries are deposited into a shared bank instead. +//! Simulate a single particle history (and all generated secondary particles, +//! if enabled), from birth to death void transport_history_based_single_particle(Particle& p); //! Simulate all particle histories using history-based parallelism void transport_history_based(); -//! Simulate all particles using history-based parallelism, with a shared -//! secondary bank -void transport_history_based_shared_secondary(); - //! Simulate all particle histories using event-based parallelism void transport_event_based(); -//! Simulate all particles using event-based parallelism, with a shared -//! secondary bank -void transport_event_based_shared_secondary(); - } // namespace openmc #endif // OPENMC_SIMULATION_H diff --git a/include/openmc/source.h b/include/openmc/source.h index 51b54a1d1..5cc0356e3 100644 --- a/include/openmc/source.h +++ b/include/openmc/source.h @@ -4,19 +4,15 @@ #ifndef OPENMC_SOURCE_H #define OPENMC_SOURCE_H -#include #include #include -#include // for pair #include "pugixml.hpp" -#include "openmc/array.h" -#include "openmc/distribution.h" #include "openmc/distribution_multi.h" #include "openmc/distribution_spatial.h" #include "openmc/memory.h" -#include "openmc/particle_type.h" +#include "openmc/particle.h" #include "openmc/vector.h" namespace openmc { @@ -25,31 +21,20 @@ namespace openmc { // Constants //============================================================================== -// Minimum number of external source sites rejected before checking againts the -// source_rejection_fraction +// Maximum number of external source spatial resamples to encounter before an +// error is thrown. constexpr int EXTSRC_REJECT_THRESHOLD {10000}; - -// Maximum number of source rejections allowed while sampling a single site -constexpr int64_t MAX_SOURCE_REJECTIONS_PER_SAMPLE {1'000'000}; +constexpr double EXTSRC_REJECT_FRACTION {0.05}; //============================================================================== // Global variables //============================================================================== -// Cumulative counters for source rejection diagnostics. These are atomic to -// allow thread-safe concurrent sampling of external sources. -extern std::atomic source_n_accept; -extern std::atomic source_n_reject; - class Source; namespace model { extern vector> external_sources; -extern vector> adjoint_sources; - -// Probability distribution for selecting external sources -extern DiscreteIndex external_sources_probability; } // namespace model @@ -152,20 +137,17 @@ public: DomainType domain_type() const { return domain_type_; } const std::unordered_set& domain_ids() const { return domain_ids_; } - // Setter for spatial distribution - void set_space(UPtrSpace space) { space_ = std::move(space); } - protected: // Indicates whether derived class already handles constraints bool constraints_applied() const override { return true; } private: // Data members - ParticleType particle_; //!< Type of particle emitted - UPtrSpace space_; //!< Spatial distribution - UPtrAngle angle_; //!< Angular distribution - UPtrDist energy_; //!< Energy distribution - UPtrDist time_; //!< Time distribution + ParticleType particle_ {ParticleType::neutron}; //!< Type of particle emitted + UPtrSpace space_; //!< Spatial distribution + UPtrAngle angle_; //!< Angular distribution + UPtrDist energy_; //!< Energy distribution + UPtrDist time_; //!< Time distribution }; //============================================================================== @@ -186,7 +168,7 @@ protected: SourceSite sample(uint64_t* seed) const override; private: - vector sites_; //!< Source sites + vector sites_; //!< Source sites from a file }; //============================================================================== @@ -221,23 +203,6 @@ typedef unique_ptr create_compiled_source_t(std::string parameters); //! Mesh-based source with different distributions for each element //============================================================================== -// Helper class to sample spatial position on a single mesh element -class MeshElementSpatial : public SpatialDistribution { -public: - MeshElementSpatial(int32_t mesh_index, int elem_index) - : mesh_index_(mesh_index), elem_index_(elem_index) - {} - - //! Sample a position from the distribution - //! \param seed Pseudorandom number seed pointer - //! \return (sampled position, importance weight) - std::pair sample(uint64_t* seed) const override; - -private: - int32_t mesh_index_ {C_NONE}; //!< Index in global meshes array - int elem_index_; //! Index of mesh element -}; - class MeshSource : public Source { public: // Constructors @@ -252,148 +217,18 @@ public: double strength() const override { return space_->total_strength(); } // Accessors - const unique_ptr& source(int32_t i) const + const std::unique_ptr& source(int32_t i) const { return sources_.size() == 1 ? sources_[0] : sources_[i]; } -private: - // Data members - unique_ptr space_; //!< Mesh spatial - vector> sources_; //!< Source distributions -}; - -//============================================================================== -//! Parametric tokamak plasma neutron source -//! -//! This source samples neutron positions from a tokamak plasma geometry using -//! Miller-style flux surface parameterization with user-specified emission -//! profiles and energy distributions. -//! -//! Flux surface parameterization: -//! R = R0 + r*cos(alpha + delta*sin(alpha)) + Delta*(1 - (r/a)^2) -//! Z = kappa * r * sin(alpha) -//! -//! The sampling algorithm: -//! 1. Sample minor radius r from precomputed CDF of S(r) * Jacobian -//! 2. Sample poloidal angle alpha from conditional P(alpha|r) using mixture -//! of precomputed CDFs weighted by functions of r -//! 3. Sample energy and time from user-provided distribution(s) -//! 4. Sample isotropic direction -//! 5. Sample toroidal angle phi uniformly in [phi_start, phi_start + -//! phi_extent] -//! 6. Transform (r, alpha, phi) to Cartesian (x, y, z), applying the optional -//! vertical shift of the plasma center -//! -//! The user provides the emission density S(r) directly (e.g., from transport -//! codes like TRANSP, ASTRA, etc.), allowing full flexibility in reaction -//! physics calculations. S(r) is a profile in arbitrary units sampled on the -//! r_over_a grid; only its shape matters, since it is normalized internally. -//! Energy distributions can be specified as either a single distribution for -//! all r, or one distribution per radial point. -//============================================================================== - -class TokamakSource : public Source { -public: - // Constructors - explicit TokamakSource(pugi::xml_node node); - - //! Sample from the tokamak source distribution - //! \param[inout] seed Pseudorandom seed pointer - //! \return Sampled site - SourceSite sample(uint64_t* seed) const override; +protected: + bool constraints_applied() const override { return true; } private: - //========================================================================== - // Private methods - - //! Precompute data structures for efficient sampling - void precompute_sampling_distributions(); - - //! Sample minor radius from marginal CDF - //! \param seed Pseudorandom seed pointer - //! \return Sampled r/a value - double sample_r_over_a(uint64_t* seed) const; - - //! Sample poloidal angle given r using mixture of precomputed CDFs - //! \param r_norm Normalized minor radius r/a - //! \param seed Pseudorandom seed pointer - //! \return Sampled poloidal angle alpha [rad] - double sample_poloidal_angle(double r_norm, uint64_t* seed) const; - - //! Compute the k-th mixture weight w_k(r) * I_hat_k for poloidal sampling - //! \param k Basis function index (0-5) - //! \param r Normalized minor radius r/a - //! \return Mixture weight for component k - double mixture_weight(int k, double r) const; - - //! Sample energy from the distribution(s) - //! \param r_norm Normalized minor radius r/a (for distribution selection) - //! \param seed Pseudorandom seed pointer - //! \return (Sampled energy [eV], importance weight) - std::pair sample_energy(double r_norm, uint64_t* seed) const; - - //! Transform from flux coordinates (r, alpha, phi) to Cartesian (x, y, z) - //! \param r Minor radius [cm] - //! \param alpha Poloidal angle [rad] - //! \param phi Toroidal angle [rad] - //! \return Position in Cartesian coordinates [cm] - Position flux_to_cartesian(double r, double alpha, double phi) const; - - //========================================================================== // Data members - - // Emission profile (input) - vector r_over_a_; //!< Normalized minor radius grid points - vector emission_density_; //!< Emission density S(r) at grid points - - // Energy distribution(s): either 1 for all r, or one per r point - vector> energy_dists_; - - // Time distribution (defaults to a delta distribution at t=0) - UPtrDist time_; - - // Angular distribution (isotropic) - UPtrAngle angle_; - - // Tokamak geometry parameters - double major_radius_; //!< Major radius R0 [cm] - double minor_radius_; //!< Minor radius a [cm] - double elongation_; //!< Elongation kappa - double triangularity_; //!< Triangularity delta - double shafranov_shift_; //!< Shafranov shift Delta [cm] - double vertical_shift_; //!< Vertical shift of plasma center [cm] - - // Normalized geometry parameters (precomputed for efficiency) - double epsilon_; //!< Inverse aspect ratio a/R0 - double delta_tilde_; //!< Normalized Shafranov shift Delta/a - - // Toroidal angle bounds - double phi_start_; //!< Starting toroidal angle [rad] - double phi_extent_; //!< Toroidal angle extent [rad] - - // Precomputed distribution for radial sampling - unique_ptr radial_dist_; - - // Coefficients of the radial geometric polynomial: A*r - B*r^2 - C*r^3 - // Also used as the analytical normalization for poloidal mixture weights - double radial_poly_a_; //!< 1 + ε·Δ̃ - double radial_poly_b_; //!< (3/8)·c₁·ε - double radial_poly_c_; //!< 2·ε·Δ̃ - - // Precomputed Bernstein basis functions for poloidal angle sampling. - // Using the factorization f(r_tilde, alpha) = R_tilde x J_tilde where: - // R_tilde = b0*(1-r)^2 + 2*b1*r*(1-r) + b2*r^2 (Bernstein quadratic) - // J_tilde = b3*(1-r) + b4*r (Bernstein linear) - // The product gives 6 non-negative basis functions g_k(alpha) with - // weights w_k(r_tilde) that are products of Bernstein polynomials. - // Distributions are tabulated on [0, pi] exploiting up-down symmetry. - static constexpr int N_POLOIDAL_BASIS = 6; //!< Number of basis functions - int n_alpha_; //!< Number of poloidal angle grid points - array, N_POLOIDAL_BASIS> - poloidal_dists_; //!< Distributions for each basis function g_k(alpha) - array - poloidal_integrals_; //!< Integrals of g_k(alpha) over [0, pi] + unique_ptr space_; //!< Mesh spatial + vector> sources_; //!< Source distributions }; //============================================================================== @@ -411,9 +246,6 @@ SourceSite sample_external_source(uint64_t* seed); void free_memory_source(); -//! Reset cumulative source rejection counters -void reset_source_rejection_counters(); - } // namespace openmc #endif // OPENMC_SOURCE_H diff --git a/include/openmc/span.h b/include/openmc/span.h deleted file mode 100644 index 723bccd76..000000000 --- a/include/openmc/span.h +++ /dev/null @@ -1,237 +0,0 @@ -#ifndef OPENMC_SPAN_H -#define OPENMC_SPAN_H -#include // for std::size_t, std::ptrdiff_t -#include // for std::begin, std::end -#include // for std::out_of_range -#include - -#include "openmc/vector.h" - -namespace openmc { - -template -class span { -public: - using value_type = T; - using pointer = T*; - using const_pointer = const T*; - using reference = T&; - using const_reference = const T&; - using iterator = T*; - using const_iterator = const T*; - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; - - /** - * @brief Default constructor for an empty span. - */ - span() noexcept : data_(nullptr), size_(0) {} - - /** - * @brief Constructs a span from a pointer and size. - * @param ptr Pointer to the first element. - * @param count Number of elements in the span. - */ - span(pointer ptr, size_type count) : data_(ptr), size_(count) {} - - /** - * @brief Constructs a span from two pointers marking the span range. - * @param first Pointer to the first element. - * @param last Pointer past the last element. - * @throws std::out_of_range if last < first. - */ - span(pointer first, pointer last) : data_(first), size_(last - first) - { - if (last < first) { - throw std::out_of_range("span: last pointer is before first pointer"); - } - } - - /** - * @brief Constructs a span from a non-const std::vector. - * @param vec Reference to the vector to create a span from. - */ - span(std::vector& vec) : data_(vec.data()), size_(vec.size()) {} - - /** - * @brief Constructs a span from a const std::vector. - * - * This is handling the semantics that a span is used - * for read-only access into a vector. - * @param vec Reference to the const vector to create a span from. - */ - template::value>> - span(const std::vector>& vec) - : data_(vec.data()), size_(vec.size()) - {} - - /** - * @brief Constructs a read-only span from a non-const span. - */ - template::value>> - span(const span>& other) noexcept - : data_(other.data()), size_(other.size()) - {} - - /** - * @brief Access an element without bounds checking. - * @param index Index of the element to access. - * @return Reference to the accessed element. - */ - reference operator[](size_type index) { return data_[index]; } - - /** - * @brief Access an element without bounds checking (const version). - * @param index Index of the element to access. - * @return Const reference to the accessed element. - */ - const_reference operator[](size_type index) const { return data_[index]; } - - /** - * @brief Access an element with bounds checking. - * @param index Index of the element to access. - * @return Reference to the accessed element. - * @throws std::out_of_range if index is out of range. - */ - reference at(size_type index) - { - if (index >= size_) { - throw std::out_of_range("span: index out of range"); - } - return data_[index]; - } - - /** - * @brief Access an element with bounds checking (const version). - * @param index Index of the element to access. - * @return Const reference to the accessed element. - * @throws std::out_of_range if index is out of range. - */ - const_reference at(size_type index) const - { - if (index >= size_) { - throw std::out_of_range("span: index out of range"); - } - return data_[index]; - } - - /** - * @brief Get a pointer to the underlying data. - * @return Pointer to the data, or nullptr if the span is empty. - */ - pointer data() noexcept { return data_; } - - /** - * @brief Get a const pointer to the underlying data. - * @return Const pointer to the data, or nullptr if the span is empty. - */ - const_pointer data() const noexcept { return data_; } - - /** - * @brief Get the number of elements in the span. - * @return The size of the span. - */ - size_type size() const noexcept { return size_; } - - /** - * @brief Check if the span is empty. - * @return True if the span is empty, false otherwise. - */ - bool empty() const noexcept { return size_ == 0; } - - /** - * @brief Get an iterator to the beginning of the span. - * @return Iterator pointing to the first element. - */ - iterator begin() noexcept { return data_; } - - /** - * @brief Get a const iterator to the beginning of the span. - * @return Const iterator pointing to the first element. - */ - const_iterator begin() const noexcept { return data_; } - - /** - * @brief Get a const iterator to the beginning of the span. - * @return Const iterator pointing to the first element. - */ - const_iterator cbegin() const noexcept { return data_; } - - /** - * @brief Get an iterator to the end of the span. - * @return Iterator pointing past the last element. - */ - iterator end() noexcept { return data_ + size_; } - - /** - * @brief Get a const iterator to the end of the span. - * @return Const iterator pointing past the last element. - */ - const_iterator end() const noexcept { return data_ + size_; } - - /** - * @brief Get a const iterator to the end of the span. - * @return Const iterator pointing past the last element. - */ - const_iterator cend() const noexcept { return data_ + size_; } - - /** - * @brief Access the first element. - * @return Reference to the first element. - * @throws std::out_of_range if the span is empty. - */ - reference front() - { - if (empty()) { - throw std::out_of_range("span::front(): span is empty"); - } - return data_[0]; - } - - /** - * @brief Access the first element (const version). - * @return Const reference to the first element. - * @throws std::out_of_range if the span is empty. - */ - const_reference front() const - { - if (empty()) { - throw std::out_of_range("span::front(): span is empty"); - } - return data_[0]; - } - - /** - * @brief Access the last element. - * @return Reference to the last element. - * @throws std::out_of_range if the span is empty. - */ - reference back() - { - if (empty()) { - throw std::out_of_range("span::back(): span is empty"); - } - return data_[size_ - 1]; - } - - /** - * @brief Access the last element (const version). - * @return Const reference to the last element. - * @throws std::out_of_range if the span is empty. - */ - const_reference back() const - { - if (empty()) { - throw std::out_of_range("span::back(): span is empty"); - } - return data_[size_ - 1]; - } - -private: - pointer data_; - size_type size_; -}; - -} // namespace openmc -#endif // OPENMC_SPAN_H diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index fb1aaf7b9..95524f6b6 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -2,14 +2,14 @@ #define OPENMC_STATE_POINT_H #include -#include + +#include #include "hdf5.h" #include "openmc/capi.h" #include "openmc/particle.h" #include "openmc/shared_array.h" -#include "openmc/span.h" #include "openmc/vector.h" namespace openmc { @@ -33,18 +33,12 @@ void load_state_point(); // values on each rank, used to create global indexing. This vector // can be created by calling calculate_parallel_index_vector on // source_bank.size() if such a vector is not already available. -// -// The source_bank variable is used as work space if MPI is used, -// so it cannot be given as a const span. -void write_h5_source_point(const char* filename, span source_bank, +void write_source_point(const char* filename, gsl::span source_bank, const vector& bank_index); -void write_source_point(std::string, span source_bank, - const vector& bank_index, bool use_mcpl); - // This appends a source bank specification to an HDF5 file // that's already open. It is used internally by write_source_point. -void write_source_bank(hid_t group_id, span source_bank, +void write_source_bank(hid_t group_id, gsl::span source_bank, const vector& bank_index); void read_source_bank( diff --git a/include/openmc/string_utils.h b/include/openmc/string_utils.h index 2e8b0d14f..6b4c69d48 100644 --- a/include/openmc/string_utils.h +++ b/include/openmc/string_utils.h @@ -1,7 +1,6 @@ #ifndef OPENMC_STRING_UTILS_H #define OPENMC_STRING_UTILS_H -#include #include #include "openmc/vector.h" @@ -16,7 +15,7 @@ std::string to_element(const std::string& name); void to_lower(std::string& str); -int word_count(const std::string& str); +int word_count(std::string const& str); vector split(const std::string& in); @@ -24,20 +23,5 @@ bool ends_with(const std::string& value, const std::string& ending); bool starts_with(const std::string& value, const std::string& beginning); -template -inline std::string concatenate(const T& values, const std::string& del = ", ") -{ - if (values.size() == 0) - return ""; - - std::stringstream oss; - auto it = values.begin(); - oss << *it++; - while (it != values.end()) { - oss << del << *it++; - } - return oss.str(); -} - } // namespace openmc #endif // OPENMC_STRING_UTILS_H diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 2d8580345..350775123 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -2,7 +2,6 @@ #define OPENMC_SURFACE_H #include // For numeric_limits -#include #include #include @@ -10,7 +9,6 @@ #include "pugixml.hpp" #include "openmc/boundary_condition.h" -#include "openmc/bounding_box.h" #include "openmc/constants.h" #include "openmc/memory.h" // for unique_ptr #include "openmc/particle.h" @@ -30,6 +28,55 @@ extern std::unordered_map surface_map; extern vector> surfaces; } // namespace model +//============================================================================== +//! Coordinates for an axis-aligned cuboid that bounds a geometric object. +//============================================================================== + +struct BoundingBox { + double xmin = -INFTY; + double xmax = INFTY; + double ymin = -INFTY; + double ymax = INFTY; + double zmin = -INFTY; + double zmax = INFTY; + + inline BoundingBox operator&(const BoundingBox& other) + { + BoundingBox result = *this; + return result &= other; + } + + inline BoundingBox operator|(const BoundingBox& other) + { + BoundingBox result = *this; + return result |= other; + } + + // intersect operator + inline BoundingBox& operator&=(const BoundingBox& other) + { + xmin = std::max(xmin, other.xmin); + xmax = std::min(xmax, other.xmax); + ymin = std::max(ymin, other.ymin); + ymax = std::min(ymax, other.ymax); + zmin = std::max(zmin, other.zmin); + zmax = std::min(zmax, other.zmax); + return *this; + } + + // union operator + inline BoundingBox& operator|=(const BoundingBox& other) + { + xmin = std::min(xmin, other.xmin); + xmax = std::max(xmax, other.xmax); + ymin = std::min(ymin, other.ymin); + ymax = std::max(ymax, other.ymax); + zmin = std::min(zmin, other.zmin); + zmax = std::max(zmax, other.zmax); + return *this; + } +}; + //============================================================================== //! A geometry primitive used to define regions of 3D space. //============================================================================== @@ -39,6 +86,7 @@ public: int id_; //!< Unique ID std::string name_; //!< User-defined name unique_ptr bc_; //!< Boundary condition + GeometryType geom_type_; //!< Geometry type indicator (CSG or DAGMC) bool surf_source_ {false}; //!< Activate source banking for the surface? explicit Surface(pugi::xml_node surf_node); @@ -63,7 +111,7 @@ public: Position r, Direction u, GeometryState* p = nullptr) const; virtual Direction diffuse_reflect( - Position r, Direction u, uint64_t* seed) const; + Position r, Direction u, uint64_t* seed, GeometryState* p = nullptr) const; //! Evaluate the equation describing the surface. //! @@ -91,26 +139,23 @@ public: //! Get the BoundingBox for this surface. virtual BoundingBox bounding_box(bool /*pos_side*/) const { return {}; } - /* Must specify if this is a CSG or DAGMC-type surface. Only - * the DAGMC surface should return the DAG type geometry, so - * by default, this returns the CSG. The main difference is that - * if the geom_type is found to be DAG in the geometry handling code, - * some DAGMC-specific operations get carried out like resetting - * the particle's intersection history when necessary. - */ - virtual GeometryType geom_type() const { return GeometryType::CSG; } - protected: virtual void to_hdf5_inner(hid_t group_id) const = 0; }; +class CSGSurface : public Surface { +public: + explicit CSGSurface(pugi::xml_node surf_node); + CSGSurface(); +}; + //============================================================================== //! A plane perpendicular to the x-axis. // //! The plane is described by the equation \f$x - x_0 = 0\f$ //============================================================================== -class SurfaceXPlane : public Surface { +class SurfaceXPlane : public CSGSurface { public: explicit SurfaceXPlane(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -128,7 +173,7 @@ public: //! The plane is described by the equation \f$y - y_0 = 0\f$ //============================================================================== -class SurfaceYPlane : public Surface { +class SurfaceYPlane : public CSGSurface { public: explicit SurfaceYPlane(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -146,7 +191,7 @@ public: //! The plane is described by the equation \f$z - z_0 = 0\f$ //============================================================================== -class SurfaceZPlane : public Surface { +class SurfaceZPlane : public CSGSurface { public: explicit SurfaceZPlane(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -164,7 +209,7 @@ public: //! The plane is described by the equation \f$A x + B y + C z - D = 0\f$ //============================================================================== -class SurfacePlane : public Surface { +class SurfacePlane : public CSGSurface { public: explicit SurfacePlane(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -182,7 +227,7 @@ public: //! \f$(y - y_0)^2 + (z - z_0)^2 - R^2 = 0\f$ //============================================================================== -class SurfaceXCylinder : public Surface { +class SurfaceXCylinder : public CSGSurface { public: explicit SurfaceXCylinder(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -201,7 +246,7 @@ public: //! \f$(x - x_0)^2 + (z - z_0)^2 - R^2 = 0\f$ //============================================================================== -class SurfaceYCylinder : public Surface { +class SurfaceYCylinder : public CSGSurface { public: explicit SurfaceYCylinder(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -220,7 +265,7 @@ public: //! \f$(x - x_0)^2 + (y - y_0)^2 - R^2 = 0\f$ //============================================================================== -class SurfaceZCylinder : public Surface { +class SurfaceZCylinder : public CSGSurface { public: explicit SurfaceZCylinder(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -239,7 +284,7 @@ public: //! \f$(x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 - R^2 = 0\f$ //============================================================================== -class SurfaceSphere : public Surface { +class SurfaceSphere : public CSGSurface { public: explicit SurfaceSphere(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -258,7 +303,7 @@ public: //! \f$(y - y_0)^2 + (z - z_0)^2 - R^2 (x - x_0)^2 = 0\f$ //============================================================================== -class SurfaceXCone : public Surface { +class SurfaceXCone : public CSGSurface { public: explicit SurfaceXCone(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -276,7 +321,7 @@ public: //! \f$(x - x_0)^2 + (z - z_0)^2 - R^2 (y - y_0)^2 = 0\f$ //============================================================================== -class SurfaceYCone : public Surface { +class SurfaceYCone : public CSGSurface { public: explicit SurfaceYCone(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -294,7 +339,7 @@ public: //! \f$(x - x_0)^2 + (y - y_0)^2 - R^2 (z - z_0)^2 = 0\f$ //============================================================================== -class SurfaceZCone : public Surface { +class SurfaceZCone : public CSGSurface { public: explicit SurfaceZCone(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -312,7 +357,7 @@ public: //! 0\f$ //============================================================================== -class SurfaceQuadric : public Surface { +class SurfaceQuadric : public CSGSurface { public: explicit SurfaceQuadric(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -330,7 +375,7 @@ public: //! \f$(x-x_0)^2/B^2 + (\sqrt{(y-y_0)^2 + (z-z_0)^2} - A)^2/C^2 -1 \f$ //============================================================================== -class SurfaceXTorus : public Surface { +class SurfaceXTorus : public CSGSurface { public: explicit SurfaceXTorus(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -347,7 +392,7 @@ public: //! \f$(y-y_0)^2/B^2 + (\sqrt{(x-x_0)^2 + (z-z_0)^2} - A)^2/C^2 -1 \f$ //============================================================================== -class SurfaceYTorus : public Surface { +class SurfaceYTorus : public CSGSurface { public: explicit SurfaceYTorus(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -364,7 +409,7 @@ public: //! \f$(z-z_0)^2/B^2 + (\sqrt{(x-x_0)^2 + (y-y_0)^2} - A)^2/C^2 -1 \f$ //============================================================================== -class SurfaceZTorus : public Surface { +class SurfaceZTorus : public CSGSurface { public: explicit SurfaceZTorus(pugi::xml_node surf_node); double evaluate(Position r) const override; @@ -379,39 +424,7 @@ public: // Non-member functions //============================================================================== -//! Read surface definitions from XML and populate the global surfaces vector. -//! -//! This function parses surface elements from the XML input, creates the -//! appropriate surface objects, and identifies periodic surfaces along with -//! their albedo values and sense information. -//! -//! \param node XML node containing surface definitions -//! \param[out] periodic_pairs Set of surface ID pairs representing periodic -//! boundary conditions -//! \param[out] albedo_map Map of surface IDs to albedo values for periodic -//! surfaces -//! \param[out] periodic_sense_map Map of surface IDs to their sense values -//! (used to determine orientation for periodic BCs) -void read_surfaces(pugi::xml_node node, - std::set>& periodic_pairs, - std::unordered_map& albedo_map, - std::unordered_map& periodic_sense_map); - -//! Resolve periodic surface pairs and assign boundary conditions. -//! -//! This function completes the setup of periodic boundary conditions by -//! resolving unpaired periodic surfaces, determining whether each pair -//! represents translational or rotational periodicity based on surface -//! normals, and assigning the appropriate boundary condition objects. -//! -//! \param[inout] periodic_pairs Set of surface ID pairs representing periodic -//! boundary conditions; unpaired entries are resolved -//! \param albedo_map Map of surface IDs to albedo values for periodic surfaces -//! \param periodic_sense_map Map of surface IDs to their sense values (used to -//! determine orientation for periodic BCs) -void prepare_boundary_conditions(std::set>& periodic_pairs, - std::unordered_map& albedo_map, - std::unordered_map& periodic_sense_map); +void read_surfaces(pugi::xml_node node); void free_memory_surfaces(); diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index 77b0d9f42..1166c0eee 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -6,6 +6,7 @@ #include #include "pugixml.hpp" +#include #include "openmc/constants.h" #include "openmc/hdf5_interface.h" @@ -33,21 +34,15 @@ enum class FilterType { MATERIALFROM, MESH, MESHBORN, - MESH_MATERIAL, MESH_SURFACE, MU, - MUSURFACE, - PARENT_NUCLIDE, PARTICLE, - PARTICLE_PRODUCTION, POLAR, - REACTION, SPHERICAL_HARMONICS, SPATIAL_LEGENDRE, SURFACE, TIME, UNIVERSE, - WEIGHT, ZERNIKE, ZERNIKE_RADIAL }; @@ -134,7 +129,7 @@ public: //! \return Number of bins int n_bins() const { return n_bins_; } - int64_t index() const { return index_; } + gsl::index index() const { return index_; } //---------------------------------------------------------------------------- // Data members @@ -144,7 +139,7 @@ protected: private: int32_t id_ {C_NONE}; - int64_t index_; + gsl::index index_; }; //============================================================================== diff --git a/include/openmc/tallies/filter_azimuthal.h b/include/openmc/tallies/filter_azimuthal.h index 4853c5545..37e1ef073 100644 --- a/include/openmc/tallies/filter_azimuthal.h +++ b/include/openmc/tallies/filter_azimuthal.h @@ -4,7 +4,8 @@ #include "openmc/vector.h" #include -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" namespace openmc { @@ -38,7 +39,7 @@ public: //---------------------------------------------------------------------------- // Accessors - void set_bins(span bins); + void set_bins(gsl::span bins); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_cell.h b/include/openmc/tallies/filter_cell.h index ac6539466..b7ea01ce6 100644 --- a/include/openmc/tallies/filter_cell.h +++ b/include/openmc/tallies/filter_cell.h @@ -4,7 +4,8 @@ #include #include -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -41,7 +42,7 @@ public: const vector& cells() const { return cells_; } - void set_cells(span cells); + void set_cells(gsl::span cells); protected: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_cell_instance.h b/include/openmc/tallies/filter_cell_instance.h index 69499765b..f500f4889 100644 --- a/include/openmc/tallies/filter_cell_instance.h +++ b/include/openmc/tallies/filter_cell_instance.h @@ -4,8 +4,9 @@ #include #include +#include + #include "openmc/cell.h" -#include "openmc/span.h" #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -21,7 +22,7 @@ public: // Constructors, destructors CellInstanceFilter() = default; - CellInstanceFilter(span instances); + CellInstanceFilter(gsl::span instances); ~CellInstanceFilter() = default; //---------------------------------------------------------------------------- @@ -46,7 +47,7 @@ public: const std::unordered_set& cells() const { return cells_; } - void set_cell_instances(span instances); + void set_cell_instances(gsl::span instances); private: //---------------------------------------------------------------------------- @@ -59,7 +60,7 @@ private: std::unordered_set cells_; //! A map from cell/instance indices to filter bin indices. - std::unordered_map map_; + std::unordered_map map_; //! Indicates if filter uses only material-filled cells bool material_cells_only_; diff --git a/include/openmc/tallies/filter_collision.h b/include/openmc/tallies/filter_collision.h index 7d42a5ddd..d2dab70ca 100644 --- a/include/openmc/tallies/filter_collision.h +++ b/include/openmc/tallies/filter_collision.h @@ -1,9 +1,9 @@ #ifndef OPENMC_TALLIES_FILTER_COLLISIONS_H #define OPENMC_TALLIES_FILTER_COLLISIONS_H +#include #include -#include "openmc/span.h" #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -39,7 +39,7 @@ public: // Accessors const vector& bins() const { return bins_; } - void set_bins(span bins); + void set_bins(gsl::span bins); protected: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_delayedgroup.h b/include/openmc/tallies/filter_delayedgroup.h index 7d11447ab..71919b2ec 100644 --- a/include/openmc/tallies/filter_delayedgroup.h +++ b/include/openmc/tallies/filter_delayedgroup.h @@ -1,7 +1,8 @@ #ifndef OPENMC_TALLIES_FILTER_DELAYEDGROUP_H #define OPENMC_TALLIES_FILTER_DELAYEDGROUP_H -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -41,7 +42,7 @@ public: const vector& groups() const { return groups_; } - void set_groups(span groups); + void set_groups(gsl::span groups); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_energy.h b/include/openmc/tallies/filter_energy.h index 3e410d9fd..e35e01a6d 100644 --- a/include/openmc/tallies/filter_energy.h +++ b/include/openmc/tallies/filter_energy.h @@ -1,8 +1,8 @@ #ifndef OPENMC_TALLIES_FILTER_ENERGY_H #define OPENMC_TALLIES_FILTER_ENERGY_H -#include "openmc/particle.h" -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -38,7 +38,7 @@ public: // Accessors const vector& bins() const { return bins_; } - void set_bins(span bins); + void set_bins(gsl::span bins); bool matches_transport_groups() const { return matches_transport_groups_; } diff --git a/include/openmc/tallies/filter_energyfunc.h b/include/openmc/tallies/filter_energyfunc.h index e03c23dda..d77ef0fa8 100644 --- a/include/openmc/tallies/filter_energyfunc.h +++ b/include/openmc/tallies/filter_energyfunc.h @@ -2,7 +2,6 @@ #define OPENMC_TALLIES_FILTER_ENERGYFUNC_H #include "openmc/constants.h" -#include "openmc/span.h" #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -43,7 +42,7 @@ public: const vector& energy() const { return energy_; } const vector& y() const { return y_; } Interpolation interpolation() const { return interpolation_; } - void set_data(span energy, span y); + void set_data(gsl::span energy, gsl::span y); void set_interpolation(const std::string& interpolation); private: diff --git a/include/openmc/tallies/filter_material.h b/include/openmc/tallies/filter_material.h index ccfe5403d..aa5df5b3a 100644 --- a/include/openmc/tallies/filter_material.h +++ b/include/openmc/tallies/filter_material.h @@ -4,7 +4,8 @@ #include #include -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -43,7 +44,7 @@ public: const vector& materials() const { return materials_; } - void set_materials(span materials); + void set_materials(gsl::span materials); protected: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_mesh.h b/include/openmc/tallies/filter_mesh.h index c35a477fe..2f48b6d4d 100644 --- a/include/openmc/tallies/filter_mesh.h +++ b/include/openmc/tallies/filter_mesh.h @@ -9,9 +9,9 @@ namespace openmc { //============================================================================== -//! Indexes the location of particle events to a mesh. For tracklength tallies, -//! it will produce multiple valid bins and the bin weight will correspond to -//! the fraction of the track length that lies in that bin. +//! Indexes the location of particle events to a regular mesh. For tracklength +//! tallies, it will produce multiple valid bins and the bin weight will +//! correspond to the fraction of the track length that lies in that bin. //============================================================================== class MeshFilter : public Filter { @@ -51,12 +51,6 @@ public: virtual bool translated() const { return translated_; } - virtual void set_rotation(const vector& rotation); - - virtual const vector& rotation() const { return rotation_; } - - virtual bool rotated() const { return rotated_; } - protected: //---------------------------------------------------------------------------- // Data members @@ -64,8 +58,6 @@ protected: int32_t mesh_; //!< Index of the mesh bool translated_ {false}; //!< Whether or not the filter is translated Position translation_ {0.0, 0.0, 0.0}; //!< Filter translation - bool rotated_ {false}; //!< Whether or not the filter is rotated - vector rotation_; //!< Filter rotation }; } // namespace openmc diff --git a/include/openmc/tallies/filter_meshmaterial.h b/include/openmc/tallies/filter_meshmaterial.h deleted file mode 100644 index 42a4edcf0..000000000 --- a/include/openmc/tallies/filter_meshmaterial.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef OPENMC_TALLIES_FILTER_MESHMATERIAL_H -#define OPENMC_TALLIES_FILTER_MESHMATERIAL_H - -#include -#include -#include -#include - -#include "openmc/position.h" -#include "openmc/random_ray/source_region.h" -#include "openmc/span.h" -#include "openmc/tallies/filter.h" -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -//! Helper structs that define a combination of a mesh element index and a -//! material index and a functor for hashing to place in an unordered_map -//============================================================================== - -struct ElementMat { - //! Check for equality - bool operator==(const ElementMat& other) const - { - return index_element == other.index_element && index_mat == other.index_mat; - } - - int32_t index_element; - int32_t index_mat; -}; - -struct ElementMatHash { - std::size_t operator()(const ElementMat& k) const - { - size_t seed = 0; - hash_combine(seed, k.index_element); - hash_combine(seed, k.index_mat); - return seed; - } -}; - -//============================================================================== -//! Indexes the location of particle events to combinations of mesh element -//! index and material. For tracklength tallies, it will produce multiple valid -//! bins and the bin weight will correspond to the fraction of the track length -//! that lies in that bin. -//============================================================================== - -class MeshMaterialFilter : public Filter { -public: - //---------------------------------------------------------------------------- - // Constructors, destructors - - ~MeshMaterialFilter() = default; - - //---------------------------------------------------------------------------- - // Methods - - std::string type_str() const override { return "meshmaterial"; } - FilterType type() const override { return FilterType::MESH_MATERIAL; } - - void from_xml(pugi::xml_node node) override; - - void get_all_bins(const Particle& p, TallyEstimator estimator, - FilterMatch& match) const override; - - void to_statepoint(hid_t filter_group) const override; - - std::string text_label(int bin) const override; - - //---------------------------------------------------------------------------- - // Accessors - - int32_t mesh() const { return mesh_; } - - void set_mesh(int32_t mesh); - - //! Set the bins based on a flat vector of alternating element index and - //! material IDs - void set_bins(span bins); - - //! Set the bins based on a vector of (element, material index) pairs - void set_bins(vector&& bins); - - virtual void set_translation(const Position& translation); - - virtual void set_translation(const double translation[3]); - - virtual const Position& translation() const { return translation_; } - - virtual bool translated() const { return translated_; } - -private: - //---------------------------------------------------------------------------- - // Data members - - int32_t mesh_; //!< Index of the mesh - bool translated_ {false}; //!< Whether or not the filter is translated - Position translation_ {0.0, 0.0, 0.0}; //!< Filter translation - - //! The indices of the mesh element-material combinations binned by this - //! filter. - vector bins_; - - //! The set of materials used in this filter - std::unordered_set materials_; - - //! A map from mesh element-material indices to filter bin indices. - std::unordered_map map_; -}; - -} // namespace openmc -#endif // OPENMC_TALLIES_FILTER_MESHMATERIAL_H diff --git a/include/openmc/tallies/filter_mu.h b/include/openmc/tallies/filter_mu.h index d6e7f1798..942ee60c2 100644 --- a/include/openmc/tallies/filter_mu.h +++ b/include/openmc/tallies/filter_mu.h @@ -1,7 +1,8 @@ #ifndef OPENMC_TALLIES_FILTER_MU_H #define OPENMC_TALLIES_FILTER_MU_H -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -37,9 +38,9 @@ public: //---------------------------------------------------------------------------- // Accessors - void set_bins(span bins); + void set_bins(gsl::span bins); -protected: +private: //---------------------------------------------------------------------------- // Data members diff --git a/include/openmc/tallies/filter_musurface.h b/include/openmc/tallies/filter_musurface.h deleted file mode 100644 index fa6816836..000000000 --- a/include/openmc/tallies/filter_musurface.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef OPENMC_TALLIES_FILTER_MU_SURFACE_H -#define OPENMC_TALLIES_FILTER_MU_SURFACE_H - -#include "openmc/tallies/filter_mu.h" -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -//! Bins the incoming-outgoing direction cosine. This is only used for surface -//! crossings. -//============================================================================== - -class MuSurfaceFilter : public MuFilter { -public: - //---------------------------------------------------------------------------- - // Constructors, destructors - - ~MuSurfaceFilter() = default; - - //---------------------------------------------------------------------------- - // Methods - - std::string type_str() const override { return "musurface"; } - FilterType type() const override { return FilterType::MUSURFACE; } - - void get_all_bins(const Particle& p, TallyEstimator estimator, - FilterMatch& match) const override; -}; - -} // namespace openmc -#endif // OPENMC_TALLIES_FILTER_MU_SURFACE_H diff --git a/include/openmc/tallies/filter_parent_nuclide.h b/include/openmc/tallies/filter_parent_nuclide.h deleted file mode 100644 index 53f8a5fa4..000000000 --- a/include/openmc/tallies/filter_parent_nuclide.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef OPENMC_TALLIES_FILTER_PARENT_NUCLIDE_H -#define OPENMC_TALLIES_FILTER_PARENT_NUCLIDE_H - -#include -#include - -#include "openmc/span.h" -#include "openmc/tallies/filter.h" -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -//! Bins events by parent nuclide (for decay photons) -//============================================================================== - -class ParentNuclideFilter : public Filter { -public: - //---------------------------------------------------------------------------- - // Constructors, destructors - - ~ParentNuclideFilter() = default; - - //---------------------------------------------------------------------------- - // Methods - - std::string type_str() const override { return "parentnuclide"; } - FilterType type() const override { return FilterType::PARENT_NUCLIDE; } - - void from_xml(pugi::xml_node node) override; - - void get_all_bins(const Particle& p, TallyEstimator estimator, - FilterMatch& match) const override; - - void to_statepoint(hid_t filter_group) const override; - - std::string text_label(int bin) const override; - - //---------------------------------------------------------------------------- - // Accessors - - const vector& bins() const { return bins_; } - void set_bins(span bins); - -protected: - //---------------------------------------------------------------------------- - // Data members - - vector bins_; - vector nuclides_; - - std::unordered_map map_; -}; - -} // namespace openmc -#endif // OPENMC_TALLIES_FILTER_PARENT_NUCLIDE_H diff --git a/include/openmc/tallies/filter_particle.h b/include/openmc/tallies/filter_particle.h index 9932a6037..a181d5cee 100644 --- a/include/openmc/tallies/filter_particle.h +++ b/include/openmc/tallies/filter_particle.h @@ -1,8 +1,7 @@ #ifndef OPENMC_TALLIES_FILTER_PARTICLE_H #define OPENMC_TALLIES_FILTER_PARTICLE_H -#include "openmc/particle_type.h" -#include "openmc/span.h" +#include "openmc/particle.h" #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -39,7 +38,7 @@ public: const vector& particles() const { return particles_; } - void set_particles(span particles); + void set_particles(gsl::span particles); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_particle_production.h b/include/openmc/tallies/filter_particle_production.h deleted file mode 100644 index 00fac9f7c..000000000 --- a/include/openmc/tallies/filter_particle_production.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OPENMC_TALLIES_FILTER_PARTICLE_PRODUCTION_H -#define OPENMC_TALLIES_FILTER_PARTICLE_PRODUCTION_H - -#include - -#include "openmc/particle.h" -#include "openmc/tallies/filter.h" -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -//! Bins the outgoing energy of secondary particles -//! -//! This filter bins secondary particles by type and, optionally, by energy. It -//! can be used to get the photon production matrix for multigroup photon -//! transport, the energy distribution of secondary neutrons, etc. The weight -//! that is applied is equal to the weight of the secondary particle. Thus, to -//! get secondary production it should be used in conjunction with the "events" -//! score. -//============================================================================== - -class ParticleProductionFilter : public Filter { -public: - //---------------------------------------------------------------------------- - // Methods - - std::string type_str() const override { return "particleproduction"; } - FilterType type() const override { return FilterType::PARTICLE_PRODUCTION; } - - void get_all_bins(const Particle& p, TallyEstimator estimator, - FilterMatch& match) const override; - - std::string text_label(int bin) const override; - - void from_xml(pugi::xml_node node) override; - - void to_statepoint(hid_t filter_group) const override; - -private: - //---------------------------------------------------------------------------- - // Data members - - vector secondary_types_; //!< Types of secondary particles - - //! Map from PDG number to index in secondary_types_ for O(1) lookup - std::unordered_map type_to_index_; - - vector energy_bins_; //!< Energy bin boundaries (optional) -}; - -} // namespace openmc -#endif // OPENMC_TALLIES_FILTER_PARTICLE_PRODUCTION_H diff --git a/include/openmc/tallies/filter_polar.h b/include/openmc/tallies/filter_polar.h index c7c73c89f..78bb25aa4 100644 --- a/include/openmc/tallies/filter_polar.h +++ b/include/openmc/tallies/filter_polar.h @@ -3,7 +3,8 @@ #include -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -38,7 +39,7 @@ public: //---------------------------------------------------------------------------- // Accessors - void set_bins(span bins); + void set_bins(gsl::span bins); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_reaction.h b/include/openmc/tallies/filter_reaction.h deleted file mode 100644 index 015729eef..000000000 --- a/include/openmc/tallies/filter_reaction.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef OPENMC_TALLIES_FILTER_REACTION_H -#define OPENMC_TALLIES_FILTER_REACTION_H - -#include "openmc/span.h" -#include "openmc/tallies/filter.h" -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -//! Bins tally events based on the reaction type (MT number). -//============================================================================== - -class ReactionFilter : public Filter { -public: - //---------------------------------------------------------------------------- - // Constructors, destructors - - ~ReactionFilter() = default; - - //---------------------------------------------------------------------------- - // Methods - - std::string type_str() const override { return "reaction"; } - FilterType type() const override { return FilterType::REACTION; } - - void from_xml(pugi::xml_node node) override; - - void get_all_bins(const Particle& p, TallyEstimator estimator, - FilterMatch& match) const override; - - void to_statepoint(hid_t filter_group) const override; - - std::string text_label(int bin) const override; - - //---------------------------------------------------------------------------- - // Accessors - - const vector& bins() const { return bins_; } - void set_bins(span bins); - -protected: - //---------------------------------------------------------------------------- - // Data members - - //! MT numbers to match - vector bins_; -}; - -} // namespace openmc - -#endif // OPENMC_TALLIES_FILTER_REACTION_H diff --git a/include/openmc/tallies/filter_sph_harm.h b/include/openmc/tallies/filter_sph_harm.h index a6904c301..5d4a4bd99 100644 --- a/include/openmc/tallies/filter_sph_harm.h +++ b/include/openmc/tallies/filter_sph_harm.h @@ -3,6 +3,8 @@ #include +#include + #include "openmc/tallies/filter.h" namespace openmc { @@ -44,7 +46,7 @@ public: SphericalHarmonicsCosine cosine() const { return cosine_; } - void set_cosine(const std::string& cosine); + void set_cosine(gsl::cstring_span cosine); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_surface.h b/include/openmc/tallies/filter_surface.h index e78243f5f..3537f1cc7 100644 --- a/include/openmc/tallies/filter_surface.h +++ b/include/openmc/tallies/filter_surface.h @@ -4,7 +4,8 @@ #include #include -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -39,7 +40,7 @@ public: //---------------------------------------------------------------------------- // Accessors - void set_surfaces(span surfaces); + void set_surfaces(gsl::span surfaces); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_time.h b/include/openmc/tallies/filter_time.h index 3ce557abd..105ef9880 100644 --- a/include/openmc/tallies/filter_time.h +++ b/include/openmc/tallies/filter_time.h @@ -1,7 +1,8 @@ #ifndef OPENMC_TALLIES_FILTER_TIME_H #define OPENMC_TALLIES_FILTER_TIME_H -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -37,7 +38,7 @@ public: // Accessors const vector& bins() const { return bins_; } - void set_bins(span bins); + void set_bins(gsl::span bins); protected: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_universe.h b/include/openmc/tallies/filter_universe.h index 461434ec4..d4894353b 100644 --- a/include/openmc/tallies/filter_universe.h +++ b/include/openmc/tallies/filter_universe.h @@ -4,7 +4,8 @@ #include #include -#include "openmc/span.h" +#include + #include "openmc/tallies/filter.h" #include "openmc/vector.h" @@ -39,7 +40,7 @@ public: //---------------------------------------------------------------------------- // Accessors - void set_universes(span universes); + void set_universes(gsl::span universes); private: //---------------------------------------------------------------------------- diff --git a/include/openmc/tallies/filter_weight.h b/include/openmc/tallies/filter_weight.h deleted file mode 100644 index 1fe9d75d3..000000000 --- a/include/openmc/tallies/filter_weight.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef OPENMC_TALLIES_FILTER_WEIGHT_H -#define OPENMC_TALLIES_FILTER_WEIGHT_H - -#include - -#include "openmc/span.h" -#include "openmc/tallies/filter.h" -#include "openmc/vector.h" - -namespace openmc { - -//============================================================================== -//! Bins the weights of the particles. -//============================================================================== - -class WeightFilter : public Filter { -public: - //---------------------------------------------------------------------------- - // Constructors, destructors - - ~WeightFilter() = default; - - //---------------------------------------------------------------------------- - // Methods - - std::string type_str() const override { return "weight"; } - FilterType type() const override { return FilterType::WEIGHT; } - - void from_xml(pugi::xml_node node) override; - - void get_all_bins(const Particle& p, TallyEstimator estimator, - FilterMatch& match) const override; - - void to_statepoint(hid_t filter_group) const override; - - std::string text_label(int bin) const override; - - //---------------------------------------------------------------------------- - // Accessors - - const vector& bins() const { return bins_; } - void set_bins(span bins); - -protected: - //---------------------------------------------------------------------------- - // Data members - vector bins_; -}; - -} // namespace openmc -#endif // OPENMC_TALLIES_FILTER_WEIGHT_H diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index ae604b732..2f0cddcf0 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -3,13 +3,14 @@ #include "openmc/constants.h" #include "openmc/memory.h" // for unique_ptr -#include "openmc/span.h" #include "openmc/tallies/filter.h" #include "openmc/tallies/trigger.h" #include "openmc/vector.h" -#include "openmc/tensor.h" #include "pugixml.hpp" +#include "xtensor/xfixed.hpp" +#include "xtensor/xtensor.hpp" +#include #include #include @@ -54,7 +55,7 @@ public: void set_nuclides(const vector& nuclides); - const tensor::Tensor& results() const { return results_; } + const xt::xtensor& results() const { return results_; } //! returns vector of indices corresponding to the tally this is called on const vector& filters() const { return filters_; } @@ -92,21 +93,19 @@ public: //! \brief Check if this tally has a specified type of filter bool has_filter(FilterType filter_type) const; - void set_filters(span filters); + void set_filters(gsl::span filters); //! Given already-set filters, set the stride lengths void set_strides(); - int64_t strides(int i) const { return strides_[i]; } + int32_t strides(int i) const { return strides_[i]; } - int64_t n_filter_bins() const { return n_filter_bins_; } + int32_t n_filter_bins() const { return n_filter_bins_; } bool multiply_density() const { return multiply_density_; } bool writable() const { return writable_; } - bool higher_moments() const { return higher_moments_; } - //---------------------------------------------------------------------------- // Other methods. @@ -124,7 +123,7 @@ public: int score_index(const std::string& score) const; //! Tally results reshaped according to filter sizes - tensor::Tensor get_reshaped_data() const; + xt::xarray get_reshaped_data() const; //! A string representing the i-th score on this tally std::string score_name(int score_idx) const; @@ -159,7 +158,7 @@ public: //! combination of filters (e.g. specific cell, specific energy group, etc.) //! and the second dimension of the array is for scores (e.g. flux, total //! reaction rate, fission reaction rate, etc.) - tensor::Tensor results_; + xt::xtensor results_; //! True if this tally should be written to statepoint files bool writable_ {true}; @@ -170,8 +169,10 @@ public: // We need to have quick access to some filters. The following gives indices // for various filters that could be in the tally or C_NONE if they are not // present. + int energy_filter_ {C_NONE}; int energyout_filter_ {C_NONE}; int delayedgroup_filter_ {C_NONE}; + int cell_filter_ {C_NONE}; vector triggers_; @@ -184,17 +185,14 @@ private: vector filters_; //!< Filter indices in global filters array //! Index strides assigned to each filter to support 1D indexing. - vector strides_; + vector strides_; - int64_t n_filter_bins_ {0}; + int32_t n_filter_bins_ {0}; //! Whether to multiply by atom density for reaction rates bool multiply_density_ {true}; - //! Whether to accumulate higher moments (third and fourth) - bool higher_moments_ {false}; - - int64_t index_; + gsl::index index_; }; //============================================================================== @@ -207,19 +205,17 @@ extern vector> tallies; extern vector active_tallies; extern vector active_analog_tallies; extern vector active_tracklength_tallies; -extern vector active_timed_tracklength_tallies; extern vector active_collision_tallies; extern vector active_meshsurf_tallies; extern vector active_surface_tallies; extern vector active_pulse_height_tallies; -extern vector pulse_height_cells; -extern vector time_grid; - +extern vector pulse_height_cells; } // namespace model namespace simulation { //! Global tallies (such as k-effective estimators) -extern tensor::StaticTensor2D global_tallies; +extern xt::xtensor_fixed> + global_tallies; //! Number of realizations for global tallies extern "C" int32_t n_realizations; @@ -245,16 +241,15 @@ void read_tallies_xml(pugi::xml_node root); //! batch to a new random variable void accumulate_tallies(); -//! Determine distance to next time boundary -// -//! \param time Current time of particle -//! \param speed Speed of particle -//! \return Distance to next time boundary (or INFTY if none) -double distance_to_time_boundary(double time, double speed); - //! Determine which tallies should be active void setup_active_tallies(); +// Alias for the type returned by xt::adapt(...). N is the dimension of the +// multidimensional array +template +using adaptor_type = + xt::xtensor_adaptor, N>; + #ifdef OPENMC_MPI //! Collect all tally results onto master process void reduce_tally_results(); diff --git a/include/openmc/tallies/tally_scoring.h b/include/openmc/tallies/tally_scoring.h index 4303ddb7a..28f1f1622 100644 --- a/include/openmc/tallies/tally_scoring.h +++ b/include/openmc/tallies/tally_scoring.h @@ -41,7 +41,7 @@ public: FilterBinIter& operator++(); - int64_t index_ {1}; + int index_ {1}; double weight_ {1.}; vector& filter_matches_; @@ -91,29 +91,11 @@ void score_analog_tally_mg(Particle& p); //! \param distance The distance in [cm] traveled by the particle void score_tracklength_tally(Particle& p, double distance); -//! Score time filtered tallies using a tracklength estimate of the flux. -// -//! This is triggered at every event (surface crossing, lattice crossing, or -//! collision) and thus cannot be done for tallies that require post-collision -//! information. -// -//! \param p The particle being tracked -//! \param total_distance The distance in [cm] traveled by the particle -void score_timed_tracklength_tally(Particle& p, double total_distance); - -//! Score mesh-surface tallies for particle currents. +//! Score surface or mesh-surface tallies for particle currents. // //! \param p The particle being tracked //! \param tallies A vector of the indices of the tallies to score to -void score_meshsurface_tally(Particle& p, const vector& tallies); - -//! Score surface tallies for particle currents. -// -//! \param p The particle being tracked -//! \param tallies A vector of the indices of the tallies to score to -//! \param normal The normal of the surface being crossed -void score_surface_tally( - Particle& p, const vector& tallies, const Direction& normal); +void score_surface_tally(Particle& p, const vector& tallies); //! Score the pulse-height tally //! This is triggered at the end of every particle history diff --git a/include/openmc/tensor.h b/include/openmc/tensor.h deleted file mode 100644 index 9e443e72f..000000000 --- a/include/openmc/tensor.h +++ /dev/null @@ -1,1210 +0,0 @@ -//! \file tensor.h -//! \brief Multi-dimensional tensor types for OpenMC. -//! -//! Tensor is the primary type: a dynamic-rank owning container that stores -//! elements contiguously in row-major order. View is a lightweight -//! non-owning reference into a Tensor's storage, returned by the slice() -//! method and flat(). StaticTensor2D is a small stack-allocated 2D -//! array used only for simulation::global_tallies. -//! -//! Slicing follows numpy conventions: each axis takes an index (rank-reducing), -//! All (keep entire axis), or Range (keep sub-range). For example, -//! arr.slice(0, all, range(2, 5)) is equivalent to numpy's arr[0, :, 2:5]. -//! -//! View is declared before Tensor because Tensor's methods return View objects. - -#ifndef OPENMC_TENSOR_H -#define OPENMC_TENSOR_H - -#include "openmc/vector.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace openmc { -namespace tensor { - -//============================================================================== -// Forward declarations -//============================================================================== - -template -class Tensor; - -template -class StaticTensor2D; - -//============================================================================== -// Storage type mapping -// -// std::vector is a bit-packed specialization that returns proxy objects -// instead of real references, which breaks generic code. storage_type_map -// redirects bool to unsigned char so that Tensor stores one byte per -// element with normal reference semantics. -//============================================================================== - -template -struct storage_type_map { - using type = T; -}; -template<> -struct storage_type_map { - using type = unsigned char; -}; -template -using storage_type = typename storage_type_map::type; - -//============================================================================== -// Slice argument types -// -// Used with the variadic slice() method on Tensor, View, and StaticTensor2D. -// Each argument corresponds to one axis: a plain integer fixes that axis at -// a single index (rank-reducing), All keeps the entire axis, and Range keeps -// a sub-range. -//============================================================================== - -//! Keep an entire axis (equivalent to numpy's ':' or xtensor's xt::all()) -struct All {}; -constexpr All all {}; - -//! Sub-range along an axis [start, end) -struct Range { - size_t start; - size_t end; // SIZE_MAX means "to end of axis" -}; - -//! Create a Range [start, end) -inline Range range(size_t start, size_t end) -{ - return {start, end}; -} - -//! Create a Range [0, end) -inline Range range(size_t end) -{ - return {0, end}; -} - -namespace detail { - -//! Internal: normalized representation of a per-axis slice argument -struct SliceArg { - enum Kind { INDEX, ALL, RANGE } kind; - size_t start; - size_t end; -}; - -inline SliceArg to_slice_arg(All) -{ - return {SliceArg::ALL, 0, 0}; -} -inline SliceArg to_slice_arg(Range r) -{ - return {SliceArg::RANGE, r.start, r.end}; -} - -template -inline - typename std::enable_if::value || std::is_enum::value, - SliceArg>::type - to_slice_arg(I i) -{ - return {SliceArg::INDEX, static_cast(i), 0}; -} - -//! Result of a slice computation: pointer offset + new shape/strides -struct SliceResult { - size_t ptr_offset; - vector shape; - vector strides; -}; - -//! Compute the result of applying slice arguments to shape/strides -template -SliceResult compute_slice(const vector& shape, - const vector& strides, First first, Rest... rest) -{ - const size_t n = 1 + sizeof...(Rest); - SliceArg args[1 + sizeof...(Rest)] = { - to_slice_arg(first), to_slice_arg(rest)...}; - - size_t offset = 0; - vector new_shape; - vector new_strides; - - for (size_t a = 0; a < n; ++a) { - switch (args[a].kind) { - case SliceArg::INDEX: - offset += args[a].start * strides[a]; - break; - case SliceArg::ALL: - new_shape.push_back(shape[a]); - new_strides.push_back(strides[a]); - break; - case SliceArg::RANGE: { - offset += args[a].start * strides[a]; - size_t end = (args[a].end == SIZE_MAX) ? shape[a] : args[a].end; - new_shape.push_back(end - args[a].start); - new_strides.push_back(strides[a]); - break; - } - } - } - - // Trailing axes not covered by arguments are implicitly All. - // This matches numpy: a[i] on a 2D array returns a 1D row. - for (size_t a = n; a < shape.size(); ++a) { - new_shape.push_back(shape[a]); - new_strides.push_back(strides[a]); - } - - return {offset, std::move(new_shape), std::move(new_strides)}; -} - -} // namespace detail - -//============================================================================== -// View: a non-owning N-dimensional view into a tensor's storage. -// -// Holds a base pointer, shape, and strides (in elements). Supports arbitrary -// rank and multi-axis slicing via the variadic slice() method. -//============================================================================== - -template -class View { -public: - //-------------------------------------------------------------------------- - // Constructors - - View(T* data, vector shape, vector strides) - : data_(data), shape_(std::move(shape)), strides_(std::move(strides)) - {} - - // Explicitly default copy/move constructors (declaring copy assignment - // below would otherwise suppress the implicit move constructor). - View(const View&) = default; - View(View&&) = default; - - //-------------------------------------------------------------------------- - // Indexing - - //! Multi-index element access (1D, 2D, 3D, ...) - template - T& operator()(Indices... indices) - { - const size_t idx[] = {static_cast(indices)...}; - size_t off = 0; - for (size_t d = 0; d < sizeof...(Indices); ++d) - off += idx[d] * strides_[d]; - return data_[off]; - } - - template - const T& operator()(Indices... indices) const - { - const size_t idx[] = {static_cast(indices)...}; - size_t off = 0; - for (size_t d = 0; d < sizeof...(Indices); ++d) - off += idx[d] * strides_[d]; - return data_[off]; - } - - //! Flat logical index (row-major order) - T& operator[](size_t i) { return data_[flat_to_offset(i)]; } - const T& operator[](size_t i) const { return data_[flat_to_offset(i)]; } - - //-------------------------------------------------------------------------- - // Accessors - - size_t size() const - { - size_t s = 1; - for (auto d : shape_) - s *= d; - return s; - } - size_t ndim() const { return shape_.size(); } - size_t shape(size_t axis) const { return shape_[axis]; } - const vector& shape_vec() const { return shape_; } - T* data() { return data_; } - const T* data() const { return data_; } - - //-------------------------------------------------------------------------- - // View accessors - - //! Multi-axis slice. Each argument corresponds to one axis and is either: - //! - an integer (fixes that axis, rank-reducing) - //! - All (keeps entire axis) - //! - Range (keeps sub-range along that axis) - //! Example: v.slice(0, all, range(2, 5)) == numpy v[0, :, 2:5] - template - View slice(First first, Rest... rest) - { - auto r = detail::compute_slice(shape_, strides_, first, rest...); - return {data_ + r.ptr_offset, std::move(r.shape), std::move(r.strides)}; - } - - template - View slice(First first, Rest... rest) const - { - auto r = detail::compute_slice(shape_, strides_, first, rest...); - return {data_ + r.ptr_offset, std::move(r.shape), std::move(r.strides)}; - } - - //-------------------------------------------------------------------------- - // Assignment operators - - //! Copy assignment: element-wise deep copy (writes through data pointer). - //! Without this, the compiler's implicit copy assignment just copies the - //! View metadata (pointer, shape, strides) instead of the viewed data. - View& operator=(const View& other) - { - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] = other[i]; - return *this; - } - - //! Fill all elements with a scalar - View& operator=(T val) - { - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] = val; - return *this; - } - - //! Assignment from initializer_list (for 1D views) - View& operator=(std::initializer_list vals) - { - auto it = vals.begin(); - for (size_t i = 0; i < size() && it != vals.end(); ++i, ++it) - data_[flat_to_offset(i)] = *it; - return *this; - } - - //! Assignment from another View - template - View& operator=(const View& other) - { - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] = other[i]; - return *this; - } - - //! Assignment from Tensor (forward-declared, defined after Tensor) - template - View& operator=(const Tensor& other); - - //! Compound addition from Tensor (forward-declared, defined after Tensor) - template - View& operator+=(const Tensor& o); - - //! Compound multiply by scalar - View& operator*=(T val) - { - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] *= val; - return *this; - } - - //! Compound divide by scalar - View& operator/=(T val) - { - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] /= val; - return *this; - } - - //-------------------------------------------------------------------------- - // Reductions - - //! Sum of all elements - T sum() const - { - // remove_const needed so accumulator is mutable when T is const-qualified - std::remove_const_t s = 0; - size_t n = size(); - for (size_t i = 0; i < n; ++i) - s += data_[flat_to_offset(i)]; - return s; - } - - //-------------------------------------------------------------------------- - // Iterators - // - // Lightweight row-major iterator parameterized on pointer type (Ptr). - // Stores a flat logical position and converts to a physical offset on each - // dereference via divmod over shape/strides. For contiguous 1D views (the - // common case) the divmod chain reduces to a single multiply-by-1, which - // the compiler optimizes away. - // - // view_iterator = mutable iterator (from non-const View) - // view_iterator = read-only iterator (from const View) - - template - class view_iterator { - Ptr base_; - size_t count_; - const size_t* shape_; - const size_t* strides_; - size_t ndim_; - - public: - using iterator_category = std::random_access_iterator_tag; - using value_type = std::remove_const_t; - using difference_type = std::ptrdiff_t; - using pointer = Ptr; - using reference = decltype(*std::declval()); - - view_iterator(Ptr base, size_t count, const View* v) - : base_(base), count_(count), shape_(v->shape_.data()), - strides_(v->strides_.data()), ndim_(v->shape_.size()) - {} - - reference operator*() const { return base_[offset()]; } - reference operator[](difference_type n) const - { - return base_[offset_of(count_ + n)]; - } - view_iterator& operator++() - { - ++count_; - return *this; - } - view_iterator operator++(int) - { - auto tmp = *this; - ++count_; - return tmp; - } - view_iterator& operator--() - { - --count_; - return *this; - } - view_iterator operator+(difference_type n) const - { - auto tmp = *this; - tmp.count_ += n; - return tmp; - } - view_iterator operator-(difference_type n) const - { - auto tmp = *this; - tmp.count_ -= n; - return tmp; - } - difference_type operator-(const view_iterator& o) const - { - return static_cast(count_) - - static_cast(o.count_); - } - view_iterator& operator+=(difference_type n) - { - count_ += n; - return *this; - } - view_iterator& operator-=(difference_type n) - { - count_ -= n; - return *this; - } - bool operator==(const view_iterator& o) const { return count_ == o.count_; } - bool operator!=(const view_iterator& o) const { return count_ != o.count_; } - bool operator<(const view_iterator& o) const { return count_ < o.count_; } - bool operator>(const view_iterator& o) const { return count_ > o.count_; } - bool operator<=(const view_iterator& o) const { return count_ <= o.count_; } - bool operator>=(const view_iterator& o) const { return count_ >= o.count_; } - friend view_iterator operator+(difference_type n, const view_iterator& it) - { - return it + n; - } - - private: - size_t offset() const { return offset_of(count_); } - size_t offset_of(size_t flat) const - { - size_t off = 0; - for (int d = static_cast(ndim_) - 1; d >= 0; --d) { - off += (flat % shape_[d]) * strides_[d]; - flat /= shape_[d]; - } - return off; - } - }; - - using iterator = view_iterator; - using const_iterator = view_iterator; - - iterator begin() { return {data_, 0, this}; } - iterator end() { return {data_, size(), this}; } - const_iterator begin() const { return cbegin(); } - const_iterator end() const { return cend(); } - const_iterator cbegin() const { return {data_, 0, this}; } - const_iterator cend() const { return {data_, size(), this}; } - -private: - //! Convert a logical flat index (row-major) to a physical element offset - size_t flat_to_offset(size_t flat) const - { - size_t off = 0; - for (int d = static_cast(shape_.size()) - 1; d >= 0; --d) { - off += (flat % shape_[d]) * strides_[d]; - flat /= shape_[d]; - } - return off; - } - - T* data_; - vector shape_; - vector strides_; -}; - -//============================================================================== -// Tensor: dynamic-rank N-dimensional tensor. -// -// Stores elements in a contiguous row-major vector> -// with a dynamic shape. -//============================================================================== - -template -class Tensor { -public: - using value_type = T; - using stored_type = storage_type; - using iterator = typename vector::iterator; - using const_iterator = typename vector::const_iterator; - - //-------------------------------------------------------------------------- - // Constructors - - Tensor() = default; - - //! Construct with shape (uninitialized for arithmetic types via vector - //! resize) - explicit Tensor(vector shape) - : shape_(std::move(shape)), data_(compute_size()) - {} - - //! Construct with shape and fill value - Tensor(vector shape, T fill) - : shape_(std::move(shape)), data_(compute_size(), fill) - {} - - //! Construct from initializer_list shape - explicit Tensor(std::initializer_list shape) - : shape_(shape), data_(compute_size()) - {} - - //! Construct from initializer_list shape with fill - Tensor(std::initializer_list shape, T fill) - : shape_(shape), data_(compute_size(), fill) - {} - - //! 1D copy from raw pointer + count - Tensor(const T* ptr, size_t count) : shape_({count}), data_(ptr, ptr + count) - {} - - //! Copy from View (preserves view's shape) - template - explicit Tensor(const View& v) : shape_(v.shape_vec()) - { - size_t n = v.size(); - data_.resize(n); - for (size_t i = 0; i < n; ++i) - data_[i] = v[i]; - } - - //-------------------------------------------------------------------------- - // Assignment - - //! Assignment from View - template - Tensor& operator=(const View& v) - { - shape_ = v.shape_vec(); - size_t n = v.size(); - data_.resize(n); - for (size_t i = 0; i < n; ++i) - data_[i] = v[i]; - return *this; - } - - //! Assignment from initializer_list of values (1D) - Tensor& operator=(std::initializer_list vals) - { - shape_ = {vals.size()}; - data_.assign(vals.begin(), vals.end()); - return *this; - } - - //-------------------------------------------------------------------------- - // Accessors - - stored_type* data() { return data_.data(); } - const stored_type* data() const { return data_.data(); } - size_t size() const { return data_.size(); } - const vector& shape() const { return shape_; } - size_t shape(size_t dim) const - { - return dim < shape_.size() ? shape_[dim] : 0; - } - size_t ndim() const { return shape_.size(); } - bool empty() const { return data_.empty(); } - - //-------------------------------------------------------------------------- - // Indexing (row-major) - - template - stored_type& operator()(Indices... indices) - { - const size_t idx[] = {static_cast(indices)...}; - size_t off = 0; - for (size_t d = 0; d < sizeof...(Indices); ++d) - off = off * shape_[d] + idx[d]; - return data_[off]; - } - - template - const stored_type& operator()(Indices... indices) const - { - const size_t idx[] = {static_cast(indices)...}; - size_t off = 0; - for (size_t d = 0; d < sizeof...(Indices); ++d) - off = off * shape_[d] + idx[d]; - return data_[off]; - } - - stored_type& operator[](size_t i) { return data_[i]; } - const stored_type& operator[](size_t i) const { return data_[i]; } - - //! First and last element - stored_type& front() { return data_.front(); } - const stored_type& front() const { return data_.front(); } - stored_type& back() { return data_.back(); } - const stored_type& back() const { return data_.back(); } - - //-------------------------------------------------------------------------- - // Iterators - - iterator begin() { return data_.begin(); } - iterator end() { return data_.end(); } - const_iterator begin() const { return data_.begin(); } - const_iterator end() const { return data_.end(); } - const_iterator cbegin() const { return data_.cbegin(); } - const_iterator cend() const { return data_.cend(); } - - //-------------------------------------------------------------------------- - // Mutation - - void resize(const vector& shape) - { - shape_ = shape; - data_.resize(compute_size()); - } - - void resize(std::initializer_list shape) - { - shape_.assign(shape.begin(), shape.end()); - data_.resize(compute_size()); - } - - void reshape(const vector& new_shape) { shape_ = new_shape; } - - void fill(T val) { std::fill(data_.begin(), data_.end(), val); } - - //-------------------------------------------------------------------------- - // View accessors - - //! Fix one axis at a given index, returning an (N-1)-dimensional view - //! Multi-axis slice. Each argument corresponds to one axis and is either: - //! - an integer (fixes that axis, rank-reducing) - //! - All (keeps entire axis) - //! - Range (keeps sub-range along that axis) - //! Example: t.slice(0, all, range(2, 5)) == numpy t[0, :, 2:5] - template - View slice(First first, Rest... rest) - { - auto strides = compute_strides(); - auto r = detail::compute_slice(shape_, strides, first, rest...); - return { - data_.data() + r.ptr_offset, std::move(r.shape), std::move(r.strides)}; - } - - template - View slice(First first, Rest... rest) const - { - auto strides = compute_strides(); - auto r = detail::compute_slice(shape_, strides, first, rest...); - return { - data_.data() + r.ptr_offset, std::move(r.shape), std::move(r.strides)}; - } - - //! Flat 1D view of all elements - View flat() - { - return {data_.data(), {data_.size()}, {size_t(1)}}; - } - View flat() const - { - return {data_.data(), {data_.size()}, {size_t(1)}}; - } - - //-------------------------------------------------------------------------- - // Reductions and transforms - - //! Sum of all elements - T sum() const - { - T s = T(0); - for (size_t i = 0; i < data_.size(); ++i) - s += data_[i]; - return s; - } - - //! Sum along an axis, reducing rank by 1 (defined out-of-line below) - Tensor sum(size_t axis) const; - - //! Product of all elements - T prod() const - { - T p = T(1); - for (size_t i = 0; i < data_.size(); ++i) - p *= data_[i]; - return p; - } - - //! True if any element is nonzero - bool any() const - { - for (size_t i = 0; i < data_.size(); ++i) - if (data_[i]) - return true; - return false; - } - - //! True if all elements are nonzero - bool all() const - { - for (size_t i = 0; i < data_.size(); ++i) - if (!data_[i]) - return false; - return true; - } - - //! Flat index of the minimum element - size_t argmin() const - { - return static_cast(std::distance(data_.data(), - std::min_element(data_.data(), data_.data() + data_.size()))); - } - - //! Reverse element order along an axis (e.g. flip(0) reverses rows) - Tensor flip(size_t axis) const - { - size_t outer_size = 1; - for (size_t d = 0; d < axis; ++d) - outer_size *= shape_[d]; - size_t axis_size = shape_[axis]; - size_t inner_size = 1; - for (size_t d = axis + 1; d < shape_.size(); ++d) - inner_size *= shape_[d]; - - Tensor r(shape_); - for (size_t o = 0; o < outer_size; ++o) - for (size_t a = 0; a < axis_size; ++a) - for (size_t i = 0; i < inner_size; ++i) - r.data_[(o * axis_size + (axis_size - 1 - a)) * inner_size + i] = - data_[(o * axis_size + a) * inner_size + i]; - return r; - } - - //-------------------------------------------------------------------------- - // Operators - - Tensor& operator+=(T val) - { - for (auto& x : data_) - x += val; - return *this; - } - Tensor& operator-=(T val) - { - for (auto& x : data_) - x -= val; - return *this; - } - Tensor& operator*=(T val) - { - for (auto& x : data_) - x *= val; - return *this; - } - Tensor& operator/=(T val) - { - for (auto& x : data_) - x /= val; - return *this; - } - Tensor& operator+=(const Tensor& o) - { - for (size_t i = 0; i < data_.size(); ++i) - data_[i] += o.data_[i]; - return *this; - } - Tensor& operator-=(const Tensor& o) - { - for (size_t i = 0; i < data_.size(); ++i) - data_[i] -= o.data_[i]; - return *this; - } - Tensor& operator*=(const Tensor& o) - { - for (size_t i = 0; i < data_.size(); ++i) - data_[i] *= o.data_[i]; - return *this; - } - Tensor& operator/=(const Tensor& o) - { - for (size_t i = 0; i < data_.size(); ++i) - data_[i] /= o.data_[i]; - return *this; - } - - Tensor operator+(const Tensor& o) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] + o.data_[i]; - return r; - } - Tensor operator-(const Tensor& o) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] - o.data_[i]; - return r; - } - Tensor operator/(const Tensor& o) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] / o.data_[i]; - return r; - } - Tensor operator*(const Tensor& o) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] * o.data_[i]; - return r; - } - - Tensor operator+(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] + val; - return r; - } - Tensor operator-(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] - val; - return r; - } - Tensor operator*(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data_[i] = data_[i] * val; - return r; - } - - Tensor operator<=(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data()[i] = data_[i] <= val; - return r; - } - Tensor operator<(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data()[i] = data_[i] < val; - return r; - } - Tensor operator>=(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data()[i] = data_[i] >= val; - return r; - } - Tensor operator>(T val) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data()[i] = data_[i] > val; - return r; - } - Tensor operator<(const Tensor& o) const - { - Tensor r(shape_); - for (size_t i = 0; i < data_.size(); ++i) - r.data()[i] = data_[i] < o.data_[i]; - return r; - } - -private: - size_t compute_size() const - { - size_t s = 1; - for (auto d : shape_) - s *= d; - return s; - } - - //! Compute row-major strides from shape - vector compute_strides() const - { - vector strides(shape_.size()); - if (!shape_.empty()) { - strides.back() = 1; - for (int d = static_cast(shape_.size()) - 2; d >= 0; --d) - strides[d] = strides[d + 1] * shape_[d + 1]; - } - return strides; - } - - //-------------------------------------------------------------------------- - // Data members - - vector shape_; - vector> data_; -}; - -//============================================================================== -// Non-member operators (scalar op tensor) -//============================================================================== - -template -Tensor operator*(T val, const Tensor& arr) -{ - return arr * val; -} - -template -Tensor operator+(T val, const Tensor& arr) -{ - return arr + val; -} - -// Mixed-type arithmetic: Tensor op Tensor -> Tensor -// A SFINAE guard is used here, as without !is_same Tensor * Tensor -// would be ambiguous between the member operator* and this non-member function. -template::value>> -Tensor operator*(const Tensor& a, const Tensor& b) -{ - Tensor r(a.shape()); - for (size_t i = 0; i < a.size(); ++i) - r.data()[i] = - static_cast(a.data()[i]) * static_cast(b.data()[i]); - return r; -} - -// Same SFINAE guard as operator* above. -template::value>> -Tensor operator/(const Tensor& a, const Tensor& b) -{ - Tensor r(a.shape()); - for (size_t i = 0; i < a.size(); ++i) - r.data()[i] = - static_cast(a.data()[i]) / static_cast(b.data()[i]); - return r; -} - -//============================================================================== -// Out-of-line method definitions (require complete types) -//============================================================================== - -template -template -View& View::operator=(const Tensor& other) -{ - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] = static_cast(other.data()[i]); - return *this; -} - -template -template -View& View::operator+=(const Tensor& o) -{ - size_t n = size(); - for (size_t i = 0; i < n; ++i) - data_[flat_to_offset(i)] += o.data()[i]; - return *this; -} - -template -Tensor Tensor::sum(size_t axis) const -{ - // Build output shape (all dims except the summed axis) - vector out_shape; - for (size_t d = 0; d < shape_.size(); ++d) - if (d != axis) - out_shape.push_back(shape_[d]); - - // Split dimensions into three zones: outer | axis | inner - size_t outer_size = 1; - for (size_t d = 0; d < axis; ++d) - outer_size *= shape_[d]; - size_t axis_size = shape_[axis]; - size_t inner_size = 1; - for (size_t d = axis + 1; d < shape_.size(); ++d) - inner_size *= shape_[d]; - - Tensor result(out_shape, T(0)); - for (size_t o = 0; o < outer_size; ++o) - for (size_t a = 0; a < axis_size; ++a) - for (size_t i = 0; i < inner_size; ++i) - result.data()[o * inner_size + i] += - data_[(o * axis_size + a) * inner_size + i]; - - return result; -} - -//============================================================================== -// StaticTensor2D: compile-time fixed 2D tensor. -//============================================================================== - -template -class StaticTensor2D { -public: - using value_type = T; - - //-------------------------------------------------------------------------- - // Indexing - - //! Templated to accept enum class indices (e.g. GlobalTally, TallyResult) - //! which don't implicitly convert to integer types. - template - T& operator()(I0 i, I1 j) - { - return data_[static_cast(i) * C + static_cast(j)]; - } - template - const T& operator()(I0 i, I1 j) const - { - return data_[static_cast(i) * C + static_cast(j)]; - } - - //-------------------------------------------------------------------------- - // Accessors - - T* data() { return data_; } - const T* data() const { return data_; } - constexpr size_t size() const { return R * C; } - std::array shape() const { return {R, C}; } - - //-------------------------------------------------------------------------- - // Mutation - - void fill(T val) { std::fill(data_, data_ + R * C, val); } - - //-------------------------------------------------------------------------- - // Iterators - - T* begin() { return data_; } - T* end() { return data_ + R * C; } - const T* begin() const { return data_; } - const T* end() const { return data_ + R * C; } - - //-------------------------------------------------------------------------- - // View accessors - - //! Multi-axis slice (same interface as Tensor/View). - template - View slice(First first, Rest... rest) - { - vector sh = {R, C}; - vector st = {C, 1}; - auto r = detail::compute_slice(sh, st, first, rest...); - return {data_ + r.ptr_offset, std::move(r.shape), std::move(r.strides)}; - } - template - View slice(First first, Rest... rest) const - { - vector sh = {R, C}; - vector st = {C, 1}; - auto r = detail::compute_slice(sh, st, first, rest...); - return {data_ + r.ptr_offset, std::move(r.shape), std::move(r.strides)}; - } - - //! Flat view (1D, contiguous) - View flat() { return {data_, {R * C}, {size_t(1)}}; } - View flat() const { return {data_, {R * C}, {size_t(1)}}; } - -private: - //-------------------------------------------------------------------------- - // Data members - - T data_[R * C] = {}; -}; - -//============================================================================== -// Non-member functions -//============================================================================== - -template -Tensor zeros(std::initializer_list shape) -{ - vector s(shape); - return Tensor(std::move(s), T(0)); -} - -template -Tensor zeros(const vector& shape) -{ - return Tensor(shape, T(0)); -} - -template -Tensor ones(std::initializer_list shape) -{ - vector s(shape); - return Tensor(std::move(s), T(1)); -} - -template -Tensor ones(const vector& shape) -{ - return Tensor(shape, T(1)); -} - -template -Tensor zeros_like(const Tensor& o) -{ - return Tensor(o.shape(), T(0)); -} - -template -Tensor full_like(const Tensor& o, V val) -{ - return Tensor(o.shape(), static_cast(val)); -} - -//! Return a 1D tensor of n evenly spaced values from start to stop (inclusive) -template -Tensor linspace(T start, T stop, size_t n) -{ - Tensor result({n}); - if (n < 2) { - result[0] = start; - return result; - } - for (size_t i = 0; i < n; ++i) { - result[i] = - start + static_cast(i) * (stop - start) / static_cast(n - 1); - } - return result; -} - -//! Concatenate two 1D tensors end-to-end -template -Tensor concatenate(const Tensor& a, const Tensor& b) -{ - size_t total = a.size() + b.size(); - Tensor result({total}); - std::copy(a.data(), a.data() + a.size(), result.data()); - std::copy(b.data(), b.data() + b.size(), result.data() + a.size()); - return result; -} - -//! Element-wise natural logarithm -template -Tensor log(const Tensor& a) -{ - Tensor r(a.shape()); - for (size_t i = 0; i < a.size(); ++i) - r.data()[i] = std::log(a.data()[i]); - return r; -} - -//! Element-wise absolute value -template -Tensor abs(const Tensor& a) -{ - Tensor r(a.shape()); - for (size_t i = 0; i < a.size(); ++i) - r.data()[i] = std::abs(a.data()[i]); - return r; -} - -//! Element-wise conditional: select from true_val where cond is true, -//! otherwise use false_val -template -Tensor where( - const Tensor& cond, const Tensor& true_val, V false_val) -{ - Tensor r(cond.shape()); - for (size_t i = 0; i < cond.size(); ++i) - r.data()[i] = - cond.data()[i] ? true_val.data()[i] : static_cast(false_val); - return r; -} - -//! Replace NaN/Inf values with finite substitutes -template -Tensor nan_to_num(const Tensor& a, T nan_val = T(0), - T posinf_val = std::numeric_limits::max(), - T neginf_val = std::numeric_limits::lowest()) -{ - Tensor r(a.shape()); - for (size_t i = 0; i < a.size(); ++i) { - T val = a.data()[i]; - if (std::isnan(val)) - r.data()[i] = nan_val; - else if (std::isinf(val)) - r.data()[i] = val > 0 ? posinf_val : neginf_val; - else - r.data()[i] = val; - } - return r; -} - -//============================================================================== -// Type traits -//============================================================================== - -//! Type trait that is true for Tensor and StaticTensor2D. -//! Used by hdf5_interface.h to select the correct write_dataset overload. -template -struct is_tensor : std::false_type {}; - -template -struct is_tensor> : std::true_type {}; - -template -struct is_tensor> : std::true_type {}; - -} // namespace tensor -} // namespace openmc - -#endif // OPENMC_TENSOR_H diff --git a/include/openmc/thermal.h b/include/openmc/thermal.h index c06a2ee0d..de0767d0a 100644 --- a/include/openmc/thermal.h +++ b/include/openmc/thermal.h @@ -5,7 +5,7 @@ #include #include -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/angle_energy.h" #include "openmc/endf.h" @@ -51,25 +51,7 @@ public: //! \param[out] mu Outgoing scattering angle cosine //! \param[inout] seed Pseudorandom seed pointer void sample(const NuclideMicroXS& micro_xs, double E_in, double* E_out, - double* mu, uint64_t* seed) const; - - //! Select the elastic or inelastic distribution to sample - //! \param[in] micro_xs Microscopic cross sections - //! \param[in] E Incident neutron energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Reference to the selected angle-energy distribution - AngleEnergy& sample_dist( - const NuclideMicroXS& micro_xs, double E, uint64_t* seed) const; - - //! Sample an outgoing energy and evaluate the angular PDF - //! \param[in] micro_xs Microscopic cross sections - //! \param[in] E_in Incoming energy in [eV] - //! \param[in] mu Scattering cosine with respect to current direction - //! \param[out] E_out Outgoing energy in [eV] - //! \param[inout] seed Pseudorandom seed pointer - //! \return Probability density for the scattering cosine - double sample_energy_and_pdf(const NuclideMicroXS& micro_xs, double E_in, - double mu, double& E_out, uint64_t* seed) const; + double* mu, uint64_t* seed); private: struct Reaction { diff --git a/include/openmc/universe.h b/include/openmc/universe.h index b7450224f..26f33cb38 100644 --- a/include/openmc/universe.h +++ b/include/openmc/universe.h @@ -1,12 +1,11 @@ #ifndef OPENMC_UNIVERSE_H #define OPENMC_UNIVERSE_H -#include "openmc/bounding_box.h" #include "openmc/cell.h" namespace openmc { -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC class DAGUniverse; #endif @@ -29,7 +28,6 @@ class Universe { public: int32_t id_; //!< Unique ID vector cells_; //!< Cells within this universe - int32_t n_instances_; //!< Number of instances of this universe //! \brief Write universe information to an HDF5 group. //! \param group_id An HDF5 group id. @@ -39,13 +37,13 @@ public: BoundingBox bounding_box() const; - /* By default, universes are CSG universes. The DAGMC - * universe overrides standard behaviors, and in the future, - * other things might too. - */ - virtual GeometryType geom_type() const { return GeometryType::CSG; } + const GeometryType& geom_type() const { return geom_type_; } + GeometryType& geom_type() { return geom_type_; } unique_ptr partitioner_; + +private: + GeometryType geom_type_ = GeometryType::CSG; }; //============================================================================== diff --git a/include/openmc/urr.h b/include/openmc/urr.h index d40c2aff7..3978c7b86 100644 --- a/include/openmc/urr.h +++ b/include/openmc/urr.h @@ -3,7 +3,7 @@ #ifndef OPENMC_URR_H #define OPENMC_URR_H -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/constants.h" #include "openmc/hdf5_interface.h" @@ -27,10 +27,10 @@ public: double heating; }; - Interpolation interp_; //!< interpolation type - int inelastic_flag_; //!< inelastic competition flag - int absorption_flag_; //!< other absorption flag - bool multiply_smooth_; //!< multiply by smooth cross section? + Interpolation interp_; //!< interpolation type + int inelastic_flag_; //!< inelastic competition flag + int absorption_flag_; //!< other absorption flag + bool multiply_smooth_; //!< multiply by smooth cross section? vector energy_; //!< incident energies auto n_energy() const { return energy_.size(); } @@ -40,11 +40,11 @@ public: * below, obviously, values of the CDF are stored. For the xs_values * variable, the columns line up with the index of cdf_values. */ - tensor::Tensor cdf_values_; // Note: must be row major! - tensor::Tensor xs_values_; + xt::xtensor cdf_values_; // Note: must be row major! + xt::xtensor xs_values_; // Number of points in the CDF - auto n_cdf() const { return cdf_values_.shape(1); } + auto n_cdf() const { return cdf_values_.shape()[1]; } //! \brief Load the URR data from the provided HDF5 group explicit UrrData(hid_t group_id); diff --git a/include/openmc/version.h.in b/include/openmc/version.h.in index 6dfc7c7dd..a518e0d63 100644 --- a/include/openmc/version.h.in +++ b/include/openmc/version.h.in @@ -9,10 +9,8 @@ namespace openmc { // clang-format off constexpr int VERSION_MAJOR {@OPENMC_VERSION_MAJOR@}; constexpr int VERSION_MINOR {@OPENMC_VERSION_MINOR@}; -constexpr int VERSION_RELEASE {@OPENMC_VERSION_PATCH@}; -constexpr bool VERSION_DEV {@OPENMC_DEV_STATE@}; -constexpr const char* VERSION_COMMIT_COUNT = "@OPENMC_COMMIT_COUNT@"; -constexpr const char* VERSION_COMMIT_HASH = "@OPENMC_COMMIT_HASH@"; +constexpr int VERSION_RELEASE {@OPENMC_VERSION_RELEASE@}; +constexpr bool VERSION_DEV {false}; constexpr std::array VERSION {VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE}; // clang-format on diff --git a/include/openmc/volume_calc.h b/include/openmc/volume_calc.h index ef75ec065..376b8c707 100644 --- a/include/openmc/volume_calc.h +++ b/include/openmc/volume_calc.h @@ -12,8 +12,9 @@ #include "openmc/tallies/trigger.h" #include "openmc/vector.h" -#include "openmc/tensor.h" #include "pugixml.hpp" +#include "xtensor/xtensor.hpp" +#include #ifdef _OPENMP #include #endif @@ -34,7 +35,7 @@ public: vector atoms; //!< Number of atoms for each nuclide vector uncertainty; //!< Uncertainty on number of atoms int iterations; //!< Number of iterations needed to obtain the results - }; // Results for a single domain + }; // Results for a single domain // Constructors VolumeCalculation(pugi::xml_node node); diff --git a/include/openmc/weight_windows.h b/include/openmc/weight_windows.h index d0b385d16..9852fe679 100644 --- a/include/openmc/weight_windows.h +++ b/include/openmc/weight_windows.h @@ -4,20 +4,22 @@ #include #include +#include #include #include #include "openmc/constants.h" #include "openmc/memory.h" #include "openmc/mesh.h" -#include "openmc/particle_type.h" -#include "openmc/span.h" +#include "openmc/particle.h" #include "openmc/tallies/tally.h" #include "openmc/vector.h" namespace openmc { -enum class WeightWindowUpdateMethod { MAGIC, FW_CADIS }; +enum class WeightWindowUpdateMethod { + MAGIC, +}; //============================================================================== // Constants @@ -25,6 +27,17 @@ enum class WeightWindowUpdateMethod { MAGIC, FW_CADIS }; constexpr double DEFAULT_WEIGHT_CUTOFF {1.0e-38}; // default low weight cutoff +//============================================================================== +// Non-member functions +//============================================================================== + +//! Apply weight windows to a particle +//! \param[in] p Particle to apply weight windows to +void apply_weight_windows(Particle& p); + +//! Free memory associated with weight windows +void free_memory_weight_windows(); + //============================================================================== // Global variables //============================================================================== @@ -52,19 +65,14 @@ struct WeightWindow { double weight_cutoff {DEFAULT_WEIGHT_CUTOFF}; int max_split {10}; - //! Whether the weight window is in a valid state. A non-positive lower - //! bound indicates that no weight window information exists at this - //! location (generators mark such cells with -1, and a lower bound of zero - //! conventionally turns the weight window game off in a cell, as in MCNP - //! wwinp files), in which case no weight window game is played. - bool is_valid() const { return lower_weight > 0.0; } + //! Whether the weight window is in a valid state + bool is_valid() const { return lower_weight >= 0.0; } //! Adjust the weight window by a constant factor void scale(double factor) { lower_weight *= factor; upper_weight *= factor; - survival_weight *= factor; } }; @@ -98,7 +106,7 @@ public: //! Set the weight window ID void set_id(int32_t id = -1); - void set_energy_bounds(span bounds); + void set_energy_bounds(gsl::span bounds); void set_mesh(const std::unique_ptr& mesh); @@ -119,9 +127,8 @@ public: //! \param[in] threshold Relative error threshold. Results over this //! threshold will be ignored \param[in] ratio Ratio of upper to lower //! weight window bounds - void update_weights(const Tally* tally, const std::string& value = "mean", - double threshold = 1.0, double ratio = 5.0, - WeightWindowUpdateMethod method = WeightWindowUpdateMethod::MAGIC); + void update_magic(const Tally* tally, const std::string& value = "mean", + double threshold = 1.0, double ratio = 5.0); // NOTE: This is unused for now but may be used in the future //! Write weight window settings to an HDF5 file @@ -130,21 +137,21 @@ public: //! Retrieve the weight window for a particle //! \param[in] p Particle to get weight window for - std::pair get_weight_window(const Particle& p) const; + WeightWindow get_weight_window(const Particle& p) const; std::array bounds_size() const; const vector& energy_bounds() const { return energy_bounds_; } - void set_bounds(const tensor::Tensor& lower_ww_bounds, - const tensor::Tensor& upper_bounds); + void set_bounds(const xt::xtensor& lower_ww_bounds, + const xt::xtensor& upper_bounds); - void set_bounds(const tensor::Tensor& lower_bounds, double ratio); + void set_bounds(const xt::xtensor& lower_bounds, double ratio); void set_bounds( - span lower_bounds, span upper_bounds); + gsl::span lower_bounds, gsl::span upper_bounds); - void set_bounds(span lower_bounds, double ratio); + void set_bounds(gsl::span lower_bounds, double ratio); void set_particle_type(ParticleType p_type); @@ -175,24 +182,25 @@ public: const std::unique_ptr& mesh() const { return model::meshes[mesh_idx_]; } - const tensor::Tensor& lower_ww_bounds() const { return lower_ww_; } - tensor::Tensor& lower_ww_bounds() { return lower_ww_; } + const xt::xtensor& lower_ww_bounds() const { return lower_ww_; } + xt::xtensor& lower_ww_bounds() { return lower_ww_; } - const tensor::Tensor& upper_ww_bounds() const { return upper_ww_; } - tensor::Tensor& upper_ww_bounds() { return upper_ww_; } + const xt::xtensor& upper_ww_bounds() const { return upper_ww_; } + xt::xtensor& upper_ww_bounds() { return upper_ww_; } ParticleType particle_type() const { return particle_type_; } private: //---------------------------------------------------------------------------- // Data members - int32_t id_; //!< Unique ID - int64_t index_; //!< Index into weight windows vector - ParticleType particle_type_; //!< Particle type to apply weight windows to + int32_t id_; //!< Unique ID + gsl::index index_; //!< Index into weight windows vector + ParticleType particle_type_ { + ParticleType::neutron}; //!< Particle type to apply weight windows to vector energy_bounds_; //!< Energy boundaries [eV] - tensor::Tensor lower_ww_; //!< Lower weight window bounds (shape: + xt::xtensor lower_ww_; //!< Lower weight window bounds (shape: //!< energy_bins, mesh_bins (k, j, i)) - tensor::Tensor + xt::xtensor upper_ww_; //!< Upper weight window bounds (shape: energy_bins, mesh_bins) double survival_ratio_ {3.0}; //!< Survival weight ratio double max_lb_ratio_ {1.0}; //!< Maximum lower bound to particle weight ratio @@ -213,11 +221,12 @@ public: void create_tally(); // Data members - int32_t tally_idx_; //!< Index of the tally used to update the weight windows - int32_t ww_idx_; //!< Index of the weight windows object being generated - WeightWindowUpdateMethod method_; //!< Method used to update weight window. - int32_t max_realizations_; //!< Maximum number of tally realizations - int32_t update_interval_; //!< Determines how often updates occur + int32_t tally_idx_; //!< Index of the tally used to update the weight windows + int32_t ww_idx_; //!< Index of the weight windows object being generated + std::string method_; //!< Method used to update weight window. Only "magic" + //!< is valid for now. + int32_t max_realizations_; //!< Maximum number of tally realizations + int32_t update_interval_; //!< Determines how often updates occur bool on_the_fly_; //!< Whether or not to keep tally results between batches or //!< realizations @@ -227,31 +236,8 @@ public: double threshold_ {1.0}; // targets_; }; -//============================================================================== -// Non-member functions -//============================================================================== - -//! Apply weight windows to a particle -//! \param[in] p Particle to apply weight windows to -void apply_weight_windows(Particle& p); - -//! Apply weight window to a particle -//! \param[in] p Particle to apply weight window to -//! \param[in] weight_window WeightWindow to apply -void apply_weight_window(Particle& p, WeightWindow weight_window); - -//! Free memory associated with weight windows -void free_memory_weight_windows(); - -//! Search weight window that apply to a particle -//! \param[in] p Particle to search weight window for -std::pair search_weight_window(const Particle& p); - //! Finalize variance reduction objects after all inputs have been read void finalize_variance_reduction(); diff --git a/include/openmc/wmp.h b/include/openmc/wmp.h index 5cc04e595..6a4abd867 100644 --- a/include/openmc/wmp.h +++ b/include/openmc/wmp.h @@ -2,7 +2,7 @@ #define OPENMC_WMP_H #include "hdf5.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include #include @@ -78,9 +78,9 @@ public: int fit_order_; //!< Order of the fit bool fissionable_; //!< Is the nuclide fissionable? vector window_info_; // Information about a window - tensor::Tensor + xt::xtensor curvefit_; // Curve fit coefficients (window, poly order, reaction) - tensor::Tensor> data_; //!< Poles and residues + xt::xtensor, 2> data_; //!< Poles and residues // Constant data static constexpr int MAX_POLY_COEFFICIENTS = diff --git a/include/openmc/xml_interface.h b/include/openmc/xml_interface.h index 17a34e5c7..bd6554c13 100644 --- a/include/openmc/xml_interface.h +++ b/include/openmc/xml_interface.h @@ -5,8 +5,9 @@ #include // for stringstream #include -#include "openmc/tensor.h" #include "pugixml.hpp" +#include "xtensor/xadapt.hpp" +#include "xtensor/xarray.hpp" #include "openmc/position.h" #include "openmc/vector.h" @@ -41,16 +42,14 @@ vector get_node_array( } template -tensor::Tensor get_node_tensor( +xt::xarray get_node_xarray( pugi::xml_node node, const char* name, bool lowercase = false) { vector v = get_node_array(node, name, lowercase); - return tensor::Tensor(v.data(), v.size()); + vector shape = {v.size()}; + return xt::adapt(v, shape); } -std::vector get_node_position_array( - pugi::xml_node node, const char* name, bool lowercase = false); - Position get_node_position( pugi::xml_node node, const char* name, bool lowercase = false); diff --git a/include/openmc/xsdata.h b/include/openmc/xsdata.h index c9dbde986..feafde68d 100644 --- a/include/openmc/xsdata.h +++ b/include/openmc/xsdata.h @@ -4,7 +4,7 @@ #ifndef OPENMC_XSDATA_H #define OPENMC_XSDATA_H -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/hdf5_interface.h" #include "openmc/memory.h" @@ -69,26 +69,26 @@ private: public: // The following quantities have the following dimensions: // [angle][incoming group] - tensor::Tensor total; - tensor::Tensor absorption; - tensor::Tensor nu_fission; - tensor::Tensor prompt_nu_fission; - tensor::Tensor kappa_fission; - tensor::Tensor fission; - tensor::Tensor inverse_velocity; + xt::xtensor total; + xt::xtensor absorption; + xt::xtensor nu_fission; + xt::xtensor prompt_nu_fission; + xt::xtensor kappa_fission; + xt::xtensor fission; + xt::xtensor inverse_velocity; // decay_rate has the following dimensions: // [angle][delayed group] - tensor::Tensor decay_rate; + xt::xtensor decay_rate; // delayed_nu_fission has the following dimensions: // [angle][delayed group][incoming group] - tensor::Tensor delayed_nu_fission; + xt::xtensor delayed_nu_fission; // chi_prompt has the following dimensions: // [angle][incoming group][outgoing group] - tensor::Tensor chi_prompt; + xt::xtensor chi_prompt; // chi_delayed has the following dimensions: // [angle][incoming group][outgoing group][delayed group] - tensor::Tensor chi_delayed; + xt::xtensor chi_delayed; // scatter has the following dimensions: [angle] vector> scatter; diff --git a/man/man1/openmc.1 b/man/man1/openmc.1 index 3205b4340..d121a8956 100644 --- a/man/man1/openmc.1 +++ b/man/man1/openmc.1 @@ -39,9 +39,6 @@ Use \fIN\fP OpenMP threads. .B "\-t\fR, \fP\-\-track" Write tracks for all particles (up to max_tracks). .TP -.BI \-q " V" "\fR,\fP \-\-verbosity" " V" -Set the output verbosity to \fIV\fP. -.TP .B "\-v\fR, \fP\-\-version" Show version information. .TP @@ -66,7 +63,7 @@ Indicates the default path to an HDF5 file that contains multi-group cross section libraries if the user has not specified the tag in .I materials.xml\fP. .SH LICENSE -Copyright \(co 2011-2026 Massachusetts Institute of Technology, UChicago +Copyright \(co 2011-2024 Massachusetts Institute of Technology, UChicago Argonne LLC, and OpenMC contributors. .PP Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/openmc/__init__.py b/openmc/__init__.py index c204929c8..12a3c87d3 100644 --- a/openmc/__init__.py +++ b/openmc/__init__.py @@ -1,4 +1,3 @@ -import importlib.metadata from openmc.arithmetic import * from openmc.bounding_box import * from openmc.cell import * @@ -15,7 +14,6 @@ from openmc.volume import * from openmc.weight_windows import * from openmc.surface import * from openmc.universe import * -from openmc.dagmc import * from openmc.source import * from openmc.settings import * from openmc.lattice import * @@ -34,12 +32,11 @@ from openmc.plotter import * from openmc.search import * from openmc.polynomial import * from openmc.tracks import * +from . import examples from .config import * # Import a few names from the model module -from openmc.model import Model, SearchResult - -from . import examples +from openmc.model import Model -__version__ = importlib.metadata.version("openmc") +__version__ = '0.15.0' diff --git a/openmc/_sparse_compat.py b/openmc/_sparse_compat.py deleted file mode 100644 index c00777e19..000000000 --- a/openmc/_sparse_compat.py +++ /dev/null @@ -1,43 +0,0 @@ -"""Compatibility module for scipy.sparse arrays - -This module provides a compatibility layer for working with scipy.sparse arrays -across different scipy versions. Sparse arrays were introduced gradually in -scipy, with full support arriving in scipy 1.15. This module provides a unified -API that uses sparse arrays when available and falls back to sparse matrices for -older scipy versions. - -For more information on the migration from sparse matrices to sparse arrays, -see: https://docs.scipy.org/doc/scipy/reference/sparse.migration_to_sparray.html -""" - -import scipy -from scipy import sparse as sp - -# Check scipy version for feature availability -_SCIPY_VERSION = tuple(map(int, scipy.__version__.split('.')[:2])) - -if _SCIPY_VERSION >= (1, 15): - # Use sparse arrays - csr_array = sp.csr_array - csc_array = sp.csc_array - dok_array = sp.dok_array - lil_array = sp.lil_array - eye_array = sp.eye_array - block_array = sp.block_array -else: - # Fall back to sparse matrices - csr_array = sp.csr_matrix - csc_array = sp.csc_matrix - dok_array = sp.dok_matrix - lil_array = sp.lil_matrix - eye_array = sp.eye - block_array = sp.bmat - -__all__ = [ - 'csr_array', - 'csc_array', - 'dok_array', - 'lil_array', - 'eye_array', - 'block_array', -] diff --git a/openmc/_xml.py b/openmc/_xml.py index 758d80525..b40ecb258 100644 --- a/openmc/_xml.py +++ b/openmc/_xml.py @@ -63,9 +63,26 @@ def get_text(elem, name, default=None): return child.text if child is not None else default +def reorder_attributes(root): + """Sort attributes in XML to preserve pre-Python 3.8 behavior -def get_elem_list(elem, name, dtype=int): - """Helper function to get a list of values from an elem + Parameters + ---------- + root : lxml.etree._Element + Root element + + """ + for el in root.iter(): + attrib = el.attrib + if len(attrib) > 1: + # adjust attribute order, e.g. by sorting + attribs = sorted(attrib.items()) + attrib.clear() + attrib.update(attribs) + + +def get_elem_tuple(elem, name, dtype=int): + '''Helper function to get a tuple of values from an elem Parameters ---------- @@ -78,9 +95,9 @@ def get_elem_list(elem, name, dtype=int): Returns ------- - list of dtype - Data read from the list - """ - text = get_text(elem, name) - if text is not None: - return [dtype(x) for x in text.split()] + tuple of dtype + Data read from the tuple + ''' + subelem = elem.find(name) + if subelem is not None: + return tuple([dtype(x) for x in subelem.text.split()]) diff --git a/openmc/arithmetic.py b/openmc/arithmetic.py index 92c42284c..821014e36 100644 --- a/openmc/arithmetic.py +++ b/openmc/arithmetic.py @@ -93,9 +93,9 @@ class CrossNuclide: Parameters ---------- - left_nuclide : str or CrossNuclide + left_nuclide : openmc.Nuclide or CrossNuclide The left nuclide in the outer product - right_nuclide : str or CrossNuclide + right_nuclide : openmc.Nuclide or CrossNuclide The right nuclide in the outer product binary_op : str The tally arithmetic binary operator (e.g., '+', '-', etc.) used to @@ -103,9 +103,9 @@ class CrossNuclide: Attributes ---------- - left_nuclide : str or CrossNuclide + left_nuclide : openmc.Nuclide or CrossNuclide The left nuclide in the outer product - right_nuclide : str or CrossNuclide + right_nuclide : openmc.Nuclide or CrossNuclide The right nuclide in the outer product binary_op : str The tally arithmetic binary operator (e.g., '+', '-', etc.) used to @@ -134,7 +134,7 @@ class CrossNuclide: @left_nuclide.setter def left_nuclide(self, left_nuclide): cv.check_type('left_nuclide', left_nuclide, - (str, CrossNuclide, AggregateNuclide)) + (openmc.Nuclide, CrossNuclide, AggregateNuclide)) self._left_nuclide = left_nuclide @property @@ -144,7 +144,7 @@ class CrossNuclide: @right_nuclide.setter def right_nuclide(self, right_nuclide): cv.check_type('right_nuclide', right_nuclide, - (str, CrossNuclide, AggregateNuclide)) + (openmc.Nuclide, CrossNuclide, AggregateNuclide)) self._right_nuclide = right_nuclide @property @@ -159,7 +159,26 @@ class CrossNuclide: @property def name(self): - return f'({self.left_nuclide} {self.binary_op} {self.right_nuclide})' + + string = '' + + # If the Summary was linked, the left nuclide is a Nuclide object + if isinstance(self.left_nuclide, openmc.Nuclide): + string += '(' + self.left_nuclide.name + # If the Summary was not linked, the left nuclide is the ZAID + else: + string += '(' + str(self.left_nuclide) + + string += ' ' + self.binary_op + ' ' + + # If the Summary was linked, the right nuclide is a Nuclide object + if isinstance(self.right_nuclide, openmc.Nuclide): + string += self.right_nuclide.name + ')' + # If the Summary was not linked, the right nuclide is the ZAID + else: + string += str(self.right_nuclide) + ')' + + return string class CrossFilter: @@ -421,7 +440,7 @@ class AggregateNuclide: Parameters ---------- - nuclides : Iterable of str or CrossNuclide + nuclides : Iterable of str or openmc.Nuclide or CrossNuclide The nuclides included in the aggregation aggregate_op : str The tally aggregation operator (e.g., 'sum', 'avg', etc.) used @@ -429,7 +448,7 @@ class AggregateNuclide: Attributes ---------- - nuclides : Iterable of str or CrossNuclide + nuclides : Iterable of str or openmc.Nuclide or CrossNuclide The nuclides included in the aggregation aggregate_op : str The tally aggregation operator (e.g., 'sum', 'avg', etc.) used @@ -454,7 +473,13 @@ class AggregateNuclide: return str(other) == str(self) def __repr__(self): - return f'{self.aggregate_op}{self.name}' + + # Append each nuclide in the aggregate to the string + string = f'{self.aggregate_op}(' + names = [nuclide.name if isinstance(nuclide, openmc.Nuclide) + else str(nuclide) for nuclide in self.nuclides] + string += ', '.join(map(str, names)) + ')' + return string @property def nuclides(self): @@ -477,9 +502,12 @@ class AggregateNuclide: @property def name(self): + # Append each nuclide in the aggregate to the string - names = [str(nuclide) for nuclide in self.nuclides] - return '(' + ', '.join(map(str, names)) + ')' + names = [nuclide.name if isinstance(nuclide, openmc.Nuclide) + else str(nuclide) for nuclide in self.nuclides] + string = '(' + ', '.join(map(str, names)) + ')' + return string class AggregateFilter: diff --git a/openmc/bounding_box.py b/openmc/bounding_box.py index f0dc06a4a..6e58ca8ba 100644 --- a/openmc/bounding_box.py +++ b/openmc/bounding_box.py @@ -1,5 +1,5 @@ from __future__ import annotations -from collections.abc import Iterable +from typing import Iterable import numpy as np @@ -42,8 +42,7 @@ class BoundingBox: def __repr__(self) -> str: return "BoundingBox(lower_left={}, upper_right={})".format( - tuple(float(x) for x in self.lower_left), - tuple(float(x) for x in self.upper_right)) + tuple(self.lower_left), tuple(self.upper_right)) def __getitem__(self, key) -> np.ndarray: return self._bounds[key] diff --git a/openmc/cell.py b/openmc/cell.py index 499cf9504..fe3939bbe 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -8,9 +8,8 @@ from uncertainties import UFloat import openmc import openmc.checkvalue as cv -from ._xml import get_elem_list, get_text +from ._xml import get_text from .mixin import IDManagerMixin -from .plots import add_plot_params from .region import Region, Complement from .surface import Halfspace from .bounding_box import BoundingBox @@ -72,10 +71,6 @@ class Cell(IDManagerMixin): temperature : float or iterable of float Temperature of the cell in Kelvin. Multiple temperatures can be given to give each distributed cell instance a unique temperature. - density : float or iterable of float - Density of the cell in [g/cm3]. Multiple densities can be given to give - each distributed cell instance a unique density. Densities set here will - override the density set on materials used to fill the cell. translation : Iterable of float If the cell is filled with a universe, this array specifies a vector that is used to translate (shift) the universe. @@ -113,7 +108,6 @@ class Cell(IDManagerMixin): self._rotation = None self._rotation_matrix = None self._temperature = None - self._density = None self._translation = None self._paths = None self._num_instances = None @@ -146,7 +140,6 @@ class Cell(IDManagerMixin): if self.fill_type == 'material': string += '\t{0: <15}=\t{1}\n'.format('Temperature', self.temperature) - string += '\t{0: <15}=\t{1}\n'.format('Density', self.density) string += '{: <16}=\t{}\n'.format('\tTranslation', self.translation) string += '{: <16}=\t{}\n'.format('\tVolume', self.volume) @@ -263,30 +256,6 @@ class Cell(IDManagerMixin): else: self._temperature = temperature - @property - def density(self): - return self._density - - @density.setter - def density(self, density): - # Make sure densities are greater than zero - cv.check_type('cell density', density, (Iterable, Real), none_ok=True) - if isinstance(density, Iterable): - cv.check_type('cell density', density, Iterable, Real) - for rho in density: - cv.check_greater_than('cell density', rho, 0.0, True) - elif isinstance(density, Real): - cv.check_greater_than('cell density', density, 0.0, True) - - # If this cell is filled with a universe or lattice, propagate - # densities to all cells contained. Otherwise, simply assign it. - if self.fill_type in ('universe', 'lattice'): - for c in self.get_all_cells().values(): - if c.fill_type == 'material': - c._density = density - else: - self._density = density - @property def translation(self): return self._translation @@ -434,8 +403,9 @@ class Cell(IDManagerMixin): if self._atoms is not None: volume = self.volume for name, atoms in self._atoms.items(): + nuclide = openmc.Nuclide(name) density = 1.0e-24 * atoms.n/volume # density in atoms/b-cm - nuclides[name] = (name, density) + nuclides[name] = (nuclide, density) else: raise RuntimeError( 'Volume information is needed to calculate microscopic ' @@ -555,8 +525,6 @@ class Cell(IDManagerMixin): clone.volume = self.volume if self.temperature is not None: clone.temperature = self.temperature - if self.density is not None: - clone.density = self.density if self.translation is not None: clone.translation = self.translation if self.rotation is not None: @@ -592,17 +560,70 @@ class Cell(IDManagerMixin): return memo[self] - @add_plot_params def plot(self, *args, **kwargs): """Display a slice plot of the cell. .. versionadded:: 0.14.0 + + Parameters + ---------- + origin : iterable of float + Coordinates at the origin of the plot. If left as None then the + bounding box center will be used to attempt to ascertain the origin. + Defaults to (0, 0, 0) if the bounding box is not finite + width : iterable of float + Width of the plot in each basis direction. If left as none then the + bounding box width will be used to attempt to ascertain the plot + width. Defaults to (10, 10) if the bounding box is not finite + pixels : Iterable of int or int + If iterable of ints provided, then this directly sets the number of + pixels to use in each basis direction. If int provided, then this + sets the total number of pixels in the plot and the number of pixels + in each basis direction is calculated from this total and the image + aspect ratio. + basis : {'xy', 'xz', 'yz'} + The basis directions for the plot + color_by : {'cell', 'material'} + Indicate whether the plot should be colored by cell or by material + colors : dict + Assigns colors to specific materials or cells. Keys are instances of + :class:`Cell` or :class:`Material` and values are RGB 3-tuples, RGBA + 4-tuples, or strings indicating SVG color names. Red, green, blue, + and alpha should all be floats in the range [0.0, 1.0], for example: + + .. code-block:: python + + # Make water blue + water = openmc.Cell(fill=h2o) + water.plot(colors={water: (0., 0., 1.)}) + seed : int + Seed for the random number generator + openmc_exec : str + Path to OpenMC executable. + axes : matplotlib.Axes + Axes to draw to + legend : bool + Whether a legend showing material or cell names should be drawn + legend_kwargs : dict + Keyword arguments passed to :func:`matplotlib.pyplot.legend`. + outline : bool + Whether outlines between color boundaries should be drawn + axis_units : {'km', 'm', 'cm', 'mm'} + Units used on the plot axis + **kwargs + Keyword arguments passed to :func:`matplotlib.pyplot.imshow` + + Returns + ------- + matplotlib.axes.Axes + Axes containing resulting image + """ # Create dummy universe but preserve used_ids - next_id = openmc.UniverseBase.next_id + next_id = openmc.Universe.next_id u = openmc.Universe(cells=[self]) - openmc.UniverseBase.used_ids.remove(u.id) - openmc.UniverseBase.next_id = next_id + openmc.Universe.used_ids.remove(u.id) + openmc.Universe.next_id = next_id return u.plot(*args, **kwargs) def create_xml_subelement(self, xml_element, memo=None): @@ -636,11 +657,8 @@ class Cell(IDManagerMixin): element.set("material", str(self.fill.id)) elif self.fill_type == 'distribmat': - material_subelement= ET.SubElement(element, "material") - matlist_str = " ".join( - ["void" if m is None else str(m.id) for m in self.fill] - ) - material_subelement.text = matlist_str + element.set("material", ' '.join(['void' if m is None else str(m.id) + for m in self.fill])) elif self.fill_type in ('universe', 'lattice'): element.set("fill", str(self.fill.id)) @@ -680,18 +698,11 @@ class Cell(IDManagerMixin): if self.temperature is not None: if isinstance(self.temperature, Iterable): - temperature_subelement= ET.SubElement(element, "temperature") - temperature_subelement.text = ' '.join(str(t) for t in self.temperature) + element.set("temperature", ' '.join( + str(t) for t in self.temperature)) else: element.set("temperature", str(self.temperature)) - if self.density is not None: - if isinstance(self.density, Iterable): - density_subelement= ET.SubElement(element, "density") - density_subelement.text = ' '.join(str(d) for d in self.density) - else: - element.set("density", str(self.density)) - if self.translation is not None: element.set("translation", ' '.join(map(str, self.translation))) @@ -731,8 +742,9 @@ class Cell(IDManagerMixin): c = cls(cell_id, name) # Assign material/distributed materials or fill - mat_ids = get_elem_list(elem, 'material', str) - if mat_ids is not None: + mat_text = get_text(elem, 'material') + if mat_text is not None: + mat_ids = mat_text.split() if len(mat_ids) > 1: c.fill = [materials[i] for i in mat_ids] else: @@ -747,16 +759,21 @@ class Cell(IDManagerMixin): c.region = Region.from_expression(region, surfaces) # Check for other attributes + t = get_text(elem, 'temperature') + if t is not None: + if ' ' in t: + c.temperature = [float(t_i) for t_i in t.split()] + else: + c.temperature = float(t) v = get_text(elem, 'volume') if v is not None: c.volume = float(v) - for key in ('temperature', 'density', 'rotation', 'translation'): - values = get_elem_list(elem, key, float) - if values is not None: + for key in ('temperature', 'rotation', 'translation'): + value = get_text(elem, key) + if value is not None: + values = [float(x) for x in value.split()] if key == 'rotation' and len(values) == 9: values = np.array(values).reshape(3, 3) - elif len(values) == 1: - values = values[0] setattr(c, key, values) # Add this cell to appropriate universe diff --git a/openmc/checkvalue.py b/openmc/checkvalue.py index 5ff2cf9ac..42df3e5ef 100644 --- a/openmc/checkvalue.py +++ b/openmc/checkvalue.py @@ -1,11 +1,12 @@ import copy import os +import typing # required to prevent typing.Union namespace overwriting Union from collections.abc import Iterable import numpy as np # Type for arguments that accept file paths -PathLike = str | os.PathLike +PathLike = typing.Union[str, os.PathLike] def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=False): @@ -37,7 +38,7 @@ def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=F [t.__name__ for t in expected_type])) else: msg = (f'Unable to set "{name}" to "{value}" which is not of type "' - f'{expected_type}"') + f'{expected_type.__name__}"') raise TypeError(msg) if expected_iter_type: diff --git a/openmc/cmfd.py b/openmc/cmfd.py index 8595d1e02..eff6a151f 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -25,7 +25,6 @@ import openmc.lib from .checkvalue import (check_type, check_length, check_value, check_greater_than, check_less_than) from .exceptions import OpenMCError -from ._sparse_compat import csr_array # See if mpi4py module can be imported, define have_mpi global variable try: @@ -981,7 +980,8 @@ class CMFDRun: loss_row = self._loss_row loss_col = self._loss_col temp_data = np.ones(len(loss_row)) - temp_loss = csr_array((temp_data, (loss_row, loss_col)), shape=(n, n)) + temp_loss = sparse.csr_matrix((temp_data, (loss_row, loss_col)), + shape=(n, n)) temp_loss.sort_indices() # Pass coremap as 1-d array of 32-bit integers @@ -1585,7 +1585,7 @@ class CMFDRun: # Create csr matrix loss_row = self._loss_row loss_col = self._loss_col - loss = csr_array((data, (loss_row, loss_col)), shape=(n, n)) + loss = sparse.csr_matrix((data, (loss_row, loss_col)), shape=(n, n)) loss.sort_indices() return loss @@ -1612,7 +1612,7 @@ class CMFDRun: # Create csr matrix prod_row = self._prod_row prod_col = self._prod_col - prod = csr_array((data, (prod_row, prod_col)), shape=(n, n)) + prod = sparse.csr_matrix((data, (prod_row, prod_col)), shape=(n, n)) prod.sort_indices() return prod diff --git a/openmc/config.py b/openmc/config.py index 23d8e23a7..b823d6b06 100644 --- a/openmc/config.py +++ b/openmc/config.py @@ -1,23 +1,7 @@ -"""Module for handling global configuration in OpenMC. - -This module exports a single object, `config`, that can be used to control -various settings, primarily paths to data files. It acts like a dictionary but -with special behaviors. - -Examples --------- ->>> import openmc ->>> openmc.config['cross_sections'] = '/path/to/my/cross_sections.xml' ->>> print(openmc.config) -{'resolve_paths': True, 'cross_sections': PosixPath('/path/to/my/cross_sections.xml')} - -""" from collections.abc import MutableMapping -from contextlib import contextmanager import os from pathlib import Path import warnings -from typing import Any, Dict, Iterator from openmc.data import DataLibrary from openmc.data.decay import _DECAY_ENERGY, _DECAY_PHOTON_ENERGY @@ -26,193 +10,84 @@ __all__ = ["config"] class _Config(MutableMapping): - """A configuration dictionary for OpenMC with special handling for path-like values. - - This class enforces valid configuration keys and synchronizes path-related - settings with their corresponding environment variables. - - Attributes - ---------- - cross_sections : pathlib.Path - Path to a cross_sections.xml file. Also sets/unsets the - OPENMC_CROSS_SECTIONS environment variable. - mg_cross_sections : pathlib.Path - Path to a multi-group cross_sections.h5 file. Also sets/unsets - the OPENMC_MG_CROSS_SECTIONS environment variable. - chain_file : pathlib.Path - Path to a depletion chain XML file. Also sets/unsets the - OPENMC_CHAIN_FILE environment variable. Setting or deleting this - clears internal decay data caches. - resolve_paths : bool - If True (default), all paths assigned are resolved to absolute - paths. If False, paths are stored as they are provided. - - """ - _PATH_KEYS: Dict[str, str] = { - 'cross_sections': 'OPENMC_CROSS_SECTIONS', - 'mg_cross_sections': 'OPENMC_MG_CROSS_SECTIONS', - 'chain_file': 'OPENMC_CHAIN_FILE' - } - - def __init__(self, data: dict = ()): - self._mapping: Dict[str, Any] = {'resolve_paths': True} + def __init__(self, data=()): + self._mapping = {} self.update(data) - def __getitem__(self, key: str) -> Any: + def __getitem__(self, key): return self._mapping[key] - def __delitem__(self, key: str): - """Delete a configuration key. - - This also deletes the corresponding environment variable if the key is a - path-like key, and clears decay data caches if 'chain_file' is deleted. - 'resolve_paths' cannot be deleted. - - """ - if key == 'resolve_paths': - raise KeyError("'resolve_paths' cannot be deleted.") + def __delitem__(self, key): del self._mapping[key] - if key in self._PATH_KEYS: - env_var = self._PATH_KEYS[key] - if env_var in os.environ: - del os.environ[env_var] - if key == 'chain_file': + if key == 'cross_sections': + del os.environ['OPENMC_CROSS_SECTIONS'] + elif key == 'mg_cross_sections': + del os.environ['OPENMC_MG_CROSS_SECTIONS'] + elif key == 'chain_file': + del os.environ['OPENMC_CHAIN_FILE'] + # Reset photon source data since it relies on chain file + _DECAY_PHOTON_ENERGY.clear() + + def __setitem__(self, key, value): + if key == 'cross_sections': + # Force environment variable to match + self._set_path(key, value) + os.environ['OPENMC_CROSS_SECTIONS'] = str(value) + elif key == 'mg_cross_sections': + self._set_path(key, value) + os.environ['OPENMC_MG_CROSS_SECTIONS'] = str(value) + elif key == 'chain_file': + self._set_path(key, value) + os.environ['OPENMC_CHAIN_FILE'] = str(value) + # Reset photon source data since it relies on chain file _DECAY_PHOTON_ENERGY.clear() _DECAY_ENERGY.clear() - - def __setitem__(self, key: str, value: Any): - """Set a configuration key and its corresponding value. - - For path-like keys, this method performs several actions: - 1. Resolves the path to an absolute path if `resolve_paths` is True. - 2. Stores the `pathlib.Path` object. - 3. Sets the corresponding environment variable (e.g., OPENMC_CROSS_SECTIONS). - 4. For 'chain_file', clears internal decay data caches. - 5. Issues a `UserWarning` if the final path does not exist. - - """ - if key in self._PATH_KEYS: - p = Path(value) - # Use .get() for robustness, defaulting to True - if self._mapping.get('resolve_paths', True): - stored_path = p.resolve(strict=False) - else: - stored_path = p - - self._mapping[key] = stored_path - os.environ[self._PATH_KEYS[key]] = str(stored_path) - - if key == 'chain_file': - _DECAY_PHOTON_ENERGY.clear() - _DECAY_ENERGY.clear() - - if not stored_path.exists(): - warnings.warn(f"Path '{stored_path}' does not exist.", UserWarning) - - elif key == 'resolve_paths': - if not isinstance(value, bool): - raise TypeError("'resolve_paths' must be a boolean.") - self._mapping[key] = value else: - valid_keys = list(self._PATH_KEYS.keys()) + ['resolve_paths'] - raise KeyError( - f"Unrecognized config key: {key}. Acceptable keys are: " - f"{', '.join(repr(k) for k in valid_keys)}." - ) + raise KeyError(f'Unrecognized config key: {key}. Acceptable keys ' + 'are "cross_sections", "mg_cross_sections" and ' + '"chain_file"') - def __iter__(self) -> Iterator[str]: + def __iter__(self): return iter(self._mapping) - def __len__(self) -> int: + def __len__(self): return len(self._mapping) - def __repr__(self) -> str: + def __repr__(self): return repr(self._mapping) - def clear(self): - """Clear all configuration keys except for 'resolve_paths'. - - This ensures that the path resolution behavior is not accidentally reset - when clearing the configuration. - - """ - # Create a copy of keys to iterate over for safe deletion - keys_to_delete = [k for k in self._mapping if k != 'resolve_paths'] - for key in keys_to_delete: - del self[key] - - @contextmanager - def patch(self, key: str, value: Any): - """Context manager to temporarily change a configuration value. - - After the `with` block, the configuration is restored to its original - state. - - Parameters - ---------- - key : str - The key of the configuration value to change. - value - The new temporary value. - - Examples - -------- - >>> openmc.config['cross_sections'] = 'endf71.xml' - >>> with openmc.config.patch('cross_sections', 'fendl32.xml'): - ... # Code in this block sees the new value - ... print(f"Inside with block: {openmc.config['cross_sections']}") - >>> # Outside the block, the value is restored - >>> print(f"Outside with block: {openmc.config['cross_sections']}") - Inside with block: fendl32.xml - Outside with block: endf71.xml - - """ - previous_value = self.get(key) - self[key] = value - try: - yield - finally: - if previous_value is None: - del self[key] - else: - self[key] = previous_value + def _set_path(self, key, value): + self._mapping[key] = p = Path(value) + if not p.exists(): + warnings.warn(f"'{value}' does not exist.") -def _default_config(**kwargs) -> _Config: - """Create a configuration initialized from environment variables. +def _default_config(): + """Return default configuration""" + config = _Config() - This function checks for OPENMC_CROSS_SECTIONS, OPENMC_MG_CROSS_SECTIONS, - and OPENMC_CHAIN_FILE environment variables. It also has logic to find - a chain file within a `cross_sections.xml` file if one is not - explicitly set. + # Set cross sections using environment variable + if "OPENMC_CROSS_SECTIONS" in os.environ: + config['cross_sections'] = os.environ["OPENMC_CROSS_SECTIONS"] + if "OPENMC_MG_CROSS_SECTIONS" in os.environ: + config['mg_cross_sections'] = os.environ["OPENMC_MG_CROSS_SECTIONS"] - Returns - ------- - _Config - A new configuration object. + # Set depletion chain + chain_file = os.environ.get("OPENMC_CHAIN_FILE") + if (chain_file is None and + config.get('cross_sections') is not None and + config['cross_sections'].exists() + ): + # Check for depletion chain in cross_sections.xml + data = DataLibrary.from_xml(config['cross_sections']) + for lib in reversed(data.libraries): + if lib['type'] == 'depletion_chain': + chain_file = lib['path'] + break + if chain_file is not None: + config['chain_file'] = chain_file - """ - config = _Config(kwargs) - for key,var in _Config._PATH_KEYS.items(): - if var in os.environ: - config[key] = os.environ[var] - - chain_file = config.get("chain_file") - xs_path = config.get("cross_sections") - if chain_file is None and xs_path is not None and xs_path.exists(): - try: - data = DataLibrary.from_xml(xs_path) - except Exception: - # Let this pass silently if cross_sections.xml can't be parsed - # or if a dependency like lxml is not available. - pass - else: - for lib in reversed(data.libraries): - if lib['type'] == 'depletion_chain': - config['chain_file'] = xs_path.parent / lib['path'] - break return config -# Global configuration dictionary for OpenMC settings. config = _default_config() diff --git a/openmc/dagmc.py b/openmc/dagmc.py deleted file mode 100644 index 75ead5e43..000000000 --- a/openmc/dagmc.py +++ /dev/null @@ -1,676 +0,0 @@ -from collections.abc import Iterable, Mapping -from numbers import Integral - -import h5py -import lxml.etree as ET -import numpy as np -import warnings - -import openmc -import openmc.checkvalue as cv -from ._xml import get_elem_list, get_text -from .checkvalue import check_type, check_value -from .surface import _BOUNDARY_TYPES -from .bounding_box import BoundingBox -from .utility_funcs import input_path -from .plots import add_plot_params - - -class DAGMCUniverse(openmc.UniverseBase): - """A reference to a DAGMC file to be used in the model. - - .. versionadded:: 0.13.0 - - Parameters - ---------- - filename : str - Path to the DAGMC file used to represent this universe. - universe_id : int, optional - Unique identifier of the universe. If not specified, an identifier will - automatically be assigned. - name : str, optional - Name of the universe. If not specified, the name is the empty string. - auto_geom_ids : bool - Set IDs automatically on initialization (True) or report overlaps in ID - space between CSG and DAGMC (False) - auto_mat_ids : bool - Set IDs automatically on initialization (True) or report overlaps in ID - space between OpenMC and UWUW materials (False) - Attributes - ---------- - id : int - Unique identifier of the universe - name : str - Name of the universe - filename : str - Path to the DAGMC file used to represent this universe. - auto_geom_ids : bool - Set IDs automatically on initialization (True) or report overlaps in ID - space between CSG and DAGMC (False) - auto_mat_ids : bool - Set IDs automatically on initialization (True) or report overlaps in ID - space between OpenMC and UWUW materials (False) - bounding_box : openmc.BoundingBox - Lower-left and upper-right coordinates of an axis-aligned bounding box - of the universe. - - .. versionadded:: 0.13.1 - material_names : list of str - Return a sorted list of materials names that are contained within the - DAGMC h5m file. This is useful when naming openmc.Material() objects as - each material name present in the DAGMC h5m file must have a matching - openmc.Material() with the same name. - - .. versionadded:: 0.13.2 - n_cells : int - The number of cells in the DAGMC model. This is the number of cells at - runtime and accounts for the implicit complement whether or not is it - present in the DAGMC file. - - .. versionadded:: 0.13.2 - n_surfaces : int - The number of surfaces in the model. - - .. versionadded:: 0.13.2 - """ - - def __init__(self, - filename: cv.PathLike, - universe_id=None, - name='', - auto_geom_ids=False, - auto_mat_ids=False): - super().__init__(universe_id, name) - # Initialize class attributes - self.filename = filename - self.auto_geom_ids = auto_geom_ids - self.auto_mat_ids = auto_mat_ids - - def __repr__(self): - string = super().__repr__() - string += '{: <16}=\t{}\n'.format('\tGeom', 'DAGMC') - string += '{: <16}=\t{}\n'.format('\tFile', self.filename) - return string - - @property - def bounding_box(self): - with h5py.File(self.filename) as dagmc_file: - coords = dagmc_file['tstt']['nodes']['coordinates'][()] - lower_left_corner = coords.min(axis=0) - upper_right_corner = coords.max(axis=0) - return openmc.BoundingBox(lower_left_corner, upper_right_corner) - - @property - def filename(self): - return self._filename - - @filename.setter - def filename(self, val: cv.PathLike): - cv.check_type('DAGMC filename', val, cv.PathLike) - self._filename = input_path(val) - - @property - def material_overrides(self): - raise AttributeError( - "DAGMCUniverse.material_overrides has been removed. Use " - "DAGMCCell objects added via add_cell() to manage per-cell " - "material assignments.") - - @material_overrides.setter - def material_overrides(self, val): - raise AttributeError( - "DAGMCUniverse.material_overrides has been removed. Use " - "DAGMCCell objects added via add_cell() to manage per-cell " - "material assignments.") - - def add_material_override(self, key, overrides=None): - """Add a material override to the universe. - - .. versionadded:: 0.15 - - Parameters - ---------- - key : openmc.DAGMCCell or int - Cell object or ID of the Cell to override - value : openmc.Material or Iterable of openmc.Material - Material(s) to be applied to the Cell passed as the key - - """ - # Ensure that they key is a valid type - if not isinstance(key, (int, openmc.DAGMCCell)): - raise ValueError("Unrecognized key type. " - "Must be an integer or openmc.DAGMCCell object") - - # Ensure that overrides is an iterable of openmc.Material - overrides = overrides if isinstance(overrides, openmc.Iterable) else [overrides] - cv.check_iterable_type('material objects', overrides, (openmc.Material, type(None))) - - # if a DAGMCCell is passed, redcue the key to the ID of the cell - if isinstance(key, openmc.DAGMCCell): - key = key.id - - if key not in self.cells: - raise ValueError(f"Cell ID '{key}' not found in DAGMC universe") - - if len(overrides) == 1: - self.cells[key].fill = overrides[0] - else: - self.cells[key].fill = list(overrides) - - @property - def auto_geom_ids(self): - return self._auto_geom_ids - - @auto_geom_ids.setter - def auto_geom_ids(self, val): - cv.check_type('DAGMC automatic geometry ids', val, bool) - self._auto_geom_ids = val - - @property - def auto_mat_ids(self): - return self._auto_mat_ids - - @auto_mat_ids.setter - def auto_mat_ids(self, val): - cv.check_type('DAGMC automatic material ids', val, bool) - self._auto_mat_ids = val - - @property - def material_names(self): - material_tags_ascii = [] - with h5py.File(self.filename) as dagmc_file_contents: - material_tags_hex = dagmc_file_contents['/tstt/tags/NAME'].get('values') - for tag in material_tags_hex: - candidate_tag = tag.tobytes().decode().replace('\x00', '') - # tags might be for temperature or reflective surfaces - if candidate_tag.startswith('mat:'): - # if name ends with _comp remove it, it is not parsed - if candidate_tag.endswith('_comp'): - candidate_tag = candidate_tag[:-5] - # removes first 4 characters as openmc.Material name should be - # set without the 'mat:' part of the tag - material_tags_ascii.append(candidate_tag[4:]) - return sorted(set(material_tags_ascii)) - - def _n_geom_elements(self, geom_type): - """ - Helper function for retrieving the number geometric entities in a DAGMC - file - - Parameters - ---------- - geom_type : str - The type of geometric entity to count. One of {'Volume', 'Surface'}. Returns - the runtime number of voumes in the DAGMC model (includes implicit complement). - - Returns - ------- - int - Number of geometry elements of the specified type - """ - cv.check_value('geometry type', geom_type, ('volume', 'surface')) - - def decode_str_tag(tag_val): - return tag_val.tobytes().decode().replace('\x00', '') - - with h5py.File(self.filename) as dagmc_file: - category_data = dagmc_file['tstt/tags/CATEGORY/values'] - category_strs = map(decode_str_tag, category_data) - n = sum([v == geom_type.capitalize() for v in category_strs]) - - # check for presence of an implicit complement in the file and - # increment the number of cells if it doesn't exist - if geom_type == 'volume': - name_data = dagmc_file['tstt/tags/NAME/values'] - name_strs = map(decode_str_tag, name_data) - if not sum(['impl_complement' in n for n in name_strs]): - n += 1 - return n - - @property - def n_cells(self): - return self._n_geom_elements('volume') - - @property - def n_surfaces(self): - return self._n_geom_elements('surface') - - def create_xml_subelement(self, xml_element, memo=None): - if memo is None: - memo = set() - - if self in memo: - return - - memo.add(self) - - # Set xml element values - dagmc_element = ET.Element('dagmc_universe') - dagmc_element.set('id', str(self.id)) - - if self.name: - dagmc_element.set('name', self.name) - if self.auto_geom_ids: - dagmc_element.set('auto_geom_ids', 'true') - if self.auto_mat_ids: - dagmc_element.set('auto_mat_ids', 'true') - dagmc_element.set('filename', str(self.filename)) - if self.cells: - for cell in self.cells.values(): - cell_element = cell.create_xml_subelement(xml_element, memo) - dagmc_element.append(cell_element) - xml_element.append(dagmc_element) - - def bounding_region( - self, - bounded_type: str = 'box', - boundary_type: str = 'vacuum', - starting_id: int = 10000, - padding_distance: float = 0. - ): - """Creates a either a spherical or box shaped bounding region around - the DAGMC geometry. - - .. versionadded:: 0.13.1 - - Parameters - ---------- - bounded_type : str - The type of bounding surface(s) to use when constructing the region. - Options include a single spherical surface (sphere) or a rectangle - made from six planes (box). - boundary_type : str - Boundary condition that defines the behavior for particles hitting - the surface. Defaults to vacuum boundary condition. Passed into the - surface construction. - starting_id : int - Starting ID of the surface(s) used in the region. For bounded_type - 'box', the next 5 IDs will also be used. Defaults to 10000 to reduce - the chance of an overlap of surface IDs with the DAGMC geometry. - padding_distance : float - Distance between the bounding region surfaces and the minimal - bounding box. Allows for the region to be larger than the DAGMC - geometry. - - Returns - ------- - openmc.Region - Region instance - """ - - check_type('boundary type', boundary_type, str) - check_value('boundary type', boundary_type, _BOUNDARY_TYPES) - check_type('starting surface id', starting_id, Integral) - check_type('bounded type', bounded_type, str) - check_value('bounded type', bounded_type, ('box', 'sphere')) - - bbox = self.bounding_box.expand(padding_distance, True) - - if bounded_type == 'sphere': - radius = np.linalg.norm(bbox.upper_right - bbox.center) - bounding_surface = openmc.Sphere( - surface_id=starting_id, - x0=bbox.center[0], - y0=bbox.center[1], - z0=bbox.center[2], - boundary_type=boundary_type, - r=radius, - ) - - return -bounding_surface - - if bounded_type == 'box': - # defines plane surfaces for all six faces of the bounding box - lower_x = openmc.XPlane(bbox[0][0], surface_id=starting_id) - upper_x = openmc.XPlane(bbox[1][0], surface_id=starting_id+1) - lower_y = openmc.YPlane(bbox[0][1], surface_id=starting_id+2) - upper_y = openmc.YPlane(bbox[1][1], surface_id=starting_id+3) - lower_z = openmc.ZPlane(bbox[0][2], surface_id=starting_id+4) - upper_z = openmc.ZPlane(bbox[1][2], surface_id=starting_id+5) - - region = +lower_x & -upper_x & +lower_y & -upper_y & +lower_z & -upper_z - - for surface in region.get_surfaces().values(): - surface.boundary_type = boundary_type - - return region - - def bounded_universe(self, bounding_cell_id=10000, **kwargs): - """Returns an openmc.Universe filled with this DAGMCUniverse and bounded - with a cell. Defaults to a box cell with a vacuum surface however this - can be changed using the kwargs which are passed directly to - DAGMCUniverse.bounding_region(). - - Parameters - ---------- - bounding_cell_id : int - The cell ID number to use for the bounding cell, defaults to 10000 to reduce - the chance of overlapping ID numbers with the DAGMC geometry. - - Returns - ------- - openmc.Universe - Universe instance - """ - bounding_cell = openmc.Cell( - fill=self, cell_id=bounding_cell_id, region=self.bounding_region(**kwargs)) - return openmc.Universe(cells=[bounding_cell]) - - @classmethod - def from_hdf5(cls, group): - """Create DAGMC universe from HDF5 group - - Parameters - ---------- - group : h5py.Group - Group in HDF5 file - - Returns - ------- - openmc.DAGMCUniverse - DAGMCUniverse instance - - """ - id = int(group.name.split('/')[-1].lstrip('universe ')) - fname = group['filename'][()].decode() - name = group['name'][()].decode() if 'name' in group else None - - out = cls(fname, universe_id=id, name=name) - - out.auto_geom_ids = bool(group.attrs['auto_geom_ids']) - out.auto_mat_ids = bool(group.attrs['auto_mat_ids']) - - return out - - @classmethod - def from_xml_element(cls, elem, mats=None): - """Generate DAGMC universe from XML element - - Parameters - ---------- - elem : lxml.etree._Element - `` element - mats : dict - Dictionary mapping material ID strings to :class:`openmc.Material` - instances (defined in :meth:`openmc.Geometry.from_xml`) - - Returns - ------- - openmc.DAGMCUniverse - DAGMCUniverse instance - - """ - id = int(get_text(elem, 'id')) - fname = get_text(elem, 'filename') - - out = cls(fname, universe_id=id) - - name = get_text(elem, 'name') - if name is not None: - out.name = name - - out.auto_geom_ids = bool(get_text(elem, "auto_geom_ids")) - out.auto_mat_ids = bool(get_text(elem, "auto_mat_ids")) - - has_overrides = elem.find('material_overrides') is not None - has_cells = elem.find('cell') is not None - - if has_overrides and has_cells: - raise ValueError( - "DAGMCUniverse cannot specify both and " - " sub-elements. Use elements only.") - - if has_overrides: - warnings.warn( - "DAGMCUniverse is deprecated and will be " - "removed in a future version. Use nested elements " - "instead.", DeprecationWarning, stacklevel=2) - out._parse_legacy_material_overrides(elem, mats) - elif has_cells: - out._parse_cell_overrides(elem, mats) - - return out - - def _parse_legacy_material_overrides(self, elem, mats): - """Parse the deprecated XML format and populate - the universe with equivalent DAGMCCell objects.""" - if mats is None: - raise ValueError( - "DAGMC material overrides found but no materials were " - "provided to populate the mapping.") - mo_elem = elem.find('material_overrides') - for co_elem in mo_elem.findall('cell_override'): - cell_id = int(get_text(co_elem, 'id')) - mat_ids = co_elem.find('material_ids').text.split() - fill_objs = [mats[mid] for mid in mat_ids] - fill = fill_objs[0] if len(fill_objs) == 1 else fill_objs - if cell_id in self.cells: - raise ValueError( - f"Duplicate DAGMC cell override specified for cell {cell_id}.") - self.add_cell(DAGMCCell(cell_id=cell_id, fill=fill)) - - def _parse_cell_overrides(self, elem, mats): - if mats is None: - raise ValueError("DAGMC cell overrides found in DAGMC universe but " - "no materials were provided to populate the " - "mapping.") - - for cell_elem in elem.findall('cell'): - cell_id = int(get_text(cell_elem, 'id')) - if cell_id in self.cells: - raise ValueError( - f"Duplicate DAGMC cell override specified for cell {cell_id}.") - DAGMCCell.from_xml_element(cell_elem, mats, self) - - def _partial_deepcopy(self): - """Clone all of the openmc.DAGMCUniverse object's attributes except for - its cells, as they are copied within the clone function. This should - only to be used within the openmc.UniverseBase.clone() context. - """ - clone = openmc.DAGMCUniverse(name=self.name, filename=self.filename) - clone.volume = self.volume - clone.auto_geom_ids = self.auto_geom_ids - clone.auto_mat_ids = self.auto_mat_ids - return clone - - def add_cell(self, cell): - """Add a cell to the universe. - - Parameters - ---------- - cell : openmc.DAGMCCell - Cell to add - - """ - if not isinstance(cell, openmc.DAGMCCell): - msg = f'Unable to add a DAGMCCell to DAGMCUniverse ' \ - f'ID="{self._id}" since "{cell}" is not a DAGMCCell' - raise TypeError(msg) - - cell_id = cell.id - - if cell_id not in self._cells: - self._cells[cell_id] = cell - - def remove_cell(self, cell): - """Remove a cell from the universe. - - Parameters - ---------- - cell : openmc.Cell - Cell to remove - - """ - - if not isinstance(cell, openmc.DAGMCCell): - msg = f'Unable to remove a Cell from Universe ID="{self._id}" ' \ - f'since "{cell}" is not a Cell' - raise TypeError(msg) - - # If the Cell is in the Universe's list of Cells, delete it - self._cells.pop(cell.id, None) - - def sync_dagmc_cells(self, mats: Iterable[openmc.Material]): - """Synchronize DAGMC cell information between Python and C API - - .. versionadded:: 0.15.1 - - Parameters - ---------- - mats : iterable of openmc.Material - Iterable of materials to assign to the DAGMC cells - - """ - import openmc.lib - if not openmc.lib.is_initialized: - raise RuntimeError("This universe must be part of an openmc.Model " - "initialized via Model.init_lib before calling " - "this method.") - - dagmc_cell_ids = openmc.lib.dagmc.dagmc_universe_cell_ids(self.id) - if len(dagmc_cell_ids) != self.n_cells: - raise ValueError( - f"Number of cells in DAGMC universe {self.id} does not match " - f"the number of cells in the Python universe." - ) - - mats_per_id = {mat.id: mat for mat in mats} - for dag_cell_id in dagmc_cell_ids: - dag_cell = openmc.lib.cells[dag_cell_id] - if isinstance(dag_cell.fill, Iterable): - fill = [mats_per_id[mat.id] for mat in dag_cell.fill if mat] - else: - fill = mats_per_id[dag_cell.fill.id] if dag_cell.fill else None - name = dag_cell.name - if dag_cell_id in self._cells: - self._cells[dag_cell_id].name = name - self._cells[dag_cell_id].fill = fill - else: - self.add_cell( - openmc.DAGMCCell(cell_id=dag_cell_id, name=name, fill=fill)) - - @add_plot_params - def plot(self, *args, **kwargs): - """Display a slice plot of the DAGMCUniverse. - """ - return openmc.Geometry(self).plot(*args, **kwargs) - - -class DAGMCCell(openmc.Cell): - """A cell class for DAGMC-based geometries. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - cell_id : int or None, optional - Unique identifier for the cell. If None, an identifier will be - automatically assigned. - name : str, optional - Name of the cell. - fill : openmc.Material or None, optional - Material filling the cell. If None, the cell is filled with vacuum. - - Attributes - ---------- - DAG_parent_universe : int - The parent universe of the cell. - - Notes - ----- - DAGMC geometries are composed of triangulated surfaces, which means cell - volumes can in principle be computed exactly (e.g. via mesh-based - integration). Manually specifying :attr:`volume` overrides any such - calculation and may introduce inconsistencies if the value does not - accurately reflect the true geometric volume. - - """ - def __init__(self, cell_id=None, name='', fill=None): - super().__init__(cell_id, name, fill, None) - - @property - def DAG_parent_universe(self): - """Get the parent universe of the cell.""" - return self._parent_universe - - @DAG_parent_universe.setter - def DAG_parent_universe(self, universe): - """Set the parent universe of the cell.""" - self._parent_universe = universe.id - - def bounding_box(self): - return BoundingBox.infinite() - - def get_all_cells(self, memo=None): - return {} - - def get_all_universes(self, memo=None): - return {} - - def clone(self, clone_materials=True, clone_regions=True, memo=None): - warnings.warn("clone is not available for cells in a DAGMC universe") - return self - - def plot(self, *args, **kwargs): - raise TypeError("plot is not available for DAGMC cells.") - - def create_xml_subelement(self, xml_element, memo=None): - if self.fill_type not in ('void', 'material', 'distribmat'): - raise TypeError("DAGMC cell overrides currently only support " - "material fills.") - if self.temperature is not None and self.fill_type not in ( - 'material', 'distribmat' - ): - raise TypeError("DAGMC cell temperature overrides require a " - "material fill.") - if self.density is not None and self.fill_type not in ('material', 'distribmat'): - raise TypeError("DAGMC cell density overrides require a " - "material fill.") - if any(getattr(self, attr) is not None for attr in ('translation', 'rotation')): - raise TypeError("DAGMC cell overrides do not support translation " - "or rotation.") - return super().create_xml_subelement(xml_element, memo) - - @classmethod - def from_xml_element(cls, elem, mats, universe): - """Generate a DAGMCCell from an XML override element. - - Parameters - ---------- - elem : lxml.etree._Element - `` element containing a DAGMC cell property override - mats : dict - Dictionary mapping material ID strings to :class:`openmc.Material` - instances - universe : DAGMCUniverse - Universe to add the parsed cell to. - - Returns - ------- - DAGMCCell - DAGMCCell instance - """ - if not isinstance(universe, DAGMCUniverse): - raise TypeError( - f"universe must be a DAGMCUniverse instance, " - f"got {type(universe).__name__}.") - - cell_id = int(get_text(elem, 'id')) - - # Validate attributes that are unsupported for DAGMC cell overrides - for tag in ('region', 'fill', 'universe'): - if get_text(elem, tag) is not None: - raise ValueError( - f"DAGMC cell {cell_id} override cannot specify '{tag}'.") - for tag in ('translation', 'rotation'): - if get_text(elem, tag) is not None: - raise ValueError( - f"DAGMC cell {cell_id} override does not support " - f"'{tag}'.") - if get_elem_list(elem, 'material', str) is None: - raise ValueError( - f"DAGMC cell {cell_id} must specify a material override.") - - return super().from_xml_element( - elem, surfaces={}, materials=mats, - get_universe=lambda _: universe) diff --git a/openmc/data/__init__.py b/openmc/data/__init__.py index 9b38d758e..c2d35565a 100644 --- a/openmc/data/__init__.py +++ b/openmc/data/__init__.py @@ -33,8 +33,5 @@ from .resonance_covariance import * from .multipole import * from .grid import * from .function import * -from .vectfit import * -from .dose.dose import dose_coefficients -from .dose.mass_attenuation import \ - mass_energy_absorption_coefficient, mass_attenuation_coefficient +from .effective_dose.dose import dose_coefficients diff --git a/openmc/data/_endf.pyx b/openmc/data/_endf.pyx new file mode 100644 index 000000000..991ee015b --- /dev/null +++ b/openmc/data/_endf.pyx @@ -0,0 +1,8 @@ +# cython: c_string_type=str, c_string_encoding=ascii + +cdef extern from "endf.c": + double cfloat_endf(const char* buffer, int n) + +def float_endf(s): + cdef const char* c_string = s + return cfloat_endf(c_string, len(s)) diff --git a/openmc/data/ace.py b/openmc/data/ace.py index d3de6a192..1247593a8 100644 --- a/openmc/data/ace.py +++ b/openmc/data/ace.py @@ -9,9 +9,9 @@ unresolved resonance region, and tabulated data in the fast region. After the ENDF data has been reconstructed and Doppler-broadened, the ACER module generates ACE-format cross sections. -.. _MCNP: https://mcnp.lanl.gov/ -.. _NJOY: https://www.njoy21.io/ -.. _ENDF: https://www.nndc.bnl.gov/endf-library/ +.. _MCNP: https://laws.lanl.gov/vhosts/mcnp.lanl.gov/ +.. _NJOY: http://t2.lanl.gov/codes.shtml +.. _ENDF: http://www.nndc.bnl.gov/endf """ @@ -24,7 +24,7 @@ import numpy as np import openmc.checkvalue as cv from openmc.mixin import EqualityMixin from .data import ATOMIC_SYMBOL, gnds_name, EV_PER_MEV, K_BOLTZMANN -from endf.records import ENDF_FLOAT_RE +from .endf import ENDF_FLOAT_RE def get_metadata(zaid, metastable_scheme='nndc'): diff --git a/openmc/data/angle_distribution.py b/openmc/data/angle_distribution.py index 778139cc2..e59ffa0c7 100644 --- a/openmc/data/angle_distribution.py +++ b/openmc/data/angle_distribution.py @@ -10,8 +10,8 @@ from openmc.mixin import EqualityMixin from openmc.stats import Univariate, Tabular, Uniform, Legendre from .function import INTERPOLATION_SCHEME from .data import EV_PER_MEV -from .endf import as_evaluation, get_head_record, get_cont_record, \ - get_tab1_record, get_list_record, get_tab2_record +from .endf import get_head_record, get_cont_record, get_tab1_record, \ + get_list_record, get_tab2_record class AngleDistribution(EqualityMixin): @@ -213,7 +213,7 @@ class AngleDistribution(EqualityMixin): Parameters ---------- - ev : openmc.data.endf.Evaluation or endf.Material + ev : openmc.data.endf.Evaluation ENDF evaluation mt : int The MT value of the reaction to get angular distributions for @@ -224,7 +224,6 @@ class AngleDistribution(EqualityMixin): Angular distribution """ - ev = as_evaluation(ev) file_obj = StringIO(ev.section[4, mt]) # Read HEAD record diff --git a/openmc/data/data.py b/openmc/data/data.py index 6e4840990..7caf31e26 100644 --- a/openmc/data/data.py +++ b/openmc/data/data.py @@ -1,25 +1,11 @@ -from __future__ import annotations - import itertools import json import os import re from pathlib import Path from math import sqrt, log -from typing import TYPE_CHECKING, Literal from warnings import warn - -from endf.data import (ATOMIC_NUMBER, ATOMIC_SYMBOL, ELEMENT_SYMBOL, - EV_PER_MEV, K_BOLTZMANN, gnds_name, zam) - -import openmc -from openmc.checkvalue import PathLike - -if TYPE_CHECKING: - from openmc.deplete import Chain - -gnds_name.__module__ = __name__ -zam.__module__ = __name__ +from typing import Dict # Isotopic abundances from Meija J, Coplen T B, et al, "Isotopic compositions # of the elements 2013 (IUPAC Technical Report)", Pure. Appl. Chem. 88 (3), @@ -109,7 +95,7 @@ NATURAL_ABUNDANCE = { 'Yb174': 0.32025, 'Yb176': 0.12995, 'Lu175': 0.97401, 'Lu176': 0.02599, 'Hf174': 0.0016, 'Hf176': 0.0526, 'Hf177': 0.186, 'Hf178': 0.2728, 'Hf179': 0.1362, - 'Hf180': 0.3508, 'Ta180_m1': 0.0001201, 'Ta181': 0.9998799, + 'Hf180': 0.3508, 'Ta180': 0.0001201, 'Ta181': 0.9998799, 'W180': 0.0012, 'W182': 0.265, 'W183': 0.1431, 'W184': 0.3064, 'W186': 0.2843, 'Re185': 0.374, 'Re187': 0.626, 'Os184': 0.0002, 'Os186': 0.0159, @@ -127,6 +113,72 @@ NATURAL_ABUNDANCE = { 'U238': 0.992742 } +# Dictionary to give element symbols from IUPAC names +# (and some common mispellings) +ELEMENT_SYMBOL = {'neutron': 'n', 'hydrogen': 'H', 'helium': 'He', + 'lithium': 'Li', 'beryllium': 'Be', 'boron': 'B', + 'carbon': 'C', 'nitrogen': 'N', 'oxygen': 'O', 'fluorine': 'F', + 'neon': 'Ne', 'sodium': 'Na', 'magnesium': 'Mg', + 'aluminium': 'Al', 'aluminum': 'Al', 'silicon': 'Si', + 'phosphorus': 'P', 'sulfur': 'S', 'sulphur': 'S', + 'chlorine': 'Cl', 'argon': 'Ar', 'potassium': 'K', + 'calcium': 'Ca', 'scandium': 'Sc', 'titanium': 'Ti', + 'vanadium': 'V', 'chromium': 'Cr', 'manganese': 'Mn', + 'iron': 'Fe', 'cobalt': 'Co', 'nickel': 'Ni', 'copper': 'Cu', + 'zinc': 'Zn', 'gallium': 'Ga', 'germanium': 'Ge', + 'arsenic': 'As', 'selenium': 'Se', 'bromine': 'Br', + 'krypton': 'Kr', 'rubidium': 'Rb', 'strontium': 'Sr', + 'yttrium': 'Y', 'zirconium': 'Zr', 'niobium': 'Nb', + 'molybdenum': 'Mo', 'technetium': 'Tc', 'ruthenium': 'Ru', + 'rhodium': 'Rh', 'palladium': 'Pd', 'silver': 'Ag', + 'cadmium': 'Cd', 'indium': 'In', 'tin': 'Sn', 'antimony': 'Sb', + 'tellurium': 'Te', 'iodine': 'I', 'xenon': 'Xe', + 'caesium': 'Cs', 'cesium': 'Cs', 'barium': 'Ba', + 'lanthanum': 'La', 'cerium': 'Ce', 'praseodymium': 'Pr', + 'neodymium': 'Nd', 'promethium': 'Pm', 'samarium': 'Sm', + 'europium': 'Eu', 'gadolinium': 'Gd', 'terbium': 'Tb', + 'dysprosium': 'Dy', 'holmium': 'Ho', 'erbium': 'Er', + 'thulium': 'Tm', 'ytterbium': 'Yb', 'lutetium': 'Lu', + 'hafnium': 'Hf', 'tantalum': 'Ta', 'tungsten': 'W', + 'wolfram': 'W', 'rhenium': 'Re', 'osmium': 'Os', + 'iridium': 'Ir', 'platinum': 'Pt', 'gold': 'Au', + 'mercury': 'Hg', 'thallium': 'Tl', 'lead': 'Pb', + 'bismuth': 'Bi', 'polonium': 'Po', 'astatine': 'At', + 'radon': 'Rn', 'francium': 'Fr', 'radium': 'Ra', + 'actinium': 'Ac', 'thorium': 'Th', 'protactinium': 'Pa', + 'uranium': 'U', 'neptunium': 'Np', 'plutonium': 'Pu', + 'americium': 'Am', 'curium': 'Cm', 'berkelium': 'Bk', + 'californium': 'Cf', 'einsteinium': 'Es', 'fermium': 'Fm', + 'mendelevium': 'Md', 'nobelium': 'No', 'lawrencium': 'Lr', + 'rutherfordium': 'Rf', 'dubnium': 'Db', 'seaborgium': 'Sg', + 'bohrium': 'Bh', 'hassium': 'Hs', 'meitnerium': 'Mt', + 'darmstadtium': 'Ds', 'roentgenium': 'Rg', 'copernicium': 'Cn', + 'nihonium': 'Nh', 'flerovium': 'Fl', 'moscovium': 'Mc', + 'livermorium': 'Lv', 'tennessine': 'Ts', 'oganesson': 'Og'} + +ATOMIC_SYMBOL = {0: 'n', 1: 'H', 2: 'He', 3: 'Li', 4: 'Be', 5: 'B', 6: 'C', + 7: 'N', 8: 'O', 9: 'F', 10: 'Ne', 11: 'Na', 12: 'Mg', 13: 'Al', + 14: 'Si', 15: 'P', 16: 'S', 17: 'Cl', 18: 'Ar', 19: 'K', + 20: 'Ca', 21: 'Sc', 22: 'Ti', 23: 'V', 24: 'Cr', 25: 'Mn', + 26: 'Fe', 27: 'Co', 28: 'Ni', 29: 'Cu', 30: 'Zn', 31: 'Ga', + 32: 'Ge', 33: 'As', 34: 'Se', 35: 'Br', 36: 'Kr', 37: 'Rb', + 38: 'Sr', 39: 'Y', 40: 'Zr', 41: 'Nb', 42: 'Mo', 43: 'Tc', + 44: 'Ru', 45: 'Rh', 46: 'Pd', 47: 'Ag', 48: 'Cd', 49: 'In', + 50: 'Sn', 51: 'Sb', 52: 'Te', 53: 'I', 54: 'Xe', 55: 'Cs', + 56: 'Ba', 57: 'La', 58: 'Ce', 59: 'Pr', 60: 'Nd', 61: 'Pm', + 62: 'Sm', 63: 'Eu', 64: 'Gd', 65: 'Tb', 66: 'Dy', 67: 'Ho', + 68: 'Er', 69: 'Tm', 70: 'Yb', 71: 'Lu', 72: 'Hf', 73: 'Ta', + 74: 'W', 75: 'Re', 76: 'Os', 77: 'Ir', 78: 'Pt', 79: 'Au', + 80: 'Hg', 81: 'Tl', 82: 'Pb', 83: 'Bi', 84: 'Po', 85: 'At', + 86: 'Rn', 87: 'Fr', 88: 'Ra', 89: 'Ac', 90: 'Th', 91: 'Pa', + 92: 'U', 93: 'Np', 94: 'Pu', 95: 'Am', 96: 'Cm', 97: 'Bk', + 98: 'Cf', 99: 'Es', 100: 'Fm', 101: 'Md', 102: 'No', + 103: 'Lr', 104: 'Rf', 105: 'Db', 106: 'Sg', 107: 'Bh', + 108: 'Hs', 109: 'Mt', 110: 'Ds', 111: 'Rg', 112: 'Cn', + 113: 'Nh', 114: 'Fl', 115: 'Mc', 116: 'Lv', 117: 'Ts', + 118: 'Og'} +ATOMIC_NUMBER = {value: key for key, value in ATOMIC_SYMBOL.items()} + DADZ = { '(n,2nd)': (-3, -1), '(n,2n)': (-1, 0), @@ -217,7 +269,11 @@ DADZ = { # Values here are from the Committee on Data for Science and Technology # (CODATA) 2018 recommendation (https://physics.nist.gov/cuu/Constants/). +# The value of the Boltzman constant in units of eV / K +K_BOLTZMANN = 8.617333262e-5 + # Unit conversions +EV_PER_MEV = 1.0e6 JOULE_PER_EV = 1.602176634e-19 # Avogadro's constant @@ -227,10 +283,13 @@ AVOGADRO = 6.02214076e23 NEUTRON_MASS = 1.00866491595 # Used in atomic_mass function as a cache -_ATOMIC_MASS: dict[str, float] = {} +_ATOMIC_MASS: Dict[str, float] = {} + +# Regex for GNDS nuclide names (used in zam function) +_GNDS_NAME_RE = re.compile(r'([A-Zn][a-z]*)(\d+)((?:_[em]\d+)?)') # Used in half_life function as a cache -_HALF_LIFE: dict[str, float] = {} +_HALF_LIFE: Dict[str, float] = {} _LOG_TWO = log(2.0) def atomic_mass(isotope): @@ -266,7 +325,7 @@ def atomic_mass(isotope): # isotopes of their element (e.g. C0), calculate the atomic mass as # the sum of the atomic mass times the natural abundance of the isotopes # that make up the element. - for element in ['C', 'Zn', 'Pt', 'Os', 'Tl', 'V']: + for element in ['C', 'Zn', 'Pt', 'Os', 'Tl']: isotope_zero = element.lower() + '0' _ATOMIC_MASS[isotope_zero] = 0. for iso, abundance in isotopes(element): @@ -305,47 +364,25 @@ def atomic_weight(element): raise ValueError(f"No naturally-occurring isotopes for element '{element}'.") -def half_life( - isotope: str, - chain_file: Literal[False] | None | PathLike | Chain = False -) -> float | None: +def half_life(isotope): """Return half-life of isotope in seconds or None if isotope is stable - By default, half-life values are from the `ENDF/B-VIII.0 decay sublibrary - `_. A depletion chain can - also be used as the source of half-life values. + Half-life values are from the `ENDF/B-VIII.0 decay sublibrary + `_. .. versionadded:: 0.13.1 - .. versionchanged:: 0.15.4 - Added the ``chain_file`` argument. - Parameters ---------- isotope : str Name of isotope, e.g., 'Pu239' - chain_file : False, None, PathLike, or openmc.deplete.Chain, optional - Source of half-life values. If ``False``, only ENDF/B-VIII.0 data is - used. If ``None``, the chain specified by - ``openmc.config['chain_file']`` is used when available. If a path or - :class:`openmc.deplete.Chain` is given, that chain is used. For ``None`` - or an explicit chain, nuclides absent from the chain fall back to - ENDF/B-VIII.0 data. Returns ------- - float or None - Half-life of isotope in [s], or None if the isotope is stable + float + Half-life of isotope in [s] """ - if chain_file is not False: - if chain_file is not None or openmc.config.get('chain_file') is not None: - # Local import avoids a circular dependency - from openmc.deplete.chain import _get_chain - chain = _get_chain(chain_file) - if isotope in chain: - return chain[isotope].half_life - global _HALF_LIFE if not _HALF_LIFE: # Load ENDF/B-VIII.0 data from JSON file @@ -355,10 +392,7 @@ def half_life( return _HALF_LIFE.get(isotope.lower()) -def decay_constant( - isotope: str, - chain_file: Literal[False] | None | PathLike | Chain = False -) -> float: +def decay_constant(isotope): """Return decay constant of isotope in [s^-1] Decay constants are based on half-life values from the @@ -367,20 +401,10 @@ def decay_constant( .. versionadded:: 0.13.1 - .. versionchanged:: 0.15.4 - Added the ``chain_file`` argument. - Parameters ---------- isotope : str Name of isotope, e.g., 'Pu239' - chain_file : False, None, PathLike, or openmc.deplete.Chain, optional - Source of half-life values. If ``False``, only ENDF/B-VIII.0 data is - used. If ``None``, the chain specified by - ``openmc.config['chain_file']`` is used when available. If a path or - :class:`openmc.deplete.Chain` is given, that chain is used. For ``None`` - or an explicit chain, nuclides absent from the chain fall back to - ENDF/B-VIII.0 data. Returns ------- @@ -392,7 +416,7 @@ def decay_constant( openmc.data.half_life """ - t = half_life(isotope, chain_file) + t = half_life(isotope) return _LOG_TWO / t if t else 0.0 @@ -500,17 +524,33 @@ def water_density(temperature, pressure=0.1013): return coeff / pi / gamma1_pi -def _get_element_symbol(element: str) -> str: - if len(element) > 2: - symbol = ELEMENT_SYMBOL.get(element.lower()) - if symbol is None: - raise ValueError(f'Element name "{element}" not recognized') - return symbol - else: - return element +def gnds_name(Z, A, m=0): + """Return nuclide name using GNDS convention + + .. versionchanged:: 0.14.0 + Function name changed from ``gnd_name`` to ``gnds_name`` + + Parameters + ---------- + Z : int + Atomic number + A : int + Mass number + m : int, optional + Metastable state + + Returns + ------- + str + Nuclide name in GNDS convention, e.g., 'Am242_m1' + + """ + if m > 0: + return f'{ATOMIC_SYMBOL[Z]}{A}_m{m}' + return f'{ATOMIC_SYMBOL[Z]}{A}' -def isotopes(element: str) -> list[tuple[str, float]]: +def isotopes(element): """Return naturally occurring isotopes and their abundances .. versionadded:: 0.12.1 @@ -531,7 +571,12 @@ def isotopes(element: str) -> list[tuple[str, float]]: If the element name is not recognized """ - element = _get_element_symbol(element) + # Convert name to symbol if needed + if len(element) > 2: + symbol = ELEMENT_SYMBOL.get(element.lower()) + if symbol is None: + raise ValueError(f'Element name "{element}" not recognised') + element = symbol # Get the nuclides present in nature result = [] @@ -540,3 +585,30 @@ def isotopes(element: str) -> list[tuple[str, float]]: result.append(kv) return result + + +def zam(name): + """Return tuple of (atomic number, mass number, metastable state) + + Parameters + ---------- + name : str + Name of nuclide using GNDS convention, e.g., 'Am242_m1' + + Returns + ------- + 3-tuple of int + Atomic number, mass number, and metastable state + + """ + try: + symbol, A, state = _GNDS_NAME_RE.match(name).groups() + except AttributeError: + raise ValueError(f"'{name}' does not appear to be a nuclide name in " + "GNDS format") + + if symbol not in ATOMIC_NUMBER: + raise ValueError(f"'{symbol}' is not a recognized element symbol") + + metastable = int(state[2:]) if state else 0 + return (ATOMIC_NUMBER[symbol], int(A), metastable) diff --git a/openmc/data/decay.py b/openmc/data/decay.py index 5f95e1281..be3dab77a 100644 --- a/openmc/data/decay.py +++ b/openmc/data/decay.py @@ -1,7 +1,8 @@ from collections.abc import Iterable -from functools import cached_property from io import StringIO from math import log +import re +from typing import Optional from warnings import warn import numpy as np @@ -12,10 +13,9 @@ import openmc.checkvalue as cv from openmc.exceptions import DataError from openmc.mixin import EqualityMixin from openmc.stats import Discrete, Tabular, Univariate, combine_distributions -from .data import gnds_name, zam +from .data import ATOMIC_SYMBOL, ATOMIC_NUMBER from .function import INTERPOLATION_SCHEME -from .endf import ( - as_evaluation, get_head_record, get_list_record, get_tab1_record) +from .endf import Evaluation, get_head_record, get_list_record, get_tab1_record # Gives name and (change in A, change in Z) resulting from decay @@ -76,7 +76,7 @@ class FissionProductYields(EqualityMixin): Parameters ---------- - ev_or_filename : str, openmc.data.endf.Evaluation, or endf.Material + ev_or_filename : str of openmc.data.endf.Evaluation ENDF fission product yield evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -126,7 +126,9 @@ class FissionProductYields(EqualityMixin): for j in range(n_products): Z, A = divmod(int(values[4*j]), 1000) isomeric_state = int(values[4*j + 1]) - name = gnds_name(Z, A, isomeric_state) + name = ATOMIC_SYMBOL[Z] + str(A) + if isomeric_state > 0: + name += f'_m{isomeric_state}' yield_j = ufloat(values[4*j + 2], values[4*j + 3]) yields[name] = yield_j @@ -134,7 +136,11 @@ class FissionProductYields(EqualityMixin): return energies, data - ev = as_evaluation(ev_or_filename) + # Get evaluation if str is passed + if isinstance(ev_or_filename, Evaluation): + ev = ev_or_filename + else: + ev = Evaluation(ev_or_filename) # Assign basic nuclide properties self.nuclide = { @@ -161,7 +167,7 @@ class FissionProductYields(EqualityMixin): Parameters ---------- - ev_or_filename : str, openmc.data.endf.Evaluation, or endf.Material + ev_or_filename : str or openmc.data.endf.Evaluation ENDF fission product yield evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -237,7 +243,9 @@ class DecayMode(EqualityMixin): @property def daughter(self): # Determine atomic number and mass number of parent - Z, A, _ = zam(self.parent) + symbol, A = re.match(r'([A-Zn][a-z]*)(\d+)', self.parent).groups() + A = int(A) + Z = ATOMIC_NUMBER[symbol] # Process changes for mode in self.modes: @@ -247,11 +255,11 @@ class DecayMode(EqualityMixin): delta_A, delta_Z = changes A += delta_A Z += delta_Z - break - else: - return None - return gnds_name(Z, A, self._daughter_state) + if self._daughter_state > 0: + return f'{ATOMIC_SYMBOL[Z]}{A}_m{self._daughter_state}' + else: + return f'{ATOMIC_SYMBOL[Z]}{A}' @property def parent(self): @@ -289,7 +297,7 @@ class Decay(EqualityMixin): Parameters ---------- - ev_or_filename : str, openmc.data.endf.Evaluation, or endf.Material + ev_or_filename : str of openmc.data.endf.Evaluation ENDF radioactive decay data evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -320,7 +328,11 @@ class Decay(EqualityMixin): """ def __init__(self, ev_or_filename): - ev = as_evaluation(ev_or_filename) + # Get evaluation if str is passed + if isinstance(ev_or_filename, Evaluation): + ev = ev_or_filename + else: + ev = Evaluation(ev_or_filename) file_obj = StringIO(ev.section[8, 457]) @@ -328,6 +340,7 @@ class Decay(EqualityMixin): self.modes = [] self.spectra = {} self.average_energies = {} + self._sources = None # Get head record items = get_head_record(file_obj) @@ -336,7 +349,10 @@ class Decay(EqualityMixin): self.nuclide['atomic_number'] = Z self.nuclide['mass_number'] = A self.nuclide['isomeric_state'] = metastable - self.nuclide['name'] = gnds_name(Z, A, metastable) + if metastable > 0: + self.nuclide['name'] = f'{ATOMIC_SYMBOL[Z]}{A}_m{metastable}' + else: + self.nuclide['name'] = f'{ATOMIC_SYMBOL[Z]}{A}' self.nuclide['mass'] = items[1] # AWR self.nuclide['excited_state'] = items[2] # State of the original nuclide self.nuclide['stable'] = (items[4] == 1) # Nucleus stability flag @@ -479,7 +495,7 @@ class Decay(EqualityMixin): Parameters ---------- - ev_or_filename : str, openmc.data.endf.Evaluation, or endf.Material + ev_or_filename : str or openmc.data.endf.Evaluation ENDF radioactive decay data evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -491,9 +507,14 @@ class Decay(EqualityMixin): """ return cls(ev_or_filename) - @cached_property + @property def sources(self): """Radioactive decay source distributions""" + # If property has been computed already, return it + # TODO: Replace with functools.cached_property when support is Python 3.9+ + if self._sources is not None: + return self._sources + sources = {} name = self.nuclide['name'] decay_constant = self.decay_constant.n @@ -551,13 +572,14 @@ class Decay(EqualityMixin): merged_sources[particle_type] = combine_distributions( dist_list, [1.0]*len(dist_list)) - return merged_sources + self._sources = merged_sources + return self._sources _DECAY_PHOTON_ENERGY = {} -def decay_photon_energy(nuclide: str) -> Univariate | None: +def decay_photon_energy(nuclide: str) -> Optional[Univariate]: """Get photon energy distribution resulting from the decay of a nuclide This function relies on data stored in a depletion chain. Before calling it @@ -576,7 +598,7 @@ def decay_photon_energy(nuclide: str) -> Univariate | None: openmc.stats.Univariate or None Distribution of energies in [eV] of photons emitted from decay, or None if no photon source exists. Note that the probabilities represent - intensities, given as [Bq/atom] (in other words, decay constants). + intensities, given as [Bq]. """ if not _DECAY_PHOTON_ENERGY: chain_file = openmc.config.get('chain_file') @@ -642,3 +664,5 @@ def decay_energy(nuclide: str): warn(f"Chain file '{chain_file}' does not have any decay energy.") return _DECAY_ENERGY.get(nuclide, 0.0) + + diff --git a/openmc/data/dose/dose.py b/openmc/data/dose/dose.py deleted file mode 100644 index 87e0cf9ae..000000000 --- a/openmc/data/dose/dose.py +++ /dev/null @@ -1,146 +0,0 @@ -from pathlib import Path - -import numpy as np - -import openmc.checkvalue as cv - -_FULL_GEOMETRIES = ('AP', 'PA', 'LLAT', 'RLAT', 'ROT', 'ISO') -_LIMITED_GEOMETRIES = ('AP', 'PA', 'ISO') - -_TABLES = { - ('icrp74', 'effective', 'neutron'): ( - Path('icrp74') / 'neutrons.txt', _FULL_GEOMETRIES), - ('icrp74', 'effective', 'photon'): ( - Path('icrp74') / 'photons.txt', _FULL_GEOMETRIES), - ('icrp116', 'effective', 'electron'): ( - Path('icrp116') / 'electrons.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'helium'): ( - Path('icrp116') / 'helium_ions.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'mu-'): ( - Path('icrp116') / 'negative_muons.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'pi-'): ( - Path('icrp116') / 'negative_pions.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'neutron'): ( - Path('icrp116') / 'neutrons.txt', _FULL_GEOMETRIES), - ('icrp116', 'effective', 'photon'): ( - Path('icrp116') / 'photons.txt', _FULL_GEOMETRIES), - ('icrp116', 'effective', 'photon kerma'): ( - Path('icrp116') / 'photons_kerma.txt', _FULL_GEOMETRIES), - ('icrp116', 'effective', 'mu+'): ( - Path('icrp116') / 'positive_muons.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'pi+'): ( - Path('icrp116') / 'positive_pions.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'positron'): ( - Path('icrp116') / 'positrons.txt', _LIMITED_GEOMETRIES), - ('icrp116', 'effective', 'proton'): ( - Path('icrp116') / 'protons.txt', _FULL_GEOMETRIES), - ('icrp74', 'ambient', 'neutron'): ( - Path('icrp74') / 'neutrons_H10.txt', None), - ('icrp74', 'ambient', 'photon'): ( - Path('icrp74') / 'photons_H10.txt', None), -} - -_DOSE_TABLES = {} - - -def _load_dose_table(data_source: str, dose_quantity: str, particle: str): - """Load dose tables from text files. - - Parameters - ---------- - data_source : {'icrp74', 'icrp116'} - The dose conversion data source to use - dose_quantity : {'effective', 'ambient'} - Dose quantity to load. 'ambient' corresponds to ambient dose - equivalent H*(10). - particle : {'neutron', 'photon', 'photon kerma', 'electron', 'positron'} - Incident particle - - """ - key = (data_source, dose_quantity, particle) - path = Path(__file__).parent / _TABLES[key][0] - data = np.loadtxt(path, skiprows=3, encoding='utf-8') - data[:, 0] *= 1e6 # Change energies to eV - _DOSE_TABLES[key] = data - - -def dose_coefficients( - particle, geometry='AP', data_source='icrp116', dose_quantity='effective' -): - """Return dose conversion coefficients. - - This function provides fluence (and air kerma) to effective dose or ambient - dose equivalent (H*(10)) conversion coefficients for various types of - external exposures based on values in ICRP publications. Corrected values - found in a corrigendum are used rather than the values in the original - report. Available libraries include `ICRP Publication 74 - ` and `ICRP Publication 116 - `. - - For ICRP 74 data, the photon effective dose per fluence is determined by - multiplying the air kerma per fluence values (Table A.1) by the effective - dose per air kerma (Table A.17). The neutron effective dose per fluence is - found in Table A.41. For ICRP 116 data, the photon effective dose per - fluence is found in Table A.1 and the neutron effective dose per fluence is - found in Table A.5. - - Parameters - ---------- - particle : {'neutron', 'photon', 'photon kerma', 'electron', 'positron'} - Incident particle - geometry : {'AP', 'PA', 'LLAT', 'RLAT', 'ROT', 'ISO'} - Irradiation geometry assumed for effective dose coefficients. Refer to - ICRP-116 (Section 3.2) for the meaning of the options here. This - argument does not apply when ``dose_quantity`` is 'ambient'. - data_source : {'icrp74', 'icrp116'} - The data source for the dose conversion coefficients. - dose_quantity : {'effective', 'ambient'} - Dose quantity to return. 'effective' returns effective dose - coefficients; 'ambient' returns ambient dose equivalent (H*(10)) - coefficients. - - Returns - ------- - energy : numpy.ndarray - Energies at which dose conversion coefficients are given - dose_coeffs : numpy.ndarray - Dose coefficients in [pSv cm^2] at provided energies. For 'photon - kerma', the coefficients are given in [Sv/Gy]. - - """ - - cv.check_value('geometry', geometry, _FULL_GEOMETRIES) - cv.check_value('data_source', data_source, {'icrp74', 'icrp116'}) - cv.check_value('dose_quantity', dose_quantity, {'effective', 'ambient'}) - - key = (data_source, dose_quantity, particle) - if key not in _TABLES: - available_particles = sorted( - p for ds, dq, p in _TABLES - if ds == data_source and dq == dose_quantity - ) - msg = ( - f"'{particle}' has no {dose_quantity} dose data in data source " - f"{data_source}. Available particles for {data_source} " - f"with dose quantity {dose_quantity} are: {available_particles}" - ) - raise ValueError(msg) - elif key not in _DOSE_TABLES: - _load_dose_table(data_source, dose_quantity, particle) - - data = _DOSE_TABLES[key] - columns = _TABLES[key][1] - - if columns is None: - if geometry != 'AP': - raise ValueError( - "Irradiation geometry is not defined for ambient dose " - "equivalent coefficients. Use the default geometry='AP'." - ) - index = 0 - else: - index = columns.index(geometry) - - energy = data[:, 0].copy() - dose_coeffs = data[:, index + 1].copy() - return energy, dose_coeffs diff --git a/openmc/data/dose/icrp74/generate_photon_effective_dose.py b/openmc/data/dose/icrp74/generate_photon_effective_dose.py deleted file mode 100644 index f8e970137..000000000 --- a/openmc/data/dose/icrp74/generate_photon_effective_dose.py +++ /dev/null @@ -1,69 +0,0 @@ -from prettytable import PrettyTable -import numpy as np - -# Data from Table A.1 (air kerma per fluence) -energy_a1 = np.array([ - 0.01, 0.015, 0.02, 0.03, 0.04, 0.05, 0.06, 0.08, 0.1, 0.15, 0.2, - 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0 -]) -air_kerma = np.array([7.43, 3.12, 1.68, 0.721, 0.429, 0.323, 0.289, 0.307, 0.371, 0.599, 0.856, 1.38, - 1.89, 2.38, 2.84, 3.69, 4.47, 6.14, 7.55, 9.96, 12.1, 14.1, 16.1, 20.1, 24.0]) - -# Data from Table A.17 (effective dose per air kerma) -energy_a17 = np.array([ - 0.01, 0.015, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.1, 0.15, 0.2, 0.3, - 0.4, 0.5, 0.6, 0.8, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0 -]) -dose_per_airkerma = { - 'AP': np.array([ - 0.00653, 0.0402, 0.122, 0.416, 0.788, 1.106, 1.308, 1.407, 1.433, 1.394, - 1.256, 1.173, 1.093, 1.056, 1.036, 1.024, 1.010, 1.003, 0.992, 0.993, - 0.993, 0.991, 0.990 - ]), - 'PA': np.array([ - 0.00248, 0.00586, 0.0181, 0.128, 0.370, 0.640, 0.846, 0.966, 1.019, - 1.030, 0.959, 0.915, 0.880, 0.871, 0.869, 0.870, 0.875, 0.880, 0.901, - 0.918, 0.924, 0.927, 0.929 - ]), - 'RLAT': np.array([ - 0.00172, 0.00549, 0.0151, 0.0782, 0.205, 0.345, 0.455, 0.522, 0.554, - 0.571, 0.551, 0.549, 0.557, 0.570, 0.585, 0.600, 0.628, 0.651, 0.728, - 0.796, 0.827, 0.846, 0.860 - ]), - 'LLAT': np.array([ - 0.00172, 0.00549, 0.0155, 0.0904, 0.241, 0.405, 0.528, 0.598, 0.628, - 0.641, 0.620, 0.615, 0.615, 0.623, 0.635, 0.648, 0.670, 0.691, 0.757, - 0.813, 0.836, 0.850, 0.859 - ]), - 'ROT': np.array([ - 0.00326, 0.0153, 0.0462, 0.191, 0.426, 0.661, 0.828, 0.924, 0.961, - 0.960, 0.892, 0.854, 0.824, 0.814, 0.812, 0.814, 0.821, 0.831, 0.871, - 0.909, 0.925, 0.934, 0.941 - ]), - 'ISO': np.array([ - 0.00271, 0.0123, 0.0362, 0.143, 0.326, 0.511, 0.642, 0.720, 0.749, - 0.748, 0.700, 0.679, 0.664, 0.667, 0.675, 0.684, 0.703, 0.719, 0.774, - 0.824, 0.846, 0.859, 0.868 - ]) -} - -# Interpolate air kerma onto energy grid for Table A.17 -air_kerma = np.interp(energy_a17, energy_a1, air_kerma) - -# Compute effective dose per fluence -dose_per_fluence = { - geometry: air_kerma * dose_per_airkerma - for geometry, dose_per_airkerma in dose_per_airkerma.items() -} - -# Create table -table = PrettyTable() -table.field_names = ['Energy (MeV)', 'AP', 'PA', 'LLAT', 'RLAT', 'ROT', 'ISO'] -table.float_format = '.7' -for i, energy in enumerate(energy_a17): - row = [energy] - for geometry in table.field_names[1:]: - row.append(dose_per_fluence[geometry][i]) - table.add_row(row) -print('Photons: Effective dose per fluence, in units of pSv cm², for monoenergetic particles incident in various geometries.\n') -print(table.get_string(border=False)) diff --git a/openmc/data/dose/icrp74/neutrons.txt b/openmc/data/dose/icrp74/neutrons.txt deleted file mode 100644 index 14aab48bd..000000000 --- a/openmc/data/dose/icrp74/neutrons.txt +++ /dev/null @@ -1,50 +0,0 @@ -Neutrons: Effective dose per fluence, in units of pSv cm², for monoenergetic particles incident in various geometries. - -Energy (MeV) AP PA LLAT RLAT ROT ISO -1.00E-09 5.24 3.52 1.68 1.36 2.99 2.4 -1.00E-08 6.55 4.39 2.04 1.7 3.72 2.89 -2.50E-08 7.6 5.16 2.31 1.99 4.4 3.3 -1.00E-07 9.95 6.77 2.86 2.58 5.75 4.13 -2.00E-07 11.2 7.63 3.21 2.92 6.43 4.59 -5.00E-07 12.8 8.76 3.72 3.35 7.27 5.2 -1.00E-06 13.8 9.55 4.12 3.67 7.84 5.63 -2.00E-06 14.5 10.2 4.39 3.89 8.31 5.96 -5.00E-06 15 10.7 4.66 4.08 8.72 6.28 -1.00E-05 15.1 11 4.8 4.16 8.9 6.44 -2.00E-05 15.1 11.1 4.89 4.2 8.92 6.51 -5.00E-05 14.8 11.1 4.95 4.19 8.82 6.51 -1.00E-04 14.6 11 4.95 4.15 8.69 6.45 -2.00E-04 14.4 10.9 4.92 4.1 8.56 6.32 -5.00E-04 14.2 10.7 4.86 4.03 8.4 6.14 -1.00E-03 14.2 10.7 4.84 4 8.34 6.04 -2.00E-03 14.4 10.8 4.87 4 8.39 6.05 -5.00E-03 15.7 11.6 5.25 4.29 9.06 6.52 -1.00E-02 18.3 13.5 6.14 5.02 10.6 7.7 -2.00E-02 23.8 17.3 7.95 6.48 13.8 10.2 -3.00E-02 29 21 9.74 7.93 16.9 12.7 -5.00E-02 38.5 27.6 13.1 10.6 22.7 17.3 -7.00E-02 47.2 33.5 16.1 13.1 27.8 21.5 -1.00E-01 59.8 41.3 20.1 16.4 34.8 27.2 -1.50E-01 80.2 52.2 25.5 21.2 45.4 35.2 -2.00E-01 99 61.5 30.3 25.6 54.8 42.4 -3.00E-01 133 77.1 38.6 33.4 71.6 54.7 -5.00E-01 188 103 53.2 46.8 99.4 75 -7.00E-01 231 124 66.6 58.3 123 92.8 -9.00E-01 267 144 79.6 69.1 144 108 -1 282 154 86 74.5 154 116 -1.2 310 175 99.8 85.8 173 130 -2 383 247 153 129 234 178 -3 432 308 195 171 283 220 -4 458 345 224 198 315 250 -5 474 366 244 217 335 272 -6 483 380 261 232 348 282 -7 490 391 274 244 358 290 -8 494 399 285 253 366 297 -9 497 406 294 261 373 303 -1.00E+01 499 412 302 268 378 309 -1.20E+01 499 422 315 278 385 322 -1.40E+01 496 429 324 286 390 333 -1.50E+01 494 431 328 290 391 338 -1.60E+01 491 433 331 293 393 342 -1.80E+01 486 435 335 299 394 345 -2.00E+01 480 436 338 305 395 343 diff --git a/openmc/data/dose/icrp74/neutrons_H10.txt b/openmc/data/dose/icrp74/neutrons_H10.txt deleted file mode 100644 index fe0036cbc..000000000 --- a/openmc/data/dose/icrp74/neutrons_H10.txt +++ /dev/null @@ -1,50 +0,0 @@ -Neutrons: Ambient per fluence, in units of pSv cm², for monoenergetic particles incident. - -Energy (MeV) Dose - 1.00E-09 6.60 - 1.00E-08 9.00 - 2.53E-08 10.6 - 1.00E-07 12.9 - 2.00E-07 13.5 - 5.00E-07 13.6 - 1.00E-06 13.3 - 2.00E-06 12.9 - 5.00E-06 12.0 - 1.00E-05 11.3 - 2.00E-05 10.6 - 5.00E-05 9.90 - 1.00E-04 9.40 - 2.00E-04 8.90 - 5.00E-04 8.30 - 1.00E-03 7.90 - 2.00E-03 7.70 - 5.00E-03 8.00 - 1.00E-02 10.5 - 2.00E-02 16.6 - 3.00E-02 23.7 - 5.00E-02 41.1 - 7.00E-02 60.0 - 1.00E-01 88.0 - 1.50E-01 132 - 2.00E-01 170 - 3.00E-01 233 - 5.00E-01 322 - 7.00E-01 375 - 9.00E-01 400 - 1 416 - 1.2 425 - 2 420 - 3 412 - 4 408 - 5 405 - 6 400 - 7 405 - 8 409 - 9 420 - 10 440 - 12 480 - 14 520 - 15 540 - 16 555 - 18 570 - 20 600 \ No newline at end of file diff --git a/openmc/data/dose/icrp74/photons.txt b/openmc/data/dose/icrp74/photons.txt deleted file mode 100644 index 1ce3d67e0..000000000 --- a/openmc/data/dose/icrp74/photons.txt +++ /dev/null @@ -1,26 +0,0 @@ -Photons: Effective dose per fluence, in units of pSv cm², for monoenergetic particles incident in various geometries. - - Energy (MeV) AP PA LLAT RLAT ROT ISO - 0.0100000 0.0485179 0.0184264 0.0127796 0.0127796 0.0242218 0.0201353 - 0.0150000 0.1254240 0.0182832 0.0171288 0.0171288 0.0477360 0.0383760 - 0.0200000 0.2049600 0.0304080 0.0260400 0.0253680 0.0776160 0.0608160 - 0.0300000 0.2999360 0.0922880 0.0651784 0.0563822 0.1377110 0.1031030 - 0.0400000 0.3380520 0.1587300 0.1033890 0.0879450 0.1827540 0.1398540 - 0.0500000 0.3572380 0.2067200 0.1308150 0.1114350 0.2135030 0.1650530 - 0.0600000 0.3780120 0.2444940 0.1525920 0.1314950 0.2392920 0.1855380 - 0.0700000 0.4192860 0.2878680 0.1782040 0.1555560 0.2753520 0.2145600 - 0.0800000 0.4399310 0.3128330 0.1927960 0.1700780 0.2950270 0.2299430 - 0.1000000 0.5171740 0.3821300 0.2378110 0.2118410 0.3561600 0.2775080 - 0.1500000 0.7523440 0.5744410 0.3713800 0.3300490 0.5343080 0.4193000 - 0.2000000 1.0040880 0.7832400 0.5264400 0.4699440 0.7310240 0.5812240 - 0.3000000 1.5083400 1.2144000 0.8487000 0.7686600 1.1371200 0.9163200 - 0.4000000 1.9958400 1.6461900 1.1774700 1.0773000 1.5384600 1.2606300 - 0.5000000 2.4656800 2.0682200 1.5113000 1.3923000 1.9325600 1.6065000 - 0.6000000 2.9081600 2.4708000 1.8403200 1.7040000 2.3117600 1.9425600 - 0.8000000 3.7269000 3.2287500 2.4723000 2.3173200 3.0294900 2.5940700 - 1.0000000 4.4834100 3.9336000 3.0887700 2.9099700 3.7145700 3.2139300 - 2.0000000 7.4896000 6.8025500 5.7153500 5.4964000 6.5760500 5.8437000 - 4.0000000 12.0153000 11.1078000 9.8373000 9.6316000 10.9989000 9.9704000 - 6.0000000 15.9873000 14.8764000 13.4596000 13.3147000 14.8925000 13.6206000 - 8.0000000 19.9191000 18.6327000 17.0850000 17.0046000 18.7734000 17.2659000 - 10.0000000 23.7600000 22.2960000 20.6160000 20.6400000 22.5840000 20.8320000 diff --git a/openmc/data/dose/icrp74/photons_H10.txt b/openmc/data/dose/icrp74/photons_H10.txt deleted file mode 100644 index 66031b2f0..000000000 --- a/openmc/data/dose/icrp74/photons_H10.txt +++ /dev/null @@ -1,28 +0,0 @@ -Photons: Ambient dose (H*10) per fluence, in units of pSv cm² - -Energy (MeV) Dose -0.010 0.061 -0.015 0.83 -0.020 1.05 -0.030 0.81 -0.040 0.64 -0.050 0.55 -0.060 0.51 -0.080 0.53 -0.100 0.61 -0.150 0.89 -0.200 1.20 -0.300 1.80 -0.400 2.38 -0.500 2.93 -0.600 3.44 -0.800 4.38 -1 5.20 -1.5 6.90 -2 8.60 -3 11.1 -4 13.4 -5 15.5 -6 17.6 -8 21.6 -10 25.6 \ No newline at end of file diff --git a/openmc/data/dose/mass_attenuation.h5 b/openmc/data/dose/mass_attenuation.h5 deleted file mode 100644 index f62785140..000000000 Binary files a/openmc/data/dose/mass_attenuation.h5 and /dev/null differ diff --git a/openmc/data/dose/mass_attenuation.py b/openmc/data/dose/mass_attenuation.py deleted file mode 100644 index c4260480b..000000000 --- a/openmc/data/dose/mass_attenuation.py +++ /dev/null @@ -1,153 +0,0 @@ -from pathlib import Path - -import numpy as np -import h5py - -import openmc.checkvalue as cv -from openmc.data import EV_PER_MEV -from ..data import ATOMIC_NUMBER -from ..function import Tabulated1D - -# Embedded NIST-126 data -# Air (Dry Near Sea Level) — NIST Standard Reference Database 126 Table 4 (doi: 10.18434/T4D01F) -# Columns: Energy (MeV), μ_en/ρ (cm^2/g) -_NIST126_AIR = np.array([ - [1.00000e-03, 3.599e03], - [1.50000e-03, 1.188e03], - [2.00000e-03, 5.262e02], - [3.00000e-03, 1.614e02], - [3.20290e-03, 1.330e02], - [3.20290e-03, 1.460e02], - [4.00000e-03, 7.636e01], - [5.00000e-03, 3.931e01], - [6.00000e-03, 2.270e01], - [8.00000e-03, 9.446e00], - [1.00000e-02, 4.742e00], - [1.50000e-02, 1.334e00], - [2.00000e-02, 5.389e-01], - [3.00000e-02, 1.537e-01], - [4.00000e-02, 6.833e-02], - [5.00000e-02, 4.098e-02], - [6.00000e-02, 3.041e-02], - [8.00000e-02, 2.407e-02], - [1.00000e-01, 2.325e-02], - [1.50000e-01, 2.496e-02], - [2.00000e-01, 2.672e-02], - [3.00000e-01, 2.872e-02], - [4.00000e-01, 2.949e-02], - [5.00000e-01, 2.966e-02], - [6.00000e-01, 2.953e-02], - [8.00000e-01, 2.882e-02], - [1.00000e00, 2.789e-02], - [1.25000e00, 2.666e-02], - [1.50000e00, 2.547e-02], - [2.00000e00, 2.345e-02], - [3.00000e00, 2.057e-02], - [4.00000e00, 1.870e-02], - [5.00000e00, 1.740e-02], - [6.00000e00, 1.647e-02], - [8.00000e00, 1.525e-02], - [1.00000e01, 1.450e-02], - [1.50000e01, 1.353e-02], - [2.00000e01, 1.311e-02], -]) - -# Registry of embedded tables: (data_source, material) -> ndarray -# Table shape: (N, 2) with columns [Energy (MeV), μen/ρ (cm^2/g)] -_MUEN_TABLES = { - ("nist126", "air"): _NIST126_AIR, -} - - -def mass_energy_absorption_coefficient( - material: str, data_source: str = "nist126" -) -> Tabulated1D: - r"""Return the mass energy-absorption coefficient as a function of energy. - - The mass energy-absorption coefficient, :math:`\mu_\text{en}/\rho`, is - defined as the fraction of incident photon energy absorbed in a material per - unit mass less the energy carried away by scattered photons. It is obtained - from `NIST Standard Reference Database 126 - `_: X-Ray Mass Attenuation Coefficients. - - Parameters - ---------- - material : {'air'} - Material compound for which to load coefficients. - data_source : {'nist126'} - Source library. - - Returns - ------- - Tabulated1D - Mass energy-absorption coefficient [cm^2/g] as a function of photon - energy [eV], using log-log interpolation. - - """ - cv.check_value("material", material, {"air"}) - cv.check_value("data_source", data_source, {"nist126"}) - - key = (data_source, material) - if key not in _MUEN_TABLES: - available = sorted({m for (ds, m) in _MUEN_TABLES.keys() if ds == data_source}) - raise ValueError( - f"No mass energy-absorption data for '{material}' in data source " - f"'{data_source}'. Available materials: {available}" - ) - - data = _MUEN_TABLES[key] - energy = data[:, 0].copy() * EV_PER_MEV # MeV -> eV - mu_en_coeffs = data[:, 1].copy() - return Tabulated1D(energy, mu_en_coeffs, - breakpoints=[len(energy)], interpolation=[5]) - - -# Used in mass_attenuation_coefficient function as a cache. -# Maps atomic number Z (int) -> Tabulated1D of (mu/rho) [cm^2/g] vs E [eV] -_MASS_ATTENUATION: dict[int, object] = {} - - -def mass_attenuation_coefficient(element): - r"""Return the photon mass attenuation coefficient as a function of energy. - - The mass energy-absorption coefficient, :math:`\mu_\text{en}/\rho`, is - defined as the fraction of incident photon energy absorbed in a material per - unit mass. Values for each element are obtained from `NIST Standard - Reference Database 8 `_: XCOM Photon Cross - Sections Database. - - Parameters - ---------- - element : str or int - Element symbol (e.g., 'Fe') or atomic number (e.g., 26). - - Returns - ------- - Tabulated1D - Mass attenuation coefficient [cm^2/g] as a function of photon energy - [eV], using log-log interpolation. - - """ - if not _MASS_ATTENUATION: - data_file = Path(__file__).with_name('mass_attenuation.h5') - with h5py.File(data_file, 'r') as f: - for key, dataset in f.items(): - energies, mu_rho = dataset[()] # shape (2, N) - _MASS_ATTENUATION[int(key)] = Tabulated1D( - energies, mu_rho, - breakpoints=[len(energies)], - interpolation=[5] # log-log - ) - - # Resolve element argument to atomic number - if isinstance(element, str): - if element not in ATOMIC_NUMBER: - raise ValueError(f"'{element}' is not a recognized element symbol") - Z = ATOMIC_NUMBER[element] - else: - Z = int(element) - - if Z not in _MASS_ATTENUATION: - raise ValueError(f"No mass attenuation data available for Z={Z}") - - return _MASS_ATTENUATION[Z] diff --git a/openmc/data/dose/__init__.py b/openmc/data/effective_dose/__init__.py similarity index 100% rename from openmc/data/dose/__init__.py rename to openmc/data/effective_dose/__init__.py diff --git a/openmc/data/effective_dose/dose.py b/openmc/data/effective_dose/dose.py new file mode 100644 index 000000000..ae981ee7d --- /dev/null +++ b/openmc/data/effective_dose/dose.py @@ -0,0 +1,74 @@ +from pathlib import Path + +import numpy as np + +_FILES = ( + ('electron', 'electrons.txt'), + ('helium', 'helium_ions.txt'), + ('mu-', 'negative_muons.txt'), + ('pi-', 'negative_pions.txt'), + ('neutron', 'neutrons.txt'), + ('photon', 'photons.txt'), + ('photon kerma', 'photons_kerma.txt'), + ('mu+', 'positive_muons.txt'), + ('pi+', 'positive_pions.txt'), + ('positron', 'positrons.txt'), + ('proton', 'protons.txt') +) + +_DOSE_ICRP116 = {} + + +def _load_dose_icrp116(): + """Load effective dose tables from text files""" + for particle, filename in _FILES: + path = Path(__file__).parent / filename + data = np.loadtxt(path, skiprows=3, encoding='utf-8') + data[:, 0] *= 1e6 # Change energies to eV + _DOSE_ICRP116[particle] = data + + +def dose_coefficients(particle, geometry='AP'): + """Return effective dose conversion coefficients from ICRP-116 + + This function provides fluence (and air kerma) to effective dose conversion + coefficients for various types of external exposures based on values in + `ICRP Publication 116 `_. + Corrected values found in a correigendum are used rather than the values in + theoriginal report. + + Parameters + ---------- + particle : {'neutron', 'photon', 'photon kerma', 'electron', 'positron'} + Incident particle + geometry : {'AP', 'PA', 'LLAT', 'RLAT', 'ROT', 'ISO'} + Irradiation geometry assumed. Refer to ICRP-116 (Section 3.2) for the + meaning of the options here. + + Returns + ------- + energy : numpy.ndarray + Energies at which dose conversion coefficients are given + dose_coeffs : numpy.ndarray + Effective dose coefficients in [pSv cm^2] at provided energies. For + 'photon kerma', the coefficients are given in [Sv/Gy]. + + """ + if not _DOSE_ICRP116: + _load_dose_icrp116() + + # Get all data for selected particle + data = _DOSE_ICRP116.get(particle) + if data is None: + raise ValueError(f"{particle} has no effective dose data") + + # Determine index for selected geometry + if particle in ('neutron', 'photon', 'proton', 'photon kerma'): + index = ('AP', 'PA', 'LLAT', 'RLAT', 'ROT', 'ISO').index(geometry) + else: + index = ('AP', 'PA', 'ISO').index(geometry) + + # Pull out energy and dose from table + energy = data[:, 0].copy() + dose_coeffs = data[:, index + 1].copy() + return energy, dose_coeffs diff --git a/openmc/data/dose/icrp116/electrons.txt b/openmc/data/effective_dose/electrons.txt similarity index 100% rename from openmc/data/dose/icrp116/electrons.txt rename to openmc/data/effective_dose/electrons.txt diff --git a/openmc/data/dose/icrp116/helium_ions.txt b/openmc/data/effective_dose/helium_ions.txt similarity index 100% rename from openmc/data/dose/icrp116/helium_ions.txt rename to openmc/data/effective_dose/helium_ions.txt diff --git a/openmc/data/dose/icrp116/negative_muons.txt b/openmc/data/effective_dose/negative_muons.txt similarity index 100% rename from openmc/data/dose/icrp116/negative_muons.txt rename to openmc/data/effective_dose/negative_muons.txt diff --git a/openmc/data/dose/icrp116/negative_pions.txt b/openmc/data/effective_dose/negative_pions.txt similarity index 100% rename from openmc/data/dose/icrp116/negative_pions.txt rename to openmc/data/effective_dose/negative_pions.txt diff --git a/openmc/data/dose/icrp116/neutrons.txt b/openmc/data/effective_dose/neutrons.txt similarity index 100% rename from openmc/data/dose/icrp116/neutrons.txt rename to openmc/data/effective_dose/neutrons.txt diff --git a/openmc/data/dose/icrp116/photons.txt b/openmc/data/effective_dose/photons.txt similarity index 100% rename from openmc/data/dose/icrp116/photons.txt rename to openmc/data/effective_dose/photons.txt diff --git a/openmc/data/dose/icrp116/photons_kerma.txt b/openmc/data/effective_dose/photons_kerma.txt similarity index 100% rename from openmc/data/dose/icrp116/photons_kerma.txt rename to openmc/data/effective_dose/photons_kerma.txt diff --git a/openmc/data/dose/icrp116/positive_muons.txt b/openmc/data/effective_dose/positive_muons.txt similarity index 100% rename from openmc/data/dose/icrp116/positive_muons.txt rename to openmc/data/effective_dose/positive_muons.txt diff --git a/openmc/data/dose/icrp116/positive_pions.txt b/openmc/data/effective_dose/positive_pions.txt similarity index 100% rename from openmc/data/dose/icrp116/positive_pions.txt rename to openmc/data/effective_dose/positive_pions.txt diff --git a/openmc/data/dose/icrp116/positrons.txt b/openmc/data/effective_dose/positrons.txt similarity index 100% rename from openmc/data/dose/icrp116/positrons.txt rename to openmc/data/effective_dose/positrons.txt diff --git a/openmc/data/dose/icrp116/protons.txt b/openmc/data/effective_dose/protons.txt similarity index 100% rename from openmc/data/dose/icrp116/protons.txt rename to openmc/data/effective_dose/protons.txt diff --git a/openmc/data/endf.c b/openmc/data/endf.c new file mode 100644 index 000000000..dd5eee541 --- /dev/null +++ b/openmc/data/endf.c @@ -0,0 +1,57 @@ +#include + +//! Convert string representation of a floating point number into a double +// +//! This function handles converting floating point numbers from an ENDF 11 +//! character field into a double, covering all the corner cases. Floating point +//! numbers are allowed to contain whitespace (which is ignored). Also, in +//! exponential notation, it allows the 'e' to be omitted. A field containing +//! only whitespace is to be interpreted as a zero. +// +//! \param buffer character input from an ENDF file +//! \param n Length of character input +//! \return Floating point number + +double cfloat_endf(const char* buffer, int n) +{ + char arr[13]; // 11 characters plus e and a null terminator + int j = 0; // current position in arr + int found_significand = 0; + int found_exponent = 0; + + // limit n to 11 characters + n = n > 11 ? 11 : n; + + int i; + for (i = 0; i < n; ++i) { + char c = buffer[i]; + + // Skip whitespace characters + if (c == ' ') continue; + + if (found_significand) { + if (!found_exponent) { + if (c == '+' || c == '-') { + // In the case that we encounter +/- and we haven't yet encountered + // e/E, we manually add it + arr[j++] = 'e'; + found_exponent = 1; + + } else if (c == 'e' || c == 'E' || c == 'd' || c == 'D') { + arr[j++] = 'e'; + found_exponent = 1; + continue; + } + } + } else if (c == '.' || (c >= '0' && c <= '9')) { + found_significand = 1; + } + + // Copy character + arr[j++] = c; + } + + // Done copying. Add null terminator and convert to double + arr[j] = '\0'; + return atof(arr); +} diff --git a/openmc/data/endf.py b/openmc/data/endf.py index edd8afffb..73299723a 100644 --- a/openmc/data/endf.py +++ b/openmc/data/endf.py @@ -1,47 +1,367 @@ """Module for parsing and manipulating data from ENDF evaluations. -All the classes and functions in this module are based on document ENDF-102 -titled "Data Formats and Procedures for the Evaluated Nuclear Data File ENDF-6". -The version from September 2023 can be found at -https://www.nndc.bnl.gov/endfdocs/ENDF-102-2023.pdf +All the classes and functions in this module are based on document +ENDF-102 titled "Data Formats and Procedures for the Evaluated Nuclear +Data File ENDF-6". The latest version from June 2009 can be found at +http://www-nds.iaea.org/ndspub/documents/endf/endf102/endf102.pdf """ import io from pathlib import PurePath import re +import numpy as np + from .data import gnds_name from .function import Tabulated1D -from endf.material import ( - Material, - _LIBRARY, - _SUBLIBRARY, - get_materials as get_evaluations, -) -from endf.incident_neutron import SUM_RULES -from endf.records import ( - float_endf, - py_float_endf, - int_endf, - get_text_record, - get_cont_record, - get_head_record, - get_list_record, - get_tab1_record as _get_tab1_record, - get_tab2_record, - get_intg_record, -) +try: + from ._endf import float_endf + _CYTHON = True +except ImportError: + _CYTHON = False + + +_LIBRARY = {0: 'ENDF/B', 1: 'ENDF/A', 2: 'JEFF', 3: 'EFF', + 4: 'ENDF/B High Energy', 5: 'CENDL', 6: 'JENDL', + 17: 'TENDL', 18: 'ROSFOND', 21: 'SG-21', 31: 'INDL/V', + 32: 'INDL/A', 33: 'FENDL', 34: 'IRDF', 35: 'BROND', + 36: 'INGDB-90', 37: 'FENDL/A', 41: 'BROND'} + +_SUBLIBRARY = { + 0: 'Photo-nuclear data', + 1: 'Photo-induced fission product yields', + 3: 'Photo-atomic data', + 4: 'Radioactive decay data', + 5: 'Spontaneous fission product yields', + 6: 'Atomic relaxation data', + 10: 'Incident-neutron data', + 11: 'Neutron-induced fission product yields', + 12: 'Thermal neutron scattering data', + 19: 'Neutron standards', + 113: 'Electro-atomic data', + 10010: 'Incident-proton data', + 10011: 'Proton-induced fission product yields', + 10020: 'Incident-deuteron data', + 10030: 'Incident-triton data', + 20030: 'Incident-helion (3He) data', + 20040: 'Incident-alpha data' +} + +SUM_RULES = {1: [2, 3], + 3: [4, 5, 11, 16, 17, 22, 23, 24, 25, 27, 28, 29, 30, 32, 33, 34, 35, + 36, 37, 41, 42, 44, 45, 152, 153, 154, 156, 157, 158, 159, 160, + 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, + 173, 174, 175, 176, 177, 178, 179, 180, 181, 183, 184, 185, + 186, 187, 188, 189, 190, 194, 195, 196, 198, 199, 200], + 4: list(range(50, 92)), + 16: list(range(875, 892)), + 18: [19, 20, 21, 38], + 27: [18, 101], + 101: [102, 103, 104, 105, 106, 107, 108, 109, 111, 112, 113, 114, + 115, 116, 117, 155, 182, 191, 192, 193, 197], + 103: list(range(600, 650)), + 104: list(range(650, 700)), + 105: list(range(700, 750)), + 106: list(range(750, 800)), + 107: list(range(800, 850))} + +ENDF_FLOAT_RE = re.compile(r'([\s\-\+]?\d*\.\d+)([\+\-]) ?(\d+)') + + +def py_float_endf(s): + """Convert string of floating point number in ENDF to float. + + The ENDF-6 format uses an 'e-less' floating point number format, + e.g. -1.23481+10. Trying to convert using the float built-in won't work + because of the lack of an 'e'. This function allows such strings to be + converted while still allowing numbers that are not in exponential notation + to be converted as well. + + Parameters + ---------- + s : str + Floating-point number from an ENDF file + + Returns + ------- + float + The number + + """ + return float(ENDF_FLOAT_RE.sub(r'\1e\2\3', s)) + + +if not _CYTHON: + float_endf = py_float_endf + + +def int_endf(s): + """Convert string of integer number in ENDF to int. + + The ENDF-6 format technically allows integers to be represented by a field + of all blanks. This function acts like int(s) except when s is a string of + all whitespace, in which case zero is returned. + + Parameters + ---------- + s : str + Integer or spaces + + Returns + ------- + integer + The number or 0 + """ + return 0 if s.isspace() else int(s) + + +def get_text_record(file_obj): + """Return data from a TEXT record in an ENDF-6 file. + + Parameters + ---------- + file_obj : file-like object + ENDF-6 file to read from + + Returns + ------- + str + Text within the TEXT record + + """ + return file_obj.readline()[:66] + + +def get_cont_record(file_obj, skip_c=False): + """Return data from a CONT record in an ENDF-6 file. + + Parameters + ---------- + file_obj : file-like object + ENDF-6 file to read from + skip_c : bool + Determine whether to skip the first two quantities (C1, C2) of the CONT + record. + + Returns + ------- + tuple + The six items within the CONT record + + """ + line = file_obj.readline() + if skip_c: + C1 = None + C2 = None + else: + C1 = float_endf(line[:11]) + C2 = float_endf(line[11:22]) + L1 = int_endf(line[22:33]) + L2 = int_endf(line[33:44]) + N1 = int_endf(line[44:55]) + N2 = int_endf(line[55:66]) + return (C1, C2, L1, L2, N1, N2) + + +def get_head_record(file_obj): + """Return data from a HEAD record in an ENDF-6 file. + + Parameters + ---------- + file_obj : file-like object + ENDF-6 file to read from + + Returns + ------- + tuple + The six items within the HEAD record + + """ + line = file_obj.readline() + ZA = int(float_endf(line[:11])) + AWR = float_endf(line[11:22]) + L1 = int_endf(line[22:33]) + L2 = int_endf(line[33:44]) + N1 = int_endf(line[44:55]) + N2 = int_endf(line[55:66]) + return (ZA, AWR, L1, L2, N1, N2) + + +def get_list_record(file_obj): + """Return data from a LIST record in an ENDF-6 file. + + Parameters + ---------- + file_obj : file-like object + ENDF-6 file to read from + + Returns + ------- + list + The six items within the header + list + The values within the list + + """ + # determine how many items are in list + items = get_cont_record(file_obj) + NPL = items[4] + + # read items + b = [] + for i in range((NPL - 1)//6 + 1): + line = file_obj.readline() + n = min(6, NPL - 6*i) + for j in range(n): + b.append(float_endf(line[11*j:11*(j + 1)])) + + return (items, b) def get_tab1_record(file_obj): """Return data from a TAB1 record in an ENDF-6 file. - This wraps the endf package's get_tab1_record to return an - openmc.data.Tabulated1D (which has HDF5 support and is a Function1D) - instead of endf.Tabulated1D. + Parameters + ---------- + file_obj : file-like object + ENDF-6 file to read from + + Returns + ------- + list + The six items within the header + openmc.data.Tabulated1D + The tabulated function + """ - params, tab = _get_tab1_record(file_obj) - return params, Tabulated1D(tab.x, tab.y, tab.breakpoints, tab.interpolation) + # Determine how many interpolation regions and total points there are + line = file_obj.readline() + C1 = float_endf(line[:11]) + C2 = float_endf(line[11:22]) + L1 = int_endf(line[22:33]) + L2 = int_endf(line[33:44]) + n_regions = int_endf(line[44:55]) + n_pairs = int_endf(line[55:66]) + params = [C1, C2, L1, L2] + + # Read the interpolation region data, namely NBT and INT + breakpoints = np.zeros(n_regions, dtype=int) + interpolation = np.zeros(n_regions, dtype=int) + m = 0 + for i in range((n_regions - 1)//3 + 1): + line = file_obj.readline() + to_read = min(3, n_regions - m) + for j in range(to_read): + breakpoints[m] = int_endf(line[0:11]) + interpolation[m] = int_endf(line[11:22]) + line = line[22:] + m += 1 + + # Read tabulated pairs x(n) and y(n) + x = np.zeros(n_pairs) + y = np.zeros(n_pairs) + m = 0 + for i in range((n_pairs - 1)//3 + 1): + line = file_obj.readline() + to_read = min(3, n_pairs - m) + for j in range(to_read): + x[m] = float_endf(line[:11]) + y[m] = float_endf(line[11:22]) + line = line[22:] + m += 1 + + return params, Tabulated1D(x, y, breakpoints, interpolation) + + +def get_tab2_record(file_obj): + # Determine how many interpolation regions and total points there are + params = get_cont_record(file_obj) + n_regions = params[4] + + # Read the interpolation region data, namely NBT and INT + breakpoints = np.zeros(n_regions, dtype=int) + interpolation = np.zeros(n_regions, dtype=int) + m = 0 + for i in range((n_regions - 1)//3 + 1): + line = file_obj.readline() + to_read = min(3, n_regions - m) + for j in range(to_read): + breakpoints[m] = int(line[0:11]) + interpolation[m] = int(line[11:22]) + line = line[22:] + m += 1 + + return params, Tabulated2D(breakpoints, interpolation) + + +def get_intg_record(file_obj): + """ + Return data from an INTG record in an ENDF-6 file. Used to store the + covariance matrix in a compact format. + + Parameters + ---------- + file_obj : file-like object + ENDF-6 file to read from + + Returns + ------- + numpy.ndarray + The correlation matrix described in the INTG record + """ + # determine how many items are in list and NDIGIT + items = get_cont_record(file_obj) + ndigit = items[2] + npar = items[3] # Number of parameters + nlines = items[4] # Lines to read + NROW_RULES = {2: 18, 3: 12, 4: 11, 5: 9, 6: 8} + nrow = NROW_RULES[ndigit] + + # read lines and build correlation matrix + corr = np.identity(npar) + for i in range(nlines): + line = file_obj.readline() + ii = int_endf(line[:5]) - 1 # -1 to account for 0 indexing + jj = int_endf(line[5:10]) - 1 + factor = 10**ndigit + for j in range(nrow): + if jj+j >= ii: + break + element = int_endf(line[11+(ndigit+1)*j:11+(ndigit+1)*(j+1)]) + if element > 0: + corr[ii, jj] = (element+0.5)/factor + elif element < 0: + corr[ii, jj] = (element-0.5)/factor + + # Symmetrize the correlation matrix + corr = corr + corr.T - np.diag(corr.diagonal()) + return corr + + +def get_evaluations(filename): + """Return a list of all evaluations within an ENDF file. + + Parameters + ---------- + filename : str + Path to ENDF-6 formatted file + + Returns + ------- + list + A list of :class:`openmc.data.endf.Evaluation` instances. + + """ + evaluations = [] + with open(str(filename), 'r') as fh: + while True: + pos = fh.tell() + line = fh.readline() + if line[66:70] == ' -1': + break + fh.seek(pos) + evaluations.append(Evaluation(fh)) + return evaluations class Evaluation: @@ -49,7 +369,7 @@ class Evaluation: Parameters ---------- - filename_or_obj : str, file-like, or endf.Material + filename_or_obj : str or file-like Path to ENDF file to read or an open file positioned at the start of an ENDF material @@ -69,25 +389,17 @@ class Evaluation: """ def __init__(self, filename_or_obj): - self.section = {} - self.info = {} - self.target = {} - self.projectile = {} - self.reaction_list = [] - - if isinstance(filename_or_obj, Material): - self.section = dict(filename_or_obj.section_text) - self.section_data = filename_or_obj.section_data - self.material = filename_or_obj.MAT - self._read_header() - return - if isinstance(filename_or_obj, (str, PurePath)): fh = open(str(filename_or_obj), 'r') need_to_close = True else: fh = filename_or_obj need_to_close = False + self.section = {} + self.info = {} + self.target = {} + self.projectile = {} + self.reaction_list = [] # Skip TPID record. Evaluators sometimes put in TPID records that are # ill-formated because they lack MF/MT values or put them in the wrong @@ -213,9 +525,23 @@ class Evaluation: self.target['isomeric_state']) -def as_evaluation(ev_or_filename): - """Return an object supporting OpenMC's legacy Evaluation interface.""" - if isinstance(ev_or_filename, Evaluation): - return ev_or_filename - else: - return Evaluation(ev_or_filename) +class Tabulated2D: + """Metadata for a two-dimensional function. + + This is a dummy class that is not really used other than to store the + interpolation information for a two-dimensional function. Once we refactor + to adopt GNDS-like data containers, this will probably be removed or + extended. + + Parameters + ---------- + breakpoints : Iterable of int + Breakpoints for interpolation regions + interpolation : Iterable of int + Interpolation scheme identification number, e.g., 3 means y is linear in + ln(x). + + """ + def __init__(self, breakpoints, interpolation): + self.breakpoints = breakpoints + self.interpolation = interpolation diff --git a/openmc/data/fission_energy.py b/openmc/data/fission_energy.py index e4fac087a..870881dba 100644 --- a/openmc/data/fission_energy.py +++ b/openmc/data/fission_energy.py @@ -5,8 +5,7 @@ from io import StringIO import openmc.checkvalue as cv from openmc.mixin import EqualityMixin from .data import EV_PER_MEV -from .endf import ( - as_evaluation, get_cont_record, get_list_record, get_tab1_record) +from .endf import get_cont_record, get_list_record, get_tab1_record, Evaluation from .function import Function1D, Tabulated1D, Polynomial, sum_functions @@ -45,7 +44,7 @@ class FissionEnergyRelease(EqualityMixin): ---------- [1] D. G. Madland, "Total prompt energy release in the neutron-induced fission of ^235U, ^238U, and ^239Pu", Nuclear Physics A 772:113--137 (2006). - + Attributes ---------- @@ -196,7 +195,7 @@ class FissionEnergyRelease(EqualityMixin): Parameters ---------- - ev : openmc.data.endf.Evaluation or endf.Material + ev : openmc.data.endf.Evaluation ENDF evaluation incident_neutron : openmc.data.IncidentNeutron Corresponding incident neutron dataset @@ -207,7 +206,7 @@ class FissionEnergyRelease(EqualityMixin): Fission energy release data """ - ev = as_evaluation(ev) + cv.check_type('evaluation', ev, Evaluation) # Check to make sure this ENDF file matches the expected isomer. if ev.target['atomic_number'] != incident_neutron.atomic_number: diff --git a/openmc/data/function.py b/openmc/data/function.py index c5914f513..23fd5e9d4 100644 --- a/openmc/data/function.py +++ b/openmc/data/function.py @@ -708,6 +708,28 @@ class ResonancesWithBackground(EqualityMixin): self.background = background self.mt = mt + def __call__(self, x): + # Get background cross section + xs = self.background(x) + + for r in self.resonances: + if not isinstance(r, openmc.data.resonance._RESOLVED): + continue + + if isinstance(x, Iterable): + # Determine which energies are within resolved resonance range + within = (r.energy_min <= x) & (x <= r.energy_max) + + # Get resonance cross sections and add to background + resonant_xs = r.reconstruct(x[within]) + xs[within] += resonant_xs[self.mt] + else: + if r.energy_min <= x <= r.energy_max: + resonant_xs = r.reconstruct(x) + xs += resonant_xs[self.mt] + + return xs + @property def background(self): return self._background diff --git a/openmc/data/library.py b/openmc/data/library.py index b49757b0d..a6ce1bbd3 100644 --- a/openmc/data/library.py +++ b/openmc/data/library.py @@ -5,7 +5,7 @@ import h5py import lxml.etree as ET import openmc -from openmc._xml import get_elem_list, get_text, clean_indentation +from openmc._xml import clean_indentation, reorder_attributes class DataLibrary(list): @@ -132,6 +132,7 @@ class DataLibrary(list): clean_indentation(root) # Write XML file + reorder_attributes(root) # TODO: Remove when support is Python 3.8+ tree = ET.ElementTree(root) tree.write(str(path), xml_declaration=True, encoding='utf-8', method='xml') @@ -172,9 +173,9 @@ class DataLibrary(list): directory = os.path.dirname(path) for lib_element in root.findall('library'): - filename = os.path.join(directory, get_text(lib_element, "path")) - filetype = get_text(lib_element, "type") - materials = get_elem_list(lib_element, "materials", str) or [] + filename = os.path.join(directory, lib_element.attrib['path']) + filetype = lib_element.attrib['type'] + materials = lib_element.attrib['materials'].split() library = {'path': filename, 'type': filetype, 'materials': materials} data.libraries.append(library) @@ -182,7 +183,7 @@ class DataLibrary(list): # get depletion chain data dep_node = root.find("depletion_chain") if dep_node is not None: - filename = os.path.join(directory, get_text(dep_node, "path")) + filename = os.path.join(directory, dep_node.attrib['path']) library = {'path': filename, 'type': 'depletion_chain', 'materials': []} data.libraries.append(library) diff --git a/openmc/data/multipole.py b/openmc/data/multipole.py index d843b5971..dd14e0d19 100644 --- a/openmc/data/multipole.py +++ b/openmc/data/multipole.py @@ -15,7 +15,7 @@ from . import WMP_VERSION, WMP_VERSION_MAJOR from .data import K_BOLTZMANN from .neutron import IncidentNeutron from .resonance import ResonanceRange -from .vectfit import vectfit, evaluate + # Constants that determine which value to access _MP_EA = 0 # Pole @@ -174,6 +174,10 @@ def _vectfit_xs(energy, ce_xs, mts, rtol=1e-3, atol=1e-5, orders=None, (poles, residues) """ + + # import vectfit package: https://github.com/liangjg/vectfit + import vectfit as vf + ne = energy.size nmt = len(mts) if ce_xs.shape != (nmt, ne): @@ -190,8 +194,8 @@ def _vectfit_xs(energy, ce_xs, mts, rtol=1e-3, atol=1e-5, orders=None, test_xs_ref[i] = np.interp(test_energy, energy, ce_xs[i]) if log: - print(f"\tenergy: {energy[0]:.3e} to {energy[-1]:.3e} eV ({ne} points)") - print(f"\terror tolerance: rtol={rtol}, atol={atol}") + print(f" energy: {energy[0]:.3e} to {energy[-1]:.3e} eV ({ne} points)") + print(f" error tolerance: rtol={rtol}, atol={atol}") # transform xs (sigma) and energy (E) to f (sigma*E) and s (sqrt(E)) to be # compatible with the multipole representation @@ -247,7 +251,7 @@ def _vectfit_xs(energy, ce_xs, mts, rtol=1e-3, atol=1e-5, orders=None, print(f"VF iteration {i_vf + 1}/{n_vf_iter}") # call vf - poles, residues, *_ = vectfit(f, s, poles, weight) + poles, residues, cf, f_fit, rms = vf.vectfit(f, s, poles, weight) # convert real pole to conjugate pairs n_real_poles = 0 @@ -264,11 +268,11 @@ def _vectfit_xs(energy, ce_xs, mts, rtol=1e-3, atol=1e-5, orders=None, if n_real_poles > 0: if log >= DETAILED_LOGGING: print(f" # real poles: {n_real_poles}") - new_poles, residues, *_ = \ - vectfit(f, s, new_poles, weight, skip_pole_update=True) + new_poles, residues, cf, f_fit, rms = \ + vf.vectfit(f, s, new_poles, weight, skip_pole=True) # assess the result on test grid - test_xs = evaluate(test_s, new_poles, residues) / test_energy + test_xs = vf.evaluate(test_s, new_poles, residues) / test_energy abserr = np.abs(test_xs - test_xs_ref) with np.errstate(invalid='ignore', divide='ignore'): relerr = abserr / test_xs_ref @@ -384,9 +388,9 @@ def _vectfit_xs(energy, ce_xs, mts, rtol=1e-3, atol=1e-5, orders=None, return (mp_poles, mp_residues) + def vectfit_nuclide(endf_file, njoy_error=5e-4, vf_pieces=None, - log=False, path_out=None, mp_filename=None, - **kwargs): + log=False, path_out=None, mp_filename=None, **kwargs): r"""Generate multipole data for a nuclide from ENDF. Parameters @@ -567,6 +571,10 @@ def _windowing(mp_data, n_cf, rtol=1e-3, atol=1e-5, n_win=None, spacing=None, format. """ + + # import vectfit package: https://github.com/liangjg/vectfit + import vectfit as vf + # unpack multipole data name = mp_data["name"] awr = mp_data["AWR"] @@ -637,7 +645,7 @@ def _windowing(mp_data, n_cf, rtol=1e-3, atol=1e-5, n_win=None, spacing=None, # reference xs from multipole form, note the residue terms in the # multipole and vector fitting representations differ by a 1j - xs_ref = evaluate(energy_sqrt, poles, residues*1j) / energy + xs_ref = vf.evaluate(energy_sqrt, poles, residues*1j) / energy # curve fit matrix matrix = np.vstack([energy**(0.5*i - 1) for i in range(n_cf + 1)]).T @@ -651,7 +659,7 @@ def _windowing(mp_data, n_cf, rtol=1e-3, atol=1e-5, n_win=None, spacing=None, # calculate the cross sections contributed by the windowed poles if rp > lp: - xs_wp = evaluate(energy_sqrt, poles[lp:rp], + xs_wp = vf.evaluate(energy_sqrt, poles[lp:rp], residues[:, lp:rp]*1j) / energy else: xs_wp = np.zeros_like(xs_ref) @@ -1046,15 +1054,7 @@ class WindowedMultipole(EqualityMixin): return cls.from_multipole(mp_data, **wmp_options) @classmethod - def from_multipole( - cls, - mp_data, - search=None, - log=False, - search_n_win=20, - search_cf_orders=None, - **kwargs, - ): + def from_multipole(cls, mp_data, search=None, log=False, **kwargs): """Generate windowed multipole neutron data from multipole data. Parameters @@ -1066,14 +1066,8 @@ class WindowedMultipole(EqualityMixin): Defaults to True if no windowing parameters are specified. log : bool or int, optional Whether to print running logs (use int for verbosity control) - search_n_win : int, optional - Number of window sizes to consider in the search grid when - ``search`` is True. - search_cf_orders : iterable of int, optional - Curve-fit orders to consider in the search grid when ``search`` is - True. Defaults to integers from 10 down to 2. **kwargs - Keyword arguments passed to :func:`openmc.data.multipole._windowing`. + Keyword arguments passed to :func:`openmc.data.multipole._windowing` Returns ------- @@ -1104,17 +1098,12 @@ class WindowedMultipole(EqualityMixin): # search optimal WMP from a range of window sizes and CF orders if log: print("Start searching ...") - if search_cf_orders is None: - search_cf_orders = range(10, 1, -1) - n_poles = sum([p.size for p in mp_data["poles"]]) n_win_min = max(5, n_poles // 20) n_win_max = 2000 if n_poles < 2000 else 8000 best_wmp = best_metric = None - for n_w in np.unique( - np.linspace(n_win_min, n_win_max, search_n_win, dtype=int) - ): - for n_cf in search_cf_orders: + for n_w in np.unique(np.linspace(n_win_min, n_win_max, 20, dtype=int)): + for n_cf in range(10, 1, -1): if log: print(f"Testing N_win={n_w} N_cf={n_cf}") diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index f17bb3fe4..894be1871 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -11,13 +11,13 @@ import h5py from . import HDF5_VERSION, HDF5_VERSION_MAJOR from .ace import Library, Table, get_table, get_metadata -from .data import ATOMIC_SYMBOL, K_BOLTZMANN, EV_PER_MEV, gnds_name +from .data import ATOMIC_SYMBOL, K_BOLTZMANN, EV_PER_MEV from .endf import ( - Evaluation, SUM_RULES, as_evaluation, get_head_record, get_tab1_record, - get_evaluations) + Evaluation, SUM_RULES, get_head_record, get_tab1_record, get_evaluations) from .fission_energy import FissionEnergyRelease from .function import Tabulated1D, Sum, ResonancesWithBackground -from .njoy import make_ace, make_pendf +from .grid import linearize, thin +from .njoy import make_ace from .product import Product from .reaction import Reaction, _get_photon_products_ace, FISSION_MTS from . import resonance as res @@ -286,7 +286,7 @@ class IncidentNeutron(EqualityMixin): if strT in data.urr: self.urr[strT] = data.urr[strT] - def add_elastic_0K_from_endf(self, filename, overwrite=False, **kwargs): + def add_elastic_0K_from_endf(self, filename, overwrite=False): """Append 0K elastic scattering cross section from an ENDF file. Parameters @@ -297,8 +297,6 @@ class IncidentNeutron(EqualityMixin): If existing 0 K data is present, this flag can be used to indicate that it should be overwritten. Otherwise, an exception will be thrown. - **kwargs - Keyword arguments passed to :func:`openmc.data.njoy.make_pendf` Raises ------ @@ -311,22 +309,75 @@ class IncidentNeutron(EqualityMixin): if '0K' in self.energy and not overwrite: raise ValueError('0 K data already exists for this nuclide.') - with tempfile.TemporaryDirectory() as tmpdir: - # Set arguments for make_pendf - pendf_path = os.path.join(tmpdir, 'pendf') - kwargs.setdefault('output_dir', tmpdir) - kwargs.setdefault('pendf', pendf_path) + data = type(self).from_endf(filename) + if data.resonances is not None: + x = [] + y = [] + for rr in data.resonances: + if isinstance(rr, res.RMatrixLimited): + raise TypeError('R-Matrix Limited not supported.') + elif isinstance(rr, res.Unresolved): + continue - # Run NJOY to create a pointwise ENDF file - make_pendf(filename, **kwargs) + # Get energies/widths for resonances + e_peak = rr.parameters['energy'].values + if isinstance(rr, res.MultiLevelBreitWigner): + gamma = rr.parameters['totalWidth'].values + elif isinstance(rr, res.ReichMoore): + df = rr.parameters + gamma = (df['neutronWidth'] + + df['captureWidth'] + + abs(df['fissionWidthA']) + + abs(df['fissionWidthB'])).values - # Add 0K elastic scattering cross section - pendf = Evaluation(pendf_path) - file_obj = StringIO(pendf.section[3, 2]) - get_head_record(file_obj) - params, xs = get_tab1_record(file_obj) - self.energy['0K'] = xs.x - self[2].xs['0K'] = xs + # Determine peak energies and widths + e_min, e_max = rr.energy_min, rr.energy_max + in_range = (e_peak > e_min) & (e_peak < e_max) + e_peak = e_peak[in_range] + gamma = gamma[in_range] + + # Get midpoints between resonances (use min/max energy of + # resolved region as absolute lower/upper bound) + e_mid = np.concatenate( + ([e_min], (e_peak[1:] + e_peak[:-1])/2, [e_max])) + + # Add grid around each resonance that includes the peak +/- the + # width times each value in _RESONANCE_ENERGY_GRID. Values are + # constrained so that points around one resonance don't overlap + # with points around another. This algorithm is from Fudge + # (https://doi.org/10.1063/1.1945057). + energies = [] + for e, g, e_lower, e_upper in zip(e_peak, gamma, e_mid[:-1], + e_mid[1:]): + e_left = e - g*_RESONANCE_ENERGY_GRID + energies.append(e_left[e_left > e_lower][::-1]) + e_right = e + g*_RESONANCE_ENERGY_GRID[1:] + energies.append(e_right[e_right < e_upper]) + + # Concatenate all points + energies = np.concatenate(energies) + + # Create 1000 equal log-spaced energies over RRR, combine with + # resonance peaks and half-height energies + e_log = np.logspace(log10(e_min), log10(e_max), 1000) + energies = np.union1d(e_log, energies) + + # Linearize and thin cross section + xi, yi = linearize(energies, data[2].xs['0K']) + xi, yi = thin(xi, yi) + + # If there are multiple resolved resonance ranges (e.g. Pu239 in + # ENDF/B-VII.1), combine them + x = np.concatenate((x, xi)) + y = np.concatenate((y, yi)) + else: + energies = data[2].xs['0K'].x + x, y = linearize(energies, data[2].xs['0K']) + x, y = thin(x, y) + + # Set 0K energy grid and elastic scattering cross section + self.energy['0K'] = x + self[2].xs['0K'] = Tabulated1D(x, y) def get_reaction_components(self, mt): """Determine what reactions make up redundant reaction. @@ -653,7 +704,7 @@ class IncidentNeutron(EqualityMixin): Parameters ---------- - ev_or_filename : openmc.data.endf.Evaluation, endf.Material, or str + ev_or_filename : openmc.data.endf.Evaluation or str ENDF evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -667,7 +718,10 @@ class IncidentNeutron(EqualityMixin): Incident neutron continuous-energy data """ - ev = as_evaluation(ev_or_filename) + if isinstance(ev_or_filename, Evaluation): + ev = ev_or_filename + else: + ev = Evaluation(ev_or_filename) atomic_number = ev.target['atomic_number'] mass_number = ev.target['mass_number'] @@ -676,7 +730,11 @@ class IncidentNeutron(EqualityMixin): temperature = ev.target['temperature'] # Determine name - name = gnds_name(atomic_number, mass_number, metastable) + element = ATOMIC_SYMBOL[atomic_number] + if metastable > 0: + name = f'{element}{mass_number}_m{metastable}' + else: + name = f'{element}{mass_number}' # Instantiate incident neutron data data = cls(name, atomic_number, mass_number, metastable, @@ -763,11 +821,6 @@ class IncidentNeutron(EqualityMixin): for table in lib.tables[1:]: data.add_temperature_from_ace(table) - # Use name based on ENDF evaluation. The name assigned by from_ace - # may be wrong for higher metastable states (e.g., Hf178_m2) - ev = evaluation if evaluation is not None else Evaluation(filename) - data.name = ev.gnds_name - # Add 0K elastic scattering cross section if '0K' not in data.energy: pendf = Evaluation(kwargs['pendf']) @@ -778,6 +831,7 @@ class IncidentNeutron(EqualityMixin): data[2].xs['0K'] = xs # Add fission energy release data + ev = evaluation if evaluation is not None else Evaluation(filename) if (1, 458) in ev.section: data.fission_energy = f = FissionEnergyRelease.from_endf(ev, data) else: @@ -803,7 +857,9 @@ class IncidentNeutron(EqualityMixin): # Helper function to get a cross section from an ENDF file on a # given energy grid def get_file3_xs(ev, mt, E): - xs = ev.section_data[3, mt]['sigma'] + file_obj = StringIO(ev.section[3, mt]) + get_head_record(file_obj) + _, xs = get_tab1_record(file_obj) return xs(E) heating_local = Reaction(901) diff --git a/openmc/data/njoy.py b/openmc/data/njoy.py index 7c99637f0..ac1b5e345 100644 --- a/openmc/data/njoy.py +++ b/openmc/data/njoy.py @@ -15,96 +15,24 @@ import openmc.data # identifiers. ThermalTuple = namedtuple('ThermalTuple', ['name', 'zaids', 'nmix']) _THERMAL_DATA = { - 'c_Ag': ThermalTuple('ag', [47107, 47109], 1), 'c_Al27': ThermalTuple('al27', [13027], 1), 'c_Al_in_Al2O3': ThermalTuple('asap00', [13027], 1), - 'c_Al_in_Y3Al5O12': ThermalTuple('alyag', [13027], 1), - 'c_Au': ThermalTuple('au', [79197], 1), 'c_Be': ThermalTuple('be', [4009], 1), - 'c_Be_distinct': ThermalTuple('besd', [4009], 1), 'c_Be_in_BeO': ThermalTuple('bebeo', [4009], 1), 'c_Be_in_Be2C': ThermalTuple('bebe2c', [4009], 1), - 'c_Be_in_BeF2': ThermalTuple('bebef2', [4009], 1), 'c_Be_in_FLiBe': ThermalTuple('beflib', [4009], 1), - 'c_BeO': ThermalTuple('beo', [4009, 8016, 8017, 8018], 2), - 'c_Bi': ThermalTuple('bi', [83209], 1), - 'c_Bi_in_Ge3Bi4O12': ThermalTuple('bigbo', [83209], 1), 'c_C6H6': ThermalTuple('benz', [1001, 6000, 6012], 2), - 'c_C_in_Be2C': ThermalTuple('cbe2c', [6000, 6012, 6013], 1), - 'c_C_in_C5O2H8': ThermalTuple('clucit', [6000, 6012, 6013], 1), - 'c_C_in_C8H8': ThermalTuple('cc8h8', [6000, 6012, 6013], 1), - 'c_C_in_C19H16_liquid': ThermalTuple('c19liq', [6000, 6012, 6013], 1), - 'c_C_in_C19H16_solid': ThermalTuple('c19sol', [6000, 6012, 6013], 1), - 'c_C_in_C2H6O_liquid': ThermalTuple('ethliq', [6000, 6012, 6013], 1), - 'c_C_in_C2H6O_solid': ThermalTuple('ethsol', [6000, 6012, 6013], 1), - 'c_C_in_C6H6_liquid': ThermalTuple('benzlq', [6000, 6012, 6013], 1), - 'c_C_in_C6H6_solid': ThermalTuple('benzsl', [6000, 6012, 6013], 1), - 'c_C_in_C7H8_liquid': ThermalTuple('tolliq', [6000, 6012, 6013], 1), - 'c_C_in_C7H8_solid': ThermalTuple('tolsol', [6000, 6012, 6013], 1), - 'c_C_in_C8H10_liquid': ThermalTuple('xylliq', [6000, 6012, 6013], 1), - 'c_C_in_C8H10_solid': ThermalTuple('xylsol', [6000, 6012, 6013], 1), - 'c_C_in_C9H12_liquid': ThermalTuple('mesliq', [6000, 6012, 6013], 1), - 'c_C_in_C9H12_solid': ThermalTuple('messol', [6000, 6012, 6013], 1), - 'c_C_in_CF2': ThermalTuple('ccf2', [6000, 6012, 6013], 1), - 'c_C_in_CH2': ThermalTuple('cch2', [6000, 6012, 6013], 1), - 'c_C_in_CH4_liquid': ThermalTuple('cch4lq', [6000, 6012, 6013], 1), - 'c_C_in_CH4_solid': ThermalTuple('cch4sl', [6000, 6012, 6013], 1), - 'c_C_in_Diamond': ThermalTuple('cdiam', [6000, 6012, 6013], 1), 'c_C_in_SiC': ThermalTuple('csic', [6000, 6012, 6013], 1), - 'c_C_in_UC_100p': ThermalTuple('cuc100', [6000, 6012, 6013], 1), - 'c_C_in_UC_10p': ThermalTuple('cuc10', [6000, 6012, 6013], 1), - 'c_C_in_UC_5p': ThermalTuple('cuc5', [6000, 6012, 6013], 1), - 'c_C_in_UC': ThermalTuple('cinuc', [6000, 6012, 6013], 1), - 'c_C_in_UC_HALEU': ThermalTuple('cuchal', [6000, 6012, 6013], 1), - 'c_C_in_UC_HEU': ThermalTuple('cucheu', [6000, 6012, 6013], 1), - 'c_C_in_ZrC': ThermalTuple('czrc', [6000, 6012, 6013], 1), - 'c_Ca': ThermalTuple('ca', [20040, 20042, 20043, 20044, 20046, 20048], 1), 'c_Ca_in_CaH2': ThermalTuple('cacah2', [20040, 20042, 20043, 20044, 20046, 20048], 1), - 'c_Ca_in_CaO2H2': ThermalTuple('cacaoh', [20040, 20042, 20043, 20044, 20046, 20048], 1), - 'c_Cr': ThermalTuple('cr', [24050, 24052, 24053, 24054], 1), - 'c_Cu': ThermalTuple('cu', [29063, 29065], 1), - 'c_D_in_7LiD': ThermalTuple('dlid', [1002], 1), 'c_D_in_D2O': ThermalTuple('dd2o', [1002], 1), 'c_D_in_D2O_solid': ThermalTuple('dice', [1002], 1), - 'c_D_in_MgD2': ThermalTuple('dmgd2', [1002], 1), - 'c_F_in_Be2': ThermalTuple('fbef2', [9019], 1), - 'c_F_in_CF2': ThermalTuple('fcf2', [9019], 1), 'c_F_in_FLiBe': ThermalTuple('fflibe', [9019], 1), - 'c_F_in_HF': ThermalTuple('f_hf', [9019], 1), - 'c_F_in_LiF': ThermalTuple('flif', [9019], 1), - 'c_F_in_MgF2': ThermalTuple('fmgf2', [9019], 1), 'c_Fe56': ThermalTuple('fe56', [26056], 1), - 'c_Fe_in_Fe_alpha': ThermalTuple('fealph', [26054, 26056, 26057, 26058], 1), - 'c_Fe_in_Fe_gamma': ThermalTuple('fegamm', [26054, 26056, 26057, 26058], 1), - 'c_Ga_in_GaN': ThermalTuple('gagan', [31069, 31071], 1), - 'c_Ga_in_GaSe': ThermalTuple('gagase', [31069, 31071], 1), - 'c_Ge': ThermalTuple('ge', [32070, 32072, 32073, 32074, 32076], 1), - 'c_Ge_in_Ge3Bi4O12': ThermalTuple('gegbo', [32070, 32072, 32073, 32074, 32076], 1), - 'c_Ge_in_GeTe': ThermalTuple('gegete', [32070, 32072, 32073, 32074, 32076], 1), 'c_Graphite': ThermalTuple('graph', [6000, 6012, 6013], 1), 'c_Graphite_10p': ThermalTuple('grph10', [6000, 6012, 6013], 1), - 'c_Graphite_20p': ThermalTuple('grph20', [6000, 6012, 6013], 1), 'c_Graphite_30p': ThermalTuple('grph30', [6000, 6012, 6013], 1), - 'c_Graphite_distinct': ThermalTuple('grphsd', [6000, 6012, 6013], 1), - 'c_H_in_7LiH': ThermalTuple('hlih', [1001], 1), 'c_H_in_C5O2H8': ThermalTuple('lucite', [1001], 1), - 'c_H_in_C8H8': ThermalTuple('hc8h8', [1001], 1), - 'c_H_in_C19H16_liquid': ThermalTuple('h19liq', [1001], 1), - 'c_H_in_C19H16_solid': ThermalTuple('h19sol', [1001], 1), - 'c_H_in_C2H6O_liquid': ThermalTuple('hetliq', [1001], 1), - 'c_H_in_C2H6O_solid': ThermalTuple('hetsol', [1001], 1), - 'c_H_in_C6H6_liquid': ThermalTuple('hbzliq', [1001], 1), - 'c_H_in_C6H6_solid': ThermalTuple('hbzsol', [1001], 1), - 'c_H_in_C7H8_liquid': ThermalTuple('htlliq', [1001], 1), - 'c_H_in_C7H8_solid': ThermalTuple('htlsol', [1001], 1), - 'c_H_in_C8H10_liquid': ThermalTuple('hxyliq', [1001], 1), - 'c_H_in_C8H10_solid': ThermalTuple('hxysol', [1001], 1), - 'c_H_in_C9H12_liquid': ThermalTuple('hmsliq', [1001], 1), - 'c_H_in_C9H12_solid': ThermalTuple('hmssol', [1001], 1), 'c_H_in_CaH2': ThermalTuple('hcah2', [1001], 1), - 'c_H_in_CaO2H2': ThermalTuple('hcaoh', [1001], 1), - 'c_H1_in_CaH2': ThermalTuple('h1cah2', [1001], 1), - 'c_H2_in_CaH2': ThermalTuple('h2cah2', [1001], 1), 'c_H_in_CH2': ThermalTuple('hch2', [1001], 1), 'c_H_in_CH4_liquid': ThermalTuple('lch4', [1001], 1), 'c_H_in_CH4_solid': ThermalTuple('sch4', [1001], 1), @@ -112,124 +40,33 @@ _THERMAL_DATA = { 'c_H_in_H2O': ThermalTuple('hh2o', [1001], 1), 'c_H_in_H2O_solid': ThermalTuple('hice', [1001], 1), 'c_H_in_HF': ThermalTuple('hhf', [1001], 1), - 'c_H_in_KOH': ThermalTuple('hkoh', [1001], 1), - 'c_H_in_LiH': ThermalTuple('hlih2', [1001], 1), 'c_H_in_Mesitylene': ThermalTuple('mesi00', [1001], 1), 'c_H_in_ParaffinicOil': ThermalTuple('hparaf', [1001], 1), 'c_H_in_Toluene': ThermalTuple('tol00', [1001], 1), - 'c_H_in_MgH2': ThermalTuple('hmgh2', [1001], 1), - 'c_H_in_MgOH2': ThermalTuple('hmgoh', [1001], 1), - 'c_H_in_NaMgH3': ThermalTuple('hnamg', [1001], 1), - 'c_H_in_NaOH': ThermalTuple('hnaoh', [1001], 1), - 'c_H_in_SrH2': ThermalTuple('hsrh2', [1001], 1), 'c_H_in_UH3': ThermalTuple('huh3', [1001], 1), 'c_H_in_YH2': ThermalTuple('hyh2', [1001], 1), 'c_H_in_ZrH': ThermalTuple('hzrh', [1001], 1), 'c_H_in_ZrH2': ThermalTuple('hzrh2', [1001], 1), 'c_H_in_ZrHx': ThermalTuple('hzrhx', [1001], 1), - 'c_I_in_NaI': ThermalTuple('inai', [53127], 1), - 'c_K': ThermalTuple('k', [19039, 19040, 19041], 1), - 'c_K_in_KOH': ThermalTuple('kkoh', [19039, 19040, 19041], 1), 'c_Li_in_FLiBe': ThermalTuple('liflib', [3006, 3007], 1), - 'c_Li_in_7LiD': ThermalTuple('lilid', [3007], 1), - 'c_Li_in_7LiH': ThermalTuple('lilih', [3007], 1), - 'c_Li_in_LiF': ThermalTuple('lilif', [3006, 3007], 1), - 'c_Li_in_LiH': ThermalTuple('lilih2', [3006, 3007], 1), 'c_Mg24': ThermalTuple('mg24', [12024], 1), - 'c_Mg_in_MgF2': ThermalTuple('mgmgf2', [12024, 12025, 12026], 1), - 'c_Mg_in_MgO': ThermalTuple('mgmgo', [12024, 12025, 12026], 1), - 'c_Mg_in_MgD2': ThermalTuple('mgmgd2', [12024, 12025, 12026], 1), - 'c_Mg_in_MgH2': ThermalTuple('mgmgh2', [12024, 12025, 12026], 1), - 'c_Mg_in_MgOH2': ThermalTuple('mgoh2', [12024, 12025, 12026], 1), - 'c_Mg_in_NaMgH3': ThermalTuple('mgnamg', [12024, 12025, 12026], 1), - 'c_Mo': ThermalTuple('mo', [42092, 42094, 42095, 42096, 42097, 42098, 42100], 1), - 'c_N_in_GaN': ThermalTuple('ngan', [7014, 7015], 1), - 'c_N_in_UN_100p': ThermalTuple('nun100', [7014, 7015], 1), - 'c_N_in_UN_10p': ThermalTuple('nun10', [7014, 7015], 1), - 'c_N_in_UN_5p': ThermalTuple('nun5', [7014, 7015], 1), 'c_N_in_UN': ThermalTuple('n-un', [7014, 7015], 1), - 'c_N_in_UN_HALEU': ThermalTuple('nunhal', [7014, 7015], 1), - 'c_N_in_UN_HEU': ThermalTuple('nunheu', [7014, 7015], 1), - 'c_Na': ThermalTuple('na', [11023], 1), - 'c_Na_in_NaI': ThermalTuple('nanai', [11023], 1), - 'c_Na_in_NaMgH3': ThermalTuple('nanamg', [11023], 1), - 'c_Na_in_NaOH': ThermalTuple('nanaoh', [11023], 1), - 'c_Nb': ThermalTuple('nb', [41093], 1), - 'c_Ni': ThermalTuple('ni', [28058, 28060, 28061, 28062, 28064], 1), 'c_O_in_Al2O3': ThermalTuple('osap00', [8016, 8017, 8018], 1), 'c_O_in_BeO': ThermalTuple('obeo', [8016, 8017, 8018], 1), - 'c_O_in_C5O2H8': ThermalTuple('olucit', [8016, 8017, 8018], 1), - 'c_O_in_C2H6O_liquid': ThermalTuple('oetliq', [8016, 8017, 8018], 1), - 'c_O_in_C2H6O_solid': ThermalTuple('oetsol', [8016, 8017, 8018], 1), - 'c_O_in_CaO2H2': ThermalTuple('ocaoh', [8016, 8017, 8018], 1), 'c_O_in_D2O': ThermalTuple('od2o', [8016, 8017, 8018], 1), 'c_O_in_H2O_solid': ThermalTuple('oice', [8016, 8017, 8018], 1), - 'c_O_in_MgO': ThermalTuple('omgo', [8016, 8017, 8018], 1), - 'c_O_in_Ge3Bi4O12': ThermalTuple('ogbo', [8016, 8017, 8018], 1), - 'c_O_in_H2O': ThermalTuple('oh2o', [8016, 8017, 8018], 1), - 'c_O_in_KOH': ThermalTuple('okoh', [8016, 8017, 8018], 1), - 'c_O_in_MgOH2': ThermalTuple('omgoh', [8016, 8017, 8018], 1), - 'c_O_in_NaOH': ThermalTuple('onaoh', [8016, 8017, 8018], 1), - 'c_O_in_PuO2': ThermalTuple('opuo2', [8016, 8017, 8018], 1), - 'c_O_in_SiO2_alpha': ThermalTuple('osio2a', [8016, 8017, 8018], 1), - 'c_O_in_UO2_100p': ThermalTuple('ouo200', [8016, 8017, 8018], 1), - 'c_O_in_UO2_10p': ThermalTuple('ouo210', [8016, 8017, 8018], 1), - 'c_O_in_UO2_5p': ThermalTuple('ouo25', [8016, 8017, 8018], 1), 'c_O_in_UO2': ThermalTuple('ouo2', [8016, 8017, 8018], 1), - 'c_O_in_UO2_HALEU': ThermalTuple('ouo2hl', [8016, 8017, 8018], 1), - 'c_O_in_UO2_HEU': ThermalTuple('ouo2he', [8016, 8017, 8018], 1), - 'c_O_in_Y3Al5O12': ThermalTuple('oyag', [8016, 8017, 8018], 1), 'c_ortho_D': ThermalTuple('orthod', [1002], 1), 'c_ortho_H': ThermalTuple('orthoh', [1001], 1), 'c_para_D': ThermalTuple('parad', [1002], 1), 'c_para_H': ThermalTuple('parah', [1001], 1), - 'c_Pb': ThermalTuple('pb', [82204, 82206, 82207, 82208], 1), - 'c_Pd': ThermalTuple('pd', [46102, 46104, 46105, 46106, 46108, 46110], 1), - 'c_Pt': ThermalTuple('pt', [78190, 78192, 78194, 78195, 78196, 78198], 1), - 'c_Pu_in_PuO2': ThermalTuple('puo2', [94239, 94240, 94241, 94242, 94243], 1), 'c_Si28': ThermalTuple('si00', [14028], 1), 'c_Si_in_SiC': ThermalTuple('sisic', [14028, 14029, 14030], 1), - 'c_Si_in_SiO2_alpha': ThermalTuple('si_o2a', [14028, 14029, 14030], 1), 'c_SiO2_alpha': ThermalTuple('sio2-a', [8016, 8017, 8018, 14028, 14029, 14030], 3), 'c_SiO2_beta': ThermalTuple('sio2-b', [8016, 8017, 8018, 14028, 14029, 14030], 3), - 'c_S_in_ZnS': ThermalTuple('szns', [16032, 16033, 16034, 16036], 1), - 'c_Se_in_GaSe': ThermalTuple('segase', [34074, 34076, 34077, 34078, 34080, 34082], 1), - 'c_Sn': ThermalTuple('sn', [50112, 50114, 50115, 50116, 50117, 50118, 50119, 50120, 50122, 50124], 1), - 'c_Sr_in_SrH2': ThermalTuple('srsrh2', [38084, 38086, 38087, 38088], 1), - 'c_Te_in_GeTe': ThermalTuple('tegete', [52120, 52122, 52123, 52124, 52125, 52126, 52128, 52130], 1), - 'c_Ti': ThermalTuple('ti', [22046, 22047, 22048, 22049, 22050], 1), - 'c_U_metal_100p': ThermalTuple('u-100p', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_metal_10p': ThermalTuple('u-10p', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_metal_5p': ThermalTuple('u-5p', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_metal': ThermalTuple('umetal', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_metal_HALEU': ThermalTuple('uhaleu', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_metal_HEU': ThermalTuple('u-heu', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UC_100p': ThermalTuple('uc-100', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UC_10p': ThermalTuple('uc-10', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UC_5p': ThermalTuple('uc-5', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UC': ThermalTuple('uc-nat', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UC_HALEU': ThermalTuple('uc-hal', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UC_HEU': ThermalTuple('uc-heu', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UN_100p': ThermalTuple('un-100', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UN_10p': ThermalTuple('un-10', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UN_5p': ThermalTuple('un-5', [92233, 92234, 92235, 92236, 92238], 1), 'c_U_in_UN': ThermalTuple('u-un', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UN_HALEU': ThermalTuple('un-hal', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UN_HEU': ThermalTuple('un-heu', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UO2_100p': ThermalTuple('uo2100', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UO2_10p': ThermalTuple('uo2-10', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UO2_5p': ThermalTuple('uo2-5', [92233, 92234, 92235, 92236, 92238], 1), 'c_U_in_UO2': ThermalTuple('uuo2', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UO2_HALEU': ThermalTuple('uo2hal', [92233, 92234, 92235, 92236, 92238], 1), - 'c_U_in_UO2_HEU': ThermalTuple('uo2heu', [92233, 92234, 92235, 92236, 92238], 1), - 'c_V': ThermalTuple('v', [23050, 23051], 1), - 'c_W': ThermalTuple('w', [74180, 74182, 74183, 74184, 74186], 1), - 'c_Y_in_Y3Al5O12': ThermalTuple('yyag', [39089], 1), 'c_Y_in_YH2': ThermalTuple('yyh2', [39089], 1), - 'c_Zn': ThermalTuple('zn', [30064, 30066, 30067, 30068, 30070], 1), - 'c_Zn_in_ZnS': ThermalTuple('znzns', [30064, 30066, 30067, 30068, 30070], 1), - 'c_Zr': ThermalTuple('zr', [40090, 40091, 40092, 40094, 40096], 1), - 'c_Zr_in_ZrC': ThermalTuple('zrzrc', [40000, 40090, 40091, 40092, 40094, 40096], 1), 'c_Zr_in_ZrH': ThermalTuple('zrzrh', [40000, 40090, 40091, 40092, 40094, 40096], 1), 'c_Zr_in_ZrH2': ThermalTuple('zrzrh2', [40000, 40090, 40091, 40092, 40094, 40096], 1), 'c_Zr_in_ZrHx': ThermalTuple('zrzrhx', [40000, 40090, 40091, 40092, 40094, 40096], 1), @@ -259,14 +96,14 @@ broadr / %%%%%%%%%%%%%%%%%%%%%%% Doppler broaden XS %%%%%%%%%%%%%%%%%%%%%%%%%%%% _TEMPLATE_HEATR = """ heatr / %%%%%%%%%%%%%%%%%%%%%%%%% Add heating kerma %%%%%%%%%%%%%%%%%%%%%%%%%%%% {nendf} {nheatr_in} {nheatr} / -{mat} 4 0 0 0 0 {ed}/ +{mat} 4 0 0 0 / 302 318 402 444 / """ _TEMPLATE_HEATR_LOCAL = """ heatr / %%%%%%%%%%%%%%%%% Add heating kerma (local photons) %%%%%%%%%%%%%%%%%%%% {nendf} {nheatr_in} {nheatr_local} / -{mat} 4 0 0 1 0 {ed}/ +{mat} 4 0 0 1 / 302 318 402 444 / """ @@ -297,12 +134,12 @@ acer / %%%%%%%%%%%%%%%%%%%%%%%% Write out in ACE format %%%%%%%%%%%%%%%%%%%%%%%% _THERMAL_TEMPLATE_THERMR = """ thermr / %%%%%%%%%%%%%%%% Add thermal scattering data (free gas) %%%%%%%%%%%%%%% 0 {nthermr1_in} {nthermr1} -0 {mat} {nbin} {num_temp} 1 0 {iform} 1 221 1/ +0 {mat} 12 {num_temp} 1 0 {iform} 1 221 1/ {temps} {error} {energy_max} thermr / %%%%%%%%%%%%%%%% Add thermal scattering data (bound) %%%%%%%%%%%%%%%%%% {nthermal_endf} {nthermr2_in} {nthermr2} -{mat_thermal} {mat} {nbin} {num_temp} {inelastic} {elastic} {iform} {natom} 222 1/ +{mat_thermal} {mat} 16 {num_temp} {inelastic} {elastic} {iform} {natom} 222 1/ {temps} {error} {energy_max} """ @@ -384,7 +221,7 @@ def run(commands, tapein, tapeout, input_filename=None, stdout=False, shutil.move(tmpfilename, str(filename)) -def make_pendf(filename, pendf='pendf', **kwargs): +def make_pendf(filename, pendf='pendf', error=0.001, stdout=False): """Generate pointwise ENDF file from an ENDF file Parameters @@ -393,9 +230,10 @@ def make_pendf(filename, pendf='pendf', **kwargs): Path to ENDF file pendf : str, optional Path of pointwise ENDF file to write - **kwargs - Keyword arguments passed to :func:`openmc.data.njoy.make_ace`. All NJOY - module arguments other than pendf default to False. + error : float, optional + Fractional error tolerance for NJOY processing + stdout : bool + Whether to display NJOY standard output Raises ------ @@ -403,15 +241,15 @@ def make_pendf(filename, pendf='pendf', **kwargs): If the NJOY process returns with a non-zero status """ - for key in ('broadr', 'heatr', 'gaspr', 'purr', 'acer'): - kwargs.setdefault(key, False) - make_ace(filename, pendf=pendf, **kwargs) + + make_ace(filename, pendf=pendf, error=error, broadr=False, + heatr=False, purr=False, acer=False, stdout=stdout) def make_ace(filename, temperatures=None, acer=True, xsdir=None, output_dir=None, pendf=False, error=0.001, broadr=True, heatr=True, gaspr=True, purr=True, evaluation=None, - smoothing=True, displacement_energy=None, **kwargs): + smoothing=True, **kwargs): """Generate incident neutron ACE file from an ENDF file File names can be passed to @@ -463,9 +301,6 @@ def make_ace(filename, temperatures=None, acer=True, xsdir=None, indicates which evaluation should be used. smoothing : bool, optional If the smoothing option (ACER card 6) is on (True) or off (False). - displacement_energy : float, optional - Threshold displacement energy in [eV]. Used in HEATR to calculate - damage-energy cross section. When None, use NJOY defaults. **kwargs Keyword arguments passed to :func:`openmc.data.njoy.run` @@ -518,7 +353,6 @@ def make_ace(filename, temperatures=None, acer=True, xsdir=None, # heatr if heatr: - ed = displacement_energy if displacement_energy is not None else 0 nheatr_in = nlast nheatr_local = nheatr_in + 1 tapeout[nheatr_local] = (output_dir / "heatr_local") if heatr is True \ @@ -593,9 +427,9 @@ def make_ace(filename, temperatures=None, acer=True, xsdir=None, def make_ace_thermal(filename, filename_thermal, temperatures=None, - ace=None, xsdir=None, output_dir=None, error=0.001, + ace='ace', xsdir=None, output_dir=None, error=0.001, iwt=2, evaluation=None, evaluation_thermal=None, - table_name=None, zaids=None, nmix=None, nbin=16, **kwargs): + table_name=None, zaids=None, nmix=None, **kwargs): """Generate thermal scattering ACE file from ENDF files Parameters @@ -608,7 +442,7 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None, Temperatures in Kelvin to produce data at. If omitted, data is produced at all temperatures given in the ENDF thermal scattering sublibrary. ace : str, optional - Path of ACE file to write. Default to ``"ace"``. + Path of ACE file to write xsdir : str, optional Path of xsdir file to write. Defaults to ``"xsdir"`` in the same directory as ``ace`` @@ -632,8 +466,6 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None, ZAIDs that the thermal scattering data applies to nmix : int, optional Number of atom types in mixed moderator - nbin : int, optional - Number of equi-probable angles **kwargs Keyword arguments passed to :func:`openmc.data.njoy.run` @@ -665,7 +497,7 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None, else: with warnings.catch_warnings(record=True) as w: proper_name = openmc.data.get_thermal_name(zsymam_thermal) - if w or proper_name not in _THERMAL_DATA: + if w: raise RuntimeError( f"Thermal scattering material {zsymam_thermal} not " "recognized. Please contact OpenMC developers at " @@ -758,7 +590,7 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None, commands += 'stop\n' run(commands, tapein, tapeout, **kwargs) - ace = (output_dir / "ace") if ace is None else Path(ace) + ace = output_dir / ace xsdir = (ace.parent / "xsdir") if xsdir is None else Path(xsdir) with ace.open('w') as ace_file, xsdir.open('w') as xsdir_file: # Concatenate ACE and xsdir files together diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 13cd3ec95..25ded24cb 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -15,8 +15,7 @@ from openmc.mixin import EqualityMixin from . import HDF5_VERSION, HDF5_VERSION_MAJOR from .ace import Table, get_metadata, get_table from .data import ATOMIC_SYMBOL, EV_PER_MEV -from .endf import ( - as_evaluation, get_head_record, get_tab1_record, get_list_record) +from .endf import Evaluation, get_head_record, get_tab1_record, get_list_record from .function import Tabulated1D @@ -204,9 +203,7 @@ class AtomicRelaxation(EqualityMixin): for subshell, df in transitions.items(): cv.check_value('subshell', subshell, _SUBSHELLS) cv.check_type('transitions', df, pd.DataFrame) - self._transitions = { - subshell: df.convert_dtypes() for subshell, df in transitions.items() - } + self._transitions = transitions @classmethod def from_ace(cls, ace): @@ -273,7 +270,7 @@ class AtomicRelaxation(EqualityMixin): Parameters ---------- - ev_or_filename : str, openmc.data.endf.Evaluation, or endf.Material + ev_or_filename : str or openmc.data.endf.Evaluation ENDF atomic relaxation evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -283,7 +280,10 @@ class AtomicRelaxation(EqualityMixin): Atomic relaxation data """ - ev = as_evaluation(ev_or_filename) + if isinstance(ev_or_filename, Evaluation): + ev = ev_or_filename + else: + ev = Evaluation(ev_or_filename) # Atomic relaxation data is always MF=28, MT=533 if (28, 533) not in ev.section: @@ -604,10 +604,10 @@ class IncidentPhoton(EqualityMixin): Parameters ---------- - photoatomic : str, openmc.data.endf.Evaluation, or endf.Material + photoatomic : str or openmc.data.endf.Evaluation ENDF photoatomic data evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. - relaxation : str, openmc.data.endf.Evaluation, or endf.Material, optional + relaxation : str or openmc.data.endf.Evaluation, optional ENDF atomic relaxation data evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. @@ -617,7 +617,10 @@ class IncidentPhoton(EqualityMixin): Photon interaction data """ - ev = as_evaluation(photoatomic) + if isinstance(photoatomic, Evaluation): + ev = photoatomic + else: + ev = Evaluation(photoatomic) Z = ev.target['atomic_number'] data = cls(Z) @@ -1066,7 +1069,7 @@ class PhotonReaction(EqualityMixin): Parameters ---------- - ev : openmc.data.endf.Evaluation or endf.Material + ev : openmc.data.endf.Evaluation ENDF photo-atomic interaction data evaluation mt : int The MT value of the reaction to get data for @@ -1077,7 +1080,6 @@ class PhotonReaction(EqualityMixin): Photon reaction data """ - ev = as_evaluation(ev) rx = cls(mt) # Read photon cross section diff --git a/openmc/data/reaction.py b/openmc/data/reaction.py index 44ced5511..8f90d2de4 100644 --- a/openmc/data/reaction.py +++ b/openmc/data/reaction.py @@ -13,24 +13,23 @@ from .angle_distribution import AngleDistribution from .angle_energy import AngleEnergy from .correlated import CorrelatedAngleEnergy from .data import ATOMIC_SYMBOL, K_BOLTZMANN, EV_PER_MEV -from .endf import as_evaluation, get_head_record, get_tab1_record, \ - get_list_record, get_tab2_record, get_cont_record +from .endf import get_head_record, get_tab1_record, get_list_record, \ + get_tab2_record, get_cont_record from .energy_distribution import EnergyDistribution, LevelInelastic, \ DiscretePhoton from .function import Tabulated1D, Polynomial from .kalbach_mann import KalbachMann from .laboratory import LaboratoryAngleEnergy from .nbody import NBodyPhaseSpace -from .photon import _SUBSHELLS from .product import Product from .uncorrelated import UncorrelatedAngleEnergy -REACTION_NAME = {1: '(n,total)', 2: '(n,elastic)', 3: "(n,nonelastic)", - 4: '(n,level)', 5: '(n,misc)', 11: '(n,2nd)', 16: '(n,2n)', - 17: '(n,3n)', 18: '(n,fission)', 19: '(n,f)', 20: '(n,nf)', - 21: '(n,2nf)', 22: '(n,na)', 23: '(n,n3a)', 24: '(n,2na)', - 25: '(n,3na)', 27: '(n,absorption)', 28: '(n,np)', 29: '(n,n2a)', +REACTION_NAME = {1: '(n,total)', 2: '(n,elastic)', 4: '(n,level)', + 5: '(n,misc)', 11: '(n,2nd)', 16: '(n,2n)', 17: '(n,3n)', + 18: '(n,fission)', 19: '(n,f)', 20: '(n,nf)', 21: '(n,2nf)', + 22: '(n,na)', 23: '(n,n3a)', 24: '(n,2na)', 25: '(n,3na)', + 27: '(n,absorption)', 28: '(n,np)', 29: '(n,n2a)', 30: '(n,2n2a)', 32: '(n,nd)', 33: '(n,nt)', 34: '(n,n3He)', 35: '(n,nd2a)', 36: '(n,nt2a)', 37: '(n,4n)', 38: '(n,3nf)', 41: '(n,2np)', 42: '(n,3np)', 44: '(n,n2p)', 45: '(n,npa)', @@ -55,10 +54,6 @@ REACTION_NAME = {1: '(n,total)', 2: '(n,elastic)', 3: "(n,nonelastic)", 198: '(n,n3p)', 199: '(n,3n2pa)', 200: '(n,5n2p)', 203: '(n,Xp)', 204: '(n,Xd)', 205: '(n,Xt)', 206: '(n,X3He)', 207: '(n,Xa)', 301: 'heating', 444: 'damage-energy', - 501: 'photon-total', 502: 'coherent-scatter', - 504: 'incoherent-scatter', 515: 'pair-production-electron', - 516: 'pair-production', 517: 'pair-production-nuclear', - 522: 'photoelectric', 649: '(n,pc)', 699: '(n,dc)', 749: '(n,tc)', 799: '(n,3Hec)', 849: '(n,ac)', 891: '(n,2nc)', 901: 'heating-local'} REACTION_NAME.update({i: f'(n,n{i - 50})' for i in range(51, 91)}) @@ -68,16 +63,9 @@ REACTION_NAME.update({i: f'(n,t{i - 700})' for i in range(700, 749)}) REACTION_NAME.update({i: f'(n,3He{i - 750})' for i in range(750, 799)}) REACTION_NAME.update({i: f'(n,a{i - 800})' for i in range(800, 849)}) REACTION_NAME.update({i: f'(n,2n{i - 875})' for i in range(875, 891)}) -REACTION_NAME.update( - {534 + i: f'photoelectric-{shell}' for i, shell in enumerate(_SUBSHELLS[1:])} -) REACTION_MT = {name: mt for mt, name in REACTION_NAME.items()} -REACTION_MT['total'] = 1 -REACTION_MT['elastic'] = 2 REACTION_MT['fission'] = 18 -REACTION_MT['absorption'] = 27 -REACTION_MT['capture'] = 102 FISSION_MTS = (18, 19, 20, 21, 38) @@ -1151,7 +1139,7 @@ class Reaction(EqualityMixin): Parameters ---------- - ev : openmc.data.endf.Evaluation or endf.Material + ev : openmc.data.endf.Evaluation ENDF evaluation mt : int The MT value of the reaction to get data for @@ -1162,7 +1150,6 @@ class Reaction(EqualityMixin): Reaction data """ - ev = as_evaluation(ev) rx = Reaction(mt) # Integrated cross section diff --git a/openmc/data/reconstruct.pyx b/openmc/data/reconstruct.pyx new file mode 100644 index 000000000..cd0bbc38b --- /dev/null +++ b/openmc/data/reconstruct.pyx @@ -0,0 +1,522 @@ +from libc.stdlib cimport malloc, calloc, free +from libc.math cimport cos, sin, sqrt, atan, M_PI + +cimport numpy as np +import numpy as np +from numpy.linalg import inv +cimport cython + + +cdef extern from "complex.h": + double cabs(double complex) + double complex conj(double complex) + double creal(complex double) + double cimag(complex double) + double complex cexp(double complex) + +# Physical constants are from CODATA 2014 +cdef double NEUTRON_MASS_ENERGY = 939.5654133e6 # eV/c^2 +cdef double HBAR_C = 197.3269788e5 # eV-b^0.5 + + +@cython.cdivision(True) +def wave_number(double A, double E): + r"""Neutron wave number in center-of-mass system. + + ENDF-102 defines the neutron wave number in the center-of-mass system in + Equation D.10 as + + .. math:: + k = \frac{2m_n}{\hbar} \frac{A}{A + 1} \sqrt{|E|} + + Parameters + ---------- + A : double + Ratio of target mass to neutron mass + E : double + Energy in eV + + Returns + ------- + double + Neutron wave number in b^-0.5 + + """ + return A/(A + 1)*sqrt(2*NEUTRON_MASS_ENERGY*abs(E))/HBAR_C + +@cython.cdivision(True) +cdef double _wave_number(double A, double E): + return A/(A + 1)*sqrt(2*NEUTRON_MASS_ENERGY*abs(E))/HBAR_C + + +@cython.cdivision(True) +cdef double phaseshift(int l, double rho): + """Calculate hardsphere phase shift as given in ENDF-102, Equation D.13 + + Parameters + ---------- + l : int + Angular momentum quantum number + rho : float + Product of the wave number and the channel radius + + Returns + ------- + double + Hardsphere phase shift + + """ + if l == 0: + return rho + elif l == 1: + return rho - atan(rho) + elif l == 2: + return rho - atan(3*rho/(3 - rho**2)) + elif l == 3: + return rho - atan((15*rho - rho**3)/(15 - 6*rho**2)) + elif l == 4: + return rho - atan((105*rho - 10*rho**3)/(105 - 45*rho**2 + rho**4)) + + +@cython.cdivision(True) +def penetration_shift(int l, double rho): + r"""Calculate shift and penetration factors as given in ENDF-102, Equations D.11 + and D.12. + + Parameters + ---------- + l : int + Angular momentum quantum number + rho : float + Product of the wave number and the channel radius + + Returns + ------- + double + Penetration factor for given :math:`l` + double + Shift factor for given :math:`l` + + """ + cdef double den + + if l == 0: + return rho, 0. + elif l == 1: + den = 1 + rho**2 + return rho**3/den, -1/den + elif l == 2: + den = 9 + 3*rho**2 + rho**4 + return rho**5/den, -(18 + 3*rho**2)/den + elif l == 3: + den = 225 + 45*rho**2 + 6*rho**4 + rho**6 + return rho**7/den, -(675 + 90*rho**2 + 6*rho**4)/den + elif l == 4: + den = 11025 + 1575*rho**2 + 135*rho**4 + 10*rho**6 + rho**8 + return rho**9/den, -(44100 + 4725*rho**2 + 270*rho**4 + 10*rho**6)/den + + +@cython.boundscheck(False) +@cython.wraparound(False) +@cython.cdivision(True) +def reconstruct_mlbw(mlbw, double E): + """Evaluate cross section using MLBW data. + + Parameters + ---------- + mlbw : openmc.data.MultiLevelBreitWigner + Multi-level Breit-Wigner resonance parameters + E : double + Energy in eV at which to evaluate the cross section + + Returns + ------- + elastic : double + Elastic scattering cross section in barns + capture : double + Radiative capture cross section in barns + fission : double + Fission cross section in barns + + """ + cdef int i, nJ, ij, l, n_res, i_res + cdef double elastic, capture, fission + cdef double A, k, rho, rhohat, I + cdef double P, S, phi, cos2phi, sin2phi + cdef double Ex, Q, rhoc, rhochat, P_c, S_c + cdef double jmin, jmax, j, Dl + cdef double E_r, gt, gn, gg, gf, gx, P_r, S_r, P_rx + cdef double gnE, gtE, Eprime, x, f + cdef double *g + cdef double (*s)[2] + cdef double [:,:] params + + I = mlbw.target_spin + A = mlbw.atomic_weight_ratio + k = _wave_number(A, E) + + elastic = 0. + capture = 0. + fission = 0. + + for i, l in enumerate(mlbw._l_values): + params = mlbw._parameter_matrix[l] + + rho = k*mlbw.channel_radius[l](E) + rhohat = k*mlbw.scattering_radius[l](E) + P, S = penetration_shift(l, rho) + phi = phaseshift(l, rhohat) + cos2phi = cos(2*phi) + sin2phi = sin(2*phi) + + # Determine shift and penetration at modified energy + if mlbw._competitive[i]: + Ex = E + mlbw.q_value[l]*(A + 1)/A + rhoc = mlbw.channel_radius[l](Ex) + rhochat = mlbw.scattering_radius[l](Ex) + P_c, S_c = penetration_shift(l, rhoc) + if Ex < 0: + P_c = 0 + + # Determine range of total angular momentum values based on equation + # 41 in LA-UR-12-27079 + jmin = abs(abs(I - l) - 0.5) + jmax = I + l + 0.5 + nJ = int(jmax - jmin + 1) + + # Determine Dl factor using Equation 43 in LA-UR-12-27079 + Dl = 2*l + 1 + g = malloc(nJ*sizeof(double)) + for ij in range(nJ): + j = jmin + ij + g[ij] = (2*j + 1)/(4*I + 2) + Dl -= g[ij] + + s = calloc(2*nJ, sizeof(double)) + for i_res in range(params.shape[0]): + # Copy resonance parameters + E_r = params[i_res, 0] + j = params[i_res, 2] + ij = int(j - jmin) + gt = params[i_res, 3] + gn = params[i_res, 4] + gg = params[i_res, 5] + gf = params[i_res, 6] + gx = params[i_res, 7] + P_r = params[i_res, 8] + S_r = params[i_res, 9] + P_rx = params[i_res, 10] + + # Calculate neutron and total width at energy E + gnE = P*gn/P_r # ENDF-102, Equation D.7 + gtE = gnE + gg + gf + if gx > 0: + gtE += gx*P_c/P_rx + + Eprime = E_r + (S_r - S)/(2*P_r)*gn # ENDF-102, Equation D.9 + x = 2*(E - Eprime)/gtE # LA-UR-12-27079, Equation 26 + f = 2*gnE/(gtE*(1 + x*x)) # Common factor in Equation 40 + s[ij][0] += f # First sum in Equation 40 + s[ij][1] += f*x # Second sum in Equation 40 + capture += f*g[ij]*gg/gtE + if gf > 0: + fission += f*g[ij]*gf/gtE + + for ij in range(nJ): + # Add all but last term of LA-UR-12-27079, Equation 40 + elastic += g[ij]*((1 - cos2phi - s[ij][0])**2 + + (sin2phi + s[ij][1])**2) + + # Add final term with Dl from Equation 40 + elastic += 2*Dl*(1 - cos2phi) + + # Free memory + free(g) + free(s) + + capture *= 2*M_PI/(k*k) + fission *= 2*M_PI/(k*k) + elastic *= M_PI/(k*k) + + return (elastic, capture, fission) + + +@cython.boundscheck(False) +@cython.wraparound(False) +@cython.cdivision(True) +def reconstruct_slbw(slbw, double E): + """Evaluate cross section using SLBW data. + + Parameters + ---------- + slbw : openmc.data.SingleLevelBreitWigner + Single-level Breit-Wigner resonance parameters + E : double + Energy in eV at which to evaluate the cross section + + Returns + ------- + elastic : double + Elastic scattering cross section in barns + capture : double + Radiative capture cross section in barns + fission : double + Fission cross section in barns + + """ + cdef int i, l, i_res + cdef double elastic, capture, fission + cdef double A, k, rho, rhohat, I + cdef double P, S, phi, cos2phi, sin2phi, sinphi2 + cdef double Ex, rhoc, rhochat, P_c, S_c + cdef double E_r, J, gt, gn, gg, gf, gx, P_r, S_r, P_rx + cdef double gnE, gtE, Eprime, f + cdef double x, theta, psi, chi + cdef double [:,:] params + + I = slbw.target_spin + A = slbw.atomic_weight_ratio + k = _wave_number(A, E) + + elastic = 0. + capture = 0. + fission = 0. + + for i, l in enumerate(slbw._l_values): + params = slbw._parameter_matrix[l] + + rho = k*slbw.channel_radius[l](E) + rhohat = k*slbw.scattering_radius[l](E) + P, S = penetration_shift(l, rho) + phi = phaseshift(l, rhohat) + cos2phi = cos(2*phi) + sin2phi = sin(2*phi) + sinphi2 = sin(phi)**2 + + # Add potential scattering -- first term in ENDF-102, Equation D.2 + elastic += 4*M_PI/(k*k)*(2*l + 1)*sinphi2 + + # Determine shift and penetration at modified energy + if slbw._competitive[i]: + Ex = E + slbw.q_value[l]*(A + 1)/A + rhoc = k*slbw.channel_radius[l](Ex) + rhochat = k*slbw.scattering_radius[l](Ex) + P_c, S_c = penetration_shift(l, rhoc) + if Ex < 0: + P_c = 0 + + for i_res in range(params.shape[0]): + # Copy resonance parameters + E_r = params[i_res, 0] + J = params[i_res, 2] + gt = params[i_res, 3] + gn = params[i_res, 4] + gg = params[i_res, 5] + gf = params[i_res, 6] + gx = params[i_res, 7] + P_r = params[i_res, 8] + S_r = params[i_res, 9] + P_rx = params[i_res, 10] + + # Calculate neutron and total width at energy E + gnE = P*gn/P_r # Equation D.7 + gtE = gnE + gg + gf + if gx > 0: + gtE += gx*P_c/P_rx + + Eprime = E_r + (S_r - S)/(2*P_r)*gn # Equation D.9 + gJ = (2*J + 1)/(4*I + 2) # Mentioned in section D.1.1.4 + + # Calculate common factor for elastic, capture, and fission + # cross sections + f = M_PI/(k*k)*gJ*gnE/((E - Eprime)**2 + gtE**2/4) + + # Add contribution to elastic per Equation D.2 + elastic += f*(gnE*cos2phi - 2*(gg + gf)*sinphi2 + + 2*(E - Eprime)*sin2phi) + + # Add contribution to capture per Equation D.3 + capture += f*gg + + # Add contribution to fission per Equation D.6 + if gf > 0: + fission += f*gf + + return (elastic, capture, fission) + + +@cython.boundscheck(False) +@cython.wraparound(False) +@cython.cdivision(True) +def reconstruct_rm(rm, double E): + """Evaluate cross section using Reich-Moore data. + + Parameters + ---------- + rm : openmc.data.ReichMoore + Reich-Moore resonance parameters + E : double + Energy in eV at which to evaluate the cross section + + Returns + ------- + elastic : double + Elastic scattering cross section in barns + capture : double + Radiative capture cross section in barns + fission : double + Fission cross section in barns + + """ + cdef int i, l, m, n, i_res + cdef int i_s, num_s, i_J, num_J + cdef double elastic, capture, fission, total + cdef double A, k, rho, rhohat, I + cdef double P, S, phi + cdef double smin, smax, s, Jmin, Jmax, J, j + cdef double E_r, gn, gg, gfa, gfb, P_r + cdef double E_diff, abs_value, gJ + cdef double Kr, Ki, x + cdef double complex Ubar, U_, factor + cdef bint hasfission + cdef np.ndarray[double, ndim=2] one + cdef np.ndarray[double complex, ndim=2] K, Imat, U + cdef double [:,:] params + + # Get nuclear spin + I = rm.target_spin + + elastic = 0. + fission = 0. + total = 0. + A = rm.atomic_weight_ratio + k = _wave_number(A, E) + one = np.eye(3) + K = np.zeros((3,3), dtype=complex) + + for i, l in enumerate(rm._l_values): + # Check for l-dependent scattering radius + rho = k*rm.channel_radius[l](E) + rhohat = k*rm.scattering_radius[l](E) + + # Calculate shift and penetrability + P, S = penetration_shift(l, rho) + + # Calculate phase shift + phi = phaseshift(l, rhohat) + + # Calculate common factor on collision matrix terms (term outside curly + # braces in ENDF-102, Eq. D.27) + Ubar = cexp(-2j*phi) + + # The channel spin is the vector sum of the target spin, I, and the + # neutron spin, 1/2, so can take on values of |I - 1/2| < s < I + 1/2 + smin = abs(I - 0.5) + smax = I + 0.5 + num_s = int(smax - smin + 1) + + for i_s in range(num_s): + s = i_s + smin + + # Total angular momentum is the vector sum of l and s and can assume + # values between |l - s| < J < l + s + Jmin = abs(l - s) + Jmax = l + s + num_J = int(Jmax - Jmin + 1) + + for i_J in range(num_J): + J = i_J + Jmin + + # Initialize K matrix + for m in range(3): + for n in range(3): + K[m,n] = 0.0 + + hasfission = False + if (l, J) in rm._parameter_matrix: + params = rm._parameter_matrix[l, J] + + for i_res in range(params.shape[0]): + # Sometimes, the same (l, J) quantum numbers can occur + # for different values of the channel spin, s. In this + # case, the sign of the channel spin indicates which + # spin is to be used. If the spin is negative assume + # this resonance comes from the I - 1/2 channel and vice + # versa. + j = params[i_res, 2] + if l > 0: + if (j < 0 and s != smin) or (j > 0 and s != smax): + continue + + # Copy resonance parameters + E_r = params[i_res, 0] + gn = params[i_res, 3] + gg = params[i_res, 4] + gfa = params[i_res, 5] + gfb = params[i_res, 6] + P_r = params[i_res, 7] + + # Calculate neutron width at energy E + gn = sqrt(P*gn/P_r) + + # Calculate j/2 * inverse of denominator of K matrix terms + factor = 0.5j/(E_r - E - 0.5j*gg) + + # Upper triangular portion of K matrix -- see ENDF-102, + # Equation D.28 + K[0,0] = K[0,0] + gn*gn*factor + if gfa != 0.0 or gfb != 0.0: + # Negate fission widths if necessary + gfa = (-1 if gfa < 0 else 1)*sqrt(abs(gfa)) + gfb = (-1 if gfb < 0 else 1)*sqrt(abs(gfb)) + + K[0,1] = K[0,1] + gn*gfa*factor + K[0,2] = K[0,2] + gn*gfb*factor + K[1,1] = K[1,1] + gfa*gfa*factor + K[1,2] = K[1,2] + gfa*gfb*factor + K[2,2] = K[2,2] + gfb*gfb*factor + hasfission = True + + # Get collision matrix + gJ = (2*J + 1)/(4*I + 2) + if hasfission: + # Copy upper triangular portion of K to lower triangular + K[1,0] = K[0,1] + K[2,0] = K[0,2] + K[2,1] = K[1,2] + + Imat = inv(one - K) + U = Ubar*(2*Imat - one) # ENDF-102, Eq. D.27 + elastic += gJ*cabs(1 - U[0,0])**2 # ENDF-102, Eq. D.24 + total += 2*gJ*(1 - creal(U[0,0])) # ENDF-102, Eq. D.23 + + # Calculate fission from ENDF-102, Eq. D.26 + fission += 4*gJ*(cabs(Imat[1,0])**2 + cabs(Imat[2,0])**2) + else: + U_ = Ubar*(2/(1 - K[0,0]) - 1) + if abs(creal(K[0,0])) < 3e-4 and abs(phi) < 3e-4: + # If K and phi are both very small, the calculated cross + # sections can lose precision because the real part of U + # ends up very close to unity. To get around this, we + # use Euler's formula to express Ubar by real and + # imaginary parts, expand cos(2phi) = 1 - 2phi^2 + + # O(phi^4), and then simplify + Kr = creal(K[0,0]) + Ki = cimag(K[0,0]) + x = 2*(-Kr + (Kr*Kr + Ki*Ki)*(1 - phi*phi) + phi*phi - + sin(2*phi)*Ki)/((1 - Kr)*(1 - Kr) + Ki*Ki) + total += 2*gJ*x + elastic += gJ*(x*x + cimag(U_)**2) + else: + total += 2*gJ*(1 - creal(U_)) # ENDF-102, Eq. D.23 + elastic += gJ*cabs(1 - U_)**2 # ENDF-102, Eq. D.24 + + # Calculate capture as difference of other cross sections as per ENDF-102, + # Equation D.25 + capture = total - elastic - fission + + elastic *= M_PI/(k*k) + capture *= M_PI/(k*k) + fission *= M_PI/(k*k) + + return (elastic, capture, fission) diff --git a/openmc/data/resonance.py b/openmc/data/resonance.py index 52ee7f1a9..31e230df5 100644 --- a/openmc/data/resonance.py +++ b/openmc/data/resonance.py @@ -7,9 +7,7 @@ import pandas as pd import openmc.checkvalue as cv from .data import NEUTRON_MASS -from .endf import ( - as_evaluation, get_head_record, get_cont_record, get_tab1_record, - get_list_record) +from .endf import get_head_record, get_cont_record, get_tab1_record, get_list_record try: from .reconstruct import wave_number, penetration_shift, reconstruct_mlbw, \ reconstruct_slbw, reconstruct_rm @@ -79,7 +77,7 @@ class Resonances: Parameters ---------- - ev : openmc.data.endf.Evaluation or endf.Material + ev : openmc.data.endf.Evaluation ENDF evaluation Returns @@ -88,7 +86,6 @@ class Resonances: Resonance data """ - ev = as_evaluation(ev) file_obj = io.StringIO(ev.section[2, 151]) # Determine whether discrete or continuous representation diff --git a/openmc/data/resonance_covariance.py b/openmc/data/resonance_covariance.py index aa86ae33c..709657044 100644 --- a/openmc/data/resonance_covariance.py +++ b/openmc/data/resonance_covariance.py @@ -74,7 +74,7 @@ class ResonanceCovariances(Resonances): Parameters ---------- - ev : openmc.data.endf.Evaluation or endf.Material + ev : openmc.data.endf.Evaluation ENDF evaluation resonances : openmc.data.Resonance object openmc.data.Resonanance object generated from the same evaluation @@ -86,7 +86,6 @@ class ResonanceCovariances(Resonances): Resonance covariance data """ - ev = endf.as_evaluation(ev) file_obj = io.StringIO(ev.section[32, 151]) # Determine whether discrete or continuous representation diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index 3b910c535..6df171d3a 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -5,6 +5,7 @@ from numbers import Real from io import StringIO import itertools import os +import re import tempfile from warnings import warn @@ -27,224 +28,62 @@ from .thermal_angle_energy import (CoherentElasticAE, IncoherentElasticAE, _THERMAL_NAMES = { - 'c_Ag': ('ag',), 'c_Al27': ('al', 'al27', 'al-27', '13-al- 27'), 'c_Al_in_Al2O3': ('asap00', 'asap', 'al(al2o3)'), - 'c_Al_in_Y3Al5O12': ('al(y3al5o1', 'alyag'), - 'c_Au': ('au',), - 'c_Be': ('be', 'be-metal', 'be-met', 'be00', 'be-metal', 'be metal', '4-be', '4-be-'), + 'c_Be': ('be', 'be-metal', 'be-met', 'be00', 'be-metal', 'be metal', '4-be'), 'c_BeO': ('beo',), - 'c_Be_distinct': ('besd', 'be+sd'), - 'c_Be_in_BeO': ('bebeo', 'be-beo', 'be-o', 'be/o', 'bbeo00', 'be(beo)', 'be_beo'), - 'c_Be_in_Be2C': ('bebe2c', 'be(be2c)'), - 'c_Be_in_BeF2': ('bebef2', 'be in bef2'), + 'c_Be_in_BeO': ('bebeo', 'be-beo', 'be-o', 'be/o', 'bbeo00', 'be(beo)'), + 'c_Be_in_Be2C': ('bebe2c',), 'c_Be_in_FLiBe': ('beflib', 'be(flibe)'), - 'c_Bi': ('83-bi-', 'bi'), - 'c_Bi_in_Ge3Bi4O12': ('bi(ge3bi4o', 'bigbo'), 'c_C6H6': ('benz', 'c6h6', 'benzine'), - 'c_C_in_Be2C': ('cbe2c', 'c(be2c)'), - 'c_C_in_C19H16_liquid': ('c(c19h16)l', 'c19liq'), - 'c_C_in_C19H16_solid': ('c(c19h16)s', 'c19sol'), - 'c_C_in_C2H6O_liquid': ('c(c2h6o)l', 'ethliq'), - 'c_C_in_C2H6O_solid': ('c(c2h6o)s', 'ethsol'), - 'c_C_in_C5O2H8': ('clucit', 'c(lucite)'), - 'c_C_in_C6H6_liquid': ('c(c6h6)l', 'benzlq'), - 'c_C_in_C6H6_solid': ('c(c6h6)s', 'benzsl'), - 'c_C_in_C7H8_liquid': ('c(c7h8)l', 'tolliq'), - 'c_C_in_C7H8_solid': ('c(c7h8)s', 'tolsol'), - 'c_C_in_C8H8': ('cc8h8', 'c(polystyr'), - 'c_C_in_C8H10_liquid': ('c(m-c8h10)l', 'xylliq'), - 'c_C_in_C8H10_solid': ('c(m-c8h10)s', 'xylsol'), - 'c_C_in_C9H12_liquid': ('c(c9h12)l', 'mesliq'), - 'c_C_in_C9H12_solid': ('c(c9h12)s', 'messol'), - 'c_C_in_CF2': ('ccf2', 'c(teflon)'), - 'c_C_in_CH2': ('c(c2h4)n r', 'cch2'), - 'c_C_in_CH4_liquid': ('c(ch4)l', 'cch4lq'), - 'c_C_in_CH4_solid': ('c(ch4)s', 'cch4sl'), - 'c_C_in_Diamond': ('c(c-diamon', 'cdiam'), - 'c_C_in_SiC': ('csic', 'c-sic', 'c(3c-sic)', 'c_sic'), - 'c_C_in_UC_100p': ('cuc100', 'cinuc_100p'), - 'c_C_in_UC_10p': ('cuc10', 'cinuc_10p'), - 'c_C_in_UC_5p': ('cuc5', 'cinuc_5p'), - 'c_C_in_UC': ('cinuc', 'cinuc_nat'), - 'c_C_in_UC_HALEU': ('cuchal', 'cinuc_haleu'), - 'c_C_in_UC_HEU': ('cucheu', 'cinuc_heu'), - 'c_C_in_ZrC': ('czrc', 'c(zrc)'), - 'c_Ca': ('ca',), - 'c_Ca_in_CaH2': ('cah', 'cah00', 'cacah2', 'ca(cah2)', 'ca_cah2'), - 'c_Ca_in_CaO2H2': ('ca(caoh2)', 'cacaoh'), - 'c_Cr': ('cr',), - 'c_Cu': ('cu',), - 'c_D_in_7LiD': ('dlid', 'd(7lid)'), + 'c_C_in_SiC': ('csic', 'c-sic', 'c(3c-sic)'), + 'c_Ca_in_CaH2': ('cah', 'cah00', 'cacah2', 'ca(cah2)'), 'c_D_in_D2O': ('dd2o', 'd-d2o', 'hwtr', 'hw', 'dhw00', 'd(d2o)'), - 'c_D_in_D2O_solid': ('dice',), - 'c_D_in_MgD2': ('d(mgd2)', 'dmgd2'), - 'c_F_in_Be2': ('fbef2', 'f in bef2'), - 'c_F_in_CF2': ('fcf2', 'f(teflon)'), + 'c_D_in_D2O_ice': ('dice',), 'c_F_in_FLiBe': ('fflibe', 'f(flibe)'), - 'c_F_in_HF': ('f_hf',), - 'c_F_in_LiF': ('f(lif)', 'flif'), - 'c_F_in_MgF2': ('fmgf2', 'f in mgf2'), 'c_Fe56': ('fe', 'fe56', 'fe-56', '26-fe- 56'), - 'c_Fe_in_Fe_alpha': ('fe(fe-alph', 'fealph'), - 'c_Fe_in_Fe_gamma': ('fe(fe-gamm', 'fegamm'), - 'c_Ga_in_GaN': ('ga(gan)', 'gagan'), - 'c_Ga_in_GaSe': ('ga(gase)', 'gagase'), - 'c_Ge': ('ge',), - 'c_Ge_in_Ge3Bi4O12': ('ge(ge3bi4o', 'gegbo'), - 'c_Ge_in_GeTe': ('ge(gete)', 'gegete'), 'c_Graphite': ('graph', 'grph', 'gr', 'gr00', 'graphite'), 'c_Graphite_10p': ('grph10', '10p graphit'), - 'c_Graphite_20p': ('grph20', '20 graphite'), 'c_Graphite_30p': ('grph30', '30p graphit'), - 'c_Graphite_distinct': ('grphsd', 'grph+sd'), - 'c_H_in_7LiH': ('hlih', 'h(7lih)'), 'c_H_in_C5O2H8': ('lucite', 'c5o2h8', 'h-luci', 'h(lucite)'), - 'c_H_in_C8H8': ('hc8h8', 'h(polystyr'), 'c_H_in_CaH2': ('hcah2', 'hca00', 'h(cah2)'), - 'c_H_in_CaO2H2': ('h(caoh2)', 'hcaoh'), - 'c_H1_in_CaH2': ('h1cah2', 'h1_cah2'), - 'c_H2_in_CaH2': ('h2cah2', 'h2_cah2'), - 'c_H_in_C19H16_liquid': ('h(c19h16)l', 'h19liq'), - 'c_H_in_C19H16_solid': ('h(c19h16)s', 'h19sol'), - 'c_H_in_C2H6O_liquid': ('h(c2h6o)l', 'hetliq'), - 'c_H_in_C2H6O_solid': ('h(c2h6o)s', 'hetsol'), - 'c_H_in_C6H6_liquid': ('h(c6h6)l', 'hbzliq'), - 'c_H_in_C6H6_solid': ('h(c6h6)s', 'hbzsol'), - 'c_H_in_C7H8_liquid': ('h(c7h8)l', 'htlliq'), - 'c_H_in_C7H8_solid': ('h(c7h8)s', 'htlsol'), - 'c_H_in_C8H10_liquid': ('h(m-c8h10)l', 'hxyliq'), - 'c_H_in_C8H10_solid': ('h(m-c8h10)s', 'hxysol'), - 'c_H_in_C9H12_liquid': ('h(c9h12)l', 'hmsliq'), - 'c_H_in_C9H12_solid': ('h(c9h12)s', 'hmssol'), - 'c_H_in_CH2': ('hch2', 'poly', 'pol', 'h-poly', 'pol00', 'h(ch2)', 'h(c2h4)n r'), - 'c_H_in_CH4_liquid': ('lch4', 'lmeth', 'l-ch4', 'h(ch4)l'), - 'c_H_in_CH4_solid': ('sch4', 'smeth', 's-ch4', 'h(ch4)s'), + 'c_H_in_CH2': ('hch2', 'poly', 'pol', 'h-poly', 'pol00', 'h(ch2)'), + 'c_H_in_CH4_liquid': ('lch4', 'lmeth', 'l-ch4'), + 'c_H_in_CH4_solid': ('sch4', 'smeth', 's-ch4'), 'c_H_in_CH4_solid_phase_II': ('sch4p2',), 'c_H_in_H2O': ('hh2o', 'h-h2o', 'lwtr', 'lw', 'lw00', 'h(h2o)'), 'c_H_in_H2O_solid': ('hice', 'h-ice', 'ice00', 'h(ice-ih)', 'h(ice)'), - 'c_H_in_HF': ('hhf', 'h(hf)', 'h_hf'), - 'c_H_in_KOH': ('h(koh)', 'hkoh'), - 'c_H_in_LiH': ('h(lih)', 'hlih2'), + 'c_H_in_HF': ('hhf', 'h(hf)'), 'c_H_in_Mesitylene': ('mesi00', 'mesi', 'mesi-phii'), - 'c_H_in_MgH2': ('h(mgh2)', 'hmgh2'), - 'c_H_in_MgOH2': ('h(mgoh2)', 'hmgoh'), - 'c_H_in_NaMgH3': ('h(namgh3)', 'hnamg'), - 'c_H_in_NaOH': ('h(naoh)', 'hnaoh'), - 'c_H_in_ParaffinicOil': ('hparaf', 'h(paraffin', 'h(paraffini'), - 'c_H_in_SrH2': ('h(srh2)', 'hsrh2'), + 'c_H_in_ParaffinicOil': ('hparaf', 'h(paraffin'), 'c_H_in_Toluene': ('tol00', 'tol', 'tolue-phii'), 'c_H_in_UH3': ('huh3', 'h(uh3)'), 'c_H_in_YH2': ('hyh2', 'h-yh2', 'h(yh2)'), 'c_H_in_ZrH': ('hzrh', 'h-zrh', 'h-zr', 'h/zr', 'hzr', 'hzr00', 'h(zrh)'), - 'c_H_in_ZrH2': ('hzrh2', 'h(zrh2)', 'h(zrh2) in'), - 'c_H_in_ZrHx': ('hzrhx', 'h(zrhx)', 'h(zrh15) i'), - 'c_I_in_NaI': ('i(nai)', 'inai'), - 'c_K': ('k',), - 'c_K_in_KOH': ('k(koh)', 'kkoh'), + 'c_H_in_ZrH2': ('hzrh2', 'h(zrh2)'), + 'c_H_in_ZrHx': ('hzrhx', 'h(zrhx)'), 'c_Li_in_FLiBe': ('liflib', 'li(flibe)'), - 'c_Li_in_7LiD': ('lilid', '7li(7lid)'), - 'c_Li_in_7LiH': ('lilih', '7li(7lih)'), - 'c_Li_in_LiF': ('li(lif)', 'lilif'), - 'c_Li_in_LiH': ('li(lih)', 'lilih2'), 'c_Mg24': ('mg', 'mg24', 'mg00', '24-mg'), - 'c_Mg_in_MgD2': ('mg(mgd2)', 'mgmgd2'), - 'c_Mg_in_MgF2': ('mgmgf2', 'mg in mgf2'), - 'c_Mg_in_MgH2': ('mg(mgh2)', 'mgmgh2'), - 'c_Mg_in_MgO': ('mgmgo', 'mg in mgo'), - 'c_Mg_in_MgOH2': ('mg(mgoh2)', 'mgoh2'), - 'c_Mg_in_NaMgH3': ('mg(namgh3)', 'mgnamg'), - 'c_Mo': ('mo',), - 'c_N_in_GaN': ('n(gan)', 'ngan'), - 'c_N_in_UN_100p': ('nun100', 'n-un-100p'), - 'c_N_in_UN_10p': ('nun10', 'n-un-10p'), - 'c_N_in_UN_5p': ('nun5', 'n-un-5p'), - 'c_N_in_UN': ('n-un', 'n(un)', 'n(un) l', 'ninun'), - 'c_N_in_UN_HALEU': ('nunhal', 'n-un-haleu'), - 'c_N_in_UN_HEU': ('nunheu', 'n-un-heu'), - 'c_Na': ('na',), - 'c_Na_in_NaI': ('na(nai)', 'nanai'), - 'c_Na_in_NaMgH3': ('na(namgh3)', 'nanamg'), - 'c_Na_in_NaOH': ('na(naoh)', 'nanaoh'), - 'c_Nb': ('nb',), - 'c_Ni': ('ni',), + 'c_N_in_UN': ('n-un', 'n(un)', 'n(un) l'), 'c_O_in_Al2O3': ('osap00', 'osap', 'o(al2o3)'), - 'c_O_in_BeO': ('obeo', 'o-beo', 'o-be', 'o/be', 'obeo00', 'o(beo)', 'o_beo'), - 'c_O_in_C2H6O_liquid': ('o(c2h6o)l', 'oetliq'), - 'c_O_in_C2H6O_solid': ('o(c2h6o)s', 'oetsol'), - 'c_O_in_C5O2H8': ('olucit', 'o(lucite)'), - 'c_O_in_CaO2H2': ('o(caoh2)', 'ocaoh'), + 'c_O_in_BeO': ('obeo', 'o-beo', 'o-be', 'o/be', 'obeo00', 'o(beo)'), 'c_O_in_D2O': ('od2o', 'o-d2o', 'ohw00', 'o(d2o)'), - 'c_O_in_H2O': ('o(h2o)', 'oh2o'), 'c_O_in_H2O_solid': ('oice', 'o-ice', 'o(ice-ih)'), - 'c_O_in_Ge3Bi4O12': ('o(ge3bi4o1', 'ogbo'), - 'c_O_in_KOH': ('o(koh)', 'okoh'), - 'c_O_in_MgO': ('omgo', 'o in mgo'), - 'c_O_in_MgOH2': ('o(mgoh2)', 'omgoh'), - 'c_O_in_NaOH': ('o(naoh)', 'onaoh'), - 'c_O_in_PuO2': ('opuo2', 'o in puo2'), - 'c_O_in_SiO2_alpha': ('osio2a', 'o_sio2a'), - 'c_O_in_UO2_100p': ('ouo200', 'o-uo2-100p'), - 'c_O_in_UO2_10p': ('ouo210', 'oinuo2-10p'), - 'c_O_in_UO2_5p': ('ouo25', 'oinuo2-5p'), 'c_O_in_UO2': ('ouo2', 'o-uo2', 'o2-u', 'o2/u', 'ouo200', 'o(uo2)'), - 'c_O_in_UO2_HALEU': ('ouo2hl', 'ouo2-haleu'), - 'c_O_in_UO2_HEU': ('ouo2he', 'o_uo2-heu'), - 'c_O_in_Y3Al5O12': ('o(y3al5o12', 'oyag'), 'c_ortho_D': ('orthod', 'orthoD', 'dortho', 'od200', 'ortod', 'ortho-d'), 'c_ortho_H': ('orthoh', 'orthoH', 'hortho', 'oh200', 'ortoh', 'ortho-h'), 'c_para_D': ('parad', 'paraD', 'dpara', 'pd200', 'para-d'), 'c_para_H': ('parah', 'paraH', 'hpara', 'ph200', 'para-h'), - 'c_Pb': ('pb',), - 'c_Pd': ('pd',), - 'c_Pt': ('pt',), - 'c_Pu_in_PuO2': ('puo2', 'pu in puo2'), 'c_Si28': ('si00', 'sili', 'si'), - 'c_Si_in_SiC': ('sisic', 'si-sic', 'si(3c-sic)', 'si_sic'), - 'c_Si_in_SiO2_alpha': ('si_o2a', 'si_sio2a'), - 'c_SiO2_alpha': ('sio2', 'sio2a', 'sio2alpha', 'sio2-a'), - 'c_SiO2_beta': ('sio2b', 'sio2beta', 'sio2-b'), - 'c_S_in_ZnS': ('s(zns-spha', 'szns'), - 'c_Se_in_GaSe': ('se(gase)', 'segase'), - 'c_Sn': ('sn',), - 'c_Sr_in_SrH2': ('sr(srh2)', 'srsrh2'), - 'c_Te_in_GeTe': ('te(gete)', 'tegete'), - 'c_Ti': ('ti',), - 'c_U_metal_100p': ('u-100p',), - 'c_U_metal_10p': ('u-10p',), - 'c_U_metal_5p': ('u-5p',), - 'c_U_metal': ('umetal', 'u-metal'), - 'c_U_metal_HALEU': ('uhaleu', 'u-haleu'), - 'c_U_metal_HEU': ('u-heu',), - 'c_U_in_UC_100p': ('uc-100', 'uinuc_100p'), - 'c_U_in_UC_10p': ('uc-10', 'uinuc_10p'), - 'c_U_in_UC_5p': ('uc-5', 'uinuc_5p'), - 'c_U_in_UC': ('uc-nat', 'uinuc_nat'), - 'c_U_in_UC_HALEU': ('uc-hal', 'uinuc_haleu'), - 'c_U_in_UC_HEU': ('uc-heu', 'uinuc_heu'), - 'c_U_in_UN_100p': ('un-100', 'u-un-100p'), - 'c_U_in_UN_10p': ('un-10', 'u-un-10p'), - 'c_U_in_UN_5p': ('un-5', 'u-un-5p'), - 'c_U_in_UN': ('u-un', 'u(un)', 'u(un) l', 'uinun'), - 'c_U_in_UN_HALEU': ('un-hal', 'u-un-haleu'), - 'c_U_in_UN_HEU': ('un-heu', 'u-un-heu'), - 'c_U_in_UO2_100p': ('uo2100', 'uuo2-100p'), - 'c_U_in_UO2_10p': ('uo2-10', 'uuo2-10p'), - 'c_U_in_UO2_5p': ('uo2-5', 'uuo2-5p'), + 'c_Si_in_SiC': ('sisic', 'si-sic', 'si(3c-sic)'), + 'c_SiO2_alpha': ('sio2', 'sio2a', 'sio2alpha'), + 'c_SiO2_beta': ('sio2b', 'sio2beta'), + 'c_U_in_UN': ('u-un', 'u(un)', 'u(un) l'), 'c_U_in_UO2': ('uuo2', 'u-uo2', 'u-o2', 'u/o2', 'uuo200', 'u(uo2)'), - 'c_U_in_UO2_HALEU': ('uo2hal', 'uuo2-haleu'), - 'c_U_in_UO2_HEU': ('uo2heu', 'u_uo2-heu'), - 'c_V': ('v',), - 'c_W': ('w',), - 'c_Y_in_Y3Al5O12': ('y(y3al5o12', 'yyag'), 'c_Y_in_YH2': ('yyh2', 'y-yh2', 'y(yh2)'), - 'c_Zn': ('zn',), - 'c_Zn_in_ZnS': ('zn(zns-sph', 'znzns'), - 'c_Zr': ('zr',), - 'c_Zr_in_ZrC': ('zrzrc', 'zr(zrc)'), 'c_Zr_in_ZrH': ('zrzrh', 'zr-zrh', 'zr-h', 'zr/h', 'zr(zrh)'), - 'c_Zr_in_ZrH2': ('zrzrh2', 'zr(zrh2)', 'zr(zrh2) i'), - 'c_Zr_in_ZrHx': ('zrzrhx', 'zr(zrhx)', 'zr(zrh15)'), + 'c_Zr_in_ZrH2': ('zrzrh2', 'zr(zrh2)'), + 'c_Zr_in_ZrHx': ('zrzrhx', 'zr(zrhx)'), } @@ -965,7 +804,7 @@ class ThermalScattering(EqualityMixin): @classmethod def from_njoy(cls, filename, filename_thermal, temperatures=None, evaluation=None, evaluation_thermal=None, - use_endf_data=True, divide_incoherent_elastic=False, **kwargs): + use_endf_data=True, **kwargs): """Generate thermal scattering data by running NJOY. Parameters @@ -988,13 +827,8 @@ class ThermalScattering(EqualityMixin): use_endf_data : bool If the material has incoherent elastic scattering, the ENDF data will be used rather than the ACE data. - divide_incoherent_elastic : bool - Divide incoherent elastic cross section by number of principal - atoms. This is not part of the ENDF-6 standard but it is how it is - processed by NJOY. **kwargs - Keyword arguments passed to - :func:`openmc.data.njoy.make_ace_thermal` + Keyword arguments passed to :func:`openmc.data.njoy.make_ace_thermal` Returns ------- @@ -1019,7 +853,7 @@ class ThermalScattering(EqualityMixin): # Load ENDF data to replace incoherent elastic if use_endf_data: - data_endf = cls.from_endf(filename_thermal, divide_incoherent_elastic) + data_endf = cls.from_endf(filename_thermal) if data_endf.elastic is not None: # Get appropriate temperatures if temperatures is None: @@ -1037,18 +871,14 @@ class ThermalScattering(EqualityMixin): return data @classmethod - def from_endf(cls, ev_or_filename, divide_incoherent_elastic=False): + def from_endf(cls, ev_or_filename): """Generate thermal scattering data from an ENDF file Parameters ---------- - ev_or_filename : openmc.data.endf.Evaluation, endf.Material, or str + ev_or_filename : openmc.data.endf.Evaluation or str ENDF evaluation to read from. If given as a string, it is assumed to be the filename for the ENDF file. - divide_incoherent_elastic : bool - Divide incoherent elastic cross section by number of principal - atoms. This is not part of the ENDF-6 standard but it is how it is - processed by NJOY. Returns ------- @@ -1056,7 +886,60 @@ class ThermalScattering(EqualityMixin): Thermal scattering data """ - ev = endf.as_evaluation(ev_or_filename) + if isinstance(ev_or_filename, endf.Evaluation): + ev = ev_or_filename + else: + ev = endf.Evaluation(ev_or_filename) + + # Read coherent/incoherent elastic data + elastic = None + if (7, 2) in ev.section: + # Define helper functions to avoid duplication + def get_coherent_elastic(file_obj): + # Get structure factor at first temperature + params, S = endf.get_tab1_record(file_obj) + strT = _temperature_str(params[0]) + n_temps = params[2] + bragg_edges = S.x + xs = {strT: CoherentElastic(bragg_edges, S.y)} + distribution = {strT: CoherentElasticAE(xs[strT])} + + # Get structure factor for subsequent temperatures + for _ in range(n_temps): + params, S = endf.get_list_record(file_obj) + strT = _temperature_str(params[0]) + xs[strT] = CoherentElastic(bragg_edges, S) + distribution[strT] = CoherentElasticAE(xs[strT]) + return xs, distribution + + def get_incoherent_elastic(file_obj): + params, W = endf.get_tab1_record(file_obj) + bound_xs = params[0] + xs = {} + distribution = {} + for T, debye_waller in zip(W.x, W.y): + strT = _temperature_str(T) + xs[strT] = IncoherentElastic(bound_xs, debye_waller) + distribution[strT] = IncoherentElasticAE(debye_waller) + return xs, distribution + + file_obj = StringIO(ev.section[7, 2]) + lhtr = endf.get_head_record(file_obj)[2] + if lhtr == 1: + # coherent elastic + xs, distribution = get_coherent_elastic(file_obj) + elif lhtr == 2: + # incoherent elastic + xs, distribution = get_incoherent_elastic(file_obj) + elif lhtr == 3: + # mixed coherent / incoherent elastic + xs_c, dist_c = get_coherent_elastic(file_obj) + xs_i, dist_i = get_incoherent_elastic(file_obj) + assert sorted(xs_c) == sorted(xs_i) + xs = {T: Sum([xs_c[T], xs_i[T]]) for T in xs_c} + distribution = {T: MixedElasticAE(dist_c[T], dist_i[T]) for T in dist_c} + + elastic = ThermalScatteringReaction(xs, distribution) # Read incoherent inelastic data assert (7, 4) in ev.section, 'No MF=7, MT=4 found in thermal scattering' @@ -1072,7 +955,6 @@ class ThermalScattering(EqualityMixin): data['A0'] = awr = B[2] data['e_max'] = energy_max = B[3] data['M0'] = B[5] - free_xs = data['free_atom_xs'] / data['M0'] # Get information about non-principal atoms n_non_principal = params[5] @@ -1117,74 +999,6 @@ class ThermalScattering(EqualityMixin): _, Teff = endf.get_tab1_record(file_obj) data['effective_temperature'].append(Teff) - # Read coherent/incoherent elastic data - elastic = None - if (7, 2) in ev.section: - # Define helper functions to avoid duplication - def get_coherent_elastic(file_obj): - # Get structure factor at first temperature - params, S = endf.get_tab1_record(file_obj) - strT = _temperature_str(params[0]) - n_temps = params[2] - bragg_edges = S.x - xs = {strT: CoherentElastic(bragg_edges, S.y)} - distribution = {strT: CoherentElasticAE(xs[strT])} - - # Get structure factor for subsequent temperatures - for _ in range(n_temps): - params, S = endf.get_list_record(file_obj) - strT = _temperature_str(params[0]) - xs[strT] = CoherentElastic(bragg_edges, S) - distribution[strT] = CoherentElasticAE(xs[strT]) - return xs, distribution - - def get_incoherent_elastic(file_obj, natom): - params, W = endf.get_tab1_record(file_obj) - bound_xs = params[0]/natom - - # Check whether divide_incoherent_elastic was applied correctly - if abs(free_xs - bound_xs/(1 + 1/data['A0'])**2) > 0.5: - if divide_incoherent_elastic: - msg = ( - 'Thermal scattering evaluation follows ENDF-6 ' - 'definition of bound cross section but ' - 'divide_incoherent_elastic=True.' - ) - else: - msg = ( - 'Thermal scattering evaluation follows NJOY ' - 'definition of bound cross section but ' - 'divide_incoherent_elastic=False.' - ) - warn(msg) - - xs = {} - distribution = {} - for T, debye_waller in zip(W.x, W.y): - strT = _temperature_str(T) - xs[strT] = IncoherentElastic(bound_xs, debye_waller) - distribution[strT] = IncoherentElasticAE(debye_waller) - return xs, distribution - - file_obj = StringIO(ev.section[7, 2]) - lhtr = endf.get_head_record(file_obj)[2] - natom = data['M0'] if divide_incoherent_elastic else 1 - if lhtr == 1: - # coherent elastic - xs, distribution = get_coherent_elastic(file_obj) - elif lhtr == 2: - # incoherent elastic - xs, distribution = get_incoherent_elastic(file_obj, natom) - elif lhtr == 3: - # mixed coherent / incoherent elastic - xs_c, dist_c = get_coherent_elastic(file_obj) - xs_i, dist_i = get_incoherent_elastic(file_obj, natom) - assert sorted(xs_c) == sorted(xs_i) - xs = {T: Sum([xs_c[T], xs_i[T]]) for T in xs_c} - distribution = {T: MixedElasticAE(dist_c[T], dist_i[T]) for T in dist_c} - - elastic = ThermalScatteringReaction(xs, distribution) - name = ev.target['zsymam'].strip() instance = cls(name, awr, energy_max, kTs) if elastic is not None: diff --git a/openmc/data/vectfit.py b/openmc/data/vectfit.py deleted file mode 100644 index c5a783a3c..000000000 --- a/openmc/data/vectfit.py +++ /dev/null @@ -1,811 +0,0 @@ -""" -Fast Relaxed Vector Fitting function - -Approximate f(s) with a rational function: - f(s)=R*(s*I-A)^(-1) + Polynomials*s -where f(s) is a vector of elements. - -When f(s) is a vector, all elements become fitted with a common pole set. The -identification is done using the pole relocating method known as Vector Fitting -[1] with relaxed non-triviality constraint for faster convergence and smaller -fitting errors [2], and utilization of matrix structure for fast solution of the -pole identifion step [3]. - -[1] B. Gustavsen and A. Semlyen, "Rational approximation of frequency - domain responses by Vector Fitting", IEEE Trans. Power Delivery, vol. 14, - no. 3, pp. 1052-1061, July 1999. -[2] B. Gustavsen, "Improving the pole relocating properties of vector - fitting", IEEE Trans. Power Delivery, vol. 21, no. 3, pp. 1587-1592, July - 2006. -[3] D. Deschrijver, M. Mrozowski, T. Dhaene, and D. De Zutter, - "Macromodeling of Multiport Systems Using a Fast Implementation of the - Vector Fitting Method", IEEE Microwave and Wireless Components Letters, vol. - 18, no. 6, pp. 383-385, June 2008. - -All credit goes to: - - Bjorn Gustavsen for his MATLAB implementation. - (http://www.sintef.no/Projectweb/VECTFIT/) - - Jingang Liang for his C++ implementation. - (https://github.com/mit-crpg/vectfit.git) - -""" - -from typing import Tuple - -import numpy as np -from scipy.linalg import eigvals, lstsq, norm, qr - - -def wlstsq(a, b): - """Apply least-squares solve with column normalization. - - Notes - ----- - This routine rescales columns of `a` to improve conditioning. Columns with - zero norm are left unscaled to avoid divide-by-zero warnings. - """ - col_norm = np.linalg.norm(a, axis=0) - scale = np.ones_like(col_norm, dtype=float) - nonzero = col_norm > 0.0 - scale[nonzero] = 1.0 / col_norm[nonzero] - scale = np.nan_to_num(scale, nan=1.0, posinf=1.0, neginf=1.0) - - sol = lstsq(a * scale, b) - return (sol[0] * scale, sol[1:]) - - -def evaluate( - eval_points: np.ndarray, - pole_values: np.ndarray, - residue_matrix: np.ndarray, - poly_coefficients: np.ndarray | None = None, -) -> np.ndarray: - """Evaluate the rational function approximation: - f(s) ≈ sum(residue / (s - pole)) + sum(poly_coefficients * s^j) - - Parameters - ---------- - eval_points : np.ndarray - 1D array of real scalar frequency values (s). - pole_values : np.ndarray - 1D array of complex poles. - residue_matrix : np.ndarray - 2D or 1D array of complex residues (shape: [num_vectors, num_poles] or [num_poles]). - poly_coefficients : np.ndarray, optional - 2D or 1D array of real polynomial coefficients (shape: [num_vectors, num_polys]). - - Returns - ------- - np.ndarray - 2D array of evaluated real function values (shape: [num_vectors, num_samples]). - - Raises - ------ - ValueError - If input arrays have incompatible shapes. - """ - eval_points = np.asarray(eval_points) - pole_values = np.asarray(pole_values) - residue_matrix = np.asarray(residue_matrix) - - if eval_points.ndim != 1: - raise ValueError("eval_points must be a 1D array") - if pole_values.ndim != 1: - raise ValueError("pole_values must be a 1D array") - - if residue_matrix.ndim == 1: - residue_matrix = residue_matrix.reshape((1, -1)) - num_vectors, _ = residue_matrix.shape - num_samples = len(eval_points) - - if poly_coefficients is not None and isinstance(poly_coefficients, list): - poly_coefficients = np.array(poly_coefficients) - if poly_coefficients is None or poly_coefficients.size == 0: - poly_coefficients = np.zeros((num_vectors, 0)) - else: - poly_coefficients = np.asarray(poly_coefficients) - if poly_coefficients.ndim == 1: - poly_coefficients = poly_coefficients.reshape((1, -1)) - elif poly_coefficients.shape[0] != num_vectors: - raise ValueError("Mismatch in residues and poly_coefficients shapes") - - num_coeffs = poly_coefficients.shape[1] - result = np.zeros((num_vectors, num_samples)) - - # term: sum over poles of (residues / (eval_points - poles)) - denominator = ( - eval_points[np.newaxis, :] - pole_values[:, np.newaxis] - ) # shape: (num_poles, num_eval) - pole_terms = residue_matrix @ (1.0 / denominator) # shape: (num_vectors, num_eval) - result = np.real(pole_terms) - - # polynomial part: sum over poly_idx of (coeff * eval_points**poly_idx) - if num_coeffs > 0: - powers = ( - eval_points[np.newaxis, :] ** np.arange(num_coeffs)[:, np.newaxis] - ) # shape: (num_coeffs, num_eval) - result += poly_coefficients @ powers # shape: (num_vectors, num_eval) - - return result - - -def vectfit( - response_matrix: np.ndarray, - eval_points: np.ndarray, - initial_poles: np.ndarray, - weights: np.ndarray, - n_polys: int = 0, - skip_pole_update: bool = False, - skip_residue_update: bool = False, -) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, float]: - """Perform vector fitting using the Fast Relaxed Vector Fitting algorithm. - - Parameters - ---------- - response_matrix : np.ndarray - Complex matrix of frequency responses (shape: [num_vectors, num_samples]). - eval_points : np.ndarray - Real frequency samples (s), shape (num_samples,). - initial_poles : np.ndarray - Initial guess for poles (complex), shape (num_poles,). - weights : np.ndarray - Weighting matrix for fitting (same shape as response_matrix). - n_polys : int, optional - Number of real polynomial terms to include. - skip_pole_update : bool, optional - Whether to skip pole relocation step. - skip_residue_update : bool, optional - Whether to skip residue fitting step. - - Returns - ------- - Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, float] - - Updated poles (np.ndarray) - - Residues (np.ndarray) - - Polynomial coefficients (np.ndarray) - - Fitted response matrix (np.ndarray) - - Root-mean-square error (float) - """ - tol_low = 1e-18 - tol_high = 1e18 - response_matrix = np.asarray(response_matrix) - eval_points = np.asarray(eval_points) - initial_poles = np.asarray(initial_poles) - weights = np.asarray(weights) - - num_vectors, num_samples = response_matrix.shape - num_poles = len(initial_poles) - - if n_polys < 0 or n_polys > 11: - raise ValueError("n_polys must be in [0, 11]") - - residue_matrix = np.zeros((num_vectors, num_poles), dtype=np.complex128) - poly_coefficients = np.zeros((num_vectors, n_polys)) - fit_result = np.zeros_like(response_matrix) - rms_error = 0.0 - - if num_poles == 0 and n_polys == 0: - rms_error = norm(response_matrix) / np.sqrt(num_vectors * num_samples) - return initial_poles, residue_matrix, poly_coefficients, fit_result, rms_error - - if not skip_pole_update and num_poles > 0: - updated_poles = identify_poles( - num_poles, - num_samples, - n_polys, - initial_poles, - eval_points, - tol_high, - weights, - response_matrix, - num_vectors, - tol_low, - ) - else: - updated_poles = initial_poles - - if not skip_residue_update: - fit_result, rms_error = identify_residues( - num_poles, - updated_poles, - num_samples, - n_polys, - eval_points, - num_vectors, - weights, - response_matrix, - poly_coefficients, - residue_matrix, - ) - - return updated_poles, residue_matrix, poly_coefficients, fit_result, rms_error - - -def compute_dk_matrix( - dk_matrix: np.ndarray, - eval_points: np.ndarray, - poles: np.ndarray, - conj_index: np.ndarray, - num_poles: int, - num_polys: int, - tol_high: float = None, -): - """Compute the dk_matrix used in windowed multipole evaluations. - - Parameters - ---------- - dk_matrix : ndarray of shape (len(eval_points), M) - The full matrix used in least-squares fitting or evaluation. - eval_points : ndarray of shape (N,) - Energy points at which to evaluate. - poles : ndarray of shape (num_poles,) - Complex poles used in the resonance model. - conj_index : ndarray of shape (num_poles,) - Index array indicating pole conjugacy behavior: 0 (normal), 1 (add conjugate), 2 (imaginary part). - num_poles : int - Number of complex poles. - num_polys : int - Number of polynomial terms (including constant term). - tol_high : float - Replacement value for infinities. - """ - # Broadcast shapes - eval_points_col = eval_points[:, np.newaxis] - poles_row = poles[np.newaxis, :] - - # Compute base terms - term1 = 1.0 / (eval_points_col - poles_row) - term2 = 1.0 / (eval_points_col - np.conj(poles_row)) - term3 = 1j / (eval_points_col - np.conj(poles_row)) - 1j / ( - eval_points_col - poles_row - ) - - # Masks for different conjugacy types - mask0 = conj_index == 0 - mask1 = conj_index == 1 - mask2 = conj_index == 2 - - # Fill dk_matrix with pole terms - dk_matrix[:, :num_poles][:, mask0] = term1[:, mask0] - dk_matrix[:, :num_poles][:, mask1] = term1[:, mask1] + term2[:, mask1] - dk_matrix[:, :num_poles][:, mask2] = term3[:, mask2] - - # Replace infinities with high tolerance value - if tol_high is not None: - inf_mask = np.isinf(dk_matrix) - dk_matrix[inf_mask] = tol_high + 0j - - # Add polynomial basis (Chebyshev-like, just powers here) - powers = np.arange(num_polys) - dk_matrix[:, num_poles : num_poles + num_polys] = eval_points_col**powers + 0j - return dk_matrix - - -def row_block_matrix( - dk_matrix: np.ndarray, - weights: np.ndarray, - response_matrix: np.ndarray, - vec_idx: int, - num_poles: int, - num_polys: int, -) -> np.ndarray: - """ - Construct a single matrix row block for the given vector index. - - Parameters - ---------- - dk_matrix : ndarray of shape (num_samples, num_poles + num_polys) - Basis function evaluations at each sample point. - weights : ndarray of shape (num_vectors, num_samples) - Sample weights for each vector. - response_matrix : ndarray of shape (num_vectors, num_samples) - Response values at each sample point. - vec_idx : int - Index of the vector to construct the A1 block for. - num_poles : int - Number of poles used in the model. - num_polys : int - Number of polynomial basis terms. - - Returns - ------- - A : ndarray of shape (num_samples, num_poles + num_polys + num_poles + 1) - Weighted and assembled matrix block for the current vector. - """ - num_samples = dk_matrix.shape[0] - A = np.zeros( - (num_samples, num_poles + num_polys + num_poles + 1), dtype=np.complex128 - ) - - # Weighted basis terms - A[:, : num_poles + num_polys] = ( - weights[vec_idx][:, np.newaxis] * dk_matrix[:, : num_poles + num_polys] - ) - - # Weighted response terms (includes poles + 1) - A[:, num_poles + num_polys : num_poles + num_polys + num_poles + 1] = ( - -weights[vec_idx][:, np.newaxis] - * dk_matrix[:, : num_poles + 1] - * response_matrix[vec_idx][:, np.newaxis] - ) - - return A - - -def process_constrained_block( - vec_idx: int, - dk_matrix: np.ndarray, - weights: np.ndarray, - response_matrix: np.ndarray, - num_samples: int, - num_poles: int, - num_polys: int, - scale_factor: float, - num_vectors: int, -) -> Tuple[int, np.ndarray, np.ndarray]: - """ - Construct a constrained least-squares system block for the given vector index. - - This function computes the A matrix using weighted evaluations of the basis functions - and response terms. It appends a constraint row to enforce physical properties - (e.g., normalization) **only for the final vector index**. The full matrix A is - decomposed via QR, and the resulting triangular block is returned. - - This routine is intended for use in the main vector fitting loop when the denominator - is well-conditioned but requires an additional constraint row for physical consistency. - - Parameters - ---------- - vec_idx : int - Index of the vector to process. - dk_matrix : ndarray of shape (num_samples, num_poles + num_polys) - Evaluated basis functions at sample points. - weights : ndarray of shape (num_vectors, num_samples) - Weight matrix per vector. - response_matrix : ndarray of shape (num_vectors, num_samples) - Response function values for each vector. - num_samples : int - Number of sample points. - num_poles : int - Number of poles in the model. - num_polys : int - Number of polynomial terms in the model. - scale_factor : float - Scaling factor applied to the final constraint row. - num_vectors : int - Total number of vectors to process. - - Returns - ------- - vec_idx : int - Index of the processed vector. - lhs_block : ndarray of shape (num_poles + 1, num_poles + 1) - Triangular matrix block from QR decomposition. - rhs_block : ndarray of shape (num_poles + 1,) or None - Right-hand side vector block (only returned for final vec_idx), else None. - """ - A1 = row_block_matrix( - dk_matrix, weights, response_matrix, vec_idx, num_poles, num_polys - ) - A = np.zeros((2 * num_samples + 1, num_poles + num_polys + num_poles + 1)) - A[:num_samples] = A1.real - A[num_samples : 2 * num_samples] = A1.imag - # Handle final row only if vec_idx is last - if vec_idx == num_vectors - 1: - A[ - 2 * num_samples, - num_poles + num_polys : num_poles + num_polys + num_poles + 1, - ] = scale_factor * np.real(dk_matrix[:, : num_poles + 1].sum(axis=0)) - - Q, R = qr(A, mode="economic") - - lhs_block = R[ - num_poles + num_polys : num_poles + num_polys + num_poles + 1, - num_poles + num_polys : num_poles + num_polys + num_poles + 1, - ] - - if vec_idx == num_vectors - 1: - rhs_block = ( - num_samples - * scale_factor - * Q[-1, num_poles + num_polys : num_poles + num_polys + num_poles + 1] - ) - else: - rhs_block = np.zeros_like( - Q[-1, num_poles + num_polys : num_poles + num_polys + num_poles + 1] - ) - - return vec_idx, lhs_block, rhs_block - - -def process_unconstrained_block( - vec_idx: int, - dk_matrix: np.ndarray, - weights: np.ndarray, - response_matrix: np.ndarray, - denom: float, - num_poles: int, - num_polys: int, -) -> Tuple[int, np.ndarray, np.ndarray]: - """ - Construct an unconstrained least-squares system block for the given vector index. - - This function is used when the fitting denominator becomes ill-conditioned - (too small or too large), and the original constrained system is replaced by - an alternative regularized least-squares problem. The A matrix is built by stacking - the real and imaginary parts of the basis evaluations, and the RHS vector b is - scaled by `denom`. - - A standard QR decomposition is used to extract the square block of the system, - which can be solved independently from the constrained system. - - Parameters - ---------- - vec_idx : int - Index of the vector to process. - dk_matrix : ndarray of shape (num_samples, num_poles + num_polys) - Evaluated basis functions at sample points. - weights : ndarray of shape (num_vectors, num_samples) - Weight matrix per vector. - response_matrix : ndarray of shape (num_vectors, num_samples) - Response function values for each vector. - denom : float - Scaling factor applied to the right-hand side vector b. - num_poles : int - Number of poles in the model. - num_polys : int - Number of polynomial terms in the model. - - Returns - ------- - vec_idx : int - Index of the processed vector. - lhs_block : ndarray of shape (num_poles, num_poles) - Triangular matrix block from QR decomposition. - rhs_block : ndarray of shape (num_poles,) - Right-hand side vector block for this vector. - """ - A1 = row_block_matrix( - dk_matrix, weights, response_matrix, vec_idx, num_poles, num_polys - ) - A = np.vstack((A1.real, A1.imag)) - - b1 = denom * weights[vec_idx] * response_matrix[vec_idx] - b = np.concatenate((b1.real, b1.imag)) - - Q, R = qr(A, mode="economic") - - lhs_block = R[ - num_poles + num_polys : num_poles + num_polys + num_poles, - num_poles + num_polys : num_poles + num_polys + num_poles, - ] - rhs_block = Q[:, num_poles + num_polys : num_poles + num_polys + num_poles].T @ b - return vec_idx, lhs_block, rhs_block - - -def identify_poles( - num_poles: int, - num_samples: int, - num_polys: int, - poles: np.ndarray, - eval_points: np.ndarray, - tol_high: float, - weights: np.ndarray, - response_matrix: np.ndarray, - num_vectors: int, - tol_low: float, -) -> np.ndarray: - """ - Internal routine to update poles via relaxed vector fitting. - - Parameters - ---------- - num_poles : int - Number of poles. - num_samples : int - Number of frequency samples. - num_polys : int - Number of polynomial terms. - poles : np.ndarray - Initial poles (complex), shape (num_poles,). - eval_points : np.ndarray - Real frequency values, shape (num_samples,). - tol_high : float - Upper tolerance threshold for denominator. - weights : np.ndarray - Weighting matrix, shape (num_vectors, num_samples). - response_matrix : np.ndarray - Complex frequency responses, shape (num_vectors, num_samples). - num_vectors : int - Number of response vectors. - tol_low : float - Lower tolerance threshold for denominator. - - Returns - ------- - np.ndarray - Updated poles as eigenvalues (shape: [num_poles]). - """ - conj_index = label_conjugate_poles(poles) - dk_matrix = np.zeros( - (num_samples, num_poles + max(num_polys, 1)), dtype=np.complex128 - ) - compute_dk_matrix( - dk_matrix, eval_points, poles, conj_index, num_poles, num_polys, tol_high - ) - # For relaxed vector fitting, include the constant term in the sigma(s) - # function even when no polynomial terms are requested. This ensures the - # constrained system is well-posed when n_polys == 0. - if num_polys == 0: - dk_matrix[:, num_poles] = 1.0 + 0j - - scale_factor = ( - np.sqrt( - sum(norm(weights[m] * response_matrix[m]) ** 2 for m in range(num_vectors)) - ) - / num_samples - ) - lhs_matrix = np.zeros((num_vectors * (num_poles + 1), num_poles + 1)) - rhs_vector = np.zeros(num_vectors * (num_poles + 1)) - - for vec_idx in range(num_vectors): - vec_idx, lhs_block, rhs_block = process_constrained_block( - vec_idx, - dk_matrix, - weights, - response_matrix, - num_samples, - num_poles, - num_polys, - scale_factor, - num_vectors, - ) - i0 = vec_idx * (num_poles + 1) - i1 = (vec_idx + 1) * (num_poles + 1) - lhs_matrix[i0:i1] = lhs_block - rhs_vector[i0:i1] = rhs_block - - solution, *_ = wlstsq(lhs_matrix, rhs_vector) - coeffs = solution[:-1] - denom = solution[-1] - - if abs(denom) < tol_low or abs(denom) > tol_high: - lhs_matrix = np.zeros((num_vectors * num_poles, num_poles)) - rhs_vector = np.zeros(num_vectors * num_poles) - # Adjust denom - if denom == 0.0: - denom = 1.0 - elif abs(denom) < tol_low: - denom = np.sign(denom) * tol_low - elif abs(denom) > tol_high: - denom = np.sign(denom) * tol_high - - # Allocate output - lhs_matrix = np.zeros((num_vectors * num_poles, num_poles)) - rhs_vector = np.zeros(num_vectors * num_poles) - - for vec_idx in range(num_vectors): - vec_idx, lhs_block, rhs_block = process_unconstrained_block( - vec_idx, - dk_matrix, - weights, - response_matrix, - denom, - num_poles, - num_polys, - ) - i0 = vec_idx * num_poles - i1 = (vec_idx + 1) * num_poles - lhs_matrix[i0:i1] = lhs_block - rhs_vector[i0:i1] = rhs_block - - coeffs, *_ = wlstsq(lhs_matrix, rhs_vector) - - lambda_matrix = np.zeros((num_poles, num_poles)) - scale_vector = np.ones((num_poles, 1)) - - # Mask for real poles (conj_index == 0) - mask_real = conj_index == 0 - real_indices = np.where(mask_real)[0] - lambda_matrix[real_indices, real_indices] = np.real(poles[real_indices]) - - # Mask for start of complex conjugate pairs (conj_index == 1) - mask_cplx_start = conj_index == 1 - cplx_indices = np.where(mask_cplx_start)[0] - - # Extract real and imaginary parts of complex conjugate poles - real_parts = np.real(poles[cplx_indices]) - imag_parts = np.imag(poles[cplx_indices]) - - # Diagonal assignments - lambda_matrix[cplx_indices, cplx_indices] = real_parts - lambda_matrix[cplx_indices + 1, cplx_indices + 1] = real_parts - - # Off-diagonal assignments - lambda_matrix[cplx_indices, cplx_indices + 1] = imag_parts - lambda_matrix[cplx_indices + 1, cplx_indices] = -imag_parts - - # Scaling vector adjustments - scale_vector[cplx_indices, 0] = 2.0 - scale_vector[cplx_indices + 1, 0] = 0.0 - - residue_matrix = lambda_matrix - np.outer(scale_vector.squeeze(), coeffs) / denom - return eigvals(residue_matrix) - - -def solve_vector_block( - vec_idx: int, - dk_matrix: np.ndarray, - weights: np.ndarray, - response_matrix: np.ndarray, - num_poles: int, - num_polys: int, -) -> Tuple[int, np.ndarray, np.ndarray]: - """ - Solve the least-squares system for a single vector index. - - Parameters - ---------- - vec_idx : int - Index of the vector to solve. - dk_matrix : ndarray - Basis function evaluations of shape (num_samples, num_poles + num_polys). - weights : ndarray - Weight array of shape (num_vectors, num_samples). - response_matrix : ndarray - Response array of shape (num_vectors, num_samples). - num_poles : int - Number of poles. - num_polys : int - Number of polynomial coefficients. - - Returns - ------- - vec_idx : int - The index of the solved vector. - residues : ndarray - Solution vector for the residues (length = num_poles). - poly_coeffs : ndarray or None - Solution vector for polynomial coefficients (length = num_polys), or None if num_polys == 0. - """ - A = dk_matrix * weights[vec_idx][:, np.newaxis] - b = weights[vec_idx] * response_matrix[vec_idx] - - lhs_matrix = np.vstack((A.real, A.imag)) - rhs_vector = np.concatenate((b.real, b.imag)) - - x = wlstsq(lhs_matrix, rhs_vector)[0] - - residues = x[:num_poles] - poly_coeffs = x[num_poles : num_poles + num_polys] if num_polys > 0 else None - - return vec_idx, residues, poly_coeffs - - -def identify_residues( - num_poles: int, - poles: np.ndarray, - num_samples: int, - num_polys: int, - eval_points: np.ndarray, - num_vectors: int, - weights: np.ndarray, - response_matrix: np.ndarray, - poly_coefficients: np.ndarray, - residue_matrix: np.ndarray, -) -> Tuple[np.ndarray, float]: - """ - Internal routine to compute residues and polynomial coefficients. - - Parameters - ---------- - num_poles : int - Number of poles. - poles : np.ndarray - Current poles (complex), shape (num_poles,). - num_samples : int - Number of frequency samples. - num_polys : int - Number of polynomial terms. - eval_points : np.ndarray - Real frequency values, shape (num_samples,). - num_vectors : int - Number of response vectors. - weights : np.ndarray - Weighting matrix, shape (num_vectors, num_samples). - response_matrix : np.ndarray - Complex frequency responses, shape (num_vectors, num_samples). - poly_coefficients : np.ndarray - Array to store output polynomial coefficients (in-place). - residue_matrix : np.ndarray - Array to store output residues (in-place). - - Returns - ------- - Tuple[np.ndarray, float] - - Fitted response matrix (np.ndarray) - - Root-mean-square fitting error (float) - """ - conj_index = label_conjugate_poles(poles) - dk_matrix = np.zeros((num_samples, num_poles + num_polys), dtype=np.complex128) - - compute_dk_matrix(dk_matrix, eval_points, poles, conj_index, num_poles, num_polys) - - real_residues = np.zeros((num_vectors, num_poles), dtype=np.float64) - - for vec_idx in range(num_vectors): - vec_idx, residues, poly_coeffs = solve_vector_block( - vec_idx, - dk_matrix, - weights, - response_matrix, - num_poles, - num_polys, - ) - real_residues[vec_idx] = residues - if poly_coeffs is not None: - poly_coefficients[vec_idx] = poly_coeffs - - # Mask for real poles - mask_real = conj_index == 0 - real_indices = np.where(mask_real)[0] - residue_matrix[:, real_indices] = real_residues[:, real_indices] - - # Mask for first of complex conjugate pairs - mask_cplx_start = conj_index == 1 - cplx_indices = np.where(mask_cplx_start)[0] - - # Compute complex residues using vectorized operations - residue_matrix[:, cplx_indices] = ( - real_residues[:, cplx_indices] + 1j * real_residues[:, cplx_indices + 1] - ) - residue_matrix[:, cplx_indices + 1] = ( - real_residues[:, cplx_indices] - 1j * real_residues[:, cplx_indices + 1] - ) - - fit_result = evaluate(eval_points, poles, residue_matrix, poly_coefficients) - rms_error = norm(fit_result - response_matrix) / np.sqrt(num_vectors * num_samples) - return fit_result, rms_error - - -def label_conjugate_poles(poles: np.ndarray) -> np.ndarray: - """ - Ensure complex poles appear in conjugate pairs and label them accordingly. - - Parameters - ---------- - poles : np.ndarray - 1D array of complex poles. - - Returns - ------- - np.ndarray - Array of integers indicating pole type: - - 0: real pole - - 1: first in a complex-conjugate pair - - 2: second in a complex-conjugate pair - - Raises - ------ - ValueError - If any complex pole does not have a valid conjugate pair. - """ - num_poles = len(poles) - conj_index = np.zeros(num_poles, dtype=int) - - # Identify complex poles (nonzero imaginary part) - is_complex = np.imag(poles) != 0.0 - - # Find conjugate pairs: poles[i+1] ≈ conj(poles[i]) - is_pair_start = is_complex[:-1] & np.isclose(np.conj(poles[:-1]), poles[1:]) - - # Mark valid conjugate pair entries - conj_index[:-1][is_pair_start] = 1 # mark i with 1 - conj_index[1:][is_pair_start] = 2 # mark i+1 with 2 - - # Now validate: all complex poles must be part of valid conjugate pairs - unmatched_complex = is_complex & (conj_index == 0) - if np.any(unmatched_complex): - raise ValueError("Complex poles must appear in conjugate pairs") - - return conj_index diff --git a/openmc/deplete/__init__.py b/openmc/deplete/__init__.py index 052e22459..8a9509e90 100644 --- a/openmc/deplete/__init__.py +++ b/openmc/deplete/__init__.py @@ -17,7 +17,6 @@ from .stepresult import * from .results import * from .integrators import * from .transfer_rates import * -from .r2s import * from . import abc from . import cram from . import helpers diff --git a/openmc/deplete/abc.py b/openmc/deplete/abc.py index 66bd7148d..7bf7f1086 100644 --- a/openmc/deplete/abc.py +++ b/openmc/deplete/abc.py @@ -1,7 +1,6 @@ """abc module. -This module contains Abstract Base Classes for implementing operator, -integrator, depletion system solver, and operator helper classes +This module contains Abstract Base Classes for implementing operator, integrator, depletion system solver, and operator helper classes """ from __future__ import annotations @@ -12,7 +11,6 @@ from copy import deepcopy from inspect import signature from numbers import Real, Integral from pathlib import Path -from textwrap import dedent import time from typing import Optional, Union, Sequence from warnings import warn @@ -25,13 +23,11 @@ from openmc.mpi import comm from openmc.utility_funcs import change_directory from openmc import Material from .stepresult import StepResult -from .chain import _get_chain -from .results import Results, _SECONDS_PER_MINUTE, _SECONDS_PER_HOUR, \ - _SECONDS_PER_DAY, _SECONDS_PER_JULIAN_YEAR +from .chain import Chain +from .results import Results from .pool import deplete from .reaction_rates import ReactionRates -from .transfer_rates import TransferRates, ExternalSourceRates -from .keff_search_control import _KeffSearchControl +from .transfer_rates import TransferRates __all__ = [ @@ -40,61 +36,10 @@ __all__ = [ "Integrator", "SIIntegrator", "DepSystemSolver", "add_params"] -def _normalize_timesteps( - timesteps: Sequence[float] | Sequence[tuple[float, str]], - source_rates: float | Sequence[float], - timestep_units: str = 's', - operator: TransportOperator | None = None, -): - if not isinstance(source_rates, Sequence): - # Ensure that rate is single value if that is the case - source_rates = [source_rates] * len(timesteps) - - if len(source_rates) != len(timesteps): - raise ValueError( - "Number of time steps ({}) != number of powers ({})".format( - len(timesteps), len(source_rates))) - - # Get list of times / units - if isinstance(timesteps[0], Sequence): - times, units = zip(*timesteps) - else: - times = timesteps - units = [timestep_units] * len(timesteps) - - # Determine number of seconds for each timestep - seconds = [] - for timestep, unit, rate in zip(times, units, source_rates): - # Make sure values passed make sense - check_type('timestep', timestep, Real) - check_greater_than('timestep', timestep, 0.0, False) - check_type('timestep units', unit, str) - check_type('source rate', rate, Real) - check_greater_than('source rate', rate, 0.0, True) - - if unit in ('s', 'sec'): - seconds.append(timestep) - elif unit in ('min', 'minute'): - seconds.append(timestep*_SECONDS_PER_MINUTE) - elif unit in ('h', 'hr', 'hour'): - seconds.append(timestep*_SECONDS_PER_HOUR) - elif unit in ('d', 'day'): - seconds.append(timestep*_SECONDS_PER_DAY) - elif unit in ('a', 'year'): - seconds.append(timestep*_SECONDS_PER_JULIAN_YEAR) - elif unit.lower() == 'mwd/kg': - watt_days_per_kg = 1e6*timestep - kilograms = 1e-3*operator.heavy_metal - if rate == 0.0: - raise ValueError("Cannot specify a timestep in [MWd/kg] when" - " the power is zero.") - days = watt_days_per_kg * kilograms / rate - seconds.append(days*_SECONDS_PER_DAY) - else: - raise ValueError(f"Invalid timestep unit '{unit}'") - - return (np.asarray(seconds), np.asarray(source_rates)) - +_SECONDS_PER_MINUTE = 60 +_SECONDS_PER_HOUR = 60*60 +_SECONDS_PER_DAY = 24*60*60 +_SECONDS_PER_JULIAN_YEAR = 365.25*24*60*60 OperatorResult = namedtuple('OperatorResult', ['k', 'rates']) OperatorResult.__doc__ = """\ @@ -128,8 +73,8 @@ class TransportOperator(ABC): Parameters ---------- - chain_file : PathLike or Chain - Path to the depletion chain XML file or instance of openmc.deplete.Chain. + chain_file : str + Path to the depletion chain XML file fission_q : dict, optional Dictionary of nuclides and their fission Q values [eV]. If not given, values will be pulled from the ``chain_file``. @@ -147,12 +92,11 @@ class TransportOperator(ABC): The depletion chain information necessary to form matrices and tallies. """ - def __init__(self, chain_file=None, fission_q=None, prev_results=None): + def __init__(self, chain_file, fission_q=None, prev_results=None): self.output_dir = '.' # Read depletion chain - self.chain = _get_chain(chain_file, fission_q) - + self.chain = Chain.from_xml(chain_file, fission_q) if prev_results is None: self.prev_res = None else: @@ -160,7 +104,7 @@ class TransportOperator(ABC): self.prev_res = prev_results @abstractmethod - def __call__(self, vec, source_rate) -> OperatorResult: + def __call__(self, vec, source_rate): """Runs a simulation. Parameters @@ -202,7 +146,7 @@ class TransportOperator(ABC): Returns ------- volume : dict of str to float - Volumes corresponding to materials in full_burn_list + Volumes corresponding to materials in burn_list nuc_list : list of str A list of all nuclide names. Used for sorting the simulation. burn_list : list of int @@ -210,8 +154,6 @@ class TransportOperator(ABC): simulation. full_burn_list : list of int All burnable materials in the geometry. - name_list : list of str - Material names corresponding to materials in full_burn_list """ def finalize(self): @@ -530,7 +472,7 @@ class Integrator(ABC): r"""Abstract class for solving the time-integration for depletion """ - _params = dedent(r""" + _params = r""" Parameters ---------- operator : openmc.deplete.abc.TransportOperator @@ -541,15 +483,17 @@ class Integrator(ABC): iterable of float. Alternatively, units can be specified for each step by passing an iterable of (value, unit) tuples. power : float or iterable of float, optional - Power of the reactor in [W]. A single value indicates that the power is - constant over all timesteps. An iterable indicates potentially different - power levels for each timestep. For a 2D problem, the power can be given - in [W/cm] as long as the "volume" assigned to a depletion material is - actually an area in [cm^2]. Either ``power``, ``power_density``, or + Power of the reactor in [W]. A single value indicates that + the power is constant over all timesteps. An iterable + indicates potentially different power levels for each timestep. + For a 2D problem, the power can be given in [W/cm] as long + as the "volume" assigned to a depletion material is actually + an area in [cm^2]. Either ``power``, ``power_density``, or ``source_rates`` must be specified. power_density : float or iterable of float, optional - Power density of the reactor in [W/gHM]. It is multiplied by initial - heavy metal inventory to get total power if ``power`` is not specified. + Power density of the reactor in [W/gHM]. It is multiplied by + initial heavy metal inventory to get total power if ``power`` + is not specified. source_rates : float or iterable of float, optional Source rate in [neutron/sec] or neutron flux in [neutron/s-cm^2] for each interval in :attr:`timesteps` @@ -561,8 +505,8 @@ class Integrator(ABC): and 'MWd/kg' indicates that the values are given in burnup (MW-d of energy deposited per kilogram of initial heavy metal). solver : str or callable, optional - If a string, must be the name of the solver responsible for solving the - Bateman equations. Current options are: + If a string, must be the name of the solver responsible for + solving the Bateman equations. Current options are: * ``cram16`` - 16th order IPF CRAM * ``cram48`` - 48th order IPF CRAM [default] @@ -571,25 +515,6 @@ class Integrator(ABC): :attr:`solver`. .. versionadded:: 0.12 - substeps : int, optional - Number of substeps per depletion interval. When greater than 1, each - interval is subdivided into `substeps` identical sub-intervals and LU - factorizations may be reused across them, improving accuracy for - nuclides with large decay-constant × timestep products. - - .. versionadded:: 0.15.4 - continue_timesteps : bool, optional - Whether or not to treat the current solve as a continuation of a - previous simulation. Defaults to `False`. When `False`, the depletion - steps provided are appended to any previous steps. If `True`, the - timesteps provided to the `Integrator` must exacly match any that exist - in the `prev_results` passed to the `Operator`. The `power`, - `power_density`, or `source_rates` must match as well. The method of - specifying `power`, `power_density`, or `source_rates` should be the - same as the initial run. - - .. versionadded:: 0.15.1 - Attributes ---------- operator : openmc.deplete.abc.TransportOperator @@ -606,46 +531,43 @@ class Integrator(ABC): :math:`\frac{\partial}{\partial t}\vec{n} = A_i\vec{n}_i` with a step size :math:`t_i`. Can be configured using the ``solver`` argument. User-supplied functions are expected to have the following signature: - ``solver(A, n0, t, substeps=1) -> n1``, where + ``solver(A, n0, t) -> n1`` where - * ``A`` is a :class:`scipy.sparse.csc_array` making up the depletion - matrix - * ``n0`` is a 1-D :class:`numpy.ndarray` of initial compositions for - a given material in atoms/cm3 - * ``t`` is a float of the time step size in seconds - * ``substeps`` is an optional integer number of substeps, and - * ``n1`` is a :class:`numpy.ndarray` of compositions at the next - time step. Expected to be of the same shape as ``n0`` - - Solvers that do not support multiple substeps should raise an exception - when ``substeps > 1``. + * ``A`` is a :class:`scipy.sparse.csc_matrix` making up the + depletion matrix + * ``n0`` is a 1-D :class:`numpy.ndarray` of initial compositions + for a given material in atoms/cm3 + * ``t`` is a float of the time step size in seconds, and + * ``n1`` is a :class:`numpy.ndarray` of compositions at the + next time step. Expected to be of the same shape as ``n0`` transfer_rates : openmc.deplete.TransferRates - Transfer rates for the depletion system used to model continuous - removal/feed between materials. + Instance of TransferRates class to perform continuous transfer during depletion .. versionadded:: 0.14.0 - external_source_rates : openmc.deplete.ExternalSourceRates - External source rates for the depletion system. - .. versionadded:: 0.15.3 - - """) + """ def __init__( self, operator: TransportOperator, - timesteps: Sequence[float] | Sequence[tuple[float, str]], + timesteps: Sequence[float], power: Optional[Union[float, Sequence[float]]] = None, power_density: Optional[Union[float, Sequence[float]]] = None, - source_rates: Optional[Union[float, Sequence[float]]] = None, + source_rates: Optional[Sequence[float]] = None, timestep_units: str = 's', - solver: str = "cram48", - substeps: int = 1, - continue_timesteps: bool = False, + solver: str = "cram48" ): - if continue_timesteps and operator.prev_res is None: - raise ValueError("Continuation run requires passing prev_results.") + # Check number of stages previously used + if operator.prev_res is not None: + res = operator.prev_res[-1] + if res.data.shape[0] != self._num_stages: + raise ValueError( + "{} incompatible with previous restart calculation. " + "Previous scheme used {} intermediate solutions, while " + "this uses {}".format( + self.__class__.__name__, res.data.shape[0], + self._num_stages)) self.operator = operator self.chain = operator.chain @@ -660,47 +582,57 @@ class Integrator(ABC): elif source_rates is None: raise ValueError("Either power, power_density, or source_rates must be set") - # Normalize timesteps and source rates - seconds, source_rates = _normalize_timesteps( - timesteps, source_rates, timestep_units, operator) - check_type("substeps", substeps, Integral) - check_greater_than("substeps", substeps, 0) + if not isinstance(source_rates, Iterable): + # Ensure that rate is single value if that is the case + source_rates = [source_rates] * len(timesteps) - if continue_timesteps: - # Get timesteps and source rates from previous results - prev_times = operator.prev_res.get_times(timestep_units) - prev_source_rates = operator.prev_res.get_source_rates() - prev_timesteps = np.diff(prev_times) + if len(source_rates) != len(timesteps): + raise ValueError( + "Number of time steps ({}) != number of powers ({})".format( + len(timesteps), len(source_rates))) - # Make sure parameters from the previous results are consistent with - # those passed to operator - num_prev = len(prev_timesteps) - if not np.array_equal(prev_timesteps, timesteps[:num_prev]): - raise ValueError( - "You are attempting to continue a run in which the previous timesteps " - "do not have the same initial timesteps as those provided to the " - "Integrator. Please make sure you are using the correct timesteps." - ) - if not np.array_equal(prev_source_rates, source_rates[:num_prev]): - raise ValueError( - "You are attempting to continue a run in which the previous results " - "do not have the same initial source rates, powers, or power densities " - "as those provided to the Integrator. Please make sure you are using " - "the correct powers, power densities, or source rates and previous " - "results file." - ) + # Get list of times / units + if isinstance(timesteps[0], Iterable): + times, units = zip(*timesteps) + else: + times = timesteps + units = [timestep_units] * len(timesteps) - # Run with only the new time steps and source rates provided - seconds = seconds[num_prev:] - source_rates = source_rates[num_prev:] + # Determine number of seconds for each timestep + seconds = [] + for timestep, unit, rate in zip(times, units, source_rates): + # Make sure values passed make sense + check_type('timestep', timestep, Real) + check_greater_than('timestep', timestep, 0.0, False) + check_type('timestep units', unit, str) + check_type('source rate', rate, Real) + check_greater_than('source rate', rate, 0.0, True) + + if unit in ('s', 'sec'): + seconds.append(timestep) + elif unit in ('min', 'minute'): + seconds.append(timestep*_SECONDS_PER_MINUTE) + elif unit in ('h', 'hr', 'hour'): + seconds.append(timestep*_SECONDS_PER_HOUR) + elif unit in ('d', 'day'): + seconds.append(timestep*_SECONDS_PER_DAY) + elif unit in ('a', 'year'): + seconds.append(timestep*_SECONDS_PER_JULIAN_YEAR) + elif unit.lower() == 'mwd/kg': + watt_days_per_kg = 1e6*timestep + kilograms = 1e-3*operator.heavy_metal + if rate == 0.0: + raise ValueError("Cannot specify a timestep in [MWd/kg] when" + " the power is zero.") + days = watt_days_per_kg * kilograms / rate + seconds.append(days*_SECONDS_PER_DAY) + else: + raise ValueError(f"Invalid timestep unit '{unit}'") self.timesteps = np.asarray(seconds) self.source_rates = np.asarray(source_rates) - self.substeps = substeps self.transfer_rates = None - self.external_source_rates = None - self._keff_search_control = None if isinstance(solver, str): # Delay importing of cram module, which requires this file @@ -734,37 +666,23 @@ class Integrator(ABC): self._solver = func return - params = list(sig.parameters.values()) - # Inspect arguments - if len(params) != 4: - raise ValueError( - "Function {} must support four arguments " - "(A, n0, t, substeps=1): {!s}" - .format(func, sig)) + if len(sig.parameters) != 3: + raise ValueError("Function {} does not support three arguments: " + "{!s}".format(func, sig)) - for ix, param in enumerate(params): - if param.kind in {param.KEYWORD_ONLY, param.VAR_KEYWORD, - param.VAR_POSITIONAL}: + for ix, param in enumerate(sig.parameters.values()): + if param.kind in {param.KEYWORD_ONLY, param.VAR_KEYWORD}: raise ValueError( f"Keyword arguments like {ix} at position {param} are not allowed") - if len(params) == 4 and params[3].default != 1: - raise ValueError( - f"Fourth solver argument must default to 1, not {params[3].default}") - self._solver = func - def _timed_deplete(self, n, rates, dt, i=None, matrix_func=None): + def _timed_deplete(self, n, rates, dt, matrix_func=None): start = time.time() results = deplete( - self._solver, self.chain, n, rates, dt, i, matrix_func, - self.transfer_rates, self.external_source_rates, self.substeps) - - # Clip unphysical negative number densities - for r in results: - r.clip(min=0.0, out=r) - + self._solver, self.chain, n, rates, dt, matrix_func, + self.transfer_rates) return time.time() - start, results @abstractmethod @@ -796,8 +714,12 @@ class Integrator(ABC): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of timestep + n_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult + Eigenvalue and reaction rates from intermediate transport + simulations """ @property @@ -828,83 +750,25 @@ class Integrator(ABC): """Get beginning of step concentrations, reaction rates from restart""" res = self.operator.prev_res[-1] # Depletion methods expect list of arrays - bos_conc = list(res.data) - rates = res.rates - k = ufloat(res.k[0], res.k[1]) + bos_conc = list(res.data[0]) + rates = res.rates[0] + k = ufloat(res.k[0, 0], res.k[0, 1]) - if res.source_rate != 0.0: - # Scale reaction rates by ratio of source rates - rates *= source_rate / res.source_rate + # Scale reaction rates by ratio of source rates + rates *= source_rate / res.source_rate return bos_conc, OperatorResult(k, rates) - def _get_start_data(self) -> tuple[float, int]: - """ - This function fetches the starting state of a depletion simulation in - terms of the simulation physical time at which to start and the index at - which the depletion simulation should start. When no previous results - exist, the time and index are both zero. When previous results do exist, - it returns the time corresponding to beginning the previous results last - timestep and the index as N-1 where N is the number of previous - StepResults found in the previous Results (as expected from 0-based - indexing). - - Note that the openmc.deplete.Results.time object is a list of float with - [t,t+dt] where t is the beginning of timestep time and t+dt is the end - of timestep time. If the previous results correspond to a simulation - that finished to completeion, it will contain a results in the form of - [t,t], but if a simulation doesn't finish all the given timesteps, it is - the t that is the desired start time, not t+dt. Thus, it is always safe - to take time[0]. - - Returns - ------- - start_time : float - Time at which depletion simulation should start in [s] - index : int - Index at which depletion simulation should start - """ + def _get_start_data(self): if self.operator.prev_res is None: return 0.0, 0 - return (self.operator.prev_res[-1].time[0], + return (self.operator.prev_res[-1].time[-1], len(self.operator.prev_res) - 1) - def _restore_keff_search_control(self, res: StepResult): - """Restore keff search control from restart results.""" - keff_search_root = res.keff_search_root - if keff_search_root is None: - raise ValueError( - "Cannot restore keff search control from restart " - "results because no stored keff_search_root is " - "available." - ) - self._keff_search_control.function(keff_search_root) - return keff_search_root - - def _get_bos_data(self, step_index, source_rate, bos_conc): - """Get beginning-of-step concentrations, rates, and control state.""" - if step_index > 0 or self.operator.prev_res is None: - if self._keff_search_control is not None and source_rate != 0.0: - keff_search_root = self._keff_search_control.run(bos_conc) - else: - keff_search_root = None - bos_conc, res = self._get_bos_data_from_operator( - step_index, source_rate, bos_conc) - else: - bos_conc, res = self._get_bos_data_from_restart( - source_rate, bos_conc) - if self._keff_search_control is not None and source_rate != 0.0: - keff_search_root = self._restore_keff_search_control(self.operator.prev_res[-1]) - else: - keff_search_root = None - - return bos_conc, res, keff_search_root - def integrate( self, final_step: bool = True, output: bool = True, - path: PathLike = 'depletion_results.h5', - write_rates: bool = False + path: PathLike = 'depletion_results.h5' ): """Perform the entire depletion process across all steps @@ -923,11 +787,6 @@ class Integrator(ABC): Path to file to write. Defaults to 'depletion_results.h5'. .. versionadded:: 0.15.0 - write_rates : bool, optional - Whether reaction rates should be written to the results file for - each step. Defaults to ``False`` to reduce file size. - - .. versionadded:: 0.15.3 """ with change_directory(self.operator.output_dir): n = self.operator.initial_condition() @@ -937,27 +796,25 @@ class Integrator(ABC): if output and comm.rank == 0: print(f"[openmc.deplete] t={t} s, dt={dt} s, source={source_rate}") - # Get beginning-of-step data from operator or restart results - n, res, keff_search_root = self._get_bos_data(i, source_rate, n) + # Solve transport equation (or obtain result from restart) + if i > 0 or self.operator.prev_res is None: + n, res = self._get_bos_data_from_operator(i, source_rate, n) + else: + n, res = self._get_bos_data_from_restart(source_rate, n) # Solve Bateman equations over time interval - proc_time, n_end = self(n, res.rates, dt, source_rate, i) + proc_time, n_list, res_list = self(n, res.rates, dt, source_rate, i) - StepResult.save( - self.operator, - n, - res, - [t, t + dt], - source_rate, - self._i_res + i, - proc_time, - write_rates=write_rates, - keff_search_root=keff_search_root, - path=path - ) + # Insert BOS concentration, transport results + n_list.insert(0, n) + res_list.insert(0, res) + + # Remove actual EOS concentration for next step + n = n_list.pop() + + StepResult.save(self.operator, n_list, res_list, [t, t + dt], + source_rate, self._i_res + i, proc_time, path) - # Update for next step - n = n_end t += dt # Final simulation -- in the case that final_step is False, a zero @@ -966,36 +823,21 @@ class Integrator(ABC): # solve) if output and final_step and comm.rank == 0: print(f"[openmc.deplete] t={t} (final operator evaluation)") - if self._keff_search_control is not None and source_rate != 0.0: - keff_search_root = self._keff_search_control.run(n) - else: - keff_search_root = None - res_final = self.operator(n, source_rate if final_step else 0.0) - StepResult.save( - self.operator, - n, - res_final, - [t, t], - source_rate, - self._i_res + len(self), - proc_time, - write_rates=write_rates, - keff_search_root=keff_search_root, - path=path - ) + res_list = [self.operator(n, source_rate if final_step else 0.0)] + StepResult.save(self.operator, [n], res_list, [t, t], + source_rate, self._i_res + len(self), proc_time, path) self.operator.write_bos_data(len(self) + self._i_res) self.operator.finalize() def add_transfer_rate( - self, - material: str | int | Material, - components: Sequence[str], - transfer_rate: float, - transfer_rate_units: str = '1/s', - timesteps: Sequence[int] | None = None, - destination_material: str | int | Material | None = None - ): + self, + material: Union[str, int, Material], + components: Sequence[str], + transfer_rate: float, + transfer_rate_units: str = '1/s', + destination_material: Optional[Union[str, int, Material]] = None + ): """Add transfer rates to depletable material. Parameters @@ -1009,204 +851,18 @@ class Integrator(ABC): transfer_rate : float Rate at which elements are transferred. A positive or negative values set removal of feed rates, respectively. + destination_material : openmc.Material or str or int, Optional + Destination material to where nuclides get fed. transfer_rate_units : {'1/s', '1/min', '1/h', '1/d', '1/a'} Units for values specified in the transfer_rate argument. 's' means seconds, 'min' means minutes, 'h' means hours, 'a' means Julian years. - timesteps : list of int, optional - List of timestep indices where to set external source rates. - Defaults to None, which means the external source rate is set for - all timesteps. - destination_material : openmc.Material or str or int, Optional - Destination material to where nuclides get fed. """ if self.transfer_rates is None: - if hasattr(self.operator, 'model'): - materials = self.operator.model.materials - elif hasattr(self.operator, 'materials'): - materials = self.operator.materials - self.transfer_rates = TransferRates( - self.operator, materials, len(self.timesteps)) + self.transfer_rates = TransferRates(self.operator, self.operator.model) - if self.external_source_rates is not None and destination_material: - raise ValueError('Currently is not possible to set a transfer rate ' - 'with destination matrial in combination with ' - 'external source rates.') - - self.transfer_rates.set_transfer_rate( - material, components, transfer_rate, transfer_rate_units, - timesteps, destination_material) - - def add_external_source_rate( - self, - material: str | int | Material, - composition: dict[str, float], - rate: float, - rate_units: str = 'g/s', - timesteps: Sequence[int] | None = None - ): - """Add external source rates to depletable material. - - Parameters - ---------- - material : openmc.Material or str or int - Depletable material - composition : dict of str to float - External source rate composition vector, where key can be an element - or a nuclide and value the corresponding weight percent. - rate : float - External source rate in units of mass per time. A positive or - negative value corresponds to a feed or removal rate, respectively. - units : {'g/s', 'g/min', 'g/h', 'g/d', 'g/a'} - Units for values specified in the `rate` argument. 's' for seconds, - 'min' for minutes, 'h' for hours, 'a' for Julian years. - timesteps : list of int, optional - List of timestep indices where to set external source rates. - Defaults to None, which means the external source rate is set for - all timesteps. - - """ - if self.external_source_rates is None: - if hasattr(self.operator, 'model'): - materials = self.operator.model.materials - elif hasattr(self.operator, 'materials'): - materials = self.operator.materials - self.external_source_rates = ExternalSourceRates( - self.operator, materials, len(self.timesteps)) - - if self.transfer_rates is not None and self.transfer_rates.index_transfer: - raise ValueError('Currently is not possible to set an external ' - 'source rate in combination with transfer rates ' - 'with destination matrial.') - - self.external_source_rates.set_external_source_rate( - material, composition, rate, rate_units, timesteps) - - - def add_redox(self, material, buffer, oxidation_states, timesteps=None): - """Add redox control to depletable material. - - Parameters - ---------- - material : openmc.Material or str or int - Depletable material - buffer : dict - Dictionary of buffer nuclides used to maintain redox balance. Keys - are nuclide names (strings) and values are their respective - fractions (float) that collectively sum to 1. - oxidation_states : dict - User-defined oxidation states for elements. Keys are element symbols - (e.g., 'H', 'He'), and values are their corresponding oxidation - states as integers (e.g., +1, 0). - timesteps : list of int, optional - List of timestep indices where to set external source rates. - Defaults to None, which means the external source rate is set for - all timesteps. - """ - if self.transfer_rates is None: - if hasattr(self.operator, 'model'): - materials = self.operator.model.materials - elif hasattr(self.operator, 'materials'): - materials = self.operator.materials - self.transfer_rates = TransferRates( - self.operator, materials, len(self.timesteps)) - - self.transfer_rates.set_redox(material, buffer, oxidation_states, timesteps) - - def add_keff_search_control( - self, - function: Callable, - x0: float, - x1: float, - bracket: Sequence[float], - **search_kwargs - ): - """Add keff search to the integrator scheme. - - This method causes OpenMC to perform a keff search during depletion to - maintain a target keff by adjusting a model parameter through the - provided function. - - .. important:: - The function **must** modify the model through ``openmc.lib`` (e.g., - ``openmc.lib.cells``, ``openmc.lib.materials``) and **NOT** through - ``openmc.Model``. The function is called within a - :class:`openmc.lib.TemporarySession` context where only the C API - (``openmc.lib``) is available for modifications. - - Parameters - ---------- - function : Callable - Function that takes a single float argument and modifies the model - through :mod:`openmc.lib`. - x0 : float - Initial lower bound for the keff search. - x1 : float - Initial upper bound for the keff search. - bracket : sequence of float - Bracket interval [x_min, x_max] that constrains the allowed parameter - values during the keff search. This is a required parameter - that defines the absolute bounds for the search. The bracket must contain - exactly 2 elements with bracket[0] < bracket[1]. These values are passed - directly to the ``x_min`` and ``x_max`` optional arguments in - :meth:`openmc.Model.keff_search`, which enforce hard limits on the - parameter range. If the keff search converges to a value outside this - bracket, it will be clamped to the nearest bracket bound with a warning. - **search_kwargs - Additional keyword arguments passed to - :meth:`openmc.Model.keff_search`. Common options include: - - * ``target`` : float, optional - Target keff value to search for. Defaults to 1.0. - * ``k_tol`` : float, optional - Stopping criterion on the function value. Defaults to 1e-4. - * ``sigma_final`` : float, optional - Maximum accepted k-effective uncertainty. Defaults to 3e-4. - * ``maxiter`` : int, optional - Maximum number of iterations. Defaults to 50. - - See :meth:`openmc.Model.keff_search` for a complete list of - available options. - - Examples - -------- - Add keff search that adjusts a control rod position: - - >>> def adjust_rod_position(position): - ... openmc.lib.cells[rod_cell.id].translation = [0, 0, position] - >>> integrator.add_keff_search_control( - ... adjust_rod_position, - ... x0=0.0, - ... x1=5.0, - ... bracket=[-10,10], - ... target=1.0, - ... k_tol=1e-4 - ... ) - - Add keff search that adjusts the U235 density: - - >>> def set_u235_density(u235_density): - ... # Get the material from openmc.lib - ... lib_mat = openmc.lib.materials[material_id] - ... # Get current nuclides and densities - ... nuclides = lib_mat.nuclides - ... densities = lib_mat.densities - ... u235_idx = nuclides.index('U235') - ... densities[u235_idx] = u235_density - ... lib_mat.set_densities(nuclides, densities) - >>> integrator.add_keff_search_control( - ... set_u235_density, - ... x0=5.0e-4, - ... x1=1.0e-3, - ... bracket=[1.0e-4, 2.0e-3], - ... target=1.0 - ... ) - - .. versionadded:: 0.15.4 - - """ - self._keff_search_control = _KeffSearchControl( - self.operator, function, x0, x1, bracket, **search_kwargs) + self.transfer_rates.set_transfer_rate(material, components, transfer_rate, + transfer_rate_units, destination_material) @add_params class SIIntegrator(Integrator): @@ -1216,7 +872,7 @@ class SIIntegrator(Integrator): the number of particles used in initial transport calculation """ - _params = dedent(r""" + _params = r""" Parameters ---------- operator : openmc.deplete.abc.TransportOperator @@ -1227,15 +883,17 @@ class SIIntegrator(Integrator): iterable of float. Alternatively, units can be specified for each step by passing an iterable of (value, unit) tuples. power : float or iterable of float, optional - Power of the reactor in [W]. A single value indicates that the power is - constant over all timesteps. An iterable indicates potentially different - power levels for each timestep. For a 2D problem, the power can be given - in [W/cm] as long as the "volume" assigned to a depletion material is - actually an area in [cm^2]. Either ``power``, ``power_density``, or + Power of the reactor in [W]. A single value indicates that + the power is constant over all timesteps. An iterable + indicates potentially different power levels for each timestep. + For a 2D problem, the power can be given in [W/cm] as long + as the "volume" assigned to a depletion material is actually + an area in [cm^2]. Either ``power``, ``power_density``, or ``source_rates`` must be specified. power_density : float or iterable of float, optional - Power density of the reactor in [W/gHM]. It is multiplied by initial - heavy metal inventory to get total power if ``power`` is not specified. + Power density of the reactor in [W/gHM]. It is multiplied by + initial heavy metal inventory to get total power if ``power`` + is not specified. source_rates : float or iterable of float, optional Source rate in [neutron/sec] or neutron flux in [neutron/s-cm^2] for each interval in :attr:`timesteps` @@ -1247,11 +905,11 @@ class SIIntegrator(Integrator): that the values are given in burnup (MW-d of energy deposited per kilogram of initial heavy metal). n_steps : int, optional - Number of stochastic iterations per depletion interval. Must be greater - than zero. Default : 10 + Number of stochastic iterations per depletion interval. + Must be greater than zero. Default : 10 solver : str or callable, optional - If a string, must be the name of the solver responsible for solving the - Bateman equations. Current options are: + If a string, must be the name of the solver responsible for + solving the Bateman equations. Current options are: * ``cram16`` - 16th order IPF CRAM * ``cram48`` - 48th order IPF CRAM [default] @@ -1260,25 +918,6 @@ class SIIntegrator(Integrator): :attr:`solver`. .. versionadded:: 0.12 - substeps : int, optional - Number of substeps per depletion interval. When greater than 1, each - interval is subdivided into `substeps` identical sub-intervals and LU - factorizations may be reused across them, improving accuracy for - nuclides with large decay-constant × timestep products. - - .. versionadded:: 0.15.4 - continue_timesteps : bool, optional - Whether or not to treat the current solve as a continuation of a - previous simulation. Defaults to `False`. If `False`, all time steps and - source rates will be run in an append fashion and will run after - whatever time steps exist, if any. If `True`, the timesteps provided to - the `Integrator` must match exactly those that exist in the - `prev_results` passed to the `Opereator`. The `power`, `power_density`, - or `source_rates` must match as well. The method of specifying `power`, - `power_density`, or `source_rates` should be the same as the initial - run. - - .. versionadded:: 0.15.1 Attributes ---------- @@ -1297,23 +936,19 @@ class SIIntegrator(Integrator): :math:`\frac{\partial}{\partial t}\vec{n} = A_i\vec{n}_i` with a step size :math:`t_i`. Can be configured using the ``solver`` argument. User-supplied functions are expected to have the following signature: - ``solver(A, n0, t, substeps=1) -> n1``, where + ``solver(A, n0, t) -> n1`` where - * ``A`` is a :class:`scipy.sparse.csc_array` making up the depletion - matrix - * ``n0`` is a 1-D :class:`numpy.ndarray` of initial compositions for - a given material in atoms/cm3 - * ``t`` is a float of the time step size in seconds - * ``substeps`` is an optional integer number of substeps, and - * ``n1`` is a :class:`numpy.ndarray` of compositions at the next - time step. Expected to be of the same shape as ``n0`` - - Solvers that do not support multiple substeps should raise an exception - when ``substeps > 1``. + * ``A`` is a :class:`scipy.sparse.csc_matrix` making up the + depletion matrix + * ``n0`` is a 1-D :class:`numpy.ndarray` of initial compositions + for a given material in atoms/cm3 + * ``t`` is a float of the time step size in seconds, and + * ``n1`` is a :class:`numpy.ndarray` of compositions at the + next time step. Expected to be of the same shape as ``n0`` .. versionadded:: 0.12 - """) + """ def __init__( self, @@ -1324,17 +959,13 @@ class SIIntegrator(Integrator): source_rates: Optional[Sequence[float]] = None, timestep_units: str = 's', n_steps: int = 10, - solver: str = "cram48", - substeps: int = 1, - continue_timesteps: bool = False, + solver: str = "cram48" ): check_type("n_steps", n_steps, Integral) check_greater_than("n_steps", n_steps, 0) super().__init__( operator, timesteps, power, power_density, source_rates, - timestep_units=timestep_units, solver=solver, - substeps=substeps, - continue_timesteps=continue_timesteps) + timestep_units=timestep_units, solver=solver) self.n_steps = n_steps def _get_bos_data_from_operator(self, step_index, step_power, n_bos): @@ -1348,41 +979,11 @@ class SIIntegrator(Integrator): self.operator.settings.particles //= self.n_steps return inherited - @abstractmethod - def __call__(self, n, rates, dt, source_rate, i): - """Perform the integration across one time step - - Parameters - ---------- - n : list of numpy.ndarray - List of atom number arrays for each material. Each array has - shape ``(n_nucs,)`` where ``n_nucs`` is the number of nuclides - rates : openmc.deplete.ReactionRates - Reaction rates (from transport operator) - dt : float - Time step in [s] - source_rate : float - Power in [W] or source rate in [neutron/sec] - i : int - Current time step index - - Returns - ------- - proc_time : float - Time spent in transport simulation - n_end : list of numpy.ndarray - Updated atom number densities for each material - op_result : OperatorResult - Eigenvalue and reaction rates resulting from transport simulation - - """ - def integrate( - self, - output: bool = True, - path: PathLike = "depletion_results.h5", - write_rates: bool = False - ): + self, + output: bool = True, + path: PathLike = "depletion_results.h5" + ): """Perform the entire depletion process across all steps Parameters @@ -1393,17 +994,11 @@ class SIIntegrator(Integrator): Path to file to write. Defaults to 'depletion_results.h5'. .. versionadded:: 0.15.0 - write_rates : bool, optional - Whether reaction rates should be written to the results file for - each step. Defaults to ``False`` to reduce file size. - - .. versionadded:: 0.15.3 """ with change_directory(self.operator.output_dir): n = self.operator.initial_condition() t, self._i_res = self._get_start_data() - res_end = None # Will be set in first iteration for i, (dt, p) in enumerate(self): if output: print(f"[openmc.deplete] t={t} s, dt={dt} s, source={p}") @@ -1413,38 +1008,28 @@ class SIIntegrator(Integrator): n, res = self._get_bos_data_from_operator(i, p, n) else: n, res = self._get_bos_data_from_restart(p, n) + else: + # Pull rates, k from previous iteration w/o + # re-running transport + res = res_list[-1] # defined in previous i iteration - proc_time, n_end, res_end = self(n, res.rates, dt, p, i) + proc_time, n_list, res_list = self(n, res.rates, dt, p, i) - StepResult.save( - self.operator, - n, - res, - [t, t + dt], - p, - self._i_res + i, - proc_time, - write_rates=write_rates, - path=path - ) + # Insert BOS concentration, transport results + n_list.insert(0, n) + res_list.insert(0, res) + + # Remove actual EOS concentration for next step + n = n_list.pop() + + StepResult.save(self.operator, n_list, res_list, [t, t + dt], + p, self._i_res + i, proc_time, path) - # Update for next step - n = n_end - res = res_end t += dt # No final simulation for SIE, use last iteration results - StepResult.save( - self.operator, - n, - res_end, - [t, t], - p, - self._i_res + len(self), - proc_time, - write_rates=write_rates, - path=path - ) + StepResult.save(self.operator, [n], [res_list[-1]], [t, t], + p, self._i_res + len(self), proc_time, path) self.operator.write_bos_data(self._i_res + len(self)) self.operator.finalize() @@ -1464,12 +1049,12 @@ class DepSystemSolver(ABC): """ @abstractmethod - def __call__(self, A, n0, dt, substeps=1): + def __call__(self, A, n0, dt): """Solve the linear system of equations for depletion Parameters ---------- - A : scipy.sparse.csc_array + A : scipy.sparse.csc_matrix Sparse transmutation matrix ``A[j, i]`` describing rates at which isotope ``i`` transmutes to isotope ``j`` n0 : numpy.ndarray @@ -1477,8 +1062,6 @@ class DepSystemSolver(ABC): material or an atom density dt : float Time [s] of the specific interval to be solved - substeps : int, optional - Number of substeps to use when the solver supports substepping. Returns ------- diff --git a/openmc/deplete/chain.py b/openmc/deplete/chain.py index a2ff6dea0..1d3834980 100644 --- a/openmc/deplete/chain.py +++ b/openmc/deplete/chain.py @@ -7,23 +7,18 @@ loaded from an .xml file and all the nuclides are linked together. from io import StringIO from itertools import chain import math -import numpy as np import re from collections import defaultdict, namedtuple from collections.abc import Mapping, Iterable from numbers import Real, Integral -from pathlib import Path from warnings import warn -from typing import List import lxml.etree as ET +import scipy.sparse as sp -from openmc.checkvalue import check_type, check_length, check_greater_than, PathLike +from openmc.checkvalue import check_type, check_greater_than from openmc.data import gnds_name, zam -from openmc.exceptions import DataError from .nuclide import FissionYieldDistribution, Nuclide -from .._xml import get_text -from .._sparse_compat import csc_array, dok_array import openmc.data @@ -249,10 +244,6 @@ class Chain: Reactions that are tracked in the depletion chain nuclide_dict : dict of str to int Maps a nuclide name to an index in nuclides. - stable_nuclides : list of openmc.deplete.Nuclide - List of stable nuclides available in the chain. - unstable_nuclides : list of openmc.deplete.Nuclide - List of unstable nuclides available in the chain. fission_yields : None or iterable of dict List of effective fission yields for materials. Each dictionary should be of the form ``{parent: {product: yield}}`` with @@ -265,11 +256,10 @@ class Chain: """ def __init__(self): - self.nuclides: List[Nuclide] = [] + self.nuclides = [] self.reactions = [] self.nuclide_dict = {} self._fission_yields = None - self._decay_matrix = None def __contains__(self, nuclide): return nuclide in self.nuclide_dict @@ -282,17 +272,7 @@ class Chain: """Number of nuclides in chain.""" return len(self.nuclides) - @property - def stable_nuclides(self) -> List[Nuclide]: - """List of stable nuclides available in the chain""" - return [nuc for nuc in self.nuclides if nuc.half_life is None] - - @property - def unstable_nuclides(self) -> List[Nuclide]: - """List of unstable nuclides available in the chain""" - return [nuc for nuc in self.nuclides if nuc.half_life is not None] - - def add_nuclide(self, nuclide: Nuclide): + def add_nuclide(self, nuclide): """Add a nuclide to the depletion chain Parameters @@ -301,7 +281,6 @@ class Chain: Nuclide to add """ - _invalidate_chain_cache(self) self.nuclide_dict[nuclide.name] = len(self.nuclides) self.nuclides.append(nuclide) @@ -319,16 +298,16 @@ class Chain: String arguments in ``decay_files``, ``fpy_files``, and ``neutron_files`` will be treated as file names to be read. - Alternatively, :class:`openmc.data.endf.Evaluation` or - ``endf.Material`` instances can be included in these arguments. + Alternatively, :class:`openmc.data.endf.Evaluation` instances + can be included in these arguments. Parameters ---------- - decay_files : list of str, openmc.data.endf.Evaluation, or endf.Material + decay_files : list of str or openmc.data.endf.Evaluation List of ENDF decay sub-library files - fpy_files : list of str, openmc.data.endf.Evaluation, or endf.Material + fpy_files : list of str or openmc.data.endf.Evaluation List of ENDF neutron-induced fission product yield sub-library files - neutron_files : list of str, openmc.data.endf.Evaluation, or endf.Material + neutron_files : list of str or openmc.data.endf.Evaluation List of ENDF neutron reaction sub-library files reactions : iterable of str, optional Transmutation reactions to include in the depletion chain, e.g., @@ -363,7 +342,7 @@ class Chain: print('Processing neutron sub-library files...') reactions = {} for f in neutron_files: - evaluation = openmc.data.endf.as_evaluation(f) + evaluation = openmc.data.endf.Evaluation(f) name = evaluation.gnds_name reactions[name] = {} for mf, mt, nc, mod in evaluation.reaction_list: @@ -407,33 +386,24 @@ class Chain: if not data.nuclide['stable'] and data.half_life.nominal_value != 0.0: nuclide.half_life = data.half_life.nominal_value nuclide.decay_energy = data.decay_energy.nominal_value - branch_ratios = [] - branch_ids = [] - for mode in data.modes: + sum_br = 0.0 + for i, mode in enumerate(data.modes): type_ = ','.join(mode.modes) if mode.daughter in decay_data: target = mode.daughter - elif 'sf' in type_: - target = None else: print('missing {} {} {}'.format( - parent, type_, mode.daughter)) + parent, ','.join(mode.modes), mode.daughter)) target = replace_missing(mode.daughter, decay_data) + + # Write branching ratio, taking care to ensure sum is unity br = mode.branching_ratio.nominal_value - branch_ratios.append(br) - branch_ids.append((type_, target)) + sum_br += br + if i == len(data.modes) - 1 and sum_br != 1.0: + br = 1.0 - sum(m.branching_ratio.nominal_value + for m in data.modes[:-1]) - if not math.isclose(sum(branch_ratios), 1.0): - max_br = max(branch_ratios) - max_index = branch_ratios.index(max_br) - - # Adjust maximum branching ratio so they sum to unity - new_br = max_br - sum(branch_ratios) + 1.0 - branch_ratios[max_index] = new_br - assert math.isclose(sum(branch_ratios), 1.0) - - # Append decay modes - for br, (type_, target) in zip(branch_ratios, branch_ids): + # Append decay mode nuclide.add_decay_mode(type_, target, br) nuclide.sources = data.sources @@ -469,6 +439,7 @@ class Chain: nuclide.add_reaction('fission', None, q_value, 1.0) fissionable = True + if fissionable: if parent in fpy_data: fpy = fpy_data[parent] @@ -558,14 +529,11 @@ class Chain: root = ET.parse(str(filename)) for i, nuclide_elem in enumerate(root.findall('nuclide')): - this_q = fission_q.get(get_text(nuclide_elem, "name")) + this_q = fission_q.get(nuclide_elem.get("name")) nuc = Nuclide.from_xml(nuclide_elem, root, this_q) chain.add_nuclide(nuc) - # Store path of XML file (used for handling cache invalidation) - chain._xml_path = str(Path(filename).resolve()) - return chain def export_to_xml(self, filename): @@ -607,152 +575,8 @@ class Chain: out[nuc.name] = dict(yield_obj) return out - @property - def decay_matrix(self): - """Sparse CSC decay transmutation matrix. - - Contains only terms from radioactive decay: diagonal loss terms - and off-diagonal gain terms (branching ratios, alpha/proton - production). Independent of reaction rates, so computed once and - cached. - - See Also - -------- - :meth:`form_rxn_matrix`, :meth:`form_matrix` - """ - if self._decay_matrix is None: - n = len(self) - rows, cols, vals = [], [], [] - - def setval(i, j, val): - rows.append(i) - cols.append(j) - vals.append(val) - - for i, nuc in enumerate(self.nuclides): - # Loss from radioactive decay - if nuc.half_life is not None: - decay_constant = math.log(2) / nuc.half_life - if decay_constant != 0.0: - setval(i, i, -decay_constant) - - # Gain from radioactive decay - if nuc.n_decay_modes != 0: - for decay_type, target, branching_ratio in nuc.decay_modes: - branch_val = branching_ratio * decay_constant - - # Allow for total annihilation for debug purposes - if branch_val != 0.0: - if target is not None and 'sf' not in decay_type: - k = self.nuclide_dict[target] - setval(k, i, branch_val) - - # Produce alphas and protons from decay - if 'alpha' in decay_type: - k = self.nuclide_dict.get('He4') - if k is not None: - count = decay_type.count('alpha') - setval(k, i, count * branch_val) - elif 'p' in decay_type: - k = self.nuclide_dict.get('H1') - if k is not None: - count = decay_type.count('p') - setval(k, i, count * branch_val) - - self._decay_matrix = csc_array((vals, (rows, cols)), shape=(n, n)) - return self._decay_matrix - - def form_rxn_matrix(self, rates, fission_yields=None): - """Form the reaction-rate portion of the transmutation matrix. - - Builds only the terms that depend on reaction rates: transmutation - reactions and fission product yields. Does not include radioactive - decay terms (see :attr:`decay_matrix`). - - Parameters - ---------- - rates : numpy.ndarray - 2D array indexed by (nuclide, reaction) - fission_yields : dict, optional - Option to use a custom set of fission yields. Expected - to be of the form ``{parent : {product : f_yield}}`` - with string nuclide names for ``parent`` and ``product``, - and ``f_yield`` as the respective fission yield - - Returns - ------- - scipy.sparse.csc_array - Sparse matrix representing reaction-rate terms. - - See Also - -------- - :attr:`decay_matrix`, :meth:`form_matrix` - """ - reactions = set() - n = len(self) - - # Accumulate indices/values and then create the matrix at the end to - # avoid expensive index checks scipy otherwise does. - rows, cols, vals = [], [], [] - - def setval(i, j, val): - rows.append(i) - cols.append(j) - vals.append(val) - - if fission_yields is None: - fission_yields = self.get_default_fission_yields() - - # Save local variables to avoid attribute lookups in loop - index_nuc = rates.index_nuc - index_rx = rates.index_rx - - for i, nuc in enumerate(self.nuclides): - if nuc.name not in index_nuc: - continue - - nuc_ind = index_nuc[nuc.name] - nuc_rates = rates[nuc_ind, :] - - for r_type, target, _, br in nuc.reactions: - r_id = index_rx[r_type] - path_rate = nuc_rates[r_id] - - # Loss term -- make sure we only count loss once for - # reactions with branching ratios - if r_type not in reactions: - reactions.add(r_type) - if path_rate != 0.0: - setval(i, i, -path_rate) - - # Gain term; allow for total annihilation for debug purposes - if r_type != 'fission': - if target is not None and path_rate != 0.0: - k = self.nuclide_dict[target] - setval(k, i, path_rate * br) - - # Determine light nuclide production, e.g., (n,d) should - # produce H2 - if path_rate != 0.0: - light_nucs = REACTIONS[r_type].secondaries - for light_nuc in light_nucs: - k = self.nuclide_dict.get(light_nuc) - if k is not None: - setval(k, i, path_rate * br) - - else: - for product, y in fission_yields[nuc.name].items(): - yield_val = y * path_rate - if yield_val != 0.0: - k = self.nuclide_dict[product] - setval(k, i, yield_val) - - reactions.clear() - - return csc_array((vals, (rows, cols)), shape=(n, n)) - def form_matrix(self, rates, fission_yields=None): - """Form the full transmutation matrix (decay + reactions). + """Forms depletion matrix. Parameters ---------- @@ -766,73 +590,97 @@ class Chain: Returns ------- - scipy.sparse.csc_array + scipy.sparse.csc_matrix Sparse matrix representing depletion. See Also -------- - :attr:`decay_matrix`, :meth:`form_rxn_matrix`, :meth:`get_default_fission_yields` """ - return self.decay_matrix + self.form_rxn_matrix(rates, fission_yields) + reactions = set() - def add_redox_term(self, matrix, buffer, oxidation_states): - r"""Adds a redox term to the depletion matrix from data contained in - the matrix itself and a few user-inputs. + # Use DOK matrix as intermediate representation for matrix + n = len(self) + matrix = sp.dok_matrix((n, n)) - The redox term to add to the buffer nuclide :math:`N_j` can be written - as: + if fission_yields is None: + fission_yields = self.get_default_fission_yields() - .. math:: - \frac{dN_j(t)}{dt} = \cdots - \frac{1}{OS_j}\sum_i N_i a_{ij} - \cdot OS_i + for i, nuc in enumerate(self.nuclides): + # Loss from radioactive decay + if nuc.half_life is not None: + decay_constant = math.log(2) / nuc.half_life + if decay_constant != 0.0: + matrix[i, i] -= decay_constant - where :math:`OS` is the oxidation states vector and :math:`a_{ij}` the - corresponding term in the Bateman matrix. + # Gain from radioactive decay + if nuc.n_decay_modes != 0: + for decay_type, target, branching_ratio in nuc.decay_modes: + branch_val = branching_ratio * decay_constant - Parameters - ---------- - matrix : scipy.sparse.csc_array - Sparse matrix representing depletion - buffer : dict - Dictionary of buffer nuclides used to maintain anoins net balance. - Keys are nuclide names (strings) and values are their respective - fractions (float) that collectively sum to 1. - oxidation_states : dict - User-defined oxidation states for elements. Keys are element symbols - (e.g., 'H', 'He'), and values are their corresponding oxidation - states as integers (e.g., +1, 0). - Returns - ------- - matrix : scipy.sparse.csc_array - Sparse matrix with redox term added - """ - # Elements list with the same size as self.nuclides - elements = [re.split(r'\d+', nuc.name)[0] for nuc in self.nuclides] + # Allow for total annihilation for debug purposes + if branch_val != 0.0: + if target is not None: + k = self.nuclide_dict[target] + matrix[k, i] += branch_val - # Match oxidation states with all elements and add 0 if not data - os = np.array([oxidation_states[elm] if elm in oxidation_states else 0 - for elm in elements]) + # Produce alphas and protons from decay + if 'alpha' in decay_type: + k = self.nuclide_dict.get('He4') + if k is not None: + count = decay_type.count('alpha') + matrix[k, i] += count * branch_val + elif 'p' in decay_type: + k = self.nuclide_dict.get('H1') + if k is not None: + count = decay_type.count('p') + matrix[k, i] += count * branch_val - # Buffer idx with nuclide index as value - buffer_idx = {nuc: self.nuclide_dict[nuc] for nuc in buffer} - array = matrix.toarray() - redox_change = np.array([]) + if nuc.name in rates.index_nuc: + # Extract all reactions for this nuclide in this cell + nuc_ind = rates.index_nuc[nuc.name] + nuc_rates = rates[nuc_ind, :] - # calculate the redox array - for i in range(len(self)): - # Net redox impact of reaction: multiply the i-th column of the - # depletion matrix by the oxidation states - redox_change = np.append(redox_change, sum(array[:, i]*os)) + for r_type, target, _, br in nuc.reactions: + # Extract reaction index, and then final reaction rate + r_id = rates.index_rx[r_type] + path_rate = nuc_rates[r_id] - # Subtract redox vector to the buffer nuclides in the matrix scaling by - # their respective oxidation states - for nuc, idx in buffer_idx.items(): - array[idx] -= redox_change * buffer[nuc] / os[idx] + # Loss term -- make sure we only count loss once for + # reactions with branching ratios + if r_type not in reactions: + reactions.add(r_type) + if path_rate != 0.0: + matrix[i, i] -= path_rate - return csc_array(array) + # Gain term; allow for total annihilation for debug purposes + if r_type != 'fission': + if target is not None and path_rate != 0.0: + k = self.nuclide_dict[target] + matrix[k, i] += path_rate * br - def form_rr_term(self, tr_rates, current_timestep, mats): + # Determine light nuclide production, e.g., (n,d) should + # produce H2 + light_nucs = REACTIONS[r_type].secondaries + for light_nuc in light_nucs: + k = self.nuclide_dict.get(light_nuc) + if k is not None: + matrix[k, i] += path_rate * br + + else: + for product, y in fission_yields[nuc.name].items(): + yield_val = y * path_rate + if yield_val != 0.0: + k = self.nuclide_dict[product] + matrix[k, i] += yield_val + + # Clear set of reactions + reactions.clear() + + # Return CSC representation instead of DOK + return matrix.tocsc() + + def form_rr_term(self, tr_rates, mats): """Function to form the transfer rate term matrices. .. versionadded:: 0.14.0 @@ -841,8 +689,6 @@ class Chain: ---------- tr_rates : openmc.deplete.TransferRates Instance of openmc.deplete.TransferRates - current_timestep : int - Current timestep index mats : string or two-tuple of strings Two cases are possible: @@ -861,75 +707,42 @@ class Chain: Returns ------- - scipy.sparse.csc_array + scipy.sparse.csc_matrix Sparse matrix representing transfer term. """ # Use DOK as intermediate representation n = len(self) - matrix = dok_array((n, n)) - - check_type("mats", mats, (tuple, str)) - if not isinstance(mats, str): - check_type("mats", mats, tuple, str) - check_length("mats", mats, 2, 2) - dest_mat, mat = mats - else: - mat = mats - dest_mat = None - - # Build transfer term - components = tr_rates.get_components(mat, current_timestep, dest_mat) + matrix = sp.dok_matrix((n, n)) for i, nuc in enumerate(self.nuclides): elm = re.split(r'\d+', nuc.name)[0] - if elm in components: - key = elm - elif nuc.name in components: - key = nuc.name - else: - continue - matrix[i, i] = sum(tr_rates.get_external_rate(mat, key, current_timestep, dest_mat)) + # Build transfer terms matrices + if isinstance(mats, str): + mat = mats + components = tr_rates.get_components(mat) + if elm in components: + matrix[i, i] = sum(tr_rates.get_transfer_rate(mat, elm)) + elif nuc.name in components: + matrix[i, i] = sum(tr_rates.get_transfer_rate(mat, nuc.name)) + else: + matrix[i, i] = 0.0 + #Build transfer terms matrices + elif isinstance(mats, tuple): + dest_mat, mat = mats + if dest_mat in tr_rates.get_destination_material(mat, elm): + dest_mat_idx = tr_rates.get_destination_material(mat, elm).index(dest_mat) + matrix[i, i] = tr_rates.get_transfer_rate(mat, elm)[dest_mat_idx] + elif dest_mat in tr_rates.get_destination_material(mat, nuc.name): + dest_mat_idx = tr_rates.get_destination_material(mat, nuc.name).index(dest_mat) + matrix[i, i] = tr_rates.get_transfer_rate(mat, nuc.name)[dest_mat_idx] + else: + matrix[i, i] = 0.0 + #Nothing else is allowed # Return CSC instead of DOK return matrix.tocsc() - def form_ext_source_term(self, ext_source_rates, current_timestep, mat): - """Function to form the external source rate term vectors. - - .. versionadded:: 0.15.3 - - Parameters - ---------- - ext_source_rates : openmc.deplete.ExternalSourceRates - Instance of openmc.deplete.ExternalSourceRates - current_timestep : int - Current timestep index - mat : string - Material id - - Returns - ------- - scipy.sparse.csc_array - Sparse vector representing external source term. - - """ - if not ext_source_rates.get_components(mat, current_timestep): - return - # Use DOK as intermediate representation - n = len(self) - vector = dok_array((n, 1)) - components = ext_source_rates.get_components(mat, current_timestep) - - for i, nuc in enumerate(self.nuclides): - # Build source term vector - if nuc.name in components: - vector[i] = sum(ext_source_rates.get_external_rate( - mat, nuc.name, current_timestep)) - - # Return CSC instead of DOK - return vector.tocsc() - def get_branch_ratios(self, reaction="(n,gamma)"): """Return a dictionary with reaction branching ratios @@ -1007,7 +820,7 @@ class Chain: -------- :meth:`get_branch_ratios` """ - _invalidate_chain_cache(self) + # Store some useful information through the validation stage sums = {} @@ -1146,7 +959,6 @@ class Chain: @fission_yields.setter def fission_yields(self, yields): - _invalidate_chain_cache(self) if yields is not None: if isinstance(yields, Mapping): yields = [yields] @@ -1367,66 +1179,3 @@ class Chain: found.update(isotopes) return found - - -# A global cache for Chain objects -_CHAIN_CACHE = {} - - -def _get_chain( - chain_file: PathLike | Chain | None = None, - fission_q: dict | None = None -) -> Chain: - """Get a depletion chain from a file or the runtime configuration. - - Parameters - ---------- - chain_file : PathLike or Chain, optional - Path to depletion chain XML file, a Chain instance, or None to use - the file specified in ``openmc.config['chain_file']``. - fission_q : dict, optional - Dictionary of nuclides and their fission Q values [eV]. If not given, - values will be pulled from the ``chain_file``. - - Returns - ------- - Chain - Depletion chain instance. - """ - # If chain_file is already a Chain, return it directly - if isinstance(chain_file, Chain): - return chain_file - - # Resolve chain_file based on config if None - if chain_file is None: - chain_file = openmc.config.get('chain_file') - if 'chain_file' not in openmc.config: - raise DataError( - "No depletion chain specified and could not find depletion " - "chain in openmc.config['chain_file']" - ) - elif not isinstance(chain_file, PathLike): - raise TypeError("chain_file must be path-like, a Chain, or None") - - # Determine the key for the cache, which consists of the absolute path, the - # file modification time, the file size, and the fission Q values. - chain_path = Path(chain_file).resolve() - stat_result = chain_path.stat() - fq_tuple = tuple(sorted(fission_q.items())) if fission_q else () - key = (chain_path, stat_result.st_mtime, stat_result.st_size, fq_tuple) - - # Check the global cache. If not cached, load the chain from XML and store - global _CHAIN_CACHE - if key not in _CHAIN_CACHE: - _CHAIN_CACHE[key] = Chain.from_xml(chain_path, fission_q) - return _CHAIN_CACHE[key] - - -def _invalidate_chain_cache(chain): - """Invalidate the cache for a specific Chain (when it is modifed).""" - chain._decay_matrix = None - if hasattr(chain, '_xml_path'): - # Remove all entries with the same path as self._xml_path - for key in list(_CHAIN_CACHE.keys()): - if str(key[0]) == chain._xml_path: - del _CHAIN_CACHE[key] diff --git a/openmc/deplete/coupled_operator.py b/openmc/deplete/coupled_operator.py index a21d57d46..acdcf467c 100644 --- a/openmc/deplete/coupled_operator.py +++ b/openmc/deplete/coupled_operator.py @@ -10,6 +10,7 @@ filesystem. import copy from warnings import warn +from typing import Optional import numpy as np from uncertainties import ufloat @@ -33,7 +34,7 @@ from .helpers import ( __all__ = ["CoupledOperator", "Operator", "OperatorResult"] -def _find_cross_sections(model: str | None = None): +def _find_cross_sections(model: Optional[str] = None): """Determine cross sections to use for depletion Parameters @@ -102,9 +103,9 @@ class CoupledOperator(OpenMCOperator): ---------- model : openmc.model.Model OpenMC model object - chain_file : PathLike or Chain, optional - Path to the depletion chain XML file or instance of openmc.deplete.Chain. - Defaults to ``openmc.config['chain_file']``. + chain_file : str, optional + Path to the depletion chain XML file. Defaults to + ``openmc.config['chain_file']``. prev_results : Results, optional Results from a previous depletion calculation. If this argument is specified, the depletion calculation will start from the latest state @@ -154,9 +155,15 @@ class CoupledOperator(OpenMCOperator): options. .. versionadded:: 0.12.1 + reduce_chain : bool, optional + If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the + depletion chain up to ``reduce_chain_level``. + + .. versionadded:: 0.12 reduce_chain_level : int, optional - Depth of the search when reducing the depletion chain. The default - value of ``None`` implies no limit on the depth. + Depth of the search when reducing the depletion chain. Only used + if ``reduce_chain`` evaluates to true. The default value of + ``None`` implies no limit on the depth. .. versionadded:: 0.12 diff_volume_method : str @@ -208,7 +215,7 @@ class CoupledOperator(OpenMCOperator): normalization_mode="fission-q", fission_q=None, fission_yield_mode="constant", fission_yield_opts=None, reaction_rate_mode="direct", reaction_rate_opts=None, - reduce_chain_level=None): + reduce_chain=False, reduce_chain_level=None): # check for old call to constructor if isinstance(model, openmc.Geometry): @@ -264,6 +271,7 @@ class CoupledOperator(OpenMCOperator): diff_volume_method=diff_volume_method, fission_q=fission_q, helper_kwargs=helper_kwargs, + reduce_chain=reduce_chain, reduce_chain_level=reduce_chain_level) def _differentiate_burnable_mats(self): @@ -399,7 +407,7 @@ class CoupledOperator(OpenMCOperator): self.materials.export_to_xml(nuclides_to_ignore=self._decay_nucs) - def __call__(self, vec, source_rate) -> OperatorResult: + def __call__(self, vec, source_rate): """Runs a simulation. Simulation will abort under the following circumstances: diff --git a/openmc/deplete/cram.py b/openmc/deplete/cram.py index 3594ffbe8..53de83bb6 100644 --- a/openmc/deplete/cram.py +++ b/openmc/deplete/cram.py @@ -3,15 +3,14 @@ Implements two different forms of CRAM for use in openmc.deplete. """ -from functools import partial import numbers import numpy as np -from scipy.sparse.linalg import spsolve, splu +import scipy.sparse as sp +import scipy.sparse.linalg as sla -from openmc.checkvalue import check_type, check_length, check_greater_than +from openmc.checkvalue import check_type, check_length from .abc import DepSystemSolver -from .._sparse_compat import csc_array, eye_array __all__ = ["CRAM16", "CRAM48", "Cram16Solver", "Cram48Solver", "IPFCramSolver"] @@ -25,12 +24,6 @@ class IPFCramSolver(DepSystemSolver): Chebyshev Rational Approximation Method and Application to Burnup Equations `_," Nucl. Sci. Eng., 182:3, 297-318. - When `substeps` > 1, the time interval is split into `substeps` identical - sub-intervals and LU factorizations are reused across them, as described - in: A. Isotalo and M. Pusa, "`Improving the Accuracy of the Chebyshev - Rational Approximation Method Using Substeps - `_," Nucl. Sci. Eng., 183:1, 65-77. - Parameters ---------- alpha : numpy.ndarray @@ -62,12 +55,12 @@ class IPFCramSolver(DepSystemSolver): self.theta = theta self.alpha0 = alpha0 - def __call__(self, A, n0, dt, substeps=1): + def __call__(self, A, n0, dt): """Solve depletion equations using IPF CRAM Parameters ---------- - A : scipy.sparse.csc_array + A : scipy.sparse.csr_matrix Sparse transmutation matrix ``A[j, i]`` desribing rates at which isotope ``i`` transmutes to isotope ``j`` n0 : numpy.ndarray @@ -75,8 +68,6 @@ class IPFCramSolver(DepSystemSolver): material or an atom density dt : float Time [s] of the specific interval to be solved - substeps : int, optional - Number of substeps per depletion interval. Returns ------- @@ -84,25 +75,12 @@ class IPFCramSolver(DepSystemSolver): Final compositions after ``dt`` """ - check_type("substeps", substeps, numbers.Integral) - check_greater_than("substeps", substeps, 0) - - step_dt = dt if substeps == 1 else dt / substeps - A = step_dt * csc_array(A, dtype=np.float64) - ident = eye_array(A.shape[0], format='csc') - - if substeps == 1: - solvers = [partial(spsolve, A - theta * ident) for theta in self.theta] - else: - # Pre-compute LU factorizations and reuse them across substeps. - solvers = [splu(A - theta * ident).solve for theta in self.theta] - + A = dt * sp.csc_matrix(A, dtype=np.float64) y = n0.copy() - for _ in range(substeps): - for alpha, solve in zip(self.alpha, solvers): - y += 2 * np.real(alpha * solve(y)) - y *= self.alpha0 - return y + ident = sp.eye(A.shape[0], format='csc') + for alpha, theta in zip(self.alpha, self.theta): + y += 2*np.real(alpha*sla.spsolve(A - theta*ident, y)) + return y * self.alpha0 # Coefficients for IPF Cram 16 diff --git a/openmc/deplete/d1s.py b/openmc/deplete/d1s.py deleted file mode 100644 index d85d2e8a7..000000000 --- a/openmc/deplete/d1s.py +++ /dev/null @@ -1,256 +0,0 @@ -"""D1S module - -This module contains functionality to support the direct 1-step (D1S) method for -shutdown dose rate calculations. - -""" - -from copy import copy -from typing import Sequence -from math import log, prod - -import numpy as np - -import openmc -from openmc.data import half_life -from .abc import _normalize_timesteps -from .chain import Chain, _get_chain -from ..checkvalue import PathLike - - -def get_radionuclides(model: openmc.Model, chain_file: PathLike | Chain | None = None) -> list[str]: - """Determine all radionuclides that can be produced during D1S. - - Parameters - ---------- - model : openmc.Model - Model that should be used for determining what nuclides are present - chain_file : PathLike | Chain - Path to the depletion chain XML file or instance of openmc.deplete.Chain. - Used for inspecting decay data. Defaults to ``openmc.config['chain_file']`` - - Returns - ------- - List of nuclide names - - """ - - # Determine what nuclides appear in the model - model_nuclides = {nuc for mat in model._materials_by_id.values() - for nuc in mat.get_nuclides()} - - # Load chain file - chain = _get_chain(chain_file) - - radionuclides = set() - for nuclide in chain.nuclides: - # Restrict to set of nuclides present in model - if nuclide.name not in model_nuclides: - continue - - # Loop over reactions and add any targets that are unstable - for rx_tuple in nuclide.reactions: - target = rx_tuple.target - if target is None: - continue - target_nuclide = chain[target] - if target_nuclide.half_life is not None: - radionuclides.add(target_nuclide.name) - - return list(radionuclides) - - -def time_correction_factors( - nuclides: list[str], - timesteps: Sequence[float] | Sequence[tuple[float, str]], - source_rates: float | Sequence[float], - timestep_units: str = 's' -) -> dict[str, np.ndarray]: - """Calculate time correction factors for the D1S method. - - This function determines the time correction factor that should be applied - to photon tallies as part of the D1S method. - - Parameters - ---------- - nuclides : list of str - The name of the nuclide to find the time correction for, e.g., 'Ni65' - timesteps : iterable of float or iterable of tuple - Array of timesteps. Note that values are not cumulative. The units are - specified by the `timestep_units` argument when `timesteps` is an - iterable of float. Alternatively, units can be specified for each step - by passing a sequence of (value, unit) tuples. - source_rates : float or iterable of float - Source rate in [neutron/sec] for each interval in `timesteps` - timestep_units : {'s', 'min', 'h', 'd', 'a'}, optional - Units for values specified in the `timesteps` argument. 's' means - seconds, 'min' means minutes, 'h' means hours, and 'a' means Julian - years. - - Returns - ------- - dict - Dictionary mapping nuclide to an array of time correction factors for - each time. - - """ - - # Determine normalized timesteps and source rates - timesteps, source_rates = _normalize_timesteps( - timesteps, source_rates, timestep_units) - - # Calculate decay rate for each nuclide - decay_rate = np.array([log(2.0) / half_life(x) for x in nuclides]) - - n_timesteps = len(timesteps) + 1 - n_nuclides = len(nuclides) - - # Create a 2D array for the time correction factors - h = np.zeros((n_timesteps, n_nuclides)) - - # Precompute all exponential terms with same shape as h - decay_dt = decay_rate[np.newaxis, :] * timesteps[:, np.newaxis] - g = np.exp(-decay_dt) - one_minus_g = -np.expm1(-decay_dt) - - # Apply recurrence relation step by step - for i in range(len(timesteps)): - # Eq. (4) in doi:10.1016/j.fusengdes.2019.111399 - h[i + 1] = source_rates[i] * one_minus_g[i] + h[i] * g[i] - - return {nuclides[i]: h[:, i] for i in range(n_nuclides)} - - -def apply_time_correction( - tally: openmc.Tally, - time_correction_factors: dict[str, np.ndarray], - index: int = -1, - sum_nuclides: bool = True -) -> openmc.Tally: - """Apply time correction factors to a tally. - - This function applies the time correction factors at the given index to a - tally that contains a :class:`~openmc.ParentNuclideFilter`. When - `sum_nuclides` is True, values over all parent nuclides will be summed, - leaving a single value for each filter combination. - - Parameters - ---------- - tally : openmc.Tally - Tally to apply the time correction factors to - time_correction_factors : dict - Time correction factors as returned by :func:`time_correction_factors` - index : int, optional - Index of the time of interest. If N timesteps are provided in - :func:`time_correction_factors`, there are N + 1 times to select from. - The default is -1 which corresponds to the final time. - sum_nuclides : bool - Whether to sum over the parent nuclides - - Returns - ------- - openmc.Tally - Derived tally with time correction factors applied - - """ - # Make sure the tally contains a ParentNuclideFilter - for i_filter, filter in enumerate(tally.filters): - if isinstance(filter, openmc.ParentNuclideFilter): - break - else: - raise ValueError('Tally must contain a ParentNuclideFilter') - - # Get list of radionuclides based on tally filter - radionuclides = [str(x) for x in tally.filters[i_filter].bins] - tcf = np.array([time_correction_factors[x][index] for x in radionuclides]) - - # Force tally results to be read and std_dev to be computed - tally.std_dev - - # Create shallow copy of tally - new_tally = copy(tally) - new_tally._filters = copy(tally._filters) - - # Determine number of bins in other filters - n_bins_before = prod([f.num_bins for f in tally.filters[:i_filter]]) - n_bins_after = prod([f.num_bins for f in tally.filters[i_filter + 1:]]) - - # Reshape sum and sum_sq, apply TCF, and sum along that axis - _, n_nuclides, n_scores = new_tally.shape - n_radionuclides = len(radionuclides) - shape = (n_bins_before, n_radionuclides, n_bins_after, n_nuclides, n_scores) - tally_sum = new_tally.sum.reshape(shape) - tally_sum_sq = new_tally.sum_sq.reshape(shape) - tally_mean = new_tally.mean.reshape(shape) - tally_std_dev = new_tally.std_dev.reshape(shape) - - # Apply TCF, broadcasting to the correct dimensions - tcf.shape = (1, -1, 1, 1, 1) - new_tally._mean = tally_mean * tcf - new_tally._std_dev = tally_std_dev * tcf - - shape = (-1, n_nuclides, n_scores) - - if sum_nuclides: - # Sum over parent nuclides (note that when combining different bins for - # parent nuclide, we can't work directly on sum_sq) - new_tally._sum = None - new_tally._sum_sq = None - new_tally._mean = new_tally.mean.sum(axis=1).reshape(shape) - new_tally._std_dev = np.linalg.norm(new_tally.std_dev, axis=1).reshape(shape) - new_tally._derived = True - - # Remove ParentNuclideFilter - new_tally.filters.pop(i_filter) - else: - # Apply TCF and change shape back to (filter combinations, nuclides, - # scores) - new_tally._sum = (tally_sum * tcf).reshape(shape) - new_tally._sum_sq = (tally_sum_sq * (tcf*tcf)).reshape(shape) - new_tally._mean.shape = shape - new_tally._std_dev.shape = shape - - return new_tally - - -def prepare_tallies( - model: openmc.Model, - nuclides: list[str] | None = None, - chain_file: str | None = None -) -> list[str]: - """Prepare tallies for the D1S method. - - This function adds a :class:`~openmc.ParentNuclideFilter` to any tally that - has a particle filter with a single 'photon' bin. - - Parameters - ---------- - model : openmc.Model - Model to prepare tallies for - nuclides : list of str, optional - Nuclides to use for the parent nuclide filter. If None, radionuclides - are determined from :func:`get_radionuclides`. - chain_file : str, optional - Chain file to use for inspecting decay data. If None, defaults to - ``openmc.config['chain_file']`` - - Returns - ------- - list of str - List of parent nuclides being filtered on - - """ - if nuclides is None: - nuclides = get_radionuclides(model, chain_file) - filter = openmc.ParentNuclideFilter(nuclides) - - # Apply parent nuclide filter to any tally that has a particle filter with a - # single 'photon' bin - for tally in model.tallies: - for f in tally.filters: - if isinstance(f, openmc.ParticleFilter): - if list(f.bins) == ['photon']: - if not tally.contains_filter(openmc.ParentNuclideFilter): - tally.filters.append(filter) - break - return nuclides diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 14780d61a..f24b89868 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -379,17 +379,17 @@ class FluxCollapseHelper(ReactionRateHelper): nuclides_direct = self._rate_tally.nuclides shape = (len(nuclides_direct), len(self._reactions_direct)) rx_rates = self.rate_tally_means[mat_index].reshape(shape) - direct_rx_index = {score: i for i, score in enumerate(self._reactions_direct)} - direct_nuc_index = {nuc: i for i, nuc in enumerate(nuclides_direct)} mat = self._materials[mat_index] for name, i_nuc in zip(self.nuclides, nuc_index): for mt, score, i_rx in zip(self._mts, self._scores, react_index): if score in self._reactions_direct and name in nuclides_direct: + # Determine index in rx_rates + i_rx_direct = self._reactions_direct.index(score) + i_nuc_direct = nuclides_direct.index(name) + # Get reaction rate from tally - i_rx_direct = direct_rx_index[score] - i_nuc_direct = direct_nuc_index[name] self._results_cache[i_nuc, i_rx] = rx_rates[i_nuc_direct, i_rx_direct] else: # Use flux to collapse reaction rate (per N) diff --git a/openmc/deplete/independent_operator.py b/openmc/deplete/independent_operator.py index bdfc32763..250b94deb 100644 --- a/openmc/deplete/independent_operator.py +++ b/openmc/deplete/independent_operator.py @@ -1,13 +1,14 @@ """Transport-independent transport operator for depletion. This module implements a transport operator that runs independently of any -transport solver by using user-provided multigroup fluxes and cross sections. +transport solver by using user-provided one-group cross sections. """ from __future__ import annotations from collections.abc import Iterable import copy +from typing import List, Set import numpy as np from uncertainties import ufloat @@ -24,12 +25,14 @@ from .helpers import ChainFissionHelper, ConstantFissionYieldHelper, SourceRateH class IndependentOperator(OpenMCOperator): - """Transport-independent transport operator based on multigroup data. + """Transport-independent transport operator that uses one-group cross + sections to calculate reaction rates. - Instances of this class can be used to perform depletion using multigroup - cross sections and multigroup fluxes. Normally, a user needn't call methods - of this class directly. Instead, an instance of this class is passed to an - integrator class, such as :class:`openmc.deplete.CECMIntegrator`. + Instances of this class can be used to perform depletion using one-group + cross sections and constant flux or constant power. Normally, a user needn't + call methods of this class directly. Instead, an instance of this class is + passed to an integrator class, such as + :class:`openmc.deplete.CECMIntegrator`. Note that passing an empty :class:`~openmc.deplete.MicroXS` instance to the ``micro_xs`` argument allows a decay-only calculation to be run. @@ -42,7 +45,7 @@ class IndependentOperator(OpenMCOperator): Parameters ---------- - materials : iterable of openmc.Material + materials : openmc.Materials Materials to deplete. fluxes : list of numpy.ndarray Flux in each group in [n-cm/src] for each domain @@ -50,42 +53,48 @@ class IndependentOperator(OpenMCOperator): Cross sections in [b] for each domain. If the :class:`~openmc.deplete.MicroXS` object is empty, a decay-only calculation will be run. - chain_file : PathLike or Chain, optional - Path to the depletion chain XML file or instance of openmc.deplete.Chain. - Defaults to ``openmc.config['chain_file']``. + chain_file : str + Path to the depletion chain XML file. Defaults to + ``openmc.config['chain_file']``. keff : 2-tuple of float, optional keff eigenvalue and uncertainty from transport calculation. + Default is None. prev_results : Results, optional Results from a previous depletion calculation. normalization_mode : {"fission-q", "source-rate"} - Indicate how reaction rates should be calculated. ``"fission-q"`` uses - the fission Q values from the depletion chain to compute the flux based - on the power. ``"source-rate"`` uses a the source rate (assumed to be - neutron flux) to calculate the reaction rates. + Indicate how reaction rates should be calculated. + ``"fission-q"`` uses the fission Q values from the depletion chain to + compute the flux based on the power. ``"source-rate"`` uses a the + source rate (assumed to be neutron flux) to calculate the + reaction rates. fission_q : dict, optional Dictionary of nuclides and their fission Q values [eV]. If not given, - values will be pulled from the ``chain_file``. Only applicable if - ``"normalization_mode" == "fission-q"``. + values will be pulled from the ``chain_file``. Only applicable + if ``"normalization_mode" == "fission-q"``. + reduce_chain : bool, optional + If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the + depletion chain up to ``reduce_chain_level``. reduce_chain_level : int, optional - Depth of the search when reducing the depletion chain. The default - value of ``None`` implies no limit on the depth. + Depth of the search when reducing the depletion chain. Only used + if ``reduce_chain`` evaluates to true. The default value of + ``None`` implies no limit on the depth. fission_yield_opts : dict of str to option, optional Optional arguments to pass to the :class:`openmc.deplete.helpers.FissionYieldHelper` object. Will be - passed directly on to the helper. Passing a value of None will use the - defaults for the associated helper. + passed directly on to the helper. Passing a value of None will use + the defaults for the associated helper. Attributes ---------- materials : openmc.Materials All materials present in the model - cross_sections : list of MicroXS - Object containing multigroup cross-sections in [b] for each material. + cross_sections : MicroXS + Object containing one-group cross-sections in [cm^2]. output_dir : pathlib.Path Path to output directory to save results. round_number : bool - Whether or not to round output to OpenMC to 8 digits. Useful in testing, - as OpenMC is incredibly sensitive to exact values. + Whether or not to round output to OpenMC to 8 digits. + Useful in testing, as OpenMC is incredibly sensitive to exact values. number : openmc.deplete.AtomNumber Total number of atoms in simulation. nuclides_with_data : set of str @@ -101,8 +110,8 @@ class IndependentOperator(OpenMCOperator): local_mats : list of str All burnable material IDs being managed by a single process prev_res : Results or None - Results from a previous depletion calculation. ``None`` if no results - are to be used. + Results from a previous depletion calculation. ``None`` if no + results are to be used. """ @@ -115,12 +124,12 @@ class IndependentOperator(OpenMCOperator): normalization_mode='fission-q', fission_q=None, prev_results=None, + reduce_chain=False, reduce_chain_level=None, fission_yield_opts=None): # Validate micro-xs parameters - check_type('materials', materials, Iterable, openmc.Material) + check_type('materials', materials, openmc.Materials) check_type('micros', micros, Iterable, MicroXS) - materials = openmc.Materials(materials) if not (len(fluxes) == len(micros) == len(materials)): msg = (f'The length of fluxes ({len(fluxes)}) should be equal to ' @@ -152,6 +161,7 @@ class IndependentOperator(OpenMCOperator): prev_results=prev_results, fission_q=fission_q, helper_kwargs=helper_kwargs, + reduce_chain=reduce_chain, reduce_chain_level=reduce_chain_level) @classmethod @@ -164,6 +174,7 @@ class IndependentOperator(OpenMCOperator): normalization_mode='fission-q', fission_q=None, prev_results=None, + reduce_chain=False, reduce_chain_level=None, fission_yield_opts=None): """ @@ -179,9 +190,9 @@ class IndependentOperator(OpenMCOperator): micro_xs : MicroXS Cross sections in [b]. If the :class:`~openmc.deplete.MicroXS` object is empty, a decay-only calculation will be run. - chain_file : PathLike or Chain, optional - Path to the depletion chain XML file or instance of - openmc.deplete.Chain. Defaults to ``openmc.config['chain_file']``. + chain_file : str, optional + Path to the depletion chain XML file. Defaults to + ``openmc.config['chain_file']``. nuc_units : {'atom/cm3', 'atom/b-cm'}, optional Units for nuclide concentration. keff : 2-tuple of float, optional @@ -199,9 +210,13 @@ class IndependentOperator(OpenMCOperator): applicable if ``"normalization_mode" == "fission-q"``. prev_results : Results, optional Results from a previous depletion calculation. + reduce_chain : bool, optional + If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the + depletion chain up to ``reduce_chain_level``. Default is False. reduce_chain_level : int, optional - Depth of the search when reducing the depletion chain. The default - value of ``None`` implies no limit on the depth. + Depth of the search when reducing the depletion chain. Only used + if ``reduce_chain`` evaluates to true. The default value of + ``None`` implies no limit on the depth. fission_yield_opts : dict of str to option, optional Optional arguments to pass to the :class:`openmc.deplete.helpers.FissionYieldHelper` class. Will be @@ -221,6 +236,7 @@ class IndependentOperator(OpenMCOperator): normalization_mode=normalization_mode, fission_q=fission_q, prev_results=prev_results, + reduce_chain=reduce_chain, reduce_chain_level=reduce_chain_level, fission_yield_opts=fission_yield_opts) @@ -229,6 +245,7 @@ class IndependentOperator(OpenMCOperator): """Puts nuclide list into an openmc.Materials object. """ + openmc.reset_auto_ids() mat = openmc.Material() if nuc_units == 'atom/b-cm': for nuc, conc in nuclides.items(): @@ -262,27 +279,15 @@ class IndependentOperator(OpenMCOperator): new_res = res_obj.distribute(self.local_mats, mat_indexes) self.prev_res.append(new_res) - def _get_nuclides_with_data(self, cross_sections: list[MicroXS]) -> set[str]: - """Finds nuclides with cross section data - - Parameters - ---------- - cross_sections : iterable of :class`~openmc.deplete.MicroXS` - List of multigroup cross-section data. - - Returns - ------- - nuclides : set of str - Set of nuclide names that have cross section data - - """ + def _get_nuclides_with_data(self, cross_sections: List[MicroXS]) -> Set[str]: + """Finds nuclides with cross section data""" return set(cross_sections[0].nuclides) class _IndependentRateHelper(ReactionRateHelper): - """Class for generating reaction rates with multigroup fluxes and - multigroup cross sections. + """Class for generating one-group reaction rates with flux and + one-group cross sections. - This class does not generate tallies and instead stores cross sections + This class does not generate tallies, and instead stores cross sections for each nuclide and transmutation reaction relevant for a depletion calculation. The reaction rate is calculated by multiplying the flux by the cross sections. @@ -339,12 +344,8 @@ class IndependentOperator(OpenMCOperator): for i_nuc in nuc_index: nuc = self.nuc_ind_map[i_nuc] - if nuc not in xs._index_nuc: - continue for i_rx in react_index: rx = self.rx_ind_map[i_rx] - if rx not in xs._index_rx: - continue # Determine reaction rate by multiplying xs in [b] by flux # in [n-cm/src] to give [(reactions/src)*b-cm/atom] @@ -388,7 +389,7 @@ class IndependentOperator(OpenMCOperator): # Return number density vector return super().initial_condition(self.materials) - def __call__(self, vec, source_rate) -> OperatorResult: + def __call__(self, vec, source_rate): """Obtain the reaction rates Parameters diff --git a/openmc/deplete/integrators.py b/openmc/deplete/integrators.py index 25e64cb2e..a877c4900 100644 --- a/openmc/deplete/integrators.py +++ b/openmc/deplete/integrators.py @@ -22,6 +22,7 @@ class PredictorIntegrator(Integrator): .. math:: \mathbf{n}_{i+1} = \exp\left(h\mathbf{A}(\mathbf{n}_i) \right) \mathbf{n}_i + """ _num_stages = 1 @@ -39,19 +40,22 @@ class PredictorIntegrator(Integrator): Time in [s] for the entire depletion interval source_rate : float Power in [W] or source rate in [neutron/sec] - _i : int, optional - Current iteration count. Not used + _i : int or None + Iteration index. Not used Returns ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray + n_list : list of list of numpy.ndarray Concentrations at end of interval + op_results : empty list + Kept for consistency with API. No intermediate calls to operator + with predictor """ - proc_time, n_end = self._timed_deplete(n, rates, dt, _i) - return proc_time, n_end + proc_time, n_end = self._timed_deplete(n, rates, dt) + return proc_time, [n_end], [] @add_params @@ -95,18 +99,21 @@ class CECMIntegrator(Integrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval + n_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult + Eigenvalue and reaction rates from transport simulations """ # deplete across first half of interval - time0, n_middle = self._timed_deplete(n, rates, dt / 2, _i) + time0, n_middle = self._timed_deplete(n, rates, dt / 2) res_middle = self.operator(n_middle, source_rate) # deplete across entire interval with BOS concentrations, # MOS reaction rates - time1, n_end = self._timed_deplete(n, res_middle.rates, dt, _i) + time1, n_end = self._timed_deplete(n, res_middle.rates, dt) - return time0 + time1, n_end + return time0 + time1, [n_middle, n_end], [res_middle] @add_params @@ -156,33 +163,39 @@ class CF4Integrator(Integrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval + n_list : list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult + Eigenvalue and reaction rates from intermediate transport + simulations """ # Step 1: deplete with matrix 1/2*A(y0) time1, n_eos1 = self._timed_deplete( - n_bos, bos_rates, dt, _i, matrix_func=cf4_f1) + n_bos, bos_rates, dt, matrix_func=cf4_f1) res1 = self.operator(n_eos1, source_rate) # Step 2: deplete with matrix 1/2*A(y1) time2, n_eos2 = self._timed_deplete( - n_bos, res1.rates, dt, _i, matrix_func=cf4_f1) + n_bos, res1.rates, dt, matrix_func=cf4_f1) res2 = self.operator(n_eos2, source_rate) # Step 3: deplete with matrix -1/2*A(y0)+A(y2) list_rates = list(zip(bos_rates, res2.rates)) time3, n_eos3 = self._timed_deplete( - n_eos1, list_rates, dt, _i, matrix_func=cf4_f2) + n_eos1, list_rates, dt, matrix_func=cf4_f2) res3 = self.operator(n_eos3, source_rate) # Step 4: deplete with two matrix exponentials list_rates = list(zip(bos_rates, res1.rates, res2.rates, res3.rates)) time4, n_inter = self._timed_deplete( - n_bos, list_rates, dt, _i, matrix_func=cf4_f3) + n_bos, list_rates, dt, matrix_func=cf4_f3) time5, n_eos5 = self._timed_deplete( - n_inter, list_rates, dt, _i, matrix_func=cf4_f4) + n_inter, list_rates, dt, matrix_func=cf4_f4) - return time1 + time2 + time3 + time4 + time5, n_eos5 + return (time1 + time2 + time3 + time4 + time5, + [n_eos1, n_eos2, n_eos3, n_eos5], + [res1, res2, res3]) @add_params @@ -228,23 +241,27 @@ class CELIIntegrator(Integrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval + n_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult + Eigenvalue and reaction rates from intermediate transport + simulation """ # deplete to end using BOS rates - proc_time, n_ce = self._timed_deplete(n_bos, rates, dt, _i) + proc_time, n_ce = self._timed_deplete(n_bos, rates, dt) res_ce = self.operator(n_ce, source_rate) # deplete using two matrix exponentials list_rates = list(zip(rates, res_ce.rates)) time_le1, n_inter = self._timed_deplete( - n_bos, list_rates, dt, _i, matrix_func=celi_f1) + n_bos, list_rates, dt, matrix_func=celi_f1) time_le2, n_end = self._timed_deplete( - n_inter, list_rates, dt, _i, matrix_func=celi_f2) + n_inter, list_rates, dt, matrix_func=celi_f2) - return proc_time + time_le1 + time_le2, n_end + return proc_time + time_le1 + time_le1, [n_ce, n_end], [res_ce] @add_params @@ -290,27 +307,31 @@ class EPCRK4Integrator(Integrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval + n_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult + Eigenvalue and reaction rates from intermediate transport + simulations """ # Step 1: deplete with matrix A(y0) / 2 - time1, n1 = self._timed_deplete(n, rates, dt, _i, matrix_func=rk4_f1) + time1, n1 = self._timed_deplete(n, rates, dt, matrix_func=rk4_f1) res1 = self.operator(n1, source_rate) # Step 2: deplete with matrix A(y1) / 2 - time2, n2 = self._timed_deplete(n, res1.rates, dt, _i, matrix_func=rk4_f1) + time2, n2 = self._timed_deplete(n, res1.rates, dt, matrix_func=rk4_f1) res2 = self.operator(n2, source_rate) # Step 3: deplete with matrix A(y2) - time3, n3 = self._timed_deplete(n, res2.rates, dt, _i) + time3, n3 = self._timed_deplete(n, res2.rates, dt) res3 = self.operator(n3, source_rate) # Step 4: deplete with matrix built from weighted rates list_rates = list(zip(rates, res1.rates, res2.rates, res3.rates)) - time4, n4 = self._timed_deplete(n, list_rates, dt, _i, matrix_func=rk4_f4) + time4, n4 = self._timed_deplete(n, list_rates, dt, matrix_func=rk4_f4) - return time1 + time2 + time3 + time4, n4 + return (time1 + time2 + time3 + time4, [n1, n2, n3, n4], [res1, res2, res3]) @add_params @@ -368,8 +389,12 @@ class LEQIIntegrator(Integrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval + n_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult + Eigenvalue and reaction rates from intermediate transport + simulation """ if i == 0: if self._i_res < 1: # need at least previous transport solution @@ -378,7 +403,7 @@ class LEQIIntegrator(Integrator): self, n_bos, bos_rates, dt, source_rate, i) prev_res = self.operator.prev_res[-2] prev_dt = self.timesteps[i] - prev_res.time[0] - self._prev_rates = prev_res.rates + self._prev_rates = prev_res.rates[0] else: prev_dt = self.timesteps[i - 1] @@ -389,9 +414,9 @@ class LEQIIntegrator(Integrator): self._prev_rates, bos_res.rates, repeat(prev_dt), repeat(dt))) time1, n_inter = self._timed_deplete( - n_bos, le_inputs, dt, i, matrix_func=leqi_f1) + n_bos, le_inputs, dt, matrix_func=leqi_f1) time2, n_eos0 = self._timed_deplete( - n_inter, le_inputs, dt, i, matrix_func=leqi_f2) + n_inter, le_inputs, dt, matrix_func=leqi_f2) res_inter = self.operator(n_eos0, source_rate) @@ -400,14 +425,16 @@ class LEQIIntegrator(Integrator): repeat(prev_dt), repeat(dt))) time3, n_inter = self._timed_deplete( - n_bos, qi_inputs, dt, i, matrix_func=leqi_f3) + n_bos, qi_inputs, dt, matrix_func=leqi_f3) time4, n_eos1 = self._timed_deplete( - n_inter, qi_inputs, dt, i, matrix_func=leqi_f4) + n_inter, qi_inputs, dt, matrix_func=leqi_f4) # store updated rates self._prev_rates = copy.deepcopy(bos_res.rates) - return time1 + time2 + time3 + time4, n_eos1 + return ( + time1 + time2 + time3 + time4, [n_eos0, n_eos1], + [bos_res, res_inter]) @add_params @@ -419,7 +446,7 @@ class SICELIIntegrator(SIIntegrator): `_. Detailed algorithm can be found in section 3.2 in `Colin Josey's thesis - `_. + `_. """ _num_stages = 2 @@ -444,13 +471,14 @@ class SICELIIntegrator(SIIntegrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval - op_result : openmc.deplete.OperatorResult + n_bos_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult Eigenvalue and reaction rates from intermediate transport simulations """ - proc_time, n_eos = self._timed_deplete(n_bos, bos_rates, dt, _i) + proc_time, n_eos = self._timed_deplete(n_bos, bos_rates, dt) n_inter = copy.deepcopy(n_eos) # Begin iteration @@ -466,13 +494,13 @@ class SICELIIntegrator(SIIntegrator): list_rates = list(zip(bos_rates, res_bar.rates)) time1, n_inter = self._timed_deplete( - n_bos, list_rates, dt, _i, matrix_func=celi_f1) + n_bos, list_rates, dt, matrix_func=celi_f1) time2, n_inter = self._timed_deplete( - n_inter, list_rates, dt, _i, matrix_func=celi_f2) + n_inter, list_rates, dt, matrix_func=celi_f2) proc_time += time1 + time2 # end iteration - return proc_time, n_inter, res_bar + return proc_time, [n_eos, n_inter], [res_bar] @add_params @@ -484,7 +512,7 @@ class SILEQIIntegrator(SIIntegrator): `_. Detailed algorithm can be found in Section 3.2 in `Colin Josey's thesis - `_. + `_. """ _num_stages = 2 @@ -509,9 +537,10 @@ class SILEQIIntegrator(SIIntegrator): ------- proc_time : float Time spent in CRAM routines for all materials in [s] - n_end : list of numpy.ndarray - Concentrations at end of interval - op_result : openmc.deplete.OperatorResult + n_list : list of list of numpy.ndarray + Concentrations at each of the intermediate points with + the final concentration as the last element + op_results : list of openmc.deplete.OperatorResult Eigenvalue and reaction rates from intermediate transport simulation """ @@ -523,7 +552,7 @@ class SILEQIIntegrator(SIIntegrator): self, n_bos, bos_rates, dt, source_rate, i) prev_res = self.operator.prev_res[-2] prev_dt = self.timesteps[i] - prev_res.time[0] - self._prev_rates = prev_res.rates + self._prev_rates = prev_res.rates[0] else: prev_dt = self.timesteps[i - 1] @@ -531,9 +560,9 @@ class SILEQIIntegrator(SIIntegrator): inputs = list(zip(self._prev_rates, bos_rates, repeat(prev_dt), repeat(dt))) proc_time, n_inter = self._timed_deplete( - n_bos, inputs, dt, i, matrix_func=leqi_f1) + n_bos, inputs, dt, matrix_func=leqi_f1) time1, n_eos = self._timed_deplete( - n_inter, inputs, dt, i, matrix_func=leqi_f2) + n_inter, inputs, dt, matrix_func=leqi_f2) proc_time += time1 n_inter = copy.deepcopy(n_eos) @@ -551,15 +580,12 @@ class SILEQIIntegrator(SIIntegrator): inputs = list(zip(self._prev_rates, bos_rates, res_bar.rates, repeat(prev_dt), repeat(dt))) time1, n_inter = self._timed_deplete( - n_bos, inputs, dt, i, matrix_func=leqi_f3) + n_bos, inputs, dt, matrix_func=leqi_f3) time2, n_inter = self._timed_deplete( - n_inter, inputs, dt, i, matrix_func=leqi_f4) + n_inter, inputs, dt, matrix_func=leqi_f4) proc_time += time1 + time2 - # Store updated rates for next step - self._prev_rates = copy.deepcopy(bos_rates) - - return proc_time, n_inter, res_bar + return proc_time, [n_eos, n_inter], [res_bar] integrator_by_name = { diff --git a/openmc/deplete/keff_search_control.py b/openmc/deplete/keff_search_control.py deleted file mode 100644 index 49f7cc4df..000000000 --- a/openmc/deplete/keff_search_control.py +++ /dev/null @@ -1,128 +0,0 @@ -from typing import Callable -from warnings import warn - -import openmc.lib - - -class _KeffSearchControl: - """Controller for keff search during depletion calculations. - - This class performs keff searches to maintain a target keff by adjusting a - model parameter through a provided function. - - Parameters - ---------- - operator : openmc.deplete.Operator - Depletion operator instance - function : Callable - Function that modifies the model based on a parameter value - x0 : float - Initial lower bound for the keff search - x1 : float - Initial upper bound for the keff search - bracket : list[float] - Absolute bracketing interval lower and upper. If the keff search - solution lies off these limits the closest limit will be set as new - result. - **search_kwargs : dict, optional - Additional keyword arguments to pass to :meth:`openmc.Model.keff_search` - - """ - def __init__(self, operator, function: Callable, x0: float, x1: float, bracket: list[float], **search_kwargs): - if len(bracket) != 2: - raise ValueError(f"bracket must have exactly 2 elements, got {len(bracket)}") - if bracket[0] >= bracket[1]: - raise ValueError(f"bracket[0] must be < bracket[1], got {bracket}") - self.x0 = x0 - self.x1 = x1 - self.operator = operator - self.function = function - self.search_kwargs = search_kwargs - self.search_kwargs['x_min'] = bracket[0] - self.search_kwargs['x_max'] = bracket[1] - - def run(self, x): - """Perform keff search and update the atom density vector. - - Parameters - ---------- - x : list of numpy.ndarray - Current atom density vector (atoms per material) - - Returns - ------- - root : float - Parameter value that achieves target keff - """ - root = self._search_for_keff() - self._update_vec(x) - return root - - def _search_for_keff(self) -> float: - """Perform the keff search using the model's keff_search method. - - Returns - ------- - float - Parameter value that achieves target keff - - Raises - ------ - ValueError - If the keff search fails to converge - """ - with openmc.lib.TemporarySession(self.operator.model): - # Only pass the first 3 required args plus explicitly provided kwargs - result = self.operator.model.keff_search( - self.function, self.x0, self.x1, **self.search_kwargs - ) - if not result.converged: - raise ValueError( - f"Search for keff failed to converge. " - f"Termination reason: {result.flag}" - ) - - root = result.root - - # Check if root is outside the bracket bounds and give a warning - if root < self.search_kwargs['x_min']: - warn(f"keff search result ({root:.6f}) is below the lower bracket " - f"bound ({self.search_kwargs['x_min']:.6f}).", UserWarning) - elif root > self.search_kwargs['x_max']: - warn(f"keff search result ({root:.6f}) is above the upper bracket " - f"bound ({self.search_kwargs['x_max']:.6f}).", UserWarning) - - # Restore the number of initial batches - openmc.lib.settings.set_batches(self.operator.model.settings.batches) - - return root - - def _update_vec(self, x): - """Update the atom density vector from openmc.lib.materials and AtomNumber object. - - The depletion vector ``x`` is rank-local, matching the materials owned - by ``self.operator.number`` on the current MPI rank. We therefore only - update entries for locally owned materials using the compositions - currently stored in ``openmc.lib.materials``. - - Parameters - ---------- - x : list of numpy.ndarray - Atom density vector to update (atoms per material) - - """ - number = self.operator.number - - for mat_idx, mat in enumerate(number.materials): - lib_material = openmc.lib.materials[int(mat)] - nuclides = lib_material.nuclides - densities = 1e24 * lib_material.densities - volume = number.get_mat_volume(mat) - - for nuc_idx, nuc in enumerate(number.burnable_nuclides): - if nuc in nuclides: - lib_nuc_idx = nuclides.index(nuc) - atom_density = densities[lib_nuc_idx] - else: - atom_density = number.get_atom_density(mat, nuc) - x[mat_idx][nuc_idx] = atom_density * volume diff --git a/openmc/deplete/microxs.py b/openmc/deplete/microxs.py index 7049f7d31..b2ae9f6c7 100644 --- a/openmc/deplete/microxs.py +++ b/openmc/deplete/microxs.py @@ -5,77 +5,58 @@ IndependentOperator class for depletion. """ from __future__ import annotations -from collections.abc import Sequence -import shutil from tempfile import TemporaryDirectory -from typing import Union, TypeAlias, Self +from typing import List, Tuple, Iterable, Optional, Union, Sequence -import h5py import pandas as pd import numpy as np from openmc.checkvalue import check_type, check_value, check_iterable_type, PathLike +from openmc.exceptions import DataError +from openmc.utility_funcs import change_directory from openmc import StatePoint from openmc.mgxs import GROUP_STRUCTURES from openmc.data import REACTION_MT import openmc -from .chain import Chain, REACTIONS, _get_chain +from .chain import Chain, REACTIONS from .coupled_operator import _find_cross_sections, _get_nuclides_with_data -from ..utility_funcs import h5py_file_or_group import openmc.lib -from openmc.mpi import comm _valid_rxns = list(REACTIONS) _valid_rxns.append('fission') _valid_rxns.append('damage-energy') -# TODO: Replace with type statement when support is Python 3.12+ -DomainTypes: TypeAlias = Union[ - Sequence[openmc.Material], - Sequence[openmc.Cell], - Sequence[openmc.Universe], - openmc.MeshBase, - openmc.Filter, - Sequence[openmc.Filter] -] +def _resolve_chain_file_path(chain_file: str): + if chain_file is None: + chain_file = openmc.config.get('chain_file') + if 'chain_file' not in openmc.config: + raise DataError( + "No depletion chain specified and could not find depletion " + "chain in openmc.config['chain_file']" + ) + return chain_file def get_microxs_and_flux( - model: openmc.Model, - domains: DomainTypes, - nuclides: Sequence[str] | None = None, - reactions: Sequence[str] | None = None, - energies: Sequence[float] | str | None = None, - reaction_rate_mode: str = 'direct', - chain_file: PathLike | Chain | None = None, - path_statepoint: PathLike | None = None, - path_input: PathLike | None = None, - run_kwargs=None, - reaction_rate_opts: dict | None = None, -) -> tuple[list[np.ndarray], list[MicroXS]]: - """Generate microscopic cross sections and fluxes for multiple domains. - - This function runs a neutron transport solve to obtain the flux and reaction - rates in the specified domains and computes multigroup microscopic cross - sections that can be used in depletion calculations with the - :class:`~openmc.deplete.IndependentOperator` class. + model: openmc.Model, + domains, + nuclides: Optional[Iterable[str]] = None, + reactions: Optional[Iterable[str]] = None, + energies: Optional[Union[Iterable[float], str]] = None, + chain_file: Optional[PathLike] = None, + run_kwargs=None + ) -> Tuple[List[np.ndarray], List[MicroXS]]: + """Generate a microscopic cross sections and flux from a Model .. versionadded:: 0.14.0 - .. versionchanged:: 0.15.3 - Added `reaction_rate_mode`, `path_statepoint`, `path_input` arguments. - Parameters ---------- model : openmc.Model OpenMC model object. Must contain geometry, materials, and settings. - domains : list of openmc.Material or openmc.Cell or openmc.Universe, or openmc.MeshBase, or openmc.Filter, or list of openmc.Filter - Domains in which to tally reaction rates, or a spatial tally filter. - A list of filters can be provided to create one set of tallies per - filter (e.g., one :class:`~openmc.MeshMaterialFilter` per mesh) that - are all evaluated in a single transport solve. Results are - concatenated across all filters in order. + domains : list of openmc.Material or openmc.Cell or openmc.Universe, or openmc.MeshBase + Domains in which to tally reaction rates. nuclides : list of str Nuclides to get cross sections for. If not specified, all burnable nuclides from the depletion chain file are used. @@ -83,41 +64,14 @@ def get_microxs_and_flux( Reactions to get cross sections for. If not specified, all neutron reactions listed in the depletion chain file are used. energies : iterable of float or str - Energy group boundaries in [eV] or the name of the group structure. - If left as None, no energy filter is applied to the flux tally. When - `reaction_rate_mode` is "direct", these boundaries define the output - flux and microscopic cross section energy group structure. When - `reaction_rate_mode` is "flux", these boundaries define the multigroup - flux tally used to collapse continuous-energy cross sections; returned - fluxes and microscopic cross sections are one-group. - reaction_rate_mode : {"direct", "flux"}, optional - The "direct" method tallies reaction rates directly (per energy - group). The "flux" method tallies a multigroup flux spectrum and then - collapses reaction rates after a transport solve. When - `reaction_rate_opts` is provided with `reaction_rate_mode='flux'`, the - specified nuclide/reaction pairs are tallied directly and those values - override the flux-collapsed values. - chain_file : PathLike or Chain, optional - Path to the depletion chain XML file or an instance of - openmc.deplete.Chain. Used to determine cross sections for materials not + Energy group boundaries in [eV] or the name of the group structure + chain_file : str, optional + Path to the depletion chain XML file that will be used in depletion + simulation. Used to determine cross sections for materials not present in the inital composition. Defaults to ``openmc.config['chain_file']``. - path_statepoint : path-like, optional - Path to write the statepoint file from the neutron transport solve to. - By default, The statepoint file is written to a temporary directory and - is not kept. - path_input : path-like, optional - Path to write the model XML file from the neutron transport solve to. - By default, the model XML file is written to a temporary directory and - not kept. run_kwargs : dict, optional Keyword arguments passed to :meth:`openmc.Model.run` - reaction_rate_opts : dict, optional - When `reaction_rate_mode="flux"`, allows selecting a subset of - nuclide/reaction pairs to be computed via direct reaction-rate tallies - over one energy bin spanning the full `energies` range. Supported keys: - "nuclides", "reactions". If "reactions" are specified without - "nuclides", all selected nuclides are used. Returns ------- @@ -126,18 +80,13 @@ def get_microxs_and_flux( list of MicroXS Cross section data in [b] for each domain - See Also - -------- - openmc.deplete.IndependentOperator - """ - check_value('reaction_rate_mode', reaction_rate_mode, {'direct', 'flux'}) - # Save any original tallies on the model - original_tallies = list(model.tallies) + original_tallies = model.tallies # Determine what reactions and nuclides are available in chain - chain = _get_chain(chain_file) + chain_file = _resolve_chain_file_path(chain_file) + chain = Chain.from_xml(chain_file) if reactions is None: reactions = chain.reactions if not nuclides: @@ -146,194 +95,69 @@ def get_microxs_and_flux( nuclides = [nuc.name for nuc in chain.nuclides if nuc.name in nuclides_with_data] - # Set up the reaction rate and flux tallies. When energies are omitted, no - # energy filter is needed for the transport calculation. A one-group energy - # range is still needed later if flux collapse is requested. - collapse_energies = energies + # Set up the reaction rate and flux tallies if energies is None: - energy_filter = None - collapse_energies = [0.0, 100.0e6] + energy_filter = openmc.EnergyFilter([0.0, 100.0e6]) elif isinstance(energies, str): energy_filter = openmc.EnergyFilter.from_group_structure(energies) else: energy_filter = openmc.EnergyFilter(energies) - - # Build list of domain filters - if isinstance(domains, openmc.Filter): - domain_filters = [domains] - elif isinstance(domains, openmc.MeshBase): - domain_filters = [openmc.MeshFilter(domains)] - elif isinstance(domains, Sequence) and len(domains) > 0 and \ - isinstance(domains[0], openmc.Filter): - domain_filters = list(domains) + if isinstance(domains, openmc.MeshBase): + domain_filter = openmc.MeshFilter(domains) elif isinstance(domains[0], openmc.Material): - domain_filters = [openmc.MaterialFilter(domains)] + domain_filter = openmc.MaterialFilter(domains) elif isinstance(domains[0], openmc.Cell): - domain_filters = [openmc.CellFilter(domains)] + domain_filter = openmc.CellFilter(domains) elif isinstance(domains[0], openmc.Universe): - domain_filters = [openmc.UniverseFilter(domains)] + domain_filter = openmc.UniverseFilter(domains) else: raise ValueError(f"Unsupported domain type: {type(domains[0])}") - # Prepare reaction-rate nuclides/reactions - rr_nuclides: list[str] = [] - rr_reactions: list[str] = [] - if reaction_rate_mode == 'direct': - rr_nuclides = list(nuclides) - rr_reactions = list(reactions) - elif reaction_rate_mode == 'flux' and reaction_rate_opts: - opts = reaction_rate_opts or {} - rr_reactions = list(opts.get('reactions', [])) - if rr_reactions: - rr_nuclides = list(opts.get('nuclides', nuclides)) - else: - rr_nuclides = list(opts.get('nuclides', [])) - # Keep only requested pairs within overall sets - if rr_nuclides: - rr_nuclides = [n for n in rr_nuclides if n in set(nuclides)] - if rr_reactions: - rr_reactions = [r for r in rr_reactions if r in set(reactions)] + rr_tally = openmc.Tally(name='MicroXS RR') + rr_tally.filters = [domain_filter, energy_filter] + rr_tally.nuclides = nuclides + rr_tally.multiply_density = False + rr_tally.scores = reactions - # Use 1-group energy filter for RR in flux mode - has_rr = bool(rr_nuclides and rr_reactions) - if has_rr and reaction_rate_mode == 'flux' and energy_filter is not None: - rr_energy_filter = openmc.EnergyFilter( - [energy_filter.values[0], energy_filter.values[-1]]) - else: - rr_energy_filter = energy_filter - - # Create one flux tally (and optionally one RR tally) per domain filter. - flux_tallies = [] - rr_tallies = [] - model.tallies = [] - for i, domain_filter in enumerate(domain_filters): - flux_tally = openmc.Tally(name=f'MicroXS flux {i}') - flux_tally.filters = [domain_filter] - if energy_filter is not None: - flux_tally.filters.append(energy_filter) - flux_tally.scores = ['flux'] - model.tallies.append(flux_tally) - flux_tallies.append(flux_tally) - - if has_rr: - rr_tally = openmc.Tally(name=f'MicroXS RR {i}') - rr_tally.filters = [domain_filter] - if rr_energy_filter is not None: - rr_tally.filters.append(rr_energy_filter) - rr_tally.nuclides = rr_nuclides - rr_tally.multiply_density = False - rr_tally.scores = rr_reactions - model.tallies.append(rr_tally) - rr_tallies.append(rr_tally) - - if openmc.lib.is_initialized: - openmc.lib.finalize() - - if comm.rank == 0: - model.export_to_model_xml() - comm.barrier() - # Reinitialize with tallies - output = run_kwargs.get('output', True) if run_kwargs else True - openmc.lib.init(intracomm=comm, output=output) + flux_tally = openmc.Tally(name='MicroXS flux') + flux_tally.filters = [domain_filter, energy_filter] + flux_tally.scores = ['flux'] + model.tallies = openmc.Tallies([rr_tally, flux_tally]) + # create temporary run with TemporaryDirectory() as temp_dir: - # Indicate to run in temporary directory unless being executed through - # openmc.lib, in which case we don't need to specify the cwd - run_kwargs = dict(run_kwargs) if run_kwargs else {} - if not openmc.lib.is_initialized: - run_kwargs.setdefault('cwd', temp_dir) - - # Run transport simulation and synchronize - statepoint_path = model.run(**run_kwargs) - comm.barrier() - - if comm.rank == 0: - # Move the statepoint file if it is being saved to a specific path - if path_statepoint is not None: - shutil.move(statepoint_path, path_statepoint) - statepoint_path = path_statepoint - - # Export the model to path_input if provided - if path_input is not None: - model.export_to_model_xml(path_input) - - # Broadcast updated statepoint path to all ranks - statepoint_path = comm.bcast(statepoint_path) - - # Read in tally results (on all ranks) - with StatePoint(statepoint_path) as sp: - for i in range(len(flux_tallies)): - flux_tallies[i] = sp.tallies[flux_tallies[i].id] - flux_tallies[i]._read_results() - if rr_tallies: - rr_tallies[i] = sp.tallies[rr_tallies[i].id] - rr_tallies[i]._read_results() - - # Concatenate results across all domain filters - fluxes = [] - all_flux_arrays = [] - for flux_tally in flux_tallies: - # Get flux values and make energy groups last dimension - flux = flux_tally.get_reshaped_data() - if energy_filter is None: - flux = flux[..., np.newaxis] # (domains, 1, 1, groups) + if run_kwargs is None: + run_kwargs = {} else: - # (domains, groups, 1, 1) -> (domains, 1, 1, groups) - flux = np.moveaxis(flux, 1, -1) - all_flux_arrays.append(flux) - fluxes.extend(flux.squeeze((1, 2))) + run_kwargs = dict(run_kwargs) + run_kwargs.setdefault('cwd', temp_dir) + statepoint_path = model.run(**run_kwargs) - # If we built reaction-rate tallies, compute microscopic cross sections - if rr_tallies: - direct_micros = [] - for flux_arr, rr_tally in zip(all_flux_arrays, rr_tallies): - flux = flux_arr - # Get reaction rates and make energy groups last dimension - reaction_rates = rr_tally.get_reshaped_data() - if rr_energy_filter is None: - # (domains, nuclides, reactions) -> - # (domains, nuclides, reactions, groups) - reaction_rates = reaction_rates[..., np.newaxis] - else: - # (domains, groups, nuclides, reactions) -> - # (domains, nuclides, reactions, groups) - reaction_rates = np.moveaxis(reaction_rates, 1, -1) + with StatePoint(statepoint_path) as sp: + rr_tally = sp.tallies[rr_tally.id] + rr_tally._read_results() + flux_tally = sp.tallies[flux_tally.id] + flux_tally._read_results() - # If RR is 1-group, sum flux over groups - if reaction_rate_mode == "flux": - flux = flux.sum(axis=-1, keepdims=True) + # Get reaction rates and flux values + reaction_rates = rr_tally.get_reshaped_data() # (domains, groups, nuclides, reactions) + flux = flux_tally.get_reshaped_data() # (domains, groups, 1, 1) - xs = np.zeros_like(reaction_rates) - d, _, _, g = np.nonzero(flux) - xs[d, ..., g] = reaction_rates[d, ..., g] / flux[d, :, :, g] - direct_micros.extend( - MicroXS(xs_i, rr_nuclides, rr_reactions) for xs_i in xs) + # Make energy groups last dimension + reaction_rates = np.moveaxis(reaction_rates, 1, -1) # (domains, nuclides, reactions, groups) + flux = np.moveaxis(flux, 1, -1) # (domains, 1, 1, groups) - if reaction_rate_mode == 'flux': - # Compute flux-collapsed microscopic XS - flux_micros = [MicroXS.from_multigroup_flux( - energies=collapse_energies, - multigroup_flux=flux_i, - chain_file=chain_file, - nuclides=nuclides, - reactions=reactions - ) for flux_i in fluxes] - - # We need to return one-group fluxes to match the microscopic cross - # sections, which are always one-group by virtue of the collapse - fluxes = [flux.sum(keepdims=True) for flux in fluxes] - - # Decide which micros to use and merge if needed - if reaction_rate_mode == 'flux' and rr_tallies: - micros = [m1.merge(m2) for m1, m2 in zip(flux_micros, direct_micros)] - elif rr_tallies: - micros = direct_micros - else: - micros = flux_micros + # Divide RR by flux to get microscopic cross sections + xs = np.empty_like(reaction_rates) # (domains, nuclides, reactions, groups) + d, _, _, g = np.nonzero(flux) + xs[d, ..., g] = reaction_rates[d, ..., g] / flux[d, :, :, g] # Reset tallies model.tallies = original_tallies + # Create lists where each item corresponds to one domain + fluxes = list(flux.squeeze((1, 2))) + micros = [MicroXS(xs_i, nuclides, reactions) for xs_i in xs] return fluxes, micros @@ -359,10 +183,8 @@ class MicroXS: :data:`openmc.deplete.chain.REACTIONS` """ - def __init__(self, data: np.ndarray, nuclides: list[str], reactions: list[str]): + def __init__(self, data: np.ndarray, nuclides: List[str], reactions: List[str]): # Validate inputs - if len(data.shape) != 3: - raise ValueError('Data array must be 3D.') if data.shape[:2] != (len(nuclides), len(reactions)): raise ValueError( f'Nuclides list of length {len(nuclides)} and ' @@ -383,12 +205,12 @@ class MicroXS: @classmethod def from_multigroup_flux( cls, - energies: Sequence[float] | str, + energies: Union[Sequence[float], str], multigroup_flux: Sequence[float], - chain_file: PathLike | None = None, + chain_file: Optional[PathLike] = None, temperature: float = 293.6, - nuclides: Sequence[str] | None = None, - reactions: Sequence[str] | None = None, + nuclides: Optional[Sequence[str]] = None, + reactions: Optional[Sequence[str]] = None, **init_kwargs: dict, ) -> MicroXS: """Generated microscopic cross sections from a known flux. @@ -397,21 +219,17 @@ class MicroXS: sections available. MicroXS entry will be 0 if the nuclide cross section is not found. - It is recommended to make repeated calls to this method within a context - manager using the :class:`openmc.lib.TemporarySession` class to avoid - re-initializing OpenMC and loading cross sections each time. - .. versionadded:: 0.15.0 Parameters ---------- energies : iterable of float or str Energy group boundaries in [eV] or the name of the group structure - multigroup_flux : iterable of float + multi_group_flux : iterable of float Energy-dependent multigroup flux values - chain_file : PathLike or Chain, optional - Path to the depletion chain XML file or an instance of - openmc.deplete.Chain. Defaults to ``openmc.config['chain_file']``. + chain_file : str, optional + Path to the depletion chain XML file that will be used in depletion + simulation. Defaults to ``openmc.config['chain_file']``. temperature : int, optional Temperature for cross section evaluation in [K]. nuclides : list of str, optional @@ -442,7 +260,9 @@ class MicroXS: if len(multigroup_flux) != len(energies) - 1: raise ValueError('Length of flux array should be len(energies)-1') - chain = _get_chain(chain_file) + chain_file_path = _resolve_chain_file_path(chain_file) + chain = Chain.from_xml(chain_file_path) + cross_sections = _find_cross_sections(model=None) nuclides_with_data = _get_nuclides_with_data(cross_sections) @@ -457,28 +277,44 @@ class MicroXS: reactions = chain.reactions mts = [REACTION_MT[name] for name in reactions] - # Create 3D array for microscopic cross sections - microxs_arr = np.zeros((len(nuclides), len(mts), 1)) - - # If flux is zero, safely return zero cross sections - multigroup_flux = np.array(multigroup_flux) - if (flux_sum := multigroup_flux.sum()) == 0.0: - return cls(microxs_arr, nuclides, reactions) - # Normalize multigroup flux - multigroup_flux /= flux_sum + multigroup_flux = np.asarray(multigroup_flux) + multigroup_flux /= multigroup_flux.sum() - # Compute microscopic cross sections within a temporary session - with openmc.lib.TemporarySession(**init_kwargs): - # For each nuclide and reaction, compute the flux-averaged xs - for nuc_index, nuc in enumerate(nuclides): - if nuc not in nuclides_with_data: - continue - lib_nuc = openmc.lib.load_nuclide(nuc) - for mt_index, mt in enumerate(mts): - microxs_arr[nuc_index, mt_index, 0] = lib_nuc.collapse_rate( - mt, temperature, energies, multigroup_flux - ) + # Create 2D array for microscopic cross sections + microxs_arr = np.zeros((len(nuclides), len(mts))) + + # Create a material with all nuclides + mat_all_nucs = openmc.Material() + for nuc in nuclides: + if nuc in nuclides_with_data: + mat_all_nucs.add_nuclide(nuc, 1.0) + mat_all_nucs.set_density("atom/b-cm", 1.0) + + # Create simple model containing the above material + surf1 = openmc.Sphere(boundary_type="vacuum") + surf1_cell = openmc.Cell(fill=mat_all_nucs, region=-surf1) + model = openmc.Model() + model.geometry = openmc.Geometry([surf1_cell]) + model.settings = openmc.Settings( + particles=1, batches=1, output={'summary': False}) + + with change_directory(tmpdir=True): + # Export model within temporary directory + model.export_to_model_xml() + + with openmc.lib.run_in_memory(**init_kwargs): + # For each nuclide and reaction, compute the flux-averaged + # cross section + for nuc_index, nuc in enumerate(nuclides): + if nuc not in nuclides_with_data: + continue + lib_nuc = openmc.lib.nuclides[nuc] + for mt_index, mt in enumerate(mts): + xs = lib_nuc.collapse_rate( + mt, temperature, energies, multigroup_flux + ) + microxs_arr[nuc_index, mt_index] = xs return cls(microxs_arr, nuclides, reactions) @@ -499,7 +335,8 @@ class MicroXS: MicroXS """ - kwargs.setdefault('float_precision', 'round_trip') + if 'float_precision' not in kwargs: + kwargs['float_precision'] = 'round_trip' df = pd.read_csv(csv_file, **kwargs) df.set_index(['nuclides', 'reactions', 'groups'], inplace=True) @@ -535,168 +372,3 @@ class MicroXS: df = pd.DataFrame({'xs': self.data.flatten()}, index=multi_index) df.to_csv(*args, **kwargs) - def to_hdf5(self, group_or_filename: h5py.Group | PathLike, **kwargs): - """Export microscopic cross section data to HDF5 format - - Parameters - ---------- - group_or_filename : h5py.Group or path-like - HDF5 group or filename to write to - kwargs : dict, optional - Keyword arguments to pass to :meth:`h5py.Group.create_dataset`. - Defaults to {'compression': 'lzf'}. - - """ - kwargs.setdefault('compression', 'lzf') - - with h5py_file_or_group(group_or_filename, 'w') as group: - # Store cross section data as 3D dataset - group.create_dataset('data', data=self.data, **kwargs) - - # Store metadata as datasets using string encoding - group.create_dataset('nuclides', data=np.array(self.nuclides, dtype='S')) - group.create_dataset('reactions', data=np.array(self.reactions, dtype='S')) - - @classmethod - def from_hdf5(cls, group_or_filename: h5py.Group | PathLike) -> Self: - """Load data from an HDF5 file - - Parameters - ---------- - group_or_filename : h5py.Group or str or PathLike - HDF5 group or path to HDF5 file. If given as an h5py.Group, the - data is read from that group. If given as a string, it is assumed - to be the filename for the HDF5 file. - - Returns - ------- - MicroXS - """ - - with h5py_file_or_group(group_or_filename, 'r') as group: - # Read data from HDF5 group - data = group['data'][:] - nuclides = [nuc.decode('utf-8') for nuc in group['nuclides'][:]] - reactions = [rxn.decode('utf-8') for rxn in group['reactions'][:]] - - return cls(data, nuclides, reactions) - - def merge(self, other: Self, prefer: str = 'other') -> Self: - """Merge two MicroXS objects by taking the union of nuclides/reactions. - - If the two objects contain overlapping nuclide/reaction entries, values - from `other` will overwrite values from `self` when `prefer='other'`. - When `prefer='self'`, values from `self` are retained for overlapping - entries, and values from `other` are used only for non-overlapping - entries. - - Parameters - ---------- - other : MicroXS - Other MicroXS instance to merge with this one. - prefer : {"other", "self"} - Which instance's data should take precedence on overlap. - - Returns - ------- - MicroXS - New instance containing the merged data. - """ - check_value('prefer', prefer, {'other', 'self'}) - - # Require same number of energy groups - if self.data.shape[2] != other.data.shape[2]: - raise ValueError( - 'Cannot merge MicroXS with different number of energy groups: ' - f"{self.data.shape[2]} vs {other.data.shape[2]}. Ensure that " - 'both were generated with consistent group structures and ' - 'treatments (e.g., both multigroup or both collapsed).' - ) - - # Build unified axes preserving order (self first, then other's new) - new_nuclides = list(self.nuclides) - for nuc in other.nuclides: - if nuc not in self._index_nuc: - new_nuclides.append(nuc) - new_reactions = list(self.reactions) - for rx in other.reactions: - if rx not in self._index_rx: - new_reactions.append(rx) - - # Allocate and fill from self (self's nuclides/reactions map to the - # first indices of new_nuclides/new_reactions by construction) - groups = self.data.shape[2] - data = np.zeros((len(new_nuclides), len(new_reactions), groups)) - idx_n = {nuc: i for i, nuc in enumerate(new_nuclides)} - idx_r = {rx: i for i, rx in enumerate(new_reactions)} - - n_self = len(self.nuclides) - r_self = len(self.reactions) - data[:n_self, :r_self] = self.data - - # Build destination index arrays for other's nuclides/reactions - dst_n = np.array([idx_n[nuc] for nuc in other.nuclides]) - dst_r = np.array([idx_r[rx] for rx in other.reactions]) - - # Copy from other, respecting precedence - if prefer == 'other': - data[np.ix_(dst_n, dst_r)] = other.data - else: - # Copy only entries where nuc or rx is absent from self - nuc_is_new = np.array( - [nuc not in self._index_nuc for nuc in other.nuclides]) - rx_is_new = np.array( - [rx not in self._index_rx for rx in other.reactions]) - mask = nuc_is_new[:, np.newaxis] | rx_is_new[np.newaxis, :] - src_i, src_j = np.where(mask) - if src_i.size: - data[dst_n[src_i], dst_r[src_j]] = other.data[src_i, src_j] - - return MicroXS(data, new_nuclides, new_reactions) - - -def write_microxs_hdf5( - micros: Sequence[MicroXS], - filename: PathLike, - names: Sequence[str] | None = None, - **kwargs -): - """Write multiple MicroXS objects to an HDF5 file - - Parameters - ---------- - micros : list of MicroXS - List of MicroXS objects - filename : PathLike - Output HDF5 filename - names : list of str, optional - Names for each MicroXS object. If None, uses 'domain_0', 'domain_1', - etc. - **kwargs - Additional keyword arguments passed to :meth:`h5py.Group.create_dataset` - """ - if names is None: - names = [f'domain_{i}' for i in range(len(micros))] - - # Open file once and write all domains using group interface - with h5py.File(filename, 'w') as f: - for microxs, name in zip(micros, names): - group = f.create_group(name) - microxs.to_hdf5(group, **kwargs) - - -def read_microxs_hdf5(filename: PathLike) -> dict[str, MicroXS]: - """Read multiple MicroXS objects from an HDF5 file - - Parameters - ---------- - filename : path-like - HDF5 filename - - Returns - ------- - dict - Dictionary mapping domain names to MicroXS objects - """ - with h5py.File(filename, 'r') as f: - return {name: MicroXS.from_hdf5(group) for name, group in f.items()} diff --git a/openmc/deplete/nuclide.py b/openmc/deplete/nuclide.py index 958814834..60e3e5317 100644 --- a/openmc/deplete/nuclide.py +++ b/openmc/deplete/nuclide.py @@ -14,7 +14,6 @@ import numpy as np from openmc.checkvalue import check_type from openmc.stats import Univariate -from .._xml import get_elem_list, get_text __all__ = [ "DecayTuple", "ReactionTuple", "Nuclide", "FissionYield", @@ -226,39 +225,38 @@ class Nuclide: """ nuc = cls() - nuc.name = get_text(element, "name") + nuc.name = element.get('name') # Check for half-life - half_life = get_text(element, "half_life") - if half_life is not None: - nuc.half_life = float(half_life) - nuc.decay_energy = float(get_text(element, "decay_energy", 0.0)) + if 'half_life' in element.attrib: + nuc.half_life = float(element.get('half_life')) + nuc.decay_energy = float(element.get('decay_energy', '0')) # Check for decay paths for decay_elem in element.iter('decay'): - d_type = get_text(decay_elem, "type") - target = get_text(decay_elem, "target") + d_type = decay_elem.get('type') + target = decay_elem.get('target') if target is not None and target.lower() == "nothing": target = None - branching_ratio = float(get_text(decay_elem, "branching_ratio")) + branching_ratio = float(decay_elem.get('branching_ratio')) nuc.decay_modes.append(DecayTuple(d_type, target, branching_ratio)) # Check for sources for src_elem in element.iter('source'): - particle = get_text(src_elem, "particle") + particle = src_elem.get('particle') distribution = Univariate.from_xml_element(src_elem) nuc.sources[particle] = distribution # Check for reaction paths for reaction_elem in element.iter('reaction'): - r_type = get_text(reaction_elem, "type") - Q = float(get_text(reaction_elem, "Q", 0.0)) - branching_ratio = float(get_text(reaction_elem, "branching_ratio", 1.0)) + r_type = reaction_elem.get('type') + Q = float(reaction_elem.get('Q', '0')) + branching_ratio = float(reaction_elem.get('branching_ratio', '1')) # If the type is not fission, get target and Q value, otherwise # just set null values if r_type != 'fission': - target = get_text(reaction_elem, "target") + target = reaction_elem.get('target') if target is not None and target.lower() == "nothing": target = None else: @@ -273,7 +271,7 @@ class Nuclide: fpy_elem = element.find('neutron_fission_yields') if fpy_elem is not None: # Check for use of FPY from other nuclide - parent = get_text(fpy_elem, "parent") + parent = fpy_elem.get('parent') if parent is not None: assert root is not None fpy_elem = root.find( @@ -531,9 +529,9 @@ class FissionYieldDistribution(Mapping): """ all_yields = {} for yield_elem in element.iter("fission_yields"): - energy = float(get_text(yield_elem, "energy")) - products = get_elem_list(yield_elem, "products", str) or [] - yields = get_elem_list(yield_elem, "data", float) or [] + energy = float(yield_elem.get("energy")) + products = yield_elem.find("products").text.split() + yields = map(float, yield_elem.find("data").text.split()) # Get a map of products to their corresponding yield all_yields[energy] = dict(zip(products, yields)) diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index 7928e89ee..75f0925c4 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -7,11 +7,12 @@ transport-independent transport operators. from abc import abstractmethod from warnings import warn +from typing import List, Tuple, Dict import numpy as np import openmc -from openmc.checkvalue import check_value, check_type, check_greater_than +from openmc.checkvalue import check_value from openmc.exceptions import DataError from openmc.mpi import comm from .abc import TransportOperator, OperatorResult @@ -36,9 +37,9 @@ class OpenMCOperator(TransportOperator): cross_sections : str or list of MicroXS Path to continuous energy cross section library, or list of objects containing cross sections. - chain_file : PathLike or Chain, optional - Path to the depletion chain XML file or instance of openmc.deplete.Chain. - Defaults to ``openmc.config['chain_file']``. + chain_file : str, optional + Path to the depletion chain XML file. Defaults to + openmc.config['chain_file']. prev_results : Results, optional Results from a previous depletion calculation. If this argument is specified, the depletion calculation will start from the latest state @@ -49,9 +50,13 @@ class OpenMCOperator(TransportOperator): Dictionary of nuclides and their fission Q values [eV]. helper_kwargs : dict Keyword arguments for helper classes + reduce_chain : bool, optional + If True, use :meth:`openmc.deplete.Chain.reduce()` to reduce the + depletion chain up to ``reduce_chain_level``. reduce_chain_level : int, optional - Depth of the search when reducing the depletion chain. The default - value of ``None`` implies no limit on the depth. + Depth of the search when reducing the depletion chain. Only used + if ``reduce_chain`` evaluates to true. The default value of + ``None`` implies no limit on the depth. diff_volume_method : str Specifies how the volumes of the new materials should be found. Default @@ -103,6 +108,7 @@ class OpenMCOperator(TransportOperator): diff_volume_method='divide equally', fission_q=None, helper_kwargs=None, + reduce_chain=False, reduce_chain_level=None): # If chain file was not specified, try to get it from global config @@ -121,13 +127,10 @@ class OpenMCOperator(TransportOperator): check_value('diff volume method', diff_volume_method, {'divide equally', 'match cell'}) - if reduce_chain_level: - check_type('reduce_chain_level', reduce_chain_level, int) - check_greater_than('reduce_chain_level', reduce_chain_level, 0) self.diff_volume_method = diff_volume_method # Reduce the chain to only those nuclides present - if reduce_chain_level is not None: + if reduce_chain: init_nuclides = set() for material in self.materials: if not material.depletable: @@ -144,6 +147,8 @@ class OpenMCOperator(TransportOperator): # Determine which nuclides have cross section data # This nuclides variables contains every nuclides # for which there is an entry in the micro_xs parameter + openmc.reset_auto_ids() + self.nuclides_with_data = self._get_nuclides_with_data( self.cross_sections) @@ -180,7 +185,7 @@ class OpenMCOperator(TransportOperator): """Assign distribmats for each burnable material""" pass - def _get_burnable_mats(self) -> tuple[list[str], dict[str, float], list[str]]: + def _get_burnable_mats(self) -> Tuple[List[str], Dict[str, float], List[str]]: """Determine depletable materials, volumes, and nuclides Returns @@ -206,12 +211,12 @@ class OpenMCOperator(TransportOperator): if nuclide in self.nuclides_with_data or self._decay_nucs: model_nuclides.add(nuclide) else: - msg = (f"Nuclide {nuclide} in material {mat.id} is not " + msg = (f"Nuclilde {nuclide} in material {mat.id} is not " "present in the depletion chain and has no cross " "section data.") warn(msg) if mat.depletable: - burnable_mats.add((str(mat.id), mat.name)) + burnable_mats.add(str(mat.id)) if mat.volume is None: if mat.name is None: msg = ("Volume not specified for depletable material " @@ -229,12 +234,9 @@ class OpenMCOperator(TransportOperator): "No depletable materials were found in the model.") # Sort the sets - burnable_mats = sorted(burnable_mats, key=lambda x: int(x[0])) + burnable_mats = sorted(burnable_mats, key=int) model_nuclides = sorted(model_nuclides) - # Store material names for later use - burnable_mats, self.name_list = zip(*burnable_mats) - # Construct a global nuclide dictionary, burned first nuclides = list(self.chain.nuclide_dict) for nuc in model_nuclides: @@ -248,7 +250,20 @@ class OpenMCOperator(TransportOperator): @abstractmethod def _get_nuclides_with_data(self, cross_sections): - """Find nuclides with cross section data.""" + """Find nuclides with cross section data + + Parameters + ---------- + cross_sections : str or pandas.DataFrame + Path to continuous energy cross section library, or object + containing one-group cross-sections. + + Returns + ------- + nuclides : set of str + Set of nuclide names that have cross secton data + + """ def _extract_number(self, local_mats, volume, all_nuclides, prev_res=None): """Construct AtomNumber using geometry @@ -382,6 +397,9 @@ class OpenMCOperator(TransportOperator): self.number.set_density(vec) self._update_materials() + # Prevent OpenMC from complaining about re-creating tallies + openmc.reset_auto_ids() + # Update tally nuclides data in preparation for transport solve nuclides = self._get_reaction_nuclides() self._rate_helper.nuclides = nuclides @@ -544,8 +562,6 @@ class OpenMCOperator(TransportOperator): A list of all material IDs to be burned. Used for sorting the simulation. full_burn_list : list List of all burnable material IDs - name_list : list of str - Material names corresponding to materials in burn_list """ nuc_list = self.number.burnable_nuclides @@ -559,4 +575,4 @@ class OpenMCOperator(TransportOperator): volume_list = comm.allgather(volume) volume = {k: v for d in volume_list for k, v in d.items()} - return volume, nuc_list, burn_list, self.burnable_mats, self.name_list + return volume, nuc_list, burn_list, self.burnable_mats diff --git a/openmc/deplete/pool.py b/openmc/deplete/pool.py index 19ad0ada5..27ecaa4dd 100644 --- a/openmc/deplete/pool.py +++ b/openmc/deplete/pool.py @@ -5,11 +5,10 @@ Provided to avoid some circular imports from itertools import repeat, starmap from multiprocessing import Pool +from scipy.sparse import bmat import numpy as np -from scipy.sparse import hstack from openmc.mpi import comm -from .._sparse_compat import block_array # Configurable switch that enables / disables the use of # multiprocessing routines during depletion @@ -41,8 +40,7 @@ def _distribute(items): return items[j:j + chunk_size] j += chunk_size -def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, - transfer_rates=None, external_source_rates=None, substeps=1, +def deplete(func, chain, n, rates, dt, matrix_func=None, transfer_rates=None, *matrix_args): """Deplete materials using given reaction rates for a specified time @@ -50,7 +48,7 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, ---------- func : callable Function to use to get new compositions. Expected to have the signature - ``func(A, n0, t, substeps=1) -> n1``. + ``func(A, n0, t) -> n1`` chain : openmc.deplete.Chain Depletion chain n : list of numpy.ndarray @@ -60,23 +58,15 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, Reaction rates (from transport operator) dt : float Time in [s] to deplete for - current_timestep : int - Current timestep index maxtrix_func : callable, optional Function to form the depletion matrix after calling ``matrix_func(chain, rates, fission_yields)``, where ``fission_yields = {parent: {product: yield_frac}}`` Expected to return the depletion matrix required by ``func`` transfer_rates : openmc.deplete.TransferRates, Optional - Transfer rates for continuous removal/feed. + Object to perform continuous reprocessing. .. versionadded:: 0.14.0 - external_source_rates : openmc.deplete.ExternalSourceRates, Optional - External source rates for continuous removal/feed. - - .. versionadded:: 0.15.3 - substeps : int, optional - Number of substeps to pass to solvers that support substepping. matrix_args: Any, optional Additional arguments passed to matrix_func @@ -103,24 +93,15 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, matrices = map(matrix_func, repeat(chain), rates, fission_yields, *matrix_args) - if (transfer_rates is not None and - current_timestep in transfer_rates.external_timesteps): + if transfer_rates is not None: # Calculate transfer rate terms as diagonal matrices transfers = map(chain.form_rr_term, repeat(transfer_rates), - repeat(current_timestep), transfer_rates.local_mats) - + transfer_rates.local_mats) # Subtract transfer rate terms from Bateman matrices matrices = [matrix - transfer for (matrix, transfer) in zip(matrices, transfers)] - if transfer_rates.redox: - for mat_idx, mat_id in enumerate(transfer_rates.local_mats): - if mat_id in transfer_rates.redox: - matrices[mat_idx] = chain.add_redox_term(matrices[mat_idx], - transfer_rates.redox[mat_id][0], - transfer_rates.redox[mat_id][1]) - - if current_timestep in transfer_rates.index_transfer: + if len(transfer_rates.index_transfer) > 0: # Gather all on comm.rank 0 matrices = comm.gather(matrices) n = comm.gather(n) @@ -131,18 +112,10 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, n = [n_elm for n_mat in n for n_elm in n_mat] # Calculate transfer rate terms as diagonal matrices - transfer_pair = {} - for mat_pair in transfer_rates.index_transfer[current_timestep]: - transfer_matrix = chain.form_rr_term(transfer_rates, - current_timestep, - mat_pair) - - # check if destination material has a redox control - if mat_pair[0] in transfer_rates.redox: - transfer_matrix = chain.add_redox_term(transfer_matrix, - transfer_rates.redox[mat_pair[0]][0], - transfer_rates.redox[mat_pair[0]][1]) - transfer_pair[mat_pair] = transfer_matrix + transfer_pair = { + mat_pair: chain.form_rr_term(transfer_rates, mat_pair) + for mat_pair in transfer_rates.index_transfer + } # Combine all matrices together in a single matrix of matrices # to be solved in one go @@ -156,18 +129,18 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, if row == col: # Fill the diagonals with the Bateman matrices cols.append(matrices[row]) - elif mat_pair in transfer_rates.index_transfer[current_timestep]: + elif mat_pair in transfer_rates.index_transfer: # Fill the off-diagonals with the transfer pair matrices cols.append(transfer_pair[mat_pair]) else: cols.append(None) rows.append(cols) - matrix = block_array(rows) + matrix = bmat(rows) # Concatenate vectors of nuclides in one n_multi = np.concatenate(n) - n_result = func(matrix, n_multi, dt, substeps) + n_result = func(matrix, n_multi, dt) # Split back the nuclide vector result into the original form n_result = np.split(n_result, np.cumsum([len(i) for i in n])[:-1]) @@ -182,26 +155,7 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, return n_result - if (external_source_rates is not None and - current_timestep in external_source_rates.external_timesteps): - # Calculate external source term vectors - sources = map(chain.form_ext_source_term, repeat(external_source_rates), - repeat(current_timestep), external_source_rates.local_mats) - - # stack vector column at the end of the matrix - matrices = [ - hstack([matrix, source]) - for matrix, source in zip(matrices, sources) - ] - - # Add a last row of zeroes to the matrices and append 1 to the last row - # of the nuclide vectors - for i, matrix in enumerate(matrices): - if not np.equal(*matrix.shape): - matrix.resize(matrix.shape[1], matrix.shape[1]) - n[i] = np.append(n[i], 1.0) - - inputs = zip(matrices, n, repeat(dt), repeat(substeps)) + inputs = zip(matrices, n, repeat(dt)) if USE_MULTIPROCESSING: with Pool(NUM_PROCESSES) as pool: @@ -209,10 +163,4 @@ def deplete(func, chain, n, rates, dt, current_timestep=None, matrix_func=None, else: n_result = list(starmap(func, inputs)) - # Remove extra value at the end of the nuclide vectors - if (external_source_rates is not None and - current_timestep in external_source_rates.external_timesteps): - external_source_rates.reformat_nuclide_vectors(n) - external_source_rates.reformat_nuclide_vectors(n_result) - return n_result diff --git a/openmc/deplete/r2s.py b/openmc/deplete/r2s.py deleted file mode 100644 index 6c19531e7..000000000 --- a/openmc/deplete/r2s.py +++ /dev/null @@ -1,845 +0,0 @@ -from __future__ import annotations -from collections.abc import Sequence -from contextlib import nullcontext -import copy -from datetime import datetime -import json -from numbers import Integral -from pathlib import Path - -import numpy as np -import openmc -from . import IndependentOperator, PredictorIntegrator -from .chain import Chain -from .microxs import get_microxs_and_flux, write_microxs_hdf5, read_microxs_hdf5 -from .results import Results -from ..checkvalue import PathLike -from ..mpi import comm -from openmc.lib import TemporarySession - - -def get_activation_materials( - model: openmc.Model, - mmv_list: list[openmc.MeshMaterialVolumes] -) -> openmc.Materials: - """Get a list of activation materials for each mesh element/material. - - When performing a mesh-based R2S calculation, a unique material is needed - for each activation region, which is a combination of a mesh element and a - material within that mesh element. This function generates a list of such - materials, each with a unique name and volume corresponding to the mesh - element and material. - - Parameters - ---------- - model : openmc.Model - The full model containing the geometry and materials. - mmv_list : list of openmc.MeshMaterialVolumes - List of mesh material volumes objects, one per mesh, containing the - materials and their volumes for each mesh element. - - Returns - ------- - openmc.Materials - A list of materials, each corresponding to a unique mesh element and - material combination across all meshes. - - """ - # Get all materials in the model - material_dict = model._get_all_materials() - - # Create a new activation material for each element-material combination - # across all meshes - materials = openmc.Materials() - for mesh_idx, mmv in enumerate(mmv_list): - mat_ids = mmv._materials[mmv._materials > -1] - volumes = mmv._volumes[mmv._materials > -1] - elems, _ = np.where(mmv._materials > -1) - - for elem, mat_id, vol in zip(elems, mat_ids, volumes): - mat = material_dict[mat_id] - new_mat = mat.clone() - new_mat.depletable = True - new_mat.name = f'Mesh {mesh_idx}, Element {elem}, Material {mat_id}' - new_mat.volume = vol - materials.append(new_mat) - - return materials - - -class R2SManager: - """Manager for Rigorous 2-Step (R2S) method calculations. - - This class is responsible for managing the materials and sources needed for - mesh-based or cell-based R2S calculations. It provides methods to get - activation materials and decay photon sources based on the mesh/cells and - materials in the OpenMC model. Multiple meshes can be specified as domains, - in which case each element--material combination of each mesh is treated as - an activation region (meshes are assumed to be non-overlapping). - - This class supports the use of a different models for the neutron and photon - transport calculation. However, for cell-based calculations, it assumes that - the only changes in the model are material assignments. For mesh-based - calculations, it checks material assignments in the photon model and any - element--material combinations that don't appear in the photon model are - skipped. - - Parameters - ---------- - neutron_model : openmc.Model - The OpenMC model to use for neutron transport. - domains : openmc.MeshBase or Sequence[openmc.MeshBase] or Sequence[openmc.Cell] - The mesh(es) or a sequence of cells that represent the spatial units - over which the R2S calculation will be performed. When a single - :class:`~openmc.MeshBase` or a sequence of meshes is given, each - element--material combination across all meshes is treated as an - activation region. - photon_model : openmc.Model, optional - The OpenMC model to use for photon transport calculations. If None, a - shallow copy of the neutron_model will be created and used. - - Attributes - ---------- - domains : list of openmc.MeshBase or Sequence[openmc.Cell] - The meshes or a sequence of cells that represent the spatial units over - which the R2S calculation will be performed. - neutron_model : openmc.Model - The OpenMC model used for neutron transport. - photon_model : openmc.Model - The OpenMC model used for photon transport calculations. - method : {'mesh-based', 'cell-based'} - Indicates whether the R2S calculation uses mesh elements ('mesh-based') - as the spatial discretization or a list of cells ('cell-based'). - results : dict - A dictionary that stores results from the R2S calculation. - - """ - def __init__( - self, - neutron_model: openmc.Model, - domains: openmc.MeshBase | Sequence[openmc.MeshBase] | Sequence[openmc.Cell], - photon_model: openmc.Model | None = None, - ): - self.neutron_model = neutron_model - if photon_model is None: - # Create a shallow copy of the neutron model for photon transport - self.photon_model = openmc.Model( - geometry=copy.copy(neutron_model.geometry), - materials=copy.copy(neutron_model.materials), - settings=copy.copy(neutron_model.settings), - tallies=copy.copy(neutron_model.tallies), - plots=copy.copy(neutron_model.plots), - ) - else: - self.photon_model = photon_model - if isinstance(domains, openmc.MeshBase): - self.method = 'mesh-based' - self.domains = [domains] - elif isinstance(domains, Sequence) and len(domains) > 0 and \ - isinstance(domains[0], openmc.MeshBase): - self.method = 'mesh-based' - self.domains = list(domains) - else: - self.method = 'cell-based' - self.domains = list(domains) - self.results = {} - - def run( - self, - timesteps: Sequence[float] | Sequence[tuple[float, str]], - source_rates: float | Sequence[float], - timestep_units: str = 's', - photon_time_indices: Sequence[int] | None = None, - output_dir: PathLike | None = None, - bounding_boxes: dict[int, openmc.BoundingBox] | None = None, - chain_file: PathLike | Chain | None = None, - micro_kwargs: dict | None = None, - mat_vol_kwargs: dict | None = None, - run_kwargs: dict | None = None, - operator_kwargs: dict | None = None, - by_parent_nuclide: bool = False, - ): - """Run the R2S calculation. - - Parameters - ---------- - timesteps : Sequence[float] or Sequence[tuple[float, str]] - Sequence of timesteps. Note that values are not cumulative. The - units are specified by the `timestep_units` argument when - `timesteps` is an iterable of float. Alternatively, units can be - specified for each step by passing an iterable of (value, unit) - tuples. - source_rates : float or Sequence[float] - Source rate in [neutron/sec] for each interval in `timesteps`. - timestep_units : {'s', 'min', 'h', 'd', 'a'}, optional - Units for values specified in the `timesteps` argument when passing - float values. 's' means seconds, 'min' means minutes, 'h' means - hours, 'd' means days, and 'a' means years (Julian). - photon_time_indices : Sequence[int], optional - Sequence of time indices at which photon transport should be run; - represented as indices into the array of times formed by the - timesteps. For example, if two timesteps are specified, the array of - times would contain three entries, and [2] would indicate computing - photon results at the last time. A value of None indicates to run - photon transport at each time that has a decay photon source. - output_dir : PathLike, optional - Path to directory where R2S calculation outputs will be saved. If - not provided, a timestamped directory 'r2s_YYYY-MM-DDTHH-MM-SS' is - created. Subdirectories will be created for the neutron transport, - activation, and photon transport steps. - bounding_boxes : dict[int, openmc.BoundingBox], optional - Dictionary mapping cell IDs to bounding boxes used for spatial - source sampling in cell-based R2S calculations. Required if method - is 'cell-based'. - chain_file : PathLike or openmc.deplete.Chain, optional - Path to the depletion chain XML file or depletion chain object to - use during activation. If not provided, the default configured - chain file will be used. - micro_kwargs : dict, optional - Additional keyword arguments passed to - :func:`openmc.deplete.get_microxs_and_flux` during the neutron - transport step. - mat_vol_kwargs : dict, optional - Additional keyword arguments passed to - :meth:`openmc.MeshBase.material_volumes`. - run_kwargs : dict, optional - Additional keyword arguments passed to :meth:`openmc.Model.run` - during the neutron and photon transport step. By default, output is - disabled. - operator_kwargs : dict, optional - Additional keyword arguments passed to - :class:`openmc.deplete.IndependentOperator`. - by_parent_nuclide : bool, optional - Whether to score photon tallies separately for each parent - radionuclide. A :class:`~openmc.ParentNuclideFilter` is added to - tallies that do not already contain one, with bins determined from - the prepared decay photon sources. - - Returns - ------- - Path - Path to the output directory containing all calculation results - """ - - if output_dir is None: - # Create timestamped output directory and broadcast to all ranks for - # consistency (different ranks may have slightly different times) - stamp = datetime.now().strftime('%Y-%m-%dT%H-%M-%S') - output_dir = Path(comm.bcast(f'r2s_{stamp}')) - else: - output_dir = Path(output_dir) - - # Set run_kwargs for the neutron transport step - if micro_kwargs is None: - micro_kwargs = {} - if run_kwargs is None: - run_kwargs = {} - if operator_kwargs is None: - operator_kwargs = {} - run_kwargs.setdefault('output', False) - micro_kwargs.setdefault('run_kwargs', run_kwargs) - - # DecaySpectrum distributions are resolved in the C++ solver using - # OPENMC_CHAIN_FILE. If a Chain object was passed, write an XML - # representation alongside the R2S outputs. - if isinstance(chain_file, Chain): - output_dir.mkdir(parents=True, exist_ok=True) - chain_path = output_dir / 'chain.xml' - if comm.rank == 0: - chain_file.export_to_xml(chain_path) - comm.barrier() - else: - chain_path = chain_file - - chain_context = ( - openmc.config.patch('chain_file', chain_path) - if chain_path is not None else nullcontext() - ) - with chain_context: - self.step1_neutron_transport( - output_dir / 'neutron_transport', mat_vol_kwargs, micro_kwargs - ) - self.step2_activation( - timesteps, source_rates, timestep_units, - output_dir / 'activation', operator_kwargs=operator_kwargs - ) - self.step3_photon_source( - photon_time_indices, bounding_boxes, output_dir / 'photon_transport', - mat_vol_kwargs=mat_vol_kwargs, - ) - self.step4_photon_transport( - output_dir / 'photon_transport', run_kwargs=run_kwargs, - by_parent_nuclide=by_parent_nuclide, - ) - - return output_dir - - def step1_neutron_transport( - self, - output_dir: PathLike = "neutron_transport", - mat_vol_kwargs: dict | None = None, - micro_kwargs: dict | None = None - ): - """Run the neutron transport step. - - This step computes the material volume fractions on each mesh, creates - mesh-material filters, and retrieves the fluxes and microscopic cross - sections for each mesh/material combination via a single transport - solve. This step will populate the 'fluxes' and 'micros' keys in the - results dictionary. For a mesh-based calculation, it will also populate - the 'mesh_material_volumes' key (a list of - :class:`~openmc.MeshMaterialVolumes`, one per mesh). - - Parameters - ---------- - output_dir : PathLike, optional - The directory where the results will be saved. - mat_vol_kwargs : dict, optional - Additional keyword arguments based to - :meth:`openmc.MeshBase.material_volumes`. - micro_kwargs : dict, optional - Additional keyword arguments passed to - :func:`openmc.deplete.get_microxs_and_flux`. - - """ - - output_dir = Path(output_dir).resolve() - output_dir.mkdir(parents=True, exist_ok=True) - - if self.method == 'mesh-based': - # Compute material volume fractions on each mesh - if mat_vol_kwargs is None: - mat_vol_kwargs = {} - mat_vol_kwargs.setdefault('bounding_boxes', True) - - mmv_list = [] - domain_filters = [] - for i, mesh in enumerate(self.domains): - mmv = comm.bcast( - mesh.material_volumes(self.neutron_model, **mat_vol_kwargs)) - mmv_list.append(mmv) - - # Save results to file - if comm.rank == 0: - mmv.save(output_dir / f'mesh_material_volumes_{i}.npz') - - # Create mesh-material filter for this mesh - domain_filters.append( - openmc.MeshMaterialFilter.from_volumes(mesh, mmv)) - - self.results['mesh_material_volumes'] = mmv_list - domains = domain_filters - else: - domains: Sequence[openmc.Cell] = self.domains - - # Check to make sure that each cell is filled with a material and - # that the volume has been set - - # TODO: If volumes are not set, run volume calculation for cells - for cell in domains: - if cell.fill is None: - raise ValueError( - f"Cell {cell.id} is not filled with a materials. " - "Please set the fill material for each cell before " - "running the R2S calculation." - ) - if cell.volume is None: - raise ValueError( - f"Cell {cell.id} does not have a volume set. " - "Please set the volume for each cell before running " - "the R2S calculation." - ) - - # Set default keyword arguments for microxs and flux calculation - if micro_kwargs is None: - micro_kwargs = {} - micro_kwargs.setdefault('path_statepoint', output_dir / 'statepoint.h5') - micro_kwargs.setdefault('path_input', output_dir / 'model.xml') - - # Run neutron transport and get fluxes and micros. Run via openmc.lib to - # maintain a consistent parallelism strategy with the activation step. - with TemporarySession(output=False): - self.results['fluxes'], self.results['micros'] = get_microxs_and_flux( - self.neutron_model, domains, **micro_kwargs) - - # Save flux and micros to file - if comm.rank == 0: - np.save(output_dir / 'fluxes.npy', self.results['fluxes']) - write_microxs_hdf5(self.results['micros'], output_dir / 'micros.h5') - - def step2_activation( - self, - timesteps: Sequence[float] | Sequence[tuple[float, str]], - source_rates: float | Sequence[float], - timestep_units: str = 's', - output_dir: PathLike = 'activation', - operator_kwargs: dict | None = None, - ): - """Run the activation step. - - This step creates a unique copy of each activation material based on the - mesh elements or cells, then solves the depletion equations for each - material using the fluxes and microscopic cross sections obtained in the - neutron transport step. This step will populate the 'depletion_results' - and 'activation_materials' keys in the results dictionary. - - Parameters - ---------- - timesteps : Sequence[float] or Sequence[tuple[float, str]] - Sequence of timesteps. Note that values are not cumulative. The - units are specified by the `timestep_units` argument when - `timesteps` is an iterable of float. Alternatively, units can be - specified for each step by passing an iterable of (value, unit) - tuples. - source_rates : float | Sequence[float] - Source rate in [neutron/sec] for each interval in `timesteps`. - timestep_units : {'s', 'min', 'h', 'd', 'a'}, optional - Units for values specified in the `timesteps` argument when passing - float values. 's' means seconds, 'min' means minutes, 'h' means - hours, 'd' means days, and 'a' means years (Julian). - output_dir : PathLike, optional - Path to directory where activation calculation outputs will be - saved. - operator_kwargs : dict, optional - Additional keyword arguments passed to - :class:`openmc.deplete.IndependentOperator`. - """ - - if self.method == 'mesh-based': - # Get unique material for each (mesh, material) combination - mmv_list = self.results['mesh_material_volumes'] - self.results['activation_materials'] = get_activation_materials( - self.neutron_model, mmv_list) - else: - # Create unique material for each cell - activation_mats = openmc.Materials() - for cell in self.domains: - mat = cell.fill.clone() - mat.name = f'Cell {cell.id}' - mat.depletable = True - mat.volume = cell.volume - activation_mats.append(mat) - self.results['activation_materials'] = activation_mats - - # Save activation materials to file - output_dir = Path(output_dir) - output_dir.mkdir(parents=True, exist_ok=True) - self.results['activation_materials'].export_to_xml( - output_dir / 'materials.xml') - - # Create depletion operator for the activation materials - if operator_kwargs is None: - operator_kwargs = {} - operator_kwargs.setdefault('normalization_mode', 'source-rate') - op = IndependentOperator( - self.results['activation_materials'], - self.results['fluxes'], - self.results['micros'], - **operator_kwargs - ) - - # Create time integrator and solve depletion equations - integrator = PredictorIntegrator( - op, timesteps, source_rates=source_rates, timestep_units=timestep_units - ) - output_path = output_dir / 'depletion_results.h5' - integrator.integrate(final_step=False, path=output_path) - comm.barrier() - - # Get depletion results - self.results['depletion_results'] = Results(output_path) - - def step3_photon_source( - self, - time_indices: Sequence[int] | None = None, - bounding_boxes: dict[int, openmc.BoundingBox] | None = None, - output_dir: PathLike = 'photon_transport', - mat_vol_kwargs: dict | None = None, - ): - """Create decay photon sources. - - This step creates decay photon sources from the activated materials for - each specified time. In mesh-based mode, the sources are created using - mesh material volumes, while in cell-based mode, they are created using - bounding boxes for each cell. This step will populate the - 'photon_sources' key in the results dictionary. - - Parameters - ---------- - time_indices : Sequence[int], optional - Sequence of time indices at which photon transport should be run; - represented as indices into the array of times formed by the - timesteps. For example, if two timesteps are specified, the array of - times would contain three entries, and [2] would indicate computing - photon results at the last time. A value of None indicates to run - photon transport at each time that has a decay photon source. - bounding_boxes : dict[int, openmc.BoundingBox], optional - Dictionary mapping cell IDs to bounding boxes used for spatial - source sampling in cell-based R2S calculations. Required if method - is 'cell-based'. - output_dir : PathLike, optional - Path to directory where photon source outputs will be saved. - mat_vol_kwargs : dict, optional - Additional keyword arguments passed to - :meth:`openmc.MeshBase.material_volumes`. - """ - - # Do not retain sources from an earlier successful call if this source - # preparation attempt fails. - self.results.pop('photon_sources', None) - - # TODO: Automatically determine bounding box for each cell - if bounding_boxes is None and self.method == 'cell-based': - raise ValueError("bounding_boxes must be provided for cell-based " - "R2S calculations.") - - output_dir = Path(output_dir) - output_dir.mkdir(parents=True, exist_ok=True) - - # Determine and validate time indices before preparing source data. - n_steps = len(self.results['depletion_results']) - implicit_time_indices = time_indices is None - if time_indices is None: - time_indices = list(range(n_steps)) - else: - time_indices = list(time_indices) - if not time_indices: - raise ValueError('time_indices must contain at least one index') - - normalized_indices = [] - for index in time_indices: - if isinstance(index, bool) or not isinstance(index, Integral): - raise TypeError('time_indices must contain only integers') - index = int(index) - if index < -n_steps or index >= n_steps: - raise IndexError( - f'Photon time index {index} is out of range for ' - f'{n_steps} depletion results') - normalized_index = index % n_steps - normalized_indices.append(normalized_index) - - # Remove duplicates while preserving order - time_indices = list(dict.fromkeys(normalized_indices)) - - # Check whether the photon model is different - neutron_univ = self.neutron_model.geometry.root_universe - photon_univ = self.photon_model.geometry.root_universe - different_photon_model = (neutron_univ != photon_univ) - - # For mesh-based calculations, compute material volume fractions for the - # photon model if it is different from the neutron model to account for - # potential material changes - if self.method == 'mesh-based' and different_photon_model: - if mat_vol_kwargs is None: - mat_vol_kwargs = {} - photon_mmv_list = [] - for i, mesh in enumerate(self.domains): - photon_mmv = comm.bcast( - mesh.material_volumes(self.photon_model, **mat_vol_kwargs)) - photon_mmv_list.append(photon_mmv) - - # Save photon MMV results to file - if comm.rank == 0: - photon_mmv.save( - output_dir / f'mesh_material_volumes_{i}.npz') - - self.results['mesh_material_volumes_photon'] = photon_mmv_list - - # Get dictionary of cells in the photon model - if different_photon_model: - photon_cells = self.photon_model.geometry.get_all_cells() - - # Determine eligible work items upfront (independent of time index). - if self.method == 'mesh-based': - work_items = self._get_mesh_work_items() - else: - work_items = [] - for cell, original_mat in zip( - self.domains, self.results['activation_materials']): - if different_photon_model: - if cell.id not in photon_cells or \ - cell.fill.id != photon_cells[cell.id].fill.id: - continue - work_items.append((cell, original_mat, bounding_boxes[cell.id])) - - # Create decay photon sources for each time index - photon_sources = { - time_index: self._create_photon_sources(time_index, work_items) - for time_index in time_indices - } - - # Determine if any times have no decay photon sources. If the user - # didn't specify any specific time indices, remove those times from the - # photon_sources dictionary. If the user did specify time indices, raise - # an error if any of those times have no decay photon sources. - empty_indices = [ - time_index for time_index, sources in photon_sources.items() - if not sources - ] - if implicit_time_indices: - for time_index in empty_indices: - del photon_sources[time_index] - if not photon_sources: - raise RuntimeError( - 'No decay photon sources were found at any depletion time') - elif empty_indices: - indices = ', '.join(str(index) for index in empty_indices) - raise RuntimeError( - f'No decay photon source was found for requested time ' - f'indices: {indices}') - - self.results['photon_sources'] = photon_sources - - def step4_photon_transport( - self, - output_dir: PathLike = 'photon_transport', - run_kwargs: dict | None = None, - by_parent_nuclide: bool = False, - ): - """Run photon transport using prepared decay photon sources. - - This step runs a photon transport calculation for each source list - created by :meth:`step3_photon_source`. It will populate the - 'photon_tallies' key in the results dictionary. - - Parameters - ---------- - output_dir : PathLike, optional - Path to directory where photon transport outputs will be saved. - run_kwargs : dict, optional - Additional keyword arguments passed to :meth:`openmc.Model.run`. - By default, output is disabled. - by_parent_nuclide : bool, optional - Whether to score photon tallies separately for each parent - radionuclide. A :class:`~openmc.ParentNuclideFilter` is added to - tallies that do not already contain one, with bins determined from - the prepared decay photon sources. - """ - if 'photon_sources' not in self.results: - raise RuntimeError( - 'Photon sources must be created with step3_photon_source ' - 'before running photon transport.') - photon_sources = self.results['photon_sources'] - if not photon_sources: - raise RuntimeError( - 'No decay photon sources are available for transport') - - if by_parent_nuclide: - radionuclides = sorted({ - nuclide - for sources in photon_sources.values() - for source in sources - for nuclide in source.energy.nuclides - }) - - if radionuclides: - parent_filter = openmc.ParentNuclideFilter(radionuclides) - for tally in self.photon_model.tallies: - if not tally.contains_filter(openmc.ParentNuclideFilter): - tally.filters.append(parent_filter) - - if run_kwargs is None: - run_kwargs = {} - run_kwargs.setdefault('output', False) - - output_dir = Path(output_dir) - output_dir.mkdir(parents=True, exist_ok=True) - - if comm.rank == 0: - tally_ids = [tally.id for tally in self.photon_model.tallies] - with open(output_dir / 'tally_ids.json', 'w') as f: - json.dump(tally_ids, f) - - self.results['photon_tallies'] = {} - - # Ensure photon transport is enabled in settings. - self.photon_model.settings.photon_transport = True - - for time_index, sources in photon_sources.items(): - self.photon_model.settings.source = sources - - # Run photon transport calculation - photon_dir = Path(output_dir) / f'time_{time_index}' - with TemporarySession(self.photon_model, cwd=photon_dir): - statepoint_path = self.photon_model.run(**run_kwargs) - - # Store tally results - with openmc.StatePoint(statepoint_path) as sp: - self.results['photon_tallies'][time_index] = [ - sp.tallies[tally.id] for tally in self.photon_model.tallies - ] - - def _get_mesh_work_items(self): - """Enumerate mesh-based work items across all meshes. - - Returns a list of (index_mat, mat_id, bbox) tuples for each eligible - mesh element--material combination, where index_mat is the index into - the activation materials list, mat_id is the material ID, and bbox is - the bounding box for that mesh element--material combination. - - Returns - ------- - list of tuple - Each tuple is (index_mat, mat_id, bbox). - """ - mmv_list = self.results['mesh_material_volumes'] - photon_mmv_list = self.results.get('mesh_material_volumes_photon') - - work_items = [] - index_mat = 0 - for mesh_idx, mat_vols in enumerate(mmv_list): - photon_mat_vols = photon_mmv_list[mesh_idx] \ - if photon_mmv_list is not None else None - - n_elements = mat_vols.num_elements - for index_elem in range(n_elements): - if photon_mat_vols is not None: - photon_materials = { - mat_id - for mat_id, _ in photon_mat_vols.by_element(index_elem) - if mat_id is not None - } - - for mat_id, _, bbox in mat_vols.by_element( - index_elem, include_bboxes=True): - if mat_id is None: - continue - if photon_mat_vols is not None \ - and mat_id not in photon_materials: - index_mat += 1 - continue - work_items.append((index_mat, mat_id, bbox)) - index_mat += 1 - - return work_items - - def _create_photon_sources(self, time_index, work_items): - """Create decay photon sources for a set of regions. - - Builds :class:`openmc.IndependentSource` objects with - :class:`openmc.stats.DecaySpectrum` energy distributions that will be - serialized to XML and resolved against the depletion chain by the C++ - solver. - - Parameters - ---------- - time_index : int - Index into depletion results. - work_items : list of tuple - For mesh-based: list of (index_mat, mat_id, bbox). - For cell-based: list of (cell, original_mat, bbox). - - Returns - ------- - list of openmc.IndependentSource - Photon sources for each activated region. - """ - step_result = self.results['depletion_results'][time_index] - materials = self.results['activation_materials'] - mesh_based = self.method == 'mesh-based' - if mesh_based: - mat_dict = self.neutron_model._get_all_materials() - - sources = [] - for item in work_items: - if mesh_based: - index_mat, domain_id, bbox = item - original_mat = materials[index_mat] - domain = mat_dict[domain_id] - else: - cell, original_mat, bbox = item - domain = cell - - activated_mat = step_result.get_material(str(original_mat.id)) - nuclides = activated_mat.get_nuclide_atom_densities() - if not nuclides: - continue - - # Eliminate nuclides with zero density - nuclides = {nuclide: density for nuclide, density in nuclides.items() - if density > 0} - - energy = openmc.stats.DecaySpectrum(nuclides, activated_mat.volume) - energy.clip(inplace=True) - if not energy.nuclides: - continue - - sources.append(openmc.IndependentSource( - space=openmc.stats.Box(bbox.lower_left, bbox.upper_right), - energy=energy, - particle='photon', - constraints={'domains': [domain]}, - )) - - return sources - - def load_results(self, path: PathLike): - """Load results from a previous R2S calculation. - - Parameters - ---------- - path : PathLike - Path to the directory containing the R2S calculation results. - - """ - path = Path(path) - - # Load neutron transport results - neutron_dir = path / 'neutron_transport' - if self.method == 'mesh-based': - mmv_files = sorted(neutron_dir.glob('mesh_material_volumes*.npz'), - key=lambda p: int(p.stem.split('_')[-1]) - if p.stem[-1].isdigit() else 0) - if mmv_files: - self.results['mesh_material_volumes'] = [ - openmc.MeshMaterialVolumes.from_npz(f) for f in mmv_files - ] - fluxes_file = neutron_dir / 'fluxes.npy' - if fluxes_file.exists(): - self.results['fluxes'] = list(np.load(fluxes_file, allow_pickle=True)) - micros_dict = read_microxs_hdf5(neutron_dir / 'micros.h5') - self.results['micros'] = [ - micros_dict[f'domain_{i}'] for i in range(len(micros_dict)) - ] - - # Load activation results - activation_dir = path / 'activation' - activation_results = activation_dir / 'depletion_results.h5' - if activation_results.exists(): - self.results['depletion_results'] = Results(activation_results) - activation_mats_file = activation_dir / 'materials.xml' - if activation_mats_file.exists(): - self.results['activation_materials'] = \ - openmc.Materials.from_xml(activation_mats_file) - - # Load photon transport results - photon_dir = path / 'photon_transport' - - # Load photon mesh material volumes if they exist (for mesh-based calculations) - if self.method == 'mesh-based': - photon_mmv_files = sorted( - photon_dir.glob('mesh_material_volumes*.npz'), - key=lambda p: int(p.stem.split('_')[-1]) - if p.stem[-1].isdigit() else 0) - if photon_mmv_files: - self.results['mesh_material_volumes_photon'] = [ - openmc.MeshMaterialVolumes.from_npz(f) - for f in photon_mmv_files - ] - - # Load tally IDs from JSON file - tally_ids_path = photon_dir / 'tally_ids.json' - if tally_ids_path.exists(): - with tally_ids_path.open('r') as f: - tally_ids = json.load(f) - self.results['photon_tallies'] = {} - - # For each photon transport calc, load the statepoint and get the - # tally results based on tally_ids - for time_dir in photon_dir.glob('time_*'): - time_index = int(time_dir.name.split('_')[1]) - for sp_path in time_dir.glob('statepoint.*.h5'): - with openmc.StatePoint(sp_path) as sp: - self.results['photon_tallies'][time_index] = [ - sp.tallies[tally_id] for tally_id in tally_ids - ] diff --git a/openmc/deplete/reaction_rates.py b/openmc/deplete/reaction_rates.py index 714d9048b..4aaf829a9 100644 --- a/openmc/deplete/reaction_rates.py +++ b/openmc/deplete/reaction_rates.py @@ -2,6 +2,7 @@ An ndarray to store reaction rates with string, integer, or slice indexing. """ +from typing import Dict import numpy as np @@ -52,9 +53,9 @@ class ReactionRates(np.ndarray): # the __array_finalize__ method (discussed here: # https://docs.scipy.org/doc/numpy/user/basics.subclassing.html) - index_mat: dict[str, int] - index_nuc: dict[str, int] - index_rx: dict[str, int] + index_mat: Dict[str, int] + index_nuc: Dict[str, int] + index_rx: Dict[str, int] def __new__(cls, local_mats, nuclides, reactions, from_results=False): # Create appropriately-sized zeroed-out ndarray diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index 0cf0141d2..2e537a1b7 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -1,17 +1,13 @@ -from __future__ import annotations - import numbers import bisect import math -from collections.abc import Iterable -from typing import Literal +import typing # required to prevent typing.Union namespace overwriting Union +from typing import Iterable, Optional, Tuple, List from warnings import warn import h5py import numpy as np -import openmc -from .chain import Chain, _get_chain from .stepresult import StepResult, VERSION_RESULTS import openmc.checkvalue as cv from openmc.data import atomic_mass, AVOGADRO @@ -22,11 +18,6 @@ from openmc.checkvalue import PathLike __all__ = ["Results", "ResultsList"] -_SECONDS_PER_MINUTE = 60 -_SECONDS_PER_HOUR = 60*60 -_SECONDS_PER_DAY = 24*60*60 -_SECONDS_PER_JULIAN_YEAR = 365.25*24*60*60 # 365.25 due to the leap year - def _get_time_as(seconds: float, units: str) -> float: """Converts the time in seconds to time in different units @@ -41,13 +32,13 @@ def _get_time_as(seconds: float, units: str) -> float: """ if units == "a": - return seconds / _SECONDS_PER_JULIAN_YEAR + return seconds / (60 * 60 * 24 * 365.25) # 365.25 due to the leap year if units == "d": - return seconds / _SECONDS_PER_DAY + return seconds / (60 * 60 * 24) elif units == "h": - return seconds / _SECONDS_PER_HOUR + return seconds / (60 * 60) elif units == "min": - return seconds / _SECONDS_PER_MINUTE + return seconds / 60 else: return seconds @@ -81,6 +72,7 @@ class Results(list): data.append(StepResult.from_hdf5(fh, i)) super().__init__(data) + @classmethod def from_hdf5(cls, filename: PathLike): """Load in depletion results from a previous file @@ -105,12 +97,11 @@ class Results(list): def get_activity( self, - mat: Material | str, + mat: typing.Union[Material, str], units: str = "Bq/cm3", by_nuclide: bool = False, - volume: float | None = None, - chain_file: Literal[False] | None | PathLike | Chain = None - ) -> tuple[np.ndarray, np.ndarray | list[dict]]: + volume: Optional[float] = None + ) -> Tuple[np.ndarray, typing.Union[np.ndarray, List[dict]]]: """Get activity of material over time. .. versionadded:: 0.14.0 @@ -119,33 +110,24 @@ class Results(list): ---------- mat : openmc.Material, str Material object or material id to evaluate - units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3'} + units : {'Bq', 'Bq/g', 'Bq/cm3'} Specifies the type of activity to return, options include total - activity [Bq], specific [Bq/g, Bq/kg] or volumetric activity - [Bq/cm3]. + activity [Bq], specific [Bq/g] or volumetric activity [Bq/cm3]. by_nuclide : bool Specifies if the activity should be returned for the material as a whole or per nuclide. Default is False. volume : float, optional Volume of the material. If not passed, defaults to using the :attr:`Material.volume` attribute. - chain_file : False, None, PathLike, or openmc.deplete.Chain, optional - Source of half-life values. If ``False``, only ENDF/B-VIII.0 data is - used. If ``None``, the chain specified by - ``openmc.config['chain_file']`` is used when available. If a path or - :class:`openmc.deplete.Chain` is given, that chain is used. For - ``None`` or an explicit chain, nuclides absent from the chain fall - back to ENDF/B-VIII.0 data. - - .. versionadded:: 0.15.4 Returns ------- times : numpy.ndarray Array of times in [s] activities : numpy.ndarray or List[dict] - Array of total activities if by_nuclide = False (default) or list of - dictionaries of activities by nuclide if by_nuclide = True. + Array of total activities if by_nuclide = False (default) + or list of dictionaries of activities by nuclide if + by_nuclide = True. """ if isinstance(mat, Material): @@ -155,13 +137,6 @@ class Results(list): else: raise TypeError('mat should be of type openmc.Material or str') - if chain_file is not False: - if chain_file is None: - if openmc.config.get('chain_file') is not None: - chain_file = _get_chain(None) - else: - chain_file = _get_chain(chain_file) - times = np.empty_like(self, dtype=float) if by_nuclide: activities = [None] * len(self) @@ -171,18 +146,17 @@ class Results(list): # Evaluate activity for each depletion time for i, result in enumerate(self): times[i] = result.time[0] - activities[i] = result.get_material(mat_id).get_activity( - units, by_nuclide, volume, chain_file=chain_file) + activities[i] = result.get_material(mat_id).get_activity(units, by_nuclide, volume) return times, activities def get_atoms( self, - mat: Material | str, + mat: typing.Union[Material, str], nuc: str, nuc_units: str = "atoms", time_units: str = "s" - ) -> tuple[np.ndarray, np.ndarray]: + ) -> Tuple[np.ndarray, np.ndarray]: """Get number of nuclides over time from a single material Parameters @@ -226,7 +200,7 @@ class Results(list): # Evaluate value in each region for i, result in enumerate(self): times[i] = result.time[0] - concentrations[i] = result[mat_id, nuc] + concentrations[i] = result[0, mat_id, nuc] # Unit conversions times = _get_time_as(times, time_units) @@ -241,11 +215,11 @@ class Results(list): def get_decay_heat( self, - mat: Material | str, + mat: typing.Union[Material, str], units: str = "W", by_nuclide: bool = False, - volume: float | None = None - ) -> tuple[np.ndarray, np.ndarray | list[dict]]: + volume: Optional[float] = None + ) -> Tuple[np.ndarray, typing.Union[np.ndarray, List[dict]]]: """Get decay heat of material over time. .. versionadded:: 0.14.0 @@ -254,9 +228,9 @@ class Results(list): ---------- mat : openmc.Material, str Material object or material id to evaluate. - units : {'W', 'W/g', 'W/kg', 'W/cm3', 'W/m3'} + units : {'W', 'W/g', 'W/cm3'} Specifies the units of decay heat to return. Options include total - heat [W], specific [W/g, W/kg] or volumetric heat [W/cm3]. + heat [W], specific [W/g] or volumetric heat [W/cm3]. by_nuclide : bool Specifies if the decay heat should be returned for the material as a whole or per nuclide. Default is False. @@ -268,7 +242,7 @@ class Results(list): ------- times : numpy.ndarray Array of times in [s] - decay_heat : numpy.ndarray or list[dict] + decay_heat : numpy.ndarray or List[dict] Array of total decay heat values if by_nuclide = False (default) or list of dictionaries of decay heat values by nuclide if by_nuclide = True. @@ -296,11 +270,11 @@ class Results(list): return times, decay_heat def get_mass(self, - mat: Material | str, + mat: typing.Union[Material, str], nuc: str, mass_units: str = "g", time_units: str = "s" - ) -> tuple[np.ndarray, np.ndarray]: + ) -> Tuple[np.ndarray, np.ndarray]: """Get mass of nuclides over time from a single material .. versionadded:: 0.14.0 @@ -350,10 +324,10 @@ class Results(list): def get_reaction_rate( self, - mat: Material | str, + mat: typing.Union[Material, str], nuc: str, rx: str - ) -> tuple[np.ndarray, np.ndarray]: + ) -> Tuple[np.ndarray, np.ndarray]: """Get reaction rate in a single material/nuclide over time Parameters @@ -386,11 +360,11 @@ class Results(list): # Evaluate value in each region for i, result in enumerate(self): times[i] = result.time[0] - rates[i] = result.rates.get(mat_id, nuc, rx) * result[mat, nuc] + rates[i] = result.rates[0].get(mat_id, nuc, rx) * result[0, mat, nuc] return times, rates - def get_keff(self, time_units: str = 's') -> tuple[np.ndarray, np.ndarray]: + def get_keff(self, time_units: str = 's') -> Tuple[np.ndarray, np.ndarray]: """Evaluates the eigenvalue from a results list. .. versionadded:: 0.13.1 @@ -420,13 +394,13 @@ class Results(list): # Get time/eigenvalue at each point for i, result in enumerate(self): times[i] = result.time[0] - eigenvalues[i] = result.k + eigenvalues[i] = result.k[0] # Convert time units if necessary times = _get_time_as(times, time_units) return times, eigenvalues - def get_eigenvalue(self, time_units: str = 's') -> tuple[np.ndarray, np.ndarray]: + def get_eigenvalue(self, time_units: str = 's') -> Tuple[np.ndarray, np.ndarray]: warn("The get_eigenvalue(...) function has been renamed get_keff and " "will be removed in a future version of OpenMC.", FutureWarning) return self.get_keff(time_units) @@ -487,26 +461,6 @@ class Results(list): return _get_time_as(times, time_units) - def get_source_rates(self) -> np.ndarray: - """ - .. versionadded:: 0.15.1 - - Returns - ------- - numpy.ndarray - 1-D vector of source rates at each point in the depletion simulation - with the units originally defined by the user. - - """ - # Results duplicate the final source rate at the final simulation time - source_rates = np.fromiter( - (r.source_rate for r in self), - dtype=self[0].source_rate.dtype, - count=len(self)-1, - ) - - return source_rates - def get_step_where( self, time, time_units: str = "d", atol: float = 1e-6, rtol: float = 1e-3 ) -> int: @@ -572,7 +526,7 @@ class Results(list): def export_to_materials( self, burnup_index: int, - nuc_with_data: Iterable[str] | None = None, + nuc_with_data: Optional[Iterable[str]] = None, path: PathLike = 'materials.xml' ) -> Materials: """Return openmc.Materials object based on results at a given step @@ -653,7 +607,7 @@ class Results(list): for nuc in result.index_nuc: if nuc not in available_cross_sections: continue - atoms = result[mat_id, nuc] + atoms = result[0, mat_id, nuc] if atoms > 0.0: atoms_per_barn_cm = 1e-24 * atoms / mat.volume mat.remove_nuclide(nuc) # Replace if it's there diff --git a/openmc/deplete/stepresult.py b/openmc/deplete/stepresult.py index 9f638a058..9cf33898f 100644 --- a/openmc/deplete/stepresult.py +++ b/openmc/deplete/stepresult.py @@ -12,12 +12,11 @@ import h5py import numpy as np import openmc +from openmc.mpi import comm, MPI from openmc.checkvalue import PathLike -from openmc.mpi import MPI, comm - from .reaction_rates import ReactionRates -VERSION_RESULTS = (1, 3) +VERSION_RESULTS = (1, 1) __all__ = ["StepResult"] @@ -31,8 +30,8 @@ class StepResult: Attributes ---------- - k : tuple of (float, float) - Eigenvalue and uncertainty at end of step. + k : list of (float, float) + Eigenvalue and uncertainty for each substep. time : list of float Time at beginning, end of step, in seconds. source_rate : float @@ -41,8 +40,8 @@ class StepResult: Number of mats. n_nuc : int Number of nuclides. - rates : ReactionRates - The reaction rates at end of step. + rates : list of ReactionRates + The reaction rates for each substep. volume : dict of str to float Dictionary mapping mat id to volume. index_mat : dict of str to int @@ -53,13 +52,13 @@ class StepResult: A dictionary mapping mat ID as string to global index. n_hdf5_mats : int Number of materials in entire geometry. + n_stages : int + Number of stages in simulation. data : numpy.ndarray - Atom quantity, stored by mat, then by nuclide. + Atom quantity, stored by stage, mat, then by nuclide. proc_time : int Average time spent depleting a material across all materials and processes - keff_search_root : float - The root returned by the keff search control. """ def __init__(self): @@ -73,10 +72,8 @@ class StepResult: self.index_mat = None self.index_nuc = None self.mat_to_hdf5_ind = None - self.name_list = None self.data = None - self.keff_search_root = None def __repr__(self): t = self.time[0] @@ -89,17 +86,17 @@ class StepResult: Parameters ---------- pos : tuple - A two-length tuple containing a mat index and a nuc - index. Both can be integers or slices, or can be + A three-length tuple containing a stage index, mat index and a nuc + index. All can be integers or slices. The second two can be strings corresponding to their respective dictionary. Returns ------- float - The atoms for mat, nuc + The atoms for stage, mat, nuc """ - mat, nuc = pos + stage, mat, nuc = pos if isinstance(mat, openmc.Material): mat = str(mat.id) if isinstance(mat, str): @@ -107,7 +104,7 @@ class StepResult: if isinstance(nuc, str): nuc = self.index_nuc[nuc] - return self.data[mat, nuc] + return self.data[stage, mat, nuc] def __setitem__(self, pos, val): """Sets an item from results. @@ -115,21 +112,21 @@ class StepResult: Parameters ---------- pos : tuple - A two-length tuple containing a mat index and a nuc - index. Both can be integers or slices, or can be + A three-length tuple containing a stage index, mat index and a nuc + index. All can be integers or slices. The second two can be strings corresponding to their respective dictionary. val : float The value to set data to. """ - mat, nuc = pos + stage, mat, nuc = pos if isinstance(mat, str): mat = self.index_mat[mat] if isinstance(nuc, str): nuc = self.index_nuc[nuc] - self.data[mat, nuc] = val + self.data[stage, mat, nuc] = val @property def n_mat(self): @@ -143,7 +140,11 @@ class StepResult: def n_hdf5_mats(self): return len(self.mat_to_hdf5_ind) - def allocate(self, volume, nuc_list, burn_list, full_burn_list, name_list=None): + @property + def n_stages(self): + return self.data.shape[0] + + def allocate(self, volume, nuc_list, burn_list, full_burn_list, stages): """Allocate memory for depletion step data Parameters @@ -156,18 +157,17 @@ class StepResult: A list of all mat IDs to be burned. Used for sorting the simulation. full_burn_list : list of str List of all burnable material IDs - name_list : list of str, optional - Material names corresponding to materials in full_burn_list + stages : int + Number of stages in simulation. """ self.volume = copy.deepcopy(volume) self.index_nuc = {nuc: i for i, nuc in enumerate(nuc_list)} self.index_mat = {mat: i for i, mat in enumerate(burn_list)} self.mat_to_hdf5_ind = {mat: i for i, mat in enumerate(full_burn_list)} - self.mat_to_name = dict(zip(full_burn_list, name_list)) if name_list is not None else {} # Create storage array - self.data = np.zeros((self.n_mat, self.n_nuc)) + self.data = np.zeros((stages, self.n_mat, self.n_nuc)) def distribute(self, local_materials, ranges): """Create a new object containing data for distributed materials @@ -192,23 +192,23 @@ class StepResult: # Direct transfer direct_attrs = ("time", "k", "source_rate", "index_nuc", - "mat_to_hdf5_ind", "mat_to_name", "proc_time") + "mat_to_hdf5_ind", "proc_time") for attr in direct_attrs: setattr(new, attr, getattr(self, attr)) # Get applicable slice of data - new.data = self.data[ranges] - new.rates = self.rates[ranges] + new.data = self.data[:, ranges] + new.rates = [r[ranges] for r in self.rates] return new - def get_material(self, mat_id: str | int) -> openmc.Material: + def get_material(self, mat_id): """Return material object for given depleted composition .. versionadded:: 0.13.2 Parameters ---------- - mat_id : str or int - Material ID as a string or integer + mat_id : str + Material ID as a string Returns ------- @@ -221,9 +221,6 @@ class StepResult: If specified material ID is not found in the StepResult """ - # Coerce to str since internal dictionaries use str keys - mat_id = str(mat_id) - with warnings.catch_warnings(): warnings.simplefilter('ignore', openmc.IDWarning) material = openmc.Material(material_id=int(mat_id)) @@ -234,18 +231,16 @@ class StepResult: f'mat_id {mat_id} not found in StepResult. Available mat_id ' f'values are {list(self.volume.keys())}' ) from e - if mat_id in self.mat_to_name: - material.name = self.mat_to_name[mat_id] for nuc, _ in sorted(self.index_nuc.items(), key=lambda x: x[1]): - atoms = self[mat_id, nuc] - if atoms <= 0.0: + atoms = self[0, mat_id, nuc] + if atoms < 0.0: continue atom_per_bcm = atoms / vol * 1e-24 material.add_nuclide(nuc, atom_per_bcm) material.volume = vol return material - def export_to_hdf5(self, filename, step, write_rates: bool = False): + def export_to_hdf5(self, filename, step): """Export results to an HDF5 file Parameters @@ -254,8 +249,6 @@ class StepResult: The filename to write to step : int What step is this? - write_rates : bool, optional - Whether to include reaction rate datasets in the results file. """ # Write new file if first time step, else add to existing file @@ -266,8 +259,7 @@ class StepResult: kwargs['driver'] = 'mpio' kwargs['comm'] = comm with h5py.File(filename, **kwargs) as handle: - self._to_hdf5(handle, step, parallel=True, - write_rates=write_rates) + self._to_hdf5(handle, step, parallel=True) else: # Gather results at root process all_results = comm.gather(self) @@ -276,18 +268,15 @@ class StepResult: if comm.rank == 0: with h5py.File(filename, **kwargs) as handle: for res in all_results: - res._to_hdf5(handle, step, parallel=False, - write_rates=write_rates) + res._to_hdf5(handle, step, parallel=False) - def _write_hdf5_metadata(self, handle, write_rates): + def _write_hdf5_metadata(self, handle): """Writes result metadata in HDF5 file Parameters ---------- handle : h5py.File or h5py.Group An hdf5 file or group type to store this in. - write_rates : bool - Whether reaction rate datasets are being written. """ # Create and save the 5 dictionaries: @@ -295,8 +284,8 @@ class StepResult: # self.index_mat -> self.volume (TODO: support for changing volumes) # self.index_nuc # reactions - # self.rates.index_nuc (can be different from above, above is superset) - # self.rates.index_rx + # self.rates[0].index_nuc (can be different from above, above is superset) + # self.rates[0].index_rx # these are shared by every step of the simulation, and should be deduplicated. # Store concentration mat and nuclide dictionaries (along with volumes) @@ -306,19 +295,13 @@ class StepResult: mat_list = sorted(self.mat_to_hdf5_ind, key=int) nuc_list = sorted(self.index_nuc) - - include_rates = ( - write_rates - and self.rates is not None - and bool(self.rates.index_nuc) - and bool(self.rates.index_rx) - ) - rxn_list = sorted(self.rates.index_rx) if include_rates else [] + rxn_list = sorted(self.rates[0].index_rx) n_mats = self.n_hdf5_mats n_nuc_number = len(nuc_list) - n_nuc_rxn = len(self.rates.index_nuc) if include_rates else 0 + n_nuc_rxn = len(self.rates[0].index_nuc) n_rxn = len(rxn_list) + n_stages = self.n_stages mat_group = handle.create_group("materials") @@ -326,56 +309,47 @@ class StepResult: mat_single_group = mat_group.create_group(mat) mat_single_group.attrs["index"] = self.mat_to_hdf5_ind[mat] mat_single_group.attrs["volume"] = self.volume[mat] - if mat in self.mat_to_name: - mat_single_group.attrs["name"] = self.mat_to_name[mat] nuc_group = handle.create_group("nuclides") for nuc in nuc_list: nuc_single_group = nuc_group.create_group(nuc) nuc_single_group.attrs["atom number index"] = self.index_nuc[nuc] - if include_rates and nuc in self.rates.index_nuc: - nuc_single_group.attrs["reaction rate index"] = ( - self.rates.index_nuc[nuc]) + if nuc in self.rates[0].index_nuc: + nuc_single_group.attrs["reaction rate index"] = self.rates[0].index_nuc[nuc] - if include_rates: - rxn_group = handle.create_group("reactions") + rxn_group = handle.create_group("reactions") - for rxn in rxn_list: - rxn_single_group = rxn_group.create_group(rxn) - rxn_single_group.attrs["index"] = ( - self.rates.index_rx[rxn]) + for rxn in rxn_list: + rxn_single_group = rxn_group.create_group(rxn) + rxn_single_group.attrs["index"] = self.rates[0].index_rx[rxn] # Construct array storage - handle.create_dataset("number", (1, n_mats, n_nuc_number), - maxshape=(None, n_mats, n_nuc_number), - chunks=True, + handle.create_dataset("number", (1, n_stages, n_mats, n_nuc_number), + maxshape=(None, n_stages, n_mats, n_nuc_number), + chunks=(1, 1, n_mats, n_nuc_number), dtype='float64') - if include_rates and n_nuc_rxn > 0 and n_rxn > 0: - handle.create_dataset( - "reaction rates", (1, n_mats, n_nuc_rxn, n_rxn), - maxshape=(None, n_mats, n_nuc_rxn, n_rxn), - chunks=True, dtype='float64') + if n_nuc_rxn > 0 and n_rxn > 0: + handle.create_dataset("reaction rates", (1, n_stages, n_mats, n_nuc_rxn, n_rxn), + maxshape=(None, n_stages, n_mats, n_nuc_rxn, n_rxn), + chunks=(1, 1, n_mats, n_nuc_rxn, n_rxn), + dtype='float64') - handle.create_dataset("eigenvalues", (1, 2), - maxshape=(None, 2), dtype='float64') + handle.create_dataset("eigenvalues", (1, n_stages, 2), + maxshape=(None, n_stages, 2), dtype='float64') handle.create_dataset("time", (1, 2), maxshape=(None, 2), dtype='float64') - handle.create_dataset("source_rate", (1,), maxshape=(None,), + handle.create_dataset("source_rate", (1, n_stages), maxshape=(None, n_stages), dtype='float64') handle.create_dataset( "depletion time", (1,), maxshape=(None,), dtype="float64") - handle.create_dataset( - "keff_search_root", (1,), maxshape=(None,), - dtype="float64") - - def _to_hdf5(self, handle, index, parallel=False, write_rates: bool = False): + def _to_hdf5(self, handle, index, parallel=False): """Converts results object into an hdf5 object. Parameters @@ -386,14 +360,12 @@ class StepResult: What step is this? parallel : bool Being called with parallel HDF5? - write_rates : bool, optional - Whether reaction rate datasets are being written. """ if "/number" not in handle: if parallel: comm.barrier() - self._write_hdf5_metadata(handle, write_rates) + self._write_hdf5_metadata(handle) if parallel: comm.barrier() @@ -407,7 +379,6 @@ class StepResult: time_dset = handle["/time"] source_rate_dset = handle["/source_rate"] proc_time_dset = handle["/depletion time"] - keff_search_root_dset = handle["/keff_search_root"] # Get number of results stored number_shape = list(number_dset.shape) @@ -441,30 +412,29 @@ class StepResult: proc_shape[0] = new_shape proc_time_dset.resize(proc_shape) - keff_search_root_shape = list(keff_search_root_dset.shape) - keff_search_root_shape[0] = new_shape - keff_search_root_dset.resize(keff_search_root_shape) - # If nothing to write, just return if len(self.index_mat) == 0: return # Add data + # Note, for the last step, self.n_stages = 1, even if n_stages != 1. + n_stages = self.n_stages inds = [self.mat_to_hdf5_ind[mat] for mat in self.index_mat] low = min(inds) high = max(inds) - number_dset[index, low:high+1] = self.data - if has_reactions: - rxn_dset[index, low:high+1] = self.rates + for i in range(n_stages): + number_dset[index, i, low:high+1] = self.data[i] + if has_reactions: + rxn_dset[index, i, low:high+1] = self.rates[i] + if comm.rank == 0: + eigenvalues_dset[index, i] = self.k[i] if comm.rank == 0: - eigenvalues_dset[index] = self.k time_dset[index] = self.time source_rate_dset[index] = self.source_rate if self.proc_time is not None: proc_time_dset[index] = ( self.proc_time / (comm.size * self.n_hdf5_mats) ) - keff_search_root_dset[index] = self.keff_search_root @classmethod def from_hdf5(cls, handle, step): @@ -489,34 +459,16 @@ class StepResult: # Older versions used "power" instead of "source_rate" source_rate_dset = handle["/power"] - # Check if this is an old format file (with stages dimension) or new format - # Old format: number has shape (n_steps, n_stages, n_mats, n_nucs) - # New format: number has shape (n_steps, n_mats, n_nucs) - has_stages = len(number_dset.shape) == 4 - - if has_stages: - # Old format - extract data from first stage (index 0) - results.data = number_dset[step, 0, :, :] - results.k = eigenvalues_dset[step, 0, :] - # source_rate had shape (n_steps, n_stages) in old format - results.source_rate = source_rate_dset[step, 0] - else: - # New format - no stages dimension - results.data = number_dset[step, :, :] - results.k = eigenvalues_dset[step, :] - results.source_rate = source_rate_dset[step] - + results.data = number_dset[step, :, :, :] + results.k = eigenvalues_dset[step, :] results.time = time_dset[step, :] + results.source_rate = source_rate_dset[step, 0] if "depletion time" in handle: proc_time_dset = handle["/depletion time"] if step < proc_time_dset.shape[0]: results.proc_time = proc_time_dset[step] - if "keff_search_root" in handle: - keff_search_root_dset = handle["/keff_search_root"] - results.keff_search_root = keff_search_root_dset[step] - if results.proc_time is None: results.proc_time = np.array([np.nan]) @@ -524,7 +476,6 @@ class StepResult: results.volume = {} results.index_mat = {} results.index_nuc = {} - results.mat_to_name = {} rxn_nuc_to_ind = {} rxn_to_ind = {} @@ -534,8 +485,6 @@ class StepResult: results.volume[mat] = vol results.index_mat[mat] = ind - if "name" in mat_handle.attrs: - results.mat_to_name[mat] = mat_handle.attrs["name"] for nuc, nuc_handle in handle["/nuclides"].items(): ind_atom = nuc_handle.attrs["atom number index"] @@ -544,46 +493,33 @@ class StepResult: if "reaction rate index" in nuc_handle.attrs: rxn_nuc_to_ind[nuc] = nuc_handle.attrs["reaction rate index"] - if "reactions" in handle: - for rxn, rxn_handle in handle["/reactions"].items(): - rxn_to_ind[rxn] = rxn_handle.attrs["index"] + for rxn, rxn_handle in handle["/reactions"].items(): + rxn_to_ind[rxn] = rxn_handle.attrs["index"] - # Reconstruct reaction rates - rate = ReactionRates(results.index_mat, rxn_nuc_to_ind, rxn_to_ind, True) - if "reaction rates" in handle: - if has_stages: - # Old format: (n_steps, n_stages, n_mats, n_nucs, n_rxns) - rate[:] = handle["/reaction rates"][step, 0, :, :, :] - else: - # New format: (n_steps, n_mats, n_nucs, n_rxns) - rate[:] = handle["/reaction rates"][step, :, :, :] - results.rates = rate + results.rates = [] + # Reconstruct reactions + for i in range(results.n_stages): + rate = ReactionRates(results.index_mat, rxn_nuc_to_ind, rxn_to_ind, True) + + if "reaction rates" in handle: + rate[:] = handle["/reaction rates"][step, i, :, :, :] + results.rates.append(rate) return results @staticmethod - def save( - op, - x, - op_results, - t, - source_rate, - step_ind, - proc_time=None, - write_rates: bool = False, - keff_search_root=None, - path: PathLike = "depletion_results.h5" - ): + def save(op, x, op_results, t, source_rate, step_ind, proc_time=None, + path: PathLike = "depletion_results.h5"): """Creates and writes depletion results to disk Parameters ---------- op : openmc.deplete.abc.TransportOperator The operator used to generate these results. - x : numpy.array - End-of-step concentrations for each material - op_results : openmc.deplete.OperatorResult - Result of applying transport operator at end of step + x : list of list of numpy.array + The prior x vectors. Indexed [i][cell] using the above equation. + op_results : list of openmc.deplete.OperatorResult + Results of applying transport operator t : list of float Time indices. source_rate : float @@ -594,42 +530,44 @@ class StepResult: Total process time spent depleting materials. This may be process-dependent and will be reduced across MPI processes. - write_rates : bool, optional - Whether reaction rates should be written to the results file. - keff_search_root : float - The root returned by the keff search control. + path : PathLike Path to file to write. Defaults to 'depletion_results.h5'. .. versionadded:: 0.14.0 """ # Get indexing terms - vol_dict, nuc_list, burn_list, full_burn_list, name_list = op.get_results_info() + vol_dict, nuc_list, burn_list, full_burn_list = op.get_results_info() + + stages = len(x) # Create results results = StepResult() - results.allocate(vol_dict, nuc_list, burn_list, full_burn_list, name_list) + results.allocate(vol_dict, nuc_list, burn_list, full_burn_list, stages) n_mat = len(burn_list) - for mat_i in range(n_mat): - results[mat_i, :] = x[mat_i] + for i in range(stages): + for mat_i in range(n_mat): + results[i, mat_i, :] = x[i][mat_i] - if isinstance(op_results.k, type(None)): - results.k = (None, None) - else: - results.k = (op_results.k.nominal_value, op_results.k.std_dev) - results.rates = op_results.rates + ks = [] + for r in op_results: + if isinstance(r.k, type(None)): + ks += [(None, None)] + else: + ks += [(r.k.nominal_value, r.k.std_dev)] + results.k = ks + results.rates = [r.rates for r in op_results] results.time = t results.source_rate = source_rate results.proc_time = proc_time if results.proc_time is not None: results.proc_time = comm.reduce(proc_time, op=MPI.SUM) - results.keff_search_root = keff_search_root if not Path(path).is_file(): Path(path).parent.mkdir(parents=True, exist_ok=True) - results.export_to_hdf5(path, step_ind, write_rates) + results.export_to_hdf5(path, step_ind) def transfer_volumes(self, model): """Transfers volumes from depletion results to geometry diff --git a/openmc/deplete/transfer_rates.py b/openmc/deplete/transfer_rates.py index ea9fc9185..01c9b2e35 100644 --- a/openmc/deplete/transfer_rates.py +++ b/openmc/deplete/transfer_rates.py @@ -1,31 +1,31 @@ -from collections import defaultdict from numbers import Real import re -from typing import Sequence - -import numpy as np from openmc.checkvalue import check_type, check_value from openmc import Material -from openmc.data import ELEMENT_SYMBOL, isotopes, AVOGADRO, atomic_mass -from .results import _SECONDS_PER_MINUTE, _SECONDS_PER_HOUR, \ - _SECONDS_PER_DAY, _SECONDS_PER_JULIAN_YEAR +from openmc.data import ELEMENT_SYMBOL +class TransferRates: + """Class for defining continuous removals and feeds. -class ExternalRates: - """External rates class for defining addition terms of depletion equation. + Molten Salt Reactors (MSRs) benefit from continuous reprocessing, + which removes fission products and feeds fresh fuel into the system. MSRs + inspired the development of this class. - .. versionadded:: 0.15.3 + An instance of this class can be passed directly to an instance of one of + the :class:`openmc.deplete.Integrator` classes. + + .. versionadded:: 0.14.0 Parameters ---------- operator : openmc.TransportOperator Depletion operator - materials : openmc.Materials - OpenMC materials. - number_of_timesteps : int - Total number of depletion timesteps + model : openmc.Model + OpenMC model containing materials and geometry. If using + :class:`openmc.deplete.CoupledOperator`, the model must also contain + a :class:`opnemc.Settings` object. Attributes ---------- @@ -33,26 +33,22 @@ class ExternalRates: All burnable material IDs. local_mats : list of str All burnable material IDs being managed by a single process - number_of_timesteps : int - Total number of depletion timesteps - external_rates : dict of str to dict - Container of timesteps, external rates, components (elements and/or - nuclides) and optionally destination material - external_timesteps : list of int - Container of all timesteps indeces with an external rate defined. + transfer_rates : dict of str to dict + Container of transfer rates, components (elements and/or nuclides) and + destination material + index_transfer : Set of pair of str + Pair of strings needed to build final matrix (destination_material, mat) """ - def __init__(self, operator, materials, number_of_timesteps): + def __init__(self, operator, model): - self.materials = materials + self.materials = model.materials self.burnable_mats = operator.burnable_mats self.local_mats = operator.local_mats - self.number_of_timesteps = number_of_timesteps #initialize transfer rates container dict - self.external_rates = {mat: defaultdict(list) for mat in self.burnable_mats} - self.external_timesteps = [] - self.redox = {} + self.transfer_rates = {mat: {} for mat in self.burnable_mats} + self.index_transfer = set() def _get_material_id(self, val): """Helper method for getting material id from Material obj or name. @@ -75,7 +71,7 @@ class ExternalRates: check_value('Material ID', str(val), self.burnable_mats) else: check_value('Material name', val, - [mat.name for mat in self.materials if mat.depletable]) + [mat.name for mat in self.materials if mat.depletable]) val = [mat.id for mat in self.materials if mat.name == val][0] elif isinstance(val, int): @@ -83,13 +79,7 @@ class ExternalRates: return str(val) - def get_external_rate( - self, - material: str | int | Material, - component: str, - timestep: int, - destination_material: str | int | Material | None = None - ): + def get_transfer_rate(self, material, component): """Return transfer rate for given material and element. Parameters @@ -98,114 +88,62 @@ class ExternalRates: Depletable material component : str Element or nuclide to get transfer rate value - timestep : int - Current timestep index - destination_material : openmc.Material or str or int, Optional - Destination material to where nuclides get fed Returns ------- - external_rate : list of floats - External rate values + transfer_rate : list of floats + Transfer rate values """ material_id = self._get_material_id(material) check_type('component', component, str) - if destination_material is not None: - dest_mat_id = self._get_material_id(destination_material) - return [i[1] for i in self.external_rates[material_id][component] - if timestep in i[0] and dest_mat_id == i[2]] - else: - return [i[1] for i in self.external_rates[material_id][component] - if timestep in i[0]] + return [i[0] for i in self.transfer_rates[material_id][component]] - def get_components(self, material, timestep, destination_material=None): - """Extract removing elements and/or nuclides for a given material at a - given timestep + def get_destination_material(self, material, component): + """Return destination material for given material and + component, if defined. Parameters ---------- material : openmc.Material or str or int Depletable material - timestep : int - Current timestep index - destination_material : openmc.Material or str or int, Optional - Destination material to where nuclides get fed + component : str + Element or nuclide that gets transferred to another material. Returns ------- - components : list - List of elements or nuclides with external rates set at a given - timestep + destination_material_id : list of str + Depletable material ID to where the element or nuclide gets + transferred """ material_id = self._get_material_id(material) - if destination_material is not None: - dest_mat_id = self._get_material_id(destination_material) + check_type('component', component, str) + if component in self.transfer_rates[material_id]: + return [i[1] for i in self.transfer_rates[material_id][component]] else: - dest_mat_id = None + return [] - all_components = [] - if material_id in self.external_rates: - mat_components = self.external_rates[material_id] + def get_components(self, material): + """Extract removing elements and/or nuclides for a given material - for component in mat_components: - if dest_mat_id: - # check for both timestep and destination material ids - if np.isin(timestep, [val[0] for val in mat_components[component]]) and \ - np.isin(dest_mat_id, [val[2] for val in mat_components[component]]): - all_components.append(component) - else: - # check only for timesteps - if np.isin(timestep, [val[0] for val in mat_components[component]]): - all_components.append(component) - return all_components + Parameters + ---------- + material : openmc.Material or str or int + Depletable material + Returns + ------- + elements : list + List of elements and nuclides where transfer rates exist -class TransferRates(ExternalRates): - """Class for defining continuous removals and feeds. - - Molten Salt Reactors (MSRs) benefit from continuous reprocessing, - which removes fission products and feeds fresh fuel into the system. MSRs - inspired the development of this class. - - An instance of this class can be passed directly to an instance of one of - the :class:`openmc.deplete.Integrator` classes. - - .. versionadded:: 0.14.0 - - Parameters - ---------- - operator : openmc.TransportOperator - Depletion operator - materials : openmc.Materials - OpenMC materials. - number_of_timesteps : int - Total number of depletion timesteps - - Attributes - ---------- - burnable_mats : list of str - All burnable material IDs. - local_mats : list of str - All burnable material IDs being managed by a single process - external_rates : dict of str to dict - Container of timesteps, transfer rates, components (elements and/or - nuclides) and destination material - external_timesteps : list of int - Container of all timesteps indeces with an external rate defined. - index_transfer : Set of pair of str - Pair of strings needed to build final matrix (destination_material, mat) - """ - - def __init__(self, operator, materials, number_of_timesteps): - super().__init__(operator, materials, number_of_timesteps) - self.index_transfer = defaultdict(list) - self.chain_nuclides = [nuc.name for nuc in operator.chain.nuclides] + """ + material_id = self._get_material_id(material) + if material_id in self.transfer_rates: + return self.transfer_rates[material_id].keys() def set_transfer_rate(self, material, components, transfer_rate, - transfer_rate_units='1/s', timesteps=None, - destination_material=None): + transfer_rate_units='1/s', destination_material=None): """Set element and/or nuclide transfer rates in a depletable material. Parameters @@ -219,14 +157,11 @@ class TransferRates(ExternalRates): transfer_rate : float Rate at which elements and/or nuclides are transferred. A positive or negative value corresponds to a removal or feed rate, respectively. + destination_material : openmc.Material or str or int, Optional + Destination material to where nuclides get fed. transfer_rate_units : {'1/s', '1/min', '1/h', '1/d', '1/a'} Units for values specified in the transfer_rate argument. 's' for seconds, 'min' for minutes, 'h' for hours, 'a' for Julian years. - timesteps : list of int, Optional - List of timestep indeces where to set transfer rates. - Default to None means the transfer rate is set for all timesteps. - destination_material : openmc.Material or str or int, Optional - Destination material to where nuclides get fed. """ material_id = self._get_material_id(material) @@ -248,25 +183,19 @@ class TransferRates(ExternalRates): if transfer_rate_units in ('1/s', '1/sec'): unit_conv = 1 elif transfer_rate_units in ('1/min', '1/minute'): - unit_conv = _SECONDS_PER_MINUTE + unit_conv = 60 elif transfer_rate_units in ('1/h', '1/hr', '1/hour'): - unit_conv = _SECONDS_PER_HOUR + unit_conv = 60*60 elif transfer_rate_units in ('1/d', '1/day'): - unit_conv = _SECONDS_PER_DAY + unit_conv = 24*60*60 elif transfer_rate_units in ('1/a', '1/year'): - unit_conv = _SECONDS_PER_JULIAN_YEAR + unit_conv = 365.25*24*60*60 else: - raise ValueError(f'Invalid transfer rate unit "{transfer_rate_units}"') - - if timesteps is not None: - for timestep in timesteps: - check_value('timestep', timestep, range(self.number_of_timesteps)) - timesteps = np.array(timesteps) - else: - timesteps = np.arange(self.number_of_timesteps) + raise ValueError('Invalid transfer rate unit ' + f'"{transfer_rate_units}"') for component in components: - current_components = self.external_rates[material_id].keys() + current_components = self.transfer_rates[material_id].keys() split_component = re.split(r'\d+', component) element = split_component[0] if element not in ELEMENT_SYMBOL.values(): @@ -290,184 +219,11 @@ class TransferRates(ExternalRates): f'where element {element} already has ' 'a transfer rate.') - self.external_rates[material_id][component].append( - (timesteps, transfer_rate/unit_conv, destination_material_id)) - - if destination_material_id is not None: - for timestep in timesteps: - self.index_transfer[timestep].append( - (destination_material_id, material_id)) - - self.external_timesteps = np.unique(np.concatenate( - [self.external_timesteps, timesteps])) - - def set_redox(self, material, buffer, oxidation_states, timesteps=None): - """Add redox control to depletable material. - - Parameters - ---------- - material : openmc.Material or str or int - Depletable material - buffer : dict - Dictionary of buffer nuclides used to maintain redox balance. - Keys are nuclide names (strings) and values are their respective - fractions (float) that collectively sum to 1. - oxidation_states : dict - User-defined oxidation states for elements. - Keys are element symbols (e.g., 'H', 'He'), and values are their - corresponding oxidation states as integers (e.g., +1, 0). - timesteps : list of int, optional - List of timestep indices where to set external source rates. - Defaults to None, which means the external source rate is set for - all timesteps. - - """ - material_id = self._get_material_id(material) - if timesteps is not None: - for timestep in timesteps: - check_value('timestep', timestep, range(self.number_of_timesteps)) - timesteps = np.array(timesteps) - else: - timesteps = np.arange(self.number_of_timesteps) - #Check nuclides in buffer exist - for nuc in buffer: - if nuc not in self.chain_nuclides: - raise ValueError(f'{nuc} is not a valid nuclide.') - # Checks element in oxidation states exist - for elm in oxidation_states: - if elm not in ELEMENT_SYMBOL.values(): - raise ValueError(f'{elm} is not a valid element.') - - self.redox[material_id] = (buffer, oxidation_states) - self.external_timesteps = np.unique(np.concatenate( - [self.external_timesteps, timesteps])) - -class ExternalSourceRates(ExternalRates): - """Class for defining external source rates. - - An instance of this class can be passed directly to an instance of one of - the :class:`openmc.deplete.Integrator` classes. - - .. versionadded:: 0.15.3 - - Parameters - ---------- - operator : openmc.TransportOperator - Depletion operator - materials : openmc.Materials - OpenMC materials. - number_of_timesteps : int - Total number of depletion timesteps - - Attributes - ---------- - burnable_mats : list of str - All burnable material IDs. - local_mats : list of str - All burnable material IDs being managed by a single process - external_timesteps : list of int - Container of all timesteps indeces with an external rate defined. - external_rates : dict of str to dict - Container of timesteps external source rates, and components - (elements and/or nuclides) - """ - - def reformat_nuclide_vectors(self, vectors): - """Remove last element of nuclide vector that was added for handling - external source rates by the depletion solver. - - Parameters - ---------- - vectors : list of array - List of nuclides vector to reformat - - """ - for mat_index, i in enumerate(self.local_mats): - if self.external_rates[i]: - vectors[mat_index] = vectors[mat_index][:-1] - - def set_external_source_rate( - self, - material: str | int | Material, - composition: dict[str, float], - rate: float, - rate_units: str = 'g/s', - timesteps: Sequence[int] | None = None - ): - """Set element and/or nuclide composition vector external source rates - to a depletable material. - - Parameters - ---------- - material : openmc.Material or str or int - Depletable material - composition : dict of str to float - External source rate composition vector, where key can be an element - or a nuclide and value the corresponding weight percent. - rate : float - External source rate in units of mass per time. A positive or - negative value corresponds to a feed or removal rate, respectively. - rate_units : {'g/s', 'g/min', 'g/h', 'g/d', 'g/a'} - Units for values specified in the `rate` argument. 's' for seconds, - 'min' for minutes, 'h' for hours, 'a' for Julian years. - timesteps : list of int, optional - List of timestep indices where to set external source rates. Default - to None, which means the external source rate is set for all - timesteps. - - """ - - material_id = self._get_material_id(material) - check_type('rate', rate, Real) - check_type('composition', composition, dict, str) - - if rate_units in ('g/s', 'g/sec'): - unit_conv = 1 - elif rate_units in ('g/min', 'g/minute'): - unit_conv = _SECONDS_PER_MINUTE - elif rate_units in ('g/h', 'g/hr', 'g/hour'): - unit_conv = _SECONDS_PER_HOUR - elif rate_units in ('g/d', 'g/day'): - unit_conv = _SECONDS_PER_DAY - elif rate_units in ('g/a', 'g/year'): - unit_conv = _SECONDS_PER_JULIAN_YEAR - else: - raise ValueError(f'Invalid external source rate unit "{rate_units}"') - - if timesteps is not None: - for timestep in timesteps: - check_value('timestep', timestep, range(self.number_of_timesteps)) - timesteps = np.asarray(timesteps) - else: - timesteps = np.arange(self.number_of_timesteps) - - components = composition.keys() - percents = composition.values() - norm_percents = [float(i) / sum(percents) for i in percents] - - atoms_per_nuc = {} - for component, percent in zip(components, norm_percents): - split_component = re.split(r'\d+', component) - element = split_component[0] - if element not in ELEMENT_SYMBOL.values(): - raise ValueError(f'{component} is not a valid nuclide or element.') - - if len(split_component) == 1: - if not isotopes(component): - raise ValueError(f'Cannot add element {component} ' - 'as it is not naturally abundant. ' - 'Specify a nuclide vector instead.') - for nuc, frac in isotopes(component): - atoms_per_nuc[nuc] = (rate / atomic_mass(nuc) * AVOGADRO * - frac * percent / unit_conv) - + if component in self.transfer_rates[material_id]: + self.transfer_rates[material_id][component].append( + (transfer_rate / unit_conv, destination_material_id)) else: - atoms_per_nuc[component] = (rate / atomic_mass(component) * - AVOGADRO * percent / unit_conv) - - for nuc, val in atoms_per_nuc.items(): - self.external_rates[material_id][nuc].append((timesteps, val, None)) - - self.external_timesteps = np.unique(np.concatenate( - [self.external_timesteps, timesteps] - )) + self.transfer_rates[material_id][component] = [ + (transfer_rate / unit_conv, destination_material_id)] + if destination_material_id is not None: + self.index_transfer.add((destination_material_id, material_id)) diff --git a/openmc/element.py b/openmc/element.py index 5deede971..082bee522 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -144,7 +144,8 @@ class Element(str): root = tree.getroot() for child in root.findall('library'): nuclide = child.attrib['materials'] - if re.match(r'{}\d+'.format(self), nuclide): + if re.match(r'{}\d+'.format(self), nuclide) and \ + '_m' not in nuclide: library_nuclides.add(nuclide) # Get a set of the mutual and absent nuclides. Convert to lists @@ -184,8 +185,8 @@ class Element(str): for nuclide in absent_nuclides: if nuclide in ['O17', 'O18'] and 'O16' in mutual_nuclides: abundances['O16'] += NATURAL_ABUNDANCE[nuclide] - elif nuclide == 'Ta180_m1' and 'Ta181' in mutual_nuclides: - abundances['Ta181'] += NATURAL_ABUNDANCE[nuclide] + elif nuclide == 'Ta180' and 'Ta181' in mutual_nuclides: + abundances['Ta181'] += NATURAL_ABUNDANCE[nuclide] elif nuclide == 'W180' and 'W182' in mutual_nuclides: abundances['W182'] += NATURAL_ABUNDANCE[nuclide] else: diff --git a/openmc/examples.py b/openmc/examples.py index 5429a59d4..fc94b8b52 100644 --- a/openmc/examples.py +++ b/openmc/examples.py @@ -3,25 +3,24 @@ from numbers import Integral import numpy as np import openmc +import openmc.model -PINCELL_PITCH = 1.26 # cm -def pwr_pin_cell() -> openmc.Model: +def pwr_pin_cell(): """Create a PWR pin-cell model. This model is a single fuel pin with 2.4 w/o enriched UO2 corresponding to a beginning-of-cycle condition and borated water. The specifications are from - the `BEAVRS `_ benchmark. Note that - the number of particles/batches is initially set very low for testing - purposes. + the `BEAVRS `_ benchmark. Note that the + number of particles/batches is initially set very low for testing purposes. Returns ------- - model : openmc.Model + model : openmc.model.Model A PWR pin-cell model """ - model = openmc.Model() + model = openmc.model.Model() # Define materials. fuel = openmc.Material(name='UO2 (2.4%)') @@ -51,7 +50,7 @@ def pwr_pin_cell() -> openmc.Model: model.materials = (fuel, clad, hot_water) # Instantiate ZCylinder surfaces - pitch = PINCELL_PITCH + pitch = 1.26 fuel_or = openmc.ZCylinder(x0=0, y0=0, r=0.39218, name='Fuel OR') clad_or = openmc.ZCylinder(x0=0, y0=0, r=0.45720, name='Clad OR') left = openmc.XPlane(x0=-pitch/2, name='left', boundary_type='reflective') @@ -78,12 +77,11 @@ def pwr_pin_cell() -> openmc.Model: model.settings.inactive = 5 model.settings.particles = 100 model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box([-pitch/2, -pitch/2, -1], - [pitch/2, pitch/2, 1]), + space=openmc.stats.Box([-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1]), constraints={'fissionable': True} ) - plot = openmc.SlicePlot.from_geometry(model.geometry) + plot = openmc.Plot.from_geometry(model.geometry) plot.pixels = (300, 300) plot.color_by = 'material' model.plots.append(plot) @@ -91,7 +89,7 @@ def pwr_pin_cell() -> openmc.Model: return model -def pwr_core() -> openmc.Model: +def pwr_core(): """Create a PWR full-core model. This model is the OECD/NEA Monte Carlo Performance benchmark which is a @@ -101,11 +99,11 @@ def pwr_core() -> openmc.Model: Returns ------- - model : openmc.Model + model : openmc.model.Model Full-core PWR model """ - model = openmc.Model() + model = openmc.model.Model() # Define materials. fuel = openmc.Material(1, name='UOX fuel') @@ -150,7 +148,7 @@ def pwr_core() -> openmc.Model: rpv_steel.add_nuclide('Ni60', 0.0026776, 'wo') rpv_steel.add_nuclide('Mn55', 0.01, 'wo') rpv_steel.add_nuclide('Cr52', 0.002092475, 'wo') - rpv_steel.add_element('C', 0.0025, 'wo') + rpv_steel.add_nuclide('C0', 0.0025, 'wo') rpv_steel.add_nuclide('Cu63', 0.0013696, 'wo') lower_rad_ref = openmc.Material(6, name='Lower radial reflector') @@ -168,8 +166,7 @@ def pwr_core() -> openmc.Model: lower_rad_ref.add_nuclide('Cr52', 0.145407678031, 'wo') lower_rad_ref.add_s_alpha_beta('c_H_in_H2O') - upper_rad_ref = openmc.Material( - 7, name='Upper radial reflector / Top plate region') + upper_rad_ref = openmc.Material(7, name='Upper radial reflector / Top plate region') upper_rad_ref.set_density('g/cm3', 4.28) upper_rad_ref.add_nuclide('H1', 0.0086117, 'wo') upper_rad_ref.add_nuclide('O16', 0.0683369, 'wo') @@ -316,17 +313,15 @@ def pwr_core() -> openmc.Model: 11, 11, 11, 11, 11, 13, 13, 14, 14, 14]) # Define fuel lattices. - l100 = openmc.RectLattice( - name='Fuel assembly (lower half)', lattice_id=100) + l100 = openmc.RectLattice(name='Fuel assembly (lower half)', lattice_id=100) l100.lower_left = (-10.71, -10.71) - l100.pitch = (PINCELL_PITCH, PINCELL_PITCH) + l100.pitch = (1.26, 1.26) l100.universes = np.tile(fuel_cold, (17, 17)) l100.universes[tube_x, tube_y] = tube_cold - l101 = openmc.RectLattice( - name='Fuel assembly (upper half)', lattice_id=101) + l101 = openmc.RectLattice(name='Fuel assembly (upper half)', lattice_id=101) l101.lower_left = (-10.71, -10.71) - l101.pitch = (PINCELL_PITCH, PINCELL_PITCH) + l101.pitch = (1.26, 1.26) l101.universes = np.tile(fuel_hot, (17, 17)) l101.universes[tube_x, tube_y] = tube_hot @@ -350,7 +345,7 @@ def pwr_core() -> openmc.Model: # Define core lattices l200 = openmc.RectLattice(name='Core lattice (lower half)', lattice_id=200) l200.lower_left = (-224.91, -224.91) - l200.pitch = (17 * PINCELL_PITCH, 17 * PINCELL_PITCH) + l200.pitch = (21.42, 21.42) l200.universes = [ [fa_cw]*21, [fa_cw]*21, @@ -376,7 +371,7 @@ def pwr_core() -> openmc.Model: l201 = openmc.RectLattice(name='Core lattice (lower half)', lattice_id=201) l201.lower_left = (-224.91, -224.91) - l201.pitch = (17 * PINCELL_PITCH, 17 * PINCELL_PITCH) + l201.pitch = (21.42, 21.42) l201.universes = [ [fa_hw]*21, [fa_hw]*21, @@ -410,14 +405,10 @@ def pwr_core() -> openmc.Model: c6 = openmc.Cell(cell_id=6, fill=top_fa, region=-s5 & +s36 & -s37) c7 = openmc.Cell(cell_id=7, fill=top_nozzle, region=-s5 & +s37 & -s38) c8 = openmc.Cell(cell_id=8, fill=upper_rad_ref, region=-s7 & +s38 & -s39) - c9 = openmc.Cell(cell_id=9, fill=bot_nozzle, - region=+s6 & -s7 & +s32 & -s38) - c10 = openmc.Cell(cell_id=10, fill=rpv_steel, - region=+s7 & -s8 & +s31 & -s39) - c11 = openmc.Cell(cell_id=11, fill=lower_rad_ref, - region=+s5 & -s6 & +s32 & -s34) - c12 = openmc.Cell(cell_id=12, fill=upper_rad_ref, - region=+s5 & -s6 & +s36 & -s38) + c9 = openmc.Cell(cell_id=9, fill=bot_nozzle, region=+s6 & -s7 & +s32 & -s38) + c10 = openmc.Cell(cell_id=10, fill=rpv_steel, region=+s7 & -s8 & +s31 & -s39) + c11 = openmc.Cell(cell_id=11, fill=lower_rad_ref, region=+s5 & -s6 & +s32 & -s34) + c12 = openmc.Cell(cell_id=12, fill=upper_rad_ref, region=+s5 & -s6 & +s36 & -s38) root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12)) # Assign root universe to geometry @@ -429,7 +420,7 @@ def pwr_core() -> openmc.Model: model.settings.source = openmc.IndependentSource(space=openmc.stats.Box( [-160, -160, -183], [160, 160, 183])) - plot = openmc.SlicePlot() + plot = openmc.Plot() plot.origin = (125, 125, 0) plot.width = (250, 250) plot.pixels = (3000, 3000) @@ -439,22 +430,22 @@ def pwr_core() -> openmc.Model: return model -def pwr_assembly() -> openmc.Model: +def pwr_assembly(): """Create a PWR assembly model. This model is a reflected 17x17 fuel assembly from the the `BEAVRS - `_ benchmark. The fuel is 2.4 w/o + `_ benchmark. The fuel is 2.4 w/o enriched UO2 corresponding to a beginning-of-cycle condition. Note that the number of particles/batches is initially set very low for testing purposes. Returns ------- - model : openmc.Model + model : openmc.model.Model A PWR assembly model """ - model = openmc.Model() + model = openmc.model.Model() # Define materials. fuel = openmc.Material(name='Fuel') @@ -488,7 +479,7 @@ def pwr_assembly() -> openmc.Model: clad_or = openmc.ZCylinder(x0=0, y0=0, r=0.45720, name='Clad OR') # Create boundary planes to surround the geometry - pitch = 17 * PINCELL_PITCH + pitch = 21.42 min_x = openmc.XPlane(x0=-pitch/2, boundary_type='reflective') max_x = openmc.XPlane(x0=+pitch/2, boundary_type='reflective') min_y = openmc.YPlane(y0=-pitch/2, boundary_type='reflective') @@ -498,10 +489,10 @@ def pwr_assembly() -> openmc.Model: fuel_pin_universe = openmc.Universe(name='Fuel Pin') fuel_cell = openmc.Cell(name='fuel', fill=fuel, region=-fuel_or) clad_cell = openmc.Cell(name='clad', fill=clad, region=+fuel_or & -clad_or) - hot_water_cell = openmc.Cell( - name='hot water', fill=hot_water, region=+clad_or) + hot_water_cell = openmc.Cell(name='hot water', fill=hot_water, region=+clad_or) fuel_pin_universe.add_cells([fuel_cell, clad_cell, hot_water_cell]) + # Create a control rod guide tube universe guide_tube_universe = openmc.Universe(name='Guide Tube') gt_inner_cell = openmc.Cell(name='guide tube inner water', fill=hot_water, @@ -514,7 +505,7 @@ def pwr_assembly() -> openmc.Model: # Create fuel assembly Lattice assembly = openmc.RectLattice(name='Fuel Assembly') - assembly.pitch = (PINCELL_PITCH, PINCELL_PITCH) + assembly.pitch = (pitch/17, pitch/17) assembly.lower_left = (-pitch/2, -pitch/2) # Create array indices for guide tube locations in lattice @@ -539,12 +530,11 @@ def pwr_assembly() -> openmc.Model: model.settings.inactive = 5 model.settings.particles = 100 model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box([-pitch/2, -pitch/2, -1], - [pitch/2, pitch/2, 1]), + space=openmc.stats.Box([-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1]), constraints={'fissionable': True} ) - plot = openmc.SlicePlot() + plot = openmc.Plot() plot.origin = (0.0, 0.0, 0) plot.width = (21.42, 21.42) plot.pixels = (300, 300) @@ -554,7 +544,7 @@ def pwr_assembly() -> openmc.Model: return model -def slab_mg(num_regions=1, mat_names=None, mgxslib_name='2g.h5') -> openmc.Model: +def slab_mg(num_regions=1, mat_names=None, mgxslib_name='2g.h5'): """Create a 1D slab model. Parameters @@ -571,7 +561,7 @@ def slab_mg(num_regions=1, mat_names=None, mgxslib_name='2g.h5') -> openmc.Model Returns ------- - model : openmc.Model + model : openmc.model.Model One-group, 1D slab model """ @@ -647,1086 +637,10 @@ def slab_mg(num_regions=1, mat_names=None, mgxslib_name='2g.h5') -> openmc.Model settings_file.output = {'summary': False} - model = openmc.Model() + model = openmc.model.Model() model.geometry = geometry_file model.materials = materials_file model.settings = settings_file model.xs_data = macros return model - - -def _generate_c5g7_materials(second_temp = False) -> openmc.Materials: - """Generate materials utilizing multi-group cross sections based on the - the C5G7 Benchmark. - - Parameters - ---------- - second_temp : bool, optional - Whether or not the cross sections should contain two temperature datapoints. - The first data point is the C5G7 cross sections, which corresponds to a temperature - of 294 K. The second data point is the C5G7 cross sections multiplied by 1/2, - which corresponds to a temperature of 394 K. This temperature dependence is - fictitious; it is used for testing temperature feedback in the random ray solver. - - Returns - ------- - materials : openmc.Materials - Materials object containing UO2 and water materials. - - Data Sources - ------------ - All cross section data are from: - Lewis et al., "Benchmark specification for determinisitc 2D/3D MOX fuel - assembly transport calculations without spatial homogenization" - """ - # Instantiate the energy group data - # MGXS for the UO2 pins. - group_edges = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6] - groups = openmc.mgxs.EnergyGroups(group_edges) - - uo2_total = np.array([0.1779492, 0.3298048, 0.4803882, 0.5543674, 0.3118013, 0.3951678, - 0.5644058]) - uo2_abs = np.array([8.0248e-03, 3.7174e-03, 2.6769e-02, 9.6236e-02, 3.0020e-02, - 1.1126e-01, 2.8278e-01]) - uo2_scatter_matrix = np.array( - [[[0.1275370, 0.0423780, 0.0000094, 0.0000000, 0.0000000, 0.0000000, 0.0000000], - [0.0000000, 0.3244560, 0.0016314, 0.0000000, 0.0000000, 0.0000000, 0.0000000], - [0.0000000, 0.0000000, 0.4509400, 0.0026792, 0.0000000, 0.0000000, 0.0000000], - [0.0000000, 0.0000000, 0.0000000, 0.4525650, 0.0055664, 0.0000000, 0.0000000], - [0.0000000, 0.0000000, 0.0000000, 0.0001253, 0.2714010, 0.0102550, 0.0000000], - [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0012968, 0.2658020, 0.0168090], - [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0085458, 0.2730800]]]) - uo2_scatter_matrix = np.rollaxis(uo2_scatter_matrix, 0, 3) - uo2_fission = np.array([7.21206e-03, 8.19301e-04, 6.45320e-03, 1.85648e-02, 1.78084e-02, - 8.30348e-02, 2.16004e-01]) - uo2_nu_fission = np.array([2.005998e-02, 2.027303e-03, 1.570599e-02, 4.518301e-02, - 4.334208e-02, 2.020901e-01, 5.257105e-01]) - uo2_chi = np.array([5.8791e-01, 4.1176e-01, 3.3906e-04, 1.1761e-07, 0.0000e+00, - 0.0000e+00, 0.0000e+00]) - - # MGXS for the H2O moderator. - h2o_total = np.array([0.15920605, 0.412969593, 0.59030986, 0.58435, 0.718, 1.2544497, - 2.650379]) - h2o_abs = np.array([6.0105e-04, 1.5793e-05, 3.3716e-04, 1.9406e-03, 5.7416e-03, - 1.5001e-02, 3.7239e-02]) - h2o_scatter_matrix = np.array( - [[[0.0444777, 0.1134000, 0.0007235, 0.0000037, 0.0000001, 0.0000000, 0.0000000], - [0.0000000, 0.2823340, 0.1299400, 0.0006234, 0.0000480, 0.0000074, 0.0000010], - [0.0000000, 0.0000000, 0.3452560, 0.2245700, 0.0169990, 0.0026443, 0.0005034], - [0.0000000, 0.0000000, 0.0000000, 0.0910284, 0.4155100, 0.0637320, 0.0121390], - [0.0000000, 0.0000000, 0.0000000, 0.0000714, 0.1391380, 0.5118200, 0.0612290], - [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0022157, 0.6999130, 0.5373200], - [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1324400, 2.4807000]]]) - h2o_scatter_matrix = np.rollaxis(h2o_scatter_matrix, 0, 3) - - # Instantiate the 7-group (C5G7) cross section data - uo2_xsdata = openmc.XSdata('UO2', groups) - uo2_xsdata.order = 0 - uo2_xsdata.set_total( - [0.1779492, 0.3298048, 0.4803882, 0.5543674, 0.3118013, 0.3951678, - 0.5644058]) - uo2_xsdata.set_absorption([8.0248e-03, 3.7174e-03, 2.6769e-02, 9.6236e-02, - 3.0020e-02, 1.1126e-01, 2.8278e-01]) - scatter_matrix = np.array( - [[[0.1275370, 0.0423780, 0.0000094, 0.0000000, 0.0000000, 0.0000000, 0.0000000], - [0.0000000, 0.3244560, 0.0016314, 0.0000000, - 0.0000000, 0.0000000, 0.0000000], - [0.0000000, 0.0000000, 0.4509400, 0.0026792, - 0.0000000, 0.0000000, 0.0000000], - [0.0000000, 0.0000000, 0.0000000, 0.4525650, - 0.0055664, 0.0000000, 0.0000000], - [0.0000000, 0.0000000, 0.0000000, 0.0001253, - 0.2714010, 0.0102550, 0.0000000], - [0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0012968, 0.2658020, 0.0168090], - [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0085458, 0.2730800]]]) - scatter_matrix = np.rollaxis(scatter_matrix, 0, 3) - uo2_xsdata.set_scatter_matrix(scatter_matrix) - uo2_xsdata.set_fission([7.21206e-03, 8.19301e-04, 6.45320e-03, - 1.85648e-02, 1.78084e-02, 8.30348e-02, - 2.16004e-01]) - nu_fission = np.array([2.005998e-02, 2.027303e-03, 1.570599e-02, - 4.518301e-02, 4.334208e-02, 2.020901e-01, - 5.257105e-01]) - uo2_xsdata.set_nu_fission(nu_fission) - uo2_xsdata.set_chi([5.8791e-01, 4.1176e-01, 3.3906e-04, 1.1761e-07, 0.0000e+00, - 0.0000e+00, 0.0000e+00]) - uo2_xsdata.set_total(uo2_total, temperature=294.0) - uo2_xsdata.set_absorption(uo2_abs, temperature=294.0) - uo2_xsdata.set_scatter_matrix(uo2_scatter_matrix, temperature=294.0) - uo2_xsdata.set_fission(uo2_fission, temperature=294.0) - uo2_xsdata.set_nu_fission(uo2_nu_fission, temperature=294.0) - uo2_xsdata.set_chi(uo2_chi, temperature=294.0) - - h2o_xsdata = openmc.XSdata('LWTR', groups) - h2o_xsdata.order = 0 - h2o_xsdata.set_total(h2o_total, temperature=294.0) - h2o_xsdata.set_absorption(h2o_abs, temperature=294.0) - h2o_xsdata.set_scatter_matrix(h2o_scatter_matrix, temperature=294.0) - - # Add the second temperature data point if requested. - if second_temp: - uo2_xsdata.add_temperature(394.0) - uo2_xsdata.set_total(0.5 * uo2_total, temperature=394.0) - uo2_xsdata.set_absorption(0.5 * uo2_abs, temperature=394.0) - uo2_xsdata.set_scatter_matrix(0.5 * uo2_scatter_matrix, temperature=394.0) - uo2_xsdata.set_fission(0.5 * uo2_fission, temperature=394.0) - uo2_xsdata.set_nu_fission(0.5 * uo2_nu_fission, temperature=394.0) - uo2_xsdata.set_chi(uo2_chi, temperature=394.0) - - h2o_xsdata.add_temperature(394.0) - h2o_xsdata.set_total(0.5 * h2o_total, temperature=394.0) - h2o_xsdata.set_absorption(0.5 * h2o_abs, temperature=394.0) - h2o_xsdata.set_scatter_matrix(0.5 * h2o_scatter_matrix, temperature=394.0) - - mg_cross_sections = openmc.MGXSLibrary(groups) - mg_cross_sections.add_xsdatas([uo2_xsdata, h2o_xsdata]) - mg_cross_sections.export_to_hdf5('mgxs.h5') - - ########################################################################### - # Create materials for the problem - - # Instantiate some Materials and register the appropriate macroscopic data - uo2 = openmc.Material(name='UO2 fuel') - uo2.set_density('macro', 1.0) - uo2.add_macroscopic('UO2') - - water = openmc.Material(name='Water') - water.set_density('macro', 1.0) - water.add_macroscopic('LWTR') - - # Instantiate a Materials collection and export to XML - materials = openmc.Materials([uo2, water]) - materials.cross_sections = "mgxs.h5" - return materials - - -def _generate_subdivided_pin_cell(uo2, water) -> openmc.Universe: - """Create a radially and azimuthally subdivided pin cell universe. Helper - function for random_ray_pin_cell() and random_ray_lattice() - - Parameters - ---------- - uo2 : openmc.Material - UO2 material - water : openmc.Material - Water material - - Returns - ------- - pincell : openmc.Universe - Universe containing an unbounded pin cell - - """ - ######################################## - # Define an unbounded pin cell universe - - # Create a surface for the fuel outer radius - fuel_or = openmc.ZCylinder(r=0.54, name='Fuel OR') - inner_ring_a = openmc.ZCylinder(r=0.33, name='inner ring a') - inner_ring_b = openmc.ZCylinder(r=0.45, name='inner ring b') - outer_ring_a = openmc.ZCylinder(r=0.60, name='outer ring a') - outer_ring_b = openmc.ZCylinder(r=0.69, name='outer ring b') - - # Instantiate Cells - fuel_a = openmc.Cell(fill=uo2, region=-inner_ring_a, name='fuel inner a') - fuel_b = openmc.Cell(fill=uo2, region=+inner_ring_a & - - inner_ring_b, name='fuel inner b') - fuel_c = openmc.Cell(fill=uo2, region=+inner_ring_b & - - fuel_or, name='fuel inner c') - moderator_a = openmc.Cell( - fill=water, region=+fuel_or & -outer_ring_a, name='moderator inner a') - moderator_b = openmc.Cell( - fill=water, region=+outer_ring_a & -outer_ring_b, name='moderator outer b') - moderator_c = openmc.Cell( - fill=water, region=+outer_ring_b, name='moderator outer c') - - # Create pin cell universe - pincell_base = openmc.Universe() - - # Register Cells with Universe - pincell_base.add_cells( - [fuel_a, fuel_b, fuel_c, moderator_a, moderator_b, moderator_c]) - - # Create planes for azimuthal sectors - azimuthal_planes = [] - for i in range(8): - angle = 2 * i * openmc.pi / 8 - normal_vector = (-openmc.sin(angle), openmc.cos(angle), 0) - azimuthal_planes.append(openmc.Plane( - a=normal_vector[0], b=normal_vector[1], c=normal_vector[2], d=0)) - - # Create a cell for each azimuthal sector - azimuthal_cells = [] - for i in range(8): - azimuthal_cell = openmc.Cell(name=f'azimuthal_cell_{i}') - azimuthal_cell.fill = pincell_base - azimuthal_cell.region = + \ - azimuthal_planes[i] & -azimuthal_planes[(i+1) % 8] - azimuthal_cells.append(azimuthal_cell) - - # Create a geometry with the azimuthal universes - pincell = openmc.Universe(cells=azimuthal_cells, name='pincell') - - return pincell - - -def random_ray_pin_cell(second_temp = False) -> openmc.Model: - """Create a PWR pin cell example using C5G7 cross section data. - cross section data. - - Parameters - ---------- - second_temp : bool, optional - Whether or not the cross sections should contain two temperature datapoints. - The first data point is the C5G7 cross sections, which corresponds to a temperature - of 294 K. The second data point is the C5G7 cross sections multiplied by 1/2, - which corresponds to a temperature of 3934 K. This temperature dependence is - fictitious; it is used for testing temperature feedback in the random ray solver. - - Returns - ------- - model : openmc.Model - A PWR pin cell model - - """ - model = openmc.Model() - - ########################################################################### - # Create Materials for the problem - materials = _generate_c5g7_materials(second_temp) - uo2 = materials[0] - water = materials[1] - - ########################################################################### - # Define problem geometry - pincell = _generate_subdivided_pin_cell(uo2, water) - - ######################################## - # Define cell containing lattice and other stuff - pitch = PINCELL_PITCH - box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective') - - pincell = openmc.Cell(fill=pincell, region=-box, name='pincell') - - # Create a geometry with the top-level cell - geometry = openmc.Geometry([pincell]) - - ########################################################################### - # Define problem settings - - # Instantiate a Settings object, set all runtime parameters, and export to XML - settings = openmc.Settings() - settings.energy_mode = "multi-group" - settings.batches = 400 - settings.inactive = 200 - settings.particles = 100 - - # Create an initial uniform spatial source distribution over fissionable zones - lower_left = (-pitch / 2, -pitch / 2, -1) - upper_right = (pitch / 2, pitch / 2, 1) - uniform_dist = openmc.stats.Box(lower_left, upper_right) - rr_source = openmc.IndependentSource(space=uniform_dist) - - settings.random_ray['distance_active'] = 100.0 - settings.random_ray['distance_inactive'] = 20.0 - settings.random_ray['ray_source'] = rr_source - settings.random_ray['volume_normalized_flux_tallies'] = True - - ########################################################################### - # Define tallies - # Now use the mesh filter in a tally and indicate what scores are desired - tally = openmc.Tally(name="Pin tally") - tally.scores = ['flux', 'fission', 'nu-fission'] - tally.estimator = 'analog' - - # Instantiate a Tallies collection and export to XML - tallies = openmc.Tallies([tally]) - - ########################################################################### - # Exporting to OpenMC model - ########################################################################### - - model.geometry = geometry - model.materials = materials - model.settings = settings - model.tallies = tallies - return model - - -def random_ray_lattice(second_temp = False) -> openmc.Model: - """Create a 2x2 PWR pin cell asymmetrical lattice example. - - This model is a 2x2 reflective lattice of fuel pins with one of the lattice - locations having just moderator instead of a fuel pin. It uses C5G7 - cross section data. - - Parameters - ---------- - second_temp : bool, optional - Whether or not the cross sections should contain two temperature datapoints. - The first data point is the C5G7 cross sections, which corresponds to a temperature - of 294 K. The second data point is the C5G7 cross sections multiplied by 1/2, - which corresponds to a temperature of 3934 K. This temperature dependence is - fictitious; it is used for testing temperature feedback in the random ray solver. - - Returns - ------- - model : openmc.Model - A PWR 2x2 lattice model - - """ - model = openmc.Model() - - ########################################################################### - # Create Materials for the problem - materials = _generate_c5g7_materials(second_temp) - uo2 = materials[0] - water = materials[1] - - ########################################################################### - # Define problem geometry - pincell = _generate_subdivided_pin_cell(uo2, water) - - ######################################## - # Define a moderator lattice universe - - moderator_infinite = openmc.Cell(name='moderator infinite') - moderator_infinite.fill = water - - mu = openmc.Universe() - mu.add_cells([moderator_infinite]) - - pitch = PINCELL_PITCH - lattice = openmc.RectLattice() - lattice.lower_left = [-pitch/2.0, -pitch/2.0] - lattice.pitch = [pitch/10.0, pitch/10.0] - lattice.universes = np.full((10, 10), mu) - - mod_lattice_cell = openmc.Cell(fill=lattice) - - mod_lattice_uni = openmc.Universe() - - mod_lattice_uni.add_cells([mod_lattice_cell]) - - ######################################## - # Define 2x2 outer lattice - lattice2x2 = openmc.RectLattice() - lattice2x2.lower_left = (-pitch, -pitch) - lattice2x2.pitch = (pitch, pitch) - lattice2x2.universes = [ - [pincell, pincell], - [pincell, mod_lattice_uni] - ] - - ######################################## - # Define cell containing lattice and other stuff - box = openmc.model.RectangularPrism(pitch*2, pitch*2, boundary_type='reflective') - - assembly = openmc.Cell(fill=lattice2x2, region=-box, name='assembly') - - # Create a geometry with the top-level cell - geometry = openmc.Geometry([assembly]) - - ########################################################################### - # Define problem settings - - # Instantiate a Settings object, set all runtime parameters, and export to XML - settings = openmc.Settings() - settings.energy_mode = "multi-group" - settings.batches = 10 - settings.inactive = 5 - settings.particles = 100 - - # Create an initial uniform spatial source distribution over fissionable zones - lower_left = (-pitch, -pitch, -1) - upper_right = (pitch, pitch, 1) - uniform_dist = openmc.stats.Box(lower_left, upper_right) - rr_source = openmc.IndependentSource(space=uniform_dist) - - settings.random_ray['distance_active'] = 100.0 - settings.random_ray['distance_inactive'] = 20.0 - settings.random_ray['ray_source'] = rr_source - settings.random_ray['volume_normalized_flux_tallies'] = True - - ########################################################################### - # Define tallies - - # Create a mesh that will be used for tallying - mesh = openmc.RegularMesh() - mesh.dimension = (2, 2) - mesh.lower_left = (-pitch, -pitch) - mesh.upper_right = (pitch, pitch) - - # Create a mesh filter that can be used in a tally - mesh_filter = openmc.MeshFilter(mesh) - - # Create an energy group filter as well - group_edges = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6] - energy_filter = openmc.EnergyFilter(group_edges) - - # Now use the mesh filter in a tally and indicate what scores are desired - tally = openmc.Tally(name="Mesh tally") - tally.filters = [mesh_filter, energy_filter] - tally.scores = ['flux', 'fission', 'nu-fission'] - tally.estimator = 'analog' - - # Instantiate a Tallies collection and export to XML - tallies = openmc.Tallies([tally]) - - ########################################################################### - # Exporting to OpenMC model - ########################################################################### - - model.geometry = geometry - model.materials = materials - model.settings = settings - model.tallies = tallies - return model - - -def random_ray_three_region_cube() -> openmc.Model: - """Create a three region cube model. - - This is a simple monoenergetic problem of a cube with three concentric cubic - regions. The innermost region is near void (with Sigma_t around 10^-5) and - contains an external isotropic source term, the middle region is void (with - Sigma_t around 10^-4), and the outer region of the cube is an absorber - (with Sigma_t around 1). - - Returns - ------- - model : openmc.Model - A three region cube model - - """ - - model = openmc.Model() - - ########################################################################### - # Helper function creates a 3 region cube with different fills in each region - def fill_cube(N, n_1, n_2, fill_1, fill_2, fill_3): - cube = [[[0 for _ in range(N)] for _ in range(N)] for _ in range(N)] - for i in range(N): - for j in range(N): - for k in range(N): - if i < n_1 and j >= (N-n_1) and k < n_1: - cube[i][j][k] = fill_1 - elif i < n_2 and j >= (N-n_2) and k < n_2: - cube[i][j][k] = fill_2 - else: - cube[i][j][k] = fill_3 - return cube - - ########################################################################### - # Create multigroup data - - # Instantiate the energy group data - ebins = [1e-5, 20.0e6] - groups = openmc.mgxs.EnergyGroups(group_edges=ebins) - - void_sigma_a = 4.0e-6 - void_sigma_s = 3.0e-4 - void_mat_data = openmc.XSdata('void', groups) - void_mat_data.order = 0 - void_mat_data.set_total([void_sigma_a + void_sigma_s]) - void_mat_data.set_absorption([void_sigma_a]) - void_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[void_sigma_s]]]), 0, 3)) - - absorber_sigma_a = 0.75 - absorber_sigma_s = 0.25 - absorber_mat_data = openmc.XSdata('absorber', groups) - absorber_mat_data.order = 0 - absorber_mat_data.set_total([absorber_sigma_a + absorber_sigma_s]) - absorber_mat_data.set_absorption([absorber_sigma_a]) - absorber_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[absorber_sigma_s]]]), 0, 3)) - - multiplier = 0.1 - source_sigma_a = void_sigma_a * multiplier - source_sigma_s = void_sigma_s * multiplier - source_mat_data = openmc.XSdata('source', groups) - source_mat_data.order = 0 - source_mat_data.set_total([source_sigma_a + source_sigma_s]) - source_mat_data.set_absorption([source_sigma_a]) - source_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[source_sigma_s]]]), 0, 3)) - - mg_cross_sections_file = openmc.MGXSLibrary(groups) - mg_cross_sections_file.add_xsdatas( - [source_mat_data, void_mat_data, absorber_mat_data]) - mg_cross_sections_file.export_to_hdf5() - - ########################################################################### - # Create materials for the problem - - # Instantiate some Macroscopic Data - source_data = openmc.Macroscopic('source') - void_data = openmc.Macroscopic('void') - absorber_data = openmc.Macroscopic('absorber') - - # Instantiate some Materials and register the appropriate Macroscopic objects - source_mat = openmc.Material(name='source') - source_mat.set_density('macro', 1.0) - source_mat.add_macroscopic(source_data) - - void_mat = openmc.Material(name='void') - void_mat.set_density('macro', 1.0) - void_mat.add_macroscopic(void_data) - - absorber_mat = openmc.Material(name='absorber') - absorber_mat.set_density('macro', 1.0) - absorber_mat.add_macroscopic(absorber_data) - - # Instantiate a Materials collection and export to XML - materials_file = openmc.Materials([source_mat, void_mat, absorber_mat]) - materials_file.cross_sections = "mgxs.h5" - - ########################################################################### - # Define problem geometry - - source_cell = openmc.Cell(fill=source_mat, name='infinite source region') - void_cell = openmc.Cell(fill=void_mat, name='infinite void region') - absorber_cell = openmc.Cell( - fill=absorber_mat, name='infinite absorber region') - - source_universe = openmc.Universe(name='source universe') - source_universe.add_cells([source_cell]) - - void_universe = openmc.Universe() - void_universe.add_cells([void_cell]) - - absorber_universe = openmc.Universe() - absorber_universe.add_cells([absorber_cell]) - - absorber_width = 30.0 - n_base = 6 - - # This variable can be increased above 1 to refine the FSR mesh resolution further - refinement_level = 2 - - n = n_base * refinement_level - pitch = absorber_width / n - - pattern = fill_cube(n, 1*refinement_level, 5*refinement_level, - source_universe, void_universe, absorber_universe) - - lattice = openmc.RectLattice() - lattice.lower_left = [0.0, 0.0, 0.0] - lattice.pitch = [pitch, pitch, pitch] - lattice.universes = pattern - - lattice_cell = openmc.Cell(fill=lattice) - - lattice_uni = openmc.Universe() - lattice_uni.add_cells([lattice_cell]) - - x_low = openmc.XPlane(x0=0.0, boundary_type='reflective') - x_high = openmc.XPlane(x0=absorber_width, boundary_type='vacuum') - - y_low = openmc.YPlane(y0=0.0, boundary_type='reflective') - y_high = openmc.YPlane(y0=absorber_width, boundary_type='vacuum') - - z_low = openmc.ZPlane(z0=0.0, boundary_type='reflective') - z_high = openmc.ZPlane(z0=absorber_width, boundary_type='vacuum') - - full_domain = openmc.Cell(fill=lattice_uni, region=+x_low & - - x_high & +y_low & -y_high & +z_low & -z_high, name='full domain') - - root = openmc.Universe(name='root universe') - root.add_cell(full_domain) - - # Create a geometry with the two cells and export to XML - geometry = openmc.Geometry(root) - - ########################################################################### - # Define problem settings - - # Instantiate a Settings object, set all runtime parameters, and export to XML - settings = openmc.Settings() - settings.energy_mode = "multi-group" - settings.inactive = 5 - settings.batches = 10 - settings.particles = 90 - settings.run_mode = 'fixed source' - - # Create an initial uniform spatial source for ray integration - lower_left_ray = [0.0, 0.0, 0.0] - upper_right_ray = [absorber_width, absorber_width, absorber_width] - uniform_dist_ray = openmc.stats.Box( - lower_left_ray, upper_right_ray, only_fissionable=False) - rr_source = openmc.IndependentSource(space=uniform_dist_ray) - - settings.random_ray['distance_active'] = 500.0 - settings.random_ray['distance_inactive'] = 100.0 - settings.random_ray['ray_source'] = rr_source - settings.random_ray['volume_normalized_flux_tallies'] = True - - # Create the neutron source in the bottom right of the moderator - # Good - fast group appears largest (besides most thermal) - strengths = [1.0] - midpoints = [100.0] - energy_distribution = openmc.stats.Discrete(x=midpoints, p=strengths) - - source = openmc.IndependentSource(energy=energy_distribution, constraints={ - 'domains': [source_universe]}, strength=3.14) - - settings.source = [source] - - ########################################################################### - # Define tallies - - estimator = 'tracklength' - - absorber_filter = openmc.MaterialFilter(absorber_mat) - absorber_tally = openmc.Tally(name="Absorber Tally") - absorber_tally.filters = [absorber_filter] - absorber_tally.scores = ['flux'] - absorber_tally.estimator = estimator - - void_filter = openmc.MaterialFilter(void_mat) - void_tally = openmc.Tally(name="Void Tally") - void_tally.filters = [void_filter] - void_tally.scores = ['flux'] - void_tally.estimator = estimator - - source_filter = openmc.MaterialFilter(source_mat) - source_tally = openmc.Tally(name="Source Tally") - source_tally.filters = [source_filter] - source_tally.scores = ['flux'] - source_tally.estimator = estimator - - # Instantiate a Tallies collection and export to XML - tallies = openmc.Tallies([source_tally, void_tally, absorber_tally]) - - ########################################################################### - # Assmble Model - - model.geometry = geometry - model.materials = materials_file - model.settings = settings - model.tallies = tallies - - return model - -def random_ray_three_region_cube_with_detectors() -> openmc.Model: - """Create a three region cube model with two external tally regions. - - This is an adaptation of the simple monoenergetic problem of a cube with - three concentric cubic regions. The innermost region is near void (with - Sigma_t around 10^-5) and contains an external isotropic source term, the - middle region is a mild scatterer (with Sigma_t around 10^-3), and the - outer region of the cube is a scatterer and absorber (with Sigma_t around - 1). - - Two cubic "detector" regions are found outside this geometry, one along the - y-axis near z=0, and the other in the upper right corner of the system. - The size of each detector is scaled to be equal to that of the source - region. The model returned by this function contains cell tallies on each - detector. - - Returns - ------- - model : openmc.Model - A three region cube model - - """ - - model = openmc.Model() - - ########################################################################### - # Helper function creates a 3 region cube with different fills in each region - def fill_cube(N, n_1, n_2, fill_1, fill_2, fill_3): - cube = [[[0 for _ in range(N)] for _ in range(N)] for _ in range(N)] - for i in range(N): - for j in range(N): - for k in range(N): - if i < n_1 and j >= (N-n_1) and k < n_1: - cube[i][j][k] = fill_1 - elif i < n_2 and j >= (N-n_2) and k < n_2: - cube[i][j][k] = fill_2 - else: - cube[i][j][k] = fill_3 - return cube - - ########################################################################### - # Create multigroup data - - # Instantiate the energy group data - ebins = [1e-5, 20.0e6] - groups = openmc.mgxs.EnergyGroups(group_edges=ebins) - - cavity_sigma_a = 4.0e-5 - cavity_sigma_s = 3.0e-3 - cavity_mat_data = openmc.XSdata('cavity', groups) - cavity_mat_data.order = 0 - cavity_mat_data.set_total([cavity_sigma_a + cavity_sigma_s]) - cavity_mat_data.set_absorption([cavity_sigma_a]) - cavity_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[cavity_sigma_s]]]), 0, 3)) - - absorber_sigma_a = 0.50 - absorber_sigma_s = 0.50 - absorber_mat_data = openmc.XSdata('absorber', groups) - absorber_mat_data.order = 0 - absorber_mat_data.set_total([absorber_sigma_a + absorber_sigma_s]) - absorber_mat_data.set_absorption([absorber_sigma_a]) - absorber_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[absorber_sigma_s]]]), 0, 3)) - - multiplier = 0.01 - source_sigma_a = cavity_sigma_a * multiplier - source_sigma_s = cavity_sigma_s * multiplier - source_mat_data = openmc.XSdata('source', groups) - source_mat_data.order = 0 - source_mat_data.set_total([source_sigma_a + source_sigma_s]) - source_mat_data.set_absorption([source_sigma_a]) - source_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[source_sigma_s]]]), 0, 3)) - - mg_cross_sections_file = openmc.MGXSLibrary(groups) - mg_cross_sections_file.add_xsdatas( - [source_mat_data, cavity_mat_data, absorber_mat_data]) - mg_cross_sections_file.export_to_hdf5() - - ########################################################################### - # Create materials for the problem - - # Instantiate some Macroscopic Data - source_data = openmc.Macroscopic('source') - cavity_data = openmc.Macroscopic('cavity') - absorber_data = openmc.Macroscopic('absorber') - - # Instantiate some Materials and register the appropriate Macroscopic objects - source_mat = openmc.Material(name='source') - source_mat.set_density('macro', 1.0) - source_mat.add_macroscopic(source_data) - - cavity_mat = openmc.Material(name='cavity') - cavity_mat.set_density('macro', 1.0) - cavity_mat.add_macroscopic(cavity_data) - - absorber_mat = openmc.Material(name='absorber') - absorber_mat.set_density('macro', 1.0) - absorber_mat.add_macroscopic(absorber_data) - - # Instantiate a Materials collection - materials_file = openmc.Materials([source_mat, cavity_mat, absorber_mat]) - materials_file.cross_sections = "mgxs.h5" - - ########################################################################### - # Define problem geometry - - source_cell = openmc.Cell(fill=source_mat, name='infinite source region') - cavity_cell = openmc.Cell(fill=cavity_mat, name='cube cavity region') - absorber_cell = openmc.Cell( - fill=absorber_mat, name='absorber region') - - source_universe = openmc.Universe(name='source universe') - source_universe.add_cells([source_cell]) - - cavity_universe = openmc.Universe() - cavity_universe.add_cells([cavity_cell]) - - absorber_universe = openmc.Universe() - absorber_universe.add_cells([absorber_cell]) - - absorber_width = 30.0 - n_base = 6 - - # This variable can be increased above 1 to refine the FSR mesh resolution further - refinement_level = 2 - - n = n_base * refinement_level - pitch = absorber_width / n - - pattern = fill_cube(n, 1*refinement_level, 5*refinement_level, - source_universe, cavity_universe, absorber_universe) - - lattice = openmc.RectLattice() - lattice.lower_left = [0.0, 0.0, 0.0] - lattice.pitch = [pitch, pitch, pitch] - lattice.universes = pattern - - lattice_cell = openmc.Cell(fill=lattice) - - lattice_uni = openmc.Universe() - lattice_uni.add_cells([lattice_cell]) - - x_low = openmc.XPlane(x0=0.0, boundary_type='reflective') - x_high = openmc.XPlane(x0=absorber_width) - - y_low = openmc.YPlane(y0=0.0, boundary_type='reflective') - y_high = openmc.YPlane(y0=absorber_width) - - z_low = openmc.ZPlane(z0=0.0, boundary_type='reflective') - z_high = openmc.ZPlane(z0=absorber_width) - - cube_domain = openmc.Cell(fill=lattice_uni, region=+x_low & - - x_high & +y_low & -y_high & +z_low & -z_high, name='full domain') - - detect_width = absorber_width / n_base - outer_width = absorber_width + detect_width - - x_outer = openmc.XPlane(x0=outer_width, boundary_type='vacuum') - y_outer = openmc.YPlane(y0=outer_width, boundary_type='vacuum') - z_outer = openmc.ZPlane(z0=outer_width, boundary_type='vacuum') - - detector1_right = openmc.XPlane(x0=detect_width) - detector1_top = openmc.ZPlane(z0=detect_width) - - detector1_region = ( - +x_low & -detector1_right & - +y_high & -y_outer & - +z_low & -detector1_top - ) - detector1 = openmc.Cell( - name='detector 1', - fill=absorber_mat, - region=detector1_region - ) - - detector2_region = ( - +x_high & -x_outer & - +y_high & -y_outer & - +z_high & -z_outer - ) - detector2 = openmc.Cell( - name='detector 2', - fill=absorber_mat, - region=detector2_region - ) - - external_x = ( - +x_high & +y_low & +z_low & -x_outer & - ((-y_outer & -z_high) | (-y_high & +z_high & -z_outer)) - ) - external_y = ( - +y_high & -y_outer & - ( - (+detector1_right & -x_high & +z_low & -z_outer) | - (-detector1_right & +x_low & +detector1_top & -z_outer) | - (+x_high & -x_outer & +z_low & -z_high) - ) - ) - external_z = ( - +x_low & +y_low & +z_high & -z_outer & - ((-y_outer & -x_high) | (-y_high & +x_high & -x_outer)) - ) - external_cell = openmc.Cell(fill=cavity_mat, - region=(external_x | external_y | external_z), - name='outside cube') - - root = openmc.Universe( - name='root universe', - cells=[cube_domain, detector1, detector2, external_cell] - ) - - # Create a geometry with the two cells and export to XML - geometry = openmc.Geometry(root) - - ########################################################################### - # Define problem settings - - # Instantiate a Settings object, set all runtime parameters, and export to XML - settings = openmc.Settings() - settings.energy_mode = "multi-group" - settings.inactive = 5 - settings.batches = 10 - settings.particles = 500 - settings.run_mode = 'fixed source' - - # Create an initial uniform spatial source for ray integration - lower_left_ray = [0.0, 0.0, 0.0] - upper_right_ray = [outer_width, outer_width, outer_width] - uniform_dist_ray = openmc.stats.Box( - lower_left_ray, upper_right_ray, only_fissionable=False) - rr_source = openmc.IndependentSource(space=uniform_dist_ray) - - settings.random_ray['distance_active'] = 800.0 - settings.random_ray['distance_inactive'] = 100.0 - settings.random_ray['ray_source'] = rr_source - settings.random_ray['volume_normalized_flux_tallies'] = True - - # Create a rectilinear source region mesh - sr_mesh = openmc.RegularMesh() - sr_mesh.dimension = (14, 14, 14) - sr_mesh.lower_left = (0.0, 0.0, 0.0) - sr_mesh.upper_right = (outer_width, outer_width, outer_width) - settings.random_ray['source_region_meshes'] = [(sr_mesh, [root])] - - # Create the neutron source in the bottom right of the moderator - # Good - fast group appears largest (besides most thermal) - strengths = [1.0] - midpoints = [100.0] - energy_distribution = openmc.stats.Discrete(x=midpoints, p=strengths) - - source = openmc.IndependentSource(energy=energy_distribution, constraints={ - 'domains': [source_universe]}, strength=3.14) - - settings.source = [source] - - ########################################################################### - # Define tallies - - estimator = 'tracklength' - - detector1_filter = openmc.CellFilter(detector1) - detector1_tally = openmc.Tally(name="Detector 1 Tally") - detector1_tally.filters = [detector1_filter] - detector1_tally.scores = ['flux'] - detector1_tally.estimator = estimator - - detector2_filter = openmc.CellFilter(detector2) - detector2_tally = openmc.Tally(name="Detector 2 Tally") - detector2_tally.filters = [detector2_filter] - detector2_tally.scores = ['flux'] - detector2_tally.estimator = estimator - - absorber_filter = openmc.MaterialFilter(absorber_mat) - absorber_tally = openmc.Tally(name="Absorber Tally") - absorber_tally.filters = [absorber_filter] - absorber_tally.scores = ['flux'] - absorber_tally.estimator = estimator - - cavity_filter = openmc.MaterialFilter(cavity_mat) - cavity_tally = openmc.Tally(name="Cavity Tally") - cavity_tally.filters = [cavity_filter] - cavity_tally.scores = ['flux'] - cavity_tally.estimator = estimator - - source_filter = openmc.MaterialFilter(source_mat) - source_tally = openmc.Tally(name="Source Tally") - source_tally.filters = [source_filter] - source_tally.scores = ['flux'] - source_tally.estimator = estimator - - # Instantiate a Tallies collection and export to XML - tallies = openmc.Tallies([detector1_tally, - detector2_tally, - absorber_tally, - cavity_tally, - source_tally]) - - ########################################################################### - # Assmble Model - - model.geometry = geometry - model.materials = materials_file - model.settings = settings - model.tallies = tallies - - return model - - -def sphere_with_shielded_pocket() -> openmc.Model: - """Create a continuous energy deep-shielding model with a far detector pocket. - - A concrete sphere is centered at the origin. A 2 MeV isotropic neutron - source sits in a small air cavity just inside the sphere surface on the -x - side, and a small steel pocket is embedded flush with the surface on the - +x axis, so roughly a meter of concrete separates the source from the - pocket while only a few centimeters of concrete back the cavity. The - sphere is enclosed in a vacuum-bounded box, with a void gap in between, so - that solvers that sample uniformly over a rectangular domain (e.g., - random ray) can be applied directly. The geometry is designed for testing - weight window and variance reduction workflows: - - - The probability that an analog source neutron reaches the steel pocket is - ~4e-5 (the product of the concrete attenuation and the pocket's small - solid angle), so an analog simulation with a few hundred histories - essentially never tallies the steel, while even crude global weight - windows allow particles to reach it reliably. - - Because the cavity sits near the surface, deep shielding (and thus a wide - weight window dynamic range) exists only within the small solid angle - subtended by the pocket, which keeps weight window splitting cheap and - convergent and the whole model fast enough for regression testing. - - Returns - ------- - model : openmc.Model - A deep-shielding model with a steel pocket behind a thick concrete - shield - - """ - model = openmc.Model() - - ########################################################################### - # Materials (few nuclides, to keep data loading cheap in multi-solve tests) - - air = openmc.Material(name='Air') - air.set_density('g/cm3', 0.001225) - air.add_nuclide('N14', 0.79, 'ao') - air.add_nuclide('O16', 0.21, 'ao') - - concrete = openmc.Material(name='Concrete') - concrete.set_density('g/cm3', 2.3) - concrete.add_nuclide('H1', 0.168759, 'ao') - concrete.add_nuclide('O16', 0.562489, 'ao') - concrete.add_nuclide('Si28', 0.203031, 'ao') - concrete.add_nuclide('Ca40', 0.044849, 'ao') - concrete.add_nuclide('Al27', 0.020872, 'ao') - - steel = openmc.Material(name='Steel') - steel.set_density('g/cm3', 7.87) - steel.add_nuclide('Fe56', 1.0) - - ########################################################################### - # Geometry - - # ~92 cm of concrete separates the cavity from the pocket face, while only - # ~6 cm of concrete backs the cavity on the -x side, so deep shielding is - # confined to the solid angle subtended by the pocket. - r_sphere = 66.0 - box_half_width = 70.0 - cavity_center_x = -54.0 - cavity_half_width = 6.0 - pocket_inner_face = 44.0 - pocket_half_width = 4.0 - - sphere = openmc.Sphere(r=r_sphere) - outer_box = openmc.model.RectangularParallelepiped( - -box_half_width, box_half_width, - -box_half_width, box_half_width, - -box_half_width, box_half_width, boundary_type='vacuum') - cavity_box = openmc.model.RectangularParallelepiped( - cavity_center_x - cavity_half_width, cavity_center_x + cavity_half_width, - -cavity_half_width, cavity_half_width, - -cavity_half_width, cavity_half_width) - # The pocket box extends past the sphere surface and is clipped by it, so - # the pocket sits flush with (and just inside) the outer surface. - pocket_box = openmc.model.RectangularParallelepiped( - pocket_inner_face, r_sphere + 1.0, - -pocket_half_width, pocket_half_width, - -pocket_half_width, pocket_half_width) - - cavity_cell = openmc.Cell(name='cavity', fill=air, region=-cavity_box) - pocket_cell = openmc.Cell(name='pocket', fill=steel, - region=-pocket_box & -sphere) - concrete_cell = openmc.Cell( - name='concrete', fill=concrete, - region=-sphere & +cavity_box & ~(-pocket_box & -sphere)) - void_cell = openmc.Cell(name='void', region=+sphere & -outer_box) - - model.geometry = openmc.Geometry( - [cavity_cell, pocket_cell, concrete_cell, void_cell]) - - ########################################################################### - # Source and settings - - source = openmc.IndependentSource() - source.space = openmc.stats.Box( - [cavity_center_x - cavity_half_width, -cavity_half_width, -cavity_half_width], - [cavity_center_x + cavity_half_width, cavity_half_width, cavity_half_width]) - source.constraints = {'domains': [cavity_cell]} - source.angle = openmc.stats.Isotropic() - source.energy = openmc.stats.delta_function(2.0e6) - - model.settings.run_mode = 'fixed source' - model.settings.source = source - model.settings.particles = 1000 - model.settings.batches = 10 - - return model diff --git a/openmc/executor.py b/openmc/executor.py index 75094e738..aacc48b3f 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -103,7 +103,6 @@ def _run(args, output, cwd): # If OpenMC is finished, break loop line = p.stdout.readline() if not line and p.poll() is not None: - p.stdout.close() break lines.append(line) @@ -165,7 +164,7 @@ def plot_inline(plots, openmc_exec='openmc', cwd='.', path_input=None): Parameters ---------- - plots : Iterable of openmc.PlotBase + plots : Iterable of openmc.Plot Plots to display openmc_exec : str Path to OpenMC executable diff --git a/openmc/filter.py b/openmc/filter.py index 87aeb70c3..e005140ee 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -1,6 +1,6 @@ from __future__ import annotations from abc import ABCMeta -from collections.abc import Iterable, Sequence +from collections.abc import Iterable import hashlib from itertools import product from numbers import Real, Integral @@ -13,21 +13,19 @@ import pandas as pd import openmc import openmc.checkvalue as cv from .cell import Cell -from .data.reaction import REACTION_NAME, REACTION_MT from .material import Material from .mixin import IDManagerMixin from .surface import Surface from .universe import UniverseBase -from ._xml import get_elem_list, get_text +from ._xml import get_text _FILTER_TYPES = ( 'universe', 'material', 'cell', 'cellborn', 'surface', 'mesh', 'energy', - 'energyout', 'mu', 'musurface', 'polar', 'azimuthal', 'distribcell', - 'delayedgroup', 'energyfunction', 'cellfrom', 'materialfrom', 'legendre', - 'spatiallegendre', 'sphericalharmonics', 'zernike', 'zernikeradial', 'particle', - 'particleproduction', 'cellinstance', 'collision', 'time', 'parentnuclide', - 'weight', 'meshborn', 'meshsurface', 'meshmaterial', 'reaction', + 'energyout', 'mu', 'polar', 'azimuthal', 'distribcell', 'delayedgroup', + 'energyfunction', 'cellfrom', 'materialfrom', 'legendre', 'spatiallegendre', + 'sphericalharmonics', 'zernike', 'zernikeradial', 'particle', 'cellinstance', + 'collision', 'time' ) _CURRENT_NAMES = ( @@ -36,6 +34,7 @@ _CURRENT_NAMES = ( 'z-min out', 'z-min in', 'z-max out', 'z-max in' ) +_PARTICLES = {'neutron', 'photon', 'electron', 'positron'} class FilterMeta(ABCMeta): @@ -127,9 +126,9 @@ class Filter(IDManagerMixin, metaclass=FilterMeta): def __gt__(self, other): if type(self) is not type(other): if self.short_name in _FILTER_TYPES and \ - other.short_name in _FILTER_TYPES: + other.short_name in _FILTER_TYPES: delta = _FILTER_TYPES.index(self.short_name) - \ - _FILTER_TYPES.index(other.short_name) + _FILTER_TYPES.index(other.short_name) return delta > 0 else: return False @@ -259,15 +258,17 @@ class Filter(IDManagerMixin, metaclass=FilterMeta): Filter object """ - filter_type = get_text(elem, "type") + filter_type = elem.get('type') + if filter_type is None: + filter_type = elem.find('type').text # If the filter type matches this class's short_name, then # there is no overridden from_xml_element method if filter_type == cls.short_name.lower(): # Get bins from element -- the default here works for any filters # that just store a list of bins that can be represented as integers - filter_id = int(get_text(elem, "id")) - bins = get_elem_list(elem, "bins", int) or [] + filter_id = int(elem.get('id')) + bins = [int(x) for x in get_text(elem, 'bins').split()] return cls(bins, filter_id=filter_id) # Search through all subclasses and find the one matching the HDF5 @@ -276,6 +277,7 @@ class Filter(IDManagerMixin, metaclass=FilterMeta): if filter_type == subclass.short_name.lower(): return subclass.from_xml_element(elem, **kwargs) + def can_merge(self, other): """Determine if filter can be merged with another. @@ -426,7 +428,6 @@ class Filter(IDManagerMixin, metaclass=FilterMeta): class WithIDFilter(Filter): """Abstract parent for filters of types with IDs (Cell, Material, etc.).""" - def __init__(self, bins, filter_id=None): bins = np.atleast_1d(bins) @@ -630,7 +631,6 @@ class CellInstanceFilter(Filter): DistribcellFilter """ - def __init__(self, bins, filter_id=None): self.bins = bins self.id = filter_id @@ -700,8 +700,8 @@ class CellInstanceFilter(Filter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - bins = get_elem_list(elem, "bins", int) or [] + filter_id = int(elem.get('id')) + bins = [int(x) for x in get_text(elem, 'bins').split()] cell_instances = list(zip(bins[::2], bins[1::2])) return cls(cell_instances, filter_id=filter_id) @@ -732,18 +732,19 @@ class SurfaceFilter(WithIDFilter): class ParticleFilter(Filter): - """Bins tally events based on the particle type. + """Bins tally events based on the Particle type. Parameters ---------- - bins : str, int, openmc.ParticleType, or sequence - The particle types to tally represented as names, PDG numbers, or types. + bins : str, or iterable of str + The particles to tally represented as strings ('neutron', 'photon', + 'electron', 'positron'). filter_id : int Unique identifier for the filter Attributes ---------- - bins : sequence of str + bins : iterable of str The particles to tally id : int Unique identifier for the filter @@ -751,7 +752,6 @@ class ParticleFilter(Filter): The number of filter bins """ - def __eq__(self, other): if type(self) is not type(other): return False @@ -764,16 +764,11 @@ class ParticleFilter(Filter): @Filter.bins.setter def bins(self, bins): - if isinstance(bins, (str, Integral, openmc.ParticleType)): - bins = [bins] - else: - cv.check_type('bins', bins, Sequence, - (str, Integral, openmc.ParticleType)) bins = np.atleast_1d(bins) - normalized = [] - for entry in bins: - normalized.append(str(openmc.ParticleType(entry))) - self._bins = np.array(normalized, dtype=str) + cv.check_iterable_type('filter bins', bins, str) + for edge in bins: + cv.check_value('filter bin', edge, _PARTICLES) + self._bins = bins @classmethod def from_hdf5(cls, group, **kwargs): @@ -788,40 +783,13 @@ class ParticleFilter(Filter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - bins = get_elem_list(elem, "bins", str) or [] + filter_id = int(elem.get('id')) + bins = get_text(elem, 'bins').split() return cls(bins, filter_id=filter_id) -class ParentNuclideFilter(ParticleFilter): - """Bins tally events based on the parent nuclide - - Parameters - ---------- - bins : str, or iterable of str - Names of nuclides (e.g., 'Ni65') - filter_id : int - Unique identifier for the filter - - Attributes - ---------- - bins : iterable of str - Names of nuclides - id : int - Unique identifier for the filter - num_bins : Integral - The number of filter bins - - """ - @Filter.bins.setter - def bins(self, bins): - bins = np.atleast_1d(bins) - cv.check_iterable_type('filter bins', bins, str) - self._bins = bins - - class MeshFilter(Filter): - r"""Bins tally event locations by mesh elements. + """Bins tally event locations by mesh elements. Parameters ---------- @@ -839,25 +807,6 @@ class MeshFilter(Filter): translation : Iterable of float This array specifies a vector that is used to translate (shift) the mesh for this filter - rotation : Iterable of float - This array specifies the angles in degrees about the x, y, and z axes - that the mesh should be rotated. The rotation applied is an intrinsic - rotation with specified Tait-Bryan angles. That is to say, if the angles - are :math:`(\phi, \theta, \psi)`, then the rotation matrix applied is - :math:`R_z(\psi) R_y(\theta) R_x(\phi)` or - - .. math:: - - \left [ \begin{array}{ccc} \cos\theta \cos\psi & -\cos\phi \sin\psi - + \sin\phi \sin\theta \cos\psi & \sin\phi \sin\psi + \cos\phi - \sin\theta \cos\psi \\ \cos\theta \sin\psi & \cos\phi \cos\psi + - \sin\phi \sin\theta \sin\psi & -\sin\phi \cos\psi + \cos\phi - \sin\theta \sin\psi \\ -\sin\theta & \sin\phi \cos\theta & \cos\phi - \cos\theta \end{array} \right ] - - A rotation matrix can also be specified directly by setting this - attribute to a nested list (or 2D numpy array) that specifies each - element of the matrix. bins : list of tuple A list of mesh indices for each filter bin, e.g. [(1, 1, 1), (2, 1, 1), ...] @@ -870,7 +819,6 @@ class MeshFilter(Filter): self.mesh = mesh self.id = filter_id self._translation = None - self._rotation = None def __hash__(self): string = type(self).__name__ + '\n' @@ -882,7 +830,6 @@ class MeshFilter(Filter): string += '{: <16}=\t{}\n'.format('\tMesh ID', self.mesh.id) string += '{: <16}=\t{}\n'.format('\tID', self.id) string += '{: <16}=\t{}\n'.format('\tTranslation', self.translation) - string += '{: <16}=\t{}\n'.format('\tRotation', self.rotation) return string @classmethod @@ -906,10 +853,6 @@ class MeshFilter(Filter): if translation: out.translation = translation[()] - rotation = group.get('rotation') - if rotation: - out.rotation = rotation[()] - return out @property @@ -930,6 +873,8 @@ class MeshFilter(Filter): @property def shape(self): + if isinstance(self, MeshSurfaceFilter): + return (self.num_bins,) return self.mesh.dimension @property @@ -942,15 +887,6 @@ class MeshFilter(Filter): cv.check_length('mesh filter translation', t, 3) self._translation = np.asarray(t) - @property - def rotation(self): - return self._rotation - - @rotation.setter - def rotation(self, rotation): - cv.check_length('mesh filter rotation', rotation, 3) - self._rotation = np.asarray(rotation) - def can_merge(self, other): # Mesh filters cannot have more than one bin return False @@ -972,36 +908,53 @@ class MeshFilter(Filter): Returns ------- pandas.DataFrame - A Pandas DataFrame with columns describing the mesh cell indices - corresponding to each filter bin. Column names depend on the mesh - type (e.g., x/y/z for RegularMesh, r/phi/z for CylindricalMesh, - r/theta/phi for SphericalMesh, or element index for - UnstructuredMesh). The number of rows in the DataFrame is the same - as the total number of bins in the corresponding tally, with the - filter bin appropriately tiled to map to the corresponding tally - bins. + A Pandas DataFrame with three columns describing the x,y,z mesh + cell indices corresponding to each filter bin. The number of rows + in the DataFrame is the same as the total number of bins in the + corresponding tally, with the filter bin appropriately tiled to map + to the corresponding tally bins. See also -------- Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ + # Initialize Pandas DataFrame + df = pd.DataFrame() + # Initialize dictionary to build Pandas Multi-index column filter_dict = {} # Append mesh ID as outermost index of multi-index mesh_key = f'mesh {self.mesh.id}' - # Determine index base (0-based for unstructured, 1-based otherwise) - idx_start = 0 if isinstance(self.mesh, openmc.UnstructuredMesh) else 1 + # Find mesh dimensions - use 3D indices for simplicity + n_dim = len(self.mesh.dimension) + if n_dim == 3: + nx, ny, nz = self.mesh.dimension + elif n_dim == 2: + nx, ny = self.mesh.dimension + nz = 1 + else: + nx = self.mesh.dimension + ny = nz = 1 - # Generate a multi-index sub-column for each axis - for label, dim_size in zip(self.mesh._axis_labels, self.mesh.dimension): - filter_dict[mesh_key, label] = _repeat_and_tile( - np.arange(idx_start, idx_start + dim_size), stride, data_size) - stride *= dim_size + # Generate multi-index sub-column for x-axis + filter_dict[mesh_key, 'x'] = _repeat_and_tile( + np.arange(1, nx + 1), stride, data_size) - return pd.DataFrame(filter_dict) + # Generate multi-index sub-column for y-axis + filter_dict[mesh_key, 'y'] = _repeat_and_tile( + np.arange(1, ny + 1), nx * stride, data_size) + + # Generate multi-index sub-column for z-axis + filter_dict[mesh_key, 'z'] = _repeat_and_tile( + np.arange(1, nz + 1), nx * ny * stride, data_size) + + # Initialize a Pandas DataFrame from the mesh dictionary + df = pd.concat([df, pd.DataFrame(filter_dict)]) + + return df def to_xml_element(self): """Return XML Element representing the Filter. @@ -1012,34 +965,22 @@ class MeshFilter(Filter): XML element containing filter data """ - element = ET.Element('filter') - element.set('id', str(self.id)) - element.set('type', self.short_name.lower()) - subelement = ET.SubElement(element, 'bins') - subelement.text = str(self.mesh.id) + element = super().to_xml_element() + element[0].text = str(self.mesh.id) if self.translation is not None: element.set('translation', ' '.join(map(str, self.translation))) - if self.rotation is not None: - element.set('rotation', ' '.join(map(str, self.rotation.ravel()))) return element @classmethod def from_xml_element(cls, elem: ET.Element, **kwargs) -> MeshFilter: mesh_id = int(get_text(elem, 'bins')) mesh_obj = kwargs['meshes'][mesh_id] - filter_id = int(get_text(elem, "id")) + filter_id = int(elem.get('id')) out = cls(mesh_obj, filter_id=filter_id) - translation = get_elem_list(elem, "translation", float) or [] + translation = elem.get('translation') if translation: - out.translation = translation - - rotation = get_elem_list(elem, 'rotation', float) or [] - if rotation: - if len(rotation) == 3: - out.rotation = rotation - elif len(rotation) == 9: - out.rotation = np.array(rotation).reshape(3, 3) + out.translation = [float(x) for x in translation.split()] return out @@ -1071,187 +1012,6 @@ class MeshBornFilter(MeshFilter): """ -class MeshMaterialFilter(MeshFilter): - """Filter events by combinations of mesh elements and materials. - - .. versionadded:: 0.15.3 - - Parameters - ---------- - mesh : openmc.MeshBase - The mesh object that events will be tallied onto - bins : iterable of 2-tuples or numpy.ndarray - Combinations of (mesh element, material) to tally, given as 2-tuples. - The first value in the tuple represents the index of the mesh element, - and the second value indicates the material (either a - :class:`openmc.Material` instance of the ID). - filter_id : int - Unique identifier for the filter - - """ - - def __init__(self, mesh: openmc.MeshBase, bins, filter_id=None): - self.mesh = mesh - self.bins = bins - self.id = filter_id - self._translation = None - - @classmethod - def from_volumes(cls, mesh: openmc.MeshBase, volumes: openmc.MeshMaterialVolumes): - """Construct a MeshMaterialFilter from a MeshMaterialVolumes object. - - Parameters - ---------- - mesh : openmc.MeshBase - The mesh object that events will be tallied onto - volumes : openmc.MeshMaterialVolumes - The mesh material volumes to use for the filter - - Returns - ------- - MeshMaterialFilter - A new MeshMaterialFilter instance - - """ - # Get flat arrays of material IDs and element indices - mat_ids = volumes._materials[volumes._materials > -1] - elems, _ = np.where(volumes._materials > -1) - - # Stack them into a 2D array of (element, material) pairs - bins = np.column_stack((elems, mat_ids)) - return cls(mesh, bins) - - def __hash__(self): - data = (type(self).__name__, self.mesh.id, tuple(self.bins.ravel())) - return hash(data) - - def __repr__(self): - string = type(self).__name__ + '\n' - string += '{: <16}=\t{}\n'.format('\tID', self.id) - string += '{: <16}=\t{}\n'.format('\tMesh ID', self.mesh.id) - string += '{: <16}=\n{}\n'.format('\tBins', self.bins) - string += '{: <16}=\t{}\n'.format('\tTranslation', self.translation) - return string - - @property - def shape(self): - return (self.num_bins,) - - @property - def mesh(self): - return self._mesh - - @mesh.setter - def mesh(self, mesh): - cv.check_type('filter mesh', mesh, openmc.MeshBase) - self._mesh = mesh - - @Filter.bins.setter - def bins(self, bins): - pairs = np.empty((len(bins), 2), dtype=int) - for i, (elem, mat) in enumerate(bins): - cv.check_type('element', elem, Integral) - cv.check_type('material', mat, (Integral, openmc.Material)) - pairs[i, 0] = elem - pairs[i, 1] = mat if isinstance(mat, Integral) else mat.id - self._bins = pairs - - def to_xml_element(self): - """Return XML element representing the filter. - - Returns - ------- - element : lxml.etree._Element - XML element containing filter data - - """ - element = ET.Element('filter') - element.set('id', str(self.id)) - element.set('type', self.short_name.lower()) - element.set('mesh', str(self.mesh.id)) - - if self.translation is not None: - element.set('translation', ' '.join(map(str, self.translation))) - - subelement = ET.SubElement(element, 'bins') - subelement.text = ' '.join(str(i) for i in self.bins.ravel()) - - return element - - @classmethod - def from_xml_element(cls, elem: ET.Element, **kwargs) -> MeshMaterialFilter: - filter_id = int(get_text(elem, "id")) - mesh_id = int(get_text(elem, "mesh")) - mesh_obj = kwargs['meshes'][mesh_id] - bins = get_elem_list(elem, "bins", int) or [] - bins = list(zip(bins[::2], bins[1::2])) - out = cls(mesh_obj, bins, filter_id=filter_id) - - translation = get_elem_list(elem, "translation", float) or [] - if translation: - out.translation = translation - return out - - @classmethod - def from_hdf5(cls, group, **kwargs): - if group['type'][()].decode() != cls.short_name.lower(): - raise ValueError("Expected HDF5 data for filter type '" - + cls.short_name.lower() + "' but got '" - + group['type'][()].decode() + " instead") - - if 'meshes' not in kwargs: - raise ValueError(cls.__name__ + " requires a 'meshes' keyword " - "argument.") - - mesh_id = group['mesh'][()] - mesh_obj = kwargs['meshes'][mesh_id] - bins = group['bins'][()] - filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - out = cls(mesh_obj, bins, filter_id=filter_id) - - translation = group.get('translation') - if translation: - out.translation = translation[()] - - return out - - def get_pandas_dataframe(self, data_size, stride, **kwargs): - """Builds a Pandas DataFrame for the Filter's bins. - - This method constructs a Pandas DataFrame object for the filter with - columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. - - Parameters - ---------- - data_size : int - The total number of bins in the tally corresponding to this filter - stride : int - Stride in memory for the filter - - Returns - ------- - pandas.DataFrame - A Pandas DataFrame with a multi-index column for the cell instance. - The number of rows in the DataFrame is the same as the total number - of bins in the corresponding tally, with the filter bin appropriately - tiled to map to the corresponding tally bins. - - See also - -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() - - """ - # Repeat and tile bins as necessary to account for other filters. - bins = np.repeat(self.bins, stride, axis=0) - tile_factor = data_size // len(bins) - bins = np.tile(bins, (tile_factor, 1)) - - columns = pd.MultiIndex.from_product([[self.short_name.lower()], - ['element', 'material']]) - return pd.DataFrame(bins, columns=columns) - - class MeshSurfaceFilter(MeshFilter): """Filter events by surface crossings on a mesh. @@ -1278,9 +1038,6 @@ class MeshSurfaceFilter(MeshFilter): The number of filter bins """ - @property - def shape(self): - return (self.num_bins,) @MeshFilter.mesh.setter def mesh(self, mesh): @@ -1399,80 +1156,6 @@ class CollisionFilter(Filter): cv.check_greater_than('filter value', x, 0, equality=True) -class ReactionFilter(Filter): - """Bins tally events based on the reaction type (MT number). - - .. versionadded:: 0.15.4 - - Parameters - ---------- - bins : str, int, or iterable thereof - The reaction types to tally. Can be reaction name strings - (e.g., ``'(n,elastic)'``, ``'(n,gamma)'``) or integer MT numbers - (e.g., 2, 102). Integer MT values are automatically converted to their - canonical string representation. - filter_id : int - Unique identifier for the filter - - Attributes - ---------- - bins : numpy.ndarray of str - Reaction name strings - id : int - Unique identifier for the filter - num_bins : int - The number of filter bins - - """ - - def __init__(self, bins, filter_id=None): - self.bins = bins - self.id = filter_id - - @Filter.bins.setter - def bins(self, bins): - if isinstance(bins, (str, Integral)): - bins = [bins] - elif not isinstance(bins, list): - bins = list(bins) - normalized = [] - for b in bins: - if isinstance(b, Integral): - if int(b) not in REACTION_NAME: - raise ValueError(f"No known reaction for MT={b}") - normalized.append(REACTION_NAME[int(b)]) - elif isinstance(b, str): - if b == 'total': - warnings.warn( - "The reaction name 'total' is ambiguous. Use " - "'(n,total)' for neutron total cross section or " - "'photon-total' for photon total. Interpreting as" - "'(n,total)'.") - if b not in REACTION_MT: - raise ValueError(f"Unknown reaction name '{b}'") - normalized.append(REACTION_NAME[REACTION_MT[b]]) - else: - raise TypeError(f"Expected str or int for reaction filter " - f"bin, got {type(b)}") - self._bins = np.array(normalized, dtype=str) - - @classmethod - def from_hdf5(cls, group, **kwargs): - if group['type'][()].decode() != cls.short_name.lower(): - raise ValueError("Expected HDF5 data for filter type '" - + cls.short_name.lower() + "' but got '" - + group['type'][()].decode() + "' instead") - bins = [b.decode() for b in group['bins'][()]] - filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - return cls(bins, filter_id=filter_id) - - @classmethod - def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - bins = get_elem_list(elem, "bins", str) or [] - return cls(bins, filter_id=filter_id) - - class RealFilter(Filter): """Tally modifier that describes phase-space and other characteristics @@ -1498,7 +1181,6 @@ class RealFilter(Filter): The number of filter bins """ - def __init__(self, values, filter_id=None): self.values = np.asarray(values) self.bins = np.vstack((self.values[:-1], self.values[1:])).T @@ -1529,7 +1211,7 @@ class RealFilter(Filter): cv.check_type('filter value', v1, Real) # Make sure that each tuple has values that are increasing - if v1 <= v0: + if v1 < v0: raise ValueError(f'Values {v0} and {v1} appear to be out of ' 'order') @@ -1663,8 +1345,8 @@ class RealFilter(Filter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - bins = get_elem_list(elem, "bins", float) or [] + filter_id = int(elem.get('id')) + bins = [float(x) for x in get_text(elem, 'bins').split()] return cls(bins, filter_id=filter_id) @@ -1675,7 +1357,7 @@ class EnergyFilter(RealFilter): ---------- values : Iterable of Real A list of values for which each successive pair constitutes a range of - energies in [eV] for a single bin. Entries must be positive and ascending. + energies in [eV] for a single bin filter_id : int Unique identifier for the filter @@ -1774,8 +1456,7 @@ class EnergyFilter(RealFilter): """ - cv.check_value('group_structure', group_structure, - openmc.mgxs.GROUP_STRUCTURES.keys()) + cv.check_value('group_structure', group_structure, openmc.mgxs.GROUP_STRUCTURES.keys()) return cls(openmc.mgxs.GROUP_STRUCTURES[group_structure.upper()]) @@ -1805,226 +1486,6 @@ class EnergyoutFilter(EnergyFilter): """ - -class ParticleProductionFilter(Filter): - """Bins tally events based on secondary particle type and energy. - - This filter bins secondary particles (e.g., photons, electrons, or recoils) - produced in a reaction by particle type and, optionally, by energy. This is - useful for constructing production matrices or analyzing secondary particle - spectra. Note that unlike other energy filters, the weight that is applied - is equal to the weight of the secondary particle. Thus, to obtain secondary - particle production, it should be used in conjunction with the "events" - score. - - The incident particle type can be filtered using :class:`ParticleFilter`. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - particles : str, int, openmc.ParticleType, or iterable thereof - Type(s) of secondary particle(s) to tally ('photon', 'neutron', etc.) - energies : Iterable of Real or str, optional - A list of energy boundaries in [eV]; each successive pair defines a bin. - Alternatively, the name of the group structure can be given as a string - (must be a key in :data:`openmc.mgxs.GROUP_STRUCTURES`). If not - provided, the filter tallies total secondary particle production without - energy binning. - filter_id : int, optional - Unique identifier for the filter - - Attributes - ---------- - particles : list of openmc.ParticleType - The secondary particle types this filter applies to - energies : numpy.ndarray or None - Energy boundaries in [eV], or None if no energy binning - bins : list - A list of bins; each element fully describes one bin. When energies are - specified, each element is a tuple ``(particle, energy_low, - energy_high)``. When no energies are specified, each element is a - particle name string. - num_bins : int - Total number of filter bins - num_energy_bins : int - Number of energy bins (1 if no energies specified) - shape : tuple of int - Shape of the filter as (n_particles, n_energy_bins) - """ - - def __init__(self, particles, energies=None, filter_id=None): - self.particles = particles - self.energies = energies - self.id = filter_id - - def __repr__(self): - string = type(self).__name__ + '\n' - string += '{: <16}=\t{}\n'.format('\tParticles', - [str(p) for p in self.particles]) - if self.energies is not None: - string += '{: <16}=\t{}\n'.format('\tEnergies', self.energies) - string += '{: <16}=\t{}\n'.format('\tID', self.id) - return string - - @property - def particles(self): - return self._particles - - @particles.setter - def particles(self, particles): - if isinstance(particles, (str, int, openmc.ParticleType)): - self._particles = [openmc.ParticleType(particles)] - else: - self._particles = [openmc.ParticleType(p) for p in particles] - - @property - def energies(self): - return self._energies - - @energies.setter - def energies(self, energies): - if energies is None: - self._energies = None - elif isinstance(energies, str): - cv.check_value('energies', energies, - openmc.mgxs.GROUP_STRUCTURES.keys()) - self._energies = np.array( - openmc.mgxs.GROUP_STRUCTURES[energies.upper()]) - else: - energies = np.asarray(energies, dtype=float) - cv.check_length('energies', energies, 2) - for i in range(len(energies) - 1): - if energies[i + 1] <= energies[i]: - raise ValueError("Energy bins must be monotonically " - "increasing.") - self._energies = energies - - @property - def bins(self): - if self.energies is None: - return [str(p) for p in self.particles] - else: - result = [] - energy_pairs = np.vstack( - (self.energies[:-1], self.energies[1:])).T - for particle in self.particles: - for e_low, e_high in energy_pairs: - result.append((str(particle), e_low, e_high)) - return result - - @bins.setter - def bins(self, bins): - # bins is set indirectly through particles/energies - pass - - def check_bins(self, bins): - pass - - @property - def num_energy_bins(self): - if self.energies is None: - return 1 - else: - return len(self.energies) - 1 - - @property - def num_bins(self): - return len(self.particles) * self.num_energy_bins - - @property - def shape(self): - return (len(self.particles), self.num_energy_bins) - - def to_xml_element(self): - element = ET.Element('filter') - element.set('id', str(self.id)) - element.set('type', self.short_name.lower()) - - subelement = ET.SubElement(element, 'particles') - subelement.text = ' '.join(str(p) for p in self.particles) - - if self.energies is not None: - subelement = ET.SubElement(element, 'energies') - subelement.text = ' '.join(str(e) for e in self.energies) - - return element - - @classmethod - def from_xml_element(cls, elem, **kwargs): - filter_id = int(elem.get('id')) - particles = get_text(elem, 'particles').split() - - bins_elem = elem.find('energies') - if bins_elem is not None: - energies = [float(x) for x in bins_elem.text.split()] - else: - energies = None - - return cls(particles, energies=energies, filter_id=filter_id) - - @classmethod - def from_hdf5(cls, group, **kwargs): - filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - - # Read particle types - particles = [b.decode() if isinstance(b, bytes) else b - for b in group['particles'][()]] - - # Read energy bins if present - if 'energies' in group: - energies = group['energies'][()] - else: - energies = None - - return cls(particles, energies=energies, filter_id=filter_id) - - def get_pandas_dataframe(self, data_size, stride, **kwargs): - """Builds a Pandas DataFrame for the Filter's bins. - - This method constructs a Pandas DataFrame object for the filter with - columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. - - Parameters - ---------- - data_size : int - The total number of bins in the tally corresponding to this filter - stride : int - Stride in memory for the filter - - Returns - ------- - pandas.DataFrame - A Pandas DataFrame with columns for particle type and, if energy - bins are specified, energy bin boundaries. - - See also - -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() - - """ - filter_dict = {} - key = self.short_name.lower() - n_ebins = self.num_energy_bins - - # Particle column — outer dimension (changes slowest) - particle_names = [str(p) for p in self.particles] - filter_dict[key, 'particle'] = _repeat_and_tile( - np.array(particle_names), n_ebins * stride, data_size) - - # Energy columns only if energies were specified - if self.energies is not None: - energy_pairs = np.vstack( - (self.energies[:-1], self.energies[1:])).T - filter_dict[key, 'energy low [eV]'] = _repeat_and_tile( - energy_pairs[:, 0], stride, data_size) - filter_dict[key, 'energy high [eV]'] = _repeat_and_tile( - energy_pairs[:, 1], stride, data_size) - - return pd.DataFrame(filter_dict) - - class TimeFilter(RealFilter): """Bins tally events based on the particle's time. @@ -2168,22 +1629,13 @@ class DistribcellFilter(Filter): @property def paths(self): - if self._paths is None: - if not hasattr(self, '_geometry'): - raise ValueError( - "Model must be exported before the 'paths' attribute is" \ - "available for a DistribcellFilter.") - - # Determine paths for cell instances - self._geometry.determine_paths() - - # Get paths for the corresponding cell - cell_id = self.bins[0] - cell = self._geometry.get_all_cells()[cell_id] - self._paths = cell.paths - return self._paths + @paths.setter + def paths(self, paths): + cv.check_iterable_type('paths', paths, str) + self._paths = paths + @Filter.bins.setter def bins(self, bins): # Format the bins as a 1D numpy array. @@ -2192,7 +1644,7 @@ class DistribcellFilter(Filter): # Make sure there is only 1 bin. if not len(bins) == 1: msg = (f'Unable to add bins "{bins}" to a DistribcellFilter since ' - 'only a single distribcell can be used per tally') + 'only a single distribcell can be used per tally') raise ValueError(msg) # Check the type and extract the id, if necessary. @@ -2345,7 +1797,7 @@ class DistribcellFilter(Filter): # requests Summary geometric information filter_bins = _repeat_and_tile( np.arange(self.num_bins), stride, data_size) - df = pd.DataFrame({self.short_name.lower(): filter_bins}) + df = pd.DataFrame({self.short_name.lower() : filter_bins}) # Concatenate with DataFrame of distribcell instance IDs if level_df is not None: @@ -2384,7 +1836,6 @@ class MuFilter(RealFilter): The number of filter bins """ - def __init__(self, values, filter_id=None): if isinstance(values, Integral): values = np.linspace(-1., 1., values + 1) @@ -2399,44 +1850,6 @@ class MuFilter(RealFilter): cv.check_less_than('filter value', x, 1., equality=True) -class MuSurfaceFilter(MuFilter): - """Bins tally events based on the angle of surface crossing. - - This filter bins events based on the cosine of the angle between the - direction of the particle and the normal to the surface at the point it - crosses. Only used in conjunction with a SurfaceFilter and current score. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - values : int or Iterable of Real - A grid of surface crossing angles which the events will be divided into. - Values represent the cosine of the angle between the direction of the - particle and the normal to the surface at the point it crosses. If an - iterable is given, the values will be used explicitly as grid points. If - a single int is given, the range [-1, 1] will be divided equally into - that number of bins. - filter_id : int - Unique identifier for the filter - - Attributes - ---------- - values : numpy.ndarray - An array of values for which each successive pair constitutes a range of - surface crossing angle cosines for a single bin. - id : int - Unique identifier for the filter - bins : numpy.ndarray - An array of shape (N, 2) where each row is a pair of cosines of surface - crossing angle for a single filter - num_bins : Integral - The number of filter bins - - """ - # Note: inherits implementation from MuFilter - - class PolarFilter(RealFilter): """Bins tally events based on the incident particle's direction. @@ -2550,7 +1963,6 @@ class DelayedGroupFilter(Filter): The number of filter bins """ - def check_bins(self, bins): # Check the bin values. for g in bins: @@ -2619,9 +2031,9 @@ class EnergyFunctionFilter(Filter): def __gt__(self, other): if type(self) is not type(other): if self.short_name in _FILTER_TYPES and \ - other.short_name in _FILTER_TYPES: + other.short_name in _FILTER_TYPES: delta = _FILTER_TYPES.index(self.short_name) - \ - _FILTER_TYPES.index(other.short_name) + _FILTER_TYPES.index(other.short_name) return delta > 0 else: return False @@ -2631,9 +2043,9 @@ class EnergyFunctionFilter(Filter): def __lt__(self, other): if type(self) is not type(other): if self.short_name in _FILTER_TYPES and \ - other.short_name in _FILTER_TYPES: + other.short_name in _FILTER_TYPES: delta = _FILTER_TYPES.index(self.short_name) - \ - _FILTER_TYPES.index(other.short_name) + _FILTER_TYPES.index(other.short_name) return delta < 0 else: return False @@ -2644,16 +2056,14 @@ class EnergyFunctionFilter(Filter): string = type(self).__name__ + '\n' string += '{: <16}=\t{}\n'.format('\tEnergy', self.energy) string += '{: <16}=\t{}\n'.format('\tInterpolant', self.y) - string += '{: <16}=\t{}\n'.format('\tInterpolation', - self.interpolation) + string += '{: <16}=\t{}\n'.format('\tInterpolation', self.interpolation) return hash(string) def __repr__(self): string = type(self).__name__ + '\n' string += '{: <16}=\t{}\n'.format('\tEnergy', self.energy) string += '{: <16}=\t{}\n'.format('\tInterpolant', self.y) - string += '{: <16}=\t{}\n'.format('\tInterpolation', - self.interpolation) + string += '{: <16}=\t{}\n'.format('\tInterpolation', self.interpolation) string += '{: <16}=\t{}\n'.format('\tID', self.id) return string @@ -2739,12 +2149,10 @@ class EnergyFunctionFilter(Filter): @interpolation.setter def interpolation(self, val): cv.check_type('interpolation', val, str) - cv.check_value('interpolation', val, - self.INTERPOLATION_SCHEMES.values()) + cv.check_value('interpolation', val, self.INTERPOLATION_SCHEMES.values()) if val == 'quadratic' and len(self.energy) < 3: - raise ValueError( - 'Quadratic interpolation requires 3 or more values.') + raise ValueError('Quadratic interpolation requires 3 or more values.') if val == 'cubic' and len(self.energy) < 4: raise ValueError('Cubic interpolation requires 3 or more values.') @@ -2789,13 +2197,12 @@ class EnergyFunctionFilter(Filter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - energy = get_elem_list(elem, "energy", float) or [] - y = get_elem_list(elem, "y", float) or [] + filter_id = int(elem.get('id')) + energy = [float(x) for x in get_text(elem, 'energy').split()] + y = [float(x) for x in get_text(elem, 'y').split()] out = cls(energy, y, filter_id=filter_id) - interpolation = get_text(elem, "interpolation") - if interpolation is not None: - out.interpolation = interpolation + if elem.find('interpolation') is not None: + out.interpolation = elem.find('interpolation').text return out def can_merge(self, other): @@ -2856,26 +2263,3 @@ class EnergyFunctionFilter(Filter): {self.short_name.lower(): filter_bins})]) return df - - -class WeightFilter(RealFilter): - """Bins tally events based on the incoming particle weight. - - Parameters - ---------- - Values : Iterable of float - A list or iterable of the weight boundaries, as float values. - filter_id : int - Unique identifier for the filter - - Attributes - ---------- - id : int - Unique identifier for the filter - bins : numpy.ndarray - An array of integer values representing the weights by which to filter - num_bins : int - The number of filter bins - values : numpy.ndarray - Array of weight boundaries - """ diff --git a/openmc/filter_expansion.py b/openmc/filter_expansion.py index b79c8fc79..f8e677578 100644 --- a/openmc/filter_expansion.py +++ b/openmc/filter_expansion.py @@ -3,8 +3,7 @@ from numbers import Integral, Real import lxml.etree as ET import openmc.checkvalue as cv -from .filter import Filter -from ._xml import get_text +from . import Filter class ExpansionFilter(Filter): @@ -50,8 +49,8 @@ class ExpansionFilter(Filter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - order = int(get_text(elem, "order")) + filter_id = int(elem.get('id')) + order = int(elem.find('order').text) return cls(order, filter_id=filter_id) def merge(self, other): @@ -264,11 +263,11 @@ class SpatialLegendreFilter(ExpansionFilter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - order = int(get_text(elem, "order")) - axis = get_text(elem, "axis") - minimum = float(get_text(elem, "min")) - maximum = float(get_text(elem, "max")) + filter_id = int(elem.get('id')) + order = int(elem.find('order').text) + axis = elem.find('axis').text + minimum = float(elem.find('min').text) + maximum = float(elem.find('max').text) return cls(order, axis, minimum, maximum, filter_id=filter_id) @@ -363,10 +362,10 @@ class SphericalHarmonicsFilter(ExpansionFilter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - order = int(get_text(elem, "order")) + filter_id = int(elem.get('id')) + order = int(elem.find('order').text) filter = cls(order, filter_id=filter_id) - filter.cosine = get_text(elem, "cosine") + filter.cosine = elem.get('cosine') return filter @@ -519,11 +518,11 @@ class ZernikeFilter(ExpansionFilter): @classmethod def from_xml_element(cls, elem, **kwargs): - filter_id = int(get_text(elem, "id")) - order = int(get_text(elem, "order")) - x = float(get_text(elem, "x")) - y = float(get_text(elem, "y")) - r = float(get_text(elem, "r")) + filter_id = int(elem.get('id')) + order = int(elem.find('order').text) + x = float(elem.find('x').text) + y = float(elem.find('y').text) + r = float(elem.find('r').text) return cls(order, x, y, r, filter_id=filter_id) diff --git a/openmc/geometry.py b/openmc/geometry.py index 8496fb23a..db927c46e 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -1,5 +1,6 @@ from __future__ import annotations import os +import typing from collections import defaultdict from copy import deepcopy from collections.abc import Iterable @@ -7,9 +8,10 @@ from pathlib import Path import warnings import lxml.etree as ET +import numpy as np + import openmc import openmc._xml as xml -from .plots import add_plot_params from .checkvalue import check_type, check_less_than, check_greater_than, PathLike @@ -39,7 +41,7 @@ class Geometry: def __init__( self, - root: openmc.UniverseBase | Iterable[openmc.Cell] | None = None, + root: typing.Optional[openmc.UniverseBase] = None, merge_surfaces: bool = False, surface_precision: int = 10 ): @@ -66,7 +68,7 @@ class Geometry: self._root_universe = root_universe @property - def bounding_box(self) -> openmc.BoundingBox: + def bounding_box(self) -> np.ndarray: return self.root_universe.bounding_box @property @@ -140,6 +142,7 @@ class Geometry: # Clean the indentation in the file to be user-readable xml.clean_indentation(element) + xml.reorder_attributes(element) # TODO: Remove when support is Python 3.8+ return element @@ -217,7 +220,7 @@ class Geometry: # Add any DAGMC universes for e in elem.findall('dagmc_universe'): - dag_univ = openmc.DAGMCUniverse.from_xml_element(e, mats) + dag_univ = openmc.DAGMCUniverse.from_xml_element(e) universes[dag_univ.id] = dag_univ # Dictionary that maps each universe to a list of cells/lattices that @@ -264,7 +267,7 @@ class Geometry: def from_xml( cls, path: PathLike = 'geometry.xml', - materials: PathLike | 'openmc.Materials' | None = 'materials.xml' + materials: typing.Optional[typing.Union[PathLike, 'openmc.Materials']] = 'materials.xml' ) -> Geometry: """Generate geometry from XML file @@ -313,7 +316,7 @@ class Geometry: """ return self.root_universe.find(point) - def get_instances(self, paths) -> int | list[int]: + def get_instances(self, paths) -> typing.Union[int, typing.List[int]]: """Return the instance number(s) for a cell/material in a geometry path. The instance numbers are used as indices into distributed @@ -360,7 +363,7 @@ class Geometry: return indices if return_list else indices[0] - def get_all_cells(self) -> dict[int, openmc.Cell]: + def get_all_cells(self) -> typing.Dict[int, openmc.Cell]: """Return all cells in the geometry. Returns @@ -374,7 +377,7 @@ class Geometry: else: return {} - def get_all_universes(self) -> dict[int, openmc.Universe]: + def get_all_universes(self) -> typing.Dict[int, openmc.Universe]: """Return all universes in the geometry. Returns @@ -389,7 +392,7 @@ class Geometry: universes.update(self.root_universe.get_all_universes()) return universes - def get_all_nuclides(self) -> list[str]: + def get_all_nuclides(self) -> typing.List[str]: """Return all nuclides within the geometry. Returns @@ -403,7 +406,7 @@ class Geometry: all_nuclides |= set(material.get_nuclides()) return sorted(all_nuclides) - def get_all_materials(self) -> dict[int, openmc.Material]: + def get_all_materials(self) -> typing.Dict[int, openmc.Material]: """Return all materials within the geometry. Returns @@ -418,7 +421,7 @@ class Geometry: else: return {} - def get_all_material_cells(self) -> dict[int, openmc.Cell]: + def get_all_material_cells(self) -> typing.Dict[int, openmc.Cell]: """Return all cells filled by a material Returns @@ -437,7 +440,7 @@ class Geometry: return material_cells - def get_all_material_universes(self) -> dict[int, openmc.Universe]: + def get_all_material_universes(self) -> typing.Dict[int, openmc.Universe]: """Return all universes having at least one material-filled cell. This method can be used to find universes that have at least one cell @@ -460,7 +463,7 @@ class Geometry: return material_universes - def get_all_lattices(self) -> dict[int, openmc.Lattice]: + def get_all_lattices(self) -> typing.Dict[int, openmc.Lattice]: """Return all lattices defined Returns @@ -478,7 +481,7 @@ class Geometry: return lattices - def get_all_surfaces(self) -> dict[int, openmc.Surface]: + def get_all_surfaces(self) -> typing.Dict[int, openmc.Surface]: """ Return all surfaces used in the geometry @@ -514,7 +517,7 @@ class Geometry: def get_materials_by_name( self, name, case_sensitive=False, matching=False - ) -> list[openmc.Material]: + ) -> typing.List[openmc.Material]: """Return a list of materials with matching names. Parameters @@ -537,7 +540,7 @@ class Geometry: def get_cells_by_name( self, name, case_sensitive=False, matching=False - ) -> list[openmc.Cell]: + ) -> typing.List[openmc.Cell]: """Return a list of cells with matching names. Parameters @@ -560,7 +563,7 @@ class Geometry: def get_surfaces_by_name( self, name, case_sensitive=False, matching=False - ) -> list[openmc.Surface]: + ) -> typing.List[openmc.Surface]: """Return a list of surfaces with matching names. .. versionadded:: 0.13.3 @@ -585,7 +588,7 @@ class Geometry: def get_cells_by_fill_name( self, name, case_sensitive=False, matching=False - ) -> list[openmc.Cell]: + ) -> typing.List[openmc.Cell]: """Return a list of cells with fills with matching names. Parameters @@ -632,7 +635,7 @@ class Geometry: def get_universes_by_name( self, name, case_sensitive=False, matching=False - ) -> list[openmc.Universe]: + ) -> typing.List[openmc.Universe]: """Return a list of universes with matching names. Parameters @@ -655,7 +658,7 @@ class Geometry: def get_lattices_by_name( self, name, case_sensitive=False, matching=False - ) -> list[openmc.Lattice]: + ) -> typing.List[openmc.Lattice]: """Return a list of lattices with matching names. Parameters @@ -676,7 +679,7 @@ class Geometry: """ return self._get_domains_by_name(name, case_sensitive, matching, 'lattice') - def remove_redundant_surfaces(self) -> dict[int, openmc.Surface]: + def remove_redundant_surfaces(self) -> typing.Dict[int, openmc.Surface]: """Remove and return all of the redundant surfaces. Uses surface_precision attribute of Geometry instance for rounding and @@ -747,37 +750,61 @@ class Geometry: clone.root_universe = self.root_universe.clone() return clone - @add_plot_params def plot(self, *args, **kwargs): """Display a slice plot of the geometry. .. versionadded:: 0.14.0 + + Parameters + ---------- + origin : iterable of float + Coordinates at the origin of the plot. If left as None then the + bounding box center will be used to attempt to ascertain the origin. + Defaults to (0, 0, 0) if the bounding box is not finite + width : iterable of float + Width of the plot in each basis direction. If left as none then the + bounding box width will be used to attempt to ascertain the plot + width. Defaults to (10, 10) if the bounding box is not finite + pixels : Iterable of int or int + If iterable of ints provided, then this directly sets the number of + pixels to use in each basis direction. If int provided, then this + sets the total number of pixels in the plot and the number of pixels + in each basis direction is calculated from this total and the image + aspect ratio. + basis : {'xy', 'xz', 'yz'} + The basis directions for the plot + color_by : {'cell', 'material'} + Indicate whether the plot should be colored by cell or by material + colors : dict + Assigns colors to specific materials or cells. Keys are instances of + :class:`Cell` or :class:`Material` and values are RGB 3-tuples, RGBA + 4-tuples, or strings indicating SVG color names. Red, green, blue, + and alpha should all be floats in the range [0.0, 1.0], for + example:: + + # Make water blue + water = openmc.Cell(fill=h2o) + universe.plot(..., colors={water: (0., 0., 1.)) + seed : int + Seed for the random number generator + openmc_exec : str + Path to OpenMC executable. + axes : matplotlib.Axes + Axes to draw to + legend : bool + Whether a legend showing material or cell names should be drawn + legend_kwargs : dict + Keyword arguments passed to :func:`matplotlib.pyplot.legend`. + outline : bool + Whether outlines between color boundaries should be drawn + axis_units : {'km', 'm', 'cm', 'mm'} + Units used on the plot axis + **kwargs + Keyword arguments passed to :func:`matplotlib.pyplot.imshow` + Returns + ------- + matplotlib.axes.Axes + Axes containing resulting image """ - model = openmc.Model() - model.geometry = self - model.materials = self.get_all_materials().values() - # collect all the material names from the geometry - all_material_names = {m.name for m in model.materials if m.name is not None} - - # makes a placeholder material for each material name if it isn't - # already present on the model. These materials are otherwise missing - # from the geometry and are needed for plotting. - for universe in model.geometry.get_all_universes().values(): - if not isinstance(universe, openmc.DAGMCUniverse): - continue - for name in universe.material_names: - # if this name is already present in the model, skip it - # (this can happen if the same material name is used in multiple - # universes) - if name in all_material_names: - continue - # if the material name is not present on the model, - # create a placeholder material with the same name - # and add it to the model - mat_dag = openmc.Material(name=name) - mat_dag.add_nuclide('H1', 1.0) - model.materials.append(mat_dag) - all_material_names.add(name) - - return model.plot(*args, **kwargs) + return self.root_universe.plot(*args, **kwargs) diff --git a/openmc/lattice.py b/openmc/lattice.py index 21849ec40..518068560 100644 --- a/openmc/lattice.py +++ b/openmc/lattice.py @@ -10,7 +10,7 @@ import numpy as np import openmc import openmc.checkvalue as cv -from ._xml import get_elem_list, get_text +from ._xml import get_text from .mixin import IDManagerMixin @@ -959,17 +959,18 @@ class RectLattice(Lattice): lat_id = int(get_text(elem, 'id')) name = get_text(elem, 'name') lat = cls(lat_id, name) - lat.lower_left = get_elem_list(elem, "lower_left", float) - lat.pitch = get_elem_list(elem, "pitch", float) + lat.lower_left = [float(i) + for i in get_text(elem, 'lower_left').split()] + lat.pitch = [float(i) for i in get_text(elem, 'pitch').split()] outer = get_text(elem, 'outer') if outer is not None: lat.outer = get_universe(int(outer)) # Get array of universes - dimension = get_elem_list(elem, 'dimension', int) + dimension = get_text(elem, 'dimension').split() shape = np.array(dimension, dtype=int)[::-1] - universes = get_elem_list(elem, 'universes', int) - uarray = np.array([get_universe(u) for u in universes]) + uarray = np.array([get_universe(int(i)) for i in + get_text(elem, 'universes').split()]) uarray.shape = shape lat.universes = uarray return lat @@ -1083,11 +1084,8 @@ class HexLattice(Lattice): from the outermost ring), and i is the index with a ring starting from the top and proceeding clockwise. orientation : {'x', 'y'} - The orientation of the lattice. The 'x' orientation means that each - lattice element has two faces that are perpendicular to the x-axis, - while the 'y' orientation means that each lattice element has two faces - that are perpendicular to the y-axis. By default, the orientation is - 'y'. + str by default 'y' orientation of main lattice diagonal another option + - 'x' num_rings : int Number of radial ring positions in the xy-plane num_axial : int @@ -1532,8 +1530,8 @@ class HexLattice(Lattice): lat_id = int(get_text(elem, 'id')) name = get_text(elem, 'name') lat = cls(lat_id, name) - lat.center = get_elem_list(elem, "center", float) - lat.pitch = get_elem_list(elem, "pitch", float) + lat.center = [float(i) for i in get_text(elem, 'center').split()] + lat.pitch = [float(i) for i in get_text(elem, 'pitch').split()] lat.orientation = get_text(elem, 'orientation', 'y') outer = get_text(elem, 'outer') if outer is not None: @@ -1550,8 +1548,8 @@ class HexLattice(Lattice): univs = [deepcopy(univs) for i in range(n_axial)] # Get flat array of universes - universes = get_elem_list(elem, "universes", int) - uarray = np.array([get_universe(u) for u in universes]) + uarray = np.array([get_universe(int(i)) for i in + get_text(elem, 'universes').split()]) # Fill nested lists j = 0 diff --git a/openmc/lib/__init__.py b/openmc/lib/__init__.py index 9b135370f..42d779441 100644 --- a/openmc/lib/__init__.py +++ b/openmc/lib/__init__.py @@ -13,10 +13,11 @@ functions or objects in :mod:`openmc.lib`, for example: """ from ctypes import CDLL, c_bool, c_int -import importlib.resources import os import sys +import pkg_resources + # Determine shared-library suffix if sys.platform == 'darwin': @@ -26,8 +27,9 @@ else: if os.environ.get('READTHEDOCS', None) != 'True': # Open shared library - _filename = importlib.resources.files(__name__) / f'libopenmc.{_suffix}' - _dll = CDLL(str(_filename)) # TODO: Remove str() when Python 3.12+ + _filename = pkg_resources.resource_filename( + __name__, f'libopenmc.{_suffix}') + _dll = CDLL(_filename) else: # For documentation builds, we don't actually have the shared library # available. Instead, we create a mock object so that when the modules @@ -40,18 +42,21 @@ else: def _dagmc_enabled(): return c_bool.in_dll(_dll, "DAGMC_ENABLED").value +def _ncrystal_enabled(): + return c_bool.in_dll(_dll, "NCRYSTAL_ENABLED").value + def _coord_levels(): return c_int.in_dll(_dll, "n_coord_levels").value def _libmesh_enabled(): return c_bool.in_dll(_dll, "LIBMESH_ENABLED").value +def _mcpl_enabled(): + return c_bool.in_dll(_dll, "MCPL_ENABLED").value + def _uwuw_enabled(): return c_bool.in_dll(_dll, "UWUW_ENABLED").value -def _strict_fp_enabled(): - return c_bool.in_dll(_dll, "STRICT_FP_ENABLED").value - from .error import * from .core import * @@ -65,7 +70,6 @@ from .settings import settings from .math import * from .plot import * from .weight_windows import * -from .dagmc import * # Flag to denote whether or not openmc.lib.init has been called # TODO: Establish and use a flag in the C++ code to represent the status of the diff --git a/openmc/lib/cell.py b/openmc/lib/cell.py index dfd09d2f9..971a24cba 100644 --- a/openmc/lib/cell.py +++ b/openmc/lib/cell.py @@ -34,10 +34,6 @@ _dll.openmc_cell_get_temperature.argtypes = [ c_int32, POINTER(c_int32), POINTER(c_double)] _dll.openmc_cell_get_temperature.restype = c_int _dll.openmc_cell_get_temperature.errcheck = _error_handler -_dll.openmc_cell_get_density.argtypes = [ - c_int32, POINTER(c_int32), POINTER(c_double)] -_dll.openmc_cell_get_density.restype = c_int -_dll.openmc_cell_get_density.errcheck = _error_handler _dll.openmc_cell_get_name.argtypes = [c_int32, POINTER(c_char_p)] _dll.openmc_cell_get_name.restype = c_int _dll.openmc_cell_get_name.errcheck = _error_handler @@ -62,10 +58,6 @@ _dll.openmc_cell_set_temperature.argtypes = [ c_int32, c_double, POINTER(c_int32), c_bool] _dll.openmc_cell_set_temperature.restype = c_int _dll.openmc_cell_set_temperature.errcheck = _error_handler -_dll.openmc_cell_set_density.argtypes = [ - c_int32, c_double, POINTER(c_int32), c_bool] -_dll.openmc_cell_set_density.restype = c_int -_dll.openmc_cell_set_density.errcheck = _error_handler _dll.openmc_cell_set_translation.argtypes = [c_int32, POINTER(c_double)] _dll.openmc_cell_set_translation.restype = c_int _dll.openmc_cell_set_translation.errcheck = _error_handler @@ -244,44 +236,6 @@ class Cell(_FortranObjectWithID): _dll.openmc_cell_set_temperature(self._index, T, instance, set_contained) - def get_density(self, instance: int | None = None): - """Get the density of a cell in [g/cm3] - - Parameters - ---------- - instance : int or None - Which instance of the cell - - """ - - if instance is not None: - instance = c_int32(instance) - - rho = c_double() - _dll.openmc_cell_get_density(self._index, instance, rho) - return rho.value - - def set_density(self, rho: float, instance: int | None = None, - set_contained: bool = False): - """Set the density of a cell - - Parameters - ---------- - rho : float - Density of the cell in [g/cm3] - instance : int or None - Which instance of the cell - set_contained : bool - If cell is not filled by a material, whether to set the density - of all filled cells - - """ - - if instance is not None: - instance = c_int32(instance) - - _dll.openmc_cell_set_density(self._index, rho, instance, set_contained) - @property def translation(self): translation = np.zeros(3) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 0ee8c3ff0..a9a549fa0 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -4,17 +4,13 @@ from ctypes import (c_bool, c_int, c_int32, c_int64, c_double, c_char_p, c_uint64, c_size_t) import sys import os -from pathlib import Path from random import getrandbits -from tempfile import TemporaryDirectory -import traceback as tb import numpy as np from numpy.ctypeslib import as_array from . import _dll from .error import _error_handler -from ..mpi import comm from openmc.checkvalue import PathLike import openmc.lib import openmc @@ -28,13 +24,10 @@ class _SourceSite(Structure): ('wgt', c_double), ('delayed_group', c_int), ('surf_id', c_int), - ('particle', c_int32), - ('parent_nuclide', c_int), + ('particle', c_int), ('parent_id', c_int64), - ('progeny_id', c_int64), - ('wgt_born', c_double), - ('wgt_ww_born', c_double), - ('n_split', c_int64)] + ('progeny_id', c_int64)] + # Define input type for numpy arrays that will be passed into C++ functions # Must be an int or double array, with single dimension that is contiguous @@ -84,7 +77,6 @@ _dll.openmc_properties_import.restype = c_int _dll.openmc_properties_import.errcheck = _error_handler _dll.openmc_run.restype = c_int _dll.openmc_run.errcheck = _error_handler -_dll.openmc_run_random_ray.restype = None _dll.openmc_reset.restype = c_int _dll.openmc_reset.errcheck = _error_handler _dll.openmc_reset_timers.restype = c_int @@ -482,24 +474,8 @@ def run(output=True): _dll.openmc_run() -def run_random_ray(output=True): - """Run a random ray simulation - - Parameters - ---------- - output : bool, optional - Whether or not to show output. Defaults to showing output - """ - - with quiet_dll(output): - _dll.openmc_run_random_ray() - -def sample_external_source( - n_samples: int = 1000, - prn_seed: int | None = None, - as_array: bool = False -) -> openmc.ParticleList | np.ndarray: - """Sample external source and return source particles. +def sample_external_source(n_samples=1, prn_seed=None): + """Sample external source .. versionadded:: 0.13.1 @@ -510,20 +486,11 @@ def sample_external_source( prn_seed : int Pseudorandom number generator (PRNG) seed; if None, one will be generated randomly. - as_array : bool - If True, return a numpy structured array instead of a - :class:`~openmc.ParticleList`. The array has fields ``'r'`` (float64, - shape 3), ``'u'`` (float64, shape 3), ``'E'`` (float64), ``'time'`` - (float64), ``'wgt'`` (float64), ``'delayed_group'`` (int32), - ``'surf_id'`` (int32), and ``'particle'`` (int32). This avoids the - overhead of constructing individual :class:`~openmc.SourceParticle` - objects and is substantially faster for large sample counts. Returns ------- - openmc.ParticleList or numpy.ndarray - List of sampled source particles, or a structured array when - *as_array* is True. + list of openmc.SourceParticle + List of samples source particles """ if n_samples <= 0: @@ -531,28 +498,19 @@ def sample_external_source( if prn_seed is None: prn_seed = getrandbits(63) - # Pre-allocate output array and sample all particles in a single C call - result = np.empty(n_samples, dtype=_SourceSite) - sites_array = (_SourceSite * n_samples).from_buffer(result) - _dll.openmc_sample_external_source( - c_size_t(n_samples), - c_uint64(prn_seed), - sites_array, - ) + # Call into C API to sample source + sites_array = (_SourceSite * n_samples)() + _dll.openmc_sample_external_source(c_size_t(n_samples), c_uint64(prn_seed), sites_array) - if as_array: - return result - - particles = [ + # Convert to list of SourceParticle and return + return [ openmc.SourceParticle( - r=site.r, u=site.u, E=site.E, time=site.time, - wgt=site.wgt, delayed_group=site.delayed_group, - surf_id=site.surf_id, - particle=openmc.ParticleType(site.particle), + r=site.r, u=site.u, E=site.E, time=site.time, wgt=site.wgt, + delayed_group=site.delayed_group, surf_id=site.surf_id, + particle=openmc.ParticleType(site.particle) ) for site in sites_array ] - return openmc.ParticleList(particles) def simulation_init(): @@ -656,106 +614,6 @@ def run_in_memory(**kwargs): finalize() -class TemporarySession: - """Context manager for running via openmc.lib in a temporary directory. - - This class is useful for accessing functionality from openmc.lib without - polluting your current working directory with OpenMC files. It is used - internally as a persistent session to avoid loading cross sections multiple - times. - - Parameters - ---------- - model : openmc.Model, optional - OpenMC model to use for the session. If None, a minimal working model is - created. - cwd : PathLike, optional - Working directory in which to run OpenMC. If None, a temporary directory - is created and deleted automatically. - **init_kwargs - Keyword arguments to pass to :func:`openmc.lib.init`. - - Attributes - ---------- - model : openmc.Model - The OpenMC model used for the session. - comm : mpi4py.MPI.Intracomm - The MPI intracommunicator used for the session. - - """ - def __init__(self, model=None, cwd=None, **init_kwargs): - self.init_kwargs = dict(init_kwargs) - self.cwd = cwd - if model is None: - surf = openmc.Sphere(boundary_type="vacuum") - cell = openmc.Cell(region=-surf) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings = openmc.Settings( - particles=1, batches=1, output={'summary': False}) - self.model = model - - # Determine MPI intercommunicator - self.comm = self.init_kwargs.get('intracomm') or comm - self.init_kwargs['intracomm'] = self.comm - - def __enter__(self): - """Initialize the OpenMC library in a temporary directory.""" - # If already initialized, the context manager is a no-op - self.already_initialized = openmc.lib.is_initialized - if self.already_initialized: - return self - - # Store original working directory - self.orig_dir = Path.cwd() - - if self.cwd is None: - # Set up temporary directory on rank 0 - if self.comm.rank == 0: - self._tmp_dir = TemporaryDirectory() - self.cwd = self._tmp_dir.name - - # Broadcast the path so that all ranks use the same directory - self.cwd = self.comm.bcast(self.cwd) - - # Create and change to specified directory - self.cwd = Path(self.cwd) - self.cwd.mkdir(parents=True, exist_ok=True) - os.chdir(self.cwd) - - # Export model on first rank and initialize OpenMC - if self.comm.rank == 0: - self.model.export_to_model_xml() - self.comm.barrier() - openmc.lib.init(**self.init_kwargs) - - return self - - def __exit__(self, exc_type, exc_value, traceback): - """Finalize the OpenMC library and clean up temporary directory.""" - if self.already_initialized: - return - - # If an exception occurred, abort all ranks immediately - if exc_type is not None: - # Print exception info on the rank that failed - tb.print_exception(exc_type, exc_value, traceback) - sys.stdout.flush() - - # Abort all MPI processes - self.comm.Abort(1) - - try: - finalize() - finally: - os.chdir(self.orig_dir) - - # Make sure all ranks have finalized before deleting temporary dir - self.comm.barrier() - if hasattr(self, '_tmp_dir'): - self._tmp_dir.cleanup() - - class _DLLGlobal: """Data descriptor that exposes global variables from libopenmc.""" def __init__(self, ctype, name): diff --git a/openmc/lib/dagmc.py b/openmc/lib/dagmc.py deleted file mode 100644 index 18ec81a4b..000000000 --- a/openmc/lib/dagmc.py +++ /dev/null @@ -1,43 +0,0 @@ -from ctypes import c_int, c_int32, POINTER, c_size_t - -import numpy as np - -from . import _dll -from .error import _error_handler - - -__all__ = [ - 'dagmc_universe_cell_ids' -] - -# DAGMC functions -_dll.openmc_dagmc_universe_get_cell_ids.argtypes = [c_int32, POINTER(c_int32), POINTER(c_size_t)] -_dll.openmc_dagmc_universe_get_cell_ids.restype = c_int -_dll.openmc_dagmc_universe_get_cell_ids.errcheck = _error_handler -_dll.openmc_dagmc_universe_get_num_cells.argtypes = [c_int32, POINTER(c_size_t)] -_dll.openmc_dagmc_universe_get_num_cells.restype = c_int -_dll.openmc_dagmc_universe_get_num_cells.errcheck = _error_handler - - -def dagmc_universe_cell_ids(universe_id: int) -> np.ndarray: - """Return an array of cell IDs for a DAGMC universe. - - Parameters - ---------- - dagmc_id : int - ID of the DAGMC universe to get cell IDs from. - - Returns - ------- - numpy.ndarray - DAGMC cell IDs for the universe. - - """ - n = c_size_t() - _dll.openmc_dagmc_universe_get_num_cells(universe_id, n) - cell_ids = np.empty(n.value, dtype=np.int32) - - _dll.openmc_dagmc_universe_get_cell_ids( - universe_id, cell_ids.ctypes.data_as(POINTER(c_int32)), n - ) - return cell_ids diff --git a/openmc/lib/filter.py b/openmc/lib/filter.py index 574a37443..340c2fa34 100644 --- a/openmc/lib/filter.py +++ b/openmc/lib/filter.py @@ -21,11 +21,9 @@ __all__ = [ 'CellInstanceFilter', 'CollisionFilter', 'DistribcellFilter', 'DelayedGroupFilter', 'EnergyFilter', 'EnergyoutFilter', 'EnergyFunctionFilter', 'LegendreFilter', 'MaterialFilter', 'MaterialFromFilter', 'MeshFilter', 'MeshBornFilter', - 'MeshMaterialFilter', 'MeshSurfaceFilter', 'MuFilter', 'MuSurfaceFilter', - 'ParentNuclideFilter', 'ParticleFilter', 'ParticleProductionFilter', 'PolarFilter', - 'ReactionFilter', 'SphericalHarmonicsFilter', 'SpatialLegendreFilter', - 'SurfaceFilter', 'TimeFilter', 'UniverseFilter', 'WeightFilter', 'ZernikeFilter', - 'ZernikeRadialFilter', 'filters' + 'MeshSurfaceFilter', 'MuFilter', 'ParticleFilter', + 'PolarFilter', 'SphericalHarmonicsFilter', 'SpatialLegendreFilter', 'SurfaceFilter', + 'UniverseFilter', 'ZernikeFilter', 'ZernikeRadialFilter', 'filters' ] # Tally functions @@ -98,14 +96,6 @@ _dll.openmc_mesh_filter_get_translation.errcheck = _error_handler _dll.openmc_mesh_filter_set_translation.argtypes = [c_int32, POINTER(c_double*3)] _dll.openmc_mesh_filter_set_translation.restype = c_int _dll.openmc_mesh_filter_set_translation.errcheck = _error_handler -_dll.openmc_mesh_filter_get_rotation.argtypes = [c_int32, POINTER(c_double), - POINTER(c_size_t)] -_dll.openmc_mesh_filter_get_rotation.restype = c_int -_dll.openmc_mesh_filter_get_rotation.errcheck = _error_handler -_dll.openmc_mesh_filter_set_rotation.argtypes = [ - c_int32, POINTER(c_double), c_size_t] -_dll.openmc_mesh_filter_set_rotation.restype = c_int -_dll.openmc_mesh_filter_set_rotation.errcheck = _error_handler _dll.openmc_meshborn_filter_get_mesh.argtypes = [c_int32, POINTER(c_int32)] _dll.openmc_meshborn_filter_get_mesh.restype = c_int _dll.openmc_meshborn_filter_get_mesh.errcheck = _error_handler @@ -133,9 +123,6 @@ _dll.openmc_meshsurface_filter_set_translation.errcheck = _error_handler _dll.openmc_new_filter.argtypes = [c_char_p, POINTER(c_int32)] _dll.openmc_new_filter.restype = c_int _dll.openmc_new_filter.errcheck = _error_handler -_dll.openmc_particle_filter_get_bins.argtypes = [c_int32, POINTER(c_int32)] -_dll.openmc_particle_filter_get_bins.restype = c_int -_dll.openmc_particle_filter_get_bins.errcheck = _error_handler _dll.openmc_spatial_legendre_filter_get_order.argtypes = [c_int32, POINTER(c_int)] _dll.openmc_spatial_legendre_filter_get_order.restype = c_int _dll.openmc_spatial_legendre_filter_get_order.errcheck = _error_handler @@ -405,10 +392,6 @@ class MeshFilter(Filter): Mesh used for the filter translation : Iterable of float 3-D coordinates of the translation vector - rotation : Iterable of float - The rotation matrix or angles of the filter mesh. This can either be - a fully specified 3 x 3 rotation matrix or an Iterable of length 3 - with the angles in degrees about the x, y, and z axes, respectively. """ filter_type = 'mesh' @@ -438,34 +421,6 @@ class MeshFilter(Filter): def translation(self, translation): _dll.openmc_mesh_filter_set_translation(self._index, (c_double*3)(*translation)) - @property - def rotation(self): - rotation_data = np.zeros(12) - rot_size = c_size_t() - - _dll.openmc_mesh_filter_get_rotation( - self._index, rotation_data.ctypes.data_as(POINTER(c_double)), - rot_size) - rot_size = rot_size.value - - if rot_size == 9: - return rotation_data[:rot_size].shape(3, 3) - elif rot_size in (0, 12): - # If size is 0, rotation_data[9:] will be zeros. This indicates no - # rotation and is the most straightforward way to always return - # an iterable of floats - return rotation_data[9:] - else: - raise ValueError( - f'Invalid size of rotation matrix: {rot_size}') - - @rotation.setter - def rotation(self, rotation_data): - flat_rotation = np.asarray(rotation_data, dtype=float).flatten() - - _dll.openmc_mesh_filter_set_rotation( - self._index, flat_rotation.ctypes.data_as(POINTER(c_double)), - c_size_t(len(flat_rotation))) class MeshBornFilter(Filter): """MeshBorn filter stored internally. @@ -524,10 +479,6 @@ class MeshBornFilter(Filter): _dll.openmc_meshborn_filter_set_translation(self._index, (c_double*3)(*translation)) -class MeshMaterialFilter(Filter): - filter_type = 'meshmaterial' - - class MeshSurfaceFilter(Filter): """MeshSurface filter stored internally. @@ -589,37 +540,21 @@ class MuFilter(Filter): filter_type = 'mu' -class MuSurfaceFilter(Filter): - filter_type = 'musurface' - - -class ParentNuclideFilter(Filter): - filter_type = 'parentnuclide' - - class ParticleFilter(Filter): filter_type = 'particle' @property def bins(self): - particle_i = np.zeros((self.n_bins,), dtype=c_int32) + particle_i = np.zeros((self.n_bins,), dtype=c_int) _dll.openmc_particle_filter_get_bins( - self._index, particle_i.ctypes.data_as(POINTER(c_int32))) + self._index, particle_i.ctypes.data_as(POINTER(c_int))) return [ParticleType(i) for i in particle_i] -class ParticleProductionFilter(Filter): - filter_type = 'particleproduction' - - class PolarFilter(Filter): filter_type = 'polar' -class ReactionFilter(Filter): - filter_type = 'reaction' - - class SphericalHarmonicsFilter(Filter): filter_type = 'sphericalharmonics' @@ -662,18 +597,10 @@ class SurfaceFilter(Filter): filter_type = 'surface' -class TimeFilter(Filter): - filter_type = 'time' - - class UniverseFilter(Filter): filter_type = 'universe' -class WeightFilter(Filter): - filter_type = 'weight' - - class ZernikeFilter(Filter): filter_type = 'zernike' @@ -703,7 +630,6 @@ _FILTER_TYPE_MAP = { 'cellborn': CellbornFilter, 'cellfrom': CellfromFilter, 'cellinstance': CellInstanceFilter, - 'collision': CollisionFilter, 'delayedgroup': DelayedGroupFilter, 'distribcell': DistribcellFilter, 'energy': EnergyFilter, @@ -714,21 +640,14 @@ _FILTER_TYPE_MAP = { 'materialfrom': MaterialFromFilter, 'mesh': MeshFilter, 'meshborn': MeshBornFilter, - 'meshmaterial': MeshMaterialFilter, 'meshsurface': MeshSurfaceFilter, 'mu': MuFilter, - 'musurface': MuSurfaceFilter, - 'parentnuclide': ParentNuclideFilter, 'particle': ParticleFilter, - 'particleproduction': ParticleProductionFilter, 'polar': PolarFilter, - 'reaction': ReactionFilter, 'sphericalharmonics': SphericalHarmonicsFilter, 'spatiallegendre': SpatialLegendreFilter, 'surface': SurfaceFilter, - 'time': TimeFilter, 'universe': UniverseFilter, - 'weight': WeightFilter, 'zernike': ZernikeFilter, 'zernikeradial': ZernikeRadialFilter } diff --git a/openmc/lib/mesh.py b/openmc/lib/mesh.py index 19e6f74d7..3546112b5 100644 --- a/openmc/lib/mesh.py +++ b/openmc/lib/mesh.py @@ -1,8 +1,8 @@ -from collections.abc import Mapping, Sequence -from ctypes import (c_int, c_int32, c_char_p, c_double, POINTER, c_void_p, - create_string_buffer, c_size_t) -from math import sqrt -import sys +from collections.abc import Mapping +from ctypes import (c_int, c_int32, c_char_p, c_double, POINTER, Structure, + create_string_buffer, c_uint64, c_size_t) +from random import getrandbits +from typing import Optional, List, Tuple, Sequence from weakref import WeakValueDictionary import numpy as np @@ -10,20 +10,23 @@ from numpy.ctypeslib import as_array from ..exceptions import AllocationError, InvalidIDError from . import _dll -from .core import _FortranObjectWithID, quiet_dll +from .core import _FortranObjectWithID from .error import _error_handler +from .material import Material from .plot import _Position -from ..bounding_box import BoundingBox -from ..mesh import MeshMaterialVolumes __all__ = [ 'Mesh', 'RegularMesh', 'RectilinearMesh', 'CylindricalMesh', - 'SphericalMesh', 'UnstructuredMesh', 'meshes', 'MeshMaterialVolumes' + 'SphericalMesh', 'UnstructuredMesh', 'meshes' ] -arr_2d_int32 = np.ctypeslib.ndpointer(dtype=np.int32, ndim=2, flags='CONTIGUOUS') -arr_2d_double = np.ctypeslib.ndpointer(dtype=np.double, ndim=2, flags='CONTIGUOUS') +class _MaterialVolume(Structure): + _fields_ = [ + ("material", c_int32), + ("volume", c_double) + ] + # Mesh functions _dll.openmc_extend_meshes.argtypes = [c_int32, c_char_p, POINTER(c_int32), @@ -42,13 +45,9 @@ _dll.openmc_mesh_get_n_elements.errcheck = _error_handler _dll.openmc_mesh_get_volumes.argtypes = [c_int32, POINTER(c_double)] _dll.openmc_mesh_get_volumes.restype = c_int _dll.openmc_mesh_get_volumes.errcheck = _error_handler -_dll.openmc_mesh_bounding_box.argtypes = [ - c_int32, POINTER(c_double), POINTER(c_double)] -_dll.openmc_mesh_bounding_box.restype = c_int -_dll.openmc_mesh_bounding_box.errcheck = _error_handler _dll.openmc_mesh_material_volumes.argtypes = [ - c_int32, c_int, c_int, c_int, c_int, arr_2d_int32, arr_2d_double, - c_void_p] + c_int32, c_int, c_int, c_int, POINTER(_MaterialVolume), + POINTER(c_int), POINTER(c_uint64)] _dll.openmc_mesh_material_volumes.restype = c_int _dll.openmc_mesh_material_volumes.errcheck = _error_handler _dll.openmc_mesh_get_plot_bins.argtypes = [ @@ -168,118 +167,60 @@ class Mesh(_FortranObjectWithID): self._index, volumes.ctypes.data_as(POINTER(c_double))) return volumes - @property - def bounding_box(self) -> BoundingBox: - inf = sys.float_info.max - ll = np.zeros(3) - ur = np.zeros(3) - _dll.openmc_mesh_bounding_box( - self._index, - ll.ctypes.data_as(POINTER(c_double)), - ur.ctypes.data_as(POINTER(c_double)) - ) - ll[ll == inf] = np.inf - ur[ur == inf] = np.inf - ll[ll == -inf] = -np.inf - ur[ur == -inf] = -np.inf - return BoundingBox(ll, ur) - def material_volumes( self, - n_samples: int | tuple[int, int, int] = 10_000, - max_materials: int = 4, - output: bool = True, - bounding_boxes: bool = False, - ) -> MeshMaterialVolumes: - """Determine volume of materials in each mesh element. - - This method works by raytracing repeatedly through the mesh to count the - estimated volume of each material in all mesh elements. Three sets of - rays are used: one set parallel to the x-axis, one parallel to the - y-axis, and one parallel to the z-axis. + n_samples: int = 10_000, + prn_seed: Optional[int] = None + ) -> List[List[Tuple[Material, float]]]: + """Determine volume of materials in each mesh element .. versionadded:: 0.15.0 - .. versionchanged:: 0.15.1 - Material volumes are now determined by raytracing rather than by - point sampling. - Parameters ---------- - n_samples : int or 3-tuple of int - Total number of rays to sample. The number of rays in each direction - is determined by the aspect ratio of the mesh bounding box. When - specified as a 3-tuple, it is interpreted as the number of rays in - the x, y, and z dimensions. - max_materials : int, optional - Estimated maximum number of materials in any given mesh element. - output : bool, optional - Whether or not to show output. - bounding_boxes : bool, optional - Whether or not to compute an axis-aligned bounding box for each - (mesh element, material) combination. When enabled, the bounding - box encloses the ray-estimator prisms used for the volume - estimation. + n_samples : int + Number of samples in each mesh element + prn_seed : int + Pseudorandom number generator (PRNG) seed; if None, one will be + generated randomly. Returns ------- - MeshMaterialVolumes - Dictionary-like object that maps material IDs to an array of volumes - equal in size to the number of mesh elements. + List of tuple of (material, volume) for each mesh element. Void volume + is represented by having a value of None in the first element of a + tuple. """ - if isinstance(n_samples, int): - # Determine number of rays in each direction based on aspect ratios - # and using the relation (nx*ny + ny*nz + nx*nz) = n_samples - width_x, width_y, width_z = self.bounding_box.width - ax = width_x / width_z - ay = width_y / width_z - f = sqrt(n_samples/(ax*ay + ax + ay)) - nx = round(f * ax) - ny = round(f * ay) - nz = round(f) - else: - nx, ny, nz = n_samples + if n_samples <= 0: + raise ValueError("Number of samples must be positive") + if prn_seed is None: + prn_seed = getrandbits(63) + prn_seed = c_uint64(prn_seed) - # Value indicating an empty slot in the hash table (matches C++) - EMPTY_SLOT = -2 + # Preallocate space for MaterialVolume results + size = 16 + result = (_MaterialVolume * size)() - # Preallocate arrays for material indices and volumes - n = self.n_elements - slot_factor = 2 - table_size = slot_factor*max_materials - materials = np.full((n, table_size), EMPTY_SLOT, dtype=np.int32) - volumes = np.zeros((n, table_size), dtype=np.float64) - bboxes = None - if bounding_boxes: - bboxes = np.empty((n, table_size, 6), dtype=np.float64) - bboxes[..., 0:3] = np.inf - bboxes[..., 3:6] = -np.inf - - # Run material volume calculation - while True: - try: - bboxes_ptr = None - if bboxes is not None: - bboxes_ptr = bboxes.ctypes.data_as(POINTER(c_double)) - with quiet_dll(output): + hits = c_int() # Number of materials hit in a given element + volumes = [] + for i_element in range(self.n_elements): + while True: + try: _dll.openmc_mesh_material_volumes( - self._index, nx, ny, nz, table_size, materials, - volumes, bboxes_ptr) - except AllocationError: - # Increase size of result array and try again - table_size *= 2 - materials = np.full((n, table_size), EMPTY_SLOT, dtype=np.int32) - volumes = np.zeros((n, table_size), dtype=np.float64) - if bounding_boxes: - bboxes = np.empty((n, table_size, 6), dtype=np.float64) - bboxes[..., 0:3] = np.inf - bboxes[..., 3:6] = -np.inf - else: - # If no error, break out of loop - break + self._index, n_samples, i_element, size, result, hits, prn_seed) + except AllocationError: + # Increase size of result array and try again + size *= 2 + result = (_MaterialVolume * size)() + else: + # If no error, break out of loop + break - return MeshMaterialVolumes(materials, volumes, bboxes) + volumes.append([ + (Material(index=r.material), r.volume) + for r in result[:hits.value] + ]) + return volumes def get_plot_bins( self, @@ -344,7 +285,7 @@ class RegularMesh(Mesh): The lower-left corner of the structured mesh. If only two coordinate are given, it is assumed that the mesh is an x-y mesh. upper_right : numpy.ndarray - The upper-right corner of the structured mesh. If only two coordinate + The upper-right corner of the structrued mesh. If only two coordinate are given, it is assumed that the mesh is an x-y mesh. width : numpy.ndarray The width of mesh cells in each direction. @@ -352,8 +293,6 @@ class RegularMesh(Mesh): Total number of mesh elements. volumes : numpy.ndarray Volume of each mesh element in [cm^3] - bounding_box : openmc.BoundingBox - Axis-aligned bounding box of the mesh """ mesh_type = 'regular' @@ -433,15 +372,13 @@ class RectilinearMesh(Mesh): lower_left : numpy.ndarray The lower-left corner of the structured mesh. upper_right : numpy.ndarray - The upper-right corner of the structured mesh. + The upper-right corner of the structrued mesh. width : numpy.ndarray The width of mesh cells in each direction. n_elements : int Total number of mesh elements. volumes : numpy.ndarray Volume of each mesh element in [cm^3] - bounding_box : openmc.BoundingBox - Axis-aligned bounding box of the mesh """ mesh_type = 'rectilinear' @@ -538,15 +475,13 @@ class CylindricalMesh(Mesh): lower_left : numpy.ndarray The lower-left corner of the structured mesh. upper_right : numpy.ndarray - The upper-right corner of the structured mesh. + The upper-right corner of the structrued mesh. width : numpy.ndarray The width of mesh cells in each direction. n_elements : int Total number of mesh elements. volumes : numpy.ndarray Volume of each mesh element in [cm^3] - bounding_box : openmc.BoundingBox - Axis-aligned bounding box of the mesh """ mesh_type = 'cylindrical' @@ -643,15 +578,13 @@ class SphericalMesh(Mesh): lower_left : numpy.ndarray The lower-left corner of the structured mesh. upper_right : numpy.ndarray - The upper-right corner of the structured mesh. + The upper-right corner of the structrued mesh. width : numpy.ndarray The width of mesh cells in each direction. n_elements : int Total number of mesh elements. volumes : numpy.ndarray Volume of each mesh element in [cm^3] - bounding_box : openmc.BoundingBox - Axis-aligned bounding box of the mesh """ mesh_type = 'spherical' @@ -757,6 +690,7 @@ class _MeshMapping(Mapping): raise KeyError(str(e)) return _get_mesh(index.value) + def __iter__(self): for i in range(len(self)): yield _get_mesh(i).id diff --git a/openmc/lib/nuclide.py b/openmc/lib/nuclide.py index ef1287cf3..8078882cf 100644 --- a/openmc/lib/nuclide.py +++ b/openmc/lib/nuclide.py @@ -40,14 +40,8 @@ def load_nuclide(name): name : str Name of the nuclide, e.g. 'U235' - Returns - ------- - Nuclide - The class:`Nuclide` that was just loaded. - """ _dll.openmc_load_nuclide(name.encode(), None, 0) - return nuclides[name] class Nuclide(_FortranObject): diff --git a/openmc/lib/plot.py b/openmc/lib/plot.py index 196682394..d98636676 100644 --- a/openmc/lib/plot.py +++ b/openmc/lib/plot.py @@ -1,15 +1,10 @@ -from collections.abc import Mapping from ctypes import (c_bool, c_int, c_size_t, c_int32, - c_double, c_uint8, Structure, POINTER) -from weakref import WeakValueDictionary + c_double, Structure, POINTER) -from ..exceptions import AllocationError, InvalidIDError from . import _dll -from .core import _FortranObjectWithID from .error import _error_handler import numpy as np -import warnings class _Position(Structure): @@ -52,637 +47,219 @@ class _Position(Structure): return f"({self.x}, {self.y}, {self.z})" -def _extract_slice_data_args(plot): - """Convert a legacy plot-like object into slice_data keyword arguments.""" - try: - kwargs = { - 'origin': tuple(plot.origin), - 'width': (plot.width, plot.height), - 'basis': plot.basis, - 'pixels': (plot.h_res, plot.v_res), - 'show_overlaps': getattr(plot, 'color_overlaps', False), - 'level': getattr(plot, 'level', -1), - } - except AttributeError as exc: - raise TypeError( - "plot must be a legacy plot-like object with origin, width, " - "height, basis, h_res, and v_res attributes." - ) from exc - return kwargs - - -_dll.openmc_slice_data.argtypes = [ - POINTER(c_double * 3), # origin - POINTER(c_double * 3), # u_span - POINTER(c_double * 3), # v_span - POINTER(c_size_t * 2), # pixels - c_bool, # show_overlaps - c_int, # level - c_int32, # filter_index - POINTER(c_int32), # geom_data - POINTER(c_double), # property_data (can be None) -] -_dll.openmc_slice_data.restype = c_int -_dll.openmc_slice_data.errcheck = _error_handler - - -def slice_data(origin, width=None, basis='xy', u_span=None, v_span=None, - pixels=None, show_overlaps=False, level=None, filter=None, - include_properties=True): - """Generate a 2D raster of geometry and property data for plotting. - - Parameters - ---------- - origin : sequence of float - Center position of the plot [x, y, z] - width : sequence of float - Width of the plot [horizontal, vertical]. Mutually exclusive with - u_span/v_span. - basis : {'xy', 'xz', 'yz'} or int - Plot basis. Ignored if u_span/v_span are provided. - u_span : sequence of float, optional - Full-width span vector for the horizontal axis (3 values). Mutually - exclusive with width. - v_span : sequence of float, optional - Full-height span vector for the vertical axis (3 values). Mutually - exclusive with width. - pixels : sequence of int - Number of pixels [horizontal, vertical] - show_overlaps : bool, optional - Whether to detect overlapping cells - level : int, optional - Universe level (None for deepest) - filter : openmc.lib.Filter, optional - Filter for bin index lookup - include_properties : bool, optional - Whether to compute temperature/density - - Returns - ------- - geom_data : numpy.ndarray - Array of shape (v_res, h_res, 3) or (v_res, h_res, 4) with int32 dtype. - Contains [cell_id, cell_instance, material_id] when no filter is provided, - or [cell_id, cell_instance, material_id, filter_bin] when a filter is provided. - property_data : numpy.ndarray or None - Array of shape (v_res, h_res, 2) with float64 dtype containing - [temperature, density], or None if include_properties=False - """ - # Set deepest level as default - if level is None: - level = -1 - if not isinstance(level, int): - raise TypeError("level must be an integer.") - - if pixels is None: - raise ValueError("pixels must be specified.") - if len(pixels) != 2: - raise ValueError("pixels must be a length-2 sequence.") - - if width is not None and (u_span is not None or v_span is not None): - raise ValueError("width is mutually exclusive with u_span/v_span.") - - if u_span is not None or v_span is not None: - if u_span is None or v_span is None: - raise ValueError("Both u_span and v_span must be provided.") - u_span = np.asarray(u_span, dtype=float) - v_span = np.asarray(v_span, dtype=float) - if u_span.shape != (3,) or v_span.shape != (3,): - raise ValueError("u_span and v_span must be length-3 sequences.") - u_norm = np.linalg.norm(u_span) - v_norm = np.linalg.norm(v_span) - if u_norm == 0.0 or v_norm == 0.0: - raise ValueError("u_span and v_span must be non-zero vectors.") - dot = float(np.dot(u_span, v_span)) - ortho_tol = 1.0e-10 * u_norm * v_norm - if abs(dot) > ortho_tol: - raise ValueError("u_span and v_span must be orthogonal.") - else: - if width is None: - raise ValueError("width must be provided when u_span/v_span are not set.") - if len(width) != 2: - raise ValueError("width must be a length-2 sequence.") - basis_map = {'xy': 1, 'xz': 2, 'yz': 3} - if isinstance(basis, str): - basis = basis.lower() - if basis not in basis_map: - raise ValueError(f"{basis} is not a valid plot basis.") - basis = basis_map[basis] - elif isinstance(basis, int): - if basis not in basis_map.values(): - raise ValueError(f"{basis} is not a valid plot basis.") - else: - raise ValueError(f"{basis} is not a valid plot basis.") - - if basis == 1: - u_span = np.array([width[0], 0.0, 0.0], dtype=float) - v_span = np.array([0.0, width[1], 0.0], dtype=float) - elif basis == 2: - u_span = np.array([width[0], 0.0, 0.0], dtype=float) - v_span = np.array([0.0, 0.0, width[1]], dtype=float) - else: - u_span = np.array([0.0, width[0], 0.0], dtype=float) - v_span = np.array([0.0, 0.0, width[1]], dtype=float) - - origin = np.asarray(origin, dtype=float) - if origin.shape != (3,): - raise ValueError("origin must be a length-3 sequence.") - - # Prepare ctypes arrays - origin_arr = (c_double * 3)(*origin) - u_span_arr = (c_double * 3)(*u_span) - v_span_arr = (c_double * 3)(*v_span) - pixels_arr = (c_size_t * 2)(*pixels) - - # Get internal filter index from filter ID if filter is provided - if filter is not None: - filter_index = c_int32() - _dll.openmc_get_filter_index(filter.id, filter_index) - filter_index = filter_index.value - else: - filter_index = -1 - - # Allocate output arrays with dynamic size based on filter - n_geom_fields = 4 if filter is not None else 3 - geom_data = np.zeros((pixels[1], pixels[0], n_geom_fields), dtype=np.int32) - if include_properties: - property_data = np.zeros((pixels[1], pixels[0], 2), dtype=np.float64) - prop_ptr = property_data.ctypes.data_as(POINTER(c_double)) - else: - property_data = None - prop_ptr = None - - _dll.openmc_slice_data( - origin_arr, - u_span_arr, - v_span_arr, - pixels_arr, - show_overlaps, - level, - filter_index, - geom_data.ctypes.data_as(POINTER(c_int32)), - prop_ptr - ) - - return geom_data, property_data - - -def id_map(plot): - """Deprecated compatibility wrapper for geometry ID maps. - - This function is kept for compatibility and will be removed in a future - release. Use `slice_data(..., include_properties=False)` instead. - """ - warnings.warn( - "openmc.lib.id_map is deprecated and will be removed in a future " - "release; use openmc.lib.slice_data(..., include_properties=False).", - FutureWarning, - ) - - kwargs = _extract_slice_data_args(plot) - geom_data, _ = slice_data(include_properties=False, **kwargs) - return geom_data[:, :, :3] - - -def property_map(plot): - """Deprecated compatibility wrapper for temperature/density maps. - - This function is kept for compatibility and will be removed in a future - release. Use `slice_data(..., include_properties=True)` instead. - """ - warnings.warn( - "openmc.lib.property_map is deprecated and will be removed in a " - "future release; use openmc.lib.slice_data(..., " - "include_properties=True).", - FutureWarning, - ) - - kwargs = _extract_slice_data_args(plot) - _, prop_data = slice_data(include_properties=True, **kwargs) - return prop_data - - -_dll.openmc_slice_data_overlap_count.argtypes = [POINTER(c_size_t)] -_dll.openmc_slice_data_overlap_count.restype = c_int -_dll.openmc_slice_data_overlap_count.errcheck = _error_handler - -_dll.openmc_slice_data_overlap_info.argtypes = [c_size_t, POINTER(c_int32)] -_dll.openmc_slice_data_overlap_info.restype = c_int -_dll.openmc_slice_data_overlap_info.errcheck = _error_handler - - -# Python wrappings for overlap functions -def slice_data_overlap_count() -> int: - """Return the number of unique overlaps from the last slice plot. - - Returns - ------- - int - Number of unique overlapping cell pairs detected by the most recent - :func:`slice_data` call with overlap checking enabled. - """ - count = c_size_t() - _dll.openmc_slice_data_overlap_count(count) - return count.value - - -def slice_data_overlap_info() -> np.ndarray: - """Return identifying information for overlaps from the last slice plot. - - Returns - ------- - numpy.ndarray - Array of shape ``(n, 3)`` with int32 dtype, where ``n`` is the number - of unique overlaps detected by the most recent :func:`slice_data` call - with overlap checking enabled. Each row contains ``[universe_id, - cell1_id, cell2_id]``. - """ - n = slice_data_overlap_count() - overlap_info = np.empty((n, 3), dtype=np.int32) - - if n > 0: - _dll.openmc_slice_data_overlap_info( - n, - overlap_info.ctypes.data_as(POINTER(c_int32)), - ) - return overlap_info - - -_dll.openmc_get_plot_index.argtypes = [c_int32, POINTER(c_int32)] -_dll.openmc_get_plot_index.restype = c_int -_dll.openmc_get_plot_index.errcheck = _error_handler - -_dll.openmc_plot_get_id.argtypes = [c_int32, POINTER(c_int32)] -_dll.openmc_plot_get_id.restype = c_int -_dll.openmc_plot_get_id.errcheck = _error_handler - -_dll.openmc_plot_set_id.argtypes = [c_int32, c_int32] -_dll.openmc_plot_set_id.restype = c_int -_dll.openmc_plot_set_id.errcheck = _error_handler - -_dll.openmc_plots_size.restype = c_size_t - -_dll.openmc_solidraytrace_plot_create.argtypes = [POINTER(c_int32)] -_dll.openmc_solidraytrace_plot_create.restype = c_int -_dll.openmc_solidraytrace_plot_create.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_pixels.argtypes = [ - c_int32, POINTER(c_int32), POINTER(c_int32)] -_dll.openmc_solidraytrace_plot_get_pixels.restype = c_int -_dll.openmc_solidraytrace_plot_get_pixels.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_pixels.argtypes = [c_int32, c_int32, c_int32] -_dll.openmc_solidraytrace_plot_set_pixels.restype = c_int -_dll.openmc_solidraytrace_plot_set_pixels.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_color_by.argtypes = [c_int32, POINTER(c_int32)] -_dll.openmc_solidraytrace_plot_get_color_by.restype = c_int -_dll.openmc_solidraytrace_plot_get_color_by.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_color_by.argtypes = [c_int32, c_int32] -_dll.openmc_solidraytrace_plot_set_color_by.restype = c_int -_dll.openmc_solidraytrace_plot_set_color_by.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_default_colors.argtypes = [c_int32] -_dll.openmc_solidraytrace_plot_set_default_colors.restype = c_int -_dll.openmc_solidraytrace_plot_set_default_colors.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_all_opaque.argtypes = [c_int32] -_dll.openmc_solidraytrace_plot_set_all_opaque.restype = c_int -_dll.openmc_solidraytrace_plot_set_all_opaque.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_opaque.argtypes = [c_int32, c_int32, c_bool] -_dll.openmc_solidraytrace_plot_set_opaque.restype = c_int -_dll.openmc_solidraytrace_plot_set_opaque.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_color.argtypes = [c_int32, c_int32, c_uint8, c_uint8, c_uint8] -_dll.openmc_solidraytrace_plot_set_color.restype = c_int -_dll.openmc_solidraytrace_plot_set_color.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_camera_position.argtypes = [ - c_int32, POINTER(c_double), POINTER(c_double), POINTER(c_double)] -_dll.openmc_solidraytrace_plot_get_camera_position.restype = c_int -_dll.openmc_solidraytrace_plot_get_camera_position.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_camera_position.argtypes = [c_int32, c_double, c_double, c_double] -_dll.openmc_solidraytrace_plot_set_camera_position.restype = c_int -_dll.openmc_solidraytrace_plot_set_camera_position.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_look_at.argtypes = [ - c_int32, POINTER(c_double), POINTER(c_double), POINTER(c_double)] -_dll.openmc_solidraytrace_plot_get_look_at.restype = c_int -_dll.openmc_solidraytrace_plot_get_look_at.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_look_at.argtypes = [c_int32, c_double, c_double, c_double] -_dll.openmc_solidraytrace_plot_set_look_at.restype = c_int -_dll.openmc_solidraytrace_plot_set_look_at.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_up.argtypes = [ - c_int32, POINTER(c_double), POINTER(c_double), POINTER(c_double)] -_dll.openmc_solidraytrace_plot_get_up.restype = c_int -_dll.openmc_solidraytrace_plot_get_up.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_up.argtypes = [c_int32, c_double, c_double, c_double] -_dll.openmc_solidraytrace_plot_set_up.restype = c_int -_dll.openmc_solidraytrace_plot_set_up.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_light_position.argtypes = [ - c_int32, POINTER(c_double), POINTER(c_double), POINTER(c_double)] -_dll.openmc_solidraytrace_plot_get_light_position.restype = c_int -_dll.openmc_solidraytrace_plot_get_light_position.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_light_position.argtypes = [c_int32, c_double, c_double, c_double] -_dll.openmc_solidraytrace_plot_set_light_position.restype = c_int -_dll.openmc_solidraytrace_plot_set_light_position.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_fov.argtypes = [c_int32, POINTER(c_double)] -_dll.openmc_solidraytrace_plot_get_fov.restype = c_int -_dll.openmc_solidraytrace_plot_get_fov.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_fov.argtypes = [c_int32, c_double] -_dll.openmc_solidraytrace_plot_set_fov.restype = c_int -_dll.openmc_solidraytrace_plot_set_fov.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_update_view.argtypes = [c_int32] -_dll.openmc_solidraytrace_plot_update_view.restype = c_int -_dll.openmc_solidraytrace_plot_update_view.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_create_image.argtypes = [c_int32, POINTER(c_uint8), c_int32, c_int32] -_dll.openmc_solidraytrace_plot_create_image.restype = c_int -_dll.openmc_solidraytrace_plot_create_image.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_color.argtypes = [c_int32, c_int32, - POINTER(c_uint8), POINTER(c_uint8), POINTER(c_uint8)] -_dll.openmc_solidraytrace_plot_get_color.restype = c_int -_dll.openmc_solidraytrace_plot_get_color.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_get_diffuse_fraction.argtypes = [ - c_int32, POINTER(c_double)] -_dll.openmc_solidraytrace_plot_get_diffuse_fraction.restype = c_int -_dll.openmc_solidraytrace_plot_get_diffuse_fraction.errcheck = _error_handler - -_dll.openmc_solidraytrace_plot_set_diffuse_fraction.argtypes = [c_int32, c_double] -_dll.openmc_solidraytrace_plot_set_diffuse_fraction.restype = c_int -_dll.openmc_solidraytrace_plot_set_diffuse_fraction.errcheck = _error_handler - - -class SolidRayTracePlot(_FortranObjectWithID): - """Solid ray-traced plot stored internally. - - This class exposes a solid ray-traced plot that is stored internally in - the OpenMC library. To obtain a view of an existing plot with a given ID, - use the :data:`openmc.lib.plots` mapping. - - Parameters - ---------- - uid : int or None - Unique ID of the plot - new : bool - When `index` is None, this argument controls whether a new object is - created or a view of an existing object is returned. - index : int or None - Index in the internal plots array. +class _PlotBase(Structure): + """A structure defining a 2-D geometry slice with underlying c-types + + C-Type Attributes + ----------------- + origin : openmc.lib.plot._Position + A position defining the origin of the plot. + width_ : openmc.lib.plot._Position + The width of the plot along the x, y, and z axes, respectively + basis_ : c_int + The axes basis of the plot view. + pixels_ : c_size_t[3] + The resolution of the plot in the horizontal and vertical dimensions + level_ : c_int + The universe level for the plot view Attributes ---------- - id : int - Unique ID of the plot. - pixels : tuple of int - Plot image dimensions as ``(width, height)``. - color_by : int - Coloring mode. Use :attr:`COLOR_BY_MATERIAL` or - :attr:`COLOR_BY_CELL`. - camera_position : tuple of float - Camera position as ``(x, y, z)``. - look_at : tuple of float - Point the camera is aimed at as ``(x, y, z)``. - up : tuple of float - Up direction as ``(x, y, z)``. - light_position : tuple of float - Position of the light source as ``(x, y, z)``. - fov : float - Horizontal field-of-view angle in degrees. - diffuse_fraction : float - Fraction of reflected light treated as diffuse (0 to 1). + origin : tuple or list of ndarray + Origin (center) of the plot + width : float + The horizontal dimension of the plot in geometry units (cm) + height : float + The vertical dimension of the plot in geometry units (cm) + basis : string + One of {'xy', 'xz', 'yz'} indicating the horizontal and vertical + axes of the plot. + h_res : int + The horizontal resolution of the plot in pixels + v_res : int + The vertical resolution of the plot in pixels + level : int + The universe level for the plot (default: -1 -> all universes shown) """ + _fields_ = [('origin_', _Position), + ('width_', _Position), + ('basis_', c_int), + ('pixels_', 3*c_size_t), + ('color_overlaps_', c_bool), + ('level_', c_int)] - COLOR_BY_MATERIAL = 0 - COLOR_BY_CELL = 1 - __instances = WeakValueDictionary() - - def __new__(cls, uid=None, new=True, index=None): - mapping = plots - if index is None: - if new: - if uid is not None and uid in mapping: - raise AllocationError( - f'A plot with ID={uid} has already been allocated.' - ) - index = c_int32() - _dll.openmc_solidraytrace_plot_create(index) - index = index.value - else: - index = mapping[uid]._index - - if index not in cls.__instances: - instance = super().__new__(cls) - instance._index = index - if uid is not None: - instance.id = uid - cls.__instances[index] = instance - - return cls.__instances[index] - - def __init__(self, uid=None, new=True, index=None): - super().__init__(uid, new, index) + def __init__(self): + self.level_ = -1 + self.color_overlaps_ = False @property - def id(self): - plot_id = c_int32() - _dll.openmc_plot_get_id(self._index, plot_id) - return plot_id.value + def origin(self): + return self.origin_ - @id.setter - def id(self, plot_id): - _dll.openmc_plot_set_id(self._index, plot_id) - - @staticmethod - def _get_xyz(getter, index): - x = c_double() - y = c_double() - z = c_double() - getter(index, x, y, z) - return (x.value, y.value, z.value) - - @staticmethod - def _set_xyz(setter, index, xyz): - x, y, z = xyz - setter(index, float(x), float(y), float(z)) + @origin.setter + def origin(self, origin): + self.origin_.x = origin[0] + self.origin_.y = origin[1] + self.origin_.z = origin[2] @property - def pixels(self): - width = c_int32() - height = c_int32() - _dll.openmc_solidraytrace_plot_get_pixels(self._index, width, height) - return (width.value, height.value) + def width(self): + return self.width_.x - @pixels.setter - def pixels(self, pixels): - width, height = pixels - _dll.openmc_solidraytrace_plot_set_pixels( - self._index, int(width), int(height)) + @width.setter + def width(self, width): + self.width_.x = width @property - def color_by(self): - color_by = c_int32() - _dll.openmc_solidraytrace_plot_get_color_by(self._index, color_by) - return color_by.value + def height(self): + return self.width_.y - @color_by.setter - def color_by(self, color_by): - _dll.openmc_solidraytrace_plot_set_color_by(self._index, int(color_by)) - - def set_default_colors(self): - _dll.openmc_solidraytrace_plot_set_default_colors(self._index) - - def set_all_opaque(self): - _dll.openmc_solidraytrace_plot_set_all_opaque(self._index) - - def set_visibility(self, domain_id, visible): - _dll.openmc_solidraytrace_plot_set_opaque( - self._index, int(domain_id), bool(visible) - ) - - def set_color(self, domain_id, color): - r, g, b = [int(c) for c in color] - _dll.openmc_solidraytrace_plot_set_color( - self._index, int(domain_id), r, g, b) + @height.setter + def height(self, height): + self.width_.y = height @property - def camera_position(self): - return self._get_xyz(_dll.openmc_solidraytrace_plot_get_camera_position, - self._index) + def basis(self): + if self.basis_ == 1: + return 'xy' + elif self.basis_ == 2: + return 'xz' + elif self.basis_ == 3: + return 'yz' - @camera_position.setter - def camera_position(self, position): - self._set_xyz(_dll.openmc_solidraytrace_plot_set_camera_position, - self._index, position) + raise ValueError(f"Plot basis {self.basis_} is invalid") + + @basis.setter + def basis(self, basis): + if isinstance(basis, str): + valid_bases = ('xy', 'xz', 'yz') + basis = basis.lower() + if basis not in valid_bases: + raise ValueError(f"{basis} is not a valid plot basis.") + + if basis == 'xy': + self.basis_ = 1 + elif basis == 'xz': + self.basis_ = 2 + elif basis == 'yz': + self.basis_ = 3 + return + + if isinstance(basis, int): + valid_bases = (1, 2, 3) + if basis not in valid_bases: + raise ValueError(f"{basis} is not a valid plot basis.") + self.basis_ = basis + return + + raise ValueError(f"{basis} of type {type(basis)} is an invalid plot basis") @property - def look_at(self): - return self._get_xyz(_dll.openmc_solidraytrace_plot_get_look_at, - self._index) + def h_res(self): + return self.pixels_[0] - @look_at.setter - def look_at(self, position): - self._set_xyz(_dll.openmc_solidraytrace_plot_set_look_at, - self._index, position) + @h_res.setter + def h_res(self, h_res): + self.pixels_[0] = h_res @property - def up(self): - return self._get_xyz(_dll.openmc_solidraytrace_plot_get_up, self._index) + def v_res(self): + return self.pixels_[1] - @up.setter - def up(self, direction): - self._set_xyz(_dll.openmc_solidraytrace_plot_set_up, self._index, - direction) + @v_res.setter + def v_res(self, v_res): + self.pixels_[1] = v_res @property - def light_position(self): - return self._get_xyz(_dll.openmc_solidraytrace_plot_get_light_position, - self._index) + def level(self): + return int(self.level_) - @light_position.setter - def light_position(self, position): - self._set_xyz(_dll.openmc_solidraytrace_plot_set_light_position, - self._index, position) + @level.setter + def level(self, level): + self.level_ = level @property - def fov(self): - fov = c_double() - _dll.openmc_solidraytrace_plot_get_fov(self._index, fov) - return fov.value + def color_overlaps(self): + return self.color_overlaps_ - @fov.setter - def fov(self, fov): - _dll.openmc_solidraytrace_plot_set_fov(self._index, float(fov)) - - def update_view(self): - _dll.openmc_solidraytrace_plot_update_view(self._index) - - def create_image(self): - width, height = self.pixels - image = np.zeros((height, width, 3), dtype=np.uint8) - _dll.openmc_solidraytrace_plot_create_image( - self._index, - image.ctypes.data_as(POINTER(c_uint8)), - width, - height - ) - return image - - def get_color(self, domain_id): - r = c_uint8() - g = c_uint8() - b = c_uint8() - _dll.openmc_solidraytrace_plot_get_color( - self._index, int(domain_id), r, g, b) - return int(r.value), int(g.value), int(b.value) + @color_overlaps.setter + def color_overlaps(self, color_overlaps): + self.color_overlaps_ = color_overlaps @property - def diffuse_fraction(self): - value = c_double() - _dll.openmc_solidraytrace_plot_get_diffuse_fraction(self._index, value) - return value.value + def color_overlaps(self): + return self.color_overlaps_ - @diffuse_fraction.setter - def diffuse_fraction(self, value): - _dll.openmc_solidraytrace_plot_set_diffuse_fraction( - self._index, float(value)) - - # Backward-compatible setter aliases - def set_pixels(self, width, height): - self.pixels = (width, height) - - def set_color_by(self, color_by): - self.color_by = color_by - - def set_camera_position(self, x, y, z): - self.camera_position = (x, y, z) - - def set_look_at(self, x, y, z): - self.look_at = (x, y, z) - - def set_up(self, x, y, z): - self.up = (x, y, z) - - def set_light_position(self, x, y, z): - self.light_position = (x, y, z) - - def set_fov(self, fov): - self.fov = fov - - def set_diffuse_fraction(self, value): - self.diffuse_fraction = value - - -class _PlotMapping(Mapping): - def __getitem__(self, key): - index = c_int32() - try: - _dll.openmc_get_plot_index(key, index) - except (AllocationError, InvalidIDError) as e: - raise KeyError(str(e)) - return SolidRayTracePlot(index=index.value) - - def __iter__(self): - for i in range(len(self)): - yield SolidRayTracePlot(index=i).id - - def __len__(self): - return _dll.openmc_plots_size() + @color_overlaps.setter + def color_overlaps(self, val): + self.color_overlaps_ = val def __repr__(self): - return repr(dict(self)) + out_str = ["-----", + "Plot:", + "-----", + f"Origin: {self.origin}", + f"Width: {self.width}", + f"Height: {self.height}", + f"Basis: {self.basis}", + f"HRes: {self.h_res}", + f"VRes: {self.v_res}", + f"Color Overlaps: {self.color_overlaps}", + f"Level: {self.level}"] + return '\n'.join(out_str) -plots = _PlotMapping() +_dll.openmc_id_map.argtypes = [POINTER(_PlotBase), POINTER(c_int32)] +_dll.openmc_id_map.restype = c_int +_dll.openmc_id_map.errcheck = _error_handler + + +def id_map(plot): + """ + Generate a 2-D map of cell and material IDs. Used for in-memory image + generation. + + Parameters + ---------- + plot : openmc.lib.plot._PlotBase + Object describing the slice of the model to be generated + + Returns + ------- + id_map : numpy.ndarray + A NumPy array with shape (vertical pixels, horizontal pixels, 3) of + OpenMC property ids with dtype int32. The last dimension of the array + contains, in order, cell IDs, cell instances, and material IDs. + + """ + img_data = np.zeros((plot.v_res, plot.h_res, 3), + dtype=np.dtype('int32')) + _dll.openmc_id_map(plot, img_data.ctypes.data_as(POINTER(c_int32))) + return img_data + + +_dll.openmc_property_map.argtypes = [POINTER(_PlotBase), POINTER(c_double)] +_dll.openmc_property_map.restype = c_int +_dll.openmc_property_map.errcheck = _error_handler + + +def property_map(plot): + """ + Generate a 2-D map of cell temperatures and material densities. Used for + in-memory image generation. + + Parameters + ---------- + plot : openmc.lib.plot._PlotBase + Object describing the slice of the model to be generated + + Returns + ------- + property_map : numpy.ndarray + A NumPy array with shape (vertical pixels, horizontal pixels, 2) of + OpenMC property ids with dtype float + + """ + prop_data = np.zeros((plot.v_res, plot.h_res, 2)) + _dll.openmc_property_map(plot, prop_data.ctypes.data_as(POINTER(c_double))) + return prop_data diff --git a/openmc/lib/settings.py b/openmc/lib/settings.py index 4fba8d48b..062670ef8 100644 --- a/openmc/lib/settings.py +++ b/openmc/lib/settings.py @@ -12,8 +12,6 @@ _RUN_MODES = {1: 'fixed source', _dll.openmc_set_seed.argtypes = [c_int64] _dll.openmc_get_seed.restype = c_int64 -_dll.openmc_set_stride.argtypes = [c_int64] -_dll.openmc_get_stride.restype = c_int64 _dll.openmc_get_n_batches.argtypes = [POINTER(c_int), c_bool] _dll.openmc_get_n_batches.restype = c_int _dll.openmc_get_n_batches.errcheck = _error_handler @@ -70,14 +68,6 @@ class _Settings: def seed(self, seed): _dll.openmc_set_seed(seed) - @property - def stride(self): - return _dll.openmc_get_stride() - - @stride.setter - def stride(self, stride): - _dll.openmc_set_stride(stride) - def set_batches(self, n_batches, set_max_batches=True, add_sp_batch=True): """Set number of batches or maximum number of batches diff --git a/openmc/lib/tally.py b/openmc/lib/tally.py index c17b16597..d0b34aedc 100644 --- a/openmc/lib/tally.py +++ b/openmc/lib/tally.py @@ -104,9 +104,7 @@ _SCORES = { -5: 'absorption', -6: 'fission', -7: 'nu-fission', -8: 'kappa-fission', -9: 'current', -10: 'events', -11: 'delayed-nu-fission', -12: 'prompt-nu-fission', -13: 'inverse-velocity', -14: 'fission-q-prompt', - -15: 'fission-q-recoverable', -16: 'decay-rate', -17: 'pulse-height', - -18: 'ifp-time-numerator', -19: 'ifp-beta-numerator', - -20: 'ifp-denominator', + -15: 'fission-q-recoverable', -16: 'decay-rate', -17: 'pulse-height' } _ESTIMATORS = { 0: 'analog', 1: 'tracklength', 2: 'collision' diff --git a/openmc/lib/weight_windows.py b/openmc/lib/weight_windows.py index 2b26d3b55..d92f01917 100644 --- a/openmc/lib/weight_windows.py +++ b/openmc/lib/weight_windows.py @@ -53,11 +53,11 @@ _dll.openmc_weight_windows_get_energy_bounds.argtypes = [c_int32, POINTER(POINTE _dll.openmc_weight_windows_get_energy_bounds.restype = c_int _dll.openmc_weight_windows_get_energy_bounds.errcheck = _error_handler -_dll.openmc_weight_windows_set_particle.argtypes = [c_int32, c_int32] +_dll.openmc_weight_windows_set_particle.argtypes = [c_int32, c_int] _dll.openmc_weight_windows_set_particle.restype = c_int _dll.openmc_weight_windows_set_particle.errcheck = _error_handler -_dll.openmc_weight_windows_get_particle.argtypes = [c_int32, POINTER(c_int32)] +_dll.openmc_weight_windows_get_particle.argtypes = [c_int32, POINTER(c_int)] _dll.openmc_weight_windows_get_particle.restype = c_int _dll.openmc_weight_windows_get_particle.errcheck = _error_handler @@ -201,13 +201,16 @@ class WeightWindows(_FortranObjectWithID): @property def particle(self): - val = c_int32() + val = c_int() _dll.openmc_weight_windows_get_particle(self._index, val) return ParticleType(val.value) @particle.setter def particle(self, p): - p = ParticleType(p) + if isinstance(p, str): + p = ParticleType.from_string(p) + else: + p = ParticleType(p) _dll.openmc_weight_windows_set_particle(self._index, int(p)) @property @@ -273,7 +276,7 @@ class WeightWindows(_FortranObjectWithID): def update_magic(self, tally, value='mean', threshold=1.0, ratio=5.0): """Update weight window values using the MAGIC method - Reference: https://inis.iaea.org/records/231pm-zzy35 + Reference: https://inis.iaea.org/search/48022314 Parameters ---------- @@ -301,10 +304,10 @@ class WeightWindows(_FortranObjectWithID): ---------- tally : openmc.lib.Tally The tally used to create the WeightWindows instance. - particle : openmc.ParticleType or str or int, optional + particle : openmc.ParticleType or str, optional The particle type to use for the WeightWindows instance. Should be - specified as an instance of ParticleType, a PDG number, or as a - name. + specified as an instance of ParticleType or as a string with a value of + 'neutron' or 'photon'. Returns ------- @@ -314,8 +317,7 @@ class WeightWindows(_FortranObjectWithID): Raises ------ ValueError - If the particle parameter is not an instance of ParticleType, a string, - or an integer PDG number. + If the particle parameter is not an instance of ParticleType or a string. ValueError If the particle parameter is not a valid particle type (i.e., not 'neutron' or 'photon'). @@ -326,13 +328,12 @@ class WeightWindows(_FortranObjectWithID): If the tally does not have a MeshFilter. """ # do some checks on particle value - if not isinstance(particle, (ParticleType, str, int)): - raise ValueError( - f"Parameter 'particle' must be {ParticleType} or one of ('neutron', 'photon')." - ) + if not isinstance(particle, (ParticleType, str)): + raise ValueError(f"Parameter 'particle' must be {ParticleType} or one of ('neutron', 'photon').") # convert particle type if needed - particle = ParticleType(particle) + if isinstance(particle, str): + particle = ParticleType.from_string(particle) if particle not in (ParticleType.NEUTRON, ParticleType.PHOTON): raise ValueError('Weight windows can only be applied for neutrons or photons') diff --git a/openmc/material.py b/openmc/material.py index 3a92efda2..6edc37216 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -2,14 +2,12 @@ from __future__ import annotations from collections import defaultdict, namedtuple, Counter from collections.abc import Iterable from copy import deepcopy -from functools import reduce from numbers import Real from pathlib import Path import re -import sys -import tempfile -from typing import TYPE_CHECKING, Literal, Sequence, Dict +import typing # imported separately as py3.8 requires typing.Iterable import warnings +from typing import Optional, List, Union, Dict import lxml.etree as ET import numpy as np @@ -18,28 +16,16 @@ import h5py import openmc import openmc.data import openmc.checkvalue as cv -from ._xml import clean_indentation, get_elem_list, get_text +from ._xml import clean_indentation, reorder_attributes from .mixin import IDManagerMixin -from .utility_funcs import input_path -from . import waste from openmc.checkvalue import PathLike -from openmc.stats import Univariate, Discrete, Mixture, Tabular -from openmc.data.data import _get_element_symbol, JOULE_PER_EV -from openmc.data.function import Tabulated1D -from openmc.data import mass_energy_absorption_coefficient, dose_coefficients - -if TYPE_CHECKING: - from openmc.deplete import Chain +from openmc.stats import Univariate, Discrete, Mixture # Units for density supported by OpenMC DENSITY_UNITS = ('g/cm3', 'g/cc', 'kg/m3', 'atom/b-cm', 'atom/cm3', 'sum', 'macro') -# Smallest normalized floating point number -_SMALLEST_NORMAL = sys.float_info.min - -_BECQUEREL_PER_CURIE = 3.7e10 NuclideTuple = namedtuple('NuclideTuple', ['name', 'percent', 'percent_type']) @@ -66,26 +52,6 @@ class Material(IDManagerMixin): temperature : float, optional Temperature of the material in Kelvin. If not specified, the material inherits the default temperature applied to the model. - density : float, optional - Density of the material (units defined separately) - density_units : str - Units used for `density`. Can be one of 'g/cm3', 'g/cc', 'kg/m3', - 'atom/b-cm', 'atom/cm3', 'sum', or 'macro'. The 'macro' unit only - applies in the case of a multi-group calculation. Defaults to 'sum'. - depletable : bool, optional - Indicate whether the material is depletable. Defaults to False. - volume : float, optional - Volume of the material in cm^3. This can either be set manually or - calculated in a stochastic volume calculation and added via the - :meth:`Material.add_volume_information` method. - components : dict of str to float or dict - Dictionary mapping element or nuclide names to their atom or weight - percent. To specify enrichment of an element, the entry of - ``components`` for that element must instead be a dictionary containing - the keyword arguments as well as a value for ``'percent'`` - percent_type : {'ao', 'wo'} - Whether the values in `components` should be interpreted as atom percent - ('ao') or weight percent ('wo'). Attributes ---------- @@ -137,28 +103,17 @@ class Material(IDManagerMixin): next_id = 1 used_ids = set() - def __init__( - self, - material_id: int | None = None, - name: str = "", - temperature: float | None = None, - density: float | None = None, - density_units: str = "sum", - depletable: bool | None = False, - volume: float | None = None, - components: dict | None = None, - percent_type: str = "ao", - ): + def __init__(self, material_id=None, name='', temperature=None): # Initialize class attributes self.id = material_id self.name = name self.temperature = temperature self._density = None - self._density_units = density_units - self._depletable = depletable + self._density_units = 'sum' + self._depletable = False self._paths = None self._num_instances = None - self._volume = volume + self._volume = None self._atoms = {} self._isotropic = [] self._ncrystal_cfg = None @@ -173,15 +128,6 @@ class Material(IDManagerMixin): # If specified, a list of table names self._sab = [] - # Set density if provided - if density is not None: - self.set_density(density_units, density) - - # Add components if provided - if components is not None: - self.add_components(components, percent_type=percent_type) - - def __repr__(self) -> str: string = 'Material\n' string += '{: <16}=\t{}\n'.format('\tID', self._id) @@ -215,11 +161,11 @@ class Material(IDManagerMixin): return string @property - def name(self) -> str | None: + def name(self) -> Optional[str]: return self._name @name.setter - def name(self, name: str | None): + def name(self, name: Optional[str]): if name is not None: cv.check_type(f'name for Material ID="{self._id}"', name, str) @@ -228,17 +174,17 @@ class Material(IDManagerMixin): self._name = '' @property - def temperature(self) -> float | None: + def temperature(self) -> Optional[float]: return self._temperature @temperature.setter - def temperature(self, temperature: Real | None): + def temperature(self, temperature: Optional[Real]): cv.check_type(f'Temperature for Material ID="{self._id}"', temperature, (Real, type(None))) self._temperature = temperature @property - def density(self) -> float | None: + def density(self) -> Optional[float]: return self._density @property @@ -256,7 +202,7 @@ class Material(IDManagerMixin): self._depletable = depletable @property - def paths(self) -> list[str]: + def paths(self) -> List[str]: if self._paths is None: raise ValueError('Material instance paths have not been determined. ' 'Call the Geometry.determine_paths() method.') @@ -271,15 +217,15 @@ class Material(IDManagerMixin): return self._num_instances @property - def nuclides(self) -> list[namedtuple]: + def nuclides(self) -> List[namedtuple]: return self._nuclides @property - def isotropic(self) -> list[str]: + def isotropic(self) -> List[str]: return self._isotropic @isotropic.setter - def isotropic(self, isotropic: Iterable[str]): + def isotropic(self, isotropic: typing.Iterable[str]): cv.check_iterable_type('Isotropic scattering nuclides', isotropic, str) self._isotropic = list(isotropic) @@ -299,12 +245,10 @@ class Material(IDManagerMixin): mass += nuc.percent # Compute and return the molar mass - if moles == 0.0: - raise ValueError("Material has no nuclides; cannot compute molar mass") return mass / moles @property - def volume(self) -> float | None: + def volume(self) -> Optional[float]: return self._volume @volume.setter @@ -314,7 +258,7 @@ class Material(IDManagerMixin): self._volume = volume @property - def ncrystal_cfg(self) -> str | None: + def ncrystal_cfg(self) -> Optional[str]: return self._ncrystal_cfg @property @@ -330,7 +274,7 @@ class Material(IDManagerMixin): return density*self.volume @property - def decay_photon_energy(self) -> Univariate | None: + def decay_photon_energy(self) -> Optional[Univariate]: warnings.warn( "The 'decay_photon_energy' property has been replaced by the " "get_decay_photon_energy() method and will be removed in a future " @@ -338,13 +282,11 @@ class Material(IDManagerMixin): return self.get_decay_photon_energy(0.0) def get_decay_photon_energy( - self, - clip_tolerance: float = 1e-6, - units: str = 'Bq', - volume: float | None = None, - exclude_nuclides: list[str] | None = None, - include_nuclides: list[str] | None = None - ) -> Univariate | None: + self, + clip_tolerance: float = 1e-6, + units: str = 'Bq', + volume: Optional[float] = None + ) -> Optional[Univariate]: r"""Return energy distribution of decay photons from unstable nuclides. .. versionadded:: 0.14.0 @@ -352,54 +294,35 @@ class Material(IDManagerMixin): Parameters ---------- clip_tolerance : float - Maximum fraction of :math:`\sum_i x_i p_i` for discrete distributions - that will be discarded. - units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3'} + Maximum fraction of :math:`\sum_i x_i p_i` for discrete + distributions that will be discarded. + units : {'Bq', 'Bq/g', 'Bq/cm3'} Specifies the units on the integral of the distribution. volume : float, optional Volume of the material. If not passed, defaults to using the :attr:`Material.volume` attribute. - exclude_nuclides : list of str, optional - Nuclides to exclude from the photon source calculation. - include_nuclides : list of str, optional - Nuclides to include in the photon source calculation. If specified, - only these nuclides are used. Returns ------- - Univariate or None - Decay photon energy distribution. The integral of this distribution is - the total intensity of the photon source in the requested units. + Decay photon energy distribution. The integral of this distribution is + the total intensity of the photon source in the requested units. """ - cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3'}) - - if exclude_nuclides is not None and include_nuclides is not None: - raise ValueError("Cannot specify both exclude_nuclides and include_nuclides") - + cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/cm3'}) if units == 'Bq': multiplier = volume if volume is not None else self.volume if multiplier is None: raise ValueError("volume must be specified if units='Bq'") elif units == 'Bq/cm3': multiplier = 1 - elif units == 'Bq/m3': - multiplier = 1e6 elif units == 'Bq/g': multiplier = 1.0 / self.get_mass_density() - elif units == 'Bq/kg': - multiplier = 1000.0 / self.get_mass_density() dists = [] probs = [] for nuc, atoms_per_bcm in self.get_nuclide_atom_densities().items(): - if exclude_nuclides is not None and nuc in exclude_nuclides: - continue - if include_nuclides is not None and nuc not in include_nuclides: - continue - source_per_atom = openmc.data.decay_photon_energy(nuc) - if source_per_atom is not None and atoms_per_bcm > 0.0: + if source_per_atom is not None: dists.append(source_per_atom) probs.append(1e24 * atoms_per_bcm * multiplier) @@ -412,197 +335,8 @@ class Material(IDManagerMixin): if isinstance(combined, (Discrete, Mixture)): combined.clip(clip_tolerance, inplace=True) - # If clipping resulted in a single distribution within a mixture, pick - # out that single distribution - if isinstance(combined, Mixture) and len(combined.distribution) == 1: - combined = combined.distribution[0] - return combined - def get_photon_contact_dose_rate( - self, - dose_quantity: str = "absorbed-air", - build_up: float = 2.0, - by_nuclide: bool = False - ) -> float | dict[str, float]: - """Compute the photon contact dose rate (CDR) produced by radioactive decay - of the material. - - The contact dose rate is calculated from decay photon energy spectra for - each nuclide in the material, combined with photon mass attenuation data - for the material and the appropriate response function for the dose quantity. - A slab-geometry approximation and a photon build-up factor are used. - - Absorbed-air dose: - The approach follows the FISPACT-II manual (UKAEA-CCFE-RE(21)02 - May 2021). - Appendix C.7.1. - This method integrates over the photon energy: - - (B/2) * (mu_en_air(E) / mu_material(E)) * E * S(E) - - Effective dose: - The approach uses ICRP-116 effective dose coefficients to convert the photon - fluence due to decay photons to effective dose. - This method integrates over the photon energy: - - (B/2) * (h_e(E) / mu_material(E)) * S(E) - - where: - - mu_en_air(E) is the air mass energy-absorption coefficient, - - mu_material(E) is the photon mass attenuation coefficient of the material, - - S(E) is the photon emission spectrum per atom, - - h_e(E) is the ICRP-116 effective dose coefficient, - - B is the build-up factor, - - E is the photon energy. - - Parameters - ---------- - dose_quantity : {'absorbed-air', 'effective'}, optional - Specifies the dose quantity to be calculated. - The only supported options are 'absorbed-air' which implements the methodology - from FISPACT-II, and 'effective' which uses ICRP-116 effective dose coefficients. - build_up : float, optional. The default value is 2.0 as suggested in the FISPACT-II - manual. - by_nuclide : bool, optional - Specifies if the cdr should be returned for the material as a - whole or per nuclide. Default is False. - - Limitations - ---------- - This method does not implement correction from Bremsstrahlung particles which can be - relevant at close distances. - In addition, it computes the gamma contact dose rate only for the unstable nuclides - for which the radiation source specification is present in the chain file. - - Returns - ------- - cdr : float or dict[str, float] - Contact Dose Rate due to decay photons. - 'absorbed-air': returns the absorbed dose in air [Gy/hr]. - 'effective': returns the effective dose [Sv/hr]. - """ - - cv.check_type("by_nuclide", by_nuclide, bool) - cv.check_type("dose_quantity", dose_quantity, str) - cv.check_value("dose_quantity", dose_quantity, {'absorbed-air', 'effective'}) - cv.check_type("build_up", build_up, Real) - cv.check_greater_than("build_up", build_up, 0.0) - - nuc_densities = self.get_nuclide_atom_densities() - if not nuc_densities: - raise ValueError("Material has no nuclides; cannot compute mass attenuation") - - # Collect partial mass densities ρ_i [g/cm³] and elemental mass - # attenuation coefficients µ_i/ρ_i [cm²/g] per nuclide - nuc_attenuation = [] - for nuc, atom_density_bcm in nuc_densities.items(): - Z = openmc.data.zam(nuc)[0] - mu_over_rho = openmc.data.mass_attenuation_coefficient(Z) - rho_i = ( - atom_density_bcm * 1.0e24 - * openmc.data.atomic_mass(nuc) / openmc.data.AVOGADRO - ) - nuc_attenuation.append((rho_i, mu_over_rho)) - - # Build union energy grid across all nuclides - mu_e_vals = reduce(np.union1d, [t.x for _, t in nuc_attenuation]) - - # Build the material linear attenuation coefficient µ_material(E) [cm⁻¹] - # as the sum of ρ_i * (µ_i/ρ_i)(E) over all nuclides - mu_material_vals = np.zeros(len(mu_e_vals)) - for rho_i, mu_over_rho in nuc_attenuation: - mu_material_vals += rho_i * mu_over_rho(mu_e_vals) - mu_material = Tabulated1D( - mu_e_vals, mu_material_vals, breakpoints=[len(mu_e_vals)], interpolation=[5]) - - # CDR computation - cdr = {} - - geometry_factor_slab = 0.5 - - # ancillary conversion factors for clarity - seconds_per_hour = 3600.0 - grams_per_kg = 1000.0 - sv_per_psv = 1e-12 - - if dose_quantity == 'absorbed-air': - # mu_en/rho for air [cm²/g] as a function of energy [eV] - response_f = mass_energy_absorption_coefficient("air", data_source="nist126") - - # Factor to convert [eV cm²/(b g s)] to [Gy/h] - multiplier = (build_up * geometry_factor_slab * seconds_per_hour - * grams_per_kg * 1e24 * JOULE_PER_EV) - - elif dose_quantity == 'effective': - # effective dose as a function of photon fluence [pSv cm²] - response_f_x, response_f_y = dose_coefficients( - "photon", geometry='AP', data_source='icrp116') - response_f = Tabulated1D(response_f_x, response_f_y, breakpoints=[ - len(response_f_x)], interpolation=[5]) - - # Convert [pSv cm²/(b-s)] to [Sv/h] - multiplier = (build_up * geometry_factor_slab * seconds_per_hour - * sv_per_psv * 1e24) - - for nuc, nuc_atoms_per_bcm in self.get_nuclide_atom_densities().items(): - photon_source_per_atom = openmc.data.decay_photon_energy(nuc) - - # nuclides with no contribution - if photon_source_per_atom is None or nuc_atoms_per_bcm <= 0.0: - cdr[nuc] = 0.0 - continue - - if not isinstance(photon_source_per_atom, (Discrete, Tabular)): - raise ValueError( - f"Unknown decay photon energy data type for nuclide {nuc}" - f"value returned: {type(photon_source_per_atom)}" - ) - - e_vals = photon_source_per_atom.x - p_vals = photon_source_per_atom.p - - # Construct list of energies from (photon source, response function, - # mu_en_air) for clipping to common energy range - e_lists = [e_vals, response_f.x, mu_e_vals] - - # clip distributions for values outside the tabulated values - left_bound = max(a.min() for a in e_lists) - right_bound = min(a.max() for a in e_lists) - - mask = (e_vals >= left_bound) & (e_vals <= right_bound) - e_vals = e_vals[mask] - p_vals = p_vals[mask] - - if isinstance(photon_source_per_atom, Tabular): - # limit the computation to the tabulated mu_en_air range - e_union = reduce(np.union1d, e_lists) - e_union = e_union[(e_union >= left_bound) & (e_union <= right_bound)] - if len(e_union) < 2: - raise ValueError("Not enough overlapping energy points to compute CDR") - - # Histogram interpolation: each new point inherits the value of - # the nearest original point to its left - p_vals = p_vals[np.searchsorted(e_vals, e_union, side='right') - 1] - e_vals = e_union - - mu_vals = mu_material(e_vals) - if dose_quantity == 'absorbed-air': - # Compute (µ_en_air(E) / µ_material(E)) * E * S(E) - integrand = (response_f(e_vals) / mu_vals) * p_vals * e_vals - elif dose_quantity == 'effective': - # Compute (h_e(E) / µ_material(E)) * S(E) - integrand = (response_f(e_vals) / mu_vals) * p_vals - - if isinstance(photon_source_per_atom, Discrete): - cdr_nuc = np.sum(integrand) - elif isinstance(photon_source_per_atom, Tabular): - cdr_nuc = np.trapezoid(integrand, e_vals) - - # Compute air-absorbed dose [Gy/h] or effective dose [Sv/h] - cdr[nuc] = float(cdr_nuc * nuc_atoms_per_bcm * multiplier) - - return cdr if by_nuclide else sum(cdr.values()) - @classmethod def from_hdf5(cls, group: h5py.Group) -> Material: """Create material from HDF5 group @@ -683,11 +417,7 @@ class Material(IDManagerMixin): """ - try: - import NCrystal - except ModuleNotFoundError as e: - raise RuntimeError('The .from_ncrystal method requires' - ' NCrystal to be installed.') from e + import NCrystal nc_mat = NCrystal.createInfo(cfg) def openmc_natabund(Z): @@ -741,7 +471,7 @@ class Material(IDManagerMixin): else: raise ValueError(f'No volume information found for material ID={self.id}.') - def set_density(self, units: str, density: float | None = None): + def set_density(self, units: str, density: Optional[float] = None): """Set the density of the material Parameters @@ -789,7 +519,6 @@ class Material(IDManagerMixin): cv.check_type('nuclide', nuclide, str) cv.check_type('percent', percent, Real) cv.check_value('percent type', percent_type, {'ao', 'wo'}) - cv.check_greater_than('percent', percent, 0, equality=True) if self._macroscopic is not None: msg = 'Unable to add a Nuclide to Material ID="{}" as a ' \ @@ -955,10 +684,10 @@ class Material(IDManagerMixin): self._macroscopic = None def add_element(self, element: str, percent: float, percent_type: str = 'ao', - enrichment: float | None = None, - enrichment_target: str | None = None, - enrichment_type: str | None = None, - cross_sections: str | None = None): + enrichment: Optional[float] = None, + enrichment_target: Optional[str] = None, + enrichment_type: Optional[str] = None, + cross_sections: Optional[str] = None): """Add a natural element to the material Parameters @@ -998,7 +727,6 @@ class Material(IDManagerMixin): cv.check_type('nuclide', element, str) cv.check_type('percent', percent, Real) - cv.check_greater_than('percent', percent, 0, equality=True) cv.check_value('percent type', percent_type, {'ao', 'wo'}) # Make sure element name is just that @@ -1069,9 +797,9 @@ class Material(IDManagerMixin): self.add_nuclide(*nuclide) def add_elements_from_formula(self, formula: str, percent_type: str = 'ao', - enrichment: float | None = None, - enrichment_target: str | None = None, - enrichment_type: str | None = None): + enrichment: Optional[float] = None, + enrichment_target: Optional[str] = None, + enrichment_type: Optional[str] = None): """Add a elements from a chemical formula to the material. .. versionadded:: 0.12 @@ -1200,7 +928,7 @@ class Material(IDManagerMixin): def make_isotropic_in_lab(self): self.isotropic = [x.name for x in self._nuclides] - def get_elements(self) -> list[str]: + def get_elements(self) -> List[str]: """Returns all elements in the material .. versionadded:: 0.12 @@ -1214,7 +942,7 @@ class Material(IDManagerMixin): return sorted({re.split(r'(\d+)', i)[0] for i in self.get_nuclides()}) - def get_nuclides(self, element: str | None = None) -> list[str]: + def get_nuclides(self, element: Optional[str] = None) -> List[str]: """Returns a list of all nuclides in the material, if the element argument is specified then just nuclides of that element are returned. @@ -1244,7 +972,7 @@ class Material(IDManagerMixin): return matching_nuclides - def get_nuclide_densities(self) -> dict[str, tuple]: + def get_nuclide_densities(self) -> Dict[str, tuple]: """Returns all nuclides in the material and their densities Returns @@ -1262,7 +990,7 @@ class Material(IDManagerMixin): return nuclides - def get_nuclide_atom_densities(self, nuclide: str | None = None) -> dict[str, float]: + def get_nuclide_atom_densities(self, nuclide: Optional[str] = None) -> Dict[str, float]: """Returns one or all nuclides in the material and their atomic densities in units of atom/b-cm @@ -1312,6 +1040,7 @@ class Material(IDManagerMixin): nuc_densities.append(nuc.percent) nuc_density_types.append(nuc.percent_type) + nucs = np.array(nucs) nuc_densities = np.array(nuc_densities) nuc_density_types = np.array(nuc_density_types) @@ -1346,65 +1075,19 @@ class Material(IDManagerMixin): return nuclides - def get_element_atom_densities(self, element: str | None = None) -> dict[str, float]: - """Returns one or all elements in the material and their atomic - densities in units of atom/b-cm - - .. versionadded:: 0.15.1 - - Parameters - ---------- - element : str, optional - Element for which atom density is desired. If not specified, the - atom density for each element in the material is given. - - Returns - ------- - elements : dict - Dictionary whose keys are element names and values are densities in - [atom/b-cm] - - """ - if element is not None: - element = _get_element_symbol(element) - - nuc_densities = self.get_nuclide_atom_densities() - - # Initialize an empty dictionary for summed values - densities = {} - - # Accumulate densities for each nuclide - for nuclide, density in nuc_densities.items(): - nuc_element = openmc.data.ATOMIC_SYMBOL[openmc.data.zam(nuclide)[0]] - if element is None or element == nuc_element: - if nuc_element not in densities: - densities[nuc_element] = 0.0 - densities[nuc_element] += float(density) - - # If specific element was requested, make sure it is present - if element is not None and element not in densities: - raise ValueError(f'Element {element} not found in material.') - - return densities - - - def get_activity( - self, - units: str = 'Bq/cm3', - by_nuclide: bool = False, - volume: float | None = None, - chain_file: Literal[False] | None | PathLike | Chain = None - ) -> dict[str, float] | float: - """Return the activity of the material or each nuclide within. + def get_activity(self, units: str = 'Bq/cm3', by_nuclide: bool = False, + volume: Optional[float] = None) -> Union[Dict[str, float], float]: + """Returns the activity of the material or for each nuclide in the + material in units of [Bq], [Bq/g] or [Bq/cm3]. .. versionadded:: 0.13.1 Parameters ---------- - units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3', 'Ci', 'Ci/m3'} + units : {'Bq', 'Bq/g', 'Bq/cm3'} Specifies the type of activity to return, options include total - activity [Bq,Ci], specific [Bq/g, Bq/kg] or volumetric activity - [Bq/cm3, Bq/m3, Ci/m3]. Default is volumetric activity [Bq/cm3]. + activity [Bq], specific [Bq/g] or volumetric activity [Bq/cm3]. + Default is volumetric activity [Bq/cm3]. by_nuclide : bool Specifies if the activity should be returned for the material as a whole or per nuclide. Default is False. @@ -1413,67 +1096,44 @@ class Material(IDManagerMixin): :attr:`Material.volume` attribute. .. versionadded:: 0.13.3 - chain_file : False, None, PathLike, or openmc.deplete.Chain, optional - Source of half-life values. If ``False``, only ENDF/B-VIII.0 data is - used. If ``None``, the chain specified by - ``openmc.config['chain_file']`` is used when available. If a path or - :class:`openmc.deplete.Chain` is given, that chain is used. For - ``None`` or an explicit chain, nuclides absent from the chain fall - back to ENDF/B-VIII.0 data. - - .. versionadded:: 0.15.4 Returns ------- - Union[dict, float] - If by_nuclide is True then a dictionary whose keys are nuclide names - and values are activity is returned. Otherwise the activity of the - material is returned as a float. + typing.Union[dict, float] + If by_nuclide is True then a dictionary whose keys are nuclide + names and values are activity is returned. Otherwise the activity + of the material is returned as a float. """ - cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3', 'Ci', 'Ci/m3'}) + cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/cm3'}) cv.check_type('by_nuclide', by_nuclide, bool) - if volume is None: - volume = self.volume - - if units in {'Bq', 'Ci'} and volume is None: - raise ValueError(f"Volume must be set in order to compute activity in '{units}'.") - if units == 'Bq': - multiplier = volume + multiplier = volume if volume is not None else self.volume elif units == 'Bq/cm3': multiplier = 1 - elif units == 'Bq/m3': - multiplier = 1e6 elif units == 'Bq/g': multiplier = 1.0 / self.get_mass_density() - elif units == 'Bq/kg': - multiplier = 1000.0 / self.get_mass_density() - elif units == 'Ci': - multiplier = volume / _BECQUEREL_PER_CURIE - elif units == 'Ci/m3': - multiplier = 1e6 / _BECQUEREL_PER_CURIE activity = {} for nuclide, atoms_per_bcm in self.get_nuclide_atom_densities().items(): - inv_seconds = openmc.data.decay_constant( - nuclide, chain_file=chain_file) + inv_seconds = openmc.data.decay_constant(nuclide) activity[nuclide] = inv_seconds * 1e24 * atoms_per_bcm * multiplier return activity if by_nuclide else sum(activity.values()) def get_decay_heat(self, units: str = 'W', by_nuclide: bool = False, - volume: float | None = None) -> dict[str, float] | float: - """Return the decay heat of the material or each nuclide within. + volume: Optional[float] = None) -> Union[Dict[str, float], float]: + """Returns the decay heat of the material or for each nuclide in the + material in units of [W], [W/g] or [W/cm3]. .. versionadded:: 0.13.3 Parameters ---------- - units : {'W', 'W/g', 'W/kg', 'W/cm3', 'W/m3'} + units : {'W', 'W/g', 'W/cm3'} Specifies the units of decay heat to return. Options include total - heat [W], specific [W/g, W/kg] or volumetric heat [W/cm3, W/m3]. + heat [W], specific [W/g] or volumetric heat [W/cm3]. Default is total heat [W]. by_nuclide : bool Specifies if the decay heat should be returned for the material as a @@ -1492,21 +1152,15 @@ class Material(IDManagerMixin): of the material is returned as a float. """ - cv.check_value('units', units, {'W', 'W/g', 'W/kg', 'W/cm3', 'W/m3'}) + cv.check_value('units', units, {'W', 'W/g', 'W/cm3'}) cv.check_type('by_nuclide', by_nuclide, bool) if units == 'W': multiplier = volume if volume is not None else self.volume - if multiplier is None: - raise ValueError("Volume must be set in order to compute total decay heat.") elif units == 'W/cm3': multiplier = 1 - elif units == 'W/m3': - multiplier = 1e6 elif units == 'W/g': multiplier = 1.0 / self.get_mass_density() - elif units == 'W/kg': - multiplier = 1000.0 / self.get_mass_density() decayheat = {} for nuclide, atoms_per_bcm in self.get_nuclide_atom_densities().items(): @@ -1517,7 +1171,7 @@ class Material(IDManagerMixin): return decayheat if by_nuclide else sum(decayheat.values()) - def get_nuclide_atoms(self, volume: float | None = None) -> dict[str, float]: + def get_nuclide_atoms(self, volume: Optional[float] = None) -> Dict[str, float]: """Return number of atoms of each nuclide in the material .. versionadded:: 0.13.1 @@ -1546,7 +1200,7 @@ class Material(IDManagerMixin): atoms[nuclide] = 1.0e24 * atom_per_bcm * volume return atoms - def get_mass_density(self, nuclide: str | None = None) -> float: + def get_mass_density(self, nuclide: Optional[str] = None) -> float: """Return mass density of one or all nuclides Parameters @@ -1568,7 +1222,7 @@ class Material(IDManagerMixin): mass_density += density_i return mass_density - def get_mass(self, nuclide: str | None = None, volume: float | None = None) -> float: + def get_mass(self, nuclide: Optional[str] = None, volume: Optional[float] = None) -> float: """Return mass of one or all nuclides. Note that this method requires that the :attr:`Material.volume` has @@ -1598,92 +1252,7 @@ class Material(IDManagerMixin): raise ValueError("Volume must be set in order to determine mass.") return volume*self.get_mass_density(nuclide) - def waste_classification(self, metal: bool = False) -> str: - """Classify the material for near-surface waste disposal. - - This method determines a waste classification for the material based on - the NRC regulations (10 CFR 61.55). Note that the NRC regulations do not - consider many long-lived radionuclides relevant to fusion systems; for - fusion applications, it is recommended to calculate a waste disposal - rating based on limits by Fetter et al. using the - :meth:`~openmc.Material.waste_disposal_rating` method. - - Parameters - ---------- - metal : bool, optional - Whether or not the material is in metal form. - - Returns - ------- - str - The waste disposal classification, which can be "Class A", "Class - B", "Class C", or "GTCC" (greater than class C). - - """ - return waste._waste_classification(self, metal=metal) - - def waste_disposal_rating( - self, - limits: str | dict[str, float] = 'Fetter', - metal: bool = False, - by_nuclide: bool = False, - ) -> float | dict[str, float]: - """Return the waste disposal rating for the material. - - This method returns a waste disposal rating for the material based on a - set of specific activity limits. The waste disposal rating is a single - number that represents the sum of the ratios of the specific activity - for each radionuclide in the material against a nuclide-specific limit. - A value less than 1.0 indicates that the material "meets" the limits - whereas a value greater than 1.0 exceeds the limits. - - Note that the limits for NRC do not consider many long-lived - radionuclides relevant to fusion systems. A paper by `Fetter et al. - `_ applies the NRC - methodology to calculate specific activity limits for an expanded set of - radionuclides. - - Parameters - ---------- - limits : str or dict, optional - The name of a predefined set of specific activity limits or a - dictionary that contains specific activity limits for radionuclides, - where keys are nuclide names and values are activities in units of - [Ci/m3]. The predefined options are: - - - 'Fetter': Uses limits from Fetter et al. (1990) - - 'NRC_long': Uses the 10 CFR 61.55 limits for long-lived - radionuclides - - 'NRC_short_A': Uses the 10 CFR 61.55 class A limits for - short-lived radionuclides - - 'NRC_short_B': Uses the 10 CFR 61.55 class B limits for - short-lived radionuclides - - 'NRC_short_C': Uses the 10 CFR 61.55 class C limits for - short-lived radionuclides - metal : bool, optional - Whether or not the material is in metal form (only applicable for - NRC based limits) - by_nuclide : bool, optional - Whether to return the waste disposal rating for each nuclide in the - material. If True, a dictionary is returned where the keys are the - nuclide names and the values are the waste disposal ratings for each - nuclide. If False, a single float value is returned that represents - the overall waste disposal rating for the material. - - Returns - ------- - float or dict - The waste disposal rating for the material or its constituent - nuclides. - - See also - -------- - Material.waste_classification() - - """ - return waste._waste_disposal_rating(self, limits, metal, by_nuclide) - - def clone(self, memo: dict | None = None) -> Material: + def clone(self, memo: Optional[dict] = None) -> Material: """Create a copy of this material with a new unique ID. Parameters @@ -1726,16 +1295,10 @@ class Material(IDManagerMixin): xml_element = ET.Element("nuclide") xml_element.set("name", nuclide.name) - # Prevent subnormal numbers from being written to XML, which causes an - # exception on the C++ side when calling std::stod - val = nuclide.percent - if abs(val) < _SMALLEST_NORMAL: - val = 0.0 - if nuclide.percent_type == 'ao': - xml_element.set("ao", str(val)) + xml_element.set("ao", str(nuclide.percent)) else: - xml_element.set("wo", str(val)) + xml_element.set("wo", str(nuclide.percent)) return xml_element @@ -1746,8 +1309,8 @@ class Material(IDManagerMixin): return xml_element def _get_nuclides_xml( - self, nuclides: Iterable[NuclideTuple], - nuclides_to_ignore: Iterable[str] | None = None)-> list[ET.Element]: + self, nuclides: typing.Iterable[NuclideTuple], + nuclides_to_ignore: Optional[typing.Iterable[str]] = None)-> List[ET.Element]: xml_elements = [] # Remove any nuclides to ignore from the XML export @@ -1759,7 +1322,7 @@ class Material(IDManagerMixin): return xml_elements def to_xml_element( - self, nuclides_to_ignore: Iterable[str] | None = None) -> ET.Element: + self, nuclides_to_ignore: Optional[typing.Iterable[str]] = None) -> ET.Element: """Return XML representation of the material Parameters @@ -1833,8 +1396,8 @@ class Material(IDManagerMixin): return element @classmethod - def mix_materials(cls, materials, fracs: Iterable[float], - percent_type: str = 'ao', **kwargs) -> Material: + def mix_materials(cls, materials, fracs: typing.Iterable[float], + percent_type: str = 'ao', name: Optional[str] = None) -> Material: """Mix materials together based on atom, weight, or volume fractions .. versionadded:: 0.12 @@ -1849,8 +1412,10 @@ class Material(IDManagerMixin): Type of percentage, must be one of 'ao', 'wo', or 'vo', to signify atom percent (molar percent), weight percent, or volume percent, optional. Defaults to 'ao' - **kwargs - Keyword arguments passed to :class:`openmc.Material` + name : str + The name for the new material, optional. Defaults to concatenated + names of input materials with percentages indicated inside + parentheses. Returns ------- @@ -1909,11 +1474,10 @@ class Material(IDManagerMixin): openmc.data.AVOGADRO # Create the new material with the desired name - if "name" not in kwargs: - kwargs["name"] = '-'.join([f'{m.name}({f})' for m, f in + if name is None: + name = '-'.join([f'{m.name}({f})' for m, f in zip(materials, fracs)]) - - new_mat = cls(**kwargs) + new_mat = openmc.Material(name=name) # Compute atom fractions of nuclides and add them to the new material tot_nuclides_per_cc = np.sum([dens for dens in nuclides_per_cc.values()]) @@ -1945,149 +1509,51 @@ class Material(IDManagerMixin): Material generated from XML element """ - mat_id = int(get_text(elem, 'id')) - + mat_id = int(elem.get('id')) # Add NCrystal material from cfg string - cfg = get_text(elem, "cfg") - if cfg is not None: + if "cfg" in elem.attrib: + cfg = elem.get("cfg") return Material.from_ncrystal(cfg, material_id=mat_id) mat = cls(mat_id) - mat.name = get_text(elem, 'name') + mat.name = elem.get('name') - temperature = get_text(elem, "temperature") - if temperature is not None: - mat.temperature = float(temperature) + if "temperature" in elem.attrib: + mat.temperature = float(elem.get("temperature")) - volume = get_text(elem, "volume") - if volume is not None: - mat.volume = float(volume) + if 'volume' in elem.attrib: + mat.volume = float(elem.get('volume')) + mat.depletable = bool(elem.get('depletable')) # Get each nuclide for nuclide in elem.findall('nuclide'): - name = get_text(nuclide, "name") + name = nuclide.attrib['name'] if 'ao' in nuclide.attrib: mat.add_nuclide(name, float(nuclide.attrib['ao'])) elif 'wo' in nuclide.attrib: mat.add_nuclide(name, float(nuclide.attrib['wo']), 'wo') - # Get depletable attribute - depletable = get_text(elem, "depletable") - mat.depletable = depletable in ('true', '1') - # Get each S(a,b) table for sab in elem.findall('sab'): - fraction = float(get_text(sab, "fraction", 1.0)) - name = get_text(sab, "name") - mat.add_s_alpha_beta(name, fraction) + fraction = float(sab.get('fraction', 1.0)) + mat.add_s_alpha_beta(sab.get('name'), fraction) # Get total material density density = elem.find('density') - units = get_text(density, "units") + units = density.get('units') if units == 'sum': mat.set_density(units) else: - value = float(get_text(density, 'value')) + value = float(density.get('value')) mat.set_density(units, value) # Check for isotropic scattering nuclides - isotropic = get_elem_list(elem, "isotropic", str) + isotropic = elem.find('isotropic') if isotropic is not None: - mat.isotropic = isotropic + mat.isotropic = isotropic.text.split() return mat - def deplete( - self, - multigroup_flux: Sequence[float], - energy_group_structure: Sequence[float] | str, - timesteps: Sequence[float] | Sequence[tuple[float, str]], - source_rates: float | Sequence[float], - timestep_units: str = 's', - chain_file: cv.PathLike | "openmc.deplete.Chain" | None = None, - reactions: Sequence[str] | None = None, - ) -> list[openmc.Material]: - """Depletes that material, evolving the nuclide densities - - .. versionadded:: 0.15.3 - - Parameters - ---------- - multigroup_flux: Sequence[float] - Energy-dependent multigroup flux values, where each sublist corresponds - to a specific material. Will be normalized so that it sums to 1. - energy_group_structure : Sequence[float] | str - Energy group boundaries in [eV] or the name of the group structure. - timesteps : iterable of float or iterable of tuple - Array of timesteps. Note that values are not cumulative. The units are - specified by the `timestep_units` argument when `timesteps` is an - iterable of float. Alternatively, units can be specified for each step - by passing an iterable of (value, unit) tuples. - source_rates : float or iterable of float, optional - Source rate in [neutron/sec] or neutron flux in [neutron/s-cm^2] for - each interval in :attr:`timesteps` - timestep_units : {'s', 'min', 'h', 'd', 'a', 'MWd/kg'} - Units for values specified in the `timesteps` argument. 's' means - seconds, 'min' means minutes, 'h' means hours, 'a' means Julian years - and 'MWd/kg' indicates that the values are given in burnup (MW-d of - energy deposited per kilogram of initial heavy metal). - chain_file : PathLike or Chain - Path to the depletion chain XML file or instance of openmc.deplete.Chain. - Defaults to ``openmc.config['chain_file']``. - reactions : list of str, optional - Reactions to get cross sections for. If not specified, all neutron - reactions listed in the depletion chain file are used. - - Returns - ------- - list of openmc.Material, one for each timestep - - """ - - materials = openmc.Materials([self]) - - depleted_materials_dict = materials.deplete( - multigroup_fluxes=[multigroup_flux], - energy_group_structures=[energy_group_structure], - timesteps=timesteps, - source_rates=source_rates, - timestep_units=timestep_units, - chain_file=chain_file, - reactions=reactions, - ) - - return depleted_materials_dict[self.id] - - - def mean_free_path(self, energy: float) -> float: - """Calculate the mean free path of neutrons in the material at a given - energy. - - .. versionadded:: 0.15.3 - - Parameters - ---------- - energy : float - Neutron energy in eV - - Returns - ------- - float - Mean free path in cm - - """ - from openmc.plotter import _calculate_cexs_elem_mat - - energy_grid, cexs = _calculate_cexs_elem_mat( - this=self, - types=["total"], - ) - total_cexs = cexs[0] - - interpolated_cexs = float(np.interp(energy, energy_grid, total_cexs)) - - return 1.0 / interpolated_cexs - class Materials(cv.CheckedList): """Collection of Materials used for an OpenMC simulation. @@ -2128,13 +1594,13 @@ class Materials(cv.CheckedList): self += materials @property - def cross_sections(self) -> Path | None: + def cross_sections(self) -> Optional[Path]: return self._cross_sections @cross_sections.setter def cross_sections(self, cross_sections): if cross_sections is not None: - self._cross_sections = input_path(cross_sections) + self._cross_sections = Path(cross_sections) def append(self, material): """Append material to collection @@ -2197,14 +1663,16 @@ class Materials(cv.CheckedList): clean_indentation(element, level=level+1) element.tail = element.tail.strip(' ') file.write((level+1)*spaces_per_level*' ') + reorder_attributes(element) # TODO: Remove when support is Python 3.8+ file.write(ET.tostring(element, encoding="unicode")) # Write the elements. - for material in sorted(set(self), key=lambda x: x.id): + for material in sorted(self, key=lambda x: x.id): element = material.to_xml_element(nuclides_to_ignore=nuclides_to_ignore) clean_indentation(element, level=level+1) element.tail = element.tail.strip(' ') file.write((level+1)*spaces_per_level*' ') + reorder_attributes(element) # TODO: Remove when support is Python 3.8+ file.write(ET.tostring(element, encoding="unicode")) # Write the closing tag for the root element. @@ -2216,7 +1684,7 @@ class Materials(cv.CheckedList): file.write(indentation) def export_to_xml(self, path: PathLike = 'materials.xml', - nuclides_to_ignore: Iterable[str] | None = None): + nuclides_to_ignore: Optional[typing.Iterable[str]] = None): """Export material collection to an XML file. Parameters @@ -2260,9 +1728,9 @@ class Materials(cv.CheckedList): materials.append(Material.from_xml_element(material)) # Check for cross sections settings - xs = get_text(elem, "cross_sections") + xs = elem.find('cross_sections') if xs is not None: - materials.cross_sections = xs + materials.cross_sections = xs.text return materials @@ -2286,123 +1754,3 @@ class Materials(cv.CheckedList): root = tree.getroot() return cls.from_xml_element(root) - - - def deplete( - self, - multigroup_fluxes: Sequence[Sequence[float]], - energy_group_structures: Sequence[Sequence[float] | str], - timesteps: Sequence[float] | Sequence[tuple[float, str]], - source_rates: float | Sequence[float], - timestep_units: str = 's', - chain_file: cv.PathLike | "openmc.deplete.Chain" | None = None, - reactions: Sequence[str] | None = None, - ) -> Dict[int, list[openmc.Material]]: - """Depletes that material, evolving the nuclide densities - - .. versionadded:: 0.15.3 - - Parameters - ---------- - multigroup_fluxes: Sequence[Sequence[float]] - Energy-dependent multigroup flux values, where each sublist corresponds - to a specific material. Will be normalized so that it sums to 1. - energy_group_structures: Sequence[Sequence[float] | str] - Energy group boundaries in [eV] or the name of the group structure. - timesteps : iterable of float or iterable of tuple - Array of timesteps. Note that values are not cumulative. The units are - specified by the `timestep_units` argument when `timesteps` is an - iterable of float. Alternatively, units can be specified for each step - by passing an iterable of (value, unit) tuples. - source_rates : float or iterable of float, optional - Source rate in [neutron/sec] or neutron flux in [neutron/s-cm^2] for - each interval in :attr:`timesteps` - timestep_units : {'s', 'min', 'h', 'd', 'a', 'MWd/kg'} - Units for values specified in the `timesteps` argument. 's' means - seconds, 'min' means minutes, 'h' means hours, 'a' means Julian years - and 'MWd/kg' indicates that the values are given in burnup (MW-d of - energy deposited per kilogram of initial heavy metal). - chain_file : PathLike or Chain - Path to the depletion chain XML file or instance of openmc.deplete.Chain. - Defaults to ``openmc.config['chain_file']``. - reactions : list of str, optional - Reactions to get cross sections for. If not specified, all neutron - reactions listed in the depletion chain file are used. - - Returns - ------- - list of openmc.Material, one for each timestep - - """ - - import openmc.deplete - from .deplete.chain import _get_chain - - # setting all materials to be depletable - for mat in self: - mat.depletable = True - - if len(multigroup_fluxes) != len(self): - raise ValueError("multigroup_fluxes length must match number of materials") - if len(energy_group_structures) != len(self): - raise ValueError("energy_group_structures length must match number of materials") - - chain = _get_chain(chain_file) - - # Create MicroXS objects for all materials - micros = [] - fluxes = [] - - with openmc.lib.TemporarySession(): - for material, flux, energy in zip( - self, multigroup_fluxes, energy_group_structures - ): - if material.volume is None: - raise ValueError( - f"Material {material.id} has no volume; cannot deplete" - ) - temperature = material.temperature or 293.6 - micro_xs = openmc.deplete.MicroXS.from_multigroup_flux( - energies=energy, - multigroup_flux=flux, - chain_file=chain, - temperature=temperature, - reactions=reactions, - ) - micros.append(micro_xs) - fluxes.append(material.volume) - - # Create a single operator for all materials - operator = openmc.deplete.IndependentOperator( - materials=self, - fluxes=fluxes, - micros=micros, - normalization_mode="source-rate", - chain_file=chain, - ) - - integrator = openmc.deplete.PredictorIntegrator( - operator=operator, - timesteps=timesteps, - source_rates=source_rates, - timestep_units=timestep_units, - ) - - with tempfile.TemporaryDirectory() as tmpdir: - # Run integrator - results_path = Path(tmpdir) / "depletion_results.h5" - integrator.integrate(path=results_path) - - # Load depletion results - results = openmc.deplete.Results(results_path) - - # For each material, get activated composition at each timestep - all_depleted_materials = { - material.id: [ - result.get_material(str(material.id)) - for result in results - ] - for material in self - } - - return all_depleted_materials diff --git a/openmc/mesh.py b/openmc/mesh.py index ff8e14577..ee58ec3b8 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -1,12 +1,14 @@ from __future__ import annotations +import typing import warnings from abc import ABC, abstractmethod -from collections.abc import Iterable, Sequence, Mapping +from collections.abc import Iterable from functools import wraps -import math +from math import pi, sqrt, atan2 from numbers import Integral, Real from pathlib import Path -from typing import Protocol +import tempfile +from typing import Optional, Sequence, Tuple, List import h5py import lxml.etree as ET @@ -15,175 +17,10 @@ import numpy as np import openmc import openmc.checkvalue as cv from openmc.checkvalue import PathLike -from .bounding_box import BoundingBox -from ._xml import get_elem_list, get_text +from openmc.utility_funcs import change_directory +from ._xml import get_text from .mixin import IDManagerMixin from .surface import _BOUNDARY_TYPES -from .utility_funcs import input_path - - -class MeshMaterialVolumes(Mapping): - """Results from a material volume in mesh calculation. - - This class provides multiple ways of accessing information about material - volumes in individual mesh elements. First, the class behaves like a - dictionary that maps material IDs to an array of volumes equal in size to - the number of mesh elements. Second, the class provides a :meth:`by_element` - method that gives all the material volumes for a specific mesh element. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - materials : numpy.ndarray - Array of shape (elements, max_materials) storing material IDs - volumes : numpy.ndarray - Array of shape (elements, max_materials) storing material volumes - bboxes : numpy.ndarray, optional - Array of shape (elements, max_materials, 6) storing axis-aligned - bounding boxes for each (element, material) combination with ordering - (xmin, ymin, zmin, xmax, ymax, zmax). Bounding boxes enclose the - ray-estimator prisms used to compute volumes. - - See Also - -------- - openmc.MeshBase.material_volumes - - Examples - -------- - If you want to get the volume of a specific material in every mesh element, - index the object with the material ID: - - >>> volumes = mesh.material_volumes(...) - >>> volumes - {1: <32121 nonzero volumes> - 2: <338186 nonzero volumes> - 3: <49120 nonzero volumes>} - - If you want the volume of all materials in a specific mesh element, use the - :meth:`by_element` method: - - >>> volumes = mesh.material_volumes(...) - >>> volumes.by_element(42) - [(2, 31.87963824195591), (1, 6.129949130817542)] - - """ - def __init__( - self, - materials: np.ndarray, - volumes: np.ndarray, - bboxes: np.ndarray | None = None - ): - self._materials = materials - self._volumes = volumes - self._bboxes = bboxes - - if self._bboxes is not None: - if self._bboxes.shape[:2] != self._materials.shape: - raise ValueError( - 'bboxes must have shape (elements, max_materials, 6) ' - 'matching materials/volumes.' - ) - if self._bboxes.shape[2] != 6: - raise ValueError( - 'bboxes must have shape (elements, max_materials, 6).' - ) - - @property - def has_bounding_boxes(self) -> bool: - return self._bboxes is not None - - @property - def num_elements(self) -> int: - return self._volumes.shape[0] - - def __iter__(self): - for mat in np.unique(self._materials): - if mat > 0: - yield mat - - def __len__(self) -> int: - return (np.unique(self._materials) > 0).sum() - - def __repr__(self) -> str: - ids, counts = np.unique(self._materials, return_counts=True) - return '{' + '\n '.join( - f'{id}: <{count} nonzero volumes>' for id, count in zip(ids, counts) if id > 0) + '}' - - def __getitem__(self, material_id: int) -> np.ndarray: - volumes = np.zeros(self.num_elements) - for i in range(self._volumes.shape[1]): - indices = (self._materials[:, i] == material_id) - volumes[indices] = self._volumes[indices, i] - return volumes - - def by_element( - self, - index_elem: int, - include_bboxes: bool = False - ) -> list[tuple[int | None, float] | tuple[int | None, float, BoundingBox | None]]: - """Get a list of volumes for each material within a specific element. - - Parameters - ---------- - index_elem : int - Mesh element index - - Returns - ------- - list of tuple - If ``include_bboxes`` is False (default), returns tuples of - (material ID, volume). If ``include_bboxes`` is True, returns - tuples of (material ID, volume, bounding box). - - """ - table_size = self._volumes.shape[1] - if include_bboxes and self._bboxes is None: - raise ValueError('Bounding boxes were not computed for this object.') - - results = [] - for i in range(table_size): - m = self._materials[index_elem, i] - if m == -2: - continue - mat_id = m if m > -1 else None - vol = self._volumes[index_elem, i] - - if include_bboxes: - vals = self._bboxes[index_elem, i] - bbox = BoundingBox(vals[0:3], vals[3:6]) - results.append((mat_id, vol, bbox)) - else: - results.append((mat_id, vol)) - - return results - - def save(self, filename: PathLike): - """Save material volumes to a .npz file. - - Parameters - ---------- - filename : path-like - Filename where data will be saved - """ - kwargs = {'materials': self._materials, 'volumes': self._volumes} - if self._bboxes is not None: - kwargs['bboxes'] = self._bboxes - np.savez_compressed(filename, **kwargs) - - @classmethod - def from_npz(cls, filename: PathLike) -> MeshMaterialVolumes: - """Generate material volumes from a .npz file - - Parameters - ---------- - filename : path-like - File where data will be read from - - """ - filedata = np.load(filename) - bboxes = filedata['bboxes'] if 'bboxes' in filedata.files else None - return cls(filedata['materials'], filedata['volumes'], bboxes) class MeshBase(IDManagerMixin, ABC): @@ -202,23 +39,17 @@ class MeshBase(IDManagerMixin, ABC): Unique identifier for the mesh name : str Name of the mesh - lower_left : Iterable of float - The lower-left coordinates - upper_right : Iterable of float - The upper-right coordinates bounding_box : openmc.BoundingBox Axis-aligned bounding box of the mesh as defined by the upper-right and lower-left coordinates. indices : Iterable of tuple An iterable of mesh indices for each mesh element, e.g. [(1, 1, 1), (2, 1, 1), ...] - n_elements : int - Number of elements in the mesh """ next_id = 1 used_ids = set() - def __init__(self, mesh_id: int | None = None, name: str = ''): + def __init__(self, mesh_id: Optional[int] = None, name: str = ''): # Initialize Mesh class attributes self.id = mesh_id self.name = name @@ -235,16 +66,6 @@ class MeshBase(IDManagerMixin, ABC): else: self._name = '' - @property - @abstractmethod - def lower_left(self): - pass - - @property - @abstractmethod - def upper_right(self): - pass - @property def bounding_box(self) -> openmc.BoundingBox: return openmc.BoundingBox(self.lower_left, self.upper_right) @@ -254,11 +75,6 @@ class MeshBase(IDManagerMixin, ABC): def indices(self): pass - @property - @abstractmethod - def n_elements(self): - pass - def __repr__(self): string = type(self).__name__ + '\n' string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) @@ -266,11 +82,10 @@ class MeshBase(IDManagerMixin, ABC): return string def _volume_dim_check(self): - if any(d == 0 for d in self.dimension): - raise RuntimeError( - f'Mesh {self.id} has a zero-size dimension. ' - 'Volumes cannot be provided.' - ) + if self.n_dimension != 3 or \ + any([d == 0 for d in self.dimension]): + raise RuntimeError(f'Mesh {self.id} is not 3D. ' + 'Volumes cannot be provided.') @classmethod def from_hdf5(cls, group: h5py.Group): @@ -287,40 +102,21 @@ class MeshBase(IDManagerMixin, ABC): Instance of a MeshBase subclass """ - mesh_type = 'regular' if 'type' not in group.keys() else group['type'][()].decode() - mesh_id = int(group.name.split('/')[-1].lstrip('mesh ')) - mesh_name = '' if 'name' not in group else group['name'][()].decode() + mesh_type = group['type'][()].decode() if mesh_type == 'regular': - return RegularMesh.from_hdf5(group, mesh_id, mesh_name) + return RegularMesh.from_hdf5(group) elif mesh_type == 'rectilinear': - return RectilinearMesh.from_hdf5(group, mesh_id, mesh_name) + return RectilinearMesh.from_hdf5(group) elif mesh_type == 'cylindrical': - return CylindricalMesh.from_hdf5(group, mesh_id, mesh_name) + return CylindricalMesh.from_hdf5(group) elif mesh_type == 'spherical': - return SphericalMesh.from_hdf5(group, mesh_id, mesh_name) + return SphericalMesh.from_hdf5(group) elif mesh_type == 'unstructured': - return UnstructuredMesh.from_hdf5(group, mesh_id, mesh_name) + return UnstructuredMesh.from_hdf5(group) else: raise ValueError('Unrecognized mesh type: "' + mesh_type + '"') - def to_xml_element(self): - """Return XML representation of the mesh - - Returns - ------- - element : lxml.etree._Element - XML element containing mesh data - - """ - elem = ET.Element("mesh") - - elem.set("id", str(self._id)) - if self.name: - elem.set("name", self.name) - - return elem - @classmethod def from_xml_element(cls, elem: ET.Element): """Generates a mesh from an XML element @@ -339,29 +135,26 @@ class MeshBase(IDManagerMixin, ABC): mesh_type = get_text(elem, 'type') if mesh_type == 'regular' or mesh_type is None: - mesh = RegularMesh.from_xml_element(elem) + return RegularMesh.from_xml_element(elem) elif mesh_type == 'rectilinear': - mesh = RectilinearMesh.from_xml_element(elem) + return RectilinearMesh.from_xml_element(elem) elif mesh_type == 'cylindrical': - mesh = CylindricalMesh.from_xml_element(elem) + return CylindricalMesh.from_xml_element(elem) elif mesh_type == 'spherical': - mesh = SphericalMesh.from_xml_element(elem) + return SphericalMesh.from_xml_element(elem) elif mesh_type == 'unstructured': - mesh = UnstructuredMesh.from_xml_element(elem) + return UnstructuredMesh.from_xml_element(elem) else: raise ValueError(f'Unrecognized mesh type "{mesh_type}" found.') - mesh.name = get_text(elem, 'name', default='') - return mesh - def get_homogenized_materials( self, model: openmc.Model, - n_samples: int | tuple[int, int, int] = 10_000, + n_samples: int = 10_000, + prn_seed: Optional[int] = None, include_void: bool = True, - material_volumes: MeshMaterialVolumes | None = None, **kwargs - ) -> list[openmc.Material]: + ) -> List[openmc.Material]: """Generate homogenized materials over each element in a mesh. .. versionadded:: 0.15.0 @@ -371,19 +164,15 @@ class MeshBase(IDManagerMixin, ABC): model : openmc.Model Model containing materials to be homogenized and the associated geometry. - n_samples : int or 2-tuple of int - Total number of rays to sample. The number of rays in each direction - is determined by the aspect ratio of the mesh bounding box. When - specified as a 3-tuple, it is interpreted as the number of rays in - the x, y, and z dimensions. + n_samples : int + Number of samples in each mesh element. + prn_seed : int, optional + Pseudorandom number generator (PRNG) seed; if None, one will be + generated randomly. include_void : bool, optional Whether homogenization should include voids. - material_volumes : MeshMaterialVolumes, optional - Previously computed mesh material volumes to use for homogenization. - If not provided, they will be computed by calling - :meth:`material_volumes`. **kwargs - Keyword-arguments passed to :meth:`material_volumes`. + Keyword-arguments passed to :func:`openmc.lib.init`. Returns ------- @@ -391,16 +180,49 @@ class MeshBase(IDManagerMixin, ABC): Homogenized material in each mesh element """ - if material_volumes is None: - vols = self.material_volumes(model, n_samples, **kwargs) - else: - vols = material_volumes - mat_volume_by_element = [vols.by_element(i) for i in range(vols.num_elements)] + import openmc.lib - # Get dictionary of all materials - materials = model._get_all_materials() + with change_directory(tmpdir=True): + # In order to get mesh into model, we temporarily replace the + # tallies with a single mesh tally using the current mesh + original_tallies = model.tallies + new_tally = openmc.Tally() + new_tally.filters = [openmc.MeshFilter(self)] + new_tally.scores = ['flux'] + model.tallies = [new_tally] + + # Export model to XML + model.export_to_model_xml() + + # Get material volume fractions + openmc.lib.init(**kwargs) + mesh = openmc.lib.tallies[new_tally.id].filters[0].mesh + mat_volume_by_element = [ + [ + (mat.id if mat is not None else None, volume) + for mat, volume in mat_volume_list + ] + for mat_volume_list in mesh.material_volumes(n_samples, prn_seed) + ] + openmc.lib.finalize() + + # Restore original tallies + model.tallies = original_tallies # Create homogenized material for each element + materials = model.geometry.get_all_materials() + + # Account for materials in DAGMC universes + # TODO: This should really get incorporated in lower-level calls to + # get_all_materials, but right now it requires information from the + # Model object + for cell in model.geometry.get_all_cells().values(): + if isinstance(cell.fill, openmc.DAGMCUniverse): + names = cell.fill.material_names + materials.update({ + mat.id: mat for mat in model.materials if mat.name in names + }) + homogenized_materials = [] for mat_volume_list in mat_volume_by_element: material_ids, volumes = [list(x) for x in zip(*mat_volume_list)] @@ -432,77 +254,6 @@ class MeshBase(IDManagerMixin, ABC): return homogenized_materials - def material_volumes( - self, - model: openmc.Model, - n_samples: int | tuple[int, int, int] = 10_000, - max_materials: int = 4, - bounding_boxes: bool = False, - **kwargs - ) -> MeshMaterialVolumes: - """Determine volume of materials in each mesh element. - - This method works by raytracing repeatedly through the mesh to count the - estimated volume of each material in all mesh elements. Three sets of - rays are used: one set parallel to the x-axis, one parallel to the - y-axis, and one parallel to the z-axis. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - model : openmc.Model - Model containing materials. - n_samples : int or 3-tuple of int - Total number of rays to sample. The number of rays in each direction - is determined by the aspect ratio of the mesh bounding box. When - specified as a 3-tuple, it is interpreted as the number of rays in - the x, y, and z dimensions. - max_materials : int, optional - Estimated maximum number of materials in any given mesh element. - bounding_boxes : bool, optional - Whether to compute an axis-aligned bounding box for each - (mesh element, material) combination. When enabled, the bounding - box encloses the ray-estimator prisms used for the volume - estimation. - **kwargs : dict - Keyword arguments passed to :func:`openmc.lib.init` - - Returns - ------- - Dictionary-like object that maps material IDs to an array of volumes - equal in size to the number of mesh elements. - - """ - import openmc.lib - - # In order to get mesh into model, we temporarily replace the - # tallies with a single mesh tally using the current mesh - original_tallies = list(model.tallies) - new_tally = openmc.Tally() - new_tally.filters = [openmc.MeshFilter(self)] - new_tally.scores = ['flux'] - model.tallies = [new_tally] - - # Set default arguments - kwargs.setdefault('output', True) - if 'args' in kwargs: - kwargs['args'] = ['-c'] + kwargs['args'] - kwargs.setdefault('args', ['-c']) - - with openmc.lib.TemporarySession(model, **kwargs): - # Get mesh from single tally - mesh = openmc.lib.tallies[new_tally.id].filters[0].mesh - - # Compute material volumes - volumes = mesh.material_volumes( - n_samples, max_materials, output=kwargs['output'], - bounding_boxes=bounding_boxes) - - # Restore original tallies - model.tallies = original_tallies - return volumes - class StructuredMesh(MeshBase): """A base class for structured mesh functionality @@ -536,20 +287,11 @@ class StructuredMesh(MeshBase): def n_dimension(self): pass - @property - @abstractmethod - def _axis_labels(self): - pass - @property @abstractmethod def _grids(self): pass - @abstractmethod - def get_indices_at_coords(self, coords: Sequence[float]) -> tuple: - pass - @property def vertices(self): """Return coordinates of mesh vertices in Cartesian coordinates. Also @@ -645,22 +387,13 @@ class StructuredMesh(MeshBase): s1 = (slice(1, None),)*ndim + (slice(None),) return (vertices[s0] + vertices[s1]) / 2 - @property - def n_elements(self): - return np.prod(self.dimension) - @property def num_mesh_cells(self): - warnings.warn( - "The 'num_mesh_cells' attribute is deprecated and will be removed in a future version. " - "Use 'n_elements' instead.", - FutureWarning, stacklevel=2 - ) - return self.n_elements + return np.prod(self.dimension) def write_data_to_vtk(self, filename: PathLike, - datasets: dict | None = None, + datasets: Optional[dict] = None, volume_normalization: bool = True, curvilinear: bool = False): """Creates a VTK object of the mesh @@ -670,16 +403,11 @@ class StructuredMesh(MeshBase): filename : str Name of the VTK file to write. datasets : dict - Dictionary whose keys are the data labels and values are the data - sets. 1D datasets are expected to be extracted directly from - statepoint data without reordering/reshaping. Multidimensional - datasets are expected to have the same dimensions as the mesh itself - with structured indexing in "C" ordering. See the "expand_dims" flag - of :meth:`~openmc.Tally.get_reshaped_data` on reshaping tally data when using - :class:`~openmc.MeshFilter`'s. + Dictionary whose keys are the data labels + and values are the data sets. volume_normalization : bool, optional - Whether or not to normalize the data by the volume of the mesh - elements. + Whether or not to normalize the data by + the volume of the mesh elements. curvilinear : bool Whether or not to write curvilinear elements. Only applies to ``SphericalMesh`` and ``CylindricalMesh``. @@ -693,27 +421,14 @@ class StructuredMesh(MeshBase): ------- vtk.StructuredGrid or vtk.UnstructuredGrid a VTK grid object representing the mesh - - Examples - -------- - 1D data from a tally with only a mesh filter and heating score: - - # pass the tally mean property of shape (N, 1, 1) directly to this - # method; dimensions of size 1 will automatically removed - >>> heating = tally.mean - >>> mesh.write_data_to_vtk({'heating': heating}) - - Multidimensional data from a tally with only a mesh - - # retrieve a data array with the mesh filter expanded into three - # dimensions, ijk; additional dimensions of size one will - # automatically be removed - >>> heating = tally.get_reshaped_data(expand_dims=True) - >>> mesh.write_data_to_vtk({'heating': heating}) """ import vtk from vtk.util import numpy_support as nps + # check that the data sets are appropriately sized + if datasets is not None: + self._check_vtk_datasets(datasets) + # write linear elements using a structured grid if not curvilinear or isinstance(self, (RegularMesh, RectilinearMesh)): vtk_grid = self._create_vtk_structured_grid() @@ -724,27 +439,22 @@ class StructuredMesh(MeshBase): writer = vtk.vtkUnstructuredGridWriter() if datasets is not None: - # maintain a list of the datasets as added to the VTK arrays to - # ensure they persist in memory until the file is written + # maintain a list of the datasets as added + # to the VTK arrays to ensure they persist + # in memory until the file is written datasets_out = [] for label, dataset in datasets.items(): - dataset = self._reshape_vtk_dataset(dataset) - self._check_vtk_dataset(label, dataset) - # If the array data is 3D, assume is in C ordering and transpose - # before flattening to match the ordering expected by the VTK - # array based on the way mesh indices are ordered in the Python - # API - # TODO: update to "C" ordering throughout - if dataset.ndim == 3: - dataset = dataset.T.ravel() + dataset = np.asarray(dataset).flatten() datasets_out.append(dataset) if volume_normalization: - dataset /= self.volumes.T.ravel() + dataset /= self.volumes.T.flatten() dataset_array = vtk.vtkDoubleArray() dataset_array.SetName(label) - dataset_array.SetArray(nps.numpy_to_vtk(dataset), dataset.size, True) + dataset_array.SetArray(nps.numpy_to_vtk(dataset), + dataset.size, + True) vtk_grid.GetCellData().AddArray(dataset_array) writer.SetFileName(str(filename)) @@ -871,155 +581,28 @@ class StructuredMesh(MeshBase): return vtk_grid - @staticmethod - def _reshape_vtk_dataset(dataset): - """Reshape a dataset to be compatible with VTK output - - This method performs the following operations on a dataset: - 1. Convert to numpy array if not already - 2. Remove any trailing dimensions of size 1 - 3. Squeeze out any extra dimensions of size 1 beyond the first 3 + def _check_vtk_datasets(self, datasets: dict): + """Perform some basic checks that the datasets are valid for this mesh Parameters ---------- - dataset : array-like - The dataset to reshape - - Returns - ------- - numpy.ndarray - The reshaped dataset - """ - reshaped_data = np.asarray(dataset) - - # detect flat array with extra dims - if all(d == 1 for d in reshaped_data.shape[1:]): - reshaped_data = reshaped_data.squeeze() - - # remove any higher dimensions with size 1 - if reshaped_data.ndim > 3 and all(d == 1 for d in reshaped_data.shape[3:]): - reshaped_data = reshaped_data.reshape(reshaped_data.shape[:3]) - - if np.shares_memory(reshaped_data, dataset): - return np.copy(reshaped_data) - else: - return reshaped_data - - def _check_vtk_dataset(self, label: str, dataset: np.ndarray): - """Perform some basic checks that a dataset is valid for this Mesh - - Parameters - ---------- - label : str - The label for the dataset being checked - dataset : numpy.ndarray - The dataset array to check against this mesh's dimensions + datasets : dict + Dictionary whose keys are the data labels + and values are the data sets. """ - cv.check_type('data label', label, str) - - if dataset.size != self.n_elements: - raise ValueError( + for label, dataset in datasets.items(): + errmsg = ( f"The size of the dataset '{label}' ({dataset.size}) should be" - f" equal to the number of mesh cells ({self.n_elements})" + f" equal to the number of mesh cells ({self.num_mesh_cells})" ) - - # accept a flat array as-is, assuming it is in the correct order - if dataset.ndim == 1: - return - - if dataset.shape != self.dimension: - raise ValueError( - f'Cannot apply multidimensional dataset "{label}" with ' - f"shape {dataset.shape} to mesh {self.id} " - f"with dimensions {self.dimension}" - ) - - @classmethod - def from_domain( - cls, - domain: HasBoundingBox | BoundingBox, - dimension: Sequence[int] | int | None = None, - mesh_id: int | None = None, - name: str = '', - **kwargs - ) -> StructuredMesh: - """Create a structured mesh from a domain using its bounding box. - - Parameters - ---------- - domain : HasBoundingBox | openmc.BoundingBox - Object used as a template for the mesh extents. If ``domain`` has a - ``bounding_box`` attribute, that bounding box is used directly. - dimension : Iterable of int or int, optional - Number of mesh cells. When omitted, the subclass-specific default is - used. If provided as a single integer, subclasses that support it - interpret it as a target total number of mesh cells. - mesh_id : int, optional - Unique identifier for the mesh. - name : str, optional - Name of the mesh. - **kwargs - Additional keyword arguments forwarded to - :meth:`from_bounding_box`. - - Returns - ------- - openmc.StructuredMesh - Structured mesh instance. - """ - if isinstance(domain, BoundingBox): - bbox = domain - elif hasattr(domain, 'bounding_box'): - bbox = domain.bounding_box - else: - raise TypeError("Domain must be a BoundingBox or have a " - "bounding_box property") - - if dimension is None: - return cls.from_bounding_box( - bbox, mesh_id=mesh_id, name=name, **kwargs) - - return cls.from_bounding_box( - bbox, dimension=dimension, mesh_id=mesh_id, name=name, **kwargs) - - @classmethod - @abstractmethod - def from_bounding_box( - cls, - bbox: openmc.BoundingBox, - dimension: Sequence[int] | int, - mesh_id: int | None = None, - name: str = '', - **kwargs - ) -> StructuredMesh: - """Create a structured mesh from a bounding box. - - Parameters - ---------- - bbox : openmc.BoundingBox - Bounding box used to define the mesh extents. - dimension : Iterable of int or int - Number of mesh cells. The interpretation and any default value are - defined by the concrete mesh type. - mesh_id : int, optional - Unique identifier for the mesh. - name : str, optional - Name of the mesh. - **kwargs - Additional keyword arguments accepted by specific subclasses. - - Returns - ------- - openmc.StructuredMesh - Structured mesh instance. - """ - pass - - -class HasBoundingBox(Protocol): - """Object that has a ``bounding_box`` attribute.""" - bounding_box: openmc.BoundingBox + if isinstance(dataset, np.ndarray): + if not dataset.size == self.num_mesh_cells: + raise ValueError(errmsg) + else: + if len(dataset) == self.num_mesh_cells: + raise ValueError(errmsg) + cv.check_type('data label', label, str) class RegularMesh(StructuredMesh): @@ -1059,7 +642,7 @@ class RegularMesh(StructuredMesh): """ - def __init__(self, mesh_id: int | None = None, name: str = ''): + def __init__(self, mesh_id: Optional[int] = None, name: str = ''): super().__init__(mesh_id, name) self._dimension = None @@ -1072,7 +655,7 @@ class RegularMesh(StructuredMesh): return tuple(self._dimension) @dimension.setter - def dimension(self, dimension: Iterable[int]): + def dimension(self, dimension: typing.Iterable[int]): cv.check_type('mesh dimension', dimension, Iterable, Integral) cv.check_length('mesh dimension', dimension, 1, 3) self._dimension = dimension @@ -1084,16 +667,12 @@ class RegularMesh(StructuredMesh): else: return None - @property - def _axis_labels(self): - return ('x', 'y', 'z')[:self.n_dimension] - @property def lower_left(self): return self._lower_left @lower_left.setter - def lower_left(self, lower_left: Iterable[Real]): + def lower_left(self, lower_left: typing.Iterable[Real]): cv.check_type('mesh lower_left', lower_left, Iterable, Real) cv.check_length('mesh lower_left', lower_left, 1, 3) self._lower_left = lower_left @@ -1113,7 +692,7 @@ class RegularMesh(StructuredMesh): return [l + w * d for l, w, d in zip(ls, ws, dims)] @upper_right.setter - def upper_right(self, upper_right: Iterable[Real]): + def upper_right(self, upper_right: typing.Iterable[Real]): cv.check_type('mesh upper_right', upper_right, Iterable, Real) cv.check_length('mesh upper_right', upper_right, 1, 3) self._upper_right = upper_right @@ -1137,7 +716,7 @@ class RegularMesh(StructuredMesh): return [(u - l) / d for u, l, d in zip(us, ls, dims)] @width.setter - def width(self, width: Iterable[Real]): + def width(self, width: typing.Iterable[Real]): cv.check_type('mesh width', width, Iterable, Real) cv.check_length('mesh width', width, 1, 3) self._width = width @@ -1210,14 +789,16 @@ class RegularMesh(StructuredMesh): string += '{0: <16}{1}{2}\n'.format('\tDimensions', '=\t', self.n_dimension) string += '{0: <16}{1}{2}\n'.format('\tVoxels', '=\t', self._dimension) string += '{0: <16}{1}{2}\n'.format('\tLower left', '=\t', self._lower_left) - string += '{0: <16}{1}{2}\n'.format('\tUpper Right', '=\t', self.upper_right) - string += '{0: <16}{1}{2}\n'.format('\tWidth', '=\t', self.width) + string += '{0: <16}{1}{2}\n'.format('\tUpper Right', '=\t', self._upper_right) + string += '{0: <16}{1}{2}\n'.format('\tWidth', '=\t', self._width) return string @classmethod - def from_hdf5(cls, group: h5py.Group, mesh_id: int, name: str): + def from_hdf5(cls, group: h5py.Group): + mesh_id = int(group.name.split('/')[-1].lstrip('mesh ')) + # Read and assign mesh properties - mesh = cls(mesh_id=mesh_id, name=name) + mesh = cls(mesh_id) mesh.dimension = group['dimension'][()] mesh.lower_left = group['lower_left'][()] if 'width' in group: @@ -1234,7 +815,7 @@ class RegularMesh(StructuredMesh): cls, lattice: 'openmc.RectLattice', division: int = 1, - mesh_id: int | None = None, + mesh_id: Optional[int] = None, name: str = '' ): """Create mesh from an existing rectangular lattice @@ -1270,47 +851,46 @@ class RegularMesh(StructuredMesh): return mesh @classmethod - def from_bounding_box( + def from_domain( cls, - bbox: openmc.BoundingBox, - dimension: Sequence[int] | int = 1000, - mesh_id: int | None = None, - name: str = '', - ) -> RegularMesh: - """Create a RegularMesh from a bounding box. + domain: typing.Union['openmc.Cell', 'openmc.Region', 'openmc.Universe', 'openmc.Geometry'], + dimension: Sequence[int] = (10, 10, 10), + mesh_id: Optional[int] = None, + name: str = '' + ): + """Create mesh from an existing openmc cell, region, universe or + geometry by making use of the objects bounding box property. Parameters ---------- - bbox : openmc.BoundingBox - Bounding box used to set the mesh extents. - dimension : Iterable of int or int, optional - The number of mesh cells in each direction (x, y, z). If a single - integer is provided, the total number of cells is distributed - across directions to produce cells with roughly equal widths. - mesh_id : int, optional - Unique identifier for the mesh. - name : str, optional - Name of the mesh. + domain : {openmc.Cell, openmc.Region, openmc.Universe, openmc.Geometry} + The object passed in will be used as a template for this mesh. The + bounding box of the property of the object passed will be used to + set the lower_left and upper_right and of the mesh instance + dimension : Iterable of int + The number of mesh cells in each direction (x, y, z). + mesh_id : int + Unique identifier for the mesh + name : str + Name of the mesh Returns ------- openmc.RegularMesh - RegularMesh instance. + RegularMesh instance + """ + cv.check_type( + "domain", + domain, + (openmc.Cell, openmc.Region, openmc.Universe, openmc.Geometry), + ) + mesh = cls(mesh_id=mesh_id, name=name) - mesh.lower_left = bbox[0] - mesh.upper_right = bbox[1] - if isinstance(dimension, int): - cv.check_greater_than("dimension", dimension, 1, equality=True) - # If a single integer is provided, divide the domain into that many - # mesh cells with roughly equal lengths in each direction - ideal_cube_volume = bbox.volume / dimension - ideal_cube_size = ideal_cube_volume ** (1 / 3) - dimension = [ - max(1, int(round(side / ideal_cube_size))) - for side in bbox.width - ] + mesh.lower_left = domain.bounding_box[0] + mesh.upper_right = domain.bounding_box[1] mesh.dimension = dimension + return mesh def to_xml_element(self): @@ -1322,7 +902,9 @@ class RegularMesh(StructuredMesh): XML element containing mesh data """ - element = super().to_xml_element() + + element = ET.Element("mesh") + element.set("id", str(self._id)) if self._dimension is not None: subelement = ET.SubElement(element, "dimension") @@ -1358,25 +940,29 @@ class RegularMesh(StructuredMesh): mesh_id = int(get_text(elem, 'id')) mesh = cls(mesh_id=mesh_id) - dimension = get_elem_list(elem, "dimension", int) + mesh_type = get_text(elem, 'type') + if mesh_type is not None: + mesh.type = mesh_type + + dimension = get_text(elem, 'dimension') if dimension is not None: - mesh.dimension = dimension + mesh.dimension = [int(x) for x in dimension.split()] - lower_left = get_elem_list(elem, "lower_left", float) + lower_left = get_text(elem, 'lower_left') if lower_left is not None: - mesh.lower_left = lower_left + mesh.lower_left = [float(x) for x in lower_left.split()] - upper_right = get_elem_list(elem, "upper_right", float) + upper_right = get_text(elem, 'upper_right') if upper_right is not None: - mesh.upper_right = upper_right + mesh.upper_right = [float(x) for x in upper_right.split()] - width = get_elem_list(elem, "width", float) + width = get_text(elem, 'width') if width is not None: - mesh.width = width + mesh.width = [float(x) for x in width.split()] return mesh - def build_cells(self, bc: str | None = None): + def build_cells(self, bc: Optional[str] = None): """Generates a lattice of universes with the same dimensionality as the mesh object. The individual cells/universes produced will not have material definitions applied and so downstream code @@ -1501,47 +1087,6 @@ class RegularMesh(StructuredMesh): return root_cell, cells - def get_indices_at_coords(self, coords: Sequence[float]) -> tuple: - """Finds the index of the mesh element at the specified coordinates. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - coords : Sequence[float] - Cartesian coordinates of the point. - - Returns - ------- - tuple - Mesh indices matching the dimensionality of the mesh - - """ - ndim = self.n_dimension - if len(coords) < ndim: - raise ValueError( - f"coords must have at least {ndim} values for a " - f"{ndim}D mesh, got {len(coords)}" - ) - - coords_array = np.array(coords[:ndim]) - lower_left = np.array(self.lower_left) - upper_right = np.array(self.upper_right) - dimension = np.array(self.dimension) - - if np.any(coords_array < lower_left) or np.any(coords_array > upper_right): - raise ValueError( - f"coords {tuple(coords_array)} are outside mesh bounds " - f"[{tuple(lower_left)}, {tuple(upper_right)}]" - ) - - # Calculate spacing for each dimension - spacing = (upper_right - lower_left) / dimension - - # Calculate indices for each coordinate - indices = np.floor((coords_array - lower_left) / spacing).astype(int) - return tuple(int(i) for i in indices[:ndim]) - def Mesh(*args, **kwargs): warnings.warn("Mesh has been renamed RegularMesh. Future versions of " @@ -1601,10 +1146,6 @@ class RectilinearMesh(StructuredMesh): def n_dimension(self): return 3 - @property - def _axis_labels(self): - return ('x', 'y', 'z') - @property def x_grid(self): return self._x_grid @@ -1697,9 +1238,11 @@ class RectilinearMesh(StructuredMesh): return string @classmethod - def from_hdf5(cls, group: h5py.Group, mesh_id: int, name: str): + def from_hdf5(cls, group: h5py.Group): + mesh_id = int(group.name.split('/')[-1].lstrip('mesh ')) + # Read and assign mesh properties - mesh = cls(mesh_id=mesh_id, name=name) + mesh = cls(mesh_id=mesh_id) mesh.x_grid = group['x_grid'][()] mesh.y_grid = group['y_grid'][()] mesh.z_grid = group['z_grid'][()] @@ -1723,9 +1266,9 @@ class RectilinearMesh(StructuredMesh): """ mesh_id = int(get_text(elem, 'id')) mesh = cls(mesh_id=mesh_id) - mesh.x_grid = get_elem_list(elem, "x_grid", float) - mesh.y_grid = get_elem_list(elem, "y_grid", float) - mesh.z_grid = get_elem_list(elem, "z_grid", float) + mesh.x_grid = [float(x) for x in get_text(elem, 'x_grid').split()] + mesh.y_grid = [float(y) for y in get_text(elem, 'y_grid').split()] + mesh.z_grid = [float(z) for z in get_text(elem, 'z_grid').split()] return mesh @@ -1739,7 +1282,8 @@ class RectilinearMesh(StructuredMesh): """ - element = super().to_xml_element() + element = ET.Element("mesh") + element.set("id", str(self._id)) element.set("type", "rectilinear") subelement = ET.SubElement(element, "x_grid") @@ -1753,90 +1297,6 @@ class RectilinearMesh(StructuredMesh): return element - def get_indices_at_coords(self, coords: Sequence[float]) -> tuple[int, int, int]: - """Find the mesh cell indices containing the specified coordinates. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - coords : Sequence[float] - Cartesian coordinates of the point as (x, y, z). - - Returns - ------- - tuple[int, int, int] - Mesh indices (ix, iy, iz). - - Raises - ------ - ValueError - If coords does not contain exactly 3 values, or if a coordinate is - outside the mesh grid boundaries. - """ - if len(coords) != 3: - raise ValueError( - f"coords must contain exactly 3 values for a rectilinear mesh, " - f"got {len(coords)}" - ) - - grids = (self.x_grid, self.y_grid, self.z_grid) - indices = [] - - for grid, value in zip(grids, coords): - if value < grid[0] or value > grid[-1]: - raise ValueError( - f"Coordinate value {value} is outside the mesh grid boundaries: " - f"[{grid[0]}, {grid[-1]}]" - ) - - idx = np.searchsorted(grid, value, side="right") - 1 - indices.append(int(min(idx, len(grid) - 2))) - - return tuple(indices) - - @classmethod - def from_bounding_box( - cls, - bbox: openmc.BoundingBox, - dimension: Sequence[int] | int = 1000, - mesh_id: int | None = None, - name: str = '', - ) -> RectilinearMesh: - """Create a RectilinearMesh from a bounding box with uniform grids. - - Parameters - ---------- - bbox : openmc.BoundingBox - Bounding box used to set the mesh extents. - dimension : Iterable of int or int, optional - The number of mesh cells in each direction (x, y, z). If a single - integer is provided, the total number of cells is distributed across - the three directions proportionally to the side lengths. - mesh_id : int, optional - Unique identifier for the mesh. - name : str, optional - Name of the mesh. - - Returns - ------- - openmc.RectilinearMesh - RectilinearMesh instance with uniform grids along each axis. - """ - if isinstance(dimension, int): - cv.check_greater_than("dimension", dimension, 1, equality=True) - ideal_cube_volume = bbox.volume / dimension - ideal_cube_size = ideal_cube_volume ** (1 / 3) - dimension = [ - max(1, int(round(side / ideal_cube_size))) - for side in bbox.width - ] - mesh = cls(mesh_id=mesh_id, name=name) - mesh.x_grid = np.linspace(bbox[0][0], bbox[1][0], num=dimension[0] + 1) - mesh.y_grid = np.linspace(bbox[0][1], bbox[1][1], num=dimension[1] + 1) - mesh.z_grid = np.linspace(bbox[0][2], bbox[1][2], num=dimension[2] + 1) - return mesh - class CylindricalMesh(StructuredMesh): """A 3D cylindrical mesh @@ -1901,9 +1361,9 @@ class CylindricalMesh(StructuredMesh): self, r_grid: Sequence[float], z_grid: Sequence[float], - phi_grid: Sequence[float] = (0, 2*math.pi), + phi_grid: Sequence[float] = (0, 2*pi), origin: Sequence[float] = (0., 0., 0.), - mesh_id: int | None = None, + mesh_id: Optional[int] = None, name: str = '', ): super().__init__(mesh_id, name) @@ -1923,10 +1383,6 @@ class CylindricalMesh(StructuredMesh): def n_dimension(self): return 3 - @property - def _axis_labels(self): - return ('r', 'phi', 'z') - @property def origin(self): return self._origin @@ -1958,7 +1414,7 @@ class CylindricalMesh(StructuredMesh): cv.check_length('mesh phi_grid', grid, 2) cv.check_increasing('mesh phi_grid', grid) grid = np.asarray(grid, dtype=float) - if np.any((grid < 0.0) | (grid > 2*math.pi)): + if np.any((grid < 0.0) | (grid > 2*pi)): raise ValueError("phi_grid values must be in [0, 2π].") self._phi_grid = grid @@ -2026,25 +1482,25 @@ class CylindricalMesh(StructuredMesh): return string def get_indices_at_coords( - self, - coords: Sequence[float] - ) -> tuple[int, int, int]: - """Finds the index of the mesh element at the specified coordinates. + self, + coords: Sequence[float] + ) -> Tuple[int, int, int]: + """Finds the index of the mesh voxel at the specified x,y,z coordinates. .. versionadded:: 0.15.0 Parameters ---------- coords : Sequence[float] - Cartesian coordinates of the point. + The x, y, z axis coordinates Returns ------- - tuple[int, int, int] + Tuple[int, int, int] The r, phi, z indices """ - r_value_from_origin = math.hypot(coords[0]-self.origin[0], coords[1]-self.origin[1]) + r_value_from_origin = sqrt((coords[0]-self.origin[0])**2 + (coords[1]-self.origin[1])**2) if r_value_from_origin < self.r_grid[0] or r_value_from_origin > self.r_grid[-1]: raise ValueError( @@ -2068,13 +1524,13 @@ class CylindricalMesh(StructuredMesh): delta_x = coords[0] - self.origin[0] delta_y = coords[1] - self.origin[1] # atan2 returns values in -pi to +pi range - phi_value = math.atan2(delta_y, delta_x) + phi_value = atan2(delta_y, delta_x) if delta_x < 0 and delta_y < 0: # returned phi_value anticlockwise and negative - phi_value += 2 * math.pi + phi_value += 2 * pi if delta_x > 0 and delta_y < 0: # returned phi_value anticlockwise and negative - phi_value += 2 * math.pi + phi_value += 2 * pi phi_grid_values = np.array(self.phi_grid) @@ -2088,11 +1544,12 @@ class CylindricalMesh(StructuredMesh): return (r_index, phi_index, z_index) @classmethod - def from_hdf5(cls, group: h5py.Group, mesh_id: int, name: str): + def from_hdf5(cls, group: h5py.Group): + mesh_id = int(group.name.split('/')[-1].lstrip('mesh ')) + # Read and assign mesh properties mesh = cls( mesh_id=mesh_id, - name=name, r_grid = group['r_grid'][()], phi_grid = group['phi_grid'][()], z_grid = group['z_grid'][()], @@ -2103,34 +1560,32 @@ class CylindricalMesh(StructuredMesh): return mesh @classmethod - def from_bounding_box( + def from_domain( cls, - bbox: openmc.BoundingBox, + domain: typing.Union['openmc.Cell', 'openmc.Region', 'openmc.Universe', 'openmc.Geometry'], dimension: Sequence[int] = (10, 10, 10), - mesh_id: int | None = None, - name: str = '', - phi_grid_bounds: Sequence[float] = (0.0, 2*math.pi), - enclose_domain: bool = False, - ) -> CylindricalMesh: - """Create CylindricalMesh from a bounding box. + mesh_id: Optional[int] = None, + phi_grid_bounds: Sequence[float] = (0.0, 2*pi), + name: str = '' + ): + """Creates a regular CylindricalMesh from an existing openmc domain. Parameters ---------- - bbox : openmc.BoundingBox - Bounding box used to set the r_grid and z_grid ranges. + domain : openmc.Cell or openmc.Region or openmc.Universe or openmc.Geometry + The object passed in will be used as a template for this mesh. The + bounding box of the property of the object passed will be used to + set the r_grid, z_grid ranges. dimension : Iterable of int The number of equally spaced mesh cells in each direction (r_grid, phi_grid, z_grid) - mesh_id : int, optional + mesh_id : int Unique identifier for the mesh - name : str, optional - Name of the mesh phi_grid_bounds : numpy.ndarray Mesh bounds points along the phi-axis in radians. The default value is (0, 2π), i.e., the full phi range. - enclose_domain : bool - If True, the mesh will encompass the bounding box of the domain. If - False, the mesh will be inscribed within the domain's bounding box. + name : str + Name of the mesh Returns ------- @@ -2138,28 +1593,43 @@ class CylindricalMesh(StructuredMesh): CylindricalMesh instance """ - if enclose_domain: - outer_radius = 0.5 * np.linalg.norm(bbox.width[:2]) - else: - outer_radius = 0.5 * min(bbox.width[:2]) + cv.check_type( + "domain", + domain, + (openmc.Cell, openmc.Region, openmc.Universe, openmc.Geometry), + ) - r_grid = np.linspace(0, outer_radius, num=dimension[0]+1) + # loaded once to avoid recalculating bounding box + cached_bb = domain.bounding_box + max_bounding_box_radius = max( + [ + cached_bb[0][0], + cached_bb[0][1], + cached_bb[1][0], + cached_bb[1][1], + ] + ) + r_grid = np.linspace( + 0, + max_bounding_box_radius, + num=dimension[0]+1 + ) phi_grid = np.linspace( phi_grid_bounds[0], phi_grid_bounds[1], num=dimension[1]+1 ) z_grid = np.linspace( - bbox[0][2], - bbox[1][2], + cached_bb[0][2], + cached_bb[1][2], num=dimension[2]+1 ) - origin = (bbox.center[0], bbox.center[1], z_grid[0]) + origin = (cached_bb.center[0], cached_bb.center[1], z_grid[0]) # make z-grid relative to the origin z_grid -= origin[2] - return cls( + mesh = cls( r_grid=r_grid, z_grid=z_grid, phi_grid=phi_grid, @@ -2168,6 +1638,8 @@ class CylindricalMesh(StructuredMesh): origin=origin ) + return mesh + def to_xml_element(self): """Return XML representation of the mesh @@ -2178,7 +1650,8 @@ class CylindricalMesh(StructuredMesh): """ - element = super().to_xml_element() + element = ET.Element("mesh") + element.set("id", str(self._id)) element.set("type", "cylindrical") subelement = ET.SubElement(element, "r_grid") @@ -2213,10 +1686,10 @@ class CylindricalMesh(StructuredMesh): mesh_id = int(get_text(elem, 'id')) mesh = cls( - r_grid = get_elem_list(elem, "r_grid", float), - phi_grid = get_elem_list(elem, "phi_grid", float), - z_grid = get_elem_list(elem, "z_grid", float), - origin = get_elem_list(elem, "origin", float) or [0., 0., 0.], + r_grid = [float(x) for x in get_text(elem, "r_grid").split()], + phi_grid = [float(x) for x in get_text(elem, "phi_grid").split()], + z_grid = [float(x) for x in get_text(elem, "z_grid").split()], + origin = [float(x) for x in get_text(elem, "origin", default=[0., 0., 0.]).split()], mesh_id=mesh_id, ) @@ -2337,10 +1810,10 @@ class SphericalMesh(StructuredMesh): def __init__( self, r_grid: Sequence[float], - phi_grid: Sequence[float] = (0, 2*math.pi), - theta_grid: Sequence[float] = (0, math.pi), + phi_grid: Sequence[float] = (0, 2*pi), + theta_grid: Sequence[float] = (0, pi), origin: Sequence[float] = (0., 0., 0.), - mesh_id: int | None = None, + mesh_id: Optional[int] = None, name: str = '', ): super().__init__(mesh_id, name) @@ -2360,10 +1833,6 @@ class SphericalMesh(StructuredMesh): def n_dimension(self): return 3 - @property - def _axis_labels(self): - return ('r', 'theta', 'phi') - @property def origin(self): return self._origin @@ -2395,7 +1864,7 @@ class SphericalMesh(StructuredMesh): cv.check_length('mesh theta_grid', grid, 2) cv.check_increasing('mesh theta_grid', grid) grid = np.asarray(grid, dtype=float) - if np.any((grid < 0.0) | (grid > math.pi)): + if np.any((grid < 0.0) | (grid > pi)): raise ValueError("theta_grid values must be in [0, π].") self._theta_grid = grid @@ -2409,7 +1878,7 @@ class SphericalMesh(StructuredMesh): cv.check_length('mesh phi_grid', grid, 2) cv.check_increasing('mesh phi_grid', grid) grid = np.asarray(grid, dtype=float) - if np.any((grid < 0.0) | (grid > 2*math.pi)): + if np.any((grid < 0.0) | (grid > 2*pi)): raise ValueError("phi_grid values must be in [0, 2π].") self._phi_grid = grid @@ -2460,82 +1929,21 @@ class SphericalMesh(StructuredMesh): return string @classmethod - def from_hdf5(cls, group: h5py.Group, mesh_id: int, name: str): + def from_hdf5(cls, group: h5py.Group): + mesh_id = int(group.name.split('/')[-1].lstrip('mesh ')) + # Read and assign mesh properties mesh = cls( r_grid = group['r_grid'][()], theta_grid = group['theta_grid'][()], phi_grid = group['phi_grid'][()], mesh_id=mesh_id, - name=name ) if 'origin' in group: mesh.origin = group['origin'][()] return mesh - @classmethod - def from_bounding_box( - cls, - bbox: openmc.BoundingBox, - dimension: Sequence[int] = (10, 10, 10), - mesh_id: int | None = None, - name: str = '', - phi_grid_bounds: Sequence[float] = (0.0, 2*math.pi), - theta_grid_bounds: Sequence[float] = (0.0, math.pi), - enclose_domain: bool = False, - ) -> SphericalMesh: - """Create SphericalMesh from a bounding box. - - Parameters - ---------- - bbox : openmc.BoundingBox - Bounding box used to set the r_grid, phi_grid, and theta_grid ranges. - dimension : Iterable of int - The number of equally spaced mesh cells in each direction (r_grid, - phi_grid, theta_grid). Spacing is in angular space (radians) for - phi and theta, and in absolute space for r. - mesh_id : int, optional - Unique identifier for the mesh - name : str, optional - Name of the mesh - phi_grid_bounds : numpy.ndarray - Mesh bounds points along the phi-axis in radians. The default value - is (0, 2π), i.e., the full phi range. - theta_grid_bounds : numpy.ndarray - Mesh bounds points along the theta-axis in radians. The default value - is (0, π), i.e., the full theta range. - enclose_domain : bool - If True, the mesh will encompass the bounding box of the domain. If - False, the mesh will be inscribed within the domain's bounding box. - - Returns - ------- - openmc.SphericalMesh - SphericalMesh instance - - """ - if enclose_domain: - outer_radius = 0.5 * np.linalg.norm(bbox.width) - else: - outer_radius = 0.5 * min(bbox.width) - - r_grid = np.linspace(0, outer_radius, num=dimension[0] + 1) - theta_grid = np.linspace( - theta_grid_bounds[0], - theta_grid_bounds[1], - num=dimension[1]+1 - ) - phi_grid = np.linspace( - phi_grid_bounds[0], - phi_grid_bounds[1], - num=dimension[2]+1 - ) - origin = np.array([bbox.center[0], bbox.center[1], bbox.center[2]]) - - return cls(r_grid=r_grid, phi_grid=phi_grid, theta_grid=theta_grid, - origin=origin, mesh_id=mesh_id, name=name) - def to_xml_element(self): """Return XML representation of the mesh @@ -2546,7 +1954,8 @@ class SphericalMesh(StructuredMesh): """ - element = super().to_xml_element() + element = ET.Element("mesh") + element.set("id", str(self._id)) element.set("type", "spherical") subelement = ET.SubElement(element, "r_grid") @@ -2581,10 +1990,10 @@ class SphericalMesh(StructuredMesh): mesh_id = int(get_text(elem, 'id')) mesh = cls( mesh_id=mesh_id, - r_grid = get_elem_list(elem, "r_grid", float), - theta_grid = get_elem_list(elem, "theta_grid", float), - phi_grid = get_elem_list(elem, "phi_grid", float), - origin = get_elem_list(elem, "origin", float) or [0., 0., 0.], + r_grid = [float(x) for x in get_text(elem, "r_grid").split()], + theta_grid = [float(x) for x in get_text(elem, "theta_grid").split()], + phi_grid = [float(x) for x in get_text(elem, "phi_grid").split()], + origin = [float(x) for x in get_text(elem, "origin", default=[0., 0., 0.]).split()], ) return mesh @@ -2643,83 +2052,6 @@ class SphericalMesh(StructuredMesh): arr[..., 2] = z + origin[2] return arr - def get_indices_at_coords( - self, - coords: Sequence[float] - ) -> tuple[int, int, int]: - """Find the mesh cell indices containing the specified coordinates. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - coords : Sequence[float] - Cartesian coordinates of the point as (x, y, z). - - Returns - ------- - tuple[int, int, int] - The r, theta, phi indices. - - Raises - ------ - ValueError - If the coordinates fall outside the mesh grid boundaries. - - """ - dx = coords[0] - self.origin[0] - dy = coords[1] - self.origin[1] - dz = coords[2] - self.origin[2] - - r_value = math.hypot(dx, dy, dz) - - if r_value < self.r_grid[0] or r_value > self.r_grid[-1]: - raise ValueError( - f'The r value {r_value} computed from the specified ' - f'coordinates is outside the r grid range ' - f'[{self.r_grid[0]}, {self.r_grid[-1]}].' - ) - - r_index = int(min( - np.searchsorted(self.r_grid, r_value, side='right') - 1, - len(self.r_grid) - 2 - )) - - if r_value == 0.0: - theta_value = 0.0 - phi_value = 0.0 - else: - theta_value = math.acos(dz / r_value) - phi_value = math.atan2(dy, dx) - if phi_value < 0: - phi_value += 2 * math.pi - - if theta_value < self.theta_grid[0] or theta_value > self.theta_grid[-1]: - raise ValueError( - f'The theta value {theta_value} computed from the specified ' - f'coordinates is outside the theta grid range ' - f'[{self.theta_grid[0]}, {self.theta_grid[-1]}].' - ) - - theta_index = int(min( - np.searchsorted(self.theta_grid, theta_value, side='right') - 1, - len(self.theta_grid) - 2 - )) - - if phi_value < self.phi_grid[0] or phi_value > self.phi_grid[-1]: - raise ValueError( - f'The phi value {phi_value} computed from the specified ' - f'coordinates is outside the phi grid range ' - f'[{self.phi_grid[0]}, {self.phi_grid[-1]}].' - ) - - phi_index = int(min( - np.searchsorted(self.phi_grid, phi_value, side='right') - 1, - len(self.phi_grid) - 2 - )) - - return (r_index, theta_index, phi_index) - def require_statepoint_data(func): @wraps(func) @@ -2742,10 +2074,8 @@ class UnstructuredMesh(MeshBase): Parameters ---------- - filename : path-like - Location of the unstructured mesh file. Supported files for 'moab' - library are .h5 and .vtk. Supported files for 'libmesh' library are - exodus mesh files .exo. + filename : str or pathlib.Path + Location of the unstructured mesh file library : {'moab', 'libmesh'} Mesh library used for the unstructured mesh tally mesh_id : int @@ -2808,12 +2138,10 @@ class UnstructuredMesh(MeshBase): _UNSUPPORTED_ELEM = -1 _LINEAR_TET = 0 _LINEAR_HEX = 1 - _VTK_TET = 10 - _VTK_HEX = 12 - def __init__(self, filename: PathLike, library: str, mesh_id: int | None = None, + def __init__(self, filename: PathLike, library: str, mesh_id: Optional[int] = None, name: str = '', length_multiplier: float = 1.0, - options: str | None = None): + options: Optional[str] = None): super().__init__(mesh_id, name) self.filename = filename self._volumes = None @@ -2832,8 +2160,8 @@ class UnstructuredMesh(MeshBase): @filename.setter def filename(self, filename): - cv.check_type('Unstructured Mesh filename', filename, PathLike) - self._filename = input_path(filename) + cv.check_type('Unstructured Mesh filename', filename, (str, Path)) + self._filename = filename @property def library(self): @@ -2845,11 +2173,11 @@ class UnstructuredMesh(MeshBase): self._library = lib @property - def options(self) -> str | None: + def options(self) -> Optional[str]: return self._options @options.setter - def options(self, options: str | None): + def options(self, options: Optional[str]): cv.check_type('options', options, (str, type(None))) self._options = options @@ -2887,7 +2215,7 @@ class UnstructuredMesh(MeshBase): return self._volumes @volumes.setter - def volumes(self, volumes: Iterable[Real]): + def volumes(self, volumes: typing.Iterable[Real]): cv.check_type("Unstructured mesh volumes", volumes, Iterable, Real) self._volumes = volumes @@ -2948,10 +2276,6 @@ class UnstructuredMesh(MeshBase): def n_dimension(self): return 3 - @property - def _axis_labels(self): - return ('element_index',) - @property @require_statepoint_data def indices(self): @@ -3023,107 +2347,60 @@ class UnstructuredMesh(MeshBase): warnings.warn( "The 'UnstructuredMesh.write_vtk_mesh' method has been renamed " "to 'write_data_to_vtk' and will be removed in a future version " - " of OpenMC.", - FutureWarning, + " of OpenMC.", FutureWarning ) self.write_data_to_vtk(**kwargs) def write_data_to_vtk( - self, - filename: PathLike | None = None, - datasets: dict | None = None, - volume_normalization: bool = True, + self, + filename: Optional[PathLike] = None, + datasets: Optional[dict] = None, + volume_normalization: bool = True ): """Map data to unstructured VTK mesh elements. - If filename is None, then a filename will be generated based on the mesh - ID, and exported to VTK format. - Parameters ---------- filename : str or pathlib.Path - Name of the VTK file to write. If the filename ends in '.vtkhdf' - then a VTKHDF format file will be written. If the filename ends in - '.vtu' then a binary VTU format file will be written. If the - filename ends in '.vtk' then a legacy VTK file will be written. + Name of the VTK file to write datasets : dict - Dictionary whose keys are the data labels and values are numpy - appropriately sized arrays of the data + Dictionary whose keys are the data labels + and values are numpy appropriately sized arrays + of the data volume_normalization : bool - Whether or not to normalize the data by the volume of the mesh - elements + Whether or not to normalize the data by the + volume of the mesh elements """ - - if Path(filename).suffix == ".vtkhdf": - - self._write_data_to_vtk_hdf5_format( - filename=filename, - datasets=datasets, - volume_normalization=volume_normalization, - ) - - elif Path(filename).suffix == ".vtk" or Path(filename).suffix == ".vtu": - - self._write_data_to_vtk_ascii_format( - filename=filename, - datasets=datasets, - volume_normalization=volume_normalization, - ) - - else: - raise ValueError( - "Unsupported file extension, The filename must end with " - "'.vtkhdf', '.vtu' or '.vtk'" - ) - - def _write_data_to_vtk_ascii_format( - self, - filename: PathLike | None = None, - datasets: dict | None = None, - volume_normalization: bool = True, - ): - from vtkmodules.util import numpy_support - from vtkmodules import vtkCommonCore - from vtkmodules import vtkCommonDataModel - from vtkmodules import vtkIOLegacy - from vtkmodules import vtkIOXML + import vtk + from vtk.util import numpy_support as nps if self.connectivity is None or self.vertices is None: - raise RuntimeError("This mesh has not been loaded from a statepoint file.") + raise RuntimeError('This mesh has not been ' + 'loaded from a statepoint file.') if filename is None: - filename = f"mesh_{self.id}.vtk" + filename = f'mesh_{self.id}.vtk' - if Path(filename).suffix == ".vtk": - writer = vtkIOLegacy.vtkUnstructuredGridWriter() - - elif Path(filename).suffix == ".vtu": - writer = vtkIOXML.vtkXMLUnstructuredGridWriter() - writer.SetCompressorTypeToZLib() - writer.SetDataModeToBinary() + writer = vtk.vtkUnstructuredGridWriter() writer.SetFileName(str(filename)) - grid = vtkCommonDataModel.vtkUnstructuredGrid() + grid = vtk.vtkUnstructuredGrid() - points = vtkCommonCore.vtkPoints() - points.SetData(numpy_support.numpy_to_vtk(self.vertices)) - grid.SetPoints(points) + vtk_pnts = vtk.vtkPoints() + vtk_pnts.SetData(nps.numpy_to_vtk(self.vertices)) + grid.SetPoints(vtk_pnts) n_skipped = 0 for elem_type, conn in zip(self.element_types, self.connectivity): if elem_type == self._LINEAR_TET: - elem = vtkCommonDataModel.vtkTetra() + elem = vtk.vtkTetra() elif elem_type == self._LINEAR_HEX: - elem = vtkCommonDataModel.vtkHexahedron() + elem = vtk.vtkHexahedron() elif elem_type == self._UNSUPPORTED_ELEM: n_skipped += 1 - continue else: - raise RuntimeError( - f"Invalid element type {elem_type} found in mesh {self.id}" - ) - + raise RuntimeError(f'Invalid element type {elem_type} found') for i, c in enumerate(conn): if c == -1: break @@ -3132,36 +2409,30 @@ class UnstructuredMesh(MeshBase): grid.InsertNextCell(elem.GetCellType(), elem.GetPointIds()) if n_skipped > 0: - warnings.warn( - f"{n_skipped} elements were not written because " - "they are not of type linear tet/hex" - ) + warnings.warn(f'{n_skipped} elements were not written because ' + 'they are not of type linear tet/hex') # check that datasets are the correct size datasets_out = [] if datasets is not None: for name, data in datasets.items(): if data.shape != self.dimension: - raise ValueError( - f'Cannot apply dataset "{name}" with ' - f"shape {data.shape} to mesh {self.id} " - f"with dimensions {self.dimension}" - ) + raise ValueError(f'Cannot apply dataset "{name}" with ' + f'shape {data.shape} to mesh {self.id} ' + f'with dimensions {self.dimension}') if volume_normalization: for name, data in datasets.items(): if np.issubdtype(data.dtype, np.integer): - warnings.warn( - f'Integer data set "{name}" will ' - "not be volume-normalized." - ) + warnings.warn(f'Integer data set "{name}" will ' + 'not be volume-normalized.') continue data /= self.volumes # add data to the mesh for name, data in datasets.items(): datasets_out.append(data) - arr = vtkCommonCore.vtkDoubleArray() + arr = vtk.vtkDoubleArray() arr.SetName(name) arr.SetNumberOfTuples(data.size) @@ -3173,120 +2444,30 @@ class UnstructuredMesh(MeshBase): writer.Write() - def _write_data_to_vtk_hdf5_format( - self, - filename: PathLike | None = None, - datasets: dict | None = None, - volume_normalization: bool = True, - ): - # This writer supports linear tetrahedra and linear hexahedra elements - conn_list = [] # flattened connectivity ids - cell_sizes = [] # number of points per cell - vtk_types = [] # VTK cell types per cell (uint8) - n_skipped = 0 - - for conn, etype in zip(self.connectivity, self.element_types): - if etype == self._LINEAR_TET: - ids = conn[:4] - vtk_types.append(self._VTK_TET) - elif etype == self._LINEAR_HEX: - ids = conn[:8] - vtk_types.append(self._VTK_HEX) - elif etype == self._UNSUPPORTED_ELEM: - n_skipped += 1 - continue - else: - raise RuntimeError( - f"Invalid element type {etype} found in mesh {self.id}" - ) - conn_list.extend(ids.tolist()) - cell_sizes.append(len(ids)) - - if n_skipped > 0: - warnings.warn( - f"{n_skipped} elements were not written because " - "they are not of type linear tet/hex" - ) - - connectivity = np.asarray(conn_list, dtype=np.int64) - - # Offsets must be length (numCells + 1) with a leading 0 and - # cumulative end-indices thereafter, per VTK's layout - cell_sizes_arr = np.asarray(cell_sizes, dtype=np.int64) - offsets = np.zeros(cell_sizes_arr.size + 1, dtype=np.int64) - np.cumsum(cell_sizes_arr, out=offsets[1:]) - - for name, data in datasets.items(): - if data.shape != self.dimension: - raise ValueError( - f'Cannot apply dataset "{name}" with ' - f"shape {data.shape} to mesh {self.id} " - f"with dimensions {self.dimension}" - ) - - with h5py.File(filename, "w") as f: - - root = f.create_group("VTKHDF") - vtk_file_format_version = (2, 1) - root.attrs["Version"] = vtk_file_format_version - ascii_type = "UnstructuredGrid".encode("ascii") - root.attrs.create( - "Type", - ascii_type, - dtype=h5py.string_dtype("ascii", len(ascii_type)), - ) - - # Create HDF5 file structure compliant with VTKHDF UnstructuredGrid - n_points = int(len(self.vertices)) - n_cells = int(len(cell_sizes)) - n_conn_ids = int(len(connectivity)) - - root.create_dataset("NumberOfPoints", data=(n_points,), dtype="i8") - root.create_dataset("NumberOfCells", data=(n_cells,), dtype="i8") - root.create_dataset("NumberOfConnectivityIds", data=(n_conn_ids,), dtype="i8") - root.create_dataset("Points", data=self.vertices.astype(np.float64, copy=False), dtype="f8") - root.create_dataset("Types", data=np.asarray(vtk_types, dtype=np.uint8), dtype="uint8") - root.create_dataset("Offsets", data=offsets.astype("i8"), dtype="i8") - root.create_dataset("Connectivity", data=connectivity.astype("i8"), dtype="i8") - - cell_data_group = root.create_group("CellData") - - for name, data in datasets.items(): - if volume_normalization: - data /= self.volumes - cell_data_group.create_dataset( - name, data=data, dtype="float64", chunks=True - ) - @classmethod - def from_hdf5(cls, group: h5py.Group, mesh_id: int, name: str): - filename = group["filename"][()].decode() - library = group["library"][()].decode() - if "options" in group.attrs: + def from_hdf5(cls, group: h5py.Group): + mesh_id = int(group.name.split('/')[-1].lstrip('mesh ')) + filename = group['filename'][()].decode() + library = group['library'][()].decode() + if 'options' in group.attrs: options = group.attrs['options'].decode() else: options = None - mesh = cls( - filename=filename, - library=library, - mesh_id=mesh_id, - name=name, - options=options, - ) + mesh = cls(filename=filename, library=library, mesh_id=mesh_id, options=options) mesh._has_statepoint_data = True - vol_data = group["volumes"][()] + vol_data = group['volumes'][()] mesh.volumes = np.reshape(vol_data, (vol_data.shape[0],)) mesh.n_elements = mesh.volumes.size - vertices = group["vertices"][()] + vertices = group['vertices'][()] mesh._vertices = vertices.reshape((-1, 3)) - connectivity = group["connectivity"][()] + connectivity = group['connectivity'][()] mesh._connectivity = connectivity.reshape((-1, 8)) - mesh._element_types = group["element_types"][()] + mesh._element_types = group['element_types'][()] - if "length_multiplier" in group: - mesh.length_multiplier = group["length_multiplier"][()] + if 'length_multiplier' in group: + mesh.length_multiplier = group['length_multiplier'][()] return mesh @@ -3300,12 +2481,12 @@ class UnstructuredMesh(MeshBase): """ - element = super().to_xml_element() + element = ET.Element("mesh") + element.set("id", str(self._id)) element.set("type", "unstructured") - element.set("library", self._library) if self.options is not None: - element.set("options", self.options) + element.set('options', self.options) subelement = ET.SubElement(element, "filename") subelement.text = str(self.filename) @@ -3332,7 +2513,7 @@ class UnstructuredMesh(MeshBase): filename = get_text(elem, 'filename') library = get_text(elem, 'library') length_multiplier = float(get_text(elem, 'length_multiplier', 1.0)) - options = get_text(elem, "options") + options = elem.get('options') return cls(filename, library, mesh_id, '', length_multiplier, options) diff --git a/openmc/mgxs/__init__.py b/openmc/mgxs/__init__.py index 5adbac9c4..4f12a8fb4 100644 --- a/openmc/mgxs/__init__.py +++ b/openmc/mgxs/__init__.py @@ -1,6 +1,6 @@ import numpy as np -from openmc.mgxs.groups import EnergyGroups, convert_flux_groups +from openmc.mgxs.groups import EnergyGroups from openmc.mgxs.library import Library from openmc.mgxs.mgxs import * from openmc.mgxs.mdgxs import * @@ -13,32 +13,27 @@ GROUP_STRUCTURES = {} - "XMAS-172_" designed for LWR analysis ([SAR1990]_, [SAN2004]_) - "SHEM-361_" designed for LWR analysis to eliminate self-shielding calculations of thermal resonances ([HFA2005]_, [SAN2007]_, [HEB2008]_) -- "SCALE-X" (where X is 44 which is designed for criticality analysis, 252 is designed - for thermal reactors and 999 for multipurpose activation) for the SCALE code suite +- "SCALE-X" (where X is 44 which is designed for criticality analysis + and 252 is designed for thermal reactors) for the SCALE code suite ([ZAL1999]_ and [REARDEN2013]_) - "MPACT-X" (where X is 51 (PWR), 60 (BWR), 69 (Magnox)) from the MPACT_ reactor physics code ([KIM2019]_ and [KIM2020]_) -- "ECCO-33" intended for fast reactor criticality benchmarks. It’s derived as a - subset of VITAMIN‑J - "ECCO-1968_" designed for fine group reactor cell calculations for fast, intermediate and thermal reactor applications ([SAR1990]_) - activation_ energy group structures "VITAMIN-J-42", "VITAMIN-J-175", - "TRIPOLI-315", "LLNL-616", "CCFE-709_" and "UKAEA-1102_" + "TRIPOLI-315", "CCFE-709_" and "UKAEA-1102_" -.. _CASMO: http://large.stanford.edu/courses/2013/ph241/dalvi1/docs/c5.physor2006.pdf +.. _CASMO: https://www.studsvik.com/SharepointFiles/CASMO-5%20Development%20and%20Applications.pdf .. _SCALE44: https://www-nds.iaea.org/publications/indc/indc-czr-0001.pdf -.. _ECCO-33: https://serpent.vtt.fi/mediawiki/index.php/ECCO_33-group_structure .. _SCALE252: https://oecd-nea.org/science/wpncs/amct/workingarea/meeting2013/EGAMCT2013_08.pdf -.. _SCALE999: https://info.ornl.gov/sites/publications/Files/Pub67728.pdf, https://www.nrc.gov/docs/ML1218/ML12184A002.pdf .. _MPACT: https://vera.ornl.gov/mpact/ .. _XMAS-172: https://www-nds.iaea.org/wimsd/energy.htm -.. _SHEM-361: http://merlin.polymtl.ca/downloads/FP214.pdf +.. _SHEM-361: https://www.polymtl.ca/merlin/downloads/FP214.pdf .. _activation: https://fispact.ukaea.uk/wiki/Keyword:GETXS .. _VITAMIN-J-42: https://www.oecd-nea.org/dbdata/nds_jefreports/jefreport-10.pdf -.. _LLNL-616: https://fispact.ukaea.uk/manual/user_manual.pdf .. _CCFE-709: https://fispact.ukaea.uk/wiki/CCFE-709_group_structure .. _UKAEA-1102: https://fispact.ukaea.uk/wiki/UKAEA-1102_group_structure -.. _ECCO-1968: https://serpent.vtt.fi/mediawiki/index.php/ECCO_1968-group_structure +.. _ECCO-1968: http://serpent.vtt.fi/mediawiki/index.php/ECCO_1968-group_structure .. [SAR1990] Sartori, E., OECD/NEA Data Bank: Standard Energy Group Structures of Cross Section Libraries for Reactor Shielding, Reactor Cell and Fusion Neutronics Applications: VITAMIN-J, ECCO-33, ECCO-2000 and XMAS JEF/DOC-315 @@ -85,16 +80,6 @@ GROUP_STRUCTURES['CASMO-25'] = np.array([ 0., 3.e-2, 5.8e-2, 1.4e-1, 2.8e-1, 3.5e-1, 6.25e-1, 9.72e-1, 1.02, 1.097, 1.15, 1.855, 4., 9.877, 1.5968e1, 1.4873e2, 5.53e3, 9.118e3, 1.11e5, 5.e5, 8.21e5, 1.353e6, 2.231e6, 3.679e6, 6.0655e6, 2.e7]) -GROUP_STRUCTURES['ECCO-33'] = np.array([ - 1.0000100000E-05, 1.0000000000E-01, 5.4000000000E-01, 4.0000000000E+00, - 8.3152870000E+00, 1.3709590000E+01, 2.2603290000E+01, 4.0169000000E+01, - 6.7904050000E+01, 9.1660880000E+01, 1.4862540000E+02, 3.0432480000E+02, - 4.5399930000E+02, 7.4851830000E+02, 1.2340980000E+03, 2.0346840000E+03, - 3.3546260000E+03, 5.5308440000E+03, 9.1188200000E+03, 1.5034390000E+04, - 2.4787520000E+04, 4.0867710000E+04, 6.7379470000E+04, 1.1109000000E+05, - 1.8315640000E+05, 3.0197380000E+05, 4.9787070000E+05, 8.2085000000E+05, - 1.3533530000E+06, 2.2313020000E+06, 3.6787940000E+06, 6.0653070000E+06, - 1.0000000000E+07, 1.9640330000E+07]) GROUP_STRUCTURES['CASMO-40'] = np.array([ 0., 1.5e-2, 3.e-2, 4.2e-2, 5.8e-2, 8.e-2, 1.e-1, 1.4e-1, 1.8e-1, 2.2e-1, 2.8e-1, 3.5e-1, 6.25e-1, 8.5e-1, 9.5e-1, @@ -361,97 +346,6 @@ GROUP_STRUCTURES['SHEM-361'] = np.array([ 4.06569e+06, 4.96585e+06, 6.06530e+06, 6.70319e+06, 7.40817e+06, 8.18730e+06, 9.04836e+06, 9.99999e+06, 1.16183e+07, 1.38403e+07, 1.49182e+07, 1.96403e+07]) -GROUP_STRUCTURES['LLNL-616'] = np.array([ - 1.0000e-5, 1.0471e-5, 1.0965e-5, 1.1482e-5, 1.2023e-5, 1.2589e-5, 1.3183e-5, - 1.3804e-5, 1.4454e-5, 1.5136e-5, 1.5849e-5, 1.6596e-5, 1.7378e-5, 1.8197e-5, - 1.9055e-5, 1.9953e-5, 2.0893e-5, 2.1878e-5, 2.2909e-5, 2.3988e-5, 2.5119e-5, - 2.6303e-5, 2.7542e-5, 2.8840e-5, 3.0200e-5, 3.1623e-5, 3.3113e-5, 3.4674e-5, - 3.6308e-5, 3.8019e-5, 3.9811e-5, 4.1687e-5, 4.3652e-5, 4.5709e-5, 4.7863e-5, - 5.0119e-5, 5.2481e-5, 5.4954e-5, 5.7544e-5, 6.0256e-5, 6.3096e-5, 6.6069e-5, - 6.9183e-5, 7.2444e-5, 7.5858e-5, 7.9433e-5, 8.3176e-5, 8.7096e-5, 9.1201e-5, - 9.5499e-5, 1.0000e-4, 1.0471e-4, 1.0965e-4, 1.1482e-4, 1.2023e-4, 1.2589e-4, - 1.3183e-4, 1.3804e-4, 1.4454e-4, 1.5136e-4, 1.5849e-4, 1.6596e-4, 1.7378e-4, - 1.8197e-4, 1.9055e-4, 1.9953e-4, 2.0893e-4, 2.1878e-4, 2.2909e-4, 2.3988e-4, - 2.5119e-4, 2.6303e-4, 2.7542e-4, 2.8840e-4, 3.0200e-4, 3.1623e-4, 3.3113e-4, - 3.4674e-4, 3.6308e-4, 3.8019e-4, 3.9811e-4, 4.1687e-4, 4.3652e-4, 4.5709e-4, - 4.7863e-4, 5.0119e-4, 5.2481e-4, 5.4954e-4, 5.7544e-4, 6.0256e-4, 6.3096e-4, - 6.6069e-4, 6.9183e-4, 7.2444e-4, 7.5858e-4, 7.9433e-4, 8.3176e-4, 8.7096e-4, - 9.1201e-4, 9.5499e-4, 1.0000e-3, 1.0471e-3, 1.0965e-3, 1.1482e-3, 1.2023e-3, - 1.2589e-3, 1.3183e-3, 1.3804e-3, 1.4454e-3, 1.5136e-3, 1.5849e-3, 1.6596e-3, - 1.7378e-3, 1.8197e-3, 1.9055e-3, 1.9953e-3, 2.0893e-3, 2.1878e-3, 2.2909e-3, - 2.3988e-3, 2.5119e-3, 2.6303e-3, 2.7542e-3, 2.8840e-3, 3.0200e-3, 3.1623e-3, - 3.3113e-3, 3.4674e-3, 3.6308e-3, 3.8019e-3, 3.9811e-3, 4.1687e-3, 4.3652e-3, - 4.5709e-3, 4.7863e-3, 5.0119e-3, 5.2481e-3, 5.4954e-3, 5.7544e-3, 6.0256e-3, - 6.3096e-3, 6.6069e-3, 6.9183e-3, 7.2444e-3, 7.5858e-3, 7.9433e-3, 8.3176e-3, - 8.7096e-3, 9.1201e-3, 9.5499e-3, 1.0000e-2, 1.0471e-2, 1.0965e-2, 1.1482e-2, - 1.2023e-2, 1.2589e-2, 1.3183e-2, 1.3804e-2, 1.4454e-2, 1.5136e-2, 1.5849e-2, - 1.6596e-2, 1.7378e-2, 1.8197e-2, 1.9055e-2, 1.9953e-2, 2.0893e-2, 2.1878e-2, - 2.2909e-2, 2.3988e-2, 2.5119e-2, 2.6303e-2, 2.7542e-2, 2.8840e-2, 3.0200e-2, - 3.1623e-2, 3.3113e-2, 3.4674e-2, 3.6308e-2, 3.8019e-2, 3.9811e-2, 4.1687e-2, - 4.3652e-2, 4.5709e-2, 4.7863e-2, 5.0119e-2, 5.2481e-2, 5.4954e-2, 5.7544e-2, - 6.0256e-2, 6.3096e-2, 6.6069e-2, 6.9183e-2, 7.2444e-2, 7.5858e-2, 7.9433e-2, - 8.3176e-2, 8.7096e-2, 9.1201e-2, 9.5499e-2, 1.0000e-1, 1.0471e-1, 1.0965e-1, - 1.1482e-1, 1.2023e-1, 1.2589e-1, 1.3183e-1, 1.3804e-1, 1.4454e-1, 1.5136e-1, - 1.5849e-1, 1.6596e-1, 1.7378e-1, 1.8197e-1, 1.9055e-1, 1.9953e-1, 2.0893e-1, - 2.1878e-1, 2.2909e-1, 2.3988e-1, 2.5119e-1, 2.6303e-1, 2.7542e-1, 2.8840e-1, - 3.0200e-1, 3.1623e-1, 3.3113e-1, 3.4674e-1, 3.6308e-1, 3.8019e-1, 3.9811e-1, - 4.1687e-1, 4.3652e-1, 4.5709e-1, 4.7863e-1, 5.0119e-1, 5.2481e-1, 5.4954e-1, - 5.7544e-1, 6.0256e-1, 6.3096e-1, 6.6069e-1, 6.9183e-1, 7.2444e-1, 7.5858e-1, - 7.9433e-1, 8.3176e-1, 8.7096e-1, 9.1201e-1, 9.5499e-1, 1.0000e0, 1.0471e0, - 1.0965e0, 1.1482e0, 1.2023e0, 1.2589e0, 1.3183e0, 1.3804e0, 1.4454e0, - 1.5136e0, 1.5849e0, 1.6596e0, 1.7378e0, 1.8197e0, 1.9055e0, 1.9953e0, - 2.0893e0, 2.1878e0, 2.2909e0, 2.3988e0, 2.5119e0, 2.6303e0, 2.7542e0, - 2.8840e0, 3.0200e0, 3.1623e0, 3.3113e0, 3.4674e0, 3.6308e0, 3.8019e0, - 3.9811e0, 4.1687e0, 4.3652e0, 4.5709e0, 4.7863e0, 5.0119e0, 5.2481e0, - 5.4954e0, 5.7544e0, 6.0256e0, 6.3096e0, 6.6069e0, 6.9183e0, 7.2444e0, - 7.5858e0, 7.9433e0, 8.3176e0, 8.7096e0, 9.1201e0, 9.5499e0, 1.0000e1, - 1.0471e1, 1.0965e1, 1.1482e1, 1.2023e1, 1.2589e1, 1.3183e1, 1.3804e1, - 1.4454e1, 1.5136e1, 1.5849e1, 1.6596e1, 1.7378e1, 1.8197e1, 1.9055e1, - 1.9953e1, 2.0893e1, 2.1878e1, 2.2909e1, 2.3988e1, 2.5119e1, 2.6303e1, - 2.7542e1, 2.8840e1, 3.0200e1, 3.1623e1, 3.3113e1, 3.4674e1, 3.6308e1, - 3.8019e1, 3.9811e1, 4.1687e1, 4.3652e1, 4.5709e1, 4.7863e1, 5.0119e1, - 5.2481e1, 5.4954e1, 5.7544e1, 6.0256e1, 6.3096e1, 6.6069e1, 6.9183e1, - 7.2444e1, 7.5858e1, 7.9433e1, 8.3176e1, 8.7096e1, 9.1201e1, 9.5499e1, - 1.0000e2, 1.0471e2, 1.0965e2, 1.1482e2, 1.2023e2, 1.2589e2, 1.3183e2, - 1.3804e2, 1.4454e2, 1.5136e2, 1.5849e2, 1.6596e2, 1.7378e2, 1.8197e2, - 1.9055e2, 1.9953e2, 2.0893e2, 2.1878e2, 2.2909e2, 2.3988e2, 2.5119e2, - 2.6303e2, 2.7542e2, 2.8840e2, 3.0200e2, 3.1623e2, 3.3113e2, 3.4674e2, - 3.6308e2, 3.8019e2, 3.9811e2, 4.1687e2, 4.3652e2, 4.5709e2, 4.7863e2, - 5.0119e2, 5.2481e2, 5.4954e2, 5.7544e2, 6.0256e2, 6.3096e2, 6.6069e2, - 6.9183e2, 7.2444e2, 7.5858e2, 7.9433e2, 8.3176e2, 8.7096e2, 9.1201e2, - 9.5499e2, 1.0000e3, 1.0471e3, 1.0965e3, 1.1482e3, 1.2023e3, 1.2589e3, - 1.3183e3, 1.3804e3, 1.4454e3, 1.5136e3, 1.5849e3, 1.6596e3, 1.7378e3, - 1.8197e3, 1.9055e3, 1.9953e3, 2.0893e3, 2.1878e3, 2.2909e3, 2.3988e3, - 2.5119e3, 2.6303e3, 2.7542e3, 2.8840e3, 3.0200e3, 3.1623e3, 3.3113e3, - 3.4674e3, 3.6308e3, 3.8019e3, 3.9811e3, 4.1687e3, 4.3652e3, 4.5709e3, - 4.7863e3, 5.0119e3, 5.2481e3, 5.4954e3, 5.7544e3, 6.0256e3, 6.3096e3, - 6.6069e3, 6.9183e3, 7.2444e3, 7.5858e3, 7.9433e3, 8.3176e3, 8.7096e3, - 9.1201e3, 9.5499e3, 1.0000e4, 1.0471e4, 1.0965e4, 1.1482e4, 1.2023e4, - 1.2589e4, 1.3183e4, 1.3804e4, 1.4454e4, 1.5136e4, 1.5849e4, 1.6596e4, - 1.7378e4, 1.8197e4, 1.9055e4, 1.9953e4, 2.0893e4, 2.1878e4, 2.2909e4, - 2.3988e4, 2.5119e4, 2.6303e4, 2.7542e4, 2.8840e4, 3.0200e4, 3.1623e4, - 3.3113e4, 3.4674e4, 3.6308e4, 3.8019e4, 3.9811e4, 4.1687e4, 4.3652e4, - 4.5709e4, 4.7863e4, 5.0119e4, 5.2481e4, 5.4954e4, 5.7544e4, 6.0256e4, - 6.3096e4, 6.6069e4, 6.9183e4, 7.2444e4, 7.5858e4, 7.9433e4, 8.3176e4, - 8.7096e4, 9.1201e4, 9.5499e4, 1.0000e5, 1.0471e5, 1.0965e5, 1.1482e5, - 1.2023e5, 1.2589e5, 1.3183e5, 1.3804e5, 1.4454e5, 1.5136e5, 1.5849e5, - 1.6596e5, 1.7378e5, 1.8197e5, 1.9055e5, 1.9953e5, 2.0893e5, 2.1878e5, - 2.2909e5, 2.3988e5, 2.5119e5, 2.6303e5, 2.7542e5, 2.8840e5, 3.0200e5, - 3.1623e5, 3.3113e5, 3.4674e5, 3.6308e5, 3.8019e5, 3.9811e5, 4.1687e5, - 4.3652e5, 4.5709e5, 4.7863e5, 5.0119e5, 5.2481e5, 5.4954e5, 5.7544e5, - 6.0256e5, 6.3096e5, 6.6069e5, 6.9183e5, 7.2444e5, 7.5858e5, 7.9433e5, - 8.3176e5, 8.7096e5, 9.1201e5, 9.5499e5, 1.0000e6, 1.0471e6, 1.0965e6, - 1.1482e6, 1.2023e6, 1.2589e6, 1.3183e6, 1.3804e6, 1.4454e6, 1.5136e6, - 1.5849e6, 1.6596e6, 1.7378e6, 1.8197e6, 1.9055e6, 1.9953e6, 2.0893e6, - 2.1878e6, 2.2909e6, 2.3988e6, 2.5119e6, 2.6303e6, 2.7542e6, 2.8840e6, - 3.0200e6, 3.1623e6, 3.3113e6, 3.4674e6, 3.6308e6, 3.8019e6, 3.9811e6, - 4.1687e6, 4.3652e6, 4.5709e6, 4.7863e6, 5.0119e6, 5.2481e6, 5.4954e6, - 5.7544e6, 6.0256e6, 6.3096e6, 6.6069e6, 6.9183e6, 7.2444e6, 7.5858e6, - 7.9433e6, 8.3176e6, 8.7096e6, 9.1201e6, 9.5499e6, 1.0000e7, 1.0471e7, - 1.0965e7, 1.1482e7, 1.2023e7, 1.2589e7, 1.3183e7, 1.3804e7, 1.4454e7, - 1.5136e7, 1.5849e7, 1.6596e7, 1.7378e7, 1.8197e7, 1.9055e7, 1.9953e7, - 2.0000e7 -]) GROUP_STRUCTURES['CCFE-709'] = np.array([ 1.e-5, 1.0471e-5, 1.0965e-5, 1.1482e-5, 1.2023e-5, 1.2589e-5, 1.3183e-5, 1.3804e-5, 1.4454e-5, 1.5136e-5, @@ -594,208 +488,7 @@ GROUP_STRUCTURES['CCFE-709'] = np.array([ 2.4000e8, 2.8000e8, 3.2000e8, 3.6000e8, 4.0000e8, 4.4000e8, 4.8000e8, 5.2000e8, 5.6000e8, 6.0000e8, 6.4000e8, 6.8000e8, 7.2000e8, 7.6000e8, 8.0000e8, - 8.4000e8, 8.8000e8, 9.2000e8, 9.6000e8, 1.0000e9]) -GROUP_STRUCTURES['SCALE-999'] = np.array([ - 1.000e-5, 1.000e-4, 5.000e-4, 7.500e-4, 1.000e-3, - 1.200e-3, 1.500e-3, 2.000e-3, 2.500e-3, 3.000e-3, - 4.000e-3, 5.000e-3, 7.500e-3, 1.000e-2, 1.450e-2, - 1.850e-2, 2.100e-2, 2.530e-2, 3.000e-2, 4.000e-2, - 5.000e-2, 6.000e-2, 7.000e-2, 8.000e-2, 9.000e-2, - 1.000e-1, 1.250e-1, 1.500e-1, 1.750e-1, 1.840e-1, - 2.000e-1, 2.250e-1, 2.500e-1, 2.750e-1, 3.000e-1, - 3.250e-1, 3.500e-1, 3.668e-1, 3.750e-1, 4.000e-1, - 4.140e-1, 4.500e-1, 5.000e-1, 5.316e-1, 5.500e-1, - 6.000e-1, 6.250e-1, 6.500e-1, 6.826e-1, 7.000e-1, - 7.500e-1, 8.000e-1, 8.500e-1, 8.764e-1, 9.000e-1, - 9.250e-1, 9.500e-1, 9.750e-1, 1.000e+0, 1.010e+0, - 1.020e+0, 1.030e+0, 1.040e+0, 1.050e+0, 1.060e+0, - 1.070e+0, 1.080e+0, 1.090e+0, 1.100e+0, 1.110e+0, - 1.120e+0, 1.130e+0, 1.140e+0, 1.150e+0, 1.175e+0, - 1.200e+0, 1.225e+0, 1.250e+0, 1.300e+0, 1.350e+0, - 1.400e+0, 1.450e+0, 1.500e+0, 1.545e+0, 1.590e+0, - 1.635e+0, 1.680e+0, 1.725e+0, 1.770e+0, 1.815e+0, - 1.860e+0, 1.900e+0, 1.940e+0, 1.970e+0, 2.000e+0, - 2.060e+0, 2.120e+0, 2.165e+0, 2.210e+0, 2.255e+0, - 2.300e+0, 2.340e+0, 2.380e+0, 2.425e+0, 2.470e+0, - 2.520e+0, 2.570e+0, 2.620e+0, 2.670e+0, 2.720e+0, - 2.770e+0, 2.820e+0, 2.870e+0, 2.920e+0, 2.970e+0, - 3.000e+0, 3.100e+0, 3.200e+0, 3.300e+0, 3.500e+0, - 3.620e+0, 3.730e+0, 3.830e+0, 3.928e+0, 4.000e+0, - 4.100e+0, 4.300e+0, 4.500e+0, 4.750e+0, 4.875e+0, - 5.000e+0, 5.044e+0, 5.250e+0, 5.400e+0, 5.550e+0, - 5.700e+0, 5.850e+0, 6.000e+0, 6.250e+0, 6.375e+0, - 6.500e+0, 6.625e+0, 6.750e+0, 6.875e+0, 7.000e+0, - 7.075e+0, 7.150e+0, 7.625e+0, 8.100e+0, 8.208e+0, - 8.315e+0, 8.708e+0, 9.100e+0, 9.550e+0, 1.000e+1, - 1.034e+1, 1.068e+1, 1.109e+1, 1.150e+1, 1.170e+1, - 1.190e+1, 1.240e+1, 1.290e+1, 1.333e+1, 1.375e+1, - 1.408e+1, 1.440e+1, 1.475e+1, 1.510e+1, 1.555e+1, - 1.600e+1, 1.650e+1, 1.700e+1, 1.730e+1, 1.760e+1, - 1.805e+1, 1.850e+1, 1.875e+1, 1.900e+1, 1.940e+1, - 2.000e+1, 2.050e+1, 2.100e+1, 2.175e+1, 2.250e+1, - 2.375e+1, 2.500e+1, 2.625e+1, 2.750e+1, 2.826e+1, - 2.902e+1, 2.951e+1, 3.000e+1, 3.063e+1, 3.125e+1, - 3.150e+1, 3.175e+1, 3.250e+1, 3.325e+1, 3.350e+1, - 3.375e+1, 3.418e+1, 3.460e+1, 3.500e+1, 3.550e+1, - 3.600e+1, 3.700e+1, 3.713e+1, 3.727e+1, 3.763e+1, - 3.800e+1, 3.855e+1, 3.910e+1, 3.935e+1, 3.960e+1, - 4.030e+1, 4.100e+1, 4.170e+1, 4.240e+1, 4.320e+1, - 4.400e+1, 4.460e+1, 4.520e+1, 4.610e+1, 4.700e+1, - 4.743e+1, 4.785e+1, 4.808e+1, 4.830e+1, 4.875e+1, - 4.920e+1, 4.990e+1, 5.060e+1, 5.130e+1, 5.200e+1, - 5.270e+1, 5.340e+1, 5.620e+1, 5.800e+1, 6.000e+1, - 6.100e+1, 6.122e+1, 6.144e+1, 6.300e+1, 6.500e+1, - 6.625e+1, 6.750e+1, 6.975e+1, 7.200e+1, 7.400e+1, - 7.600e+1, 7.745e+1, 7.889e+1, 7.945e+1, 8.000e+1, - 8.170e+1, 8.200e+1, 8.400e+1, 8.600e+1, 8.800e+1, - 9.000e+1, 9.250e+1, 9.500e+1, 9.700e+1, 1.000e+2, - 1.012e+2, 1.038e+2, 1.050e+2, 1.080e+2, 1.105e+2, - 1.130e+2, 1.160e+2, 1.175e+2, 1.190e+2, 1.205e+2, - 1.220e+2, 1.240e+2, 1.260e+2, 1.280e+2, 1.301e+2, - 1.325e+2, 1.350e+2, 1.375e+2, 1.400e+2, 1.430e+2, - 1.450e+2, 1.475e+2, 1.500e+2, 1.525e+2, 1.550e+2, - 1.575e+2, 1.600e+2, 1.625e+2, 1.650e+2, 1.670e+2, - 1.700e+2, 1.716e+2, 1.739e+2, 1.763e+2, 1.786e+2, - 1.800e+2, 1.877e+2, 1.885e+2, 1.915e+2, 1.930e+2, - 1.962e+2, 1.999e+2, 2.020e+2, 2.074e+2, 2.088e+2, - 2.095e+2, 2.122e+2, 2.145e+2, 2.175e+2, 2.200e+2, - 2.237e+2, 2.269e+2, 2.301e+2, 2.333e+2, 2.367e+2, - 2.400e+2, 2.442e+2, 2.484e+2, 2.527e+2, 2.571e+2, - 2.615e+2, 2.661e+2, 2.707e+2, 2.754e+2, 2.801e+2, - 2.850e+2, 2.899e+2, 2.948e+2, 2.999e+2, 3.050e+2, - 3.107e+2, 3.165e+2, 3.224e+2, 3.284e+2, 3.345e+2, - 3.408e+2, 3.471e+2, 3.536e+2, 3.591e+2, 3.648e+2, - 3.705e+2, 3.764e+2, 3.823e+2, 3.883e+2, 3.944e+2, - 4.007e+2, 4.070e+2, 4.134e+2, 4.199e+2, 4.265e+2, - 4.332e+2, 4.400e+2, 4.470e+2, 4.540e+2, 4.595e+2, - 4.650e+2, 4.706e+2, 4.763e+2, 4.821e+2, 4.879e+2, - 4.937e+2, 4.997e+2, 5.057e+2, 5.118e+2, 5.180e+2, - 5.243e+2, 5.306e+2, 5.370e+2, 5.435e+2, 5.500e+2, - 5.581e+2, 5.662e+2, 5.745e+2, 5.830e+2, 5.932e+2, - 6.036e+2, 6.142e+2, 6.250e+2, 6.359e+2, 6.471e+2, - 6.585e+2, 6.700e+2, 6.765e+2, 6.830e+2, 6.909e+2, - 6.988e+2, 7.069e+2, 7.150e+2, 7.232e+2, 7.316e+2, - 7.400e+2, 7.485e+2, 7.598e+2, 7.712e+2, 7.827e+2, - 7.945e+2, 8.064e+2, 8.185e+2, 8.308e+2, 8.433e+2, - 8.559e+2, 8.688e+2, 8.818e+2, 8.950e+2, 9.085e+2, - 9.221e+2, 9.360e+2, 9.500e+2, 9.555e+2, 9.611e+2, - 9.720e+2, 9.829e+2, 9.940e+2, 1.005e+3, 1.017e+3, - 1.028e+3, 1.040e+3, 1.051e+3, 1.063e+3, 1.075e+3, - 1.087e+3, 1.100e+3, 1.112e+3, 1.125e+3, 1.137e+3, - 1.150e+3, 1.171e+3, 1.191e+3, 1.213e+3, 1.234e+3, - 1.249e+3, 1.265e+3, 1.280e+3, 1.296e+3, 1.312e+3, - 1.328e+3, 1.344e+3, 1.361e+3, 1.377e+3, 1.394e+3, - 1.411e+3, 1.429e+3, 1.446e+3, 1.464e+3, 1.482e+3, - 1.500e+3, 1.525e+3, 1.550e+3, 1.585e+3, 1.610e+3, - 1.636e+3, 1.662e+3, 1.689e+3, 1.716e+3, 1.744e+3, - 1.772e+3, 1.800e+3, 1.828e+3, 1.856e+3, 1.885e+3, - 1.914e+3, 1.943e+3, 1.973e+3, 2.004e+3, 2.035e+3, - 2.075e+3, 2.116e+3, 2.158e+3, 2.200e+3, 2.250e+3, - 2.290e+3, 2.337e+3, 2.386e+3, 2.435e+3, 2.500e+3, - 2.532e+3, 2.580e+3, 2.613e+3, 2.679e+3, 2.747e+3, - 2.808e+3, 2.871e+3, 2.935e+3, 3.000e+3, 3.035e+3, - 3.112e+3, 3.191e+3, 3.272e+3, 3.355e+3, 3.440e+3, - 3.527e+3, 3.616e+3, 3.707e+3, 3.740e+3, 3.819e+3, - 3.900e+3, 3.998e+3, 4.099e+3, 4.202e+3, 4.307e+3, - 4.400e+3, 4.500e+3, 4.620e+3, 4.740e+3, 4.850e+3, - 4.960e+3, 5.100e+3, 5.250e+3, 5.400e+3, 5.531e+3, - 5.645e+3, 5.700e+3, 5.879e+3, 6.000e+3, 6.128e+3, - 6.258e+3, 6.392e+3, 6.528e+3, 6.667e+3, 6.809e+3, - 6.954e+3, 7.102e+3, 7.212e+3, 7.323e+3, 7.437e+3, - 7.552e+3, 7.669e+3, 7.787e+3, 7.908e+3, 8.030e+3, - 8.159e+3, 8.289e+3, 8.422e+3, 8.557e+3, 8.694e+3, - 8.834e+3, 8.975e+3, 9.119e+3, 9.307e+3, 9.500e+3, - 9.763e+3, 1.003e+4, 1.031e+4, 1.060e+4, 1.086e+4, - 1.114e+4, 1.142e+4, 1.171e+4, 1.202e+4, 1.234e+4, - 1.266e+4, 1.300e+4, 1.324e+4, 1.348e+4, 1.373e+4, - 1.398e+4, 1.424e+4, 1.450e+4, 1.476e+4, 1.503e+4, - 1.527e+4, 1.550e+4, 1.574e+4, 1.599e+4, 1.623e+4, - 1.649e+4, 1.674e+4, 1.700e+4, 1.727e+4, 1.755e+4, - 1.783e+4, 1.812e+4, 1.841e+4, 1.870e+4, 1.900e+4, - 1.931e+4, 1.965e+4, 2.000e+4, 2.045e+4, 2.092e+4, - 2.139e+4, 2.188e+4, 2.229e+4, 2.271e+4, 2.314e+4, - 2.358e+4, 2.388e+4, 2.418e+4, 2.450e+4, 2.479e+4, - 2.500e+4, 2.520e+4, 2.552e+4, 2.580e+4, 2.606e+4, - 2.653e+4, 2.700e+4, 2.737e+4, 2.774e+4, 2.812e+4, - 2.850e+4, 2.887e+4, 2.924e+4, 2.962e+4, 3.000e+4, - 3.045e+4, 3.090e+4, 3.136e+4, 3.183e+4, 3.243e+4, - 3.304e+4, 3.367e+4, 3.431e+4, 3.468e+4, 3.507e+4, - 3.545e+4, 3.584e+4, 3.624e+4, 3.663e+4, 3.704e+4, - 3.744e+4, 3.786e+4, 3.827e+4, 3.869e+4, 3.912e+4, - 3.955e+4, 3.998e+4, 4.042e+4, 4.087e+4, 4.136e+4, - 4.186e+4, 4.237e+4, 4.288e+4, 4.340e+4, 4.393e+4, - 4.446e+4, 4.500e+4, 4.565e+4, 4.631e+4, 4.721e+4, - 4.812e+4, 4.905e+4, 5.000e+4, 5.099e+4, 5.200e+4, - 5.248e+4, 5.347e+4, 5.448e+4, 5.551e+4, 5.656e+4, - 5.740e+4, 5.826e+4, 5.912e+4, 6.000e+4, 6.088e+4, - 6.177e+4, 6.267e+4, 6.358e+4, 6.451e+4, 6.545e+4, - 6.641e+4, 6.738e+4, 6.851e+4, 6.965e+4, 7.081e+4, - 7.200e+4, 7.300e+4, 7.399e+4, 7.500e+4, 7.610e+4, - 7.722e+4, 7.835e+4, 7.950e+4, 8.074e+4, 8.200e+4, - 8.250e+4, 8.374e+4, 8.500e+4, 8.652e+4, 8.788e+4, - 8.926e+4, 9.067e+4, 9.210e+4, 9.355e+4, 9.502e+4, - 9.652e+4, 9.804e+4, 1.000e+5, 1.013e+5, 1.027e+5, - 1.040e+5, 1.054e+5, 1.068e+5, 1.082e+5, 1.096e+5, - 1.111e+5, 1.125e+5, 1.139e+5, 1.153e+5, 1.168e+5, - 1.183e+5, 1.197e+5, 1.213e+5, 1.228e+5, 1.241e+5, - 1.255e+5, 1.269e+5, 1.283e+5, 1.291e+5, 1.307e+5, - 1.323e+5, 1.340e+5, 1.357e+5, 1.374e+5, 1.391e+5, - 1.409e+5, 1.426e+5, 1.445e+5, 1.463e+5, 1.481e+5, - 1.490e+5, 1.519e+5, 1.538e+5, 1.557e+5, 1.576e+5, - 1.596e+5, 1.616e+5, 1.637e+5, 1.657e+5, 1.678e+5, - 1.699e+5, 1.721e+5, 1.742e+5, 1.764e+5, 1.786e+5, - 1.809e+5, 1.832e+5, 1.855e+5, 1.878e+5, 1.902e+5, - 1.926e+5, 1.962e+5, 2.000e+5, 2.024e+5, 2.050e+5, - 2.076e+5, 2.102e+5, 2.128e+5, 2.155e+5, 2.182e+5, - 2.209e+5, 2.237e+5, 2.265e+5, 2.294e+5, 2.323e+5, - 2.352e+5, 2.381e+5, 2.411e+5, 2.442e+5, 2.472e+5, - 2.500e+5, 2.527e+5, 2.555e+5, 2.584e+5, 2.612e+5, - 2.641e+5, 2.670e+5, 2.700e+5, 2.732e+5, 2.767e+5, - 2.802e+5, 2.837e+5, 2.873e+5, 2.909e+5, 2.945e+5, - 2.972e+5, 2.985e+5, 3.020e+5, 3.053e+5, 3.088e+5, - 3.122e+5, 3.157e+5, 3.192e+5, 3.228e+5, 3.264e+5, - 3.300e+5, 3.337e+5, 3.379e+5, 3.422e+5, 3.465e+5, - 3.508e+5, 3.553e+5, 3.597e+5, 3.643e+5, 3.688e+5, - 3.735e+5, 3.782e+5, 3.829e+5, 3.877e+5, 3.938e+5, - 4.000e+5, 4.076e+5, 4.138e+5, 4.200e+5, 4.249e+5, - 4.299e+5, 4.349e+5, 4.400e+5, 4.452e+5, 4.505e+5, - 4.553e+5, 4.601e+5, 4.650e+5, 4.700e+5, 4.772e+5, - 4.845e+5, 4.920e+5, 4.995e+5, 5.054e+5, 5.113e+5, - 5.173e+5, 5.234e+5, 5.299e+5, 5.365e+5, 5.432e+5, - 5.500e+5, 5.557e+5, 5.614e+5, 5.672e+5, 5.730e+5, - 5.784e+5, 5.891e+5, 6.000e+5, 6.081e+5, 6.158e+5, - 6.235e+5, 6.313e+5, 6.393e+5, 6.468e+5, 6.545e+5, - 6.622e+5, 6.700e+5, 6.790e+5, 6.926e+5, 7.065e+5, - 7.154e+5, 7.244e+5, 7.335e+5, 7.427e+5, 7.500e+5, - 7.576e+5, 7.653e+5, 7.730e+5, 7.808e+5, 7.904e+5, - 8.002e+5, 8.100e+5, 8.200e+5, 8.301e+5, 8.403e+5, - 8.506e+5, 8.611e+5, 8.750e+5, 8.874e+5, 9.000e+5, - 9.072e+5, 9.200e+5, 9.400e+5, 9.616e+5, 9.800e+5, - 1.003e+6, 1.010e+6, 1.040e+6, 1.070e+6, 1.100e+6, - 1.108e+6, 1.136e+6, 1.165e+6, 1.200e+6, 1.225e+6, - 1.250e+6, 1.287e+6, 1.317e+6, 1.356e+6, 1.400e+6, - 1.423e+6, 1.461e+6, 1.500e+6, 1.536e+6, 1.572e+6, - 1.612e+6, 1.653e+6, 1.695e+6, 1.738e+6, 1.782e+6, - 1.827e+6, 1.850e+6, 1.921e+6, 1.969e+6, 2.019e+6, - 2.070e+6, 2.123e+6, 2.176e+6, 2.231e+6, 2.307e+6, - 2.354e+6, 2.365e+6, 2.385e+6, 2.466e+6, 2.479e+6, - 2.535e+6, 2.592e+6, 2.658e+6, 2.725e+6, 2.794e+6, - 2.865e+6, 2.932e+6, 3.000e+6, 3.080e+6, 3.166e+6, - 3.247e+6, 3.329e+6, 3.413e+6, 3.499e+6, 3.588e+6, - 3.679e+6, 3.772e+6, 3.867e+6, 3.965e+6, 4.066e+6, - 4.183e+6, 4.304e+6, 4.398e+6, 4.493e+6, 4.607e+6, - 4.724e+6, 4.800e+6, 4.882e+6, 4.966e+6, 5.092e+6, - 5.221e+6, 5.353e+6, 5.488e+6, 5.627e+6, 5.770e+6, - 5.916e+6, 6.065e+6, 6.219e+6, 6.376e+6, 6.434e+6, - 6.592e+6, 6.703e+6, 6.873e+6, 7.047e+6, 7.225e+6, - 7.408e+6, 7.596e+6, 7.788e+6, 7.985e+6, 8.187e+6, - 8.395e+6, 8.607e+6, 8.825e+6, 9.048e+6, 9.278e+6, - 9.512e+6, 9.753e+6, 1.000e+7, 1.025e+7, 1.051e+7, - 1.078e+7, 1.105e+7, 1.133e+7, 1.162e+7, 1.191e+7, - 1.221e+7, 1.252e+7, 1.284e+7, 1.317e+7, 1.350e+7, - 1.384e+7, 1.419e+7, 1.455e+7, 1.492e+7, 1.530e+7, - 1.568e+7, 1.608e+7, 1.649e+7, 1.691e+7, 1.733e+7, - 1.790e+7, 1.845e+7, 1.900e+7, 1.964e+7, 2.000e+7]) + 8.4000e8, 8.8000e8, 9.2000e8, 9.6000e8, 1.0000e9,]) GROUP_STRUCTURES['UKAEA-1102'] = np.array([ 1.0000e-5, 1.0471e-5, 1.0965e-5, 1.1482e-5, 1.2023e-5, 1.2589e-5, 1.3183e-5, 1.3804e-5, 1.4454e-5, 1.5136e-5, diff --git a/openmc/mgxs/groups.py b/openmc/mgxs/groups.py index aea7a6d29..182402ed7 100644 --- a/openmc/mgxs/groups.py +++ b/openmc/mgxs/groups.py @@ -78,7 +78,6 @@ class EnergyGroups: @group_edges.setter def group_edges(self, edges): cv.check_type('group edges', edges, Iterable, Real) - cv.check_increasing('group edges', edges) cv.check_greater_than('number of group edges', len(edges), 1) self._group_edges = np.array(edges) @@ -301,139 +300,3 @@ class EnergyGroups: # Assign merged edges to merged groups merged_groups.group_edges = list(merged_edges) return merged_groups - - -def convert_flux_groups(flux, source_groups, target_groups): - """Convert flux spectrum between energy group structures. - - Uses flux-per-unit-lethargy conservation, which assumes constant flux per - unit lethargy within each source group and distributes flux to target - groups proportionally to their lethargy width. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - flux : Iterable of float - Flux values for source groups. Length must equal - source_groups.num_groups. - source_groups : EnergyGroups or str - Energy group structure of the input flux with boundaries in [eV]. - Can be an EnergyGroups instance or the name of a group structure - (e.g., 'CCFE-709'). - target_groups : EnergyGroups or str - Target energy group structure with boundaries in [eV]. Can be an - EnergyGroups instance or the name of a group structure - (e.g., 'UKAEA-1102'). - - Returns - ------- - numpy.ndarray - Flux values for target groups. Total flux is conserved for - overlapping energy regions. - - Raises - ------ - TypeError - If source_groups or target_groups is not EnergyGroups or str - ValueError - If flux length doesn't match source_groups, or flux contains - negative, NaN, or infinite values - - See Also - -------- - EnergyGroups : Energy group structure class - - Notes - ----- - The assumption of constant flux per unit lethargy within each source - group is physically reasonable for most reactor spectra but is not - exact. For best accuracy, use source spectra with sufficiently fine - energy resolution. - - Examples - -------- - Convert FNS 709-group flux to UKAEA-1102 structure: - - >>> import numpy as np - >>> flux_709 = np.load('tests/fns_flux_709.npy') - >>> flux_1102 = openmc.mgxs.convert_flux_groups(flux_709, 'CCFE-709', 'UKAEA-1102') - - Convert using EnergyGroups instances: - - >>> source = openmc.mgxs.EnergyGroups([1.0, 10.0, 100.0]) - >>> target = openmc.mgxs.EnergyGroups([1.0, 5.0, 10.0, 50.0, 100.0]) - >>> flux_target = openmc.mgxs.convert_flux_groups([1e8, 2e8], source, target) - - References - ---------- - .. [1] J. J. Duderstadt and L. J. Hamilton, "Nuclear Reactor Analysis," - John Wiley & Sons, 1976. - .. [2] M. Fleming and J.-Ch. Sublet, "FISPACT-II User Manual," - UKAEA-R(18)001, UK Atomic Energy Authority, 2018. See GRPCONVERT keyword. - - """ - # Handle string group structure names - if isinstance(source_groups, str): - source_groups = EnergyGroups(source_groups) - if isinstance(target_groups, str): - target_groups = EnergyGroups(target_groups) - - # Type validation - cv.check_type('source_groups', source_groups, EnergyGroups) - cv.check_type('target_groups', target_groups, EnergyGroups) - - # Convert flux to numpy array - flux = np.asarray(flux, dtype=np.float64) - if flux.ndim != 1: - raise ValueError(f'flux must be 1-dimensional, got shape {flux.shape}') - - # Validate flux length matches source groups - if len(flux) != source_groups.num_groups: - raise ValueError( - f'Length of flux ({len(flux)}) must equal number of source ' - f'groups ({source_groups.num_groups})' - ) - - # Check for invalid flux values - if np.any(np.isnan(flux)): - raise ValueError('flux contains NaN values') - if np.any(np.isinf(flux)): - raise ValueError('flux contains infinite values') - if np.any(flux < 0): - raise ValueError('flux values must be non-negative') - - # Get energy edges - source_edges = source_groups.group_edges - target_edges = target_groups.group_edges - num_target = target_groups.num_groups - - # Initialize output array - flux_target = np.zeros(num_target) - - # Main conversion loop: distribute flux using lethargy weighting - for idx_src, flux_src in enumerate(flux): - if flux_src == 0: - continue - - e_low_src = source_edges[idx_src] - e_high_src = source_edges[idx_src + 1] - lethargy_src = np.log(e_high_src / e_low_src) - - for idx_tgt in range(num_target): - e_low_tgt = target_edges[idx_tgt] - e_high_tgt = target_edges[idx_tgt + 1] - - # Skip non-overlapping groups - if e_high_tgt <= e_low_src or e_low_tgt >= e_high_src: - continue - - # Calculate overlap region - e_low_overlap = max(e_low_src, e_low_tgt) - e_high_overlap = min(e_high_src, e_high_tgt) - lethargy_overlap = np.log(e_high_overlap / e_low_overlap) - - # Distribute flux proportionally to lethargy fraction - flux_target[idx_tgt] += flux_src * (lethargy_overlap / lethargy_src) - - return flux_target diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index faa83c048..12a4630bd 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -10,10 +10,8 @@ import numpy as np import openmc import openmc.mgxs import openmc.checkvalue as cv -from openmc.checkvalue import PathLike from ..tallies import ESTIMATOR_TYPES -ROOM_TEMPERATURE_KELVIN = 294.0 class Library: """A multi-energy-group and multi-delayed-group cross section library for @@ -557,14 +555,14 @@ class Library: self.all_mgxs[domain.id][mgxs_type] = mgxs - def add_to_tallies(self, tallies, merge=True): - """Add tallies from all MGXS objects to a tallies object. + def add_to_tallies_file(self, tallies_file, merge=True): + """Add all tallies from all MGXS objects to a tallies file. NOTE: This assumes that :meth:`Library.build_library` has been called Parameters ---------- - tallies : openmc.Tallies + tallies_file : openmc.Tallies A Tallies collection to add each MGXS' tallies to generate a 'tallies.xml' input file for OpenMC merge : bool @@ -573,7 +571,7 @@ class Library: """ - cv.check_type('tallies', tallies, openmc.Tallies) + cv.check_type('tallies_file', tallies_file, openmc.Tallies) # Add tallies from each MGXS for each domain and mgxs type for domain in self.domains: @@ -588,15 +586,7 @@ class Library: = list(range(1, self.num_delayed_groups + 1)) for tally in mgxs.tallies.values(): - tallies.append(tally, merge=merge) - - def add_to_tallies_file(self, tallies_file, merge=True): - warn( - "The Library.add_to_tallies_file(...) method has been renamed to" - "add_to_tallies(...) and will be removed in a future version of " - "OpenMC.", FutureWarning - ) - self.add_to_tallies(tallies_file, merge=merge) + tallies_file.append(tally, merge=merge) def load_from_statepoint(self, statepoint): """Extracts tallies in an OpenMC StatePoint with the data needed to @@ -861,7 +851,7 @@ class Library: 'since a statepoint has not yet been loaded' raise ValueError(msg) - cv.check_type('filename', filename, (str, PathLike)) + cv.check_type('filename', filename, str) cv.check_type('directory', directory, str) import h5py @@ -904,7 +894,7 @@ class Library: """ - cv.check_type('filename', filename, (str, PathLike)) + cv.check_type('filename', filename, str) cv.check_type('directory', directory, str) # Make directory if it does not exist @@ -940,7 +930,7 @@ class Library: """ - cv.check_type('filename', filename, (str, PathLike)) + cv.check_type('filename', filename, str) cv.check_type('directory', directory, str) # Make directory if it does not exist @@ -955,7 +945,7 @@ class Library: return pickle.load(f) def get_xsdata(self, domain, xsdata_name, nuclide='total', xs_type='macro', - subdomain=None, apply_domain_chi=False, temperature=ROOM_TEMPERATURE_KELVIN): + subdomain=None, apply_domain_chi=False): """Generates an openmc.XSdata object describing a multi-group cross section dataset for writing to an openmc.MGXSLibrary object. @@ -991,9 +981,6 @@ class Library: downstream multigroup solvers that precompute a material-specific chi before the transport solve provides group-wise fluxes. Defaults to False. - temperature : float, optional - The temperature to set in the XSdata object. Defaults to 294 K - (room temperature). Returns ------- @@ -1040,7 +1027,6 @@ class Library: else: representation = 'isotropic' xsdata = openmc.XSdata(name, self.energy_groups, - temperatures=[temperature], representation=representation) xsdata.num_delayed_groups = self.num_delayed_groups if self.num_polar > 1 or self.num_azimuthal > 1: @@ -1058,61 +1044,45 @@ class Library: # Now get xs data itself if 'nu-transport' in self.mgxs_types and self.correction == 'P0': mymgxs = self.get_mgxs(domain, 'nu-transport') - xsdata.set_total_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuclide], + xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) elif 'transport' in self.mgxs_types and self.correction == 'P0': mymgxs = self.get_mgxs(domain, 'transport') - xsdata.set_total_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuclide], + xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) elif 'total' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'total') - xsdata.set_total_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuclide], + xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'absorption' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'absorption') - xsdata.set_absorption_mgxs(mymgxs, - temperature=temperature, - xs_type=xs_type, + xsdata.set_absorption_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'fission' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'fission') - xsdata.set_fission_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuclide], - subdomain=subdomain) + xsdata.set_fission_mgxs(mymgxs, xs_type=xs_type, + nuclide=[nuclide], subdomain=subdomain) if 'kappa-fission' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'kappa-fission') - xsdata.set_kappa_fission_mgxs(mymgxs, - temperature=temperature, - xs_type=xs_type, + xsdata.set_kappa_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'inverse-velocity' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'inverse-velocity') - xsdata.set_inverse_velocity_mgxs(mymgxs, - temperature=temperature, - xs_type=xs_type, + xsdata.set_inverse_velocity_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'nu-fission matrix' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'nu-fission matrix') - xsdata.set_nu_fission_mgxs(mymgxs, - temperature=temperature, - xs_type=xs_type, + xsdata.set_nu_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) @@ -1122,9 +1092,7 @@ class Library: nuc = "sum" else: nuc = nuclide - xsdata.set_chi_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuc], + xsdata.set_chi_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuc], subdomain=subdomain) if 'chi-prompt' in self.mgxs_types: @@ -1133,10 +1101,8 @@ class Library: nuc = "sum" else: nuc = nuclide - xsdata.set_chi_prompt_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuc], - subdomain=subdomain) + xsdata.set_chi_prompt_mgxs(mymgxs, xs_type=xs_type, + nuclide=[nuc], subdomain=subdomain) if 'chi-delayed' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'chi-delayed') @@ -1144,61 +1110,53 @@ class Library: nuc = "sum" else: nuc = nuclide - xsdata.set_chi_delayed_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, - nuclide=[nuc], - subdomain=subdomain) + xsdata.set_chi_delayed_mgxs(mymgxs, xs_type=xs_type, + nuclide=[nuc], subdomain=subdomain) if 'nu-fission' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'nu-fission') - xsdata.set_nu_fission_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_nu_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'prompt-nu-fission' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'prompt-nu-fission') - xsdata.set_prompt_nu_fission_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_prompt_nu_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'prompt-nu-fission matrix' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'prompt-nu-fission matrix') - xsdata.set_prompt_nu_fission_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_prompt_nu_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'delayed-nu-fission' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'delayed-nu-fission') - xsdata.set_delayed_nu_fission_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_delayed_nu_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'delayed-nu-fission matrix' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'delayed-nu-fission matrix') - xsdata.set_delayed_nu_fission_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_delayed_nu_fission_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) if 'beta' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'beta') - xsdata.set_beta_mgxs(mymgxs, temperature=temperature, xs_type=xs_type, - nuclide=[nuclide], subdomain=subdomain) + xsdata.set_beta_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], + subdomain=subdomain) if 'decay-rate' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'decay-rate') - xsdata.set_decay_rate_mgxs(mymgxs, temperature=temperature, xs_type=xs_type, - nuclide=[nuclide], subdomain=subdomain) + xsdata.set_decay_rate_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], + subdomain=subdomain) # If multiplicity matrix is available, prefer that if 'multiplicity matrix' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'multiplicity matrix') - xsdata.set_multiplicity_matrix_mgxs(mymgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_multiplicity_matrix_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) using_multiplicity = True @@ -1209,7 +1167,6 @@ class Library: scatt_mgxs = self.get_mgxs(domain, 'scatter matrix') nuscatt_mgxs = self.get_mgxs(domain, 'nu-scatter matrix') xsdata.set_multiplicity_matrix_mgxs(nuscatt_mgxs, scatt_mgxs, - temperature=temperature, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) @@ -1222,7 +1179,6 @@ class Library: nuscatt_mgxs = \ self.get_mgxs(domain, 'consistent nu-scatter matrix') xsdata.set_multiplicity_matrix_mgxs(nuscatt_mgxs, scatt_mgxs, - temperature=temperature, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) @@ -1237,8 +1193,7 @@ class Library: else: nuscatt_mgxs = \ self.get_mgxs(domain, 'consistent nu-scatter matrix') - xsdata.set_scatter_matrix_mgxs(nuscatt_mgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_scatter_matrix_mgxs(nuscatt_mgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) else: @@ -1249,8 +1204,7 @@ class Library: else: nuscatt_mgxs = \ self.get_mgxs(domain, 'consistent nu-scatter matrix') - xsdata.set_scatter_matrix_mgxs(nuscatt_mgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_scatter_matrix_mgxs(nuscatt_mgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) @@ -1290,23 +1244,14 @@ class Library: 'are ignored since multiplicity or nu-scatter matrices '\ 'were not tallied for ' + xsdata_name warn(msg, RuntimeWarning) - - if 'scatter matrix' in self.mgxs_types: - scatt_mgxs = self.get_mgxs(domain, 'scatter matrix') - elif 'consistent scatter matrix' in self.mgxs_types: - scatt_mgxs = self.get_mgxs(domain, 'consistent scatter matrix') - else: - raise ValueError(f'No scatter matrix found for {xsdata_name}.') - - xsdata.set_scatter_matrix_mgxs(scatt_mgxs, temperature=temperature, - xs_type=xs_type, + xsdata.set_scatter_matrix_mgxs(scatt_mgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) return xsdata def create_mg_library(self, xs_type='macro', xsdata_names=None, - apply_domain_chi=False, temperature=ROOM_TEMPERATURE_KELVIN): + apply_domain_chi=False): """Creates an openmc.MGXSLibrary object to contain the MGXS data for the Multi-Group mode of OpenMC. @@ -1332,9 +1277,6 @@ class Library: downstream multigroup solvers that precompute a material-specific chi before the transport solve provides group-wise fluxes. Defaults to False. - temperature : float, optional - The temperature to set in the MGXSLibrary object. Defaults to 294 K - (room temperature). Returns ------- diff --git a/openmc/mgxs/mdgxs.py b/openmc/mgxs/mdgxs.py index 57cc955ba..b95a4fbc0 100644 --- a/openmc/mgxs/mdgxs.py +++ b/openmc/mgxs/mdgxs.py @@ -7,7 +7,6 @@ import numpy as np import openmc import openmc.checkvalue as cv -from openmc.checkvalue import PathLike from openmc.mgxs import MGXS from .mgxs import _DOMAIN_TO_FILTER @@ -723,7 +722,7 @@ class MDGXS(MGXS): """ - cv.check_type('filename', filename, (str, PathLike)) + cv.check_type('filename', filename, str) cv.check_type('directory', directory, str) cv.check_value('format', format, ['csv', 'excel', 'pickle', 'latex']) cv.check_value('xs_type', xs_type, ['macro', 'micro']) @@ -877,8 +876,8 @@ class MDGXS(MGXS): # energy groups such that data is from fast to thermal if self.domain_type == 'mesh': mesh_str = f'mesh {self.domain.id}' - mesh_cols = [(mesh_str, label) for label in self.domain._axis_labels] - df.sort_values(by=mesh_cols + columns, inplace=True) + df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), + (mesh_str, 'z')] + columns, inplace=True) else: df.sort_values(by=[self.domain_type] + columns, inplace=True) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 4c13c7508..588b6f64e 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -2,7 +2,6 @@ import copy from numbers import Integral import os import warnings -from textwrap import dedent import h5py import numpy as np @@ -10,7 +9,6 @@ import numpy as np import openmc from openmc.data import REACTION_MT, REACTION_NAME, FISSION_MTS import openmc.checkvalue as cv -from openmc.checkvalue import PathLike from ..tallies import ESTIMATOR_TYPES from . import EnergyGroups @@ -166,7 +164,7 @@ class MGXS: """ - _params = dedent(""" + _params = """ Parameters ---------- domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.RegularMesh @@ -253,7 +251,7 @@ class MGXS: .. versionadded:: 0.13.1 - """) + """ # Store whether or not the number density should be removed for microscopic # values of this data @@ -958,7 +956,7 @@ class MGXS: self.xs_tally._nuclides = [] nuclides = self.get_nuclides() for nuclide in nuclides: - self.xs_tally.nuclides.append(nuclide) + self.xs_tally.nuclides.append(openmc.Nuclide(nuclide)) # Remove NaNs which may have resulted from divide-by-zero operations self.xs_tally._mean = np.nan_to_num(self.xs_tally.mean) @@ -1923,7 +1921,7 @@ class MGXS: # Create an HDF5 group for the subdomain if self.domain_type == 'distribcell': - group_name = str(subdomain).zfill(num_digits) + group_name = ''.zfill(num_digits) subdomain_group = domain_group.require_group(group_name) else: subdomain_group = domain_group @@ -1983,7 +1981,7 @@ class MGXS: """ - cv.check_type('filename', filename, (str, PathLike)) + cv.check_type('filename', filename, str) cv.check_type('directory', directory, str) cv.check_value('format', format, ['csv', 'excel', 'pickle', 'latex']) cv.check_value('xs_type', xs_type, ['macro', 'micro']) @@ -2127,15 +2125,15 @@ class MGXS: df['std. dev.'] /= np.tile(densities, tile_factor) # Replace NaNs by zeros (happens if nuclide density is zero) - df['mean'] = df['mean'].replace(np.nan, 0.0) - df['std. dev.'] = df['std. dev.'].replace(np.nan, 0.0) + df['mean'].replace(np.nan, 0.0, inplace=True) + df['std. dev.'].replace(np.nan, 0.0, inplace=True) # Sort the dataframe by domain type id (e.g., distribcell id) and # energy groups such that data is from fast to thermal if self.domain_type == 'mesh': mesh_str = f'mesh {self.domain.id}' - mesh_cols = [(mesh_str, label) for label in self.domain._axis_labels] - df.sort_values(by=mesh_cols + columns, inplace=True) + df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), + (mesh_str, 'z')] + columns, inplace=True) else: df.sort_values(by=[self.domain_type] + columns, inplace=True) diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index ab9b58b7a..b840563cf 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -11,7 +11,7 @@ import openmc import openmc.mgxs from openmc.mgxs import SCATTER_TABULAR, SCATTER_LEGENDRE, SCATTER_HISTOGRAM from .checkvalue import check_type, check_value, check_greater_than, \ - check_iterable_type, check_less_than, check_filetype_version, PathLike + check_iterable_type, check_less_than, check_filetype_version ROOM_TEMPERATURE_KELVIN = 294.0 @@ -484,8 +484,7 @@ class XSdata: check_type('temperature', temperature, Real) - temp_store = self.temperatures.tolist() - temp_store.append(temperature) + temp_store = self.temperatures.tolist().append(temperature) self.temperatures = temp_store self._total.append(None) @@ -515,75 +514,6 @@ class XSdata: if np.sum(array) > 0: self._fissionable = True - def add_temperature_data(self, other): - """This method adds temperature-dependent cross section - values from another XSdata object to this XSdata object. - Note: if a temperature datapoint from 'other' already exists in this - object, it will be overridden. - - Parameters - ---------- - other: openmc.XSdata - The other XSdata object to fetch data from - """ - - # Sanity check to make sure they have the same name, energy group structure, - # and delayed group structure - check_value('name', other.name, self.name) - check_value('energy_groups', other.energy_groups, [self.energy_groups]) - check_value('delayed_groups', other.num_delayed_groups, [self.num_delayed_groups]) - - # Add the temperature data. - for temp in other.temperatures: - if temp not in self.temperatures: - self.add_temperature(temp) - - if np.all(other.absorption[other._temperature_index(temp)] != None): - self.set_absorption(other.absorption[other._temperature_index(temp)], temp) - - if np.all(other.beta[other._temperature_index(temp)] != None): - self.set_beta(other.beta[other._temperature_index(temp)], temp) - - if np.all(other.chi[other._temperature_index(temp)] != None): - self.set_chi(other.chi[other._temperature_index(temp)], temp) - - if np.all(other.chi_delayed[other._temperature_index(temp)] != None): - self.set_chi_delayed(other.chi_delayed[other._temperature_index(temp)], temp) - - if np.all(other.chi_prompt[other._temperature_index(temp)] != None): - self.set_chi_prompt(other.chi_prompt[other._temperature_index(temp)], temp) - - if np.all(other.decay_rate[other._temperature_index(temp)] != None): - self.set_decay_rate(other.decay_rate[other._temperature_index(temp)], temp) - - if np.all(other.delayed_nu_fission[other._temperature_index(temp)] != None): - self.set_delayed_nu_fission(other.delayed_nu_fission[other._temperature_index(temp)], temp) - - if np.all(other.fission[other._temperature_index(temp)] != None): - self.set_fission(other.fission[other._temperature_index(temp)], temp) - - if np.all(other.inverse_velocity[other._temperature_index(temp)] != None): - self.set_inverse_velocity(other.inverse_velocity[other._temperature_index(temp)], temp) - - if np.all(other.kappa_fission[other._temperature_index(temp)] != None): - self.set_kappa_fission(other.kappa_fission[other._temperature_index(temp)], temp) - - if np.all(other.multiplicity_matrix[other._temperature_index(temp)] != None): - self.set_multiplicity_matrix(other.multiplicity_matrix[other._temperature_index(temp)], temp) - - if np.all(other.nu_fission[other._temperature_index(temp)] != None): - self.set_nu_fission(other.nu_fission[other._temperature_index(temp)], temp) - - if np.all(other.prompt_nu_fission[other._temperature_index(temp)] != None): - self.set_prompt_nu_fission(other.prompt_nu_fission[other._temperature_index(temp)], temp) - - if np.all(other.scatter_matrix[other._temperature_index(temp)] != None): - self.set_scatter_matrix(other.scatter_matrix[other._temperature_index(temp)], temp) - - if np.all(other.fission[other._temperature_index(temp)] != None): - self.set_total(other.total[other._temperature_index(temp)], temp) - - def set_total(self, total, temperature=ROOM_TEMPERATURE_KELVIN): """This method sets the cross section for this XSdata object at the provided temperature. @@ -2576,7 +2506,7 @@ class MGXSLibrary: Parameters ---------- - filename : str or PathLike + filename : str Filename of file, default is mgxs.h5. libver : {'earliest', 'latest'} Compatibility mode for the HDF5 file. 'latest' will produce files @@ -2584,7 +2514,8 @@ class MGXSLibrary: """ - check_type('filename', filename, (str, PathLike)) + check_type('filename', filename, str) + # Create and write to the HDF5 file file = h5py.File(filename, "w", libver=libver) file.attrs['filetype'] = np.bytes_(_FILETYPE_MGXS_LIBRARY) @@ -2623,21 +2554,21 @@ class MGXSLibrary: raise ValueError("Either path or openmc.config['mg_cross_sections']" "must be set") - check_type('filename', filename, (str, PathLike)) - with h5py.File(filename, 'r') as file: + check_type('filename', filename, str) + file = h5py.File(filename, 'r') - # Check filetype and version - check_filetype_version(file, _FILETYPE_MGXS_LIBRARY, - _VERSION_MGXS_LIBRARY) + # Check filetype and version + check_filetype_version(file, _FILETYPE_MGXS_LIBRARY, + _VERSION_MGXS_LIBRARY) - group_structure = file.attrs['group structure'] - num_delayed_groups = file.attrs['delayed_groups'] - energy_groups = openmc.mgxs.EnergyGroups(group_structure) - data = cls(energy_groups, num_delayed_groups) + group_structure = file.attrs['group structure'] + num_delayed_groups = file.attrs['delayed_groups'] + energy_groups = openmc.mgxs.EnergyGroups(group_structure) + data = cls(energy_groups, num_delayed_groups) - for group_name, group in file.items(): - data.add_xsdata(openmc.XSdata.from_hdf5(group, group_name, - energy_groups, - num_delayed_groups)) + for group_name, group in file.items(): + data.add_xsdata(openmc.XSdata.from_hdf5(group, group_name, + energy_groups, + num_delayed_groups)) return data diff --git a/openmc/mixin.py b/openmc/mixin.py index 28c97bfdd..31c26ec76 100644 --- a/openmc/mixin.py +++ b/openmc/mixin.py @@ -39,8 +39,6 @@ class IDManagerMixin: """ - min_id = 0 - @property def id(self): return self._id @@ -66,7 +64,7 @@ class IDManagerMixin: else: name = cls.__name__ cv.check_type(f'{name} ID', uid, Integral) - cv.check_greater_than(f'{name} ID', uid, cls.min_id, equality=True) + cv.check_greater_than(f'{name} ID', uid, 0, equality=True) if uid in cls.used_ids: msg = f'Another {name} instance already exists with id={uid}.' warn(msg, IDWarning) @@ -74,17 +72,12 @@ class IDManagerMixin: cls.used_ids.add(uid) self._id = uid - @classmethod - def reset_ids(cls): - """Reset counters""" - cls.used_ids.clear() - cls.next_id = 1 - def reset_auto_ids(): """Reset counters for all auto-generated IDs""" for cls in IDManagerMixin.__subclasses__(): - cls.reset_ids() + cls.used_ids.clear() + cls.next_id = 1 def reserve_ids(ids, cls=None): diff --git a/openmc/model/funcs.py b/openmc/model/funcs.py index e076b080a..41aa920ea 100644 --- a/openmc/model/funcs.py +++ b/openmc/model/funcs.py @@ -39,8 +39,8 @@ def borated_water(boron_ppm, temperature=293., pressure=0.1013, temp_unit='K', press_unit : {'MPa', 'psi'} The units used for the `pressure` argument. density : float - Water density in [g / cm^3]. If specified, this value overrides - the value that is computed from the temperature and pressure arguments. + Water density in [g / cm^3]. If specified, this value overrides the + temperature and pressure arguments. **kwargs All keyword arguments are passed to the created Material object. @@ -95,7 +95,10 @@ def borated_water(boron_ppm, temperature=293., pressure=0.1013, temp_unit='K', frac_B = boron_ppm * 1e-6 / M_B # Build the material. - out = openmc.Material(temperature=T, **kwargs) + if density is None: + out = openmc.Material(temperature=T, **kwargs) + else: + out = openmc.Material(**kwargs) out.add_element('H', frac_H, 'ao') out.add_element('O', frac_O, 'ao') out.add_element('B', frac_B, 'ao') diff --git a/openmc/model/model.py b/openmc/model/model.py index c3bfa3b55..2160c97e6 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -1,48 +1,25 @@ from __future__ import annotations -from collections.abc import Callable, Iterable, Sequence -import copy -from dataclasses import dataclass, field -from functools import cache +from collections.abc import Iterable +from functools import lru_cache +import os from pathlib import Path -import math -from numbers import Integral, Real -import random -import re -from tempfile import NamedTemporaryFile, TemporaryDirectory -from typing import Any, Protocol +from numbers import Integral +from tempfile import NamedTemporaryFile import warnings +from typing import Optional, Dict import h5py import lxml.etree as ET -import numpy as np -from scipy.optimize import curve_fit import openmc import openmc._xml as xml from openmc.dummy_comm import DummyCommunicator from openmc.executor import _process_CLI_arguments -from openmc.checkvalue import (check_type, check_value, check_greater_than, - check_length, PathLike) +from openmc.checkvalue import check_type, check_value, PathLike from openmc.exceptions import InvalidIDError -from openmc.plots import add_plot_params, _BASIS_INDICES, id_map_to_rgb from openmc.utility_funcs import change_directory -# Protocol for a function that is passed to search_keff -class ModelModifier(Protocol): - def __call__(self, val: float, **kwargs: Any) -> None: - ... - - -def _check_pixels(pixels: int | Sequence[int]) -> None: - if isinstance(pixels, Integral): - check_greater_than('pixels', pixels, 0) - else: - check_length('pixels', pixels, 2) - for p in pixels: - check_greater_than('pixels', p, 0) - - class Model: """Model container. @@ -86,22 +63,27 @@ class Model: """ - def __init__( - self, - geometry: openmc.Geometry | None = None, - materials: openmc.Materials | None = None, - settings: openmc.Settings | None = None, - tallies: openmc.Tallies | None = None, - plots: openmc.Plots | None = None, - ): - self.geometry = openmc.Geometry() if geometry is None else geometry - self.materials = openmc.Materials() if materials is None else materials - self.settings = openmc.Settings() if settings is None else settings - self.tallies = openmc.Tallies() if tallies is None else tallies - self.plots = openmc.Plots() if plots is None else plots + def __init__(self, geometry=None, materials=None, settings=None, + tallies=None, plots=None): + self.geometry = openmc.Geometry() + self.materials = openmc.Materials() + self.settings = openmc.Settings() + self.tallies = openmc.Tallies() + self.plots = openmc.Plots() + + if geometry is not None: + self.geometry = geometry + if materials is not None: + self.materials = materials + if settings is not None: + self.settings = settings + if tallies is not None: + self.tallies = tallies + if plots is not None: + self.plots = plots @property - def geometry(self) -> openmc.Geometry: + def geometry(self) -> Optional[openmc.Geometry]: return self._geometry @geometry.setter @@ -110,7 +92,7 @@ class Model: self._geometry = geometry @property - def materials(self) -> openmc.Materials: + def materials(self) -> Optional[openmc.Materials]: return self._materials @materials.setter @@ -119,14 +101,12 @@ class Model: if isinstance(materials, openmc.Materials): self._materials = materials else: - if not hasattr(self, '_materials'): - self._materials = openmc.Materials() del self._materials[:] for mat in materials: self._materials.append(mat) @property - def settings(self) -> openmc.Settings: + def settings(self) -> Optional[openmc.Settings]: return self._settings @settings.setter @@ -135,7 +115,7 @@ class Model: self._settings = settings @property - def tallies(self) -> openmc.Tallies: + def tallies(self) -> Optional[openmc.Tallies]: return self._tallies @tallies.setter @@ -144,32 +124,24 @@ class Model: if isinstance(tallies, openmc.Tallies): self._tallies = tallies else: - if not hasattr(self, '_tallies'): - self._tallies = openmc.Tallies() del self._tallies[:] for tally in tallies: self._tallies.append(tally) @property - def plots(self) -> openmc.Plots: + def plots(self) -> Optional[openmc.Plots]: return self._plots @plots.setter def plots(self, plots): - check_type('plots', plots, Iterable, openmc.PlotBase) + check_type('plots', plots, Iterable, openmc.Plot) if isinstance(plots, openmc.Plots): self._plots = plots else: - if not hasattr(self, '_plots'): - self._plots = openmc.Plots() del self._plots[:] for plot in plots: self._plots.append(plot) - @property - def bounding_box(self) -> openmc.BoundingBox: - return self.geometry.bounding_box - @property def is_initialized(self) -> bool: try: @@ -179,7 +151,7 @@ class Model: return False @property - @cache + @lru_cache(maxsize=None) def _materials_by_id(self) -> dict: """Dictionary mapping material ID --> material""" if self.materials: @@ -189,15 +161,15 @@ class Model: return {mat.id: mat for mat in mats} @property - @cache + @lru_cache(maxsize=None) def _cells_by_id(self) -> dict: """Dictionary mapping cell ID --> cell""" cells = self.geometry.get_all_cells() return {cell.id: cell for cell in cells.values()} @property - @cache - def _cells_by_name(self) -> dict[int, openmc.Cell]: + @lru_cache(maxsize=None) + def _cells_by_name(self) -> Dict[int, openmc.Cell]: # Get the names maps, but since names are not unique, store a set for # each name key. In this way when the user requests a change by a name, # the change will be applied to all of the same name. @@ -209,8 +181,8 @@ class Model: return result @property - @cache - def _materials_by_name(self) -> dict[int, openmc.Material]: + @lru_cache(maxsize=None) + def _materials_by_name(self) -> Dict[int, openmc.Material]: if self.materials is None: mats = self.geometry.get_all_materials().values() else: @@ -222,124 +194,25 @@ class Model: result[mat.name].add(mat) return result - # TODO: This should really get incorporated in lower-level calls to - # get_all_materials, but right now it requires information from the Model object - def _get_all_materials(self) -> dict[int, openmc.Material]: - """Get all materials including those in DAGMC universes - - Returns - ------- - dict - Dictionary mapping material ID to material instances - """ - # Get all materials from the Geometry object - materials = self.geometry.get_all_materials() - - # Account for materials in DAGMC universes - for cell in self.geometry.get_all_cells().values(): - if isinstance(cell.fill, openmc.DAGMCUniverse): - names = cell.fill.material_names - materials.update({ - mat.id: mat for mat in self.materials if mat.name in names - }) - - return materials - - def add_kinetics_parameters_tallies(self, num_groups: int | None = None): - """Add tallies for calculating kinetics parameters using the IFP method. - - This method adds tallies to the model for calculating two kinetics - parameters, the generation time and the effective delayed neutron - fraction (beta effective). After a model is run, these parameters can be - determined through the :meth:`openmc.StatePoint.ifp_results` method. - - Parameters - ---------- - num_groups : int, optional - Number of precursor groups to filter the delayed neutron fraction. - If None, only the total effective delayed neutron fraction is - tallied. - - """ - if not any('ifp-time-numerator' in t.scores for t in self.tallies): - gen_time_tally = openmc.Tally(name='IFP time numerator') - gen_time_tally.scores = ['ifp-time-numerator'] - self.tallies.append(gen_time_tally) - if not any('ifp-beta-numerator' in t.scores for t in self.tallies): - beta_tally = openmc.Tally(name='IFP beta numerator') - beta_tally.scores = ['ifp-beta-numerator'] - if num_groups is not None: - beta_tally.filters = [openmc.DelayedGroupFilter(list(range(1, num_groups + 1)))] - self.tallies.append(beta_tally) - if not any('ifp-denominator' in t.scores for t in self.tallies): - denom_tally = openmc.Tally(name='IFP denominator') - denom_tally.scores = ['ifp-denominator'] - self.tallies.append(denom_tally) - - # TODO: This should also be incorporated into lower-level calls in - # settings.py, but it requires information about the tallies currently - # on the active Model - def _assign_fw_cadis_tally_IDs(self): - # Verify that all tallies assigned as targets on WeightWindowGenerators - # exist within model.tallies. If this is the case, convert the .targets - # attribute of each WeightWindowGenerator to a sequence of tally IDs. - if len(self.settings.weight_window_generators) == 0: - return - - # List of valid tally IDs - reference_tally_ids = np.asarray([tal.id for tal in self.tallies]) - - for wwg in self.settings.weight_window_generators: - # Only proceeds if the "targets" attribute is an openmc.Tallies, - # which means it hasn't been checked against model.tallies. - if isinstance(wwg.targets, openmc.Tallies): - id_vec = [] - for tal in wwg.targets: - # check against model tallies for equivalence - id_next = None - for reference_tal in self.tallies: - if tal == reference_tal: - id_next = reference_tal.id - break - - if id_next is None: - raise RuntimeError( - f'Local FW-CADIS target tally {tal.id} not found on model.tallies!') - else: - id_vec.append(id_next) - - wwg.targets = id_vec - - elif isinstance(wwg.targets, np.ndarray): - invalid = wwg.targets[~np.isin(wwg.targets, reference_tally_ids)] - if len(invalid) > 0: - raise RuntimeError( - f'Local FW-CADIS target tally IDs {invalid} not found on model.tallies!') - @classmethod - def from_xml( - cls, - geometry: PathLike = "geometry.xml", - materials: PathLike = "materials.xml", - settings: PathLike = "settings.xml", - tallies: PathLike = "tallies.xml", - plots: PathLike = "plots.xml", - ) -> Model: + def from_xml(cls, geometry='geometry.xml', materials='materials.xml', + settings='settings.xml', tallies='tallies.xml', + plots='plots.xml') -> Model: """Create model from existing XML files Parameters ---------- - geometry : PathLike + geometry : str Path to geometry.xml file - materials : PathLike + materials : str Path to materials.xml file - settings : PathLike + settings : str Path to settings.xml file - tallies : PathLike + tallies : str Path to tallies.xml file .. versionadded:: 0.13.0 - plots : PathLike + plots : str Path to plots.xml file .. versionadded:: 0.13.0 @@ -353,20 +226,19 @@ class Model: materials = openmc.Materials.from_xml(materials) geometry = openmc.Geometry.from_xml(geometry, materials) settings = openmc.Settings.from_xml(settings) - tallies = openmc.Tallies.from_xml( - tallies) if Path(tallies).exists() else None + tallies = openmc.Tallies.from_xml(tallies) if Path(tallies).exists() else None plots = openmc.Plots.from_xml(plots) if Path(plots).exists() else None return cls(geometry, materials, settings, tallies, plots) @classmethod - def from_model_xml(cls, path: PathLike = "model.xml") -> Model: + def from_model_xml(cls, path='model.xml'): """Create model from single XML file .. versionadded:: 0.13.3 Parameters ---------- - path : PathLike + path : str or PathLike Path to model.xml file """ parser = ET.XMLParser(huge_tree=True) @@ -376,33 +248,20 @@ class Model: model = cls() meshes = {} - model.settings = openmc.Settings.from_xml_element( - root.find('settings'), meshes) - model.materials = openmc.Materials.from_xml_element( - root.find('materials')) - model.geometry = openmc.Geometry.from_xml_element( - root.find('geometry'), model.materials) + model.settings = openmc.Settings.from_xml_element(root.find('settings'), meshes) + model.materials = openmc.Materials.from_xml_element(root.find('materials')) + model.geometry = openmc.Geometry.from_xml_element(root.find('geometry'), model.materials) if root.find('tallies') is not None: - model.tallies = openmc.Tallies.from_xml_element( - root.find('tallies'), meshes) + model.tallies = openmc.Tallies.from_xml_element(root.find('tallies'), meshes) if root.find('plots') is not None: model.plots = openmc.Plots.from_xml_element(root.find('plots')) return model - def init_lib( - self, - threads: int | None = None, - geometry_debug: bool = False, - restart_file: PathLike | None = None, - tracks: bool = False, - output: bool = True, - event_based: bool | None = None, - intracomm=None, - directory: PathLike | None = None, - ): + def init_lib(self, threads=None, geometry_debug=False, restart_file=None, + tracks=False, output=True, event_based=None, intracomm=None): """Initializes the model in memory via the C API .. versionadded:: 0.13.0 @@ -417,7 +276,7 @@ class Model: variable). geometry_debug : bool, optional Turn on geometry debugging during simulation. Defaults to False. - restart_file : PathLike, optional + restart_file : str, optional Path to restart file to use tracks : bool, optional Enables the writing of particles tracks. The number of particle @@ -430,8 +289,6 @@ class Model: the Settings will be used. intracomm : mpi4py.MPI.Intracomm or None, optional MPI intracommunicator - directory : PathLike or None, optional - Directory to write XML files to. Defaults to None. """ import openmc.lib @@ -445,8 +302,7 @@ class Model: args = _process_CLI_arguments( volume=False, geometry_debug=geometry_debug, restart_file=restart_file, threads=threads, tracks=tracks, - event_based=event_based, path_input=directory) - + event_based=event_based) # Args adds the openmc_exec command in the first entry; remove it args = args[1:] @@ -460,10 +316,7 @@ class Model: self._intracomm = DummyCommunicator() if self._intracomm.rank == 0: - if directory is not None: - self.export_to_xml(directory=directory) - else: - self.export_to_xml() + self.export_to_xml() self._intracomm.barrier() # We cannot pass DummyCommunicator to openmc.lib.init so pass instead @@ -471,30 +324,6 @@ class Model: # communicator openmc.lib.init(args=args, intracomm=intracomm, output=output) - def sync_dagmc_universes(self): - """Synchronize all DAGMC universes in the current geometry. - - This method iterates over all DAGMC universes in the geometry and - synchronizes their cells with the current material assignments. Requires - that the model has been initialized via :meth:`Model.init_lib`. - Synchronized DAGMC cells can then be edited and exported as nested - `` overrides inside each `` element. - - .. versionadded:: 0.15.1 - - """ - if self.is_initialized: - if self.materials: - materials = self.materials - else: - materials = list(self.geometry.get_all_materials().values()) - for univ in self.geometry.get_all_universes().values(): - if isinstance(univ, openmc.DAGMCUniverse): - univ.sync_dagmc_cells(materials) - else: - raise ValueError("The model must be initialized before calling " - "this method") - def finalize_lib(self): """Finalize simulation and free memory allocated for the C API @@ -506,15 +335,9 @@ class Model: openmc.lib.finalize() - def deplete( - self, - method: str = "cecm", - final_step: bool = True, - operator_kwargs: dict | None = None, - directory: PathLike = ".", - output: bool = True, - **integrator_kwargs, - ): + def deplete(self, timesteps, method='cecm', final_step=True, + operator_kwargs=None, directory='.', output=True, + **integrator_kwargs): """Deplete model using specified timesteps/power .. versionchanged:: 0.13.0 @@ -523,12 +346,10 @@ class Model: Parameters ---------- - timesteps : iterable of float or iterable of tuple - Array of timesteps. Note that values are not cumulative. The units are - specified by the `timestep_units` argument when `timesteps` is an - iterable of float. Alternatively, units can be specified for each step - by passing an iterable of (value, unit) tuples. - method : str + timesteps : iterable of float + Array of timesteps in units of [s]. Note that values are not + cumulative. + method : str, optional Integration method used for depletion (e.g., 'cecm', 'predictor'). Defaults to 'cecm'. final_step : bool, optional @@ -537,14 +358,14 @@ class Model: operator_kwargs : dict Keyword arguments passed to the depletion operator initializer (e.g., :func:`openmc.deplete.Operator`) - directory : PathLike, optional + directory : str, optional Directory to write XML files to. If it doesn't exist already, it will be created. Defaults to the current working directory output : bool Capture OpenMC output from standard out integrator_kwargs : dict - Remaining keyword arguments passed to the depletion integrator - (e.g., :class:`openmc.deplete.CECMIntegrator`). + Remaining keyword arguments passed to the depletion Integrator + initializer (e.g., :func:`openmc.deplete.integrator.cecm`). """ @@ -575,7 +396,8 @@ class Model: check_value('method', method, dep.integrators.integrator_by_name.keys()) integrator_class = dep.integrators.integrator_by_name[method] - integrator = integrator_class(depletion_operator, **integrator_kwargs) + integrator = integrator_class(depletion_operator, timesteps, + **integrator_kwargs) # Now perform the depletion with openmc.lib.quiet_dll(output): @@ -598,20 +420,12 @@ class Model: depletion_operator.cleanup_when_done = True depletion_operator.finalize() - def _link_geometry_to_filters(self): - """Establishes a link between distribcell filters and the geometry""" - for tally in self.tallies: - for f in tally.filters: - if isinstance(f, openmc.DistribcellFilter): - f._geometry = self.geometry - - def export_to_xml(self, directory: PathLike = '.', remove_surfs: bool = False, - nuclides_to_ignore: Iterable[str] | None = None): + def export_to_xml(self, directory='.', remove_surfs=False): """Export model to separate XML files. Parameters ---------- - directory : PathLike + directory : str Directory to write XML files to. If it doesn't exist already, it will be created. remove_surfs : bool @@ -619,16 +433,12 @@ class Model: exporting. .. versionadded:: 0.13.1 - nuclides_to_ignore : list of str - Nuclides to ignore when exporting to XML. - """ # Create directory if required d = Path(directory) if not d.is_dir(): d.mkdir(parents=True, exist_ok=True) - self._assign_fw_cadis_tally_IDs() self.settings.export_to_xml(d) self.geometry.export_to_xml(d, remove_surfs=remove_surfs) @@ -636,21 +446,18 @@ class Model: # for all materials in the geometry and use that to automatically build # a collection. if self.materials: - self.materials.export_to_xml(d, nuclides_to_ignore=nuclides_to_ignore) + self.materials.export_to_xml(d) else: materials = openmc.Materials(self.geometry.get_all_materials() .values()) - materials.export_to_xml(d, nuclides_to_ignore=nuclides_to_ignore) + materials.export_to_xml(d) if self.tallies: self.tallies.export_to_xml(d) if self.plots: self.plots.export_to_xml(d) - self._link_geometry_to_filters() - - def export_to_model_xml(self, path: PathLike = 'model.xml', remove_surfs: bool = False, - nuclides_to_ignore: Iterable[str] | None = None): + def export_to_model_xml(self, path='model.xml', remove_surfs=False): """Export model to a single XML file. .. versionadded:: 0.13.3 @@ -663,8 +470,6 @@ class Model: remove_surfs : bool Whether or not to remove redundant surfaces from the geometry when exporting. - nuclides_to_ignore : list of str - Nuclides to ignore when exporting to XML. """ xml_path = Path(path) @@ -687,9 +492,6 @@ class Model: "set the Geometry.merge_surfaces attribute instead.") self.geometry.merge_surfaces = True - # Link FW-CADIS WeightWindowGenerator target tallies, if present - self._assign_fw_cadis_tally_IDs() - # provide a memo to track which meshes have been written mesh_memo = set() settings_element = self.settings.to_xml_element(mesh_memo) @@ -713,27 +515,22 @@ class Model: fh.write("\n") # Write the materials collection to the open XML file first. # This will write the XML header also - materials._write_xml(fh, False, level=1, - nuclides_to_ignore=nuclides_to_ignore) + materials._write_xml(fh, False, level=1) # Write remaining elements as a tree fh.write(ET.tostring(geometry_element, encoding="unicode")) fh.write(ET.tostring(settings_element, encoding="unicode")) if self.tallies: tallies_element = self.tallies.to_xml_element(mesh_memo) - xml.clean_indentation( - tallies_element, level=1, trailing_indent=self.plots) + xml.clean_indentation(tallies_element, level=1, trailing_indent=self.plots) fh.write(ET.tostring(tallies_element, encoding="unicode")) if self.plots: plots_element = self.plots.to_xml_element() - xml.clean_indentation( - plots_element, level=1, trailing_indent=False) + xml.clean_indentation(plots_element, level=1, trailing_indent=False) fh.write(ET.tostring(plots_element, encoding="unicode")) fh.write("\n") - self._link_geometry_to_filters() - - def import_properties(self, filename: PathLike): + def import_properties(self, filename): """Import physical properties .. versionchanged:: 0.13.0 @@ -741,7 +538,7 @@ class Model: Parameters ---------- - filename : PathLike + filename : str Path to properties HDF5 file See Also @@ -763,7 +560,7 @@ class Model: raise ValueError("Number of cells in properties file doesn't " "match current model.") - # Update temperatures and densities for cells filled with materials + # Update temperatures for cells filled with materials for name, group in cells_group.items(): cell_id = int(name.split()[1]) cell = cells[cell_id] @@ -778,20 +575,6 @@ class Model: else: lib_cell.set_temperature(temperature[0]) - if group['density']: - density = group['density'][()] - if density.size > 1: - cell.density = [rho for rho in density] - else: - cell.density = density - if self.is_initialized: - lib_cell = openmc.lib.cells[cell_id] - if density.size > 1: - for i, rho in enumerate(density): - lib_cell.set_density(rho, i) - else: - lib_cell.set_density(density[0]) - # Make sure number of materials matches mats_group = fh['materials'] n_cells = mats_group.attrs['n_materials'] @@ -808,22 +591,10 @@ class Model: C_mat = openmc.lib.materials[mat_id] C_mat.set_density(atom_density, 'atom/b-cm') - def run( - self, - particles: int | None = None, - threads: int | None = None, - geometry_debug: bool = False, - restart_file: PathLike | None = None, - tracks: bool = False, - output: bool = True, - cwd: PathLike = ".", - openmc_exec: PathLike = "openmc", - mpi_args: Iterable[str] = None, - event_based: bool | None = None, - export_model_xml: bool = True, - apply_tally_results: bool = False, - **export_kwargs, - ) -> Path: + def run(self, particles=None, threads=None, geometry_debug=False, + restart_file=None, tracks=False, output=True, cwd='.', + openmc_exec='openmc', mpi_args=None, event_based=None, + export_model_xml=True, **export_kwargs): """Run OpenMC If the C API has been initialized, then the C API is used, otherwise, @@ -873,11 +644,6 @@ class Model: to True. .. versionadded:: 0.13.3 - apply_tally_results : bool - Whether to apply results of the final statepoint file to the - model's tally objects. - - .. versionadded:: 0.15.1 **export_kwargs Keyword arguments passed to either :meth:`Model.export_to_model_xml` or :meth:`Model.export_to_xml`. @@ -949,23 +715,11 @@ class Model: if mtime >= tstart: # >= allows for poor clock resolution tstart = mtime last_statepoint = sp - - if apply_tally_results: - self.apply_tally_results(last_statepoint) - return last_statepoint - def calculate_volumes( - self, - threads: int | None = None, - output: bool = True, - cwd: PathLike = ".", - openmc_exec: PathLike = "openmc", - mpi_args: list[str] | None = None, - apply_volumes: bool = True, - export_model_xml: bool = True, - **export_kwargs, - ): + def calculate_volumes(self, threads=None, output=True, cwd='.', + openmc_exec='openmc', mpi_args=None, + apply_volumes=True): """Runs an OpenMC stochastic volume calculation and, if requested, applies volumes to the model @@ -994,13 +748,6 @@ class Model: apply_volumes : bool, optional Whether apply the volume calculation results from this calculation to the model. Defaults to applying the volumes. - export_model_xml : bool, optional - Exports a single model.xml file rather than separate files. Defaults - to True. - **export_kwargs - Keyword arguments passed to either :meth:`Model.export_to_model_xml` - or :meth:`Model.export_to_xml`. - """ if len(self.settings.volume_calculations) == 0: @@ -1022,15 +769,10 @@ class Model: openmc.lib.calculate_volumes(output) else: - if export_model_xml: - self.export_to_model_xml(**export_kwargs) - else: - self.export_to_xml(**export_kwargs) - path_input = export_kwargs.get("path", None) - openmc.calculate_volumes( - threads=threads, output=output, openmc_exec=openmc_exec, - mpi_args=mpi_args, path_input=path_input - ) + self.export_to_xml() + openmc.calculate_volumes(threads=threads, output=output, + openmc_exec=openmc_exec, + mpi_args=mpi_args) # Now we apply the volumes if apply_volumes: @@ -1052,489 +794,7 @@ class Model: openmc.lib.materials[domain_id].volume = \ vol_calc.volumes[domain_id].n - - def _set_plot_defaults( - self, - origin: Sequence[float] | None, - width: Sequence[float] | None, - pixels: int | Sequence[int], - basis: str - ): - _check_pixels(pixels) - - x, y, _ = _BASIS_INDICES[basis] - - bb = self.bounding_box - # checks to see if bounding box contains -inf or inf values - if np.isinf(bb.extent[basis]).any(): - if origin is None: - origin = (0, 0, 0) - if width is None: - width = (10, 10) - else: - if origin is None: - # if nan values in the bb.center they get replaced with 0.0 - # this happens when the bounding_box contains inf values - with warnings.catch_warnings(): - warnings.simplefilter("ignore", RuntimeWarning) - origin = np.nan_to_num(bb.center) - if width is None: - bb_width = bb.width - width = (bb_width[x], bb_width[y]) - - if isinstance(pixels, int): - aspect_ratio = width[0] / width[1] - pixels_y = math.sqrt(pixels / aspect_ratio) - pixels = (int(pixels / pixels_y), int(pixels_y)) - - return origin, width, pixels - - def id_map( - self, - origin: Sequence[float] | None = None, - width: Sequence[float] | None = None, - pixels: int | Sequence[int] = 40000, - basis: str = 'xy', - color_overlaps: bool = False, - **init_kwargs - ) -> np.ndarray: - """Generate an ID map for domains based on the plot parameters - - If the model is not yet initialized, it will be initialized with - openmc.lib. If the model is initialized, the model will remain - initialized after this method call exits. - - .. versionadded:: 0.15.3 - - Parameters - ---------- - origin : Sequence[float], optional - Origin of the plot. If unspecified, this argument defaults to the - center of the bounding box if the bounding box does not contain inf - values for the provided basis, otherwise (0.0, 0.0, 0.0). - width : Sequence[float], optional - Width of the plot. If unspecified, this argument defaults to the - width of the bounding box if the bounding box does not contain inf - values for the provided basis, otherwise (10.0, 10.0). - pixels : int | Sequence[int], optional - If an iterable of ints is provided then this directly sets the - number of pixels to use in each basis direction. If a single int is - provided then this sets the total number of pixels in the plot and - the number of pixels in each basis direction is calculated from this - total and the image aspect ratio based on the width argument. - basis : {'xy', 'yz', 'xz'}, optional - Basis of the plot. - color_overlaps : bool, optional - Whether to assign unique IDs (-3) to overlapping regions. If False, - overlapping regions will be assigned the ID of the lowest-numbered - cell that occupies that region. Defaults to False. - **init_kwargs - Keyword arguments passed to :meth:`Model.init_lib`. - - Returns - ------- - id_map : numpy.ndarray - A NumPy array with shape (vertical pixels, horizontal pixels, 3) of - OpenMC property IDs with dtype int32. The last dimension of the - array contains cell IDs, cell instances, and material IDs (in that - order). - """ - ids, _ = self.slice_data( - origin=origin, - width=width, - pixels=pixels, - basis=basis, - show_overlaps=color_overlaps, - level=-1, - include_properties=False, - **init_kwargs, - ) - return ids - - def slice_data( - self, - origin: Sequence[float] | None = None, - width: Sequence[float] | None = None, - pixels: int | Sequence[int] = 40000, - basis: str = 'xy', - u_span: Sequence[float] | None = None, - v_span: Sequence[float] | None = None, - show_overlaps: bool = False, - level: int = -1, - filter: openmc.Filter | None = None, - include_properties: bool = True, - **init_kwargs - ) -> tuple[np.ndarray, np.ndarray | None]: - """Generate geometry and property data for a 2D plot slice. - - This method combines the functionality of :meth:`id_map` and property - mapping into a single call, avoiding duplicate geometry lookups. It also - supports filter bin index lookup for tally visualization. - - .. versionadded:: 0.16.0 - - Parameters - ---------- - origin : Sequence[float], optional - Origin of the plot. If unspecified, this argument defaults to the - center of the bounding box if the bounding box does not contain inf - values for the provided basis, otherwise (0.0, 0.0, 0.0). - width : Sequence[float], optional - Width of the plot. If unspecified, this argument defaults to the - width of the bounding box if the bounding box does not contain inf - values for the provided basis, otherwise (10.0, 10.0). - pixels : int | Sequence[int], optional - If an iterable of ints is provided then this directly sets the - number of pixels to use in each basis direction. If a single int is - provided then this sets the total number of pixels in the plot and - the number of pixels in each basis direction is calculated from this - total and the image aspect ratio based on the width argument. - basis : {'xy', 'yz', 'xz'}, optional - Basis of the plot. - u_span : Sequence[float], optional - Full-width span vector for an oriented slice (3 values). Mutually - exclusive with width. - v_span : Sequence[float], optional - Full-height span vector for an oriented slice (3 values). Mutually - exclusive with width. - show_overlaps : bool, optional - Whether to identify and assign unique IDs (-3) to overlapping - regions. If False, overlapping regions will be assigned the ID of - the lowest-numbered cell that occupies that region. Defaults to - False. - level : int, optional - Universe level to plot (-1 for deepest). Defaults to -1. - filter : openmc.Filter, optional - If provided, the information for each pixel also includes an index - in the filter corresponding to the pixel position. - include_properties : bool, optional - Whether to include temperature/density data. Defaults to True. - **init_kwargs - Keyword arguments passed to :meth:`Model.init_lib`. - - Returns - ------- - geom_data : numpy.ndarray - Shape (v_res, h_res, 3) or (v_res, h_res, 4) int32 array. Contains - [cell_id, cell_instance, material_id] when no filter, or [cell_id, - cell_instance, material_id, filter_bin] with filter. - property_data : numpy.ndarray or None - Shape (v_res, h_res, 2) float64 array with [temperature, density], - or None if include_properties=False. - """ - import openmc.lib - - _check_pixels(pixels) - - if width is not None and (u_span is not None or v_span is not None): - raise ValueError("width is mutually exclusive with u_span/v_span.") - - if u_span is not None or v_span is not None: - if u_span is None or v_span is None: - raise ValueError("Both u_span and v_span must be provided.") - if origin is None: - origin = (0.0, 0.0, 0.0) - if isinstance(pixels, int): - u_norm = np.linalg.norm(u_span) - v_norm = np.linalg.norm(v_span) - aspect_ratio = u_norm / v_norm - pixels_y = math.sqrt(pixels / aspect_ratio) - pixels = (int(pixels / pixels_y), int(pixels_y)) - else: - origin, width, pixels = self._set_plot_defaults( - origin, width, pixels, basis) - - # Silence output by default. Also set arguments to start in volume - # calculation mode to avoid loading cross sections - init_kwargs.setdefault('output', False) - init_kwargs.setdefault('args', ['-c']) - - # If filter does not already appear in the model, temporarily add a - # tally with the filter - original_length = len(self.tallies) - if filter is not None: - filter_ids = {f.id for t in self.tallies for f in t.filters} - if filter.id not in filter_ids: - # Create temporary tally while preserving ID assignment - next_id = openmc.Tally.next_id - temp_tally = openmc.Tally() - temp_tally.filters = [filter] - temp_tally.scores = ['flux'] - self.tallies.append(temp_tally) - openmc.Tally.used_ids.remove(temp_tally.id) - openmc.Tally.next_id = next_id - - with openmc.lib.TemporarySession(self, **init_kwargs): - geom_data, property_data = openmc.lib.slice_data( - origin=origin, - width=width, - basis=basis, - u_span=u_span, - v_span=v_span, - pixels=pixels, - show_overlaps=show_overlaps, - level=level, - filter=filter, - include_properties=include_properties, - ) - - # If filter was temporarily added, remove it - if len(self.tallies) > original_length: - self.tallies.pop() - - return geom_data, property_data - - @add_plot_params - def plot( - self, - origin: Sequence[float] | None = None, - width: Sequence[float] | None = None, - pixels: int | Sequence[int] = 40000, - basis: str = 'xy', - color_by: str = 'cell', - colors: dict | None = None, - seed: int | None = None, - axes=None, - legend: bool = False, - axis_units: str = 'cm', - outline: bool | str = False, - show_overlaps: bool = False, - overlap_color: Sequence[int] | str = (255, 0, 0), - n_samples: int | None = None, - plane_tolerance: float = 1., - legend_kwargs: dict | None = None, - source_kwargs: dict | None = None, - contour_kwargs: dict | None = None, - **kwargs, - ): - """Display a slice plot of the model. - - .. versionadded:: 0.15.1 - """ - import matplotlib.patches as mpatches - import matplotlib.pyplot as plt - - check_type('n_samples', n_samples, int | None) - if n_samples is not None: - check_greater_than('n_samples', n_samples, 0, equality=True) - check_type('plane_tolerance', plane_tolerance, Real) - check_greater_than('plane_tolerance', plane_tolerance, 0.0) - - if legend_kwargs is None: - legend_kwargs = {} - legend_kwargs.setdefault('bbox_to_anchor', (1.05, 1)) - legend_kwargs.setdefault('loc', 2) - legend_kwargs.setdefault('borderaxespad', 0.0) - if source_kwargs is None: - source_kwargs = {} - source_kwargs.setdefault('marker', 'x') - - # Set indices using basis and create axis labels - x, y, z = _BASIS_INDICES[basis] - xlabel, ylabel = f'{basis[0]} [{axis_units}]', f'{basis[1]} [{axis_units}]' - - # Determine extents of plot - origin, width, pixels = self._set_plot_defaults( - origin, width, pixels, basis) - - axis_scaling_factor = {'km': 0.00001, 'm': 0.01, 'cm': 1, 'mm': 10} - - x_min = (origin[x] - 0.5*width[0]) * axis_scaling_factor[axis_units] - x_max = (origin[x] + 0.5*width[0]) * axis_scaling_factor[axis_units] - y_min = (origin[y] - 0.5*width[1]) * axis_scaling_factor[axis_units] - y_max = (origin[y] + 0.5*width[1]) * axis_scaling_factor[axis_units] - - # Determine whether any materials contains macroscopic data and if so, - # set energy mode accordingly and check that mg cross sections path is accessible - for mat in self.geometry.get_all_materials().values(): - if mat._macroscopic is not None: - self.settings.energy_mode = 'multi-group' - if 'mg_cross_sections' not in openmc.config: - raise RuntimeError("'mg_cross_sections' path must be set in " - "openmc.config before plotting.") - break - - # Get plot IDs from the C API - id_map, _ = self.slice_data( - origin=origin, - width=width, - pixels=pixels, - basis=basis, - show_overlaps=show_overlaps, - include_properties=False, - ) - - # Generate colors if not provided - if colors is None and seed is not None: - # Use the colorize method to generate random colors - plot = openmc.SlicePlot() - plot.color_by = color_by - plot.colorize(self.geometry, seed=seed) - colors = plot.colors - - # Convert ID map to RGB image - img = id_map_to_rgb( - id_map=id_map, - color_by=color_by, - colors=colors, - overlap_color=overlap_color - ) - - # Create a figure sized such that the size of the axes within - # exactly matches the number of pixels specified - if axes is None: - px = 1/plt.rcParams['figure.dpi'] - fig, axes = plt.subplots() - axes.set_xlabel(xlabel) - axes.set_ylabel(ylabel) - params = fig.subplotpars - width_px = pixels[0]*px/(params.right - params.left) - height_px = pixels[1]*px/(params.top - params.bottom) - fig.set_size_inches(width_px, height_px) - - if outline: - # Combine R, G, B values into a single int for contour detection - rgb = (img * 256).astype(int) - image_value = (rgb[..., 0] << 16) + \ - (rgb[..., 1] << 8) + (rgb[..., 2]) - - # Set default arguments for contour() - if contour_kwargs is None: - contour_kwargs = {} - contour_kwargs.setdefault('colors', 'k') - contour_kwargs.setdefault('linestyles', 'solid') - contour_kwargs.setdefault('algorithm', 'serial') - - axes.contour( - image_value, - origin="upper", - levels=np.unique(image_value), - extent=(x_min, x_max, y_min, y_max), - **contour_kwargs - ) - - # If only showing outline, set the axis limits and aspect explicitly - if outline == 'only': - axes.set_xlim(x_min, x_max) - axes.set_ylim(y_min, y_max) - axes.set_aspect('equal') - - # Add legend showing which colors represent which material or cell - if legend: - if colors is None or len(colors) == 0: - raise ValueError("Must pass 'colors' dictionary if you " - "are adding a legend via legend=True.") - - if color_by == "cell": - expected_key_type = openmc.Cell - else: - expected_key_type = openmc.Material - - patches = [] - for key, color in colors.items(): - if isinstance(key, int): - raise TypeError( - "Cannot use IDs in colors dict for auto legend.") - elif not isinstance(key, expected_key_type): - raise TypeError( - "Color dict key type does not match color_by") - - # this works whether we're doing cells or materials - label = key.name if key.name != '' else key.id - - # matplotlib takes RGB on 0-1 scale rather than 0-255 - if len(color) == 3 and not isinstance(color, str): - scaled_color = ( - color[0]/255, color[1]/255, color[2]/255) - else: - scaled_color = color - - key_patch = mpatches.Patch(color=scaled_color, label=label) - patches.append(key_patch) - - axes.legend(handles=patches, **legend_kwargs) - - # Plot image and return the axes - if outline != 'only': - axes.imshow(img, extent=(x_min, x_max, y_min, y_max), **kwargs) - - if n_samples: - # Sample external source particles - particles = self.sample_external_source(n_samples) - - # Get points within tolerance of the slice plane - slice_value = origin[z] - xs = [] - ys = [] - tol = plane_tolerance - for particle in particles: - if (slice_value - tol < particle.r[z] < slice_value + tol): - xs.append(particle.r[x] * axis_scaling_factor[axis_units]) - ys.append(particle.r[y] * axis_scaling_factor[axis_units]) - axes.scatter(xs, ys, **source_kwargs) - - return axes - - def sample_external_source( - self, - n_samples: int = 1000, - prn_seed: int | None = None, - as_array: bool = False, - **init_kwargs - ) -> openmc.ParticleList | np.ndarray: - """Sample external source and return source particles. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - n_samples : int - Number of samples - prn_seed : int - Pseudorandom number generator (PRNG) seed; if None, one will be - generated randomly. - as_array : bool - If True, return a numpy structured array instead of a - :class:`~openmc.ParticleList`. - **init_kwargs - Keyword arguments passed to :func:`openmc.lib.init` - - Returns - ------- - openmc.ParticleList or numpy.ndarray - List of sampled source particles, or a structured array when - *as_array* is True. - """ - import openmc.lib - - # Silence output by default. Also set arguments to start in volume - # calculation mode to avoid loading cross sections - init_kwargs.setdefault('output', False) - init_kwargs.setdefault('args', ['-c']) - - with openmc.lib.TemporarySession(self, **init_kwargs): - return openmc.lib.sample_external_source( - n_samples=n_samples, prn_seed=prn_seed, as_array=as_array - ) - - def apply_tally_results(self, statepoint: PathLike | openmc.StatePoint): - """Apply results from a statepoint to tally objects on the Model - - Parameters - ---------- - statepoint : PathLike or openmc.StatePoint - Statepoint file used to update tally results - """ - self.tallies.add_results(statepoint) - - def plot_geometry( - self, - output: bool = True, - cwd: PathLike = ".", - openmc_exec: PathLike = "openmc", - export_model_xml: bool = True, - **export_kwargs, - ): + def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc'): """Creates plot images as specified by the Model.plots attribute .. versionadded:: 0.13.0 @@ -1543,18 +803,12 @@ class Model: ---------- output : bool, optional Capture OpenMC output from standard out - cwd : PathLike, optional + cwd : str, optional Path to working directory to run in. Defaults to the current working directory. - openmc_exec : PathLike, optional + openmc_exec : str, optional Path to OpenMC executable. Defaults to 'openmc'. This only applies to the case when not using the C API. - export_model_xml : bool, optional - Exports a single model.xml file rather than separate files. Defaults - to True. - **export_kwargs - Keyword arguments passed to either :meth:`Model.export_to_model_xml` - or :meth:`Model.export_to_xml`. """ @@ -1568,22 +822,11 @@ class Model: # Compute the volumes openmc.lib.plot_geometry(output) else: - if export_model_xml: - self.export_to_model_xml(**export_kwargs) - else: - self.export_to_xml(**export_kwargs) - path_input = export_kwargs.get("path", None) - openmc.plot_geometry(output=output, openmc_exec=openmc_exec, - path_input=path_input) + self.export_to_xml() + openmc.plot_geometry(output=output, openmc_exec=openmc_exec) - def _change_py_lib_attribs( - self, - names_or_ids: Iterable[str] | Iterable[int], - value: float | Iterable[float], - obj_type: str, - attrib_name: str, - density_units: str = "atom/b-cm", - ): + def _change_py_lib_attribs(self, names_or_ids, value, obj_type, + attrib_name, density_units='atom/b-cm'): # Method to do the same work whether it is a cell or material and # a temperature or volume check_type('names_or_ids', names_or_ids, Iterable, (Integral, str)) @@ -1662,9 +905,7 @@ class Model: else: setattr(lib_obj, attrib_name, value) - def rotate_cells( - self, names_or_ids: Iterable[str] | Iterable[int], vector: Iterable[float] - ): + def rotate_cells(self, names_or_ids, vector): """Rotate the identified cell(s) by the specified rotation vector. The rotation is only applied to cells filled with a universe. @@ -1686,9 +927,7 @@ class Model: self._change_py_lib_attribs(names_or_ids, vector, 'cell', 'rotation') - def translate_cells( - self, names_or_ids: Iterable[str] | Iterable[int], vector: Iterable[float] - ): + def translate_cells(self, names_or_ids, vector): """Translate the identified cell(s) by the specified translation vector. The translation is only applied to cells filled with a universe. @@ -1711,12 +950,7 @@ class Model: self._change_py_lib_attribs(names_or_ids, vector, 'cell', 'translation') - def update_densities( - self, - names_or_ids: Iterable[str] | Iterable[int], - density: float, - density_units: str = "atom/b-cm", - ): + def update_densities(self, names_or_ids, density, density_units='atom/b-cm'): """Update the density of a given set of materials to a new value .. note:: If applying this change to a name that is not unique, then @@ -1739,9 +973,7 @@ class Model: self._change_py_lib_attribs(names_or_ids, density, 'material', 'density', density_units) - def update_cell_temperatures( - self, names_or_ids: Iterable[str] | Iterable[int], temperature: float - ): + def update_cell_temperatures(self, names_or_ids, temperature): """Update the temperature of a set of cells to the given value .. note:: If applying this change to a name that is not unique, then @@ -1762,9 +994,7 @@ class Model: self._change_py_lib_attribs(names_or_ids, temperature, 'cell', 'temperature') - def update_material_volumes( - self, names_or_ids: Iterable[str] | Iterable[int], volume: float - ): + def update_material_volumes(self, names_or_ids, volume): """Update the volume of a set of materials to the given value .. note:: If applying this change to a name that is not unique, then @@ -1784,1401 +1014,53 @@ class Model: self._change_py_lib_attribs(names_or_ids, volume, 'material', 'volume') - def differentiate_depletable_mats(self, diff_volume_method: str = None): + def differentiate_depletable_mats(self, diff_volume_method: str): """Assign distribmats for each depletable material .. versionadded:: 0.14.0 - .. versionchanged:: 0.15.1 - diff_volume_method default is None, do not set volumes on the new - material ovjects. Is now a convenience method for - differentiate_mats(diff_volume_method, depletable_only=True) - Parameters ---------- diff_volume_method : str Specifies how the volumes of the new materials should be found. - - None: Do not assign volumes to the new materials (Default) - - 'divide equally': Divide the original material volume equally between the new materials - - 'match cell': Set the volume of the material to the volume of the cell they fill + Default is to 'divide equally' which divides the original material + volume equally between the new materials, 'match cell' sets the + volume of the material to volume of the cell they fill. """ - self.differentiate_mats(diff_volume_method, depletable_only=True) - - def differentiate_mats(self, diff_volume_method: str = None, depletable_only: bool = True): - """Assign distribmats for each material - - .. versionadded:: 0.15.1 - - Parameters - ---------- - diff_volume_method : str - Specifies how the volumes of the new materials should be found. - - None: Do not assign volumes to the new materials (Default) - - 'divide equally': Divide the original material volume equally between the new materials - - 'match cell': Set the volume of the material to the volume of the cell they fill - depletable_only : bool - Default is True, only depletable materials will be differentiated. If False, all materials will be - differentiated. - """ - check_value('volume differentiation method', diff_volume_method, ("divide equally", "match cell", None)) - # Count the number of instances for each cell and material self.geometry.determine_paths(instances_only=True) - # Get list of materials - if self.materials: - materials = self.materials - else: - materials = list(self.geometry.get_all_materials().values()) + # Extract all depletable materials which have multiple instances + distribmats = set( + [mat for mat in self.materials + if mat.depletable and mat.num_instances > 1]) - # Find all or depletable_only materials which have multiple instance - distribmats = set() - for mat in materials: - # Differentiate all materials with multiple instances - diff_mat = mat.num_instances > 1 - # If depletable_only is True, differentiate only depletable materials - if depletable_only: - diff_mat = diff_mat and mat.depletable - if diff_mat: - # Assign volumes to the materials according to requirements - if diff_volume_method == "divide equally": - if mat.volume is None: - raise RuntimeError( - "Volume not specified for " - f"material with ID={mat.id}.") - else: - mat.volume /= mat.num_instances - elif diff_volume_method == "match cell": - for cell in self.geometry.get_all_material_cells().values(): - if cell.fill == mat: + if diff_volume_method == 'divide equally': + for mat in distribmats: + if mat.volume is None: + raise RuntimeError("Volume not specified for depletable " + f"material with ID={mat.id}.") + mat.volume /= mat.num_instances + + if distribmats: + # Assign distribmats to cells + for cell in self.geometry.get_all_material_cells().values(): + if cell.fill in distribmats: + mat = cell.fill + if diff_volume_method == 'divide equally': + cell.fill = [mat.clone() for _ in range(cell.num_instances)] + elif diff_volume_method == 'match cell': + for _ in range(cell.num_instances): + cell.fill = mat.clone() if not cell.volume: raise ValueError( f"Volume of cell ID={cell.id} not specified. " "Set volumes of cells prior to using " - "diff_volume_method='match cell'.") - distribmats.add(mat) - - if not distribmats: - return - - # Assign distribmats to cells - for cell in self.geometry.get_all_material_cells().values(): - if cell.fill in distribmats: - mat = cell.fill - - # Clone materials - if cell.num_instances > 1: - cell.fill = [mat.clone() for _ in range(cell.num_instances)] - else: - cell.fill = mat.clone() - - # For 'match cell', assign volumes based on the cells - if diff_volume_method == 'match cell': - if cell.fill_type == 'distribmat': - for clone_mat in cell.fill: - clone_mat.volume = cell.volume - else: - cell.fill.volume = cell.volume + "diff_volume_method='match cell'." + ) + cell.fill.volume = cell.volume if self.materials is not None: self.materials = openmc.Materials( self.geometry.get_all_materials().values() ) - - @staticmethod - def _auto_generate_mgxs_lib( - model: openmc.model.Model, - groups: openmc.mgxs.EnergyGroups, - correction: str | None, - directory: PathLike, - ) -> openmc.mgxs.Library: - """ - Automatically generate a multi-group cross section libray from a model - with the specified group structure. - - Parameters - ---------- - model : openmc.Model - The model to generate the MGXS library from. - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : str - Directory to run the simulation in, so as to contain XML files. - - Returns - ------- - mgxs_lib : openmc.mgxs.Library - OpenMC MGXS Library object - """ - - # Initialize MGXS library with a finished OpenMC geometry object - mgxs_lib = openmc.mgxs.Library(model.geometry) - - # Pick energy group structure - mgxs_lib.energy_groups = groups - - # Disable transport correction - mgxs_lib.correction = correction - - # Specify needed cross sections for random ray - if correction == 'P0': - mgxs_lib.mgxs_types = [ - 'nu-transport', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', - 'kappa-fission' - ] - elif correction is None: - mgxs_lib.mgxs_types = [ - 'total', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', - 'kappa-fission' - ] - - # Specify a "material" domain type for the cross section tally filters - mgxs_lib.domain_type = "material" - - # Specify the domains over which to compute multi-group cross sections - mgxs_lib.domains = model.geometry.get_all_materials().values() - - # Do not compute cross sections on a nuclide-by-nuclide basis - mgxs_lib.by_nuclide = False - - # Check the library - if no errors are raised, then the library is satisfactory. - mgxs_lib.check_library_for_openmc_mgxs() - - # Construct all tallies needed for the multi-group cross section library - mgxs_lib.build_library() - - # Create a "tallies.xml" file for the MGXS Library - mgxs_lib.add_to_tallies(model.tallies, merge=True) - - # Run - statepoint_filename = model.run(cwd=directory) - - # Load MGXS - with openmc.StatePoint(statepoint_filename) as sp: - mgxs_lib.load_from_statepoint(sp) - - return mgxs_lib - - def _create_mgxs_sources( - self, - groups: openmc.mgxs.EnergyGroups, - spatial_dist: openmc.stats.Spatial, - source_energy: openmc.stats.Univariate | None = None, - ) -> list[openmc.IndependentSource]: - """Create a list of independent sources to use with MGXS generation. - - Note that in all cases, a discrete source that is uniform over all - energy groups is created (strength = 0.01) to ensure that total cross - sections are generated for all energy groups. In the case that the user - has provided a source_energy distribution as an argument, an additional - source (strength = 0.99) is created using that energy distribution. If - the user has not provided a source_energy distribution, but the model - has sources defined, and all of those sources are of IndependentSource - type, then additional sources are created based on the model's existing - sources, keeping their energy distributions but replacing their - spatial/angular distributions, with their combined strength being 0.99. - If the user has not provided a source_energy distribution and no sources - are defined on the model and the run mode is 'eigenvalue', then a - default Watt spectrum source (strength = 0.99) is added. - - Parameters - ---------- - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - spatial_dist : openmc.stats.Spatial - Spatial distribution to use for all sources. - source_energy : openmc.stats.Univariate, optional - Energy distribution to use when generating MGXS data, replacing any - existing sources in the model. - - Returns - ------- - list[openmc.IndependentSource] - A list of independent sources to use for MGXS generation. - """ - # Make a discrete source that is uniform over the bins of the group structure - midpoints = [] - strengths = [] - for i in range(groups.num_groups): - bounds = groups.get_group_bounds(i+1) - midpoints.append((bounds[0] + bounds[1]) / 2.0) - strengths.append(1.0) - - uniform_energy = openmc.stats.Discrete(x=midpoints, p=strengths) - uniform_distribution = openmc.IndependentSource(spatial_dist, energy=uniform_energy, strength=0.01) - sources = [uniform_distribution] - - # If the user provided an energy distribution, use that - if source_energy is not None: - user_energy = openmc.IndependentSource( - space=spatial_dist, energy=source_energy, strength=0.99) - sources.append(user_energy) - - # If the user did not provide an energy distribution, create sources - # based on what is in their model, keeping the energy spectrum but - # replacing the spatial/angular distributions. We only do this if ALL - # sources are of IndependentSource type, as we can't pull the energy - # distribution from e.g. CompiledSource or FileSource types. - else: - if self.settings.source is not None: - for src in self.settings.source: - if not isinstance(src, openmc.IndependentSource): - break - else: - n_user_sources = len(self.settings.source) - for src in self.settings.source: - # Create a new IndependentSource with adjusted strength, space, and angle - user_source = openmc.IndependentSource( - space=spatial_dist, - energy=src.energy, - strength=0.99 / n_user_sources - ) - sources.append(user_source) - else: - # No user sources defined. If we are in eigenvalue mode, then use the default Watt spectrum. - if self.settings.run_mode == 'eigenvalue': - watt_energy = openmc.stats.Watt() - watt_source = openmc.IndependentSource( - space=spatial_dist, energy=watt_energy, strength=0.99) - sources.append(watt_source) - - return sources - - @staticmethod - def _isothermal_infinite_media_mgxs( - material: openmc.Material, - groups: openmc.mgxs.EnergyGroups, - settings: openmc.Settings, - correction: str | None, - directory: PathLike, - source: openmc.IndependentSource, - temperature: float | None = None, - ) -> openmc.XSdata: - """Generate a single MGXS set for one material, where the geometry is an - infinite medium composed of that material at an isothermal temperature value. - - Parameters - ---------- - material : openmc.Material - The material to generate MGXS for - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - settings : openmc.Settings - Settings for the generation run, used verbatim except for the - fields owned by the infinite medium method. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : str - Directory to run the simulation in, so as to contain XML files. - source : openmc.IndependentSource - Source to use when generating MGXS. - temperature : float, optional - The isothermal temperature value to apply to the material. If not specified, - defaults to the temperature in the material. - - Returns - ------- - data : openmc.XSdata - The material MGXS for the given temperature isotherm. - """ - model = openmc.Model() - - # Set materials on the model - model.materials = [material] - if temperature is not None: - model.materials[-1].temperature = temperature - - # The provided settings are used verbatim, except for the fields - # owned by the infinite medium method - model.settings = copy.deepcopy(settings) - model.settings.source = source - - # Geometry - box = openmc.model.RectangularPrism( - 100000.0, 100000.0, boundary_type='reflective') - name = material.name - infinite_cell = openmc.Cell(name=name, fill=model.materials[-1], region=-box) - infinite_universe = openmc.Universe(name=name, cells=[infinite_cell]) - model.geometry.root_universe = infinite_universe - - # Generate MGXS - mgxs_lib = Model._auto_generate_mgxs_lib( - model, groups, correction, directory) - - if temperature is not None: - return mgxs_lib.get_xsdata(domain=material, xsdata_name=name, - temperature=temperature) - else: - return mgxs_lib.get_xsdata(domain=material, xsdata_name=name) - - def _generate_infinite_medium_mgxs( - self, - groups: openmc.mgxs.EnergyGroups, - settings: openmc.Settings, - mgxs_path: PathLike, - correction: str | None, - directory: PathLike, - source_energy: openmc.stats.Univariate | None = None, - temperatures: Sequence[float] | None = None, - ) -> None: - """Generate a MGXS library by running multiple OpenMC simulations, each - representing an infinite medium simulation of a single isolated - material. A discrete source is used to sample particles, with an equal - strength spread across each of the energy groups. This is a highly naive - method that ignores all spatial self shielding effects and all resonance - shielding effects between materials. If temperature data points are provided, - isothermal cross sections are generated at each temperature point for - each material to build a temperature interpolation table. - - Note that in all cases, a discrete source that is uniform over all - energy groups is created (strength = 0.01) to ensure that total cross - sections are generated for all energy groups. In the case that the user - has provided a source_energy distribution as an argument, an additional - source (strength = 0.99) is created using that energy distribution. If - the user has not provided a source_energy distribution, but the model - has sources defined, and all of those sources are of IndependentSource - type, then additional sources are created based on the model's existing - sources, keeping their energy distributions but replacing their - spatial/angular distributions, with their combined strength being 0.99. - If the user has not provided a source_energy distribution and no sources - are defined on the model and the run mode is 'eigenvalue', then a - default Watt spectrum source (strength = 0.99) is added. - - Parameters - ---------- - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - settings : openmc.Settings - Settings for the generation run(s), used verbatim except for the - fields owned by the infinite medium method. - mgxs_path : str - Filename for the MGXS HDF5 file. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : str - Directory to run the simulation in, so as to contain XML files. - source_energy : openmc.stats.Univariate, optional - Energy distribution to use when generating MGXS data, replacing any - existing sources in the model. - temperatures : Sequence[float], optional - A list of temperatures to generate MGXS at. Each infinite material region - is isothermal at a given temperature data point for cross - section generation. - """ - - src = self._create_mgxs_sources( - groups, - spatial_dist=openmc.stats.Point(), - source_energy=source_energy - ) - - if temperatures is None: - mgxs_sets = [] - for material in self.materials: - xs_data = Model._isothermal_infinite_media_mgxs( - material, - groups, - settings, - correction, - directory, - src - ) - mgxs_sets.append(xs_data) - - # Write the file to disk. - mgxs_file = openmc.MGXSLibrary(energy_groups=groups) - for mgxs_set in mgxs_sets: - mgxs_file.add_xsdata(mgxs_set) - mgxs_file.export_to_hdf5(mgxs_path) - else: - # Build a series of XSData objects, one for each isothermal temperature value. - raw_mgxs_sets = {} - for temperature in temperatures: - raw_mgxs_sets[temperature] = [] - for material in self.materials: - xs_data = Model._isothermal_infinite_media_mgxs( - material, - groups, - settings, - correction, - directory, - src, - temperature - ) - raw_mgxs_sets[temperature].append(xs_data) - - # Unpack the isothermal XSData objects and build a single XSData object per material. - mgxs_sets = [] - for m in range(len(self.materials)): - mgxs_sets.append(openmc.XSdata(self.materials[m].name, groups, - temperatures=temperatures)) - mgxs_sets[-1].order = 0 - for temperature in temperatures: - mgxs_sets[-1].add_temperature_data(raw_mgxs_sets[temperature][m]) - - # Write the file to disk. - mgxs_file = openmc.MGXSLibrary(energy_groups=groups) - for mgxs_set in mgxs_sets: - mgxs_file.add_xsdata(mgxs_set) - mgxs_file.export_to_hdf5(mgxs_path) - - @staticmethod - def _create_stochastic_slab_geometry( - materials: Sequence[openmc.Material], - cell_thickness: float = 1.0, - num_repeats: int = 100, - ) -> tuple[openmc.Geometry, openmc.stats.Box]: - """Create a geometry representing a stochastic "sandwich" of materials in a - layered slab geometry. To reduce the impact of the order of materials in - the slab, the materials are applied to 'num_repeats' different randomly - positioned layers of 'cell_thickness' each. - - Parameters - ---------- - materials : list of openmc.Material - List of materials to assign. Each material will appear exactly num_repeats times, - then the ordering is randomly shuffled. - cell_thickness : float, optional - Thickness of each lattice cell in x (default 1.0 cm). - num_repeats : int, optional - Number of repeats for each material (default 100). - - Returns - ------- - geometry : openmc.Geometry - The constructed geometry. - box : openmc.stats.Box - A spatial sampling distribution covering the full slab domain. - """ - if not materials: - raise ValueError("At least one material must be provided.") - - num_materials = len(materials) - total_cells = num_materials * num_repeats - total_width = total_cells * cell_thickness - - # Generate an infinite cell/universe for each material - universes = [] - for i in range(num_materials): - cell = openmc.Cell(fill=materials[i]) - universes.append(openmc.Universe(cells=[cell])) - - # Make a list of randomized material idx assignments for the stochastic slab - assignments = list(range(num_materials)) * num_repeats - random.seed(42) - random.shuffle(assignments) - - # Create a list of the (randomized) universe assignments to be used - # when defining the problem lattice. - lattice_entries = [universes[m] for m in assignments] - - # Create the RectLattice for the 1D material variation in x. - lattice = openmc.RectLattice() - lattice.pitch = (cell_thickness, total_width, total_width) - lattice.lower_left = (0.0, 0.0, 0.0) - lattice.universes = [[lattice_entries]] - lattice.outer = universes[0] - - # Define the six outer surfaces with reflective boundary conditions - rpp = openmc.model.RectangularParallelepiped( - 0.0, total_width, 0.0, total_width, 0.0, total_width, - boundary_type='reflective' - ) - - # Create an outer cell that fills with the lattice. - outer_cell = openmc.Cell(fill=lattice, region=-rpp) - - # Build the geometry - geometry = openmc.Geometry([outer_cell]) - - # Define the spatial distribution that covers the full cubic domain - box = openmc.stats.Box(*outer_cell.bounding_box) - - return geometry, box - - @staticmethod - def _isothermal_stochastic_slab_mgxs( - stoch_geom: openmc.Geometry, - groups: openmc.mgxs.EnergyGroups, - settings: openmc.Settings, - correction: str | None, - directory: PathLike, - source: openmc.IndependentSource, - temperature: float | None = None, - ) -> dict[str, openmc.XSdata]: - """Generate MGXS assuming a stochastic "sandwich" of materials in a layered - slab geometry. If a temperature is specified, all materials in the slab have - their temperatures set to be isothermal at this temperature. - - Parameters - ---------- - stoch_geom : openmc.Geometry - The stochastic slab geometry. - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - settings : openmc.Settings - Settings for the generation run, used verbatim except for the - fields owned by the stochastic slab method. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : str - Directory to run the simulation in, so as to contain XML files. - source : openmc.IndependentSource - Source to use when generating MGXS. - temperature : float, optional - The isothermal temperature value to apply to the materials in the - slab. If not specified, defaults to the temperature in the materials. - - Returns - ------- - data : dict[str, openmc.XSdata] - A dictionary where the key is the name of the material and the value is the isothermal MGXS. - """ - - model = openmc.Model() - model.geometry = stoch_geom - - if temperature is not None: - for material in model.geometry.get_all_materials().values(): - material.temperature = temperature - - # The provided settings are used verbatim, except for the fields - # owned by the stochastic slab method - model.settings = copy.deepcopy(settings) - model.settings.source = source - - # Generate MGXS - mgxs_lib = Model._auto_generate_mgxs_lib( - model, groups, correction, directory) - - # Fetch all of the isothermal results. - if temperature is not None: - return { - mat.name : mgxs_lib.get_xsdata(domain=mat, xsdata_name=mat.name, - temperature=temperature) - for mat in mgxs_lib.domains - } - else: - return { - mat.name : mgxs_lib.get_xsdata(domain=mat, xsdata_name=mat.name) - for mat in mgxs_lib.domains - } - - def _generate_stochastic_slab_mgxs( - self, - groups: openmc.mgxs.EnergyGroups, - settings: openmc.Settings, - mgxs_path: PathLike, - correction: str | None, - directory: PathLike, - source_energy: openmc.stats.Univariate | None = None, - temperatures: Sequence[float] | None = None, - ) -> None: - """Generate MGXS assuming a stochastic "sandwich" of materials in a layered - slab geometry. While geometry-specific spatial shielding effects are not - captured, this method can be useful when the geometry has materials only - found far from the source region that the "material_wise" method would - not be capable of generating cross sections for. Conversely, this method - will generate cross sections for all materials in the problem regardless - of type. If this is a fixed source problem, a discrete source is used to - sample particles, with an equal strength spread across each of the - energy groups. If temperature data points are provided, - isothermal cross sections are generated at each temperature point for - the stochastic slab to build a temperature interpolation table. - - Parameters - ---------- - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - settings : openmc.Settings - Settings for the generation run(s), used verbatim except for the - fields owned by the stochastic slab method. - mgxs_path : str - Filename for the MGXS HDF5 file. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : str - Directory to run the simulation in, so as to contain XML files. - source_energy : openmc.stats.Univariate, optional - Energy distribution to use when generating MGXS data, replacing any - existing sources in the model. In all cases, a discrete source that - is uniform over all energy groups is created (strength = 0.01) to - ensure that total cross sections are generated for all energy - groups. In the case that the user has provided a source_energy - distribution as an argument, an additional source (strength = 0.99) - is created using that energy distribution. If the user has not - provided a source_energy distribution, but the model has sources - defined, and all of those sources are of IndependentSource type, - then additional sources are created based on the model's existing - sources, keeping their energy distributions but replacing their - spatial/angular distributions, with their combined strength being - 0.99. If the user has not provided a source_energy distribution and - no sources are defined on the model and the run mode is - 'eigenvalue', then a default Watt spectrum source (strength = 0.99) - is added. - temperatures : Sequence[float], optional - A list of temperatures to generate MGXS at. Each infinite material region - is isothermal at a given temperature data point for cross - section generation. - """ - - # Stochastic slab geometry - geo, spatial_distribution = Model._create_stochastic_slab_geometry( - self.materials) - - src = self._create_mgxs_sources( - groups, - spatial_dist=spatial_distribution, - source_energy=source_energy - ) - - if temperatures is None: - mgxs_sets = Model._isothermal_stochastic_slab_mgxs( - geo, - groups, - settings, - correction, - directory, - src - ).values() - - # Write the file to disk. - mgxs_file = openmc.MGXSLibrary(energy_groups=groups) - for mgxs_set in mgxs_sets: - mgxs_file.add_xsdata(mgxs_set) - mgxs_file.export_to_hdf5(mgxs_path) - else: - # Build a series of XSData objects, one for each isothermal temperature value. - raw_mgxs_sets = {} - for temperature in temperatures: - raw_mgxs_sets[temperature] = Model._isothermal_stochastic_slab_mgxs( - geo, - groups, - settings, - correction, - directory, - src, - temperature - ) - - # Unpack the isothermal XSData objects and build a single XSData object per material. - mgxs_sets = [] - for mat in self.materials: - mgxs_sets.append(openmc.XSdata(mat.name, groups, temperatures=temperatures)) - mgxs_sets[-1].order = 0 - for temperature in temperatures: - mgxs_sets[-1].add_temperature_data(raw_mgxs_sets[temperature][mat.name]) - - # Write the file to disk. - mgxs_file = openmc.MGXSLibrary(energy_groups=groups) - for mgxs_set in mgxs_sets: - mgxs_file.add_xsdata(mgxs_set) - mgxs_file.export_to_hdf5(mgxs_path) - - @staticmethod - def _isothermal_materialwise_mgxs( - input_model: openmc.Model, - groups: openmc.mgxs.EnergyGroups, - settings: openmc.Settings, - correction: str | None, - directory: PathLike, - temperature: float | None = None, - ) -> dict[str, openmc.XSdata]: - """Generate a material-wise MGXS library for the model by running the - original continuous energy OpenMC simulation. If a temperature is - specified, each material in the input model is set to that temperature. - Otherwise, the original material temperatures are used. If temperature - data points are provided, isothermal cross sections are generated at - each temperature point for the whole model to build a temperature - interpolation table. - - Parameters - ---------- - input_model : openmc.Model - The model to use when computing material-wise MGXS. - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - settings : openmc.Settings - Settings for the generation run, used verbatim. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : str - Directory to run the simulation in, so as to contain XML files. - temperature : float, optional - The isothermal temperature value to apply to the materials in the - input model. If not specified, defaults to the temperatures in the - materials. - - Returns - ------- - data : dict[str, openmc.XSdata] - A dictionary where the key is the name of the material and the value is the isothermal MGXS. - """ - model = copy.deepcopy(input_model) - model.tallies = openmc.Tallies() - - if temperature is not None: - for material in model.geometry.get_all_materials().values(): - material.temperature = temperature - - # The provided settings are used verbatim - model.settings = copy.deepcopy(settings) - - # Generate MGXS - mgxs_lib = Model._auto_generate_mgxs_lib( - model, groups, correction, directory) - - # Fetch all of the isothermal results. - if temperature is not None: - return { - mat.name : mgxs_lib.get_xsdata(domain=mat, xsdata_name=mat.name, - temperature=temperature) - for mat in mgxs_lib.domains - } - else: - return { - mat.name : mgxs_lib.get_xsdata(domain=mat, xsdata_name=mat.name) - for mat in mgxs_lib.domains - } - - def _generate_material_wise_mgxs( - self, - groups: openmc.mgxs.EnergyGroups, - settings: openmc.Settings, - mgxs_path: PathLike, - correction: str | None, - directory: PathLike, - temperatures: Sequence[float] | None = None, - ) -> None: - """Generate a material-wise MGXS library for the model by running the - original continuous energy OpenMC simulation of the full material - geometry and source, and tally MGXS data for each material. This method - accurately conserves reaction rates totaled over the entire simulation - domain. However, when the geometry has materials only found far from the - source region, it is possible the Monte Carlo solver may not be able to - score any tallies to these material types, thus resulting in zero cross - section values for these materials. For such cases, the "stochastic - slab" method may be more appropriate. - - Parameters - ---------- - groups : openmc.mgxs.EnergyGroups - Energy group structure for the MGXS. - settings : openmc.Settings - Settings for the generation run(s), used verbatim. - mgxs_path : PathLike - Filename for the MGXS HDF5 file. - correction : str - Transport correction to apply to the MGXS. Options are None and - "P0". - directory : PathLike - Directory to run the simulation in, so as to contain XML files. - temperatures : Sequence[float], optional - A list of temperatures to generate MGXS at. Each infinite material region - is isothermal at a given temperature data point for cross - section generation. - """ - if temperatures is None: - mgxs_sets = Model._isothermal_materialwise_mgxs( - self, groups, settings, correction, directory).values() - - # Write the file to disk. - mgxs_file = openmc.MGXSLibrary(energy_groups=groups) - for mgxs_set in mgxs_sets: - mgxs_file.add_xsdata(mgxs_set) - mgxs_file.export_to_hdf5(mgxs_path) - else: - # Build a series of XSData objects, one for each isothermal temperature value. - raw_mgxs_sets = {} - for temperature in temperatures: - raw_mgxs_sets[temperature] = Model._isothermal_materialwise_mgxs( - self, groups, settings, correction, directory, temperature) - - # Unpack the isothermal XSData objects and build a single XSData object per material. - mgxs_sets = [] - for mat in self.materials: - mgxs_sets.append(openmc.XSdata(mat.name, groups, temperatures=temperatures)) - mgxs_sets[-1].order = 0 - for temperature in temperatures: - mgxs_sets[-1].add_temperature_data(raw_mgxs_sets[temperature][mat.name]) - - # Write the file to disk. - mgxs_file = openmc.MGXSLibrary(energy_groups=groups) - for mgxs_set in mgxs_sets: - mgxs_file.add_xsdata(mgxs_set) - mgxs_file.export_to_hdf5(mgxs_path) - - def convert_to_multigroup( - self, - method: str = "material_wise", - groups: str | Sequence[float] | openmc.mgxs.EnergyGroups = "CASMO-2", - nparticles: int | None = None, - overwrite_mgxs_library: bool = False, - mgxs_path: PathLike = "mgxs.h5", - correction: str | None = None, - source_energy: openmc.stats.Univariate | None = None, - temperatures: Sequence[float] | None = None, - temperature_settings: dict | None = None, - **kwargs, - ): - """Convert all materials from continuous energy to multigroup. - - If no MGXS data library file is found, generate one using one or more - continuous energy Monte Carlo simulations. - - Parameters - ---------- - method : {"material_wise", "stochastic_slab", "infinite_medium"}, optional - Method to generate the MGXS. - groups : openmc.mgxs.EnergyGroups, str, or sequence of float, optional - Energy group structure for the MGXS. Can be an - :class:`openmc.mgxs.EnergyGroups` object, a string name of a - predefined group structure from :data:`openmc.mgxs.GROUP_STRUCTURES` - (e.g., ``"CASMO-2"``), or a sequence of floats specifying energy - bin boundaries in eV (e.g., ``[0.0, 1e6]`` for a single group). - Defaults to ``"CASMO-2"``. - nparticles : int, optional - Number of particles to simulate per batch when generating MGXS. - Defaults to 2000. - - .. deprecated:: 0.15.4 - Pass ``particles`` as a keyword argument instead. - overwrite_mgxs_library : bool, optional - Whether to overwrite an existing MGXS library file. - mgxs_path : str, optional - Path to the mgxs.h5 library file. - correction : str, optional - Transport correction to apply to the MGXS. Options are None and - "P0". - source_energy : openmc.stats.Univariate, optional - Energy distribution to use when generating MGXS data, replacing any - existing sources in the model. In all cases, a discrete source that - is uniform over all energy groups is created (strength = 0.01) to - ensure that total cross sections are generated for all energy - groups. In the case that the user has provided a source_energy - distribution as an argument, an additional source (strength = 0.99) - is created using that energy distribution. If the user has not - provided a source_energy distribution, but the model has sources - defined, and all of those sources are of IndependentSource type, - then additional sources are created based on the model's existing - sources, keeping their energy distributions but replacing their - spatial/angular distributions, with their combined strength being - 0.99. If the user has not provided a source_energy distribution and - no sources are defined on the model and the run mode is - 'eigenvalue', then a default Watt spectrum source (strength = 0.99) - is added. Note that this argument is only used when using the - "stochastic_slab" or "infinite_medium" MGXS generation methods. - temperatures : Sequence[float], optional - A list of temperatures to generate MGXS at. Each infinite material region - is isothermal at a given temperature data point for cross - section generation. - temperature_settings : dict, optional - A dictionary of temperature settings to use when generating MGXS. - Valid entries for temperature_settings are the same as the valid - entries in openmc.Settings.temperature_settings. - - .. deprecated:: 0.15.4 - Pass ``temperature`` as a keyword argument instead. - **kwargs - :class:`openmc.Settings` attributes used to customize the continuous - energy simulation(s) that generate the MGXS library. Only the - attributes given override the generation defaults. For example, - ``model.convert_to_multigroup(particles=100_000)`` adjusts only the - particle count. The run mode cannot be overridden, as it is - determined by the generation method. The surrogate-geometry methods - also construct their own sources and always disable - ``create_fission_neutrons`` so that fission is treated as capture. - A ``weight_windows_file`` is applied during ``"material_wise"`` - generation and ignored with a warning by the other methods; see the - user guide for the weight window "bootstrapping" workflow this - enables. Cannot be combined with the deprecated ``nparticles`` or - ``temperature_settings`` arguments. - - .. versionadded:: 0.15.4 - """ - if not isinstance(groups, openmc.mgxs.EnergyGroups): - groups = openmc.mgxs.EnergyGroups(groups) - - check_value('method', method, - ('material_wise', 'stochastic_slab', 'infinite_medium')) - - # Keyword arguments are Settings attributes applied as overrides on - # the generation defaults - settings = openmc.Settings(**kwargs) if kwargs else None - - # The model may reference its materials only through the geometry. - # The materials are converted in place and library-wide attributes - # like cross_sections must persist on the model afterwards, so - # populate the explicit collection if it is empty (sorted by ID for - # reproducibility, since geometry traversal order is arbitrary) - if not self.materials: - self.materials = openmc.Materials(sorted( - self.geometry.get_all_materials().values(), - key=lambda mat: mat.id)) - - if nparticles is not None or temperature_settings is not None: - warnings.warn( - 'The "nparticles" and "temperature_settings" arguments are ' - 'deprecated. Pass "particles" and "temperature" as keyword ' - 'arguments instead.', FutureWarning) - if settings is not None: - raise ValueError( - 'The deprecated "nparticles" and "temperature_settings" ' - 'arguments cannot be combined with Settings keyword ' - 'arguments.') - - # Resolve the settings for the MGXS generation run(s) in three layers, - # with later layers taking precedence: the model's own settings - # ("material_wise") or a fresh Settings object (surrogate methods), then - # the generation defaults, then the user's keyword-argument overrides. - user_settings = settings - if method == 'material_wise': - settings = copy.deepcopy(self.settings) - else: - settings = openmc.Settings() - settings.temperature = copy.deepcopy(self.settings.temperature) - - settings.batches = 100 if method == 'infinite_medium' else 200 - if method != 'infinite_medium': - settings.inactive = 100 - settings.particles = 2000 - settings.output = {'summary': True, 'tallies': False} - if nparticles is not None: - settings.particles = nparticles - if temperature_settings is not None: - settings.temperature = temperature_settings - - if user_settings is not None: - # The surrogate-geometry methods construct their own sources - if method != "material_wise" and len(user_settings.source) > 0: - warnings.warn( - 'The given "source" setting is ignored by the ' - f'"{method}" MGXS generation method, which constructs ' - 'its own sources.') - # Apply the settings attributes passed by the caller - for name in kwargs: - if hasattr(type(settings), name): - setattr(settings, name, copy.deepcopy( - getattr(user_settings, name))) - - # The run mode is the one attribute that cannot be detected as - # user-populated (a fresh Settings object defaults it to 'eigenvalue'), - # so it is owned by the generation method: "material_wise" always takes - # it from the model, while the surrogate-geometry methods always run in - # fixed source mode. The surrogate-geometry methods also treat fission - # as capture (nu-fission is still tallied) - if method == 'material_wise': - settings.run_mode = self.settings.run_mode - else: - settings.run_mode = 'fixed source' - settings.create_fission_neutrons = False - - # A weight windows file on the generation settings is loaded and - # applied (specifying a file turns weight windows on) during the - # "material_wise" method's continuous energy simulation of the - # original geometry, allowing materials far from the source -- - # which an analog simulation may struggle to reach -- to still be - # tallied, and thus obtain nonzero cross sections. The - # "stochastic_slab" and "infinite_medium" methods use simplified - # surrogate geometries for which weight windows defined over the - # original geometry are neither applicable nor needed. - if settings.weight_windows_file is not None and \ - method != "material_wise": - warnings.warn( - 'The "weight_windows_file" setting is only applicable to ' - 'the "material_wise" MGXS generation method and will be ' - f'ignored for the "{method}" method.' - ) - settings.weight_windows_file = None - - # Do all work (including MGXS generation) in a temporary directory - # to avoid polluting the working directory with residual XML files - with TemporaryDirectory() as tmpdir: - - # Determine if there are DAGMC universes in the model. If so, we need to synchronize - # the dagmc materials with cells. - # TODO: Can this be done without having to init/finalize? - for univ in self.geometry.get_all_universes().values(): - if isinstance(univ, openmc.DAGMCUniverse): - # Initialize in stochastic volume mode (non-transport mode) - # This mode doesn't require - # valid transport settings like particles/batches - original_run_mode = self.settings.run_mode - self.settings.run_mode = 'volume' - self.init_lib(directory=tmpdir) - self.sync_dagmc_universes() - self.finalize_lib() - # Restore original run mode - self.settings.run_mode = original_run_mode - break - - # Temporarily replace each material's name with a unique, valid HDF5 - # dataset name (its name plus ID) for use as its MGXS library entry - # and macroscopic. The ID keeps the name unique even when materials - # share a name; the original names are restored at the end. - original_names = [material.name for material in self.materials] - for material in self.materials: - base = material.name if material.name and material.name.strip() \ - else "material" - material.name = re.sub(r'[^a-zA-Z0-9]', '_', base) + f"_{material.id}" - - # If needed, generate the needed MGXS data library file - if not Path(mgxs_path).is_file() or overwrite_mgxs_library: - if method == "infinite_medium": - self._generate_infinite_medium_mgxs( - groups, settings, mgxs_path, correction, tmpdir, - source_energy, temperatures) - elif method == "material_wise": - self._generate_material_wise_mgxs( - groups, settings, mgxs_path, correction, tmpdir, - temperatures) - elif method == "stochastic_slab": - self._generate_stochastic_slab_mgxs( - groups, settings, mgxs_path, correction, tmpdir, - source_energy, temperatures) - else: - raise ValueError( - f'MGXS generation method "{method}" not recognized') - else: - print(f'Existing MGXS library file "{mgxs_path}" will be used') - - # Convert all continuous energy materials to multigroup - self.materials.cross_sections = mgxs_path - for material in self.materials: - material.set_density('macro', 1.0) - material._nuclides = [] - material._sab = [] - material.add_macroscopic(material.name) - - self.settings.energy_mode = 'multi-group' - - # Restore the user's original material names. - for material, name in zip(self.materials, original_names): - material.name = name - - def convert_to_random_ray(self): - """Convert a multigroup model to use random ray. - - This method determines values for the needed settings and adds them to - the settings.random_ray dictionary so as to enable random ray mode. The - settings that are populated are: - - - 'ray_source' (openmc.IndependentSource): Where random ray starting - points are sampled from. - - 'distance_inactive' (float): The "dead zone" distance at the beginning - of the ray. - - 'distance_active' (float): The "active" distance of the ray - - 'particles' (int): Number of rays to simulate - - The method will determine reasonable defaults for each of the above - variables based on analysis of the model's geometry. The function will - have no effect if the random ray dictionary is already defined in the - model settings. - """ - # If the random ray dictionary is already set, don't overwrite it - if self.settings.random_ray: - warnings.warn("Random ray conversion skipped as " - "settings.random_ray dictionary is already set.") - return - - if self.settings.energy_mode != 'multi-group': - raise ValueError( - "Random ray conversion failed: energy mode must be " - "'multi-group'. Use convert_to_multigroup() first." - ) - - # Helper function for detecting infinity - def _replace_infinity(value): - if np.isinf(value): - return 1.0 if value > 0 else -1.0 - return value - - # Get a bounding box for sampling rays. We can utilize the geometry's bounding box - # though for 2D problems we need to detect the infinities and replace them with an - # arbitrary finite value. - bounding_box = self.geometry.bounding_box - lower_left = [_replace_infinity(v) for v in bounding_box.lower_left] - upper_right = [_replace_infinity(v) for v in bounding_box.upper_right] - uniform_dist_ray = openmc.stats.Box(lower_left, upper_right) - rr_source = openmc.IndependentSource(space=uniform_dist_ray) - self.settings.random_ray['ray_source'] = rr_source - - # For the dead zone and active length, a reasonable guess is the larger of either: - # 1) The maximum chord length through the geometry (as defined by its bounding box) - # 2) 30 cm - # Then, set the active length to be 5x longer than the dead zone length, for the sake of efficiency. - chord_length = np.array(upper_right) - np.array(lower_left) - max_length = max(np.linalg.norm(chord_length), 30.0) - - self.settings.random_ray['distance_inactive'] = max_length - self.settings.random_ray['distance_active'] = 5 * max_length - - # Take a wild guess as to how many rays are needed - self.settings.particles = 2 * int(max_length) - - def keff_search( - self, - func: ModelModifier, - x0: float, - x1: float, - target: float = 1.0, - k_tol: float = 1e-4, - sigma_final: float = 3e-4, - p: float = 0.5, - q: float = 0.95, - memory: int = 4, - x_min: float | None = None, - x_max: float | None = None, - b0: int | None = None, - b_min: int = 20, - b_max: int | None = None, - maxiter: int = 50, - output: bool = False, - func_kwargs: dict[str, Any] | None = None, - run_kwargs: dict[str, Any] | None = None, - ) -> SearchResult: - r"""Perform a keff search on a model parametrized by a single variable. - - This method uses the GRsecant method described in a paper by `Price and - Roskoff `_. The GRsecant - method is a modification of the secant method that accounts for - uncertainties in the function evaluations. The method uses a weighted - linear fit of the most recent function evaluations to predict the next - point to evaluate. It also adaptively changes the number of batches to - meet the target uncertainty value at each iteration. - - The target uncertainty for iteration :math:`n+1` is determined by the - following equation (following Eq. (8) in the paper): - - .. math:: - \sigma_{i+1} = q \sigma_\text{final} \left ( \frac{ \min \left \{ - \left\lvert k_i - k_\text{target} \right\rvert : k=0,1,\dots,n - \right \} }{k_\text{tol}} \right )^p - - where :math:`q` is a multiplicative factor less than 1, given as the - ``sigma_factor`` parameter below. - - Parameters - ---------- - func : ModelModifier - Function that takes the parameter to be searched and makes a - modification to the model. - x0 : float - First guess for the parameter passed to `func` - x1 : float - Second guess for the parameter passed to `func` - target : float, optional - keff value to search for - k_tol : float, optional - Stopping criterion on the function value; the absolute value must be - within ``k_tol`` of zero to be accepted. - sigma_final : float, optional - Maximum accepted k-effective uncertainty for the stopping criterion. - p : float, optional - Exponent used in the stopping criterion. - q : float, optional - Multiplicative factor used in the stopping criterion. - memory : int, optional - Number of most-recent points used in the weighted linear fit of - ``f(x) = a + b x`` to predict the next point. - x_min : float, optional - Minimum allowed value for the parameter ``x``. - x_max : float, optional - Maximum allowed value for the parameter ``x``. - b0 : int, optional - Number of active batches to use for the initial function - evaluations. If None, uses the model's current setting. - b_min : int, optional - Minimum number of active batches to use in a function evaluation. - b_max : int, optional - Maximum number of active batches to use in a function evaluation. - maxiter : int, optional - Maximum number of iterations to perform. - output : bool, optional - Whether or not to display output showing iteration progress. - func_kwargs : dict, optional - Keyword-based arguments to pass to the `func` function. - run_kwargs : dict, optional - Keyword arguments to pass to :meth:`openmc.Model.run` or - :meth:`openmc.lib.run`. - - Returns - ------- - SearchResult - Result object containing the estimated root (parameter value) and - evaluation history (parameters, means, standard deviations, and - batches), plus convergence status and termination reason. - - """ - import openmc.lib - - check_type('model modifier', func, Callable) - check_type('target', target, Real) - if memory < 2: - raise ValueError("memory must be ≥ 2") - func_kwargs = {} if func_kwargs is None else dict(func_kwargs) - run_kwargs = {} if run_kwargs is None else dict(run_kwargs) - run_kwargs.setdefault('output', False) - - # Create lists to store the history of evaluations - xs: list[float] = [] - fs: list[float] = [] - ss: list[float] = [] - gs: list[int] = [] - count = 0 - - # Helper function to evaluate f and store results - def eval_at(x: float, batches: int) -> tuple[float, float]: - # Modify the model with the current guess - func(x, **func_kwargs) - - # Change the number of batches and run the model - batches += self.settings.inactive - if openmc.lib.is_initialized: - openmc.lib.settings.set_batches(batches) - openmc.lib.reset() - openmc.lib.run(**run_kwargs) - sp_filepath = f'statepoint.{batches}.h5' - else: - self.settings.batches = batches - sp_filepath = self.run(**run_kwargs) - - # Extract keff and its uncertainty - with openmc.StatePoint(sp_filepath) as sp: - keff = sp.keff - - if output: - nonlocal count - count += 1 - print(f'Iteration {count}: {batches=}, {x=:.6g}, {keff=:.5f}') - - xs.append(float(x)) - fs.append(float(keff.n - target)) - ss.append(float(keff.s)) - gs.append(int(batches)) - return fs[-1], ss[-1] - - # Default b0 to current model settings if not explicitly provided - if b0 is None: - b0 = self.settings.batches - self.settings.inactive - - # Perform the search (inlined GRsecant) in a temporary directory - with TemporaryDirectory() as tmpdir: - if not openmc.lib.is_initialized: - run_kwargs.setdefault('cwd', tmpdir) - - # ---- Seed with two evaluations - f0, s0 = eval_at(x0, b0) - if abs(f0) <= k_tol and s0 <= sigma_final: - return SearchResult(x0, xs, fs, ss, gs, True, "converged") - f1, s1 = eval_at(x1, b0) - if abs(f1) <= k_tol and s1 <= sigma_final: - return SearchResult(x1, xs, fs, ss, gs, True, "converged") - - for _ in range(maxiter - 2): - # ------ Step 1: propose next x via GRsecant - m = min(memory, len(xs)) - - # Perform a curve fit on f(x) = a + bx accounting for - # uncertainties. This is equivalent to minimizing the function - # in Equation (A.14) - (a, b), _ = curve_fit( - lambda x, a, b: a + b*x, - xs[-m:], fs[-m:], sigma=ss[-m:], absolute_sigma=True - ) - x_new = float(-a / b) - - # Clamp x_new to the bounds if provided - if x_min is not None: - x_new = max(x_new, x_min) - if x_max is not None: - x_new = min(x_new, x_max) - - # ------ Step 2: choose target σ for next run (Eq. 8 + clamp) - - min_abs_f = float(np.min(np.abs(fs))) - base = q * sigma_final - ratio = min_abs_f / k_tol if k_tol > 0 else 1.0 - sig = base * (ratio ** p) - sig_target = max(sig, base) - - # ------ Step 3: choose generations to hit σ_target (Appendix C) - - # Use at least two past points for regression - if len(gs) >= 2 and np.var(np.log(gs)) > 0.0: - # Perform a curve fit based on Eq. (C.3) to solve for ln(k). - # Note that unlike in the paper, we do not leave r as an - # undetermined parameter and choose r=0.5. - (ln_k,), _ = curve_fit( - lambda ln_b, ln_k: ln_k - 0.5*ln_b, - np.log(gs[-4:]), np.log(ss[-4:]), - ) - k = float(np.exp(ln_k)) - else: - k = float(ss[-1] * math.sqrt(gs[-1])) - - b_new = (k / sig_target) ** 2 - - # Clamp and round up to integer - b_new = max(b_min, math.ceil(b_new)) - if b_max is not None: - b_new = min(b_new, b_max) - - # Evaluate at proposed x with batches determined above - f_new, s_new = eval_at(x_new, b_new) - - # Termination based on both criteria (|f| and σ) - if abs(f_new) <= k_tol and s_new <= sigma_final: - return SearchResult(x_new, xs, fs, ss, gs, True, "converged") - - return SearchResult(xs[-1], xs, fs, ss, gs, False, "maxiter") - - -@dataclass -class SearchResult: - """Result of a GRsecant keff search. - - Attributes - ---------- - root : float - Estimated parameter value where f(x) = 0 at termination. - parameters : list[float] - Parameter values (x) evaluated during the search, in order. - keffs : list[float] - Estimated keff values for each evaluation. - stdevs : list[float] - One-sigma uncertainties of keff for each evaluation. - batches : list[int] - Number of active batches used for each evaluation. - converged : bool - Whether both |f| <= k_tol and sigma <= sigma_final were met. - flag : str - Reason for termination (e.g., "converged", "maxiter"). - """ - root: float - parameters: list[float] = field(repr=False) - means: list[float] = field(repr=False) - stdevs: list[float] = field(repr=False) - batches: list[int] = field(repr=False) - converged: bool - flag: str - - @property - def function_calls(self) -> int: - """Number of function evaluations performed.""" - return len(self.parameters) - - @property - def total_batches(self) -> int: - """Total number of active batches used across all evaluations.""" - return sum(self.batches) diff --git a/openmc/model/surface_composite.py b/openmc/model/surface_composite.py index 5962897de..2945f73b7 100644 --- a/openmc/model/surface_composite.py +++ b/openmc/model/surface_composite.py @@ -1,12 +1,12 @@ -from __future__ import annotations from abc import ABC, abstractmethod -from collections.abc import Iterable, Sequence +from collections.abc import Iterable from copy import copy from functools import partial from math import sqrt, pi, sin, cos, isclose from numbers import Real import warnings import operator +from typing import Sequence import numpy as np from scipy.spatial import ConvexHull, Delaunay @@ -27,16 +27,12 @@ class CompositeSurface(ABC): return surf def rotate(self, rotation, pivot=(0., 0., 0.), order='xyz', inplace=False): - surf = self if inplace else copy(self) + surf = copy(self) for name in self._surface_names: s = getattr(surf, name) setattr(surf, name, s.rotate(rotation, pivot, order, inplace)) return surf - @property - def component_surfaces(self): - return [getattr(self, name) for name in self._surface_names] - @property def boundary_type(self): return getattr(self, self._surface_names[0]).boundary_type @@ -45,11 +41,9 @@ class CompositeSurface(ABC): def boundary_type(self, boundary_type): # Set boundary type on underlying surfaces, but not for ambiguity plane # on one-sided cones - classes = (XConeOneSided, YConeOneSided, ZConeOneSided, Vessel) for name in self._surface_names: - if isinstance(self, classes) and name.startswith('plane'): - continue - getattr(self, name).boundary_type = boundary_type + if name != 'plane': + getattr(self, name).boundary_type = boundary_type def __repr__(self): return f"<{type(self).__name__} at 0x{id(self):x}>" @@ -96,8 +90,8 @@ class CylinderSector(CompositeSurface): counterclockwise direction with respect to the first basis axis (+y, +z, or +x). Must be greater than :attr:`theta1`. center : iterable of float - Coordinate for central axes of cylinders in the (y, z), (x, z), or (x, y) - basis. Defaults to (0,0). + Coordinate for central axes of cylinders in the (y, z), (x, z), or (x, y) + basis. Defaults to (0,0). axis : {'x', 'y', 'z'} Central axis of the cylinders defining the inner and outer surfaces of the sector. Defaults to 'z'. @@ -125,7 +119,7 @@ class CylinderSector(CompositeSurface): r2, theta1, theta2, - center=(0., 0.), + center=(0.,0.), axis='z', **kwargs): @@ -135,11 +129,6 @@ class CylinderSector(CompositeSurface): if theta2 <= theta1: raise ValueError('theta2 must be greater than theta1.') - # Determine whether the angle between theta1 and theta2 is a reflex - # angle, in which case we need to use a union between the planar - # half-spaces - self._reflex = (theta2 - theta1 > 180.0) - phi1 = pi / 180 * theta1 phi2 = pi / 180 * theta2 @@ -174,9 +163,6 @@ class CylinderSector(CompositeSurface): **kwargs) self.plane2 = openmc.Plane.from_points(p1, p2_plane2, p3_plane2, **kwargs) - if axis == 'y': - self.plane1.flip_normal() - self.plane2.flip_normal() @classmethod def from_theta_alpha(cls, @@ -231,11 +217,17 @@ class CylinderSector(CompositeSurface): return cls(r1, r2, theta1, theta2, center=center, axis=axis, **kwargs) def __neg__(self): - if self._reflex: - return -self.outer_cyl & +self.inner_cyl & (-self.plane1 | +self.plane2) + if isinstance(self.inner_cyl, openmc.YCylinder): + return -self.outer_cyl & +self.inner_cyl & +self.plane1 & -self.plane2 else: return -self.outer_cyl & +self.inner_cyl & -self.plane1 & +self.plane2 + def __pos__(self): + if isinstance(self.inner_cyl, openmc.YCylinder): + return +self.outer_cyl | -self.inner_cyl | -self.plane1 | +self.plane2 + else: + return +self.outer_cyl | -self.inner_cyl | +self.plane1 | -self.plane2 + class IsogonalOctagon(CompositeSurface): r"""Infinite isogonal octagon composite surface @@ -654,88 +646,8 @@ class RectangularParallelepiped(CompositeSurface): return +self.xmax | -self.xmin | +self.ymax | -self.ymin | +self.zmax | -self.zmin -class OrthogonalBox(CompositeSurface): - """Arbitrarily oriented orthogonal box - - This composite surface is composed of four or six planar surfaces that form - an arbitrarily oriented orthogonal box when combined. - - Parameters - ---------- - v : iterable of float - (x,y,z) coordinates of a corner of the box - a1 : iterable of float - Vector of first side starting from ``v`` - a2 : iterable of float - Vector of second side starting from ``v`` - a3 : iterable of float, optional - Vector of third side starting from ``v``. When not specified, it is - assumed that the box will be infinite along the vector normal to the - plane specified by ``a1`` and ``a2``. - **kwargs - Keyword arguments passed to underlying plane classes - - Attributes - ---------- - ax1_min, ax1_max : openmc.Plane - Planes representing minimum and maximum along first axis - ax2_min, ax2_max : openmc.Plane - Planes representing minimum and maximum along second axis - ax3_min, ax3_max : openmc.Plane - Planes representing minimum and maximum along third axis - - """ - _surface_names = ('ax1_min', 'ax1_max', 'ax2_min', 'ax2_max', 'ax3_min', 'ax3_max') - - def __init__(self, v, a1, a2, a3=None, **kwargs): - v = np.array(v) - a1 = np.array(a1) - a2 = np.array(a2) - if has_a3 := a3 is not None: - a3 = np.array(a3) - else: - a3 = np.cross(a1, a2) # normal to plane specified by a1 and a2 - - # Generate corners of box - p1 = v - p2 = v + a1 - p3 = v + a2 - p4 = v + a3 - p5 = v + a1 + a2 - p6 = v + a2 + a3 - p7 = v + a1 + a3 - - # Generate 6 planes of box - self.ax1_min = openmc.Plane.from_points(p1, p3, p4, **kwargs) - self.ax1_max = openmc.Plane.from_points(p2, p5, p7, **kwargs) - self.ax2_min = openmc.Plane.from_points(p1, p4, p2, **kwargs) - self.ax2_max = openmc.Plane.from_points(p3, p6, p5, **kwargs) - if has_a3: - self.ax3_min = openmc.Plane.from_points(p1, p2, p3, **kwargs) - self.ax3_max = openmc.Plane.from_points(p4, p7, p6, **kwargs) - - # Make sure a point inside the box produces the correct senses. If not, - # flip the plane coefficients so it does. - mid_point = v + (a1 + a2 + a3)/2 - nums = (1, 2, 3) if has_a3 else (1, 2) - for num in nums: - min_surf = getattr(self, f'ax{num}_min') - max_surf = getattr(self, f'ax{num}_max') - if mid_point in -min_surf: - min_surf.flip_normal() - if mid_point in +max_surf: - max_surf.flip_normal() - - def __neg__(self): - region = (+self.ax1_min & -self.ax1_max & - +self.ax2_min & -self.ax2_max) - if hasattr(self, 'ax3_min'): - region &= (+self.ax3_min & -self.ax3_max) - return region - - class XConeOneSided(CompositeSurface): - r"""One-sided cone parallel the x-axis + """One-sided cone parallel the x-axis A one-sided cone is composed of a normal cone surface and a "disambiguation" surface that eliminates the ambiguity as to which region of space is @@ -748,16 +660,15 @@ class XConeOneSided(CompositeSurface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. + Parameter related to the aperture [:math:`\\rm cm^2`]. + It can be interpreted as the increase in the radius squared per cm along + the cone's axis of revolution. up : bool Whether to select the side of the cone that extends to infinity in the positive direction of the coordinate axis (the positive half-space of @@ -788,9 +699,15 @@ class XConeOneSided(CompositeSurface): def __neg__(self): return -self.cone & (+self.plane if self.up else -self.plane) + def __pos__(self): + if self.up: + return (+self.cone & +self.plane) | -self.plane + else: + return (+self.cone & -self.plane) | +self.plane + class YConeOneSided(CompositeSurface): - r"""One-sided cone parallel the y-axis + """One-sided cone parallel the y-axis A one-sided cone is composed of a normal cone surface and a "disambiguation" surface that eliminates the ambiguity as to which region of space is @@ -803,16 +720,15 @@ class YConeOneSided(CompositeSurface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. + Parameter related to the aperture [:math:`\\rm cm^2`]. + It can be interpreted as the increase in the radius squared per cm along + the cone's axis of revolution. up : bool Whether to select the side of the cone that extends to infinity in the positive direction of the coordinate axis (the positive half-space of @@ -841,10 +757,11 @@ class YConeOneSided(CompositeSurface): self.up = up __neg__ = XConeOneSided.__neg__ + __pos__ = XConeOneSided.__pos__ class ZConeOneSided(CompositeSurface): - r"""One-sided cone parallel the z-axis + """One-sided cone parallel the z-axis A one-sided cone is composed of a normal cone surface and a "disambiguation" surface that eliminates the ambiguity as to which region of space is @@ -857,16 +774,15 @@ class ZConeOneSided(CompositeSurface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. + Parameter related to the aperture [:math:`\\rm cm^2`]. + It can be interpreted as the increase in the radius squared per cm along + the cone's axis of revolution. up : bool Whether to select the side of the cone that extends to infinity in the positive direction of the coordinate axis (the positive half-space of @@ -895,6 +811,7 @@ class ZConeOneSided(CompositeSurface): self.up = up __neg__ = XConeOneSided.__neg__ + __pos__ = XConeOneSided.__pos__ class Polygon(CompositeSurface): @@ -1261,11 +1178,11 @@ class Polygon(CompositeSurface): else: op = operator.neg if basis == 'xy': - surf = openmc.Plane(a=dx, b=dy, c=0.0, d=-c) + surf = openmc.Plane(a=dx, b=dy, d=-c) elif basis == 'yz': - surf = openmc.Plane(a=0.0, b=dx, c=dy, d=-c) + surf = openmc.Plane(b=dx, c=dy, d=-c) elif basis == 'xz': - surf = openmc.Plane(a=dx, b=0.0, c=dy, d=-c) + surf = openmc.Plane(a=dx, c=dy, d=-c) else: y0 = -c/dy r2 = dy**2 / dx**2 @@ -1328,43 +1245,25 @@ class Polygon(CompositeSurface): surfsets.append(surf_ops) return surfsets - def offset(self, distance: float | Sequence[float] | np.ndarray) -> Polygon: + def offset(self, distance): """Offset this polygon by a set distance Parameters ---------- - distance : float or sequence of float or np.ndarray + distance : float The distance to offset the polygon by. Positive is outward - (expanding) and negative is inward (shrinking). If a float is - provided, the same offset is applied to all vertices. If a list or - tuple is provided, each vertex gets a different offset. If an - iterable or numpy array is provided, each vertex gets a different - offset. + (expanding) and negative is inward (shrinking). Returns ------- offset_polygon : openmc.model.Polygon """ - - if isinstance(distance, float): - distance = np.full(len(self.points), distance) - elif isinstance(distance, Sequence): - distance = np.array(distance) - elif not isinstance(distance, np.ndarray): - raise TypeError("Distance must be a float or sequence of float.") - - if len(distance) != len(self.points): - raise ValueError( - f"Length of distance {len(distance)} array must " - f"match number of polygon points {len(self.points)}" - ) - normals = np.insert(self._normals, 0, self._normals[-1, :], axis=0) cos2theta = np.sum(normals[1:, :]*normals[:-1, :], axis=-1, keepdims=True) costheta = np.cos(np.arccos(cos2theta) / 2) nvec = (normals[1:, :] + normals[:-1, :]) unit_nvec = nvec / np.linalg.norm(nvec, axis=-1, keepdims=True) - disp_vec = distance[:, np.newaxis] / costheta * unit_nvec + disp_vec = distance / costheta * unit_nvec return type(self)(self.points + disp_vec, basis=self.basis) @@ -1747,216 +1646,3 @@ class HexagonalPrism(CompositeSurface): prism &= ~corners return prism - - -def _rotation_matrix(v1, v2): - """Compute rotation matrix that would rotate v1 into v2. - - Parameters - ---------- - v1 : numpy.ndarray - Unrotated vector - v2 : numpy.ndarray - Rotated vector - - Returns - ------- - 3x3 rotation matrix - - """ - # Normalize vectors and compute cosine - u1 = v1 / np.linalg.norm(v1) - u2 = v2 / np.linalg.norm(v2) - cos_angle = np.dot(u1, u2) - - I = np.identity(3) - - # Handle special case where vectors are parallel or anti-parallel - if isclose(abs(cos_angle), 1.0, rel_tol=1e-8): - return np.sign(cos_angle)*I - else: - # Calculate rotation angle - sin_angle = np.sqrt(1 - cos_angle*cos_angle) - - # Calculate axis of rotation - axis = np.cross(u1, u2) - axis /= np.linalg.norm(axis) - - # Create cross-product matrix K - kx, ky, kz = axis - K = np.array([ - [0.0, -kz, ky], - [kz, 0.0, -kx], - [-ky, kx, 0.0] - ]) - - # Create rotation matrix using Rodrigues' rotation formula - return I + K * sin_angle + (K @ K) * (1 - cos_angle) - - -class ConicalFrustum(CompositeSurface): - """Conical frustum. - - A conical frustum, also known as a right truncated cone, is a cone that is - truncated by two parallel planes that are perpendicular to the axis of the - cone. The lower and upper base of the conical frustum are circular faces. - This surface is equivalent to the TRC macrobody in MCNP. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - center_base : iterable of float - Cartesian coordinates of the center of the bottom planar face. - axis : iterable of float - Vector from the center of the bottom planar face to the center of the - top planar face that defines the axis of the cone. The length of this - vector is the height of the conical frustum. - r1 : float - Radius of the lower cone base - r2 : float - Radius of the upper cone base - **kwargs - Keyword arguments passed to underlying plane classes - - Attributes - ---------- - cone : openmc.Cone - Cone surface - plane_bottom : openmc.Plane - Plane surface defining the bottom of the frustum - plane_top : openmc.Plane - Plane surface defining the top of the frustum - - """ - _surface_names = ('cone', 'plane_bottom', 'plane_top') - - def __init__(self, center_base: Sequence[float], axis: Sequence[float], - r1: float, r2: float, **kwargs): - center_base = np.array(center_base) - axis = np.array(axis) - - # Determine length of axis height vector - h = np.linalg.norm(axis) - - # To create the frustum oriented with the correct axis, first we will - # create a cone along the z axis and then rotate it according to the - # given axis. Thus, we first need to determine the apex using the z axis - # as a reference. - x0, y0, z0 = center_base - if r1 != r2: - apex = z0 + r1*h/(r1 - r2) - r_sq = ((r1 - r2)/h)**2 - cone = openmc.ZCone(x0, y0, apex, r2=r_sq, **kwargs) - else: - # In the degenerate case r1 == r2, the cone becomes a cylinder - cone = openmc.ZCylinder(x0, y0, r1, **kwargs) - - # Create the parallel planes - plane_bottom = openmc.ZPlane(z0, **kwargs) - plane_top = openmc.ZPlane(z0 + h, **kwargs) - - # Determine rotation matrix corresponding to specified axis - u = np.array([0., 0., 1.]) - rotation = _rotation_matrix(u, axis) - - # Rotate the surfaces - self.cone = cone.rotate(rotation, pivot=center_base) - self.plane_bottom = plane_bottom.rotate(rotation, pivot=center_base) - self.plane_top = plane_top.rotate(rotation, pivot=center_base) - - def __neg__(self) -> openmc.Region: - return +self.plane_bottom & -self.plane_top & -self.cone - - -class Vessel(CompositeSurface): - """Vessel composed of cylinder with semi-ellipsoid top and bottom. - - This composite surface is represented by a finite cylinder with ellipsoidal - top and bottom surfaces. This surface is equivalent to the 'vesesl' surface - in Serpent. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - r : float - Radius of vessel. - p1 : float - Minimum coordinate for cylindrical part of vessel. - p2 : float - Maximum coordinate for cylindrical part of vessel. - h1 : float - Height of bottom ellipsoidal part of vessel. - h2 : float - Height of top ellipsoidal part of vessel. - center : 2-tuple of float - Coordinate for central axis of the cylinder in the (y, z), (x, z), or - (x, y) basis. Defaults to (0,0). - axis : {'x', 'y', 'z'} - Central axis of the cylinder. - - """ - - _surface_names = ('cyl', 'plane_bottom', 'plane_top', 'bottom', 'top') - - def __init__(self, r: float, p1: float, p2: float, h1: float, h2: float, - center: Sequence[float] = (0., 0.), axis: str = 'z', **kwargs): - if p1 >= p2: - raise ValueError('p1 must be less than p2') - check_value('axis', axis, {'x', 'y', 'z'}) - - c1, c2 = center - cyl_class = getattr(openmc, f'{axis.upper()}Cylinder') - plane_class = getattr(openmc, f'{axis.upper()}Plane') - self.cyl = cyl_class(c1, c2, r, **kwargs) - self.plane_bottom = plane_class(p1) - self.plane_top = plane_class(p2) - - # General equation for an ellipsoid: - # (x-x₀)²/r² + (y-y₀)²/r² + (z-z₀)²/h² = 1 - # (x-x₀)² + (y-y₀)² + (z-z₀)²s² = r² - # Let s = r/h: - # (x² - 2x₀x + x₀²) + (y² - 2y₀y + y₀²) + (z² - 2z₀z + z₀²)s² = r² - # x² + y² + s²z² - 2x₀x - 2y₀y - 2s²z₀z + (x₀² + y₀² + z₀²s² - r²) = 0 - - sb = (r/h1) - st = (r/h2) - kwargs['a'] = kwargs['b'] = kwargs['c'] = 1.0 - kwargs_bottom = kwargs - kwargs_top = kwargs.copy() - - sb2 = sb*sb - st2 = st*st - kwargs_bottom['k'] = c1*c1 + c2*c2 + p1*p1*sb2 - r*r - kwargs_top['k'] = c1*c1 + c2*c2 + p2*p2*st2 - r*r - - if axis == 'x': - kwargs_bottom['a'] *= sb2 - kwargs_top['a'] *= st2 - kwargs_bottom['g'] = -2*p1*sb2 - kwargs_top['g'] = -2*p2*st2 - kwargs_top['h'] = kwargs_bottom['h'] = -2*c1 - kwargs_top['j'] = kwargs_bottom['j'] = -2*c2 - elif axis == 'y': - kwargs_bottom['b'] *= sb2 - kwargs_top['b'] *= st2 - kwargs_top['g'] = kwargs_bottom['g'] = -2*c1 - kwargs_bottom['h'] = -2*p1*sb2 - kwargs_top['h'] = -2*p2*st2 - kwargs_top['j'] = kwargs_bottom['j'] = -2*c2 - elif axis == 'z': - kwargs_bottom['c'] *= sb2 - kwargs_top['c'] *= st2 - kwargs_top['g'] = kwargs_bottom['g'] = -2*c1 - kwargs_top['h'] = kwargs_bottom['h'] = -2*c2 - kwargs_bottom['j'] = -2*p1*sb2 - kwargs_top['j'] = -2*p2*st2 - - self.bottom = openmc.Quadric(**kwargs_bottom) - self.top = openmc.Quadric(**kwargs_top) - - def __neg__(self): - return ((-self.cyl & +self.plane_bottom & -self.plane_top) | - (-self.bottom & -self.plane_bottom) | - (-self.top & +self.plane_top)) diff --git a/openmc/particle_restart.py b/openmc/particle_restart.py index 44864107d..317d8761b 100644 --- a/openmc/particle_restart.py +++ b/openmc/particle_restart.py @@ -1,7 +1,6 @@ import h5py import openmc.checkvalue as cv -from .particle_type import ParticleType _VERSION_PARTICLE_RESTART = 2 @@ -29,8 +28,8 @@ class Particle: Type of simulation (criticality or fixed source) id : long Identifier of the particle - type : openmc.ParticleType - Particle type + type : int + Particle type (1 = neutron, 2 = photon, 3 = electron, 4 = positron) weight : float Weight of the particle energy : float @@ -53,7 +52,7 @@ class Particle: self.energy = f['energy'][()] self.generations_per_batch = f['generations_per_batch'][()] self.id = f['id'][()] - self.type = ParticleType(f['type'][()]) + self.type = f['type'][()] self.n_particles = f['n_particles'][()] self.run_mode = f['run_mode'][()].decode() self.uvw = f['uvw'][()] diff --git a/openmc/particle_type.py b/openmc/particle_type.py deleted file mode 100644 index 9d7713443..000000000 --- a/openmc/particle_type.py +++ /dev/null @@ -1,228 +0,0 @@ -from numbers import Integral - -from openmc.data import gnds_name, zam, ATOMIC_SYMBOL - - -_PDG_NAME = { - 2112: 'neutron', - 22: 'photon', - 11: 'electron', - -11: 'positron', - 2212: 'H1', -} - -_ALIAS_PDG = { - 'neutron': 2112, - 'n': 2112, - 'photon': 22, - 'gamma': 22, - 'electron': 11, - 'positron': -11, - 'proton': 2212, - 'p': 2212, - 'h1': 2212, - 'deuteron': 1000010020, - 'd': 1000010020, - 'h2': 1000010020, - 'triton': 1000010030, - 't': 1000010030, - 'h3': 1000010030, - 'alpha': 1000020040, - 'he4': 1000020040, -} - -_LEGACY_PARTICLE_INDEX = { - 0: 2112, - 1: 22, - 2: 11, - 3: -11, -} - - -class ParticleType: - """Particle type defined by a PDG number. - - ParticleType uses the Particle Data Group (PDG) Monte Carlo numbering scheme - to uniquely identify particle types. This includes elementary particles - (neutrons, photons, etc.) and nuclear codes for isotopes. - - Parameters - ---------- - value : str, int, or ParticleType - The particle identifier. Can be: - - - A string name (e.g., 'neutron', 'photon', 'He4', 'U235') - - An integer PDG number (e.g., 2112 for neutron) - - A string with PDG prefix (e.g., 'pdg:2112') - - An existing ParticleType instance - - Attributes - ---------- - pdg_number : int - The PDG number for this particle type - zam : tuple of int or None - For nuclear particles, the (Z, A, m) tuple where Z is atomic number, - A is mass number, and m is metastable state. None for elementary particles. - is_nucleus : bool - Whether this particle is a nucleus (ion) - - Examples - -------- - >>> neutron = ParticleType('neutron') - >>> neutron.pdg_number - 2112 - >>> he4 = ParticleType('He4') - >>> he4.zam - (2, 4, 0) - >>> ParticleType(2112) == ParticleType('neutron') - True - - """ - - __slots__ = ('_pdg_number',) - - def __init__(self, value: 'str | int | ParticleType'): - if isinstance(value, ParticleType): - pdg = value._pdg_number - elif isinstance(value, str): - pdg = self._pdg_number_from_string(value) - elif isinstance(value, Integral): - pdg = int(value) - # Handle legacy particle indices (0, 1, 2, 3) - if pdg in _LEGACY_PARTICLE_INDEX: - pdg = _LEGACY_PARTICLE_INDEX[pdg] - else: - raise TypeError(f"Cannot create ParticleType from {type(value).__name__}") - - self._pdg_number = pdg - - def __eq__(self, other): - if isinstance(other, ParticleType): - return self._pdg_number == other._pdg_number - if isinstance(other, Integral): - return self._pdg_number == int(other) - if isinstance(other, str): - try: - return self._pdg_number == ParticleType(other)._pdg_number - except (ValueError, TypeError): - return False - return NotImplemented - - def __hash__(self) -> int: - return hash(self._pdg_number) - - def __int__(self) -> int: - return self._pdg_number - - @property - def pdg_number(self) -> int: - return self._pdg_number - - @staticmethod - def _pdg_number_from_string(value: str) -> int: - """Parse a string to get a PDG number. - - Parameters - ---------- - value : str - Particle identifier string - - Returns - ------- - int - PDG number - - Raises - ------ - ValueError - If string cannot be parsed as a valid particle identifier - - """ - s = value.strip() - if not s: - raise ValueError('Particle identifier cannot be empty.') - - lower = s.lower() - if lower.startswith('pdg:'): - code_str = lower[4:] - try: - return int(code_str) - except ValueError: - raise ValueError(f'Invalid PDG number: {code_str}') - - if lower in _ALIAS_PDG: - return _ALIAS_PDG[lower] - - # Assume it is a GNDS nuclide name - Z, A, m = zam(s) - if Z <= 0 or Z > 999 or A <= 0 or A > 999 or m < 0 or m > 9: - raise ValueError('Invalid Z/A/m for nuclear PDG number.') - return 1000000000 + Z * 10000 + A * 10 + m - - def __repr__(self) -> str: - return f'' - - def __str__(self) -> str: - """Return a canonical string representation of the particle type. - - Returns - ------- - str - Canonical name (e.g., 'neutron', 'He4', 'pdg:12345') - - """ - if self._pdg_number in _PDG_NAME: - return _PDG_NAME[self._pdg_number] - - if (zam_tuple := self.zam) is not None: - Z, A, m = zam_tuple - if Z <= 0 or Z > max(ATOMIC_SYMBOL) or A <= 0 or A > 999: - raise ValueError(f"Invalid nuclear PDG number: {self._pdg_number}") - return gnds_name(Z, A, m) - - return f'pdg:{self._pdg_number}' - - @property - def zam(self) -> 'tuple[int, int, int] | None': - """Return the (Z, A, m) tuple for nuclear particles. - - Returns - ------- - tuple of int or None - For nuclear particles, returns (Z, A, m) where Z is atomic number, - A is mass number, and m is metastable state. Returns None for - elementary particles. - - """ - if self._pdg_number < 1000000000: - return None - Z = (self._pdg_number // 10000) % 1000 - A = (self._pdg_number // 10) % 1000 - m = self._pdg_number % 10 - if Z <= 0 or A <= 0: - return None - else: - return (Z, A, m) - - @property - def is_nucleus(self) -> bool: - """Return whether this particle is a nucleus. - - Returns - ------- - bool - True if the particle is a nucleus (ion), False otherwise - - """ - return self.zam is not None - - -# Define common particle constants -ParticleType.NEUTRON = ParticleType(2112) -ParticleType.PHOTON = ParticleType(22) -ParticleType.ELECTRON = ParticleType(11) -ParticleType.POSITRON = ParticleType(-11) -ParticleType.PROTON = ParticleType(2212) -ParticleType.DEUTERON = ParticleType(1000010020) -ParticleType.TRITON = ParticleType(1000010030) -ParticleType.ALPHA = ParticleType(1000020040) diff --git a/openmc/plots.py b/openmc/plots.py index 531184095..0d9dca30e 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -1,8 +1,7 @@ -from collections.abc import Iterable, Mapping, Sequence +from collections.abc import Iterable, Mapping from numbers import Integral, Real from pathlib import Path -from textwrap import dedent -import warnings +from typing import Optional import h5py import lxml.etree as ET @@ -12,13 +11,11 @@ import openmc import openmc.checkvalue as cv from openmc.checkvalue import PathLike -from ._xml import clean_indentation, get_elem_list, get_text +from ._xml import clean_indentation, get_elem_tuple, reorder_attributes, get_text from .mixin import IDManagerMixin _BASES = {'xy', 'xz', 'yz'} -_BASIS_INDICES = {'xy': (0, 1, 2), 'xz': (0, 2, 1), 'yz': (1, 2, 0)} - _SVG_COLORS = { 'aliceblue': (240, 248, 255), 'antiquewhite': (250, 235, 215), @@ -169,98 +166,6 @@ _SVG_COLORS = { 'yellowgreen': (154, 205, 50) } -_PLOT_PARAMS = dedent("""\ - - Parameters - ---------- - origin : iterable of float - Coordinates at the origin of the plot. If left as None, - the center of the bounding box will be used to attempt to ascertain - the origin with infinite values being replaced by 0. - width : iterable of float - Width of the plot in each basis direction. If left as none then the - width of the bounding box will be used to attempt to - ascertain the plot width. Defaults to (10, 10) if the bounding box - contains inf values. - pixels : Iterable of int or int - If an iterable of ints is provided then this directly sets the - number of pixels to use in each basis direction. If a single int - is provided then this sets the total number of pixels in the plot - and the number of pixels in each basis direction is calculated - from this total and the image aspect ratio based on the width - argument. - basis : {'xy', 'xz', 'yz'} - The basis directions for the plot - color_by : {'cell', 'material'} - Indicate whether the plot should be colored by cell or by material - colors : dict - Assigns colors to specific materials or cells. Keys are instances of - :class:`Cell` or :class:`Material` and values are RGB 3-tuples, RGBA - 4-tuples, or strings indicating SVG color names. Red, green, blue, - and alpha should all be integers in the range [0, 255], for example: - - .. code-block:: python - - # Make water blue - water = openmc.Cell(fill=h2o) - universe.plot(..., colors={water: (0, 0, 255)) - seed : int - Seed for the random number generator - openmc_exec : str - Path to OpenMC executable. - axes : matplotlib.Axes - Axes to draw to - - .. versionadded:: 0.13.1 - legend : bool - Whether a legend showing material or cell names should be drawn - - .. versionadded:: 0.14.0 - axis_units : {'km', 'm', 'cm', 'mm'} - Units used on the plot axis - - .. versionadded:: 0.14.0 - outline : bool or str - Whether outlines between color boundaries should be drawn. If set to - 'only', only outlines will be drawn. - - .. versionadded:: 0.14.0 - show_overlaps: bool - Indicate whether or not overlapping regions are shown. - Default is False. - overlap_color: Iterable of int or str - Color to apply to overlapping regions. Default is red. - n_samples : int, optional - The number of source particles to sample and add to plot. Defaults - to None which doesn't plot any particles on the plot. - plane_tolerance: float - When plotting a plane the source locations within the plane +/- - the plane_tolerance will be included and those outside of the - plane_tolerance will not be shown - legend_kwargs : dict - Keyword arguments passed to :func:`matplotlib.pyplot.legend`. - - .. versionadded:: 0.14.0 - source_kwargs : dict, optional - Keyword arguments passed to :func:`matplotlib.pyplot.scatter`. - contour_kwargs : dict, optional - Keyword arguments passed to :func:`matplotlib.pyplot.contour`. - **kwargs - Keyword arguments passed to :func:`matplotlib.pyplot.imshow`. - - Returns - ------- - matplotlib.axes.Axes - Axes containing resulting image -""") - - -# Decorator for consistently adding plot parameters to docstrings (Model.plot, -# Geometry.plot, Universe.plot, etc.) -def add_plot_params(func): - func.__doc__ += _PLOT_PARAMS - return func - def _get_plot_image(plot, cwd): from IPython.display import Image @@ -346,95 +251,14 @@ def voxel_to_vtk(voxel_file: PathLike, output: PathLike = 'plot.vti'): writer.SetInputData(grid) else: writer.SetInput(grid) - output = str(output) if not output.endswith(".vti"): output += ".vti" - writer.SetFileName(output) + writer.SetFileName(str(output)) writer.Write() return output -def id_map_to_rgb( - id_map: np.ndarray, - color_by: str = 'cell', - colors: dict | None = None, - overlap_color: Sequence[int] | str = (255, 0, 0) -) -> np.ndarray: - """Convert ID map array to RGB image array. - - Parameters - ---------- - id_map : numpy.ndarray - Array with shape (v_pixels, h_pixels, 3) containing cell IDs, - cell instances, and material IDs - color_by : {'cell', 'material'} - Whether to color by cell or material - colors : dict, optional - Dictionary mapping cells/materials to colors - overlap_color : sequence of int or str, optional - Color to use for overlaps. Defaults to red (255, 0, 0). - - Returns - ------- - numpy.ndarray - RGB image array with shape (v_pixels, h_pixels, 3) with values - in range [0, 1] for matplotlib - """ - # Initialize RGB array with white background (values between 0 and 1 for matplotlib) - img = np.ones(id_map.shape, dtype=float) - - # Get the appropriate index based on color_by - if color_by == 'cell': - id_index = 0 # Cell IDs are in the first channel - elif color_by == 'material': - id_index = 2 # Material IDs are in the third channel - else: - raise ValueError("color_by must be either 'cell' or 'material'") - - # Get all unique IDs in the plot - unique_ids = np.unique(id_map[:, :, id_index]) - - # Generate default colors if not provided - if colors is None: - colors = {} - - # Convert colors dict to use IDs as keys - color_map = {} - for key, color in colors.items(): - if isinstance(key, (openmc.Cell, openmc.Material)): - color_map[key.id] = color - else: - color_map[key] = color - - # Generate random colors for IDs not in color_map - rng = np.random.RandomState(1) - for uid in unique_ids: - if uid > 0 and uid not in color_map: - color_map[uid] = rng.randint(0, 256, (3,)) - - # Apply colors to each pixel - for uid in unique_ids: - if uid == -1: # Background/void - continue - elif uid == -3: # Overlap (only present if color_overlaps was True) - if isinstance(overlap_color, str): - rgb = _SVG_COLORS[overlap_color.lower()] - else: - rgb = overlap_color - mask = id_map[:, :, id_index] == uid - img[mask] = np.array(rgb) / 255.0 - elif uid in color_map: - color = color_map[uid] - if isinstance(color, str): - rgb = _SVG_COLORS[color.lower()] - else: - rgb = color - mask = id_map[:, :, id_index] == uid - img[mask] = np.array(rgb) / 255.0 - - return img - class PlotBase(IDManagerMixin): """ Parameters @@ -520,7 +344,7 @@ class PlotBase(IDManagerMixin): @filename.setter def filename(self, filename): - cv.check_type('filename', filename, (str, PathLike)) + cv.check_type('filename', filename, str) self._filename = filename @property @@ -646,21 +470,13 @@ class PlotBase(IDManagerMixin): else: domains = geometry.get_all_cells().values() + # Set the seed for the random number generator rng = np.random.RandomState(seed) # Generate random colors for each feature for domain in domains: self.colors[domain] = rng.randint(0, 256, (3,)) - def _colors_to_xml(self, element): - for domain, color in sorted(self._colors.items(), - key=lambda x: self._get_id(x[0])): - subelement = ET.SubElement(element, "color") - subelement.set("id", str(self._get_id(domain))) - if isinstance(color, str): - color = _SVG_COLORS[color.lower()] - subelement.set("rgb", ' '.join(str(x) for x in color)) - def to_xml_element(self): """Save common plot attributes to XML element @@ -707,15 +523,14 @@ class PlotBase(IDManagerMixin): return element -class SlicePlot(PlotBase): - """Definition of a 2D slice plot of the geometry. +class Plot(PlotBase): + """Definition of a finite region of space to be plotted. - Colors that are used in plots can be given as RGB tuples, e.g. - (255, 255, 255) would be white, or by a string indicating a + OpenMC is capable of generating two-dimensional slice plots, or + three-dimensional voxel or projection plots. Colors that are used in plots can be given as + RGB tuples, e.g. (255, 255, 255) would be white, or by a string indicating a valid `SVG color `_. - .. versionadded:: 0.15.4 - Parameters ---------- plot_id : int @@ -730,7 +545,7 @@ class SlicePlot(PlotBase): name : str Name of the plot pixels : Iterable of int - Number of pixels to use in each direction (2 values) + Number of pixels to use in each direction filename : str Path to write the plot to color_by : {'cell', 'material'} @@ -753,9 +568,11 @@ class SlicePlot(PlotBase): level : int Universe depth to plot at width : Iterable of float - Width of the plot in each basis direction (2 values) + Width of the plot in each basis direction origin : tuple or list of ndarray - Origin (center) of the plot (3 values) + Origin (center) of the plot + type : {'slice', 'voxel'} + The type of the plot basis : {'xy', 'xz', 'yz'} The basis directions for the plot meshlines : dict @@ -768,37 +585,10 @@ class SlicePlot(PlotBase): super().__init__(plot_id, name) self._width = [4.0, 4.0] self._origin = [0., 0., 0.] + self._type = 'slice' self._basis = 'xy' self._meshlines = None - @property - def type(self): - warnings.warn( - "The 'type' attribute is deprecated and will be removed in a future version. " - "This is a SlicePlot instance.", - FutureWarning, stacklevel=2 - ) - return 'slice' - - @type.setter - def type(self, value): - raise TypeError( - "Setting plot.type is no longer supported. " - "Use openmc.SlicePlot() for 2D slice plots or openmc.VoxelPlot() for 3D voxel plots." - ) - - @property - def pixels(self): - return self._pixels - - @pixels.setter - def pixels(self, pixels): - cv.check_type('plot pixels', pixels, Iterable, Integral) - cv.check_length('plot pixels', pixels, 2, 2) - for dim in pixels: - cv.check_greater_than('plot pixels', dim, 0) - self._pixels = pixels - @property def width(self): return self._width @@ -806,7 +596,7 @@ class SlicePlot(PlotBase): @width.setter def width(self, width): cv.check_type('plot width', width, Iterable, Real) - cv.check_length('plot width', width, 2, 2) + cv.check_length('plot width', width, 2, 3) self._width = width @property @@ -819,6 +609,15 @@ class SlicePlot(PlotBase): cv.check_length('plot origin', origin, 3) self._origin = origin + @property + def type(self): + return self._type + + @type.setter + def type(self, plottype): + cv.check_value('plot type', plottype, ['slice', 'voxel']) + self._type = plottype + @property def basis(self): return self._basis @@ -861,10 +660,11 @@ class SlicePlot(PlotBase): self._meshlines = meshlines def __repr__(self): - string = 'SlicePlot\n' + string = 'Plot\n' string += '{: <16}=\t{}\n'.format('\tID', self._id) string += '{: <16}=\t{}\n'.format('\tName', self._name) string += '{: <16}=\t{}\n'.format('\tFilename', self._filename) + string += '{: <16}=\t{}\n'.format('\tType', self._type) string += '{: <16}=\t{}\n'.format('\tBasis', self._basis) string += '{: <16}=\t{}\n'.format('\tWidth', self._width) string += '{: <16}=\t{}\n'.format('\tOrigin', self._origin) @@ -980,7 +780,7 @@ class SlicePlot(PlotBase): self._colors[domain] = (r, g, b) def to_xml_element(self): - """Return XML representation of the slice plot + """Return XML representation of the slice/voxel plot Returns ------- @@ -990,8 +790,10 @@ class SlicePlot(PlotBase): """ element = super().to_xml_element() - element.set("type", "slice") - element.set("basis", self._basis) + element.set("type", self._type) + + if self._type == 'slice': + element.set("basis", self._basis) subelement = ET.SubElement(element, "origin") subelement.text = ' '.join(map(str, self._origin)) @@ -1000,7 +802,13 @@ class SlicePlot(PlotBase): subelement.text = ' '.join(map(str, self._width)) if self._colors: - self._colors_to_xml(element) + for domain, color in sorted(self._colors.items(), + key=lambda x: PlotBase._get_id(x[0])): + subelement = ET.SubElement(element, "color") + subelement.set("id", str(PlotBase._get_id(domain))) + if isinstance(color, str): + color = _SVG_COLORS[color.lower()] + subelement.set("rgb", ' '.join(str(x) for x in color)) if self._show_overlaps: subelement = ET.SubElement(element, "show_overlaps") @@ -1037,63 +845,68 @@ class SlicePlot(PlotBase): Returns ------- - openmc.SlicePlot - SlicePlot object + openmc.Plot + Plot object """ - plot_id = int(get_text(elem, "id")) + plot_id = int(elem.get("id")) name = get_text(elem, 'name', '') plot = cls(plot_id, name) if "filename" in elem.keys(): - plot.filename = get_text(elem, "filename") - plot.color_by = get_text(elem, "color_by") - plot.basis = get_text(elem, "basis") + plot.filename = elem.get("filename") + plot.color_by = elem.get("color_by") + plot.type = elem.get("type") + if plot.type == 'slice': + plot.basis = elem.get("basis") - plot.origin = tuple(get_elem_list(elem, "origin", float)) - plot.width = tuple(get_elem_list(elem, "width", float)) - plot.pixels = tuple(get_elem_list(elem, "pixels")) - background = get_elem_list(elem, "background") - if background is not None: - plot._background = tuple(background) + plot.origin = get_elem_tuple(elem, "origin", float) + plot.width = get_elem_tuple(elem, "width", float) + plot.pixels = get_elem_tuple(elem, "pixels") + plot._background = get_elem_tuple(elem, "background") # Set plot colors colors = {} for color_elem in elem.findall("color"): - uid = int(get_text(color_elem, "id")) - colors[uid] = tuple(get_elem_list(color_elem, "rgb", int)) + uid = int(color_elem.get("id")) + colors[uid] = tuple([int(x) + for x in color_elem.get("rgb").split()]) plot.colors = colors # Set masking information mask_elem = elem.find("mask") if mask_elem is not None: - plot.mask_components = get_elem_list(mask_elem, "components", int) - background = get_elem_list(mask_elem, "background", int) + plot.mask_components = [ + int(x) for x in mask_elem.get("components").split()] + background = mask_elem.get("background") if background is not None: - plot.mask_background = tuple(background) + plot.mask_background = tuple( + [int(x) for x in background.split()]) # show overlaps - overlap = get_text(elem, "show_overlaps") - if overlap is not None: - plot.show_overlaps = (overlap in ('true', '1')) - overlap_color = get_elem_list(elem, "overlap_color", int) + overlap_elem = elem.find("show_overlaps") + if overlap_elem is not None: + plot.show_overlaps = (overlap_elem.text in ('true', '1')) + overlap_color = get_elem_tuple(elem, "overlap_color") if overlap_color is not None: - plot.overlap_color = tuple(overlap_color) + plot.overlap_color = overlap_color # Set universe level - level = get_text(elem, "level") + level = elem.find("level") if level is not None: - plot.level = int(level) + plot.level = int(level.text) # Set meshlines mesh_elem = elem.find("meshlines") if mesh_elem is not None: - meshlines = {'type': get_text(mesh_elem, "meshtype")} + meshlines = {'type': mesh_elem.get('meshtype')} if 'id' in mesh_elem.keys(): - meshlines['id'] = int(get_text(mesh_elem, "id")) + meshlines['id'] = int(mesh_elem.get('id')) if 'linewidth' in mesh_elem.keys(): - meshlines['linewidth'] = int(get_text(mesh_elem, "linewidth")) + meshlines['linewidth'] = int(mesh_elem.get('linewidth')) if 'color' in mesh_elem.keys(): - meshlines['color'] = tuple(get_elem_list(mesh_elem, "color", int)) + meshlines['color'] = tuple( + [int(x) for x in mesh_elem.get('color').split()] + ) plot.meshlines = meshlines return plot @@ -1129,215 +942,9 @@ class SlicePlot(PlotBase): # Return produced image return _get_plot_image(self, cwd) - - -class VoxelPlot(PlotBase): - """Definition of a 3D voxel plot of the geometry. - - Colors that are used in plots can be given as RGB tuples, e.g. - (255, 255, 255) would be white, or by a string indicating a - valid `SVG color `_. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - plot_id : int - Unique identifier for the plot - name : str - Name of the plot - - Attributes - ---------- - id : int - Unique identifier - name : str - Name of the plot - pixels : Iterable of int - Number of pixels to use in each direction (3 values) - filename : str - Path to write the plot to - color_by : {'cell', 'material'} - Indicate whether the plot should be colored by cell or by material - background : Iterable of int or str - Color of the background - mask_components : Iterable of openmc.Cell or openmc.Material or int - The cells or materials (or corresponding IDs) to mask - mask_background : Iterable of int or str - Color to apply to all cells/materials listed in mask_components - show_overlaps : bool - Indicate whether or not overlapping regions are shown - overlap_color : Iterable of int or str - Color to apply to overlapping regions - colors : dict - Dictionary indicating that certain cells/materials should be - displayed with a particular color. The keys can be of type - :class:`~openmc.Cell`, :class:`~openmc.Material`, or int (ID for a - cell/material). - level : int - Universe depth to plot at - width : Iterable of float - Width of the plot in each dimension (3 values) - origin : tuple or list of ndarray - Origin (center) of the plot (3 values) - - """ - - def __init__(self, plot_id=None, name=''): - super().__init__(plot_id, name) - self._width = [4.0, 4.0, 4.0] - self._origin = [0., 0., 0.] - self._pixels = [400, 400, 400] - - @property - def pixels(self): - return self._pixels - - @pixels.setter - def pixels(self, pixels): - cv.check_type('plot pixels', pixels, Iterable, Integral) - cv.check_length('plot pixels', pixels, 3, 3) - for dim in pixels: - cv.check_greater_than('plot pixels', dim, 0) - self._pixels = pixels - - @property - def width(self): - return self._width - - @width.setter - def width(self, width): - cv.check_type('plot width', width, Iterable, Real) - cv.check_length('plot width', width, 3, 3) - self._width = width - - @property - def origin(self): - return self._origin - - @origin.setter - def origin(self, origin): - cv.check_type('plot origin', origin, Iterable, Real) - cv.check_length('plot origin', origin, 3) - self._origin = origin - - def __repr__(self): - string = 'VoxelPlot\n' - string += '{: <16}=\t{}\n'.format('\tID', self._id) - string += '{: <16}=\t{}\n'.format('\tName', self._name) - string += '{: <16}=\t{}\n'.format('\tFilename', self._filename) - string += '{: <16}=\t{}\n'.format('\tWidth', self._width) - string += '{: <16}=\t{}\n'.format('\tOrigin', self._origin) - string += '{: <16}=\t{}\n'.format('\tPixels', self._pixels) - string += '{: <16}=\t{}\n'.format('\tColor by', self._color_by) - string += '{: <16}=\t{}\n'.format('\tBackground', self._background) - string += '{: <16}=\t{}\n'.format('\tMask components', - self._mask_components) - string += '{: <16}=\t{}\n'.format('\tMask background', - self._mask_background) - string += '{: <16}=\t{}\n'.format('\tOverlap Color', - self._overlap_color) - string += '{: <16}=\t{}\n'.format('\tColors', self._colors) - string += '{: <16}=\t{}\n'.format('\tLevel', self._level) - return string - - def to_xml_element(self): - """Return XML representation of the voxel plot - - Returns - ------- - element : lxml.etree._Element - XML element containing plot data - - """ - - element = super().to_xml_element() - element.set("type", "voxel") - - subelement = ET.SubElement(element, "origin") - subelement.text = ' '.join(map(str, self._origin)) - - subelement = ET.SubElement(element, "width") - subelement.text = ' '.join(map(str, self._width)) - - if self._colors: - self._colors_to_xml(element) - - if self._show_overlaps: - subelement = ET.SubElement(element, "show_overlaps") - subelement.text = "true" - - if self._overlap_color is not None: - color = self._overlap_color - if isinstance(color, str): - color = _SVG_COLORS[color.lower()] - subelement = ET.SubElement(element, "overlap_color") - subelement.text = ' '.join(str(x) for x in color) - - return element - - @classmethod - def from_xml_element(cls, elem): - """Generate plot object from an XML element - - Parameters - ---------- - elem : lxml.etree._Element - XML element - - Returns - ------- - openmc.VoxelPlot - VoxelPlot object - - """ - plot_id = int(get_text(elem, "id")) - name = get_text(elem, 'name', '') - plot = cls(plot_id, name) - if "filename" in elem.keys(): - plot.filename = get_text(elem, "filename") - plot.color_by = get_text(elem, "color_by") - - plot.origin = tuple(get_elem_list(elem, "origin", float)) - plot.width = tuple(get_elem_list(elem, "width", float)) - plot.pixels = tuple(get_elem_list(elem, "pixels")) - background = get_elem_list(elem, "background") - if background is not None: - plot._background = tuple(background) - - # Set plot colors - colors = {} - for color_elem in elem.findall("color"): - uid = int(get_text(color_elem, "id")) - colors[uid] = tuple(get_elem_list(color_elem, "rgb", int)) - plot.colors = colors - - # Set masking information - mask_elem = elem.find("mask") - if mask_elem is not None: - plot.mask_components = get_elem_list(mask_elem, "components", int) - background = get_elem_list(mask_elem, "background", int) - if background is not None: - plot.mask_background = tuple(background) - - # show overlaps - overlap = get_text(elem, "show_overlaps") - if overlap is not None: - plot.show_overlaps = (overlap in ('true', '1')) - overlap_color = get_elem_list(elem, "overlap_color", int) - if overlap_color is not None: - plot.overlap_color = tuple(overlap_color) - - # Set universe level - level = get_text(elem, "level") - if level is not None: - plot.level = int(level) - - return plot - - def to_vtk(self, output: PathLike | None = None, + def to_vtk(self, output: Optional[PathLike] = None, openmc_exec: str = 'openmc', cwd: str = '.'): - """Render plot as a voxel image + """Render plot as an voxel image This method runs OpenMC in plotting mode to produce a .vti file. @@ -1358,6 +965,9 @@ class VoxelPlot(PlotBase): Path of the .vti file produced """ + if self.type != 'voxel': + raise ValueError('Generating a VTK file only works for voxel plots') + # Create plots.xml Plots([self]).export_to_xml(cwd) @@ -1377,31 +987,20 @@ class VoxelPlot(PlotBase): return voxel_to_vtk(h5_voxel_file, output) -def Plot(plot_id=None, name=''): - """Legacy Plot class for backward compatibility. - - .. deprecated:: 0.15.4 - Use :class:`SlicePlot` for 2D slice plots or :class:`VoxelPlot` for 3D voxel plots. - - """ - warnings.warn( - "The Plot class is deprecated. Use SlicePlot for 2D slice plots " - "or VoxelPlot for 3D voxel plots.", FutureWarning - ) - return SlicePlot(plot_id, name) - - -class RayTracePlot(PlotBase): +class ProjectionPlot(PlotBase): """Definition of a camera's view of OpenMC geometry + Colors are defined in the same manner as the Plot class, but with the addition + of a coloring parameter resembling a macroscopic cross section in units of inverse + centimeters. The volume rendering technique is used to color regions of the model. + An infinite cross section denotes a fully opaque region, and zero represents a + transparent region which will expose the color of the regions behind it. + The camera projection may either by orthographic or perspective. Perspective - projections are more similar to a pinhole camera, and orthographic - projections preserve parallel lines and distances. + projections are more similar to a pinhole camera, and orthographic projections + preserve parallel lines and distances. - This is an abstract base class that :class:`WireframeRayTracePlot` and - :class:`SolidRayTracePlot` finish the implementation of. - - .. versionadded:: 0.15.1 + .. versionadded:: 0.14.0 Parameters ---------- @@ -1429,6 +1028,21 @@ class RayTracePlot(PlotBase): unlike with the default perspective projection. The height of the array is deduced from the ratio of pixel dimensions for the image. Defaults to zero, i.e. using perspective projection. + wireframe_thickness : int + Line thickness employed for drawing wireframes around cells or + material regions. Can be set to zero for no wireframes at all. + Defaults to one pixel. + wireframe_color : tuple of ints + RGB color of the wireframe lines. Defaults to black. + wireframe_domains : iterable of either Material or Cells + If provided, the wireframe is only drawn around these. + If color_by is by material, it must be a list of materials, else cells. + xs : dict + A mapping from cell/material IDs to floats. The floating point values + are macroscopic cross sections influencing the volume rendering opacity + of each geometric region. Zero corresponds to perfect transparency, and + infinity equivalent to opaque. These must be set by the user, but default + values can be obtained using the set_transparent method. """ def __init__(self, plot_id=None, name=''): @@ -1439,6 +1053,10 @@ class RayTracePlot(PlotBase): self._look_at = (0.0, 0.0, 0.0) self._up = (0.0, 0.0, 1.0) self._orthographic_width = 0.0 + self._wireframe_thickness = 1 + self._wireframe_color = _SVG_COLORS['black'] + self._wireframe_domains = [] + self._xs = {} @property def horizontal_field_of_view(self): @@ -1492,206 +1110,6 @@ class RayTracePlot(PlotBase): assert orthographic_width >= 0.0 self._orthographic_width = orthographic_width - def _check_domains_consistent_with_color_by(self, domains): - """Check domains are the same as the type we are coloring by""" - for region in domains: - # if an integer is passed, we have to assume it was a valid ID - if isinstance(region, int): - continue - - if self._color_by == 'material': - if not isinstance(region, openmc.Material): - raise Exception('Domain list must be materials if ' - 'color_by=material') - else: - if not isinstance(region, openmc.Cell): - raise Exception('Domain list must be cells if ' - 'color_by=cell') - - def to_xml_element(self): - """Return XML representation of the ray trace plot - - Returns - ------- - element : lxml.etree._Element - XML element containing plot data - - """ - - element = super().to_xml_element() - element.set("id", str(self._id)) - - subelement = ET.SubElement(element, "camera_position") - subelement.text = ' '.join(map(str, self._camera_position)) - - subelement = ET.SubElement(element, "look_at") - subelement.text = ' '.join(map(str, self._look_at)) - - subelement = ET.SubElement(element, "horizontal_field_of_view") - subelement.text = str(self._horizontal_field_of_view) - - # do not need to write if orthographic_width == 0.0 - if self._orthographic_width > 0.0: - subelement = ET.SubElement(element, "orthographic_width") - subelement.text = str(self._orthographic_width) - - return element - - def __repr__(self): - string = '' - string += '{: <16}=\t{}\n'.format('\tID', self._id) - string += '{: <16}=\t{}\n'.format('\tName', self._name) - string += '{: <16}=\t{}\n'.format('\tFilename', self._filename) - string += '{: <16}=\t{}\n'.format('\tHorizontal FOV', - self._horizontal_field_of_view) - string += '{: <16}=\t{}\n'.format('\tOrthographic width', - self._orthographic_width) - string += '{: <16}=\t{}\n'.format('\tCamera position', - self._camera_position) - string += '{: <16}=\t{}\n'.format('\tLook at', self._look_at) - string += '{: <16}=\t{}\n'.format('\tUp', self._up) - string += '{: <16}=\t{}\n'.format('\tPixels', self._pixels) - string += '{: <16}=\t{}\n'.format('\tColor by', self._color_by) - string += '{: <16}=\t{}\n'.format('\tBackground', self._background) - string += '{: <16}=\t{}\n'.format('\tColors', self._colors) - string += '{: <16}=\t{}\n'.format('\tLevel', self._level) - return string - - def _read_xml_attributes(self, elem): - """Helper function called by from_xml_element - of child classes. These are common vaues to be - read by any ray traced plot. - - Returns - ------- - None - """ - - filename = get_text(elem, "filename") - if filename is not None: - self.filename = filename - self.color_by = get_text(elem, "color_by") - - horizontal_fov = get_text(elem, "horizontal_field_of_view") - if horizontal_fov is not None: - self.horizontal_field_of_view = float(horizontal_fov) - - orthographic_width = get_text(elem, "orthographic_width") - if orthographic_width is not None: - self.orthographic_width = float(orthographic_width) - - self.pixels = tuple(get_elem_list(elem, "pixels", int)) - self.camera_position = tuple(get_elem_list(elem, "camera_position", float)) - self.look_at = tuple(get_elem_list(elem, "look_at", float)) - - background = get_elem_list(elem, "background", int) - if background is not None: - self.background = tuple(background) - - # Set masking information - if (mask_elem := elem.find("mask")) is not None: - mask_components = get_elem_list(mask_elem, "components", int) - # TODO: set mask components(needs geometry information) - background = get_elem_list(mask_elem, "background", int) - if background is not None: - self.mask_background = tuple(background) - - # Set universe level - level = get_text(elem, "level") - if level is not None: - self.level = int(level) - - -class WireframeRayTracePlot(RayTracePlot): - """Plots wireframes of geometry with volume rendered colors - - Colors are defined in the same manner as the Plot class, but with the - addition of a coloring parameter resembling a macroscopic cross section in - units of inverse centimeters. The volume rendering technique is used to - color regions of the model. An infinite cross section denotes a fully opaque - region, and zero represents a transparent region which will expose the color - of the regions behind it. - - .. versionchanged:: 0.15.1 - Renamed from ProjectionPlot to WireframeRayTracePlot - - Parameters - ---------- - plot_id : int - Unique identifier for the plot - name : str - Name of the plot - - Attributes - ---------- - id : int - Unique identifier - name : str - Name of the plot - pixels : Iterable of int - Number of pixels to use in each direction - filename : str - Path to write the plot to - color_by : {'cell', 'material'} - Indicate whether the plot should be colored by cell or by material - background : Iterable of int or str - Color of the background - mask_components : Iterable of openmc.Cell or openmc.Material or int - The cells or materials (or corresponding IDs) to mask - mask_background : Iterable of int or str - Color to apply to all cells/materials listed in mask_components - show_overlaps : bool - Indicate whether or not overlapping regions are shown - overlap_color : Iterable of int or str - Color to apply to overlapping regions - colors : dict - Dictionary indicating that certain cells/materials should be - displayed with a particular color. The keys can be of type - :class:`~openmc.Cell`, :class:`~openmc.Material`, or int (ID for a - cell/material). - level : int - Universe depth to plot at - horizontal_field_of_view : float - Field of view horizontally, in units of degrees, defaults to 70. - camera_position : tuple or list of ndarray - Position of the camera in 3D space. Defaults to (1, 0, 0). - look_at : tuple or list of ndarray - The center of the camera's image points to this place in 3D space. - Set to (0, 0, 0) by default. - up : tuple or list of ndarray - Which way is up for the camera. Must not be parallel to the - line between look_at and camera_position. Set to (0, 0, 1) by default. - orthographic_width : float - If set to a nonzero value, an orthographic projection is used. - All rays traced from the orthographic pixel array travel in the - same direction. The width of the starting array must be specified, - unlike with the default perspective projection. The height of the - array is deduced from the ratio of pixel dimensions for the image. - Defaults to zero, i.e. using perspective projection. - wireframe_thickness : int - Line thickness employed for drawing wireframes around cells or material - regions. Can be set to zero for no wireframes at all. Defaults to one - pixel. - wireframe_color : tuple of ints - RGB color of the wireframe lines. Defaults to black. - wireframe_domains : iterable of either Material or Cells - If provided, the wireframe is only drawn around these. If color_by is by - material, it must be a list of materials, else cells. - xs : dict - A mapping from cell/material IDs to floats. The floating point values - are macroscopic cross sections influencing the volume rendering opacity - of each geometric region. Zero corresponds to perfect transparency, and - infinity equivalent to opaque. These must be set by the user, but - default values can be obtained using the :meth:`set_transparent` method. - """ - - def __init__(self, plot_id=None, name=''): - super().__init__(plot_id, name) - self._wireframe_thickness = 1 - self._wireframe_color = _SVG_COLORS['black'] - self._wireframe_domains = [] - self._xs = {} - @property def wireframe_thickness(self): return self._wireframe_thickness @@ -1718,6 +1136,15 @@ class WireframeRayTracePlot(RayTracePlot): @wireframe_domains.setter def wireframe_domains(self, wireframe_domains): + for region in wireframe_domains: + if self._color_by == 'material': + if not isinstance(region, openmc.Material): + raise Exception('Must provide a list of materials for \ + wireframe_region if color_by=Material') + else: + if not isinstance(region, openmc.Cell): + raise Exception('Must provide a list of cells for \ + wireframe_region if color_by=cell') self._wireframe_domains = wireframe_domains @property @@ -1754,18 +1181,6 @@ class WireframeRayTracePlot(RayTracePlot): for domain in domains: self.xs[domain] = 0.0 - def __repr__(self): - string = 'Wireframe Ray-traced Plot\n' - string += super().__repr__() - string += '{: <16}=\t{}\n'.format('\tWireframe thickness', - self._wireframe_thickness) - string += '{: <16}=\t{}\n'.format('\tWireframe color', - self._wireframe_color) - string += '{: <16}=\t{}\n'.format('\tWireframe domains', - self._wireframe_domains) - string += '{: <16}=\t{}\n'.format('\tTransparencies', self._xs) - return string - def to_xml_element(self): """Return XML representation of the projection plot @@ -1775,8 +1190,15 @@ class WireframeRayTracePlot(RayTracePlot): XML element containing plot data """ + element = super().to_xml_element() - element.set("type", "wireframe_raytrace") + element.set("type", "projection") + + subelement = ET.SubElement(element, "camera_position") + subelement.text = ' '.join(map(str, self._camera_position)) + + subelement = ET.SubElement(element, "look_at") + subelement.text = ' '.join(map(str, self._look_at)) subelement = ET.SubElement(element, "wireframe_thickness") subelement.text = str(self._wireframe_thickness) @@ -1787,8 +1209,6 @@ class WireframeRayTracePlot(RayTracePlot): color = _SVG_COLORS[color.lower()] subelement.text = ' '.join(str(x) for x in color) - self._check_domains_consistent_with_color_by(self.wireframe_domains) - if self._wireframe_domains: id_list = [x.id for x in self._wireframe_domains] subelement = ET.SubElement(element, "wireframe_ids") @@ -1806,213 +1226,43 @@ class WireframeRayTracePlot(RayTracePlot): subelement.set("rgb", ' '.join(str(x) for x in color)) subelement.set("xs", str(self._xs[domain])) + subelement = ET.SubElement(element, "horizontal_field_of_view") + subelement.text = str(self._horizontal_field_of_view) + + # do not need to write if orthographic_width == 0.0 + if self._orthographic_width > 0.0: + subelement = ET.SubElement(element, "orthographic_width") + subelement.text = str(self._orthographic_width) + return element - @classmethod - def from_xml_element(cls, elem): - """Generate plot object from an XML element - - Parameters - ---------- - elem : lxml.etree._Element - XML element - - Returns - ------- - openmc.WireframeRayTracePlot - WireframeRayTracePlot object - - """ - - plot_id = int(get_text(elem, "id")) - plot_name = get_text(elem, 'name', '') - plot = cls(plot_id, plot_name) - plot.type = "wireframe_raytrace" - - plot._read_xml_attributes(elem) - - # Attempt to get wireframe thickness.May not be present - wireframe_thickness = get_text(elem, "wireframe_thickness") - if wireframe_thickness is not None: - plot.wireframe_thickness = int(wireframe_thickness) - wireframe_color = get_elem_list(elem, "wireframe_color", int) - if wireframe_color: - plot.wireframe_color = wireframe_color - - # Set plot colors - for color_elem in elem.findall("color"): - uid = int(get_text(color_elem, "id")) - plot.colors[uid] = tuple(get_elem_list(color_elem, "rgb", int)) - plot.xs[uid] = float(get_text(color_elem, "xs")) - - return plot - - -class SolidRayTracePlot(RayTracePlot): - """Phong shading-based rendering of an OpenMC geometry - - This class defines a plot that uses Phong shading to enhance the - visualization of an OpenMC geometry by incorporating diffuse lighting and - configurable opacity for certain regions. It extends :class:`RayTracePlot` - by adding parameters related to lighting and transparency. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - plot_id : int, optional - Unique identifier for the plot - name : str, optional - Name of the plot - - Attributes - ---------- - id : int - Unique identifier - name : str - Name of the plot - pixels : Iterable of int - Number of pixels to use in each direction - filename : str - Path to write the plot to - color_by : {'cell', 'material'} - Indicate whether the plot should be colored by cell or by material - overlap_color : Iterable of int or str - Color to apply to overlapping regions - colors : dict - Dictionary indicating that certain cells/materials should be - displayed with a particular color. The keys can be of type - :class:`~openmc.Cell`, :class:`~openmc.Material`, or int (ID for a - cell/material). - horizontal_field_of_view : float - Field of view horizontally, in units of degrees, defaults to 70. - camera_position : tuple or list of ndarray - Position of the camera in 3D space. Defaults to (1, 0, 0). - look_at : tuple or list of ndarray - The center of the camera's image points to this place in 3D space. - Set to (0, 0, 0) by default. - up : tuple or list of ndarray - Which way is up for the camera. Must not be parallel to the - line between look_at and camera_position. Set to (0, 0, 1) by default. - orthographic_width : float - If set to a nonzero value, an orthographic projection is used. - All rays traced from the orthographic pixel array travel in the - same direction. The width of the starting array must be specified, - unlike with the default perspective projection. The height of the - array is deduced from the ratio of pixel dimensions for the image. - Defaults to zero, i.e. using perspective projection. - light_position : tuple or list of float - Position of the light source in 3D space. Defaults to None, which places - the light at the camera position. - diffuse_fraction : float - Fraction of lighting that is diffuse (non-directional). Defaults to 0.1. - Must be between 0 and 1. - opaque_domains : list - List of domains (e.g., cells or materials) that should be rendered as - opaque rather than allowing transparency. - """ - - def __init__(self, plot_id=None, name=''): - super().__init__(plot_id, name) - self._light_position = None - self._diffuse_fraction = 0.1 - self._opaque_domains = [] - - @property - def light_position(self): - return self._light_position - - @light_position.setter - def light_position(self, x): - cv.check_type('plot light position', x, Iterable, Real) - cv.check_length('plot light position', x, 3) - self._light_position = x - - @property - def diffuse_fraction(self): - return self._diffuse_fraction - - @diffuse_fraction.setter - def diffuse_fraction(self, x): - cv.check_type('diffuse fraction', x, Real) - cv.check_greater_than('diffuse fraction', x, 0.0, equality=True) - cv.check_less_than('diffuse fraction', x, 1.0, equality=True) - self._diffuse_fraction = x - - @property - def opaque_domains(self): - return self._opaque_domains - - @opaque_domains.setter - def opaque_domains(self, x): - # Note that _check_domains_consistent_with_color_by checks - # the types within later. This is because we don't necessarily - # know what types are acceptable until the user has set the - # color_by attribute, too. - cv.check_type('opaque domains', x, Iterable) - self._opaque_domains = x - def __repr__(self): - string = 'Solid Ray-traced Plot\n' - string += super().__repr__() - string += '{: <16}=\t{}\n'.format('\tDiffuse Fraction', - self._diffuse_fraction) - string += '{: <16}=\t{}\n'.format('\tLight position', - self._light_position) - string += '{: <16}=\t{}\n'.format('\tOpaque domains', - self._opaque_domains) + string = 'Projection Plot\n' + string += '{: <16}=\t{}\n'.format('\tID', self._id) + string += '{: <16}=\t{}\n'.format('\tName', self._name) + string += '{: <16}=\t{}\n'.format('\tFilename', self._filename) + string += '{: <16}=\t{}\n'.format('\tHorizontal FOV', + self._horizontal_field_of_view) + string += '{: <16}=\t{}\n'.format('\tOrthographic width', + self._orthographic_width) + string += '{: <16}=\t{}\n'.format('\tWireframe thickness', + self._wireframe_thickness) + string += '{: <16}=\t{}\n'.format('\tWireframe color', + self._wireframe_color) + string += '{: <16}=\t{}\n'.format('\tWireframe domains', + self._wireframe_domains) + string += '{: <16}=\t{}\n'.format('\tCamera position', + self._camera_position) + string += '{: <16}=\t{}\n'.format('\tLook at', self._look_at) + string += '{: <16}=\t{}\n'.format('\tUp', self._up) + string += '{: <16}=\t{}\n'.format('\tPixels', self._pixels) + string += '{: <16}=\t{}\n'.format('\tColor by', self._color_by) + string += '{: <16}=\t{}\n'.format('\tBackground', self._background) + string += '{: <16}=\t{}\n'.format('\tColors', self._colors) + string += '{: <16}=\t{}\n'.format('\tTransparencies', self._xs) + string += '{: <16}=\t{}\n'.format('\tLevel', self._level) return string - def to_xml_element(self): - """Return XML representation of the solid ray-traced plot - - Returns - ------- - element : lxml.etree._Element - XML element containing plot data - - """ - element = super().to_xml_element() - element.set("type", "solid_raytrace") - - # no light position means put it at the camera - if self._light_position: - subelement = ET.SubElement(element, "light_position") - subelement.text = ' '.join(map(str, self._light_position)) - - # no diffuse fraction defaults to 0.1 - if self._diffuse_fraction: - subelement = ET.SubElement(element, "diffuse_fraction") - subelement.text = str(self._diffuse_fraction) - - self._check_domains_consistent_with_color_by(self.opaque_domains) - subelement = ET.SubElement(element, "opaque_ids") - - # Extract all IDs, or use the integer value passed in - # explicitly if that was given - subelement.text = ' '.join( - [str(domain) if isinstance(domain, int) else - str(domain.id) for domain in self._opaque_domains]) - - if self._colors: - self._colors_to_xml(element) - - return element - - def _read_phong_attributes(self, elem): - """Read attributes specific to the Phong plot from an XML element""" - light_position = get_elem_list(elem, 'light_position', float) - if light_position is not None: - self.light_position = tuple(light_position) - - diffuse_fraction = get_text(elem, "diffuse_fraction") - if diffuse_fraction is not None: - self.diffuse_fraction = float(diffuse_fraction) - - opaque_domains = get_elem_list(elem, 'opaque_ids', int) - if opaque_domains is not None: - self.opaque_domains = opaque_domains - @classmethod def from_xml_element(cls, elem): """Generate plot object from an XML element @@ -2024,51 +1274,88 @@ class SolidRayTracePlot(RayTracePlot): Returns ------- - openmc.WireframeRayTracePlot - WireframeRayTracePlot object + openmc.ProjectionPlot + ProjectionPlot object """ + plot_id = int(elem.get("id")) + plot = cls(plot_id) + if "filename" in elem.keys(): + plot.filename = elem.get("filename") + plot.color_by = elem.get("color_by") + plot.type = "projection" - plot_id = int(get_text(elem, "id")) - plot_name = get_text(elem, 'name', '') - plot = cls(plot_id, plot_name) - plot.type = "solid_raytrace" + horizontal_fov = elem.find("horizontal_field_of_view") + if horizontal_fov is not None: + plot.horizontal_field_of_view = float(horizontal_fov.text) - plot._read_xml_attributes(elem) - plot._read_phong_attributes(elem) + tmp = elem.find("orthographic_width") + if tmp is not None: + plot.orthographic_width = float(tmp) + + plot.pixels = get_elem_tuple(elem, "pixels") + plot.camera_position = get_elem_tuple(elem, "camera_position", float) + plot.look_at = get_elem_tuple(elem, "look_at", float) + + # Attempt to get wireframe thickness. May not be present + wireframe_thickness = elem.get("wireframe_thickness") + if wireframe_thickness: + plot.wireframe_thickness = int(wireframe_thickness) + wireframe_color = elem.get("wireframe_color") + if wireframe_color: + plot.wireframe_color = [int(item) for item in wireframe_color] # Set plot colors + colors = {} + xs = {} for color_elem in elem.findall("color"): - uid = get_text(color_elem, "id") - plot.colors[uid] = tuple(get_elem_list(color_elem, "rgb", int)) + uid = color_elem.get("id") + colors[uid] = get_elem_tuple(color_elem, "rgb") + xs[uid] = float(color_elem.get("xs")) + + # Set masking information + mask_elem = elem.find("mask") + if mask_elem is not None: + mask_components = [int(x) + for x in mask_elem.get("components").split()] + # TODO: set mask components (needs geometry information) + background = mask_elem.get("background") + if background is not None: + plot.mask_background = tuple( + [int(x) for x in background.split()]) + + # Set universe level + level = elem.find("level") + if level is not None: + plot.level = int(level.text) return plot class Plots(cv.CheckedList): - """Collection of plots used for an OpenMC simulation. + """Collection of Plots used for an OpenMC simulation. This class corresponds directly to the plots.xml input file. It can be thought of as a normal Python list where each member is inherits from :class:`PlotBase`. It behaves like a list as the following example demonstrates: - >>> xz_plot = openmc.SlicePlot() - >>> big_plot = openmc.VoxelPlot() - >>> small_plot = openmc.SlicePlot() + >>> xz_plot = openmc.Plot() + >>> big_plot = openmc.Plot() + >>> small_plot = openmc.Plot() >>> p = openmc.Plots((xz_plot, big_plot)) >>> p.append(small_plot) >>> small_plot = p.pop() Parameters ---------- - plots : Iterable of openmc.PlotBase + plots : Iterable of openmc.Plot or openmc.ProjectionPlot plots to add to the collection """ def __init__(self, plots=None): - super().__init__(PlotBase, 'plots collection') + super().__init__((Plot, ProjectionPlot), 'plots collection') self._plots_file = ET.Element("plots") if plots is not None: self += plots @@ -2078,7 +1365,7 @@ class Plots(cv.CheckedList): Parameters ---------- - plot : openmc.PlotBase + plot : openmc.Plot or openmc.ProjectionPlot Plot to append """ @@ -2091,7 +1378,7 @@ class Plots(cv.CheckedList): ---------- index : int Index in list - plot : openmc.PlotBase + plot : openmc.Plot Plot to insert """ @@ -2167,6 +1454,8 @@ class Plots(cv.CheckedList): # Clean the indentation in the file to be user-readable clean_indentation(self._plots_file) + # TODO: Remove when support is Python 3.8+ + reorder_attributes(self._plots_file) return self._plots_file @@ -2207,20 +1496,11 @@ class Plots(cv.CheckedList): # Generate each plot plots = cls() for e in elem.findall('plot'): - plot_type = get_text(e, "type") - if plot_type == 'wireframe_raytrace': - plots.append(WireframeRayTracePlot.from_xml_element(e)) - elif plot_type == 'solid_raytrace': - plots.append(SolidRayTracePlot.from_xml_element(e)) - elif plot_type == 'slice': - plots.append(SlicePlot.from_xml_element(e)) - elif plot_type == 'voxel': - plots.append(VoxelPlot.from_xml_element(e)) - elif plot_type is None: - # For backward compatibility, assume slice if no type specified - plots.append(SlicePlot.from_xml_element(e)) + plot_type = e.get('type') + if plot_type == 'projection': + plots.append(ProjectionPlot.from_xml_element(e)) else: - raise ValueError("Unknown plot type: {}".format(plot_type)) + plots.append(Plot.from_xml_element(e)) return plots @classmethod diff --git a/openmc/plotter.py b/openmc/plotter.py index abd8ab6dd..8b205b79d 100644 --- a/openmc/plotter.py +++ b/openmc/plotter.py @@ -1,7 +1,5 @@ -from __future__ import annotations from itertools import chain from numbers import Integral, Real -from typing import Dict, Iterable, List import numpy as np @@ -122,29 +120,18 @@ def _get_title(reactions): return 'Cross Section Plot' -def plot_xs( - reactions: Dict[str | openmc.Material, List[str]], - divisor_types: Iterable[str] | None = None, - temperature: float = 294.0, - axis: "plt.Axes" | None = None, - sab_name: str | None = None, - ce_cross_sections: str | None = None, - mg_cross_sections: str | None = None, - enrichment: float | None = None, - plot_CE: bool = True, - orders: Iterable[int] | None = None, - divisor_orders: Iterable[int] | None = None, - energy_axis_units: str = "eV", - **kwargs, -) -> "plt.Figure" | None: +def plot_xs(reactions, divisor_types=None, temperature=294., axis=None, + sab_name=None, ce_cross_sections=None, mg_cross_sections=None, + enrichment=None, plot_CE=True, orders=None, divisor_orders=None, + energy_axis_units="eV", **kwargs): """Creates a figure of continuous-energy cross sections for this item. Parameters ---------- reactions : dict keys can be either a nuclide or element in string form or an - openmc.Material object. Values are a list of the types of - cross sections to include in the plot. + openmc.Material object. Values are the type of cross sections to + include in the plot. divisor_types : Iterable of values of PLOT_TYPES, optional Cross section types which will divide those produced by types before plotting. A type of 'unity' can be used to effectively not @@ -288,6 +275,7 @@ def plot_xs( return fig + def calculate_cexs(this, types, temperature=294., sab_name=None, cross_sections=None, enrichment=None, ncrystal_cfg=None): """Calculates continuous-energy cross sections of a requested type. @@ -413,8 +401,7 @@ def _calculate_cexs_nuclide(this, types, temperature=294., sab_name=None, # Prep S(a,b) data if needed if sab_name: - sab = openmc.data.ThermalScattering.from_hdf5( - library.get_by_material(sab_name, data_type='thermal')['path']) + sab = openmc.data.ThermalScattering.from_hdf5(sab_name) # Obtain the nearest temperature if strT in sab.temperatures: sabT = strT @@ -501,7 +488,7 @@ def _calculate_cexs_nuclide(this, types, temperature=294., sab_name=None, elif ncrystal_cfg: import NCrystal nc_scatter = NCrystal.createScatter(ncrystal_cfg) - nc_func = nc_scatter.xsect + nc_func = nc_scatter.crossSectionNonOriented nc_emax = 5 # eV # this should be obtained from NCRYSTAL_MAX_ENERGY energy_grid = np.union1d(np.geomspace(min(energy_grid), 1.1*nc_emax, @@ -641,13 +628,14 @@ def _calculate_cexs_elem_mat(this, types, temperature=294., sab = openmc.data.ThermalScattering.from_hdf5( library.get_by_material(sab_name, data_type='thermal')['path']) for nuc in sab.nuclides: - sabs[nuc] = sab_name + sabs[nuc] = library.get_by_material(sab_name, + data_type='thermal')['path'] else: if sab_name: - sab = openmc.data.ThermalScattering.from_hdf5( - library.get_by_material(sab_name, data_type='thermal')['path']) + sab = openmc.data.ThermalScattering.from_hdf5(sab_name) for nuc in sab.nuclides: - sabs[nuc] = sab_name + sabs[nuc] = library.get_by_material(sab_name, + data_type='thermal')['path'] # Now we can create the data sets to be plotted xs = {} @@ -655,8 +643,8 @@ def _calculate_cexs_elem_mat(this, types, temperature=294., for nuclide in nuclides.items(): name = nuclide[0] nuc = nuclide[1] - sab_name = sabs[name] - temp_E, temp_xs = calculate_cexs(nuc, types, T, sab_name, cross_sections, + sab_tab = sabs[name] + temp_E, temp_xs = calculate_cexs(nuc, types, T, sab_tab, cross_sections, ncrystal_cfg=ncrystal_cfg ) E.append(temp_E) diff --git a/openmc/polynomial.py b/openmc/polynomial.py index 341cdff47..1259c61ca 100644 --- a/openmc/polynomial.py +++ b/openmc/polynomial.py @@ -92,7 +92,7 @@ class Zernike(Polynomial): Parameters ---------- coef : Iterable of float - A list of coefficients of each term in Zernike polynomials + A list of coefficients of each term in radial only Zernike polynomials radius : float Domain of Zernike polynomials to be applied on. Default is 1. diff --git a/openmc/region.py b/openmc/region.py index cb9f3abd2..e509b1528 100644 --- a/openmc/region.py +++ b/openmc/region.py @@ -1,4 +1,3 @@ -from __future__ import annotations from abc import ABC, abstractmethod from collections.abc import MutableSequence from copy import deepcopy @@ -8,7 +7,6 @@ import numpy as np import openmc from .bounding_box import BoundingBox -from .plots import add_plot_params class Region(ABC): @@ -32,9 +30,8 @@ class Region(ABC): def __or__(self, other): return Union((self, other)) - @abstractmethod - def __invert__(self) -> Region: - pass + def __invert__(self): + return Complement(self) @abstractmethod def __contains__(self, point): @@ -344,11 +341,47 @@ class Region(ABC): return type(self)(n.rotate(rotation, pivot=pivot, order=order, inplace=inplace, memo=memo) for n in self) - @add_plot_params def plot(self, *args, **kwargs): """Display a slice plot of the region. .. versionadded:: 0.15.0 + + Parameters + ---------- + origin : iterable of float + Coordinates at the origin of the plot. If left as None then the + bounding box center will be used to attempt to ascertain the origin. + Defaults to (0, 0, 0) if the bounding box is not finite + width : iterable of float + Width of the plot in each basis direction. If left as none then the + bounding box width will be used to attempt to ascertain the plot + width. Defaults to (10, 10) if the bounding box is not finite + pixels : Iterable of int or int + If iterable of ints provided, then this directly sets the number of + pixels to use in each basis direction. If int provided, then this + sets the total number of pixels in the plot and the number of pixels + in each basis direction is calculated from this total and the image + aspect ratio. + basis : {'xy', 'xz', 'yz'} + The basis directions for the plot + seed : int + Seed for the random number generator + openmc_exec : str + Path to OpenMC executable. + axes : matplotlib.Axes + Axes to draw to + outline : bool + Whether outlines between color boundaries should be drawn + axis_units : {'km', 'm', 'cm', 'mm'} + Units used on the plot axis + **kwargs + Keyword arguments passed to :func:`matplotlib.pyplot.imshow` + + Returns + ------- + matplotlib.axes.Axes + Axes containing resulting image + """ for key in ('color_by', 'colors', 'legend', 'legend_kwargs'): if key in kwargs: @@ -409,9 +442,6 @@ class Intersection(Region, MutableSequence): self.append(other) return self - def __invert__(self) -> Union: - return Union(~n for n in self) - # Implement mutable sequence protocol by delegating to list def __getitem__(self, key): return self._nodes[key] @@ -500,9 +530,6 @@ class Union(Region, MutableSequence): self.append(other) return self - def __invert__(self) -> Intersection: - return Intersection(~n for n in self) - # Implement mutable sequence protocol by delegating to list def __getitem__(self, key): return self._nodes[key] @@ -576,7 +603,7 @@ class Complement(Region): """ - def __init__(self, node: Region): + def __init__(self, node): self.node = node def __contains__(self, point): @@ -595,9 +622,6 @@ class Complement(Region): """ return point not in self.node - def __invert__(self) -> Region: - return self.node - def __str__(self): return '~' + str(self.node) @@ -613,7 +637,18 @@ class Complement(Region): @property def bounding_box(self) -> BoundingBox: - return (~self.node).bounding_box + # Use De Morgan's laws to distribute the complement operator so that it + # only applies to surface half-spaces, thus allowing us to calculate the + # bounding box in the usual recursive manner. + if isinstance(self.node, Union): + temp_region = Intersection(~n for n in self.node) + elif isinstance(self.node, Intersection): + temp_region = Union(~n for n in self.node) + elif isinstance(self.node, Complement): + temp_region = self.node.node + else: + temp_region = ~self.node + return temp_region.bounding_box def get_surfaces(self, surfaces=None): """Recursively find and return all the surfaces referenced by the node diff --git a/openmc/settings.py b/openmc/settings.py index 22f36b262..fae6f6383 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -1,23 +1,21 @@ -from collections.abc import Iterable, Mapping, MutableSequence, Sequence +from collections.abc import Iterable, Mapping, MutableSequence from enum import Enum import itertools from math import ceil from numbers import Integral, Real from pathlib import Path -import traceback +import typing # required to prevent typing.Union namespace overwriting Union +from typing import Optional import lxml.etree as ET -import warnings -import openmc + import openmc.checkvalue as cv -from openmc.checkvalue import PathLike from openmc.stats.multivariate import MeshSpatial -from ._xml import clean_indentation, get_elem_list, get_text -from .mesh import _read_meshes, RegularMesh, MeshBase -from .source import SourceBase, MeshSource, IndependentSource -from .utility_funcs import input_path -from .volume import VolumeCalculation -from .weight_windows import WeightWindows, WeightWindowGenerator, WeightWindowsList +from . import (RegularMesh, SourceBase, MeshSource, IndependentSource, + VolumeCalculation, WeightWindows, WeightWindowGenerator) +from ._xml import clean_indentation, get_text, reorder_attributes +from openmc.checkvalue import PathLike +from .mesh import _read_meshes class RunMode(Enum): @@ -41,10 +39,6 @@ class Settings: Attributes ---------- - atomic_relaxation : bool - Whether to simulate the atomic relaxation cascade (fluorescence photons - and Auger electrons) following photoelectric and incoherent scattering - interactions. batches : int Number of batches to simulate confidence_intervals : bool @@ -52,42 +46,19 @@ class Settings: half-width of the 95% two-sided confidence interval. If False, uncertainties on tally results will be reported as the sample standard deviation. - collision_track : dict - Options for writing collision information. Acceptable keys are: - - :max_collisions: Maximum number of collisions to be banked per file. (int) - :max_collision_track_files: Maximum number of collision_track files. (int) - :mcpl: Output in the form of an MCPL-file. (bool) - :cell_ids: List of cell IDs to define cells in which collisions should be banked. (list of int) - :universe_ids: List of universe IDs to define universes in which collisions should be banked. (list of int) - :material_ids: List of material IDs to define materials in which collisions should be banked. (list of int) - :nuclides: List of nuclides to define nuclides in which collisions should be banked. - (ex: ["I135m", "U233"] ). (list of str) - :reactions: List of reaction to define specific reactions that should be banked - (ex: ["(n,fission)", 2, "(n,2n)"] ). (list of str or int) - :deposited_E_threshold: Number to define the minimum deposited energy during - per collision to trigger banking. (float) - create_delayed_neutrons : bool - Whether delayed neutrons are created in fission. - - .. versionadded:: 0.13.3 create_fission_neutrons : bool Indicate whether fission neutrons should be created or not. cutoff : dict Dictionary defining weight cutoff, energy cutoff and time cutoff. The - dictionary may have the following keys, 'weight', 'weight_avg', - 'survival_normalization', 'energy_neutron', 'energy_photon', - 'energy_electron', 'energy_positron', 'time_neutron', 'time_photon', - 'time_electron', and 'time_positron'. Value for 'weight' should be a - float indicating weight cutoff below which particle undergo Russian - roulette. Value for 'weight_avg' should be a float indicating weight - assigned to particles that are not killed after Russian roulette. Value - of energy should be a float indicating energy in eV below which particle - type will be killed. Value of time should be a float in seconds. - Particles will be killed exactly at the specified time. Value for - 'survival_normalization' is a bool indicating whether or not the weight - cutoff parameters will be applied relative to the particle's starting - weight or to its current weight. + dictionary may have ten keys, 'weight', 'weight_avg', 'energy_neutron', + 'energy_photon', 'energy_electron', 'energy_positron', 'time_neutron', + 'time_photon', 'time_electron', and 'time_positron'. Value for 'weight' + should be a float indicating weight cutoff below which particle undergo + Russian roulette. Value for 'weight_avg' should be a float indicating + weight assigned to particles that are not killed after Russian roulette. + Value of energy should be a float indicating energy in eV below which + particle type will be killed. Value of time should be a float in + seconds. Particles will be killed exactly at the specified time. delayed_photon_scaling : bool Indicate whether to scale the fission photon yield by (EGP + EGD)/EGP where EGP is the energy release of prompt photons and EGD is the energy @@ -108,15 +79,8 @@ class Settings: history-based parallelism. .. versionadded:: 0.12 - free_gas_threshold : float - Energy multiplier (in units of :math:`kT`) below which the free gas - scattering treatment is applied for elastic scattering. If not - specified, a value of 400.0 is used. generations_per_batch : int Number of generations per batch - ifp_n_generation : int - Number of generations to consider for the Iterated Fission Probability - method. max_lost_particles : int Maximum number of lost particles @@ -156,10 +120,6 @@ class Settings: Maximum number of times a particle can split during a history .. versionadded:: 0.13 - max_secondaries : int - Maximum secondary bank size - - .. versionadded:: 0.15.3 max_tracks : int Maximum number of tracks written to a track file (per MPI process). @@ -187,62 +147,16 @@ class Settings: Initial seed for randomly generated plot colors. ptables : bool Determine whether probability tables are used. - properties_file : PathLike - Location of the properties file to load cell temperatures/densities - and material densities random_ray : dict Options for configuring the random ray solver. Acceptable keys are: :distance_inactive: - Indicates the total inactive distance in [cm] a ray should travel + Indicates the total active distance in [cm] a ray should travel :distance_active: Indicates the total active distance in [cm] a ray should travel :ray_source: Starting ray distribution (must be uniform in space and angle) as specified by a :class:`openmc.SourceBase` object. - :volume_estimator: - Choice of volume estimator for the random ray solver. Options are - 'naive', 'simulation_averaged', or 'hybrid'. - The default is 'hybrid'. - :source_shape: - Assumed shape of the source distribution within each source region. - Options are 'flat' (default), 'linear', or 'linear_xy'. - :volume_normalized_flux_tallies: - Whether to normalize flux tallies by volume (bool). The default is - 'False'. When enabled, flux tallies will be reported in units of - cm/cm^3. When disabled, flux tallies will be reported in units of cm - (i.e., total distance traveled by neutrons in the spatial tally - region). - :adjoint: - Whether to run the random ray solver in adjoint mode (bool). The - default is 'False'. - :sample_method: - Sampling method for the ray starting location and direction of - travel. Options are `prng` (default), `halton`, or `s2`. `s2` - modifies the `prng` sampling method such that rays are sampled - with directions (-1, 0, 0) or (1, 0, 0). This is used for verification - against analytic transport benchmarks which are often derivied with - a reduced angular domain. - :source_region_meshes: - List of tuples where each tuple contains a mesh and a list of - domains. Each domain is an instance of openmc.Material, openmc.Cell, - or openmc.Universe. The mesh will be applied to the listed domains - to subdivide source regions so as to improve accuracy and/or conform - with tally meshes. - :diagonal_stabilization_rho: - The rho factor for use with diagonal stabilization. This technique is - applied when negative diagonal (in-group) elements are detected in - the scattering matrix of input MGXS data, which is a common feature - of transport corrected MGXS data. The default is 1.0, which ensures - no negative diagonal elements are present in the iteration matrix and - thus stabilizes the simulation. A value of 0.0 will disable diagonal - stabilization. Values between 0.0 and 1.0 will apply a degree of - stabilization, which may be desirable as stronger diagonal stabilization - also tends to dampen the convergence rate of the solver, thus requiring - more iterations to converge. - :adjoint_source: - Source object used to define localized adjoint source/detector response - function. .. versionadded:: 0.15.0 resonance_scattering : dict @@ -260,21 +174,8 @@ class Settings: The type of calculation to perform (default is 'eigenvalue') seed : int Seed for the linear congruential pseudorandom number generator - shared_secondary_bank : bool - Whether to use a shared secondary particle bank. When enabled, - secondary particles are collected into a global bank, sorted for - reproducibility, and load-balanced across MPI ranks between - generations. If not specified, the shared secondary bank is - enabled automatically for fixed-source simulations with weight - windows active, and disabled otherwise. - - .. versionadded:: 0.15.4 source : Iterable of openmc.SourceBase Distribution of source sites in space, angle, and energy - source_rejection_fraction : float - Minimum fraction of source sites that must be accepted when applying - rejection sampling based on constraints. If not specified, the default - value is 0.05. sourcepoint : dict Options for writing source points. Acceptable keys are: @@ -288,8 +189,6 @@ class Settings: Options for writing state points. Acceptable keys are: :batches: list of batches at which to write statepoint files - stride : int - Number of random numbers allocated for each source particle history surf_source_read : dict Options for reading surface source points. Acceptable keys are: @@ -301,7 +200,6 @@ class Settings: banked (int) :max_particles: Maximum number of particles to be banked on surfaces per process (int) - :max_source_files: Maximum number of surface source files to be created (int) :mcpl: Output in the form of an MCPL-file (bool) :cell: Cell ID used to determine if particles crossing identified surfaces are to be banked. Particles coming from or going to this @@ -312,14 +210,6 @@ class Settings: :cellto: Cell ID used to determine if particles crossing identified surfaces are to be banked. Particles going to this declared cell will be banked (int) - surface_grazing_cutoff : float - Surface flux cosine cutoff. If not specified, the default value is - 0.001. For more information, see the surface tally section in the theory - manual. - surface_grazing_ratio : float - Surface flux cosine substitution ratio. If not specified, the default - value is 0.5. For more information, see the surface tally section in the - theory manual. survival_biasing : bool Indicate whether survival biasing is to be used tabular_legendre : dict @@ -359,20 +249,15 @@ class Settings: Maximum number of batches simulated. If this is set, the number of batches specified via ``batches`` is interpreted as the minimum number of batches - uniform_source_sampling : bool - Whether to sampling among multiple sources uniformly, applying their - strengths as weights to sampled particles. ufs_mesh : openmc.RegularMesh Mesh to be used for redistributing source sites via the uniform fission site (UFS) method. - use_decay_photons : bool - Produce decay photons from neutron reactions instead of prompt verbosity : int Verbosity during simulation between 1 and 10. Verbosity levels are described in :ref:`verbosity`. volume_calculations : VolumeCalculation or iterable of VolumeCalculation Stochastic volume calculation specifications - weight_windows : WeightWindowsList + weight_windows : WeightWindows or iterable of WeightWindows Weight windows to use for variance reduction .. versionadded:: 0.13 @@ -386,6 +271,10 @@ class Settings: .. versionadded:: 0.14.0 + create_delayed_neutrons : bool + Whether delayed neutrons are created in fission. + + .. versionadded:: 0.13.3 weight_windows_on : bool Whether weight windows are enabled @@ -416,22 +305,14 @@ class Settings: # Source subelement self._source = cv.CheckedList(SourceBase, 'source distributions') - self._source_rejection_fraction = None self._confidence_intervals = None self._electron_treatment = None self._photon_transport = None - self._atomic_relaxation = None self._plot_seed = None self._ptables = None - self._properties_file = None - self._uniform_source_sampling = None self._seed = None - self._stride = None - self._surface_grazing_cutoff = None - self._surface_grazing_ratio = None self._survival_biasing = None - self._free_gas_threshold = None # Shannon entropy mesh self._entropy_mesh = None @@ -443,12 +324,6 @@ class Settings: self._output = None - # Iterated Fission Probability - self._ifp_n_generation = None - - # Collision track feature - self._collision_track = {} - # Output options self._statepoint = {} self._sourcepoint = {} @@ -487,33 +362,19 @@ class Settings: self._max_particles_in_flight = None self._max_particle_events = None self._write_initial_source = None - self._weight_windows = WeightWindowsList() - self._weight_window_generators = cv.CheckedList( - WeightWindowGenerator, 'weight window generators') + self._weight_windows = cv.CheckedList(WeightWindows, 'weight windows') + self._weight_window_generators = cv.CheckedList(WeightWindowGenerator, 'weight window generators') self._weight_windows_on = None - self._shared_secondary_bank = None self._weight_windows_file = None self._weight_window_checkpoints = {} self._max_history_splits = None self._max_tracks = None - self._max_secondaries = None - self._use_decay_photons = None self._random_ray = {} for key, value in kwargs.items(): setattr(self, key, value) - def __setattr__(self, name: str, value): - if not name.startswith('_'): - try: - getattr(self, name) - except AttributeError as e: - msg, = traceback.format_exception_only(e) - msg = msg.strip().split(maxsplit=1)[-1] - warnings.warn(msg, stacklevel=2) - super().__setattr__(name, value) - @property def run_mode(self) -> str: return self._run_mode.value @@ -541,9 +402,8 @@ class Settings: @generations_per_batch.setter def generations_per_batch(self, generations_per_batch: int): - cv.check_type('generations per batch', generations_per_batch, Integral) - cv.check_greater_than('generations per batch', - generations_per_batch, 0) + cv.check_type('generations per patch', generations_per_batch, Integral) + cv.check_greater_than('generations per batch', generations_per_batch, 0) self._generations_per_batch = generations_per_batch @property @@ -573,8 +433,7 @@ class Settings: @rel_max_lost_particles.setter def rel_max_lost_particles(self, rel_max_lost_particles: float): cv.check_type('rel_max_lost_particles', rel_max_lost_particles, Real) - cv.check_greater_than('rel_max_lost_particles', - rel_max_lost_particles, 0) + cv.check_greater_than('rel_max_lost_particles', rel_max_lost_particles, 0) cv.check_less_than('rel_max_lost_particles', rel_max_lost_particles, 1) self._rel_max_lost_particles = rel_max_lost_particles @@ -584,10 +443,8 @@ class Settings: @max_write_lost_particles.setter def max_write_lost_particles(self, max_write_lost_particles: int): - cv.check_type('max_write_lost_particles', - max_write_lost_particles, Integral) - cv.check_greater_than('max_write_lost_particles', - max_write_lost_particles, 0) + cv.check_type('max_write_lost_particles', max_write_lost_particles, Integral) + cv.check_greater_than('max_write_lost_particles', max_write_lost_particles, 0) self._max_write_lost_particles = max_write_lost_particles @property @@ -608,12 +465,12 @@ class Settings: def keff_trigger(self, keff_trigger: dict): if not isinstance(keff_trigger, dict): msg = f'Unable to set a trigger on keff from "{keff_trigger}" ' \ - 'which is not a Python dictionary' + 'which is not a Python dictionary' raise ValueError(msg) elif 'type' not in keff_trigger: msg = f'Unable to set a trigger on keff from "{keff_trigger}" ' \ - 'which does not have a "type" key' + 'which does not have a "type" key' raise ValueError(msg) elif keff_trigger['type'] not in ['variance', 'std_dev', 'rel_err']: @@ -623,7 +480,7 @@ class Settings: elif 'threshold' not in keff_trigger: msg = f'Unable to set a trigger on keff from "{keff_trigger}" ' \ - 'which does not have a "threshold" key' + 'which does not have a "threshold" key' raise ValueError(msg) elif not isinstance(keff_trigger['threshold'], Real): @@ -640,7 +497,7 @@ class Settings: @energy_mode.setter def energy_mode(self, energy_mode: str): cv.check_value('energy mode', energy_mode, - ['continuous-energy', 'multi-group']) + ['continuous-energy', 'multi-group']) self._energy_mode = energy_mode @property @@ -648,7 +505,7 @@ class Settings: return self._max_order @max_order.setter - def max_order(self, max_order: int | None): + def max_order(self, max_order: Optional[int]): if max_order is not None: cv.check_type('maximum scattering order', max_order, Integral) cv.check_greater_than('maximum scattering order', max_order, 0, @@ -656,15 +513,14 @@ class Settings: self._max_order = max_order @property - def source(self) -> list[SourceBase]: + def source(self) -> typing.List[SourceBase]: return self._source @source.setter - def source(self, source: SourceBase | Iterable[SourceBase]): + def source(self, source: typing.Union[SourceBase, typing.Iterable[SourceBase]]): if not isinstance(source, MutableSequence): source = [source] - self._source = cv.CheckedList( - SourceBase, 'source distributions', source) + self._source = cv.CheckedList(SourceBase, 'source distributions', source) @property def confidence_intervals(self) -> bool: @@ -681,19 +537,9 @@ class Settings: @electron_treatment.setter def electron_treatment(self, electron_treatment: str): - cv.check_value('electron treatment', - electron_treatment, ['led', 'ttb']) + cv.check_value('electron treatment', electron_treatment, ['led', 'ttb']) self._electron_treatment = electron_treatment - @property - def atomic_relaxation(self) -> bool: - return self._atomic_relaxation - - @atomic_relaxation.setter - def atomic_relaxation(self, atomic_relaxation: bool): - cv.check_type('atomic relaxation', atomic_relaxation, bool) - self._atomic_relaxation = atomic_relaxation - @property def ptables(self) -> bool: return self._ptables @@ -712,15 +558,6 @@ class Settings: cv.check_type('photon transport', photon_transport, bool) self._photon_transport = photon_transport - @property - def uniform_source_sampling(self) -> bool: - return self._uniform_source_sampling - - @uniform_source_sampling.setter - def uniform_source_sampling(self, uniform_source_sampling: bool): - cv.check_type('strength as weights', uniform_source_sampling, bool) - self._uniform_source_sampling = uniform_source_sampling - @property def plot_seed(self): return self._plot_seed @@ -741,37 +578,6 @@ class Settings: cv.check_greater_than('random number generator seed', seed, 0) self._seed = seed - @property - def stride(self) -> int: - return self._stride - - @stride.setter - def stride(self, stride: int): - cv.check_type('random number generator stride', stride, Integral) - cv.check_greater_than('random number generator stride', stride, 0) - self._stride = stride - - @property - def surface_grazing_cutoff(self) -> float: - return self._surface_grazing_cutoff - - @surface_grazing_cutoff.setter - def surface_grazing_cutoff(self, surface_grazing_cutoff: float): - cv.check_type('surface grazing cutoff', surface_grazing_cutoff, float) - cv.check_greater_than('surface grazing cutoff', surface_grazing_cutoff, 0.0) - cv.check_less_than('surface grazing cutoff', surface_grazing_cutoff, 1.0) - self._surface_grazing_cutoff = surface_grazing_cutoff - - @property - def surface_grazing_ratio(self) -> float: - return self._surface_grazing_ratio - - @surface_grazing_ratio.setter - def surface_grazing_ratio(self, surface_grazing_ratio: float): - cv.check_type('surface grazing ratio', surface_grazing_ratio, float) - cv.check_greater_than('surface grazing ratio', surface_grazing_ratio, 0.0) - self._surface_grazing_ratio = surface_grazing_ratio - @property def survival_biasing(self) -> bool: return self._survival_biasing @@ -806,8 +612,7 @@ class Settings: @trigger_max_batches.setter def trigger_max_batches(self, trigger_max_batches: int): cv.check_type('trigger maximum batches', trigger_max_batches, Integral) - cv.check_greater_than('trigger maximum batches', - trigger_max_batches, 0) + cv.check_greater_than('trigger maximum batches', trigger_max_batches, 0) self._trigger_max_batches = trigger_max_batches @property @@ -816,10 +621,8 @@ class Settings: @trigger_batch_interval.setter def trigger_batch_interval(self, trigger_batch_interval: int): - cv.check_type('trigger batch interval', - trigger_batch_interval, Integral) - cv.check_greater_than('trigger batch interval', - trigger_batch_interval, 0) + cv.check_type('trigger batch interval', trigger_batch_interval, Integral) + cv.check_greater_than('trigger batch interval', trigger_batch_interval, 0) self._trigger_batch_interval = trigger_batch_interval @property @@ -884,18 +687,14 @@ class Settings: return self._surf_source_read @surf_source_read.setter - def surf_source_read(self, ssr: dict): - cv.check_type('surface source reading options', ssr, Mapping) - for key, value in ssr.items(): + def surf_source_read(self, surf_source_read: dict): + cv.check_type('surface source reading options', surf_source_read, Mapping) + for key, value in surf_source_read.items(): cv.check_value('surface source reading key', key, ('path')) if key == 'path': - cv.check_type('path to surface source file', value, PathLike) - self._surf_source_read = dict(ssr) - - # Resolve path to surface source file - if 'path' in ssr: - self._surf_source_read['path'] = input_path(ssr['path']) + cv.check_type('path to surface source file', value, str) + self._surf_source_read = surf_source_read @property def surf_source_write(self) -> dict: @@ -903,29 +702,24 @@ class Settings: @surf_source_write.setter def surf_source_write(self, surf_source_write: dict): - cv.check_type("surface source writing options", - surf_source_write, Mapping) + cv.check_type("surface source writing options", surf_source_write, Mapping) for key, value in surf_source_write.items(): cv.check_value( "surface source writing key", key, - ("surface_ids", "max_particles", "max_source_files", - "mcpl", "cell", "cellfrom", "cellto"), + ("surface_ids", "max_particles", "mcpl", "cell", "cellfrom", "cellto"), ) if key == "surface_ids": cv.check_type( "surface ids for source banking", value, Iterable, Integral ) for surf_id in value: - cv.check_greater_than( - "surface id for source banking", surf_id, 0) - + cv.check_greater_than("surface id for source banking", surf_id, 0) elif key == "mcpl": cv.check_type("write to an MCPL-format file", value, bool) - elif key in ("max_particles", "max_source_files", "cell", "cellfrom", "cellto"): + elif key in ("max_particles", "cell", "cellfrom", "cellto"): name = { "max_particles": "maximum particle banks on surfaces per process", - "max_source_files": "maximun surface source files to be written", "cell": "Cell ID for source banking (from or to)", "cellfrom": "Cell ID for source banking (from only)", "cellto": "Cell ID for source banking (to only)", @@ -935,79 +729,6 @@ class Settings: self._surf_source_write = surf_source_write - @property - def collision_track(self) -> dict: - return self._collision_track - - @collision_track.setter - def collision_track(self, collision_track: dict): - cv.check_type('Collision tracking options', collision_track, Mapping) - for key, value in collision_track.items(): - cv.check_value('collision_track key', key, - ('cell_ids', 'reactions', 'universe_ids', 'material_ids', 'nuclides', - 'deposited_E_threshold', 'max_collisions', 'max_collision_track_files', 'mcpl')) - if key == 'cell_ids': - cv.check_type('cell ids for collision tracking data banking', value, - Iterable, Integral) - for cell_id in value: - cv.check_greater_than('cell id for collision tracking data banking', - cell_id, 0) - elif key == 'reactions': - cv.check_type('MT numbers for collision tracking data banking', value, - Iterable) - for reaction in value: - if isinstance(reaction, int): - cv.check_greater_than( - 'MT number for collision tracking data banking', reaction, 0 - ) - elif isinstance(reaction, str): - # check against allowed strings? so far let C++ code handle it - pass - else: - raise TypeError( - f"MT number for collision tracking data banking must be a positive int or string, " - f"got {type(reaction).__name__}") - elif key == 'universe_ids': - cv.check_type('universe ids for collision tracking data banking', value, - Iterable, Integral) - for universe_id in value: - cv.check_greater_than('universe id for collision tracking data banking', - universe_id, 0) - elif key == 'material_ids': - cv.check_type('material ids for collision tracking data banking', value, - Iterable, Integral) - for material_id in value: - cv.check_greater_than('material id for collision tracking data banking', - material_id, 0) - elif key == 'nuclides': - cv.check_type('nuclides for collision tracking data banking', value, - Iterable, str) - for nuclide in value: - # If nuclide name doesn't look valid, give a warning - try: - openmc.data.zam(nuclide) - except ValueError: - warnings.warn(f"Nuclide {nuclide} is not valid") - elif key == 'deposited_E_threshold': - cv.check_type('Deposited Energy Threshold for collision tracking data banking', - value, Real) - cv.check_greater_than('Deposited Energy Threshold for collision tracking data banking', - value, 0) - elif key == 'max_collisions': - cv.check_type('maximum collisions banks per file', - value, Integral) - cv.check_greater_than('maximum collisions banks in collision tracking', - value, 0) - elif key == 'max_collision_track_files': - cv.check_type('maximum collisions banks', - value, Integral) - cv.check_greater_than('maximum number of collision_track files ', - value, 0) - elif key == 'mcpl': - cv.check_type('write to an MCPL-format file', value, bool) - - self._collision_track = collision_track - @property def no_reduce(self) -> bool: return self._no_reduce @@ -1028,17 +749,6 @@ class Settings: cv.check_less_than('verbosity', verbosity, 10, True) self._verbosity = verbosity - @property - def ifp_n_generation(self) -> int: - return self._ifp_n_generation - - @ifp_n_generation.setter - def ifp_n_generation(self, ifp_n_generation: int): - if ifp_n_generation is not None: - cv.check_type("number of generations", ifp_n_generation, Integral) - cv.check_greater_than("number of generations", ifp_n_generation, 0) - self._ifp_n_generation = ifp_n_generation - @property def tabular_legendre(self) -> dict: return self._tabular_legendre @@ -1085,19 +795,7 @@ class Settings: self._temperature = temperature @property - def properties_file(self) -> PathLike | None: - return self._properties_file - - @properties_file.setter - def properties_file(self, value: PathLike | None): - if value is None: - self._properties_file = None - else: - cv.check_type('properties file', value, PathLike) - self._properties_file = input_path(value) - - @property - def trace(self) -> Iterable: + def trace(self) -> typing.Iterable: return self._trace @trace.setter @@ -1110,12 +808,12 @@ class Settings: self._trace = trace @property - def track(self) -> Iterable[Iterable[int]]: + def track(self) -> typing.Iterable[typing.Iterable[int]]: return self._track @track.setter - def track(self, track: Iterable[Iterable[int]]): - cv.check_type('track', track, Sequence) + def track(self, track: typing.Iterable[typing.Iterable[int]]): + cv.check_type('track', track, Iterable) for t in track: if len(t) != 3: msg = f'Unable to set the track to "{t}" since its length is not 3' @@ -1136,7 +834,7 @@ class Settings: def cutoff(self, cutoff: dict): if not isinstance(cutoff, Mapping): msg = f'Unable to set cutoff from "{cutoff}" which is not a '\ - 'Python dictionary' + 'Python dictionary' raise ValueError(msg) for key in cutoff: if key == 'weight': @@ -1146,15 +844,13 @@ class Settings: cv.check_type('average survival weight', cutoff[key], Real) cv.check_greater_than('average survival weight', cutoff[key], 0.0) - elif key == 'survival_normalization': - cv.check_type('survival normalization', cutoff[key], bool) elif key in ['energy_neutron', 'energy_photon', 'energy_electron', 'energy_positron']: cv.check_type('energy cutoff', cutoff[key], Real) cv.check_greater_than('energy cutoff', cutoff[key], 0.0) else: msg = f'Unable to set cutoff to "{key}" which is unsupported ' \ - 'by OpenMC' + 'by OpenMC' self._cutoff = cutoff @@ -1199,12 +895,12 @@ class Settings: self._resonance_scattering = res @property - def volume_calculations(self) -> list[VolumeCalculation]: + def volume_calculations(self) -> typing.List[VolumeCalculation]: return self._volume_calculations @volume_calculations.setter def volume_calculations( - self, vol_calcs: VolumeCalculation | Iterable[VolumeCalculation] + self, vol_calcs: typing.Union[VolumeCalculation, typing.Iterable[VolumeCalculation]] ): if not isinstance(vol_calcs, MutableSequence): vol_calcs = [vol_calcs] @@ -1298,14 +994,14 @@ class Settings: self._write_initial_source = value @property - def weight_windows(self) -> WeightWindowsList: + def weight_windows(self) -> typing.List[WeightWindows]: return self._weight_windows @weight_windows.setter - def weight_windows(self, value: WeightWindows | Sequence[WeightWindows]): - if not isinstance(value, Sequence): + def weight_windows(self, value: typing.Union[WeightWindows, typing.Iterable[WeightWindows]]): + if not isinstance(value, MutableSequence): value = [value] - self._weight_windows = WeightWindowsList(value) + self._weight_windows = cv.CheckedList(WeightWindows, 'weight windows', value) @property def weight_windows_on(self) -> bool: @@ -1316,15 +1012,6 @@ class Settings: cv.check_type('weight windows on', value, bool) self._weight_windows_on = value - @property - def shared_secondary_bank(self) -> bool: - return self._shared_secondary_bank - - @shared_secondary_bank.setter - def shared_secondary_bank(self, value: bool): - cv.check_type('shared secondary bank', value, bool) - self._shared_secondary_bank = value - @property def weight_window_checkpoints(self) -> dict: return self._weight_window_checkpoints @@ -1332,14 +1019,12 @@ class Settings: @weight_window_checkpoints.setter def weight_window_checkpoints(self, weight_window_checkpoints: dict): for key in weight_window_checkpoints.keys(): - cv.check_value('weight_window_checkpoints', - key, ('collision', 'surface')) + cv.check_value('weight_window_checkpoints', key, ('collision', 'surface')) self._weight_window_checkpoints = weight_window_checkpoints @property def max_splits(self): - raise AttributeError( - 'max_splits has been deprecated. Please use max_history_splits instead') + raise AttributeError('max_splits has been deprecated. Please use max_history_splits instead') @property def max_history_splits(self) -> int: @@ -1351,16 +1036,6 @@ class Settings: cv.check_greater_than('max particle splits', value, 0) self._max_history_splits = value - @property - def max_secondaries(self) -> int: - return self._max_secondaries - - @max_secondaries.setter - def max_secondaries(self, value: int): - cv.check_type('maximum secondary bank size', value, Integral) - cv.check_greater_than('max secondary bank size', value, 0) - self._max_secondaries = value - @property def max_tracks(self) -> int: return self._max_tracks @@ -1372,27 +1047,23 @@ class Settings: self._max_tracks = value @property - def weight_windows_file(self) -> PathLike | None: + def weight_windows_file(self) -> Optional[PathLike]: return self._weight_windows_file @weight_windows_file.setter - def weight_windows_file(self, value: PathLike | None): - if value is None: - self._weight_windows_file = None - else: - cv.check_type('weight windows file', value, PathLike) - self._weight_windows_file = input_path(value) + def weight_windows_file(self, value: PathLike): + cv.check_type('weight windows file', value, (str, Path)) + self._weight_windows_file = value @property - def weight_window_generators(self) -> list[WeightWindowGenerator]: + def weight_window_generators(self) -> typing.List[WeightWindowGenerator]: return self._weight_window_generators @weight_window_generators.setter def weight_window_generators(self, wwgs): if not isinstance(wwgs, MutableSequence): wwgs = [wwgs] - self._weight_window_generators = cv.CheckedList( - WeightWindowGenerator, 'weight window generators', wwgs) + self._weight_window_generators = cv.CheckedList(WeightWindowGenerator, 'weight window generators', wwgs) @property def random_ray(self) -> dict: @@ -1403,94 +1074,22 @@ class Settings: if not isinstance(random_ray, Mapping): raise ValueError(f'Unable to set random_ray from "{random_ray}" ' 'which is not a dict.') - for key, value in random_ray.items(): + for key in random_ray: if key == 'distance_active': - cv.check_type('active ray length', value, Real) - cv.check_greater_than('active ray length', value, 0.0) + cv.check_type('active ray length', random_ray[key], Real) + cv.check_greater_than('active ray length', random_ray[key], 0.0) elif key == 'distance_inactive': - cv.check_type('inactive ray length', value, Real) + cv.check_type('inactive ray length', random_ray[key], Real) cv.check_greater_than('inactive ray length', - value, 0.0, True) + random_ray[key], 0.0, True) elif key == 'ray_source': - cv.check_type('random ray source', value, SourceBase) - elif key == 'volume_estimator': - cv.check_value('volume estimator', value, - ('naive', 'simulation_averaged', - 'hybrid')) - elif key == 'source_shape': - cv.check_value('source shape', value, - ('flat', 'linear', 'linear_xy')) - elif key == 'volume_normalized_flux_tallies': - cv.check_type('volume normalized flux tallies', value, bool) - elif key == 'adjoint': - cv.check_type('adjoint', value, bool) - elif key == 'source_region_meshes': - cv.check_type('source region meshes', value, Iterable) - for mesh, domains in value: - cv.check_type('mesh', mesh, MeshBase) - cv.check_type('domains', domains, Iterable) - valid_types = (openmc.Material, - openmc.Cell, openmc.Universe) - for domain in domains: - if not isinstance(domain, valid_types): - raise ValueError( - f'Invalid domain type: {type(domain)}. Expected ' - 'openmc.Material, openmc.Cell, or openmc.Universe.') - elif key == 'sample_method': - cv.check_value('sample method', value, - ('prng', 'halton', 's2')) - elif key == 'diagonal_stabilization_rho': - cv.check_type('diagonal stabilization rho', value, Real) - cv.check_greater_than('diagonal stabilization rho', - value, 0.0, True) - elif key == 'adjoint_source': - if not isinstance(value, MutableSequence): - value = [value] - for source in value: - if not isinstance(source, SourceBase): - raise ValueError( - f'Invalid adjoint source type: {type(source)}. ' - 'Expected openmc.SourceBase.') + cv.check_type('random ray source', random_ray[key], SourceBase) else: raise ValueError(f'Unable to set random ray to "{key}" which is ' 'unsupported by OpenMC') self._random_ray = random_ray - @property - def use_decay_photons(self) -> bool: - return self._use_decay_photons - - @use_decay_photons.setter - def use_decay_photons(self, value): - cv.check_type('use decay photons', value, bool) - self._use_decay_photons = value - - @property - def source_rejection_fraction(self) -> float: - return self._source_rejection_fraction - - @source_rejection_fraction.setter - def source_rejection_fraction(self, source_rejection_fraction: float): - cv.check_type('source_rejection_fraction', - source_rejection_fraction, Real) - cv.check_greater_than('source_rejection_fraction', - source_rejection_fraction, 0) - cv.check_less_than('source_rejection_fraction', - source_rejection_fraction, 1) - self._source_rejection_fraction = source_rejection_fraction - - @property - def free_gas_threshold(self) -> float | None: - return self._free_gas_threshold - - @free_gas_threshold.setter - def free_gas_threshold(self, free_gas_threshold: float | None): - if free_gas_threshold is not None: - cv.check_type('free gas threshold', free_gas_threshold, Real) - cv.check_greater_than('free gas threshold', free_gas_threshold, 0.0) - self._free_gas_threshold = free_gas_threshold - def _create_run_mode_subelement(self, root): elem = ET.SubElement(root, "run_mode") elem.text = self._run_mode.value @@ -1588,11 +1187,6 @@ class Settings: subelement.text = ' '.join( str(x) for x in self._statepoint['batches']) - def _create_uniform_source_sampling_subelement(self, root): - if self._uniform_source_sampling is not None: - element = ET.SubElement(root, "uniform_source_sampling") - element.text = str(self._uniform_source_sampling).lower() - def _create_sourcepoint_subelement(self, root): if self._sourcepoint: element = ET.SubElement(root, "source_point") @@ -1624,7 +1218,7 @@ class Settings: element = ET.SubElement(root, "surf_source_read") if 'path' in self._surf_source_read: subelement = ET.SubElement(element, "path") - subelement.text = str(self._surf_source_read['path']) + subelement.text = self._surf_source_read['path'] def _create_surf_source_write_subelement(self, root): if self._surf_source_write: @@ -1637,50 +1231,11 @@ class Settings: if "mcpl" in self._surf_source_write: subelement = ET.SubElement(element, "mcpl") subelement.text = str(self._surf_source_write["mcpl"]).lower() - for key in ("max_particles", "max_source_files", "cell", "cellfrom", "cellto"): + for key in ("max_particles", "cell", "cellfrom", "cellto"): if key in self._surf_source_write: subelement = ET.SubElement(element, key) subelement.text = str(self._surf_source_write[key]) - def _create_collision_track_subelement(self, root): - if self._collision_track: - element = ET.SubElement(root, "collision_track") - if 'cell_ids' in self._collision_track: - subelement = ET.SubElement(element, "cell_ids") - subelement.text = ' '.join( - str(x) for x in self._collision_track['cell_ids']) - if 'reactions' in self._collision_track: - subelement = ET.SubElement(element, "reactions") - subelement.text = ' '.join( - str(x) for x in self._collision_track['reactions']) - if 'universe_ids' in self._collision_track: - subelement = ET.SubElement(element, "universe_ids") - subelement.text = ' '.join( - str(x) for x in self._collision_track['universe_ids']) - if 'material_ids' in self._collision_track: - subelement = ET.SubElement(element, "material_ids") - subelement.text = ' '.join( - str(x) for x in self._collision_track['material_ids']) - if 'nuclides' in self._collision_track: - subelement = ET.SubElement(element, "nuclides") - subelement.text = ' '.join( - str(x) for x in self._collision_track['nuclides']) - if 'deposited_E_threshold' in self._collision_track: - subelement = ET.SubElement(element, "deposited_E_threshold") - subelement.text = str( - self._collision_track['deposited_E_threshold']) - if 'max_collisions' in self._collision_track: - subelement = ET.SubElement(element, "max_collisions") - subelement.text = str(self._collision_track['max_collisions']) - if 'max_collision_track_files' in self._collision_track: - subelement = ET.SubElement( - element, "max_collision_track_files") - subelement.text = str( - self._collision_track['max_collision_track_files']) - if 'mcpl' in self._collision_track: - subelement = ET.SubElement(element, "mcpl") - subelement.text = str(self._collision_track['mcpl']).lower() - def _create_confidence_intervals(self, root): if self._confidence_intervals is not None: element = ET.SubElement(root, "confidence_intervals") @@ -1691,11 +1246,6 @@ class Settings: element = ET.SubElement(root, "electron_treatment") element.text = str(self._electron_treatment) - def _create_atomic_relaxation_subelement(self, root): - if self._atomic_relaxation is not None: - element = ET.SubElement(root, "atomic_relaxation") - element.text = str(self._atomic_relaxation).lower() - def _create_photon_transport_subelement(self, root): if self._photon_transport is not None: element = ET.SubElement(root, "photon_transport") @@ -1716,21 +1266,6 @@ class Settings: element = ET.SubElement(root, "seed") element.text = str(self._seed) - def _create_stride_subelement(self, root): - if self._stride is not None: - element = ET.SubElement(root, "stride") - element.text = str(self._stride) - - def _create_surface_grazing_cutoff_subelement(self, root): - if self._surface_grazing_cutoff is not None: - element = ET.SubElement(root, "surface_grazing_cutoff") - element.text = str(self._surface_grazing_cutoff) - - def _create_surface_grazing_ratio_subelement(self, root): - if self._surface_grazing_ratio is not None: - element = ET.SubElement(root, "surface_grazing_ratio") - element.text = str(self._surface_grazing_ratio) - def _create_survival_biasing_subelement(self, root): if self._survival_biasing is not None: element = ET.SubElement(root, "survival_biasing") @@ -1741,8 +1276,7 @@ class Settings: element = ET.SubElement(root, "cutoff") for key, value in self._cutoff.items(): subelement = ET.SubElement(element, key) - subelement.text = str(value) if key != 'survival_normalization' \ - else str(value).lower() + subelement.text = str(value) def _create_entropy_mesh_subelement(self, root, mesh_memo=None): if self.entropy_mesh is None: @@ -1751,8 +1285,8 @@ class Settings: # use default heuristic for entropy mesh if not set by user if self.entropy_mesh.dimension is None: if self.particles is None: - raise RuntimeError("Number of particles must be set in order to " - "use entropy mesh dimension heuristic") + raise RuntimeError("Number of particles must be set in order to " \ + "use entropy mesh dimension heuristic") else: n = ceil((self.particles / 20.0)**(1.0 / 3.0)) d = len(self.entropy_mesh.lower_left) @@ -1793,11 +1327,6 @@ class Settings: element = ET.SubElement(root, "no_reduce") element.text = str(self._no_reduce).lower() - def _create_ifp_n_generation_subelement(self, root): - if self._ifp_n_generation is not None: - element = ET.SubElement(root, "ifp_n_generation") - element.text = str(self._ifp_n_generation) - def _create_tabular_legendre_subelements(self, root): if self.tabular_legendre: element = ET.SubElement(root, "tabular_legendre") @@ -1818,12 +1347,6 @@ class Settings: else: element.text = str(value) - def _create_properties_file_element(self, root): - if self.properties_file is not None: - element = ET.Element("properties_file") - element.text = str(self.properties_file) - root.append(element) - def _create_trace_subelement(self, root): if self._trace is not None: element = ET.SubElement(root, "trace") @@ -1848,13 +1371,7 @@ class Settings: path = f"./mesh[@id='{self.ufs_mesh.id}']" if root.find(path) is None: root.append(self.ufs_mesh.to_xml_element()) - if mesh_memo is not None: - mesh_memo.add(self.ufs_mesh.id) - - def _create_use_decay_photons_subelement(self, root): - if self._use_decay_photons is not None: - element = ET.SubElement(root, "use_decay_photons") - element.text = str(self._use_decay_photons).lower() + if mesh_memo is not None: mesh_memo.add(self.ufs_mesh.id) def _create_resonance_scattering_subelement(self, root): res = self.resonance_scattering @@ -1938,16 +1455,10 @@ class Settings: if mesh_memo is not None: mesh_memo.add(ww.mesh.id) - def _create_weight_windows_on_subelement(self, root): if self._weight_windows_on is not None: elem = ET.SubElement(root, "weight_windows_on") elem.text = str(self._weight_windows_on).lower() - def _create_shared_secondary_bank_subelement(self, root): - if self._shared_secondary_bank is not None: - elem = ET.SubElement(root, "shared_secondary_bank") - elem.text = str(self._shared_secondary_bank).lower() - def _create_weight_window_generators_subelement(self, root, mesh_memo=None): if not self.weight_window_generators: return @@ -1960,17 +1471,14 @@ class Settings: if mesh_memo is not None and wwg.mesh.id in mesh_memo: continue - # See if a element already exists -- if not, add it - path = f"./mesh[@id='{wwg.mesh.id}']" - if root.find(path) is None: - root.append(wwg.mesh.to_xml_element()) - if mesh_memo is not None: - mesh_memo.add(wwg.mesh.id) + root.append(wwg.mesh.to_xml_element()) + if mesh_memo is not None: + mesh_memo.add(wwg.mesh) def _create_weight_windows_file_element(self, root): if self.weight_windows_file is not None: element = ET.Element("weight_windows_file") - element.text = str(self.weight_windows_file) + element.text = self.weight_windows_file root.append(element) def _create_weight_window_checkpoints_subelement(self, root): @@ -1980,88 +1488,33 @@ class Settings: if 'collision' in self._weight_window_checkpoints: subelement = ET.SubElement(element, "collision") - subelement.text = str( - self._weight_window_checkpoints['collision']).lower() + subelement.text = str(self._weight_window_checkpoints['collision']).lower() if 'surface' in self._weight_window_checkpoints: subelement = ET.SubElement(element, "surface") - subelement.text = str( - self._weight_window_checkpoints['surface']).lower() + subelement.text = str(self._weight_window_checkpoints['surface']).lower() def _create_max_history_splits_subelement(self, root): if self._max_history_splits is not None: elem = ET.SubElement(root, "max_history_splits") elem.text = str(self._max_history_splits) - def _create_max_secondaries_subelement(self, root): - if self._max_secondaries is not None: - elem = ET.SubElement(root, "max_secondaries") - elem.text = str(self._max_secondaries) - def _create_max_tracks_subelement(self, root): if self._max_tracks is not None: elem = ET.SubElement(root, "max_tracks") elem.text = str(self._max_tracks) - def _create_random_ray_subelement(self, root, mesh_memo=None): + def _create_random_ray_subelement(self, root): if self._random_ray: element = ET.SubElement(root, "random_ray") for key, value in self._random_ray.items(): if key == 'ray_source' and isinstance(value, SourceBase): - subelement = ET.SubElement(element, 'ray_source') source_element = value.to_xml_element() - if source_element.find('bias') is not None: - raise RuntimeError( - "Ray source distributions should not be biased.") - subelement.append(source_element) - - elif key == 'source_region_meshes': - subelement = ET.SubElement(element, 'source_region_meshes') - for mesh, domains in value: - mesh_elem = ET.SubElement(subelement, 'mesh') - mesh_elem.set('id', str(mesh.id)) - for domain in domains: - domain_elem = ET.SubElement(mesh_elem, 'domain') - domain_elem.set('id', str(domain.id)) - domain_elem.set( - 'type', domain.__class__.__name__.lower()) - if mesh_memo is not None and mesh.id not in mesh_memo: - domain_elem.set('type', domain.__class__.__name__.lower()) - # See if a element already exists -- if not, add it - path = f"./mesh[@id='{mesh.id}']" - if root.find(path) is None: - root.append(mesh.to_xml_element()) - if mesh_memo is not None: - mesh_memo.add(mesh.id) - elif key == 'adjoint_source': - subelement = ET.SubElement(element, 'adjoint_source') - # Check that all entries are valid SourceBase instances, in case - # the random_ray setter was not used to populate dict entries. - if not isinstance(value, MutableSequence): - value = [value] - for source in value: - if not isinstance(source, SourceBase): - raise ValueError( - f'Invalid adjoint source type: {type(source)}. ' - 'Expected openmc.SourceBase.') - subelement.append(source.to_xml_element()) - elif isinstance(value, bool): - subelement = ET.SubElement(element, key) - subelement.text = str(value).lower() + element.append(source_element) else: subelement = ET.SubElement(element, key) subelement.text = str(value) - def _create_source_rejection_fraction_subelement(self, root): - if self._source_rejection_fraction is not None: - element = ET.SubElement(root, "source_rejection_fraction") - element.text = str(self._source_rejection_fraction) - - def _create_free_gas_threshold_subelement(self, root): - if self._free_gas_threshold is not None: - element = ET.SubElement(root, "free_gas_threshold") - element.text = str(self._free_gas_threshold) - def _eigenvalue_from_xml_element(self, root): elem = root.find('eigenvalue') if elem is not None: @@ -2147,67 +1600,47 @@ class Settings: def _statepoint_from_xml_element(self, root): elem = root.find('state_point') if elem is not None: - batches = get_elem_list(elem, "batches", int) - if batches is not None: - self.statepoint['batches'] = batches + text = get_text(elem, 'batches') + if text is not None: + self.statepoint['batches'] = [int(x) for x in text.split()] def _sourcepoint_from_xml_element(self, root): elem = root.find('source_point') if elem is not None: for key in ('separate', 'write', 'overwrite_latest', 'batches', 'mcpl'): - if key in ('separate', 'write', 'mcpl', 'overwrite_latest'): - value = get_text(elem, key) in ('true', '1') - if key == 'overwrite_latest': - key = 'overwrite' - else: - value = get_elem_list(elem, key, int) + value = get_text(elem, key) if value is not None: + if key in ('separate', 'write', 'mcpl'): + value = value in ('true', '1') + elif key == 'overwrite_latest': + value = value in ('true', '1') + key = 'overwrite' + else: + value = [int(x) for x in value.split()] self.sourcepoint[key] = value def _surf_source_read_from_xml_element(self, root): elem = root.find('surf_source_read') if elem is not None: - ssr = {} value = get_text(elem, 'path') if value is not None: - ssr['path'] = value - self.surf_source_read = ssr + self.surf_source_read['path'] = value def _surf_source_write_from_xml_element(self, root): elem = root.find('surf_source_write') if elem is None: return - for key in ('surface_ids', 'max_particles', 'max_source_files', 'mcpl', 'cell', 'cellto', 'cellfrom'): - if key == 'surface_ids': - value = get_elem_list(elem, key, int) - else: - value = get_text(elem, key) + for key in ('surface_ids', 'max_particles', 'mcpl', 'cell', 'cellto', 'cellfrom'): + value = get_text(elem, key) if value is not None: - if key == 'mcpl': + if key == 'surface_ids': + value = [int(x) for x in value.split()] + elif key == 'mcpl': value = value in ('true', '1') - elif key in ('max_particles', 'max_source_files', 'cell', 'cellfrom', 'cellto'): + elif key in ('max_particles', 'cell', 'cellfrom', 'cellto'): value = int(value) self.surf_source_write[key] = value - def _collision_track_from_xml_element(self, root): - elem = root.find('collision_track') - if elem is not None: - for key in ('cell_ids', 'reactions', 'universe_ids', 'material_ids', 'nuclides', - 'deposited_E_threshold', 'max_collisions', "max_collision_track_files", 'mcpl'): - value = get_text(elem, key) - if value is not None: - if key in ('cell_ids', 'universe_ids', 'material_ids'): - value = [int(x) for x in value.split()] - elif key in ('reactions', 'nuclides'): - value = value.split() - elif key in ('max_collisions', 'max_collision_track_files'): - value = int(value) - elif key == 'deposited_E_threshold': - value = float(value) - elif key == 'mcpl': - value = value in ('true', '1') - self.collision_track[key] = value - def _confidence_intervals_from_xml_element(self, root): text = get_text(root, 'confidence_intervals') if text is not None: @@ -2218,11 +1651,6 @@ class Settings: if text is not None: self.electron_treatment = text - def _atomic_relaxation_from_xml_element(self, root): - text = get_text(root, 'atomic_relaxation') - if text is not None: - self.atomic_relaxation = text in ('true', '1') - def _energy_mode_from_xml_element(self, root): text = get_text(root, 'energy_mode') if text is not None: @@ -2238,11 +1666,6 @@ class Settings: if text is not None: self.photon_transport = text in ('true', '1') - def _uniform_source_sampling_from_xml_element(self, root): - text = get_text(root, 'uniform_source_sampling') - if text is not None: - self.uniform_source_sampling = text in ('true', '1') - def _plot_seed_from_xml_element(self, root): text = get_text(root, 'plot_seed') if text is not None: @@ -2258,21 +1681,6 @@ class Settings: if text is not None: self.seed = int(text) - def _stride_from_xml_element(self, root): - text = get_text(root, 'stride') - if text is not None: - self.stride = int(text) - - def _surface_grazing_cutoff_from_xml_element(self, root): - text = get_text(root, 'surface_grazing_cutoff') - if text is not None: - self.surface_grazing_cutoff = float(text) - - def _surface_grazing_ratio_from_xml_element(self, root): - text = get_text(root, 'surface_grazing_ratio') - if text is not None: - self.surface_grazing_ratio = float(text) - def _survival_biasing_from_xml_element(self, root): text = get_text(root, 'survival_biasing') if text is not None: @@ -2284,14 +1692,10 @@ class Settings: self.cutoff = {} for key in ('energy_neutron', 'energy_photon', 'energy_electron', 'energy_positron', 'weight', 'weight_avg', 'time_neutron', - 'time_photon', 'time_electron', 'time_positron', - 'survival_normalization'): + 'time_photon', 'time_electron', 'time_positron'): value = get_text(elem, key) if value is not None: - if key == 'survival_normalization': - self.cutoff[key] = value in ('true', '1') - else: - self.cutoff[key] = float(value) + self.cutoff[key] = float(value) def _entropy_mesh_from_xml_element(self, root, meshes): text = get_text(root, 'entropy_mesh') @@ -2323,11 +1727,6 @@ class Settings: if text is not None: self.verbosity = int(text) - def _ifp_n_generation_from_xml_element(self, root): - text = get_text(root, 'ifp_n_generation') - if text is not None: - self.ifp_n_generation = int(text) - def _tabular_legendre_from_xml_element(self, root): elem = root.find('tabular_legendre') if elem is not None: @@ -2347,26 +1746,22 @@ class Settings: text = get_text(root, 'temperature_method') if text is not None: self.temperature['method'] = text - text = get_elem_list(root, "temperature_range", float) + text = get_text(root, 'temperature_range') if text is not None: - self.temperature['range'] = text + self.temperature['range'] = [float(x) for x in text.split()] text = get_text(root, 'temperature_multipole') if text is not None: self.temperature['multipole'] = text in ('true', '1') - def _properties_file_from_xml_element(self, root): - text = get_text(root, 'properties_file') - if text is not None: - self.properties_file = text - def _trace_from_xml_element(self, root): - text = get_elem_list(root, "trace", int) + text = get_text(root, 'trace') if text is not None: - self.trace = text + self.trace = [int(x) for x in text.split()] def _track_from_xml_element(self, root): - values = get_elem_list(root, "track", int) - if values is not None: + text = get_text(root, 'track') + if text is not None: + values = [int(x) for x in text.split()] self.track = list(zip(values[::3], values[1::3], values[2::3])) def _ufs_mesh_from_xml_element(self, root, meshes): @@ -2383,15 +1778,14 @@ class Settings: if elem is not None: keys = ('enable', 'method', 'energy_min', 'energy_max', 'nuclides') for key in keys: - if key == 'nuclides': - value = get_elem_list(elem, key, str) - else: - value = get_text(elem, key) + value = get_text(elem, key) if value is not None: if key == 'enable': value = value in ('true', '1') elif key in ('energy_min', 'energy_max'): value = float(value) + elif key == 'nuclides': + value = value.split() self.resonance_scattering[key] = value def _create_fission_neutrons_from_xml_element(self, root): @@ -2449,21 +1843,10 @@ class Settings: ww = WeightWindows.from_xml_element(elem, meshes) self.weight_windows.append(ww) - def _weight_windows_on_from_xml_element(self, root): text = get_text(root, 'weight_windows_on') if text is not None: self.weight_windows_on = text in ('true', '1') - def _shared_secondary_bank_from_xml_element(self, root): - text = get_text(root, 'shared_secondary_bank') - if text is not None: - self.shared_secondary_bank = text in ('true', '1') - - def _weight_windows_file_from_xml_element(self, root): - text = get_text(root, 'weight_windows_file') - if text is not None: - self.weight_windows_file = text - def _weight_window_checkpoints_from_xml_element(self, root): elem = root.find('weight_window_checkpoints') if elem is None: @@ -2479,86 +1862,21 @@ class Settings: if text is not None: self.max_history_splits = int(text) - def _max_secondaries_from_xml_element(self, root): - text = get_text(root, 'max_secondaries') - if text is not None: - self.max_secondaries = int(text) - def _max_tracks_from_xml_element(self, root): text = get_text(root, 'max_tracks') if text is not None: self.max_tracks = int(text) - def _random_ray_from_xml_element(self, root, meshes=None): + def _random_ray_from_xml_element(self, root): elem = root.find('random_ray') if elem is not None: self.random_ray = {} for child in elem: - if child.tag in ('distance_inactive', 'distance_active', 'diagonal_stabilization_rho'): + if child.tag in ('distance_inactive', 'distance_active'): self.random_ray[child.tag] = float(child.text) - elif child.tag == 'ray_source': - source_element = child.find('source') - source = SourceBase.from_xml_element(source_element) - if child.find('bias') is not None: - raise RuntimeError( - "Ray source distributions should not be biased.") + elif child.tag == 'source': + source = SourceBase.from_xml_element(child) self.random_ray['ray_source'] = source - elif child.tag == 'volume_estimator': - self.random_ray['volume_estimator'] = child.text - elif child.tag == 'source_shape': - self.random_ray['source_shape'] = child.text - elif child.tag == 'volume_normalized_flux_tallies': - self.random_ray['volume_normalized_flux_tallies'] = ( - child.text in ('true', '1') - ) - elif child.tag == 'adjoint': - self.random_ray['adjoint'] = ( - child.text in ('true', '1') - ) - elif child.tag == 'adjoint_source': - self.random_ray['adjoint_source'] = [] - for subelem in child.findall('source'): - src = SourceBase.from_xml_element(subelem) - # add newly constructed source object to the list - self.random_ray['adjoint_source'].append(src) - elif child.tag == 'sample_method': - self.random_ray['sample_method'] = child.text - elif child.tag == 'source_region_meshes': - self.random_ray['source_region_meshes'] = [] - for mesh_elem in child.findall('mesh'): - mesh_id = int(get_text(mesh_elem, 'id')) - if meshes and mesh_id in meshes: - mesh = meshes[mesh_id] - else: - mesh = MeshBase.from_xml_element(mesh_elem) - domains = [] - for domain_elem in mesh_elem.findall('domain'): - domain_id = int(get_text(domain_elem, "id")) - domain_type = get_text(domain_elem, "type") - if domain_type == 'material': - domain = openmc.Material(domain_id) - elif domain_type == 'cell': - domain = openmc.Cell(domain_id) - elif domain_type == 'universe': - domain = openmc.Universe(domain_id) - domains.append(domain) - self.random_ray['source_region_meshes'].append( - (mesh, domains)) - - def _use_decay_photons_from_xml_element(self, root): - text = get_text(root, 'use_decay_photons') - if text is not None: - self.use_decay_photons = text in ('true', '1') - - def _source_rejection_fraction_from_xml_element(self, root): - text = get_text(root, 'source_rejection_fraction') - if text is not None: - self.source_rejection_fraction = float(text) - - def _free_gas_threshold_from_xml_element(self, root): - text = get_text(root, 'free_gas_threshold') - if text is not None: - self.free_gas_threshold = float(text) def to_xml_element(self, mesh_memo=None): """Create a 'settings' element to be written to an XML file. @@ -2586,30 +1904,22 @@ class Settings: self._create_sourcepoint_subelement(element) self._create_surf_source_read_subelement(element) self._create_surf_source_write_subelement(element) - self._create_collision_track_subelement(element) self._create_confidence_intervals(element) self._create_electron_treatment_subelement(element) - self._create_atomic_relaxation_subelement(element) self._create_energy_mode_subelement(element) self._create_max_order_subelement(element) self._create_photon_transport_subelement(element) - self._create_uniform_source_sampling_subelement(element) self._create_plot_seed_subelement(element) self._create_ptables_subelement(element) self._create_seed_subelement(element) - self._create_stride_subelement(element) - self._create_surface_grazing_cutoff_subelement(element) - self._create_surface_grazing_ratio_subelement(element) self._create_survival_biasing_subelement(element) self._create_cutoff_subelement(element) self._create_entropy_mesh_subelement(element, mesh_memo) self._create_trigger_subelement(element) self._create_no_reduce_subelement(element) self._create_verbosity_subelement(element) - self._create_ifp_n_generation_subelement(element) self._create_tabular_legendre_subelements(element) self._create_temperature_subelements(element) - self._create_properties_file_element(element) self._create_trace_subelement(element) self._create_track_subelement(element) self._create_ufs_mesh_subelement(element, mesh_memo) @@ -2625,21 +1935,16 @@ class Settings: self._create_log_grid_bins_subelement(element) self._create_write_initial_source_subelement(element) self._create_weight_windows_subelement(element, mesh_memo) - self._create_weight_windows_on_subelement(element) - self._create_shared_secondary_bank_subelement(element) self._create_weight_window_generators_subelement(element, mesh_memo) self._create_weight_windows_file_element(element) self._create_weight_window_checkpoints_subelement(element) self._create_max_history_splits_subelement(element) self._create_max_tracks_subelement(element) - self._create_max_secondaries_subelement(element) - self._create_random_ray_subelement(element, mesh_memo) - self._create_use_decay_photons_subelement(element) - self._create_source_rejection_fraction_subelement(element) - self._create_free_gas_threshold_subelement(element) + self._create_random_ray_subelement(element) # Clean the indentation in the file to be user-readable clean_indentation(element) + reorder_attributes(element) # TODO: Remove when support is Python 3.8+ return element @@ -2705,30 +2010,22 @@ class Settings: settings._sourcepoint_from_xml_element(elem) settings._surf_source_read_from_xml_element(elem) settings._surf_source_write_from_xml_element(elem) - settings._collision_track_from_xml_element(elem) settings._confidence_intervals_from_xml_element(elem) settings._electron_treatment_from_xml_element(elem) - settings._atomic_relaxation_from_xml_element(elem) settings._energy_mode_from_xml_element(elem) settings._max_order_from_xml_element(elem) settings._photon_transport_from_xml_element(elem) - settings._uniform_source_sampling_from_xml_element(elem) settings._plot_seed_from_xml_element(elem) settings._ptables_from_xml_element(elem) settings._seed_from_xml_element(elem) - settings._stride_from_xml_element(elem) - settings._surface_grazing_cutoff_from_xml_element(elem) - settings._surface_grazing_ratio_from_xml_element(elem) settings._survival_biasing_from_xml_element(elem) settings._cutoff_from_xml_element(elem) settings._entropy_mesh_from_xml_element(elem, meshes) settings._trigger_from_xml_element(elem) settings._no_reduce_from_xml_element(elem) settings._verbosity_from_xml_element(elem) - settings._ifp_n_generation_from_xml_element(elem) settings._tabular_legendre_from_xml_element(elem) settings._temperature_from_xml_element(elem) - settings._properties_file_from_xml_element(elem) settings._trace_from_xml_element(elem) settings._track_from_xml_element(elem) settings._ufs_mesh_from_xml_element(elem, meshes) @@ -2743,19 +2040,13 @@ class Settings: settings._log_grid_bins_from_xml_element(elem) settings._write_initial_source_from_xml_element(elem) settings._weight_windows_from_xml_element(elem, meshes) - settings._weight_windows_on_from_xml_element(elem) - settings._shared_secondary_bank_from_xml_element(elem) - settings._weight_windows_file_from_xml_element(elem) settings._weight_window_generators_from_xml_element(elem, meshes) settings._weight_window_checkpoints_from_xml_element(elem) settings._max_history_splits_from_xml_element(elem) settings._max_tracks_from_xml_element(elem) - settings._max_secondaries_from_xml_element(elem) - settings._random_ray_from_xml_element(elem, meshes) - settings._use_decay_photons_from_xml_element(elem) - settings._source_rejection_fraction_from_xml_element(elem) - settings._free_gas_threshold_from_xml_element(elem) + settings._random_ray_from_xml_element(elem) + # TODO: Get volume calculations return settings @classmethod diff --git a/openmc/source.py b/openmc/source.py index 5947540d6..51ed74de3 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -1,26 +1,24 @@ from __future__ import annotations from abc import ABC, abstractmethod -from collections.abc import Iterable, Sequence -from numbers import Integral, Real -from pathlib import Path +from collections.abc import Iterable +from enum import IntEnum +from numbers import Real import warnings -from typing import Any +import typing # imported separately as py3.8 requires typing.Iterable +# also required to prevent typing.Union namespace overwriting Union +from typing import Optional, Sequence, Dict, Any import lxml.etree as ET import numpy as np import h5py -import pandas as pd import openmc import openmc.checkvalue as cv from openmc.checkvalue import PathLike from openmc.stats.multivariate import UnitSphere, Spatial from openmc.stats.univariate import Univariate -from ._xml import get_elem_list, get_text +from ._xml import get_text from .mesh import MeshBase, StructuredMesh, UnstructuredMesh -from .particle_type import ParticleType -from .statepoint import _VERSION_STATEPOINT -from .utility_funcs import input_path class SourceBase(ABC): @@ -46,7 +44,7 @@ class SourceBase(ABC): Attributes ---------- - type : {'independent', 'file', 'compiled', 'mesh', 'tokamak'} + type : {'independent', 'file', 'compiled', 'mesh'} Indicator of source type. strength : float Strength of the source @@ -59,8 +57,8 @@ class SourceBase(ABC): def __init__( self, - strength: float | None = 1.0, - constraints: dict[str, Any] | None = None + strength: Optional[float] = 1.0, + constraints: Optional[Dict[str, Any]] = None ): self.strength = strength self.constraints = constraints @@ -77,11 +75,11 @@ class SourceBase(ABC): self._strength = strength @property - def constraints(self) -> dict[str, Any]: + def constraints(self) -> Dict[str, Any]: return self._constraints @constraints.setter - def constraints(self, constraints: dict[str, Any] | None): + def constraints(self, constraints: Optional[Dict[str, Any]]): self._constraints = {} if constraints is None: return @@ -107,12 +105,10 @@ class SourceBase(ABC): cv.check_type('fissionable', value, bool) self._constraints['fissionable'] = value elif key == 'rejection_strategy': - cv.check_value('rejection strategy', - value, ('resample', 'kill')) + cv.check_value('rejection strategy', value, ('resample', 'kill')) self._constraints['rejection_strategy'] = value else: - raise ValueError( - f'Unknown key in constraints dictionary: {key}') + raise ValueError('Unknown key in constraints dictionary: {key}') @abstractmethod def populate_xml_element(self, element): @@ -146,16 +142,13 @@ class SourceBase(ABC): dt_elem = ET.SubElement(constraints_elem, "domain_type") dt_elem.text = constraints["domain_type"] id_elem = ET.SubElement(constraints_elem, "domain_ids") - id_elem.text = ' '.join(str(uid) - for uid in constraints["domain_ids"]) + id_elem.text = ' '.join(str(uid) for uid in constraints["domain_ids"]) if "time_bounds" in constraints: dt_elem = ET.SubElement(constraints_elem, "time_bounds") - dt_elem.text = ' '.join(str(t) - for t in constraints["time_bounds"]) + dt_elem.text = ' '.join(str(t) for t in constraints["time_bounds"]) if "energy_bounds" in constraints: dt_elem = ET.SubElement(constraints_elem, "energy_bounds") - dt_elem.text = ' '.join(str(E) - for E in constraints["energy_bounds"]) + dt_elem.text = ' '.join(str(E) for E in constraints["energy_bounds"]) if "fissionable" in constraints: dt_elem = ET.SubElement(constraints_elem, "fissionable") dt_elem.text = str(constraints["fissionable"]).lower() @@ -203,14 +196,11 @@ class SourceBase(ABC): return FileSource.from_xml_element(elem) elif source_type == 'mesh': return MeshSource.from_xml_element(elem, meshes) - elif source_type == 'tokamak': - return TokamakSource.from_xml_element(elem) else: - raise ValueError( - f'Source type {source_type} is not recognized') + raise ValueError(f'Source type {source_type} is not recognized') @staticmethod - def _get_constraints(elem: ET.Element) -> dict[str, Any]: + def _get_constraints(elem: ET.Element) -> Dict[str, Any]: # Find element containing constraints constraints_elem = elem.find("constraints") elem = constraints_elem if constraints_elem is not None else elem @@ -218,7 +208,7 @@ class SourceBase(ABC): constraints = {} domain_type = get_text(elem, "domain_type") if domain_type is not None: - domain_ids = get_elem_list(elem, "domain_ids", int) + domain_ids = [int(x) for x in get_text(elem, "domain_ids").split()] # Instantiate some throw-away domains that are used by the # constructor to assign IDs @@ -232,13 +222,13 @@ class SourceBase(ABC): domains = [openmc.Universe(uid) for uid in domain_ids] constraints['domains'] = domains - time_bounds = get_elem_list(elem, "time_bounds", float) + time_bounds = get_text(elem, "time_bounds") if time_bounds is not None: - constraints['time_bounds'] = time_bounds + constraints['time_bounds'] = [float(x) for x in time_bounds.split()] - energy_bounds = get_elem_list(elem, "energy_bounds", float) + energy_bounds = get_text(elem, "energy_bounds") if energy_bounds is not None: - constraints['energy_bounds'] = energy_bounds + constraints['energy_bounds'] = [float(x) for x in energy_bounds.split()] fissionable = get_text(elem, "fissionable") if fissionable is not None: @@ -268,8 +258,8 @@ class IndependentSource(SourceBase): time distribution of source sites strength : float Strength of the source - particle : str or int or openmc.ParticleType - Source particle type (name, PDG number, or type) + particle : {'neutron', 'photon'} + Source particle type domains : iterable of openmc.Cell, openmc.Material, or openmc.Universe Domains to reject based on, i.e., if a sampled spatial location is not within one of these domains, it will be rejected. @@ -305,9 +295,10 @@ class IndependentSource(SourceBase): type : str Indicator of source type: 'independent' - .. versionadded:: 0.14.0 - particle : str or int or openmc.ParticleType - Source particle type (alias, PDG number, or GNDS nuclide name) + .. versionadded:: 0.14.0 + + particle : {'neutron', 'photon'} + Source particle type constraints : dict Constraints on sampled source particles. Valid keys include 'domain_type', 'domain_ids', 'time_bounds', 'energy_bounds', @@ -317,15 +308,14 @@ class IndependentSource(SourceBase): def __init__( self, - space: openmc.stats.Spatial | None = None, - angle: openmc.stats.UnitSphere | None = None, - energy: openmc.stats.Univariate | None = None, - time: openmc.stats.Univariate | None = None, + space: Optional[openmc.stats.Spatial] = None, + angle: Optional[openmc.stats.UnitSphere] = None, + energy: Optional[openmc.stats.Univariate] = None, + time: Optional[openmc.stats.Univariate] = None, strength: float = 1.0, - particle: str | int | ParticleType = 'neutron', - domains: Sequence[openmc.Cell | openmc.Material | - openmc.Universe] | None = None, - constraints: dict[str, Any] | None = None + particle: str = 'neutron', + domains: Optional[Sequence[typing.Union[openmc.Cell, openmc.Material, openmc.Universe]]] = None, + constraints: Optional[Dict[str, Any]] = None ): if domains is not None: warnings.warn("The 'domains' arguments has been replaced by the " @@ -407,12 +397,13 @@ class IndependentSource(SourceBase): self._time = time @property - def particle(self) -> ParticleType: + def particle(self): return self._particle @particle.setter def particle(self, particle): - self._particle = ParticleType(particle) + cv.check_value('source particle', particle, ['neutron', 'photon']) + self._particle = particle def populate_xml_element(self, element): """Add necessary source information to an XML element @@ -423,7 +414,7 @@ class IndependentSource(SourceBase): XML element containing source data """ - element.set("particle", str(self.particle)) + element.set("particle", self.particle) if self.space is not None: element.append(self.space.to_xml_element()) if self.angle is not None: @@ -533,12 +524,11 @@ class MeshSource(SourceBase): 'fissionable', and 'rejection_strategy'. """ - def __init__( self, mesh: MeshBase, sources: Sequence[SourceBase], - constraints: dict[str, Any] | None = None, + constraints: Optional[Dict[str, Any]] = None, ): super().__init__(strength=None, constraints=constraints) self.mesh = mesh @@ -572,10 +562,10 @@ class MeshSource(SourceBase): s = np.asarray(s) if isinstance(self.mesh, StructuredMesh): - if s.size != self.mesh.n_elements: + if s.size != self.mesh.num_mesh_cells: raise ValueError( f'The length of the source array ({s.size}) does not match ' - f'the number of mesh elements ({self.mesh.n_elements}).') + f'the number of mesh elements ({self.mesh.num_mesh_cells}).') # If user gave a multidimensional array, flatten in the order # of the mesh indices @@ -584,8 +574,7 @@ class MeshSource(SourceBase): elif isinstance(self.mesh, UnstructuredMesh): if s.ndim > 1: - raise ValueError( - 'Sources must be a 1-D array for unstructured mesh') + raise ValueError('Sources must be a 1-D array for unstructured mesh') self._sources = s for src in self._sources: @@ -654,8 +643,7 @@ class MeshSource(SourceBase): mesh_id = int(get_text(elem, 'mesh')) mesh = meshes[mesh_id] - sources = [SourceBase.from_xml_element( - e) for e in elem.iterchildren('source')] + sources = [SourceBase.from_xml_element(e) for e in elem.iterchildren('source')] constraints = cls._get_constraints(elem) return cls(mesh, sources, constraints=constraints) @@ -665,8 +653,7 @@ def Source(*args, **kwargs): A function for backward compatibility of sources. Will be removed in the future. Please update to IndependentSource. """ - warnings.warn( - "This class is deprecated in favor of 'IndependentSource'", FutureWarning) + warnings.warn("This class is deprecated in favor of 'IndependentSource'", FutureWarning) return openmc.IndependentSource(*args, **kwargs) @@ -677,7 +664,7 @@ class CompiledSource(SourceBase): Parameters ---------- - library : path-like + library : str or None Path to a compiled shared library parameters : str Parameters to be provided to the compiled shared library function @@ -699,7 +686,7 @@ class CompiledSource(SourceBase): Attributes ---------- - library : pathlib.Path + library : str or None Path to a compiled shared library parameters : str Parameters to be provided to the compiled shared library function @@ -713,16 +700,19 @@ class CompiledSource(SourceBase): 'fissionable', and 'rejection_strategy'. """ - def __init__( self, - library: PathLike, - parameters: str | None = None, + library: Optional[str] = None, + parameters: Optional[str] = None, strength: float = 1.0, - constraints: dict[str, Any] | None = None + constraints: Optional[Dict[str, Any]] = None ) -> None: super().__init__(strength=strength, constraints=constraints) - self.library = library + + self._library = None + if library is not None: + self.library = library + self._parameters = None if parameters is not None: self.parameters = parameters @@ -732,13 +722,13 @@ class CompiledSource(SourceBase): return "compiled" @property - def library(self) -> Path: + def library(self) -> str: return self._library @library.setter - def library(self, library_name: PathLike): - cv.check_type('library', library_name, PathLike) - self._library = input_path(library_name) + def library(self, library_name): + cv.check_type('library', library_name, str) + self._library = library_name @property def parameters(self) -> str: @@ -758,7 +748,7 @@ class CompiledSource(SourceBase): XML element containing source data """ - element.set("library", str(self.library)) + element.set("library", self.library) if self.parameters is not None: element.set("parameters", self.parameters) @@ -804,7 +794,7 @@ class FileSource(SourceBase): Parameters ---------- - path : path-like + path : str or pathlib.Path Path to the source file from which sites should be sampled strength : float Strength of the source (default is 1.0) @@ -839,12 +829,14 @@ class FileSource(SourceBase): def __init__( self, - path: PathLike, + path: Optional[PathLike] = None, strength: float = 1.0, - constraints: dict[str, Any] | None = None + constraints: Optional[Dict[str, Any]] = None ): super().__init__(strength=strength, constraints=constraints) - self.path = path + self._path = None + if path is not None: + self.path = path @property def type(self) -> str: @@ -856,8 +848,8 @@ class FileSource(SourceBase): @path.setter def path(self, p: PathLike): - cv.check_type('source file', p, PathLike) - self._path = input_path(p) + cv.check_type('source file', p, str) + self._path = p def populate_xml_element(self, element): """Add necessary file source information to an XML element @@ -869,7 +861,7 @@ class FileSource(SourceBase): """ if self.path is not None: - element.set("file", str(self.path)) + element.set("file", self.path) @classmethod def from_xml_element(cls, elem: ET.Element) -> openmc.FileSource: @@ -898,430 +890,52 @@ class FileSource(SourceBase): return cls(**kwargs) -class TokamakSource(SourceBase): - r"""A source representing neutron emission from a tokamak plasma. - - This source samples neutron positions from a tokamak plasma geometry using - Miller-style flux surface parameterization. The user provides an emission - profile S(r/a) as a function of normalized minor radius, along with one or - more energy distributions. - - The flux surface parameterization is - - .. math:: - - \begin{aligned} - R &= R_0 + r \cos\left(\alpha + \delta \sin\alpha\right) - + \Delta \left[1 - \left(\frac{r}{a}\right)^2\right] \\ - Z &= Z_\mathrm{shift} + \kappa r \sin\alpha - \end{aligned} - - where :math:`R_0` is major radius, :math:`a` is minor radius, - :math:`\kappa` is elongation, :math:`\delta` is triangularity, - :math:`\Delta` is the Shafranov shift, and :math:`Z_\mathrm{shift}` is - the vertical shift. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - major_radius : float - Major radius R0 in [cm] - minor_radius : float - Minor radius a in [cm] - elongation : float - Plasma elongation κ (must be > 0) - triangularity : float - Plasma triangularity δ (must be in [-1, 1]) - shafranov_shift : float - Shafranov shift Δ in [cm] (must be >= 0 and < a/2) - r_over_a : numpy.ndarray - Normalized minor radius grid points, must start at 0 and end at 1 - emission_density : numpy.ndarray - Emission density S(r) at each r/a point (arbitrary units, must be >= 0). - Values are linearly interpolated between grid points and refined on an - internal grid for radial sampling. Must have the same length as - ``r_over_a`` and contain at least one positive value. - energy : openmc.stats.Univariate or Sequence[openmc.stats.Univariate] - Energy distribution(s). Either a single distribution used at all radii, - or one distribution per ``r_over_a`` grid point. When one distribution - per grid point is given, the energy of a sampled particle is drawn from - one of the two distributions bracketing its sampled radius, selected - stochastically with probability proportional to the proximity of the - radius to each grid point (stochastic interpolation). - time : openmc.stats.Univariate, optional - Time distribution of the source. If None, particles are born at - :math:`t=0`, matching the default behavior of - :class:`openmc.IndependentSource`. - phi_start : float - Starting toroidal angle in [rad] (default: 0) - phi_extent : float - Toroidal angle extent in [rad] (default: 2π) - n_alpha : int - Number of poloidal angle grid points for CDF sampling (default: 101) - vertical_shift : float - Vertical shift of the plasma center in [cm] (default: 0) - strength : float - Strength of the source (default: 1.0) - constraints : dict - Constraints on sampled source particles. See :class:`SourceBase` for - valid keys and values. - - Attributes - ---------- - major_radius : float - Major radius R0 in [cm] - minor_radius : float - Minor radius a in [cm] - elongation : float - Plasma elongation κ - triangularity : float - Plasma triangularity δ - shafranov_shift : float - Shafranov shift Δ in [cm] - r_over_a : numpy.ndarray - Normalized minor radius grid points - emission_density : numpy.ndarray - Emission density S(r) at each r/a point - energy : list of openmc.stats.Univariate - Energy distribution(s) - time : openmc.stats.Univariate or None - Time distribution of the source - phi_start : float - Starting toroidal angle in [rad] - phi_extent : float - Toroidal angle extent in [rad] - n_alpha : int - Number of poloidal angle grid points - vertical_shift : float - Vertical shift of the plasma center in [cm] - strength : float - Strength of the source - type : str - Indicator of source type: 'tokamak' - constraints : dict - Constraints on sampled source particles - +class ParticleType(IntEnum): """ - - def __init__( - self, - major_radius: float, - minor_radius: float, - elongation: float, - triangularity: float, - shafranov_shift: float, - r_over_a: Sequence[float], - emission_density: Sequence[float], - energy: Univariate | Sequence[Univariate], - time: Univariate | None = None, - phi_start: float = 0.0, - phi_extent: float = 2.0 * np.pi, - n_alpha: int = 101, - vertical_shift: float = 0.0, - strength: float = 1.0, - constraints: dict[str, Any] | None = None - ): - super().__init__(strength=strength, constraints=constraints) - self.major_radius = major_radius - self.minor_radius = minor_radius - self.elongation = elongation - self.triangularity = triangularity - self.shafranov_shift = shafranov_shift - self.r_over_a = r_over_a - self.emission_density = emission_density - self.phi_start = phi_start - self.phi_extent = phi_extent - self.n_alpha = n_alpha - self.vertical_shift = vertical_shift - self.energy = energy - self.time = time - - self._validate() - - def _validate(self): - """Validate relationships between tokamak source parameters.""" - if self.minor_radius >= self.major_radius: - raise ValueError( - f"minor_radius ({self.minor_radius}) must be smaller than " - f"major_radius ({self.major_radius})") - if self.shafranov_shift >= 0.5 * self.minor_radius: - raise ValueError( - f"shafranov_shift ({self.shafranov_shift}) must be smaller " - f"than half the minor_radius ({0.5 * self.minor_radius})") - if len(self.emission_density) != len(self.r_over_a): - raise ValueError( - f"emission_density (length {len(self.emission_density)}) must " - f"have the same length as r_over_a (length {len(self.r_over_a)})") - if not np.any(self.emission_density > 0.0): - raise ValueError("emission_density must contain a positive value") - if len(self.energy) not in (1, len(self.r_over_a)): - raise ValueError( - f"Number of energy distributions ({len(self.energy)}) must be " - f"either 1 or equal to the number of r_over_a grid points " - f"({len(self.r_over_a)})") - - @property - def type(self) -> str: - return "tokamak" - - @property - def major_radius(self) -> float: - return self._major_radius - - @major_radius.setter - def major_radius(self, value: float): - cv.check_type('major radius', value, Real) - cv.check_greater_than('major radius', value, 0.0) - self._major_radius = value - - @property - def minor_radius(self) -> float: - return self._minor_radius - - @minor_radius.setter - def minor_radius(self, value: float): - cv.check_type('minor radius', value, Real) - cv.check_greater_than('minor radius', value, 0.0) - self._minor_radius = value - - @property - def elongation(self) -> float: - return self._elongation - - @elongation.setter - def elongation(self, value: float): - cv.check_type('elongation', value, Real) - cv.check_greater_than('elongation', value, 0.0) - self._elongation = value - - @property - def triangularity(self) -> float: - return self._triangularity - - @triangularity.setter - def triangularity(self, value: float): - cv.check_type('triangularity', value, Real) - cv.check_greater_than('triangularity', value, -1.0, equality=True) - cv.check_less_than('triangularity', value, 1.0, equality=True) - self._triangularity = value - - @property - def shafranov_shift(self) -> float: - return self._shafranov_shift - - @shafranov_shift.setter - def shafranov_shift(self, value: float): - cv.check_type('Shafranov shift', value, Real) - cv.check_greater_than('Shafranov shift', value, 0.0, equality=True) - self._shafranov_shift = value - - @property - def r_over_a(self) -> np.ndarray: - return self._r_over_a - - @r_over_a.setter - def r_over_a(self, value: Sequence[float]): - value = np.asarray(value, dtype=float) - if value.ndim != 1 or len(value) < 2: - raise ValueError("r_over_a must be a 1-D array with at least 2 points") - if value[0] != 0.0: - raise ValueError("r_over_a must start at 0") - if value[-1] != 1.0: - raise ValueError("r_over_a must end at 1") - if not np.all(np.diff(value) > 0): - raise ValueError("r_over_a must be strictly increasing") - self._r_over_a = value - - @property - def emission_density(self) -> np.ndarray: - return self._emission_density - - @emission_density.setter - def emission_density(self, value: Sequence[float]): - value = np.asarray(value, dtype=float) - if value.ndim != 1: - raise ValueError("emission_density must be a 1-D array") - if np.any(value < 0): - raise ValueError("emission_density values cannot be negative") - self._emission_density = value - - @property - def energy(self) -> list[Univariate]: - return self._energy - - @energy.setter - def energy(self, value: Univariate | Sequence[Univariate]): - if isinstance(value, Univariate): - self._energy = [value] - else: - cv.check_iterable_type('energy distributions', value, Univariate) - self._energy = list(value) - - @property - def time(self) -> Univariate | None: - return self._time - - @time.setter - def time(self, value: Univariate | None): - if value is not None: - cv.check_type('time distribution', value, Univariate) - self._time = value - - @property - def phi_start(self) -> float: - return self._phi_start - - @phi_start.setter - def phi_start(self, value: float): - cv.check_type('phi_start', value, Real) - self._phi_start = value - - @property - def phi_extent(self) -> float: - return self._phi_extent - - @phi_extent.setter - def phi_extent(self, value: float): - cv.check_type('phi_extent', value, Real) - cv.check_greater_than('phi_extent', value, 0.0) - cv.check_less_than('phi_extent', value, 2.0 * np.pi, equality=True) - self._phi_extent = value - - @property - def n_alpha(self) -> int: - return self._n_alpha - - @n_alpha.setter - def n_alpha(self, value: int): - cv.check_type('n_alpha', value, Integral) - cv.check_greater_than('n_alpha', value, 2) - if value < 51: - warnings.warn( - "n_alpha values below 51 may introduce noticeable " - "discretization bias in tokamak source sampling", stacklevel=2) - self._n_alpha = value - - @property - def vertical_shift(self) -> float: - return self._vertical_shift - - @vertical_shift.setter - def vertical_shift(self, value: float): - cv.check_type('vertical shift', value, Real) - self._vertical_shift = value - - def populate_xml_element(self, element): - """Add necessary tokamak source information to an XML element - - Returns - ------- - element : lxml.etree._Element - XML element containing source data - - """ - self._validate() - - # Geometry parameters - ET.SubElement(element, "major_radius").text = str(self.major_radius) - ET.SubElement(element, "minor_radius").text = str(self.minor_radius) - ET.SubElement(element, "elongation").text = str(self.elongation) - ET.SubElement(element, "triangularity").text = str(self.triangularity) - ET.SubElement(element, "shafranov_shift").text = str(self.shafranov_shift) - - # Toroidal angle bounds - ET.SubElement(element, "phi_start").text = str(self.phi_start) - ET.SubElement(element, "phi_extent").text = str(self.phi_extent) - - # Poloidal sampling resolution - ET.SubElement(element, "n_alpha").text = str(self.n_alpha) - - # Vertical shift - if self.vertical_shift != 0.0: - ET.SubElement(element, "vertical_shift").text = str(self.vertical_shift) - - # Emission profile - ET.SubElement(element, "r_over_a").text = ' '.join(str(r) for r in self.r_over_a) - ET.SubElement(element, "emission_density").text = ' '.join(str(s) for s in self.emission_density) - - # Energy distribution(s) - for dist in self.energy: - element.append(dist.to_xml_element('energy')) - - # Time distribution - if self.time is not None: - element.append(self.time.to_xml_element('time')) + IntEnum class representing a particle type. Type + values mirror those found in the C++ class. + """ + NEUTRON = 0 + PHOTON = 1 + ELECTRON = 2 + POSITRON = 3 @classmethod - def from_xml_element(cls, elem: ET.Element) -> TokamakSource: - """Generate tokamak source from an XML element + def from_string(cls, value: str): + """ + Constructs a ParticleType instance from a string. Parameters ---------- - elem : lxml.etree._Element - XML element + value : str + The string representation of the particle type. Returns ------- - openmc.TokamakSource - Source generated from XML element - + The corresponding ParticleType instance. """ - # Read geometry parameters - major_radius = float(get_text(elem, 'major_radius')) - minor_radius = float(get_text(elem, 'minor_radius')) - elongation = float(get_text(elem, 'elongation')) - triangularity = float(get_text(elem, 'triangularity')) - shafranov_shift = float(get_text(elem, 'shafranov_shift')) + try: + return cls[value.upper()] + except KeyError: + raise ValueError(f"Invalid string for creation of {cls.__name__}: {value}") - # Read optional parameters - phi_start_text = get_text(elem, 'phi_start') - phi_start = float(phi_start_text) if phi_start_text else 0.0 + def __repr__(self) -> str: + """ + Returns a string representation of the ParticleType instance. - phi_extent_text = get_text(elem, 'phi_extent') - phi_extent = float(phi_extent_text) if phi_extent_text else 2.0 * np.pi + Returns: + str: The lowercase name of the ParticleType instance. + """ + return self.name.lower() - n_alpha_text = get_text(elem, 'n_alpha') - n_alpha = int(n_alpha_text) if n_alpha_text else 101 + # needed for < Python 3.11 + def __str__(self) -> str: + return self.__repr__() - vertical_shift_text = get_text(elem, 'vertical_shift') - vertical_shift = float(vertical_shift_text) if vertical_shift_text else 0.0 - - # Read emission profile - r_over_a = np.array([float(x) for x in get_text(elem, 'r_over_a').split()]) - emission_density = np.array([float(x) for x in get_text(elem, 'emission_density').split()]) - - # Read energy distributions - energy = [Univariate.from_xml_element(e) for e in elem.findall('energy')] - if len(energy) == 1: - energy = energy[0] - - # Read time distribution - time_elem = elem.find('time') - time = Univariate.from_xml_element(time_elem) if time_elem is not None else None - - # Read constraints and strength - constraints = cls._get_constraints(elem) - strength_text = get_text(elem, 'strength') - strength = float(strength_text) if strength_text else 1.0 - - return cls( - major_radius=major_radius, - minor_radius=minor_radius, - elongation=elongation, - triangularity=triangularity, - shafranov_shift=shafranov_shift, - r_over_a=r_over_a, - emission_density=emission_density, - energy=energy, - time=time, - phi_start=phi_start, - phi_extent=phi_extent, - n_alpha=n_alpha, - vertical_shift=vertical_shift, - strength=strength, - constraints=constraints - ) + # needed for <= 3.7, IntEnum will use the mixed-in type's `__format__` method otherwise + # this forces it to default to the standard object format, relying on __str__ under the hood + def __format__(self, spec): + return object.__format__(self, spec) class SourceParticle: @@ -1346,21 +960,20 @@ class SourceParticle: Delayed group particle was created in (neutrons only) surf_id : int Surface ID where particle is at, if any. - particle : ParticleType or str or int - Type of the particle (type, name, or PDG number) + particle : ParticleType + Type of the particle """ - def __init__( self, - r: Iterable[float] = (0., 0., 0.), - u: Iterable[float] = (0., 0., 1.), + r: typing.Iterable[float] = (0., 0., 0.), + u: typing.Iterable[float] = (0., 0., 1.), E: float = 1.0e6, time: float = 0.0, wgt: float = 1.0, delayed_group: int = 0, surf_id: int = 0, - particle: ParticleType | str | int = ParticleType.NEUTRON + particle: ParticleType = ParticleType.NEUTRON ): self.r = tuple(r) @@ -1372,16 +985,9 @@ class SourceParticle: self.surf_id = surf_id self.particle = particle - @property - def particle(self) -> ParticleType: - return self._particle - - @particle.setter - def particle(self, particle): - self._particle = ParticleType(particle) - def __repr__(self): - return f'' + name = self.particle.name.lower() + return f'' def to_tuple(self) -> tuple: """Return source particle attributes as a tuple @@ -1393,11 +999,11 @@ class SourceParticle: """ return (self.r, self.u, self.E, self.time, self.wgt, - self.delayed_group, self.surf_id, self.particle.pdg_number) + self.delayed_group, self.surf_id, self.particle.value) def write_source_file( - source_particles: Iterable[SourceParticle], + source_particles: typing.Iterable[SourceParticle], filename: PathLike, **kwargs ): """Write a source file using a collection of source particles @@ -1416,177 +1022,31 @@ def write_source_file( openmc.SourceParticle """ - cv.check_iterable_type( - "source particles", source_particles, SourceParticle) - pl = ParticleList(source_particles) - pl.export_to_hdf5(filename, **kwargs) + # Create compound datatype for source particles + pos_dtype = np.dtype([('x', ' ParticleList: - """Create particle list from an HDF5 file. - - Parameters - ---------- - filename : path-like - Path to source file to read. - - Returns - ------- - ParticleList instance - - """ - with h5py.File(filename, 'r') as fh: - filetype = fh.attrs['filetype'] - arr = fh['source_bank'][...] - - if filetype != b'source': - raise ValueError(f'File {filename} is not a source file') - - source_particles = [ - SourceParticle(*params, ParticleType(particle)) - for *params, particle in arr - ] - return cls(source_particles) - - @classmethod - def from_mcpl(cls, filename: PathLike) -> ParticleList: - """Create particle list from an MCPL file. - - Parameters - ---------- - filename : path-like - Path to MCPL file to read. - - Returns - ------- - ParticleList instance - - """ - import mcpl - # Process .mcpl file - particles = [] - with mcpl.MCPLFile(filename) as f: - for particle in f.particles: - particle_type = ParticleType(particle.pdgcode) - - # Create a source particle instance. Note that MCPL stores - # energy in MeV and time in ms. - source_particle = SourceParticle( - r=tuple(particle.position), - u=tuple(particle.direction), - E=1.0e6*particle.ekin, - time=1.0e-3*particle.time, - wgt=particle.weight, - particle=particle_type - ) - particles.append(source_particle) - - return cls(particles) - - def __getitem__(self, index): - """ - Return a new ParticleList object containing the particle(s) - at the specified index or slice. - - Parameters - ---------- - index : int, slice or list - The index, slice or list to select from the list of particles - - Returns - ------- - openmc.ParticleList or openmc.SourceParticle - A new object with the selected particle(s) - """ - if isinstance(index, int): - # If it's a single integer, return the corresponding particle - return super().__getitem__(index) - elif isinstance(index, slice): - # If it's a slice, return a new ParticleList object with the - # sliced particles - return ParticleList(super().__getitem__(index)) - elif isinstance(index, list): - # If it's a list of integers, return a new ParticleList object with - # the selected particles. Note that Python 3.10 gets confused if you - # use super() here, so we call list.__getitem__ directly. - return ParticleList([list.__getitem__(self, i) for i in index]) - else: - raise TypeError(f"Invalid index type: {type(index)}. Must be int, " - "slice, or list of int.") - - def to_dataframe(self) -> pd.DataFrame: - """A dataframe representing the source particles - - Returns - ------- - pandas.DataFrame - DataFrame containing the source particles attributes. - """ - # Extract the attributes of the source particles into a list of tuples - data = [(sp.r[0], sp.r[1], sp.r[2], sp.u[0], sp.u[1], sp.u[2], - sp.E, sp.time, sp.wgt, sp.delayed_group, sp.surf_id, - str(sp.particle)) for sp in self] - - # Define the column names for the DataFrame - columns = ['x', 'y', 'z', 'u_x', 'u_y', 'u_z', 'E', 'time', 'wgt', - 'delayed_group', 'surf_id', 'particle'] - - # Create the pandas DataFrame from the data - return pd.DataFrame(data, columns=columns) - - def export_to_hdf5(self, filename: PathLike, **kwargs): - """Export particle list to an HDF5 file. - - This method write out an .h5 file that can be used as a source file in - conjunction with the :class:`openmc.FileSource` class. - - Parameters - ---------- - filename : path-like - Path to source file to write - **kwargs - Keyword arguments to pass to :class:`h5py.File` - - See Also - -------- - openmc.FileSource - - """ - # Create compound datatype for source particles - pos_dtype = np.dtype([('x', ' ParticleList: +def read_source_file(filename: PathLike) -> typing.List[SourceParticle]: """Read a source file and return a list of source particles. .. versionadded:: 0.15.0 @@ -1598,148 +1058,23 @@ def read_source_file(filename: PathLike) -> ParticleList: Returns ------- - openmc.ParticleList + list of SourceParticle + Source particles read from file See Also -------- openmc.SourceParticle """ - filename = Path(filename) - if filename.suffix not in ('.h5', '.mcpl'): - raise ValueError('Source file must have a .h5 or .mcpl extension.') + with h5py.File(filename, 'r') as fh: + filetype = fh.attrs['filetype'] + arr = fh['source_bank'][...] - if filename.suffix == '.h5': - return ParticleList.from_hdf5(filename) - else: - return ParticleList.from_mcpl(filename) + if filetype != b'source': + raise ValueError(f'File {filename} is not a source file') + source_particles = [] + for *params, particle in arr: + source_particles.append(SourceParticle(*params, ParticleType(particle))) -def read_collision_track_hdf5(filename): - """Read a collision track file in HDF5 format. - - Parameters - ---------- - filename : str or path-like - Path to the HDF5 collision track file. - - Returns - ------- - numpy.ndarray - Structured array containing collision track data. - - See Also - -------- - read_collision_track_mcpl - read_collision_track_file - """ - - with h5py.File(filename, 'r') as file: - data = file['collision_track_bank'][:] - - return data - - -def read_collision_track_mcpl(file_path): - """Read a collision track file in MCPL format. - - Parameters - ---------- - file_path : str or path-like - Path to the MCPL collision track file. - - Returns - ------- - numpy.ndarray - Structured array of particle collision track information, including - position, direction, energy, weight, reaction data, and identifiers. - - See Also - -------- - read_collision_track_hdf5 - read_collision_track_file - """ - import mcpl - myfile = mcpl.MCPLFile(file_path) - data = { - 'r': [], # for position (x, y, z) - 'u': [], # for direction (ux, uy, uz) - 'E': [], 'dE': [], 'time': [], - 'wgt': [], 'event_mt': [], 'delayed_group': [], - 'cell_id': [], 'nuclide_id': [], 'material_id': [], - 'universe_id': [], 'n_collision': [], 'particle': [], - 'parent_id': [], 'progeny_id': [] - } - - # Read and collect data from the MCPL file - for i, p in enumerate(myfile.particles): - if f'blob_{i}' in myfile.blobs: - blob_data = myfile.blobs[f'blob_{i}'] - decoded_str = blob_data.decode('utf-8') - pairs = decoded_str.split(';') - values_dict = {k.strip(): v.strip() - for k, v in (pair.split(':') for pair in pairs if pair.strip())} - - data['r'].append((p.x, p.y, p.z)) # Append as tuple - data['u'].append((p.ux, p.uy, p.uz)) # Append as tuple - data['E'].append(p.ekin * 1e6) - data['dE'].append(float(values_dict.get('dE', 0))) - data['time'].append(p.time * 1e-3) - data['wgt'].append(p.weight) - data['event_mt'].append(int(values_dict.get('event_mt', 0))) - data['delayed_group'].append( - int(values_dict.get('delayed_group', 0))) - data['cell_id'].append(int(values_dict.get('cell_id', 0))) - data['nuclide_id'].append(int(values_dict.get('nuclide_id', 0))) - data['material_id'].append(int(values_dict.get('material_id', 0))) - data['universe_id'].append(int(values_dict.get('universe_id', 0))) - data['n_collision'].append(int(values_dict.get('n_collision', 0))) - data['particle'].append(ParticleType(p.pdgcode)) - data['parent_id'].append(int(values_dict.get('parent_id', 0))) - data['progeny_id'].append(int(values_dict.get('progeny_id', 0))) - - dtypes = [ - ('r', [('x', 'f8'), ('y', 'f8'), ('z', 'f8')]), - ('u', [('x', 'f8'), ('y', 'f8'), ('z', 'f8')]), - ('E', 'f8'), ('dE', 'f8'), ('time', 'f8'), ('wgt', 'f8'), - ('event_mt', 'f8'), ('delayed_group', 'i4'), ('cell_id', 'i4'), - ('nuclide_id', 'i4'), ('material_id', 'i4'), ('universe_id', 'i4'), - ('n_collision', 'i4'), ('particle', 'i4'), - ('parent_id', 'i8'), ('progeny_id', 'i8') - ] - - structured_array = np.zeros(len(data['r']), dtype=dtypes) - for key in data: - structured_array[key] = data[key] # Assign data - - return structured_array - - -def read_collision_track_file(filename): - """Read a collision track file (HDF5 or MCPL) and return its data. - - Parameters - ---------- - filename : str or path-like - Path to the collision track file to read. Must end with - ``.h5`` or ``.mcpl``. - - Returns - ------- - numpy.ndarray - Structured array containing collision track data. - - See Also - -------- - read_collision_track_hdf5 - read_collision_track_mcpl - """ - - filename = Path(filename) - if filename.suffix not in ('.h5', '.mcpl'): - raise ValueError('Collision track file must have a .h5 or .mcpl extension.') - - if filename.suffix == '.h5': - return read_collision_track_hdf5(filename) - else: - return read_collision_track_mcpl(filename) + return source_particles diff --git a/openmc/statepoint.py b/openmc/statepoint.py index a10ec3a83..13aac0caf 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -1,5 +1,4 @@ from datetime import datetime -from collections import namedtuple import glob import re import os @@ -7,9 +6,7 @@ import warnings import h5py import numpy as np -from pathlib import Path from uncertainties import ufloat -from uncertainties.unumpy import uarray import openmc import openmc.checkvalue as cv @@ -17,9 +14,6 @@ import openmc.checkvalue as cv _VERSION_STATEPOINT = 18 -KineticsParameters = namedtuple("KineticsParameters", ["generation_time", "beta_effective"]) - - class StatePoint: """State information on a simulation at a certain point in time (at the end of a given batch). Statepoints can be used to analyze tally results as well @@ -104,8 +98,6 @@ class StatePoint: and whose values are time values in seconds. seed : int Pseudorandom number generator seed - stride : int - Number of random numbers allocated for each particle history source : numpy.ndarray of compound datatype Array of source sites. The compound datatype has fields 'r', 'u', 'E', 'wgt', 'delayed_group', 'surf_id', and 'particle', corresponding to @@ -363,10 +355,6 @@ class StatePoint: def seed(self): return self._f['seed'][()] - @property - def stride(self): - return self._f['stride'][()] - @property def source(self): return self._f['source_bank'][()] if self.source_present else None @@ -427,17 +415,13 @@ class StatePoint: # Create Tally object and assign basic properties tally = openmc.Tally(tally_id) - tally._sp_filename = Path(self._f.filename) + tally._sp_filename = self._f.filename tally.name = group['name'][()].decode() if 'name' in group else '' # Check if tally has multiply_density attribute if "multiply_density" in group.attrs: tally.multiply_density = group.attrs["multiply_density"].item() > 0 - # Check if tally has higher_moments attribute - if 'higher_moments' in group.attrs: - tally.higher_moments = bool(group.attrs['higher_moments'][()]) - # Read the number of realizations n_realizations = group['n_realizations'][()] @@ -464,11 +448,14 @@ class StatePoint: nuclide_names = group['nuclides'][()] # Add all nuclides to the Tally - tally.nuclides = [name.decode().strip() for name in nuclide_names] + for name in nuclide_names: + nuclide = openmc.Nuclide(name.decode().strip()) + tally.nuclides.append(nuclide) # Add the scores to the Tally scores = group['score_bins'][()] - tally.scores = [score.decode() for score in scores] + for score in scores: + tally.scores.append(score.decode()) # Add Tally to the global dictionary of all Tallies tally.sparse = self.sparse @@ -539,16 +526,15 @@ class StatePoint: def get_tally(self, scores=[], filters=[], nuclides=[], name=None, id=None, estimator=None, exact_filters=False, - exact_nuclides=False, exact_scores=False, - multiply_density=None, derivative=None, filter_type=None): + exact_nuclides=False, exact_scores=False): """Finds and returns a Tally object with certain properties. This routine searches the list of Tallies and returns the first Tally found which satisfies all of the input parameters. NOTE: If any of the "exact" parameters are False (default), the input - parameters do not need to match the complete Tally specification and may - only represent a subset of the Tally's properties. If an "exact" + parameters do not need to match the complete Tally specification and + may only represent a subset of the Tally's properties. If an "exact" parameter is True then number of scores, filters, or nuclides in the parameters must precisely match those of any matching Tally. @@ -575,18 +561,9 @@ class StatePoint: to those in the matching Tally. If False (default), the nuclides in the parameters may be a subset of those in the matching Tally. exact_scores : bool - If True, the number of scores in the parameters must be identical to - those in the matching Tally. If False (default), the scores in the - parameters may be a subset of those in the matching Tally. Default - is None (no check). - multiply_density : bool, optional - If not None, the Tally must have the multiply_density attribute set - to the same value as this parameter. - derivative : openmc.TallyDerivative, optional - TallyDerivative object to match. - filter_type : type, optional - If not None, the Tally must have at least one Filter that is an - instance of this type. For example `openmc.MeshFilter`. + If True, the number of scores in the parameters must be identical + to those in the matching Tally. If False (default), the scores + in the parameters may be a subset of those in the matching Tally. Returns ------- @@ -614,25 +591,17 @@ class StatePoint: if id and id != test_tally.id: continue - # Determine if Tally has queried estimator, only move on to next tally - # if the estimator is both specified and the tally estimtor does not - # match - if estimator is not None and estimator != test_tally.estimator: + # Determine if Tally has queried estimator + if estimator and estimator != test_tally.estimator: continue # The number of filters, nuclides and scores must exactly match if exact_scores and len(scores) != test_tally.num_scores: continue - if exact_nuclides and nuclides and len(nuclides) != test_tally.num_nuclides: - continue - if exact_nuclides and not nuclides and test_tally.nuclides != ['total']: + if exact_nuclides and len(nuclides) != test_tally.num_nuclides: continue if exact_filters and len(filters) != test_tally.num_filters: continue - if derivative is not None and derivative != test_tally.derivative: - continue - if multiply_density is not None and multiply_density != test_tally.multiply_density: - continue # Determine if Tally has the queried score(s) if scores: @@ -660,10 +629,6 @@ class StatePoint: if not contains_filters: continue - if filter_type is not None: - if not any(isinstance(f, filter_type) for f in test_tally.filters): - continue - # Determine if Tally has the queried Nuclide(s) if nuclides: if not all(nuclide in test_tally.nuclides for nuclide in nuclides): @@ -723,59 +688,6 @@ class StatePoint: cell = cells[cell_id] if not cell._paths: summary.geometry.determine_paths() - tally_filter._paths = cell.paths + tally_filter.paths = cell.paths self._summary = summary - - def get_kinetics_parameters(self) -> KineticsParameters: - """Get kinetics parameters from IFP tallies. - - This method searches the tallies in the statepoint for the tallies - required to compute kinetics parameters using the Iterated Fission - Probability (IFP) method. - - Returns - ------- - KineticsParameters - A named tuple containing the generation time and effective delayed - neutron fraction. If the necessary tallies for one or both - parameters are not found, that parameter is returned as None. - - """ - - denom_tally = None - gen_time_tally = None - beta_tally = None - for tally in self.tallies.values(): - if 'ifp-denominator' in tally.scores: - denom_tally = self.get_tally(scores=['ifp-denominator']) - if 'ifp-time-numerator' in tally.scores: - gen_time_tally = self.get_tally(scores=['ifp-time-numerator']) - if 'ifp-beta-numerator' in tally.scores: - beta_tally = self.get_tally(scores=['ifp-beta-numerator']) - - if denom_tally is None: - return KineticsParameters(None, None) - - def get_ufloat(tally, score): - return uarray(tally.get_values(scores=[score]), - tally.get_values(scores=[score], value='std_dev')) - - denom_values = get_ufloat(denom_tally, 'ifp-denominator') - if gen_time_tally is None: - generation_time = None - else: - gen_time_values = get_ufloat(gen_time_tally, 'ifp-time-numerator') - gen_time_values /= denom_values*self.keff - generation_time = gen_time_values.flatten()[0] - - if beta_tally is None: - beta_effective = None - else: - beta_values = get_ufloat(beta_tally, 'ifp-beta-numerator') - beta_values /= denom_values - beta_effective = beta_values.flatten() - if beta_effective.size == 1: - beta_effective = beta_effective[0] - - return KineticsParameters(generation_time, beta_effective) diff --git a/openmc/stats/multivariate.py b/openmc/stats/multivariate.py index d48697037..ce9740ad2 100644 --- a/openmc/stats/multivariate.py +++ b/openmc/stats/multivariate.py @@ -1,6 +1,7 @@ from __future__ import annotations +import typing from abc import ABC, abstractmethod -from collections.abc import Iterable, Sequence +from collections.abc import Iterable from math import cos, pi from numbers import Real from warnings import warn @@ -8,11 +9,10 @@ from warnings import warn import lxml.etree as ET import numpy as np -import openmc import openmc.checkvalue as cv -from .._xml import get_elem_list, get_text +from .._xml import get_text from ..mesh import MeshBase -from .univariate import PowerLaw, Uniform, Univariate, delta_function +from .univariate import PowerLaw, Uniform, Univariate class UnitSphere(ABC): @@ -79,9 +79,6 @@ class PolarAzimuthal(UnitSphere): reference_uvw : Iterable of float Direction from which polar angle is measured. Defaults to the positive z-direction. - reference_vwu : Iterable of float - Direction from which azimuthal angle is measured. Defaults to the positive - x-direction. Attributes ---------- @@ -92,9 +89,8 @@ class PolarAzimuthal(UnitSphere): """ - def __init__(self, mu=None, phi=None, reference_uvw=(0., 0., 1.), reference_vwu=(1., 0., 0.)): + def __init__(self, mu=None, phi=None, reference_uvw=(0., 0., 1.)): super().__init__(reference_uvw) - self.reference_vwu = reference_vwu if mu is not None: self.mu = mu else: @@ -105,20 +101,6 @@ class PolarAzimuthal(UnitSphere): else: self.phi = Uniform(0., 2*pi) - @property - def reference_vwu(self): - return self._reference_vwu - - @reference_vwu.setter - def reference_vwu(self, vwu): - cv.check_type('reference v direction', vwu, Iterable, Real) - vwu = np.asarray(vwu) - uvw = self.reference_uvw - cv.check_greater_than('reference v direction must not be parallel to reference u direction', np.linalg.norm(np.cross(vwu,uvw)), 1e-6*np.linalg.norm(vwu)) - vwu -= vwu.dot(uvw)*uvw - cv.check_less_than('reference v direction must be orthogonal to reference u direction', np.abs(vwu.dot(uvw)), 1e-6) - self._reference_vwu = vwu/np.linalg.norm(vwu) - @property def mu(self): return self._mu @@ -137,30 +119,19 @@ class PolarAzimuthal(UnitSphere): cv.check_type('azimuthal angle', phi, Univariate) self._phi = phi - def to_xml_element(self, element_name: str = None): + def to_xml_element(self): """Return XML representation of the angular distribution - Parameters - ---------- - element_name : str, optional - XML element name - Returns ------- element : lxml.etree._Element XML element containing angular distribution data """ - if element_name is not None: - element = ET.Element(element_name) - else: - element = ET.Element('angle') - + element = ET.Element('angle') element.set("type", "mu-phi") if self.reference_uvw is not None: element.set("reference_uvw", ' '.join(map(str, self.reference_uvw))) - if self.reference_vwu is not None: - element.set("reference_vwu", ' '.join(map(str, self.reference_vwu))) element.append(self.mu.to_xml_element('mu')) element.append(self.phi.to_xml_element('phi')) return element @@ -181,53 +152,19 @@ class PolarAzimuthal(UnitSphere): """ mu_phi = cls() - uvw = get_elem_list(elem, "reference_uvw", float) + uvw = get_text(elem, 'reference_uvw') if uvw is not None: - mu_phi.reference_uvw = uvw - vwu = get_elem_list(elem, "reference_vwu", float) - if vwu is not None: - mu_phi.reference_vwu = vwu + mu_phi.reference_uvw = [float(x) for x in uvw.split()] mu_phi.mu = Univariate.from_xml_element(elem.find('mu')) mu_phi.phi = Univariate.from_xml_element(elem.find('phi')) return mu_phi class Isotropic(UnitSphere): - """Isotropic angular distribution. + """Isotropic angular distribution.""" - Parameters - ---------- - bias : openmc.stats.PolarAzimuthal, optional - Distribution for biased sampling. - - Attributes - ---------- - bias : openmc.stats.PolarAzimuthal or None - Distribution for biased sampling - - """ - - def __init__(self, bias: PolarAzimuthal | None = None): + def __init__(self): super().__init__() - self.bias = bias - - @property - def bias(self): - return self._bias - - @bias.setter - def bias(self, bias): - cv.check_type('Biasing distribution', bias, PolarAzimuthal, none_ok=True) - if bias is not None: - if (bias.mu.bias is not None) or (bias.phi.bias is not None): - raise RuntimeError('Biasing distributions should not have their own bias.') - elif (bias.mu.support != (-1., 1.) - or not np.all(np.isclose(bias.phi.support, (0., 2*np.pi)))): - raise ValueError("Biasing distribution for an isotropic " - "distribution should be supported on " - "mu=(-1.0,1.0) and phi=(0.0,2*pi).") - - self._bias = bias def to_xml_element(self): """Return XML representation of the isotropic distribution @@ -240,15 +177,6 @@ class Isotropic(UnitSphere): """ element = ET.Element('angle') element.set("type", "isotropic") - - if self.bias is not None: - bias_dist = self.bias - if (bias_dist.mu.bias is not None) or (bias_dist.phi.bias is not None): - raise RuntimeError('Biasing distributions should not have their own bias!') - else: - bias_elem = self.bias.to_xml_element("bias") - element.append(bias_elem) - return element @classmethod @@ -266,13 +194,7 @@ class Isotropic(UnitSphere): Isotropic distribution generated from XML element """ - bias_elem = elem.find('bias') - if bias_elem is not None: - bias_dist = PolarAzimuthal.from_xml_element(bias_elem) - return cls(bias=bias_dist) - else: - return cls() - + return cls() class Monodirectional(UnitSphere): @@ -290,7 +212,7 @@ class Monodirectional(UnitSphere): """ - def __init__(self, reference_uvw: Sequence[float] = [1., 0., 0.]): + def __init__(self, reference_uvw: typing.Sequence[float] = [1., 0., 0.]): super().__init__(reference_uvw) def to_xml_element(self): @@ -324,9 +246,9 @@ class Monodirectional(UnitSphere): """ monodirectional = cls() - uvw = get_elem_list(elem, "reference_uvw", float) + uvw = get_text(elem, 'reference_uvw') if uvw is not None: - monodirectional.reference_uvw = uvw + monodirectional.reference_uvw = [float(x) for x in uvw.split()] return monodirectional @@ -357,8 +279,6 @@ class Spatial(ABC): return Point.from_xml_element(elem) elif distribution == 'mesh': return MeshSpatial.from_xml_element(elem, meshes) - elif distribution == 'cloud': - return PointCloud.from_xml_element(elem) class CartesianIndependent(Spatial): @@ -582,7 +502,7 @@ class SphericalIndependent(Spatial): r = Univariate.from_xml_element(elem.find('r')) cos_theta = Univariate.from_xml_element(elem.find('cos_theta')) phi = Univariate.from_xml_element(elem.find('phi')) - origin = get_elem_list(elem, "origin", float) + origin = [float(x) for x in elem.get('origin').split()] return cls(r, cos_theta, phi, origin=origin) @@ -610,10 +530,6 @@ class CylindricalIndependent(Spatial): origin: Iterable of float, optional coordinates (x0, y0, z0) of the center of the cylindrical reference frame. Defaults to (0.0, 0.0, 0.0) - r_dir : Iterable of float, optional - Unit vector of the cylinder r axis at phi=0. - z_dir : Iterable of float, optional - Unit vector of the cylinder z axis direction. Attributes ---------- @@ -627,21 +543,14 @@ class CylindricalIndependent(Spatial): origin: Iterable of float, optional coordinates (x0, y0, z0) of the center of the cylindrical reference frame. Defaults to (0.0, 0.0, 0.0) - r_dir : Iterable of float, optional - Unit vector of the cylinder r axis at phi=0. - z_dir : Iterable of float, optional - Unit vector of the cylinder z axis direction. """ - def __init__(self, r, phi, z, origin=(0.0, 0.0, 0.0), r_dir=(1.0, 0.0, 0.0), - z_dir=(0.0, 0.0, 1.0)): + def __init__(self, r, phi, z, origin=(0.0, 0.0, 0.0)): self.r = r self.phi = phi self.z = z self.origin = origin - self.z_dir = z_dir - self.r_dir = r_dir @property def r(self): @@ -680,33 +589,6 @@ class CylindricalIndependent(Spatial): origin = np.asarray(origin) self._origin = origin - @property - def z_dir(self): - return self._z_dir - - @z_dir.setter - def z_dir(self, z_dir): - cv.check_type('z-axis direction', z_dir, Iterable, Real) - z_dir = np.array(z_dir) - norm = np.linalg.norm(z_dir) - cv.check_greater_than('z-axis direction magnitude', norm, 0.0) - z_dir /= norm - self._z_dir = z_dir - - @property - def r_dir(self): - return self._r_dir - - @r_dir.setter - def r_dir(self, r_dir): - cv.check_type('r-axis direction', r_dir, Iterable, Real) - r_dir = np.array(r_dir) - r_dir -= np.dot(r_dir, self.z_dir) * self.z_dir - norm = np.linalg.norm(r_dir) - cv.check_greater_than('r-axis direction magnitude', norm, 0.0) - r_dir /= norm - self._r_dir = r_dir - def to_xml_element(self): """Return XML representation of the spatial distribution @@ -721,12 +603,7 @@ class CylindricalIndependent(Spatial): element.append(self.r.to_xml_element('r')) element.append(self.phi.to_xml_element('phi')) element.append(self.z.to_xml_element('z')) - if not np.allclose(self.origin, [0., 0., 0.]): - element.set("origin", ' '.join(map(str, self.origin))) - if not np.allclose(self.r_dir, [1., 0., 0.]): - element.set("r_dir", ' '.join(map(str, self.r_dir))) - if not np.allclose(self.z_dir, [0., 0., 1.]): - element.set("z_dir", ' '.join(map(str, self.z_dir))) + element.set("origin", ' '.join(map(str, self.origin))) return element @classmethod @@ -747,10 +624,8 @@ class CylindricalIndependent(Spatial): r = Univariate.from_xml_element(elem.find('r')) phi = Univariate.from_xml_element(elem.find('phi')) z = Univariate.from_xml_element(elem.find('z')) - origin = get_elem_list(elem, "origin", float) or [0.0, 0.0, 0.0] - r_dir = get_elem_list(elem, "r_dir", float) or [1.0, 0.0, 0.0] - z_dir = get_elem_list(elem, "z_dir", float) or [0.0, 0.0, 1.0] - return cls(r, phi, z, origin=origin, r_dir=r_dir, z_dir=z_dir) + origin = [float(x) for x in elem.get('origin').split()] + return cls(r, phi, z, origin=origin) class MeshSpatial(Spatial): @@ -772,9 +647,6 @@ class MeshSpatial(Spatial): volume_normalized : bool, optional Whether or not the strengths will be multiplied by element volumes at runtime. Default is True. - bias : iterable of float, optional - An iterable of values giving the selection weights assigned to each - element during biased sampling. Attributes ---------- @@ -785,16 +657,12 @@ class MeshSpatial(Spatial): volume_normalized : bool Whether or not the strengths will be multiplied by element volumes at runtime. - bias : numpy.ndarray or None - Distribution for biased sampling """ - def __init__(self, mesh, strengths=None, volume_normalized=True, - bias: Sequence[float] | None = None): + def __init__(self, mesh, strengths=None, volume_normalized=True): self.mesh = mesh self.strengths = strengths self.volume_normalized = volume_normalized - self.bias = bias @property def mesh(self): @@ -827,23 +695,6 @@ class MeshSpatial(Spatial): else: self._strengths = None - @property - def bias(self): - return self._bias - - @bias.setter - def bias(self, given_bias): - if given_bias is not None: - cv.check_type('Biasing strengths array', given_bias, Iterable, Real) - bias_array = np.asarray(given_bias, dtype=float).flatten() - if bias_array.size != self.strengths.size: - raise ValueError( - 'Bias strengths array must have same size as strengths array.') - else: - self._bias = bias_array - else: - self._bias = None - @property def num_strength_bins(self): if self.strengths is None: @@ -869,9 +720,6 @@ class MeshSpatial(Spatial): subelement = ET.SubElement(element, 'strengths') subelement.text = ' '.join(str(e) for e in self.strengths) - if self.bias is not None: - Univariate._append_array_bias_to_xml(self, element) - return element @classmethod @@ -893,153 +741,19 @@ class MeshSpatial(Spatial): """ - mesh_id = int(get_text(elem, "mesh_id")) + mesh_id = int(elem.get('mesh_id')) # check if this mesh has been read in from another location already if mesh_id not in meshes: raise ValueError(f'Could not locate mesh with ID "{mesh_id}"') + volume_normalized = elem.get("volume_normalized") volume_normalized = get_text(elem, 'volume_normalized').lower() == 'true' - strengths = get_elem_list(elem, 'strengths', float) - bias_strengths = Univariate._read_array_bias_from_xml(elem) - return cls(meshes[mesh_id], strengths, volume_normalized, bias=bias_strengths) - - -class PointCloud(Spatial): - """Spatial distribution from a point cloud. - - This distribution specifies a discrete list of points, with corresponding - relative probabilities. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - positions : iterable of 3-tuples - The points in space to be sampled - strengths : iterable of float, optional - An iterable of values that represents the relative probabilty of each - point. - bias : iterable of float, optional - An iterable of values representing the relative probability of each - point under biased sampling. - - Attributes - ---------- - positions : numpy.ndarray - The points in space to be sampled with shape (N, 3) - strengths : numpy.ndarray or None - An array of relative probabilities for each mesh point - bias : numpy.ndarray or None - An array of relative probabilities for biased sampling of mesh points - """ - - def __init__( - self, - positions: Sequence[Sequence[float]], - strengths: Sequence[float] | None = None, - bias: Sequence[float] | None = None - ): - self.positions = positions - self.strengths = strengths - self.bias = bias - - @property - def positions(self) -> np.ndarray: - return self._positions - - @positions.setter - def positions(self, positions): - positions = np.array(positions, dtype=float) - if positions.ndim != 2: - raise ValueError('positions must be a 2D array') - elif positions.shape[1] != 3: - raise ValueError('Each position must have 3 values') - self._positions = positions - - @property - def strengths(self) -> np.ndarray: - return self._strengths - - @strengths.setter - def strengths(self, strengths): + strengths = get_text(elem, 'strengths') if strengths is not None: - strengths = np.array(strengths, dtype=float) - if strengths.ndim != 1: - raise ValueError('strengths must be a 1D array') - elif strengths.size != self.positions.shape[0]: - raise ValueError('strengths must have the same length as positions') - self._strengths = strengths + strengths = [float(b) for b in get_text(elem, 'strengths').split()] - @property - def bias(self): - return self._bias - - @bias.setter - def bias(self, given_bias): - if given_bias is not None: - cv.check_type('Biasing strengths array', given_bias, Iterable, Real) - bias_array = np.asarray(given_bias, dtype=float).flatten() - if bias_array.size != self.strengths.size: - raise ValueError( - 'Bias strengths array must have same size as strengths array.') - else: - self._bias = bias_array - else: - self._bias = None - - @property - def num_strength_bins(self) -> int: - if self.strengths is None: - raise ValueError('Strengths are not set') - return self.strengths.size - - def to_xml_element(self) -> ET.Element: - """Return XML representation of the spatial distribution - - Returns - ------- - element : lxml.etree._Element - XML element containing spatial distribution data - - """ - element = ET.Element('space') - element.set('type', 'cloud') - - subelement = ET.SubElement(element, 'coords') - subelement.text = ' '.join(str(e) for e in self.positions.flatten()) - - if self.strengths is not None: - subelement = ET.SubElement(element, 'strengths') - subelement.text = ' '.join(str(e) for e in self.strengths) - - if self.bias is not None: - Univariate._append_array_bias_to_xml(self, element) - - return element - - @classmethod - def from_xml_element(cls, elem: ET.Element) -> PointCloud: - """Generate spatial distribution from an XML element - - Parameters - ---------- - elem : lxml.etree._Element - XML element - - Returns - ------- - openmc.stats.PointCloud - Spatial distribution generated from XML element - - - """ - coord_data = get_elem_list(elem, 'coords', float) - positions = np.array(coord_data).reshape((-1, 3)) - - strengths = get_elem_list(elem, 'strengths', float) - bias_strengths = Univariate._read_array_bias_from_xml(elem) - return cls(positions, strengths, bias=bias_strengths) + return cls(meshes[mesh_id], strengths, volume_normalized) class Box(Spatial): @@ -1075,8 +789,8 @@ class Box(Spatial): def __init__( self, - lower_left: Sequence[float], - upper_right: Sequence[float], + lower_left: typing.Sequence[float], + upper_right: typing.Sequence[float], only_fissionable: bool = False ): self.lower_left = lower_left @@ -1151,7 +865,7 @@ class Box(Spatial): """ only_fissionable = get_text(elem, 'type') == 'fission' - params = get_elem_list(elem, "parameters", float) + params = [float(x) for x in get_text(elem, 'parameters').split()] lower_left = params[:len(params)//2] upper_right = params[len(params)//2:] return cls(lower_left, upper_right, only_fissionable) @@ -1175,7 +889,7 @@ class Point(Spatial): """ - def __init__(self, xyz: Sequence[float] = (0., 0., 0.)): + def __init__(self, xyz: typing.Sequence[float] = (0., 0., 0.)): self.xyz = xyz @property @@ -1218,16 +932,16 @@ class Point(Spatial): Point distribution generated from XML element """ - xyz = get_elem_list(elem, "parameters", float) + xyz = [float(x) for x in get_text(elem, 'parameters').split()] return cls(xyz) def spherical_uniform( r_outer: float, r_inner: float = 0.0, - thetas: Sequence[float] = (0., pi), - phis: Sequence[float] = (0., 2*pi), - origin: Sequence[float] = (0., 0., 0.) + thetas: typing.Sequence[float] = (0., pi), + phis: typing.Sequence[float] = (0., 2*pi), + origin: typing.Sequence[float] = (0., 0., 0.) ): """Return a uniform spatial distribution over a spherical shell. @@ -1264,49 +978,3 @@ def spherical_uniform( phis_dist = Uniform(phis[0], phis[1]) return SphericalIndependent(r_dist, cos_thetas_dist, phis_dist, origin) - - -def cylindrical_uniform( - r_outer: float, - height: float, - r_inner: float = 0.0, - phis: Sequence[float] = (0., 2*pi), - **kwargs, -): - """Return a uniform spatial distribution over a cylindrical shell. - - This function provides a uniform spatial distribution over a cylindrical - shell between `r_inner` and `r_outer`. When `height` is zero, a delta - function is used for the z-distribution, giving a uniform distribution over - a flat ring (annulus) at z=0 in the local coordinate frame. Optionally, the - range of angles can be restricted by the `phis` argument. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - r_outer : float - Outer radius of the cylindrical shell in [cm] - height : float - Height of the cylindrical shell in [cm]. When 0, the distribution is a - flat ring at z=0 in the local frame. - r_inner : float - Inner radius of the cylindrical shell in [cm] - phis : iterable of float - Starting and ending phi coordinates (azimuthal angle) in radians in a - reference frame centered at `origin`. - **kwargs - Keyword arguments passed directly to - :class:`~openmc.stats.CylindricalIndependent` (e.g., ``origin``, - ``r_dir``, ``z_dir``). - - Returns - ------- - openmc.stats.CylindricalIndependent - Uniform distribution over the cylindrical shell - """ - - r_dist = PowerLaw(r_inner, r_outer, 1) - phis_dist = Uniform(phis[0], phis[1]) - z_dist = delta_function(0.0) if height == 0.0 else Uniform(-height/2, height/2) - return CylindricalIndependent(r_dist, phis_dist, z_dist, **kwargs) diff --git a/openmc/stats/univariate.py b/openmc/stats/univariate.py index 1b18bcb17..4069c5a9e 100644 --- a/openmc/stats/univariate.py +++ b/openmc/stats/univariate.py @@ -1,23 +1,19 @@ from __future__ import annotations +import math +import typing from abc import ABC, abstractmethod from collections import defaultdict -from collections.abc import Iterable, Sequence -from functools import cache -from math import sqrt, pi, exp, log +from collections.abc import Iterable +from copy import deepcopy from numbers import Real -from pathlib import Path from warnings import warn import lxml.etree as ET import numpy as np from scipy.integrate import trapezoid -from scipy.special import exprel, hyp1f1, lambertw -import scipy import openmc.checkvalue as cv -from openmc.data import atomic_mass, NEUTRON_MASS -import openmc.data -from .._xml import get_elem_list, get_text +from .._xml import get_text from ..mixin import EqualityMixin _INTERPOLATION_SCHEMES = { @@ -29,71 +25,13 @@ _INTERPOLATION_SCHEMES = { } -def exprel2(x): - """Evaluate 2*(exp(x)-1-x)/x^2 without loss of precision near 0""" - return hyp1f1(1, 3, x) - - -def log1prel(x): - """Evaluate log(1+x)/x without loss of precision near 0""" - return np.where(np.abs(x) < 1e-16, 1.0, np.log1p(x) / x) - - class Univariate(EqualityMixin, ABC): """Probability distribution of a single random variable. The Univariate class is an abstract class that can be derived to implement a specific probability distribution. - Parameters - ---------- - bias : Iterable of float, optional - Distribution or discrete probabilities for biased sampling or discrete - probabilities for biased sampling. - """ - def __init__(self, bias: Univariate | Sequence[float] | None = None): - self.bias = bias - - @property - def bias(self): - return self._bias - - @bias.setter - def bias(self, bias): - check_bias_support(self, bias) - self._bias = bias - - def _append_bias_to_xml(self, element: ET.Element) -> None: - """Append bias distribution element to XML if present.""" - if self.bias is not None: - if self.bias.bias is not None: - raise RuntimeError('Biasing distributions should not have their own bias.') - bias_elem = self.bias.to_xml_element("bias") - element.append(bias_elem) - - @classmethod - def _read_bias_from_xml(cls, elem: ET.Element): - """Read bias distribution from XML element if present.""" - bias_elem = elem.find('bias') - if bias_elem is not None: - return Univariate.from_xml_element(bias_elem) - return None - - def _append_array_bias_to_xml(self, element: ET.Element) -> None: - """Append array-based bias probabilities to XML.""" - if self.bias is not None: - bias_elem = ET.SubElement(element, "bias") - bias_elem.text = ' '.join(map(str, self.bias)) - - @classmethod - def _read_array_bias_from_xml(cls, elem: ET.Element): - """Read array-based bias probabilities from XML.""" - bias_elem = elem.find('bias') - if bias_elem is not None: - return get_elem_list(elem, "bias", float) - return None - @abstractmethod def to_xml_element(self, element_name): return '' @@ -120,19 +58,18 @@ class Univariate(EqualityMixin, ABC): return Normal.from_xml_element(elem) elif distribution == 'muir': # Support older files where Muir had its own class - return muir(*get_elem_list(elem, "parameters", float)) + params = [float(x) for x in get_text(elem, 'parameters').split()] + return muir(*params) elif distribution == 'tabular': return Tabular.from_xml_element(elem) elif distribution == 'legendre': return Legendre.from_xml_element(elem) elif distribution == 'mixture': return Mixture.from_xml_element(elem) - elif distribution == 'decay_spectrum': - return DecaySpectrum.from_xml_element(elem) @abstractmethod - def _sample_unbiased(self, n_samples: int = 1, seed: int | None = None): - """Sample without bias handling. + def sample(n_samples: int = 1, seed: typing.Optional[int] = None): + """Sample the univariate distribution Parameters ---------- @@ -144,35 +81,10 @@ class Univariate(EqualityMixin, ABC): Returns ------- numpy.ndarray - The array of sampled values + A 1-D array of sampled values """ pass - def sample(self, n_samples: int = 1, seed: int | None = None): - """Sample the univariate distribution, handling biasing automatically. - - Parameters - ---------- - n_samples : int - Number of sampled values to generate - seed : int or None - Initial random number seed. - - Returns - ------- - tuple of numpy.ndarray - A tuple of (samples, weights) - """ - if self.bias is None: - x = self._sample_unbiased(n_samples, seed) - return x, np.ones_like(x) - else: - if self.bias.bias is not None: - raise RuntimeError('Biasing distributions should not have their own bias.') - x, _ = self.bias.sample(n_samples=n_samples, seed=seed) - weight = self.evaluate(x) / self.bias.evaluate(x) - return x, weight - def integral(self): """Return integral of distribution @@ -185,75 +97,6 @@ class Univariate(EqualityMixin, ABC): """ return 1.0 - @abstractmethod - def evaluate(self, x: float | Sequence[float]): - """Evaluate the probability density at the provided value. - - Parameters - ---------- - x : float or sequence of float - Location to evaluate p(x) - - Returns - ------- - float or numpy.ndarray - Value of p(x) - """ - pass - - @property - @abstractmethod - def support(self): - """Return the support of the probability distribution. - - Returns - ------- - set or tuple of float or dict - Returns the set of unique points assigned probability mass in a - discrete distribution, the sampling interval for a continuous - distribution, or a dictionary storing the discrete and continuous - parts of the support of a mixed random variable - """ - pass - -def _intensity_clip(intensity: Sequence[float], tolerance: float = 1e-6) -> np.ndarray: - """Clip low-importance points from an array of intensities. - - Given an array of intensities, this function returns an array of indices for - points that contribute non-negligibly to the total sum of intensities. - - Parameters - ---------- - intensity : sequence of float - Intensities in arbitrary units. - tolerance : float - Maximum fraction of intensities that will be discarded. - - Returns - ------- - Array of indices - - """ - # Get indices of intensities from largest to smallest - index_sort = np.argsort(intensity)[::-1] - - # Get intensities from largest to smallest - sorted_intensity = np.asarray(intensity)[index_sort] - - # Determine cumulative sum of probabilities - cumsum = np.cumsum(sorted_intensity) - cumsum /= cumsum[-1] - - # Find index that satisfies cutoff - index_cutoff = np.searchsorted(cumsum, 1.0 - tolerance) - - # Now get indices up to cutoff - new_indices = index_sort[:index_cutoff + 1] - - # Put back in the order of the original array and return - new_indices.sort() - return new_indices - class Discrete(Univariate): """Distribution characterized by a probability mass function. @@ -268,9 +111,6 @@ class Discrete(Univariate): Values of the random variable p : Iterable of float Discrete probability for each value - bias : Iterable of float, optional - Alternative discrete probabilities for biased sampling. Defaults to - None for unbiased sampling. Attributes ---------- @@ -278,18 +118,12 @@ class Discrete(Univariate): Values of the random variable p : numpy.ndarray Discrete probability for each value - support : set - Values of the random variable over which the distribution is - nonzero-valued - bias : numpy.ndarray or None - Discrete probabilities for biased sampling """ - def __init__(self, x, p, bias=None): + def __init__(self, x, p): self.x = x self.p = p - super().__init__(bias) def __len__(self): return len(self.x) @@ -318,42 +152,10 @@ class Discrete(Univariate): cv.check_greater_than('discrete probability', pk, 0.0, True) self._p = np.array(p, dtype=float) - @property - def support(self): - return set(np.unique(self._x)) - - @Univariate.bias.setter - def bias(self, bias): - if bias is None: - self._bias = bias - else: - if isinstance(bias, Real): - bias = [bias] - cv.check_type('discrete bias probabilities', bias, Iterable, Real) - for bk in bias: - cv.check_greater_than('discrete probability', bk, 0.0, True) - if len(bias) != len(self.x): - raise RuntimeError("Discrete distribution has unequal number of " - "biased and unbiased probability entries.") - self._bias = np.array(bias, dtype=float) - def cdf(self): return np.insert(np.cumsum(self.p), 0, 0.0) def sample(self, n_samples=1, seed=None): - if self.bias is None: - samples = self._sample_unbiased(n_samples, seed) - return samples, np.ones_like(samples) - else: - rng = np.random.RandomState(seed) - p = self.p / self.p.sum() - b = self.bias / self.bias.sum() - indices = rng.choice(self.x.size, n_samples, p=b) - biased_sample = self.x[indices] - wgt = p[indices] / b[indices] - return biased_sample, wgt - - def _sample_unbiased(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) p = self.p / self.p.sum() return rng.choice(self.x, n_samples, p=p) @@ -363,9 +165,6 @@ class Discrete(Univariate): norm = sum(self.p) self.p = [val / norm for val in self.p] - def evaluate(self, x): - raise NotImplementedError - def to_xml_element(self, element_name): """Return XML representation of the discrete distribution @@ -385,7 +184,7 @@ class Discrete(Univariate): params = ET.SubElement(element, "parameters") params.text = ' '.join(map(str, self.x)) + ' ' + ' '.join(map(str, self.p)) - self._append_array_bias_to_xml(element) + return element @classmethod @@ -403,17 +202,16 @@ class Discrete(Univariate): Discrete distribution generated from XML element """ - params = get_elem_list(elem, "parameters", float) + params = [float(x) for x in get_text(elem, 'parameters').split()] x = params[:len(params)//2] p = params[len(params)//2:] - bias_dist = cls._read_array_bias_from_xml(elem) - return cls(x, p, bias=bias_dist) + return cls(x, p) @classmethod def merge( cls, - dists: Sequence[Discrete], - probs: Sequence[float] + dists: typing.Sequence[Discrete], + probs: typing.Sequence[int] ): """Merge multiple discrete distributions into a single distribution @@ -435,52 +233,18 @@ class Discrete(Univariate): if len(dists) != len(probs): raise ValueError("Number of distributions and probabilities must match.") - biasing = False - for d in dists: - if d.bias is not None: - # If we find that at least one distribution is biased, all - # distributions which are not biased will be assigned their - # default probability vector as a "bias" so that biased - # sampling can occur on the merged distribution. - biasing = True - break - # Combine distributions accounting for duplicate x values x_merged = set() p_merged = defaultdict(float) - new_bias = None + for dist, p_dist in zip(dists, probs): + for x, p in zip(dist.x, dist.p): + x_merged.add(x) + p_merged[x] += p*p_dist - if biasing: - b_merged = defaultdict(float) - - # Generate any missing bias distributions - dists = dists.copy() - for i, d in enumerate(dists): - if d.bias is None: - dists[i] = Discrete(d.x, d.p, bias=d.p) - - for dist, p_dist in zip(dists, probs): - for x, p, b in zip(dist.x, dist.p, dist.bias): - x_merged.add(x) - p_merged[x] += p*p_dist - b_merged[x] += b*p_dist - - # Create values and bias probabilities as arrays - x_arr = np.array(sorted(x_merged)) - new_bias = np.array([b_merged[x] for x in x_arr]) - - else: - for dist, p_dist in zip(dists, probs): - for x, p in zip(dist.x, dist.p): - x_merged.add(x) - p_merged[x] += p*p_dist - - # Create values as array - x_arr = np.array(sorted(x_merged)) - - # Create probabilities as array + # Create values and probabilities as arrays + x_arr = np.array(sorted(x_merged)) p_arr = np.array([p_merged[x] for x in x_arr]) - return cls(x_arr, p_arr, new_bias) + return cls(x_arr, p_arr) def integral(self): """Return integral of distribution @@ -494,20 +258,6 @@ class Discrete(Univariate): """ return np.sum(self.p) - def mean(self) -> float: - """Return mean of the discrete distribution - - The mean is the weighted average of the discrete values. - - .. versionadded:: 0.15.3 - - Returns - ------- - float - Mean of discrete distribution - """ - return np.sum(self.x * self.p) / np.sum(self.p) - def clip(self, tolerance: float = 1e-6, inplace: bool = False) -> Discrete: r"""Remove low-importance points from discrete distribution. @@ -517,9 +267,6 @@ class Discrete(Univariate): function will remove any low-importance points such that :math:`\sum_i x_i p_i` is preserved to within some threshold. - For biased distributions, clipping should be performed before the bias - probabilities are added. - .. versionadded:: 0.14.0 Parameters @@ -534,51 +281,38 @@ class Discrete(Univariate): Discrete distribution with low-importance points removed """ - if self.bias is not None: - raise RuntimeError("Biased discrete distributions should be clipped " - "before applying bias.") - cv.check_less_than("tolerance", tolerance, 1.0, equality=True) cv.check_greater_than("tolerance", tolerance, 0.0, equality=True) - # Compute intensities + # Determine (reversed) sorted order of probabilities intensity = self.p * self.x + index_sort = np.argsort(intensity)[::-1] - # Get indices for intensities above threshold - indices = _intensity_clip(intensity, tolerance=tolerance) + # Get probabilities in above order + sorted_intensity = intensity[index_sort] + + # Determine cumulative sum of probabilities + cumsum = np.cumsum(sorted_intensity) + cumsum /= cumsum[-1] + + # Find index which satisfies cutoff + index_cutoff = np.searchsorted(cumsum, 1.0 - tolerance) + + # Now get indices up to cutoff + new_indices = index_sort[:index_cutoff + 1] + new_indices.sort() # Create new discrete distribution if inplace: - self.x = self.x[indices] - self.p = self.p[indices] + self.x = self.x[new_indices] + self.p = self.p[new_indices] return self else: - new_x = self.x[indices] - new_p = self.p[indices] + new_x = self.x[new_indices] + new_p = self.p[new_indices] return type(self)(new_x, new_p) -def delta_function(value: float, intensity: float = 1.0) -> Discrete: - """Return a discrete distribution with a single point. - - .. versionadded:: 0.15.1 - - Parameters - ---------- - value : float - Value of the random variable. - intensity : float, optional - When used for an energy distribution, this can be used to assign an - intensity. - - Returns - ------- - Discrete distribution with a single point - - """ - return Discrete([value], [intensity]) - - class Uniform(Univariate): """Distribution with constant probability over a finite interval [a,b] @@ -588,8 +322,6 @@ class Uniform(Univariate): Lower bound of the sampling interval. Defaults to zero. b : float, optional Upper bound of the sampling interval. Defaults to unity. - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Attributes ---------- @@ -597,19 +329,12 @@ class Uniform(Univariate): Lower bound of the sampling interval b : float Upper bound of the sampling interval - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling """ - def __init__(self, a: float = 0.0, b: float = 1.0, - bias: Univariate | None = None): + def __init__(self, a: float = 0.0, b: float = 1.0): self.a = a self.b = b - super().__init__(bias) def __len__(self): return 2 @@ -632,37 +357,16 @@ class Uniform(Univariate): cv.check_type('Uniform b', b, Real) self._b = b - @property - def support(self): - return (self._a, self._b) - def to_tabular(self): - if self.bias is not None: - raise RuntimeError("to_tabular() is not permitted for biased distributions.") prob = 1./(self.b - self.a) t = Tabular([self.a, self.b], [prob, prob], 'histogram') t.c = [0., 1.] return t - def _sample_unbiased(self, n_samples=1, seed=None): + def sample(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) return rng.uniform(self.a, self.b, n_samples) - def evaluate(self, x): - return np.where((self.a <= x) & (x <= self.b), 1/(self.b - self.a), 0.0) - - def mean(self) -> float: - """Return mean of the uniform distribution - - .. versionadded:: 0.15.3 - - Returns - ------- - float - Mean of uniform distribution - """ - return 0.5 * (self.a + self.b) - def to_xml_element(self, element_name: str): """Return XML representation of the uniform distribution @@ -680,7 +384,6 @@ class Uniform(Univariate): element = ET.Element(element_name) element.set("type", "uniform") element.set("parameters", f'{self.a} {self.b}') - self._append_bias_to_xml(element) return element @classmethod @@ -698,9 +401,8 @@ class Uniform(Univariate): Uniform distribution generated from XML element """ - params = get_elem_list(elem, "parameters", float) - bias_dist = cls._read_bias_from_xml(elem) - return cls(*params, bias=bias_dist) + params = get_text(elem, 'parameters').split() + return cls(*map(float, params)) class PowerLaw(Univariate): @@ -719,8 +421,6 @@ class PowerLaw(Univariate): n : float, optional Power law exponent. Defaults to zero, which is equivalent to a uniform distribution. - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Attributes ---------- @@ -730,23 +430,13 @@ class PowerLaw(Univariate): Upper bound of the sampling interval n : float Power law exponent - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling """ - def __init__(self, a: float = 0.0, b: float = 1.0, n: float = 0., - bias: Univariate | None = None): - if a >= b: - raise ValueError( - "Lower bound of sampling interval must be less than upper bound.") + def __init__(self, a: float = 0.0, b: float = 1.0, n: float = 0.): self.a = a self.b = b self.n = n - super().__init__(bias) def __len__(self): return 3 @@ -758,9 +448,6 @@ class PowerLaw(Univariate): @a.setter def a(self, a): cv.check_type('interval lower bound', a, Real) - if a < 0: - raise ValueError( - "PowerLaw sampling is restricted to positive-valued intervals.") self._a = a @property @@ -770,9 +457,6 @@ class PowerLaw(Univariate): @b.setter def b(self, b): cv.check_type('interval upper bound', b, Real) - if b < 0: - raise ValueError( - "PowerLaw sampling is restricted to positive-valued intervals.") self._b = b @property @@ -784,11 +468,7 @@ class PowerLaw(Univariate): cv.check_type('power law exponent', n, Real) self._n = n - @property - def support(self): - return (self._a, self._b) - - def _sample_unbiased(self, n_samples=1, seed=None): + def sample(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) xi = rng.random(n_samples) pwr = self.n + 1 @@ -796,10 +476,6 @@ class PowerLaw(Univariate): span = self.b**pwr - offset return np.power(offset + xi * span, 1/pwr) - def evaluate(self, x): - c = (self.n + 1)/(self.b**(self.n + 1) - self.a**(self.n + 1)) - return np.where((self.a <= x) & (x <= self.b), c * np.abs(x)**self.n, 0.0) - def to_xml_element(self, element_name: str): """Return XML representation of the power law distribution @@ -817,7 +493,6 @@ class PowerLaw(Univariate): element = ET.Element(element_name) element.set("type", "powerlaw") element.set("parameters", f'{self.a} {self.b} {self.n}') - self._append_bias_to_xml(element) return element @classmethod @@ -835,9 +510,8 @@ class PowerLaw(Univariate): Distribution generated from XML element """ - params = get_elem_list(elem, "parameters", float) - bias_dist = cls._read_bias_from_xml(elem) - return cls(*map(float, params), bias=bias_dist) + params = get_text(elem, 'parameters').split() + return cls(*map(float, params)) class Maxwell(Univariate): @@ -851,24 +525,16 @@ class Maxwell(Univariate): ---------- theta : float Effective temperature for distribution in eV - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Attributes ---------- theta : float Effective temperature for distribution in eV - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling """ - def __init__(self, theta, bias: Univariate | None = None): + def __init__(self, theta): self.theta = theta - super().__init__(bias) def __len__(self): return 1 @@ -883,11 +549,7 @@ class Maxwell(Univariate): cv.check_greater_than('Maxwell temperature', theta, 0.0) self._theta = theta - @property - def support(self): - return (0.0, np.inf) - - def _sample_unbiased(self, n_samples=1, seed=None): + def sample(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) return self.sample_maxwell(self.theta, n_samples, rng=rng) @@ -895,10 +557,9 @@ class Maxwell(Univariate): def sample_maxwell(t, n_samples: int, rng=None): if rng is None: rng = np.random.default_rng() - return rng.gamma(1.5, t, n_samples) - - def evaluate(self, E): - return scipy.stats.gamma.pdf(E, 1.5, scale=self.theta) + r1, r2, r3 = rng.random((3, n_samples)) + c = np.cos(0.5 * np.pi * r3) + return -t * (np.log(r1) + np.log(r2) * c * c) def to_xml_element(self, element_name: str): """Return XML representation of the Maxwellian distribution @@ -917,7 +578,6 @@ class Maxwell(Univariate): element = ET.Element(element_name) element.set("type", "maxwell") element.set("parameters", str(self.theta)) - self._append_bias_to_xml(element) return element @classmethod @@ -936,8 +596,7 @@ class Maxwell(Univariate): """ theta = float(get_text(elem, 'parameters')) - bias_dist = cls._read_bias_from_xml(elem) - return cls(theta, bias=bias_dist) + return cls(theta) class Watt(Univariate): @@ -953,8 +612,6 @@ class Watt(Univariate): First parameter of distribution in units of eV b : float Second parameter of distribution in units of 1/eV - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Attributes ---------- @@ -962,18 +619,12 @@ class Watt(Univariate): First parameter of distribution in units of eV b : float Second parameter of distribution in units of 1/eV - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling """ - def __init__(self, a=0.988e6, b=2.249e-6, bias: Univariate | None = None): + def __init__(self, a=0.988e6, b=2.249e-6): self.a = a self.b = b - super().__init__(bias) def __len__(self): return 2 @@ -998,21 +649,13 @@ class Watt(Univariate): cv.check_greater_than('Watt b', b, 0.0) self._b = b - @property - def support(self): - return (0.0, np.inf) - - def _sample_unbiased(self, n_samples=1, seed=None): + def sample(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) w = Maxwell.sample_maxwell(self.a, n_samples, rng=rng) u = rng.uniform(-1., 1., n_samples) aab = self.a * self.a * self.b return w + 0.25*aab + u*np.sqrt(aab*w) - def evaluate(self, E): - c = 2.0/(sqrt(pi * self.b) * (self.a**1.5) * exp(self.a*self.b/4)) - return c*np.exp(-E/self.a)*np.sinh(np.sqrt(self.b*E)) - def to_xml_element(self, element_name: str): """Return XML representation of the Watt distribution @@ -1030,7 +673,6 @@ class Watt(Univariate): element = ET.Element(element_name) element.set("type", "watt") element.set("parameters", f'{self.a} {self.b}') - self._append_bias_to_xml(element) return element @classmethod @@ -1048,35 +690,23 @@ class Watt(Univariate): Watt distribution generated from XML element """ - params = get_elem_list(elem, "parameters", float) - bias_dist = cls._read_bias_from_xml(elem) - return cls(*map(float, params), bias=bias_dist) + params = get_text(elem, 'parameters').split() + return cls(*map(float, params)) class Normal(Univariate): - r"""Normally distributed sampling with optional truncation. + r"""Normally distributed sampling. - The normal distribution is characterized by parameters :math:`\mu` and - :math:`\sigma` and has density function :math:`p(X) = 1/(\sqrt{2\pi}\sigma) - e^{-(X-\mu)^2/(2\sigma^2)}`. When truncated to the interval [lower, upper], - the distribution is renormalized so that the PDF integrates to 1 over the - truncation interval. - - .. versionchanged:: 0.15.4 - Added optional truncation bounds via `lower` and `upper` parameters. + The Normal Distribution is characterized by two parameters + :math:`\mu` and :math:`\sigma` and has density function + :math:`p(X) dX = 1/(\sqrt{2\pi}\sigma) e^{-(X-\mu)^2/(2\sigma^2)}` Parameters ---------- mean_value : float - Mean value of the distribution + Mean value of the distribution std_dev : float Standard deviation of the Normal distribution - lower : float, optional - Lower truncation bound. Defaults to -infinity (no lower bound). - upper : float, optional - Upper truncation bound. Defaults to +infinity (no upper bound). - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Attributes ---------- @@ -1084,29 +714,13 @@ class Normal(Univariate): Mean of the Normal distribution std_dev : float Standard deviation of the Normal distribution - lower : float - Lower truncation bound - upper : float - Upper truncation bound - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling """ - def __init__(self, mean_value, std_dev, lower=-np.inf, upper=np.inf, - bias: Univariate | None = None): + def __init__(self, mean_value, std_dev): self.mean_value = mean_value self.std_dev = std_dev - self.lower = lower - self.upper = upper - self._compute_normalization() - super().__init__(bias) def __len__(self): - if self._is_truncated: - return 4 return 2 @property @@ -1128,69 +742,9 @@ class Normal(Univariate): cv.check_greater_than('Normal std_dev', std_dev, 0.0) self._std_dev = std_dev - @property - def lower(self): - return self._lower - - @lower.setter - def lower(self, lower): - cv.check_type('Normal lower bound', lower, Real) - self._lower = lower - - @property - def upper(self): - return self._upper - - @upper.setter - def upper(self, upper): - cv.check_type('Normal upper bound', upper, Real) - self._upper = upper - - def _compute_normalization(self): - """Compute normalization factor for truncated distribution.""" - # Check if truncation bounds are finite - self._is_truncated = (self._lower > -np.inf or self._upper < np.inf) - - if self._lower >= self._upper: - raise ValueError("Normal distribution lower bound must be less " - "than upper bound.") - - if self._is_truncated: - alpha = (self._lower - self._mean_value) / self._std_dev - beta = (self._upper - self._mean_value) / self._std_dev - cdf_diff = scipy.stats.norm.cdf(beta) - scipy.stats.norm.cdf(alpha) - if cdf_diff <= 0: - raise ValueError("Truncation bounds exclude entire distribution") - self._norm_factor = 1.0 / cdf_diff - else: - self._norm_factor = 1.0 - - @property - def support(self): - return (self._lower, self._upper) - - def _sample_unbiased(self, n_samples=1, seed=None): + def sample(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) - if not self._is_truncated: - return rng.normal(self.mean_value, self.std_dev, n_samples) - else: - # Use scipy's truncated normal for efficient direct sampling - a = (self._lower - self._mean_value) / self._std_dev - b = (self._upper - self._mean_value) / self._std_dev - return scipy.stats.truncnorm.rvs( - a, b, loc=self._mean_value, scale=self._std_dev, - size=n_samples, random_state=rng - ) - - def evaluate(self, x): - """Evaluate PDF at x, returning normalized value for truncated dist.""" - x = np.asarray(x) - f = scipy.stats.norm.pdf(x, self.mean_value, self.std_dev) - if self._is_truncated: - # PDF is zero outside bounds - in_bounds = (x >= self._lower) & (x <= self._upper) - f = np.where(in_bounds, f * self._norm_factor, 0.0) - return f + return rng.normal(self.mean_value, self.std_dev, n_samples) def to_xml_element(self, element_name: str): """Return XML representation of the Normal distribution @@ -1203,17 +757,12 @@ class Normal(Univariate): Returns ------- element : lxml.etree._Element - XML element containing Normal distribution data + XML element containing Watt distribution data """ element = ET.Element(element_name) element.set("type", "normal") - if self._is_truncated: - element.set("parameters", - f'{self.mean_value} {self.std_dev} {self.lower} {self.upper}') - else: - element.set("parameters", f'{self.mean_value} {self.std_dev}') - self._append_bias_to_xml(element) + element.set("parameters", f'{self.mean_value} {self.std_dev}') return element @classmethod @@ -1231,15 +780,11 @@ class Normal(Univariate): Normal distribution generated from XML element """ - params = get_elem_list(elem, "parameters", float) - bias_dist = cls._read_bias_from_xml(elem) - if len(params) == 4: - return cls(params[0], params[1], params[2], params[3], bias=bias_dist) - else: - return cls(params[0], params[1], bias=bias_dist) + params = get_text(elem, 'parameters').split() + return cls(*map(float, params)) -def muir(e0: float, m_rat: float, kt: float, bias: Univariate | None = None): +def muir(e0: float, m_rat: float, kt: float): """Generate a Muir energy spectrum The Muir energy spectrum is a normal distribution, but for convenience @@ -1257,8 +802,6 @@ def muir(e0: float, m_rat: float, kt: float, bias: Univariate | None = None): Ratio of the sum of the masses of the reaction inputs to 1 amu kt : float Ion temperature for the Muir distribution in [eV] - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Returns ------- @@ -1267,8 +810,8 @@ def muir(e0: float, m_rat: float, kt: float, bias: Univariate | None = None): """ # https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-05411-MS - std_dev = sqrt(2 * e0 * kt / m_rat) - return Normal(e0, std_dev, bias=bias) + std_dev = math.sqrt(2 * e0 * kt / m_rat) + return Normal(e0, std_dev) # Retain deprecated name for the time being @@ -1282,138 +825,6 @@ def Muir(*args, **kwargs): return muir(*args, **kwargs) -def fusion_neutron_spectrum( - ion_temp: float, - reactants: str = 'DD', - bias: Univariate | None = None -) -> Normal: - r"""Return a Gaussian energy distribution for fusion neutron emission. - - Computes the mean energy and spectral width of the neutron energy spectrum - from thermonuclear fusion reactions in a plasma with Maxwellian ion velocity - distributions. The mean neutron energy is calculated as - - .. math:: - - \langle E_n \rangle = E_0 + \Delta E_\text{th} - - where :math:`E_0` is the neutron energy at zero ion temperature and - :math:`\Delta E_\text{th}` is the thermal peak shift due to the motion of - the reacting ions. The spectral width is characterized by the FWHM: - - .. math:: - - W_{1/2} = \omega_0 (1 + \delta_\omega) \sqrt{T_i} - - where :math:`\omega_0` is the width at the :math:`T_i \to 0` limit and - :math:`\delta_\omega` is a temperature-dependent correction term. Both - :math:`\Delta E_\text{th}` and :math:`\delta_\omega` are evaluated using - interpolation formulas from `Ballabio et al. - `_: Table III for :math:`0 < - T_i \le 40` keV and Table IV for :math:`40 < T_i < 100` keV. The returned - distribution is a normal (Gaussian) approximation to the spectrum. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - ion_temp : float - Ion temperature of the plasma in [eV]. - reactants : {'DD', 'DT'} - Fusion reactants. 'DD' corresponds to the D(d,n)\ :sup:`3`\ He reaction - and 'DT' to the T(d,n)\ :math:`\alpha` reaction. - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. - - Returns - ------- - openmc.stats.Normal - Normal distribution with mean and standard deviation corresponding to - the first and second moments of the fusion neutron energy spectrum. Both - the mean and standard deviation are in [eV]. - - """ - if ion_temp < 0.0 or ion_temp > 100e3: - raise ValueError("Ion temperature must be between 0 and 100 keV.") - - # Formulas from doi:10.1088/0029-5515/38/11/310 - mn = NEUTRON_MASS - md = atomic_mass('H2') - ev_per_c2 = 931.49410372*1e6 - if reactants == 'DD': - mhe3 = atomic_mass('He3') - Q = (md + md - mhe3 - mn)*ev_per_c2 - E_n = mhe3/(mhe3 + mn)*Q - w0 = 82.542 - - # Low-T constants for peak shift (Table III) - a1 = 4.69515 - a2 = -0.040729 - a3 = 0.47 - a4 = 0.81844 - - # Low-T constants for width correction (Table III) - b1 = 1.7013e-3 - b2 = 0.16888 - b3 = 0.49 - b4 = 7.9460e-4 - - # High-T constants for peak shift (Table IV) - a5 = 18.225 - a6 = 2.1525 - - # High-T constants for width correction (Table IV) - b5 = 8.4619e-3 - b6 = 8.3241e-4 - - elif reactants == 'DT': - mt = atomic_mass('H3') - ma = atomic_mass('He4') - Q = (md + mt - ma - mn)*ev_per_c2 - E_n = ma/(ma + mn)*Q - w0 = 177.259 - - # Low-T constants for peak shift (Table III) - a1 = 5.30509 - a2 = 2.4736e-3 - a3 = 1.84 - a4 = 1.3818 - - # Low-T constants for width correction (Table III) - b1 = 5.1068e-4 - b2 = 7.6223e-3 - b3 = 1.78 - b4 = 8.7691e-5 - - # High-T constants for peak shift (Table IV) - a5 = 37.771 - a6 = 0.92181 - - # High-T constants for width correction (Table IV) - b5 = 2.0199e-3 - b6 = 5.9501e-5 - else: - raise ValueError("Invalid reactants specified. Must be 'DD' or 'DT'.") - - # Ion temperature in keV - T = ion_temp * 1e-3 - - if T <= 40.0: - # Low-temperature interpolation (Table III, 0 < T_i <= 40 keV) - Delta_E = a1/(1 + a2*T**a3)*T**(2/3) + a4*T - delta_w = b1/(1 + b2*T**b3)*T**(2/3) + b4*T - else: - # High-temperature interpolation (Table IV, 40 < T_i < 100 keV) - Delta_E = a5 + a6*T - delta_w = b5 + b6*T - - # Calculate FWHM - fwhm = (w0*(1 + delta_w) * sqrt(T))*1e3 - - sigma = fwhm / (2*sqrt(2*log(2))) - return Normal(E_n + Delta_E * 1e3, sigma, bias=bias) - - class Tabular(Univariate): """Piecewise continuous probability distribution. @@ -1427,15 +838,12 @@ class Tabular(Univariate): Tabulated values of the random variable p : Iterable of float Tabulated probabilities. For histogram interpolation, if the length of - `p` is the same as `x`, the last value is ignored. Probabilities `p` are - given per unit of `x`. + `p` is the same as `x`, the last value is ignored. interpolation : {'histogram', 'linear-linear', 'linear-log', 'log-linear', 'log-log'}, optional Indicates how the density function is interpolated between tabulated points. Defaults to 'linear-linear'. ignore_negative : bool Ignore negative probabilities - bias : openmc.stats.Univariate, optional - Distribution for biased sampling. Attributes ---------- @@ -1446,30 +854,15 @@ class Tabular(Univariate): interpolation : {'histogram', 'linear-linear', 'linear-log', 'log-linear', 'log-log'} Indicates how the density function is interpolated between tabulated points. Defaults to 'linear-linear'. - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling - - Notes - ----- - The probabilities `p` are interpreted per unit of the corresponding - independent variable `x`. This follows the definition of a probability - density function (PDF) in probability theory, where the PDF represents the - relative likelihood of the random variable taking on a particular value per - unit of the variable. For example, if `x` represents energy in eV, then `p` - should represent probabilities per eV. """ def __init__( self, - x: Sequence[float], - p: Sequence[float], + x: typing.Sequence[float], + p: typing.Sequence[float], interpolation: str = 'linear-linear', - ignore_negative: bool = False, - bias: Univariate | None = None + ignore_negative: bool = False ): self.interpolation = interpolation @@ -1491,7 +884,6 @@ class Tabular(Univariate): self._x = x self._p = p - super().__init__(bias) def __len__(self): return self.p.size @@ -1513,10 +905,6 @@ class Tabular(Univariate): cv.check_value('interpolation', interpolation, _INTERPOLATION_SCHEMES) self._interpolation = interpolation - @property - def support(self): - return (self._x[0], self._x[-1]) - def cdf(self): c = np.zeros_like(self.x) x = self.x @@ -1526,71 +914,51 @@ class Tabular(Univariate): c[1:] = p[:x.size-1] * np.diff(x) elif self.interpolation == 'linear-linear': c[1:] = 0.5 * (p[:-1] + p[1:]) * np.diff(x) - elif self.interpolation == "linear-log": - m = np.diff(p) / np.diff(np.log(x)) - c[1:] = p[:-1] * np.diff(x) + m * ( - x[1:] * (np.diff(np.log(x)) - 1.0) + x[:-1] - ) - elif self.interpolation == "log-linear": - m = np.diff(np.log(p)) / np.diff(x) - c[1:] = p[:-1] * np.diff(x) * exprel(m * np.diff(x)) - elif self.interpolation == "log-log": - m = np.diff(np.log(x * p)) / np.diff(np.log(x)) - c[1:] = (x * p)[:-1] * np.diff(np.log(x)) * exprel(m * np.diff(np.log(x))) else: - raise NotImplementedError( - f"Cannot generate CDFs for tabular " - f"distributions using {self.interpolation} interpolation" - ) + raise NotImplementedError('Can only generate CDFs for tabular ' + 'distributions using histogram or ' + 'linear-linear interpolation') + return np.cumsum(c) def mean(self): """Compute the mean of the tabular distribution""" + if self.interpolation == 'linear-linear': + mean = 0.0 + for i in range(1, len(self.x)): + y_min = self.p[i-1] + y_max = self.p[i] + x_min = self.x[i-1] + x_max = self.x[i] - # use normalized probabilities when computing mean - p = self.p / self.cdf().max() - x = self.x - x_min = x[:-1] - x_max = x[1:] - p_min = p[: x.size - 1] + m = (y_max - y_min) / (x_max - x_min) - if self.interpolation == "linear-linear": - m = np.diff(p) / np.diff(x) - mean = ((1.0 / 3.0) * m * np.diff(x**3) - + 0.5 * (p_min - m * x_min) * np.diff(x**2)).sum() - elif self.interpolation == "linear-log": - m = np.diff(p) / np.diff(np.log(x)) - mean = ( - (1.0 / 4.0) * m * x_min**2 - * ((x_max / x_min)**2 * (2 * np.diff(np.log(x)) - 1) + 1) - + 0.5 * p_min * np.diff(x**2) - ).sum() - elif self.interpolation == "log-linear": - m = np.diff(np.log(p)) / np.diff(x) - mean = (p_min * ( - np.diff(x) ** 2 - * ((0.5 * exprel2(m * np.diff(x)) * (m * np.diff(x) - 1) + 1)) - + np.diff(x) * x_min * exprel(m * np.diff(x))) - ).sum() - elif self.interpolation == "log-log": - m = np.diff(np.log(p)) / np.diff(np.log(x)) - mean = (p_min * x_min**2 * np.diff(np.log(x)) - * exprel((m + 2) * np.diff(np.log(x)))).sum() - elif self.interpolation == "histogram": - mean = (0.5 * (x_min + x_max) * np.diff(x) * p_min).sum() + exp_val = (1./3.) * m * (x_max**3 - x_min**3) + exp_val += 0.5 * m * x_min * (x_min**2 - x_max**2) + exp_val += 0.5 * y_min * (x_max**2 - x_min**2) + mean += exp_val + + elif self.interpolation == 'histogram': + x_l = self.x[:-1] + x_r = self.x[1:] + p_l = self.p[:self.x.size-1] + mean = (0.5 * (x_l + x_r) * (x_r - x_l) * p_l).sum() else: - raise NotImplementedError( - f"Cannot compute mean for tabular " - f"distributions using {self.interpolation} interpolation" - ) + raise NotImplementedError('Can only compute mean for tabular ' + 'distributions using histogram ' + 'or linear-linear interpolation.') + + # Normalize for when integral of distribution is not 1 + mean /= self.integral() + return mean def normalize(self): """Normalize the probabilities stored on the distribution""" self._p /= self.cdf().max() - def _sample_unbiased(self, n_samples: int = 1, seed: int | None = None): + def sample(self, n_samples: int = 1, seed: typing.Optional[int] = None): rng = np.random.RandomState(seed) xi = rng.random(n_samples) @@ -1642,93 +1010,15 @@ class Tabular(Univariate): quad[quad < 0.0] = 0.0 m[non_zero] = x_i[non_zero] + (np.sqrt(quad) - p_i[non_zero]) / m[non_zero] samples_out = m - elif self.interpolation == "linear-log": - # get variable and probability values for the - # next entry - x_i1 = self.x[cdf_idx + 1] - p_i1 = p[cdf_idx + 1] - # compute slope between entries - m = (p_i1 - p_i) / np.log(x_i1 / x_i) - # set values for zero slope - zero = m == 0.0 - m[zero] = x_i[zero] + (xi[zero] - c_i[zero]) / p_i[zero] - positive = m > 0 - negative = m < 0 - a = p_i / m - 1 - m[positive] = ( - x_i - * ((xi - c_i) / (m * x_i) + a) - / np.real(lambertw((((xi - c_i) / (m * x_i) + a)) * np.exp(a))) - )[positive] - m[negative] = ( - x_i - * ((xi - c_i) / (m * x_i) + a) - / np.real(lambertw((((xi - c_i) / (m * x_i) + a)) * np.exp(a), -1.0)) - )[negative] - samples_out = m - elif self.interpolation == "log-linear": - # get variable and probability values for the - # next entry - x_i1 = self.x[cdf_idx + 1] - p_i1 = p[cdf_idx + 1] - # compute slope between entries - m = np.log(p_i1 / p_i) / (x_i1 - x_i) - f = (xi - c_i) / p_i - - samples_out = x_i + f * log1prel(m * f) - elif self.interpolation == "log-log": - # get variable and probability values for the - # next entry - x_i1 = self.x[cdf_idx + 1] - p_i1 = p[cdf_idx + 1] - # compute slope between entries - m = np.log((x_i1 * p_i1) / (x_i * p_i)) / np.log(x_i1 / x_i) - f = (xi - c_i) / (x_i * p_i) - - samples_out = x_i * np.exp(f * log1prel(m * f)) else: - raise NotImplementedError( - f"Cannot sample tabular distributions " - f"for {self.inteprolation} interpolation " - ) + raise NotImplementedError('Can only sample tabular distributions ' + 'using histogram or ' + 'linear-linear interpolation') assert all(samples_out < self.x[-1]) return samples_out - def sample(self, n_samples: int = 1, seed: int | None = None): - if self.bias is None: - samples = self._sample_unbiased(n_samples, seed) - return samples, np.ones_like(samples) - else: - if self.bias.bias is not None: - raise RuntimeError('Biasing distributions should not have their own bias.') - biased_sample, _ = self.bias.sample(n_samples=n_samples, seed=seed) - self.normalize() # must have normalized probabilities to apply correct weights - wgt = np.array([self.evaluate(s) / self.bias.evaluate(s) for s in biased_sample]) - return biased_sample, wgt - - def evaluate(self, x): - if self.interpolation == 'linear-linear': - i = np.searchsorted(self.x, x, side='left') - 1 - if i < 0 or i >= len(self.p) - 1: - return 0.0 - x0, x1 = self.x[i], self.x[i + 1] - p0, p1 = self.p[i], self.p[i + 1] - t = (x - x0) / (x1 - x0) - return (1 - t) * p0 + t * p1 - - elif self.interpolation == 'histogram': - i = np.searchsorted(self.x, x, side='right') - 1 - if i < 0 or i >= len(self.p): - return 0.0 - return self.p[i] - - else: - raise NotImplementedError('Can only evaluate tabular ' - 'distributions using histogram ' - 'or linear-linear interpolation.') - def to_xml_element(self, element_name: str): """Return XML representation of the tabular distribution @@ -1749,7 +1039,7 @@ class Tabular(Univariate): params = ET.SubElement(element, "parameters") params.text = ' '.join(map(str, self.x)) + ' ' + ' '.join(map(str, self.p)) - self._append_bias_to_xml(element) + return element @classmethod @@ -1768,12 +1058,10 @@ class Tabular(Univariate): """ interpolation = get_text(elem, 'interpolation') - params = get_elem_list(elem, "parameters", float) - m = (len(params) + 1)//2 # +1 for when len(params) is odd - x = params[:m] - p = params[m:] - bias_dist = cls._read_bias_from_xml(elem) - return cls(x, p, interpolation, bias=bias_dist) + params = [float(x) for x in get_text(elem, 'parameters').split()] + x = params[:len(params)//2] + p = params[len(params)//2:] + return cls(x, p, interpolation) def integral(self): """Return integral of distribution @@ -1789,22 +1077,9 @@ class Tabular(Univariate): return np.sum(np.diff(self.x) * self.p[:self.x.size-1]) elif self.interpolation == 'linear-linear': return trapezoid(self.p, self.x) - elif self.interpolation == "linear-log": - m = np.diff(self.p) / np.diff(np.log(self.x)) - return np.sum( - self.p[:-1] * np.diff(self.x) - + m * (self.x[1:] * (np.diff(np.log(self.x)) - 1.0) + self.x[:-1]) - ) - elif self.interpolation == "log-linear": - m = np.diff(np.log(self.p)) / np.diff(self.x) - return np.sum(self.p[:-1] * np.diff(self.x) * exprel(m * np.diff(self.x))) - elif self.interpolation == "log-log": - m = np.diff(np.log(self.p)) / np.diff(np.log(self.x)) - return np.sum(self.p[:-1] * self.x[:-1] * np.diff(np.log(self.x)) - * exprel((m + 1) * np.diff(np.log(self.x)))) else: raise NotImplementedError( - f'integral() not supported for {self.interpolation} interpolation') + f'integral() not supported for {self.inteprolation} interpolation') class Legendre(Univariate): @@ -1816,24 +1091,16 @@ class Legendre(Univariate): coefficients : Iterable of Real Expansion coefficients :math:`a_\ell`. Note that the :math:`(2\ell + 1)/2` factor should not be included. - bias : openmc.stats.Univariate or None, optional - Distribution for biased sampling. Attributes ---------- coefficients : Iterable of Real Expansion coefficients :math:`a_\ell`. Note that the :math:`(2\ell + 1)/2` factor should not be included. - support : tuple of float - A 2-tuple (lower, upper) defining the interval over which the - distribution is nonzero-valued - bias : openmc.stats.Univariate or None - Distribution for biased sampling """ - def __init__(self, coefficients: Sequence[float], bias: Univariate | None = None): - super().__init__(bias) + def __init__(self, coefficients: typing.Sequence[float]): self.coefficients = coefficients self._legendre_poly = None @@ -1857,19 +1124,9 @@ class Legendre(Univariate): def coefficients(self, coefficients): self._coefficients = np.asarray(coefficients) - @property - def support(self): - raise NotImplementedError - - def _sample_unbiased(self, n_samples=1, seed=None): - raise NotImplementedError - def sample(self, n_samples=1, seed=None): raise NotImplementedError - def evaluate(self, x): - raise NotImplementedError - def to_xml_element(self, element_name): raise NotImplementedError @@ -1887,9 +1144,6 @@ class Mixture(Univariate): Probability of selecting a particular distribution distribution : Iterable of Univariate List of distributions with corresponding probabilities - bias : Iterable of Real, optional - Probability of selecting a particular distribution under biased - sampling Attributes ---------- @@ -1897,20 +1151,14 @@ class Mixture(Univariate): Probability of selecting a particular distribution distribution : Iterable of Univariate List of distributions with corresponding probabilities - support : dict - Dictionary containing discrete and continuous parts of the support - bias : numpy.ndarray or None - Probability of selecting each distribution under biased sampling """ def __init__( self, - probability: Sequence[float], - distribution: Sequence[Univariate], - bias: Sequence[float] | None = None + probability: typing.Sequence[float], + distribution: typing.Sequence[Univariate] ): - super().__init__(bias) self.probability = probability self.distribution = distribution @@ -1928,7 +1176,7 @@ class Mixture(Univariate): for p in probability: cv.check_greater_than('mixture distribution probabilities', p, 0.0, True) - self._probability = np.array(probability, dtype=float) + self._probability = probability @property def distribution(self): @@ -1940,52 +1188,10 @@ class Mixture(Univariate): Iterable, Univariate) self._distribution = distribution - @Univariate.bias.setter - def bias(self, bias): - if bias is None: - self._bias = bias - else: - cv.check_type('biased mixture distribution probabilities', bias, - Iterable, Real) - for b in bias: - cv.check_greater_than('biased mixture distribution probabilities', - b, 0.0, True) - self._bias = np.array(bias, dtype=float) - - @property - def support(self): - discrete_points = set() - intervals = [] - - for dist in self.distribution: - if isinstance(dist, Discrete): - discrete_points |= dist.support - else: - intervals.append(tuple(dist.support)) - - if intervals: - # simplify union by combining intervals when able - sorted_intervals = sorted(intervals, key=lambda x: x[0]) - merged = [sorted_intervals[0]] - - for current in sorted_intervals[1:]: - prev_start, prev_end = merged[-1] - curr_start, curr_end = current - - if curr_start <= prev_end: - merged[-1] = (prev_start, max(prev_end, curr_end)) - else: - merged.append(current) - - intervals = merged - - return {"discrete": discrete_points, "continuous": intervals} - def cdf(self): return np.insert(np.cumsum(self.probability), 0, 0.0) - def _sample_unbiased(self, n_samples=1, seed=None): - # Mixture uses internal bias mechanism, not base class bias + def sample(self, n_samples=1, seed=None): rng = np.random.RandomState(seed) # Get probability of each distribution accounting for its intensity @@ -1998,49 +1204,11 @@ class Mixture(Univariate): # Draw samples from the distributions sampled above out = np.empty_like(idx, dtype=float) - out_wgt = np.empty_like(idx, dtype=float) for i in np.unique(idx): n_dist_samples = np.count_nonzero(idx == i) - samples, weights = self.distribution[i].sample(n_dist_samples) + samples = self.distribution[i].sample(n_dist_samples) out[idx == i] = samples - out_wgt[idx == i] = weights - return out, out_wgt - - def sample(self, n_samples=1, seed=None): - # Mixture uses internal bias mechanism, not base class bias - if self.bias is None: - return self._sample_unbiased(n_samples, seed) - - rng = np.random.RandomState(seed) - - # Get probability of each distribution accounting for its intensity - p = np.array([prob*dist.integral() for prob, dist in - zip(self.probability, self.distribution)]) - p /= p.sum() - - b = np.array([prob*dist.integral() for prob, dist in - zip(self.bias, self.distribution)]) - b /= b.sum() - - # Sample from the distributions using biased probabilities - idx = rng.choice(range(len(self.distribution)), n_samples, p=b) - idx_wgt = np.ones(n_samples) - for i in np.unique(idx): - idx_wgt[idx == i] = p[i]/b[i] - - # Draw samples from the distributions sampled above - out = np.empty_like(idx, dtype=float) - out_wgt = np.empty_like(idx, dtype=float) - for i in np.unique(idx): - n_dist_samples = np.count_nonzero(idx == i) - samples, weights = self.distribution[i].sample(n_dist_samples) - out[idx == i] = samples - out_wgt[idx == i] = weights * idx_wgt[idx == i] - return out, out_wgt - - def evaluate(self, x): - raise NotImplementedError( - "evaluate() is undefined for Mixture distributions") + return out def normalize(self): """Normalize the probabilities stored on the distribution""" @@ -2071,7 +1239,6 @@ class Mixture(Univariate): data.set("probability", str(p)) data.append(d.to_xml_element("dist")) - self._append_array_bias_to_xml(element) return element @classmethod @@ -2097,8 +1264,7 @@ class Mixture(Univariate): probability.append(float(get_text(pair, 'probability'))) distribution.append(Univariate.from_xml_element(pair.find("dist"))) - bias_dist = cls._read_array_bias_from_xml(elem) - return cls(probability, distribution, bias=bias_dist) + return cls(probability, distribution) def integral(self): """Return integral of the distribution @@ -2115,507 +1281,91 @@ class Mixture(Univariate): for p, dist in zip(self.probability, self.distribution) ]) - def mean(self) -> float: - """Return mean of the mixture distribution - - The mean is the weighted average of the means of the component - distributions, weighted by probability * integral. - - .. versionadded:: 0.15.3 - - Returns - ------- - float - Mean of the mixture distribution - """ - # Weight each component by its probability and integral - weights = [p*dist.integral() for p, dist in - zip(self.probability, self.distribution)] - total_weight = sum(weights) - - if total_weight == 0: - return 0.0 - - return sum([w*dist.mean() for w, dist in - zip(weights, self.distribution)]) / total_weight - def clip(self, tolerance: float = 1e-6, inplace: bool = False) -> Mixture: - r"""Remove low-importance points / distributions + r"""Remove low-importance points from contained discrete distributions. - Like :meth:`Discrete.clip`, this method will remove low-importance - points from discrete distributions contained within the mixture but it - will also clip any distributions that have negligible contributions to - the overall intensity. + Given a probability mass function :math:`p(x)` with :math:`\{x_1, x_2, + x_3, \dots\}` the possible values of the random variable with + corresponding probabilities :math:`\{p_1, p_2, p_3, \dots\}`, this + function will remove any low-importance points such that :math:`\sum_i + x_i p_i` is preserved to within some threshold. .. versionadded:: 0.14.0 Parameters ---------- tolerance : float - Maximum fraction of intensities that will be discarded. + Maximum fraction of :math:`\sum_i x_i p_i` that will be discarded + for any discrete distributions within the mixture distribution. inplace : bool Whether to modify the current object in-place or return a new one. Returns ------- - Distribution with low-importance points / distributions removed + Discrete distribution with low-importance points removed """ - # Calculate mean * integral for original distribution to compare later. - original_mean_integral = self.mean() * self.integral() - - # Determine indices for any distributions that contribute non-negligibly - # to overall mean * integral - mean_integrals = [prob*dist.mean()*dist.integral() for prob, dist in - zip(self.probability, self.distribution)] - indices = _intensity_clip(mean_integrals, tolerance=tolerance) - - # Clip mixture of distributions - probability = self.probability[indices] - distribution = [self.distribution[i] for i in indices] - - # Clip points from Discrete distributions - distribution = [ - dist.clip(tolerance, inplace) if isinstance(dist, Discrete) else dist - for dist in distribution - ] - if inplace: - # Set attributes of current object and return - self.probability = probability - self.distribution = distribution - new_dist = self - else: - # Create new distribution - new_dist = type(self)(probability, distribution) - - # Show warning if mean * integral of new distribution is not within - # tolerance of original. For energy distributions, mean * integral - # represents total energy. - new_mean_integral = new_dist.mean() * new_dist.integral() - diff = (original_mean_integral - new_mean_integral)/original_mean_integral - if diff > tolerance: - warn("Clipping mixture distribution resulted in a mean*integral " - f"that is lower by a fraction of {diff} when tolerance={tolerance}.") - - return new_dist - - -class DecaySpectrum(Univariate): - """Energy distribution from decay photon spectra of a mixture of nuclides. - - This distribution stores nuclide names, their atom densities, and the volume - of the region. When written to XML and read by the C++ solver, the nuclide - names are resolved against the depletion chain to obtain the decay photon - energy spectra and decay constants. The resulting distribution is a mixture - of per-nuclide photon spectra weighted by absolute activity. The volume is - necessary so that the C++ solver can compute the total photon emission rate - in [photons/s], which is used as the source strength. - - .. versionadded:: 0.15.4 - - Parameters - ---------- - nuclides : dict - Dictionary mapping nuclide name (str) to atom density (float) in units - of [atom/b-cm]. - volume : float - Volume of the source region in [cm³]. Used together with atom densities - to compute the absolute photon emission rate. - - Attributes - ---------- - nuclides : dict - Dictionary mapping nuclide name to atom density in [atom/b-cm]. - volume : float - Volume of the source region in [cm³]. - - """ - - def __init__(self, nuclides: dict[str, float], volume: float): - super().__init__(bias=None) - self._dist_cache = None - self._dist_cache_key = None - self.nuclides = nuclides - self.volume = volume - - def __len__(self): - return len(self.nuclides) - - @property - def nuclides(self): - return self._nuclides - - @nuclides.setter - def nuclides(self, nuclides): - cv.check_type('nuclides', nuclides, dict) - for name, density in nuclides.items(): - cv.check_type('nuclide name', name, str) - cv.check_type(f'atom density for {name}', density, Real) - cv.check_greater_than(f'atom density for {name}', density, 0.0, True) - self._nuclides = dict(nuclides) - self._dist_cache = None - self._dist_cache_key = None - - @property - def volume(self): - return self._volume - - @volume.setter - def volume(self, volume): - cv.check_type('volume', volume, Real) - cv.check_greater_than('volume', volume, 0.0) - self._volume = float(volume) - self._dist_cache = None - self._dist_cache_key = None - - @staticmethod - def _chain_file_cache_key(): - """Return a hashable key for the active depletion chain.""" - chain_file = openmc.config.get('chain_file') - if chain_file is None: - return None - - path = Path(chain_file).resolve() - try: - stat = path.stat() - except OSError: - return (path, None, None) - return (path, stat.st_mtime, stat.st_size) - - def to_distribution(self): - """Convert to a concrete distribution using decay chain data. - - Builds a combined photon energy distribution by looking up each nuclide - in the depletion chain via :func:`openmc.data.decay_photon_energy` and - weighting by absolute atom count (``density * 1e24 * volume``). The - result is cached on the object; the cache is invalidated automatically - when :attr:`nuclides` or :attr:`volume` are reassigned. - - Requires ``openmc.config['chain_file']`` to be set. - - Returns - ------- - openmc.stats.Univariate or None - Combined photon energy distribution, or ``None`` if no nuclide in - :attr:`nuclides` has a photon source in the chain. - - """ - chain_key = self._chain_file_cache_key() - if self._dist_cache is not None and self._dist_cache_key == chain_key: - return self._dist_cache - - dists = [] - weights = [] - for name, density in self.nuclides.items(): - dist = openmc.data.decay_photon_energy(name) - if dist is not None: - dists.append(dist) - weights.append(density * 1e24 * self.volume) - - if not dists: - return None - - self._dist_cache = combine_distributions(dists, weights) - self._dist_cache_key = chain_key - return self._dist_cache - - def to_xml_element(self, element_name: str): - """Return XML representation of the decay photon distribution - - Parameters - ---------- - element_name : str - XML element name - - Returns - ------- - element : lxml.etree._Element - XML element containing decay photon distribution data - - """ - element = ET.Element(element_name) - element.set("type", "decay_spectrum") - element.set("volume", str(self.volume)) - nuclides = ET.SubElement(element, "nuclides") - nuclides.text = ' '.join(self.nuclides) - parameters = ET.SubElement(element, "parameters") - parameters.text = ' '.join(str(density) for density in self.nuclides.values()) - return element - - @classmethod - def from_xml_element(cls, elem: ET.Element): - """Generate decay photon distribution from an XML element - - Parameters - ---------- - elem : lxml.etree._Element - XML element - - Returns - ------- - openmc.stats.DecaySpectrum - Decay photon distribution generated from XML element - - """ - volume = float(elem.get('volume')) - names = get_elem_list(elem, 'nuclides', str) - densities = get_elem_list(elem, 'parameters', float) - nuclides = dict(zip(names, densities)) - return cls(nuclides, volume) - - def _sample_unbiased(self, n_samples=1, seed=None): - dist = self.to_distribution() - if dist is None: - raise RuntimeError( - "DecaySpectrum._sample_unbiased requires chain data but none " - "was found. Ensure openmc.config['chain_file'] is set and the " - "chain contains photon sources for the nuclides present." - ) - return dist.sample(n_samples, seed)[0] - - def integral(self): - """Return integral of the distribution - - Returns the total photon emission rate in [photons/s] by delegating to - :meth:`to_distribution`. Returns ``0.0`` when no chain data is - available (e.g., ``openmc.config['chain_file']`` is not set). - - Returns - ------- - float - Total photon emission rate in [photons/s], or ``0.0`` if chain - data is unavailable. - """ - try: - dist = self.to_distribution() - except Exception: - return 0.0 - if dist is None: - return 0.0 - return dist.integral() - - @staticmethod - @cache - def _photon_integral(nuclide: str, chain_key) -> float | None: - """Return the per-atom photon emission integral for a nuclide""" - dist = openmc.data.decay_photon_energy(nuclide) - return dist.integral() if dist is not None else None - - def clip(self, tolerance: float = 1e-9, inplace: bool = False): - """Remove nuclides with negligible contribution to photon emission. - - Nuclides that are stable or have no photon source in the depletion - chain are removed unconditionally. The remaining nuclides are ranked - by their photon emission rate (proportional to - ``atom_density * decay_constant * photon_yield``) and the least - important are discarded until the cumulative discarded fraction of the - total emission rate exceeds *tolerance*. - - Requires ``openmc.config['chain_file']`` to be set. - - Parameters - ---------- - tolerance : float - Maximum fraction of total photon emission rate that may be - discarded. - inplace : bool - Whether to modify the current object in-place or return a new one. - - Returns - ------- - openmc.stats.DecaySpectrum - Distribution with negligible nuclides removed. - - """ - # Compute per-nuclide emission rate; drop non-emitters - emitting_names = [] - emitting_densities = [] - rates = [] - chain_key = self._chain_file_cache_key() - for name, density in self.nuclides.items(): - integral = DecaySpectrum._photon_integral(name, chain_key) - if integral is None: - continue - emitting_names.append(name) - emitting_densities.append(density) - rates.append(density * self.volume * integral) - - if not emitting_names: - new_nuclides = {} - else: - indices = _intensity_clip(rates, tolerance=tolerance) - new_nuclides = { - emitting_names[i]: emitting_densities[i] for i in indices - } - - if inplace: - self._nuclides = new_nuclides - self._dist_cache = None - self._dist_cache_key = None + for dist in self.distribution: + if isinstance(dist, Discrete): + dist.clip(tolerance, inplace=True) return self - return type(self)(new_nuclides, self.volume) - - @property - def support(self): - return (0.0, np.inf) - - def evaluate(self, x): - """Evaluate the probability density at a given value. - - Delegates to the combined distribution built from chain data. Raises - ``NotImplementedError`` if the combined distribution is a - :class:`~openmc.stats.Mixture` (which does not support - ``evaluate()``). - - Parameters - ---------- - x : float - Value at which to evaluate the PDF. - - Returns - ------- - float - Probability density at *x*. - """ - dist = self.to_distribution() - if dist is None: - raise RuntimeError( - "DecaySpectrum.evaluate requires chain data. Ensure " - "openmc.config['chain_file'] is set." - ) - return dist.evaluate(x) - - def mean(self): - """Return the mean of the distribution. - - Delegates to the combined distribution built from chain data. - - Returns - ------- - float - Mean photon energy in [eV]. - """ - dist = self.to_distribution() - if dist is None: - raise RuntimeError( - "DecaySpectrum.mean requires chain data. Ensure " - "openmc.config['chain_file'] is set." - ) - return dist.mean() + else: + distribution = [ + dist.clip(tolerance) if isinstance(dist, Discrete) else dist + for dist in self.distribution + ] + return type(self)(self.probability, distribution) def combine_distributions( - dists: Sequence[Discrete | Tabular | Mixture], - probs: Sequence[float] + dists: typing.Sequence[Univariate], + probs: typing.Sequence[float] ): """Combine distributions with specified probabilities This function can be used to combine multiple instances of - :class:`~openmc.stats.Discrete`, :class:`~openmc.stats.Tabular` and - :class:`~openmc.stats.Mixture` of them. Multiple discrete distributions are - merged into a single distribution and the remainder of the distributions are - put into a :class:`~openmc.stats.Mixture` distribution. + :class:`~openmc.stats.Discrete` and `~openmc.stats.Tabular`. Multiple + discrete distributions are merged into a single distribution and the + remainder of the distributions are put into a :class:`~openmc.stats.Mixture` + distribution. .. versionadded:: 0.13.1 Parameters ---------- - dists : sequence of openmc.stats.Discrete, openmc.stats.Tabular, or openmc.stats.Mixture + dists : iterable of openmc.stats.Univariate Distributions to combine - probs : sequence of float + probs : iterable of float Probability (or intensity) of each distribution """ - new_probs = [] - new_dists = [] - for i, dist in enumerate(dists): - cv.check_type(f'dists[{i}]', dist, (Discrete, Tabular, Mixture)) - cv.check_type(f'probs[{i}]', probs[i], Real) - cv.check_greater_than(f'probs[{i}]', probs[i], 0.0) - if isinstance(dist, Mixture): - if dist.bias is not None: - warn("A Mixture distribution with a bias specified was passed " - "to combine_distributions. The bias will be discarded " - "during flattening.") - for j, d in enumerate(dist.distribution): - cv.check_type(f'dists[{i}].distribution[{j}]', d, (Discrete, Tabular)) - new_probs.append(probs[i]*dist.probability[j]) - new_dists.append(d) - else: - new_probs.append(probs[i]) - new_dists.append(dist) - - probs = new_probs - dists = new_dists + # Get copy of distribution list so as not to modify the argument + dist_list = deepcopy(dists) # Get list of discrete/continuous distribution indices - discrete_index = [i for i, d in enumerate(dists) if isinstance(d, Discrete)] - cont_index = [i for i, d in enumerate(dists) if isinstance(d, Tabular)] + discrete_index = [i for i, d in enumerate(dist_list) if isinstance(d, Discrete)] + cont_index = [i for i, d in enumerate(dist_list) if isinstance(d, Tabular)] - cont_dists = [dists[i] for i in cont_index] - cont_probs = [probs[i] for i in cont_index] + # Apply probabilites to continuous distributions + for i in cont_index: + dist = dist_list[i] + dist._p *= probs[i] if discrete_index: # Create combined discrete distribution - dist_discrete = [dists[i] for i in discrete_index] + dist_discrete = [dist_list[i] for i in discrete_index] discrete_probs = [probs[i] for i in discrete_index] combined_dist = Discrete.merge(dist_discrete, discrete_probs) - if cont_index: - return Mixture(cont_probs + [1.0], cont_dists + [combined_dist]) - else: - return combined_dist - else: - if len(cont_dists) == 1: - dist = cont_dists[0] - return Tabular(dist.x, dist.p * cont_probs[0], - dist.interpolation, bias=dist.bias) - else: - return Mixture(cont_probs, cont_dists) + # Replace multiple discrete distributions with merged + for idx in reversed(discrete_index): + dist_list.pop(idx) + dist_list.append(combined_dist) -def check_bias_support(parent: Univariate, bias: Univariate | None): - """Ensure that bias distributions share the support of the univariate - distribution they are biasing. + # Combine discrete and continuous if present + if len(dist_list) > 1: + probs = [1.0]*len(dist_list) + dist_list[:] = [Mixture(probs, dist_list.copy())] - Parameters - ---------- - parent : openmc.stats.Univariate - Distributions to be biased - bias : openmc.stats.Univariate or None - Proposed bias distribution - - """ - if bias is None: - return - - def mismatch_error(err_type, msg): - raise err_type(f"Support of parent {type(parent).__name__} and bias " - f"{type(bias).__name__} distributions do not match. " - f"{msg}") - - p_sup, b_sup = parent.support, bias.support - - if isinstance(p_sup, set) or isinstance(b_sup, set): - raise RuntimeError("Discrete distributions cannot be used as biasing " - "distributions or be biased by another Univariate " - "distribution. Instead, assign a vector of " - "alternate probabilities to the bias attribute.") - - elif isinstance(p_sup, dict) or isinstance (b_sup, dict): - raise RuntimeError("Mixture distributions cannot be used as biasing " - "distributions or be biased by another Univariate " - "distribution. Instead, instantiate the Mixture " - "object using biased member distributions, or " - "assign a vector of alternative probabilities to " - "the bias attribute.") - - elif isinstance(p_sup, tuple): - if isinstance(b_sup, tuple): - if p_sup != b_sup: - mismatch_error(ValueError, "") - else: - mismatch_error(TypeError, "Incompatible support types.") - - else: - raise TypeError("Unrecognized type for parent distribution support") + return dist_list[0] diff --git a/openmc/summary.py b/openmc/summary.py index ca5cfadd7..6423f8ce1 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -127,23 +127,11 @@ class Summary: self._fast_materials[material.id] = material def _read_surfaces(self): - periodic_surface_ids = set() for group in self._f['geometry/surfaces'].values(): surface = openmc.Surface.from_hdf5(group) # surface may be None for DAGMC surfaces if surface: self._fast_surfaces[surface.id] = surface - if surface.boundary_type == "periodic": - periodic_surface_ids.add(surface.id) - - # Assign periodic surfaces when information is in file - for surface_id in periodic_surface_ids: - group = self._f[f'geometry/surfaces/surface {surface_id}'] - surface = self._fast_surfaces[surface_id] - if 'periodic_surface_id' in group: - periodic_surface_id = int(group['periodic_surface_id'][()]) - surface.periodic_surface = self._fast_surfaces[periodic_surface_id] - def _read_cells(self): diff --git a/openmc/surface.py b/openmc/surface.py index c2afeb613..0fa2ae439 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -1,4 +1,3 @@ -from __future__ import annotations from abc import ABC, abstractmethod from collections.abc import Iterable from copy import deepcopy @@ -13,7 +12,6 @@ from .checkvalue import check_type, check_value, check_length, check_greater_tha from .mixin import IDManagerMixin, IDWarning from .region import Region, Intersection, Union from .bounding_box import BoundingBox -from ._xml import get_elem_list, get_text _BOUNDARY_TYPES = {'transmission', 'vacuum', 'reflective', 'periodic', 'white'} @@ -38,13 +36,10 @@ class SurfaceCoefficient: value : float or str Value of the coefficient (float) or the name of the coefficient that it is equivalent to (str). - positive : bool - Does the surface coefficient must be positive. Defaults to False. """ - def __init__(self, value, positive=False): + def __init__(self, value): self.value = value - self.positive = positive def __get__(self, instance, owner=None): if instance is None: @@ -59,8 +54,6 @@ class SurfaceCoefficient: if isinstance(self.value, Real): raise AttributeError('This coefficient is read-only') check_type(f'{self.value} coefficient', value, Real) - if self.positive: - check_greater_than(f'{self.value} coefficient', value, 0.0) instance._coefficients[self.value] = value @@ -125,11 +118,12 @@ class Surface(IDManagerMixin, ABC): surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles - freely pass through the surface. Note that only axis-aligned - periodicity is supported around the x-, y-, and z-axes. + freely pass through the surface. Note that periodic boundary conditions + can only be applied to x-, y-, and z-planes, and only axis-aligned + periodicity is supported. albedo : float, optional Albedo of the surfaces as a ratio of particle weight after interaction with the surface to the initial weight. Values must be positive. Only @@ -140,7 +134,7 @@ class Surface(IDManagerMixin, ABC): Attributes ---------- - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -156,7 +150,6 @@ class Surface(IDManagerMixin, ABC): """ - min_id = 1 next_id = 1 used_ids = set() _atol = 1.e-12 @@ -315,7 +308,7 @@ class Surface(IDManagerMixin, ABC): coeffs = self._get_base_coeffs() coeffs = np.asarray(coeffs) nonzeros = ~np.isclose(coeffs, 0., rtol=0., atol=self._atol) - norm_factor = coeffs[nonzeros][0] + norm_factor = np.abs(coeffs[nonzeros][0]) return tuple([c/norm_factor for c in coeffs]) def is_equal(self, other): @@ -457,17 +450,17 @@ class Surface(IDManagerMixin, ABC): """ # Determine appropriate class - surf_type = get_text(elem, "type") + surf_type = elem.get('type') cls = _SURFACE_CLASSES[surf_type] # Determine ID, boundary type, boundary albedo, coefficients kwargs = {} - kwargs['surface_id'] = int(get_text(elem, "id")) - kwargs['boundary_type'] = get_text(elem, "boundary", "transmission") + kwargs['surface_id'] = int(elem.get('id')) + kwargs['boundary_type'] = elem.get('boundary', 'transmission') if kwargs['boundary_type'] in _ALBEDO_BOUNDARIES: - kwargs['albedo'] = float(get_text(elem, "albedo", 1.0)) - kwargs['name'] = get_text(elem, "name") - coeffs = get_elem_list(elem, "coeffs", float) + kwargs['albedo'] = float(elem.get('albedo', 1.0)) + kwargs['name'] = elem.get('name') + coeffs = [float(x) for x in elem.get('coeffs').split()] kwargs.update(dict(zip(cls._coeff_keys, coeffs))) return cls(**kwargs) @@ -689,7 +682,7 @@ class Plane(PlaneMixin, Surface): The 'C' parameter for the plane. Defaults to 0. d : float, optional The 'D' parameter for the plane. Defaults to 0. - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -713,7 +706,7 @@ class Plane(PlaneMixin, Surface): The 'C' parameter for the plane d : float The 'D' parameter for the plane - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -809,13 +802,6 @@ class Plane(PlaneMixin, Surface): d = np.dot(n, p1) return cls(a=a, b=b, c=c, d=d, **kwargs) - def flip_normal(self): - """Modify plane coefficients to reverse the normal vector.""" - self.a = -self.a - self.b = -self.b - self.c = -self.c - self.d = -self.d - class XPlane(PlaneMixin, Surface): """A plane perpendicular to the x axis of the form :math:`x - x_0 = 0` @@ -824,10 +810,11 @@ class XPlane(PlaneMixin, Surface): ---------- x0 : float, optional Location of the plane in [cm]. Defaults to 0. - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles - freely pass through the surface. + freely pass through the surface. Only axis-aligned periodicity is + supported, i.e., x-planes can only be paired with x-planes. albedo : float, optional Albedo of the surfaces as a ratio of particle weight after interaction with the surface to the initial weight. Values must be positive. Only @@ -842,7 +829,7 @@ class XPlane(PlaneMixin, Surface): ---------- x0 : float Location of the plane in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -888,10 +875,11 @@ class YPlane(PlaneMixin, Surface): ---------- y0 : float, optional Location of the plane in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles - freely pass through the surface. + freely pass through the surface. Only axis-aligned periodicity is + supported, i.e., y-planes can only be paired with y-planes. albedo : float, optional Albedo of the surfaces as a ratio of particle weight after interaction with the surface to the initial weight. Values must be positive. Only @@ -906,7 +894,7 @@ class YPlane(PlaneMixin, Surface): ---------- y0 : float Location of the plane in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -952,10 +940,11 @@ class ZPlane(PlaneMixin, Surface): ---------- z0 : float, optional Location of the plane in [cm]. Defaults to 0. - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles - freely pass through the surface. + freely pass through the surface. Only axis-aligned periodicity is + supported, i.e., z-planes can only be paired with z-planes. albedo : float, optional Albedo of the surfaces as a ratio of particle weight after interaction with the surface to the initial weight. Values must be positive. Only @@ -970,7 +959,7 @@ class ZPlane(PlaneMixin, Surface): ---------- z0 : float Location of the plane in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'periodic', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1200,7 +1189,7 @@ class Cylinder(QuadricMixin, Surface): dz : float, optional z-component of the vector representing the axis of the cylinder. Defaults to 1. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1231,7 +1220,7 @@ class Cylinder(QuadricMixin, Surface): y-component of the vector representing the axis of the cylinder dz : float z-component of the vector representing the axis of the cylinder - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1266,7 +1255,7 @@ class Cylinder(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r = SurfaceCoefficient('r', positive=True) + r = SurfaceCoefficient('r') dx = SurfaceCoefficient('dx') dy = SurfaceCoefficient('dy') dz = SurfaceCoefficient('dz') @@ -1375,7 +1364,7 @@ class XCylinder(QuadricMixin, Surface): z-coordinate for the origin of the Cylinder in [cm]. Defaults to 0 r : float, optional Radius of the cylinder in [cm]. Defaults to 1. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1398,7 +1387,7 @@ class XCylinder(QuadricMixin, Surface): z-coordinate for the origin of the Cylinder in [cm] r : float Radius of the cylinder in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1432,7 +1421,7 @@ class XCylinder(QuadricMixin, Surface): x0 = SurfaceCoefficient(0.) y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r = SurfaceCoefficient('r', positive=True) + r = SurfaceCoefficient('r') dx = SurfaceCoefficient(1.) dy = SurfaceCoefficient(0.) dz = SurfaceCoefficient(0.) @@ -1473,7 +1462,7 @@ class YCylinder(QuadricMixin, Surface): z-coordinate for the origin of the Cylinder in [cm]. Defaults to 0 r : float, optional Radius of the cylinder in [cm]. Defaults to 1. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1496,7 +1485,7 @@ class YCylinder(QuadricMixin, Surface): z-coordinate for the origin of the Cylinder in [cm] r : float Radius of the cylinder in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1530,7 +1519,7 @@ class YCylinder(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient(0.) z0 = SurfaceCoefficient('z0') - r = SurfaceCoefficient('r', positive=True) + r = SurfaceCoefficient('r') dx = SurfaceCoefficient(0.) dy = SurfaceCoefficient(1.) dz = SurfaceCoefficient(0.) @@ -1571,7 +1560,7 @@ class ZCylinder(QuadricMixin, Surface): y-coordinate for the origin of the Cylinder in [cm]. Defaults to 0 r : float, optional Radius of the cylinder in [cm]. Defaults to 1. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1594,7 +1583,7 @@ class ZCylinder(QuadricMixin, Surface): y-coordinate for the origin of the Cylinder in [cm] r : float Radius of the cylinder in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1628,7 +1617,7 @@ class ZCylinder(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient(0.) - r = SurfaceCoefficient('r', positive=True) + r = SurfaceCoefficient('r') dx = SurfaceCoefficient(0.) dy = SurfaceCoefficient(0.) dz = SurfaceCoefficient(1.) @@ -1670,7 +1659,7 @@ class Sphere(QuadricMixin, Surface): z-coordinate of the center of the sphere in [cm]. Defaults to 0. r : float, optional Radius of the sphere in [cm]. Defaults to 1. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1694,7 +1683,7 @@ class Sphere(QuadricMixin, Surface): z-coordinate of the center of the sphere in [cm] r : float Radius of the sphere in [cm] - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1728,7 +1717,7 @@ class Sphere(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r = SurfaceCoefficient('r', positive=True) + r = SurfaceCoefficient('r') def _get_base_coeffs(self): x0, y0, z0, r = self.x0, self.y0, self.z0, self.r @@ -1756,7 +1745,7 @@ class Sphere(QuadricMixin, Surface): class Cone(QuadricMixin, Surface): - r"""A conical surface parallel to the x-, y-, or z-axis. + """A conical surface parallel to the x-, y-, or z-axis. .. Note:: This creates a double cone, which is two one-sided cones that meet at their apex. @@ -1766,26 +1755,28 @@ class Cone(QuadricMixin, Surface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex in [cm]. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex in [cm]. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex in [cm]. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. + Parameter related to the aperture [:math:`\\rm cm^2`]. + It can be interpreted as the increase in the radius squared per cm along + the cone's axis of revolution. dx : float, optional x-component of the vector representing the axis of the cone. + Defaults to 0. dy : float, optional y-component of the vector representing the axis of the cone. + Defaults to 0. dz : float, optional z-component of the vector representing the axis of the cone. + Defaults to 1. surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1806,14 +1797,14 @@ class Cone(QuadricMixin, Surface): z0 : float z-coordinate of the apex in [cm] r2 : float - Parameter related to the aperture + Parameter related to the aperature [cm^2] dx : float x-component of the vector representing the axis of the cone. dy : float y-component of the vector representing the axis of the cone. dz : float z-component of the vector representing the axis of the cone. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1854,7 +1845,7 @@ class Cone(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r2 = SurfaceCoefficient('r2', positive=True) + r2 = SurfaceCoefficient('r2') dx = SurfaceCoefficient('dx') dy = SurfaceCoefficient('dy') dz = SurfaceCoefficient('dz') @@ -1912,7 +1903,7 @@ class Cone(QuadricMixin, Surface): class XCone(QuadricMixin, Surface): - r"""A cone parallel to the x-axis of the form :math:`(y - y_0)^2 + (z - z_0)^2 = + """A cone parallel to the x-axis of the form :math:`(y - y_0)^2 + (z - z_0)^2 = r^2 (x - x_0)^2`. .. Note:: @@ -1922,17 +1913,16 @@ class XCone(QuadricMixin, Surface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex in [cm]. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex in [cm]. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex in [cm]. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + Parameter related to the aperture [:math:`\\rm cm^2`]. + It can be interpreted as the increase in the radius squared per cm along + the cone's axis of revolution. + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -1955,8 +1945,8 @@ class XCone(QuadricMixin, Surface): z0 : float z-coordinate of the apex in [cm] r2 : float - Parameter related to the aperture - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -1990,7 +1980,7 @@ class XCone(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r2 = SurfaceCoefficient('r2', positive=True) + r2 = SurfaceCoefficient('r2') dx = SurfaceCoefficient(1.) dy = SurfaceCoefficient(0.) dz = SurfaceCoefficient(0.) @@ -2014,7 +2004,7 @@ class XCone(QuadricMixin, Surface): class YCone(QuadricMixin, Surface): - r"""A cone parallel to the y-axis of the form :math:`(x - x_0)^2 + (z - z_0)^2 = + """A cone parallel to the y-axis of the form :math:`(x - x_0)^2 + (z - z_0)^2 = r^2 (y - y_0)^2`. .. Note:: @@ -2024,17 +2014,16 @@ class YCone(QuadricMixin, Surface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex in [cm]. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex in [cm]. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex in [cm]. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + Parameter related to the aperture [:math:`\\rm cm^2`]. + It can be interpreted as the increase in the radius squared per cm along + the cone's axis of revolution. + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -2057,8 +2046,8 @@ class YCone(QuadricMixin, Surface): z0 : float z-coordinate of the apex in [cm] r2 : float - Parameter related to the aperture - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -2092,7 +2081,7 @@ class YCone(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r2 = SurfaceCoefficient('r2', positive=True) + r2 = SurfaceCoefficient('r2') dx = SurfaceCoefficient(0.) dy = SurfaceCoefficient(1.) dz = SurfaceCoefficient(0.) @@ -2116,7 +2105,7 @@ class YCone(QuadricMixin, Surface): class ZCone(QuadricMixin, Surface): - r"""A cone parallel to the z-axis of the form :math:`(x - x_0)^2 + (y - y_0)^2 = + """A cone parallel to the z-axis of the form :math:`(x - x_0)^2 + (y - y_0)^2 = r^2 (z - z_0)^2`. .. Note:: @@ -2126,17 +2115,16 @@ class ZCone(QuadricMixin, Surface): Parameters ---------- x0 : float, optional - x-coordinate of the apex in [cm]. + x-coordinate of the apex in [cm]. Defaults to 0. y0 : float, optional - y-coordinate of the apex in [cm]. + y-coordinate of the apex in [cm]. Defaults to 0. z0 : float, optional - z-coordinate of the apex in [cm]. + z-coordinate of the apex in [cm]. Defaults to 0. r2 : float, optional - The square of the slope of the cone. It is defined as - :math:`\left(\frac{r}{h}\right)^2` for a radius, :math:`r` and an axial - distance :math:`h` from the apex. An easy way to define this quantity is - to take the square of the radius of the cone (in cm) 1 cm from the apex. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + Parameter related to the aperature [cm^2]. + This is the square of the radius of the cone 1 cm from. + This can also be treated as the square of the slope of the cone relative to its axis. + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -2159,8 +2147,8 @@ class ZCone(QuadricMixin, Surface): z0 : float z-coordinate of the apex in [cm] r2 : float - Parameter related to the aperture. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -2194,7 +2182,7 @@ class ZCone(QuadricMixin, Surface): x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - r2 = SurfaceCoefficient('r2', positive=True) + r2 = SurfaceCoefficient('r2') dx = SurfaceCoefficient(0.) dy = SurfaceCoefficient(0.) dz = SurfaceCoefficient(1.) @@ -2225,7 +2213,7 @@ class Quadric(QuadricMixin, Surface): ---------- a, b, c, d, e, f, g, h, j, k : float, optional coefficients for the surface. All default to 0. - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'}, optional + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. @@ -2243,7 +2231,7 @@ class Quadric(QuadricMixin, Surface): ---------- a, b, c, d, e, f, g, h, j, k : float coefficients for the surface - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -2297,9 +2285,9 @@ class TorusMixin: x0 = SurfaceCoefficient('x0') y0 = SurfaceCoefficient('y0') z0 = SurfaceCoefficient('z0') - a = SurfaceCoefficient('a', positive=True) - b = SurfaceCoefficient('b', positive=True) - c = SurfaceCoefficient('c', positive=True) + a = SurfaceCoefficient('a') + b = SurfaceCoefficient('b') + c = SurfaceCoefficient('c') def translate(self, vector, inplace=False): surf = self if inplace else self.clone() @@ -2395,7 +2383,7 @@ class XTorus(TorusMixin, Surface): Minor radius of the torus in [cm] (parallel to axis of revolution) c : float Minor radius of the torus in [cm] (perpendicular to axis of revolution) - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -2470,7 +2458,7 @@ class YTorus(TorusMixin, Surface): Minor radius of the torus in [cm] (parallel to axis of revolution) c : float Minor radius of the torus (perpendicular to axis of revolution) - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -2545,7 +2533,7 @@ class ZTorus(TorusMixin, Surface): Minor radius of the torus in [cm] (parallel to axis of revolution) c : float Minor radius of the torus in [cm] (perpendicular to axis of revolution) - boundary_type : {'transmission', 'vacuum', 'reflective', 'white'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'white'} Boundary condition that defines the behavior for particles hitting the surface. albedo : float @@ -2636,7 +2624,7 @@ class Halfspace(Region): else: return Union((self, other)) - def __invert__(self) -> Halfspace: + def __invert__(self): return -self.surface if self.side == '+' else +self.surface def __contains__(self, point): diff --git a/openmc/tallies.py b/openmc/tallies.py index ceced4255..f39ffa078 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -1,9 +1,7 @@ -from __future__ import annotations from collections.abc import Iterable, MutableSequence import copy -from functools import partial, reduce, wraps +from functools import partial, reduce from itertools import product -from math import sqrt, log from numbers import Integral, Real import operator from pathlib import Path @@ -12,29 +10,11 @@ import lxml.etree as ET import h5py import numpy as np import pandas as pd -from scipy.stats import chi2, norm +import scipy.sparse as sps import openmc import openmc.checkvalue as cv -from openmc.filter import ( - Filter, - DistribcellFilter, - EnergyFunctionFilter, - DelayedGroupFilter, - FilterMeta, - MeshFilter, - MeshBornFilter, -) -from openmc.arithmetic import ( - CrossFilter, - AggregateFilter, - CrossScore, - AggregateScore, - CrossNuclide, - AggregateNuclide, -) -from ._sparse_compat import lil_array -from ._xml import clean_indentation, get_elem_list, get_text +from ._xml import clean_indentation, reorder_attributes, get_text from .mixin import IDManagerMixin from .mesh import MeshBase @@ -48,12 +28,12 @@ _PRODUCT_TYPES = ['tensor', 'entrywise'] # The following indicate acceptable types when setting Tally.scores, # Tally.nuclides, and Tally.filters -_SCORE_CLASSES = (str, CrossScore, AggregateScore) -_NUCLIDE_CLASSES = (str, CrossNuclide, AggregateNuclide) -_FILTER_CLASSES = (Filter, CrossFilter, AggregateFilter) +_SCORE_CLASSES = (str, openmc.CrossScore, openmc.AggregateScore) +_NUCLIDE_CLASSES = (str, openmc.CrossNuclide, openmc.AggregateNuclide) +_FILTER_CLASSES = (openmc.Filter, openmc.CrossFilter, openmc.AggregateFilter) # Valid types of estimators -ESTIMATOR_TYPES = {'tracklength', 'collision', 'analog'} +ESTIMATOR_TYPES = ['tracklength', 'collision', 'analog'] class Tally(IDManagerMixin): @@ -67,18 +47,6 @@ class Tally(IDManagerMixin): will automatically be assigned name : str, optional Name of the tally. If not specified, the name is the empty string. - scores : list of str, optional - List of scores, e.g. ['flux', 'fission'] - filters : list of openmc.Filter, optional - List of filters for the tally - nuclides : list of str, optional - List of nuclides to score results for - estimator : {'analog', 'tracklength', 'collision'}, optional - Type of estimator for the tally - triggers : list of openmc.Trigger, optional - List of tally triggers - derivative : openmc.TallyDerivative, optional - A material perturbation derivative to apply to all scores in the tally Attributes ---------- @@ -97,9 +65,7 @@ class Tally(IDManagerMixin): scores : list of str List of defined scores, e.g. 'flux', 'fission', etc. estimator : {'analog', 'tracklength', 'collision'} - Type of estimator for the tally. If unset (None), OpenMC will automatically - select an appropriate estimator based on the tally filters and scores - with a preference for 'tracklength'. + Type of estimator for the tally triggers : list of openmc.Trigger List of tally triggers num_scores : int @@ -122,24 +88,10 @@ class Tally(IDManagerMixin): sum_sq : numpy.ndarray An array containing the sum of each independent realization squared for each bin - sum_third : numpy.ndarray - An array containing the sum of each independent realization to the third power for - each bin - sum_fourth : numpy.ndarray - An array containing the sum of each independent realization to the fourth power for - each bin mean : numpy.ndarray An array containing the sample mean for each bin std_dev : numpy.ndarray An array containing the sample standard deviation for each bin - vov : numpy.ndarray - An array containing the variance of the variance for each tally bin - higher_moments : bool - Whether or not the tally accumulates the sums third and fourth to compute higher-order moments - figure_of_merit : numpy.ndarray - An array containing the figure of merit for each bin - - .. versionadded:: 0.15.3 derived : bool Whether or not the tally is derived from one or more other tallies sparse : bool @@ -153,9 +105,7 @@ class Tally(IDManagerMixin): next_id = 1 used_ids = set() - def __init__(self, tally_id=None, name='', scores=None, filters=None, - nuclides=None, estimator=None, triggers=None, - derivative=None): + def __init__(self, tally_id=None, name=''): # Initialize Tally class attributes self.id = tally_id self.name = name @@ -172,13 +122,8 @@ class Tally(IDManagerMixin): self._sum = None self._sum_sq = None - self._sum_third = None - self._sum_fourth = None self._mean = None self._std_dev = None - self._vov = None - self._higher_moments = False - self._simulation_time = None self._with_batch_statistics = False self._derived = False self._sparse = False @@ -186,49 +131,6 @@ class Tally(IDManagerMixin): self._sp_filename = None self._results_read = False - if filters is not None: - self.filters = filters - if nuclides is not None: - self.nuclides = nuclides - if scores is not None: - self.scores = scores - if estimator is not None: - self.estimator = estimator - if triggers is not None: - self.triggers = triggers - if derivative is not None: - self.derivative = derivative - - def __eq__(self, other): - if other.id != self.id: - return False - if other.name != self.name: - return False - # estimators are automatically set based on the tally filters and scores - # during OpenMC initialization if this value is None, so it is not - # considered a requirement for equivalence if it is unset on either - # tally as it implies that the user is allowing OpenMC to select an - # appropriate estimator. If the value is explicitly set on both tallies, - # then the values must match for the tallies to be considered equivalent. - if self.estimator is not None and other.estimator is not None and other.estimator != self.estimator: - return False - if other.filters != self.filters: - return False - # for tallies are loaded from statpoint files - # an empty nuclide list is equivalent to a list with 'total' - other_nuclides = other.nuclides.copy() - self_nuclides = self.nuclides.copy() - if 'total' in other_nuclides: - other_nuclides.remove('total') - if 'total' in self_nuclides: - self_nuclides.remove('total') - if other_nuclides != self_nuclides: - return False - for attr in {'scores', 'triggers', 'derivative', 'multiply_density'}: - if getattr(other, attr) != getattr(self, attr): - return False - return True - def __repr__(self): parts = ['Tally'] parts.append('{: <15}=\t{}'.format('ID', self.id)) @@ -244,25 +146,6 @@ class Tally(IDManagerMixin): parts.append('{: <15}=\t{}'.format('Multiply dens.', self.multiply_density)) return '\n\t'.join(parts) - @staticmethod - def ensure_results(f): - """A decorator to be applied to any method that might use tally results. - Results will be loaded if appropriate based on the tally properties. - - Args: - f function: Tally method to wrap - - Returns: - function: Wrapped function that reads tally results before calling - the methodif necessary - """ - @wraps(f) - def read(self): - if self._sp_filename is not None and not self.derived: - self._read_results() - return f(self) - return read - @property def name(self): return self._name @@ -281,15 +164,6 @@ class Tally(IDManagerMixin): cv.check_type('multiply density', value, bool) self._multiply_density = value - @property - def higher_moments(self) -> bool: - return self._higher_moments - - @higher_moments.setter - def higher_moments(self, value): - cv.check_type("higher_moments", value, bool) - self._higher_moments = value - @property def filters(self): return self._filters @@ -311,7 +185,6 @@ class Tally(IDManagerMixin): self._filters = cv.CheckedList(_FILTER_CLASSES, 'tally filters', filters) @property - @ensure_results def nuclides(self): return self._nuclides @@ -334,7 +207,7 @@ class Tally(IDManagerMixin): @property def num_nuclides(self): - return max(len(self._nuclides), 1) + return len(self._nuclides) @property def scores(self): @@ -393,8 +266,7 @@ class Tally(IDManagerMixin): @estimator.setter def estimator(self, estimator): - # allow the estimator to be set to None (let OpenMC choose the estimator at runtime) - cv.check_value('estimator', estimator, ESTIMATOR_TYPES | {None}) + cv.check_value('estimator', estimator, ESTIMATOR_TYPES) self._estimator = estimator @property @@ -408,7 +280,6 @@ class Tally(IDManagerMixin): triggers) @property - @ensure_results def num_realizations(self): return self._num_realizations @@ -433,26 +304,8 @@ class Tally(IDManagerMixin): # Open the HDF5 statepoint file with h5py.File(self._sp_filename, 'r') as f: - # Set number of realizations - group = f[f'tallies/tally {self.id}'] - self._num_realizations = int(group['n_realizations'][()]) - - for filt in self.filters: - if isinstance(filt, DistribcellFilter): - filter_group = f[f'tallies/filters/filter {filt.id}'] - filt._num_bins = int(filter_group['n_bins'][()]) - - # Update nuclides - nuclide_names = group['nuclides'][()] - self._nuclides = [name.decode().strip() for name in nuclide_names] - # Check for higher_moments attribute - if "higher_moments" in group.attrs: - self._higher_moments = bool(group.attrs["higher_moments"][()]) - else: - self._higher_moments = False - # Extract Tally data from the file - data = group['results'] + data = f[f'tallies/tally {self.id}/results'] sum_ = data[:, :, 0] sum_sq = data[:, :, 1] @@ -464,38 +317,22 @@ class Tally(IDManagerMixin): self._sum = sum_ self._sum_sq = sum_sq - if self._higher_moments: - # Extract additional Tally data when higher moments enabled - sum_third = data[:, :, 2] - sum_fourth = data[:, :, 3] - - # Reshape the results arrays - sum_third = np.reshape(sum_third, self.shape) - sum_fourth = np.reshape(sum_fourth, self.shape) - - # Set the additional data for this Tally - self._sum_third = sum_third - self._sum_fourth = sum_fourth - # Convert NumPy arrays to SciPy sparse LIL matrices if self.sparse: - self._sum = lil_array(self._sum.flatten(), self._sum.shape) - self._sum_sq = lil_array(self._sum_sq.flatten(), self._sum_sq.shape) - self._sum_third = lil_array(self._sum_third.flatten(), self._sum_third.shape) - self._sum_fourth = lil_array(self._sum_fourth.flatten(), self._sum_fourth.shape) - - # Read simulation time (needed for figure of merit) - self._simulation_time = f["runtime"]["simulation"][()] + self._sum = sps.lil_matrix(self._sum.flatten(), self._sum.shape) + self._sum_sq = sps.lil_matrix(self._sum_sq.flatten(), self._sum_sq.shape) # Indicate that Tally results have been read self._results_read = True @property - @ensure_results def sum(self): if not self._sp_filename or self.derived: return None + # Make sure results have been read + self._read_results() + if self.sparse: return np.reshape(self._sum.toarray(), self.shape) else: @@ -507,11 +344,13 @@ class Tally(IDManagerMixin): self._sum = sum @property - @ensure_results def sum_sq(self): if not self._sp_filename or self.derived: return None + # Make sure results have been read + self._read_results() + if self.sparse: return np.reshape(self._sum_sq.toarray(), self.shape) else: @@ -522,52 +361,6 @@ class Tally(IDManagerMixin): cv.check_type('sum_sq', sum_sq, Iterable) self._sum_sq = sum_sq - @property - @ensure_results - def sum_third(self): - if not self._higher_moments: - raise ValueError( - "Higher moments have not been enabled for this tally. To make " - "higher moments available, set the higher_moments attribute to " - "True before running a simulation." - ) - - if not self._sp_filename or self.derived: - return None - - if self.sparse: - return np.reshape(self._sum_third.toarray(), self.shape) - else: - return self._sum_third - - @sum_third.setter - def sum_third(self, sum_third): - cv.check_type("sum_third", sum_third, Iterable) - self._sum_third = sum_third - - @property - @ensure_results - def sum_fourth(self): - if not self._higher_moments: - raise ValueError( - "Higher moments have not been enabled for this tally. To make " - "higher moments available, set the higher_moments attribute to " - "True before running a simulation." - ) - - if not self._sp_filename or self.derived: - return None - - if self.sparse: - return np.reshape(self._sum_fourth.toarray(), self.shape) - else: - return self._sum_fourth - - @sum_fourth.setter - def sum_fourth(self, sum_fourth): - cv.check_type("sum_fourth", sum_fourth, Iterable) - self._sum_fourth = sum_fourth - @property def mean(self): if self._mean is None: @@ -578,7 +371,8 @@ class Tally(IDManagerMixin): # Convert NumPy array to SciPy sparse LIL matrix if self.sparse: - self._mean = lil_array(self._mean.flatten(), self._mean.shape) + self._mean = sps.lil_matrix(self._mean.flatten(), + self._mean.shape) if self.sparse: return np.reshape(self._mean.toarray(), self.shape) @@ -599,7 +393,8 @@ class Tally(IDManagerMixin): # Convert NumPy array to SciPy sparse LIL matrix if self.sparse: - self._std_dev = lil_array(self._std_dev.flatten(), self._std_dev.shape) + self._std_dev = sps.lil_matrix(self._std_dev.flatten(), + self._std_dev.shape) self.with_batch_statistics = True @@ -608,359 +403,6 @@ class Tally(IDManagerMixin): else: return self._std_dev - @property - def vov(self): - if self._vov is None: - n = self.num_realizations - sum1 = self.sum - sum2 = self.sum_sq - sum3 = self.sum_third - sum4 = self.sum_fourth - self._vov = np.zeros_like(sum1, dtype=float) - - # Calculate the variance of the variance (Eq. 2.232 in - # https://doi.org/10.2172/2372634) - numerator = (sum4 - (4.0*sum3*sum1)/n - + (6.0*sum2*(sum1**2))/(n**2) - - (3.0*(sum1)**4)/(n**3)) - denominator = (sum2 - (1.0/n)*(sum1**2))**2 - - mask = denominator > 0.0 - - self._vov[mask] = numerator[mask]/denominator[mask] - 1.0/n - - if self.sparse: - self._vov = lil_array(self._vov.flatten(), self._vov.shape) - - if self.sparse: - return np.reshape(self._vov.toarray(), self.shape) - else: - return self._vov - - @property - def m2(self): - n = self.num_realizations - return self.sum_sq/n - self.mean**2 - - @property - def m3(self): - n = self.num_realizations - mean = self.mean - sum2 = self.sum_sq/n - sum3 = self.sum_third/n - - return sum3 - 3.0*mean*sum2 + 2.0*mean**3 - - @property - def m4(self): - n = self.num_realizations - mean = self.mean - sum2 = self.sum_sq/n - sum3 = self.sum_third/n - sum4 = self.sum_fourth/n - - return sum4 - 4.0*mean*sum3 + 6.0*(mean**2)*sum2 - 3.0*mean**4 - - def skew(self, bias=False) -> np.ndarray: - """Return the sample skewness of each tally bin. - - This method computes and returns the unadjusted or adjusted - Fisher-Pearson coefficient of skewness. - - Parameters - ---------- - bias : bool - If False, calculations are corrected for bias and the adjusted - Fisher-Pearson skewness (:math:`G_1`) is returned. If True, - calculations are not corrected for bias and the unadjusted skewness - (:math:`g_1`) is returned. - - Returns - ------- - float - The skewness of each tally bin - """ - n = self.num_realizations - m2 = self.m2 - m3 = self.m3 - - with np.errstate(divide="ignore", invalid="ignore"): - g1 = np.where(m2 > 0.0, m3/(m2**1.5), 0.0) - - if bias: - return g1 - else: - if n <= 2: - raise ValueError("Insufficient number of independent realizations" - f"for bias-corrected skewness: need n >= 3, got {n=}.") - else: - return sqrt(n*(n - 1))/(n - 2)*g1 - - def kurtosis(self, fisher=True, bias=False) -> np.ndarray: - r"""Return the sample kurtosis of each tally bin. - - This method computes and returns the sample kurtosis using either - Pearson's or Fisher's definition, with or without finite-sample bias - correction. The value returned depends on the `bias` and `fisher` - arguments as follows: - - - **bias=True, fisher=False**: Returns :math:`b_2` (Pearson's kurtosis) - This is the raw fourth standardized moment: :math:`m_4/m_2^2`. For a - normal distribution, :math:`b_2\approx 3`. - - - **bias=True, fisher=True**: Returns :math:`g_2` (excess kurtosis) This - is :math:`b_2 - 3`, centered at 0 for normal distributions. Positive - values indicate heavier tails, negative values lighter tails. - - - **bias=False, fisher=True** (default): Returns :math:`G_2` (adjusted - excess kurtosis). This applies finite-sample bias correction to - :math:`g_2`. This is the recommended estimator for statistical - inference. - - - **bias=False, fisher=False**: Returns bias-corrected Pearson's - kurtosis. This is :math:`G_2 + 3`. - - Parameters - ---------- - fisher : bool, optional - If True (default), Fisher's definition is used (excess kurtosis). If - False, Pearson's definition is used. - bias : bool, optional - If False (default), calculations are corrected for statistical bias - using finite-sample adjustments. If True, calculations use the - biased estimator (population formulas). - - Returns - ------- - numpy.ndarray - The kurtosis of each tally bin - - """ - n = self.num_realizations - m2 = self.m2 - m4 = self.m4 - - with np.errstate(divide="ignore", invalid="ignore"): - b2 = np.where(m2 > 0.0, m4/(m2**2), 0.0) - g2 = b2 - 3.0 - - if bias: - # Biased estimator (g2 or b2) - return g2 if fisher else b2 - else: - # Unbiased estimator with finite-sample correction - if n <= 3: - raise ValueError("Insufficient number of independent realizations" - f"for bias-corrected kurtosis: need n >= 4, got {n=}.") - else: - G2 = ((n - 1)/((n - 2)*(n - 3)))*((n + 1)*g2 + 6.0) - return G2 if fisher else G2 + 3.0 - - def skewtest(self, alternative: str = "two-sided"): - """Perform D'Agostino and Pearson's test for skewness. - - This method tests the null hypothesis that the skewness of the - population that the sample was drawn from is the same as that of a - corresponding normal distribution. - - Parameters - ---------- - alternative : {'two-sided', 'less', 'greater'}, optional - Defines the alternative hypothesis. The following options are - available: - - * 'two-sided': the skewness of the distribution is different from - that of the normal distribution (i.e., non-zero) - * 'less': the skewness of the distribution is less than that of the - normal distribution - * 'greater': the skewness of the distribution is greater than that - of the normal distribution - - Returns - ------- - statistic : np.ndarray - The computed z-score for the skewness test for each tally bin - pvalue : np.ndarray - The p-value for the hypothesis test for each tally bin - - Notes - ----- - This test is based on `D'Agostino and Pearson's test - `_. The test requires at least - 8 realizations to produce valid results. - - """ - n = self.num_realizations - if n < 8: - raise ValueError("Skewness test is not well-defined for n < 8.") - - g1 = self.skew(bias=True) - - # --- Z1 (skewness) --- - y = g1 * sqrt(((n + 1.0)*(n + 3.0))/(6.0*(n - 2.0))) - beta2 = (3.0*(n**2 + 27.0*n - 70.0)*(n + 1.0)*(n + 3.0) - )/((n - 2.0)*(n + 5.0)*(n + 7.0)*(n + 9.0)) - W2 = -1.0 + sqrt(2.0*(beta2 - 1.0)) - delta = 1.0 / sqrt(log(sqrt(W2))) - alpha = sqrt(2.0 / (W2 - 1.0)) - Zb1 = np.where( - y >= 0.0, - delta*np.log((y/alpha) + np.sqrt((y/alpha)**2 + 1.0)), - -delta*np.log((-y/alpha) + np.sqrt((y/alpha)**2 + 1.0)) - ) - - # p-value - if alternative == "two-sided": - p = 2.0 * (1.0 - norm.cdf(np.abs(Zb1))) - elif alternative == "greater": - p = 1.0 - norm.cdf(Zb1) - elif alternative == "less": - p = norm.cdf(Zb1) - else: - raise ValueError("alternative must be 'two-sided', 'greater', or 'less'") - - return Zb1, p - - def kurtosistest(self, alternative: str = "two-sided"): - """Perform D'Agostino and Pearson's test for kurtosis. - - This method tests the null hypothesis that the kurtosis of the - population that the sample was drawn from is the same as that of a - corresponding normal distribution. - - Parameters - ---------- - alternative : {'two-sided', 'less', 'greater'}, optional - Defines the alternative hypothesis. Default is 'two-sided'. The - following options are available: - - * 'two-sided': the kurtosis of the distribution is different from - that of the normal distribution - * 'less': the kurtosis of the distribution is less than that of the - normal distribution - * 'greater': the kurtosis of the distribution is greater than that - of the normal distribution - - Returns - ------- - statistic : np.ndarray - The computed z-score for the kurtosis test for each tally bin - pvalue : np.ndarray - The p-value for the hypothesis test for each tally bin - - Raises - ------ - ValueError - If the number of realizations is less than 20, or if an invalid - alternative hypothesis is specified. - - Notes - ----- - This test is based on `D'Agostino and Pearson's test - `_. The test is typically - recommended for at least 20 realizations to produce valid results. - - """ - n = self.num_realizations - if n < 20: - raise ValueError("Kurtosis test is typically recommended for n >= 20.") - - b2 = self.kurtosis(bias=True, fisher=False) - - # --- Z2 (kurtosis) --- - mean_b2 = 3.0 * (n - 1.0) / (n + 1.0) - var_b2 = (24.0*n*(n - 2.0)*(n - 3.0)/( - (n + 1.0)**2*(n + 3.0)*(n + 5.0))) - x = (b2 - mean_b2)/np.sqrt(var_b2) - moment = ((6.0*(n**2 - 5.0*n + 2.0))/((n + 7.0)*(n + 9.0)) - )*sqrt((6.0*(n + 3.0)*(n + 5.0))/(n*(n - 2.0)*(n - 3.0))) - A = 6.0 + (8.0/moment)*((2.0/moment) + sqrt(1.0 + 4.0/(moment**2))) - Zb2 = (1.0- 2.0/(9.0*A) - ((1.0 - 2.0/A) / (1.0 + (x - )*sqrt(2.0/(A - 4.0))))**(1.0/3.0)) / sqrt(2.0/(9.0*A)) - - # p-value - if alternative == "two-sided": - p = 2.0 * (1.0 - norm.cdf(np.abs(Zb2))) - elif alternative == "greater": - p = 1.0 - norm.cdf(Zb2) - elif alternative == "less": - p = norm.cdf(Zb2) - else: - raise ValueError("alternative must be 'two-sided', 'greater', or 'less'") - - return Zb2, p - - def normaltest(self, alternative: str = "two-sided"): - """Perform D'Agostino and Pearson's omnibus test for normality. - - This method tests the null hypothesis that a sample comes from a normal - distribution. It combines skewness and kurtosis to produce an omnibus - test of normality. - - Parameters - ---------- - alternative : {'two-sided', 'less', 'greater'}, optional - Defines the alternative hypothesis used for the component skewness - and kurtosis tests. Default is 'two-sided'. The following options - are available: - - * 'two-sided': the distribution is different from normal - * 'less': used for the component tests - * 'greater': used for the component tests - - Returns - ------- - statistic : np.ndarray - The computed z-score for the normality test for each tally bin - pvalue : np.ndarray - The p-value for the hypothesis test for each tally bin - - Raises - ------ - ValueError - If the number of realizations is less than 20, or if an invalid - alternative hypothesis is specified. - - Notes - ----- - This test combines a test for skewness and a test for kurtosis to - produce an `omnibus test `_. - The test statistic is: - - .. math:: - - K^2 = Z_1^2 + Z_2^2 - - where :math:`Z_1` is the z-score from the skewness test and :math:`Z_2` - is the z-score from the kurtosis test. This statistic follows a - chi-square distribution with 2 degrees of freedom. - - The test requires at least 20 realizations to produce valid results. - - """ - n = self.num_realizations - if n < 20: - raise ValueError("normaltest requires n >= 20 (per D'Agostino-Pearson).") - - # Use the component tests - Z1, _ = self.skewtest(alternative) - Z2, _ = self.kurtosistest(alternative) - - # Combine as chi-square with df=2 since we have skewness and kurtosis - K2 = Z1*Z1 + Z2*Z2 - p = chi2.sf(K2, df=2) - return K2, p - - @property - def figure_of_merit(self): - mean = self.mean - std_dev = self.std_dev - fom = np.zeros_like(mean) - nonzero = np.abs(mean) > 0 - rel_err = std_dev[nonzero] / mean[nonzero] - fom[nonzero] = 1.0 / (rel_err**2 * self._simulation_time) - return fom - @property def with_batch_statistics(self): return self._with_batch_statistics @@ -1005,17 +447,16 @@ class Tally(IDManagerMixin): # Convert NumPy arrays to SciPy sparse LIL matrices if sparse and not self.sparse: if self._sum is not None: - self._sum = lil_array(self._sum.flatten(), self._sum.shape) + self._sum = sps.lil_matrix(self._sum.flatten(), self._sum.shape) if self._sum_sq is not None: - self._sum_sq = lil_array(self._sum_sq.flatten(), self._sum_sq.shape) - if self._sum_third is not None: - self._sum_third = lil_array(self._sum_third.flatten(), self._sum_third.shape) - if self._sum_fourth is not None: - self._sum_fourth = lil_array(self._sum_fourth.flatten(), self._sum_fourth.shape) + self._sum_sq = sps.lil_matrix(self._sum_sq.flatten(), + self._sum_sq.shape) if self._mean is not None: - self._mean = lil_array(self._mean.flatten(), self._mean.shape) + self._mean = sps.lil_matrix(self._mean.flatten(), + self._mean.shape) if self._std_dev is not None: - self._std_dev = lil_array(self._std_dev.flatten(), self._std_dev.shape) + self._std_dev = sps.lil_matrix(self._std_dev.flatten(), + self._std_dev.shape) self._sparse = True @@ -1025,10 +466,6 @@ class Tally(IDManagerMixin): self._sum = np.reshape(self._sum.toarray(), self.shape) if self._sum_sq is not None: self._sum_sq = np.reshape(self._sum_sq.toarray(), self.shape) - if self._sum_third is not None: - self._sum_third = np.reshape(self._sum_third.toarray(), self.shape) - if self._sum_fourth is not None: - self._sum_fourth = np.reshape(self._sum_fourth.toarray(), self.shape) if self._mean is not None: self._mean = np.reshape(self._mean.toarray(), self.shape) if self._std_dev is not None: @@ -1074,7 +511,7 @@ class Tally(IDManagerMixin): Parameters ---------- - nuclide : str + nuclide : openmc.Nuclide Nuclide to remove """ @@ -1106,8 +543,8 @@ class Tally(IDManagerMixin): return False # Return False if only one tally has a delayed group filter - tally1_dg = self.contains_filter(DelayedGroupFilter) - tally2_dg = other.contains_filter(DelayedGroupFilter) + tally1_dg = self.contains_filter(openmc.DelayedGroupFilter) + tally2_dg = other.contains_filter(openmc.DelayedGroupFilter) if tally1_dg != tally2_dg: return False @@ -1355,34 +792,6 @@ class Tally(IDManagerMixin): merged_tally._sum_sq = np.reshape(merged_sum_sq, merged_tally.shape) - # Concatenate sum_third arrays if present in both tallies - if self._sum_third is not None and other._sum_third is not None: - self_sum_third = self.get_reshaped_data(value="sum_third") - other_sum_third = other_copy.get_reshaped_data(value="sum_third") - - if join_right: - merged_sum_third = np.concatenate((self_sum_third, other_sum_third), - axis=merge_axis) - else: - merged_sum_third = np.concatenate((other_sum_third, self_sum_third), - axis=merge_axis) - - merged_tally._sum_third = np.reshape(merged_sum_third, merged_tally.shape) - - # Concatenate sum_fourth arrays if present in both tallies - if self._sum_fourth is not None and other._sum_fourth is not None: - self_sum_fourth = self.get_reshaped_data(value="sum_fourth") - other_sum_fourth = other_copy.get_reshaped_data(value="sum_fourth") - - if join_right: - merged_sum_fourth = np.concatenate((self_sum_fourth, other_sum_fourth), - axis=merge_axis) - else: - merged_sum_fourth = np.concatenate((other_sum_fourth, self_sum_fourth), - axis=merge_axis) - - merged_tally._sum_fourth = np.reshape(merged_sum_fourth, merged_tally.shape) - # Concatenate mean arrays if present in both tallies if self.mean is not None and other.mean is not None: self_mean = self.get_reshaped_data(value='mean') @@ -1472,46 +881,8 @@ class Tally(IDManagerMixin): subelement = ET.SubElement(element, "derivative") subelement.text = str(self.derivative.id) - # Optional higher moments accumulation - if self.higher_moments: - subelement = ET.SubElement(element, "higher_moments") - subelement.text = str(self.higher_moments).lower() - return element - def add_results(self, statepoint: cv.PathLike | openmc.StatePoint): - """Add results from the provided statepoint file to this tally instance - - .. versionadded:: 0.15.1 - - Parameters - ---------- - statepoint : openmc.PathLike or openmc.StatePoint - Statepoint used to update tally results - """ - # derived tallies are populated with data based on combined tallies - # and should not be modified - if self.derived: - return - - if isinstance(statepoint, openmc.StatePoint): - self._sp_filename = Path(statepoint._f.filename) - else: - self._sp_filename = Path(str(statepoint)) - - # reset these properties to ensure that any results access after this - # point are based on the current statepoint file - self._sum = None - self._sum_sq = None - self._sum_third = None - self._sum_fourth = None - self._mean = None - self._std_dev = None - self._vov = None - self._higher_moments = False - self._num_realizations = 0 - self._results_read = False - @classmethod def from_xml_element(cls, elem, **kwargs): """Generate tally object from an XML element @@ -1529,8 +900,8 @@ class Tally(IDManagerMixin): Tally object """ - tally_id = int(get_text(elem, "id")) - name = get_text(elem, "name", "") + tally_id = int(elem.get('id')) + name = elem.get('name', '') tally = cls(tally_id=tally_id, name=name) text = get_text(elem, 'multiply_density') @@ -1538,24 +909,25 @@ class Tally(IDManagerMixin): tally.multiply_density = text in ('true', '1') # Read filters - filter_ids = get_elem_list(elem, "filters", int) - if filter_ids is not None: + filters_elem = elem.find('filters') + if filters_elem is not None: + filter_ids = [int(x) for x in filters_elem.text.split()] tally.filters = [kwargs['filters'][uid] for uid in filter_ids] # Read nuclides - nuclides = get_elem_list(elem, "nuclides", str) - if nuclides is not None: - tally.nuclides = nuclides + nuclides_elem = elem.find('nuclides') + if nuclides_elem is not None: + tally.nuclides = nuclides_elem.text.split() # Read scores - scores = get_elem_list(elem, "scores", str) - if scores is not None: - tally.scores = scores + scores_elem = elem.find('scores') + if scores_elem is not None: + tally.scores = scores_elem.text.split() # Set estimator - estimator = get_text(elem, "estimator") - if estimator is not None: - tally.estimator = estimator + estimator_elem = elem.find('estimator') + if estimator_elem is not None: + tally.estimator = estimator_elem.text # Read triggers tally.triggers = [ @@ -1564,9 +936,9 @@ class Tally(IDManagerMixin): ] # Read tally derivative - deriv = get_text(elem, "derivative") - if deriv is not None: - deriv_id = int(deriv) + deriv_elem = elem.find('derivative') + if deriv_elem is not None: + deriv_id = int(deriv_elem.text) tally.derivative = kwargs['derivatives'][deriv_id] return tally @@ -1619,7 +991,7 @@ class Tally(IDManagerMixin): # Also check to see if the desired filter is wrapped up in an # aggregate - elif isinstance(test_filter, AggregateFilter): + elif isinstance(test_filter, openmc.AggregateFilter): if isinstance(test_filter.aggregate_filter, filter_type): return test_filter @@ -1648,10 +1020,17 @@ class Tally(IDManagerMixin): in the Tally. """ - # Look for the user-requested nuclide in all of the Tally's nuclides + # Look for the user-requested nuclide in all of the Tally's Nuclides for i, test_nuclide in enumerate(self.nuclides): - if test_nuclide == nuclide: - return i + # If the Summary was linked, then values are Nuclide objects + if isinstance(test_nuclide, openmc.Nuclide): + if test_nuclide.name == nuclide: + return i + + # If the Summary has not been linked, then values are ZAIDs + else: + if test_nuclide == nuclide: + return i msg = (f'Unable to get the nuclide index for Tally since "{nuclide}" ' 'is not one of the nuclides') @@ -1721,7 +1100,7 @@ class Tally(IDManagerMixin): """ - cv.check_type('filters', filters, Iterable, FilterMeta) + cv.check_type('filters', filters, Iterable, openmc.FilterMeta) cv.check_type('filter_bins', filter_bins, Iterable, tuple) # If user did not specify any specific Filters, use them all @@ -1804,7 +1183,7 @@ class Tally(IDManagerMixin): """ for score in scores: - if not isinstance(score, (str, CrossScore)): + if not isinstance(score, (str, openmc.CrossScore)): msg = f'Unable to get score indices for score "{score}" in ' \ f'ID="{self.id}" since it is not a string or CrossScore ' \ 'Tally' @@ -1878,9 +1257,7 @@ class Tally(IDManagerMixin): (value == 'std_dev' and self.std_dev is None) or \ (value == 'rel_err' and self.mean is None) or \ (value == 'sum' and self.sum is None) or \ - (value == 'sum_sq' and self.sum_sq is None) or \ - (value == "sum_third" and self.sum_third is None) or \ - (value == "sum_fourth" and self.sum_fourth is None): + (value == 'sum_sq' and self.sum_sq is None): msg = f'The Tally ID="{self.id}" has no data to return' raise ValueError(msg) @@ -1903,14 +1280,10 @@ class Tally(IDManagerMixin): data = self.sum[indices] elif value == 'sum_sq': data = self.sum_sq[indices] - elif value == "sum_third": - data = self.sum_third[indices] - elif value == "sum_fourth": - data = self.sum_fourth[indices] else: msg = f'Unable to return results from Tally ID="{value}" since ' \ f'the requested value "{self.id}" is not \'mean\', ' \ - '\'std_dev\', \'rel_err\', \'sum\', \'sum_sq\', \'sum_third\' or \'sum_fourth\'' + '\'std_dev\', \'rel_err\', \'sum\', or \'sum_sq\'' raise LookupError(msg) return data @@ -1984,7 +1357,9 @@ class Tally(IDManagerMixin): column_name = 'nuclide' for nuclide in self.nuclides: - if isinstance(nuclide, openmc.AggregateNuclide): + if isinstance(nuclide, openmc.Nuclide): + nuclides.append(nuclide.name) + elif isinstance(nuclide, openmc.AggregateNuclide): nuclides.append(nuclide.name) column_name = f'{nuclide.aggregate_op}(nuclide)' else: @@ -2001,9 +1376,9 @@ class Tally(IDManagerMixin): column_name = 'score' for score in self.scores: - if isinstance(score, (str, CrossScore)): + if isinstance(score, (str, openmc.CrossScore)): scores.append(str(score)) - elif isinstance(score, AggregateScore): + elif isinstance(score, openmc.AggregateScore): scores.append(score.name) column_name = f'{score.aggregate_op}(score)' @@ -2026,7 +1401,7 @@ class Tally(IDManagerMixin): # Expand the columns into Pandas MultiIndices for readability if pd.__version__ >= '0.16': - columns = copy.deepcopy(list(df.columns.values)) + columns = copy.deepcopy(df.columns.values) # Convert all elements in columns list to tuples for i, column in enumerate(columns): @@ -2048,7 +1423,7 @@ class Tally(IDManagerMixin): df.columns = pd.MultiIndex.from_tuples(columns) # Modify the df.to_string method so that it prints formatted strings. - # Credit to https://stackoverflow.com/users/3657742/chrisb for this trick + # Credit to http://stackoverflow.com/users/3657742/chrisb for this trick df.to_string = partial(df.to_string, float_format=float_format.format) return df @@ -2103,7 +1478,7 @@ class Tally(IDManagerMixin): for i, f in enumerate(self.filters): if expand_dims: # Mesh filter indices are backwards so we need to flip them - if type(f) in {MeshFilter, MeshBornFilter}: + if isinstance(f, openmc.MeshFilter): fshape = f.shape[::-1] new_shape += fshape idx0, idx1 = i, i + len(fshape) - 1 @@ -2290,7 +1665,7 @@ class Tally(IDManagerMixin): else: all_filters = [self_copy.filters, other_copy.filters] for self_filter, other_filter in product(*all_filters): - new_filter = CrossFilter(self_filter, other_filter, + new_filter = openmc.CrossFilter(self_filter, other_filter, binary_op) new_tally.filters.append(new_filter) @@ -2301,7 +1676,7 @@ class Tally(IDManagerMixin): else: all_nuclides = [self_copy.nuclides, other_copy.nuclides] for self_nuclide, other_nuclide in product(*all_nuclides): - new_nuclide = CrossNuclide(self_nuclide, other_nuclide, + new_nuclide = openmc.CrossNuclide(self_nuclide, other_nuclide, binary_op) new_tally.nuclides.append(new_nuclide) @@ -2312,9 +1687,9 @@ class Tally(IDManagerMixin): if score1 == score2: return score1 else: - return CrossScore(score1, score2, binary_op) + return openmc.CrossScore(score1, score2, binary_op) else: - return CrossScore(score1, score2, binary_op) + return openmc.CrossScore(score1, score2, binary_op) # Add scores to the new tally if score_product == 'entrywise': @@ -2523,16 +1898,16 @@ class Tally(IDManagerMixin): # Construct lists of tuples for the bins in each of the two filters filters = [type(filter1), type(filter2)] - if isinstance(filter1, DistribcellFilter): + if isinstance(filter1, openmc.DistribcellFilter): filter1_bins = [b for b in range(filter1.num_bins)] - elif isinstance(filter1, EnergyFunctionFilter): + elif isinstance(filter1, openmc.EnergyFunctionFilter): filter1_bins = [None] else: filter1_bins = filter1.bins - if isinstance(filter2, DistribcellFilter): + if isinstance(filter2, openmc.DistribcellFilter): filter2_bins = [b for b in range(filter2.num_bins)] - elif isinstance(filter2, EnergyFunctionFilter): + elif isinstance(filter2, openmc.EnergyFunctionFilter): filter2_bins = [None] else: filter2_bins = filter2.bins @@ -2665,11 +2040,11 @@ class Tally(IDManagerMixin): raise ValueError(msg) # Check that the scores are valid - if not isinstance(score1, (str, CrossScore)): + if not isinstance(score1, (str, openmc.CrossScore)): msg = 'Unable to swap score1 "{}" in Tally ID="{}" since it is ' \ 'not a string or CrossScore'.format(score1, self.id) raise ValueError(msg) - elif not isinstance(score2, (str, CrossScore)): + elif not isinstance(score2, (str, openmc.CrossScore)): msg = 'Unable to swap score2 "{}" in Tally ID="{}" since it is ' \ 'not a string or CrossScore'.format(score2, self.id) raise ValueError(msg) @@ -2975,8 +2350,7 @@ class Tally(IDManagerMixin): new_tally.name = self.name new_tally._mean = self.mean / other new_tally._std_dev = self.std_dev * np.abs(1. / other) - if self.estimator is not None: - new_tally.estimator = self.estimator + new_tally.estimator = self.estimator new_tally.with_summary = self.with_summary new_tally.num_realizations = self.num_realizations @@ -3240,16 +2614,6 @@ class Tally(IDManagerMixin): new_sum_sq = self.get_values(scores, filters, filter_bins, nuclides, 'sum_sq') new_tally.sum_sq = new_sum_sq - if not self.derived and self._sum_third is not None: - new_sum_third = self.get_values( - scores, filters, filter_bins, nuclides, "sum_third" - ) - new_tally._sum_third = new_sum_third - if not self.derived and self._sum_fourth is not None: - new_sum_fourth = self.get_values( - scores, filters, filter_bins, nuclides, "sum_fourth" - ) - new_tally._sum_fourth = new_sum_fourth if self.mean is not None: new_mean = self.get_values(scores, filters, filter_bins, nuclides, 'mean') @@ -3279,8 +2643,8 @@ class Tally(IDManagerMixin): # Determine the nuclide indices from any of the requested nuclides for nuclide in self.nuclides: - if nuclide not in nuclides: - nuclide_index = self.get_nuclide_index(nuclide) + if nuclide.name not in nuclides: + nuclide_index = self.get_nuclide_index(nuclide.name) nuclide_indices.append(nuclide_index) # Loop over indices in reverse to remove excluded Nuclides @@ -3313,7 +2677,7 @@ class Tally(IDManagerMixin): new_filter.bins = [f.bins[i] for i in bin_indices] # Set number of bins manually for mesh/distribcell filters - if filter_type is DistribcellFilter: + if filter_type is openmc.DistribcellFilter: new_filter._num_bins = f._num_bins # Replace existing filter with new one @@ -3379,16 +2743,16 @@ class Tally(IDManagerMixin): std_dev = self.get_reshaped_data(value='std_dev') # Sum across any filter bins specified by the user - if isinstance(filter_type, FilterMeta): + if isinstance(filter_type, openmc.FilterMeta): find_filter = self.find_filter(filter_type) # If user did not specify filter bins, sum across all bins if len(filter_bins) == 0: bin_indices = np.arange(find_filter.num_bins) - if isinstance(find_filter, DistribcellFilter): + if isinstance(find_filter, openmc.DistribcellFilter): filter_bins = np.arange(find_filter.num_bins) - elif isinstance(find_filter, EnergyFunctionFilter): + elif isinstance(find_filter, openmc.EnergyFunctionFilter): filter_bins = [None] else: filter_bins = find_filter.bins @@ -3417,7 +2781,7 @@ class Tally(IDManagerMixin): # Add AggregateFilter to the tally sum if not remove_filter: - filter_sum = AggregateFilter(self_filter, + filter_sum = openmc.AggregateFilter(self_filter, [tuple(filter_bins)], 'sum') tally_sum.filters.append(filter_sum) @@ -3440,7 +2804,7 @@ class Tally(IDManagerMixin): std_dev = np.sqrt(std_dev) # Add AggregateNuclide to the tally sum - nuclide_sum = AggregateNuclide(nuclides, 'sum') + nuclide_sum = openmc.AggregateNuclide(nuclides, 'sum') tally_sum.nuclides.append(nuclide_sum) # Add a copy of this tally's nuclides to the tally sum @@ -3458,7 +2822,7 @@ class Tally(IDManagerMixin): std_dev = np.sqrt(std_dev) # Add AggregateScore to the tally sum - score_sum = AggregateScore(scores, 'sum') + score_sum = openmc.AggregateScore(scores, 'sum') tally_sum.scores.append(score_sum) # Add a copy of this tally's scores to the tally sum @@ -3531,16 +2895,16 @@ class Tally(IDManagerMixin): std_dev = self.get_reshaped_data(value='std_dev') # Average across any filter bins specified by the user - if isinstance(filter_type, FilterMeta): + if isinstance(filter_type, openmc.FilterMeta): find_filter = self.find_filter(filter_type) # If user did not specify filter bins, average across all bins if len(filter_bins) == 0: bin_indices = np.arange(find_filter.num_bins) - if isinstance(find_filter, DistribcellFilter): + if isinstance(find_filter, openmc.DistribcellFilter): filter_bins = np.arange(find_filter.num_bins) - elif isinstance(find_filter, EnergyFunctionFilter): + elif isinstance(find_filter, openmc.EnergyFunctionFilter): filter_bins = [None] else: filter_bins = find_filter.bins @@ -3570,7 +2934,7 @@ class Tally(IDManagerMixin): # Add AggregateFilter to the tally avg if not remove_filter: - filter_sum = AggregateFilter(self_filter, + filter_sum = openmc.AggregateFilter(self_filter, [tuple(filter_bins)], 'avg') tally_avg.filters.append(filter_sum) @@ -3594,7 +2958,7 @@ class Tally(IDManagerMixin): std_dev = np.sqrt(std_dev) # Add AggregateNuclide to the tally avg - nuclide_avg = AggregateNuclide(nuclides, 'avg') + nuclide_avg = openmc.AggregateNuclide(nuclides, 'avg') tally_avg.nuclides.append(nuclide_avg) # Add a copy of this tally's nuclides to the tally avg @@ -3613,7 +2977,7 @@ class Tally(IDManagerMixin): std_dev = np.sqrt(std_dev) # Add AggregateScore to the tally avg - score_sum = AggregateScore(scores, 'avg') + score_sum = openmc.AggregateScore(scores, 'avg') tally_avg.scores.append(score_sum) # Add a copy of this tally's scores to the tally avg @@ -3690,12 +3054,6 @@ class Tally(IDManagerMixin): if not self.derived and self.sum_sq is not None: new_tally._sum_sq = np.zeros(new_tally.shape, dtype=np.float64) new_tally._sum_sq[diag_indices, :, :] = self.sum_sq - if not self.derived and self._sum_third is not None: - new_tally._sum_third = np.zeros(new_tally.shape, dtype=np.float64) - new_tally._sum_third[diag_indices, :, :] = self.sum_third - if not self.derived and self._sum_fourth is not None: - new_tally._sum_fourth = np.zeros(new_tally.shape, dtype=np.float64) - new_tally._sum_fourth[diag_indices, :, :] = self.sum_fourth if self.mean is not None: new_tally._mean = np.zeros(new_tally.shape, dtype=np.float64) new_tally._mean[diag_indices, :, :] = self.mean @@ -3746,17 +3104,43 @@ class Tallies(cv.CheckedList): if possible. Defaults to False. """ + if not isinstance(tally, Tally): + msg = f'Unable to add a non-Tally "{tally}" to the Tallies instance' + raise TypeError(msg) + if merge: + merged = False + # Look for a tally to merge with this one for i, tally2 in enumerate(self): + # If a mergeable tally is found if tally2.can_merge(tally): # Replace tally2 with the merged tally merged_tally = tally2.merge(tally) self[i] = merged_tally - return + merged = True + break - super().append(tally) + # If no mergeable tally was found, simply add this tally + if not merged: + super().append(tally) + + else: + super().append(tally) + + def insert(self, index, item): + """Insert tally before index + + Parameters + ---------- + index : int + Index in list + item : openmc.Tally + Tally to insert + + """ + super().insert(index, item) def merge_tallies(self): """Merge any mergeable tallies together. Note that n-way merges are @@ -3782,19 +3166,6 @@ class Tallies(cv.CheckedList): # Continue iterating from the first loop break - def add_results(self, statepoint: cv.PathLike | openmc.StatePoint): - """Add results from the provided statepoint file - - .. versionadded:: 0.15.1 - - Parameters - ---------- - statepoint : openmc.PathLike or openmc.StatePoint - Statepoint used to update tally results - """ - for tally in self: - tally.add_results(statepoint) - def _create_tally_subelements(self, root_element): for tally in self: root_element.append(tally.to_xml_element()) @@ -3803,7 +3174,7 @@ class Tallies(cv.CheckedList): already_written = memo if memo else set() for tally in self: for f in tally.filters: - if isinstance(f, MeshFilter): + if isinstance(f, openmc.MeshFilter): if f.mesh.id in already_written: continue if len(f.mesh.name) > 0: @@ -3847,6 +3218,7 @@ class Tallies(cv.CheckedList): # Clean the indentation in the file to be user-readable clean_indentation(element) + reorder_attributes(element) # TODO: Remove when support is Python 3.8+ return element @@ -3898,7 +3270,7 @@ class Tallies(cv.CheckedList): # Read filter elements filters = {} for e in elem.findall('filter'): - filter = Filter.from_xml_element(e, meshes=meshes) + filter = openmc.Filter.from_xml_element(e, meshes=meshes) filters[filter.id] = filter # Read derivative elements diff --git a/openmc/tally_derivative.py b/openmc/tally_derivative.py index f7ba5dce5..ff918c1b3 100644 --- a/openmc/tally_derivative.py +++ b/openmc/tally_derivative.py @@ -4,7 +4,6 @@ import lxml.etree as ET import openmc.checkvalue as cv from .mixin import EqualityMixin, IDManagerMixin -from ._xml import get_text class TallyDerivative(EqualityMixin, IDManagerMixin): @@ -123,8 +122,8 @@ class TallyDerivative(EqualityMixin, IDManagerMixin): Tally derivative object """ - derivative_id = int(get_text(elem, "id")) - variable = get_text(elem, "variable") - material = int(get_text(elem, "material")) - nuclide = get_text(elem, "nuclide") if variable == "nuclide_density" else None + derivative_id = int(elem.get("id")) + variable = elem.get("variable") + material = int(elem.get("material")) + nuclide = elem.get("nuclide") if variable == "nuclide_density" else None return cls(derivative_id, variable, material, nuclide) diff --git a/openmc/tracks.py b/openmc/tracks.py index 44e3c0eba..61e5a7244 100644 --- a/openmc/tracks.py +++ b/openmc/tracks.py @@ -4,8 +4,7 @@ from collections.abc import Sequence import h5py from .checkvalue import check_filetype_version -from .particle_type import ParticleType -from .source import SourceParticle +from .source import SourceParticle, ParticleType from pathlib import Path @@ -26,7 +25,7 @@ states : numpy.ndarray """ def _particle_track_repr(self): - return f"" + return f"" ParticleTrack.__repr__ = _particle_track_repr @@ -93,8 +92,8 @@ class Track(Sequence): Parameters ---------- - particle : str or int or openmc.ParticleType - Matching particle type (name, PDG number, or type) + particle : {'neutron', 'photon', 'electron', 'positron'} + Matching particle type state_filter : function Function that takes a state (structured datatype) and returns a bool depending on some criteria. @@ -127,7 +126,7 @@ class Track(Sequence): for t in self: # Check for matching particle if particle is not None: - if t.particle != ParticleType(particle): + if t.particle.name.lower() != particle: continue # Apply arbitrary state filter @@ -185,7 +184,7 @@ class Track(Sequence): def sources(self): sources = [] for particle_track in self: - particle_type = particle_track.particle + particle_type = ParticleType(particle_track.particle) state = particle_track.states[0] sources.append( SourceParticle( @@ -297,16 +296,16 @@ class Tracks(list): for state in pt.states: points.InsertNextPoint(state['r']) - # Create VTK line and assign points to line. - n = pt.states.size - line = vtk.vtkPolyLine() - line.GetPointIds().SetNumberOfIds(n) - for i in range(n): - line.GetPointIds().SetId(i, point_offset + i) - point_offset += n + # Create VTK line and assign points to line. + n = pt.states.size + line = vtk.vtkPolyLine() + line.GetPointIds().SetNumberOfIds(n) + for i in range(n): + line.GetPointIds().SetId(i, point_offset + i) + point_offset += n - # Add line to cell array - cells.InsertNextCell(line) + # Add line to cell array + cells.InsertNextCell(line) data = vtk.vtkPolyData() data.SetPoints(points) diff --git a/openmc/trigger.py b/openmc/trigger.py index 70b6b7a03..be2537e3a 100644 --- a/openmc/trigger.py +++ b/openmc/trigger.py @@ -5,7 +5,6 @@ import lxml.etree as ET import openmc.checkvalue as cv from .mixin import EqualityMixin -from ._xml import get_elem_list, get_text class Trigger(EqualityMixin): @@ -130,16 +129,16 @@ class Trigger(EqualityMixin): """ # Generate trigger object - trigger_type = get_text(elem, "type") - threshold = float(get_text(elem, "threshold")) - ignore_zeros = str(get_text(elem, "ignore_zeros", "false")).lower() + trigger_type = elem.get("type") + threshold = float(elem.get("threshold")) + ignore_zeros = str(elem.get("ignore_zeros", "false")).lower() # Try to convert to bool. Let Trigger error out on instantiation. ignore_zeros = ignore_zeros in ('true', '1') trigger = cls(trigger_type, threshold, ignore_zeros) # Add scores if present - scores = get_elem_list(elem, "scores", str) + scores = elem.get("scores") if scores is not None: - trigger.scores = scores + trigger.scores = scores.split() return trigger diff --git a/openmc/universe.py b/openmc/universe.py index 0e64693ba..9fab9ae51 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -1,14 +1,21 @@ -from __future__ import annotations +import math from abc import ABC, abstractmethod from collections.abc import Iterable -from numbers import Real +from numbers import Integral, Real +from pathlib import Path +from tempfile import TemporaryDirectory +import warnings +import h5py +import lxml.etree as ET import numpy as np import openmc import openmc.checkvalue as cv +from ._xml import get_text +from .checkvalue import check_type, check_value from .mixin import IDManagerMixin -from .plots import add_plot_params +from .surface import _BOUNDARY_TYPES class UniverseBase(ABC, IDManagerMixin): @@ -46,10 +53,6 @@ class UniverseBase(ABC, IDManagerMixin): def name(self): return self._name - @property - def cells(self): - return self._cells - @name.setter def name(self, name): if name is not None: @@ -130,48 +133,418 @@ class UniverseBase(ABC, IDManagerMixin): """ - def _determine_paths(self, path='', instances_only=False): - """Count the number of instances for each cell in the universe, and - record the count in the :attr:`Cell.num_instances` properties.""" + @abstractmethod + def _partial_deepcopy(self): + """Deepcopy all parameters of an openmc.UniverseBase object except its cells. + This should only be used from the openmc.UniverseBase.clone() context. - univ_path = path + f'u{self.id}' + """ - for cell in self.cells.values(): - cell_path = f'{univ_path}->c{cell.id}' - fill = cell._fill - fill_type = cell.fill_type + def clone(self, clone_materials=True, clone_regions=True, memo=None): + """Create a copy of this universe with a new unique ID, and clones + all cells within this universe. - # If universe-filled, recursively count cells in filling universe - if fill_type == 'universe': - fill._determine_paths(cell_path + '->', instances_only) - # If lattice-filled, recursively call for all universes in lattice - elif fill_type == 'lattice': - latt = fill + Parameters + ---------- + clone_materials : bool + Whether to create separates copies of the materials filling cells + contained in this universe. + clone_regions : bool + Whether to create separates copies of the regions bounding cells + contained in this universe. + memo : dict or None + A nested dictionary of previously cloned objects. This parameter + is used internally and should not be specified by the user. - # Count instances in each universe in the lattice - for index in latt._natural_indices: - latt_path = '{}->l{}({})->'.format( - cell_path, latt.id, ",".join(str(x) for x in index)) - univ = latt.get_universe(index) - univ._determine_paths(latt_path, instances_only) + Returns + ------- + clone : openmc.Universe + The clone of this universe - else: - if fill_type == 'material': - mat = fill - elif fill_type == 'distribmat': - mat = fill[cell._num_instances] + """ + if memo is None: + memo = {} + + # If no memoize'd clone exists, instantiate one + if self not in memo: + clone = self._partial_deepcopy() + + # Clone all cells for the universe clone + clone._cells = {} + for cell in self._cells.values(): + clone.add_cell(cell.clone(clone_materials, clone_regions, + memo)) + + # Memoize the clone + memo[self] = clone + + return memo[self] + + +class Universe(UniverseBase): + """A collection of cells that can be repeated. + + Parameters + ---------- + universe_id : int, optional + Unique identifier of the universe. If not specified, an identifier will + automatically be assigned + name : str, optional + Name of the universe. If not specified, the name is the empty string. + cells : Iterable of openmc.Cell, optional + Cells to add to the universe. By default no cells are added. + + Attributes + ---------- + id : int + Unique identifier of the universe + name : str + Name of the universe + cells : dict + Dictionary whose keys are cell IDs and values are :class:`Cell` + instances + volume : float + Volume of the universe in cm^3. This can either be set manually or + calculated in a stochastic volume calculation and added via the + :meth:`Universe.add_volume_information` method. + bounding_box : openmc.BoundingBox + Lower-left and upper-right coordinates of an axis-aligned bounding box + of the universe. + + """ + + def __init__(self, universe_id=None, name='', cells=None): + super().__init__(universe_id, name) + + if cells is not None: + self.add_cells(cells) + + def __repr__(self): + string = super().__repr__() + string += '{: <16}=\t{}\n'.format('\tGeom', 'CSG') + string += '{: <16}=\t{}\n'.format('\tCells', list(self._cells.keys())) + return string + + @property + def cells(self): + return self._cells + + @property + def bounding_box(self): + regions = [c.region for c in self.cells.values() + if c.region is not None] + if regions: + return openmc.Union(regions).bounding_box + else: + return openmc.BoundingBox.infinite() + + @classmethod + def from_hdf5(cls, group, cells): + """Create universe from HDF5 group + + Parameters + ---------- + group : h5py.Group + Group in HDF5 file + cells : dict + Dictionary mapping cell IDs to instances of :class:`openmc.Cell`. + + Returns + ------- + openmc.Universe + Universe instance + + """ + universe_id = int(group.name.split('/')[-1].lstrip('universe ')) + cell_ids = group['cells'][()] + + # Create this Universe + universe = cls(universe_id) + + # Add each Cell to the Universe + for cell_id in cell_ids: + universe.add_cell(cells[cell_id]) + + return universe + + def find(self, point): + """Find cells/universes/lattices which contain a given point + + Parameters + ---------- + point : 3-tuple of float + Cartesian coordinates of the point + + Returns + ------- + list + Sequence of universes, cells, and lattices which are traversed to + find the given point + + """ + p = np.asarray(point) + for cell in self._cells.values(): + if p in cell: + if cell.fill_type in ('material', 'distribmat', 'void'): + return [self, cell] + elif cell.fill_type == 'universe': + if cell.translation is not None: + p -= cell.translation + if cell.rotation is not None: + p[:] = cell.rotation_matrix.dot(p) + return [self, cell] + cell.fill.find(p) else: - mat = None + return [self, cell] + cell.fill.find(p) + return [] - if mat is not None: - mat._num_instances += 1 - if not instances_only: - mat._paths.append(f'{cell_path}->m{mat.id}') + # default kwargs that are passed to plt.legend in the plot method below. + _default_legend_kwargs = {'bbox_to_anchor': ( + 1.05, 1), 'loc': 2, 'borderaxespad': 0.0} - # Append current path - cell._num_instances += 1 - if not instances_only: - cell._paths.append(cell_path) + def plot(self, origin=None, width=None, pixels=40000, + basis='xy', color_by='cell', colors=None, seed=None, + openmc_exec='openmc', axes=None, legend=False, axis_units='cm', + legend_kwargs=_default_legend_kwargs, outline=False, + **kwargs): + """Display a slice plot of the universe. + + Parameters + ---------- + origin : iterable of float + Coordinates at the origin of the plot. If left as None, + universe.bounding_box.center will be used to attempt to ascertain + the origin with infinite values being replaced by 0. + width : iterable of float + Width of the plot in each basis direction. If left as none then the + universe.bounding_box.width() will be used to attempt to + ascertain the plot width. Defaults to (10, 10) if the bounding_box + contains inf values + pixels : Iterable of int or int + If iterable of ints provided then this directly sets the number of + pixels to use in each basis direction. If int provided then this + sets the total number of pixels in the plot and the number of + pixels in each basis direction is calculated from this total and + the image aspect ratio. + basis : {'xy', 'xz', 'yz'} + The basis directions for the plot + color_by : {'cell', 'material'} + Indicate whether the plot should be colored by cell or by material + colors : dict + Assigns colors to specific materials or cells. Keys are instances of + :class:`Cell` or :class:`Material` and values are RGB 3-tuples, RGBA + 4-tuples, or strings indicating SVG color names. Red, green, blue, + and alpha should all be floats in the range [0.0, 1.0], for example: + + .. code-block:: python + + # Make water blue + water = openmc.Cell(fill=h2o) + universe.plot(..., colors={water: (0., 0., 1.)) + seed : int + Seed for the random number generator + openmc_exec : str + Path to OpenMC executable. + axes : matplotlib.Axes + Axes to draw to + + .. versionadded:: 0.13.1 + legend : bool + Whether a legend showing material or cell names should be drawn + + .. versionadded:: 0.14.0 + legend_kwargs : dict + Keyword arguments passed to :func:`matplotlib.pyplot.legend`. + + .. versionadded:: 0.14.0 + outline : bool + Whether outlines between color boundaries should be drawn + + .. versionadded:: 0.14.0 + axis_units : {'km', 'm', 'cm', 'mm'} + Units used on the plot axis + + .. versionadded:: 0.14.0 + **kwargs + Keyword arguments passed to :func:`matplotlib.pyplot.imshow` + + Returns + ------- + matplotlib.axes.Axes + Axes containing resulting image + + """ + import matplotlib.image as mpimg + import matplotlib.patches as mpatches + import matplotlib.pyplot as plt + + # Determine extents of plot + if basis == 'xy': + x, y = 0, 1 + xlabel, ylabel = f'x [{axis_units}]', f'y [{axis_units}]' + elif basis == 'yz': + x, y = 1, 2 + xlabel, ylabel = f'y [{axis_units}]', f'z [{axis_units}]' + elif basis == 'xz': + x, y = 0, 2 + xlabel, ylabel = f'x [{axis_units}]', f'z [{axis_units}]' + + bb = self.bounding_box + # checks to see if bounding box contains -inf or inf values + if np.isinf(bb.extent[basis]).any(): + if origin is None: + origin = (0, 0, 0) + if width is None: + width = (10, 10) + else: + if origin is None: + # if nan values in the bb.center they get replaced with 0.0 + # this happens when the bounding_box contains inf values + with warnings.catch_warnings(): + warnings.simplefilter("ignore", RuntimeWarning) + origin = np.nan_to_num(bb.center) + if width is None: + bb_width = bb.width + x_width = bb_width['xyz'.index(basis[0])] + y_width = bb_width['xyz'.index(basis[1])] + width = (x_width, y_width) + + if isinstance(pixels, int): + aspect_ratio = width[0] / width[1] + pixels_y = math.sqrt(pixels / aspect_ratio) + pixels = (int(pixels / pixels_y), int(pixels_y)) + + axis_scaling_factor = {'km': 0.00001, 'm': 0.01, 'cm': 1, 'mm': 10} + + x_min = (origin[x] - 0.5*width[0]) * axis_scaling_factor[axis_units] + x_max = (origin[x] + 0.5*width[0]) * axis_scaling_factor[axis_units] + y_min = (origin[y] - 0.5*width[1]) * axis_scaling_factor[axis_units] + y_max = (origin[y] + 0.5*width[1]) * axis_scaling_factor[axis_units] + + with TemporaryDirectory() as tmpdir: + model = openmc.Model() + model.geometry = openmc.Geometry(self) + if seed is not None: + model.settings.plot_seed = seed + + # Determine whether any materials contains macroscopic data and if + # so, set energy mode accordingly + for mat in self.get_all_materials().values(): + if mat._macroscopic is not None: + model.settings.energy_mode = 'multi-group' + break + + # Create plot object matching passed arguments + plot = openmc.Plot() + plot.origin = origin + plot.width = width + plot.pixels = pixels + plot.basis = basis + plot.color_by = color_by + if colors is not None: + plot.colors = colors + model.plots.append(plot) + + # Run OpenMC in geometry plotting mode + model.plot_geometry(False, cwd=tmpdir, openmc_exec=openmc_exec) + + # Read image from file + img_path = Path(tmpdir) / f'plot_{plot.id}.png' + if not img_path.is_file(): + img_path = img_path.with_suffix('.ppm') + img = mpimg.imread(str(img_path)) + + # Create a figure sized such that the size of the axes within + # exactly matches the number of pixels specified + if axes is None: + px = 1/plt.rcParams['figure.dpi'] + fig, axes = plt.subplots() + axes.set_xlabel(xlabel) + axes.set_ylabel(ylabel) + params = fig.subplotpars + width = pixels[0]*px/(params.right - params.left) + height = pixels[1]*px/(params.top - params.bottom) + fig.set_size_inches(width, height) + + if outline: + # Combine R, G, B values into a single int + rgb = (img * 256).astype(int) + image_value = (rgb[..., 0] << 16) + \ + (rgb[..., 1] << 8) + (rgb[..., 2]) + + axes.contour( + image_value, + origin="upper", + colors="k", + linestyles="solid", + linewidths=1, + levels=np.unique(image_value), + extent=(x_min, x_max, y_min, y_max), + ) + + # add legend showing which colors represent which material + # or cell if that was requested + if legend: + if plot.colors == {}: + raise ValueError("Must pass 'colors' dictionary if you " + "are adding a legend via legend=True.") + + if color_by == "cell": + expected_key_type = openmc.Cell + else: + expected_key_type = openmc.Material + + patches = [] + for key, color in plot.colors.items(): + + if isinstance(key, int): + raise TypeError( + "Cannot use IDs in colors dict for auto legend.") + elif not isinstance(key, expected_key_type): + raise TypeError( + "Color dict key type does not match color_by") + + # this works whether we're doing cells or materials + label = key.name if key.name != '' else key.id + + # matplotlib takes RGB on 0-1 scale rather than 0-255. at + # this point PlotBase has already checked that 3-tuple + # based colors are already valid, so if the length is three + # then we know it just needs to be converted to the 0-1 + # format. + if len(color) == 3 and not isinstance(color, str): + scaled_color = ( + color[0]/255, color[1]/255, color[2]/255) + else: + scaled_color = color + + key_patch = mpatches.Patch(color=scaled_color, label=label) + patches.append(key_patch) + + axes.legend(handles=patches, **legend_kwargs) + + # Plot image and return the axes + axes.imshow(img, extent=(x_min, x_max, y_min, y_max), **kwargs) + return axes + + def add_cell(self, cell): + """Add a cell to the universe. + + Parameters + ---------- + cell : openmc.Cell + Cell to add + + """ + + if not isinstance(cell, openmc.Cell): + msg = f'Unable to add a Cell to Universe ID="{self._id}" since ' \ + f'"{cell}" is not a Cell' + raise TypeError(msg) + + cell_id = cell.id + + if cell_id not in self._cells: + self._cells[cell_id] = cell def add_cells(self, cells): """Add multiple cells to the universe. @@ -191,19 +564,76 @@ class UniverseBase(ABC, IDManagerMixin): for cell in cells: self.add_cell(cell) - @abstractmethod - def add_cell(self, cell): - pass - - @abstractmethod def remove_cell(self, cell): - pass + """Remove a cell from the universe. + + Parameters + ---------- + cell : openmc.Cell + Cell to remove + + """ + + if not isinstance(cell, openmc.Cell): + msg = f'Unable to remove a Cell from Universe ID="{self._id}" ' \ + f'since "{cell}" is not a Cell' + raise TypeError(msg) + + # If the Cell is in the Universe's list of Cells, delete it + self._cells.pop(cell.id, None) def clear_cells(self): """Remove all cells from the universe.""" self._cells.clear() + def get_nuclides(self): + """Returns all nuclides in the universe + + Returns + ------- + nuclides : list of str + List of nuclide names + + """ + + nuclides = [] + + # Append all Nuclides in each Cell in the Universe to the dictionary + for cell in self.cells.values(): + for nuclide in cell.get_nuclides(): + if nuclide not in nuclides: + nuclides.append(nuclide) + + return nuclides + + def get_nuclide_densities(self): + """Return all nuclides contained in the universe + + Returns + ------- + nuclides : dict + Dictionary whose keys are nuclide names and values are 2-tuples of + (nuclide, density) + + """ + nuclides = {} + + if self._atoms: + volume = self.volume + for name, atoms in self._atoms.items(): + nuclide = openmc.Nuclide(name) + density = 1.0e-24 * atoms.n/volume # density in atoms/b-cm + nuclides[name] = (nuclide, density) + else: + raise RuntimeError( + 'Volume information is needed to calculate microscopic cross ' + f'sections for universe {self.id}. This can be done by running ' + 'a stochastic volume calculation via the ' + 'openmc.VolumeCalculation object') + + return nuclides + def get_all_cells(self, memo=None): """Return all cells that are contained within the universe @@ -254,260 +684,6 @@ class UniverseBase(ABC, IDManagerMixin): return materials - @abstractmethod - def _partial_deepcopy(self): - """Deepcopy all parameters of an openmc.UniverseBase object except its cells. - This should only be used from the openmc.UniverseBase.clone() context. - - """ - - def clone(self, clone_materials=True, clone_regions=True, memo=None): - """Create a copy of this universe with a new unique ID, and clones - all cells within this universe. - - Parameters - ---------- - clone_materials : bool - Whether to create separates copies of the materials filling cells - contained in this universe. - clone_regions : bool - Whether to create separates copies of the regions bounding cells - contained in this universe. - memo : dict or None - A nested dictionary of previously cloned objects. This parameter - is used internally and should not be specified by the user. - - Returns - ------- - clone : openmc.Universe - The clone of this universe - - """ - if memo is None: - memo = {} - - # If no memoize'd clone exists, instantiate one - if self not in memo: - clone = self._partial_deepcopy() - - # Clone all cells for the universe clone - clone._cells = {} - for cell in self._cells.values(): - clone.add_cell(cell.clone(clone_materials, clone_regions, - memo)) - - # Memoize the clone - memo[self] = clone - - return memo[self] - - def find(self, point): - """Find cells/universes/lattices which contain a given point - - Parameters - ---------- - point : 3-tuple of float - Cartesian coordinates of the point - - Returns - ------- - list - Sequence of universes, cells, and lattices which are traversed to - find the given point - - """ - p = np.asarray(point) - for cell in self._cells.values(): - if p in cell: - if cell.fill_type in ('material', 'distribmat', 'void'): - return [self, cell] - elif cell.fill_type == 'universe': - if cell.translation is not None: - p -= cell.translation - if cell.rotation is not None: - p[:] = cell.rotation_matrix.dot(p) - return [self, cell] + cell.fill.find(p) - else: - return [self, cell] + cell.fill.find(p) - return [] - - @add_plot_params - def plot(self, *args, **kwargs): - """Display a slice plot of the universe. - """ - model = openmc.Model() - model.geometry = openmc.Geometry(self) - return model.plot(*args, **kwargs) - - def get_nuclides(self): - """Returns all nuclides in the universe - - Returns - ------- - nuclides : list of str - List of nuclide names - - """ - - nuclides = [] - - # Append all Nuclides in each Cell in the Universe to the dictionary - for cell in self.cells.values(): - for nuclide in cell.get_nuclides(): - if nuclide not in nuclides: - nuclides.append(nuclide) - - return nuclides - - def get_nuclide_densities(self): - """Return all nuclides contained in the universe - - Returns - ------- - nuclides : dict - Dictionary whose keys are nuclide names and values are 2-tuples of - (nuclide, density) - - """ - nuclides = {} - - if self._atoms: - volume = self.volume - for name, atoms in self._atoms.items(): - density = 1.0e-24 * atoms.n/volume # density in atoms/b-cm - nuclides[name] = (name, density) - else: - raise RuntimeError( - 'Volume information is needed to calculate microscopic cross ' - f'sections for universe {self.id}. This can be done by running ' - 'a stochastic volume calculation via the ' - 'openmc.VolumeCalculation object') - - return nuclides - - - -class Universe(UniverseBase): - """A collection of cells that can be repeated. - - Parameters - ---------- - universe_id : int, optional - Unique identifier of the universe. If not specified, an identifier will - automatically be assigned - name : str, optional - Name of the universe. If not specified, the name is the empty string. - cells : Iterable of openmc.Cell, optional - Cells to add to the universe. By default no cells are added. - - Attributes - ---------- - id : int - Unique identifier of the universe - name : str - Name of the universe - cells : dict - Dictionary whose keys are cell IDs and values are :class:`Cell` - instances - volume : float - Volume of the universe in cm^3. This can either be set manually or - calculated in a stochastic volume calculation and added via the - :meth:`Universe.add_volume_information` method. - bounding_box : openmc.BoundingBox - Lower-left and upper-right coordinates of an axis-aligned bounding box - of the universe. - - """ - - def __init__(self, universe_id=None, name='', cells=None): - super().__init__(universe_id, name) - - if cells is not None: - self.add_cells(cells) - - def __repr__(self): - string = super().__repr__() - string += '{: <16}=\t{}\n'.format('\tGeom', 'CSG') - string += '{: <16}=\t{}\n'.format('\tCells', list(self._cells.keys())) - return string - - @property - def bounding_box(self) -> openmc.BoundingBox: - regions = [c.region for c in self.cells.values() - if c.region is not None] - if regions: - return openmc.Union(regions).bounding_box - else: - return openmc.BoundingBox.infinite() - - @classmethod - def from_hdf5(cls, group, cells): - """Create universe from HDF5 group - - Parameters - ---------- - group : h5py.Group - Group in HDF5 file - cells : dict - Dictionary mapping cell IDs to instances of :class:`openmc.Cell`. - - Returns - ------- - openmc.Universe - Universe instance - - """ - universe_id = int(group.name.split('/')[-1].lstrip('universe ')) - cell_ids = group['cells'][()] - - # Create this Universe - universe = cls(universe_id) - - # Add each Cell to the Universe - for cell_id in cell_ids: - universe.add_cell(cells[cell_id]) - - return universe - - - def add_cell(self, cell): - """Add a cell to the universe. - - Parameters - ---------- - cell : openmc.Cell - Cell to add - - """ - - if not isinstance(cell, openmc.Cell): - msg = f'Unable to add a Cell to Universe ID="{self._id}" since ' \ - f'"{cell}" is not a Cell' - raise TypeError(msg) - - cell_id = cell.id - - if cell_id not in self._cells: - self._cells[cell_id] = cell - - def remove_cell(self, cell): - """Remove a cell from the universe. - - Parameters - ---------- - cell : openmc.Cell - Cell to remove - - """ - - if not isinstance(cell, openmc.Cell): - msg = f'Unable to remove a Cell from Universe ID="{self._id}" ' \ - f'since "{cell}" is not a Cell' - raise TypeError(msg) - - # If the Cell is in the Universe's list of Cells, delete it - self._cells.pop(cell.id, None) - def create_xml_subelement(self, xml_element, memo=None): if memo is None: memo = set() @@ -528,6 +704,50 @@ class Universe(UniverseBase): cell_element.set("universe", str(self._id)) xml_element.append(cell_element) + def _determine_paths(self, path='', instances_only=False): + """Count the number of instances for each cell in the universe, and + record the count in the :attr:`Cell.num_instances` properties.""" + + univ_path = path + f'u{self.id}' + + for cell in self.cells.values(): + cell_path = f'{univ_path}->c{cell.id}' + fill = cell._fill + fill_type = cell.fill_type + + # If universe-filled, recursively count cells in filling universe + if fill_type == 'universe': + fill._determine_paths(cell_path + '->', instances_only) + + # If lattice-filled, recursively call for all universes in lattice + elif fill_type == 'lattice': + latt = fill + + # Count instances in each universe in the lattice + for index in latt._natural_indices: + latt_path = '{}->l{}({})->'.format( + cell_path, latt.id, ",".join(str(x) for x in index)) + univ = latt.get_universe(index) + univ._determine_paths(latt_path, instances_only) + + else: + if fill_type == 'material': + mat = fill + elif fill_type == 'distribmat': + mat = fill[cell._num_instances] + else: + mat = None + + if mat is not None: + mat._num_instances += 1 + if not instances_only: + mat._paths.append(f'{cell_path}->m{mat.id}') + + # Append current path + cell._num_instances += 1 + if not instances_only: + cell._paths.append(cell_path) + def _partial_deepcopy(self): """Clone all of the openmc.Universe object's attributes except for its cells, as they are copied within the clone function. This should only to be @@ -536,3 +756,364 @@ class Universe(UniverseBase): clone = openmc.Universe(name=self.name) clone.volume = self.volume return clone + + +class DAGMCUniverse(UniverseBase): + """A reference to a DAGMC file to be used in the model. + + .. versionadded:: 0.13.0 + + Parameters + ---------- + filename : str + Path to the DAGMC file used to represent this universe. + universe_id : int, optional + Unique identifier of the universe. If not specified, an identifier will + automatically be assigned. + name : str, optional + Name of the universe. If not specified, the name is the empty string. + auto_geom_ids : bool + Set IDs automatically on initialization (True) or report overlaps in ID + space between CSG and DAGMC (False) + auto_mat_ids : bool + Set IDs automatically on initialization (True) or report overlaps in ID + space between OpenMC and UWUW materials (False) + + Attributes + ---------- + id : int + Unique identifier of the universe + name : str + Name of the universe + filename : str + Path to the DAGMC file used to represent this universe. + auto_geom_ids : bool + Set IDs automatically on initialization (True) or report overlaps in ID + space between CSG and DAGMC (False) + auto_mat_ids : bool + Set IDs automatically on initialization (True) or report overlaps in ID + space between OpenMC and UWUW materials (False) + bounding_box : openmc.BoundingBox + Lower-left and upper-right coordinates of an axis-aligned bounding box + of the universe. + + .. versionadded:: 0.13.1 + material_names : list of str + Return a sorted list of materials names that are contained within the + DAGMC h5m file. This is useful when naming openmc.Material() objects + as each material name present in the DAGMC h5m file must have a + matching openmc.Material() with the same name. + + .. versionadded:: 0.13.2 + n_cells : int + The number of cells in the DAGMC model. This is the number of cells at + runtime and accounts for the implicit complement whether or not is it + present in the DAGMC file. + + .. versionadded:: 0.13.2 + n_surfaces : int + The number of surfaces in the model. + + .. versionadded:: 0.13.2 + + """ + + def __init__(self, + filename, + universe_id=None, + name='', + auto_geom_ids=False, + auto_mat_ids=False): + super().__init__(universe_id, name) + # Initialize class attributes + self.filename = filename + self.auto_geom_ids = auto_geom_ids + self.auto_mat_ids = auto_mat_ids + + def __repr__(self): + string = super().__repr__() + string += '{: <16}=\t{}\n'.format('\tGeom', 'DAGMC') + string += '{: <16}=\t{}\n'.format('\tFile', self.filename) + return string + + @property + def bounding_box(self): + with h5py.File(self.filename) as dagmc_file: + coords = dagmc_file['tstt']['nodes']['coordinates'][()] + lower_left_corner = coords.min(axis=0) + upper_right_corner = coords.max(axis=0) + return openmc.BoundingBox(lower_left_corner, upper_right_corner) + + @property + def filename(self): + return self._filename + + @filename.setter + def filename(self, val): + cv.check_type('DAGMC filename', val, (Path, str)) + self._filename = val + + @property + def auto_geom_ids(self): + return self._auto_geom_ids + + @auto_geom_ids.setter + def auto_geom_ids(self, val): + cv.check_type('DAGMC automatic geometry ids', val, bool) + self._auto_geom_ids = val + + @property + def auto_mat_ids(self): + return self._auto_mat_ids + + @auto_mat_ids.setter + def auto_mat_ids(self, val): + cv.check_type('DAGMC automatic material ids', val, bool) + self._auto_mat_ids = val + + @property + def material_names(self): + dagmc_file_contents = h5py.File(self.filename) + material_tags_hex = dagmc_file_contents['/tstt/tags/NAME'].get( + 'values') + material_tags_ascii = [] + for tag in material_tags_hex: + candidate_tag = tag.tobytes().decode().replace('\x00', '') + # tags might be for temperature or reflective surfaces + if candidate_tag.startswith('mat:'): + # removes first 4 characters as openmc.Material name should be + # set without the 'mat:' part of the tag + material_tags_ascii.append(candidate_tag[4:]) + + return sorted(set(material_tags_ascii)) + + def get_all_cells(self, memo=None): + return {} + + def get_all_materials(self, memo=None): + return {} + + def _n_geom_elements(self, geom_type): + """ + Helper function for retrieving the number geometric entities in a DAGMC + file + + Parameters + ---------- + geom_type : str + The type of geometric entity to count. One of {'Volume', 'Surface'}. Returns + the runtime number of voumes in the DAGMC model (includes implicit complement). + + Returns + ------- + int + Number of geometry elements of the specified type + """ + cv.check_value('geometry type', geom_type, ('volume', 'surface')) + + def decode_str_tag(tag_val): + return tag_val.tobytes().decode().replace('\x00', '') + + dagmc_filepath = Path(self.filename).resolve() + with h5py.File(dagmc_filepath) as dagmc_file: + category_data = dagmc_file['tstt/tags/CATEGORY/values'] + category_strs = map(decode_str_tag, category_data) + n = sum([v == geom_type.capitalize() for v in category_strs]) + + # check for presence of an implicit complement in the file and + # increment the number of cells if it doesn't exist + if geom_type == 'volume': + name_data = dagmc_file['tstt/tags/NAME/values'] + name_strs = map(decode_str_tag, name_data) + if not sum(['impl_complement' in n for n in name_strs]): + n += 1 + return n + + @property + def n_cells(self): + return self._n_geom_elements('volume') + + @property + def n_surfaces(self): + return self._n_geom_elements('surface') + + def create_xml_subelement(self, xml_element, memo=None): + if memo is None: + memo = set() + + if self in memo: + return + + memo.add(self) + + # Set xml element values + dagmc_element = ET.Element('dagmc_universe') + dagmc_element.set('id', str(self.id)) + + if self.auto_geom_ids: + dagmc_element.set('auto_geom_ids', 'true') + if self.auto_mat_ids: + dagmc_element.set('auto_mat_ids', 'true') + dagmc_element.set('filename', str(self.filename)) + xml_element.append(dagmc_element) + + def bounding_region( + self, + bounded_type: str = 'box', + boundary_type: str = 'vacuum', + starting_id: int = 10000, + padding_distance: float = 0. + ): + """Creates a either a spherical or box shaped bounding region around + the DAGMC geometry. + + .. versionadded:: 0.13.1 + + Parameters + ---------- + bounded_type : str + The type of bounding surface(s) to use when constructing the region. + Options include a single spherical surface (sphere) or a rectangle + made from six planes (box). + boundary_type : str + Boundary condition that defines the behavior for particles hitting + the surface. Defaults to vacuum boundary condition. Passed into the + surface construction. + starting_id : int + Starting ID of the surface(s) used in the region. For bounded_type + 'box', the next 5 IDs will also be used. Defaults to 10000 to reduce + the chance of an overlap of surface IDs with the DAGMC geometry. + padding_distance : float + Distance between the bounding region surfaces and the minimal + bounding box. Allows for the region to be larger than the DAGMC + geometry. + + Returns + ------- + openmc.Region + Region instance + """ + + check_type('boundary type', boundary_type, str) + check_value('boundary type', boundary_type, _BOUNDARY_TYPES) + check_type('starting surface id', starting_id, Integral) + check_type('bounded type', bounded_type, str) + check_value('bounded type', bounded_type, ('box', 'sphere')) + + bbox = self.bounding_box.expand(padding_distance, True) + + if bounded_type == 'sphere': + radius = np.linalg.norm(bbox.upper_right - bbox.center) + bounding_surface = openmc.Sphere( + surface_id=starting_id, + x0=bbox.center[0], + y0=bbox.center[1], + z0=bbox.center[2], + boundary_type=boundary_type, + r=radius, + ) + + return -bounding_surface + + if bounded_type == 'box': + # defines plane surfaces for all six faces of the bounding box + lower_x = openmc.XPlane(bbox[0][0], surface_id=starting_id) + upper_x = openmc.XPlane(bbox[1][0], surface_id=starting_id+1) + lower_y = openmc.YPlane(bbox[0][1], surface_id=starting_id+2) + upper_y = openmc.YPlane(bbox[1][1], surface_id=starting_id+3) + lower_z = openmc.ZPlane(bbox[0][2], surface_id=starting_id+4) + upper_z = openmc.ZPlane(bbox[1][2], surface_id=starting_id+5) + + region = +lower_x & -upper_x & +lower_y & -upper_y & +lower_z & -upper_z + + for surface in region.get_surfaces().values(): + surface.boundary_type = boundary_type + + return region + + def bounded_universe(self, bounding_cell_id=10000, **kwargs): + """Returns an openmc.Universe filled with this DAGMCUniverse and bounded + with a cell. Defaults to a box cell with a vacuum surface however this + can be changed using the kwargs which are passed directly to + DAGMCUniverse.bounding_region(). + + Parameters + ---------- + bounding_cell_id : int + The cell ID number to use for the bounding cell, defaults to 10000 to reduce + the chance of overlapping ID numbers with the DAGMC geometry. + + Returns + ------- + openmc.Universe + Universe instance + """ + bounding_cell = openmc.Cell( + fill=self, cell_id=bounding_cell_id, region=self.bounding_region(**kwargs)) + return openmc.Universe(cells=[bounding_cell]) + + @classmethod + def from_hdf5(cls, group): + """Create DAGMC universe from HDF5 group + + Parameters + ---------- + group : h5py.Group + Group in HDF5 file + + Returns + ------- + openmc.DAGMCUniverse + DAGMCUniverse instance + + """ + id = int(group.name.split('/')[-1].lstrip('universe ')) + fname = group['filename'][()].decode() + name = group['name'][()].decode() if 'name' in group else None + + out = cls(fname, universe_id=id, name=name) + + out.auto_geom_ids = bool(group.attrs['auto_geom_ids']) + out.auto_mat_ids = bool(group.attrs['auto_mat_ids']) + + return out + + @classmethod + def from_xml_element(cls, elem): + """Generate DAGMC universe from XML element + + Parameters + ---------- + elem : lxml.etree._Element + `` element + + Returns + ------- + openmc.DAGMCUniverse + DAGMCUniverse instance + + """ + id = int(get_text(elem, 'id')) + fname = get_text(elem, 'filename') + + out = cls(fname, universe_id=id) + + name = get_text(elem, 'name') + if name is not None: + out.name = name + + out.auto_geom_ids = bool(elem.get('auto_geom_ids')) + out.auto_mat_ids = bool(elem.get('auto_mat_ids')) + + return out + + def _partial_deepcopy(self): + """Clone all of the openmc.DAGMCUniverse object's attributes except for + its cells, as they are copied within the clone function. This should + only to be used within the openmc.UniverseBase.clone() context. + """ + clone = openmc.DAGMCUniverse(name=self.name, filename=self.filename) + clone.volume = self.volume + clone.auto_geom_ids = self.auto_geom_ids + clone.auto_mat_ids = self.auto_mat_ids + return clone diff --git a/openmc/utility_funcs.py b/openmc/utility_funcs.py index 935a58985..4eb307c93 100644 --- a/openmc/utility_funcs.py +++ b/openmc/utility_funcs.py @@ -2,15 +2,12 @@ from contextlib import contextmanager import os from pathlib import Path from tempfile import TemporaryDirectory +from typing import Optional -import h5py - -import openmc from .checkvalue import PathLike - @contextmanager -def change_directory(working_dir: PathLike | None = None, *, tmpdir: bool = False): +def change_directory(working_dir: Optional[PathLike] = None, *, tmpdir: bool = False): """Context manager for executing in a provided working directory Parameters @@ -39,40 +36,3 @@ def change_directory(working_dir: PathLike | None = None, *, tmpdir: bool = Fals os.chdir(orig_dir) if tmpdir: tmp.cleanup() - - -def input_path(filename: PathLike) -> Path: - """Return a path object for an input file based on global configuration - - Parameters - ---------- - filename : PathLike - Path to input file - - Returns - ------- - pathlib.Path - Path object - - """ - if openmc.config['resolve_paths']: - return Path(filename).resolve() - else: - return Path(filename) - - -@contextmanager -def h5py_file_or_group(group_or_filename: PathLike | h5py.Group, *args, **kwargs): - """Context manager for opening an HDF5 file or using an existing group - - Parameters - ---------- - group_or_filename : path-like or h5py.Group - Path to HDF5 file, or group from an existing HDF5 file - - """ - if isinstance(group_or_filename, h5py.Group): - yield group_or_filename - else: - with h5py.File(group_or_filename, *args, **kwargs) as f: - yield f diff --git a/openmc/volume.py b/openmc/volume.py index c44adf98a..df19def1e 100644 --- a/openmc/volume.py +++ b/openmc/volume.py @@ -10,7 +10,7 @@ from uncertainties import ufloat import openmc import openmc.checkvalue as cv -from openmc._xml import get_elem_list, get_text +from openmc._xml import get_text _VERSION_VOLUME = 1 @@ -375,10 +375,13 @@ class VolumeCalculation: """ domain_type = get_text(elem, "domain_type") - ids = get_elem_list(elem, "domain_ids", int) + domain_ids = get_text(elem, "domain_ids").split() + ids = [int(x) for x in domain_ids] samples = int(get_text(elem, "samples")) - lower_left = tuple(get_elem_list(elem, "lower_left", float)) - upper_right = tuple(get_elem_list(elem, "upper_right", float)) + lower_left = get_text(elem, "lower_left").split() + lower_left = tuple([float(x) for x in lower_left]) + upper_right = get_text(elem, "upper_right").split() + upper_right = tuple([float(x) for x in upper_right]) # Instantiate some throw-away domains that are used by the constructor # to assign IDs diff --git a/openmc/waste.py b/openmc/waste.py deleted file mode 100644 index 80cfc0adc..000000000 --- a/openmc/waste.py +++ /dev/null @@ -1,286 +0,0 @@ -from __future__ import annotations - -import openmc -from openmc.data import half_life - - -def _waste_classification(mat: openmc.Material, metal: bool = True) -> str: - """Classify a material for near-surface waste disposal. - - This method determines a waste classification for a material based on the - NRC regulations (10 CFR 61.55). - - Parameters - ---------- - mat : openmc.Material - The material to classify. - metal : bool, optional - Whether or not the material is in metal form. This changes the - acceptable limits in Tables 1 and 2 for certain nuclides. - - Returns - ------- - str - The waste disposal classification, which can be "Class A", "Class B", - "Class C", or "GTCC" (greater than class C). - - """ - # Determine metrics based on Tables 1 and 2 using sum of fractions rule for - # mixture of radionuclides from §61.55(a)(7) - ratio1 = _waste_disposal_rating(mat, 'NRC_long', metal=metal) - ratio2 = [ - _waste_disposal_rating(mat, 'NRC_short_A', metal=metal), - _waste_disposal_rating(mat, 'NRC_short_B', metal=metal), - _waste_disposal_rating(mat, 'NRC_short_C', metal=metal), - ] - - # Determine which nuclides are present in Table 1 and Table 2 - table1_nuclides_present = (ratio1 > 0.0) - table2_nuclides_present = any(x > 0.0 for x in ratio2) - - # Helper function for classifying based on Table 2 - def classify_table2(col1, col2, col3): - if col1 < 1.0: - return "Class A" - elif col2 < 1.0: - return "Class B" - elif col3 < 1.0: - return "Class C" - else: - return "GTCC" - - if table1_nuclides_present and table2_nuclides_present: - # Classification based on §61.55(a)(5) - if ratio1 < 0.1: - return classify_table2(*ratio2) - elif ratio1 < 1.0: - return "Class C" if ratio2[2] < 1.0 else "GTCC" - else: - return "GTCC" - - elif table1_nuclides_present: - # Classification based on §61.55(a)(3) - if ratio1 < 0.1: - return "Class A" - elif ratio1 < 1.0: - return "Class C" - else: - return "GTCC" - - elif table2_nuclides_present: - # Classification based on §61.55(a)(4) - return classify_table2(*ratio2) - - else: - # Classification based on §61.55(a)(6) - return "Class A" - - -def _waste_disposal_rating( - mat: openmc.Material, - limits: str | dict[str, float] = 'Fetter', - metal: bool = False, - by_nuclide: bool = False, -) -> float | dict[str, float]: - """Return the waste disposal rating for a material. - - This method returns a waste disposal rating for the material based on a set - of specific activity limits. The waste disposal rating is a single number - that represents the sum of the ratios of the specific activity for each - radionuclide in the material against a nuclide-specific limit. A value less - than 1.0 indicates that the material "meets" the limits whereas a value - greater than 1.0 exceeds the limits. - - Parameters - ---------- - mat : openmc.Material - The material to classify. - limits : str or dict, optional - The name of a predefined set of specific activity limits or a dictionary - that contains specific activity limits for radionuclides, where keys are - nuclide names and values are activities in units of [Ci/m3]. The - predefined options are: - - - 'Fetter': Uses limits from Fetter et al. (1990) - - 'NRC_long': Uses the 10 CFR 61.55 limits for long-lived radionuclides - - 'NRC_short_A': Uses the 10 CFR 61.55 class A limits for short-lived - radionuclides - - 'NRC_short_B': Uses the 10 CFR 61.55 class B limits for short-lived - radionuclides - - 'NRC_short_C': Uses the 10 CFR 61.55 class C limits for short-lived - radionuclides - metal : bool, optional - Whether or not the material is in metal form (only applicable for NRC - based limits) - by_nuclide : bool, optional - Whether to return the waste disposal rating for each nuclide in the - material. If True, a dictionary is returned where the keys are the - nuclide names and the values are the waste disposal ratings for each - nuclide. If False, a single float value is returned that represents the - overall waste disposal rating for the material. - - Returns - ------- - float or dict - The waste disposal rating for the material or its constituent nuclides. - - """ - if limits == 'Fetter': - # Specific activity limits for radionuclides with half-lives between 5 - # years and 1e12 years from Table 2 in Fetter - limits = { - "Be10": 5.0e3, - "C14": 6.0e2, - "Al26": 9.0e-2, - "Si32": 6.0e2, - "Cl36": 1.0e1, - "Ar39": 2.0e4, - "Ar42": 2.0e4, - "K40": 2.0e0, - "Ca41": 1.0e4, - "Ti44": 2.0e2, - "Fe60": 1.0e-1, - "Co60": 3.0e8, - "Ni59": 9.0e2, - "Ni63": 7.0e5, - "Se79": 5.0e1, - "Kr81": 3.0e1, - "Sr90": 8.0e5, - "Nb91": 2.0e2, - "Nb92": 2.0e-1, - "Nb94": 2.0e-1, - "Mo93": 4.0e3, - "Tc97": 4.0e-1, - "Tc98": 1.0e-2, - "Tc99": 6.0e-2, - "Pd107": 9.0e2, - "Ag108_m1": 3.0e0, - "Sn121_m1": 7.0e5, - "Sn126": 1.0e-1, - "I129": 2.0e0, - "Cs137": 5.0e4, - "Ba133": 2.0e8, - "La137": 2.0e2, - "Sm151": 5.0e7, - "Eu150_m1": 3.0e3, - "Eu152": 3.0e5, - "Eu154": 5.0e6, - "Gd148": 2.0e5, - "Gd150": 2.0e3, - "Tb157": 5.0e3, - "Tb158": 4.0e0, - "Dy154": 1.0e3, - "Ho166_m1": 2.0e-1, - "Hf178_m1": 9.0e3, - "Hf182": 2.0e-1, - "Re186_m1": 2.0e1, - "Ir192_m1": 1.0e0, - "Pt193": 2.0e8, - "Hg194": 5.0e-1, - "Pb202": 6.0e-1, - "Pb210": 3.0e7, - "Bi207": 9.0e3, - "Bi208": 8.0e-2, - "Bi210_m1": 1.0e0, - "Po209": 3.0e3, - "Ra226": 1.0e-1, - "Ra228": 3.0e7, - "Ac227": 5.0e5, - "Th229": 2.0e0, - "Th230": 3.0e-1, - "Th232": 1.0e-1, - "Pa231": 7.0e-1, - "U232": 3.0e1, - "U233": 2.0e1, - "U234": 9.0e1, - "U235": 2.0e0, - "Np236": 1.0e0, - "Np237": 1.0e0, - "Pu238": 7.0e4, - "Pu239": 1.0e3, - "Pu240": 1.0e3, - "Pu241": 2.0e3, - "Pu242": 1.0e3, - "Pu244": 9.0e-1, - "Am241": 5.0e1, - "Am242_m1": 3.0e2, - "Am243": 2.0e0, - "Cm243": 6.0e2, - "Cm244": 5.0e5, - "Cm245": 5.0e0, - "Cm246": 8.0e2, - "Cm248": 8.0e2, - } - - elif limits == 'NRC_long': - # Specific activity limits for long-lived radionuclides from Table 1 in - # 10 CFR 61.55 in Ci/m3. - limits = { - 'C14': 8.0, - 'Tc99': 3.0, - 'I129': 0.08, - } - if metal: - limits['C14'] = 80.0 - limits['Ni59'] = 220.0 - limits['Nb94'] = 0.2 - - # Convert values in nCi/g to Ci/m3 - factor = (1e6 * mat.get_mass_density()) / 1e9 - limits.update({ - 'Pu241': 3500.0 * factor, - 'Cm242': 20000.0 * factor, - 'Np237': 100.0 * factor, - 'Pu238': 100.0 * factor, - 'Pu239': 100.0 * factor, - 'Pu240': 100.0 * factor, - 'Pu242': 100.0 * factor, - 'Pu244': 100.0 * factor, - 'Am241': 100.0 * factor, - 'Am243': 100.0 * factor, - 'Cm243': 100.0 * factor, - 'Cm244': 100.0 * factor, - 'Cm245': 100.0 * factor, - 'Cm246': 100.0 * factor, - 'Cm247': 100.0 * factor, - 'Cm248': 100.0 * factor, - 'Bk247': 100.0 * factor, - 'Cf249': 100.0 * factor, - 'Cf250': 100.0 * factor, - 'Cf251': 100.0 * factor, - }) - - elif limits == 'NRC_short_A': - # Get Class A specific activity limits for short-lived radionuclides - # from Table 2 in 10 CFR 61.55 - limits = { - 'H3': 40.0, - 'Co60': 700.0, - 'Ni63': 35.0 if metal else 3.5, - 'Sr90': 0.04, - 'Cs137': 1.0 - } - - # Add radionuclides with half-lives < 5 years to limits for class A - five_years = 60.0 * 60.0 * 24.0 * 365.25 * 5.0 - for nuc in mat.get_nuclides(): - if half_life(nuc) is not None and half_life(nuc) < five_years: - limits[nuc] = 700.0 - - elif limits == 'NRC_short_B': - # Get Class B specific activity limits for short-lived radionuclides - # from Table 2 in 10 CFR 61.55 - limits = {'Ni63': 700.0 if metal else 70.0, 'Sr90': 150.0, 'Cs137': 44.0} - - elif limits == 'NRC_short_C': - # Get Class C specific activity limits for short-lived radionuclides - # from Table 2 in 10 CFR 61.55 - limits = {'Ni63': 7000.0 if metal else 700.0, 'Sr90': 7000.0, 'Cs137': 4600.0} - - # Calculate the sum of the fractions of the activity of each radionuclide - # compared to the specified limits - ratio = {} - for nuc, ci_m3 in mat.get_activity(units="Ci/m3", by_nuclide=True).items(): - if nuc in limits: - ratio[nuc] = ci_m3 / limits[nuc] - return ratio if by_nuclide else sum(ratio.values()) diff --git a/openmc/weight_windows.py b/openmc/weight_windows.py index 63af2596e..96f1db892 100644 --- a/openmc/weight_windows.py +++ b/openmc/weight_windows.py @@ -1,8 +1,6 @@ from __future__ import annotations from numbers import Real, Integral -from collections.abc import Iterable, Sequence -from pathlib import Path -from typing import Self +from typing import Iterable, List, Optional, Dict, Sequence import warnings import lxml.etree as ET @@ -10,13 +8,12 @@ import numpy as np import h5py import openmc +from openmc.filter import _PARTICLES from openmc.mesh import MeshBase, RectilinearMesh, CylindricalMesh, SphericalMesh, UnstructuredMesh -from openmc.tallies import Tallies import openmc.checkvalue as cv from openmc.checkvalue import PathLike -from ._xml import get_elem_list, get_text, clean_indentation +from ._xml import get_text, clean_indentation from .mixin import IDManagerMixin -from .particle_type import ParticleType class WeightWindows(IDManagerMixin): @@ -51,7 +48,7 @@ class WeightWindows(IDManagerMixin): A list of values for which each successive pair constitutes a range of energies in [eV] for a single bin. If no energy bins are provided, the maximum and minimum energy for the data available at runtime. - particle_type : str or int or openmc.ParticleType + particle_type : {'neutron', 'photon'} Particle type the weight windows apply to survival_ratio : float Ratio of the survival weight to the lower weight window bound for @@ -93,7 +90,7 @@ class WeightWindows(IDManagerMixin): survival_ratio : float Ratio of the survival weight to the lower weight window bound for rouletting - max_lower_bound_ratio : float + max_lower_bound_ratio: float Maximum allowed ratio of a particle's weight to the weight window's lower bound. (Default: 1.0) max_split : int @@ -113,15 +110,15 @@ class WeightWindows(IDManagerMixin): self, mesh: MeshBase, lower_ww_bounds: Iterable[float], - upper_ww_bounds: Iterable[float] | None = None, - upper_bound_ratio: float | None = None, - energy_bounds: Iterable[Real] | None = None, - particle_type: str | int | openmc.ParticleType = 'neutron', - survival_ratio: float = 3.0, - max_lower_bound_ratio: float | None = None, + upper_ww_bounds: Optional[Iterable[float]] = None, + upper_bound_ratio: Optional[float] = None, + energy_bounds: Optional[Iterable[Real]] = None, + particle_type: str = 'neutron', + survival_ratio: float = 3, + max_lower_bound_ratio: Optional[float] = None, max_split: int = 10, weight_cutoff: float = 1.e-38, - id: int | None = None + id: Optional[int] = None ): self.mesh = mesh self.id = id @@ -213,15 +210,13 @@ class WeightWindows(IDManagerMixin): self._mesh = mesh @property - def particle_type(self) -> ParticleType: + def particle_type(self) -> str: return self._particle_type @particle_type.setter - def particle_type(self, pt): - ptype = ParticleType(pt) - if ptype not in {ParticleType.NEUTRON, ParticleType.PHOTON}: - raise ValueError("Weight windows can only be applied for neutrons or photons") - self._particle_type = ptype + def particle_type(self, pt: str): + cv.check_value('Particle type', pt, _PARTICLES) + self._particle_type = pt @property def energy_bounds(self) -> Iterable[Real]: @@ -331,11 +326,10 @@ class WeightWindows(IDManagerMixin): subelement.text = str(self.mesh.id) subelement = ET.SubElement(element, 'particle_type') - subelement.text = str(self.particle_type) + subelement.text = self.particle_type - if self.energy_bounds is not None: - subelement = ET.SubElement(element, 'energy_bounds') - subelement.text = ' '.join(str(e) for e in self.energy_bounds) + subelement = ET.SubElement(element, 'energy_bounds') + subelement.text = ' '.join(str(e) for e in self.energy_bounds) subelement = ET.SubElement(element, 'lower_ww_bounds') subelement.text = ' '.join(str(b) for b in self.lower_ww_bounds.ravel('F')) @@ -359,7 +353,7 @@ class WeightWindows(IDManagerMixin): return element @classmethod - def from_xml_element(cls, elem: ET.Element, meshes: dict[int, MeshBase]) -> Self: + def from_xml_element(cls, elem: ET.Element, meshes: Dict[int, MeshBase]) -> WeightWindows: """Generate weight window settings from an XML element Parameters @@ -381,9 +375,9 @@ class WeightWindows(IDManagerMixin): mesh = meshes[mesh_id] # Read all other parameters - lower_ww_bounds = get_elem_list(elem, "lower_ww_bounds", float) - upper_ww_bounds = get_elem_list(elem, "upper_ww_bounds", float) - e_bounds = get_elem_list(elem, "energy_bounds", float) + lower_ww_bounds = [float(l) for l in get_text(elem, 'lower_ww_bounds').split()] + upper_ww_bounds = [float(u) for u in get_text(elem, 'upper_ww_bounds').split()] + e_bounds = [float(b) for b in get_text(elem, 'energy_bounds').split()] particle_type = get_text(elem, 'particle_type') survival_ratio = float(get_text(elem, 'survival_ratio')) @@ -413,7 +407,7 @@ class WeightWindows(IDManagerMixin): ) @classmethod - def from_hdf5(cls, group: h5py.Group, meshes: dict[int, MeshBase]) -> Self: + def from_hdf5(cls, group: h5py.Group, meshes: Dict[int, MeshBase]) -> WeightWindows: """Create weight windows from HDF5 group Parameters @@ -463,7 +457,7 @@ class WeightWindows(IDManagerMixin): ) -def wwinp_to_wws(path: PathLike) -> WeightWindowsList: +def wwinp_to_wws(path: PathLike) -> List[WeightWindows]: """Create WeightWindows instances from a wwinp file .. versionadded:: 0.13.1 @@ -475,13 +469,180 @@ def wwinp_to_wws(path: PathLike) -> WeightWindowsList: Returns ------- - WeightWindowsList + list of openmc.WeightWindows """ - warnings.warn( - "This function is deprecated in favor of 'WeightWindowsList.from_wwinp'", - FutureWarning - ) - return WeightWindowsList.from_wwinp(path) + + with open(path) as wwinp: + # BLOCK 1 + header = wwinp.readline().split(None, 4) + # read file type, time-dependence, number of + # particles, mesh type and problem identifier + _if, iv, ni, nr = [int(x) for x in header[:4]] + + # header value checks + if _if != 1: + raise ValueError(f'Found incorrect file type, if: {_if}') + + if iv > 1: + # read number of time bins for each particle, 'nt(1...ni)' + nt = np.fromstring(wwinp.readline(), sep=' ', dtype=int) + + # raise error if time bins are present for now + raise ValueError('Time-dependent weight windows ' + 'are not yet supported') + else: + nt = ni * [1] + + # read number of energy bins for each particle, 'ne(1...ni)' + ne = np.fromstring(wwinp.readline(), sep=' ', dtype=int) + + # read coarse mesh dimensions and lower left corner + mesh_description = np.fromstring(wwinp.readline(), sep=' ') + nfx, nfy, nfz = mesh_description[:3].astype(int) + xyz0 = mesh_description[3:] + + # read cylindrical and spherical mesh vectors if present + if nr == 16: + # read number of coarse bins + line_arr = np.fromstring(wwinp.readline(), sep=' ') + ncx, ncy, ncz = line_arr[:3].astype(int) + # read polar vector (x1, y1, z1) + xyz1 = line_arr[3:] + # read azimuthal vector (x2, y2, z2) + line_arr = np.fromstring(wwinp.readline(), sep=' ') + xyz2 = line_arr[:3] + + # oriented polar and azimuthal vectors aren't yet supported + if np.count_nonzero(xyz1) or np.count_nonzero(xyz2): + raise NotImplementedError('Custom sphere/cylinder orientations are not supported') + + # read geometry type + nwg = int(line_arr[-1]) + + elif nr == 10: + # read rectilinear data: + # number of coarse mesh bins and mesh type + ncx, ncy, ncz, nwg = \ + np.fromstring(wwinp.readline(), sep=' ').astype(int) + else: + raise RuntimeError(f'Invalid mesh description (nr) found: {nr}') + + # read BLOCK 2 and BLOCK 3 data into a single array + ww_data = np.fromstring(wwinp.read(), sep=' ') + + # extract mesh data from the ww_data array + start_idx = 0 + + # first values in the mesh definition arrays are the first + # coordinate of the grid + end_idx = start_idx + 1 + 3 * ncx + i0, i_vals = ww_data[start_idx], ww_data[start_idx+1:end_idx] + start_idx = end_idx + + end_idx = start_idx + 1 + 3 * ncy + j0, j_vals = ww_data[start_idx], ww_data[start_idx+1:end_idx] + start_idx = end_idx + + end_idx = start_idx + 1 + 3 * ncz + k0, k_vals = ww_data[start_idx], ww_data[start_idx+1:end_idx] + start_idx = end_idx + + # mesh consistency checks + if nr == 16 and nwg == 1 or nr == 10 and nwg != 1: + raise ValueError(f'Mesh description in header ({nr}) ' + f'does not match the mesh type ({nwg})') + + if nr == 10 and (xyz0 != (i0, j0, k0)).any(): + raise ValueError(f'Mesh origin in the header ({xyz0}) ' + f' does not match the origin in the mesh ' + f' description ({i0, j0, k0})') + + # create openmc mesh object + grids = [] + mesh_definition = [(i0, i_vals, nfx), (j0, j_vals, nfy), (k0, k_vals, nfz)] + for grid0, grid_vals, n_pnts in mesh_definition: + # file spec checks for the mesh definition + if (grid_vals[2::3] != 1.0).any(): + raise ValueError('One or more mesh ratio value, qx, ' + 'is not equal to one') + + s = int(grid_vals[::3].sum()) + if s != n_pnts: + raise ValueError(f'Sum of the fine bin entries, {s}, does ' + f'not match the number of fine bins, {n_pnts}') + + # extend the grid based on the next coarse bin endpoint, px + # and the number of fine bins in the coarse bin, sx + intervals = grid_vals.reshape(-1, 3) + coords = [grid0] + for sx, px, qx in intervals: + coords += np.linspace(coords[-1], px, int(sx + 1)).tolist()[1:] + + grids.append(np.array(coords)) + + if nwg == 1: + mesh = RectilinearMesh() + mesh.x_grid, mesh.y_grid, mesh.z_grid = grids + elif nwg == 2: + mesh = CylindricalMesh( + r_grid=grids[0], + z_grid=grids[1], + phi_grid=grids[2], + origin = xyz0, + ) + elif nwg == 3: + mesh = SphericalMesh( + r_grid=grids[0], + theta_grid=grids[1], + phi_grid=grids[2], + origin = xyz0 + ) + + # extract weight window values from array + wws = [] + for ne_i, nt_i, particle_type in zip(ne, nt, ('neutron', 'photon')): + # no information to read for this particle if + # either the energy bins or time bins are empty + if ne_i == 0 or nt_i == 0: + continue + + if iv > 1: + # time bins are parsed but unused for now + end_idx = start_idx + nt_i + time_bounds = ww_data[start_idx:end_idx] + np.insert(time_bounds, (0,), (0.0,)) + start_idx = end_idx + + # read energy boundaries + end_idx = start_idx + ne_i + energy_bounds = np.insert(ww_data[start_idx:end_idx], (0,), (0.0,)) + # convert from MeV to eV + energy_bounds *= 1e6 + start_idx = end_idx + + # read weight window values + end_idx = start_idx + (nfx * nfy * nfz) * nt_i * ne_i + + # read values and reshape according to ordering + # slowest to fastest: t, e, z, y, x + # reorder with transpose since our ordering is x, y, z, e, t + ww_shape = (nt_i, ne_i, nfz, nfy, nfx) + ww_values = ww_data[start_idx:end_idx].reshape(ww_shape).T + # Only use first time bin since we don't support time dependent weight + # windows yet. + ww_values = ww_values[:, :, :, :, 0] + start_idx = end_idx + + # create a weight window object + ww = WeightWindows(id=None, + mesh=mesh, + lower_ww_bounds=ww_values, + upper_bound_ratio=5.0, + energy_bounds=energy_bounds, + particle_type=particle_type) + wws.append(ww) + + return wws class WeightWindowGenerator: @@ -496,12 +657,11 @@ class WeightWindowGenerator: A list of values for which each successive pair constitutes a range of energies in [eV] for a single bin. If no energy bins are provided, the maximum and minimum energy for the data available at runtime. - particle_type : str or int or openmc.ParticleType + particle_type : {'neutron', 'photon'} Particle type the weight windows apply to - method : {'magic', 'fw_cadis'} - The weight window generation methodology applied during an update. - targets : :class:`openmc.Tallies` or iterable of int - Target tallies for local variance reduction via FW-CADIS. + method : {'magic'} + The weight window generation methodology applied during an update. Only + 'magic' is currently supported. max_realizations : int The upper limit for number of tally realizations when generating weight windows. @@ -517,12 +677,11 @@ class WeightWindowGenerator: energy_bounds : Iterable of Real A list of values for which each successive pair constitutes a range of energies in [eV] for a single bin - particle_type : openmc.ParticleType + particle_type : {'neutron', 'photon'} Particle type the weight windows apply to - method : {'magic', 'fw_cadis'} - The weight window generation methodology applied during an update. - targets : :class:`openmc.Tallies` or numpy.ndarray - Target tallies for local variance reduction via FW-CADIS. + method : {'magic'} + The weight window generation methodology applied during an update. Only + 'magic' is currently supported. max_realizations : int The upper limit for number of tally realizations when generating weight windows. @@ -534,15 +693,14 @@ class WeightWindowGenerator: Whether or not to apply weight windows on the fly. """ - _WWG_PARAMS = {'value': str, 'threshold': float, 'ratio': float} + _MAGIC_PARAMS = {'value': str, 'threshold': float, 'ratio': float} def __init__( self, mesh: openmc.MeshBase, - energy_bounds: Sequence[float] | None = None, - particle_type: str | int | openmc.ParticleType = 'neutron', + energy_bounds: Optional[Sequence[float]] = None, + particle_type: str = 'neutron', method: str = 'magic', - targets: openmc.Tallies | Iterable[int] | None = None, max_realizations: int = 1, update_interval: int = 1, on_the_fly: bool = True @@ -555,7 +713,6 @@ class WeightWindowGenerator: self.energy_bounds = energy_bounds self.particle_type = particle_type self.method = method - self.targets = targets self.max_realizations = max_realizations self.update_interval = update_interval self.on_the_fly = on_the_fly @@ -563,7 +720,7 @@ class WeightWindowGenerator: def __repr__(self): string = type(self).__name__ + '\n' string += f'\t{"Mesh":<20}=\t{self.mesh.id}\n' - string += f'\t{"Particle:":<20}=\t{str(self.particle_type)}\n' + string += f'\t{"Particle:":<20}=\t{self.particle_type}\n' string += f'\t{"Energy Bounds:":<20}=\t{self.energy_bounds}\n' string += f'\t{"Method":<20}=\t{self.method}\n' string += f'\t{"Max Realizations:":<20}=\t{self.max_realizations}\n' @@ -594,15 +751,13 @@ class WeightWindowGenerator: self._energy_bounds = eb @property - def particle_type(self) -> ParticleType: + def particle_type(self) -> str: return self._particle_type @particle_type.setter - def particle_type(self, pt): - ptype = ParticleType(pt) - if ptype not in {ParticleType.NEUTRON, ParticleType.PHOTON}: - raise ValueError("Weight windows can only be applied for neutrons or photons") - self._particle_type = ptype + def particle_type(self, pt: str): + cv.check_value('particle type', pt, ('neutron', 'photon')) + self._particle_type = pt @property def method(self) -> str: @@ -611,29 +766,13 @@ class WeightWindowGenerator: @method.setter def method(self, m: str): cv.check_type('generation method', m, str) - cv.check_value('generation method', m, ('magic', 'fw_cadis')) + cv.check_value('generation method', m, {'magic'}) self._method = m if self._update_parameters is not None: try: self._check_update_parameters() except (TypeError, KeyError): warnings.warn(f'Update parameters are invalid for the "{m}" method.') - - @property - def targets(self) -> openmc.Tallies: - return self._targets - - @targets.setter - def targets(self, t): - if t is None: - self._targets = t - else: - cv.check_type('Local FW-CADIS target tallies', t, Iterable) - cv.check_greater_than('Local FW-CADIS target tallies', len(t), 0) - if not isinstance(t, openmc.Tallies): - cv.check_iterable_type('Local FW-CADIS target tallies', t, int) - t = np.asarray(list(t), dtype=int) - self._targets = t @property def max_realizations(self) -> int: @@ -660,14 +799,14 @@ class WeightWindowGenerator: return self._update_parameters def _check_update_parameters(self, params: dict): - if self.method == 'magic' or self.method == 'fw_cadis': - check_params = self._WWG_PARAMS + if self.method == 'magic': + check_params = self._MAGIC_PARAMS for key, val in params.items(): if key not in check_params: raise ValueError(f'Invalid param "{key}" for {self.method} ' 'weight window generation') - cv.check_type(f'weight window generation param: "{key}"', val, self._WWG_PARAMS[key]) + cv.check_type(f'weight window generation param: "{key}"', val, self._MAGIC_PARAMS[key]) @update_parameters.setter def update_parameters(self, params: dict): @@ -703,8 +842,8 @@ class WeightWindowGenerator: update_parameters : dict The update parameters as-read from the XML node (keys: str, values: str) """ - if method == 'magic' or method == 'fw_cadis': - check_params = cls._WWG_PARAMS + if method == 'magic': + check_params = cls._MAGIC_PARAMS for param, param_type in check_params.items(): if param in update_parameters: @@ -721,7 +860,7 @@ class WeightWindowGenerator: subelement = ET.SubElement(element, 'energy_bounds') subelement.text = ' '.join(str(e) for e in self.energy_bounds) particle_elem = ET.SubElement(element, 'particle_type') - particle_elem.text = str(self.particle_type) + particle_elem.text = self.particle_type realizations_elem = ET.SubElement(element, 'max_realizations') realizations_elem.text = str(self.max_realizations) update_interval_elem = ET.SubElement(element, 'update_interval') @@ -730,20 +869,6 @@ class WeightWindowGenerator: otf_elem.text = str(self.on_the_fly).lower() method_elem = ET.SubElement(element, 'method') method_elem.text = self.method - if self.targets is not None: - if self.method != 'fw_cadis': - raise ValueError( - "FW-CADIS update method is required in order to use " \ - "target tallies for WeightWindowGenerator.") - elif isinstance(self.targets, openmc.Tallies): - raise RuntimeError( - "FW-CADIS target tallies must be checked to ensure they are " \ - "present on model.tallies. Use model.export_to_xml() or " \ - "model.export_to_model_xml() to link FW-CADIS target tallies.") - else: - targets_elem = ET.SubElement(element, 'targets') - targets_elem.text = ' '.join(str(tally_id) for tally_id in self.targets) - if self.update_parameters is not None: self._update_parameters_subelement(element) @@ -752,7 +877,7 @@ class WeightWindowGenerator: return element @classmethod - def from_xml_element(cls, elem: ET.Element, meshes: dict) -> Self: + def from_xml_element(cls, elem: ET.Element, meshes: dict) -> WeightWindowGenerator: """ Create a weight window generation object from an XML element @@ -770,8 +895,8 @@ class WeightWindowGenerator: mesh_id = int(get_text(elem, 'mesh')) mesh = meshes[mesh_id] - - energy_bounds = get_elem_list(elem, "energy_bounds", float) + + energy_bounds = [float(x) for x in get_text(elem, 'energy_bounds').split()] particle_type = get_text(elem, 'particle_type') wwg = cls(mesh, energy_bounds, particle_type) @@ -780,14 +905,6 @@ class WeightWindowGenerator: wwg.update_interval = int(get_text(elem, 'update_interval')) wwg.on_the_fly = bool(get_text(elem, 'on_the_fly')) wwg.method = get_text(elem, 'method') - targets_elem = elem.find('targets') - if targets_elem is not None: - if wwg.method != 'fw_cadis': - raise ValueError( - "FW-CADIS update method is required in order to use " \ - "target tallies for WeightWindowGenerator.") - else: - wwg.targets = get_elem_list(elem, "targets") if elem.find('update_parameters') is not None: update_parameters = {} @@ -800,8 +917,8 @@ class WeightWindowGenerator: return wwg -def hdf5_to_wws(path='weight_windows.h5') -> WeightWindowsList: - """Create a WeightWindowsList from a weight windows HDF5 file +def hdf5_to_wws(path='weight_windows.h5'): + """Create WeightWindows instances from a weight windows HDF5 file .. versionadded:: 0.14.0 @@ -812,280 +929,13 @@ def hdf5_to_wws(path='weight_windows.h5') -> WeightWindowsList: Returns ------- - WeightWindowsList + list of openmc.WeightWindows """ - warnings.warn( - "This function is deprecated in favor of 'WeightWindowsList.from_hdf5'", - FutureWarning - ) - return WeightWindowsList.from_hdf5(path) - -class WeightWindowsList(list): - """A list of WeightWindows objects. - - .. versionadded:: 0.15.3 - - Parameters - ---------- - iterable : iterable of openmc.WeightWindows - An iterable of WeightWindows objects to initialize the list with - - """ - def __init__(self, iterable: Iterable[WeightWindows] = ()): - super().__init__(iterable) - - @classmethod - def from_hdf5(cls, path: PathLike = 'weight_windows.h5') -> Self: - """Create WeightWindowsList from a weight windows HDF5 file. - - Parameters - ---------- - path : PathLike - Path to the weight windows hdf5 file - - Returns - ------- - WeightWindowsList - A list of WeightWindows objects read from the file - """ - - with h5py.File(path) as h5_file: - # read in all of the meshes in the mesh node - meshes = {} - for mesh_group in h5_file['meshes']: - mesh = MeshBase.from_hdf5(h5_file['meshes'][mesh_group]) - meshes[mesh.id] = mesh - wws = [ - WeightWindows.from_hdf5(ww, meshes) - for ww in h5_file['weight_windows'].values() - ] - - return cls(wws) - - @classmethod - def from_wwinp(cls, path: PathLike) -> Self: - """Create WeightWindowsList from a wwinp file. - - Parameters - ---------- - path : PathLike - Path to the wwinp file - - Returns - ------- - WeightWindowsList - A list of WeightWindows objects read from the file - """ - - with open(path) as wwinp: - # BLOCK 1 - header = wwinp.readline().split(None, 4) - # read file type, time-dependence, number of - # particles, mesh type and problem identifier - _if, iv, ni, nr = [int(x) for x in header[:4]] - - # header value checks - if _if != 1: - raise ValueError(f'Found incorrect file type, if: {_if}') - - if iv > 1: - # read number of time bins for each particle, 'nt(1...ni)' - nt = np.fromstring(wwinp.readline(), sep=' ', dtype=int) - - # raise error if time bins are present for now - raise ValueError('Time-dependent weight windows ' - 'are not yet supported') - else: - nt = ni * [1] - - # read number of energy bins for each particle, 'ne(1...ni)' - ne = np.fromstring(wwinp.readline(), sep=' ', dtype=int) - - # read coarse mesh dimensions and lower left corner - mesh_description = np.fromstring(wwinp.readline(), sep=' ') - nfx, nfy, nfz = mesh_description[:3].astype(int) - xyz0 = mesh_description[3:] - - # read cylindrical and spherical mesh vectors if present - if nr == 16: - # read number of coarse bins - line_arr = np.fromstring(wwinp.readline(), sep=' ') - ncx, ncy, ncz = line_arr[:3].astype(int) - # read polar vector (x1, y1, z1) - xyz1 = line_arr[3:] - # read azimuthal vector (x2, y2, z2) - line_arr = np.fromstring(wwinp.readline(), sep=' ') - xyz2 = line_arr[:3] - - # Get polar and azimuthal axes - polar_axis = xyz1 - xyz0 - azimuthal_axis = xyz2 - xyz0 - - # Check for polar axis other than (0, 0, 1) - norm = np.linalg.norm(polar_axis) - if not np.isclose(polar_axis[2]/norm, 1.0): - raise NotImplementedError('Polar axis not aligned to z-axis not supported') - - # Check for azimuthal axis other than (1, 0, 0) - norm = np.linalg.norm(azimuthal_axis) - if not np.isclose(azimuthal_axis[0]/norm, 1.0): - raise NotImplementedError('Azimuthal axis not aligned to x-axis not supported') - - # read geometry type - nwg = int(line_arr[-1]) - - elif nr == 10: - # read rectilinear data: - # number of coarse mesh bins and mesh type - ncx, ncy, ncz, nwg = \ - np.fromstring(wwinp.readline(), sep=' ').astype(int) - else: - raise RuntimeError(f'Invalid mesh description (nr) found: {nr}') - - # read BLOCK 2 and BLOCK 3 data into a single array - ww_data = np.fromstring(wwinp.read(), sep=' ') - - # extract mesh data from the ww_data array - start_idx = 0 - - # first values in the mesh definition arrays are the first - # coordinate of the grid - end_idx = start_idx + 1 + 3 * ncx - i0, i_vals = ww_data[start_idx], ww_data[start_idx+1:end_idx] - start_idx = end_idx - - end_idx = start_idx + 1 + 3 * ncy - j0, j_vals = ww_data[start_idx], ww_data[start_idx+1:end_idx] - start_idx = end_idx - - end_idx = start_idx + 1 + 3 * ncz - k0, k_vals = ww_data[start_idx], ww_data[start_idx+1:end_idx] - start_idx = end_idx - - # mesh consistency checks - if nr == 16 and nwg == 1 or nr == 10 and nwg != 1: - raise ValueError(f'Mesh description in header ({nr}) ' - f'does not match the mesh type ({nwg})') - - if nr == 10 and (xyz0 != (i0, j0, k0)).any(): - raise ValueError(f'Mesh origin in the header ({xyz0}) ' - f' does not match the origin in the mesh ' - f' description ({i0, j0, k0})') - - # create openmc mesh object - grids = [] - mesh_definition = [(i0, i_vals, nfx), (j0, j_vals, nfy), (k0, k_vals, nfz)] - for grid0, grid_vals, n_pnts in mesh_definition: - # file spec checks for the mesh definition - if (grid_vals[2::3] != 1.0).any(): - raise ValueError('One or more mesh ratio value, qx, ' - 'is not equal to one') - - s = int(grid_vals[::3].sum()) - if s != n_pnts: - raise ValueError(f'Sum of the fine bin entries, {s}, does ' - f'not match the number of fine bins, {n_pnts}') - - # extend the grid based on the next coarse bin endpoint, px - # and the number of fine bins in the coarse bin, sx - intervals = grid_vals.reshape(-1, 3) - coords = [grid0] - for sx, px, qx in intervals: - coords += np.linspace(coords[-1], px, int(sx + 1)).tolist()[1:] - - grids.append(np.array(coords)) - - if nwg == 1: - mesh = RectilinearMesh() - mesh.x_grid, mesh.y_grid, mesh.z_grid = grids - elif nwg == 2: - mesh = CylindricalMesh( - r_grid=grids[0], - z_grid=grids[1], - phi_grid=grids[2], - origin = xyz0, - ) - elif nwg == 3: - mesh = SphericalMesh( - r_grid=grids[0], - theta_grid=grids[1], - phi_grid=grids[2], - origin = xyz0 - ) - - # extract weight window values from array - wws = cls() - for ne_i, nt_i, particle_type in zip(ne, nt, ('neutron', 'photon')): - # no information to read for this particle if - # either the energy bins or time bins are empty - if ne_i == 0 or nt_i == 0: - continue - - if iv > 1: - # time bins are parsed but unused for now - end_idx = start_idx + nt_i - time_bounds = ww_data[start_idx:end_idx] - np.insert(time_bounds, (0,), (0.0,)) - start_idx = end_idx - - # read energy boundaries - end_idx = start_idx + ne_i - energy_bounds = np.insert(ww_data[start_idx:end_idx], (0,), (0.0,)) - # convert from MeV to eV - energy_bounds *= 1e6 - start_idx = end_idx - - # read weight window values - end_idx = start_idx + (nfx * nfy * nfz) * nt_i * ne_i - - # read values and reshape according to ordering - # slowest to fastest: t, e, z, y, x - # reorder with transpose since our ordering is x, y, z, e, t - ww_shape = (nt_i, ne_i, nfz, nfy, nfx) - ww_values = ww_data[start_idx:end_idx].reshape(ww_shape).T - # Only use first time bin since we don't support time dependent weight - # windows yet. - ww_values = ww_values[:, :, :, :, 0] - start_idx = end_idx - - # create a weight window object - ww = WeightWindows(id=None, - mesh=mesh, - lower_ww_bounds=ww_values, - upper_bound_ratio=5.0, - energy_bounds=energy_bounds, - particle_type=particle_type) - wws.append(ww) - - return wws - - def export_to_hdf5(self, path: PathLike = 'weight_windows.h5', **init_kwargs): - """Write weight windows to an HDF5 file. - - Parameters - ---------- - path : PathLike - Path to the file to write weight windows to - **init_kwargs - Keyword arguments passed to :func:`openmc.lib.init` - - """ - import openmc.lib - cv.check_type('path', path, PathLike) - - # Create a temporary model with the weight windows - model = openmc.Model() - sph = openmc.Sphere(boundary_type='vacuum') - cell = openmc.Cell(region=-sph) - model.geometry = openmc.Geometry([cell]) - model.settings.weight_windows = self - model.settings.particles = 100 - model.settings.batches = 1 - - # Get absolute path before moving to temporary directory - path = Path(path).resolve() - - # Load the model with openmc.lib and then export it to an HDF5 file - with openmc.lib.TemporarySession(model, **init_kwargs): - openmc.lib.export_weight_windows(path) + with h5py.File(path) as h5_file: + # read in all of the meshes in the mesh node + meshes = {} + for mesh_group in h5_file['meshes']: + mesh = MeshBase.from_hdf5(h5_file['meshes'][mesh_group]) + meshes[mesh.id] = mesh + return [WeightWindows.from_hdf5(ww, meshes) for ww in h5_file['weight_windows'].values()] diff --git a/pyproject.toml b/pyproject.toml index c769fb7d7..d5970617a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,77 +1,2 @@ [build-system] -requires = ["setuptools", "setuptools-scm", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "openmc" -authors = [ - {name = "The OpenMC Development Team", email = "openmc@anl.gov"}, -] -description = "OpenMC" -dynamic = ["version"] -requires-python = ">=3.12" -license = {file = "LICENSE"} -classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: End Users/Desktop", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Topic :: Scientific/Engineering", - "Programming Language :: C++", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.14", -] -dependencies = [ - "numpy", - "h5py", - "scipy", - "ipython", - "matplotlib", - "pandas", - "lxml", - "uncertainties", - "endf", -] - -[project.optional-dependencies] -depletion-mpi = ["mpi4py"] -docs = [ - "breathe", - "sphinx", - "sphinxcontrib-katex", - "sphinx-numfig", - "jupyter", - "sphinxcontrib-svg2pdfconverter", - "sphinx-rtd-theme" -] -test = [ - "packaging", - "pytest", - "pytest-cov>=4.0", - "pytest-rerunfailures", - "colorama", - "openpyxl", -] -ci = ["coverage>=7.4", "gcovr>=7.2"] -vtk = ["vtk"] - -[project.urls] -Homepage = "https://openmc.org" -Documentation = "https://docs.openmc.org" -Repository = "https://github.com/openmc-dev/openmc" -Issues = "https://github.com/openmc-dev/openmc/issues" - -[tool.setuptools.packages.find] -include = ['openmc*'] -exclude = ['tests*'] - -[tool.setuptools.package-data] -"openmc.data.dose" = ["**/*.txt", "*.h5"] -"openmc.data" = ["*.txt", "*.DAT", "*.json", "*.h5"] -"openmc.lib" = ["libopenmc.dylib", "libopenmc.so"] - -[tool.setuptools_scm] +requires = ["setuptools", "wheel", "numpy", "cython"] diff --git a/scripts/openmc-ace-to-hdf5 b/scripts/openmc-ace-to-hdf5 new file mode 100755 index 000000000..66ae7e2a9 --- /dev/null +++ b/scripts/openmc-ace-to-hdf5 @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 + +"""This script can be used to create HDF5 nuclear data libraries used by +OpenMC. There are four different ways you can specify ACE libraries that are to +be converted: + +1. List each ACE library as a positional argument. This is very useful in + conjunction with the usual shell utilities (ls, find, etc.). +2. Use the --xsdir option to specify a MCNP xsdir file. +3. Use the --xsdata option to specify a Serpent xsdata file. + +The script does not use any extra information from xsdir/xsdata files to +determine whether the nuclide is metastable. Instead, the --metastable argument +can be used to specify whether the ZAID naming convention follows the NNDC data +convention (1000*Z + A + 300 + 100*m), or the MCNP data convention (essentially +the same as NNDC, except that the first metastable state of Am242 is 95242 and +the ground state is 95642). + +""" + +import argparse +from functools import partial +import os +from pathlib import Path +import warnings + +import openmc.data +from openmc.data.ace import TableType + + +def ace_to_hdf5(destination, xsdir, xsdata, libraries, metastable, libver): + + if not destination.is_dir(): + destination.mkdir(parents=True, exist_ok=True) + + ace_libraries = [] + if xsdir is not None: + ace_libraries.extend(openmc.data.ace.get_libraries_from_xsdir(xsdir)) + elif xsdata is not None: + ace_libraries.extend(openmc.data.ace.get_libraries_from_xsdata(xsdata)) + else: + ace_libraries = [Path(lib) for lib in libraries] + + converted = {} + library = openmc.data.DataLibrary() + + for path in ace_libraries: + # Check that ACE library exists + if not os.path.exists(path): + warnings.warn(f"ACE library '{path}' does not exist.") + continue + + lib = openmc.data.ace.Library(path) + for table in lib.tables: + # Check type of the ACE table and determine appropriate class / + # conversion function + if table.data_type == TableType.NEUTRON_CONTINUOUS: + name = table.zaid + cls = openmc.data.IncidentNeutron + converter = partial(cls.from_ace, metastable_scheme=metastable) + elif table.data_type == TableType.THERMAL_SCATTERING: + # Adjust name to be the new thermal scattering name + name = openmc.data.get_thermal_name(table.zaid) + cls = openmc.data.ThermalScattering + converter = cls.from_ace + else: + print(f"Can't convert ACE table {table.name}") + continue + + if name not in converted: + try: + data = converter(table) + except Exception as e: + print(f"Failed to convert {table.name}: {e}") + continue + + print(f"Converting {table.name} (ACE) to {data.name} (HDF5)") + + # Determine output filename + outfile = destination / (data.name.replace(".", "_") + ".h5") + data.export_to_hdf5(outfile, "w", libver=libver) + + # Register with library + library.register_file(outfile) + + # Add nuclide to list + converted[name] = outfile + else: + # Read existing HDF5 file + data = cls.from_hdf5(converted[name]) + + # Add data for new temperature + try: + print(f"Converting {table.name} (ACE) to {data.name} (HDF5)") + if table.data_type == TableType.NEUTRON_CONTINUOUS: + data.add_temperature_from_ace(table, metastable) + else: + data.add_temperature_from_ace(table) + except Exception as e: + print(f"Failed to convert {table.name}: {e}") + continue + + # Re-export + data.export_to_hdf5(converted[name], "w", libver=libver) + + # Write cross_sections.xml + library.export_to_xml(destination / "cross_sections.xml") + + +if __name__ == "__main__": + + class CustomFormatter( + argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter + ): + pass + + parser = argparse.ArgumentParser( + description=__doc__, formatter_class=CustomFormatter + ) + parser.add_argument("libraries", nargs="*", help="ACE libraries to convert to HDF5") + parser.add_argument( + "-d", + "--destination", + type=Path, + default=Path.cwd(), + help="Directory to create new library in", + ) + parser.add_argument( + "-m", + "--metastable", + choices=["mcnp", "nndc"], + default="nndc", + help="How to interpret ZAIDs for metastable nuclides", + ) + parser.add_argument("--xsdir", help="MCNP xsdir file that lists " "ACE libraries") + parser.add_argument( + "--xsdata", help="Serpent xsdata file that lists " "ACE libraries" + ) + parser.add_argument( + "--libver", + choices=["earliest", "latest"], + default="earliest", + help="Output HDF5 versioning. Use " + "'earliest' for backwards compatibility or 'latest' " + "for performance", + ) + args = parser.parse_args() + + ace_to_hdf5( + destination=args.destination, + xsdir=args.xsdir, + xsdata=args.xsdata, + libraries=args.libraries, + metastable=args.metastable, + libver=args.libver, + ) diff --git a/scripts/openmc-plot-mesh-tally b/scripts/openmc-plot-mesh-tally new file mode 100755 index 000000000..2a4fcd743 --- /dev/null +++ b/scripts/openmc-plot-mesh-tally @@ -0,0 +1,344 @@ +#!/usr/bin/env python3 + +"""Python script to plot tally data generated by OpenMC.""" + + +import os +import sys +import argparse +import tkinter as tk +import tkinter.filedialog as filedialog +import tkinter.font as font +import tkinter.messagebox as messagebox +import tkinter.ttk as ttk + +import matplotlib +matplotlib.use("TkAgg") +from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg +from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk +from matplotlib.figure import Figure +import matplotlib.pyplot as plt +import numpy as np + +from openmc import StatePoint, MeshFilter, UnstructuredMesh + +_COMBOBOX_SELECTED = '<>' + + +def mesh_filter_check(filter): + """ + Check that the filter is a usable mesh filter + """ + return isinstance(filter, MeshFilter) and not isinstance(filter.mesh, UnstructuredMesh) + + +class MeshPlotter(tk.Frame): + def __init__(self, parent, filename): + super().__init__(parent) + + self.labels = { + 'Cell': 'Cell:', + 'Cellborn': 'Cell born:', + 'Surface': 'Surface:', + 'Material': 'Material:', + 'Universe': 'Universe:', + 'Energy': 'Energy in:', + 'Energyout': 'Energy out:' + } + + self.filterBoxes = {} + + # Read data from source or leakage fraction file + self.get_file_data(filename) + + # Set up top-level window + top = self.winfo_toplevel() + top.title('Mesh Tally Plotter: ' + filename) + top.rowconfigure(0, weight=1) + top.columnconfigure(0, weight=1) + self.grid(sticky=tk.W+tk.N) + + # Create widgets and draw to screen + self.create_widgets() + self.update() + + def create_widgets(self): + figureFrame = tk.Frame(self) + figureFrame.grid(row=0, column=0) + + # Create the Figure and Canvas + self.dpi = 100 + self.fig = Figure((5.0, 5.0), dpi=self.dpi) + self.canvas = FigureCanvasTkAgg(self.fig, master=figureFrame) + self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1) + + # Create the navigation toolbar, tied to the canvas + self.mpl_toolbar = NavigationToolbar2Tk(self.canvas, figureFrame) + self.mpl_toolbar.update() + self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1) + + # Create frame for comboboxes + self.selectFrame = tk.Frame(self) + self.selectFrame.grid(row=1, column=0, sticky=tk.W+tk.E) + + # Tally selection + labelTally = tk.Label(self.selectFrame, text='Tally:') + labelTally.grid(row=0, column=0, sticky=tk.W) + self.tallyBox = ttk.Combobox(self.selectFrame, state='readonly') + self.tallyBox['values'] = [self.datafile.tallies[i].id + for i in self.meshTallies] + self.tallyBox.current(0) + self.tallyBox.grid(row=0, column=1, sticky=tk.W+tk.E) + self.tallyBox.bind(_COMBOBOX_SELECTED, self.update) + + # Planar basis selection + labelBasis = tk.Label(self.selectFrame, text='Basis:') + labelBasis.grid(row=1, column=0, sticky=tk.W) + self.basisBox = ttk.Combobox(self.selectFrame, state='readonly') + self.basisBox['values'] = ('xy', 'yz', 'xz') + self.basisBox.current(0) + self.basisBox.grid(row=1, column=1, sticky=tk.W+tk.E) + self.basisBox.bind(_COMBOBOX_SELECTED, self.update) + + # Axial level + labelAxial = tk.Label(self.selectFrame, text='Axial level:') + labelAxial.grid(row=2, column=0, sticky=tk.W) + self.axialBox = ttk.Combobox(self.selectFrame, state='readonly') + self.axialBox.grid(row=2, column=1, sticky=tk.W+tk.E) + self.axialBox.bind(_COMBOBOX_SELECTED, self.redraw) + + # Option for mean/uncertainty + labelMean = tk.Label(self.selectFrame, text='Mean/Uncertainty:') + labelMean.grid(row=3, column=0, sticky=tk.W) + self.meanBox = ttk.Combobox(self.selectFrame, state='readonly') + self.meanBox['values'] = ('Mean', 'Absolute uncertainty', + 'Relative uncertainty') + self.meanBox.current(0) + self.meanBox.grid(row=3, column=1, sticky=tk.W+tk.E) + self.meanBox.bind(_COMBOBOX_SELECTED, self.update) + + # Scores + labelScore = tk.Label(self.selectFrame, text='Score:') + labelScore.grid(row=4, column=0, sticky=tk.W) + self.scoreBox = ttk.Combobox(self.selectFrame, state='readonly') + self.scoreBox.grid(row=4, column=1, sticky=tk.W+tk.E) + self.scoreBox.bind(_COMBOBOX_SELECTED, self.redraw) + + # Filter label + boldfont = font.Font(weight='bold') + labelFilters = tk.Label(self.selectFrame, text='Filters:', + font=boldfont) + labelFilters.grid(row=5, column=0, sticky=tk.W) + + def update(self, event=None): + widget = event.widget if event else None + + tally_id = self.meshTallies[self.tallyBox.current()] + selectedTally = self.datafile.tallies[tally_id] + + # Get mesh for selected tally + self.mesh = selectedTally.find_filter(MeshFilter).mesh + + # Get mesh dimensions + if len(self.mesh.dimension) == 2: + self.nx, self.ny = self.mesh.dimension + self.nz = 1 + else: + self.nx, self.ny, self.nz = self.mesh.dimension + + # Repopulate comboboxes baesd on current basis selection + text = self.basisBox.get() + if text == 'xy': + self.axialBox['values'] = [str(i+1) for i in range(self.nz)] + elif text == 'yz': + self.axialBox['values'] = [str(i+1) for i in range(self.nx)] + else: + self.axialBox['values'] = [str(i+1) for i in range(self.ny)] + self.axialBox.current(0) + + # If update() was called by a change in the basis combobox, we don't + # need to repopulate the filters + if widget == self.basisBox: + self.redraw() + return + + # Update scores + self.scoreBox['values'] = selectedTally.scores + self.scoreBox.current(0) + + # Remove any filter labels/comboboxes that exist + for row in range(6, self.selectFrame.grid_size()[1]): + for w in self.selectFrame.grid_slaves(row=row): + w.grid_forget() + w.destroy() + + # create a label/combobox for each filter in selected tally + count = 0 + for f in selectedTally.filters: + filterType = f.short_name + if filterType == 'Mesh': + continue + count += 1 + + # Create label and combobox for this filter + label = tk.Label(self.selectFrame, text=self.labels[filterType]) + label.grid(row=count+6, column=0, sticky=tk.W) + combobox = ttk.Combobox(self.selectFrame, state='readonly') + self.filterBoxes[filterType] = combobox + + # Set combobox items + if filterType in ['Energy', 'Energyout']: + combobox['values'] = ['{} to {}'.format(*ebin) + for ebin in f.bins] + else: + combobox['values'] = [str(i) for i in f.bins] + + combobox.current(0) + combobox.grid(row=count+6, column=1, sticky=tk.W+tk.E) + combobox.bind(_COMBOBOX_SELECTED, self.redraw) + + # If There are no filters, leave a 'None available' message + if count == 0: + count += 1 + label = tk.Label(self.selectFrame, text="None Available") + label.grid(row=count+6, column=0, sticky=tk.W) + + self.redraw() + + def redraw(self, event=None): + basis = self.basisBox.current() + 1 + axial_level = self.axialBox.current() + 1 + mbvalue = self.meanBox.get() + + # Get selected tally + tally_id = self.meshTallies[self.tallyBox.current()] + selectedTally = self.datafile.tallies[tally_id] + + # Create spec_list + spec_list = [] + for f in selectedTally.filters: + if f.short_name == 'Mesh': + mesh_filter = f + continue + elif f.short_name in ['Energy', 'Energyout']: + index = self.filterBoxes[f.short_name].current() + ebin = f.bins[index] + spec_list.append((type(f), (ebin,))) + else: + index = self.filterBoxes[f.short_name].current() + spec_list.append((type(f), (index,))) + + dims = (self.nx, self.ny, self.nz) + + text = self.basisBox.get() + if text == 'xy': + h_ind = 0 + v_ind = 1 + elif text == 'yz': + h_ind = 1 + v_ind = 2 + else: + h_ind = 0 + v_ind = 2 + + axial_ind = 3 - (h_ind + v_ind) + dims = (dims[h_ind], dims[v_ind]) + + mesh_dim = len(self.mesh.dimension) + if mesh_dim == 3: + mesh_indices = [0,0,0] + else: + mesh_indices = [0,0] + + matrix = np.zeros(dims) + for i in range(dims[0]): + for j in range(dims[1]): + if mesh_dim == 3: + mesh_indices[h_ind] = i + 1 + mesh_indices[v_ind] = j + 1 + mesh_indices[axial_ind] = axial_level + else: + mesh_indices[0] = i + 1 + mesh_indices[1] = j + 1 + filters, filter_bins = zip(*spec_list + [ + (type(mesh_filter), (tuple(mesh_indices),))]) + mean = selectedTally.get_values( + [self.scoreBox.get()], filters, filter_bins) + stdev = selectedTally.get_values( + [self.scoreBox.get()], filters, filter_bins, + value='std_dev') + if mbvalue == 'Mean': + matrix[i, j] = mean + elif mbvalue == 'Absolute uncertainty': + matrix[i, j] = stdev + else: + if mean > 0.: + matrix[i, j] = stdev/mean + else: + matrix[i, j] = 0. + + # Clear the figure + self.fig.clear() + + # Make figure, set up color bar + self.axes = self.fig.add_subplot(111) + cax = self.axes.imshow(matrix.transpose(), vmin=0.0, vmax=matrix.max(), + interpolation='none', origin='lower') + self.fig.colorbar(cax) + + self.axes.set_xticks([]) + self.axes.set_yticks([]) + self.axes.set_aspect('equal') + + # Draw canvas + self.canvas.draw() + + def get_file_data(self, filename): + # Create StatePoint object and read in data + self.datafile = StatePoint(filename) + + meshes = self.datafile.meshes + if any(isinstance(m, UnstructuredMesh) for m in meshes.values()): + warn_msg = "Unstructured meshes are present in the" \ + " statepoint file but are not currently" \ + " supported by this script" + messagebox.showwarning("Unstructured Meshes", message=warn_msg) + + # Find which tallies are mesh tallies + self.meshTallies = [] + for itally, tally in self.datafile.tallies.items(): + if any([mesh_filter_check(f) for f in tally.filters]): + self.meshTallies.append(itally) + + if not self.meshTallies: + messagebox.showerror("Invalid StatePoint File", + "File does not contain mesh tallies!") + sys.exit(1) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('statepoint', nargs='?', help='Statepoint file') + args = parser.parse_args() + + # Hide root window + root = tk.Tk() + root.withdraw() + + # If no filename given as command-line argument, open file dialog + if args.statepoint is None: + filename = filedialog.askopenfilename(title='Select statepoint file', + initialdir='.') + else: + filename = args.statepoint + + if filename: + # Check to make sure file exists + if not os.path.isfile(filename): + messagebox.showerror("File not found", + "Could not find regular file: " + filename) + sys.exit(1) + + app = MeshPlotter(root, filename) + root.deiconify() + root.mainloop() diff --git a/scripts/openmc-track-combine b/scripts/openmc-track-combine new file mode 100755 index 000000000..f69f2151c --- /dev/null +++ b/scripts/openmc-track-combine @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +"""Combine multiple HDF5 particle track files.""" + +import argparse + +import openmc + + +def main(): + # Parse command-line arguments + parser = argparse.ArgumentParser( + description='Combine particle track files into a single .h5 file.') + parser.add_argument('input', metavar='IN', nargs='+', + help='Input HDF5 particle track filename(s).') + parser.add_argument('-o', '--out', metavar='OUT', default='tracks.h5', + help='Output HDF5 particle track file.') + + args = parser.parse_args() + openmc.Tracks.combine(args.input, args.out) + + +if __name__ == '__main__': + main() diff --git a/scripts/openmc-track-to-vtk b/scripts/openmc-track-to-vtk new file mode 100755 index 000000000..82439bea7 --- /dev/null +++ b/scripts/openmc-track-to-vtk @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +"""Convert HDF5 particle track to VTK poly data. + +""" + +import argparse + +import openmc +import vtk + + +def _parse_args(): + # Create argument parser. + parser = argparse.ArgumentParser( + description='Convert particle track file(s) to a .pvtp file.') + parser.add_argument('input', metavar='IN', type=str, + help='Input particle track data filename.') + parser.add_argument('-o', '--out', metavar='OUT', type=str, dest='out', + help='Output VTK poly data filename.') + + # Parse and return commandline arguments. + return parser.parse_args() + + +def main(): + # Parse commandline arguments. + args = _parse_args() + + # Make sure that the output filename ends with '.pvtp'. + if not args.out: + args.out = 'tracks.pvtp' + elif not args.out.endswith('.pvtp'): + args.out += '.pvtp' + + # Write coordinate values to points array. + track_file = openmc.Tracks(args.input) + track_file.write_to_vtk(args.out) + +if __name__ == '__main__': + main() diff --git a/scripts/openmc-update-inputs b/scripts/openmc-update-inputs new file mode 100755 index 000000000..2d49c0626 --- /dev/null +++ b/scripts/openmc-update-inputs @@ -0,0 +1,299 @@ +#!/usr/bin/env python3 +"""Update OpenMC's input XML files to the latest format. + +""" + +import argparse +from itertools import chain +from random import randint +from shutil import move +import xml.etree.ElementTree as ET + +import openmc.data + + +description = "Update OpenMC's input XML files to the latest format." +epilog = """\ +If any of the given files do not match the most up-to-date formatting, then they +will be automatically rewritten. The old out-of-date files will not be deleted; +they will be moved to a new file with '.original' appended to their name. + +Formatting changes that will be made: + +geometry.xml: Lattices containing 'outside' attributes/tags will be replaced + with lattices containing 'outer' attributes, and the appropriate + cells/universes will be added. Any 'surfaces' attributes/elements on a cell + will be renamed 'region'. + +materials.xml: Nuclide names will be changed from ACE aliases (e.g., Am-242m) to + HDF5/GNDS names (e.g., Am242_m1). Thermal scattering table names will be + changed from ACE aliases (e.g., HH2O) to HDF5/GNDS names (e.g., c_H_in_H2O). + +""" + + +def parse_args(): + """Read the input files from the commandline.""" + # Create argument parser. + parser = argparse.ArgumentParser( + description=description, + epilog=epilog, + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument('input', metavar='IN', type=str, nargs='+', + help='Input XML file(s).') + + # Parse and return commandline arguments. + return parser.parse_args() + + +def get_universe_ids(geometry_root): + """Return a set of universe id numbers.""" + root = geometry_root + out = set() + + # Get the ids of universes defined by cells. + for cell in root.iter('cell'): + # Get universe attributes/elements + if 'universe' in cell.attrib: + uid = cell.attrib['universe'] + out.add(int(uid)) + elif cell.find('universe') is not None: + elem = cell.find('universe') + uid = elem.text + out.add(int(uid)) + else: + # Default to universe 0 + out.add(0) + + # Get the ids of universes defined by lattices. + for lat in root.iter('lattice'): + # Get id attributes. + if 'id' in lat.attrib: + uid = lat.attrib['id'] + out.add(int(uid)) + + # Get id elements. + elif lat.find('id') is not None: + elem = lat.find('id') + uid = elem.text + out.add(int(uid)) + + return out + + +def get_cell_ids(geometry_root): + """Return a set of cell id numbers.""" + root = geometry_root + out = set() + + # Get the ids of universes defined by cells. + for cell in root.iter('cell'): + # Get id attributes. + if 'id' in cell.attrib: + cid = cell.attrib['id'] + out.add(int(cid)) + + # Get id elements. + elif cell.find('id') is not None: + elem = cell.find('id') + cid = elem.text + out.add(int(cid)) + + return out + + +def find_new_id(current_ids, preferred=None): + """Return a new id that is not already present in current_ids.""" + distance_from_preferred = 21 + max_random_attempts = 10000 + + # First, try to find an id near the preferred number. + if preferred is not None: + assert isinstance(preferred, int) + for i in range(1, distance_from_preferred): + if (preferred - i not in current_ids) and (preferred - i > 0): + return preferred - i + if (preferred + i not in current_ids) and (preferred + i > 0): + return preferred + i + + # If that was unsuccessful, attempt to randomly guess a new id number. + for i in range(max_random_attempts): + num = randint(1, 2147483647) + if num not in current_inds: + return num + + # Raise an error if an id was not found. + raise RuntimeError('Could not find a unique id number for a new universe.') + + +def get_lat_id(lattice_element): + """Return the id integer of the lattice_element.""" + assert isinstance(lattice_element, ET.Element) + if 'id' in lattice_element.attrib: + return int(lattice_element.attrib['id'].strip()) + elif any([child.tag == 'id' for child in lattice_element]): + elem = lattice_element.find('id') + return int(elem.text.strip()) + else: + raise RuntimeError('Could not find the id for a lattice.') + + +def pop_lat_outside(lattice_element): + """Return lattice's outside material and remove from attributes/elements.""" + assert isinstance(lattice_element, ET.Element) + + # Check attributes. + if 'outside' in lattice_element.attrib: + material = lattice_element.attrib['outside'].strip() + del lattice_element.attrib['outside'] + + # Check subelements. + elif any([child.tag == 'outside' for child in lattice_element]): + elem = lattice_element.find('outside') + material = elem.text.strip() + lattice_element.remove(elem) + + # No 'outside' specified. This means the outside is a void. + else: + material = 'void' + + return material + + +def update_geometry(geometry_root): + """Update the given XML geometry tree. Return True if changes were made.""" + root = geometry_root + was_updated = False + + # Get a set of already-used universe and cell ids. + uids = get_universe_ids(root) + cids = get_cell_ids(root) + taken_ids = uids.union(cids) + + # Replace 'outside' with 'outer' in lattices. + for lat in chain(root.iter('lattice'), root.iter('hex_lattice')): + # Get the lattice's id. + lat_id = get_lat_id(lat) + + # Ignore lattices that have 'outer' specified. + if any([child.tag == 'outer' for child in lat]): continue + if 'outer' in lat.attrib: continue + + # Pop the 'outside' material. + material = pop_lat_outside(lat) + + # Get an id number for a new outer universe. Ideally, the id should + # be close to the lattice's id. + new_uid = find_new_id(taken_ids, preferred=lat_id) + assert new_uid not in taken_ids + + # Add the new universe filled with the old 'outside' material to the + # geometry. + new_cell = ET.Element('cell') + new_cell.attrib['id'] = str(new_uid) + new_cell.attrib['universe'] = str(new_uid) + new_cell.attrib['material'] = material + root.append(new_cell) + taken_ids.add(new_uid) + + # Add the new universe to the lattice's 'outer' attribute. + lat.attrib['outer'] = str(new_uid) + + was_updated = True + + # Remove 'type' from lattice definitions. + for lat in root.iter('lattice'): + elem = lat.find('type') + if elem is not None: + lat.remove(elem) + was_updated = True + if 'type' in lat.attrib: + del lat.attrib['type'] + was_updated = True + + # Change 'width' to 'pitch' in lattice definitions. + for lat in root.iter('lattice'): + elem = lat.find('width') + if elem is not None: + elem.tag = 'pitch' + was_updated = True + if 'width' in lat.attrib: + lat.attrib['pitch'] = lat.attrib['width'] + del lat.attrib['width'] + was_updated = True + + # Change 'surfaces' to 'region' in cell definitions + for cell in root.iter('cell'): + elem = cell.find('surfaces') + if elem is not None: + elem.tag = 'region' + was_updated = True + if 'surfaces' in cell.attrib: + cell.attrib['region'] = cell.attrib['surfaces'] + del cell.attrib['surfaces'] + was_updated = True + + return was_updated + +def update_materials(root): + """Update the given XML materials tree. Return True if changes were made.""" + was_updated = False + + for material in root.findall('material'): + for nuclide in material.findall('nuclide'): + if 'name' in nuclide.attrib: + nucname = nuclide.attrib['name'].replace('-', '') + # If a nuclide name is in the ZAID notation (e.g., a number), + # convert it to the proper nuclide name. + if nucname.strip().isnumeric(): + nucname = openmc.data.ace.get_metadata(int(nucname))[0] + nucname = nucname.replace('Nat', '0') + if nucname.endswith('m'): + nucname = nucname[:-1] + '_m1' + nuclide.set('name', nucname) + was_updated = True + + elif nuclide.find('name') is not None: + name_elem = nuclide.find('name') + nucname = name_elem.text + nucname = nucname.replace('-', '') + nucname = nucname.replace('Nat', '0') + if nucname.endswith('m'): + nucname = nucname[:-1] + '_m1' + name_elem.text = nucname + was_updated = True + + for sab in material.findall('sab'): + if 'name' in sab.attrib: + sabname = sab.attrib['name'] + sab.set('name', openmc.data.get_thermal_name(sabname)) + was_updated = True + + elif sab.find('name') is not None: + name_elem = sab.find('name') + sabname = name_elem.text + name_elem.text = openmc.data.get_thermal_name(sabname) + was_updated = True + + return was_updated + + +if __name__ == '__main__': + args = parse_args() + for fname in args.input: + # Parse the XML data. + tree = ET.parse(fname) + root = tree.getroot() + was_updated = False + + if root.tag == 'geometry': + was_updated = update_geometry(root) + elif root.tag == 'materials': + was_updated = update_materials(root) + + if was_updated: + # Move the original geometry file to preserve it. + move(fname, fname + '.original') + + # Write a new geometry file. + tree.write(fname, xml_declaration=True) diff --git a/scripts/openmc-update-mgxs b/scripts/openmc-update-mgxs new file mode 100755 index 000000000..aac6959b7 --- /dev/null +++ b/scripts/openmc-update-mgxs @@ -0,0 +1,212 @@ +#!/usr/bin/env python3 +"""Update OpenMC's deprecated multi-group cross section XML files to the latest +HDF5-based format. + +""" + +import os +import warnings +import xml.etree.ElementTree as ET + +import argparse +import numpy as np + +import openmc.mgxs_library + + +def parse_args(): + """Read the input files from the commandline.""" + # Create argument parser + parser = argparse.ArgumentParser(description=__doc__, + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument('-i', '--input', type=argparse.FileType('r'), + help='input XML file') + parser.add_argument('-o', '--output', nargs='?', default='', + help='output file, in HDF5 format') + args = vars(parser.parse_args()) + + if args['output'] == '': + filename = args['input'].name + extension = os.path.splitext(filename) + if extension == '.xml': + filename = filename[:filename.rfind('.')] + '.h5' + args['output'] = filename + + # Parse and return commandline arguments. + return args + + +def get_data(element, entry): + value = element.find(entry) + if value is not None: + value = value.text.strip() + elif entry in element.attrib: + value = element.attrib[entry].strip() + else: + value = None + + return value + + +def main(): + args = parse_args() + + # Parse the XML data. + tree = ET.parse(args['input']) + root = tree.getroot() + + # Get old metadata + group_structure = tree.find('group_structure').text.strip() + group_structure = np.array(group_structure.split(), dtype=float) + # Convert from MeV to eV + group_structure *= 1.e6 + energy_groups = openmc.mgxs.EnergyGroups(group_structure) + + inverse_velocity = tree.find('inverse-velocity') + if inverse_velocity is not None: + inverse_velocity = inverse_velocity.text.split() + inverse_velocity = np.array(inverse_velocity, dtype=float) + else: + inverse_velocity = None + + xsd = [] + names = [] + + # Now move on to the cross section data itself + for xsdata_elem in root.iter('xsdata'): + name = get_data(xsdata_elem, 'name') + + temperature = get_data(xsdata_elem, 'kT') + if temperature is not None: + temperature = float(temperature) / openmc.data.K_BOLTZMANN * 1.E6 + else: + temperature = 294. + temperatures = [temperature] + + awr = get_data(xsdata_elem, 'awr') + if awr is not None: + awr = float(awr) + + representation = get_data(xsdata_elem, 'representation') + if representation is None: + representation = 'isotropic' + if representation == 'angle': + n_azi = int(get_data(xsdata_elem, 'num_azimuthal')) + n_pol = int(get_data(xsdata_elem, 'num_polar')) + + scatter_format = get_data(xsdata_elem, 'scatt_type') + if scatter_format is None: + scatter_format = 'legendre' + + order = int(get_data(xsdata_elem, 'order')) + + tab_leg = get_data(xsdata_elem, 'tabular_legendre') + if tab_leg is not None: + warnings.warn('The tabular_legendre option has moved to the ' + 'settings.xml file and must be added manually') + + # Either add the data to a previously existing xsdata (if it is + # for the same 'name' but a different temperature), or create a + # new one. + try: + # It is in our list, so store that entry + i = names.index(name) + except ValueError: + # It is not in our list, so add it + i = -1 + xsd.append(openmc.XSdata(name, energy_groups, + temperatures=temperatures, + representation=representation)) + if awr is not None: + xsd[-1].atomic_weight_ratio = awr + if representation == 'angle': + xsd[-1].num_azimuthal = n_azi + xsd[-1].num_polar = n_pol + xsd[-1].scatter_format = scatter_format + xsd[-1].order = order + names.append(name) + + if scatter_format == 'legendre': + order_dim = order + 1 + else: + order_dim = order + + if i != -1: + xsd[i].add_temperature(temperature) + + total = get_data(xsdata_elem, 'total') + if total is not None: + total = np.array(total.split(), dtype=float) + total.shape = xsd[i].xs_shapes['[G]'] + xsd[i].set_total(total, temperature) + + if inverse_velocity is not None: + xsd[i].set_inverse_velocity(inverse_velocity, temperature) + + absorption = get_data(xsdata_elem, 'absorption') + absorption = np.array(absorption.split(), dtype=float) + absorption.shape = xsd[i].xs_shapes['[G]'] + xsd[i].set_absorption(absorption, temperature) + + scatter = get_data(xsdata_elem, 'scatter') + scatter = np.array(scatter.split(), dtype=float) + # This is now a flattened-array of something that started with a + # shape of [Order][G][G']; we need to unflatten and then switch the + # ordering + in_shape = (order_dim, energy_groups.num_groups, + energy_groups.num_groups) + if representation == 'angle': + in_shape = (n_pol, n_azi) + in_shape + scatter.shape = in_shape + scatter = np.swapaxes(scatter, 2, 3) + scatter = np.swapaxes(scatter, 3, 4) + else: + scatter.shape = in_shape + scatter = np.swapaxes(scatter, 0, 1) + scatter = np.swapaxes(scatter, 1, 2) + + xsd[i].set_scatter_matrix(scatter, temperature) + + multiplicity = get_data(xsdata_elem, 'multiplicity') + if multiplicity is not None: + multiplicity = np.array(multiplicity.split(), dtype=float) + multiplicity.shape = xsd[i].xs_shapes["[G][G']"] + xsd[i].set_multiplicity_matrix(multiplicity, temperature) + + fission = get_data(xsdata_elem, 'fission') + if fission is not None: + fission = np.array(fission.split(), dtype=float) + fission.shape = xsd[i].xs_shapes['[G]'] + xsd[i].set_fission(fission, temperature) + + kappa_fission = get_data(xsdata_elem, 'kappa_fission') + if kappa_fission is not None: + kappa_fission = np.array(kappa_fission.split(), dtype=float) + kappa_fission.shape = xsd[i].xs_shapes['[G]'] + xsd[i].set_kappa_fission(kappa_fission, temperature) + + chi = get_data(xsdata_elem, 'chi') + if chi is not None: + chi = np.array(chi.split(), dtype=float) + chi.shape = xsd[i].xs_shapes['[G]'] + xsd[i].set_chi(chi, temperature) + else: + chi = None + + nu_fission = get_data(xsdata_elem, 'nu_fission') + if nu_fission is not None: + nu_fission = np.array(nu_fission.split(), dtype=float) + if chi is not None: + nu_fission.shape = xsd[i].xs_shapes['[G]'] + else: + nu_fission.shape = xsd[i].xs_shapes["[G][G']"] + xsd[i].set_nu_fission(nu_fission, temperature) + + # Build library as we go, but first we have enough to initialize it + lib = openmc.MGXSLibrary(energy_groups) + lib.add_xsdatas(xsd) + lib.export_to_hdf5(args['output']) + + +if __name__ == '__main__': + main() diff --git a/scripts/openmc-voxel-to-vtk b/scripts/openmc-voxel-to-vtk new file mode 100755 index 000000000..3f59ffd42 --- /dev/null +++ b/scripts/openmc-voxel-to-vtk @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +from argparse import ArgumentParser + +import openmc + + +if __name__ == "__main__": + # Process command line arguments + parser = ArgumentParser('Converts a voxel HDF5 file to a VTK file') + parser.add_argument("voxel_file", help="Path to voxel h5 file") + parser.add_argument( + "-o", + "--output", + action="store", + default="plot", + help="Path to output VTK file.", + ) + args = parser.parse_args() + print("Reading and translating data...") + openmc.voxel_to_vtk(args.voxel_file, args.output) + print(f"Written VTK file {args.output}...") diff --git a/setup.py b/setup.py new file mode 100755 index 000000000..de87e1490 --- /dev/null +++ b/setup.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python + +import glob +import sys +import numpy as np + +from setuptools import setup, find_packages +from Cython.Build import cythonize + + +# Determine shared library suffix +if sys.platform == 'darwin': + suffix = 'dylib' +else: + suffix = 'so' + +# Get version information from __init__.py. This is ugly, but more reliable than +# using an import. +with open('openmc/__init__.py', 'r') as f: + version = f.readlines()[-1].split()[-1].strip("'") + +kwargs = { + 'name': 'openmc', + 'version': version, + 'packages': find_packages(exclude=['tests*']), + 'scripts': glob.glob('scripts/openmc-*'), + + # Data files and libraries + 'package_data': { + 'openmc.lib': ['libopenmc.{}'.format(suffix)], + 'openmc.data': ['mass_1.mas20.txt', 'BREMX.DAT', 'half_life.json', '*.h5'], + 'openmc.data.effective_dose': ['*.txt'] + }, + + # Metadata + 'author': 'The OpenMC Development Team', + 'author_email': 'openmc@anl.gov', + 'description': 'OpenMC', + 'url': 'https://openmc.org', + 'download_url': 'https://github.com/openmc-dev/openmc/releases', + 'project_urls': { + 'Issue Tracker': 'https://github.com/openmc-dev/openmc/issues', + 'Documentation': 'https://docs.openmc.org', + 'Source Code': 'https://github.com/openmc-dev/openmc', + }, + 'classifiers': [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: End Users/Desktop', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Topic :: Scientific/Engineering' + 'Programming Language :: C++', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + ], + + # Dependencies + 'python_requires': '>=3.10', + 'install_requires': [ + 'numpy>=1.9', 'h5py', 'scipy', 'ipython', 'matplotlib', + 'pandas', 'lxml', 'uncertainties', 'setuptools' + ], + 'extras_require': { + 'depletion-mpi': ['mpi4py'], + 'docs': ['sphinx', 'sphinxcontrib-katex', 'sphinx-numfig', 'jupyter', + 'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme'], + 'test': ['pytest', 'pytest-cov', 'colorama', 'openpyxl'], + 'vtk': ['vtk'], + }, + # Cython is used to add resonance reconstruction and fast float_endf + 'ext_modules': cythonize('openmc/data/*.pyx'), + 'include_dirs': [np.get_include()] +} + +setup(**kwargs) diff --git a/src/atomic_mass.cpp b/src/atomic_mass.cpp deleted file mode 100644 index 0e63c9603..000000000 --- a/src/atomic_mass.cpp +++ /dev/null @@ -1,3569 +0,0 @@ -#include "openmc/atomic_mass.h" - -namespace openmc { - -// Atomic masses in [u] from AME2020 and CODATA 2018 -std::unordered_map ATOMIC_MASS = { - {11, MASS_ELECTRON}, - {22, 0.0}, - {2112, MASS_NEUTRON}, - {2212, MASS_PROTON}, - {1000010020, MASS_DEUTRON}, - {1000020030, MASS_HELION}, - {1000020040, MASS_ALPHA}, - {1000010030, 3.01604928132}, - {1000030030, 3.030775}, - {1000010040, 4.026431867}, - {1000030040, 4.027185561}, - {1000010050, 5.035311492}, - {1000020050, 5.012057224}, - {1000030050, 5.0125378}, - {1000040050, 5.03987}, - {1000010060, 6.044955437}, - {1000020060, 6.018885889}, - {1000030060, 6.01512288742}, - {1000040060, 6.0197264090000004}, - {1000050060, 6.0508}, - {1000010070, 7.052749}, - {1000020070, 7.027990652}, - {1000030070, 7.01600343426}, - {1000040070, 7.016928714}, - {1000050070, 7.029712}, - {1000020080, 8.033934388}, - {1000030080, 8.022486244}, - {1000040080, 8.005305102}, - {1000050080, 8.024607315}, - {1000060080, 8.037643039}, - {1000020090, 9.043946414}, - {1000030090, 9.026790191}, - {1000040090, 9.012183062}, - {1000050090, 9.013329645}, - {1000060090, 9.031037202}, - {1000020100, 10.052815306}, - {1000030100, 10.035483453}, - {1000040100, 10.013534692}, - {1000050100, 10.012936862}, - {1000060100, 10.016853217}, - {1000070100, 10.04165354}, - {1000030110, 11.043723581}, - {1000040110, 11.02166108}, - {1000050110, 11.009305166}, - {1000060110, 11.011432597}, - {1000070110, 11.026157593}, - {1000080110, 11.051249828}, - {1000030120, 12.052613942}, - {1000040120, 12.026922082}, - {1000050120, 12.014352638}, - {1000060120, 12.0}, - {1000070120, 12.01861318}, - {1000080120, 12.034367726}, - {1000030130, 13.061171503}, - {1000040130, 13.036134506}, - {1000050130, 13.017779981}, - {1000060130, 13.00335483534}, - {1000070130, 13.005738609}, - {1000080130, 13.024815435}, - {1000090130, 13.045121}, - {1000040140, 14.04289292}, - {1000050140, 14.02540401}, - {1000060140, 14.00324198862}, - {1000070140, 14.00307400425}, - {1000080140, 14.008596706}, - {1000090140, 14.034315196}, - {1000040150, 15.053490215}, - {1000050150, 15.031087023}, - {1000060150, 15.010599256}, - {1000070150, 15.00010889827}, - {1000080150, 15.003065636}, - {1000090150, 15.017785139}, - {1000100150, 15.043172977}, - {1000040160, 16.061672036}, - {1000050160, 16.039841045}, - {1000060160, 16.014701255}, - {1000070160, 16.006101925}, - {1000080160, 15.99491461926}, - {1000090160, 16.011460278}, - {1000100160, 16.02575086}, - {1000050170, 17.046931399}, - {1000060170, 17.02257865}, - {1000070170, 17.008448876}, - {1000080170, 16.99913175595}, - {1000090170, 17.002095237}, - {1000100170, 17.017713962}, - {1000110170, 17.037273}, - {1000050180, 18.055601683}, - {1000060180, 18.02675193}, - {1000070180, 18.014077563}, - {1000080180, 17.99915961214}, - {1000090180, 18.000937324}, - {1000100180, 18.005708696}, - {1000110180, 18.026879388}, - {1000050190, 19.064166}, - {1000060190, 19.034797594}, - {1000070190, 19.017022389}, - {1000080190, 19.003577969}, - {1000090190, 18.99840316207}, - {1000100190, 19.001880906}, - {1000110190, 19.013880264}, - {1000120190, 19.03417992}, - {1000050200, 20.074505644}, - {1000060200, 20.040261732}, - {1000070200, 20.023367295}, - {1000080200, 20.004075357}, - {1000090200, 19.999981252}, - {1000100200, 19.99244017525}, - {1000110200, 20.007354301}, - {1000120200, 20.018763075}, - {1000050210, 21.084147485}, - {1000060210, 21.049}, - {1000070210, 21.027087573}, - {1000080210, 21.008654948}, - {1000090210, 20.999948893}, - {1000100210, 20.993846685}, - {1000110210, 20.997654459}, - {1000120210, 21.011705764}, - {1000130210, 21.029082}, - {1000060220, 22.05755399}, - {1000070220, 22.034100918}, - {1000080220, 22.009965744}, - {1000090220, 22.002998812}, - {1000100220, 21.991385113}, - {1000110220, 21.994437547}, - {1000120220, 21.999570597}, - {1000130220, 22.01954}, - {1000140220, 22.036114}, - {1000060230, 23.06889}, - {1000070230, 23.039421}, - {1000080230, 23.015696686}, - {1000090230, 23.003526875}, - {1000100230, 22.994466905}, - {1000110230, 22.98976928195}, - {1000120230, 22.994123768}, - {1000130230, 23.007244351}, - {1000140230, 23.025711}, - {1000070240, 24.05039}, - {1000080240, 24.019861}, - {1000090240, 24.00809937}, - {1000100240, 23.993610649}, - {1000110240, 23.990963012}, - {1000120240, 23.985041689}, - {1000130240, 23.999947598}, - {1000140240, 24.01153543}, - {1000150240, 24.036522}, - {1000070250, 25.0601}, - {1000080250, 25.029338919}, - {1000090250, 25.012167727}, - {1000100250, 24.997814797}, - {1000110250, 24.989953974}, - {1000120250, 24.985836966}, - {1000130250, 24.990428308}, - {1000140250, 25.004108798}, - {1000150250, 25.021675}, - {1000080260, 26.037210155}, - {1000090260, 26.020048065}, - {1000100260, 26.000516496}, - {1000110260, 25.992634649}, - {1000120260, 25.982592972}, - {1000130260, 25.986891876}, - {1000140260, 25.992333818}, - {1000150260, 26.01178}, - {1000160260, 26.029716}, - {1000080270, 27.047955}, - {1000090270, 27.026981897}, - {1000100270, 27.007569462}, - {1000110270, 26.994076408}, - {1000120270, 26.984340647}, - {1000130270, 26.981538408}, - {1000140270, 26.986704687}, - {1000150270, 26.999292499}, - {1000160270, 27.018777}, - {1000080280, 28.05591}, - {1000090280, 28.035860448}, - {1000100280, 28.012130767}, - {1000110280, 27.998939}, - {1000120280, 27.983875426}, - {1000130280, 27.981910009}, - {1000140280, 27.97692653442}, - {1000150280, 27.99232646}, - {1000160280, 28.004372762}, - {1000170280, 28.030349}, - {1000090290, 29.043103}, - {1000100290, 29.019753}, - {1000110290, 29.002877091}, - {1000120290, 28.988607163}, - {1000130290, 28.980453164}, - {1000140290, 28.97649466434}, - {1000150290, 28.981800368}, - {1000160290, 28.996678}, - {1000170290, 29.015053}, - {1000180290, 29.040761}, - {1000090300, 30.052561}, - {1000100300, 30.024992235}, - {1000110300, 30.009097931}, - {1000120300, 29.990465454}, - {1000130300, 29.982969171}, - {1000140300, 29.973770137}, - {1000150300, 29.97831349}, - {1000160300, 29.98490677}, - {1000170300, 30.005018333}, - {1000180300, 30.023694}, - {1000090310, 31.061023}, - {1000100310, 31.033474816}, - {1000110310, 31.013146654}, - {1000120310, 30.996648232}, - {1000130310, 30.983949754}, - {1000140310, 30.975363196}, - {1000150310, 30.97376199768}, - {1000160310, 30.979557002}, - {1000170310, 30.992448097}, - {1000180310, 31.012158}, - {1000190310, 31.03678}, - {1000100320, 32.03972}, - {1000110320, 32.020011024}, - {1000120320, 31.999110138}, - {1000130320, 31.988084338}, - {1000140320, 31.974151538}, - {1000150320, 31.973907643}, - {1000160320, 31.97207117354}, - {1000170320, 31.985684605}, - {1000180320, 31.997637824}, - {1000190320, 32.023607}, - {1000100330, 33.049523}, - {1000110330, 33.025529}, - {1000120330, 33.005327862}, - {1000130330, 32.990877685}, - {1000140330, 32.977976964}, - {1000150330, 32.971725692}, - {1000160330, 32.97145890862}, - {1000170330, 32.977451988}, - {1000180330, 32.989925545}, - {1000190330, 33.008095}, - {1000200330, 33.033312}, - {1000100340, 34.056728}, - {1000110340, 34.03401}, - {1000120340, 34.008935455}, - {1000130340, 33.996781924}, - {1000140340, 33.978538045}, - {1000150340, 33.973645886}, - {1000160340, 33.967867011}, - {1000170340, 33.97376249}, - {1000180340, 33.980270092}, - {1000190340, 33.99869}, - {1000200340, 34.015985}, - {1000110350, 35.040614}, - {1000120350, 35.01679}, - {1000130350, 34.999759816}, - {1000140350, 34.984550111}, - {1000150350, 34.973314045}, - {1000160350, 34.969032321}, - {1000170350, 34.968852694}, - {1000180350, 34.975257719}, - {1000190350, 34.988005406}, - {1000200350, 35.005572}, - {1000210350, 35.029093}, - {1000110360, 36.049279}, - {1000120360, 36.021879}, - {1000130360, 36.006388}, - {1000140360, 35.986649271}, - {1000150360, 35.97825961}, - {1000160360, 35.967080692}, - {1000170360, 35.968306822}, - {1000180360, 35.967545106}, - {1000190360, 35.981301887}, - {1000200360, 35.993074388}, - {1000210360, 36.017338}, - {1000110370, 37.057042}, - {1000120370, 37.030286265}, - {1000130370, 37.010531}, - {1000140370, 36.992945191}, - {1000150370, 36.979606942}, - {1000160370, 36.9711255}, - {1000170370, 36.965902573}, - {1000180370, 36.966776301}, - {1000190370, 36.97337589}, - {1000200370, 36.985897849}, - {1000210370, 37.004058}, - {1000220370, 37.027021}, - {1000110380, 38.066458}, - {1000120380, 38.03658}, - {1000130380, 38.017681}, - {1000140380, 37.995523}, - {1000150380, 37.984303105}, - {1000160380, 37.9711633}, - {1000170380, 37.968010408}, - {1000180380, 37.962732102}, - {1000190380, 37.969081114}, - {1000200380, 37.976319223}, - {1000210380, 37.995438}, - {1000220380, 38.012206}, - {1000110390, 39.075123}, - {1000120390, 39.045921}, - {1000130390, 39.02307}, - {1000140390, 39.002491}, - {1000150390, 38.986285865}, - {1000160390, 38.97513385}, - {1000170390, 38.968008151}, - {1000180390, 38.964313037}, - {1000190390, 38.96370648482}, - {1000200390, 38.970710811}, - {1000210390, 38.984784953}, - {1000220390, 39.002684}, - {1000230390, 39.02423}, - {1000120400, 40.053194}, - {1000130400, 40.03094}, - {1000140400, 40.006083641}, - {1000150400, 39.991262221}, - {1000160400, 39.975482561}, - {1000170400, 39.970415466}, - {1000180400, 39.96238312204}, - {1000190400, 39.963998165}, - {1000200400, 39.96259085}, - {1000210400, 39.977967275}, - {1000220400, 39.990345146}, - {1000230400, 40.013387}, - {1000120410, 41.062373}, - {1000130410, 41.037134}, - {1000140410, 41.014171}, - {1000150410, 40.994654}, - {1000160410, 40.979593451}, - {1000170410, 40.970684525}, - {1000180410, 40.96450057}, - {1000190410, 40.96182525611}, - {1000200410, 40.962277905}, - {1000210410, 40.969251163}, - {1000220410, 40.983148}, - {1000230410, 41.000333}, - {1000240410, 41.021911}, - {1000130420, 42.045078}, - {1000140420, 42.018078}, - {1000150420, 42.00117214}, - {1000160420, 41.9810651}, - {1000170420, 41.973342}, - {1000180420, 41.963045737}, - {1000190420, 41.962402305}, - {1000200420, 41.95861778}, - {1000210420, 41.965516686}, - {1000220420, 41.973049369}, - {1000230420, 41.99182}, - {1000240420, 42.007579}, - {1000130430, 43.05182}, - {1000140430, 43.026119}, - {1000150430, 43.005411}, - {1000160430, 42.986907635}, - {1000170430, 42.9740637}, - {1000180430, 42.965636056}, - {1000190430, 42.960734701}, - {1000200430, 42.958766381}, - {1000210430, 42.961150425}, - {1000220430, 42.96852842}, - {1000230430, 42.980766}, - {1000240430, 42.997885}, - {1000250430, 43.018647}, - {1000140440, 44.031466}, - {1000150440, 44.011927}, - {1000160440, 43.990118846}, - {1000170440, 43.978014918}, - {1000180440, 43.964923814}, - {1000190440, 43.961586984}, - {1000200440, 43.955481489}, - {1000210440, 43.959402818}, - {1000220440, 43.959689936}, - {1000230440, 43.974440977}, - {1000240440, 43.985591}, - {1000250440, 44.008009}, - {1000140450, 45.039818}, - {1000150450, 45.017134}, - {1000160450, 44.996414}, - {1000170450, 44.980394353}, - {1000180450, 44.968039731}, - {1000190450, 44.960691491}, - {1000200450, 44.95618627}, - {1000210450, 44.955907051}, - {1000220450, 44.958120758}, - {1000230450, 44.965768498}, - {1000240450, 44.97905}, - {1000250450, 44.994654}, - {1000260450, 45.015467}, - {1000150460, 46.02452}, - {1000160460, 46.000687}, - {1000170460, 45.985254926}, - {1000180460, 45.968039243999996}, - {1000190460, 45.961981584}, - {1000200460, 45.953687726}, - {1000210460, 45.955167034}, - {1000220460, 45.952626356}, - {1000230460, 45.960197389}, - {1000240460, 45.968360969}, - {1000250460, 45.986669}, - {1000260460, 46.001299}, - {1000150470, 47.030929}, - {1000160470, 47.00773}, - {1000170470, 46.989715}, - {1000180470, 46.972767112}, - {1000190470, 46.961661612}, - {1000200470, 46.954541134}, - {1000210470, 46.952402444}, - {1000220470, 46.951757491}, - {1000230470, 46.954903558}, - {1000240470, 46.962894995}, - {1000250470, 46.975774}, - {1000260470, 46.992346}, - {1000270470, 47.011401}, - {1000160480, 48.013301}, - {1000170480, 47.995405}, - {1000180480, 47.976001}, - {1000190480, 47.965341184}, - {1000200480, 47.952522654}, - {1000210480, 47.952222903}, - {1000220480, 47.947940677}, - {1000230480, 47.9522509}, - {1000240480, 47.954029431}, - {1000250480, 47.96854876}, - {1000260480, 47.980667}, - {1000270480, 48.001857}, - {1000280480, 48.019515}, - {1000160490, 49.021891}, - {1000170490, 49.000794}, - {1000180490, 48.981685}, - {1000190490, 48.968210753}, - {1000200490, 48.955662625}, - {1000210490, 48.950013159}, - {1000220490, 48.947864391}, - {1000230490, 48.948510509}, - {1000240490, 48.95133372}, - {1000250490, 48.95961335}, - {1000260490, 48.973429}, - {1000270490, 48.989501}, - {1000280490, 49.009157}, - {1000170500, 50.008266}, - {1000180500, 49.985797}, - {1000190500, 49.972380015}, - {1000200500, 49.957499215}, - {1000210500, 49.952187437}, - {1000220500, 49.944785622}, - {1000230500, 49.947156681}, - {1000240500, 49.946042209}, - {1000250500, 49.954238157}, - {1000260500, 49.962988}, - {1000270500, 49.981117}, - {1000280500, 49.996286}, - {1000170510, 51.015341}, - {1000180510, 50.993033}, - {1000190510, 50.975828664}, - {1000200510, 50.960995663}, - {1000210510, 50.953568838}, - {1000220510, 50.946609468}, - {1000230510, 50.943957664}, - {1000240510, 50.944765388}, - {1000250510, 50.94820877}, - {1000260510, 50.956855137}, - {1000270510, 50.970647}, - {1000280510, 50.987493}, - {1000170520, 52.024004}, - {1000180520, 51.998519}, - {1000190520, 51.981602}, - {1000200520, 51.963213646}, - {1000210520, 51.95649617}, - {1000220520, 51.946883509}, - {1000230520, 51.944773636}, - {1000240520, 51.940504714}, - {1000250520, 51.94555909}, - {1000260520, 51.948113364}, - {1000270520, 51.963130224}, - {1000280520, 51.975781}, - {1000290520, 51.997982}, - {1000180530, 53.00729}, - {1000190530, 52.9868}, - {1000200530, 52.968451}, - {1000210530, 52.958379173}, - {1000220530, 52.949670714}, - {1000230530, 52.94433494}, - {1000240530, 52.940646304}, - {1000250530, 52.941287497}, - {1000260530, 52.945305629}, - {1000270530, 52.954203278}, - {1000280530, 52.96819}, - {1000290530, 52.985894}, - {1000180540, 54.013484}, - {1000190540, 53.994471}, - {1000200540, 53.972989}, - {1000210540, 53.963029359}, - {1000220540, 53.950892}, - {1000230540, 53.946432009}, - {1000240540, 53.938877359}, - {1000250540, 53.940355772}, - {1000260540, 53.939608189}, - {1000270540, 53.948459075}, - {1000280540, 53.957833}, - {1000290540, 53.977198}, - {1000300540, 53.993879}, - {1000190550, 55.000505}, - {1000200550, 54.979978}, - {1000210550, 54.966889637}, - {1000220550, 54.955091}, - {1000230550, 54.947262}, - {1000240550, 54.940836637}, - {1000250550, 54.93804304}, - {1000260550, 54.938291158}, - {1000270550, 54.941996416}, - {1000280550, 54.951329846}, - {1000290550, 54.966038}, - {1000300550, 54.984681}, - {1000190560, 56.008567}, - {1000200560, 55.985496}, - {1000210560, 55.972607611}, - {1000220560, 55.957677675}, - {1000230560, 55.950420082}, - {1000240560, 55.940648977}, - {1000250560, 55.938902816}, - {1000260560, 55.934935537}, - {1000270560, 55.939838032}, - {1000280560, 55.942127761}, - {1000290560, 55.958529278}, - {1000300560, 55.972743}, - {1000310560, 55.995878}, - {1000190570, 57.015169}, - {1000200570, 56.992958}, - {1000210570, 56.977047999999996}, - {1000220570, 56.963068098}, - {1000230570, 56.952297}, - {1000240570, 56.943612112}, - {1000250570, 56.938285944}, - {1000260570, 56.93539195}, - {1000270570, 56.936289819}, - {1000280570, 56.939791394}, - {1000290570, 56.949211686}, - {1000300570, 56.965056}, - {1000310570, 56.983457}, - {1000190580, 58.023543}, - {1000200580, 57.998357}, - {1000210580, 57.983382}, - {1000220580, 57.966808519}, - {1000230580, 57.956595985}, - {1000240580, 57.944184501}, - {1000250580, 57.940066643}, - {1000260580, 57.933273575}, - {1000270580, 57.935751292}, - {1000280580, 57.93534165}, - {1000290580, 57.944532283}, - {1000300580, 57.954590296}, - {1000310580, 57.974728999999996}, - {1000320580, 57.991863}, - {1000190590, 59.030864}, - {1000200590, 59.006237}, - {1000210590, 58.988374}, - {1000220590, 58.972217}, - {1000230590, 58.959623343}, - {1000240590, 58.948345426}, - {1000250590, 58.940391111}, - {1000260590, 58.934873492}, - {1000270590, 58.933193523999996}, - {1000280590, 58.934345442}, - {1000290590, 58.939496713}, - {1000300590, 58.949311886}, - {1000310590, 58.963757}, - {1000320590, 58.982426}, - {1000200600, 60.011809}, - {1000210600, 59.995115}, - {1000220600, 59.976275}, - {1000230600, 59.964479215}, - {1000240600, 59.949641656}, - {1000250600, 59.943136574}, - {1000260600, 59.934070249}, - {1000270600, 59.933815536}, - {1000280600, 59.930785129}, - {1000290600, 59.937363787}, - {1000300600, 59.941841317}, - {1000310600, 59.957498}, - {1000320600, 59.970445}, - {1000330600, 59.993945}, - {1000200610, 61.020408}, - {1000210610, 61.000537}, - {1000220610, 60.982426}, - {1000230610, 60.967603529}, - {1000240610, 60.95437813}, - {1000250610, 60.944452541}, - {1000260610, 60.936746241}, - {1000270610, 60.932476031}, - {1000280610, 60.931054819}, - {1000290610, 60.933457375}, - {1000300610, 60.939506964}, - {1000310610, 60.949398861}, - {1000320610, 60.963725}, - {1000330610, 60.981535}, - {1000210620, 62.007848}, - {1000220620, 61.986903}, - {1000230620, 61.972932556}, - {1000240620, 61.95614292}, - {1000250620, 61.947907384}, - {1000260620, 61.936791809}, - {1000270620, 61.934058198}, - {1000280620, 61.928344753}, - {1000290620, 61.932594803}, - {1000300620, 61.934333359}, - {1000310620, 61.944189639}, - {1000320620, 61.954761}, - {1000330620, 61.973784}, - {1000210630, 63.014031}, - {1000220630, 62.993709}, - {1000230630, 62.976661}, - {1000240630, 62.961161}, - {1000250630, 62.949664672}, - {1000260630, 62.940272698}, - {1000270630, 62.93359963}, - {1000280630, 62.929669021}, - {1000290630, 62.929597119}, - {1000300630, 62.93321114}, - {1000310630, 62.939294194}, - {1000320630, 62.949628}, - {1000330630, 62.964036}, - {1000340630, 62.981911}, - {1000220640, 63.998411}, - {1000230640, 63.98248}, - {1000240640, 63.963886}, - {1000250640, 63.953849369}, - {1000260640, 63.940987761}, - {1000270640, 63.935810176}, - {1000280640, 63.927966228}, - {1000290640, 63.929764001}, - {1000300640, 63.929141776}, - {1000310640, 63.936840366}, - {1000320640, 63.941689912}, - {1000330640, 63.95756}, - {1000340640, 63.971165}, - {1000220650, 65.005593}, - {1000230650, 64.986999}, - {1000240650, 64.969608}, - {1000250650, 64.956019749}, - {1000260650, 64.945015323}, - {1000270650, 64.936462071}, - {1000280650, 64.930084585}, - {1000290650, 64.927789476}, - {1000300650, 64.929240534}, - {1000310650, 64.932734424}, - {1000320650, 64.939368136}, - {1000330650, 64.949611}, - {1000340650, 64.964552}, - {1000350650, 64.982297}, - {1000230660, 65.993237}, - {1000240660, 65.973011}, - {1000250660, 65.960546833}, - {1000260660, 65.946249958}, - {1000270660, 65.939442943}, - {1000280660, 65.929139333}, - {1000290660, 65.928868804}, - {1000300660, 65.926033639}, - {1000310660, 65.931589766}, - {1000320660, 65.933862124}, - {1000330660, 65.944148778}, - {1000340660, 65.955276}, - {1000350660, 65.974697}, - {1000230670, 66.998128}, - {1000240670, 66.979313}, - {1000250670, 66.96395}, - {1000260670, 66.95093}, - {1000270670, 66.940609625}, - {1000280670, 66.931569413}, - {1000290670, 66.92772949}, - {1000300670, 66.927127422}, - {1000310670, 66.928202276}, - {1000320670, 66.932716999}, - {1000330670, 66.93925111}, - {1000340670, 66.949994}, - {1000350670, 66.965078}, - {1000360670, 66.983305}, - {1000240680, 67.983156}, - {1000250680, 67.968953}, - {1000260680, 67.952875}, - {1000270680, 67.944559401}, - {1000280680, 67.931868787}, - {1000290680, 67.929610887}, - {1000300680, 67.924844232}, - {1000310680, 67.927980161}, - {1000320680, 67.928095305}, - {1000330680, 67.936774127}, - {1000340680, 67.941825236}, - {1000350680, 67.958356}, - {1000360680, 67.972489}, - {1000240690, 68.989662}, - {1000250690, 68.972775}, - {1000260690, 68.957918}, - {1000270690, 68.945909}, - {1000280690, 68.935610267}, - {1000290690, 68.929429267}, - {1000300690, 68.92655036}, - {1000310690, 68.925573528}, - {1000320690, 68.927964467}, - {1000330690, 68.932246289}, - {1000340690, 68.939414845}, - {1000350690, 68.95033841}, - {1000360690, 68.965496}, - {1000240700, 69.993945}, - {1000250700, 69.978046}, - {1000260700, 69.960397}, - {1000270700, 69.9500534}, - {1000280700, 69.9364313}, - {1000290700, 69.932392078}, - {1000300700, 69.925319175}, - {1000310700, 69.926021914}, - {1000320700, 69.924248542}, - {1000330700, 69.930934642}, - {1000340700, 69.933515521}, - {1000350700, 69.944792321}, - {1000360700, 69.955877}, - {1000250710, 70.982158}, - {1000260710, 70.965722}, - {1000270710, 70.952366923}, - {1000280710, 70.940518962}, - {1000290710, 70.932676831}, - {1000300710, 70.927719578}, - {1000310710, 70.924702554}, - {1000320710, 70.92495212}, - {1000330710, 70.927113594}, - {1000340710, 70.932209431}, - {1000350710, 70.939342153}, - {1000360710, 70.950265695}, - {1000370710, 70.965335}, - {1000250720, 71.988009}, - {1000260720, 71.968599}, - {1000270720, 71.956736}, - {1000280720, 71.941785924}, - {1000290720, 71.935820306}, - {1000300720, 71.926842806}, - {1000310720, 71.926367452}, - {1000320720, 71.922075824}, - {1000330720, 71.926752291}, - {1000340720, 71.927140506}, - {1000350720, 71.936594606}, - {1000360720, 71.942092406}, - {1000370720, 71.958851}, - {1000250730, 72.992807}, - {1000260730, 72.974246}, - {1000270730, 72.959238}, - {1000280730, 72.946206681}, - {1000290730, 72.936674376}, - {1000300730, 72.92958258}, - {1000310730, 72.92517468}, - {1000320730, 72.923458954}, - {1000330730, 72.923829086}, - {1000340730, 72.926754881}, - {1000350730, 72.931673441}, - {1000360730, 72.939289193}, - {1000370730, 72.950604506}, - {1000380730, 72.9657}, - {1000260740, 73.977821}, - {1000270740, 73.963993}, - {1000280740, 73.947718}, - {1000290740, 73.93987486}, - {1000300740, 73.92940726}, - {1000310740, 73.926945725}, - {1000320740, 73.92117776}, - {1000330740, 73.923928596}, - {1000340740, 73.922475933}, - {1000350740, 73.929910279}, - {1000360740, 73.933084016}, - {1000370740, 73.944265867}, - {1000380740, 73.95617}, - {1000260750, 74.984219}, - {1000270750, 74.967192}, - {1000280750, 74.952506}, - {1000290750, 74.941523817}, - {1000300750, 74.932840244}, - {1000310750, 74.926504484}, - {1000320750, 74.92285837}, - {1000330750, 74.921594562}, - {1000340750, 74.92252287}, - {1000350750, 74.925810566}, - {1000360750, 74.930945744}, - {1000370750, 74.9385732}, - {1000380750, 74.949952767}, - {1000390750, 74.96584}, - {1000260760, 75.988631}, - {1000270760, 75.972453}, - {1000280760, 75.954707}, - {1000290760, 75.945268974}, - {1000300760, 75.933114956}, - {1000310760, 75.928827624}, - {1000320760, 75.921402725}, - {1000330760, 75.922392011}, - {1000340760, 75.919213702}, - {1000350760, 75.924541574}, - {1000360760, 75.925910743}, - {1000370760, 75.935073031}, - {1000380760, 75.94176276}, - {1000390760, 75.958937}, - {1000270770, 76.976479}, - {1000280770, 76.959903}, - {1000290770, 76.947543599}, - {1000300770, 76.936887197}, - {1000310770, 76.929154299}, - {1000320770, 76.923549843}, - {1000330770, 76.920647555}, - {1000340770, 76.91991415}, - {1000350770, 76.921379193}, - {1000360770, 76.924669999}, - {1000370770, 76.930401599}, - {1000380770, 76.937945454}, - {1000390770, 76.950146}, - {1000400770, 76.966076}, - {1000270780, 77.983553}, - {1000280780, 77.962555}, - {1000290780, 77.951916524}, - {1000300780, 77.938289204}, - {1000310780, 77.931610854}, - {1000320780, 77.922852911}, - {1000330780, 77.921827771}, - {1000340780, 77.917309244}, - {1000350780, 77.921145858}, - {1000360780, 77.920366341}, - {1000370780, 77.928141866}, - {1000380780, 77.932179979}, - {1000390780, 77.94399}, - {1000400780, 77.956146}, - {1000280790, 78.969769}, - {1000290790, 78.9544731}, - {1000300790, 78.942638067}, - {1000310790, 78.932851582}, - {1000320790, 78.925359506}, - {1000330790, 78.920948419}, - {1000340790, 78.918499252}, - {1000350790, 78.918337574}, - {1000360790, 78.920082919}, - {1000370790, 78.923990095}, - {1000380790, 78.929704692}, - {1000390790, 78.937946}, - {1000400790, 78.94979}, - {1000410790, 78.966022}, - {1000280800, 79.975051}, - {1000290800, 79.960623}, - {1000300800, 79.944552929}, - {1000310800, 79.936420773}, - {1000320800, 79.925350773}, - {1000330800, 79.92247444}, - {1000340800, 79.916521761}, - {1000350800, 79.918529784}, - {1000360800, 79.91637794}, - {1000370800, 79.922516442}, - {1000380800, 79.924517538}, - {1000390800, 79.93435475}, - {1000400800, 79.941213}, - {1000410800, 79.958754}, - {1000280810, 80.982727}, - {1000290810, 80.965743}, - {1000300810, 80.950402617}, - {1000310810, 80.938133841}, - {1000320810, 80.928832941}, - {1000330810, 80.922132288}, - {1000340810, 80.917993019}, - {1000350810, 80.916288197}, - {1000360810, 80.916589703}, - {1000370810, 80.9189939}, - {1000380810, 80.923211393}, - {1000390810, 80.929454283}, - {1000400810, 80.938245}, - {1000410810, 80.95023}, - {1000420810, 80.966226}, - {1000280820, 81.988492}, - {1000290820, 81.972378}, - {1000300820, 81.954574097}, - {1000310820, 81.943176531}, - {1000320820, 81.929774031}, - {1000330820, 81.924738731}, - {1000340820, 81.916699531}, - {1000350820, 81.916801752}, - {1000360820, 81.91348115368}, - {1000370820, 81.918209023}, - {1000380820, 81.918399845}, - {1000390820, 81.926930189}, - {1000400820, 81.931707497}, - {1000410820, 81.94438}, - {1000420820, 81.956661}, - {1000290830, 82.97811}, - {1000300830, 82.961041}, - {1000310830, 82.9471203}, - {1000320830, 82.9345391}, - {1000330830, 82.9252069}, - {1000340830, 82.919118604}, - {1000350830, 82.915175285}, - {1000360830, 82.914126516}, - {1000370830, 82.915114181}, - {1000380830, 82.917554372}, - {1000390830, 82.922484026}, - {1000400830, 82.929240926}, - {1000410830, 82.93815}, - {1000420830, 82.950252}, - {1000430830, 82.966377}, - {1000290840, 83.985271}, - {1000300840, 83.965829}, - {1000310840, 83.952663}, - {1000320840, 83.93757509}, - {1000330840, 83.92930329000001}, - {1000340840, 83.918466761}, - {1000350840, 83.916496417}, - {1000360840, 83.91149772708}, - {1000370840, 83.914375223}, - {1000380840, 83.913419118}, - {1000390840, 83.92067106}, - {1000400840, 83.923325663}, - {1000410840, 83.934305711}, - {1000420840, 83.941846}, - {1000430840, 83.959527}, - {1000300850, 84.973054}, - {1000310850, 84.957333}, - {1000320850, 84.942969658}, - {1000330850, 84.932163658}, - {1000340850, 84.922260758}, - {1000350850, 84.915645758}, - {1000360850, 84.91252726}, - {1000370850, 84.91178973604}, - {1000380850, 84.912932041}, - {1000390850, 84.916433039}, - {1000400850, 84.921443199}, - {1000410850, 84.928845836}, - {1000420850, 84.938260736}, - {1000430850, 84.950778}, - {1000440850, 84.967117}, - {1000300860, 85.978463}, - {1000310860, 85.963757}, - {1000320860, 85.946967}, - {1000330860, 85.936701532}, - {1000340860, 85.924311732}, - {1000350860, 85.918805432}, - {1000360860, 85.91061062468}, - {1000370860, 85.911167443}, - {1000380860, 85.90926072473}, - {1000390860, 85.914886095}, - {1000400860, 85.916296814}, - {1000410860, 85.925781536}, - {1000420860, 85.931174092}, - {1000430860, 85.944637}, - {1000440860, 85.957305}, - {1000310870, 86.969007}, - {1000320870, 86.953204}, - {1000330870, 86.940291716}, - {1000340870, 86.928688616}, - {1000350870, 86.920674016}, - {1000360870, 86.913354759}, - {1000370870, 86.909180529}, - {1000380870, 86.90887749454}, - {1000390870, 86.9108761}, - {1000400870, 86.914817338}, - {1000410870, 86.920692473}, - {1000420870, 86.928196198}, - {1000430870, 86.938067185}, - {1000440870, 86.950907}, - {1000310880, 87.975963}, - {1000320880, 87.957574}, - {1000330880, 87.94584}, - {1000340880, 87.93141749}, - {1000350880, 87.92408329}, - {1000360880, 87.914447879}, - {1000370880, 87.91131559}, - {1000380880, 87.905612253}, - {1000390880, 87.909501274}, - {1000400880, 87.910220715}, - {1000410880, 87.918226476}, - {1000420880, 87.921967779}, - {1000430880, 87.933794211}, - {1000440880, 87.941664}, - {1000450880, 87.960429}, - {1000320890, 88.96453}, - {1000330890, 88.950048}, - {1000340890, 88.936669058}, - {1000350890, 88.926704558}, - {1000360890, 88.917835449}, - {1000370890, 88.912278136}, - {1000380890, 88.907450808}, - {1000390890, 88.905838156}, - {1000400890, 88.908879751}, - {1000410890, 88.913444696}, - {1000420890, 88.919468149}, - {1000430890, 88.927648649}, - {1000440890, 88.937337849}, - {1000450890, 88.950992}, - {1000320900, 89.969436}, - {1000330900, 89.955995}, - {1000340900, 89.940096}, - {1000350900, 89.931292848}, - {1000360900, 89.919527929}, - {1000370900, 89.914797557}, - {1000380900, 89.90772787}, - {1000390900, 89.907141749}, - {1000400900, 89.904698755}, - {1000410900, 89.911259201}, - {1000420900, 89.91393127}, - {1000430900, 89.924073919}, - {1000440900, 89.930344378}, - {1000450900, 89.944569}, - {1000460900, 89.95737}, - {1000330910, 90.960816}, - {1000340910, 90.9457}, - {1000350910, 90.934398617}, - {1000360910, 90.923806309}, - {1000370910, 90.916537261}, - {1000380910, 90.910195942}, - {1000390910, 90.907298048}, - {1000400910, 90.905640205}, - {1000410910, 90.906990256}, - {1000420910, 90.91174519}, - {1000430910, 90.918424972}, - {1000440910, 90.92674153}, - {1000450910, 90.937123}, - {1000460910, 90.950435}, - {1000330920, 91.967386}, - {1000340920, 91.94984}, - {1000350920, 91.939631595}, - {1000360920, 91.926173092}, - {1000370920, 91.919728477}, - {1000380920, 91.911038222}, - {1000390920, 91.908945752}, - {1000400920, 91.905035336}, - {1000410920, 91.90718858}, - {1000420920, 91.906807153}, - {1000430920, 91.915269777}, - {1000440920, 91.920234373}, - {1000450920, 91.932367692}, - {1000460920, 91.941192225}, - {1000470920, 91.95971}, - {1000340930, 92.956135}, - {1000350930, 92.94322}, - {1000360930, 92.931147172}, - {1000370930, 92.922039334}, - {1000380930, 92.914024314}, - {1000390930, 92.909578434}, - {1000400930, 92.906470661}, - {1000410930, 92.90637317}, - {1000420930, 92.906808772}, - {1000430930, 92.910245147}, - {1000440930, 92.917104442}, - {1000450930, 92.925912778}, - {1000460930, 92.936680426}, - {1000470930, 92.950188}, - {1000340940, 93.96049}, - {1000350940, 93.948846}, - {1000360940, 93.934140452}, - {1000370940, 93.926394819}, - {1000380940, 93.915355641}, - {1000390940, 93.911592062}, - {1000400940, 93.906312523}, - {1000410940, 93.907279001}, - {1000420940, 93.905083586}, - {1000430940, 93.909652319}, - {1000440940, 93.91134286}, - {1000450940, 93.92173045}, - {1000460940, 93.929036286}, - {1000470940, 93.943744}, - {1000480940, 93.956586}, - {1000340950, 94.9673}, - {1000350950, 94.952925}, - {1000360950, 94.939710922}, - {1000370950, 94.929263849}, - {1000380950, 94.919358282}, - {1000390950, 94.912819697}, - {1000400950, 94.908040276}, - {1000410950, 94.90683111}, - {1000420950, 94.905837436}, - {1000430950, 94.907652281}, - {1000440950, 94.910404415}, - {1000450950, 94.915897893}, - {1000460950, 94.924888506}, - {1000470950, 94.935688}, - {1000480950, 94.949483}, - {1000350960, 95.95898}, - {1000360960, 95.943014473}, - {1000370960, 95.934133398}, - {1000380960, 95.921719045}, - {1000390960, 95.915909305}, - {1000400960, 95.908277615}, - {1000410960, 95.908101586}, - {1000420960, 95.90467477}, - {1000430960, 95.907866675}, - {1000440960, 95.90758891}, - {1000450960, 95.914451705}, - {1000460960, 95.918213739}, - {1000470960, 95.930743903}, - {1000480960, 95.940341}, - {1000490960, 95.959109}, - {1000350970, 96.963499}, - {1000360970, 96.949088782}, - {1000370970, 96.937177117}, - {1000380970, 96.926375621}, - {1000390970, 96.918286702}, - {1000400970, 96.910963802}, - {1000410970, 96.908101622}, - {1000420970, 96.906016903}, - {1000430970, 96.90636072}, - {1000440970, 96.907545776}, - {1000450970, 96.911327872}, - {1000460970, 96.916471985}, - {1000470970, 96.9238814}, - {1000480970, 96.934799343}, - {1000490970, 96.949125}, - {1000350980, 97.969887}, - {1000360980, 97.952635}, - {1000370980, 97.941632317}, - {1000380980, 97.928692636}, - {1000390980, 97.922394841}, - {1000400980, 97.912740448}, - {1000410980, 97.910332645}, - {1000420980, 97.905403609}, - {1000430980, 97.907211206}, - {1000440980, 97.905286709}, - {1000450980, 97.910707734}, - {1000460980, 97.912698335}, - {1000470980, 97.92155997}, - {1000480980, 97.927389315}, - {1000490980, 97.942129}, - {1000360990, 98.958776}, - {1000370990, 98.94511919}, - {1000380990, 98.932883604}, - {1000390990, 98.924160839}, - {1000400990, 98.916675081}, - {1000410990, 98.911609377}, - {1000420990, 98.907707299}, - {1000430990, 98.906249681}, - {1000440990, 98.905930284}, - {1000450990, 98.908121241}, - {1000460990, 98.911773073}, - {1000470990, 98.917645766}, - {1000480990, 98.924925845}, - {1000490990, 98.93411}, - {1000500990, 98.948495}, - {1000361000, 99.962995}, - {1000371000, 99.950331532}, - {1000381000, 99.93578327}, - {1000391000, 99.927727678}, - {1000401000, 99.918010499}, - {1000411000, 99.914340578}, - {1000421000, 99.907467982}, - {1000431000, 99.907652715}, - {1000441000, 99.90421046}, - {1000451000, 99.908114147}, - {1000461000, 99.908520438}, - {1000471000, 99.916115443}, - {1000481000, 99.920348829}, - {1000491000, 99.931101929}, - {1000501000, 99.938648944}, - {1000361010, 100.969318}, - {1000371010, 100.954302}, - {1000381010, 100.940606264}, - {1000391010, 100.930160817}, - {1000401010, 100.921458454}, - {1000411010, 100.915306508}, - {1000421010, 100.910337648}, - {1000431010, 100.907305271}, - {1000441010, 100.905573086}, - {1000451010, 100.906158903}, - {1000461010, 100.908284824}, - {1000471010, 100.912683951}, - {1000481010, 100.918586209}, - {1000491010, 100.926414025}, - {1000501010, 100.935259252}, - {1000371020, 101.960008}, - {1000381020, 101.944004679}, - {1000391020, 101.934328471}, - {1000401020, 101.923154181}, - {1000411020, 101.918090447}, - {1000421020, 101.910293725}, - {1000431020, 101.909207239}, - {1000441020, 101.904340312}, - {1000451020, 101.906834282}, - {1000461020, 101.905632292}, - {1000471020, 101.911704538}, - {1000481020, 101.914481797}, - {1000491020, 101.924105911}, - {1000501020, 101.930289525}, - {1000511020, 101.945142}, - {1000371030, 102.964401}, - {1000381030, 102.949243}, - {1000391030, 102.937243796}, - {1000401030, 102.927204054}, - {1000411030, 102.919453416}, - {1000421030, 102.913091954}, - {1000431030, 102.90917396}, - {1000441030, 102.906314846}, - {1000451030, 102.905494081}, - {1000461030, 102.906111074}, - {1000471030, 102.908960558}, - {1000481030, 102.913416922}, - {1000491030, 102.91987883}, - {1000501030, 102.927973}, - {1000511030, 102.939162}, - {1000371040, 103.970531}, - {1000381040, 103.953022}, - {1000391040, 103.941943}, - {1000401040, 103.929449193}, - {1000411040, 103.922907728}, - {1000421040, 103.913747443}, - {1000431040, 103.911433718}, - {1000441040, 103.905425312}, - {1000451040, 103.906645309}, - {1000461040, 103.904030393}, - {1000471040, 103.908623715}, - {1000481040, 103.909856228}, - {1000491040, 103.918214538}, - {1000501040, 103.923105195}, - {1000511040, 103.936344}, - {1000521040, 103.946723408}, - {1000381050, 104.959001}, - {1000391050, 104.945711}, - {1000401050, 104.934021832}, - {1000411050, 104.924942577}, - {1000421050, 104.91698198899999}, - {1000431050, 104.911662024}, - {1000441050, 104.907745478}, - {1000451050, 104.905687787}, - {1000461050, 104.905079479}, - {1000471050, 104.906525604}, - {1000481050, 104.909463893}, - {1000491050, 104.914502322}, - {1000501050, 104.921268421}, - {1000511050, 104.931276547}, - {1000521050, 104.943304516}, - {1000381060, 105.963177}, - {1000391060, 105.950842}, - {1000401060, 105.93693}, - {1000411060, 105.928928505}, - {1000421060, 105.918273231}, - {1000431060, 105.914356674}, - {1000441060, 105.907328181}, - {1000451060, 105.907285879}, - {1000461060, 105.903480287}, - {1000471060, 105.906663499}, - {1000481060, 105.906459791}, - {1000491060, 105.913463596}, - {1000501060, 105.916957394}, - {1000511060, 105.928637979}, - {1000521060, 105.937498521}, - {1000531060, 105.953516}, - {1000381070, 106.969672}, - {1000391070, 106.954943}, - {1000401070, 106.942007}, - {1000411070, 106.931589685}, - {1000421070, 106.92211977}, - {1000431070, 106.915458437}, - {1000441070, 106.909969837}, - {1000451070, 106.906747975}, - {1000461070, 106.905128058}, - {1000471070, 106.905091509}, - {1000481070, 106.906612049}, - {1000491070, 106.910287497}, - {1000501070, 106.915713649}, - {1000511070, 106.924150621}, - {1000521070, 106.934882}, - {1000531070, 106.946935}, - {1000391080, 107.960515}, - {1000401080, 107.945303}, - {1000411080, 107.936075604}, - {1000421080, 107.924047508}, - {1000431080, 107.918493493}, - {1000441080, 107.910185793}, - {1000451080, 107.908715304}, - {1000461080, 107.903891806}, - {1000471080, 107.905950245}, - {1000481080, 107.904183588}, - {1000491080, 107.909693654}, - {1000501080, 107.91189429}, - {1000511080, 107.922226731}, - {1000521080, 107.929380469}, - {1000531080, 107.943348}, - {1000541080, 107.954232285}, - {1000391090, 108.965131}, - {1000401090, 108.950907}, - {1000411090, 108.939141}, - {1000421090, 108.928438318}, - {1000431090, 108.920254107}, - {1000441090, 108.913323707}, - {1000451090, 108.908749555}, - {1000461090, 108.905950576}, - {1000471090, 108.904755778}, - {1000481090, 108.904986697}, - {1000491090, 108.907149679}, - {1000501090, 108.911292857}, - {1000511090, 108.918141203}, - {1000521090, 108.927304532}, - {1000531090, 108.938086022}, - {1000541090, 108.950434955}, - {1000401100, 109.954675}, - {1000411100, 109.943843}, - {1000421100, 109.930717956}, - {1000431100, 109.923741263}, - {1000441100, 109.914038501}, - {1000451100, 109.911079745}, - {1000461100, 109.905172878}, - {1000471100, 109.906110724}, - {1000481100, 109.90300747}, - {1000491100, 109.907170674}, - {1000501100, 109.907844835}, - {1000511100, 109.916854283}, - {1000521100, 109.922458102}, - {1000531100, 109.935085102}, - {1000541100, 109.944258759}, - {1000401110, 110.960837}, - {1000411110, 110.947439}, - {1000421110, 110.935651966}, - {1000431110, 110.925898966}, - {1000441110, 110.917567566}, - {1000451110, 110.911643164}, - {1000461110, 110.907690358}, - {1000471110, 110.905296827}, - {1000481110, 110.904183776}, - {1000491110, 110.905107236}, - {1000501110, 110.907741143}, - {1000511110, 110.913218187}, - {1000521110, 110.921000587}, - {1000531110, 110.930269236}, - {1000541110, 110.94147}, - {1000551110, 110.953945}, - {1000401120, 111.965196}, - {1000411120, 111.952689}, - {1000421120, 111.938293}, - {1000431120, 111.929941658}, - {1000441120, 111.918806922}, - {1000451120, 111.914405199}, - {1000461120, 111.907330557}, - {1000471120, 111.907048548}, - {1000481120, 111.902763896}, - {1000491120, 111.905538718}, - {1000501120, 111.904824894}, - {1000511120, 111.912399903}, - {1000521120, 111.916727848}, - {1000531120, 111.928004548}, - {1000541120, 111.935559068}, - {1000551120, 111.950172}, - {1000401130, 112.971723}, - {1000411130, 112.956833}, - {1000421130, 112.943478}, - {1000431130, 112.932569032}, - {1000441130, 112.922846729}, - {1000451130, 112.915440212}, - {1000461130, 112.910261912}, - {1000471130, 112.906572865}, - {1000481130, 112.904408105}, - {1000491130, 112.904060451}, - {1000501130, 112.905175857}, - {1000511130, 112.909374664}, - {1000521130, 112.915891}, - {1000531130, 112.923650062}, - {1000541130, 112.933221663}, - {1000551130, 112.944428484}, - {1000561130, 112.95737}, - {1000411140, 113.962469}, - {1000421140, 113.946666}, - {1000431140, 113.93709}, - {1000441140, 113.92461443}, - {1000451140, 113.91872168}, - {1000461140, 113.91036943}, - {1000471140, 113.908823029}, - {1000481140, 113.903364998}, - {1000491140, 113.904916405}, - {1000501140, 113.90278013}, - {1000511140, 113.909289155}, - {1000521140, 113.91208782}, - {1000531140, 113.9220189}, - {1000541140, 113.927980329}, - {1000551140, 113.941292244}, - {1000561140, 113.950718489}, - {1000411150, 114.966849}, - {1000421150, 114.952174}, - {1000431150, 114.9401}, - {1000441150, 114.929033049}, - {1000451150, 114.920311649}, - {1000461150, 114.913659333}, - {1000471150, 114.908767445}, - {1000481150, 114.905437426}, - {1000491150, 114.903878772}, - {1000501150, 114.903344695}, - {1000511150, 114.906598}, - {1000521150, 114.911902}, - {1000531150, 114.918048}, - {1000541150, 114.926293943}, - {1000551150, 114.93591}, - {1000561150, 114.947482}, - {1000411160, 115.972914}, - {1000421160, 115.955759}, - {1000431160, 115.94502}, - {1000441160, 115.931219191}, - {1000451160, 115.92406206}, - {1000461160, 115.914297872}, - {1000471160, 115.911386809}, - {1000481160, 115.90476323}, - {1000491160, 115.905259992}, - {1000501160, 115.901742825}, - {1000511160, 115.906792732}, - {1000521160, 115.908465558}, - {1000531160, 115.916885513}, - {1000541160, 115.921580955}, - {1000551160, 115.933395}, - {1000561160, 115.941621}, - {1000571160, 115.957005}, - {1000421170, 116.961686}, - {1000431170, 116.94832}, - {1000441170, 116.936135}, - {1000451170, 116.926036291}, - {1000461170, 116.917955584}, - {1000471170, 116.911774086}, - {1000481170, 116.907226039}, - {1000491170, 116.904515729}, - {1000501170, 116.902954036}, - {1000511170, 116.904841519}, - {1000521170, 116.908646227}, - {1000531170, 116.913645649}, - {1000541170, 116.920358758}, - {1000551170, 116.928616723}, - {1000561170, 116.938316403}, - {1000571170, 116.950326}, - {1000421180, 117.965249}, - {1000431180, 117.953526}, - {1000441180, 117.938808}, - {1000451180, 117.930341116}, - {1000461180, 117.919067273}, - {1000471180, 117.914595484}, - {1000481180, 117.906921956}, - {1000491180, 117.906356705}, - {1000501180, 117.90160663}, - {1000511180, 117.905532194}, - {1000521180, 117.905860104}, - {1000531180, 117.913074}, - {1000541180, 117.916178678}, - {1000551180, 117.926559517}, - {1000561180, 117.933226}, - {1000571180, 117.946731}, - {1000421190, 118.971465}, - {1000431190, 118.956876}, - {1000441190, 118.94409}, - {1000451190, 118.932556951}, - {1000461190, 118.923341138}, - {1000471190, 118.915570309}, - {1000481190, 118.909847052}, - {1000491190, 118.905851622}, - {1000501190, 118.903311266}, - {1000511190, 118.903944062}, - {1000521190, 118.906405699}, - {1000531190, 118.91006091}, - {1000541190, 118.915410641}, - {1000551190, 118.922377327}, - {1000561190, 118.930659683}, - {1000571190, 118.940934}, - {1000581190, 118.952957}, - {1000431200, 119.962426}, - {1000441200, 119.946623}, - {1000451200, 119.937069}, - {1000461200, 119.924551745}, - {1000471200, 119.918784765}, - {1000481200, 119.909868065}, - {1000491200, 119.907967489}, - {1000501200, 119.902202557}, - {1000511200, 119.905080308}, - {1000521200, 119.904065779}, - {1000531200, 119.910093729}, - {1000541200, 119.911784267}, - {1000551200, 119.920677277}, - {1000561200, 119.926044997}, - {1000571200, 119.938196}, - {1000581200, 119.946613}, - {1000431210, 120.96614}, - {1000441210, 120.952098}, - {1000451210, 120.939613}, - {1000461210, 120.928950342}, - {1000471210, 120.920125279}, - {1000481210, 120.91296366}, - {1000491210, 120.907852778}, - {1000501210, 120.904243488}, - {1000511210, 120.903811353}, - {1000521210, 120.904945065}, - {1000531210, 120.907411492}, - {1000541210, 120.911453012}, - {1000551210, 120.917227235}, - {1000561210, 120.924052286}, - {1000571210, 120.933236}, - {1000581210, 120.943435}, - {1000591210, 120.955393}, - {1000431220, 121.97176}, - {1000441220, 121.955147}, - {1000451220, 121.944305}, - {1000461220, 121.930631693}, - {1000471220, 121.923664446}, - {1000481220, 121.91345905}, - {1000491220, 121.910282458}, - {1000501220, 121.903445494}, - {1000511220, 121.905169335}, - {1000521220, 121.903044708}, - {1000531220, 121.907590094}, - {1000541220, 121.908367655}, - {1000551220, 121.916108144}, - {1000561220, 121.919904}, - {1000571220, 121.93071}, - {1000581220, 121.93787}, - {1000591220, 121.951927}, - {1000441230, 122.960762}, - {1000451230, 122.947192}, - {1000461230, 122.935126}, - {1000471230, 122.92531506}, - {1000481230, 122.91689246}, - {1000491230, 122.910435252}, - {1000501230, 122.905727065}, - {1000511230, 122.904215292}, - {1000521230, 122.904271022}, - {1000531230, 122.905589753}, - {1000541230, 122.908482235}, - {1000551230, 122.91299606}, - {1000561230, 122.91878106}, - {1000571230, 122.9263}, - {1000581230, 122.93528}, - {1000591230, 122.946076}, - {1000441240, 123.96394}, - {1000451240, 123.952002}, - {1000461240, 123.937305}, - {1000471240, 123.928899227}, - {1000481240, 123.917659772}, - {1000491240, 123.913184873}, - {1000501240, 123.905279619}, - {1000511240, 123.905937065}, - {1000521240, 123.902818341}, - {1000531240, 123.906210297}, - {1000541240, 123.905885174}, - {1000551240, 123.912247366}, - {1000561240, 123.915093627}, - {1000571240, 123.924574275}, - {1000581240, 123.93031}, - {1000591240, 123.94294}, - {1000601240, 123.951873}, - {1000441250, 124.969544}, - {1000451250, 124.955094}, - {1000461250, 124.942072}, - {1000471250, 124.930735}, - {1000481250, 124.92125759}, - {1000491250, 124.913673841}, - {1000501250, 124.90778937}, - {1000511250, 124.905254264}, - {1000521250, 124.904431178}, - {1000531250, 124.90463061}, - {1000541250, 124.90638764}, - {1000551250, 124.909725953}, - {1000561250, 124.91447184}, - {1000571250, 124.92081593099999}, - {1000581250, 124.92844}, - {1000591250, 124.937659}, - {1000601250, 124.948395}, - {1000451260, 125.960064}, - {1000461260, 125.944401}, - {1000471260, 125.934814}, - {1000481260, 125.92243029}, - {1000491260, 125.916468202}, - {1000501260, 125.907658958}, - {1000511260, 125.907253158}, - {1000521260, 125.903312144}, - {1000531260, 125.905624205}, - {1000541260, 125.904297422}, - {1000551260, 125.909445821}, - {1000561260, 125.911250202}, - {1000571260, 125.919512667}, - {1000581260, 125.923971}, - {1000591260, 125.93524}, - {1000601260, 125.942694}, - {1000611260, 125.957327}, - {1000451270, 126.963789}, - {1000461270, 126.949307}, - {1000471270, 126.937037}, - {1000481270, 126.926203291}, - {1000491270, 126.91746604}, - {1000501270, 126.910391726}, - {1000511270, 126.906925557}, - {1000521270, 126.905226993}, - {1000531270, 126.904472592}, - {1000541270, 126.905183636}, - {1000551270, 126.907417527}, - {1000561270, 126.911091272}, - {1000571270, 126.916375083}, - {1000581270, 126.922727}, - {1000591270, 126.93071}, - {1000601270, 126.939978}, - {1000611270, 126.951358}, - {1000451280, 127.970649}, - {1000461280, 127.952345}, - {1000471280, 127.941266}, - {1000481280, 127.927816778}, - {1000491280, 127.920353637}, - {1000501280, 127.910507828}, - {1000511280, 127.909146121}, - {1000521280, 127.904461237}, - {1000531280, 127.905809355}, - {1000541280, 127.90353075341}, - {1000551280, 127.907748452}, - {1000561280, 127.908352446}, - {1000571280, 127.915592123}, - {1000581280, 127.918911}, - {1000591280, 127.928791}, - {1000601280, 127.935018}, - {1000611280, 127.948234}, - {1000621280, 127.957971}, - {1000461290, 128.959334}, - {1000471290, 128.944315}, - {1000481290, 128.932235597}, - {1000491290, 128.921808534}, - {1000501290, 128.91348244}, - {1000511290, 128.909146623}, - {1000521290, 128.906596419}, - {1000531290, 128.904983643}, - {1000541290, 128.90478085742}, - {1000551290, 128.90606591}, - {1000561290, 128.908683409}, - {1000571290, 128.912695592}, - {1000581290, 128.918102}, - {1000591290, 128.925095}, - {1000601290, 128.933038}, - {1000611290, 128.942909}, - {1000621290, 128.954557}, - {1000461300, 129.964863}, - {1000471300, 129.950727}, - {1000481300, 129.934387563}, - {1000491300, 129.924952257}, - {1000501300, 129.913974531}, - {1000511300, 129.911662686}, - {1000521300, 129.906222745}, - {1000531300, 129.906670168}, - {1000541300, 129.903509346}, - {1000551300, 129.906709281}, - {1000561300, 129.906326002}, - {1000571300, 129.912369413}, - {1000581300, 129.914736}, - {1000591300, 129.92359}, - {1000601300, 129.928506}, - {1000611300, 129.940451}, - {1000621300, 129.948792}, - {1000631300, 129.964022}, - {1000461310, 130.972367}, - {1000471310, 130.956253}, - {1000481310, 130.94072774}, - {1000491310, 130.926972839}, - {1000501310, 130.917053067}, - {1000511310, 130.911989339}, - {1000521310, 130.90852221}, - {1000531310, 130.906126375}, - {1000541310, 130.90508412808}, - {1000551310, 130.905468457}, - {1000561310, 130.906946315}, - {1000571310, 130.91007}, - {1000581310, 130.914429465}, - {1000591310, 130.92023496}, - {1000601310, 130.92724802}, - {1000611310, 130.935834}, - {1000621310, 130.946022}, - {1000631310, 130.957634}, - {1000471320, 131.96307}, - {1000481320, 131.945823136}, - {1000491320, 131.932998444}, - {1000501320, 131.917823898}, - {1000511320, 131.914508013}, - {1000521320, 131.908546713}, - {1000531320, 131.907993511}, - {1000541320, 131.90415508346}, - {1000551320, 131.90643774}, - {1000561320, 131.905061231}, - {1000571320, 131.910119047}, - {1000581320, 131.911466226}, - {1000591320, 131.91924}, - {1000601320, 131.923321237}, - {1000611320, 131.93384}, - {1000621320, 131.940805}, - {1000631320, 131.954696}, - {1000471330, 132.968781}, - {1000481330, 132.952614}, - {1000491330, 132.938067}, - {1000501330, 132.923913753}, - {1000511330, 132.915272128}, - {1000521330, 132.91096333}, - {1000531330, 132.9078284}, - {1000541330, 132.905910748}, - {1000551330, 132.905451958}, - {1000561330, 132.906007443}, - {1000571330, 132.908218}, - {1000581330, 132.911520402}, - {1000591330, 132.916330558}, - {1000601330, 132.922348}, - {1000611330, 132.929782}, - {1000621330, 132.93856}, - {1000631330, 132.94929}, - {1000641330, 132.961288}, - {1000481340, 133.957638}, - {1000491340, 133.944208}, - {1000501340, 133.92868043}, - {1000511340, 133.920537334}, - {1000521340, 133.911396376}, - {1000531340, 133.90977566}, - {1000541340, 133.90539303}, - {1000551340, 133.906718501}, - {1000561340, 133.904508249}, - {1000571340, 133.908514011}, - {1000581340, 133.908928142}, - {1000591340, 133.915696729}, - {1000601340, 133.918790207}, - {1000611340, 133.928326}, - {1000621340, 133.93411}, - {1000631340, 133.946537}, - {1000641340, 133.955416}, - {1000481350, 134.964766}, - {1000491350, 134.949425}, - {1000501350, 134.934908603}, - {1000511350, 134.925184354}, - {1000521350, 134.916554715}, - {1000531350, 134.910059355}, - {1000541350, 134.907231441}, - {1000551350, 134.905976907}, - {1000561350, 134.905688447}, - {1000571350, 134.906984427}, - {1000581350, 134.909160662}, - {1000591350, 134.913111772}, - {1000601350, 134.918181318}, - {1000611350, 134.92478499999999}, - {1000621350, 134.93252}, - {1000631350, 134.94187}, - {1000641350, 134.952496}, - {1000651350, 134.964516}, - {1000491360, 135.956017}, - {1000501360, 135.939699}, - {1000511360, 135.930749009}, - {1000521360, 135.92010118}, - {1000531360, 135.914604693}, - {1000541360, 135.907214474}, - {1000551360, 135.907311431}, - {1000561360, 135.9045758}, - {1000571360, 135.907634962}, - {1000581360, 135.907129256}, - {1000591360, 135.91267747}, - {1000601360, 135.914976061}, - {1000611360, 135.923595949}, - {1000621360, 135.928275553}, - {1000631360, 135.93962}, - {1000641360, 135.9473}, - {1000651360, 135.96146}, - {1000491370, 136.961535}, - {1000501370, 136.946162}, - {1000511370, 136.935522519}, - {1000521370, 136.925599354}, - {1000531370, 136.918028178}, - {1000541370, 136.911557771}, - {1000551370, 136.907089296}, - {1000561370, 136.905827207}, - {1000571370, 136.906450438}, - {1000581370, 136.907762416}, - {1000591370, 136.910679183}, - {1000601370, 136.914563099}, - {1000611370, 136.920479519}, - {1000621370, 136.927007959}, - {1000631370, 136.935430719}, - {1000641370, 136.94502}, - {1000651370, 136.95602}, - {1000501380, 137.951143}, - {1000511380, 137.941331}, - {1000521380, 137.929472452}, - {1000531380, 137.922726392}, - {1000541380, 137.914146268}, - {1000551380, 137.911017119}, - {1000561380, 137.905247059}, - {1000571380, 137.907124041}, - {1000581380, 137.90599418}, - {1000591380, 137.910757495}, - {1000601380, 137.911950938}, - {1000611380, 137.919576119}, - {1000621380, 137.923243988}, - {1000631380, 137.933709}, - {1000641380, 137.940247}, - {1000651380, 137.953193}, - {1000661380, 137.9625}, - {1000501390, 138.957799}, - {1000511390, 138.946269}, - {1000521390, 138.935367191}, - {1000531390, 138.9264934}, - {1000541390, 138.9187922}, - {1000551390, 138.913363822}, - {1000561390, 138.908841164}, - {1000571390, 138.906362927}, - {1000581390, 138.906647029}, - {1000591390, 138.9089327}, - {1000601390, 138.911951208}, - {1000611390, 138.916799228}, - {1000621390, 138.922296631}, - {1000631390, 138.929792307}, - {1000641390, 138.93813}, - {1000651390, 138.94833}, - {1000661390, 138.959527}, - {1000501400, 139.962973}, - {1000511400, 139.952345}, - {1000521400, 139.939487057}, - {1000531400, 139.931715914}, - {1000541400, 139.921645814}, - {1000551400, 139.917283707}, - {1000561400, 139.910608231}, - {1000571400, 139.909487285}, - {1000581400, 139.905448433}, - {1000591400, 139.9090856}, - {1000601400, 139.90954613}, - {1000611400, 139.916035918}, - {1000621400, 139.918994714}, - {1000631400, 139.928087633}, - {1000641400, 139.933674}, - {1000651400, 139.945805048}, - {1000661400, 139.95402}, - {1000671400, 139.968526}, - {1000511410, 140.957552}, - {1000521410, 140.945604}, - {1000531410, 140.935666081}, - {1000541410, 140.926787181}, - {1000551410, 140.920045279}, - {1000561410, 140.914403653}, - {1000571410, 140.910971155}, - {1000581410, 140.908285991}, - {1000591410, 140.907659604}, - {1000601410, 140.90961669}, - {1000611410, 140.913555081}, - {1000621410, 140.918481545}, - {1000631410, 140.924931734}, - {1000641410, 140.932126}, - {1000651410, 140.941448}, - {1000661410, 140.95128}, - {1000671410, 140.963108}, - {1000511420, 141.963918}, - {1000521420, 141.950027}, - {1000531420, 141.941166595}, - {1000541420, 141.929973095}, - {1000551420, 141.924299514}, - {1000561420, 141.916432904}, - {1000571420, 141.91409076}, - {1000581420, 141.909250208}, - {1000591420, 141.91005164}, - {1000601420, 141.907728824}, - {1000611420, 141.912890982}, - {1000621420, 141.915209415}, - {1000631420, 141.923446719}, - {1000641420, 141.928116}, - {1000651420, 141.939280858}, - {1000661420, 141.946194}, - {1000671420, 141.96001}, - {1000681420, 141.970016}, - {1000521430, 142.956489}, - {1000531430, 142.945475}, - {1000541430, 142.93536955}, - {1000551430, 142.927347346}, - {1000561430, 142.920625149}, - {1000571430, 142.916079482}, - {1000581430, 142.912391953}, - {1000591430, 142.910822624}, - {1000601430, 142.909819815}, - {1000611430, 142.910938068}, - {1000621430, 142.914634848}, - {1000631430, 142.920298678}, - {1000641430, 142.926750678}, - {1000651430, 142.935137332}, - {1000661430, 142.943994332}, - {1000671430, 142.95486}, - {1000681430, 142.966548}, - {1000521440, 143.961116}, - {1000531440, 143.951336}, - {1000541440, 143.938945076}, - {1000551440, 143.932075402}, - {1000561440, 143.922954821}, - {1000571440, 143.919645589}, - {1000581440, 143.913652763}, - {1000591440, 143.913310682}, - {1000601440, 143.910092798}, - {1000611440, 143.912596208}, - {1000621440, 143.912006285}, - {1000631440, 143.918819481}, - {1000641440, 143.922963}, - {1000651440, 143.933045}, - {1000661440, 143.939269512}, - {1000671440, 143.952109712}, - {1000681440, 143.9607}, - {1000691440, 143.976211}, - {1000521450, 144.967783}, - {1000531450, 144.955845}, - {1000541450, 144.944719631}, - {1000551450, 144.935528927}, - {1000561450, 144.9275184}, - {1000571450, 144.921808065}, - {1000581450, 144.917265113}, - {1000591450, 144.914517987}, - {1000601450, 144.912579151}, - {1000611450, 144.912755748}, - {1000621450, 144.913417157}, - {1000631450, 144.916272659}, - {1000641450, 144.921710051}, - {1000651450, 144.928717001}, - {1000661450, 144.937473992}, - {1000671450, 144.947267392}, - {1000681450, 144.957874}, - {1000691450, 144.970389}, - {1000531460, 145.961846}, - {1000541460, 145.948518245}, - {1000551460, 145.940621867}, - {1000561460, 145.9303632}, - {1000571460, 145.925688017}, - {1000581460, 145.918812294}, - {1000591460, 145.91768763}, - {1000601460, 145.913122459}, - {1000611460, 145.91470224}, - {1000621460, 145.913046835}, - {1000631460, 145.917210852}, - {1000641460, 145.918318513}, - {1000651460, 145.927252739}, - {1000661460, 145.932844526}, - {1000671460, 145.944993503}, - {1000681460, 145.952418357}, - {1000691460, 145.966661}, - {1000531470, 146.966505}, - {1000541470, 146.954482}, - {1000551470, 146.944261512}, - {1000561470, 146.9353039}, - {1000571470, 146.9284178}, - {1000581470, 146.9226899}, - {1000591470, 146.919007438}, - {1000601470, 146.916105969}, - {1000611470, 146.915144944}, - {1000621470, 146.914904401}, - {1000631470, 146.91675244}, - {1000641470, 146.919101014}, - {1000651470, 146.92405462}, - {1000661470, 146.931082712}, - {1000671470, 146.940142293}, - {1000681470, 146.949964456}, - {1000691470, 146.961379887}, - {1000541480, 147.958508}, - {1000551480, 147.949639026}, - {1000561480, 147.938223}, - {1000571480, 147.9326794}, - {1000581480, 147.924424186}, - {1000591480, 147.922129992}, - {1000601480, 147.916899027}, - {1000611480, 147.917481091}, - {1000621480, 147.914829233}, - {1000631480, 147.918091288}, - {1000641480, 147.918121414}, - {1000651480, 147.924275476}, - {1000661480, 147.927149944}, - {1000671480, 147.937743925}, - {1000681480, 147.944735026}, - {1000691480, 147.958384026}, - {1000701480, 147.967547}, - {1000541490, 148.964573}, - {1000551490, 148.953516}, - {1000561490, 148.943284}, - {1000571490, 148.935351259}, - {1000581490, 148.9284269}, - {1000591490, 148.9237361}, - {1000601490, 148.920154583}, - {1000611490, 148.918341507}, - {1000621490, 148.917191211}, - {1000631490, 148.917936875}, - {1000641490, 148.919347666}, - {1000651490, 148.923253792}, - {1000661490, 148.927327516}, - {1000671490, 148.933820457}, - {1000681490, 148.942306}, - {1000691490, 148.952828}, - {1000701490, 148.964219}, - {1000541500, 149.968878}, - {1000551500, 149.959023}, - {1000561500, 149.9464411}, - {1000571500, 149.9395475}, - {1000581500, 149.930384032}, - {1000591500, 149.926676391}, - {1000601500, 149.920901322}, - {1000611500, 149.920990014}, - {1000621500, 149.917281993}, - {1000631500, 149.919707092}, - {1000641500, 149.918663949}, - {1000651500, 149.923664799}, - {1000661500, 149.925593068}, - {1000671500, 149.933498353}, - {1000681500, 149.937915524}, - {1000691500, 149.95009}, - {1000701500, 149.958314}, - {1000711500, 149.973407}, - {1000551510, 150.963199}, - {1000561510, 150.951755}, - {1000571510, 150.942769}, - {1000581510, 150.9342722}, - {1000591510, 150.928309066}, - {1000601510, 150.923839363}, - {1000611510, 150.921216613}, - {1000621510, 150.919938859}, - {1000631510, 150.919856606}, - {1000641510, 150.920354922}, - {1000651510, 150.92310897}, - {1000661510, 150.926191279}, - {1000671510, 150.931698176}, - {1000681510, 150.937448567}, - {1000691510, 150.945494433}, - {1000701510, 150.955402453}, - {1000711510, 150.967471}, - {1000551520, 151.968728}, - {1000561520, 151.95533}, - {1000571520, 151.947085}, - {1000581520, 151.936682}, - {1000591520, 151.9315529}, - {1000601520, 151.924691242}, - {1000611520, 151.923505185}, - {1000621520, 151.919738646}, - {1000631520, 151.92175098}, - {1000641520, 151.919798414}, - {1000651520, 151.924081855}, - {1000661520, 151.924725274}, - {1000671520, 151.931717618}, - {1000681520, 151.935050347}, - {1000691520, 151.944476}, - {1000701520, 151.950326699}, - {1000711520, 151.96412}, - {1000561530, 152.960848}, - {1000571530, 152.950553}, - {1000581530, 152.941052}, - {1000591530, 152.933903511}, - {1000601530, 152.927717868}, - {1000611530, 152.924156252}, - {1000621530, 152.922103576}, - {1000631530, 152.921236789}, - {1000641530, 152.921756945}, - {1000651530, 152.923441694}, - {1000661530, 152.925771729}, - {1000671530, 152.930206671}, - {1000681530, 152.93508635}, - {1000691530, 152.942058023}, - {1000701530, 152.949372}, - {1000711530, 152.958802248}, - {1000721530, 152.970692}, - {1000561540, 153.964659}, - {1000571540, 153.955416}, - {1000581540, 153.94394}, - {1000591540, 153.937885165}, - {1000601540, 153.929597404}, - {1000611540, 153.926712791}, - {1000621540, 153.922215756}, - {1000631540, 153.922985699}, - {1000641540, 153.920872974}, - {1000651540, 153.924683681}, - {1000661540, 153.92442892}, - {1000671540, 153.930606776}, - {1000681540, 153.932790799}, - {1000691540, 153.941570062}, - {1000701540, 153.946395696}, - {1000711540, 153.957416}, - {1000721540, 153.964863}, - {1000571550, 154.95928}, - {1000581550, 154.948706}, - {1000591550, 154.940509193}, - {1000601550, 154.933135598}, - {1000611550, 154.928136951}, - {1000621550, 154.924646645}, - {1000631550, 154.922899847}, - {1000641550, 154.922629356}, - {1000651550, 154.923509511}, - {1000661550, 154.925758049}, - {1000671550, 154.929103363}, - {1000681550, 154.93321571}, - {1000691550, 154.939209576}, - {1000701550, 154.945783216}, - {1000711550, 154.954326005}, - {1000721550, 154.963167}, - {1000731550, 154.974248}, - {1000571560, 155.964519}, - {1000581560, 155.951884}, - {1000591560, 155.9447669}, - {1000601560, 155.935370358}, - {1000611560, 155.931114059}, - {1000621560, 155.925538191}, - {1000631560, 155.924762976}, - {1000641560, 155.92213012}, - {1000651560, 155.924754209}, - {1000661560, 155.924283593}, - {1000671560, 155.929641634}, - {1000681560, 155.931065926}, - {1000691560, 155.938985746}, - {1000701560, 155.942817096}, - {1000711560, 155.953086606}, - {1000721560, 155.959399083}, - {1000731560, 155.972087}, - {1000571570, 156.968792}, - {1000581570, 156.957133}, - {1000591570, 156.9480031}, - {1000601570, 156.939351074}, - {1000611570, 156.933121298}, - {1000621570, 156.928418598}, - {1000631570, 156.925432556}, - {1000641570, 156.923967424}, - {1000651570, 156.924031888}, - {1000661570, 156.925469555}, - {1000671570, 156.928251974}, - {1000681570, 156.931922652}, - {1000691570, 156.936973}, - {1000701570, 156.94265136799999}, - {1000711570, 156.950144807}, - {1000721570, 156.958288}, - {1000731570, 156.968227445}, - {1000741570, 156.978862}, - {1000581580, 157.960773}, - {1000591580, 157.952603}, - {1000601580, 157.94220562}, - {1000611580, 157.936546948}, - {1000621580, 157.929949262}, - {1000631580, 157.927782192}, - {1000641580, 157.9241112}, - {1000651580, 157.925419942}, - {1000661580, 157.924414817}, - {1000671580, 157.92894491}, - {1000681580, 157.929893474}, - {1000691580, 157.936979525}, - {1000701580, 157.939871202}, - {1000711580, 157.94931562}, - {1000721580, 157.954801217}, - {1000731580, 157.966593}, - {1000741580, 157.974565}, - {1000581590, 158.966355}, - {1000591590, 158.956232}, - {1000601590, 158.946619085}, - {1000611590, 158.939286409}, - {1000621590, 158.93321713}, - {1000631590, 158.929099512}, - {1000641590, 158.926395822}, - {1000651590, 158.925353707}, - {1000661590, 158.925745938}, - {1000671590, 158.927718683}, - {1000681590, 158.93069079}, - {1000691590, 158.934975}, - {1000701590, 158.940060257}, - {1000711590, 158.946635615}, - {1000721590, 158.953995837}, - {1000731590, 158.963028046}, - {1000741590, 158.972696}, - {1000751590, 158.984106}, - {1000591600, 159.961138}, - {1000601600, 159.949839172}, - {1000611600, 159.943215272}, - {1000621600, 159.935337032}, - {1000631600, 159.931836982}, - {1000641600, 159.927061202}, - {1000651600, 159.927174553}, - {1000661600, 159.925203578}, - {1000671600, 159.928735538}, - {1000681600, 159.929077193}, - {1000691600, 159.935264177}, - {1000701600, 159.93755921}, - {1000711600, 159.946033}, - {1000721600, 159.950682728}, - {1000731600, 159.961541678}, - {1000741600, 159.968513946}, - {1000751600, 159.98188}, - {1000591610, 160.965121}, - {1000601610, 160.954664}, - {1000611610, 160.946229837}, - {1000621610, 160.939160062}, - {1000631610, 160.933663991}, - {1000641610, 160.929676267}, - {1000651610, 160.927576806}, - {1000661610, 160.926939425}, - {1000671610, 160.927861815}, - {1000681610, 160.93000353}, - {1000691610, 160.933549}, - {1000701610, 160.937912384}, - {1000711610, 160.943572}, - {1000721610, 160.950277927}, - {1000731610, 160.958369489}, - {1000741610, 160.967249}, - {1000751610, 160.977624313}, - {1000761610, 160.989054}, - {1000601620, 161.958121}, - {1000611620, 161.950574}, - {1000621620, 161.941621687}, - {1000631620, 161.936958329}, - {1000641620, 161.930991812}, - {1000651620, 161.9292754}, - {1000661620, 161.92680450699999}, - {1000671620, 161.929102543}, - {1000681620, 161.928787299}, - {1000691620, 161.934001211}, - {1000701620, 161.935779342}, - {1000711620, 161.943282776}, - {1000721620, 161.947215526}, - {1000731620, 161.957292907}, - {1000741620, 161.963500341}, - {1000751620, 161.975896}, - {1000761620, 161.984434}, - {1000601630, 162.963414}, - {1000611630, 162.953881}, - {1000621630, 162.945679085}, - {1000631630, 162.93926551}, - {1000641630, 162.93409664}, - {1000651630, 162.930653609}, - {1000661630, 162.928737221}, - {1000671630, 162.92874026}, - {1000681630, 162.930039908}, - {1000691630, 162.932658282}, - {1000701630, 162.936345406}, - {1000711630, 162.941179}, - {1000721630, 162.947107211}, - {1000731630, 162.954337194}, - {1000741630, 162.962524251}, - {1000751630, 162.972085434}, - {1000761630, 162.982462}, - {1000771630, 162.994299}, - {1000611640, 163.958819}, - {1000621640, 163.948550061}, - {1000631640, 163.942852943}, - {1000641640, 163.935916193}, - {1000651640, 163.933327561}, - {1000661640, 163.929180819}, - {1000671640, 163.930240548}, - {1000681640, 163.929207739}, - {1000691640, 163.933538019}, - {1000701640, 163.934500743}, - {1000711640, 163.941339}, - {1000721640, 163.944370709}, - {1000731640, 163.953534}, - {1000741640, 163.958952445}, - {1000751640, 163.970507122}, - {1000761640, 163.978073158}, - {1000771640, 163.991966}, - {1000611650, 164.96278}, - {1000621650, 164.95329}, - {1000631650, 164.94554007}, - {1000641650, 164.93931708}, - {1000651650, 164.934955198}, - {1000661650, 164.931709402}, - {1000671650, 164.930329116}, - {1000681650, 164.930733482}, - {1000691650, 164.932441843}, - {1000701650, 164.935270241}, - {1000711650, 164.939406758}, - {1000721650, 164.944567}, - {1000731650, 164.950780287}, - {1000741650, 164.958280663}, - {1000751650, 164.967085831}, - {1000761650, 164.976654}, - {1000771650, 164.987552}, - {1000781650, 164.999658}, - {1000621660, 165.956575}, - {1000631660, 165.949813}, - {1000641660, 165.941630413}, - {1000651660, 165.937939727}, - {1000661660, 165.93281281}, - {1000671660, 165.932291209}, - {1000681660, 165.930301067}, - {1000691660, 165.933562136}, - {1000701660, 165.933876439}, - {1000711660, 165.939859}, - {1000721660, 165.94218}, - {1000731660, 165.950512}, - {1000741660, 165.955031952}, - {1000751660, 165.965821216}, - {1000761660, 165.972698135}, - {1000771660, 165.985716}, - {1000781660, 165.994866}, - {1000621670, 166.962072}, - {1000631670, 166.953011}, - {1000641670, 166.945490012}, - {1000651670, 166.940007046}, - {1000661670, 166.935682415}, - {1000671670, 166.933140254}, - {1000681670, 166.932056192}, - {1000691670, 166.932857206}, - {1000701670, 166.934954069}, - {1000711670, 166.938243}, - {1000721670, 166.9426}, - {1000731670, 166.948093}, - {1000741670, 166.95481108}, - {1000751670, 166.962604}, - {1000761670, 166.971552304}, - {1000771670, 166.981671973}, - {1000781670, 166.99275}, - {1000621680, 167.966033}, - {1000631680, 167.957863}, - {1000641680, 167.948309}, - {1000651680, 167.943337074}, - {1000661680, 167.937134977}, - {1000671680, 167.935523766}, - {1000681680, 167.932378282}, - {1000691680, 167.934178457}, - {1000701680, 167.933891297}, - {1000711680, 167.938729798}, - {1000721680, 167.940568}, - {1000731680, 167.948047}, - {1000741680, 167.951805459}, - {1000751680, 167.961572607}, - {1000761680, 167.96779905}, - {1000771680, 167.979960978}, - {1000781680, 167.988180196}, - {1000791680, 168.002716}, - {1000631690, 168.961717}, - {1000641690, 168.952882}, - {1000651690, 168.945807}, - {1000661690, 168.940315231}, - {1000671690, 168.93687989}, - {1000681690, 168.934598444}, - {1000691690, 168.934218956}, - {1000701690, 168.935184208}, - {1000711690, 168.937645845}, - {1000721690, 168.941259}, - {1000731690, 168.946011}, - {1000741690, 168.951778689}, - {1000751690, 168.958765979}, - {1000761690, 168.967017521}, - {1000771690, 168.976281743}, - {1000781690, 168.986619}, - {1000791690, 168.99808}, - {1000631700, 169.96687}, - {1000641700, 169.956146}, - {1000651700, 169.949855}, - {1000661700, 169.94234}, - {1000671700, 169.939626548}, - {1000681700, 169.935471933}, - {1000691700, 169.935807093}, - {1000701700, 169.934767242}, - {1000711700, 169.93847923}, - {1000721700, 169.939609}, - {1000731700, 169.946175}, - {1000741700, 169.949231235}, - {1000751700, 169.958234844}, - {1000761700, 169.963579273}, - {1000771700, 169.975113}, - {1000781700, 169.982502087}, - {1000791700, 169.996024}, - {1000801700, 170.005814}, - {1000641710, 170.961127}, - {1000651710, 170.953011}, - {1000661710, 170.946312}, - {1000671710, 170.941472713}, - {1000681710, 170.938037372}, - {1000691710, 170.936435162}, - {1000701710, 170.936331515}, - {1000711710, 170.937918591}, - {1000721710, 170.940492}, - {1000731710, 170.944476}, - {1000741710, 170.949451}, - {1000751710, 170.955716}, - {1000761710, 170.963180402}, - {1000771710, 170.97164552}, - {1000781710, 170.981248868}, - {1000791710, 170.991881533}, - {1000801710, 171.003585}, - {1000641720, 171.964605}, - {1000651720, 171.957391}, - {1000661720, 171.948728}, - {1000671720, 171.94473}, - {1000681720, 171.939363461}, - {1000691720, 171.938406959}, - {1000701720, 171.936386654}, - {1000711720, 171.93909132}, - {1000721720, 171.939449716}, - {1000731720, 171.944895}, - {1000741720, 171.947292}, - {1000751720, 171.955376165}, - {1000761720, 171.960017309}, - {1000771720, 171.970607035}, - {1000781720, 171.977341059}, - {1000791720, 171.989996704}, - {1000801720, 171.998860581}, - {1000651730, 172.960805}, - {1000661730, 172.953043}, - {1000671730, 172.94702}, - {1000681730, 172.9424}, - {1000691730, 172.93960663}, - {1000701730, 172.938216211}, - {1000711730, 172.938935722}, - {1000721730, 172.940513}, - {1000731730, 172.94375}, - {1000741730, 172.947689}, - {1000751730, 172.953243}, - {1000761730, 172.959808387}, - {1000771730, 172.967505477}, - {1000781730, 172.976449922}, - {1000791730, 172.986224263}, - {1000801730, 172.997143}, - {1000651740, 173.965679}, - {1000661740, 173.955845}, - {1000671740, 173.950757}, - {1000681740, 173.94423}, - {1000691740, 173.942174061}, - {1000701740, 173.938867545}, - {1000711740, 173.94034284}, - {1000721740, 173.940048377}, - {1000731740, 173.944454}, - {1000741740, 173.946079}, - {1000751740, 173.953115}, - {1000761740, 173.957063192}, - {1000771740, 173.966949939}, - {1000781740, 173.972820431}, - {1000791740, 173.984908}, - {1000801740, 173.992870575}, - {1000661750, 174.960569}, - {1000671750, 174.953516}, - {1000681750, 174.94777}, - {1000691750, 174.94384231}, - {1000701750, 174.941281907}, - {1000711750, 174.940777211}, - {1000721750, 174.941511424}, - {1000731750, 174.943737}, - {1000741750, 174.946717}, - {1000751750, 174.951381}, - {1000761750, 174.956945126}, - {1000771750, 174.964149519}, - {1000781750, 174.972400593}, - {1000791750, 174.981316375}, - {1000801750, 174.991444451}, - {1000661760, 175.963918}, - {1000671760, 175.957713}, - {1000681760, 175.94994}, - {1000691760, 175.946997707}, - {1000701760, 175.942574706}, - {1000711760, 175.942691711}, - {1000721760, 175.941409797}, - {1000731760, 175.944857}, - {1000741760, 175.945634}, - {1000751760, 175.951623}, - {1000761760, 175.954770315}, - {1000771760, 175.963626261}, - {1000781760, 175.968938162}, - {1000791760, 175.980116925}, - {1000801760, 175.98734867}, - {1000811760, 176.000627731}, - {1000671770, 176.961052}, - {1000681770, 176.95399}, - {1000691770, 176.948932}, - {1000701770, 176.945263846}, - {1000711770, 176.94376357}, - {1000721770, 176.943230187}, - {1000731770, 176.94448194}, - {1000741770, 176.946643}, - {1000751770, 176.950328}, - {1000761770, 176.954957902}, - {1000771770, 176.9613015}, - {1000781770, 176.968469541}, - {1000791770, 176.976869701}, - {1000801770, 176.98628459}, - {1000811770, 176.996414252}, - {1000671780, 177.965507}, - {1000681780, 177.956779}, - {1000691780, 177.952506}, - {1000701780, 177.9466694}, - {1000711780, 177.945960065}, - {1000721780, 177.943708322}, - {1000731780, 177.94568}, - {1000741780, 177.945885791}, - {1000751780, 177.950989}, - {1000761780, 177.953253334}, - {1000771780, 177.961079395}, - {1000781780, 177.965649288}, - {1000791780, 177.976056714}, - {1000801780, 177.982484756}, - {1000811780, 177.995047}, - {1000821780, 178.003836171}, - {1000681790, 178.961267}, - {1000691790, 178.955018}, - {1000701790, 178.94993}, - {1000711790, 178.947332985}, - {1000721790, 178.945825705}, - {1000731790, 178.94593905}, - {1000741790, 178.947079378}, - {1000751790, 178.949989686}, - {1000761790, 178.953815985}, - {1000771790, 178.959117594}, - {1000781790, 178.965358742}, - {1000791790, 178.973173666}, - {1000801790, 178.981821759}, - {1000811790, 178.991122185}, - {1000821790, 179.002202492}, - {1000681800, 179.96438}, - {1000691800, 179.959023}, - {1000701800, 179.951991}, - {1000711800, 179.949890744}, - {1000721800, 179.946559537}, - {1000731800, 179.947467589}, - {1000741800, 179.946713304}, - {1000751800, 179.950791568}, - {1000761800, 179.952381665}, - {1000771800, 179.959229446}, - {1000781800, 179.96303801}, - {1000791800, 179.972489738}, - {1000801800, 179.97826018}, - {1000811800, 179.98991895}, - {1000821800, 179.997916177}, - {1000691810, 180.961954}, - {1000701810, 180.95589}, - {1000711810, 180.951908}, - {1000721810, 180.949110834}, - {1000731810, 180.947998528}, - {1000741810, 180.948218733}, - {1000751810, 180.950061507}, - {1000761810, 180.953247188}, - {1000771810, 180.957634691}, - {1000781810, 180.963089946}, - {1000791810, 180.970079102}, - {1000801810, 180.977819368}, - {1000811810, 180.986259978}, - {1000821810, 180.9966606}, - {1000691820, 181.966194}, - {1000701820, 181.958239}, - {1000711820, 181.955158}, - {1000721820, 181.950563684}, - {1000731820, 181.950154612}, - {1000741820, 181.948205636}, - {1000751820, 181.95121156}, - {1000761820, 181.952110154}, - {1000771820, 181.958076296}, - {1000781820, 181.961171605}, - {1000791820, 181.969614433}, - {1000801820, 181.974689173}, - {1000811820, 181.985692649}, - {1000821820, 181.992673537}, - {1000701830, 182.962426}, - {1000711830, 182.957363}, - {1000721830, 182.953533203}, - {1000731830, 182.95137538}, - {1000741830, 182.950224416}, - {1000751830, 182.950821306}, - {1000761830, 182.953125028}, - {1000771830, 182.956841231}, - {1000781830, 182.961595895}, - {1000791830, 182.967588106}, - {1000801830, 182.974444652}, - {1000811830, 182.982192843}, - {1000821830, 182.991862527}, - {1000701840, 183.965002}, - {1000711840, 183.96103}, - {1000721840, 183.955448507}, - {1000731840, 183.954009958}, - {1000741840, 183.95093318}, - {1000751840, 183.952528073}, - {1000761840, 183.952492919}, - {1000771840, 183.957476}, - {1000781840, 183.959921929}, - {1000791840, 183.967451523}, - {1000801840, 183.971717709}, - {1000811840, 183.981874973}, - {1000821840, 183.988135634}, - {1000831840, 184.001347}, - {1000701850, 184.969425}, - {1000711850, 184.963542}, - {1000721850, 184.958862}, - {1000731850, 184.955561317}, - {1000741850, 184.953421206}, - {1000751850, 184.95295832}, - {1000761850, 184.954045969}, - {1000771850, 184.956698}, - {1000781850, 184.960613659}, - {1000791850, 184.965798871}, - {1000801850, 184.971890696}, - {1000811850, 184.978789189}, - {1000821850, 184.98761}, - {1000831850, 184.9976}, - {1000711860, 185.96745}, - {1000721860, 185.960897}, - {1000731860, 185.958553036}, - {1000741860, 185.95436514}, - {1000751860, 185.954989172}, - {1000761860, 185.953837569}, - {1000771860, 185.957946754}, - {1000781860, 185.959350845}, - {1000791860, 185.965952703}, - {1000801860, 185.969362061}, - {1000811860, 185.978654787}, - {1000821860, 185.984239409}, - {1000831860, 185.996623169}, - {1000841860, 186.004403174}, - {1000711870, 186.970188}, - {1000721870, 186.964573}, - {1000731870, 186.960391}, - {1000741870, 186.957161249}, - {1000751870, 186.955752217}, - {1000761870, 186.955749569}, - {1000771870, 186.957542}, - {1000781870, 186.960616646}, - {1000791870, 186.964542147}, - {1000801870, 186.96981354}, - {1000811870, 186.97590474}, - {1000821870, 186.983910842}, - {1000831870, 186.993147272}, - {1000841870, 187.003031482}, - {1000711880, 187.974428}, - {1000721880, 187.966903}, - {1000731880, 187.963596}, - {1000741880, 187.958488325}, - {1000751880, 187.958113658}, - {1000761880, 187.955837292}, - {1000771880, 187.958834999}, - {1000781880, 187.959397521}, - {1000791880, 187.965247966}, - {1000801880, 187.967580738}, - {1000811880, 187.976020886}, - {1000821880, 187.980879079}, - {1000831880, 187.992276064}, - {1000841880, 187.999415586}, - {1000721890, 188.970853}, - {1000731890, 188.96569}, - {1000741890, 188.961557}, - {1000751890, 188.959227764}, - {1000761890, 188.958145949}, - {1000771890, 188.958722602}, - {1000781890, 188.960848485}, - {1000791890, 188.963948286}, - {1000801890, 188.968194776}, - {1000811890, 188.973573525}, - {1000821890, 188.980843658}, - {1000831890, 188.989195139}, - {1000841890, 188.998473425}, - {1000721900, 189.973376}, - {1000731900, 189.969168}, - {1000741900, 189.963103542}, - {1000751900, 189.961800064}, - {1000761900, 189.958445442}, - {1000771900, 189.960543374}, - {1000781900, 189.959949823}, - {1000791900, 189.964751746}, - {1000801900, 189.96632225}, - {1000811900, 189.973841771}, - {1000821900, 189.978081872}, - {1000831900, 189.988624828}, - {1000841900, 189.995101731}, - {1000731910, 190.97153}, - {1000741910, 190.966531}, - {1000751910, 190.963123322}, - {1000761910, 190.960928105}, - {1000771910, 190.960591455}, - {1000781910, 190.961676261}, - {1000791910, 190.963716452}, - {1000801910, 190.967158301}, - {1000811910, 190.971784093}, - {1000821910, 190.978216455}, - {1000831910, 190.985786972}, - {1000841910, 190.994558494}, - {1000851910, 191.004148081}, - {1000731920, 191.975201}, - {1000741920, 191.968202}, - {1000751920, 191.966088}, - {1000761920, 191.961478765}, - {1000771920, 191.962602414}, - {1000781920, 191.961042667}, - {1000791920, 191.964817615}, - {1000801920, 191.965634263}, - {1000811920, 191.972225}, - {1000821920, 191.975789598}, - {1000831920, 191.985470077}, - {1000841920, 191.991340274}, - {1000851920, 192.003140912}, - {1000731930, 192.97766}, - {1000741930, 192.971884}, - {1000751930, 192.967545}, - {1000761930, 192.964149637}, - {1000771930, 192.962923753}, - {1000781930, 192.962984546}, - {1000791930, 192.964138442}, - {1000801930, 192.966653395}, - {1000811930, 192.970501994}, - {1000821930, 192.976135914}, - {1000831930, 192.98294722}, - {1000841930, 192.991062421}, - {1000851930, 192.999927725}, - {1000861930, 193.009707973}, - {1000731940, 193.98161}, - {1000741940, 193.973795}, - {1000751940, 193.970735}, - {1000761940, 193.965179407}, - {1000771940, 193.965075703}, - {1000781940, 193.962683498}, - {1000791940, 193.965419051}, - {1000801940, 193.965449108}, - {1000811940, 193.971081408}, - {1000821940, 193.974011788}, - {1000831940, 193.982798581}, - {1000841940, 193.988186058}, - {1000851940, 193.999230816}, - {1000861940, 194.006145636}, - {1000741950, 194.977735}, - {1000751950, 194.97256}, - {1000761950, 194.968318}, - {1000771950, 194.965976898}, - {1000781950, 194.964794325}, - {1000791950, 194.965037823}, - {1000801950, 194.966705809}, - {1000811950, 194.969774052}, - {1000821950, 194.974516167}, - {1000831950, 194.980648759}, - {1000841950, 194.988065781}, - {1000851950, 194.99627448}, - {1000861950, 195.005421703}, - {1000741960, 195.979882}, - {1000751960, 195.975996}, - {1000761960, 195.969643261}, - {1000771960, 195.968399669}, - {1000781960, 195.964954648}, - {1000791960, 195.966571213}, - {1000801960, 195.965833445}, - {1000811960, 195.970481189}, - {1000821960, 195.972787552}, - {1000831960, 195.980666509}, - {1000841960, 195.985540722}, - {1000851960, 195.995799034}, - {1000861960, 196.002120431}, - {1000741970, 196.984036}, - {1000751970, 196.978153}, - {1000761970, 196.973076}, - {1000771970, 196.969657217}, - {1000781970, 196.96734303}, - {1000791970, 196.966570103}, - {1000801970, 196.967213715}, - {1000811970, 196.969560492}, - {1000821970, 196.973434737}, - {1000831970, 196.978864927}, - {1000841970, 196.985621939}, - {1000851970, 196.993177353}, - {1000861970, 197.001621446}, - {1000871970, 197.011008086}, - {1000751980, 197.98176}, - {1000761980, 197.974664}, - {1000771980, 197.972399}, - {1000781980, 197.967896718}, - {1000791980, 197.968243714}, - {1000801980, 197.966769177}, - {1000811980, 197.970446669}, - {1000821980, 197.97201545}, - {1000831980, 197.979201316}, - {1000841980, 197.983388753}, - {1000851980, 197.992797864}, - {1000861980, 197.998679197}, - {1000871980, 198.010282081}, - {1000751990, 198.984187}, - {1000761990, 198.978239}, - {1000771990, 198.973807097}, - {1000781990, 198.970597022}, - {1000791990, 198.968766573}, - {1000801990, 198.968280994}, - {1000811990, 198.969877}, - {1000821990, 198.97291262}, - {1000831990, 198.977672841}, - {1000841990, 198.983640445}, - {1000851990, 198.990527715}, - {1000861990, 198.998325436}, - {1000871990, 199.007269384}, - {1000762000, 199.980086}, - {1000772000, 199.976844}, - {1000782000, 199.971444609}, - {1000792000, 199.970756558}, - {1000802000, 199.968326941}, - {1000812000, 199.970963608}, - {1000822000, 199.971818546}, - {1000832000, 199.97813129}, - {1000842000, 199.981812355}, - {1000852000, 199.990351099}, - {1000862000, 199.995705335}, - {1000872000, 200.006584666}, - {1000762010, 200.984069}, - {1000772010, 200.978701}, - {1000782010, 200.974513305}, - {1000792010, 200.971657678}, - {1000802010, 200.970303054}, - {1000812010, 200.970820235}, - {1000822010, 200.972870431}, - {1000832010, 200.976995017}, - {1000842010, 200.982263799}, - {1000852010, 200.988417058}, - {1000862010, 200.995590511}, - {1000872010, 201.003852491}, - {1000882010, 201.012814699}, - {1000762020, 201.986548}, - {1000772020, 201.982136}, - {1000782020, 201.975639}, - {1000792020, 201.973856}, - {1000802020, 201.970643604}, - {1000812020, 201.972108874}, - {1000822020, 201.972151613}, - {1000832020, 201.977723042}, - {1000842020, 201.980738934}, - {1000852020, 201.988625686}, - {1000862020, 201.993263982}, - {1000872020, 202.003329637}, - {1000882020, 202.009742305}, - {1000762030, 202.992195}, - {1000772030, 202.984573}, - {1000782030, 202.979055}, - {1000792030, 202.975154492}, - {1000802030, 202.972872396}, - {1000812030, 202.972344098}, - {1000822030, 202.973390617}, - {1000832030, 202.976892077}, - {1000842030, 202.981416072}, - {1000852030, 202.986942904}, - {1000862030, 202.993361155}, - {1000872030, 203.000940867}, - {1000882030, 203.009233907}, - {1000772040, 203.989726}, - {1000782040, 203.981084}, - {1000792040, 203.97811}, - {1000802040, 203.973494037}, - {1000812040, 203.97386342}, - {1000822040, 203.973043506}, - {1000832040, 203.977835687}, - {1000842040, 203.980310078}, - {1000852040, 203.987251393}, - {1000862040, 203.991443729}, - {1000872040, 204.000651972}, - {1000882040, 204.006506855}, - {1000772050, 204.993988}, - {1000782050, 204.986237}, - {1000792050, 204.980064}, - {1000802050, 204.976073151}, - {1000812050, 204.974427318}, - {1000822050, 204.974481682}, - {1000832050, 204.977385182}, - {1000842050, 204.981190006}, - {1000852050, 204.986060546}, - {1000862050, 204.991723228}, - {1000872050, 204.998593854}, - {1000882050, 205.006230692}, - {1000892050, 205.015144152}, - {1000782060, 205.99008}, - {1000792060, 205.984766}, - {1000802060, 205.977513837}, - {1000812060, 205.976110108}, - {1000822060, 205.97446521}, - {1000832060, 205.978498843}, - {1000842060, 205.980473662}, - {1000852060, 205.986645768}, - {1000862060, 205.990195409}, - {1000872060, 205.998661441}, - {1000882060, 206.003827842}, - {1000892060, 206.014476477}, - {1000782070, 206.995556}, - {1000792070, 206.988577}, - {1000802070, 206.9823}, - {1000812070, 206.977418605}, - {1000822070, 206.975896821}, - {1000832070, 206.978470551}, - {1000842070, 206.981593334}, - {1000852070, 206.985799715}, - {1000862070, 206.990730224}, - {1000872070, 206.99694145}, - {1000882070, 207.00377242}, - {1000892070, 207.011965967}, - {1000782080, 207.999463}, - {1000792080, 207.993655}, - {1000802080, 207.985759}, - {1000812080, 207.982018006}, - {1000822080, 207.976652005}, - {1000832080, 207.97974206}, - {1000842080, 207.981246035}, - {1000852080, 207.986613011}, - {1000862080, 207.989634513}, - {1000872080, 207.997139082}, - {1000882080, 208.001855012}, - {1000892080, 208.011552251}, - {1000902080, 208.017915348}, - {1000792090, 208.997606}, - {1000802090, 208.990757}, - {1000812090, 208.985351713}, - {1000822090, 208.981089978}, - {1000832090, 208.980398599}, - {1000842090, 208.982430361}, - {1000852090, 208.986168701}, - {1000862090, 208.990401389}, - {1000872090, 208.995939701}, - {1000882090, 209.001994902}, - {1000892090, 209.009495375}, - {1000902090, 209.017601}, - {1000792100, 210.002877}, - {1000802100, 209.99431}, - {1000812100, 209.990072942}, - {1000822100, 209.984188381}, - {1000832100, 209.984120237}, - {1000842100, 209.982873686}, - {1000852100, 209.987147423}, - {1000862100, 209.989688862}, - {1000872100, 209.996410596}, - {1000882100, 210.000475406}, - {1000892100, 210.009408625}, - {1000902100, 210.015093515}, - {1000802110, 210.999581}, - {1000812110, 210.993475}, - {1000822110, 210.988735288}, - {1000832110, 210.987268715}, - {1000842110, 210.986653171}, - {1000852110, 210.987496226}, - {1000862110, 210.990600767}, - {1000872110, 210.995555189}, - {1000882110, 211.000893049}, - {1000892110, 211.007668846}, - {1000902110, 211.014896923}, - {1000912110, 211.023674036}, - {1000802120, 212.003242}, - {1000812120, 211.998335}, - {1000822120, 211.991895891}, - {1000832120, 211.99128503}, - {1000842120, 211.988867982}, - {1000852120, 211.990737301}, - {1000862120, 211.990703946}, - {1000872120, 211.99622542}, - {1000882120, 211.999786619}, - {1000892120, 212.007836442}, - {1000902120, 212.01300157}, - {1000912120, 212.023184819}, - {1000802130, 213.008803}, - {1000812130, 213.001915}, - {1000822130, 212.996560796}, - {1000832130, 212.99438357}, - {1000842130, 212.992857154}, - {1000852130, 212.992936593}, - {1000862130, 212.993885147}, - {1000872130, 212.99618441}, - {1000882130, 213.000370971}, - {1000892130, 213.006592665}, - {1000902130, 213.01301147}, - {1000912130, 213.021099644}, - {1000802140, 214.012636}, - {1000812140, 214.00694}, - {1000822140, 213.999803521}, - {1000832140, 213.998710909}, - {1000842140, 213.995201287}, - {1000852140, 213.996372331}, - {1000862140, 213.99536265}, - {1000872140, 213.998971193}, - {1000882140, 214.00009956}, - {1000892140, 214.0069064}, - {1000902140, 214.01148148}, - {1000912140, 214.020891055}, - {1000802150, 215.018368}, - {1000812150, 215.010768}, - {1000822150, 215.004661591}, - {1000832150, 215.001749095}, - {1000842150, 214.999418385}, - {1000852150, 214.998651002}, - {1000862150, 214.998745037}, - {1000872150, 215.000341534}, - {1000882150, 215.002718208}, - {1000892150, 215.006474061}, - {1000902150, 215.01172464}, - {1000912150, 215.019113955}, - {1000922150, 215.026719774}, - {1000802160, 216.022459}, - {1000812160, 216.015964}, - {1000822160, 216.008062}, - {1000832160, 216.006305985}, - {1000842160, 216.001913416}, - {1000852160, 216.002422643}, - {1000862160, 216.000271942}, - {1000872160, 216.003189523}, - {1000882160, 216.003533534}, - {1000892160, 216.008749101}, - {1000902160, 216.011055933}, - {1000912160, 216.019134633}, - {1000922160, 216.024762829}, - {1000812170, 217.020032}, - {1000822170, 217.013162}, - {1000832170, 217.009372}, - {1000842170, 217.006316145}, - {1000852170, 217.004717794}, - {1000862170, 217.003927632}, - {1000872170, 217.00463198}, - {1000882170, 217.006322676}, - {1000892170, 217.009342325}, - {1000902170, 217.013103443}, - {1000912170, 217.018309024}, - {1000922170, 217.02466}, - {1000812180, 218.025454}, - {1000822180, 218.016779}, - {1000832180, 218.014188}, - {1000842180, 218.008971234}, - {1000852180, 218.008695941}, - {1000862180, 218.005601123}, - {1000872180, 218.00757862}, - {1000882180, 218.007134297}, - {1000892180, 218.01164886}, - {1000902180, 218.013276248}, - {1000912180, 218.020021133}, - {1000922180, 218.023504877}, - {1000822190, 219.022136}, - {1000832190, 219.01752}, - {1000842190, 219.013614}, - {1000852190, 219.011160587}, - {1000862190, 219.009478683}, - {1000872190, 219.009250664}, - {1000882190, 219.010084715}, - {1000892190, 219.012420425}, - {1000902190, 219.015526432}, - {1000912190, 219.019949909}, - {1000922190, 219.025009233}, - {1000932190, 219.031601865}, - {1000822200, 220.025905}, - {1000832200, 220.022501}, - {1000842200, 220.016386}, - {1000852200, 220.015433}, - {1000862200, 220.011392443}, - {1000872200, 220.012326789}, - {1000882200, 220.011027542}, - {1000892200, 220.014754527}, - {1000902200, 220.015769866}, - {1000912200, 220.021769753}, - {1000922200, 220.024706}, - {1000932200, 220.03271628}, - {1000832210, 221.02598}, - {1000842210, 221.021228}, - {1000852210, 221.018017}, - {1000862210, 221.015535637}, - {1000872210, 221.014253714}, - {1000882210, 221.013917293}, - {1000892210, 221.015599721}, - {1000902210, 221.018185757}, - {1000912210, 221.021873393}, - {1000922210, 221.026323297}, - {1000932210, 221.03211}, - {1000942210, 221.038572}, - {1000832220, 222.031079}, - {1000842220, 222.02414}, - {1000852220, 222.022494}, - {1000862220, 222.017576017}, - {1000872220, 222.017582615}, - {1000882220, 222.015373371}, - {1000892220, 222.017844232}, - {1000902220, 222.01846822}, - {1000912220, 222.023687064}, - {1000922220, 222.026057957}, - {1000932220, 222.033574706}, - {1000942220, 222.037638}, - {1000832230, 223.034611}, - {1000842230, 223.02907}, - {1000852230, 223.025151}, - {1000862230, 223.021889283}, - {1000872230, 223.019734241}, - {1000882230, 223.018500648}, - {1000892230, 223.019135982}, - {1000902230, 223.020811083}, - {1000912230, 223.023980414}, - {1000922230, 223.027960754}, - {1000932230, 223.03291334}, - {1000942230, 223.038777}, - {1000952230, 223.04584}, - {1000832240, 224.039796}, - {1000842240, 224.03211}, - {1000852240, 224.029749}, - {1000862240, 224.024095803}, - {1000872240, 224.023348096}, - {1000882240, 224.020210361}, - {1000892240, 224.021722249}, - {1000902240, 224.021466137}, - {1000912240, 224.025617286}, - {1000922240, 224.027635913}, - {1000932240, 224.03438803}, - {1000942240, 224.037875}, - {1000952240, 224.046442}, - {1000842250, 225.037123}, - {1000852250, 225.032528}, - {1000862250, 225.028485572}, - {1000872250, 225.025572466}, - {1000882250, 225.023610502}, - {1000892250, 225.023228601}, - {1000902250, 225.023950975}, - {1000912250, 225.026147927}, - {1000922250, 225.02938505}, - {1000932250, 225.033943422}, - {1000942250, 225.03897}, - {1000952250, 225.045508}, - {1000842260, 226.04031}, - {1000852260, 226.037209}, - {1000862260, 226.03086138}, - {1000872260, 226.029544512}, - {1000882260, 226.025408186}, - {1000892260, 226.026096999}, - {1000902260, 226.024903699}, - {1000912260, 226.027948217}, - {1000922260, 226.029338669}, - {1000932260, 226.035230364}, - {1000942260, 226.03825}, - {1000952260, 226.04613}, - {1000842270, 227.04539}, - {1000852270, 227.040183}, - {1000862270, 227.035304393}, - {1000872270, 227.031865413}, - {1000882270, 227.029176205}, - {1000892270, 227.027750594}, - {1000902270, 227.027702546}, - {1000912270, 227.028803586}, - {1000922270, 227.031181124}, - {1000932270, 227.034975012}, - {1000942270, 227.039474}, - {1000952270, 227.045282}, - {1000852280, 228.04496}, - {1000862280, 228.037835415}, - {1000872280, 228.035839433}, - {1000882280, 228.031068574}, - {1000892280, 228.031019685}, - {1000902280, 228.028739741}, - {1000912280, 228.031050758}, - {1000922280, 228.031368959}, - {1000932280, 228.036313}, - {1000942280, 228.038763325}, - {1000952280, 228.046001}, - {1000852290, 229.048191}, - {1000862290, 229.042257272}, - {1000872290, 229.038291443}, - {1000882290, 229.034956703}, - {1000892290, 229.032947}, - {1000902290, 229.031761357}, - {1000912290, 229.032095585}, - {1000922290, 229.033505976}, - {1000932290, 229.036287269}, - {1000942290, 229.040145099}, - {1000952290, 229.045282534}, - {1000862300, 230.045271}, - {1000872300, 230.042390787}, - {1000882300, 230.037054776}, - {1000892300, 230.036327}, - {1000902300, 230.033132267}, - {1000912300, 230.034539717}, - {1000922300, 230.033940114}, - {1000932300, 230.03782806}, - {1000942300, 230.039648313}, - {1000952300, 230.046025}, - {1000862310, 231.049973}, - {1000872310, 231.045175353}, - {1000882310, 231.041027085}, - {1000892310, 231.038393}, - {1000902310, 231.036302764}, - {1000912310, 231.0358825}, - {1000922310, 231.03629218}, - {1000932310, 231.038243598}, - {1000942310, 231.041125946}, - {1000952310, 231.045529}, - {1000962310, 231.050746}, - {1000872320, 232.049461219}, - {1000882320, 232.043475267}, - {1000892320, 232.042034}, - {1000902320, 232.038053606}, - {1000912320, 232.038590205}, - {1000922320, 232.037154765}, - {1000932320, 232.040107}, - {1000942320, 232.041182133}, - {1000952320, 232.046613}, - {1000962320, 232.04974}, - {1000872330, 233.052517833}, - {1000882330, 233.04759457}, - {1000892330, 233.044346}, - {1000902330, 233.041580126}, - {1000912330, 233.040246535}, - {1000922330, 233.039634294}, - {1000932330, 233.040739421}, - {1000942330, 233.042997411}, - {1000952330, 233.046468}, - {1000962330, 233.050771485}, - {1000972330, 233.056652}, - {1000882340, 234.0503821}, - {1000892340, 234.048139}, - {1000902340, 234.043599801}, - {1000912340, 234.043305555}, - {1000922340, 234.040950296}, - {1000932340, 234.042893245}, - {1000942340, 234.043317489}, - {1000952340, 234.047731}, - {1000962340, 234.050158568}, - {1000972340, 234.057322}, - {1000882350, 235.05489}, - {1000892350, 235.05084}, - {1000902350, 235.047255}, - {1000912350, 235.045399}, - {1000922350, 235.043928117}, - {1000932350, 235.044061518}, - {1000942350, 235.045284609}, - {1000952350, 235.047906478}, - {1000962350, 235.051545}, - {1000972350, 235.056651}, - {1000892360, 236.054988}, - {1000902360, 236.049657}, - {1000912360, 236.048668}, - {1000922360, 236.04556613}, - {1000932360, 236.046568296}, - {1000942360, 236.046056661}, - {1000952360, 236.049427}, - {1000962360, 236.051372112}, - {1000972360, 236.057479}, - {1000892370, 237.057993}, - {1000902370, 237.053629}, - {1000912370, 237.051023}, - {1000922370, 237.048728309}, - {1000932370, 237.04817164}, - {1000942370, 237.048407888}, - {1000952370, 237.049995}, - {1000962370, 237.052868988}, - {1000972370, 237.057123}, - {1000982370, 237.062199272}, - {1000902380, 238.056388}, - {1000912380, 238.054637}, - {1000922380, 238.050786936}, - {1000932380, 238.050944603}, - {1000942380, 238.049558175}, - {1000952380, 238.051982531}, - {1000962380, 238.053081606}, - {1000972380, 238.058204}, - {1000982380, 238.06149}, - {1000902390, 239.060655}, - {1000912390, 239.05726}, - {1000922390, 239.054291989}, - {1000932390, 239.052937538}, - {1000942390, 239.052161596}, - {1000952390, 239.053022729}, - {1000962390, 239.054908519}, - {1000972390, 239.058239}, - {1000982390, 239.062482}, - {1000992390, 239.06831}, - {1000912400, 240.061203}, - {1000922400, 240.056592411}, - {1000932400, 240.056163778}, - {1000942400, 240.05381174}, - {1000952400, 240.055298374}, - {1000962400, 240.055528233}, - {1000972400, 240.059758}, - {1000982400, 240.062253447}, - {1000992400, 240.068949}, - {1000912410, 241.064134}, - {1000922410, 241.06033}, - {1000932410, 241.058309671}, - {1000942410, 241.056849651}, - {1000952410, 241.056827343}, - {1000962410, 241.057651218}, - {1000972410, 241.060098}, - {1000982410, 241.06369}, - {1000992410, 241.068592}, - {1001002410, 241.074311}, - {1000922420, 242.062931}, - {1000932420, 242.061639548}, - {1000942420, 242.058740979}, - {1000952420, 242.059547358}, - {1000962420, 242.058834187}, - {1000972420, 242.061999}, - {1000982420, 242.063754544}, - {1000992420, 242.069567}, - {1001002420, 242.07343}, - {1000922430, 243.067075}, - {1000932430, 243.064204}, - {1000942430, 243.062002068}, - {1000952430, 243.061379889}, - {1000962430, 243.061387329}, - {1000972430, 243.063005905}, - {1000982430, 243.065475}, - {1000992430, 243.069508}, - {1001002430, 243.074414}, - {1000932440, 244.067891}, - {1000942440, 244.064204401}, - {1000952440, 244.064282892}, - {1000962440, 244.062750622}, - {1000972440, 244.065178969}, - {1000982440, 244.065999447}, - {1000992440, 244.070881}, - {1001002440, 244.074036}, - {1001012440, 244.081157}, - {1000932450, 245.070693}, - {1000942450, 245.067824554}, - {1000952450, 245.066452827}, - {1000962450, 245.065491047}, - {1000972450, 245.066359814}, - {1000982450, 245.068046755}, - {1000992450, 245.071192}, - {1001002450, 245.075354}, - {1001012450, 245.080864}, - {1000942460, 246.070204172}, - {1000952460, 246.069774}, - {1000962460, 246.067222016}, - {1000972460, 246.0686713}, - {1000982460, 246.068803685}, - {1000992460, 246.072806474}, - {1001002460, 246.075353334}, - {1001012460, 246.081713}, - {1000942470, 247.0743}, - {1000952470, 247.072092}, - {1000962470, 247.070352678}, - {1000972470, 247.070305889}, - {1000982470, 247.070971348}, - {1000992470, 247.073621929}, - {1001002470, 247.076944}, - {1001012470, 247.08152}, - {1000952480, 248.075752}, - {1000962480, 248.072349086}, - {1000972480, 248.073141689}, - {1000982480, 248.072182905}, - {1000992480, 248.075469}, - {1001002480, 248.077185451}, - {1001012480, 248.082607}, - {1001022480, 248.086623}, - {1000952490, 249.07848}, - {1000962490, 249.075953992}, - {1000972490, 249.074983118}, - {1000982490, 249.074850428}, - {1000992490, 249.076409}, - {1001002490, 249.078926042}, - {1001012490, 249.082857155}, - {1001022490, 249.087802}, - {1000962500, 250.078357541}, - {1000972500, 250.078317195}, - {1000982500, 250.076404494}, - {1000992500, 250.078611}, - {1001002500, 250.079519765}, - {1001012500, 250.084164934}, - {1001022500, 250.087565}, - {1000962510, 251.082284988}, - {1000972510, 251.080760555}, - {1000982510, 251.079587171}, - {1000992510, 251.079991431}, - {1001002510, 251.08154513}, - {1001012510, 251.084774287}, - {1001022510, 251.088942}, - {1001032510, 251.094289}, - {1000962520, 252.08487}, - {1000972520, 252.08431}, - {1000982520, 252.081626507}, - {1000992520, 252.082979173}, - {1001002520, 252.082466019}, - {1001012520, 252.086385}, - {1001022520, 252.08896607}, - {1001032520, 252.095048}, - {1000972530, 253.08688}, - {1000982530, 253.085133723}, - {1000992530, 253.084821241}, - {1001002530, 253.085180945}, - {1001012530, 253.087143}, - {1001022530, 253.09056278}, - {1001032530, 253.09503385}, - {1001042530, 253.100528}, - {1000972540, 254.0906}, - {1000982540, 254.087323575}, - {1000992540, 254.088024337}, - {1001002540, 254.086852424}, - {1001012540, 254.08959}, - {1001022540, 254.090954211}, - {1001032540, 254.096238813}, - {1001042540, 254.100055}, - {1000982550, 255.091046}, - {1000992550, 255.090273504}, - {1001002550, 255.089963495}, - {1001012550, 255.091081702}, - {1001022550, 255.093196439}, - {1001032550, 255.096562399}, - {1001042550, 255.101267}, - {1001052550, 255.106919}, - {1000982560, 256.093442}, - {1000992560, 256.093597}, - {1001002560, 256.091771699}, - {1001012560, 256.093888}, - {1001022560, 256.094281912}, - {1001032560, 256.098494024}, - {1001042560, 256.101151464}, - {1001052560, 256.107674}, - {1000992570, 257.095979}, - {1001002570, 257.095105419}, - {1001012570, 257.095537343}, - {1001022570, 257.096884203}, - {1001032570, 257.09948}, - {1001042570, 257.102916796}, - {1001052570, 257.107520042}, - {1000992580, 258.09952}, - {1001002580, 258.097077}, - {1001012580, 258.098433634}, - {1001022580, 258.098205}, - {1001032580, 258.101753}, - {1001042580, 258.103429895}, - {1001052580, 258.108972995}, - {1001062580, 258.11304}, - {1001002590, 259.100596}, - {1001012590, 259.100445}, - {1001022590, 259.100998364}, - {1001032590, 259.1029}, - {1001042590, 259.105601}, - {1001052590, 259.109491859}, - {1001062590, 259.114353}, - {1001002600, 260.102809}, - {1001012600, 260.10365}, - {1001022600, 260.102641}, - {1001032600, 260.105504}, - {1001042600, 260.10644}, - {1001052600, 260.111297}, - {1001062600, 260.114383435}, - {1001072600, 260.121443}, - {1001012610, 261.105828}, - {1001022610, 261.105696}, - {1001032610, 261.106879}, - {1001042610, 261.108769591}, - {1001052610, 261.111979}, - {1001062610, 261.115948135}, - {1001072610, 261.121395733}, - {1001012620, 262.109144}, - {1001022620, 262.107463}, - {1001032620, 262.109615}, - {1001042620, 262.109923}, - {1001052620, 262.114067}, - {1001062620, 262.116338978}, - {1001072620, 262.122654688}, - {1001022630, 263.110714}, - {1001032630, 263.111293}, - {1001042630, 263.112461}, - {1001052630, 263.114987}, - {1001062630, 263.118299}, - {1001072630, 263.122916}, - {1001082630, 263.128479}, - {1001022640, 264.112734}, - {1001032640, 264.114198}, - {1001042640, 264.113876}, - {1001052640, 264.117297}, - {1001062640, 264.11893}, - {1001072640, 264.124486}, - {1001082640, 264.12835633}, - {1001032650, 265.116193}, - {1001042650, 265.116683}, - {1001052650, 265.1185}, - {1001062650, 265.121089}, - {1001072650, 265.124955}, - {1001082650, 265.129791744}, - {1001092650, 265.135937}, - {1001032660, 266.119874}, - {1001042660, 266.118236}, - {1001052660, 266.121032}, - {1001062660, 266.121973}, - {1001072660, 266.12679}, - {1001082660, 266.130048783}, - {1001092660, 266.137062253}, - {1001042670, 267.121787}, - {1001052670, 267.122399}, - {1001062670, 267.124323}, - {1001072670, 267.127499}, - {1001082670, 267.131678}, - {1001092670, 267.137189}, - {1001102670, 267.143726}, - {1001042680, 268.123968}, - {1001052680, 268.125669}, - {1001062680, 268.125389}, - {1001072680, 268.129584}, - {1001082680, 268.132011}, - {1001092680, 268.138649}, - {1001102680, 268.143477}, - {1001052690, 269.127911}, - {1001062690, 269.128495}, - {1001072690, 269.130411}, - {1001082690, 269.133649}, - {1001092690, 269.138809}, - {1001102690, 269.144750965}, - {1001052700, 270.131399}, - {1001062700, 270.130362}, - {1001072700, 270.133366}, - {1001082700, 270.134313}, - {1001092700, 270.140322}, - {1001102700, 270.14458662}, - {1001062710, 271.133782}, - {1001072710, 271.135115}, - {1001082710, 271.137082}, - {1001092710, 271.140741}, - {1001102710, 271.145951}, - {1001062720, 272.135825}, - {1001072720, 272.138259}, - {1001082720, 272.138492}, - {1001092720, 272.143298}, - {1001102720, 272.146091}, - {1001112720, 272.153273}, - {1001062730, 273.139475}, - {1001072730, 273.140294}, - {1001082730, 273.141458}, - {1001092730, 273.144695}, - {1001102730, 273.148455}, - {1001112730, 273.153393}, - {1001072740, 274.143599}, - {1001082740, 274.143217}, - {1001092740, 274.147343}, - {1001102740, 274.149434}, - {1001112740, 274.155247}, - {1001072750, 275.145766}, - {1001082750, 275.14653}, - {1001092750, 275.148972}, - {1001102750, 275.152085}, - {1001112750, 275.156088}, - {1001072760, 276.149169}, - {1001082760, 276.148348}, - {1001092760, 276.151705}, - {1001102760, 276.153022}, - {1001112760, 276.158226}, - {1001122760, 276.161418}, - {1001072770, 277.151477}, - {1001082770, 277.151772}, - {1001092770, 277.153525}, - {1001102770, 277.155763}, - {1001112770, 277.159322}, - {1001122770, 277.163535}, - {1001072780, 278.154988}, - {1001082780, 278.153753}, - {1001092780, 278.156487}, - {1001102780, 278.157007}, - {1001112780, 278.16159}, - {1001122780, 278.164083}, - {1001132780, 278.170725}, - {1001082790, 279.157274}, - {1001092790, 279.158439}, - {1001102790, 279.159984}, - {1001112790, 279.16288}, - {1001122790, 279.166422}, - {1001132790, 279.171187}, - {1001082800, 280.159335}, - {1001092800, 280.161579}, - {1001102800, 280.161375}, - {1001112800, 280.165204}, - {1001122800, 280.167102}, - {1001132800, 280.173098}, - {1001092810, 281.163608}, - {1001102810, 281.164545}, - {1001112810, 281.166757}, - {1001122810, 281.169563}, - {1001132810, 281.17371}, - {1001092820, 282.166888}, - {1001102820, 282.166174}, - {1001112820, 282.169343}, - {1001122820, 282.170507}, - {1001132820, 282.17577}, - {1001102830, 283.169437}, - {1001112830, 283.171101}, - {1001122830, 283.173202}, - {1001132830, 283.176666}, - {1001102840, 284.171187}, - {1001112840, 284.173882}, - {1001122840, 284.17436}, - {1001132840, 284.178843}, - {1001142840, 284.181192}, - {1001112850, 285.175771}, - {1001122850, 285.177227}, - {1001132850, 285.180106}, - {1001142850, 285.183503}, - {1001112860, 286.178756}, - {1001122860, 286.178691}, - {1001132860, 286.182456}, - {1001142860, 286.184226}, - {1001122870, 287.181826}, - {1001132870, 287.184064}, - {1001142870, 287.18672}, - {1001152870, 287.19082}, - {1001122880, 288.183501}, - {1001132880, 288.186764}, - {1001142880, 288.187781}, - {1001152880, 288.192879}, - {1001132890, 289.188461}, - {1001142890, 289.190517}, - {1001152890, 289.193971}, - {1001162890, 289.198023}, - {1001132900, 290.191429}, - {1001142900, 290.191875}, - {1001152900, 290.196235}, - {1001162900, 290.198635}, - {1001142910, 291.194848}, - {1001152910, 291.197725}, - {1001162910, 291.201014}, - {1001172910, 291.205748}, - {1001152920, 292.200323}, - {1001162920, 292.201969}, - {1001172920, 292.207861}, - {1001162930, 293.204583}, - {1001172930, 293.208727}, - {1001182930, 293.213423}, - {1001172940, 294.21084}, - {1001182940, 294.213979}, - {1001182950, 295.216178}, -}; - -} // namespace openmc diff --git a/src/bank.cpp b/src/bank.cpp index 5b12b48fd..8d00d5440 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -1,14 +1,11 @@ #include "openmc/bank.h" #include "openmc/capi.h" #include "openmc/error.h" -#include "openmc/ifp.h" #include "openmc/message_passing.h" #include "openmc/simulation.h" #include "openmc/vector.h" #include -#include -#include namespace openmc { @@ -22,8 +19,6 @@ vector source_bank; SharedArray surf_source_bank; -SharedArray collision_track_bank; - // The fission bank is allocated as a SharedArray, rather than a vector, as it // will be shared by all threads in the simulation. It will be allocated to a // fixed maximum capacity in the init_fission_bank() function. Then, Elements @@ -31,26 +26,11 @@ SharedArray collision_track_bank; // function. SharedArray fission_bank; -vector> ifp_source_delayed_group_bank; - -vector> ifp_source_lifetime_bank; - -vector> ifp_fission_delayed_group_bank; - -vector> ifp_fission_lifetime_bank; - // Each entry in this vector corresponds to the number of progeny produced // this generation for the particle located at that index. This vector is // used to efficiently sort the fission bank after each iteration. vector progeny_per_particle; -// When shared secondary bank mode is enabled, secondaries produced during -// transport are collected in the write bank. When a secondary generation is -// complete, write is moved to read for transport, and a new empty write bank -// is created. This repeats until no secondaries remain. -SharedArray shared_secondary_bank_read; -SharedArray shared_secondary_bank_write; - } // namespace simulation //============================================================================== @@ -61,15 +41,8 @@ void free_memory_bank() { simulation::source_bank.clear(); simulation::surf_source_bank.clear(); - simulation::collision_track_bank.clear(); simulation::fission_bank.clear(); simulation::progeny_per_particle.clear(); - simulation::ifp_source_delayed_group_bank.clear(); - simulation::ifp_source_lifetime_bank.clear(); - simulation::ifp_fission_delayed_group_bank.clear(); - simulation::ifp_fission_lifetime_bank.clear(); - simulation::shared_secondary_bank_read.clear(); - simulation::shared_secondary_bank_write.clear(); } void init_fission_bank(int64_t max) @@ -78,13 +51,13 @@ void init_fission_bank(int64_t max) simulation::progeny_per_particle.resize(simulation::work_per_rank); } -// Performs an O(n) sort on a fission or secondary bank, by leveraging +// Performs an O(n) sort on the fission bank, by leveraging // the parent_id and progeny_id fields of banked particles. See the following // paper for more details: // "Reproducibility and Monte Carlo Eigenvalue Calculations," F.B. Brown and // T.M. Sutton, 1992 ANS Annual Meeting, Transactions of the American Nuclear // Society, Volume 65, Page 235. -void sort_bank(SharedArray& bank, bool is_fission_bank) +void sort_fission_bank() { // Ensure we don't read off the end of the array if we ran with 0 particles if (simulation::progeny_per_particle.size() == 0) { @@ -93,211 +66,47 @@ void sort_bank(SharedArray& bank, bool is_fission_bank) // Perform exclusive scan summation to determine starting indices in fission // bank for each parent particle id - std::exclusive_scan(simulation::progeny_per_particle.begin(), - simulation::progeny_per_particle.end(), - simulation::progeny_per_particle.begin(), 0); + int64_t tmp = simulation::progeny_per_particle[0]; + simulation::progeny_per_particle[0] = 0; + for (int64_t i = 1; i < simulation::progeny_per_particle.size(); i++) { + int64_t value = simulation::progeny_per_particle[i - 1] + tmp; + tmp = simulation::progeny_per_particle[i]; + simulation::progeny_per_particle[i] = value; + } + + // TODO: C++17 introduces the exclusive_scan() function which could be + // used to replace everything above this point in this function. // We need a scratch vector to make permutation of the fission bank into // sorted order easy. Under normal usage conditions, the fission bank is // over provisioned, so we can use that as scratch space. SourceSite* sorted_bank; vector sorted_bank_holder; - vector> sorted_ifp_delayed_group_bank; - vector> sorted_ifp_lifetime_bank; // If there is not enough space, allocate a temporary vector and point to it - if (bank.size() > bank.capacity() / 2) { - sorted_bank_holder.resize(bank.size()); + if (simulation::fission_bank.size() > + simulation::fission_bank.capacity() / 2) { + sorted_bank_holder.resize(simulation::fission_bank.size()); sorted_bank = sorted_bank_holder.data(); } else { // otherwise, point sorted_bank to unused portion of the fission bank - sorted_bank = bank.data() + bank.size(); + sorted_bank = &simulation::fission_bank[simulation::fission_bank.size()]; } - if (settings::ifp_on && is_fission_bank) { - allocate_temporary_vector_ifp( - sorted_ifp_delayed_group_bank, sorted_ifp_lifetime_bank); - } - - // Use parent and progeny indices to sort bank - for (int64_t i = 0; i < bank.size(); i++) { - const auto& site = bank[i]; - if (site.parent_id < 0 || - site.parent_id >= - static_cast(simulation::progeny_per_particle.size())) { - fatal_error(fmt::format("Invalid parent_id {} for banked site (expected " - "range [0, {})).", - site.parent_id, simulation::progeny_per_particle.size())); - } - int64_t idx = - simulation::progeny_per_particle[site.parent_id] + site.progeny_id; - if (idx < 0 || idx >= bank.size()) { + // Use parent and progeny indices to sort fission bank + for (int64_t i = 0; i < simulation::fission_bank.size(); i++) { + const auto& site = simulation::fission_bank[i]; + int64_t offset = site.parent_id - 1 - simulation::work_index[mpi::rank]; + int64_t idx = simulation::progeny_per_particle[offset] + site.progeny_id; + if (idx >= simulation::fission_bank.size()) { fatal_error("Mismatch detected between sum of all particle progeny and " - "bank size during sorting."); + "shared fission bank size."); } sorted_bank[idx] = site; - if (settings::ifp_on && is_fission_bank) { - copy_ifp_data_from_fission_banks( - i, sorted_ifp_delayed_group_bank[idx], sorted_ifp_lifetime_bank[idx]); - } } // Copy sorted bank into the fission bank - std::copy(sorted_bank, sorted_bank + bank.size(), bank.data()); - if (settings::ifp_on && is_fission_bank) { - copy_ifp_data_to_fission_banks( - sorted_ifp_delayed_group_bank.data(), sorted_ifp_lifetime_bank.data()); - } -} - -// This function redistributes SourceSite particles across MPI ranks to -// achieve load balancing while preserving the global ordering of particles. -// -// GUARANTEES: -// ----------- -// 1. Global Order Preservation: After redistribution, each rank holds a -// contiguous slice of the original global ordering. For example, if the -// input across 3 ranks was: -// - Rank 0: IDs 0-4 -// - Rank 1: IDs 5-6 -// - Rank 2: IDs 7-200 -// Then after redistribution (assuming ~67 particles per rank): -// - Rank 0: IDs 0-66 (contiguous) -// - Rank 1: IDs 67-133 (contiguous) -// - Rank 2: IDs 134-200 (contiguous) -// The global ordering is always preserved - no rank will ever hold -// non-contiguous ID ranges like "0-4 and 100-200". -// -// 2. Even Load Balancing: Particles are distributed as evenly as possible. -// If total % n_procs != 0, the first 'remainder' ranks each get one extra -// particle (i.e., floor division with remainder distributed to lower -// ranks). This follows the same logic as calculate_work(). -// -// HOW IT WORKS: -// ------------- -// The algorithm uses overlap-based redistribution: -// 1. Each rank's current data occupies a range [cumulative_before[rank], -// cumulative_before[rank+1]) in the global index space. -// 2. Each rank's target data should occupy [cumulative_target[rank], -// cumulative_target[rank+1]) in the same global index space. -// 3. For each pair of (source_rank, dest_rank), we calculate the overlap -// between what source_rank currently has and what dest_rank needs. -// 4. MPI_Alltoallv transfers exactly these overlapping regions, with -// displacements ensuring data lands at the correct position in the -// receiving buffer. -// -// EDGE CASES HANDLED: -// ------------------- -// - Single rank (n_procs == 1): Returns immediately with local size, no MPI. -// - Empty total (all ranks have 0 particles): Returns 0 immediately. -// - Imbalanced input (e.g., one rank has all particles): Works correctly; -// that rank will send portions to all other ranks based on target ranges. -// - Non-divisible totals: First 'remainder' ranks get one extra particle. -int64_t synchronize_global_secondary_bank( - SharedArray& shared_secondary_bank) -{ - // Get current size of local bank - int64_t local_size = shared_secondary_bank.size(); - - if (mpi::n_procs == 1) { - return local_size; - } - -#ifdef OPENMC_MPI - // Gather all sizes to all ranks - vector all_sizes(mpi::n_procs); - MPI_Allgather(&local_size, 1, MPI_INT64_T, all_sizes.data(), 1, MPI_INT64_T, - mpi::intracomm); - - // Calculate total and check for empty case - int64_t total = 0; - for (int64_t size : all_sizes) { - total += size; - } - - // If we don't have any items to distribute, return - if (total == 0) { - return total; - } - - int64_t base_count = total / mpi::n_procs; - int64_t remainder = total % mpi::n_procs; - - // Calculate target size for each rank - // First 'remainder' ranks get base_count + 1, rest get base_count - vector target_sizes(mpi::n_procs); - for (int i = 0; i < mpi::n_procs; ++i) { - target_sizes[i] = base_count + (i < remainder ? 1 : 0); - } - - // Calculate send and receive counts in terms of SourceSite objects - // (not bytes) - vector send_counts(mpi::n_procs, 0); - vector recv_counts(mpi::n_procs, 0); - vector send_displs(mpi::n_procs, 0); - vector recv_displs(mpi::n_procs, 0); - - // Calculate cumulative positions (starting index for each rank in the - // global array) - vector cumulative_before(mpi::n_procs + 1, 0); - vector cumulative_target(mpi::n_procs + 1, 0); - for (int i = 0; i < mpi::n_procs; ++i) { - cumulative_before[i + 1] = cumulative_before[i] + all_sizes[i]; - cumulative_target[i + 1] = cumulative_target[i] + target_sizes[i]; - } - - // Determine send and receive amounts for each rank - int64_t my_start = cumulative_before[mpi::rank]; - int64_t my_end = cumulative_before[mpi::rank + 1]; - int64_t my_target_start = cumulative_target[mpi::rank]; - int64_t my_target_end = cumulative_target[mpi::rank + 1]; - - for (int r = 0; r < mpi::n_procs; ++r) { - // Send: overlap between my current range and rank r's target range - int64_t send_overlap_start = std::max(my_start, cumulative_target[r]); - int64_t send_overlap_end = std::min(my_end, cumulative_target[r + 1]); - if (send_overlap_start < send_overlap_end) { - int64_t count = send_overlap_end - send_overlap_start; - int64_t displ = send_overlap_start - my_start; - if (count > std::numeric_limits::max() || - displ > std::numeric_limits::max()) { - fatal_error("Secondary bank size exceeds MPI_Alltoallv int limit."); - } - send_counts[r] = static_cast(count); - send_displs[r] = static_cast(displ); - } - - // Recv: overlap between rank r's current range and my target range - int64_t recv_overlap_start = - std::max(cumulative_before[r], my_target_start); - int64_t recv_overlap_end = - std::min(cumulative_before[r + 1], my_target_end); - if (recv_overlap_start < recv_overlap_end) { - int64_t count = recv_overlap_end - recv_overlap_start; - int64_t displ = recv_overlap_start - my_target_start; - if (count > std::numeric_limits::max() || - displ > std::numeric_limits::max()) { - fatal_error("Secondary bank size exceeds MPI_Alltoallv int limit."); - } - recv_counts[r] = static_cast(count); - recv_displs[r] = static_cast(displ); - } - } - - // Prepare receive buffer with target size - SharedArray new_bank(target_sizes[mpi::rank]); - - // Perform all-to-all redistribution using the custom MPI type - MPI_Alltoallv(shared_secondary_bank.data(), send_counts.data(), - send_displs.data(), mpi::source_site, new_bank.data(), recv_counts.data(), - recv_displs.data(), mpi::source_site, mpi::intracomm); - - // Replace old bank with redistributed data - shared_secondary_bank = std::move(new_bank); - - return total; -#else - return local_size; -#endif + std::copy(sorted_bank, sorted_bank + simulation::fission_bank.size(), + simulation::fission_bank.data()); } //============================================================================== diff --git a/src/boundary_condition.cpp b/src/boundary_condition.cpp index d166f1247..b58054dce 100644 --- a/src/boundary_condition.cpp +++ b/src/boundary_condition.cpp @@ -38,9 +38,6 @@ void VacuumBC::handle_particle(Particle& p, const Surface& surf) const void ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const { Direction u = surf.reflect(p.r(), p.u(), &p); - - // normalize reflected u to ensure no floating point error leads to - // unnormalized directions u /= u.norm(); // Handle the effects of the surface albedo on the particle's weight. @@ -56,9 +53,6 @@ void ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const void WhiteBC::handle_particle(Particle& p, const Surface& surf) const { Direction u = surf.diffuse_reflect(p.r(), p.u(), p.current_seed()); - - // normalize outgoing u to ensure no floating point error leads to - // unnormalized directions u /= u.norm(); // Handle the effects of the surface albedo on the particle's weight. @@ -135,8 +129,24 @@ TranslationalPeriodicBC::TranslationalPeriodicBC(int i_surf, int j_surf) void TranslationalPeriodicBC::handle_particle( Particle& p, const Surface& surf) const { - auto new_r = p.r() + translation_; - int new_surface = p.surface() > 0 ? j_surf_ + 1 : -(j_surf_ + 1); + // TODO: off-by-one on surface indices throughout this function. + int i_particle_surf = std::abs(p.surface()) - 1; + + // Figure out which of the two BC surfaces were struck then find the + // particle's new location and surface. + Position new_r; + int new_surface; + if (i_particle_surf == i_surf_) { + new_r = p.r() + translation_; + new_surface = p.surface() > 0 ? j_surf_ + 1 : -(j_surf_ + 1); + } else if (i_particle_surf == j_surf_) { + new_r = p.r() - translation_; + new_surface = p.surface() > 0 ? i_surf_ + 1 : -(i_surf_ + 1); + } else { + throw std::runtime_error( + "Called BoundaryCondition::handle_particle after " + "hitting a surface, but that surface is not recognized by the BC."); + } // Handle the effects of the surface albedo on the particle's weight. BoundaryCondition::handle_albedo(p, surf); @@ -149,45 +159,63 @@ void TranslationalPeriodicBC::handle_particle( // RotationalPeriodicBC implementation //============================================================================== -RotationalPeriodicBC::RotationalPeriodicBC( - int i_surf, int j_surf, PeriodicAxis axis) - : PeriodicBC(std::abs(i_surf) - 1, std::abs(j_surf) - 1) +RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf) + : PeriodicBC(i_surf, j_surf) { Surface& surf1 {*model::surfaces[i_surf_]}; Surface& surf2 {*model::surfaces[j_surf_]}; - // below convention for right handed coordinate system - switch (axis) { - case x: - zero_axis_idx_ = 0; // x component of plane must be zero - axis_1_idx_ = 1; // y component independent - axis_2_idx_ = 2; // z component dependent - break; - case y: - zero_axis_idx_ = 1; // y component of plane must be zero - axis_1_idx_ = 2; // z component independent - axis_2_idx_ = 0; // x component dependent - break; - case z: - zero_axis_idx_ = 2; // z component of plane must be zero - axis_1_idx_ = 0; // x component independent - axis_2_idx_ = 1; // y component dependent - break; - default: - throw std::invalid_argument( - fmt::format("You've specified an axis that is not x, y, or z.")); + // Check the type of the first surface + bool surf1_is_xyplane; + if (const auto* ptr = dynamic_cast(&surf1)) { + surf1_is_xyplane = true; + } else if (const auto* ptr = dynamic_cast(&surf1)) { + surf1_is_xyplane = true; + } else if (const auto* ptr = dynamic_cast(&surf1)) { + surf1_is_xyplane = false; + } else { + throw std::invalid_argument(fmt::format( + "Surface {} is an invalid type for " + "rotational periodic BCs. Only x-planes, y-planes, or general planes " + "(that are perpendicular to z) are supported for these BCs.", + surf1.id_)); } - Direction ax = {0.0, 0.0, 0.0}; - ax[zero_axis_idx_] = 1.0; - - auto i_sign = std::copysign(1, i_surf); - auto j_sign = -std::copysign(1, j_surf); + // Check the type of the second surface + bool surf2_is_xyplane; + if (const auto* ptr = dynamic_cast(&surf2)) { + surf2_is_xyplane = true; + } else if (const auto* ptr = dynamic_cast(&surf2)) { + surf2_is_xyplane = true; + } else if (const auto* ptr = dynamic_cast(&surf2)) { + surf2_is_xyplane = false; + } else { + throw std::invalid_argument(fmt::format( + "Surface {} is an invalid type for " + "rotational periodic BCs. Only x-planes, y-planes, or general planes " + "(that are perpendicular to z) are supported for these BCs.", + surf2.id_)); + } // Compute the surface normal vectors and make sure they are perpendicular - // to the correct axis - Direction norm1 = i_sign * surf1.normal({0, 0, 0}); - Direction norm2 = j_sign * surf2.normal({0, 0, 0}); + // to the z-axis + Direction norm1 = surf1.normal({0, 0, 0}); + Direction norm2 = surf2.normal({0, 0, 0}); + if (std::abs(norm1.z) > FP_PRECISION) { + throw std::invalid_argument(fmt::format( + "Rotational periodic BCs are only " + "supported for rotations about the z-axis, but surface {} is not " + "perpendicular to the z-axis.", + surf1.id_)); + } + if (std::abs(norm2.z) > FP_PRECISION) { + throw std::invalid_argument(fmt::format( + "Rotational periodic BCs are only " + "supported for rotations about the z-axis, but surface {} is not " + "perpendicular to the z-axis.", + surf2.id_)); + } + // Make sure both surfaces intersect the origin if (std::abs(surf1.evaluate({0, 0, 0})) > FP_COINCIDENT) { throw std::invalid_argument(fmt::format( @@ -204,15 +232,15 @@ RotationalPeriodicBC::RotationalPeriodicBC( surf2.id_)); } - // Compute the signed rotation angle about the periodic axis. Note that - // (n1×n2)·a = |n1||n2|sin(θ) and n1·n2 = |n1||n2|cos(θ), where a is the axis - // of rotation. - auto c = norm1.cross(norm2); - angle_ = std::atan2(c.dot(ax), norm1.dot(norm2)); - - // If the normals point in the same general direction, the surface sense - // should change when crossing the boundary - flip_sense_ = (i_sign * j_sign > 0.0); + // Compute the BC rotation angle. Here it is assumed that both surface + // normal vectors point inwards---towards the valid geometry region. + // Consequently, the rotation angle is not the difference between the two + // normals, but is instead the difference between one normal and one + // anti-normal. (An incident ray on one surface must be an outgoing ray on + // the other surface after rotation hence the anti-normal.) + double theta1 = std::atan2(norm1.y, norm1.x); + double theta2 = std::atan2(norm2.y, norm2.x) + PI; + angle_ = theta2 - theta1; // Warn the user if the angle does not evenly divide a circle double rem = std::abs(std::remainder((2 * PI / angle_), 1.0)); @@ -227,29 +255,35 @@ RotationalPeriodicBC::RotationalPeriodicBC( void RotationalPeriodicBC::handle_particle( Particle& p, const Surface& surf) const { - int new_surface = p.surface() > 0 ? -(j_surf_ + 1) : j_surf_ + 1; - if (flip_sense_) - new_surface = -new_surface; + // TODO: off-by-one on surface indices throughout this function. + int i_particle_surf = std::abs(p.surface()) - 1; - // Rotate the particle's position and direction. + // Figure out which of the two BC surfaces were struck to figure out if a + // forward or backward rotation is required. Specify the other surface as + // the particle's new surface. + double theta; + int new_surface; + if (i_particle_surf == i_surf_) { + theta = angle_; + new_surface = p.surface() > 0 ? -(j_surf_ + 1) : j_surf_ + 1; + } else if (i_particle_surf == j_surf_) { + theta = -angle_; + new_surface = p.surface() > 0 ? -(i_surf_ + 1) : i_surf_ + 1; + } else { + throw std::runtime_error( + "Called BoundaryCondition::handle_particle after " + "hitting a surface, but that surface is not recognized by the BC."); + } + + // Rotate the particle's position and direction about the z-axis. Position r = p.r(); Direction u = p.u(); - double cos_theta = std::cos(angle_); - double sin_theta = std::sin(angle_); - - Position new_r; - new_r[zero_axis_idx_] = r[zero_axis_idx_]; - new_r[axis_1_idx_] = cos_theta * r[axis_1_idx_] - sin_theta * r[axis_2_idx_]; - new_r[axis_2_idx_] = sin_theta * r[axis_1_idx_] + cos_theta * r[axis_2_idx_]; - - Direction new_u; - new_u[zero_axis_idx_] = u[zero_axis_idx_]; - new_u[axis_1_idx_] = cos_theta * u[axis_1_idx_] - sin_theta * u[axis_2_idx_]; - new_u[axis_2_idx_] = sin_theta * u[axis_1_idx_] + cos_theta * u[axis_2_idx_]; - - // normalize new_u to ensure no floating point error leads to unnormalized - // directions - new_u /= new_u.norm(); + double cos_theta = std::cos(theta); + double sin_theta = std::sin(theta); + Position new_r = { + cos_theta * r.x - sin_theta * r.y, sin_theta * r.x + cos_theta * r.y, r.z}; + Direction new_u = { + cos_theta * u.x - sin_theta * u.y, sin_theta * u.x + cos_theta * u.y, u.z}; // Handle the effects of the surface albedo on the particle's weight. BoundaryCondition::handle_albedo(p, surf); diff --git a/src/bremsstrahlung.cpp b/src/bremsstrahlung.cpp index ec1088101..d22d6392a 100644 --- a/src/bremsstrahlung.cpp +++ b/src/bremsstrahlung.cpp @@ -6,7 +6,7 @@ #include "openmc/search.h" #include "openmc/settings.h" -#include "openmc/tensor.h" +#include "xtensor/xmath.hpp" namespace openmc { @@ -16,8 +16,8 @@ namespace openmc { namespace data { -tensor::Tensor ttb_e_grid; -tensor::Tensor ttb_k_grid; +xt::xtensor ttb_e_grid; +xt::xtensor ttb_k_grid; vector ttb; } // namespace data @@ -31,13 +31,13 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost) if (p.material() == MATERIAL_VOID) return; - int photon = ParticleType::photon().transport_index(); + int photon = static_cast(ParticleType::photon); if (p.E() < settings::energy_cutoff[photon]) return; // Get bremsstrahlung data for this material and particle type BremsstrahlungData* mat; - if (p.type() == ParticleType::positron()) { + if (p.type() == ParticleType::positron) { mat = &model::materials[p.material()]->ttb_->positron; } else { mat = &model::materials[p.material()]->ttb_->electron; @@ -112,14 +112,8 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost) std::pow(a * (c - c_l) / (std::exp(w_l) * p_l) + 1.0, 1.0 / a); if (w > settings::energy_cutoff[photon]) { - // If the energy of the secondary photon is larger than the remaining - // energy of the primary particle, adjust it to the remaining energy - if (*E_lost + w > p.E()) { - w = p.E() - *E_lost; - } - // Create secondary photon - p.create_secondary(p.wgt(), p.u(), w, ParticleType::photon()); + p.create_secondary(p.wgt(), p.u(), w, ParticleType::photon); *E_lost += w; } } diff --git a/src/cell.cpp b/src/cell.cpp index 06bc29a66..888766787 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -2,7 +2,6 @@ #include "openmc/cell.h" #include -#include #include #include #include @@ -11,6 +10,7 @@ #include #include +#include #include "openmc/capi.h" #include "openmc/constants.h" @@ -40,11 +40,6 @@ vector> cells; // Cell implementation //============================================================================== -int32_t Cell::n_instances() const -{ - return model::universes[universe_]->n_instances_; -} - void Cell::set_rotation(const vector& rot) { if (fill_ == C_NONE) { @@ -57,7 +52,7 @@ void Cell::set_rotation(const vector& rot) fatal_error(fmt::format("Non-3D rotation vector applied to cell {}", id_)); } - // Compute and store the inverse rotation matrix for the angles given. + // Compute and store the rotation matrix. rotation_.clear(); rotation_.reserve(rot.size() == 9 ? 9 : 12); if (rot.size() == 3) { @@ -101,25 +96,6 @@ double Cell::temperature(int32_t instance) const } } -double Cell::density_mult(int32_t instance) const -{ - if (instance >= 0) { - return density_mult_.size() == 1 ? density_mult_.at(0) - : density_mult_.at(instance); - } else { - return density_mult_[0]; - } -} - -double Cell::density(int32_t instance) const -{ - const int32_t mat_index = material(instance); - if (mat_index == MATERIAL_VOID) - return 0.0; - - return density_mult(instance) * model::materials[mat_index]->density_gpcc(); -} - void Cell::set_temperature(double T, int32_t instance, bool set_contained) { if (settings::temperature_method == TemperatureMethod::INTERPOLATION) { @@ -139,8 +115,8 @@ void Cell::set_temperature(double T, int32_t instance, bool set_contained) if (type_ == Fill::MATERIAL) { if (instance >= 0) { // If temperature vector is not big enough, resize it first - if (sqrtkT_.size() != n_instances()) - sqrtkT_.resize(n_instances(), sqrtkT_[0]); + if (sqrtkT_.size() != n_instances_) + sqrtkT_.resize(n_instances_, sqrtkT_[0]); // Set temperature for the corresponding instance sqrtkT_.at(instance) = std::sqrt(K_BOLTZMANN * T); @@ -161,7 +137,7 @@ void Cell::set_temperature(double T, int32_t instance, bool set_contained) auto contained_cells = this->get_contained_cells(instance); for (const auto& entry : contained_cells) { auto& cell = model::cells[entry.first]; - assert(cell->type_ == Fill::MATERIAL); + Expects(cell->type_ == Fill::MATERIAL); auto& instances = entry.second; for (auto instance : instances) { cell->set_temperature(T, instance); @@ -170,47 +146,6 @@ void Cell::set_temperature(double T, int32_t instance, bool set_contained) } } -void Cell::set_density(double density, int32_t instance, bool set_contained) -{ - if (type_ != Fill::MATERIAL && !set_contained) { - fatal_error( - fmt::format("Attempted to set the density multiplier of cell {} " - "which is not filled by a material.", - id_)); - } - - if (type_ == Fill::MATERIAL) { - const int32_t mat_index = material(instance); - if (mat_index == MATERIAL_VOID) - return; - - if (instance >= 0) { - // If density multiplier vector is not big enough, resize it first - if (density_mult_.size() != n_instances()) - density_mult_.resize(n_instances(), density_mult_[0]); - - // Set density multiplier for the corresponding instance - density_mult_.at(instance) = - density / model::materials[mat_index]->density_gpcc(); - } else { - // Set density multiplier for all instances - for (auto& x : density_mult_) { - x = density / model::materials[mat_index]->density_gpcc(); - } - } - } else { - auto contained_cells = this->get_contained_cells(instance); - for (const auto& entry : contained_cells) { - auto& cell = model::cells[entry.first]; - assert(cell->type_ == Fill::MATERIAL); - auto& instances = entry.second; - for (auto instance : instances) { - cell->set_density(density, instance); - } - } - } -} - void Cell::export_properties_hdf5(hid_t group) const { // Create a group for this cell. @@ -222,15 +157,6 @@ void Cell::export_properties_hdf5(hid_t group) const temps.push_back(sqrtkT_val * sqrtkT_val / K_BOLTZMANN); write_dataset(cell_group, "temperature", temps); - // Write density for one or more cell instances - if (type_ == Fill::MATERIAL && material_.size() > 0) { - vector density; - for (int32_t i = 0; i < density_mult_.size(); ++i) - density.push_back(this->density(i)); - - write_dataset(cell_group, "density", density); - } - close_group(cell_group); } @@ -244,8 +170,8 @@ void Cell::import_properties_hdf5(hid_t group) // Ensure number of temperatures makes sense auto n_temps = temps.size(); - if (n_temps > 1 && n_temps != n_instances()) { - fatal_error(fmt::format( + if (n_temps > 1 && n_temps != n_instances_) { + throw std::runtime_error(fmt::format( "Number of temperatures for cell {} doesn't match number of instances", id_)); } @@ -253,29 +179,10 @@ void Cell::import_properties_hdf5(hid_t group) // Modify temperatures for the cell sqrtkT_.clear(); sqrtkT_.resize(temps.size()); - for (int64_t i = 0; i < temps.size(); ++i) { + for (gsl::index i = 0; i < temps.size(); ++i) { this->set_temperature(temps[i], i); } - // Read densities - if (object_exists(cell_group, "density")) { - vector density; - read_dataset(cell_group, "density", density); - - // Ensure number of densities makes sense - auto n_density = density.size(); - if (n_density > 1 && n_density != n_instances()) { - fatal_error(fmt::format("Number of densities for cell {} " - "doesn't match number of instances", - id_)); - } - - // Set densities. - for (int32_t i = 0; i < n_density; ++i) { - this->set_density(density[i], i); - } - } - close_group(cell_group); } @@ -315,8 +222,6 @@ void Cell::to_hdf5(hid_t cell_group) const temps.push_back(sqrtkT_val * sqrtkT_val / K_BOLTZMANN); write_dataset(group, "temperature", temps); - write_dataset(group, "density_mult", density_mult_); - } else if (type_ == Fill::UNIVERSE) { write_dataset(group, "fill_type", "universe"); write_dataset(group, "fill", model::universes[fill_]->id_); @@ -340,69 +245,20 @@ void Cell::to_hdf5(hid_t cell_group) const close_group(group); } -//============================================================================== -// XML parsing helpers for nodes -//============================================================================== - -vector parse_cell_material_xml(pugi::xml_node node, int32_t cell_id) -{ - vector mats { - get_node_array(node, "material", true)}; - if (mats.empty()) { - fatal_error(fmt::format( - "An empty material element was specified for cell {}", cell_id)); - } - vector material; - material.reserve(mats.size()); - for (const auto& mat : mats) { - if (mat == "void") { - material.push_back(MATERIAL_VOID); - } else { - material.push_back(std::stoi(mat)); - } - } - return material; -} - -vector parse_cell_temperature_xml(pugi::xml_node node, int32_t cell_id) -{ - auto temperatures = get_node_array(node, "temperature"); - if (temperatures.empty()) { - fatal_error(fmt::format( - "An empty temperature element was specified for cell {}", cell_id)); - } - for (auto T : temperatures) { - if (T < 0) { - fatal_error(fmt::format( - "Cell {} was specified with a negative temperature", cell_id)); - } - } - return temperatures; -} - -vector parse_cell_density_xml(pugi::xml_node node, int32_t cell_id) -{ - auto densities = get_node_array(node, "density"); - if (densities.empty()) { - fatal_error(fmt::format( - "An empty density element was specified for cell {}", cell_id)); - } - for (auto rho : densities) { - if (rho <= 0) { - fatal_error(fmt::format( - "Cell {} was specified with a density less than or equal to zero", - cell_id)); - } - } - return densities; -} - //============================================================================== // CSGCell implementation //============================================================================== +// default constructor +CSGCell::CSGCell() +{ + geom_type_ = GeometryType::CSG; +} + CSGCell::CSGCell(pugi::xml_node cell_node) { + geom_type_ = GeometryType::CSG; + if (check_for_node(cell_node, "id")) { id_ = std::stoi(get_node_value(cell_node, "id")); } else { @@ -447,12 +303,26 @@ CSGCell::CSGCell(pugi::xml_node cell_node) // universe), more than one material (distribmats), and some materials may // be "void". if (material_present) { - material_ = parse_cell_material_xml(cell_node, id_); + vector mats { + get_node_array(cell_node, "material", true)}; + if (mats.size() > 0) { + material_.reserve(mats.size()); + for (std::string mat : mats) { + if (mat.compare("void") == 0) { + material_.push_back(MATERIAL_VOID); + } else { + material_.push_back(std::stoi(mat)); + } + } + } else { + fatal_error(fmt::format( + "An empty material element was specified for cell {}", id_)); + } } // Read the temperature element which may be distributed like materials. if (check_for_node(cell_node, "temperature")) { - sqrtkT_ = parse_cell_temperature_xml(cell_node, id_); + sqrtkT_ = get_node_array(cell_node, "temperature"); sqrtkT_.shrink_to_fit(); // Make sure this is a material-filled cell. @@ -463,41 +333,20 @@ CSGCell::CSGCell(pugi::xml_node cell_node) id_)); } + // Make sure all temperatures are non-negative. + for (auto T : sqrtkT_) { + if (T < 0) { + fatal_error(fmt::format( + "Cell {} was specified with a negative temperature", id_)); + } + } + // Convert to sqrt(k*T). for (auto& T : sqrtkT_) { T = std::sqrt(K_BOLTZMANN * T); } } - // Read the density element which can be distributed similar to temperature. - // These get assigned to the density multiplier, requiring a division by - // the material density. - // Note: calculating the actual density multiplier is deferred until materials - // are finalized. density_mult_ contains the true density in the meantime. - if (check_for_node(cell_node, "density")) { - density_mult_ = parse_cell_density_xml(cell_node, id_); - density_mult_.shrink_to_fit(); - - // Make sure this is a material-filled cell. - if (material_.size() == 0) { - fatal_error(fmt::format( - "Cell {} was specified with a density but no material. Density" - "specification is only valid for cells filled with a material.", - id_)); - } - - // Make sure this is a non-void material. - for (auto mat_id : material_) { - if (mat_id == MATERIAL_VOID) { - fatal_error(fmt::format( - "Cell {} was specified with a density, but contains a void " - "material. Density specification is only valid for cells " - "filled with a non-void material.", - id_)); - } - } - } - // Read the region specification. std::string region_spec; if (check_for_node(cell_node, "region")) { @@ -686,7 +535,7 @@ Region::Region(std::string region_spec, int32_t cell_id) if (token == OP_UNION) { simple_ = false; // Ensure intersections have precedence over unions - enforce_precedence(); + add_precedence(); break; } } @@ -729,7 +578,7 @@ void Region::apply_demorgan( //! precedence than unions using parentheses. //============================================================================== -void Region::add_parentheses(int64_t start) +gsl::index Region::add_parentheses(gsl::index start) { int32_t start_token = expression_[start]; // Add left parenthesis and set new position to be after parenthesis @@ -738,6 +587,14 @@ void Region::add_parentheses(int64_t start) } expression_.insert(expression_.begin() + start - 1, OP_LEFT_PAREN); + // Keep track of return iterator distance. If we don't encounter a left + // parenthesis, we return an iterator corresponding to wherever the right + // parenthesis is inserted. If a left parenthesis is encountered, an iterator + // corresponding to the left parenthesis is returned. Also note that we keep + // track of a *distance* instead of an iterator because the underlying memory + // allocation may change. + std::size_t return_it_dist = 0; + // Add right parenthesis // While the start iterator is within the bounds of infix while (start + 1 < expression_.size()) { @@ -751,6 +608,7 @@ void Region::add_parentheses(int64_t start) // in the region, when the operator is an intersection then include the // operator and next surface if (expression_[start] == OP_LEFT_PAREN) { + return_it_dist = start; int depth = 1; do { start++; @@ -767,73 +625,54 @@ void Region::add_parentheses(int64_t start) --start; } expression_.insert(expression_.begin() + start, OP_RIGHT_PAREN); - return; + if (return_it_dist > 0) { + return return_it_dist; + } else { + return start - 1; + } } } } - // If we get here a right parenthesis hasn't been placed + // If we get here a right parenthesis hasn't been placed, + // return iterator expression_.push_back(OP_RIGHT_PAREN); + if (return_it_dist > 0) { + return return_it_dist; + } else { + return start - 1; + } } -//============================================================================== -//! Add parentheses to enforce operator precedence in region expressions -//! -//! This function ensures that intersection operators have higher precedence -//! than union operators by adding parentheses where needed. For example: -//! "1 2 | 3" becomes "(1 2) | 3" -//! "1 | 2 3" becomes "1 | (2 3)" -//! -//! The algorithm uses stacks to track the current operator type and its -//! position at each parenthesis depth level. When it encounters a different -//! operator at the same depth, it adds parentheses to group the -//! higher-precedence operations. //============================================================================== -void Region::enforce_precedence() +void Region::add_precedence() { - // Stack tracking the operator type at each depth (0 = no operator seen yet) - vector op_stack = {0}; + int32_t current_op = 0; + std::size_t current_dist = 0; - // Stack tracking where the operator sequence started at each depth - vector pos_stack = {0}; - - for (int64_t i = 0; i < expression_.size(); ++i) { + for (gsl::index i = 0; i < expression_.size(); i++) { int32_t token = expression_[i]; - if (token == OP_LEFT_PAREN) { - // Entering a new parenthesis level - push new tracking state - op_stack.push_back(0); - pos_stack.push_back(0); - continue; - } else if (token == OP_RIGHT_PAREN) { - // Exiting a parenthesis level - pop tracking state (keep at least one) - if (op_stack.size() > 1) { - op_stack.pop_back(); - pos_stack.pop_back(); - } - continue; - } - if (token == OP_UNION || token == OP_INTERSECTION) { - if (op_stack.back() == 0) { - // First operator at this depth - record it and its position - op_stack.back() = token; - pos_stack.back() = i; - } else if (token != op_stack.back()) { - // Encountered a different operator at the same depth - need to add - // parentheses to enforce precedence. Intersection has higher - // precedence, so we parenthesize the intersection terms. - if (op_stack.back() == OP_INTERSECTION) { - add_parentheses(pos_stack.back()); + if (current_op == 0) { + // Set the current operator if is hasn't been set + current_op = token; + current_dist = i; + } else if (token != current_op) { + // If the current operator doesn't match the token, add parenthesis to + // assert precedence + if (current_op == OP_INTERSECTION) { + i = add_parentheses(current_dist); } else { - add_parentheses(i); + i = add_parentheses(i); } - - // Restart the scan since we modified the expression - i = -1; // Will be incremented to 0 by the for loop - op_stack = {0}; - pos_stack = {0}; + current_op = 0; + current_dist = 0; } + } else if (token > OP_COMPLEMENT) { + // If the token is a parenthesis reset the current operator + current_op = 0; + current_dist = 0; } } } @@ -1107,7 +946,7 @@ BoundingBox Region::bounding_box_complex(vector postfix) const } } - assert(i_stack == 0); + Ensures(i_stack == 0); return stack.front(); } @@ -1194,7 +1033,7 @@ void populate_universes() model::universes.back()->cells_.push_back(index_cell); model::universe_map[uid] = model::universes.size() - 1; } else { -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC // Skip implicit complement cells for now Universe* univ = model::universes[it->second].get(); DAGUniverse* dag_univ = dynamic_cast(univ); @@ -1293,24 +1132,6 @@ extern "C" int openmc_cell_set_temperature( return 0; } -extern "C" int openmc_cell_set_density( - int32_t index, double density, const int32_t* instance, bool set_contained) -{ - if (index < 0 || index >= model::cells.size()) { - strcpy(openmc_err_msg, "Index in cells array is out of bounds."); - return OPENMC_E_OUT_OF_BOUNDS; - } - - int32_t instance_index = instance ? *instance : -1; - try { - model::cells[index]->set_density(density, instance_index, set_contained); - } catch (const std::exception& e) { - set_errmsg(e.what()); - return OPENMC_E_UNASSIGNED; - } - return 0; -} - extern "C" int openmc_cell_get_temperature( int32_t index, const int32_t* instance, double* T) { @@ -1329,36 +1150,6 @@ extern "C" int openmc_cell_get_temperature( return 0; } -extern "C" int openmc_cell_get_density( - int32_t index, const int32_t* instance, double* density) -{ - if (index < 0 || index >= model::cells.size()) { - strcpy(openmc_err_msg, "Index in cells array is out of bounds."); - return OPENMC_E_OUT_OF_BOUNDS; - } - - int32_t instance_index = instance ? *instance : -1; - try { - if (model::cells[index]->type_ != Fill::MATERIAL) { - fatal_error( - fmt::format("Cell {}, instance {} is not filled with a material.", - model::cells[index]->id_, instance_index)); - } - - int32_t mat_index = model::cells[index]->material(instance_index); - if (mat_index == MATERIAL_VOID) { - *density = 0.0; - } else { - *density = model::cells[index]->density_mult(instance_index) * - model::materials[mat_index]->density_gpcc(); - } - } catch (const std::exception& e) { - set_errmsg(e.what()); - return OPENMC_E_UNASSIGNED; - } - return 0; -} - //! Get the bounding box of a cell extern "C" int openmc_cell_bounding_box( const int32_t index, double* llc, double* urc) @@ -1370,14 +1161,14 @@ extern "C" int openmc_cell_bounding_box( bbox = c->bounding_box(); // set lower left corner values - llc[0] = bbox.min.x; - llc[1] = bbox.min.y; - llc[2] = bbox.min.z; + llc[0] = bbox.xmin; + llc[1] = bbox.ymin; + llc[2] = bbox.zmin; // set upper right corner values - urc[0] = bbox.max.x; - urc[1] = bbox.max.y; - urc[2] = bbox.max.z; + urc[0] = bbox.xmax; + urc[1] = bbox.ymax; + urc[2] = bbox.zmax; return 0; } @@ -1427,8 +1218,8 @@ struct ParentCell { lattice_index < other.lattice_index); } - int64_t cell_index; - int64_t lattice_index; + gsl::index cell_index; + gsl::index lattice_index; }; //! Structure used to insert ParentCell into hashed STL data structures @@ -1531,10 +1322,10 @@ vector Cell::find_parent_cells( bool cell_found = false; for (auto it = coords.begin(); it != coords.end(); it++) { const auto& coord = *it; - const auto& cell = model::cells[coord.cell()]; + const auto& cell = model::cells[coord.cell]; // if the cell at this level matches the current cell, stop adding to the // stack - if (coord.cell() == model::cell_map[this->id_]) { + if (coord.cell == model::cell_map[this->id_]) { cell_found = true; break; } @@ -1544,10 +1335,10 @@ vector Cell::find_parent_cells( int lattice_idx = C_NONE; if (cell->type_ == Fill::LATTICE) { const auto& next_coord = *(it + 1); - lattice_idx = model::lattices[next_coord.lattice()]->get_flat_index( - next_coord.lattice_index()); + lattice_idx = model::lattices[next_coord.lattice]->get_flat_index( + next_coord.lattice_i); } - stack.push(coord.universe(), {coord.cell(), lattice_idx}); + stack.push(coord.universe, {coord.cell, lattice_idx}); } // if this loop finished because the cell was found and @@ -1835,7 +1626,7 @@ extern "C" int openmc_cell_get_num_instances( set_errmsg("Index in cells array is out of bounds."); return OPENMC_E_OUT_OF_BOUNDS; } - *num_instances = model::cells[index]->n_instances(); + *num_instances = model::cells[index]->n_instances_; return 0; } diff --git a/src/chain.cpp b/src/chain.cpp deleted file mode 100644 index 3915c016c..000000000 --- a/src/chain.cpp +++ /dev/null @@ -1,131 +0,0 @@ -//! \file chain.cpp -//! \brief Depletion chain and associated information - -#include "openmc/chain.h" - -#include // for getenv -#include // for make_unique -#include // for stod - -#include -#include - -#include "openmc/distribution.h" // for distribution_from_xml -#include "openmc/error.h" -#include "openmc/reaction.h" -#include "openmc/xml_interface.h" // for get_node_value - -namespace openmc { - -//============================================================================== -// ChainNuclide implementation -//============================================================================== - -ChainNuclide::ChainNuclide(pugi::xml_node node) -{ - name_ = get_node_value(node, "name"); - if (check_for_node(node, "half_life")) { - half_life_ = std::stod(get_node_value(node, "half_life")); - } - if (check_for_node(node, "decay_energy")) { - decay_energy_ = std::stod(get_node_value(node, "decay_energy")); - } - - // Read reactions to store MT -> product map - for (pugi::xml_node reaction_node : node.children("reaction")) { - std::string rx_name = get_node_value(reaction_node, "type"); - if (!reaction_node.attribute("target")) - continue; - std::string rx_target = get_node_value(reaction_node, "target"); - double branching_ratio = 1.0; - if (reaction_node.attribute("branching_ratio")) { - branching_ratio = - std::stod(get_node_value(reaction_node, "branching_ratio")); - } - int mt = reaction_mt(rx_name); - reaction_products_[mt].push_back({rx_target, branching_ratio}); - } - - for (pugi::xml_node source_node : node.children("source")) { - auto particle = get_node_value(source_node, "particle"); - if (particle == "photon") { - photon_energy_ = distribution_from_xml(source_node); - break; - } - } - - // Set entry in mapping - data::chain_nuclide_map[name_] = data::chain_nuclides.size(); -} - -ChainNuclide::~ChainNuclide() -{ - data::chain_nuclide_map.erase(name_); -} - -//============================================================================== -// DecayPhotonAngleEnergy implementation -//============================================================================== - -void DecayPhotonAngleEnergy::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - E_out = photon_energy_->sample(seed).first; - mu = Uniform(-1., 1.).sample(seed).first; -} - -double DecayPhotonAngleEnergy::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - E_out = photon_energy_->sample(seed).first; - return 0.5; -} - -//============================================================================== -// Global variables -//============================================================================== - -namespace data { - -std::unordered_map chain_nuclide_map; -vector> chain_nuclides; - -} // namespace data - -//============================================================================== -// Non-member functions -//============================================================================== - -void read_chain_file_xml() -{ - free_memory_chain(); - - char* chain_file_path = std::getenv("OPENMC_CHAIN_FILE"); - if (!chain_file_path) { - return; - } - - write_message(5, "Reading chain file: {}...", chain_file_path); - - pugi::xml_document doc; - auto result = doc.load_file(chain_file_path); - if (!result) { - fatal_error( - fmt::format("Error processing chain file: {}", chain_file_path)); - } - - // Get root element - pugi::xml_node root = doc.document_element(); - - for (auto node : root.children("nuclide")) { - data::chain_nuclides.push_back(std::make_unique(node)); - } -} - -void free_memory_chain() -{ - data::chain_nuclides.clear(); - data::chain_nuclide_map.clear(); -} - -} // namespace openmc diff --git a/src/cmfd_solver.cpp b/src/cmfd_solver.cpp index 714a5bf3a..943042f67 100644 --- a/src/cmfd_solver.cpp +++ b/src/cmfd_solver.cpp @@ -5,7 +5,7 @@ #ifdef _OPENMP #include #endif -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include "openmc/bank.h" #include "openmc/capi.h" @@ -36,7 +36,7 @@ double spectral; int nx, ny, nz, ng; -tensor::Tensor indexmap; +xt::xtensor indexmap; int use_all_threads; @@ -79,14 +79,15 @@ int get_cmfd_energy_bin(const double E) // COUNT_BANK_SITES bins fission sites according to CMFD mesh and energy //============================================================================== -tensor::Tensor count_bank_sites( - tensor::Tensor& bins, bool* outside) +xt::xtensor count_bank_sites( + xt::xtensor& bins, bool* outside) { // Determine shape of array for counts std::size_t cnt_size = cmfd::nx * cmfd::ny * cmfd::nz * cmfd::ng; + vector cnt_shape = {cnt_size}; // Create array of zeros - tensor::Tensor cnt = tensor::zeros({cnt_size}); + xt::xarray cnt {cnt_shape, 0.0}; bool outside_ = false; auto bank_size = simulation::source_bank.size(); @@ -112,22 +113,29 @@ tensor::Tensor count_bank_sites( bins[i] = mesh_bin * cmfd::ng + energy_bin; } + // Create copy of count data. Since ownership will be acquired by xtensor, + // std::allocator must be used to avoid Valgrind mismatched free() / delete + // warnings. int total = cnt.size(); - tensor::Tensor counts = tensor::zeros({cnt_size}); + double* cnt_reduced = std::allocator {}.allocate(total); #ifdef OPENMC_MPI // collect values from all processors MPI_Reduce( - cnt.data(), counts.data(), total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); + cnt.data(), cnt_reduced, total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); // Check if there were sites outside the mesh for any processor MPI_Reduce(&outside_, outside, 1, MPI_C_BOOL, MPI_LOR, 0, mpi::intracomm); #else - std::copy(cnt.data(), cnt.data() + total, counts.data()); + std::copy(cnt.data(), cnt.data() + total, cnt_reduced); *outside = outside_; #endif + // Adapt reduced values in array back into an xarray + auto arr = xt::adapt(cnt_reduced, total, xt::acquire_ownership(), cnt_shape); + xt::xarray counts = arr; + return counts; } @@ -143,19 +151,19 @@ extern "C" void openmc_cmfd_reweight( std::size_t src_size = cmfd::nx * cmfd::ny * cmfd::nz * cmfd::ng; // count bank sites for CMFD mesh, store bins in bank_bins for reweighting - tensor::Tensor bank_bins = tensor::zeros({bank_size}); + xt::xtensor bank_bins({bank_size}, 0); bool sites_outside; - tensor::Tensor sourcecounts = + xt::xtensor sourcecounts = count_bank_sites(bank_bins, &sites_outside); // Compute CMFD weightfactors - tensor::Tensor weightfactors = tensor::ones({src_size}); + xt::xtensor weightfactors = xt::xtensor({src_size}, 1.); if (mpi::master) { if (sites_outside) { fatal_error("Source sites outside of the CMFD mesh"); } - double norm = sourcecounts.sum() / cmfd::norm; + double norm = xt::sum(sourcecounts)() / cmfd::norm; for (int i = 0; i < src_size; i++) { if (sourcecounts[i] > 0 && cmfd_src[i] > 0) { weightfactors[i] = cmfd_src[i] * norm / sourcecounts[i]; @@ -553,7 +561,7 @@ void free_memory_cmfd() cmfd::indices.clear(); cmfd::egrid.clear(); - // Resize tensors to be empty + // Resize xtensors to be empty cmfd::indexmap.resize({0}); // Set pointers to null diff --git a/src/collision_track.cpp b/src/collision_track.cpp deleted file mode 100644 index 2e749007f..000000000 --- a/src/collision_track.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include "openmc/collision_track.h" - -#include -#include - -#include - -#include "openmc/bank.h" -#include "openmc/bank_io.h" -#include "openmc/cell.h" -#include "openmc/constants.h" -#include "openmc/error.h" -#include "openmc/file_utils.h" -#include "openmc/hdf5_interface.h" -#include "openmc/material.h" -#include "openmc/mcpl_interface.h" -#include "openmc/message_passing.h" -#include "openmc/nuclide.h" -#include "openmc/output.h" -#include "openmc/particle.h" -#include "openmc/settings.h" -#include "openmc/simulation.h" -#include "openmc/universe.h" - -#ifdef OPENMC_MPI -#include -#endif - -namespace openmc { - -namespace { - -hid_t h5_collision_track_banktype() -{ - hid_t postype = H5Tcreate(H5T_COMPOUND, sizeof(Position)); - H5Tinsert(postype, "x", HOFFSET(Position, x), H5T_NATIVE_DOUBLE); - H5Tinsert(postype, "y", HOFFSET(Position, y), H5T_NATIVE_DOUBLE); - H5Tinsert(postype, "z", HOFFSET(Position, z), H5T_NATIVE_DOUBLE); - - hid_t banktype = H5Tcreate(H5T_COMPOUND, sizeof(CollisionTrackSite)); - - H5Tinsert(banktype, "r", HOFFSET(CollisionTrackSite, r), postype); - H5Tinsert(banktype, "u", HOFFSET(CollisionTrackSite, u), postype); - H5Tinsert(banktype, "E", HOFFSET(CollisionTrackSite, E), H5T_NATIVE_DOUBLE); - H5Tinsert(banktype, "dE", HOFFSET(CollisionTrackSite, dE), H5T_NATIVE_DOUBLE); - H5Tinsert( - banktype, "time", HOFFSET(CollisionTrackSite, time), H5T_NATIVE_DOUBLE); - H5Tinsert( - banktype, "wgt", HOFFSET(CollisionTrackSite, wgt), H5T_NATIVE_DOUBLE); - H5Tinsert(banktype, "event_mt", HOFFSET(CollisionTrackSite, event_mt), - H5T_NATIVE_INT); - H5Tinsert(banktype, "delayed_group", - HOFFSET(CollisionTrackSite, delayed_group), H5T_NATIVE_INT); - H5Tinsert( - banktype, "cell_id", HOFFSET(CollisionTrackSite, cell_id), H5T_NATIVE_INT); - H5Tinsert(banktype, "nuclide_id", HOFFSET(CollisionTrackSite, nuclide_id), - H5T_NATIVE_INT); - H5Tinsert(banktype, "material_id", HOFFSET(CollisionTrackSite, material_id), - H5T_NATIVE_INT); - H5Tinsert(banktype, "universe_id", HOFFSET(CollisionTrackSite, universe_id), - H5T_NATIVE_INT); - H5Tinsert(banktype, "n_collision", HOFFSET(CollisionTrackSite, n_collision), - H5T_NATIVE_INT); - H5Tinsert(banktype, "particle", HOFFSET(CollisionTrackSite, particle), - H5T_NATIVE_INT); - H5Tinsert(banktype, "parent_id", HOFFSET(CollisionTrackSite, parent_id), - H5T_NATIVE_INT64); - H5Tinsert(banktype, "progeny_id", HOFFSET(CollisionTrackSite, progeny_id), - H5T_NATIVE_INT64); - H5Tclose(postype); - return banktype; -} - -void write_collision_track_bank(hid_t group_id, - openmc::span collision_track_bank, - const openmc::vector& bank_index) -{ - hid_t banktype = h5_collision_track_banktype(); -#ifdef OPENMC_MPI - write_bank_dataset("collision_track_bank", group_id, collision_track_bank, - bank_index, banktype, banktype, mpi::collision_track_site); -#else - write_bank_dataset("collision_track_bank", group_id, collision_track_bank, - bank_index, banktype, banktype); -#endif - - H5Tclose(banktype); -} - -void write_h5_collision_track(const char* filename, - openmc::span collision_track_bank, - const openmc::vector& bank_index) -{ -#ifdef PHDF5 - bool parallel = true; -#else - bool parallel = false; -#endif - - if (!filename) - fatal_error("write_h5_collision_track filename needs a nonempty name."); - - std::string filename_(filename); - const auto extension = get_file_extension(filename_); - if (extension.empty()) { - filename_.append(".h5"); - } else if (extension != "h5") { - warning("write_h5_collision_track was passed a file extension differing " - "from .h5, but an hdf5 file will be written."); - } - - hid_t file_id; - if (mpi::master || parallel) { - file_id = file_open(filename_.c_str(), 'w', true); - - // Write filetype and version info - write_attribute(file_id, "filetype", "collision_track"); - write_attribute(file_id, "version", VERSION_COLLISION_TRACK); - } - - write_collision_track_bank(file_id, collision_track_bank, bank_index); - - if (mpi::master || parallel) - file_close(file_id); -} - -} // namespace - -bool should_record_event(int id_cell, int mt_event, const std::string& nuclide, - int id_universe, int id_material, double energy_loss) -{ - auto matches_filter = [](const auto& filter_set, const auto& value) { - return filter_set.empty() || filter_set.count(value) > 0; - }; - - const auto& cfg = settings::collision_track_config; - return simulation::current_batch > settings::n_inactive && - !simulation::collision_track_bank.full() && - matches_filter(cfg.cell_ids, id_cell) && - matches_filter(cfg.mt_numbers, mt_event) && - matches_filter(cfg.universe_ids, id_universe) && - matches_filter(cfg.material_ids, id_material) && - matches_filter(cfg.nuclides, nuclide) && - (cfg.deposited_energy_threshold == 0 || - cfg.deposited_energy_threshold < energy_loss); -} - -void collision_track_reserve_bank() -{ - simulation::collision_track_bank.reserve( - settings::collision_track_config.max_collisions); -} - -void collision_track_flush_bank() -{ - const auto& cfg = settings::collision_track_config; - if (simulation::ct_current_file > cfg.max_files) - return; - - bool last_batch = (simulation::current_batch == settings::n_batches); - if (!simulation::collision_track_bank.full() && !last_batch) - return; - - auto size = simulation::collision_track_bank.size(); - if (size == 0 && !last_batch) - return; - - auto collision_track_work_index = mpi::calculate_parallel_index_vector(size); - openmc::span collisiontrackbankspan( - simulation::collision_track_bank.begin(), size); - - std::string ext = cfg.mcpl_write ? "mcpl" : "h5"; - auto filename = fmt::format("{}collision_track.{}.{}", settings::path_output, - simulation::ct_current_file, ext); - - if (cfg.max_files == 1 || (simulation::ct_current_file == 1 && last_batch)) { - filename = settings::path_output + "collision_track." + ext; - } - write_message("Creating {}...", filename, 4); - - if (cfg.mcpl_write) { - write_mcpl_collision_track( - filename.c_str(), collisiontrackbankspan, collision_track_work_index); - } else { - write_h5_collision_track( - filename.c_str(), collisiontrackbankspan, collision_track_work_index); - } - - simulation::collision_track_bank.clear(); - if (!last_batch && cfg.max_files >= 1) { - collision_track_reserve_bank(); - } - ++simulation::ct_current_file; -} - -void collision_track_record(Particle& particle) -{ - int cell_index = particle.lowest_coord().cell(); - if (cell_index == C_NONE) - return; - - int cell_id = model::cells[cell_index]->id_; - std::string nuclide {}; - int nuclide_id = 0; - if (particle.event_nuclide() != NUCLIDE_NONE) { - const auto* nuclide_ptr = data::nuclides[particle.event_nuclide()].get(); - nuclide = nuclide_ptr->name_; - nuclide_id = nuclide_ptr->particle_type().pdg_number(); - } - int universe_id = model::universes[particle.lowest_coord().universe()]->id_; - double delta_E = particle.E_last() - particle.E(); - int material_index = particle.material(); - if (material_index == C_NONE) - return; - - int material_id = model::materials[material_index]->id_; - - if (!should_record_event(cell_id, particle.event_mt(), nuclide, universe_id, - material_id, delta_E)) - return; - - CollisionTrackSite site; - site.r = particle.r(); - site.u = particle.u(); - site.E = particle.E_last(); - site.dE = delta_E; - site.time = particle.time(); - site.wgt = particle.wgt(); - site.event_mt = particle.event_mt(); - site.delayed_group = particle.delayed_group(); - site.cell_id = cell_id; - site.nuclide_id = nuclide_id; - site.material_id = material_id; - site.universe_id = universe_id; - site.n_collision = particle.n_collision(); - site.particle = particle.type(); - site.parent_id = particle.id(); - site.progeny_id = particle.n_progeny(); - simulation::collision_track_bank.thread_safe_append(site); -} - -} // namespace openmc diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index ec9da5b8a..a7bd86095 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -23,7 +23,6 @@ #include "pugixml.hpp" #include // for getenv -#include #include namespace openmc { @@ -254,7 +253,7 @@ void read_ce_cross_sections(const vector>& nuc_temps, if (settings::photon_transport && settings::electron_treatment == ElectronTreatment::TTB) { // Take logarithm of energies since they are log-log interpolated - data::ttb_e_grid = tensor::log(data::ttb_e_grid); + data::ttb_e_grid = xt::log(data::ttb_e_grid); } // Show minimum/maximum temperature @@ -283,15 +282,10 @@ void read_ce_cross_sections(const vector>& nuc_temps, void read_ce_cross_sections_xml() { // Check if cross_sections.xml exists - std::filesystem::path filename(settings::path_cross_sections); - if (!std::filesystem::exists(filename)) { - fatal_error( - "Cross sections XML file '" + filename.string() + "' does not exist."); - } - - if (std::filesystem::is_directory(filename)) { - fatal_error("OPENMC_CROSS_SECTIONS is set to a directory. " - "It should be set to an XML file."); + const auto& filename = settings::path_cross_sections; + if (!file_exists(filename)) { + // Could not find cross_sections.xml file + fatal_error("Cross sections XML file '" + filename + "' does not exist."); } write_message("Reading cross sections XML file...", 5); @@ -311,10 +305,15 @@ void read_ce_cross_sections_xml() } else { // If no directory is listed in cross_sections.xml, by default select the // directory in which the cross_sections.xml file resides - if (filename.has_parent_path()) { - directory = filename.parent_path().string(); - } else { + + // TODO: Use std::filesystem functionality when C++17 is adopted + auto pos = filename.rfind("/"); + if (pos == std::string::npos) { + // No '\\' found, so the file must be in the same directory as + // materials.xml directory = settings::path_input; + } else { + directory = filename.substr(0, pos); } } diff --git a/src/dagmc.cpp b/src/dagmc.cpp index a5cc71b52..a29a2589f 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -1,7 +1,5 @@ #include "openmc/dagmc.h" -#include - #include "openmc/constants.h" #include "openmc/container_util.h" #include "openmc/error.h" @@ -13,26 +11,25 @@ #include "openmc/settings.h" #include "openmc/string_utils.h" -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW #include "uwuw.hpp" #endif #include #include -#include #include #include #include namespace openmc { -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC const bool DAGMC_ENABLED = true; #else const bool DAGMC_ENABLED = false; #endif -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW const bool UWUW_ENABLED = true; #else const bool UWUW_ENABLED = false; @@ -40,7 +37,7 @@ const bool UWUW_ENABLED = false; } // namespace openmc -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC namespace openmc { @@ -50,10 +47,6 @@ namespace openmc { DAGUniverse::DAGUniverse(pugi::xml_node node) { - MaterialOverrides material_overrides; - TemperatureOverrides temperature_overrides; - DensityOverrides density_overrides; - if (check_for_node(node, "id")) { id_ = std::stoi(get_node_value(node, "id")); } else { @@ -63,8 +56,7 @@ DAGUniverse::DAGUniverse(pugi::xml_node node) if (check_for_node(node, "filename")) { filename_ = get_node_value(node, "filename"); if (!starts_with(filename_, "/")) { - std::filesystem::path d(dir_name(settings::path_input)); - filename_ = (d / filename_).string(); + filename_ = dir_name(settings::path_input) + filename_; } } else { fatal_error("Must specify a file for the DAGMC universe"); @@ -80,77 +72,7 @@ DAGUniverse::DAGUniverse(pugi::xml_node node) adjust_material_ids_ = get_node_value_bool(node, "auto_mat_ids"); } - // Get material assignment overrides from nested DAGMC cell elements. - if (node.child("cell")) { - for (pugi::xml_node cell_node : node.children("cell")) { - if (!check_for_node(cell_node, "id")) { - fatal_error( - "Must specify id for each DAGMC cell override in ."); - } - - int32_t cell_id = std::stoi(get_node_value(cell_node, "id")); - - if (check_for_node(cell_node, "region")) { - fatal_error(fmt::format( - "DAGMC cell {} override cannot specify a region.", cell_id)); - } - if (check_for_node(cell_node, "fill")) { - fatal_error(fmt::format( - "DAGMC cell {} override currently only supports material fills.", - cell_id)); - } - if (check_for_node(cell_node, "universe")) { - fatal_error(fmt::format( - "DAGMC cell {} override cannot specify a universe.", cell_id)); - } - if (check_for_node(cell_node, "translation") || - check_for_node(cell_node, "rotation")) { - fatal_error(fmt::format( - "DAGMC cell {} override does not support translation or rotation.", - cell_id)); - } - if (!check_for_node(cell_node, "material")) { - fatal_error(fmt::format( - "DAGMC cell {} override must specify material.", cell_id)); - } - - auto inserted = material_overrides.emplace( - cell_id, parse_cell_material_xml(cell_node, cell_id)); - if (!inserted.second) { - fatal_error(fmt::format( - "Duplicate DAGMC cell override specified for cell {}", cell_id)); - } - - if (check_for_node(cell_node, "temperature")) { - temperature_overrides.emplace( - cell_id, parse_cell_temperature_xml(cell_node, cell_id)); - } - - if (check_for_node(cell_node, "density")) { - density_overrides.emplace( - cell_id, parse_cell_density_xml(cell_node, cell_id)); - } - } - } else if (check_for_node(node, "material_overrides")) { - if (node.child("cell")) { - fatal_error("DAGMCUniverse cannot specify both and " - " sub-elements. Use elements only."); - } - warning("DAGMCUniverse is deprecated. Use nested " - " elements under instead."); - for (pugi::xml_node co : - node.child("material_overrides").children("cell_override")) { - int32_t cell_id = std::stoi(get_node_value(co, "id")); - std::istringstream iss(co.child("material_ids").text().get()); - vector mats; - for (std::string s; iss >> s;) { - mats.push_back(s == "void" ? MATERIAL_VOID : std::stoi(s)); - } - material_overrides.emplace(cell_id, mats); - } - } - - initialize(material_overrides, temperature_overrides, density_overrides); + initialize(); } DAGUniverse::DAGUniverse( @@ -167,12 +89,9 @@ DAGUniverse::DAGUniverse(std::shared_ptr dagmc_ptr, : dagmc_instance_(dagmc_ptr), filename_(filename), adjust_geometry_ids_(auto_geom_ids), adjust_material_ids_(auto_mat_ids) { - MaterialOverrides material_overrides; - TemperatureOverrides temperature_overrides; - DensityOverrides density_overrides; set_id(); init_metadata(); - init_geometry(material_overrides, temperature_overrides, density_overrides); + init_geometry(); } void DAGUniverse::set_id() @@ -191,25 +110,13 @@ void DAGUniverse::set_id() void DAGUniverse::initialize() { - MaterialOverrides material_overrides; - TemperatureOverrides temperature_overrides; - initialize(material_overrides, temperature_overrides); -} - -void DAGUniverse::initialize(const MaterialOverrides& material_overrides, - const TemperatureOverrides& temperature_overrides, - const DensityOverrides& density_overrides) -{ -#ifdef OPENMC_UWUW_ENABLED - // read uwuw materials from the .h5m file if present - read_uwuw_materials(); -#endif + geom_type() = GeometryType::DAG; init_dagmc(); init_metadata(); - init_geometry(material_overrides, temperature_overrides, density_overrides); + init_geometry(); } void DAGUniverse::init_dagmc() @@ -245,9 +152,7 @@ void DAGUniverse::init_metadata() MB_CHK_ERR_CONT(rval); } -void DAGUniverse::init_geometry(const MaterialOverrides& material_overrides, - const TemperatureOverrides& temperature_overrides, - const DensityOverrides& density_overrides) +void DAGUniverse::init_geometry() { moab::ErrorCode rval; @@ -273,9 +178,6 @@ void DAGUniverse::init_geometry(const MaterialOverrides& material_overrides, : dagmc_instance_->id_by_index(3, c->dag_index()); c->universe_ = this->id_; c->fill_ = C_NONE; // no fill, single universe - if (dagmc_instance_->is_implicit_complement(vol_handle)) { - c->name_ = "implicit complement"; - } auto in_map = model::cell_map.find(c->id_); if (in_map == model::cell_map.end()) { @@ -304,68 +206,15 @@ void DAGUniverse::init_geometry(const MaterialOverrides& material_overrides, if (mat_str == "graveyard") { graveyard = vol_handle; } - if (material_overrides.count(c->id_)) { - override_assign_material(c, material_overrides); - } else if (mat_str == "void" || mat_str == "vacuum" || - mat_str == "graveyard") { + + // material void checks + if (mat_str == "void" || mat_str == "vacuum" || mat_str == "graveyard") { c->material_.push_back(MATERIAL_VOID); - } else if (uses_uwuw()) { - uwuw_assign_material(vol_handle, c); } else { - legacy_assign_material(mat_str, c); - } - - if (temperature_overrides.count(c->id_)) { - if (c->material_.empty() || c->material_[0] == MATERIAL_VOID) { - fatal_error(fmt::format("DAGMC cell {} was specified with a " - "temperature but no non-void material.", - c->id_)); - } - - c->sqrtkT_.clear(); - const auto& temp_overrides = temperature_overrides.at(c->id_); - c->sqrtkT_.reserve(temp_overrides.size()); - for (auto T : temp_overrides) { - c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * T)); - } - - if (settings::verbosity >= 10) { - std::stringstream override_values; - for (size_t i = 0; i < temp_overrides.size(); ++i) { - if (i > 0) { - override_values << " "; - } - override_values << temp_overrides[i]; - } - auto msg = fmt::format("Overriding DAGMC cell {} property " - "'temperature [K]' with value(s): {}", - c->id_, override_values.str()); - write_message(msg, 10); - } - } - - if (density_overrides.count(c->id_)) { - if (c->material_.empty() || c->material_[0] == MATERIAL_VOID) { - fatal_error(fmt::format("DAGMC cell {} was specified with a density " - "but no non-void material.", - c->id_)); - } - // density_mult_ holds the true density until materials are finalized, - // at which point it is converted to a proper multiplier (same as CSG). - c->density_mult_ = density_overrides.at(c->id_); - - if (settings::verbosity >= 10) { - const auto& dens = density_overrides.at(c->id_); - std::stringstream override_values; - for (size_t i = 0; i < dens.size(); ++i) { - if (i > 0) - override_values << " "; - override_values << dens[i]; - } - write_message(fmt::format("Overriding DAGMC cell {} property " - "'density [g/cm³]' with value(s): {}", - c->id_, override_values.str()), - 10); + if (uses_uwuw()) { + uwuw_assign_material(vol_handle, c); + } else { + legacy_assign_material(mat_str, c); } } @@ -378,21 +227,18 @@ void DAGUniverse::init_geometry(const MaterialOverrides& material_overrides, continue; } - // assign cell temperature if not explicitly overridden - if (c->sqrtkT_.empty()) { - const auto& mat = - model::materials[model::material_map.at(c->material_[0])]; - if (dagmc_instance_->has_prop(vol_handle, "temp")) { - rval = dagmc_instance_->prop_value(vol_handle, "temp", temp_value); - MB_CHK_ERR_CONT(rval); - double temp = std::stod(temp_value); - c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * temp)); - } else if (mat->temperature() > 0.0) { - c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * mat->temperature())); - } else { - c->sqrtkT_.push_back( - std::sqrt(K_BOLTZMANN * settings::temperature_default)); - } + // assign cell temperature + const auto& mat = model::materials[model::material_map.at(c->material_[0])]; + if (dagmc_instance_->has_prop(vol_handle, "temp")) { + rval = dagmc_instance_->prop_value(vol_handle, "temp", temp_value); + MB_CHK_ERR_CONT(rval); + double temp = std::stod(temp_value); + c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * temp)); + } else if (mat->temperature() > 0.0) { + c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * mat->temperature())); + } else { + c->sqrtkT_.push_back( + std::sqrt(K_BOLTZMANN * settings::temperature_default)); } model::cells.emplace_back(std::move(c)); @@ -559,7 +405,7 @@ bool DAGUniverse::find_cell(GeometryState& p) const // cells, place it in the implicit complement bool found = Universe::find_cell(p); if (!found && model::universe_map[this->id_] != model::root_universe) { - p.lowest_coord().cell() = implicit_complement_idx(); + p.lowest_coord().cell = implicit_complement_idx(); found = true; } return found; @@ -585,16 +431,16 @@ void DAGUniverse::to_hdf5(hid_t universes_group) const bool DAGUniverse::uses_uwuw() const { -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW return uwuw_ && !uwuw_->material_library.empty(); #else return false; -#endif // OPENMC_UWUW_ENABLED +#endif // UWUW } std::string DAGUniverse::get_uwuw_materials_xml() const { -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW if (!uses_uwuw()) { throw std::runtime_error("This DAGMC Universe does not use UWUW materials"); } @@ -614,12 +460,12 @@ std::string DAGUniverse::get_uwuw_materials_xml() const return ss.str(); #else fatal_error("DAGMC was not configured with UWUW."); -#endif // OPENMC_UWUW_ENABLED +#endif // UWUW } void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const { -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW if (!uses_uwuw()) { throw std::runtime_error( "This DAGMC universe does not use UWUW materials."); @@ -632,7 +478,7 @@ void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const mats_xml.close(); #else fatal_error("DAGMC was not configured with UWUW."); -#endif // OPENMC_UWUW_ENABLED +#endif } void DAGUniverse::legacy_assign_material( @@ -694,7 +540,7 @@ void DAGUniverse::legacy_assign_material( void DAGUniverse::read_uwuw_materials() { -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW // If no filename was provided, don't read UWUW materials if (filename_ == "") return; @@ -734,13 +580,16 @@ void DAGUniverse::read_uwuw_materials() } #else fatal_error("DAGMC was not configured with UWUW."); -#endif // OPENMC_UWUW_ENABLED +#endif } void DAGUniverse::uwuw_assign_material( moab::EntityHandle vol_handle, std::unique_ptr& c) const { -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW + // read materials from uwuw material file + read_uwuw_materials(); + // lookup material in uwuw if present std::string uwuw_mat = dmd_ptr->volume_material_property_data_eh[vol_handle]; if (uwuw_->material_library.count(uwuw_mat) != 0) { @@ -752,59 +601,21 @@ void DAGUniverse::uwuw_assign_material( } else { fatal_error(fmt::format("Material with value '{}' not found in the " "UWUW material library", - uwuw_mat)); + mat_str)); } #else fatal_error("DAGMC was not configured with UWUW."); -#endif // OPENMC_UWUW_ENABLED +#endif } - -void DAGUniverse::override_assign_material(std::unique_ptr& c, - const MaterialOverrides& material_overrides) const -{ - // if Cell ID matches an override key, use it to override the material - // assignment else if UWUW is used, get the material assignment from the DAGMC - // metadata - // Notify User that an override is being applied on a DAGMCCell - write_message(fmt::format("Applying override for DAGMCCell {}", c->id_), 8); - - const auto& mat_overrides = material_overrides.at(c->id_); - if (settings::verbosity >= 10) { - std::stringstream override_values; - for (size_t i = 0; i < mat_overrides.size(); ++i) { - if (i > 0) { - override_values << " "; - } - if (mat_overrides[i] == MATERIAL_VOID) { - override_values << "void"; - } else { - override_values << mat_overrides[i]; - } - } - auto msg = fmt::format("Overriding DAGMC cell {} property 'material' " - "with value(s): {}", - c->id_, override_values.str()); - write_message(msg, 10); - } - - // Override the material assignment for each cell instance using the legacy - // assignement - for (auto mat_id : mat_overrides) { - if (mat_id != MATERIAL_VOID && - model::material_map.find(mat_id) == model::material_map.end()) { - fatal_error(fmt::format( - "Material with ID '{}' not found for DAGMC cell {}", mat_id, c->id_)); - } - c->material_.push_back(mat_id); - } -} - //============================================================================== // DAGMC Cell implementation //============================================================================== DAGCell::DAGCell(std::shared_ptr dag_ptr, int32_t dag_idx) - : Cell {}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx) {}; + : Cell {}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx) +{ + geom_type_ = GeometryType::DAG; +}; std::pair DAGCell::distance( Position r, Direction u, int32_t on_surface, GeometryState* p) const @@ -815,11 +626,11 @@ std::pair DAGCell::distance( p->last_dir() = u; p->history().reset(); } - if (on_surface == SURFACE_NONE) { + if (on_surface == 0) { p->history().reset(); } - const auto& univ = model::universes[p->lowest_coord().universe()]; + const auto& univ = model::universes[p->lowest_coord().universe]; DAGUniverse* dag_univ = static_cast(univ.get()); if (!dag_univ) @@ -896,7 +707,7 @@ BoundingBox DAGCell::bounding_box() const double min[3], max[3]; rval = dagmc_ptr_->getobb(vol, min, max); MB_CHK_ERR_CONT(rval); - return {{min[0], min[1], min[2]}, {max[0], max[1], max[2]}}; + return {min[0], max[0], min[1], max[1], min[2], max[2]}; } //============================================================================== @@ -905,7 +716,9 @@ BoundingBox DAGCell::bounding_box() const DAGSurface::DAGSurface(std::shared_ptr dag_ptr, int32_t dag_idx) : Surface {}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx) -{} // empty constructor +{ + geom_type_ = GeometryType::DAG; +} // empty constructor moab::EntityHandle DAGSurface::mesh_handle() const { @@ -945,13 +758,16 @@ Direction DAGSurface::normal(Position r) const Direction DAGSurface::reflect(Position r, Direction u, GeometryState* p) const { - assert(p); + Expects(p); + p->history().reset_to_last_intersection(); + moab::ErrorCode rval; + moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_); double pnt[3] = {r.x, r.y, r.z}; double dir[3]; - moab::ErrorCode rval = - dagmc_ptr_->get_angle(mesh_handle(), pnt, dir, &p->history()); + rval = dagmc_ptr_->get_angle(surf, pnt, dir, &p->history()); MB_CHK_ERR_CONT(rval); - return u.reflect(dir); + p->last_dir() = u.reflect(dir); + return p->last_dir(); } //============================================================================== @@ -984,7 +800,7 @@ void check_dagmc_root_univ() int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ) { - auto surfp = dynamic_cast(model::surfaces[surf].get()); + auto surfp = dynamic_cast(model::surfaces[surf - 1].get()); auto cellp = dynamic_cast(model::cells[curr_cell].get()); auto univp = static_cast(model::universes[univ].get()); @@ -1000,61 +816,12 @@ int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ) return univp->cell_index(new_vol); } -extern "C" int openmc_dagmc_universe_get_cell_ids( - int32_t univ_id, int32_t* ids, size_t* n) -{ - // make sure the universe id is a DAGMC Universe - const auto& univ = model::universes[model::universe_map[univ_id]]; - if (univ->geom_type() != GeometryType::DAG) { - set_errmsg(fmt::format("Universe {} is not a DAGMC Universe", univ_id)); - return OPENMC_E_INVALID_TYPE; - } - - std::vector dag_cell_ids; - for (const auto& cell_index : univ->cells_) { - const auto& cell = model::cells[cell_index]; - if (cell->geom_type() == GeometryType::CSG) { - set_errmsg(fmt::format("Cell {} is not a DAGMC Cell", cell->id_)); - return OPENMC_E_INVALID_TYPE; - } - dag_cell_ids.push_back(cell->id_); - } - std::copy(dag_cell_ids.begin(), dag_cell_ids.end(), ids); - *n = dag_cell_ids.size(); - return 0; -} - -extern "C" int openmc_dagmc_universe_get_num_cells(int32_t univ_id, size_t* n) -{ - // make sure the universe id is a DAGMC Universe - const auto& univ = model::universes[model::universe_map[univ_id]]; - if (univ->geom_type() != GeometryType::DAG) { - set_errmsg(fmt::format("Universe {} is not a DAGMC universe", univ_id)); - return OPENMC_E_INVALID_TYPE; - } - *n = univ->cells_.size(); - return 0; -} - } // namespace openmc #else namespace openmc { -extern "C" int openmc_dagmc_universe_get_cell_ids( - int32_t univ_id, int32_t* ids, size_t* n) -{ - set_errmsg("OpenMC was not configured with DAGMC"); - return OPENMC_E_UNASSIGNED; -}; - -extern "C" int openmc_dagmc_universe_get_num_cells(int32_t univ_id, size_t* n) -{ - set_errmsg("OpenMC was not configured with DAGMC"); - return OPENMC_E_UNASSIGNED; -}; - void read_dagmc_universes(pugi::xml_node node) { if (check_for_node(node, "dagmc_universe")) { @@ -1069,4 +836,4 @@ int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ); } // namespace openmc -#endif // OPENMC_DAGMC_ENABLED +#endif // DAGMC diff --git a/src/distribution.cpp b/src/distribution.cpp index cbdd13127..3026630b3 100644 --- a/src/distribution.cpp +++ b/src/distribution.cpp @@ -7,90 +7,17 @@ #include // for accumulate #include // for runtime_error #include // for string, stod -#include -#include "openmc/chain.h" -#include "openmc/constants.h" +#include + #include "openmc/error.h" #include "openmc/math_functions.h" #include "openmc/random_dist.h" #include "openmc/random_lcg.h" #include "openmc/xml_interface.h" -namespace { -std::unordered_set decay_spectrum_missing_chain_nuclides; -} - namespace openmc { -//============================================================================== -// Helper function for computing importance weights from biased sampling -//============================================================================== - -vector compute_importance_weights( - const vector& p, const vector& b) -{ - std::size_t n = p.size(); - - // Normalize original probabilities - double sum_p = std::accumulate(p.begin(), p.end(), 0.0); - vector p_norm(n); - for (std::size_t i = 0; i < n; ++i) { - p_norm[i] = p[i] / sum_p; - } - - // Normalize bias probabilities - double sum_b = std::accumulate(b.begin(), b.end(), 0.0); - vector b_norm(n); - for (std::size_t i = 0; i < n; ++i) { - b_norm[i] = b[i] / sum_b; - } - - // Compute importance weights - vector weights(n); - for (std::size_t i = 0; i < n; ++i) { - weights[i] = (b_norm[i] == 0.0) ? INFTY : p_norm[i] / b_norm[i]; - } - return weights; -} - -std::pair Distribution::sample(uint64_t* seed) const -{ - if (bias_) { - // Sample from the bias distribution and compute importance weight - double val = bias_->sample_unbiased(seed); - double wgt = this->evaluate(val) / bias_->evaluate(val); - return {val, wgt}; - } else { - // Unbiased sampling: return sampled value with weight 1.0 - double val = sample_unbiased(seed); - return {val, 1.0}; - } -} - -// PDF evaluation not supported for all distribution types -double Distribution::evaluate(double x) const -{ - throw std::runtime_error( - "PDF evaluation not implemented for this distribution type."); -} - -void Distribution::read_bias_from_xml(pugi::xml_node node) -{ - if (check_for_node(node, "bias")) { - pugi::xml_node bias_node = node.child("bias"); - - if (check_for_node(bias_node, "bias")) { - openmc::fatal_error( - "Distribution has a bias distribution with its own bias distribution. " - "Please ensure bias distributions do not have their own bias."); - } - - UPtrDist bias = distribution_from_xml(bias_node); - this->set_bias(std::move(bias)); - } -} - //============================================================================== // DiscreteIndex implementation //============================================================================== @@ -103,14 +30,15 @@ DiscreteIndex::DiscreteIndex(pugi::xml_node node) assign({params.data() + n, n}); } -DiscreteIndex::DiscreteIndex(span p) +DiscreteIndex::DiscreteIndex(gsl::span p) { assign(p); } -void DiscreteIndex::assign(span p) +void DiscreteIndex::assign(gsl::span p) { prob_.assign(p.begin(), p.end()); + this->init_alias(); } @@ -189,55 +117,24 @@ void DiscreteIndex::normalize() // Discrete implementation //============================================================================== -Discrete::Discrete(pugi::xml_node node) +Discrete::Discrete(pugi::xml_node node) : di_(node) { auto params = get_node_array(node, "parameters"); + std::size_t n = params.size() / 2; - // First half is x values, second half is probabilities x_.assign(params.begin(), params.begin() + n); - const double* p = params.data() + n; - - // Check for bias - if (check_for_node(node, "bias")) { - // Get bias probabilities - auto bias_params = get_node_array(node, "bias"); - if (bias_params.size() != n) { - openmc::fatal_error( - "Size mismatch: Attempted to bias Discrete distribution with " + - std::to_string(n) + " probability entries using a bias with " + - std::to_string(bias_params.size()) + - " entries. Please ensure distributions have the same size."); - } - - // Compute importance weights - vector p_vec(p, p + n); - weight_ = compute_importance_weights(p_vec, bias_params); - - // Initialize DiscreteIndex with bias probabilities for sampling - di_.assign(bias_params); - } else { - // Unbiased case: weight_ stays empty - di_.assign({p, n}); - } } Discrete::Discrete(const double* x, const double* p, size_t n) : di_({p, n}) { + x_.assign(x, x + n); } -std::pair Discrete::sample(uint64_t* seed) const +double Discrete::sample(uint64_t* seed) const { - size_t idx = di_.sample(seed); - double wgt = weight_.empty() ? 1.0 : weight_[idx]; - return {x_[idx], wgt}; -} - -double Discrete::sample_unbiased(uint64_t* seed) const -{ - size_t idx = di_.sample(seed); - return x_[idx]; + return x_[di_.sample(seed)]; } //============================================================================== @@ -254,26 +151,13 @@ Uniform::Uniform(pugi::xml_node node) a_ = params.at(0); b_ = params.at(1); - - read_bias_from_xml(node); } -double Uniform::sample_unbiased(uint64_t* seed) const +double Uniform::sample(uint64_t* seed) const { return a_ + prn(seed) * (b_ - a_); } -double Uniform::evaluate(double x) const -{ - if (x <= a()) { - return 0.0; - } else if (x >= b()) { - return 0.0; - } else { - return 1 / (b() - a()); - } -} - //============================================================================== // PowerLaw implementation //============================================================================== @@ -293,24 +177,9 @@ PowerLaw::PowerLaw(pugi::xml_node node) offset_ = std::pow(a, n + 1); span_ = std::pow(b, n + 1) - offset_; ninv_ = 1 / (n + 1); - - read_bias_from_xml(node); } -double PowerLaw::evaluate(double x) const -{ - if (x <= a()) { - return 0.0; - } else if (x >= b()) { - return 0.0; - } else { - int pwr = n() + 1; - double norm = pwr / span_; - return norm * std::pow(std::fabs(x), n()); - } -} - -double PowerLaw::sample_unbiased(uint64_t* seed) const +double PowerLaw::sample(uint64_t* seed) const { return std::pow(offset_ + prn(seed) * span_, ninv_); } @@ -322,21 +191,13 @@ double PowerLaw::sample_unbiased(uint64_t* seed) const Maxwell::Maxwell(pugi::xml_node node) { theta_ = std::stod(get_node_value(node, "parameters")); - - read_bias_from_xml(node); } -double Maxwell::sample_unbiased(uint64_t* seed) const +double Maxwell::sample(uint64_t* seed) const { return maxwell_spectrum(theta_, seed); } -double Maxwell::evaluate(double x) const -{ - double c = (2.0 / SQRT_PI) * std::pow(theta_, -1.5); - return c * std::sqrt(x) * std::exp(-x / theta_); -} - //============================================================================== // Watt implementation //============================================================================== @@ -350,111 +211,31 @@ Watt::Watt(pugi::xml_node node) a_ = params.at(0); b_ = params.at(1); - - read_bias_from_xml(node); } -double Watt::sample_unbiased(uint64_t* seed) const +double Watt::sample(uint64_t* seed) const { return watt_spectrum(a_, b_, seed); } -double Watt::evaluate(double x) const -{ - double c = - 2.0 / (std::sqrt(PI * b_) * std::pow(a_, 1.5) * std::exp(a_ * b_ / 4.0)); - return c * std::exp(-x / a_) * std::sinh(std::sqrt(b_ * x)); -} - //============================================================================== // Normal implementation //============================================================================== - -Normal::Normal(double mean_value, double std_dev, double lower, double upper) - : mean_value_ {mean_value}, std_dev_ {std_dev}, lower_ {lower}, upper_ {upper} -{ - compute_normalization(); -} - Normal::Normal(pugi::xml_node node) { auto params = get_node_array(node, "parameters"); - if (params.size() != 2 && params.size() != 4) { + if (params.size() != 2) { openmc::fatal_error("Normal energy distribution must have two " - "parameters (mean, std_dev) or four parameters " - "(mean, std_dev, lower, upper) specified."); + "parameters specified."); } mean_value_ = params.at(0); std_dev_ = params.at(1); - - // Optional truncation bounds - if (params.size() == 4) { - lower_ = params.at(2); - upper_ = params.at(3); - } else { - lower_ = -INFTY; - upper_ = INFTY; - } - - compute_normalization(); - read_bias_from_xml(node); } -void Normal::compute_normalization() +double Normal::sample(uint64_t* seed) const { - // Validate bounds - if (lower_ >= upper_) { - openmc::fatal_error( - "Normal distribution lower bound must be less than upper bound."); - } - - // Check if truncation bounds are finite - is_truncated_ = (lower_ > -INFTY || upper_ < INFTY); - - if (is_truncated_) { - double alpha = (lower_ - mean_value_) / std_dev_; - double beta = (upper_ - mean_value_) / std_dev_; - double cdf_diff = standard_normal_cdf(beta) - standard_normal_cdf(alpha); - - if (cdf_diff <= 0.0) { - openmc::fatal_error( - "Normal distribution truncation bounds exclude entire distribution."); - } - norm_factor_ = 1.0 / cdf_diff; - } else { - norm_factor_ = 1.0; - } -} - -double Normal::sample_unbiased(uint64_t* seed) const -{ - if (!is_truncated_) { - return normal_variate(mean_value_, std_dev_, seed); - } - - // Rejection sampling for truncated normal - double x; - do { - x = normal_variate(mean_value_, std_dev_, seed); - } while (x < lower_ || x > upper_); - return x; -} - -double Normal::evaluate(double x) const -{ - // Return 0 outside truncation bounds - if (x < lower_ || x > upper_) { - return 0.0; - } - - // Standard normal PDF value - double pdf = (1.0 / (std::sqrt(2.0 * PI) * std_dev_)) * - std::exp(-std::pow((x - mean_value_), 2.0) / - (2.0 * std::pow(std_dev_, 2.0))); - - // Apply normalization for truncation - return pdf * norm_factor_; + return normal_variate(mean_value_, std_dev_, seed); } //============================================================================== @@ -469,10 +250,6 @@ Tabular::Tabular(pugi::xml_node node) interp_ = Interpolation::histogram; } else if (temp == "linear-linear") { interp_ = Interpolation::lin_lin; - } else if (temp == "log-linear") { - interp_ = Interpolation::log_lin; - } else if (temp == "log-log") { - interp_ = Interpolation::log_log; } else { openmc::fatal_error( "Unsupported interpolation type for distribution: " + temp); @@ -481,18 +258,12 @@ Tabular::Tabular(pugi::xml_node node) interp_ = Interpolation::histogram; } - // Read and initialize tabular distribution. If number of parameters is odd, - // add an extra zero for the 'p' array. + // Read and initialize tabular distribution auto params = get_node_array(node, "parameters"); - if (params.size() % 2 != 0) { - params.push_back(0.0); - } std::size_t n = params.size() / 2; const double* x = params.data(); const double* p = x + n; init(x, p, n); - - read_bias_from_xml(node); } Tabular::Tabular(const double* x, const double* p, int n, Interpolation interp, @@ -509,6 +280,13 @@ void Tabular::init( std::copy(x, x + n, std::back_inserter(x_)); std::copy(p, p + n, std::back_inserter(p_)); + // Check interpolation parameter + if (interp_ != Interpolation::histogram && + interp_ != Interpolation::lin_lin) { + openmc::fatal_error("Only histogram and linear-linear interpolation " + "for tabular distribution is supported."); + } + // Calculate cumulative distribution function if (c) { std::copy(c, c + n, std::back_inserter(c_)); @@ -520,18 +298,6 @@ void Tabular::init( c_[i] = c_[i - 1] + p_[i - 1] * (x_[i] - x_[i - 1]); } else if (interp_ == Interpolation::lin_lin) { c_[i] = c_[i - 1] + 0.5 * (p_[i - 1] + p_[i]) * (x_[i] - x_[i - 1]); - } else if (interp_ == Interpolation::log_lin) { - double m = std::log(p_[i] / p_[i - 1]) / (x_[i] - x_[i - 1]); - c_[i] = c_[i - 1] + p_[i - 1] * (x_[i] - x_[i - 1]) * - exprel(m * (x_[i] - x_[i - 1])); - } else if (interp_ == Interpolation::log_log) { - double m = std::log((x_[i] * p_[i]) / (x_[i - 1] * p_[i - 1])) / - std::log(x_[i] / x_[i - 1]); - c_[i] = c_[i - 1] + x_[i - 1] * p_[i - 1] * - std::log(x_[i] / x_[i - 1]) * - exprel(m * std::log(x_[i] / x_[i - 1])); - } else { - UNREACHABLE(); } } } @@ -546,15 +312,20 @@ void Tabular::init( } } -double Tabular::sample_unbiased(uint64_t* seed) const +double Tabular::sample(uint64_t* seed) const { // Sample value of CDF double c = prn(seed); // Find first CDF bin which is above the sampled value - auto c_iter = std::lower_bound(c_.begin() + 1, c_.end(), c); - int i = std::distance(c_.begin(), c_iter) - 1; - double c_i = c_[i]; + double c_i = c_[0]; + int i; + std::size_t n = c_.size(); + for (i = 0; i < n - 1; ++i) { + if (c <= c_[i + 1]) + break; + c_i = c_[i + 1]; + } // Determine bounding PDF values double x_i = x_[i]; @@ -567,7 +338,7 @@ double Tabular::sample_unbiased(uint64_t* seed) const } else { return x_i; } - } else if (interp_ == Interpolation::lin_lin) { + } else { // Linear-linear interpolation double x_i1 = x_[i + 1]; double p_i1 = p_[i + 1]; @@ -580,52 +351,6 @@ double Tabular::sample_unbiased(uint64_t* seed) const (std::sqrt(std::max(0.0, p_i * p_i + 2 * m * (c - c_i))) - p_i) / m; } - } else if (interp_ == Interpolation::log_lin) { - // Log-linear interpolation - double x_i1 = x_[i + 1]; - double p_i1 = p_[i + 1]; - - double m = std::log(p_i1 / p_i) / (x_i1 - x_i); - double f = (c - c_i) / p_i; - return x_i + f * log1prel(m * f); - } else if (interp_ == Interpolation::log_log) { - // Log-Log interpolation - double x_i1 = x_[i + 1]; - double p_i1 = p_[i + 1]; - - double m = std::log((x_i1 * p_i1) / (x_i * p_i)) / std::log(x_i1 / x_i); - double f = (c - c_i) / (p_i * x_i); - return x_i * std::exp(f * log1prel(m * f)); - } else { - UNREACHABLE(); - } -} - -double Tabular::evaluate(double x) const -{ - int i; - - if (interp_ == Interpolation::histogram) { - i = std::upper_bound(x_.begin(), x_.end(), x) - x_.begin() - 1; - if (i < 0 || i >= static_cast(p_.size())) { - return 0.0; - } else { - return p_[i]; - } - } else { - i = std::lower_bound(x_.begin(), x_.end(), x) - x_.begin() - 1; - - if (i < 0 || i >= static_cast(p_.size()) - 1) { - return 0.0; - } else { - double x0 = x_[i]; - double x1 = x_[i + 1]; - double p0 = p_[i]; - double p1 = p_[i + 1]; - - double t = (x - x0) / (x1 - x0); - return (1 - t) * p0 + t * p1; - } } } @@ -633,7 +358,7 @@ double Tabular::evaluate(double x) const // Equiprobable implementation //============================================================================== -double Equiprobable::sample_unbiased(uint64_t* seed) const +double Equiprobable::sample(uint64_t* seed) const { std::size_t n = x_.size(); @@ -645,27 +370,13 @@ double Equiprobable::sample_unbiased(uint64_t* seed) const return xl + ((n - 1) * r - i) * (xr - xl); } -double Equiprobable::evaluate(double x) const -{ - double x_min = *std::min_element(x_.begin(), x_.end()); - double x_max = *std::max_element(x_.begin(), x_.end()); - - if (x < x_min || x > x_max) { - return 0.0; - } else { - return 1.0 / (x_max - x_min); - } -} - //============================================================================== // Mixture implementation //============================================================================== Mixture::Mixture(pugi::xml_node node) { - vector probabilities; - - // First pass: collect distributions and their probabilities + double cumsum = 0.0; for (pugi::xml_node pair : node.children("pair")) { // Check that required data exists if (!pair.attribute("probability")) @@ -673,60 +384,36 @@ Mixture::Mixture(pugi::xml_node node) if (!pair.child("dist")) fatal_error("Mixture pair element does not have a distribution."); - // Get probability and distribution + // cummulative sum of probabilities double p = std::stod(pair.attribute("probability").value()); - auto dist = distribution_from_xml(pair.child("dist")); - // Weight probability by the distribution's integral - double weighted_prob = p * dist->integral(); - probabilities.push_back(weighted_prob); - distribution_.push_back(std::move(dist)); + // Save cummulative probability and distribution + auto dist = distribution_from_xml(pair.child("dist")); + cumsum += p * dist->integral(); + + distribution_.push_back(std::make_pair(cumsum, std::move(dist))); } - // Save sum of weighted probabilities - integral_ = std::accumulate(probabilities.begin(), probabilities.end(), 0.0); - - std::size_t n = probabilities.size(); - - // Check for bias - if (check_for_node(node, "bias")) { - // Get bias probabilities - auto bias_params = get_node_array(node, "bias"); - if (bias_params.size() != n) { - openmc::fatal_error( - "Size mismatch: Attempted to bias Mixture distribution with " + - std::to_string(n) + " components using a bias with " + - std::to_string(bias_params.size()) + - " entries. Please ensure distributions have the same size."); - } - - // Compute importance weights - weight_ = compute_importance_weights(probabilities, bias_params); - - // Initialize DiscreteIndex with bias probabilities for sampling - di_.assign(bias_params); - } else { - // Unbiased case: weight_ stays empty - di_.assign(probabilities); + // Normalize cummulative probabilities to 1 + for (auto& pair : distribution_) { + pair.first /= cumsum; } } -std::pair Mixture::sample(uint64_t* seed) const +double Mixture::sample(uint64_t* seed) const { - size_t idx = di_.sample(seed); + // Sample value of CDF + const double p = prn(seed); + + // find matching distribution + const auto it = std::lower_bound(distribution_.cbegin(), distribution_.cend(), + p, [](const DistPair& pair, double p) { return pair.first < p; }); + + // This should not happen. Catch it + Ensures(it != distribution_.cend()); // Sample the chosen distribution - auto [val, sub_wgt] = distribution_[idx]->sample(seed); - - // Multiply by component selection weight - double mix_wgt = weight_.empty() ? 1.0 : weight_[idx]; - return {val, mix_wgt * sub_wgt}; -} - -double Mixture::sample_unbiased(uint64_t* seed) const -{ - size_t idx = di_.sample(seed); - return distribution_[idx]->sample(seed).first; + return it->second->sample(seed); } //============================================================================== @@ -759,8 +446,6 @@ UPtrDist distribution_from_xml(pugi::xml_node node) dist = UPtrDist {new Tabular(node)}; } else if (type == "mixture") { dist = UPtrDist {new Mixture(node)}; - } else if (type == "decay_spectrum") { - dist = UPtrDist {new DecaySpectrum(node)}; } else if (type == "muir") { openmc::fatal_error( "'muir' distributions are now specified using the openmc.stats.muir() " @@ -771,120 +456,4 @@ UPtrDist distribution_from_xml(pugi::xml_node node) return dist; } -//============================================================================== -// DecaySpectrum implementation -//============================================================================== - -DecaySpectrum::DecaySpectrum(pugi::xml_node node) -{ - // Read the region volume [cm^3] needed for absolute emission rate - if (!check_for_node(node, "volume")) - fatal_error("DecaySpectrum: 'volume' attribute is required."); - double volume = std::stod(get_node_value(node, "volume")); - - // Read nuclide names and atom densities from XML - vector nuclide_indices; - vector atoms; - auto names = get_node_array(node, "nuclides"); - auto densities = get_node_array(node, "parameters"); - if (names.size() != densities.size()) { - fatal_error("DecaySpectrum nuclides and parameters must have the same " - "length."); - } - - for (size_t i = 0; i < names.size(); ++i) { - const auto& name = names[i]; - double density = densities[i]; - - // Look up nuclide in the depletion chain - auto it = data::chain_nuclide_map.find(name); - if (it == data::chain_nuclide_map.end()) { - if (decay_spectrum_missing_chain_nuclides.insert(name).second) { - warning("Nuclide '" + name + - "' appears in a DecaySpectrum source but is not present in " - "the depletion chain; it will be ignored."); - } - continue; - } - - int nuclide_index = it->second; - const auto& chain_nuc = data::chain_nuclides[nuclide_index]; - const Distribution* photon_dist = chain_nuc->photon_energy(); - if (!photon_dist) - continue; - - // Skip non-positive densities and warn if negative - if (density <= 0.0) { - if (density < 0.0) { - warning("Nuclide '" + name + - "' has a negative density in a DecaySpectrum source; it will " - "be ignored."); - } - continue; - } - - // atoms = density [atom/b-cm] * 1e24 [b/cm^2] * volume [cm^3] - double atoms_i = density * 1.0e24 * volume; - - nuclide_indices.push_back(nuclide_index); - atoms.push_back(atoms_i); - } - - init(std::move(nuclide_indices), atoms); -} - -void DecaySpectrum::init( - vector nuclide_indices, const vector& atoms) -{ - if (nuclide_indices.size() != atoms.size()) { - fatal_error("DecaySpectrum nuclide index and atoms arrays must have " - "the same length."); - } - - vector probs; - probs.reserve(nuclide_indices.size()); - for (size_t i = 0; i < nuclide_indices.size(); ++i) { - // Distribution integral is in [photons/s/atom]; multiplying by atoms gives - // the total emission rate [photons/s] for this nuclide. - const auto* dist = - data::chain_nuclides[nuclide_indices[i]]->photon_energy(); - probs.push_back(atoms[i] * dist->integral()); - } - - nuclide_indices_ = std::move(nuclide_indices); - integral_ = std::accumulate(probs.begin(), probs.end(), 0.0); - if (nuclide_indices_.empty() || integral_ <= 0.0) { - fatal_error("DecaySpectrum source did not resolve any nuclides with decay " - "photon spectra and positive atom densities. Ensure " - "OPENMC_CHAIN_FILE is set and matches the nuclides in the " - "source definition."); - } - di_.assign(probs); -} - -DecaySpectrum::Sample DecaySpectrum::sample_with_parent(uint64_t* seed) const -{ - size_t idx = di_.sample(seed); - int parent_nuclide = nuclide_indices_[idx]; - const auto* dist = data::chain_nuclides[parent_nuclide]->photon_energy(); - auto [energy, weight] = dist->sample(seed); - return {energy, weight, parent_nuclide}; -} - -std::pair DecaySpectrum::sample(uint64_t* seed) const -{ - auto sample = sample_with_parent(seed); - return {sample.energy, sample.weight}; -} - -double DecaySpectrum::integral() const -{ - return integral_; -} - -double DecaySpectrum::sample_unbiased(uint64_t* seed) const -{ - return sample_with_parent(seed).energy; -} - } // namespace openmc diff --git a/src/distribution_angle.cpp b/src/distribution_angle.cpp index ecb5961f6..5e92b794a 100644 --- a/src/distribution_angle.cpp +++ b/src/distribution_angle.cpp @@ -2,11 +2,11 @@ #include // for abs, copysign -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" +#include "xtensor/xview.hpp" #include "openmc/endf.h" #include "openmc/hdf5_interface.h" -#include "openmc/math_functions.h" #include "openmc/random_lcg.h" #include "openmc/search.h" #include "openmc/vector.h" // for vector @@ -29,7 +29,7 @@ AngleDistribution::AngleDistribution(hid_t group) hid_t dset = open_dataset(group, "mu"); read_attribute(dset, "offsets", offsets); read_attribute(dset, "interpolation", interp); - tensor::Tensor temp; + xt::xarray temp; read_dataset(dset, temp); close_dataset(dset); @@ -40,13 +40,13 @@ AngleDistribution::AngleDistribution(hid_t group) if (i < n_energy - 1) { n = offsets[i + 1] - j; } else { - n = temp.shape(1) - j; + n = temp.shape()[1] - j; } // Create and initialize tabular distribution - tensor::View xs = temp.slice(0, tensor::range(j, j + n)); - tensor::View ps = temp.slice(1, tensor::range(j, j + n)); - tensor::View cs = temp.slice(2, tensor::range(j, j + n)); + auto xs = xt::view(temp, 0, xt::range(j, j + n)); + auto ps = xt::view(temp, 1, xt::range(j, j + n)); + auto cs = xt::view(temp, 2, xt::range(j, j + n)); vector x {xs.begin(), xs.end()}; vector p {ps.begin(), ps.end()}; vector c {cs.begin(), cs.end()}; @@ -64,17 +64,30 @@ AngleDistribution::AngleDistribution(hid_t group) double AngleDistribution::sample(double E, uint64_t* seed) const { - // Find energy bin and calculate interpolation factor + // Determine number of incoming energies + auto n = energy_.size(); + + // Find energy bin and calculate interpolation factor -- if the energy is + // outside the range of the tabulated energies, choose the first or last bins int i; double r; - get_energy_index(energy_, E, i, r); + if (E < energy_[0]) { + i = 0; + r = 0.0; + } else if (E > energy_[n - 1]) { + i = n - 2; + r = 1.0; + } else { + i = lower_bound_index(energy_.begin(), energy_.end(), E); + r = (E - energy_[i]) / (energy_[i + 1] - energy_[i]); + } // Sample between the ith and (i+1)th bin if (r > prn(seed)) ++i; // Sample i-th distribution - double mu = distribution_[i]->sample(seed).first; + double mu = distribution_[i]->sample(seed); // Make sure mu is in range [-1,1] and return if (std::abs(mu) > 1.0) @@ -82,19 +95,4 @@ double AngleDistribution::sample(double E, uint64_t* seed) const return mu; } -double AngleDistribution::evaluate(double E, double mu) const -{ - // Find energy bin and calculate interpolation factor - int i; - double r; - get_energy_index(energy_, E, i, r); - - double pdf = 0.0; - if (r > 0.0) - pdf += r * distribution_[i + 1]->evaluate(mu); - if (r < 1.0) - pdf += (1.0 - r) * distribution_[i]->evaluate(mu); - return pdf; -} - } // namespace openmc diff --git a/src/distribution_energy.cpp b/src/distribution_energy.cpp index 2f8e6cf1a..a4a5ce9e1 100644 --- a/src/distribution_energy.cpp +++ b/src/distribution_energy.cpp @@ -4,7 +4,7 @@ #include // for size_t #include // for back_inserter -#include "openmc/tensor.h" +#include "xtensor/xview.hpp" #include "openmc/endf.h" #include "openmc/hdf5_interface.h" @@ -60,11 +60,11 @@ ContinuousTabular::ContinuousTabular(hid_t group) hid_t dset = open_dataset(group, "energy"); // Get interpolation parameters - tensor::Tensor temp; + xt::xarray temp; read_attribute(dset, "interpolation", temp); - tensor::View temp_b = temp.slice(0); // breakpoints - tensor::View temp_i = temp.slice(1); // interpolation parameters + auto temp_b = xt::view(temp, 0); // view of breakpoints + auto temp_i = xt::view(temp, 1); // view of interpolation parameters std::copy(temp_b.begin(), temp_b.end(), std::back_inserter(breakpoints_)); for (const auto i : temp_i) @@ -85,7 +85,7 @@ ContinuousTabular::ContinuousTabular(hid_t group) read_attribute(dset, "interpolation", interp); read_attribute(dset, "n_discrete_lines", n_discrete); - tensor::Tensor eout; + xt::xarray eout; read_dataset(dset, eout); close_dataset(dset); @@ -96,7 +96,7 @@ ContinuousTabular::ContinuousTabular(hid_t group) if (i < n_energy - 1) { n = offsets[i + 1] - j; } else { - n = eout.shape(1) - j; + n = eout.shape()[1] - j; } // Assign interpolation scheme and number of discrete lines @@ -105,15 +105,15 @@ ContinuousTabular::ContinuousTabular(hid_t group) d.n_discrete = n_discrete[i]; // Copy data - d.e_out = eout.slice(0, tensor::range(j, j + n)); - d.p = eout.slice(1, tensor::range(j, j + n)); + d.e_out = xt::view(eout, 0, xt::range(j, j + n)); + d.p = xt::view(eout, 1, xt::range(j, j + n)); // To get answers that match ACE data, for now we still use the tabulated // CDF values that were passed through to the HDF5 library. At a later // time, we can remove the CDF values from the HDF5 library and // reconstruct them using the PDF if (true) { - d.c = eout.slice(2, tensor::range(j, j + n)); + d.c = xt::view(eout, 2, xt::range(j, j + n)); } else { // Calculate cumulative distribution function -- discrete portion for (int k = 0; k < d.n_discrete; ++k) { diff --git a/src/distribution_multi.cpp b/src/distribution_multi.cpp index 47785649b..b7b3efe52 100644 --- a/src/distribution_multi.cpp +++ b/src/distribution_multi.cpp @@ -1,6 +1,6 @@ #include "openmc/distribution_multi.h" -#include // for move, clamp +#include // for move #include // for sqrt, sin, cos, max #include "openmc/constants.h" @@ -20,7 +20,7 @@ unique_ptr UnitSphereDistribution::create( if (check_for_node(node, "type")) type = get_node_value(node, "type", true, true); if (type == "isotropic") { - return UPtrAngle {new Isotropic(node)}; + return UPtrAngle {new Isotropic()}; } else if (type == "monodirectional") { return UPtrAngle {new Monodirectional(node)}; } else if (type == "mu-phi") { @@ -44,7 +44,6 @@ UnitSphereDistribution::UnitSphereDistribution(pugi::xml_node node) fatal_error("Angular distribution reference direction must have " "three parameters specified."); u_ref_ = Direction(u_ref.data()); - u_ref_ /= u_ref_.norm(); } } @@ -59,16 +58,6 @@ PolarAzimuthal::PolarAzimuthal(Direction u, UPtrDist mu, UPtrDist phi) PolarAzimuthal::PolarAzimuthal(pugi::xml_node node) : UnitSphereDistribution {node} { - // Read reference directional unit vector - if (check_for_node(node, "reference_vwu")) { - auto v_ref = get_node_array(node, "reference_vwu"); - if (v_ref.size() != 3) - fatal_error("Angular distribution reference v direction must have " - "three parameters specified."); - v_ref_ = Direction(v_ref.data()); - v_ref_ /= v_ref_.norm(); - } - w_ref_ = u_ref_.cross(v_ref_); if (check_for_node(node, "mu")) { pugi::xml_node node_dist = node.child("mu"); mu_ = distribution_from_xml(node_dist); @@ -84,79 +73,23 @@ PolarAzimuthal::PolarAzimuthal(pugi::xml_node node) } } -std::pair PolarAzimuthal::sample(uint64_t* seed) const -{ - return sample_impl(seed, false); -} - -std::pair PolarAzimuthal::sample_as_bias( - uint64_t* seed) const -{ - return sample_impl(seed, true); -} - -std::pair PolarAzimuthal::sample_impl( - uint64_t* seed, bool return_pdf) const +Direction PolarAzimuthal::sample(uint64_t* seed) const { // Sample cosine of polar angle - auto [mu, mu_wgt] = mu_->sample(seed); + double mu = mu_->sample(seed); + if (mu == 1.0) + return u_ref_; // Sample azimuthal angle - auto [phi, phi_wgt] = phi_->sample(seed); + double phi = phi_->sample(seed); - // Compute either the PDF value or the importance weight - double weight = - return_pdf ? (mu_->evaluate(mu) * phi_->evaluate(phi)) : (mu_wgt * phi_wgt); - - if (mu == 1.0) - return {u_ref_, weight}; - if (mu == -1.0) - return {-u_ref_, weight}; - - double f = std::sqrt(1 - mu * mu); - return {mu * u_ref_ + f * std::cos(phi) * v_ref_ + f * std::sin(phi) * w_ref_, - weight}; -} - -double PolarAzimuthal::evaluate(Direction u) const -{ - double mu = std::clamp(u.dot(u_ref_), -1.0, 1.0); - double phi = 0.0; - double sin_theta_sq = std::max(0.0, 1.0 - mu * mu); - if (sin_theta_sq > 0.0) { - double sin_theta = std::sqrt(sin_theta_sq); - double cos_phi = u.dot(v_ref_) / sin_theta; - double sin_phi = u.dot(w_ref_) / sin_theta; - phi = std::atan2(sin_phi, cos_phi); - if (phi < 0.0) - phi += 2.0 * PI; - } - return mu_->evaluate(mu) * phi_->evaluate(phi); + return rotate_angle(u_ref_, mu, &phi, seed); } //============================================================================== // Isotropic implementation //============================================================================== -Isotropic::Isotropic(pugi::xml_node node) : UnitSphereDistribution {node} -{ - if (check_for_node(node, "bias")) { - pugi::xml_node bias_node = node.child("bias"); - std::string bias_type = get_node_value(bias_node, "type", true, true); - if (bias_type != "mu-phi") { - openmc::fatal_error( - "Isotropic distributions may only be biased by a PolarAzimuthal."); - } - auto bias = std::make_unique(bias_node); - if (bias->mu()->bias() || bias->phi()->bias()) { - openmc::fatal_error( - "Attempted to bias Isotropic distribution with a biased PolarAzimuthal " - "distribution. Please ensure bias distributions are unbiased."); - } - this->set_bias(std::move(bias)); - } -} - Direction isotropic_direction(uint64_t* seed) { double phi = uniform_distribution(0., 2.0 * PI, seed); @@ -165,28 +98,18 @@ Direction isotropic_direction(uint64_t* seed) std::sqrt(1.0 - mu * mu) * std::sin(phi)}; } -std::pair Isotropic::sample(uint64_t* seed) const +Direction Isotropic::sample(uint64_t* seed) const { - if (bias()) { - auto [val, eval] = bias()->sample_as_bias(seed); - return {val, 1.0 / (4.0 * PI * eval)}; - } else { - return {isotropic_direction(seed), 1.0}; - } -} - -double Isotropic::evaluate(Direction u) const -{ - return 1.0 / (4.0 * PI); + return isotropic_direction(seed); } //============================================================================== // Monodirectional implementation //============================================================================== -std::pair Monodirectional::sample(uint64_t* seed) const +Direction Monodirectional::sample(uint64_t* seed) const { - return {u_ref_, 1.0}; + return u_ref_; } } // namespace openmc diff --git a/src/distribution_spatial.cpp b/src/distribution_spatial.cpp index 5a3452422..8dbd7d887 100644 --- a/src/distribution_spatial.cpp +++ b/src/distribution_spatial.cpp @@ -26,8 +26,6 @@ unique_ptr SpatialDistribution::create(pugi::xml_node node) return UPtrSpace {new SphericalIndependent(node)}; } else if (type == "mesh") { return UPtrSpace {new MeshSpatial(node)}; - } else if (type == "cloud") { - return UPtrSpace {new PointCloud(node)}; } else if (type == "box") { return UPtrSpace {new SpatialBox(node)}; } else if (type == "fission") { @@ -80,13 +78,9 @@ CartesianIndependent::CartesianIndependent(pugi::xml_node node) } } -std::pair CartesianIndependent::sample(uint64_t* seed) const +Position CartesianIndependent::sample(uint64_t* seed) const { - auto [x_val, x_wgt] = x_->sample(seed); - auto [y_val, y_wgt] = y_->sample(seed); - auto [z_val, z_wgt] = z_->sample(seed); - Position xi {x_val, y_val, z_val}; - return {xi, x_wgt * y_wgt * z_wgt}; + return {x_->sample(seed), y_->sample(seed), z_->sample(seed)}; } //============================================================================== @@ -141,51 +135,16 @@ CylindricalIndependent::CylindricalIndependent(pugi::xml_node node) // If no coordinates were specified, default to (0, 0, 0) origin_ = {0.0, 0.0, 0.0}; } - - // Read cylinder z_dir - if (check_for_node(node, "z_dir")) { - auto z_dir = get_node_array(node, "z_dir"); - if (z_dir.size() == 3) { - z_dir_ = z_dir; - z_dir_ /= z_dir_.norm(); - } else { - fatal_error("z_dir for cylindrical source distribution must be length 3"); - } - } else { - // If no z_dir was specified, default to (0, 0, 1) - z_dir_ = {0.0, 0.0, 1.0}; - } - - // Read cylinder r_dir - if (check_for_node(node, "r_dir")) { - auto r_dir = get_node_array(node, "r_dir"); - if (r_dir.size() == 3) { - r_dir_ = r_dir; - r_dir_ /= r_dir_.norm(); - } else { - fatal_error("r_dir for cylindrical source distribution must be length 3"); - } - } else { - // If no r_dir was specified, default to (1, 0, 0) - r_dir_ = {1.0, 0.0, 0.0}; - } - - if (r_dir_.dot(z_dir_) > 1e-12) - fatal_error("r_dir must be perpendicular to z_dir"); - - auto phi_dir = z_dir_.cross(r_dir_); - phi_dir /= phi_dir.norm(); - phi_dir_ = phi_dir; } -std::pair CylindricalIndependent::sample(uint64_t* seed) const +Position CylindricalIndependent::sample(uint64_t* seed) const { - auto [r, r_wgt] = r_->sample(seed); - auto [phi, phi_wgt] = phi_->sample(seed); - auto [z, z_wgt] = z_->sample(seed); - Position xi = - r * (cos(phi) * r_dir_ + sin(phi) * phi_dir_) + z * z_dir_ + origin_; - return {xi, r_wgt * phi_wgt * z_wgt}; + double r = r_->sample(seed); + double phi = phi_->sample(seed); + double x = r * cos(phi) + origin_.x; + double y = r * sin(phi) + origin_.y; + double z = z_->sample(seed) + origin_.z; + return {x, y, z}; } //============================================================================== @@ -242,17 +201,16 @@ SphericalIndependent::SphericalIndependent(pugi::xml_node node) } } -std::pair SphericalIndependent::sample(uint64_t* seed) const +Position SphericalIndependent::sample(uint64_t* seed) const { - auto [r, r_wgt] = r_->sample(seed); - auto [cos_theta, cos_theta_wgt] = cos_theta_->sample(seed); - auto [phi, phi_wgt] = phi_->sample(seed); + double r = r_->sample(seed); + double cos_theta = cos_theta_->sample(seed); + double phi = phi_->sample(seed); // sin(theta) by sin**2 + cos**2 = 1 double x = r * std::sqrt(1 - cos_theta * cos_theta) * cos(phi) + origin_.x; double y = r * std::sqrt(1 - cos_theta * cos_theta) * sin(phi) + origin_.y; double z = r * cos_theta + origin_.z; - Position xi {x, y, z}; - return {xi, r_wgt * cos_theta_wgt * phi_wgt}; + return {x, y, z}; } //============================================================================== @@ -262,11 +220,9 @@ std::pair SphericalIndependent::sample(uint64_t* seed) const MeshSpatial::MeshSpatial(pugi::xml_node node) { - auto spatial_type = get_node_value(node, "type", true, true); - if (spatial_type != "mesh") { - fatal_error( - fmt::format("Incorrect spatial type '{}' for a MeshSpatial distribution", - spatial_type)); + if (get_node_value(node, "type", true, true) != "mesh") { + fatal_error(fmt::format( + "Incorrect spatial type '{}' for a MeshSpatial distribution")); } // No in-tet distributions implemented, could include distributions for the @@ -302,40 +258,9 @@ MeshSpatial::MeshSpatial(pugi::xml_node node) } elem_idx_dist_.assign(strengths); - - if (check_for_node(node, "bias")) { - pugi::xml_node bias_node = node.child("bias"); - - if (check_for_node(bias_node, "strengths")) { - std::vector bias_strengths(n_bins, 1.0); - bias_strengths = get_node_array(node, "strengths"); - - if (bias_strengths.size() != n_bins) { - fatal_error( - fmt::format("Number of entries in the bias strengths array {} does " - "not match the number of entities in mesh {} ({}).", - bias_strengths.size(), mesh_id, n_bins)); - } - - if (get_node_value_bool(node, "volume_normalized")) { - for (int i = 0; i < n_bins; i++) { - bias_strengths[i] *= this->mesh()->volume(i); - } - } - - // Compute importance weights - weight_ = compute_importance_weights(strengths, bias_strengths); - - // Re-initialize DiscreteIndex with bias strengths for sampling - elem_idx_dist_.assign(bias_strengths); - } else { - fatal_error(fmt::format( - "Bias node for mesh {} found without strengths array.", mesh_id)); - } - } } -MeshSpatial::MeshSpatial(int32_t mesh_idx, span strengths) +MeshSpatial::MeshSpatial(int32_t mesh_idx, gsl::span strengths) : mesh_idx_(mesh_idx) { check_element_types(); @@ -368,80 +293,9 @@ std::pair MeshSpatial::sample_mesh(uint64_t* seed) const return {elem_idx, mesh()->sample_element(elem_idx, seed)}; } -std::pair MeshSpatial::sample(uint64_t* seed) const +Position MeshSpatial::sample(uint64_t* seed) const { - auto [elem_idx, u] = this->sample_mesh(seed); - double wgt = weight_.empty() ? 1.0 : weight_[elem_idx]; - return {u, wgt}; -} - -//============================================================================== -// PointCloud implementation -//============================================================================== - -PointCloud::PointCloud(pugi::xml_node node) -{ - if (check_for_node(node, "coords")) { - point_cloud_ = get_node_position_array(node, "coords"); - } else { - fatal_error("No coordinates were provided for the PointCloud " - "spatial distribution"); - } - - std::vector strengths; - - if (check_for_node(node, "strengths")) - strengths = get_node_array(node, "strengths"); - else - strengths.resize(point_cloud_.size(), 1.0); - - if (strengths.size() != point_cloud_.size()) { - fatal_error( - fmt::format("Number of entries for the strengths array {} does " - "not match the number of spatial points provided {}.", - strengths.size(), point_cloud_.size())); - } - - point_idx_dist_.assign(strengths); - - if (check_for_node(node, "bias")) { - pugi::xml_node bias_node = node.child("bias"); - - if (check_for_node(bias_node, "strengths")) { - std::vector bias_strengths(point_cloud_.size(), 1.0); - bias_strengths = get_node_array(node, "strengths"); - - if (bias_strengths.size() != point_cloud_.size()) { - fatal_error( - fmt::format("Number of entries in the bias strengths array {} does " - "not match the number of spatial points provided {}.", - bias_strengths.size(), point_cloud_.size())); - } - - // Compute importance weights - weight_ = compute_importance_weights(strengths, bias_strengths); - - // Re-initialize DiscreteIndex with bias strengths for sampling - point_idx_dist_.assign(bias_strengths); - } else { - fatal_error( - fmt::format("Bias node for PointCloud found without strengths array.")); - } - } -} - -PointCloud::PointCloud( - std::vector point_cloud, span strengths) -{ - point_cloud_.assign(point_cloud.begin(), point_cloud.end()); - point_idx_dist_.assign(strengths); -} - -std::pair PointCloud::sample(uint64_t* seed) const -{ - int32_t index = point_idx_dist_.sample(seed); - double wgt = weight_.empty() ? 1.0 : weight_[index]; - return {point_cloud_[index], wgt}; + return this->sample_mesh(seed).second; } //============================================================================== @@ -461,15 +315,10 @@ SpatialBox::SpatialBox(pugi::xml_node node, bool fission) upper_right_ = Position {params[3], params[4], params[5]}; } -SpatialBox::SpatialBox(Position lower_left, Position upper_right, bool fission) - : lower_left_(lower_left), upper_right_(upper_right), - only_fissionable_(fission) -{} - -std::pair SpatialBox::sample(uint64_t* seed) const +Position SpatialBox::sample(uint64_t* seed) const { Position xi {prn(seed), prn(seed), prn(seed)}; - return {lower_left_ + xi * (upper_right_ - lower_left_), 1.0}; + return lower_left_ + xi * (upper_right_ - lower_left_); } //============================================================================== @@ -488,9 +337,9 @@ SpatialPoint::SpatialPoint(pugi::xml_node node) r_ = Position {params.data()}; } -std::pair SpatialPoint::sample(uint64_t* seed) const +Position SpatialPoint::sample(uint64_t* seed) const { - return {r_, 1.0}; + return r_; } } // namespace openmc diff --git a/src/eigenvalue.cpp b/src/eigenvalue.cpp index bc8dcc9ea..d5410094b 100644 --- a/src/eigenvalue.cpp +++ b/src/eigenvalue.cpp @@ -1,6 +1,9 @@ #include "openmc/eigenvalue.h" -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xmath.hpp" +#include "xtensor/xtensor.hpp" +#include "xtensor/xview.hpp" #include "openmc/array.h" #include "openmc/bank.h" @@ -8,7 +11,6 @@ #include "openmc/constants.h" #include "openmc/error.h" #include "openmc/hdf5_interface.h" -#include "openmc/ifp.h" #include "openmc/math_functions.h" #include "openmc/mesh.h" #include "openmc/message_passing.h" @@ -36,7 +38,7 @@ namespace simulation { double keff_generation; array k_sum; vector entropy; -tensor::Tensor source_frac; +xt::xtensor source_frac; } // namespace simulation @@ -124,54 +126,54 @@ void synchronize_bank() "No fission sites banked on MPI rank " + std::to_string(mpi::rank)); } - simulation::time_bank_sample.start(); + // Make sure all processors start at the same point for random sampling. Then + // skip ahead in the sequence using the starting index in the 'global' + // fission bank for each processor. - // Allocate temporary source bank -- we don't really know how many fission - // sites were created, so overallocate by a factor of 3 - int64_t index_temp = 0; + int64_t id = simulation::total_gen + overall_generation(); + uint64_t seed = init_seed(id, STREAM_TRACKING); + advance_prn_seed(start, &seed); - vector temp_sites(3 * simulation::work_per_rank); + // Determine how many fission sites we need to sample from the source bank + // and the probability for selecting a site. - // Temporary banks for IFP - vector> temp_delayed_groups; - vector> temp_lifetimes; - if (settings::ifp_on) { - resize_ifp_data( - temp_delayed_groups, temp_lifetimes, 3 * simulation::work_per_rank); + int64_t sites_needed; + if (total < settings::n_particles) { + sites_needed = settings::n_particles % total; + } else { + sites_needed = settings::n_particles; } + double p_sample = static_cast(sites_needed) / total; + + simulation::time_bank_sample.start(); // ========================================================================== // SAMPLE N_PARTICLES FROM FISSION BANK AND PLACE IN TEMP_SITES - // We use Uniform Combing method to exactly get the targeted particle size - // [https://doi.org/10.1080/00295639.2022.2091906] + // Allocate temporary source bank -- we don't really know how many fission + // sites were created, so overallocate by a factor of 3 + int64_t index_temp = 0; + vector temp_sites(3 * simulation::work_per_rank); - // Make sure all processors use the same random number seed. - int64_t id = simulation::total_gen + overall_generation(); - uint64_t seed = init_seed(id, STREAM_TRACKING); + for (int64_t i = 0; i < simulation::fission_bank.size(); i++) { + const auto& site = simulation::fission_bank[i]; - // Comb specification - double teeth_distance = static_cast(total) / settings::n_particles; - double teeth_offset = prn(&seed) * teeth_distance; - - // First and last hitting tooth - int64_t end = start + simulation::fission_bank.size(); - int64_t tooth_start = std::ceil((start - teeth_offset) / teeth_distance); - int64_t tooth_end = std::floor((end - teeth_offset) / teeth_distance) + 1; - - // Locally comb particles in fission_bank - double tooth = tooth_start * teeth_distance + teeth_offset; - for (int64_t i = tooth_start; i < tooth_end; i++) { - int64_t idx = std::floor(tooth) - start; - temp_sites[index_temp] = simulation::fission_bank[idx]; - if (settings::ifp_on) { - copy_ifp_data_from_fission_banks( - idx, temp_delayed_groups[index_temp], temp_lifetimes[index_temp]); + // If there are less than n_particles particles banked, automatically add + // int(n_particles/total) sites to temp_sites. For example, if you need + // 1000 and 300 were banked, this would add 3 source sites per banked site + // and the remaining 100 would be randomly sampled. + if (total < settings::n_particles) { + for (int64_t j = 1; j <= settings::n_particles / total; ++j) { + temp_sites[index_temp] = site; + ++index_temp; + } } - ++index_temp; - // Next tooth - tooth += teeth_distance; + // Randomly sample sites needed + if (prn(&seed) < p_sample) { + temp_sites[index_temp] = site; + ++index_temp; + } } // At this point, the sampling of source sites is done and now we need to @@ -186,17 +188,40 @@ void synchronize_bank() MPI_Exscan(&index_temp, &start, 1, MPI_INT64_T, MPI_SUM, mpi::intracomm); finish = start + index_temp; - // TODO: protect for MPI_Exscan at rank 0 - // Allocate space for bank_position if this hasn't been done yet - std::vector bank_position(mpi::n_procs); - MPI_Allgather(&start, 1, MPI_INT64_T, bank_position.data(), 1, MPI_INT64_T, - mpi::intracomm); + int64_t bank_position[mpi::n_procs]; + MPI_Allgather( + &start, 1, MPI_INT64_T, bank_position, 1, MPI_INT64_T, mpi::intracomm); #else start = 0; finish = index_temp; #endif + // Now that the sampling is complete, we need to ensure that we have exactly + // n_particles source sites. The way this is done in a reproducible manner is + // to adjust only the source sites on the last processor. + + if (mpi::rank == mpi::n_procs - 1) { + if (finish > settings::n_particles) { + // If we have extra sites sampled, we will simply discard the extra + // ones on the last processor + index_temp = settings::n_particles - start; + + } else if (finish < settings::n_particles) { + // If we have too few sites, repeat sites from the very end of the + // fission bank + sites_needed = settings::n_particles - finish; + for (int i = 0; i < sites_needed; ++i) { + int i_bank = simulation::fission_bank.size() - sites_needed + i; + temp_sites[index_temp] = simulation::fission_bank[i_bank]; + ++index_temp; + } + } + + // the last processor should not be sending sites to right + finish = simulation::work_index[mpi::rank + 1]; + } + simulation::time_bank_sample.stop(); simulation::time_bank_sendrecv.start(); @@ -204,32 +229,15 @@ void synchronize_bank() // ========================================================================== // SEND BANK SITES TO NEIGHBORS - // IFP number of generation - int ifp_n_generation; - if (settings::ifp_on) { - broadcast_ifp_n_generation( - ifp_n_generation, temp_delayed_groups, temp_lifetimes); - } - int64_t index_local = 0; vector requests; - // IFP send buffers - vector send_delayed_groups; - vector send_lifetimes; - if (start < settings::n_particles) { // Determine the index of the processor which has the first part of the // source_bank for the local processor int neighbor = upper_bound_index( simulation::work_index.begin(), simulation::work_index.end(), start); - // Resize IFP send buffers - if (settings::ifp_on && mpi::n_procs > 1) { - resize_ifp_data(send_delayed_groups, send_lifetimes, - ifp_n_generation * 3 * simulation::work_per_rank); - } - while (start < finish) { // Determine the number of sites to send int64_t n = @@ -242,16 +250,6 @@ void synchronize_bank() MPI_Isend(&temp_sites[index_local], static_cast(n), mpi::source_site, neighbor, mpi::rank, mpi::intracomm, &requests.back()); - - if (settings::ifp_on) { - // Send IFP data - if (is_beta_effective_or_both()) - send_ifp_info(index_local, n, ifp_n_generation, neighbor, requests, - temp_delayed_groups, send_delayed_groups); - if (is_generation_time_or_both()) - send_ifp_info(index_local, n, ifp_n_generation, neighbor, requests, - temp_lifetimes, send_lifetimes); - } } // Increment all indices @@ -273,11 +271,6 @@ void synchronize_bank() start = simulation::work_index[mpi::rank]; index_local = 0; - // IFP receive buffers - vector recv_delayed_groups; - vector recv_lifetimes; - vector deserialization_info; - // Determine what process has the source sites that will need to be stored at // the beginning of this processor's source bank. @@ -286,13 +279,7 @@ void synchronize_bank() neighbor = mpi::n_procs - 1; } else { neighbor = - upper_bound_index(bank_position.begin(), bank_position.end(), start); - } - - // Resize IFP receive buffers - if (settings::ifp_on && mpi::n_procs > 1) { - resize_ifp_data(recv_delayed_groups, recv_lifetimes, - ifp_n_generation * simulation::work_per_rank); + upper_bound_index(bank_position, bank_position + mpi::n_procs, start); } while (start < simulation::work_index[mpi::rank + 1]) { @@ -314,28 +301,13 @@ void synchronize_bank() MPI_Irecv(&simulation::source_bank[index_local], static_cast(n), mpi::source_site, neighbor, neighbor, mpi::intracomm, &requests.back()); - if (settings::ifp_on) { - // Receive IFP data - if (is_beta_effective_or_both()) - receive_ifp_data(index_local, n, ifp_n_generation, neighbor, requests, - recv_delayed_groups, deserialization_info); - if (is_generation_time_or_both()) - receive_ifp_data(index_local, n, ifp_n_generation, neighbor, requests, - recv_lifetimes, deserialization_info); - } - } else { - // If the source sites are on this processor, we can simply copy them + // If the source sites are on this procesor, we can simply copy them // from the temp_sites bank index_temp = start - bank_position[mpi::rank]; std::copy(&temp_sites[index_temp], &temp_sites[index_temp + n], &simulation::source_bank[index_local]); - - if (settings::ifp_on) { - copy_partial_ifp_data_to_source_banks( - index_temp, n, index_local, temp_delayed_groups, temp_lifetimes); - } } // Increment all indices @@ -351,21 +323,9 @@ void synchronize_bank() int n_request = requests.size(); MPI_Waitall(n_request, requests.data(), MPI_STATUSES_IGNORE); - if (settings::ifp_on) { - if (is_beta_effective_or_both()) - deserialize_ifp_info(ifp_n_generation, recv_delayed_groups, - simulation::ifp_source_delayed_group_bank, deserialization_info); - if (is_generation_time_or_both()) - deserialize_ifp_info(ifp_n_generation, recv_lifetimes, - simulation::ifp_source_lifetime_bank, deserialization_info); - } - #else std::copy(temp_sites.data(), temp_sites.data() + settings::n_particles, simulation::source_bank.begin()); - if (settings::ifp_on) { - copy_complete_ifp_data_to_source_banks(temp_delayed_groups, temp_lifetimes); - } #endif simulation::time_bank_sendrecv.stop(); @@ -411,16 +371,6 @@ void calculate_average_keff() t_value * std::sqrt( (simulation::k_sum[1] / n - std::pow(simulation::keff, 2)) / (n - 1)); - - // In some cases (such as an infinite medium problem), random ray - // may estimate k exactly and in an unvarying manner between iterations. - // In this case, the floating point roundoff between the division and the - // power operations may cause an extremely small negative value to occur - // inside the sqrt operation, leading to NaN. If this occurs, we check for - // it and set the std dev to zero. - if (!std::isfinite(simulation::keff_std)) { - simulation::keff_std = 0.0; - } } } } @@ -449,7 +399,7 @@ int openmc_get_keff(double* k_combined) const auto& gt = simulation::global_tallies; array kv {}; - tensor::Tensor cov = tensor::zeros({3, 3}); + xt::xtensor cov = xt::zeros({3, 3}); kv[0] = gt(GlobalTally::K_COLLISION, TallyResult::SUM) / n; kv[1] = gt(GlobalTally::K_ABSORPTION, TallyResult::SUM) / n; kv[2] = gt(GlobalTally::K_TRACKLENGTH, TallyResult::SUM) / n; @@ -588,7 +538,7 @@ void shannon_entropy() { // Get source weight in each mesh bin bool sites_outside; - tensor::Tensor p = + xt::xtensor p = simulation::entropy_mesh->count_sites(simulation::fission_bank.data(), simulation::fission_bank.size(), &sites_outside); @@ -600,13 +550,13 @@ void shannon_entropy() if (mpi::master) { // Normalize to total weight of bank sites - p /= p.sum(); + p /= xt::sum(p); // Sum values to obtain Shannon entropy double H = 0.0; for (auto p_i : p) { if (p_i > 0.0) { - H -= p_i * std::log2(p_i); + H -= p_i * std::log(p_i) / std::log(2.0); } } @@ -624,7 +574,7 @@ void ufs_count_sites() std::size_t n = simulation::ufs_mesh->n_bins(); double vol_frac = simulation::ufs_mesh->volume_frac_; - simulation::source_frac = tensor::Tensor({n}, vol_frac); + simulation::source_frac = xt::xtensor({n}, vol_frac); } else { // count number of source sites in each ufs mesh cell @@ -646,7 +596,7 @@ void ufs_count_sites() #endif // Normalize to total weight to get fraction of source in each cell - double total = simulation::source_frac.sum(); + double total = xt::sum(simulation::source_frac)(); simulation::source_frac /= total; // Since the total starting weight is not equal to n_particles, we need to diff --git a/src/endf.cpp b/src/endf.cpp index 8a9c5e48a..c0c1d2e7e 100644 --- a/src/endf.cpp +++ b/src/endf.cpp @@ -5,7 +5,8 @@ #include // for back_inserter #include // for runtime_error -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" +#include "xtensor/xview.hpp" #include "openmc/array.h" #include "openmc/constants.h" @@ -87,83 +88,6 @@ bool is_inelastic_scatter(int mt) } } -bool mt_matches(int event_mt, int target_mt) -{ - // Direct match - if (event_mt == target_mt) - return true; - - // Check if event_mt is a component of target_mt summation reaction - switch (target_mt) { - case TOTAL_XS: - return event_mt == ELASTIC || mt_matches(event_mt, N_NONELASTIC); - - case N_NONELASTIC: { - static constexpr int components[] = {4, 5, 11, 16, 17, 22, 23, 24, 25, 27, - 28, 29, 30, 32, 33, 34, 35, 36, 37, 41, 42, 44, 45, 152, 153, 154, 156, - 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, - 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, - 188, 189, 190, 194, 195, 196, 198, 199, 200}; - for (int mt : components) { - if (mt_matches(event_mt, mt)) - return true; - } - return false; - } - - case N_LEVEL: - // Inelastic scattering levels - return event_mt >= 50 && event_mt <= N_NC; - - case N_2N: - // (n,2n) to excited states - return event_mt >= N_2N0 && event_mt <= N_2NC; - - case N_FISSION: - return is_fission(event_mt); - - case 27: - return is_fission(event_mt) || is_disappearance(event_mt); - - case N_DISAPPEAR: { - return is_disappearance(event_mt); - } - - case N_P: - // (n,p) to excited states - return event_mt >= N_P0 && event_mt <= N_PC; - - case N_D: - // (n,d) to excited states - return event_mt >= N_D0 && event_mt <= N_DC; - - case N_T: - // (n,t) to excited states - return event_mt >= N_T0 && event_mt <= N_TC; - - case N_3HE: - // (n,3He) to excited states - return event_mt >= N_3HE0 && event_mt <= N_3HEC; - - case N_A: - // (n,alpha) to excited states - return event_mt >= N_A0 && event_mt <= N_AC; - - case 501: - return event_mt == 502 || event_mt == 504 || mt_matches(event_mt, 516) || - mt_matches(event_mt, 522); - - case PAIR_PROD: - return event_mt == PAIR_PROD_ELEC || event_mt == PAIR_PROD_NUC; - - case PHOTOELECTRIC: - return event_mt >= 534 && event_mt < 573; - - default: - return false; - } -} - unique_ptr read_function(hid_t group, const char* name) { hid_t obj_id = open_object(group, name); @@ -229,11 +153,11 @@ Tabulated1D::Tabulated1D(hid_t dset) for (const auto i : int_temp) int_.push_back(int2interp(i)); - tensor::Tensor arr; + xt::xarray arr; read_dataset(dset, arr); - tensor::View xs = arr.slice(0); - tensor::View ys = arr.slice(1); + auto xs = xt::view(arr, 0); + auto ys = xt::view(arr, 1); std::copy(xs.begin(), xs.end(), std::back_inserter(x_)); std::copy(ys.begin(), ys.end(), std::back_inserter(y_)); @@ -305,12 +229,12 @@ double Tabulated1D::operator()(double x) const CoherentElasticXS::CoherentElasticXS(hid_t dset) { // Read 2D array from dataset - tensor::Tensor arr; + xt::xarray arr; read_dataset(dset, arr); // Get views for Bragg edges and structure factors - tensor::View E = arr.slice(0); - tensor::View s = arr.slice(1); + auto E = xt::view(arr, 0); + auto s = xt::view(arr, 1); // Copy Bragg edges and partial sums of structure factors std::copy(E.begin(), E.end(), std::back_inserter(bragg_edges_)); diff --git a/src/error.cpp b/src/error.cpp index f99f5935f..566950a97 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -110,26 +110,23 @@ void write_message(const std::string& message, int level) void fatal_error(const std::string& message, int err) { -#pragma omp critical(FatalError) - { #ifdef _POSIX_VERSION - // Make output red if user is in a terminal - if (isatty(STDERR_FILENO)) { - std::cerr << "\033[0;31m"; - } -#endif - - // Write error message - std::cerr << " ERROR: "; - output(message, std::cerr, 8); - -#ifdef _POSIX_VERSION - // Reset color for terminal - if (isatty(STDERR_FILENO)) { - std::cerr << "\033[0m"; - } -#endif + // Make output red if user is in a terminal + if (isatty(STDERR_FILENO)) { + std::cerr << "\033[0;31m"; } +#endif + + // Write error message + std::cerr << " ERROR: "; + output(message, std::cerr, 8); + +#ifdef _POSIX_VERSION + // Reset color for terminal + if (isatty(STDERR_FILENO)) { + std::cerr << "\033[0m"; + } +#endif #ifdef OPENMC_MPI MPI_Abort(mpi::intracomm, err); diff --git a/src/event.cpp b/src/event.cpp index 2d436bb9d..ae914c8be 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -1,9 +1,5 @@ #include "openmc/event.h" - -#include "openmc/bank.h" -#include "openmc/error.h" #include "openmc/material.h" -#include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/timer.h" @@ -67,8 +63,7 @@ void process_init_events(int64_t n_particles, int64_t source_offset) simulation::time_event_init.start(); #pragma omp parallel for schedule(runtime) for (int64_t i = 0; i < n_particles; i++) { - initialize_particle_track( - simulation::particles[i], source_offset + i + 1, false); + initialize_history(simulation::particles[i], source_offset + i + 1); dispatch_xs_event(i); } simulation::time_event_init.stop(); @@ -78,17 +73,17 @@ void process_calculate_xs_events(SharedArray& queue) { simulation::time_event_calculate_xs.start(); - // TODO: If using C++17, we could perform a parallel sort of the queue by - // particle type, material type, and then energy, in order to improve cache - // locality and reduce thread divergence on GPU. However, the parallel - // algorithms typically require linking against an additional library (Intel - // TBB). Prior to C++17, std::sort is a serial only operation, which in this - // case makes it too slow to be practical for most test problems. + // TODO: If using C++17, perform a parallel sort of the queue + // by particle type, material type, and then energy, in order to + // improve cache locality and reduce thread divergence on GPU. Prior + // to C++17, std::sort is a serial only operation, which in this case + // makes it too slow to be practical for most test problems. // // std::sort(std::execution::par_unseq, queue.data(), queue.data() + // queue.size()); int64_t offset = simulation::advance_particle_queue.size(); + ; #pragma omp parallel for schedule(runtime) for (int64_t i = 0; i < queue.size(); i++) { @@ -119,7 +114,7 @@ void process_advance_particle_events() p.event_advance(); if (!p.alive()) continue; - if (p.collision_distance() > p.boundary().distance()) { + if (p.collision_distance() > p.boundary().distance) { simulation::surface_crossing_queue.thread_safe_append({p, buffer_idx}); } else { simulation::collision_queue.thread_safe_append({p, buffer_idx}); @@ -140,7 +135,7 @@ void process_surface_crossing_events() int64_t buffer_idx = simulation::surface_crossing_queue[i].idx; Particle& p = simulation::particles[buffer_idx]; p.event_cross_surface(); - p.event_check_limit_and_revive(); + p.event_revive_from_secondary(); if (p.alive()) dispatch_xs_event(buffer_idx); } @@ -159,7 +154,7 @@ void process_collision_events() int64_t buffer_idx = simulation::collision_queue[i].idx; Particle& p = simulation::particles[buffer_idx]; p.event_collide(); - p.event_check_limit_and_revive(); + p.event_revive_from_secondary(); if (p.alive()) dispatch_xs_event(buffer_idx); } @@ -180,45 +175,4 @@ void process_death_events(int64_t n_particles) simulation::time_event_death.stop(); } -void process_transport_events() -{ - while (true) { - int64_t max = std::max({simulation::calculate_fuel_xs_queue.size(), - simulation::calculate_nonfuel_xs_queue.size(), - simulation::advance_particle_queue.size(), - simulation::surface_crossing_queue.size(), - simulation::collision_queue.size()}); - - if (max == 0) { - break; - } else if (max == simulation::calculate_fuel_xs_queue.size()) { - process_calculate_xs_events(simulation::calculate_fuel_xs_queue); - } else if (max == simulation::calculate_nonfuel_xs_queue.size()) { - process_calculate_xs_events(simulation::calculate_nonfuel_xs_queue); - } else if (max == simulation::advance_particle_queue.size()) { - process_advance_particle_events(); - } else if (max == simulation::surface_crossing_queue.size()) { - process_surface_crossing_events(); - } else if (max == simulation::collision_queue.size()) { - process_collision_events(); - } - } -} - -void process_init_secondary_events(int64_t n_particles, int64_t offset, - const SharedArray& shared_secondary_bank) -{ - simulation::time_event_init.start(); -#pragma omp parallel for schedule(runtime) - for (int64_t i = 0; i < n_particles; i++) { - initialize_particle_track(simulation::particles[i], offset + i + 1, true); - const SourceSite& site = shared_secondary_bank[offset + i]; - simulation::particles[i].event_revive_from_secondary(site); - if (simulation::particles[i].alive()) { - dispatch_xs_event(i); - } - } - simulation::time_event_init.stop(); -} - } // namespace openmc diff --git a/src/external/quartic_solver.cpp b/src/external/quartic_solver.cpp index 71bdb25c3..0b280e83c 100644 --- a/src/external/quartic_solver.cpp +++ b/src/external/quartic_solver.cpp @@ -1,4 +1,3 @@ -#define _USE_MATH_DEFINES // to make M_PI declared in Intel and MSVC compilers #include #include #include diff --git a/src/file_utils.cpp b/src/file_utils.cpp index 517f82d15..197c9767c 100644 --- a/src/file_utils.cpp +++ b/src/file_utils.cpp @@ -1,42 +1,65 @@ #include "openmc/file_utils.h" -#include +#include // any_of +#include // for isalpha +#include // for ifstream +#include namespace openmc { bool dir_exists(const std::string& path) { - std::filesystem::path d(path); - return std::filesystem::is_directory(d); + struct stat s; + if (stat(path.c_str(), &s) != 0) + return false; + + return s.st_mode & S_IFDIR; } bool file_exists(const std::string& filename) { - std::filesystem::path p(filename); - if (!std::filesystem::exists(p)) { + // rule out file being a path to a directory + if (dir_exists(filename)) return false; - } - if (std::filesystem::is_directory(p)) { - return false; - } - return true; + + std::ifstream s {filename}; + return s.good(); } std::string dir_name(const std::string& filename) { - std::filesystem::path p(filename); - return (p.parent_path()).string(); + size_t pos = filename.find_last_of("\\/"); + return (std::string::npos == pos) ? "" : filename.substr(0, pos + 1); } std::string get_file_extension(const std::string& filename) { - std::filesystem::path p(filename); - auto ext = p.extension(); - if (!ext.empty()) { - // path::extension includes the period - return ext.string().substr(1); - } - return ""; + // try our best to work on windows... +#if defined(_WIN32) || defined(_WIN64) + const char sep_char = '\\'; +#else + const char sep_char = '/'; +#endif + + // check that at least one letter is present + const auto last_period_pos = filename.find_last_of('.'); + const auto last_sep_pos = filename.find_last_of(sep_char); + + // no file extension. In the first case, we are only given + // a file name. In the second, we have been given a file path. + // If that's the case, periods are allowed in directory names, + // but have the interpretation as preceding a file extension + // after the last separator. + if (last_period_pos == std::string::npos || + (last_sep_pos < std::string::npos && last_period_pos < last_sep_pos)) + return ""; + + const std::string ending = filename.substr(last_period_pos + 1); + + // check that at least one character is present. + const bool has_alpha = std::any_of(ending.begin(), ending.end(), + [](char x) { return static_cast(std::isalpha(x)); }); + return has_alpha ? ending : ""; } } // namespace openmc diff --git a/src/finalize.cpp b/src/finalize.cpp index fd891d9dd..2bde0e338 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -2,9 +2,7 @@ #include "openmc/bank.h" #include "openmc/capi.h" -#include "openmc/chain.h" #include "openmc/cmfd_solver.h" -#include "openmc/collision_track.h" #include "openmc/constants.h" #include "openmc/cross_sections.h" #include "openmc/dagmc.h" @@ -15,12 +13,10 @@ #include "openmc/material.h" #include "openmc/mesh.h" #include "openmc/message_passing.h" -#include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" #include "openmc/photon.h" #include "openmc/plot.h" #include "openmc/random_lcg.h" -#include "openmc/random_ray/random_ray_simulation.h" #include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/source.h" @@ -31,7 +27,7 @@ #include "openmc/volume_calc.h" #include "openmc/weight_windows.h" -#include "openmc/tensor.h" +#include "xtensor/xview.hpp" namespace openmc { @@ -45,7 +41,6 @@ void free_memory() free_memory_photon(); free_memory_settings(); free_memory_thermal(); - free_memory_chain(); library_clear(); nuclides_clear(); free_memory_source(); @@ -80,7 +75,6 @@ int openmc_finalize() // Reset global variables settings::assume_separate = false; settings::check_overlaps = false; - settings::collision_track_config = CollisionTrackConfig {}; settings::confidence_intervals = false; settings::create_fission_neutrons = true; settings::create_delayed_neutrons = true; @@ -90,7 +84,6 @@ int openmc_finalize() settings::time_cutoff = {INFTY, INFTY, INFTY, INFTY}; settings::entropy_on = false; settings::event_based = false; - settings::free_gas_threshold = 400.0; settings::gen_per_batch = 1; settings::legendre_to_tabular = true; settings::legendre_to_tabular_points = -1; @@ -98,7 +91,6 @@ int openmc_finalize() settings::max_lost_particles = 10; settings::max_order = 0; settings::max_particles_in_flight = 100000; - settings::max_secondaries = 10000; settings::max_particle_events = 1'000'000; settings::max_history_splits = 10'000'000; settings::max_tracks = 1000; @@ -125,33 +117,21 @@ int openmc_finalize() settings::restart_run = false; settings::run_CE = true; settings::run_mode = RunMode::UNSET; - settings::surface_grazing_cutoff = 0.001; - settings::surface_grazing_ratio = 0.5; - settings::solver_type = SolverType::MONTE_CARLO; settings::source_latest = false; - settings::source_rejection_fraction = 0.05; settings::source_separate = false; settings::source_write = true; - settings::ssw_cell_id = C_NONE; - settings::ssw_cell_type = SSWCellType::None; - settings::ssw_max_particles = 0; - settings::ssw_max_files = 1; settings::survival_biasing = false; settings::temperature_default = 293.6; settings::temperature_method = TemperatureMethod::NEAREST; settings::temperature_multipole = false; settings::temperature_range = {0.0, 0.0}; settings::temperature_tolerance = 10.0; - settings::properties_file.clear(); settings::trigger_on = false; settings::trigger_predict = false; settings::trigger_batch_interval = 1; - settings::uniform_source_sampling = false; settings::ufs_on = false; settings::urr_ptables_on = true; - settings::use_decay_photons = false; - settings::use_shared_secondary_bank = false; - settings::verbosity = -1; + settings::verbosity = 7; settings::weight_cutoff = 0.25; settings::weight_survive = 1.0; settings::weight_windows_file.clear(); @@ -161,47 +141,39 @@ int openmc_finalize() simulation::keff = 1.0; simulation::need_depletion_rx = false; - simulation::ssw_current_file = 1; simulation::total_gen = 0; simulation::entropy_mesh = nullptr; simulation::ufs_mesh = nullptr; - data::energy_max = {INFTY, INFTY, INFTY, INFTY}; - data::energy_min = {0.0, 0.0, 0.0, 0.0}; + data::energy_max = {INFTY, INFTY}; + data::energy_min = {0.0, 0.0}; data::temperature_min = 0.0; data::temperature_max = INFTY; - data::mg = {}; model::root_universe = -1; model::plotter_seed = 1; openmc::openmc_set_seed(DEFAULT_SEED); - openmc::openmc_set_stride(DEFAULT_STRIDE); // Deallocate arrays free_memory(); -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH settings::libmesh_init.reset(); #endif // Free all MPI types #ifdef OPENMC_MPI - if (mpi::source_site != MPI_DATATYPE_NULL) { + if (mpi::source_site != MPI_DATATYPE_NULL) MPI_Type_free(&mpi::source_site); - } - if (mpi::collision_track_site != MPI_DATATYPE_NULL) { - MPI_Type_free(&mpi::collision_track_site); - } #endif - openmc_finalize_random_ray(); - return 0; } int openmc_reset() { + model::universe_cell_counts.clear(); model::universe_level_counts.clear(); for (auto& t : model::tallies) { @@ -210,7 +182,7 @@ int openmc_reset() // Reset global tallies simulation::n_realizations = 0; - simulation::global_tallies.fill(0.0); + xt::view(simulation::global_tallies, xt::all()) = 0.0; simulation::k_col_abs = 0.0; simulation::k_col_tra = 0.0; @@ -221,7 +193,6 @@ int openmc_reset() settings::cmfd_run = false; simulation::n_lost_particles = 0; - simulation::simulation_tracks_completed = 0; return 0; } @@ -244,6 +215,5 @@ int openmc_hard_reset() // Reset the random number generator state openmc::openmc_set_seed(DEFAULT_SEED); - openmc::openmc_set_stride(DEFAULT_STRIDE); return 0; } diff --git a/src/geometry.cpp b/src/geometry.cpp index bf654f4f9..445b19faa 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -26,64 +26,39 @@ int n_coord_levels; vector overlap_check_count; -vector overlap_keys; -std::unordered_map overlap_key_index; - } // namespace model //============================================================================== // Non-member functions //============================================================================== -int check_cell_overlap(GeometryState& p, bool error) +bool check_cell_overlap(GeometryState& p, bool error) { int n_coord = p.n_coord(); - // If no overlap found, return a nonphysical index - int overlap_index = -1; - // Loop through each coordinate level for (int j = 0; j < n_coord; j++) { - Universe& univ = *model::universes[p.coord(j).universe()]; + Universe& univ = *model::universes[p.coord(j).universe]; // Loop through each cell on this level for (auto index_cell : univ.cells_) { Cell& c = *model::cells[index_cell]; - if (c.contains(p.coord(j).r(), p.coord(j).u(), p.surface())) { -#pragma omp atomic - ++model::overlap_check_count[index_cell]; - if (index_cell != p.coord(j).cell()) { + if (c.contains(p.coord(j).r, p.coord(j).u, p.surface())) { + if (index_cell != p.coord(j).cell) { if (error) { fatal_error( fmt::format("Overlapping cells detected: {}, {} on universe {}", - c.id_, model::cells[p.coord(j).cell()]->id_, univ.id_)); + c.id_, model::cells[p.coord(j).cell]->id_, univ.id_)); } - - // With no fatal error (plotter is calling), now adds overlaps and - // ensures order does not matter when making overlap key - int cell_a = model::cells[index_cell]->id_; - int cell_b = model::cells[p.coord(j).cell()]->id_; - int a = std::min(cell_a, cell_b); - int b = std::max(cell_a, cell_b); - OverlapKey key {univ.id_, a, b}; -#pragma omp critical(overlap_key_update) - { - auto it = model::overlap_key_index.find(key); - if (it != model::overlap_key_index.end()) { - overlap_index = it->second; // already exists, reuse index - } else { - int idx = int(model::overlap_keys.size()); - model::overlap_keys.push_back(key); - model::overlap_key_index[key] = idx; - overlap_index = idx; - } - } - break; + return true; } +#pragma omp atomic + ++model::overlap_check_count[index_cell]; } } } - return overlap_index; + + return false; } //============================================================================== @@ -98,7 +73,7 @@ int cell_instance_at_level(const GeometryState& p, int level) } // determine the cell instance - Cell& c {*model::cells[p.coord(level).cell()]}; + Cell& c {*model::cells[p.coord(level).cell]}; // quick exit if this cell doesn't have distribcell instances if (c.distribcell_index_ == C_NONE) @@ -107,13 +82,13 @@ int cell_instance_at_level(const GeometryState& p, int level) // compute the cell's instance int instance = 0; for (int i = 0; i < level; i++) { - const auto& c_i {*model::cells[p.coord(i).cell()]}; + const auto& c_i {*model::cells[p.coord(i).cell]}; if (c_i.type_ == Fill::UNIVERSE) { instance += c_i.offset_[c.distribcell_index_]; } else if (c_i.type_ == Fill::LATTICE) { instance += c_i.offset_[c.distribcell_index_]; - auto& lat {*model::lattices[p.coord(i + 1).lattice()]}; - const auto& i_xyz {p.coord(i + 1).lattice_index()}; + auto& lat {*model::lattices[p.coord(i + 1).lattice]}; + const auto& i_xyz {p.coord(i + 1).lattice_i}; if (lat.are_valid_indices(i_xyz)) { instance += lat.offset(c.distribcell_index_, i_xyz); } @@ -136,7 +111,7 @@ bool find_cell_inner( i_cell = *it; // Make sure the search cell is in the same universe. - int i_universe = p.lowest_coord().universe(); + int i_universe = p.lowest_coord().universe; if (model::cells[i_cell]->universe_ != i_universe) continue; @@ -145,7 +120,7 @@ bool find_cell_inner( Direction u {p.u_local()}; auto surf = p.surface(); if (model::cells[i_cell]->contains(r, u, surf)) { - p.lowest_coord().cell() = i_cell; + p.lowest_coord().cell = i_cell; found = true; break; } @@ -171,7 +146,7 @@ bool find_cell_inner( // code below this conditional, we set i_cell back to C_NONE to indicate // that. if (i_cell == C_NONE) { - int i_universe = p.lowest_coord().universe(); + int i_universe = p.lowest_coord().universe; const auto& univ {model::universes[i_universe]}; found = univ->find_cell(p); } @@ -179,7 +154,7 @@ bool find_cell_inner( if (!found) { return found; } - i_cell = p.lowest_coord().cell(); + i_cell = p.lowest_coord().cell; // Announce the cell that the particle is entering. if (found && verbose) { @@ -197,13 +172,11 @@ bool find_cell_inner( p.cell_instance() = cell_instance_at_level(p, p.n_coord() - 1); } - // Set the material, temperature and density multiplier. + // Set the material and temperature. p.material_last() = p.material(); p.material() = c.material(p.cell_instance()); p.sqrtkT_last() = p.sqrtkT(); p.sqrtkT() = c.sqrtkT(p.cell_instance()); - p.density_mult_last() = p.density_mult(); - p.density_mult() = c.density_mult(p.cell_instance()); return true; @@ -213,14 +186,14 @@ bool find_cell_inner( // Set the lower coordinate level universe. auto& coord {p.coord(p.n_coord())}; - coord.universe() = c.fill_; + coord.universe = c.fill_; // Set the position and direction. - coord.r() = p.r_local(); - coord.u() = p.u_local(); + coord.r = p.r_local(); + coord.u = p.u_local(); // Apply translation. - coord.r() -= c.translation_; + coord.r -= c.translation_; // Apply rotation. if (!c.rotation_.empty()) { @@ -235,11 +208,11 @@ bool find_cell_inner( // Set the position and direction. auto& coord {p.coord(p.n_coord())}; - coord.r() = p.r_local(); - coord.u() = p.u_local(); + coord.r = p.r_local(); + coord.u = p.u_local(); // Apply translation. - coord.r() -= c.translation_; + coord.r -= c.translation_; // Apply rotation. if (!c.rotation_.empty()) { @@ -247,21 +220,21 @@ bool find_cell_inner( } // Determine lattice indices. - auto& i_xyz {coord.lattice_index()}; - lat.get_indices(coord.r(), coord.u(), i_xyz); + auto& i_xyz {coord.lattice_i}; + lat.get_indices(coord.r, coord.u, i_xyz); // Get local position in appropriate lattice cell - coord.r() = lat.get_local_position(coord.r(), i_xyz); + coord.r = lat.get_local_position(coord.r, i_xyz); // Set lattice indices. - coord.lattice() = c.fill_; + coord.lattice = c.fill_; // Set the lower coordinate level universe. if (lat.are_valid_indices(i_xyz)) { - coord.universe() = lat[i_xyz]; + coord.universe = lat[i_xyz]; } else { if (lat.outer_ != NO_OUTER_UNIVERSE) { - coord.universe() = lat.outer_; + coord.universe = lat.outer_; } else { p.mark_as_lost(fmt::format( "Particle {} left lattice {}, but it has no outer definition.", @@ -288,7 +261,7 @@ bool neighbor_list_find_cell(GeometryState& p, bool verbose) // Get the cell this particle was in previously. auto coord_lvl = p.n_coord() - 1; - auto i_cell = p.coord(coord_lvl).cell(); + auto i_cell = p.coord(coord_lvl).cell; Cell& c {*model::cells[i_cell]}; // Search for the particle in that cell's neighbor list. Return if we @@ -302,15 +275,15 @@ bool neighbor_list_find_cell(GeometryState& p, bool verbose) // neighboring cell. found = find_cell_inner(p, nullptr, verbose); if (found) - c.neighbors_.push_back(p.coord(coord_lvl).cell()); + c.neighbors_.push_back(p.coord(coord_lvl).cell); return found; } bool exhaustive_find_cell(GeometryState& p, bool verbose) { - int i_universe = p.lowest_coord().universe(); + int i_universe = p.lowest_coord().universe; if (i_universe == C_NONE) { - p.coord(0).universe() = model::root_universe; + p.coord(0).universe = model::root_universe; p.n_coord() = 1; i_universe = model::root_universe; } @@ -326,32 +299,32 @@ bool exhaustive_find_cell(GeometryState& p, bool verbose) void cross_lattice(GeometryState& p, const BoundaryInfo& boundary, bool verbose) { auto& coord {p.lowest_coord()}; - auto& lat {*model::lattices[coord.lattice()]}; + auto& lat {*model::lattices[coord.lattice]}; if (verbose) { write_message( fmt::format(" Crossing lattice {}. Current position ({},{},{}). r={}", - lat.id_, coord.lattice_index()[0], coord.lattice_index()[1], - coord.lattice_index()[2], p.r()), + lat.id_, coord.lattice_i[0], coord.lattice_i[1], coord.lattice_i[2], + p.r()), 1); } // Set the lattice indices. - coord.lattice_index()[0] += boundary.lattice_translation()[0]; - coord.lattice_index()[1] += boundary.lattice_translation()[1]; - coord.lattice_index()[2] += boundary.lattice_translation()[2]; + coord.lattice_i[0] += boundary.lattice_translation[0]; + coord.lattice_i[1] += boundary.lattice_translation[1]; + coord.lattice_i[2] += boundary.lattice_translation[2]; // Set the new coordinate position. const auto& upper_coord {p.coord(p.n_coord() - 2)}; - const auto& cell {model::cells[upper_coord.cell()]}; - Position r = upper_coord.r(); + const auto& cell {model::cells[upper_coord.cell]}; + Position r = upper_coord.r; r -= cell->translation_; if (!cell->rotation_.empty()) { r = r.rotate(cell->rotation_); } - p.r_local() = lat.get_local_position(r, coord.lattice_index()); + p.r_local() = lat.get_local_position(r, coord.lattice_i); - if (!lat.are_valid_indices(coord.lattice_index())) { + if (!lat.are_valid_indices(coord.lattice_i)) { // The particle is outside the lattice. Search for it from the base coords. p.n_coord() = 1; bool found = exhaustive_find_cell(p); @@ -364,7 +337,7 @@ void cross_lattice(GeometryState& p, const BoundaryInfo& boundary, bool verbose) } else { // Find cell in next lattice element. - p.lowest_coord().universe() = lat[coord.lattice_index()]; + p.lowest_coord().universe = lat[coord.lattice_i]; bool found = exhaustive_find_cell(p); if (!found) { @@ -394,9 +367,9 @@ BoundaryInfo distance_to_boundary(GeometryState& p) // Loop over each coordinate level. for (int i = 0; i < p.n_coord(); i++) { const auto& coord {p.coord(i)}; - const Position& r {coord.r()}; - const Direction& u {coord.u()}; - Cell& c {*model::cells[coord.cell()]}; + const Position& r {coord.r}; + const Direction& u {coord.u}; + Cell& c {*model::cells[coord.cell]}; // Find the oncoming surface in this cell and the distance to it. auto surface_distance = c.distance(r, u, p.surface(), &p); @@ -404,24 +377,24 @@ BoundaryInfo distance_to_boundary(GeometryState& p) level_surf_cross = surface_distance.second; // Find the distance to the next lattice tile crossing. - if (coord.lattice() != C_NONE) { - auto& lat {*model::lattices[coord.lattice()]}; + if (coord.lattice != C_NONE) { + auto& lat {*model::lattices[coord.lattice]}; // TODO: refactor so both lattice use the same position argument (which // also means the lat.type attribute can be removed) std::pair> lattice_distance; switch (lat.type_) { case LatticeType::rect: - lattice_distance = lat.distance(r, u, coord.lattice_index()); + lattice_distance = lat.distance(r, u, coord.lattice_i); break; case LatticeType::hex: - auto& cell_above {model::cells[p.coord(i - 1).cell()]}; - Position r_hex {p.coord(i - 1).r()}; + auto& cell_above {model::cells[p.coord(i - 1).cell]}; + Position r_hex {p.coord(i - 1).r}; r_hex -= cell_above->translation_; - if (coord.rotated()) { + if (coord.rotated) { r_hex = r_hex.rotate(cell_above->rotation_); } - r_hex.z = coord.r().z; - lattice_distance = lat.distance(r_hex, u, coord.lattice_index()); + r_hex.z = coord.r.z; + lattice_distance = lat.distance(r_hex, u, coord.lattice_i); break; } d_lat = lattice_distance.first; @@ -437,7 +410,7 @@ BoundaryInfo distance_to_boundary(GeometryState& p) // If the boundary on this coordinate level is coincident with a boundary on // a higher level then we need to make sure that the higher level boundary // is selected. This logic must consider floating point precision. - double& d = info.distance(); + double& d = info.distance; if (d_surf < d_lat - FP_COINCIDENT) { if (d == INFINITY || (d - d_surf) / d >= FP_REL_PRECISION) { // Update closest distance @@ -448,29 +421,29 @@ BoundaryInfo distance_to_boundary(GeometryState& p) // have to explicitly check which half-space the particle would be // traveling into if the surface is crossed if (c.is_simple() || d == INFTY) { - info.surface() = level_surf_cross; + info.surface_index = level_surf_cross; } else { Position r_hit = r + d_surf * u; Surface& surf {*model::surfaces[std::abs(level_surf_cross) - 1]}; Direction norm = surf.normal(r_hit); if (u.dot(norm) > 0) { - info.surface() = std::abs(level_surf_cross); + info.surface_index = std::abs(level_surf_cross); } else { - info.surface() = -std::abs(level_surf_cross); + info.surface_index = -std::abs(level_surf_cross); } } - info.lattice_translation()[0] = 0; - info.lattice_translation()[1] = 0; - info.lattice_translation()[2] = 0; - info.coord_level() = i + 1; + info.lattice_translation[0] = 0; + info.lattice_translation[1] = 0; + info.lattice_translation[2] = 0; + info.coord_level = i + 1; } } else { if (d == INFINITY || (d - d_lat) / d >= FP_REL_PRECISION) { d = d_lat; - info.surface() = SURFACE_NONE; - info.lattice_translation() = level_lat_trans; - info.coord_level() = i + 1; + info.surface_index = 0; + info.lattice_translation = level_lat_trans; + info.coord_level = i + 1; } } } @@ -495,7 +468,7 @@ extern "C" int openmc_find_cell( return OPENMC_E_GEOMETRY; } - *index = geom_state.lowest_coord().cell(); + *index = geom_state.lowest_coord().cell; *instance = geom_state.cell_instance(); return 0; } @@ -505,14 +478,14 @@ extern "C" int openmc_global_bounding_box(double* llc, double* urc) auto bbox = model::universes.at(model::root_universe)->bounding_box(); // set lower left corner values - llc[0] = bbox.min.x; - llc[1] = bbox.min.y; - llc[2] = bbox.min.z; + llc[0] = bbox.xmin; + llc[1] = bbox.ymin; + llc[2] = bbox.zmin; // set upper right corner values - urc[0] = bbox.max.x; - urc[1] = bbox.max.y; - urc[2] = bbox.max.z; + urc[0] = bbox.xmax; + urc[1] = bbox.ymax; + urc[2] = bbox.zmax; return 0; } diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index a740740c1..050d4db96 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -25,9 +25,21 @@ namespace openmc { namespace model { +std::unordered_map> + universe_cell_counts; std::unordered_map universe_level_counts; } // namespace model +// adds the cell counts of universe b to universe a +void update_universe_cell_count(int32_t a, int32_t b) +{ + auto& universe_a_counts = model::universe_cell_counts[a]; + const auto& universe_b_counts = model::universe_cell_counts[b]; + for (const auto& it : universe_b_counts) { + universe_a_counts[it.first] += it.second; + } +} + void read_geometry_xml() { // Display output message @@ -55,13 +67,8 @@ void read_geometry_xml() void read_geometry_xml(pugi::xml_node root) { // Read surfaces, cells, lattice - std::set> periodic_pairs; - std::unordered_map albedo_map; - std::unordered_map periodic_sense_map; - - read_surfaces(root, periodic_pairs, albedo_map, periodic_sense_map); + read_surfaces(root); read_cells(root); - prepare_boundary_conditions(periodic_pairs, albedo_map, periodic_sense_map); read_lattices(root); // Check to make sure a boundary condition was applied to at least one @@ -200,24 +207,6 @@ void assign_temperatures() //============================================================================== -void finalize_cell_densities() -{ - for (auto& c : model::cells) { - // Convert to density multipliers. - if (!c->density_mult_.empty()) { - for (int32_t instance = 0; instance < c->density_mult_.size(); - ++instance) { - c->density_mult_[instance] /= - model::materials[c->material(instance)]->density_gpcc(); - } - } else { - c->density_mult_ = {1.0}; - } - } -} - -//============================================================================== - void get_temperatures( vector>& nuc_temps, vector>& thermal_temps) { @@ -274,7 +263,7 @@ void finalize_geometry() { // Perform some final operations to set up the geometry adjust_indices(); - count_universe_instances(); + count_cell_instances(model::root_universe); partition_universes(); // Assign temperatures to cells that don't have temperatures already assigned @@ -355,7 +344,7 @@ void prepare_distribcell(const std::vector* user_distribcells) // By default, add material cells to the list of distributed cells if (settings::material_cell_offsets) { - for (int64_t i = 0; i < model::cells.size(); ++i) { + for (gsl::index i = 0; i < model::cells.size(); ++i) { if (model::cells[i]->type_ == Fill::MATERIAL) distribcells.insert(i); } @@ -367,49 +356,35 @@ void prepare_distribcell(const std::vector* user_distribcells) Cell& c {*model::cells[i]}; if (c.material_.size() > 1) { - if (c.material_.size() != c.n_instances()) { + if (c.material_.size() != c.n_instances_) { fatal_error(fmt::format( "Cell {} was specified with {} materials but has {} distributed " "instances. The number of materials must equal one or the number " "of instances.", - c.id_, c.material_.size(), c.n_instances())); + c.id_, c.material_.size(), c.n_instances_)); } } if (c.sqrtkT_.size() > 1) { - if (c.sqrtkT_.size() != c.n_instances()) { + if (c.sqrtkT_.size() != c.n_instances_) { fatal_error(fmt::format( "Cell {} was specified with {} temperatures but has {} distributed " "instances. The number of temperatures must equal one or the number " "of instances.", - c.id_, c.sqrtkT_.size(), c.n_instances())); - } - } - - if (c.density_mult_.size() > 1) { - if (c.density_mult_.size() != c.n_instances()) { - fatal_error(fmt::format("Cell {} was specified with {} density " - "multipliers but has {} distributed " - "instances. The number of density multipliers " - "must equal one or the number " - "of instances.", - c.id_, c.density_mult_.size(), c.n_instances())); + c.id_, c.sqrtkT_.size(), c.n_instances_)); } } } // Search through universes for material cells and assign each one a - // distribcell array index according to the containing universe. + // unique distribcell array index. + int distribcell_index = 0; vector target_univ_ids; for (const auto& u : model::universes) { for (auto idx : u->cells_) { if (distribcells.find(idx) != distribcells.end()) { - if (!contains(target_univ_ids, u->id_)) { - target_univ_ids.push_back(u->id_); - } - model::cells[idx]->distribcell_index_ = - std::find(target_univ_ids.begin(), target_univ_ids.end(), u->id_) - - target_univ_ids.begin(); + model::cells[idx]->distribcell_index_ = distribcell_index++; + target_univ_ids.push_back(u->id_); } } } @@ -444,7 +419,8 @@ void prepare_distribcell(const std::vector* user_distribcells) } else if (c.type_ == Fill::LATTICE) { c.offset_[map] = offset; Lattice& lat = *model::lattices[c.fill_]; - offset += lat.fill_offset_table(target_univ_id, map, univ_count_memo); + offset += + lat.fill_offset_table(offset, target_univ_id, map, univ_count_memo); } } } @@ -453,12 +429,32 @@ void prepare_distribcell(const std::vector* user_distribcells) //============================================================================== -void count_universe_instances() +void count_cell_instances(int32_t univ_indx) { - for (auto& univ : model::universes) { - std::unordered_map univ_count_memo; - univ->n_instances_ = count_universe_instances( - model::root_universe, univ->id_, univ_count_memo); + const auto univ_counts = model::universe_cell_counts.find(univ_indx); + if (univ_counts != model::universe_cell_counts.end()) { + for (const auto& it : univ_counts->second) { + model::cells[it.first]->n_instances_ += it.second; + } + } else { + for (int32_t cell_indx : model::universes[univ_indx]->cells_) { + Cell& c = *model::cells[cell_indx]; + ++c.n_instances_; + model::universe_cell_counts[univ_indx][cell_indx] += 1; + + if (c.type_ == Fill::UNIVERSE) { + // This cell contains another universe. Recurse into that universe. + count_cell_instances(c.fill_); + update_universe_cell_count(univ_indx, c.fill_); + } else if (c.type_ == Fill::LATTICE) { + // This cell contains a lattice. Recurse into the lattice universes. + Lattice& lat = *model::lattices[c.fill_]; + for (auto it = lat.begin(); it != lat.end(); ++it) { + count_cell_instances(*it); + update_universe_cell_count(univ_indx, *it); + } + } + } } } @@ -532,16 +528,19 @@ std::string distribcell_path_inner(int32_t target_cell, int32_t map, // Material cells don't contain other cells so ignore them. if (c.type_ != Fill::MATERIAL) { - int32_t temp_offset = offset + c.offset_[map]; - if (c.type_ == Fill::LATTICE) { + int32_t temp_offset; + if (c.type_ == Fill::UNIVERSE) { + temp_offset = + offset + c.offset_[map]; // TODO: should also apply to lattice fills? + } else { Lattice& lat = *model::lattices[c.fill_]; int32_t indx = lat.universes_.size() * map + lat.begin().indx_; - temp_offset += lat.offsets_[indx]; + temp_offset = offset + lat.offsets_[indx]; } // The desired cell is the first cell that gives an offset smaller or // equal to the target offset. - if (temp_offset <= target_offset) + if (temp_offset <= target_offset - c.offset_[map]) break; } } @@ -571,12 +570,12 @@ std::string distribcell_path_inner(int32_t target_cell, int32_t map, path << "l" << lat.id_; for (ReverseLatticeIter it = lat.rbegin(); it != lat.rend(); ++it) { int32_t indx = lat.universes_.size() * map + it.indx_; - int32_t temp_offset = offset + lat.offsets_[indx] + c.offset_[map]; - if (temp_offset <= target_offset) { + int32_t temp_offset = offset + lat.offsets_[indx]; + if (temp_offset <= target_offset - c.offset_[map]) { offset = temp_offset; path << "(" << lat.index_to_string(it.indx_) << ")->"; - path << distribcell_path_inner( - target_cell, map, target_offset, *model::universes[*it], offset); + path << distribcell_path_inner(target_cell, map, target_offset, + *model::universes[*it], offset + c.offset_[map]); return path.str(); } } diff --git a/src/hdf5_interface.cpp b/src/hdf5_interface.cpp index 00c6a4399..27b750b93 100644 --- a/src/hdf5_interface.cpp +++ b/src/hdf5_interface.cpp @@ -4,7 +4,8 @@ #include #include -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" +#include "xtensor/xtensor.hpp" #include #include "hdf5.h" @@ -91,7 +92,7 @@ void get_shape_attr(hid_t obj_id, const char* name, hsize_t* dims) H5Aclose(attr); } -hid_t create_group(hid_t parent_id, const char* name) +hid_t create_group(hid_t parent_id, char const* name) { hid_t out = H5Gcreate(parent_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (out < 0) { @@ -224,7 +225,8 @@ void get_name(hid_t obj_id, std::string& name) { size_t size = 1 + H5Iget_name(obj_id, nullptr, 0); name.resize(size); - H5Iget_name(obj_id, name.data(), size); + // TODO: switch to name.data() when using C++17 + H5Iget_name(obj_id, &name[0], size); } int get_num_datasets(hid_t group_id) @@ -465,19 +467,22 @@ void read_dataset_lowlevel(hid_t obj_id, const char* name, hid_t mem_type_id, } template<> -void read_dataset( - hid_t dset, tensor::Tensor>& tensor, bool indep) +void read_dataset(hid_t dset, xt::xarray>& arr, bool indep) { // Get shape of dataset vector shape = object_shape(dset); - // Resize tensor and read data directly - vector tshape(shape.begin(), shape.end()); - tensor.resize(tshape); + // Allocate new array to read data into + std::size_t size = 1; + for (const auto x : shape) + size *= x; + vector> buffer(size); - // Read data from dataset - read_complex(dset, nullptr, - reinterpret_cast*>(tensor.data()), indep); + // Read data from attribute + read_complex(dset, nullptr, buffer.data(), indep); + + // Adapt into xarray + arr = xt::adapt(buffer, shape); } void read_double(hid_t obj_id, const char* name, double* buffer, bool indep) @@ -532,14 +537,14 @@ void read_complex( H5Tclose(complex_id); } -void read_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score, - hsize_t n_results, double* results) +void read_tally_results( + hid_t group_id, hsize_t n_filter, hsize_t n_score, double* results) { // Create dataspace for hyperslab in memory constexpr int ndim = 3; - hsize_t dims[ndim] {n_filter, n_score, n_results}; + hsize_t dims[ndim] {n_filter, n_score, 3}; hsize_t start[ndim] {0, 0, 1}; - hsize_t count[ndim] {n_filter, n_score, n_results - 1}; + hsize_t count[ndim] {n_filter, n_score, 2}; hid_t memspace = H5Screate_simple(ndim, dims, nullptr); H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, nullptr, count, nullptr); @@ -682,15 +687,15 @@ void write_string( group_id, 0, nullptr, buffer.length(), name, buffer.c_str(), indep); } -void write_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score, - hsize_t n_results, const double* results) +void write_tally_results( + hid_t group_id, hsize_t n_filter, hsize_t n_score, const double* results) { // Set dimensions of sum/sum_sq hyperslab to store constexpr int ndim = 3; - hsize_t count[ndim] {n_filter, n_score, n_results - 1}; + hsize_t count[ndim] {n_filter, n_score, 2}; // Set dimensions of results array - hsize_t dims[ndim] {n_filter, n_score, n_results}; + hsize_t dims[ndim] {n_filter, n_score, 3}; hsize_t start[ndim] {0, 0, 1}; hid_t memspace = H5Screate_simple(ndim, dims, nullptr); H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, nullptr, count, nullptr); diff --git a/src/ifp.cpp b/src/ifp.cpp deleted file mode 100644 index f0f98b8ef..000000000 --- a/src/ifp.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "openmc/ifp.h" - -#include "openmc/bank.h" -#include "openmc/message_passing.h" -#include "openmc/particle.h" -#include "openmc/particle_data.h" -#include "openmc/settings.h" -#include "openmc/simulation.h" -#include "openmc/vector.h" - -namespace openmc { - -bool is_beta_effective_or_both() -{ - if (settings::ifp_parameter == IFPParameter::BetaEffective || - settings::ifp_parameter == IFPParameter::Both) { - return true; - } - return false; -} - -bool is_generation_time_or_both() -{ - if (settings::ifp_parameter == IFPParameter::GenerationTime || - settings::ifp_parameter == IFPParameter::Both) { - return true; - } - return false; -} - -void ifp(const Particle& p, int64_t idx) -{ - if (is_beta_effective_or_both()) { - const auto& delayed_groups = - simulation::ifp_source_delayed_group_bank[p.current_work()]; - simulation::ifp_fission_delayed_group_bank[idx] = - _ifp(p.delayed_group(), delayed_groups); - } - if (is_generation_time_or_both()) { - const auto& lifetimes = - simulation::ifp_source_lifetime_bank[p.current_work()]; - simulation::ifp_fission_lifetime_bank[idx] = _ifp(p.lifetime(), lifetimes); - } -} - -void resize_simulation_ifp_banks() -{ - resize_ifp_data(simulation::ifp_source_delayed_group_bank, - simulation::ifp_source_lifetime_bank, simulation::work_per_rank); - resize_ifp_data(simulation::ifp_fission_delayed_group_bank, - simulation::ifp_fission_lifetime_bank, 3 * simulation::work_per_rank); -} - -void copy_ifp_data_from_fission_banks( - int i_bank, vector& delayed_groups, vector& lifetimes) -{ - if (is_beta_effective_or_both()) { - delayed_groups = simulation::ifp_fission_delayed_group_bank[i_bank]; - } - if (is_generation_time_or_both()) { - lifetimes = simulation::ifp_fission_lifetime_bank[i_bank]; - } -} - -#ifdef OPENMC_MPI -void broadcast_ifp_n_generation(int& n_generation, - const vector>& delayed_groups, - const vector>& lifetimes) -{ - if (mpi::rank == 0) { - if (is_beta_effective_or_both()) { - n_generation = static_cast(delayed_groups[0].size()); - } else { - n_generation = static_cast(lifetimes[0].size()); - } - } - MPI_Bcast(&n_generation, 1, MPI_INT, 0, mpi::intracomm); -} - -void copy_partial_ifp_data_to_source_banks(int64_t idx, int n, int64_t i_bank, - const vector>& delayed_groups, - const vector>& lifetimes) -{ - if (is_beta_effective_or_both()) { - std::copy(&delayed_groups[idx], &delayed_groups[idx + n], - &simulation::ifp_source_delayed_group_bank[i_bank]); - } - if (is_generation_time_or_both()) { - std::copy(&lifetimes[idx], &lifetimes[idx + n], - &simulation::ifp_source_lifetime_bank[i_bank]); - } -} -#endif - -void copy_complete_ifp_data_to_source_banks( - const vector>& delayed_groups, - const vector>& lifetimes) -{ - if (is_beta_effective_or_both()) { - std::copy(delayed_groups.data(), - delayed_groups.data() + settings::n_particles, - simulation::ifp_source_delayed_group_bank.begin()); - } - if (is_generation_time_or_both()) { - std::copy(lifetimes.data(), lifetimes.data() + settings::n_particles, - simulation::ifp_source_lifetime_bank.begin()); - } -} - -void allocate_temporary_vector_ifp( - vector>& delayed_groups, vector>& lifetimes) -{ - if (is_beta_effective_or_both()) { - delayed_groups.resize(simulation::fission_bank.size()); - } - if (is_generation_time_or_both()) { - lifetimes.resize(simulation::fission_bank.size()); - } -} - -void copy_ifp_data_to_fission_banks(const vector* const delayed_groups_ptr, - const vector* lifetimes_ptr) -{ - if (is_beta_effective_or_both()) { - std::copy(delayed_groups_ptr, - delayed_groups_ptr + simulation::fission_bank.size(), - simulation::ifp_fission_delayed_group_bank.data()); - } - if (is_generation_time_or_both()) { - std::copy(lifetimes_ptr, lifetimes_ptr + simulation::fission_bank.size(), - simulation::ifp_fission_lifetime_bank.data()); - } -} - -} // namespace openmc diff --git a/src/initialize.cpp b/src/initialize.cpp index 78b414f78..cc1eac9cf 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -12,7 +12,6 @@ #include #include "openmc/capi.h" -#include "openmc/chain.h" #include "openmc/constants.h" #include "openmc/cross_sections.h" #include "openmc/error.h" @@ -38,7 +37,7 @@ #include "openmc/vector.h" #include "openmc/weight_windows.h" -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH #include "libmesh/libmesh.h" #endif @@ -64,7 +63,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm) if (err) return err; -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH const int n_threads = num_threads(); // initialize libMesh if it hasn't been initialized already // (if initialized externally, the libmesh_init object needs to be provided @@ -99,10 +98,9 @@ int openmc_init(int argc, char* argv[], const void* intracomm) } #endif - // Initialize random number generator -- if the user specifies a seed and/or - // stride, it will be re-initialized later + // Initialize random number generator -- if the user specifies a seed, it + // will be re-initialized later openmc::openmc_set_seed(DEFAULT_SEED); - openmc::openmc_set_stride(DEFAULT_STRIDE); // Copy previous locale and set locale to C. This is a workaround for an issue // whereby when openmc_init is called from the plotter, the Qt application @@ -118,10 +116,6 @@ int openmc_init(int argc, char* argv[], const void* intracomm) if (!read_model_xml()) read_separate_xml_files(); - if (!settings::properties_file.empty()) { - openmc_properties_import(settings::properties_file.c_str()); - } - // Reset locale to previous state if (std::setlocale(LC_ALL, prev_locale.c_str()) == NULL) { fatal_error("Cannot reset locale."); @@ -161,7 +155,7 @@ void initialize_mpi(MPI_Comm intracomm) // Create bank datatype SourceSite b; - MPI_Aint disp[14]; + MPI_Aint disp[10]; MPI_Get_address(&b.r, &disp[0]); MPI_Get_address(&b.u, &disp[1]); MPI_Get_address(&b.E, &disp[2]); @@ -170,70 +164,17 @@ void initialize_mpi(MPI_Comm intracomm) MPI_Get_address(&b.delayed_group, &disp[5]); MPI_Get_address(&b.surf_id, &disp[6]); MPI_Get_address(&b.particle, &disp[7]); - MPI_Get_address(&b.parent_nuclide, &disp[8]); - MPI_Get_address(&b.parent_id, &disp[9]); - MPI_Get_address(&b.progeny_id, &disp[10]); - MPI_Get_address(&b.wgt_born, &disp[11]); - MPI_Get_address(&b.wgt_ww_born, &disp[12]); - MPI_Get_address(&b.n_split, &disp[13]); - for (int i = 13; i >= 0; --i) { + MPI_Get_address(&b.parent_id, &disp[8]); + MPI_Get_address(&b.progeny_id, &disp[9]); + for (int i = 9; i >= 0; --i) { disp[i] -= disp[0]; } - // Block counts for each field - int blocks[] = {3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - - // Types for each field - MPI_Datatype types[] = { - MPI_DOUBLE, // r (3 doubles) - MPI_DOUBLE, // u (3 doubles) - MPI_DOUBLE, // E - MPI_DOUBLE, // time - MPI_DOUBLE, // wgt - MPI_INT, // delayed_group - MPI_INT, // surf_id - MPI_INT, // particle (enum) - MPI_INT, // parent_nuclide - MPI_INT64_T, // parent_id - MPI_INT64_T, // progeny_id - MPI_DOUBLE, // wgt_born - MPI_DOUBLE, // wgt_ww_born - MPI_INT64_T // n_split - }; - - MPI_Type_create_struct(14, blocks, disp, types, &mpi::source_site); + int blocks[] {3, 3, 1, 1, 1, 1, 1, 1, 1, 1}; + MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, + MPI_DOUBLE, MPI_INT, MPI_INT, MPI_INT, MPI_LONG, MPI_LONG}; + MPI_Type_create_struct(10, blocks, disp, types, &mpi::source_site); MPI_Type_commit(&mpi::source_site); - - CollisionTrackSite bc; - MPI_Aint dispc[16]; - MPI_Get_address(&bc.r, &dispc[0]); // double - MPI_Get_address(&bc.u, &dispc[1]); // double - MPI_Get_address(&bc.E, &dispc[2]); // double - MPI_Get_address(&bc.dE, &dispc[3]); // double - MPI_Get_address(&bc.time, &dispc[4]); // double - MPI_Get_address(&bc.wgt, &dispc[5]); // double - MPI_Get_address(&bc.event_mt, &dispc[6]); // int - MPI_Get_address(&bc.delayed_group, &dispc[7]); // int - MPI_Get_address(&bc.cell_id, &dispc[8]); // int - MPI_Get_address(&bc.nuclide_id, &dispc[9]); // int - MPI_Get_address(&bc.material_id, &dispc[10]); // int - MPI_Get_address(&bc.universe_id, &dispc[11]); // int - MPI_Get_address(&bc.n_collision, &dispc[12]); // int - MPI_Get_address(&bc.particle, &dispc[13]); // int - MPI_Get_address(&bc.parent_id, &dispc[14]); // int64_t - MPI_Get_address(&bc.progeny_id, &dispc[15]); // int64_t - for (int i = 15; i >= 0; --i) { - dispc[i] -= dispc[0]; - } - - int blocksc[] = {3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - MPI_Datatype typesc[] = {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, - MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT, MPI_INT, MPI_INT, MPI_INT, - MPI_INT, MPI_INT, MPI_INT, MPI_INT64_T, MPI_INT64_T}; - - MPI_Type_create_struct( - 16, blocksc, dispc, typesc, &mpi::collision_track_site); - MPI_Type_commit(&mpi::collision_track_site); } #endif // OPENMC_MPI @@ -251,15 +192,6 @@ int parse_command_line(int argc, char* argv[]) i += 1; settings::n_particles = std::stoll(argv[i]); - } else if (arg == "-q" || arg == "--verbosity") { - i += 1; - settings::verbosity = std::stoi(argv[i]); - if (settings::verbosity > 10 || settings::verbosity < 1) { - auto msg = fmt::format("Invalid verbosity: {}.", settings::verbosity); - strcpy(openmc_err_msg, msg.c_str()); - return OPENMC_E_INVALID_ARGUMENT; - } - } else if (arg == "-e" || arg == "--event") { settings::event_based = true; } else if (arg == "-r" || arg == "--restart") { @@ -321,11 +253,6 @@ int parse_command_line(int argc, char* argv[]) settings::run_mode = RunMode::VOLUME; } else if (arg == "-s" || arg == "--threads") { // Read number of threads - if (i + 1 >= argc) { - std::string msg {"Number of threads not specified."}; - strcpy(openmc_err_msg, msg.c_str()); - return OPENMC_E_INVALID_ARGUMENT; - } i += 1; #ifdef _OPENMP @@ -387,28 +314,6 @@ int parse_command_line(int argc, char* argv[]) return 0; } -// TODO: Pulse-height tallies require per-history scoring across the full -// particle tree (parent + all descendants). The shared secondary bank -// transports each secondary as an independent Particle, breaking this -// assumption. A proper fix would defer pulse-height scoring: save -// (root_source_id, cell, pht_storage) per particle, then aggregate by -// root_source_id after all secondary generations complete before scoring -// into the histogram. For now, disable shared secondary when pulse-height -// tallies are present. -static void check_pulse_height_compatibility() -{ - if (settings::use_shared_secondary_bank) { - for (const auto& t : model::tallies) { - if (t->type_ == TallyType::PULSE_HEIGHT) { - settings::use_shared_secondary_bank = false; - warning("Pulse-height tallies are not yet compatible with the shared " - "secondary bank. Disabling shared secondary bank."); - break; - } - } - } -} - bool read_model_xml() { std::string model_filename = settings::path_input; @@ -437,10 +342,8 @@ bool read_model_xml() auto settings_root = root.child("settings"); // Verbosity - if (check_for_node(settings_root, "verbosity") && settings::verbosity == -1) { + if (check_for_node(settings_root, "verbosity")) { settings::verbosity = std::stoi(get_node_value(settings_root, "verbosity")); - } else if (settings::verbosity == -1) { - settings::verbosity = 7; } // To this point, we haven't displayed any output since we didn't know what @@ -453,10 +356,6 @@ bool read_model_xml() write_message( fmt::format("Reading model XML file '{}' ...", model_filename), 5); - // Read chain data before settings so DecaySpectrum source distributions can - // resolve nuclides while sources are constructed. - read_chain_file_xml(); - read_settings_xml(settings_root); // If other XML files are present, display warning @@ -496,15 +395,9 @@ bool read_model_xml() // Finalize cross sections having assigned temperatures finalize_cross_sections(); - // Compute cell density multipliers now that material densities - // have been finalized (from geometry_aux.h) - finalize_cell_densities(); - if (check_for_node(root, "tallies")) read_tallies_xml(root.child("tallies")); - check_pulse_height_compatibility(); - // Initialize distribcell_filters prepare_distribcell(); @@ -526,15 +419,10 @@ bool read_model_xml() void read_separate_xml_files() { - // Read chain data before settings so DecaySpectrum source distributions can - // resolve nuclides while sources are constructed. - read_chain_file_xml(); - read_settings_xml(); if (settings::run_mode != RunMode::PLOTTING) { read_cross_sections_xml(); } - read_materials_xml(); read_geometry_xml(); @@ -543,15 +431,8 @@ void read_separate_xml_files() // Finalize cross sections having assigned temperatures finalize_cross_sections(); - - // Compute cell density multipliers now that material densities - // have been finalized (from geometry_aux.h) - finalize_cell_densities(); - read_tallies_xml(); - check_pulse_height_compatibility(); - // Initialize distribcell_filters prepare_distribcell(); diff --git a/src/lattice.cpp b/src/lattice.cpp index 9e56c58e8..73005ad09 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -10,7 +10,6 @@ #include "openmc/geometry.h" #include "openmc/geometry_aux.h" #include "openmc/hdf5_interface.h" -#include "openmc/math_functions.h" #include "openmc/string_utils.h" #include "openmc/vector.h" #include "openmc/xml_interface.h" @@ -104,8 +103,8 @@ void Lattice::adjust_indices() //============================================================================== -int32_t Lattice::fill_offset_table(int32_t target_univ_id, int map, - std::unordered_map& univ_count_memo) +int32_t Lattice::fill_offset_table(int32_t offset, int32_t target_univ_id, + int map, std::unordered_map& univ_count_memo) { // If the offsets have already been determined for this "map", don't bother // recalculating all of them and just return the total offset. Note that the @@ -120,7 +119,6 @@ int32_t Lattice::fill_offset_table(int32_t target_univ_id, int map, count_universe_instances(last_univ, target_univ_id, univ_count_memo); } - int32_t offset = 0; for (LatticeIter it = begin(); it != end(); ++it) { offsets_[map * universes_.size() + it.indx_] = offset; offset += count_universe_instances(*it, target_univ_id, univ_count_memo); @@ -262,32 +260,46 @@ std::pair> RectLattice::distance( double x0 {copysign(0.5 * pitch_[0], u.x)}; double y0 {copysign(0.5 * pitch_[1], u.y)}; - // Evaluate the distance to each oncoming edge independently. Comparing these - // distances directly (rather than reconstructing the crossing position) - // avoids the floating-point cancellation that occurs for large pitches. - double dx = u.x != 0.0 ? (x0 - x) / u.x : INFTY; - double dy = u.y != 0.0 ? (y0 - y) / u.y : INFTY; - double dz = INFTY; - if (is_3d_) { - double z0 {copysign(0.5 * pitch_[2], u.z)}; - dz = u.z != 0.0 ? (z0 - z) / u.z : INFTY; + // Left and right sides + double d {INFTY}; + array lattice_trans; + if ((std::abs(x - x0) > FP_PRECISION) && u.x != 0) { + d = (x0 - x) / u.x; + if (u.x > 0) { + lattice_trans = {1, 0, 0}; + } else { + lattice_trans = {-1, 0, 0}; + } } - // The distance to the nearest lattice boundary is the smallest axial - // distance. - double d = std::min({dx, dy, dz}); + // Front and back sides + if ((std::abs(y - y0) > FP_PRECISION) && u.y != 0) { + double this_d = (y0 - y) / u.y; + if (this_d < d) { + d = this_d; + if (u.y > 0) { + lattice_trans = {0, 1, 0}; + } else { + lattice_trans = {0, -1, 0}; + } + } + } - // Determine which lattice boundaries are being crossed. The axis attaining - // the minimum is exactly equal to d, so at least one translation is always - // set for a finite crossing; a near-equal second axis indicates a corner - // crossing. - array lattice_trans = {0, 0, 0}; - if (isclose(d, dx, FP_COINCIDENT, FP_PRECISION)) - lattice_trans[0] = copysign(1, u.x); - if (isclose(d, dy, FP_COINCIDENT, FP_PRECISION)) - lattice_trans[1] = copysign(1, u.y); - if (is_3d_ && isclose(d, dz, FP_COINCIDENT, FP_PRECISION)) - lattice_trans[2] = copysign(1, u.z); + // Top and bottom sides + if (is_3d_) { + double z0 {copysign(0.5 * pitch_[2], u.z)}; + if ((std::abs(z - z0) > FP_PRECISION) && u.z != 0) { + double this_d = (z0 - z) / u.z; + if (this_d < d) { + d = this_d; + if (u.z > 0) { + lattice_trans = {0, 0, 1}; + } else { + lattice_trans = {0, 0, -1}; + } + } + } + } return {d, lattice_trans}; } @@ -349,26 +361,6 @@ Position RectLattice::get_local_position( //============================================================================== -Direction RectLattice::get_normal( - const array& i_xyz, bool& is_valid) const -{ - is_valid = false; - Direction dir = {0.0, 0.0, 0.0}; - if ((std::abs(i_xyz[0]) == 1) && (i_xyz[1] == 0) && (i_xyz[2] == 0)) { - is_valid = true; - dir[0] = std::copysign(1.0, i_xyz[0]); - } else if ((i_xyz[0] == 0) && (std::abs(i_xyz[1]) == 1) && (i_xyz[2] == 0)) { - is_valid = true; - dir[1] = std::copysign(1.0, i_xyz[1]); - } else if ((i_xyz[0] == 0) && (i_xyz[1] == 0) && (std::abs(i_xyz[2]) == 1)) { - is_valid = true; - dir[2] = std::copysign(1.0, i_xyz[2]); - } - return dir; -} - -//============================================================================== - int32_t& RectLattice::offset(int map, const array& i_xyz) { return offsets_[n_cells_[0] * n_cells_[1] * n_cells_[2] * map + @@ -1015,91 +1007,6 @@ Position HexLattice::get_local_position( //============================================================================== -Direction HexLattice::get_normal( - const array& i_xyz, bool& is_valid) const -{ - // Short description of the direction vectors used here. The beta, gamma, and - // delta vectors point towards the flat sides of each hexagonal tile. - // Y - orientation: - // basis0 = (1, 0) - // basis1 = (-1/sqrt(3), 1) = +120 degrees from basis0 - // beta = (sqrt(3)/2, 1/2) = +30 degrees from basis0 - // gamma = (sqrt(3)/2, -1/2) = -60 degrees from beta - // delta = (0, 1) = +60 degrees from beta - // X - orientation: - // basis0 = (1/sqrt(3), -1) - // basis1 = (0, 1) = +120 degrees from basis0 - // beta = (1, 0) = +30 degrees from basis0 - // gamma = (1/2, -sqrt(3)/2) = -60 degrees from beta - // delta = (1/2, sqrt(3)/2) = +60 degrees from beta - - is_valid = false; - Direction dir = {0.0, 0.0, 0.0}; - if ((i_xyz[0] == 0) && (i_xyz[1] == 0) && (std::abs(i_xyz[2]) == 1)) { - is_valid = true; - dir[2] = std::copysign(1.0, i_xyz[2]); - } else if ((i_xyz[2] == 0) && - std::max({std::abs(i_xyz[0]), std::abs(i_xyz[1]), - std::abs(i_xyz[0] + i_xyz[1])}) == 1) { - is_valid = true; - // beta direction - if ((i_xyz[0] == 1) && (i_xyz[1] == 0)) { - if (orientation_ == Orientation::y) { - dir[0] = 0.5 * std::sqrt(3.0); - dir[1] = 0.5; - } else { - dir[0] = 1.0; - dir[1] = 0.0; - } - } else if ((i_xyz[0] == -1) && (i_xyz[1] == 0)) { - if (orientation_ == Orientation::y) { - dir[0] = -0.5 * std::sqrt(3.0); - dir[1] = -0.5; - } else { - dir[0] = -1.0; - dir[1] = 0.0; - } - // gamma direction - } else if ((i_xyz[0] == 1) && (i_xyz[1] == -1)) { - if (orientation_ == Orientation::y) { - dir[0] = 0.5 * std::sqrt(3.0); - dir[1] = -0.5; - } else { - dir[0] = 0.5; - dir[1] = -0.5 * std::sqrt(3.0); - } - } else if ((i_xyz[0] == -1) && (i_xyz[1] == 1)) { - if (orientation_ == Orientation::y) { - dir[0] = -0.5 * std::sqrt(3.0); - dir[1] = 0.5; - } else { - dir[0] = -0.5; - dir[1] = 0.5 * std::sqrt(3.0); - } - // delta direction - } else if ((i_xyz[0] == 0) && (i_xyz[1] == 1)) { - if (orientation_ == Orientation::y) { - dir[0] = 0.0; - dir[1] = 1.0; - } else { - dir[0] = 0.5; - dir[1] = 0.5 * std::sqrt(3.0); - } - } else if ((i_xyz[0] == 0) && (i_xyz[1] == -1)) { - if (orientation_ == Orientation::y) { - dir[0] = 0.0; - dir[1] = -1.0; - } else { - dir[0] = -0.5; - dir[1] = -0.5 * std::sqrt(3.0); - } - } - } - return dir; -} - -//============================================================================== - bool HexLattice::is_valid_index(int indx) const { int nx {2 * n_rings_ - 1}; diff --git a/src/material.cpp b/src/material.cpp index 21b11b8b9..aad7008e7 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1,14 +1,15 @@ #include "openmc/material.h" #include // for min, max, sort, fill -#include #include #include #include #include #include -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xoperation.hpp" +#include "xtensor/xview.hpp" #include "openmc/capi.h" #include "openmc/container_util.h" @@ -214,7 +215,7 @@ Material::Material(pugi::xml_node node) // allocate arrays in Material object auto n = names.size(); nuclide_.reserve(n); - atom_density_ = tensor::Tensor({n}); + atom_density_ = xt::empty({n}); if (settings::photon_transport) element_.reserve(n); @@ -288,14 +289,14 @@ Material::Material(pugi::xml_node node) // Check to make sure either all atom percents or all weight percents are // given - if (!((atom_density_ >= 0.0).all() || (atom_density_ <= 0.0).all())) { + if (!(xt::all(atom_density_ >= 0.0) || xt::all(atom_density_ <= 0.0))) { fatal_error( "Cannot mix atom and weight percents in material " + std::to_string(id_)); } // Determine density if it is a sum value if (sum_density) - density_ = atom_density_.sum(); + density_ = xt::sum(atom_density_)(); if (check_for_node(node, "temperature")) { temperature_ = std::stod(get_node_value(node, "temperature")); @@ -366,7 +367,7 @@ Material& Material::clone() mat->name_ = name_; mat->nuclide_ = nuclide_; mat->element_ = element_; - mat->ncrystal_mat_ = ncrystal_mat_.clone(); + mat->ncrystal_mat_ = ncrystal_mat_; mat->atom_density_ = atom_density_; mat->density_ = density_; mat->density_gpcc_ = density_gpcc_; @@ -433,7 +434,7 @@ void Material::normalize_density() // determine normalized atom percents. if given atom percents, this is // straightforward. if given weight percents, the value is w/awr and is // divided by sum(w/awr) - atom_density_ /= atom_density_.sum(); + atom_density_ /= xt::sum(atom_density_)(); // Change density in g/cm^3 to atom/b-cm. Since all values are now in // atom percent, the sum needs to be re-evaluated as 1/sum(x*awr) @@ -452,15 +453,12 @@ void Material::normalize_density() // Calculate nuclide atom densities atom_density_ *= density_; - // Calculate density in [g/cm^3] and charge density in [e/b-cm] + // Calculate density in g/cm^3. density_gpcc_ = 0.0; - charge_density_ = 0.0; for (int i = 0; i < nuclide_.size(); ++i) { int i_nuc = nuclide_[i]; double awr = settings::run_CE ? data::nuclides[i_nuc]->awr_ : 1.0; - int z = settings::run_CE ? data::nuclides[i_nuc]->Z_ : 0.0; density_gpcc_ += atom_density_(i) * awr * MASS_NEUTRON / N_AVOGADRO; - charge_density_ += atom_density_(i) * z; } } @@ -639,14 +637,14 @@ void Material::init_bremsstrahlung() bool positron = (particle == 1); // Allocate arrays for TTB data - ttb->pdf = tensor::zeros({n_e, n_e}); - ttb->cdf = tensor::zeros({n_e, n_e}); - ttb->yield = tensor::zeros({n_e}); + ttb->pdf = xt::zeros({n_e, n_e}); + ttb->cdf = xt::zeros({n_e, n_e}); + ttb->yield = xt::empty({n_e}); // Allocate temporary arrays - auto stopping_power_collision = tensor::zeros({n_e}); - auto stopping_power_radiative = tensor::zeros({n_e}); - auto dcs = tensor::zeros({n_e, n_k}); + xt::xtensor stopping_power_collision({n_e}, 0.0); + xt::xtensor stopping_power_radiative({n_e}, 0.0); + xt::xtensor dcs({n_e, n_k}, 0.0); double Z_eq_sq = 0.0; double sum_density = 0.0; @@ -696,18 +694,18 @@ void Material::init_bremsstrahlung() 1.0595e-3 * std::pow(t, 5) + 7.0568e-5 * std::pow(t, 6) - 1.808e-6 * std::pow(t, 7)); stopping_power_radiative(i) *= r; - tensor::View dcs_i = dcs.slice(i); + auto dcs_i = xt::view(dcs, i, xt::all()); dcs_i *= r; } } // Total material stopping power - tensor::Tensor stopping_power = + xt::xtensor stopping_power = stopping_power_collision + stopping_power_radiative; // Loop over photon energies - auto f = tensor::zeros({n_e}); - auto z = tensor::zeros({n_e}); + xt::xtensor f({n_e}, 0.0); + xt::xtensor z({n_e}, 0.0); for (int i = 0; i < n_e - 1; ++i) { double w = data::ttb_e_grid(i); @@ -778,15 +776,14 @@ void Material::init_bremsstrahlung() // Loop over photon energies double c = 0.0; for (int i = 0; i < j; ++i) { - // Integrate the CDF from the PDF using the fact that the PDF is linear - // in log-log space + // Integrate the CDF from the PDF using the trapezoidal rule in log-log + // space double w_l = std::log(data::ttb_e_grid(i)); double w_r = std::log(data::ttb_e_grid(i + 1)); double x_l = std::log(ttb->pdf(j, i)); double x_r = std::log(ttb->pdf(j, i + 1)); - double beta = (x_r - x_l) / (w_r - w_l); - double a = beta + 1.0; - c += std::exp(w_l + x_l) / a * std::expm1(a * (w_r - w_l)); + + c += 0.5 * (w_r - w_l) * (std::exp(w_l + x_l) + std::exp(w_r + x_r)); ttb->cdf(j, i + 1) = c; } @@ -795,8 +792,7 @@ void Material::init_bremsstrahlung() } // Use logarithm of number yield since it is log-log interpolated - ttb->yield = - tensor::where(ttb->yield > 0.0, tensor::log(ttb->yield), -500.0); + ttb->yield = xt::where(ttb->yield > 0.0, xt::log(ttb->yield), -500.0); } } @@ -818,9 +814,9 @@ void Material::calculate_xs(Particle& p) const p.macro_xs().fission = 0.0; p.macro_xs().nu_fission = 0.0; - if (p.type().is_neutron()) { + if (p.type() == ParticleType::neutron) { this->calculate_neutron_xs(p); - } else if (p.type().is_photon()) { + } else if (p.type() == ParticleType::photon) { this->calculate_photon_xs(p); } } @@ -828,7 +824,7 @@ void Material::calculate_xs(Particle& p) const void Material::calculate_neutron_xs(Particle& p) const { // Find energy index on energy grid - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); int i_grid = std::log(p.E() / data::energy_min[neutron]) / simulation::log_spacing; @@ -889,7 +885,7 @@ void Material::calculate_neutron_xs(Particle& p) const // ADD TO MACROSCOPIC CROSS SECTION // Copy atom density of nuclide in material - double atom_density = this->atom_density(i, p.density_mult()); + double atom_density = atom_density_(i); // Add contributions to cross sections p.macro_xs().total += atom_density * micro.total; @@ -924,7 +920,7 @@ void Material::calculate_photon_xs(Particle& p) const // ADD TO MACROSCOPIC CROSS SECTION // Copy atom density of nuclide in material - double atom_density = this->atom_density(i, p.density_mult()); + double atom_density = atom_density_(i); // Add contributions to material macroscopic cross sections p.macro_xs().total += atom_density * micro.total; @@ -937,7 +933,7 @@ void Material::calculate_photon_xs(Particle& p) const void Material::set_id(int32_t id) { - assert(id >= 0 || id == C_NONE); + Expects(id >= 0 || id == C_NONE); // Clear entry in material map if an ID was already assigned before if (id_ != C_NONE) { @@ -965,9 +961,9 @@ void Material::set_id(int32_t id) model::material_map[id] = index_; } -void Material::set_density(double density, const std::string& units) +void Material::set_density(double density, gsl::cstring_span units) { - assert(density >= 0.0); + Expects(density >= 0.0); if (nuclide_.empty()) { throw std::runtime_error {"No nuclides exist in material yet."}; @@ -978,21 +974,18 @@ void Material::set_density(double density, const std::string& units) density_ = density; // Determine normalized atom percents - double sum_percent = atom_density_.sum(); + double sum_percent = xt::sum(atom_density_)(); atom_density_ /= sum_percent; // Recalculate nuclide atom densities based on given density atom_density_ *= density; - // Calculate density in g/cm^3 and charge density in [e/b-cm] + // Calculate density in g/cm^3. density_gpcc_ = 0.0; - charge_density_ = 0.0; for (int i = 0; i < nuclide_.size(); ++i) { int i_nuc = nuclide_[i]; double awr = data::nuclides[i_nuc]->awr_; - int z = settings::run_CE ? data::nuclides[i_nuc]->Z_ : 0.0; density_gpcc_ += atom_density_(i) * awr * MASS_NEUTRON / N_AVOGADRO; - charge_density_ += atom_density_(i) * z; } } else if (units == "g/cm3" || units == "g/cc") { // Determine factor by which to change densities @@ -1003,7 +996,6 @@ void Material::set_density(double density, const std::string& units) density_gpcc_ = density; density_ *= f; atom_density_ *= f; - charge_density_ *= f; } else { throw std::invalid_argument { "Invalid units '" + std::string(units.data()) + "' specified."}; @@ -1014,18 +1006,18 @@ void Material::set_densities( const vector& name, const vector& density) { auto n = name.size(); - assert(n > 0); - assert(n == density.size()); + Expects(n > 0); + Expects(n == density.size()); if (n != nuclide_.size()) { nuclide_.resize(n); - atom_density_ = tensor::zeros({n}); + atom_density_ = xt::zeros({n}); if (settings::photon_transport) element_.resize(n); } double sum_density = 0.0; - for (int64_t i = 0; i < n; ++i) { + for (gsl::index i = 0; i < n; ++i) { const auto& nuc {name[i]}; if (data::nuclide_map.find(nuc) == data::nuclide_map.end()) { int err = openmc_load_nuclide(nuc.c_str(), nullptr, 0); @@ -1034,7 +1026,7 @@ void Material::set_densities( } nuclide_[i] = data::nuclide_map.at(nuc); - assert(density[i] > 0.0); + Expects(density[i] > 0.0); atom_density_(i) = density[i]; sum_density += density[i]; @@ -1180,8 +1172,8 @@ void Material::add_nuclide(const std::string& name, double density) auto n = nuclide_.size(); // Create copy of atom_density_ array with one extra entry - tensor::Tensor atom_density = tensor::zeros({n}); - atom_density.slice(tensor::range(0, n - 1)) = atom_density_; + xt::xtensor atom_density = xt::zeros({n}); + xt::view(atom_density, xt::range(0, n - 1)) = atom_density_; atom_density(n - 1) = density; atom_density_ = atom_density; diff --git a/src/math_functions.cpp b/src/math_functions.cpp index ddacc2bd9..ba1c6c3db 100644 --- a/src/math_functions.cpp +++ b/src/math_functions.cpp @@ -1,7 +1,5 @@ #include "openmc/math_functions.h" -#include // for numeric_limits - #include "openmc/external/Faddeeva.hh" #include "openmc/constants.h" @@ -97,13 +95,6 @@ double t_percentile(double p, int df) return t; } -double standard_normal_cdf(double z) -{ - // Use the complementary error function to compute the standard normal CDF - // Phi(z) = 0.5 * (1 + erf(z / sqrt(2))) = 0.5 * erfc(-z / sqrt(2)) - return 0.5 * std::erfc(-z / std::sqrt(2.0)); -} - void calc_pn_c(int n, double x, double pnx[]) { pnx[0] = 1.; @@ -659,7 +650,7 @@ void calc_zn(int n, double rho, double phi, double zn[]) // =========================================================================== // Determine vector of sin(n*phi) and cos(n*phi). This takes advantage of the // following recurrence relations so that only a single sin/cos have to be - // evaluated (https://mathworld.wolfram.com/Multiple-AngleFormulas.html) + // evaluated (http://mathworld.wolfram.com/Multiple-AngleFormulas.html) // // sin(nx) = 2 cos(x) sin((n-1)x) - sin((n-2)x) // cos(nx) = 2 cos(x) cos((n-1)x) - cos((n-2)x) @@ -928,85 +919,4 @@ std::complex w_derivative(std::complex z, int order) } } -double exprel(double x) -{ - if (std::abs(x) < 1e-16) - return 1.0; - else { - return std::expm1(x) / x; - } -} - -double log1prel(double x) -{ - if (std::abs(x) < 1e-16) - return 1.0; - else { - return std::log1p(x) / x; - } -} - -double cyl_bessel_j(int n, double x) -{ - // Handle negative arguments via the parity relation - // J_n(-x) = (-1)^n J_n(x); std::cyl_bessel_j has a domain error for x < 0. - double sign = 1.0; - if (x < 0.0) { - x = -x; - if (n % 2 == 1) - sign = -1.0; - } - -#if defined(__cpp_lib_math_special_functions) && \ - __cpp_lib_math_special_functions >= 201603L - return sign * std::cyl_bessel_j(static_cast(n), x); -#else - // Ascending power series (e.g., Abramowitz & Stegun eq. 9.1.10): - // J_n(x) = sum_{m=0}^inf (-1)^m / (m! (m+n)!) * (x/2)^(2m+n) - // The term ratio is -(x/2)^2 / (m*(m+n)), so for |x| <= 2 the series - // converges to machine precision within ~20 terms. - double half_x = 0.5 * x; - - // First term: (x/2)^n / n! - double term = 1.0; - for (int k = 1; k <= n; ++k) { - term *= half_x / k; - } - - double sum = term; - double neg_half_x_sq = -half_x * half_x; - for (int m = 1; m <= 50; ++m) { - term *= neg_half_x_sq / (m * (m + n)); - sum += term; - if (std::abs(term) <= - std::numeric_limits::epsilon() * std::abs(sum)) - break; - } - return sign * sum; -#endif -} - -// Helper function to get index and interpolation function on an incident energy -// grid -void get_energy_index( - const vector& energies, double E, int& i, double& f) -{ - // Get index and interpolation factor for linear-linear energy grid - i = 0; - f = 0.0; - if (E >= energies.front()) { - i = lower_bound_index(energies.begin(), energies.end(), E); - if (i + 1 < energies.size()) - f = (E - energies[i]) / (energies[i + 1] - energies[i]); - } -} - -// Return true if two floating-point values are approximately equal within a -// combined relative and absolute tolerance. -bool isclose(double a, double b, double rel_tol, double abs_tol) -{ - return std::abs(a - b) <= - std::max(rel_tol * std::max(std::abs(a), std::abs(b)), abs_tol); -} - } // namespace openmc diff --git a/src/mcpl_interface.cpp b/src/mcpl_interface.cpp index 30c41ec5a..5c3df026c 100644 --- a/src/mcpl_interface.cpp +++ b/src/mcpl_interface.cpp @@ -11,636 +11,217 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#else -#include +#ifdef OPENMC_MCPL +#include #endif -// WARNING: These declarations MUST EXACTLY MATCH the structure and function -// signatures of the libmcpl being loaded at runtime. Any discrepancy will -// likely lead to crashes or incorrect behavior. This is a maintenance risk. -// MCPL 2.2.0 - -#pragma pack(push, 1) -struct mcpl_particle_repr_t { - double ekin; - double polarisation[3]; - double position[3]; - double direction[3]; - double time; - double weight; - int32_t pdgcode; - uint32_t userflags; -}; -#pragma pack(pop) - -// Opaque struct definitions replicating the MCPL C-API to ensure ABI -// compatibility without including mcpl.h. These must be kept in sync. -struct mcpl_file_t { - void* internal; -}; -struct mcpl_outfile_t { - void* internal; -}; - -// Function pointer types for the dynamically loaded MCPL library -using mcpl_open_file_fpt = mcpl_file_t* (*)(const char* filename); -using mcpl_hdr_nparticles_fpt = uint64_t (*)(mcpl_file_t* file_handle); -using mcpl_read_fpt = const mcpl_particle_repr_t* (*)(mcpl_file_t* file_handle); -using mcpl_close_file_fpt = void (*)(mcpl_file_t* file_handle); - -using mcpl_hdr_add_data_fpt = void (*)(mcpl_outfile_t* file_handle, - const char* key, uint32_t datalength, const char* data); -using mcpl_create_outfile_fpt = mcpl_outfile_t* (*)(const char* filename); -using mcpl_hdr_set_srcname_fpt = void (*)( - mcpl_outfile_t* outfile_handle, const char* srcname); -using mcpl_add_particle_fpt = void (*)( - mcpl_outfile_t* outfile_handle, const mcpl_particle_repr_t* particle); -using mcpl_close_outfile_fpt = void (*)(mcpl_outfile_t* outfile_handle); -using mcpl_hdr_add_stat_sum_fpt = void (*)( - mcpl_outfile_t* outfile_handle, const char* key, double value); - namespace openmc { -#ifdef _WIN32 -using LibraryHandleType = HMODULE; +//============================================================================== +// Constants +//============================================================================== + +#ifdef OPENMC_MCPL +const bool MCPL_ENABLED = true; #else -using LibraryHandleType = void*; +const bool MCPL_ENABLED = false; #endif -std::string get_last_library_error() -{ -#ifdef _WIN32 - DWORD error_code = GetLastError(); - if (error_code == 0) - return "No error reported by system."; // More accurate than "No error." - LPSTR message_buffer = nullptr; - size_t size = - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&message_buffer, 0, NULL); - std::string message(message_buffer, size); - LocalFree(message_buffer); - while ( - !message.empty() && (message.back() == '\n' || message.back() == '\r')) { - message.pop_back(); - } - return message; -#else - const char* err = dlerror(); - return err ? std::string(err) : "No error reported by dlerror."; -#endif -} +//============================================================================== +// Functions +//============================================================================== -struct McplApi { - mcpl_open_file_fpt open_file; - mcpl_hdr_nparticles_fpt hdr_nparticles; - mcpl_read_fpt read; - mcpl_close_file_fpt close_file; - mcpl_create_outfile_fpt create_outfile; - mcpl_hdr_set_srcname_fpt hdr_set_srcname; - mcpl_hdr_add_data_fpt hdr_add_data; - mcpl_add_particle_fpt add_particle; - mcpl_close_outfile_fpt close_outfile; - mcpl_hdr_add_stat_sum_fpt hdr_add_stat_sum; - - explicit McplApi(LibraryHandleType lib_handle) - { - if (!lib_handle) - throw std::runtime_error( - "MCPL library handle is null during API binding."); - - auto load_symbol_platform = [lib_handle](const char* name) { - void* sym = nullptr; -#ifdef _WIN32 - sym = (void*)GetProcAddress(lib_handle, name); -#else - sym = dlsym(lib_handle, name); -#endif - if (!sym) { - throw std::runtime_error( - fmt::format("Failed to load MCPL symbol '{}': {}", name, - get_last_library_error())); - } - return sym; - }; - - open_file = reinterpret_cast( - load_symbol_platform("mcpl_open_file")); - hdr_nparticles = reinterpret_cast( - load_symbol_platform("mcpl_hdr_nparticles")); - read = reinterpret_cast(load_symbol_platform("mcpl_read")); - close_file = reinterpret_cast( - load_symbol_platform("mcpl_close_file")); - create_outfile = reinterpret_cast( - load_symbol_platform("mcpl_create_outfile")); - hdr_set_srcname = reinterpret_cast( - load_symbol_platform("mcpl_hdr_set_srcname")); - add_particle = reinterpret_cast( - load_symbol_platform("mcpl_add_particle")); - close_outfile = reinterpret_cast( - load_symbol_platform("mcpl_close_outfile")); - - // Try to load mcpl_hdr_add_data (available in MCPL >= 2.1.0) - // Set to nullptr if not available for graceful fallback - try { - hdr_add_data = reinterpret_cast( - load_symbol_platform("mcpl_hdr_add_data")); - } catch (const std::runtime_error&) { - hdr_add_data = nullptr; - } - - // Try to load mcpl_hdr_add_stat_sum (available in MCPL >= 2.1.0) - // Set to nullptr if not available for graceful fallback - try { - hdr_add_stat_sum = reinterpret_cast( - load_symbol_platform("mcpl_hdr_add_stat_sum")); - } catch (const std::runtime_error&) { - hdr_add_stat_sum = nullptr; - } - } -}; - -static LibraryHandleType g_mcpl_lib_handle = nullptr; -static std::unique_ptr g_mcpl_api; -static bool g_mcpl_init_attempted = false; -static bool g_mcpl_successfully_loaded = false; -static std::string g_mcpl_load_error_msg; -static std::once_flag g_mcpl_init_flag; - -void append_error(std::string& existing_msg, const std::string& new_error) -{ - if (!existing_msg.empty()) { - existing_msg += "; "; - } - existing_msg += new_error; -} - -void initialize_mcpl_interface_impl() -{ - g_mcpl_init_attempted = true; - g_mcpl_load_error_msg.clear(); - - // Try mcpl-config - if (!g_mcpl_lib_handle) { - FILE* pipe = nullptr; -#ifdef _WIN32 - pipe = _popen("mcpl-config --show libpath", "r"); -#else - pipe = popen("mcpl-config --show libpath 2>/dev/null", "r"); -#endif - if (pipe) { - char buffer[512]; - if (fgets(buffer, sizeof(buffer), pipe) != nullptr) { - std::string shlibpath = buffer; - // Remove trailing whitespace - while (!shlibpath.empty() && - std::isspace(static_cast(shlibpath.back()))) { - shlibpath.pop_back(); - } - - if (!shlibpath.empty()) { -#ifdef _WIN32 - g_mcpl_lib_handle = LoadLibraryA(shlibpath.c_str()); -#else - g_mcpl_lib_handle = dlopen(shlibpath.c_str(), RTLD_LAZY); -#endif - if (!g_mcpl_lib_handle) { - append_error( - g_mcpl_load_error_msg, fmt::format("From mcpl-config ({}): {}", - shlibpath, get_last_library_error())); - } - } - } -#ifdef _WIN32 - _pclose(pipe); -#else - pclose(pipe); -#endif - } else { // pipe failed to open - append_error(g_mcpl_load_error_msg, - "mcpl-config command not found or failed to execute"); - } - } - - // Try standard library names - if (!g_mcpl_lib_handle) { -#ifdef _WIN32 - const char* standard_names[] = {"mcpl.dll", "libmcpl.dll"}; -#else - const char* standard_names[] = {"libmcpl.so", "libmcpl.dylib"}; -#endif - for (const char* name : standard_names) { -#ifdef _WIN32 - g_mcpl_lib_handle = LoadLibraryA(name); -#else - g_mcpl_lib_handle = dlopen(name, RTLD_LAZY); -#endif - if (g_mcpl_lib_handle) - break; - } - if (!g_mcpl_lib_handle) { - append_error( - g_mcpl_load_error_msg, fmt::format("Using standard names (e.g. {}): {}", - standard_names[0], get_last_library_error())); - } - } - - if (!g_mcpl_lib_handle) { - if (mpi::master) { - warning(fmt::format("MCPL library could not be loaded. MCPL-dependent " - "features will be unavailable. Load attempts: {}", - g_mcpl_load_error_msg.empty() - ? "No specific error during load attempts." - : g_mcpl_load_error_msg)); - } - g_mcpl_successfully_loaded = false; - return; - } - - try { - g_mcpl_api = std::make_unique(g_mcpl_lib_handle); - g_mcpl_successfully_loaded = true; - // Do not call dlclose/FreeLibrary at exit. Leaking the handle is safer - // and standard practice for libraries used for the application's lifetime. - } catch (const std::runtime_error& e) { - append_error(g_mcpl_load_error_msg, - fmt::format( - "MCPL library loaded, but failed to bind symbols: {}", e.what())); - if (mpi::master) { - warning(g_mcpl_load_error_msg); - } -#ifdef _WIN32 - FreeLibrary(g_mcpl_lib_handle); -#else - dlclose(g_mcpl_lib_handle); -#endif - g_mcpl_lib_handle = nullptr; - g_mcpl_successfully_loaded = false; - } -} - -void initialize_mcpl_interface_if_needed() -{ - std::call_once(g_mcpl_init_flag, initialize_mcpl_interface_impl); -} - -bool is_mcpl_interface_available() -{ - initialize_mcpl_interface_if_needed(); - return g_mcpl_successfully_loaded; -} - -inline void ensure_mcpl_ready_or_fatal() -{ - initialize_mcpl_interface_if_needed(); - if (!g_mcpl_successfully_loaded) { - fatal_error("MCPL functionality is required, but the MCPL library is not " - "available or failed to initialize. Please ensure MCPL is " - "installed and its library can be found (e.g., via PATH on " - "Windows, LD_LIBRARY_PATH on Linux, or DYLD_LIBRARY_PATH on " - "macOS). You can often install MCPL with 'pip install mcpl' or " - "'conda install mcpl'."); - } -} - -SourceSite mcpl_particle_to_site(const mcpl_particle_repr_t* particle_repr) +#ifdef OPENMC_MCPL +SourceSite mcpl_particle_to_site(const mcpl_particle_t* particle) { SourceSite site; - site.particle = ParticleType {particle_repr->pdgcode}; + + switch (particle->pdgcode) { + case 2112: + site.particle = ParticleType::neutron; + break; + case 22: + site.particle = ParticleType::photon; + break; + case 11: + site.particle = ParticleType::electron; + break; + case -11: + site.particle = ParticleType::positron; + break; + } // Copy position and direction - site.r.x = particle_repr->position[0]; - site.r.y = particle_repr->position[1]; - site.r.z = particle_repr->position[2]; - site.u.x = particle_repr->direction[0]; - site.u.y = particle_repr->direction[1]; - site.u.z = particle_repr->direction[2]; + site.r.x = particle->position[0]; + site.r.y = particle->position[1]; + site.r.z = particle->position[2]; + site.u.x = particle->direction[0]; + site.u.y = particle->direction[1]; + site.u.z = particle->direction[2]; + // MCPL stores kinetic energy in [MeV], time in [ms] - site.E = particle_repr->ekin * 1e6; - site.time = particle_repr->time * 1e-3; - site.wgt = particle_repr->weight; + site.E = particle->ekin * 1e6; + site.time = particle->time * 1e-3; + site.wgt = particle->weight; + return site; } +#endif + +//============================================================================== vector mcpl_source_sites(std::string path) { - ensure_mcpl_ready_or_fatal(); vector sites; - mcpl_file_t* mcpl_file = g_mcpl_api->open_file(path.c_str()); - if (!mcpl_file) { - fatal_error(fmt::format("MCPL: Could not open file '{}'. It might be " - "missing, inaccessible, or not a valid MCPL file.", - path)); - } +#ifdef OPENMC_MCPL + // Open MCPL file and determine number of particles + auto mcpl_file = mcpl_open_file(path.c_str()); + size_t n_sites = mcpl_hdr_nparticles(mcpl_file); - size_t n_particles_in_file = g_mcpl_api->hdr_nparticles(mcpl_file); - if (n_particles_in_file > 0) { - sites.reserve(n_particles_in_file); - } - - for (size_t i = 0; i < n_particles_in_file; ++i) { - const mcpl_particle_repr_t* p_repr = g_mcpl_api->read(mcpl_file); - if (!p_repr) { - warning(fmt::format("MCPL: Read error or unexpected end of file '{}' " - "after reading {} of {} expected particles.", - path, sites.size(), n_particles_in_file)); - break; + for (int i = 0; i < n_sites; i++) { + // Extract particle from mcpl-file, checking if it is a neutron, photon, + // electron, or positron. Otherwise skip. + const mcpl_particle_t* particle; + int pdg = 0; + while (pdg != 2112 && pdg != 22 && pdg != 11 && pdg != -11) { + particle = mcpl_read(mcpl_file); + pdg = particle->pdgcode; } - sites.push_back(mcpl_particle_to_site(p_repr)); + + // Convert to source site and add to vector + sites.push_back(mcpl_particle_to_site(particle)); } - g_mcpl_api->close_file(mcpl_file); - + // Check that some sites were read if (sites.empty()) { - if (n_particles_in_file > 0) { - fatal_error(fmt::format( - "MCPL file '{}' contained {} particles, but no particles could be " - "read.", - path, n_particles_in_file)); - } else { - fatal_error(fmt::format( - "MCPL file '{}' is empty or contains no particle data.", path)); - } + fatal_error("MCPL file contained no neutron, photon, electron, or positron " + "source particles."); } + + mcpl_close_file(mcpl_file); +#else + fatal_error( + "Your build of OpenMC does not support reading MCPL source files."); +#endif + return sites; } -void write_mcpl_source_bank_internal(mcpl_outfile_t* file_id, - span local_source_bank, - const vector& bank_index_all_ranks) +//============================================================================== + +#ifdef OPENMC_MCPL +void write_mcpl_source_bank(mcpl_outfile_t file_id, + gsl::span source_bank, const vector& bank_index) { + int64_t dims_size = settings::n_particles; + int64_t count_size = simulation::work_per_rank; + if (mpi::master) { - if (!file_id) { - fatal_error("MCPL: Internal error - master rank called " - "write_mcpl_source_bank_internal with null file_id."); - } - vector receive_buffer; + // Particles are writeen to disk from the master node only - for (int rank_idx = 0; rank_idx < mpi::n_procs; ++rank_idx) { - size_t num_sites_on_rank = static_cast( - bank_index_all_ranks[rank_idx + 1] - bank_index_all_ranks[rank_idx]); - if (num_sites_on_rank == 0) - continue; - - span sites_to_write; + // Save source bank sites since the array is overwritten below #ifdef OPENMC_MPI - if (rank_idx == mpi::rank) { - sites_to_write = openmc::span( - local_source_bank.data(), num_sites_on_rank); - } else { - if (receive_buffer.size() < num_sites_on_rank) { - receive_buffer.resize(num_sites_on_rank); + vector temp_source {source_bank.begin(), source_bank.end()}; +#endif + + // loop over the other nodes and receive data - then write those. + for (int i = 0; i < mpi::n_procs; ++i) { + // number of particles for node node i + size_t count[] {static_cast(bank_index[i + 1] - bank_index[i])}; + +#ifdef OPENMC_MPI + if (i > 0) + MPI_Recv(source_bank.data(), count[0], mpi::source_site, i, i, + mpi::intracomm, MPI_STATUS_IGNORE); +#endif + // now write the source_bank data again. + for (const auto& site : source_bank) { + // particle is now at the iterator + // write it to the mcpl-file + mcpl_particle_t p; + p.position[0] = site.r.x; + p.position[1] = site.r.y; + p.position[2] = site.r.z; + + // mcpl requires that the direction vector is unit length + // which is also the case in openmc + p.direction[0] = site.u.x; + p.direction[1] = site.u.y; + p.direction[2] = site.u.z; + + // MCPL stores kinetic energy in [MeV], time in [ms] + p.ekin = site.E * 1e-6; + p.time = site.time * 1e3; + p.weight = site.wgt; + + switch (site.particle) { + case ParticleType::neutron: + p.pdgcode = 2112; + break; + case ParticleType::photon: + p.pdgcode = 22; + break; + case ParticleType::electron: + p.pdgcode = 11; + break; + case ParticleType::positron: + p.pdgcode = -11; + break; } - MPI_Recv(receive_buffer.data(), num_sites_on_rank, mpi::source_site, - rank_idx, rank_idx, mpi::intracomm, MPI_STATUS_IGNORE); - sites_to_write = openmc::span( - receive_buffer.data(), num_sites_on_rank); - } -#else - sites_to_write = openmc::span( - local_source_bank.data(), num_sites_on_rank); -#endif - for (const auto& site : sites_to_write) { - mcpl_particle_repr_t p_repr {}; - p_repr.position[0] = site.r.x; - p_repr.position[1] = site.r.y; - p_repr.position[2] = site.r.z; - p_repr.direction[0] = site.u.x; - p_repr.direction[1] = site.u.y; - p_repr.direction[2] = site.u.z; - p_repr.ekin = site.E * 1e-6; - p_repr.time = site.time * 1e3; - p_repr.weight = site.wgt; - p_repr.pdgcode = site.particle.pdg_number(); - g_mcpl_api->add_particle(file_id, &p_repr); + + mcpl_add_particle(file_id, &p); } } +#ifdef OPENMC_MPI + // Restore state of source bank + std::copy(temp_source.begin(), temp_source.end(), source_bank.begin()); +#endif } else { #ifdef OPENMC_MPI - if (!local_source_bank.empty()) { - MPI_Send(local_source_bank.data(), local_source_bank.size(), - mpi::source_site, 0, mpi::rank, mpi::intracomm); - } + MPI_Send(source_bank.data(), count_size, mpi::source_site, 0, mpi::rank, + mpi::intracomm); #endif } } +#endif -void write_mcpl_source_point(const char* filename, span source_bank, - const vector& bank_index) +//============================================================================== + +void write_mcpl_source_point(const char* filename, + gsl::span source_bank, const vector& bank_index) { - ensure_mcpl_ready_or_fatal(); - std::string filename_(filename); const auto extension = get_file_extension(filename_); - if (extension.empty()) { + if (extension == "") { filename_.append(".mcpl"); } else if (extension != "mcpl") { - warning(fmt::format("Specified filename '{}' has an extension '.{}', but " - "an MCPL file (.mcpl) will be written using this name.", - filename, extension)); + warning("write_mcpl_source_point was passed a file extension differing " + "from .mcpl, but an mcpl file will be written."); } - mcpl_outfile_t* file_id = nullptr; +#ifdef OPENMC_MCPL + mcpl_outfile_t file_id; + std::string line; if (mpi::master) { - file_id = g_mcpl_api->create_outfile(filename_.c_str()); - if (!file_id) { - fatal_error(fmt::format( - "MCPL: Failed to create output file '{}'. Check permissions and path.", - filename_)); - } - std::string src_line; + file_id = mcpl_create_outfile(filename_.c_str()); if (VERSION_DEV) { - src_line = fmt::format("OpenMC {}.{}.{}-dev{}", VERSION_MAJOR, - VERSION_MINOR, VERSION_RELEASE, VERSION_COMMIT_COUNT); + line = fmt::format("OpenMC {0}.{1}.{2}-development", VERSION_MAJOR, + VERSION_MINOR, VERSION_RELEASE); } else { - src_line = fmt::format( - "OpenMC {}.{}.{}", VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE); - } - g_mcpl_api->hdr_set_srcname(file_id, src_line.c_str()); - - // Initialize stat:sum with -1 to indicate incomplete file (issue #3514) - // This follows MCPL >= 2.1.0 convention for tracking simulation statistics - // The -1 value indicates "not available" if file creation is interrupted - if (g_mcpl_api->hdr_add_stat_sum) { - // Using key "openmc_np1" following tkittel's recommendation - // Initial value of -1 prevents misleading values in case of crashes - g_mcpl_api->hdr_add_stat_sum(file_id, "openmc_np1", -1.0); + line = fmt::format( + "OpenMC {0}.{1}.{2}", VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE); } + mcpl_hdr_set_srcname(file_id, line.c_str()); } - write_mcpl_source_bank_internal(file_id, source_bank, bank_index); + write_mcpl_source_bank(file_id, source_bank, bank_index); if (mpi::master) { - if (file_id) { - // Update stat:sum with actual particle count before closing (issue #3514) - // This represents the original number of source particles in the - // simulation (not the number of particles in the file) - if (g_mcpl_api->hdr_add_stat_sum) { - // Calculate total source particles from active batches - // Per issue #3514: this should be the original number of source - // particles, not the number written to the file - int64_t total_source_particles = - static_cast(settings::n_batches - settings::n_inactive) * - settings::gen_per_batch * settings::n_particles; - // Update with actual count - this overwrites the initial -1 value - g_mcpl_api->hdr_add_stat_sum( - file_id, "openmc_np1", static_cast(total_source_particles)); - } - - g_mcpl_api->close_outfile(file_id); - } + mcpl_close_outfile(file_id); } -} - -// Collision track feature with MCPL -void write_mcpl_collision_track_internal(mcpl_outfile_t* file_id, - span collision_track_bank, - const vector& bank_index_all_ranks) -{ - if (mpi::master) { - if (!file_id) { - fatal_error("MCPL: Internal error - master rank called " - "write_mcpl_source_bank_internal with null file_id."); - } - vector receive_buffer; - vector all_sites; - all_sites.reserve(static_cast(bank_index_all_ranks.back())); - vector all_blobs; - all_blobs.reserve(static_cast(bank_index_all_ranks.back())); - - for (int rank_idx = 0; rank_idx < mpi::n_procs; ++rank_idx) { - size_t num_sites_on_rank = static_cast( - bank_index_all_ranks[rank_idx + 1] - bank_index_all_ranks[rank_idx]); - if (num_sites_on_rank == 0) - continue; - - span sites_to_process; -#ifdef OPENMC_MPI - if (rank_idx == mpi::rank) { - sites_to_process = openmc::span( - collision_track_bank.data(), num_sites_on_rank); - } else { - receive_buffer.resize(num_sites_on_rank); - MPI_Recv(receive_buffer.data(), num_sites_on_rank, - mpi::collision_track_site, rank_idx, rank_idx, mpi::intracomm, - MPI_STATUS_IGNORE); - sites_to_process = openmc::span( - receive_buffer.data(), num_sites_on_rank); - } -#else - sites_to_process = openmc::span( - collision_track_bank.data(), num_sites_on_rank); #endif - - for (const auto& site : sites_to_process) { - std::ostringstream custom_data_stream; - custom_data_stream << " dE : " << site.dE - << " ; event_mt : " << site.event_mt - << " ; delayed_group : " << site.delayed_group - << " ; cell_id : " << site.cell_id - << " ; nuclide_id : " << site.nuclide_id - << " ; material_id : " << site.material_id - << " ; universe_id : " << site.universe_id - << " ; n_collision : " << site.n_collision - << " ; parent_id : " << site.parent_id - << " ; progeny_id : " << site.progeny_id; - - all_blobs.push_back(custom_data_stream.str()); - all_sites.push_back(site); - } - } - - for (size_t idx = 0; idx < all_blobs.size(); ++idx) { - const auto& blob = all_blobs[idx]; - std::string key = "blob_" + std::to_string(idx); - g_mcpl_api->hdr_add_data(file_id, key.c_str(), blob.size(), blob.c_str()); - } - - for (const auto& site : all_sites) { - mcpl_particle_repr_t p_repr {}; - p_repr.position[0] = site.r.x; - p_repr.position[1] = site.r.y; - p_repr.position[2] = site.r.z; - p_repr.direction[0] = site.u.x; - p_repr.direction[1] = site.u.y; - p_repr.direction[2] = site.u.z; - p_repr.ekin = site.E * 1e-6; - p_repr.time = site.time * 1e3; - p_repr.weight = site.wgt; - p_repr.pdgcode = site.particle.pdg_number(); - g_mcpl_api->add_particle(file_id, &p_repr); - } - } else { -#ifdef OPENMC_MPI - if (!collision_track_bank.empty()) { - MPI_Send(collision_track_bank.data(), collision_track_bank.size(), - mpi::collision_track_site, 0, mpi::rank, mpi::intracomm); - } -#endif - } -} - -void write_mcpl_collision_track(const char* filename, - span collision_track_bank, - const vector& bank_index) -{ - ensure_mcpl_ready_or_fatal(); - - std::string filename_(filename); - const auto extension = get_file_extension(filename_); - if (extension.empty()) { - filename_.append(".mcpl"); - } else if (extension != "mcpl") { - warning(fmt::format("Specified filename '{}' has an extension '.{}', but " - "an MCPL file (.mcpl) will be written using this name.", - filename, extension)); - } - - mcpl_outfile_t* file_id = nullptr; - - if (mpi::master) { - file_id = g_mcpl_api->create_outfile(filename_.c_str()); - if (!file_id) { - fatal_error(fmt::format( - "MCPL: Failed to create output file '{}'. Check permissions and path.", - filename_)); - } - std::string src_line; - if (VERSION_DEV) { - src_line = fmt::format("OpenMC {}.{}.{}-dev{}", VERSION_MAJOR, - VERSION_MINOR, VERSION_RELEASE, VERSION_COMMIT_COUNT); - } else { - src_line = fmt::format( - "OpenMC {}.{}.{}", VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE); - } - - g_mcpl_api->hdr_set_srcname(file_id, src_line.c_str()); - } - write_mcpl_collision_track_internal( - file_id, collision_track_bank, bank_index); - - if (mpi::master) { - if (file_id) { - g_mcpl_api->close_outfile(file_id); - } - } } } // namespace openmc diff --git a/src/mesh.cpp b/src/mesh.cpp index b05560d2a..c57dd5dcc 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1,23 +1,20 @@ #include "openmc/mesh.h" #include // for copy, equal, min, min_element -#include -#include // for ceil -#include // for size_t -#include // for uint64_t -#include // for memcpy -#include -#include // for accumulate +#include // for ceil +#include // for size_t +#include #include -#ifdef _MSC_VER -#include // for _InterlockedCompareExchange -#endif - #ifdef OPENMC_MPI #include "mpi.h" #endif -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xeval.hpp" +#include "xtensor/xmath.hpp" +#include "xtensor/xsort.hpp" +#include "xtensor/xtensor.hpp" +#include "xtensor/xview.hpp" #include // for fmt #include "openmc/capi.h" @@ -31,27 +28,23 @@ #include "openmc/memory.h" #include "openmc/message_passing.h" #include "openmc/openmp_interface.h" -#include "openmc/output.h" #include "openmc/particle_data.h" #include "openmc/plot.h" #include "openmc/random_dist.h" #include "openmc/search.h" #include "openmc/settings.h" -#include "openmc/string_utils.h" #include "openmc/tallies/filter.h" #include "openmc/tallies/tally.h" -#include "openmc/timer.h" #include "openmc/volume_calc.h" #include "openmc/xml_interface.h" -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH #include "libmesh/mesh_modification.h" #include "libmesh/mesh_tools.h" #include "libmesh/numeric_vector.h" -#include "libmesh/replicated_mesh.h" #endif -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC #include "moab/FileOptions.hpp" #endif @@ -61,16 +54,12 @@ namespace openmc { // Global variables //============================================================================== -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH const bool LIBMESH_ENABLED = true; #else const bool LIBMESH_ENABLED = false; #endif -// Value used to indicate an empty slot in the hash table. We use -2 because -// the value -1 is used to indicate a void material. -constexpr int32_t EMPTY = -2; - namespace model { std::unordered_map mesh_map; @@ -78,7 +67,7 @@ vector> meshes; } // namespace model -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH namespace settings { unique_ptr libmesh_init; const libMesh::Parallel::Communicator* libmesh_comm {nullptr}; @@ -112,281 +101,19 @@ inline bool check_intersection_point(double x1, double x0, double y1, double y0, return false; } -//! Atomic compare-and-swap for signed 32-bit integer -// -//! \param[in,out] ptr Pointer to value to update -//! \param[in,out] expected Value to compare to -//! \param[in] desired If comparison is successful, value to update to -//! \return True if the comparison was successful and the value was updated -inline bool atomic_cas_int32(int32_t* ptr, int32_t& expected, int32_t desired) -{ -#if defined(__GNUC__) || defined(__clang__) - // For gcc/clang, use the __atomic_compare_exchange_n intrinsic - return __atomic_compare_exchange_n( - ptr, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); - -#elif defined(_MSC_VER) - // For MSVC, use the _InterlockedCompareExchange intrinsic - int32_t old_val = - _InterlockedCompareExchange(reinterpret_cast(ptr), - static_cast(desired), static_cast(expected)); - return (old_val == expected); - -#else -#error "No compare-and-swap implementation available for this compiler." -#endif -} - -// Helper function equivalent to std::bit_cast in C++20 -template -inline To bit_cast_value(const From& value) -{ - To out; - std::memcpy(&out, &value, sizeof(To)); - return out; -} - -inline void atomic_update_double(double* ptr, double value, bool is_min) -{ -#if defined(__GNUC__) || defined(__clang__) - using may_alias_uint64_t [[gnu::may_alias]] = uint64_t; - auto* bits_ptr = reinterpret_cast(ptr); - uint64_t current_bits = __atomic_load_n(bits_ptr, __ATOMIC_SEQ_CST); - double current = bit_cast_value(current_bits); - while (is_min ? (value < current) : (value > current)) { - uint64_t desired_bits = bit_cast_value(value); - uint64_t expected_bits = current_bits; - if (__atomic_compare_exchange_n(bits_ptr, &expected_bits, desired_bits, - false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { - return; - } - current_bits = expected_bits; - current = bit_cast_value(current_bits); - } - -#elif defined(_MSC_VER) - auto* bits_ptr = reinterpret_cast(ptr); - long long current_bits = *bits_ptr; - double current = bit_cast_value(current_bits); - while (is_min ? (value < current) : (value > current)) { - long long desired_bits = bit_cast_value(value); - long long old_bits = - _InterlockedCompareExchange64(bits_ptr, desired_bits, current_bits); - if (old_bits == current_bits) { - return; - } - current_bits = old_bits; - current = bit_cast_value(current_bits); - } - -#else -#error "No compare-and-swap implementation available for this compiler." -#endif -} - -inline void atomic_max_double(double* ptr, double value) -{ - atomic_update_double(ptr, value, false); -} - -inline void atomic_min_double(double* ptr, double value) -{ - atomic_update_double(ptr, value, true); -} - -namespace detail { - -//============================================================================== -// MaterialVolumes implementation -//============================================================================== - -void MaterialVolumes::add_volume( - int index_elem, int index_material, double volume, const BoundingBox* bbox) -{ - // This method handles adding elements to the materials hash table, - // implementing open addressing with linear probing. Consistency across - // multiple threads is handled by with an atomic compare-and-swap operation. - // Ideally, we would use #pragma omp atomic compare, but it was introduced in - // OpenMP 5.1 and is not widely supported yet. - - // Loop for linear probing - for (int attempt = 0; attempt < table_size_; ++attempt) { - // Determine slot to check, making sure it is positive - int slot = (index_material + attempt) % table_size_; - if (slot < 0) - slot += table_size_; - int32_t* slot_ptr = &this->materials(index_elem, slot); - - // Non-atomic read of current material - int32_t current_val = *slot_ptr; - - // Found the desired material; accumulate volume and bbox - if (current_val == index_material) { -#pragma omp atomic - this->volumes(index_elem, slot) += volume; - if (bbox) { - atomic_min_double(&this->bboxes(index_elem, slot, 0), bbox->min.x); - atomic_min_double(&this->bboxes(index_elem, slot, 1), bbox->min.y); - atomic_min_double(&this->bboxes(index_elem, slot, 2), bbox->min.z); - atomic_max_double(&this->bboxes(index_elem, slot, 3), bbox->max.x); - atomic_max_double(&this->bboxes(index_elem, slot, 4), bbox->max.y); - atomic_max_double(&this->bboxes(index_elem, slot, 5), bbox->max.z); - } - return; - } - - // Slot appears to be empty; attempt to claim - if (current_val == EMPTY) { - // Attempt compare-and-swap from EMPTY to index_material - int32_t expected_val = EMPTY; - bool claimed_slot = - atomic_cas_int32(slot_ptr, expected_val, index_material); - - // If we claimed the slot or another thread claimed it but the same - // material was inserted, proceed to accumulate - if (claimed_slot || (expected_val == index_material)) { -#pragma omp atomic - this->volumes(index_elem, slot) += volume; - if (bbox) { - atomic_min_double(&this->bboxes(index_elem, slot, 0), bbox->min.x); - atomic_min_double(&this->bboxes(index_elem, slot, 1), bbox->min.y); - atomic_min_double(&this->bboxes(index_elem, slot, 2), bbox->min.z); - atomic_max_double(&this->bboxes(index_elem, slot, 3), bbox->max.x); - atomic_max_double(&this->bboxes(index_elem, slot, 4), bbox->max.y); - atomic_max_double(&this->bboxes(index_elem, slot, 5), bbox->max.z); - } - return; - } - } - } - - // If table is full, set a flag that can be checked later - table_full_ = true; -} - -void MaterialVolumes::add_volume_unsafe( - int index_elem, int index_material, double volume, const BoundingBox* bbox) -{ - // Linear probe - for (int attempt = 0; attempt < table_size_; ++attempt) { - // Determine slot to check, making sure it is positive - int slot = (index_material + attempt) % table_size_; - if (slot < 0) - slot += table_size_; - - // Read current material - int32_t current_val = this->materials(index_elem, slot); - - // Found the desired material; accumulate volume and bbox - if (current_val == index_material) { - this->volumes(index_elem, slot) += volume; - if (bbox) { - this->bboxes(index_elem, slot, 0) = - std::min(this->bboxes(index_elem, slot, 0), bbox->min.x); - this->bboxes(index_elem, slot, 1) = - std::min(this->bboxes(index_elem, slot, 1), bbox->min.y); - this->bboxes(index_elem, slot, 2) = - std::min(this->bboxes(index_elem, slot, 2), bbox->min.z); - this->bboxes(index_elem, slot, 3) = - std::max(this->bboxes(index_elem, slot, 3), bbox->max.x); - this->bboxes(index_elem, slot, 4) = - std::max(this->bboxes(index_elem, slot, 4), bbox->max.y); - this->bboxes(index_elem, slot, 5) = - std::max(this->bboxes(index_elem, slot, 5), bbox->max.z); - } - return; - } - - // Claim empty slot - if (current_val == EMPTY) { - this->materials(index_elem, slot) = index_material; - this->volumes(index_elem, slot) += volume; - if (bbox) { - this->bboxes(index_elem, slot, 0) = - std::min(this->bboxes(index_elem, slot, 0), bbox->min.x); - this->bboxes(index_elem, slot, 1) = - std::min(this->bboxes(index_elem, slot, 1), bbox->min.y); - this->bboxes(index_elem, slot, 2) = - std::min(this->bboxes(index_elem, slot, 2), bbox->min.z); - this->bboxes(index_elem, slot, 3) = - std::max(this->bboxes(index_elem, slot, 3), bbox->max.x); - this->bboxes(index_elem, slot, 4) = - std::max(this->bboxes(index_elem, slot, 4), bbox->max.y); - this->bboxes(index_elem, slot, 5) = - std::max(this->bboxes(index_elem, slot, 5), bbox->max.z); - } - return; - } - } - - // If table is full, set a flag that can be checked later - table_full_ = true; -} - -} // namespace detail - //============================================================================== // Mesh implementation //============================================================================== -template -const std::unique_ptr& Mesh::create( - T dataset, const std::string& mesh_type, const std::string& mesh_library) -{ - // Determine mesh type. Add to model vector and map - if (mesh_type == RegularMesh::mesh_type) { - model::meshes.push_back(make_unique(dataset)); - } else if (mesh_type == RectilinearMesh::mesh_type) { - model::meshes.push_back(make_unique(dataset)); - } else if (mesh_type == CylindricalMesh::mesh_type) { - model::meshes.push_back(make_unique(dataset)); - } else if (mesh_type == SphericalMesh::mesh_type) { - model::meshes.push_back(make_unique(dataset)); -#ifdef OPENMC_DAGMC_ENABLED - } else if (mesh_type == UnstructuredMesh::mesh_type && - mesh_library == MOABMesh::mesh_lib_type) { - model::meshes.push_back(make_unique(dataset)); -#endif -#ifdef OPENMC_LIBMESH_ENABLED - } else if (mesh_type == UnstructuredMesh::mesh_type && - mesh_library == LibMesh::mesh_lib_type) { - model::meshes.push_back(make_unique(dataset)); -#endif - } else if (mesh_type == UnstructuredMesh::mesh_type) { - fatal_error("Unstructured mesh support is not enabled or the mesh " - "library is invalid."); - } else { - fatal_error(fmt::format("Invalid mesh type: {}", mesh_type)); - } - - // Map ID to position in vector - model::mesh_map[model::meshes.back()->id_] = model::meshes.size() - 1; - - return model::meshes.back(); -} - Mesh::Mesh(pugi::xml_node node) { // Read mesh id id_ = std::stoi(get_node_value(node, "id")); - if (check_for_node(node, "name")) - name_ = get_node_value(node, "name"); -} - -Mesh::Mesh(hid_t group) -{ - // Read mesh ID - read_attribute(group, "id", id_); - - // Read mesh name - if (object_exists(group, "name")) { - read_dataset(group, "name", name_); - } } void Mesh::set_id(int32_t id) { - assert(id >= 0 || id == C_NONE); + Expects(id >= 0 || id == C_NONE); // Clear entry in mesh map in case one was already assigned if (id_ != C_NONE) { @@ -411,13 +138,7 @@ void Mesh::set_id(int32_t id) // Update ID and entry in the mesh map id_ = id; - - // find the index of this mesh in the model::meshes vector - // (search in reverse because this mesh was likely just added to the vector) - auto it = std::find_if(model::meshes.rbegin(), model::meshes.rend(), - [this](const std::unique_ptr& mesh) { return mesh.get() == this; }); - - model::mesh_map[id] = std::distance(model::meshes.begin(), it.base()) - 1; + model::mesh_map[id] = model::meshes.size() - 1; } vector Mesh::volumes() const @@ -429,325 +150,90 @@ vector Mesh::volumes() const return volumes; } -void Mesh::material_volumes(int nx, int ny, int nz, int table_size, - int32_t* materials, double* volumes) const +int Mesh::material_volumes( + int n_sample, int bin, gsl::span result, uint64_t* seed) const { - this->material_volumes(nx, ny, nz, table_size, materials, volumes, nullptr); -} - -void Mesh::material_volumes(int nx, int ny, int nz, int table_size, - int32_t* materials, double* volumes, double* bboxes) const -{ - if (mpi::master) { - header("MESH MATERIAL VOLUMES CALCULATION", 7); - } - write_message(7, "Number of mesh elements = {}", n_bins()); - write_message(7, "Number of rays (x) = {}", nx); - write_message(7, "Number of rays (y) = {}", ny); - write_message(7, "Number of rays (z) = {}", nz); - int64_t n_total = static_cast(nx) * ny + - static_cast(ny) * nz + - static_cast(nx) * nz; - write_message(7, "Total number of rays = {}", n_total); - write_message(7, "Table size per mesh element = {}", table_size); - - Timer timer; - timer.start(); - - // Create object for keeping track of materials/volumes - detail::MaterialVolumes result(materials, volumes, bboxes, table_size); - bool compute_bboxes = bboxes != nullptr; - - // Determine bounding box - auto bbox = this->bounding_box(); - - std::array n_rays = {nx, ny, nz}; - - // Determine effective width of rays - Position width = bbox.max - bbox.min; - width.x = (nx > 0) ? width.x / nx : 0.0; - width.y = (ny > 0) ? width.y / ny : 0.0; - width.z = (nz > 0) ? width.z / nz : 0.0; - - // Set flag for mesh being contained within model - bool out_of_model = false; + vector materials; + vector hits; #pragma omp parallel { - // Preallocate vector for mesh indices and length fractions and particle - vector bins; - vector length_fractions; - Particle p; + vector local_materials; + vector local_hits; + GeometryState geom; - SourceSite site; - site.E = 1.0; - site.particle = ParticleType::neutron(); - - for (int axis = 0; axis < 3; ++axis) { - // Set starting position and direction - site.r = {0.0, 0.0, 0.0}; - site.r[axis] = bbox.min[axis]; - site.u = {0.0, 0.0, 0.0}; - site.u[axis] = 1.0; - - // Determine width of rays and number of rays in other directions - int ax1 = (axis + 1) % 3; - int ax2 = (axis + 2) % 3; - double min1 = bbox.min[ax1]; - double min2 = bbox.min[ax2]; - double d1 = width[ax1]; - double d2 = width[ax2]; - int n1 = n_rays[ax1]; - int n2 = n_rays[ax2]; - if (n1 == 0 || n2 == 0) { - continue; - } - - // Divide rays in first direction over MPI processes by computing starting - // and ending indices - int min_work = n1 / mpi::n_procs; - int remainder = n1 % mpi::n_procs; - int n1_local = (mpi::rank < remainder) ? min_work + 1 : min_work; - int i1_start = mpi::rank * min_work + std::min(mpi::rank, remainder); - int i1_end = i1_start + n1_local; - - // Loop over rays on face of bounding box -#pragma omp for collapse(2) - for (int i1 = i1_start; i1 < i1_end; ++i1) { - for (int i2 = 0; i2 < n2; ++i2) { - site.r[ax1] = min1 + (i1 + 0.5) * d1; - site.r[ax2] = min2 + (i2 + 0.5) * d2; - - p.from_source(&site); - - // Determine particle's location - if (!exhaustive_find_cell(p)) { - out_of_model = true; - continue; - } - - // Set birth cell attribute - if (p.cell_born() == C_NONE) - p.cell_born() = p.lowest_coord().cell(); - - // Initialize last cells from current cell - for (int j = 0; j < p.n_coord(); ++j) { - p.cell_last(j) = p.coord(j).cell(); - } - p.n_coord_last() = p.n_coord(); - - while (true) { - // Ray trace from r_start to r_end - Position r0 = p.r(); - double max_distance = bbox.max[axis] - r0[axis]; - - // Find the distance to the nearest boundary - BoundaryInfo boundary = distance_to_boundary(p); - - // Advance particle forward - double distance = std::min(boundary.distance(), max_distance); - p.move_distance(distance); - - // Determine what mesh elements were crossed by particle - bins.clear(); - length_fractions.clear(); - this->bins_crossed(r0, p.r(), p.u(), bins, length_fractions); - - // Add volumes to any mesh elements that were crossed - int i_material = p.material(); - if (i_material != C_NONE) { - i_material = model::materials[i_material]->id(); - } - double cumulative_frac = 0.0; - for (int i_bin = 0; i_bin < bins.size(); i_bin++) { - int mesh_index = bins[i_bin]; - double length = distance * length_fractions[i_bin]; - double volume = length * d1 * d2; - - if (compute_bboxes) { - double axis_start = r0[axis] + distance * cumulative_frac; - double axis_end = axis_start + length; - cumulative_frac += length_fractions[i_bin]; - - Position contrib_min = site.r; - Position contrib_max = site.r; - - contrib_min[ax1] = site.r[ax1] - 0.5 * d1; - contrib_max[ax1] = site.r[ax1] + 0.5 * d1; - contrib_min[ax2] = site.r[ax2] - 0.5 * d2; - contrib_max[ax2] = site.r[ax2] + 0.5 * d2; - contrib_min[axis] = std::min(axis_start, axis_end); - contrib_max[axis] = std::max(axis_start, axis_end); - - BoundingBox contrib_bbox {contrib_min, contrib_max}; - contrib_bbox &= bbox; - - result.add_volume( - mesh_index, i_material, volume, &contrib_bbox); - } else { - // Add volume to result - result.add_volume(mesh_index, i_material, volume); - } - } - - if (distance == max_distance) - break; - - // cross next geometric surface - for (int j = 0; j < p.n_coord(); ++j) { - p.cell_last(j) = p.coord(j).cell(); - } - p.n_coord_last() = p.n_coord(); - - // Set surface that particle is on and adjust coordinate levels - p.surface() = boundary.surface(); - p.n_coord() = boundary.coord_level(); - - if (boundary.lattice_translation()[0] != 0 || - boundary.lattice_translation()[1] != 0 || - boundary.lattice_translation()[2] != 0) { - // Particle crosses lattice boundary - cross_lattice(p, boundary); - } else { - // Particle crosses surface - const auto& surf {model::surfaces[p.surface_index()].get()}; - p.cross_surface(*surf); - } - } - } - } - } - } - - // Check for errors - if (out_of_model) { - throw std::runtime_error("Mesh not fully contained in geometry."); - } else if (result.table_full()) { - throw std::runtime_error("Maximum number of materials for mesh material " - "volume calculation insufficient."); - } - - // Compute time for raytracing - double t_raytrace = timer.elapsed(); - -#ifdef OPENMC_MPI - // Combine results from multiple MPI processes - if (mpi::n_procs > 1) { - int total = this->n_bins() * table_size; - int total_bbox = total * 6; - if (mpi::master) { - // Allocate temporary buffer for receiving data - vector mats(total); - vector vols(total); - vector recv_bboxes; - if (compute_bboxes) { - recv_bboxes.resize(total_bbox); - } - - for (int i = 1; i < mpi::n_procs; ++i) { - // Receive material indices and volumes from process i - MPI_Recv(mats.data(), total, MPI_INT32_T, i, i, mpi::intracomm, - MPI_STATUS_IGNORE); - MPI_Recv(vols.data(), total, MPI_DOUBLE, i, i, mpi::intracomm, - MPI_STATUS_IGNORE); - if (compute_bboxes) { - MPI_Recv(recv_bboxes.data(), total_bbox, MPI_DOUBLE, i, i, - mpi::intracomm, MPI_STATUS_IGNORE); - } - - // Combine with existing results; we can call thread unsafe version of - // add_volume because each thread is operating on a different element #pragma omp for - for (int index_elem = 0; index_elem < n_bins(); ++index_elem) { - for (int k = 0; k < table_size; ++k) { - int index = index_elem * table_size + k; - if (mats[index] != EMPTY) { - if (compute_bboxes) { - int bbox_index = index * 6; - BoundingBox slot_bbox { - {recv_bboxes[bbox_index + 0], recv_bboxes[bbox_index + 1], - recv_bboxes[bbox_index + 2]}, - {recv_bboxes[bbox_index + 3], recv_bboxes[bbox_index + 4], - recv_bboxes[bbox_index + 5]}}; - result.add_volume_unsafe( - index_elem, mats[index], vols[index], &slot_bbox); - } else { - result.add_volume_unsafe(index_elem, mats[index], vols[index]); - } - } - } - } + for (int i = 0; i < n_sample; ++i) { + // Get seed for i-th sample + uint64_t seed_i = future_seed(3 * i, *seed); + + // Sample position and set geometry state + geom.r() = this->sample_element(bin, &seed_i); + geom.u() = {1., 0., 0.}; + geom.n_coord() = 1; + + // If this location is not in the geometry at all, move on to next block + if (!exhaustive_find_cell(geom)) + continue; + + int i_material = geom.material(); + + // Check if this material was previously hit and if so, increment count + auto it = + std::find(local_materials.begin(), local_materials.end(), i_material); + if (it == local_materials.end()) { + local_materials.push_back(i_material); + local_hits.push_back(1); + } else { + local_hits[it - local_materials.begin()]++; } - } else { - // Send material indices and volumes to process 0 - MPI_Send(materials, total, MPI_INT32_T, 0, mpi::rank, mpi::intracomm); - MPI_Send(volumes, total, MPI_DOUBLE, 0, mpi::rank, mpi::intracomm); - if (compute_bboxes) { - MPI_Send(bboxes, total_bbox, MPI_DOUBLE, 0, mpi::rank, mpi::intracomm); - } - } + } // omp for + + // Reduce index/hits lists from each thread into a single copy + reduce_indices_hits(local_materials, local_hits, materials, hits); + } // omp parallel + + // Advance RNG seed + advance_prn_seed(3 * n_sample, seed); + + // Make sure span passed in is large enough + if (hits.size() > result.size()) { + return -1; } - // Report time for MPI communication - double t_mpi = timer.elapsed() - t_raytrace; -#else - double t_mpi = 0.0; -#endif - - // Normalize based on known volumes of elements - for (int i = 0; i < this->n_bins(); ++i) { - // Estimated total volume in element i - double volume = 0.0; - for (int j = 0; j < table_size; ++j) { - volume += result.volumes(i, j); - } - // Renormalize volumes based on known volume of element i - double norm = this->volume(i) / volume; - for (int j = 0; j < table_size; ++j) { - result.volumes(i, j) *= norm; - } + // Convert hits to fractions + for (int i_mat = 0; i_mat < hits.size(); ++i_mat) { + double fraction = double(hits[i_mat]) / n_sample; + result[i_mat].material = materials[i_mat]; + result[i_mat].volume = fraction * this->volume(bin); } - - // Get total time and normalization time - timer.stop(); - double t_total = timer.elapsed(); - double t_norm = t_total - t_raytrace - t_mpi; - - // Show timing statistics - if (settings::verbosity < 7 || !mpi::master) - return; - header("Timing Statistics", 7); - fmt::print(" Total time elapsed = {:.4e} seconds\n", t_total); - fmt::print(" Ray tracing = {:.4e} seconds\n", t_raytrace); - fmt::print(" MPI communication = {:.4e} seconds\n", t_mpi); - fmt::print(" Normalization = {:.4e} seconds\n", t_norm); - fmt::print(" Calculation rate = {:.4e} rays/seconds\n", - n_total / t_raytrace); - fmt::print(" Calculation rate (per thread) = {:.4e} rays/seconds\n", - n_total / (t_raytrace * mpi::n_procs * num_threads())); - std::fflush(stdout); + return hits.size(); } -void Mesh::to_hdf5(hid_t group) const +vector Mesh::material_volumes( + int n_sample, int bin, uint64_t* seed) const { - // Create group for mesh - std::string group_name = fmt::format("mesh {}", id_); - hid_t mesh_group = create_group(group, group_name.c_str()); + // Create result vector with space for 8 pairs + vector result; + result.reserve(8); - // Write mesh type - write_dataset(mesh_group, "type", this->get_mesh_type()); + int size = -1; + while (true) { + // Get material volumes + size = this->material_volumes( + n_sample, bin, {result.data(), result.data() + result.capacity()}, seed); - // Write mesh ID - write_attribute(mesh_group, "id", id_); + // If capacity was sufficient, resize the vector and return + if (size >= 0) { + result.resize(size); + break; + } - // Write mesh name - write_dataset(mesh_group, "name", name_); + // Otherwise, increase capacity of the vector + result.reserve(2 * result.capacity()); + } - // Write mesh data - this->to_hdf5_inner(mesh_group); - - // Close group - close_group(mesh_group); + return result; } //============================================================================== @@ -767,9 +253,11 @@ std::string StructuredMesh::bin_label(int bin) const } } -tensor::Tensor StructuredMesh::get_shape_tensor() const +xt::xtensor StructuredMesh::get_x_shape() const { - return tensor::Tensor(shape_.data(), static_cast(n_dimension_)); + // because method is const, shape_ is const as well and can't be adapted + auto tmp_shape = shape_; + return xt::adapt(tmp_shape, {n_dimension_}); } Position StructuredMesh::sample_element( @@ -795,7 +283,6 @@ Position StructuredMesh::sample_element( UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) { - n_dimension_ = 3; // check the mesh type if (check_for_node(node, "type")) { @@ -832,68 +319,6 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) } } -UnstructuredMesh::UnstructuredMesh(hid_t group) : Mesh(group) -{ - n_dimension_ = 3; - - // check the mesh type - if (object_exists(group, "type")) { - std::string temp; - read_dataset(group, "type", temp); - if (temp != mesh_type) { - fatal_error(fmt::format("Invalid mesh type: {}", temp)); - } - } - - // check if a length unit multiplier was specified - if (object_exists(group, "length_multiplier")) { - read_dataset(group, "length_multiplier", length_multiplier_); - } - - // get the filename of the unstructured mesh to load - if (object_exists(group, "filename")) { - read_dataset(group, "filename", filename_); - if (!file_exists(filename_)) { - fatal_error("Mesh file '" + filename_ + "' does not exist!"); - } - } else { - fatal_error(fmt::format( - "No filename supplied for unstructured mesh with ID: {}", id_)); - } - - if (attribute_exists(group, "options")) { - read_attribute(group, "options", options_); - } - - // check if mesh tally data should be written with - // statepoint files - if (attribute_exists(group, "output")) { - read_attribute(group, "output", output_); - } -} - -void UnstructuredMesh::determine_bounds() -{ - double xmin = INFTY; - double ymin = INFTY; - double zmin = INFTY; - double xmax = -INFTY; - double ymax = -INFTY; - double zmax = -INFTY; - int n = this->n_vertices(); - for (int i = 0; i < n; ++i) { - auto v = this->vertex(i); - xmin = std::min(v.x, xmin); - ymin = std::min(v.y, ymin); - zmin = std::min(v.z, zmin); - xmax = std::max(v.x, xmax); - ymax = std::max(v.y, ymax); - zmax = std::max(v.z, zmax); - } - lower_left_ = {xmin, ymin, zmin}; - upper_right_ = {xmax, ymax, zmax}; -} - Position UnstructuredMesh::sample_tet( std::array coords, uint64_t* seed) const { @@ -942,8 +367,11 @@ std::string UnstructuredMesh::bin_label(int bin) const return fmt::format("Mesh Index ({})", bin); }; -void UnstructuredMesh::to_hdf5_inner(hid_t mesh_group) const +void UnstructuredMesh::to_hdf5(hid_t group) const { + hid_t mesh_group = create_group(group, fmt::format("mesh {}", id_)); + + write_dataset(mesh_group, "type", mesh_type); write_dataset(mesh_group, "filename", filename_); write_dataset(mesh_group, "library", this->library()); if (!options_.empty()) { @@ -954,11 +382,10 @@ void UnstructuredMesh::to_hdf5_inner(hid_t mesh_group) const write_dataset(mesh_group, "length_multiplier", length_multiplier_); // write vertex coordinates - tensor::Tensor vertices( - {static_cast(this->n_vertices()), static_cast(3)}); + xt::xtensor vertices({static_cast(this->n_vertices()), 3}); for (int i = 0; i < this->n_vertices(); i++) { auto v = this->vertex(i); - vertices.slice(i) = {v.x, v.y, v.z}; + xt::view(vertices, i, xt::all()) = xt::xarray({v.x, v.y, v.z}); } write_dataset(mesh_group, "vertices", vertices); @@ -966,10 +393,8 @@ void UnstructuredMesh::to_hdf5_inner(hid_t mesh_group) const // write element types and connectivity vector volumes; - tensor::Tensor connectivity( - {static_cast(this->n_bins()), static_cast(8)}); - tensor::Tensor elem_types( - {static_cast(this->n_bins()), static_cast(1)}); + xt::xtensor connectivity({static_cast(this->n_bins()), 8}); + xt::xtensor elem_types({static_cast(this->n_bins()), 1}); for (int i = 0; i < this->n_bins(); i++) { auto conn = this->connectivity(i); @@ -977,18 +402,21 @@ void UnstructuredMesh::to_hdf5_inner(hid_t mesh_group) const // write linear tet element if (conn.size() == 4) { - elem_types.slice(i) = static_cast(ElementType::LINEAR_TET); - connectivity.slice(i) = { - conn[0], conn[1], conn[2], conn[3], -1, -1, -1, -1}; + xt::view(elem_types, i, xt::all()) = + static_cast(ElementType::LINEAR_TET); + xt::view(connectivity, i, xt::all()) = + xt::xarray({conn[0], conn[1], conn[2], conn[3], -1, -1, -1, -1}); // write linear hex element } else if (conn.size() == 8) { - elem_types.slice(i) = static_cast(ElementType::LINEAR_HEX); - connectivity.slice(i) = { - conn[0], conn[1], conn[2], conn[3], conn[4], conn[5], conn[6], conn[7]}; + xt::view(elem_types, i, xt::all()) = + static_cast(ElementType::LINEAR_HEX); + xt::view(connectivity, i, xt::all()) = xt::xarray({conn[0], conn[1], + conn[2], conn[3], conn[4], conn[5], conn[6], conn[7]}); } else { num_elem_skipped++; - elem_types.slice(i) = static_cast(ElementType::UNSUPPORTED); - connectivity.slice(i) = -1; + xt::view(elem_types, i, xt::all()) = + static_cast(ElementType::UNSUPPORTED); + xt::view(connectivity, i, xt::all()) = -1; } } @@ -1003,6 +431,8 @@ void UnstructuredMesh::to_hdf5_inner(hid_t mesh_group) const write_dataset(mesh_group, "volumes", volumes); write_dataset(mesh_group, "connectivity", connectivity); write_dataset(mesh_group, "element_types", elem_types); + + close_group(mesh_group); } void UnstructuredMesh::set_length_multiplier(double length_multiplier) @@ -1080,29 +510,16 @@ int StructuredMesh::get_bin(Position r) const int StructuredMesh::n_bins() const { - // Bin indices are stored as 32-bit ints in the tally system. - int64_t n = 1; - for (int i = 0; i < n_dimension_; ++i) - n *= shape_[i]; - if (n > std::numeric_limits::max()) { - fatal_error(fmt::format( - "Mesh {} has too many bins ({}) for 32-bit tally indexing", id_, n)); - } - return static_cast(n); + return std::accumulate( + shape_.begin(), shape_.begin() + n_dimension_, 1, std::multiplies<>()); } int StructuredMesh::n_surface_bins() const { - // Surface bin indices are stored as 32-bit ints in the tally system. - int64_t n = static_cast(n_bins()) * 4 * n_dimension_; - if (n > std::numeric_limits::max()) { - fatal_error(fmt::format( - "Mesh {} has too many surface bins ({}) for tally indexing", id_, n)); - } - return static_cast(n); + return 4 * n_dimension_ * n_bins(); } -tensor::Tensor StructuredMesh::count_sites( +xt::xtensor StructuredMesh::count_sites( const SourceSite* bank, int64_t length, bool* outside) const { // Determine shape of array for counts @@ -1110,7 +527,7 @@ tensor::Tensor StructuredMesh::count_sites( vector shape = {m}; // Create array of zeros - auto cnt = tensor::zeros(shape); + xt::xarray cnt {shape, 0.0}; bool outside_ = false; for (int64_t i = 0; i < length; i++) { @@ -1129,31 +546,37 @@ tensor::Tensor StructuredMesh::count_sites( cnt(mesh_bin) += site.wgt; } - // Create reduced count data - auto counts = tensor::zeros(shape); + // Create copy of count data. Since ownership will be acquired by xtensor, + // std::allocator must be used to avoid Valgrind mismatched free() / delete + // warnings. int total = cnt.size(); + double* cnt_reduced = std::allocator {}.allocate(total); #ifdef OPENMC_MPI // collect values from all processors MPI_Reduce( - cnt.data(), counts.data(), total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); + cnt.data(), cnt_reduced, total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); // Check if there were sites outside the mesh for any processor if (outside) { MPI_Reduce(&outside_, outside, 1, MPI_C_BOOL, MPI_LOR, 0, mpi::intracomm); } #else - std::copy(cnt.data(), cnt.data() + total, counts.data()); + std::copy(cnt.data(), cnt.data() + total, cnt_reduced); if (outside) *outside = outside_; #endif + // Adapt reduced values in array back into an xarray + auto arr = xt::adapt(cnt_reduced, total, xt::acquire_ownership(), shape); + xt::xarray counts = arr; + return counts; } // raytrace through the mesh. The template class T will do the tallying. -// A modern optimizing compiler can recognize the noop method of T and -// eliminate that call entirely. +// A modern optimizing compiler can recognize the noop method of T and eleminate +// that call entirely. template void StructuredMesh::raytrace_mesh( Position r0, Position r1, const Direction& u, T tally) const @@ -1169,11 +592,6 @@ void StructuredMesh::raytrace_mesh( if (total_distance == 0.0 && settings::solver_type != SolverType::RANDOM_RAY) return; - // keep a copy of the original global position to pass to get_indices, - // which performs its own transformation to local coordinates - Position global_r = r0; - Position local_r = local_coords(r0); - const int n = n_dimension_; // Flag if position is inside the mesh @@ -1184,7 +602,7 @@ void StructuredMesh::raytrace_mesh( // Calculate index of current cell. Offset the position a tiny bit in // direction of flight - MeshIndex ijk = get_indices(global_r + TINY_BIT * u, in_mesh); + MeshIndex ijk = get_indices(r0 + TINY_BIT * u, in_mesh); // if track is very short, assume that it is completely inside one cell. // Only the current cell will score and no surfaces @@ -1195,10 +613,16 @@ void StructuredMesh::raytrace_mesh( return; } + // translate start and end positions, + // this needs to come after the get_indices call because it does its own + // translation + local_coords(r0); + local_coords(r1); + // Calculate initial distances to next surfaces in all three dimensions std::array distances; for (int k = 0; k < n; ++k) { - distances[k] = distance_to_grid_boundary(ijk, k, local_r, u, 0.0); + distances[k] = distance_to_grid_boundary(ijk, k, r0, u, 0.0); } // Loop until r = r1 is eventually reached @@ -1220,30 +644,28 @@ void StructuredMesh::raytrace_mesh( if (traveled_distance >= total_distance) return; - // If we have not reached r1, we have hit a surface. Tally outward - // current + // If we have not reached r1, we have hit a surface. Tally outward current tally.surface(ijk, k, distances[k].max_surface, false); // Update cell and calculate distance to next surface in k-direction. // The two other directions are still valid! ijk[k] = distances[k].next_index; distances[k] = - distance_to_grid_boundary(ijk, k, local_r, u, traveled_distance); + distance_to_grid_boundary(ijk, k, r0, u, traveled_distance); // Check if we have left the interior of the mesh in_mesh = ((ijk[k] >= 1) && (ijk[k] <= shape_[k])); - // If we are still inside the mesh, tally inward current for the next - // cell + // If we are still inside the mesh, tally inward current for the next cell if (in_mesh) tally.surface(ijk, k, !distances[k].max_surface, true); } else { // not inside mesh - // For all directions outside the mesh, find the distance that we need - // to travel to reach the next surface. Use the largest distance, as - // only this will cross all outer surfaces. - int k_max {-1}; + // For all directions outside the mesh, find the distance that we need to + // travel to reach the next surface. Use the largest distance, as only + // this will cross all outer surfaces. + int k_max {0}; for (int k = 0; k < n; ++k) { if ((ijk[k] < 1 || ijk[k] > shape_[k]) && (distances[k].distance > traveled_distance)) { @@ -1251,25 +673,20 @@ void StructuredMesh::raytrace_mesh( k_max = k; } } - // Assure some distance is traveled - if (k_max == -1) { - traveled_distance += TINY_BIT; - } // If r1 is not inside the mesh, exit here if (traveled_distance >= total_distance) return; - // Calculate the new cell index and update all distances to next - // surfaces. - ijk = get_indices(global_r + (traveled_distance + TINY_BIT) * u, in_mesh); + // Calculate the new cell index and update all distances to next surfaces. + ijk = get_indices(r0 + (traveled_distance + TINY_BIT) * u, in_mesh); for (int k = 0; k < n; ++k) { distances[k] = - distance_to_grid_boundary(ijk, k, local_r, u, traveled_distance); + distance_to_grid_boundary(ijk, k, r0, u, traveled_distance); } // If inside the mesh, Tally inward current - if (in_mesh && k_max >= 0) + if (in_mesh) tally.surface(ijk, k_max, !distances[k_max].max_surface, true); } } @@ -1338,72 +755,6 @@ void StructuredMesh::surface_bins_crossed( // RegularMesh implementation //============================================================================== -int RegularMesh::set_grid() -{ - tensor::Tensor shape(shape_.data(), static_cast(n_dimension_)); - - // Check that dimensions are all greater than zero - if ((shape <= 0).any()) { - set_errmsg("All entries for a regular mesh dimensions " - "must be positive."); - return OPENMC_E_INVALID_ARGUMENT; - } - - // Make sure lower_left and dimension match - if (lower_left_.size() != n_dimension_) { - set_errmsg("Number of entries in lower_left must be the same " - "as the regular mesh dimensions."); - return OPENMC_E_INVALID_ARGUMENT; - } - if (width_.size() > 0) { - - // Check to ensure width has same dimensions - if (width_.size() != n_dimension_) { - set_errmsg("Number of entries on width must be the same as " - "the regular mesh dimensions."); - return OPENMC_E_INVALID_ARGUMENT; - } - - // Check for negative widths - if ((width_ < 0.0).any()) { - set_errmsg("Cannot have a negative width on a regular mesh."); - return OPENMC_E_INVALID_ARGUMENT; - } - - // Set width and upper right coordinate - upper_right_ = lower_left_ + shape * width_; - - } else if (upper_right_.size() > 0) { - - // Check to ensure upper_right_ has same dimensions - if (upper_right_.size() != n_dimension_) { - set_errmsg("Number of entries on upper_right must be the " - "same as the regular mesh dimensions."); - return OPENMC_E_INVALID_ARGUMENT; - } - - // Check that upper-right is above lower-left - if ((upper_right_ < lower_left_).any()) { - set_errmsg( - "The upper_right coordinates of a regular mesh must be greater than " - "the lower_left coordinates."); - return OPENMC_E_INVALID_ARGUMENT; - } - - // Set width - width_ = (upper_right_ - lower_left_) / shape; - } - - // Set material volumes - volume_frac_ = 1.0 / shape.prod(); - - element_volume_ = 1.0; - for (int i = 0; i < n_dimension_; i++) { - element_volume_ *= width_[i]; - } - return 0; -} - RegularMesh::RegularMesh(pugi::xml_node node) : StructuredMesh {node} { // Determine number of dimensions for mesh @@ -1411,75 +762,84 @@ RegularMesh::RegularMesh(pugi::xml_node node) : StructuredMesh {node} fatal_error("Must specify on a regular mesh."); } - tensor::Tensor shape = get_node_tensor(node, "dimension"); + xt::xtensor shape = get_node_xarray(node, "dimension"); int n = n_dimension_ = shape.size(); if (n != 1 && n != 2 && n != 3) { fatal_error("Mesh must be one, two, or three dimensions."); } std::copy(shape.begin(), shape.end(), shape_.begin()); + // Check that dimensions are all greater than zero + if (xt::any(shape <= 0)) { + fatal_error("All entries on the element for a tally " + "mesh must be positive."); + } + // Check for lower-left coordinates if (check_for_node(node, "lower_left")) { // Read mesh lower-left corner location - lower_left_ = get_node_tensor(node, "lower_left"); + lower_left_ = get_node_xarray(node, "lower_left"); } else { fatal_error("Must specify on a mesh."); } + // Make sure lower_left and dimension match + if (shape.size() != lower_left_.size()) { + fatal_error("Number of entries on must be the same " + "as the number of entries on ."); + } + if (check_for_node(node, "width")) { // Make sure one of upper-right or width were specified if (check_for_node(node, "upper_right")) { fatal_error("Cannot specify both and on a mesh."); } - width_ = get_node_tensor(node, "width"); + width_ = get_node_xarray(node, "width"); + + // Check to ensure width has same dimensions + auto n = width_.size(); + if (n != lower_left_.size()) { + fatal_error("Number of entries on must be the same as " + "the number of entries on ."); + } + + // Check for negative widths + if (xt::any(width_ < 0.0)) { + fatal_error("Cannot have a negative on a tally mesh."); + } + + // Set width and upper right coordinate + upper_right_ = xt::eval(lower_left_ + shape * width_); } else if (check_for_node(node, "upper_right")) { + upper_right_ = get_node_xarray(node, "upper_right"); - upper_right_ = get_node_tensor(node, "upper_right"); + // Check to ensure width has same dimensions + auto n = upper_right_.size(); + if (n != lower_left_.size()) { + fatal_error("Number of entries on must be the " + "same as the number of entries on ."); + } + // Check that upper-right is above lower-left + if (xt::any(upper_right_ < lower_left_)) { + fatal_error("The coordinates must be greater than " + "the coordinates on a tally mesh."); + } + + // Set width + width_ = xt::eval((upper_right_ - lower_left_) / shape); } else { fatal_error("Must specify either or on a mesh."); } - if (int err = set_grid()) { - fatal_error(openmc_err_msg); - } -} + // Set material volumes + volume_frac_ = 1.0 / xt::prod(shape)(); -RegularMesh::RegularMesh(hid_t group) : StructuredMesh {group} -{ - // Determine number of dimensions for mesh - if (!object_exists(group, "dimension")) { - fatal_error("Must specify on a regular mesh."); - } - - tensor::Tensor shape; - read_dataset(group, "dimension", shape); - int n = n_dimension_ = shape.size(); - if (n != 1 && n != 2 && n != 3) { - fatal_error("Mesh must be one, two, or three dimensions."); - } - std::copy(shape.begin(), shape.end(), shape_.begin()); - - // Check for lower-left coordinates - if (object_exists(group, "lower_left")) { - // Read mesh lower-left corner location - read_dataset(group, "lower_left", lower_left_); - } else { - fatal_error("Must specify lower_left dataset on a mesh."); - } - - if (object_exists(group, "upper_right")) { - - read_dataset(group, "upper_right", upper_right_); - - } else { - fatal_error("Must specify either upper_right dataset on a mesh."); - } - - if (int err = set_grid()) { - fatal_error(openmc_err_msg); + element_volume_ = 1.0; + for (int i = 0; i < n_dimension_; i++) { + element_volume_ *= width_[i]; } } @@ -1522,7 +882,6 @@ StructuredMesh::MeshDistance RegularMesh::distance_to_grid_boundary( d.next_index--; d.distance = (negative_grid_boundary(ijk, i) - r0[i]) / u[i]; } - return d; } @@ -1567,15 +926,20 @@ std::pair, vector> RegularMesh::plot( return {axis_lines[0], axis_lines[1]}; } -void RegularMesh::to_hdf5_inner(hid_t mesh_group) const +void RegularMesh::to_hdf5(hid_t group) const { - write_dataset(mesh_group, "dimension", get_shape_tensor()); + hid_t mesh_group = create_group(group, "mesh " + std::to_string(id_)); + + write_dataset(mesh_group, "type", "regular"); + write_dataset(mesh_group, "dimension", get_x_shape()); write_dataset(mesh_group, "lower_left", lower_left_); write_dataset(mesh_group, "upper_right", upper_right_); write_dataset(mesh_group, "width", width_); + + close_group(mesh_group); } -tensor::Tensor RegularMesh::count_sites( +xt::xtensor RegularMesh::count_sites( const SourceSite* bank, int64_t length, bool* outside) const { // Determine shape of array for counts @@ -1583,7 +947,7 @@ tensor::Tensor RegularMesh::count_sites( vector shape = {m}; // Create array of zeros - auto cnt = tensor::zeros(shape); + xt::xarray cnt {shape, 0.0}; bool outside_ = false; for (int64_t i = 0; i < length; i++) { @@ -1602,25 +966,31 @@ tensor::Tensor RegularMesh::count_sites( cnt(mesh_bin) += site.wgt; } - // Create reduced count data - auto counts = tensor::zeros(shape); + // Create copy of count data. Since ownership will be acquired by xtensor, + // std::allocator must be used to avoid Valgrind mismatched free() / delete + // warnings. int total = cnt.size(); + double* cnt_reduced = std::allocator {}.allocate(total); #ifdef OPENMC_MPI // collect values from all processors MPI_Reduce( - cnt.data(), counts.data(), total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); + cnt.data(), cnt_reduced, total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); // Check if there were sites outside the mesh for any processor if (outside) { MPI_Reduce(&outside_, outside, 1, MPI_C_BOOL, MPI_LOR, 0, mpi::intracomm); } #else - std::copy(cnt.data(), cnt.data() + total, counts.data()); + std::copy(cnt.data(), cnt.data() + total, cnt_reduced); if (outside) *outside = outside_; #endif + // Adapt reduced values in array back into an xarray + auto arr = xt::adapt(cnt_reduced, total, xt::acquire_ownership(), shape); + xt::xarray counts = arr; + return counts; } @@ -1646,19 +1016,6 @@ RectilinearMesh::RectilinearMesh(pugi::xml_node node) : StructuredMesh {node} } } -RectilinearMesh::RectilinearMesh(hid_t group) : StructuredMesh {group} -{ - n_dimension_ = 3; - - read_dataset(group, "x_grid", grid_[0]); - read_dataset(group, "y_grid", grid_[1]); - read_dataset(group, "z_grid", grid_[2]); - - if (int err = set_grid()) { - fatal_error(openmc_err_msg); - } -} - const std::string RectilinearMesh::mesh_type = "rectilinear"; std::string RectilinearMesh::get_mesh_type() const @@ -1759,11 +1116,16 @@ std::pair, vector> RectilinearMesh::plot( return {axis_lines[0], axis_lines[1]}; } -void RectilinearMesh::to_hdf5_inner(hid_t mesh_group) const +void RectilinearMesh::to_hdf5(hid_t group) const { + hid_t mesh_group = create_group(group, "mesh " + std::to_string(id_)); + + write_dataset(mesh_group, "type", "rectilinear"); write_dataset(mesh_group, "x_grid", grid_[0]); write_dataset(mesh_group, "y_grid", grid_[1]); write_dataset(mesh_group, "z_grid", grid_[2]); + + close_group(mesh_group); } double RectilinearMesh::volume(const MeshIndex& ijk) const @@ -1794,19 +1156,6 @@ CylindricalMesh::CylindricalMesh(pugi::xml_node node) } } -CylindricalMesh::CylindricalMesh(hid_t group) : PeriodicStructuredMesh {group} -{ - n_dimension_ = 3; - read_dataset(group, "r_grid", grid_[0]); - read_dataset(group, "phi_grid", grid_[1]); - read_dataset(group, "z_grid", grid_[2]); - read_dataset(group, "origin", origin_); - - if (int err = set_grid()) { - fatal_error(openmc_err_msg); - } -} - const std::string CylindricalMesh::mesh_type = "cylindrical"; std::string CylindricalMesh::get_mesh_type() const @@ -1817,7 +1166,7 @@ std::string CylindricalMesh::get_mesh_type() const StructuredMesh::MeshIndex CylindricalMesh::get_indices( Position r, bool& in_mesh) const { - r = local_coords(r); + local_coords(r); Position mapped_r; mapped_r[0] = std::hypot(r.x, r.y); @@ -1828,7 +1177,7 @@ StructuredMesh::MeshIndex CylindricalMesh::get_indices( } else { mapped_r[1] = std::atan2(r.y, r.x); if (mapped_r[1] < 0) - mapped_r[1] += 2 * PI; + mapped_r[1] += 2 * M_PI; } MeshIndex idx = StructuredMesh::get_indices(mapped_r, in_mesh); @@ -1887,19 +1236,18 @@ double CylindricalMesh::find_r_crossing( const double inv_denominator = 1.0 / denominator; const double p = (u.x * r.x + u.y * r.y) * inv_denominator; - double R = std::sqrt(r.x * r.x + r.y * r.y); - double D = p * p - (R - r0) * (R + r0) * inv_denominator; + double c = r.x * r.x + r.y * r.y - r0 * r0; + double D = p * p - c * inv_denominator; if (D < 0.0) return INFTY; D = std::sqrt(D); - // Particle is already on the shell surface; avoid spurious crossing - if (std::abs(R - r0) <= RADIAL_MESH_TOL * (1.0 + std::abs(r0))) + // the solution -p - D is always smaller as -p + D : Check this one first + if (std::abs(c) <= RADIAL_MESH_TOL) return INFTY; - // Check -p - D first because it is always smaller as -p + D if (-p - D > l) return -p - D; if (-p + D > l) @@ -1966,21 +1314,23 @@ StructuredMesh::MeshDistance CylindricalMesh::distance_to_grid_boundary( const MeshIndex& ijk, int i, const Position& r0, const Direction& u, double l) const { + Position r = r0 - origin_; + if (i == 0) { return std::min( - MeshDistance(ijk[i] + 1, true, find_r_crossing(r0, u, l, ijk[i])), - MeshDistance(ijk[i] - 1, false, find_r_crossing(r0, u, l, ijk[i] - 1))); + MeshDistance(ijk[i] + 1, true, find_r_crossing(r, u, l, ijk[i])), + MeshDistance(ijk[i] - 1, false, find_r_crossing(r, u, l, ijk[i] - 1))); } else if (i == 1) { return std::min(MeshDistance(sanitize_phi(ijk[i] + 1), true, - find_phi_crossing(r0, u, l, ijk[i])), + find_phi_crossing(r, u, l, ijk[i])), MeshDistance(sanitize_phi(ijk[i] - 1), false, - find_phi_crossing(r0, u, l, ijk[i] - 1))); + find_phi_crossing(r, u, l, ijk[i] - 1))); } else { - return find_z_crossing(r0, u, l, ijk[i]); + return find_z_crossing(r, u, l, ijk[i]); } } @@ -2022,10 +1372,8 @@ int CylindricalMesh::set_grid() full_phi_ = (grid_[1].front() == 0.0) && (grid_[1].back() == 2.0 * PI); - lower_left_ = {origin_[0] - grid_[0].back(), origin_[1] - grid_[0].back(), - origin_[2] + grid_[2].front()}; - upper_right_ = {origin_[0] + grid_[0].back(), origin_[1] + grid_[0].back(), - origin_[2] + grid_[2].back()}; + lower_left_ = {grid_[0].front(), grid_[1].front(), grid_[2].front()}; + upper_right_ = {grid_[0].back(), grid_[1].back(), grid_[2].back()}; return 0; } @@ -2045,12 +1393,17 @@ std::pair, vector> CylindricalMesh::plot( return {axis_lines[0], axis_lines[1]}; } -void CylindricalMesh::to_hdf5_inner(hid_t mesh_group) const +void CylindricalMesh::to_hdf5(hid_t group) const { + hid_t mesh_group = create_group(group, "mesh " + std::to_string(id_)); + + write_dataset(mesh_group, "type", "cylindrical"); write_dataset(mesh_group, "r_grid", grid_[0]); write_dataset(mesh_group, "phi_grid", grid_[1]); write_dataset(mesh_group, "z_grid", grid_[2]); write_dataset(mesh_group, "origin", origin_); + + close_group(mesh_group); } double CylindricalMesh::volume(const MeshIndex& ijk) const @@ -2086,20 +1439,6 @@ SphericalMesh::SphericalMesh(pugi::xml_node node) } } -SphericalMesh::SphericalMesh(hid_t group) : PeriodicStructuredMesh {group} -{ - n_dimension_ = 3; - - read_dataset(group, "r_grid", grid_[0]); - read_dataset(group, "theta_grid", grid_[1]); - read_dataset(group, "phi_grid", grid_[2]); - read_dataset(group, "origin", origin_); - - if (int err = set_grid()) { - fatal_error(openmc_err_msg); - } -} - const std::string SphericalMesh::mesh_type = "spherical"; std::string SphericalMesh::get_mesh_type() const @@ -2110,7 +1449,7 @@ std::string SphericalMesh::get_mesh_type() const StructuredMesh::MeshIndex SphericalMesh::get_indices( Position r, bool& in_mesh) const { - r = local_coords(r); + local_coords(r); Position mapped_r; mapped_r[0] = r.norm(); @@ -2122,7 +1461,7 @@ StructuredMesh::MeshIndex SphericalMesh::get_indices( mapped_r[1] = std::acos(r.z / mapped_r.x); mapped_r[2] = std::atan2(r.y, r.x); if (mapped_r[2] < 0) - mapped_r[2] += 2 * PI; + mapped_r[2] += 2 * M_PI; } MeshIndex idx = StructuredMesh::get_indices(mapped_r, in_mesh); @@ -2145,8 +1484,7 @@ Position SphericalMesh::sample_element( double phi_min = this->phi(ijk[2] - 1); double phi_max = this->phi(ijk[2]); - double cos_theta = - uniform_distribution(std::cos(theta_min), std::cos(theta_max), seed); + double cos_theta = uniform_distribution(theta_min, theta_max, seed); double sin_theta = std::sin(std::acos(cos_theta)); double phi = uniform_distribution(phi_min, phi_max, seed); double r_min_cub = std::pow(r_min, 3); @@ -2173,16 +1511,15 @@ double SphericalMesh::find_r_crossing( if (r0 == 0.0) return INFTY; const double p = r.dot(u); - double R = r.norm(); - double D = p * p - (R - r0) * (R + r0); + double c = r.dot(r) - r0 * r0; + double D = p * p - c; - // Particle is already on the shell surface; avoid spurious crossing - if (std::abs(R - r0) <= RADIAL_MESH_TOL * (1.0 + std::abs(r0))) + if (std::abs(c) <= RADIAL_MESH_TOL) return INFTY; if (D >= 0.0) { D = std::sqrt(D); - // Check -p - D first because it is always smaller as -p + D + // the solution -p - D is always smaller as -p + D : Check this one first if (-p - D > l) return -p - D; if (-p + D > l) @@ -2216,8 +1553,7 @@ double SphericalMesh::find_theta_crossing( const double b = r.dot(u) * cos_t_2 - r.z * u.z; const double c = r.dot(r) * cos_t_2 - r.z * r.z; - // if factor of s^2 is zero, direction of flight is parallel to theta - // surface + // if factor of s^2 is zero, direction of flight is parallel to theta surface if (std::abs(a) < FP_PRECISION) { // if b vanishes, direction of flight is within theta surface and crossing // is not possible @@ -2225,8 +1561,7 @@ double SphericalMesh::find_theta_crossing( return INFTY; const double s = -0.5 * c / b; - // Check if solution is in positive direction of flight and has correct - // sign + // Check if solution is in positive direction of flight and has correct sign if ((s > l) && (std::signbit(r.z + s * u.z) == sgn)) return s; @@ -2352,9 +1687,8 @@ int SphericalMesh::set_grid() full_theta_ = (grid_[1].front() == 0.0) && (grid_[1].back() == PI); full_phi_ = (grid_[2].front() == 0.0) && (grid_[2].back() == 2 * PI); - double r = grid_[0].back(); - lower_left_ = {origin_[0] - r, origin_[1] - r, origin_[2] - r}; - upper_right_ = {origin_[0] + r, origin_[1] + r, origin_[2] + r}; + lower_left_ = {grid_[0].front(), grid_[1].front(), grid_[2].front()}; + upper_right_ = {grid_[0].back(), grid_[1].back(), grid_[2].back()}; return 0; } @@ -2374,12 +1708,17 @@ std::pair, vector> SphericalMesh::plot( return {axis_lines[0], axis_lines[1]}; } -void SphericalMesh::to_hdf5_inner(hid_t mesh_group) const +void SphericalMesh::to_hdf5(hid_t group) const { + hid_t mesh_group = create_group(group, "mesh " + std::to_string(id_)); + + write_dataset(mesh_group, "type", SphericalMesh::mesh_type); write_dataset(mesh_group, "r_grid", grid_[0]); write_dataset(mesh_group, "theta_grid", grid_[1]); write_dataset(mesh_group, "phi_grid", grid_[2]); write_dataset(mesh_group, "origin", origin_); + + close_group(mesh_group); } double SphericalMesh::volume(const MeshIndex& ijk) const @@ -2481,14 +1820,14 @@ extern "C" int openmc_add_unstructured_mesh( std::string mesh_file(filename); bool valid_lib = false; -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC if (lib_name == MOABMesh::mesh_lib_type) { model::meshes.push_back(std::move(make_unique(mesh_file))); valid_lib = true; } #endif -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH if (lib_name == LibMesh::mesh_lib_type) { model::meshes.push_back(std::move(make_unique(mesh_file))); valid_lib = true; @@ -2560,45 +1899,22 @@ extern "C" int openmc_mesh_get_volumes(int32_t index, double* volumes) return 0; } -//! Get the bounding box of a mesh -extern "C" int openmc_mesh_bounding_box(int32_t index, double* ll, double* ur) +extern "C" int openmc_mesh_material_volumes(int32_t index, int n_sample, + int bin, int result_size, void* result, int* hits, uint64_t* seed) { - if (int err = check_mesh(index)) - return err; - - BoundingBox bbox = model::meshes[index]->bounding_box(); - - // set lower left corner values - ll[0] = bbox.min.x; - ll[1] = bbox.min.y; - ll[2] = bbox.min.z; - - // set upper right corner values - ur[0] = bbox.max.x; - ur[1] = bbox.max.y; - ur[2] = bbox.max.z; - return 0; -} - -extern "C" int openmc_mesh_material_volumes(int32_t index, int nx, int ny, - int nz, int table_size, int32_t* materials, double* volumes, double* bboxes) -{ - if (int err = check_mesh(index)) - return err; - - try { - model::meshes[index]->material_volumes( - nx, ny, nz, table_size, materials, volumes, bboxes); - } catch (const std::exception& e) { - set_errmsg(e.what()); - if (starts_with(e.what(), "Mesh")) { - return OPENMC_E_GEOMETRY; - } else { - return OPENMC_E_ALLOCATE; - } + auto result_ = reinterpret_cast(result); + if (!result_) { + set_errmsg("Invalid result pointer passed to openmc_mesh_material_volumes"); + return OPENMC_E_INVALID_ARGUMENT; } - return 0; + if (int err = check_mesh(index)) + return err; + + int n = model::meshes[index]->material_volumes( + n_sample, bin, {result_, result_ + result_size}, seed); + *hits = n; + return (n == -1) ? OPENMC_E_ALLOCATE : 0; } extern "C" int openmc_mesh_get_plot_bins(int32_t index, Position origin, @@ -2692,7 +2008,7 @@ extern "C" int openmc_regular_mesh_get_params( return err; RegularMesh* m = dynamic_cast(model::meshes[index].get()); - if (m->lower_left_.empty()) { + if (m->lower_left_.dimension() == 0) { set_errmsg("Mesh parameters have not been set."); return OPENMC_E_ALLOCATE; } @@ -2719,17 +2035,17 @@ extern "C" int openmc_regular_mesh_set_params( vector shape = {static_cast(n)}; if (ll && ur) { - m->lower_left_ = tensor::Tensor(ll, n); - m->upper_right_ = tensor::Tensor(ur, n); - m->width_ = (m->upper_right_ - m->lower_left_) / m->get_shape_tensor(); + m->lower_left_ = xt::adapt(ll, n, xt::no_ownership(), shape); + m->upper_right_ = xt::adapt(ur, n, xt::no_ownership(), shape); + m->width_ = (m->upper_right_ - m->lower_left_) / m->get_x_shape(); } else if (ll && width) { - m->lower_left_ = tensor::Tensor(ll, n); - m->width_ = tensor::Tensor(width, n); - m->upper_right_ = m->lower_left_ + m->get_shape_tensor() * m->width_; + m->lower_left_ = xt::adapt(ll, n, xt::no_ownership(), shape); + m->width_ = xt::adapt(width, n, xt::no_ownership(), shape); + m->upper_right_ = m->lower_left_ + m->get_x_shape() * m->width_; } else if (ur && width) { - m->upper_right_ = tensor::Tensor(ur, n); - m->width_ = tensor::Tensor(width, n); - m->lower_left_ = m->upper_right_ - m->get_shape_tensor() * m->width_; + m->upper_right_ = xt::adapt(ur, n, xt::no_ownership(), shape); + m->width_ = xt::adapt(width, n, xt::no_ownership(), shape); + m->lower_left_ = m->upper_right_ - m->get_x_shape() * m->width_; } else { set_errmsg("At least two parameters must be specified."); return OPENMC_E_INVALID_ARGUMENT; @@ -2739,7 +2055,7 @@ extern "C" int openmc_regular_mesh_set_params( // TODO: incorporate this into method in RegularMesh that can be called from // here and from constructor - m->volume_frac_ = 1.0 / m->get_shape_tensor().prod(); + m->volume_frac_ = 1.0 / xt::prod(m->get_x_shape())(); m->element_volume_ = 1.0; for (int i = 0; i < m->n_dimension_; i++) { m->element_volume_ *= m->width_[i]; @@ -2788,7 +2104,7 @@ int openmc_structured_mesh_get_grid_impl(int32_t index, double** grid_x, return err; C* m = dynamic_cast(model::meshes[index].get()); - if (m->lower_left_.empty()) { + if (m->lower_left_.dimension() == 0) { set_errmsg("Mesh parameters have not been set."); return OPENMC_E_ALLOCATE; } @@ -2856,7 +2172,7 @@ extern "C" int openmc_spherical_mesh_set_grid(int32_t index, index, grid_x, nx, grid_y, ny, grid_z, nz); } -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC const std::string MOABMesh::mesh_lib_type = "moab"; @@ -2865,15 +2181,8 @@ MOABMesh::MOABMesh(pugi::xml_node node) : UnstructuredMesh(node) initialize(); } -MOABMesh::MOABMesh(hid_t group) : UnstructuredMesh(group) -{ - initialize(); -} - MOABMesh::MOABMesh(const std::string& filename, double length_multiplier) - : UnstructuredMesh() { - n_dimension_ = 3; filename_ = filename; set_length_multiplier(length_multiplier); initialize(); @@ -2956,12 +2265,9 @@ void MOABMesh::initialize() } } } - - // Determine bounds of mesh - this->determine_bounds(); } -void MOABMesh::prepare_for_point_location() +void MOABMesh::prepare_for_tallies() { // if the KDTree has already been constructed, do nothing if (kdtree_) @@ -3011,8 +2317,7 @@ void MOABMesh::build_kdtree(const moab::Range& all_tets) all_tets_and_tris.merge(all_tris); // create a kd-tree instance - write_message( - 7, "Building adaptive k-d tree for tet mesh with ID {}...", id_); + write_message("Building adaptive k-d tree for tet mesh...", 7); kdtree_ = make_unique(mbi_.get()); // Determine what options to use @@ -3041,8 +2346,7 @@ void MOABMesh::intersect_track(const moab::CartVect& start, moab::ErrorCode rval; vector tris; // get all intersections with triangles in the tet mesh - // (distances are relative to the start point, not the previous - // intersection) + // (distances are relative to the start point, not the previous intersection) rval = kdtree_->ray_intersect_triangles(kdtree_root_, FP_COINCIDENT, dir.array(), start.array(), tris, hits, 0, track_len); if (rval != moab::MB_SUCCESS) { @@ -3565,7 +2869,7 @@ void MOABMesh::write(const std::string& base_filename) const #endif -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH const std::string LibMesh::mesh_lib_type = "libmesh"; @@ -3578,23 +2882,9 @@ LibMesh::LibMesh(pugi::xml_node node) : UnstructuredMesh(node) initialize(); } -LibMesh::LibMesh(hid_t group) : UnstructuredMesh(group) -{ - // filename_ and length_multiplier_ will already be set by the - // UnstructuredMesh constructor - set_mesh_pointer_from_filename(filename_); - set_length_multiplier(length_multiplier_); - initialize(); -} - // create the mesh from a pointer to a libMesh Mesh LibMesh::LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier) { - if (!input_mesh.is_replicated()) { - fatal_error("At present LibMesh tallies require a replicated mesh. Please " - "ensure 'input_mesh' is a libMesh::ReplicatedMesh."); - } - m_ = &input_mesh; set_length_multiplier(length_multiplier); initialize(); @@ -3603,7 +2893,6 @@ LibMesh::LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier) // create the mesh from an input file LibMesh::LibMesh(const std::string& filename, double length_multiplier) { - n_dimension_ = 3; set_mesh_pointer_from_filename(filename); set_length_multiplier(length_multiplier); initialize(); @@ -3612,32 +2901,25 @@ LibMesh::LibMesh(const std::string& filename, double length_multiplier) void LibMesh::set_mesh_pointer_from_filename(const std::string& filename) { filename_ = filename; - unique_m_ = - make_unique(*settings::libmesh_comm, n_dimension_); + unique_m_ = make_unique(*settings::libmesh_comm, n_dimension_); m_ = unique_m_.get(); m_->read(filename_); } -// build a libMesh equation system for storing values -void LibMesh::build_eqn_sys() -{ - eq_system_name_ = fmt::format("mesh_{}_system", id_); - equation_systems_ = make_unique(*m_); - libMesh::ExplicitSystem& eq_sys = - equation_systems_->add_system(eq_system_name_); -} - // intialize from mesh file void LibMesh::initialize() { if (!settings::libmesh_comm) { - fatal_error("Attempting to use an unstructured mesh without a libMesh " - "communicator."); + fatal_error( + "Attempting to use an unstructured mesh without a libMesh communicator."); } // assuming that unstructured meshes used in OpenMC are 3D n_dimension_ = 3; + if (length_multiplier_ > 0.0) { + libMesh::MeshTools::Modification::scale(*m_, length_multiplier_); + } // if OpenMC is managing the libMesh::MeshBase instance, prepare the mesh. // Otherwise assume that it is prepared by its owning application if (unique_m_) { @@ -3651,6 +2933,13 @@ void LibMesh::initialize() filename_)); } + // create an equation system for storing values + eq_system_name_ = fmt::format("mesh_{}_system", id_); + + equation_systems_ = make_unique(*m_); + libMesh::ExplicitSystem& eq_sys = + equation_systems_->add_system(eq_system_name_); + for (int i = 0; i < num_threads(); i++) { pl_.emplace_back(m_->sub_point_locator()); pl_.back()->set_contains_point_tol(FP_COINCIDENT); @@ -3663,17 +2952,6 @@ void LibMesh::initialize() // bounding box for the mesh for quick rejection checks bbox_ = libMesh::MeshTools::create_bounding_box(*m_); - libMesh::Point ll = bbox_.min(); - libMesh::Point ur = bbox_.max(); - if (length_multiplier_ > 0.0) { - lower_left_ = {length_multiplier_ * ll(0), length_multiplier_ * ll(1), - length_multiplier_ * ll(2)}; - upper_right_ = {length_multiplier_ * ur(0), length_multiplier_ * ur(1), - length_multiplier_ * ur(2)}; - } else { - lower_left_ = {ll(0), ll(1), ll(2)}; - upper_right_ = {ur(0), ur(1), ur(2)}; - } } // Sample position within a tet for LibMesh type tets @@ -3683,27 +2961,18 @@ Position LibMesh::sample_element(int32_t bin, uint64_t* seed) const // Get tet vertex coordinates from LibMesh std::array tet_verts; for (int i = 0; i < elem.n_nodes(); i++) { - const auto& node_ref = elem.node_ref(i); + auto node_ref = elem.node_ref(i); tet_verts[i] = {node_ref(0), node_ref(1), node_ref(2)}; } // Samples position within tet using Barycentric coordinates - Position sampled_position = this->sample_tet(tet_verts, seed); - if (length_multiplier_ > 0.0) { - return length_multiplier_ * sampled_position; - } else { - return sampled_position; - } + return this->sample_tet(tet_verts, seed); } Position LibMesh::centroid(int bin) const { const auto& elem = this->get_element_from_bin(bin); auto centroid = elem.vertex_average(); - if (length_multiplier_ > 0.0) { - return length_multiplier_ * Position(centroid(0), centroid(1), centroid(2)); - } else { - return {centroid(0), centroid(1), centroid(2)}; - } + return {centroid(0), centroid(1), centroid(2)}; } int LibMesh::n_vertices() const @@ -3713,12 +2982,8 @@ int LibMesh::n_vertices() const Position LibMesh::vertex(int vertex_id) const { - const auto& node_ref = m_->node_ref(vertex_id); - if (length_multiplier_ > 0.0) { - return length_multiplier_ * Position(node_ref(0), node_ref(1), node_ref(2)); - } else { - return {node_ref(0), node_ref(1), node_ref(2)}; - } + const auto node_ref = m_->node_ref(vertex_id); + return {node_ref(0), node_ref(1), node_ref(2)}; } std::vector LibMesh::connectivity(int elem_id) const @@ -3761,10 +3026,6 @@ int LibMesh::n_surface_bins() const void LibMesh::add_score(const std::string& var_name) { - if (!equation_systems_) { - build_eqn_sys(); - } - // check if this is a new variable std::string value_name = var_name + "_mean"; if (!variable_map_.count(value_name)) { @@ -3786,20 +3047,14 @@ void LibMesh::add_score(const std::string& var_name) void LibMesh::remove_scores() { - if (equation_systems_) { - auto& eqn_sys = equation_systems_->get_system(eq_system_name_); - eqn_sys.clear(); - variable_map_.clear(); - } + auto& eqn_sys = equation_systems_->get_system(eq_system_name_); + eqn_sys.clear(); + variable_map_.clear(); } void LibMesh::set_score_data(const std::string& var_name, const vector& values, const vector& std_dev) { - if (!equation_systems_) { - build_eqn_sys(); - } - auto& eqn_sys = equation_systems_->get_system(eq_system_name_); if (!eqn_sys.is_initialized()) { @@ -3817,22 +3072,18 @@ void LibMesh::set_score_data(const std::string& var_name, for (auto it = m_->local_elements_begin(); it != m_->local_elements_end(); it++) { - if (!(*it)->active()) { - continue; - } - auto bin = get_bin_from_element(*it); // set value vector value_dof_indices; dof_map.dof_indices(*it, value_dof_indices, value_num); - assert(value_dof_indices.size() == 1); + Ensures(value_dof_indices.size() == 1); eqn_sys.solution->set(value_dof_indices[0], values.at(bin)); // set std dev vector std_dev_dof_indices; dof_map.dof_indices(*it, std_dev_dof_indices, std_dev_num); - assert(std_dev_dof_indices.size() == 1); + Ensures(std_dev_dof_indices.size() == 1); eqn_sys.solution->set(std_dev_dof_indices[0], std_dev.at(bin)); } } @@ -3859,11 +3110,6 @@ int LibMesh::get_bin(Position r) const // look-up a tet using the point locator libMesh::Point p(r.x, r.y, r.z); - if (length_multiplier_ > 0.0) { - // Scale the point down - p /= length_multiplier_; - } - // quick rejection check if (!bbox_.contains_point(p)) { return -1; @@ -3897,100 +3143,10 @@ const libMesh::Elem& LibMesh::get_element_from_bin(int bin) const double LibMesh::volume(int bin) const { - return this->get_element_from_bin(bin).volume() * length_multiplier_ * - length_multiplier_ * length_multiplier_; + return this->get_element_from_bin(bin).volume(); } -AdaptiveLibMesh::AdaptiveLibMesh(libMesh::MeshBase& input_mesh, - double length_multiplier, - const std::set& block_ids) - : LibMesh(input_mesh, length_multiplier), block_ids_(block_ids), - block_restrict_(!block_ids_.empty()), - num_active_( - block_restrict_ - ? std::distance(m_->active_subdomain_set_elements_begin(block_ids_), - m_->active_subdomain_set_elements_end(block_ids_)) - : m_->n_active_elem()) -{ - // if the mesh is adaptive elements aren't guaranteed by libMesh to be - // contiguous in ID space, so we need to map from bin indices (defined over - // active elements) to global dof ids - bin_to_elem_map_.reserve(num_active_); - elem_to_bin_map_.resize(m_->n_elem(), -1); - auto begin = block_restrict_ - ? m_->active_subdomain_set_elements_begin(block_ids_) - : m_->active_elements_begin(); - auto end = block_restrict_ ? m_->active_subdomain_set_elements_end(block_ids_) - : m_->active_elements_end(); - for (const auto& elem : libMesh::as_range(begin, end)) { - bin_to_elem_map_.push_back(elem->id()); - elem_to_bin_map_[elem->id()] = bin_to_elem_map_.size() - 1; - } -} - -int AdaptiveLibMesh::n_bins() const -{ - return num_active_; -} - -void AdaptiveLibMesh::add_score(const std::string& var_name) -{ - warning(fmt::format( - "Exodus output cannot be provided as unstructured mesh {} is adaptive.", - this->id_)); -} - -void AdaptiveLibMesh::set_score_data(const std::string& var_name, - const vector& values, const vector& std_dev) -{ - warning(fmt::format( - "Exodus output cannot be provided as unstructured mesh {} is adaptive.", - this->id_)); -} - -void AdaptiveLibMesh::write(const std::string& filename) const -{ - warning(fmt::format( - "Exodus output cannot be provided as unstructured mesh {} is adaptive.", - this->id_)); -} - -int AdaptiveLibMesh::get_bin(Position r) const -{ - // look-up a tet using the point locator - libMesh::Point p(r.x, r.y, r.z); - - if (length_multiplier_ > 0.0) { - // Scale the point down - p /= length_multiplier_; - } - - // quick rejection check - if (!bbox_.contains_point(p)) { - return -1; - } - - const auto& point_locator = pl_.at(thread_num()); - - const auto elem_ptr = (*point_locator)(p, &block_ids_); - return elem_ptr ? get_bin_from_element(elem_ptr) : -1; -} - -int AdaptiveLibMesh::get_bin_from_element(const libMesh::Elem* elem) const -{ - int bin = elem_to_bin_map_[elem->id()]; - if (bin >= n_bins() || bin < 0) { - fatal_error(fmt::format("Invalid bin: {}", bin)); - } - return bin; -} - -const libMesh::Elem& AdaptiveLibMesh::get_element_from_bin(int bin) const -{ - return m_->elem_ref(bin_to_elem_map_.at(bin)); -} - -#endif // OPENMC_LIBMESH_ENABLED +#endif // LIBMESH //============================================================================== // Non-member functions @@ -4004,8 +3160,8 @@ void read_meshes(pugi::xml_node root) // Check to make sure multiple meshes in the same file don't share IDs int id = std::stoi(get_node_value(node, "id")); if (contains(mesh_ids, id)) { - fatal_error(fmt::format("Two or more meshes use the same unique ID " - "'{}' in the same input file", + fatal_error(fmt::format( + "Two or more meshes use the same unique ID '{}' in the same input file", id)); } mesh_ids.insert(id); @@ -4030,51 +3186,34 @@ void read_meshes(pugi::xml_node root) mesh_lib = get_node_value(node, "library", true, true); } - Mesh::create(node, mesh_type, mesh_lib); - } -} - -void read_meshes(hid_t group) -{ - std::unordered_set mesh_ids; - - std::vector ids; - read_attribute(group, "ids", ids); - - for (auto id : ids) { - - // Check to make sure multiple meshes in the same file don't share IDs - if (contains(mesh_ids, id)) { - fatal_error(fmt::format("Two or more meshes use the same unique ID " - "'{}' in the same HDF5 input file", - id)); - } - mesh_ids.insert(id); - - // If we've already read a mesh with the same ID in a *different* file, - // assume it is the same here - if (model::mesh_map.find(id) != model::mesh_map.end()) { - warning(fmt::format("Mesh with ID={} appears in multiple files.", id)); - continue; - } - - std::string name = fmt::format("mesh {}", id); - hid_t mesh_group = open_group(group, name.c_str()); - - std::string mesh_type; - if (object_exists(mesh_group, "type")) { - read_dataset(mesh_group, "type", mesh_type); + // Read mesh and add to vector + if (mesh_type == RegularMesh::mesh_type) { + model::meshes.push_back(make_unique(node)); + } else if (mesh_type == RectilinearMesh::mesh_type) { + model::meshes.push_back(make_unique(node)); + } else if (mesh_type == CylindricalMesh::mesh_type) { + model::meshes.push_back(make_unique(node)); + } else if (mesh_type == SphericalMesh::mesh_type) { + model::meshes.push_back(make_unique(node)); +#ifdef DAGMC + } else if (mesh_type == UnstructuredMesh::mesh_type && + mesh_lib == MOABMesh::mesh_lib_type) { + model::meshes.push_back(make_unique(node)); +#endif +#ifdef LIBMESH + } else if (mesh_type == UnstructuredMesh::mesh_type && + mesh_lib == LibMesh::mesh_lib_type) { + model::meshes.push_back(make_unique(node)); +#endif + } else if (mesh_type == UnstructuredMesh::mesh_type) { + fatal_error("Unstructured mesh support is not enabled or the mesh " + "library is invalid."); } else { - mesh_type = "regular"; + fatal_error("Invalid mesh type: " + mesh_type); } - // determine the mesh library to use - std::string mesh_lib; - if (object_exists(mesh_group, "library")) { - read_dataset(mesh_group, "library", mesh_lib); - } - - Mesh::create(mesh_group, mesh_type, mesh_lib); + // Map ID to position in vector + model::mesh_map[model::meshes.back()->id_] = model::meshes.size() - 1; } } diff --git a/src/message_passing.cpp b/src/message_passing.cpp index cf6113ed6..374c1aa72 100644 --- a/src/message_passing.cpp +++ b/src/message_passing.cpp @@ -10,7 +10,6 @@ bool master {true}; #ifdef OPENMC_MPI MPI_Comm intracomm {MPI_COMM_NULL}; MPI_Datatype source_site {MPI_DATATYPE_NULL}; -MPI_Datatype collision_track_site {MPI_DATATYPE_NULL}; #endif extern "C" bool openmc_master() @@ -39,14 +38,6 @@ vector calculate_parallel_index_vector(int64_t size) return result; } -#ifdef OPENMC_MPI -// Specializations of the MPITypeMap template struct -template<> -const MPI_Datatype MPITypeMap::mpi_type = MPI_INT; -template<> -const MPI_Datatype MPITypeMap::mpi_type = MPI_DOUBLE; -#endif - } // namespace mpi } // namespace openmc diff --git a/src/mgxs.cpp b/src/mgxs.cpp index 1dc090ab9..9eae5a7da 100644 --- a/src/mgxs.cpp +++ b/src/mgxs.cpp @@ -5,13 +5,15 @@ #include #include -#include "openmc/tensor.h" +#include "xtensor/xadapt.hpp" +#include "xtensor/xmath.hpp" +#include "xtensor/xsort.hpp" +#include "xtensor/xview.hpp" #include #include "openmc/error.h" #include "openmc/math_functions.h" #include "openmc/mgxs_interface.h" -#include "openmc/nuclide.h" #include "openmc/random_lcg.h" #include "openmc/settings.h" #include "openmc/string_utils.h" @@ -30,7 +32,8 @@ void Mgxs::init(const std::string& in_name, double in_awr, // Set the metadata name = in_name; awr = in_awr; - kTs = tensor::Tensor(in_kTs.data(), in_kTs.size()); + // TODO: Remove adapt when in_KTs is an xtensor + kTs = xt::adapt(in_kTs); fissionable = in_fissionable; scatter_format = in_scatter_format; xs.resize(in_kTs.size()); @@ -69,25 +72,18 @@ void Mgxs::metadata_from_hdf5(hid_t xs_id, const vector& temperature, } get_datasets(kT_group, dset_names); vector shape = {num_temps}; - tensor::Tensor temps_available(shape); + xt::xarray available_temps(shape); for (int i = 0; i < num_temps; i++) { - read_double(kT_group, dset_names[i], &temps_available[i], true); + read_double(kT_group, dset_names[i], &available_temps[i], true); // convert eV to Kelvin - temps_available[i] = std::round(temps_available[i] / K_BOLTZMANN); + available_temps[i] /= K_BOLTZMANN; // Done with dset_names, so delete it delete[] dset_names[i]; } delete[] dset_names; - std::sort(temps_available.begin(), temps_available.end()); - - // Set the global upper and lower interpolation bounds to avoid errors - // involving C-API functions. - data::temperature_min = - std::min(data::temperature_min, temps_available.front()); - data::temperature_max = - std::max(data::temperature_max, temps_available.back()); + std::sort(available_temps.begin(), available_temps.end()); // If only one temperature is available, lets just use nearest temperature // interpolation @@ -103,22 +99,17 @@ void Mgxs::metadata_from_hdf5(hid_t xs_id, const vector& temperature, case TemperatureMethod::NEAREST: // Determine actual temperatures to read for (const auto& T : temperature) { - // Determine the closest temperature value - auto i_closest = tensor::abs(temps_available - T).argmin(); - - double temp_actual = temps_available[i_closest]; + auto i_closest = xt::argmin(xt::abs(available_temps - T))[0]; + double temp_actual = available_temps[i_closest]; if (std::fabs(temp_actual - T) < settings::temperature_tolerance) { if (std::find(temps_to_read.begin(), temps_to_read.end(), std::round(temp_actual)) == temps_to_read.end()) { temps_to_read.push_back(std::round(temp_actual)); } } else { - fatal_error(fmt::format( - "MGXS library does not contain cross sections " - "for {} at or near {} K. Available temperatures " - "are {} K. Consider making use of openmc.Settings.temperature " - "to specify how intermediate temperatures are treated.", - in_name, std::round(T), concatenate(temps_available))); + fatal_error(fmt::format("MGXS library does not contain cross sections " + "for {} at or near {} K.", + in_name, std::round(T))); } } break; @@ -131,16 +122,16 @@ void Mgxs::metadata_from_hdf5(hid_t xs_id, const vector& temperature, in_name + " at temperatures that bound " + std::to_string(std::round(temperature[i]))); } - if ((temps_available[j] <= temperature[i]) && - (temperature[i] < temps_available[j + 1])) { + if ((available_temps[j] <= temperature[i]) && + (temperature[i] < available_temps[j + 1])) { if (std::find(temps_to_read.begin(), temps_to_read.end(), - temps_available[j]) == temps_to_read.end()) { - temps_to_read.push_back(temps_available[j]); + std::round(available_temps[j])) == temps_to_read.end()) { + temps_to_read.push_back(std::round((int)available_temps[j])); } if (std::find(temps_to_read.begin(), temps_to_read.end(), - temps_available[j + 1]) == temps_to_read.end()) { - temps_to_read.push_back(temps_available[j + 1]); + std::round(available_temps[j + 1])) == temps_to_read.end()) { + temps_to_read.push_back(std::round((int)available_temps[j + 1])); } break; } @@ -339,7 +330,7 @@ Mgxs::Mgxs(const std::string& in_name, const vector& mat_kTs, for (int m = 0; m < micros.size(); m++) { switch (settings::temperature_method) { case TemperatureMethod::NEAREST: { - micro_t[m] = tensor::abs(micros[m]->kTs - temp_desired).argmin(); + micro_t[m] = xt::argmin(xt::abs(micros[m]->kTs - temp_desired))[0]; auto temp_actual = micros[m]->kTs[micro_t[m]]; if (std::abs(temp_actual - temp_desired) >= @@ -352,7 +343,7 @@ Mgxs::Mgxs(const std::string& in_name, const vector& mat_kTs, case TemperatureMethod::INTERPOLATION: // Get a list of bounding temperatures for each actual temperature // present in the model - for (int k = 0; k < micros[m]->kTs.shape(0) - 1; k++) { + for (int k = 0; k < micros[m]->kTs.shape()[0] - 1; k++) { if ((micros[m]->kTs[k] <= temp_desired) && (temp_desired < micros[m]->kTs[k + 1])) { micro_t[m] = k; @@ -365,7 +356,7 @@ Mgxs::Mgxs(const std::string& in_name, const vector& mat_kTs, } } } // end switch - } // end microscopic temperature loop + } // end microscopic temperature loop // Now combine the microscopic data at each relevant temperature // We will do this by treating the multiple temperatures of a nuclide as @@ -458,7 +449,7 @@ double Mgxs::get_xs(MgxsType xstype, int gin, const int* gout, const double* mu, val = xs_t->delayed_nu_fission(a, *dg, gin); } else { val = 0.; - for (int d = 0; d < xs_t->delayed_nu_fission.shape(1); d++) { + for (int d = 0; d < xs_t->delayed_nu_fission.shape()[1]; d++) { val += xs_t->delayed_nu_fission(a, d, gin); } } @@ -473,7 +464,7 @@ double Mgxs::get_xs(MgxsType xstype, int gin, const int* gout, const double* mu, } else { // provide an outgoing group-wise sum val = 0.; - for (int g = 0; g < xs_t->chi_prompt.shape(2); g++) { + for (int g = 0; g < xs_t->chi_prompt.shape()[2]; g++) { val += xs_t->chi_prompt(a, gin, g); } } @@ -492,13 +483,13 @@ double Mgxs::get_xs(MgxsType xstype, int gin, const int* gout, const double* mu, } else { if (dg != nullptr) { val = 0.; - for (int g = 0; g < xs_t->delayed_nu_fission.shape(2); g++) { + for (int g = 0; g < xs_t->delayed_nu_fission.shape()[2]; g++) { val += xs_t->delayed_nu_fission(a, *dg, gin, g); } } else { val = 0.; - for (int g = 0; g < xs_t->delayed_nu_fission.shape(2); g++) { - for (int d = 0; d < xs_t->delayed_nu_fission.shape(3); d++) { + for (int g = 0; g < xs_t->delayed_nu_fission.shape()[2]; g++) { + for (int d = 0; d < xs_t->delayed_nu_fission.shape()[3]; d++) { val += xs_t->delayed_nu_fission(a, d, gin, g); } } @@ -510,8 +501,6 @@ double Mgxs::get_xs(MgxsType xstype, int gin, const int* gout, const double* mu, break; case MgxsType::INVERSE_VELOCITY: val = xs_t->inverse_velocity(a, gin); - if (!(val > 0)) - val = data::mg.default_inverse_velocity_[gin]; break; case MgxsType::DECAY_RATE: if (dg != nullptr) { @@ -611,12 +600,10 @@ void Mgxs::calculate_xs(Particle& p) } int temperature = p.mg_xs_cache().t; int angle = p.mg_xs_cache().a; - p.macro_xs().total = xs[temperature].total(angle, p.g()) * p.density_mult(); - p.macro_xs().absorption = - xs[temperature].absorption(angle, p.g()) * p.density_mult(); + p.macro_xs().total = xs[temperature].total(angle, p.g()); + p.macro_xs().absorption = xs[temperature].absorption(angle, p.g()); p.macro_xs().nu_fission = - fissionable ? xs[temperature].nu_fission(angle, p.g()) * p.density_mult() - : 0.; + fissionable ? xs[temperature].nu_fission(angle, p.g()) : 0.; } //============================================================================== @@ -636,7 +623,7 @@ bool Mgxs::equiv(const Mgxs& that) int Mgxs::get_temperature_index(double sqrtkT) const { - return tensor::abs(kTs - sqrtkT * sqrtkT).argmin(); + return xt::argmin(xt::abs(kTs - sqrtkT * sqrtkT))[0]; } //============================================================================== diff --git a/src/mgxs_interface.cpp b/src/mgxs_interface.cpp index 865c56580..0febc612b 100644 --- a/src/mgxs_interface.cpp +++ b/src/mgxs_interface.cpp @@ -146,7 +146,7 @@ void MgxsInterface::create_macro_xs() num_energy_groups_, num_delayed_groups_); } else { // Preserve the ordering of materials by including a blank entry - macro_xs_.emplace_back(false); + macro_xs_.emplace_back(); } } } @@ -169,13 +169,13 @@ vector> MgxsInterface::get_mat_kTs() continue; // Get temperature of cell (rounding to nearest integer) - for (int k = 0; k < cell->sqrtkT_.size(); ++k) { - double kT = cell->sqrtkT_[k] * cell->sqrtkT_[k]; + double sqrtkT = + cell->sqrtkT_.size() == 1 ? cell->sqrtkT_[j] : cell->sqrtkT_[0]; + double kT = sqrtkT * sqrtkT; - // Add temperature if it hasn't already been added - if (!contains(kTs[i_material], kT)) { - kTs[i_material].push_back(kT); - } + // Add temperature if it hasn't already been added + if (!contains(kTs[i_material], kT)) { + kTs[i_material].push_back(kT); } } } @@ -237,19 +237,6 @@ void MgxsInterface::read_header(const std::string& path_cross_sections) "library file!"); } - // Calculate approximate default inverse velocity data - for (int i = 0; i < energy_bins_.size() - 1; ++i) { - double e_min = std::max(energy_bins_[i + 1], 1e-5); - double e_max = energy_bins_[i]; - double alpha = 1.0 / (C_LIGHT * std::log(e_max / e_min)); - double k_max = std::sqrt(1 + 2.0 * MASS_NEUTRON_EV / e_max); - double k_min = std::sqrt(1 + 2.0 * MASS_NEUTRON_EV / e_min); - double inv_v = - alpha * (2.0 * (std::atanh(1.0 / k_max) - std::atanh(1.0 / k_min)) - - (k_max - k_min)); - default_inverse_velocity_.push_back(inv_v); - } - // Close MGXS HDF5 file file_close(file_id); } @@ -257,7 +244,7 @@ void MgxsInterface::read_header(const std::string& path_cross_sections) void put_mgxs_header_data_to_globals() { // Get the minimum and maximum energies - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); data::energy_min[neutron] = data::mg.energy_bins_.back(); data::energy_max[neutron] = data::mg.energy_bins_.front(); diff --git a/src/ncrystal_interface.cpp b/src/ncrystal_interface.cpp index 935d2b885..b39f62d90 100644 --- a/src/ncrystal_interface.cpp +++ b/src/ncrystal_interface.cpp @@ -7,34 +7,89 @@ namespace openmc { //============================================================================== -// NCrystalMat implementation +// Constants //============================================================================== -NCrystalMat::NCrystalMat(const std::string& cfg) : cfg_(cfg), proc_(cfg.c_str()) -{} +#ifdef NCRYSTAL +const bool NCRYSTAL_ENABLED = true; +#else +const bool NCRYSTAL_ENABLED = false; +#endif + +//============================================================================== +// NCrystal wrapper class for the OpenMC random number generator +//============================================================================== + +#ifdef NCRYSTAL +class NCrystalRNGWrapper : public NCrystal::RNGStream { +public: + constexpr NCrystalRNGWrapper(uint64_t* seed) noexcept : openmc_seed_(seed) {} + +protected: + double actualGenerate() override + { + return std::max( + std::numeric_limits::min(), prn(openmc_seed_)); + } + +private: + uint64_t* openmc_seed_; +}; +#endif + +//============================================================================== +// NCrystal implementation +//============================================================================== + +NCrystalMat::NCrystalMat(const std::string& cfg) +{ +#ifdef NCRYSTAL + cfg_ = cfg; + ptr_ = NCrystal::FactImpl::createScatter(cfg); +#else + fatal_error("Your build of OpenMC does not support NCrystal materials."); +#endif +} + +#ifdef NCRYSTAL +std::string NCrystalMat::cfg() const +{ + return cfg_; +} double NCrystalMat::xs(const Particle& p) const { // Calculate scattering XS per atom with NCrystal, only once per material - double neutron_state[4] = {p.E(), p.u().x, p.u().y, p.u().z}; - return proc_.cross_section(neutron_state); + NCrystal::CachePtr dummy_cache; + auto nc_energy = NCrystal::NeutronEnergy {p.E()}; + return ptr_->crossSection(dummy_cache, nc_energy, {p.u().x, p.u().y, p.u().z}) + .get(); } void NCrystalMat::scatter(Particle& p) const { - // Scatter with NCrystal, using the OpenMC RNG stream: - uint64_t* seed = p.current_seed(); - std::function rng = [&seed]() { return prn(seed); }; - double neutron_state[4] = {p.E(), p.u().x, p.u().y, p.u().z}; - proc_.scatter(rng, neutron_state); + NCrystalRNGWrapper rng(p.current_seed()); // Initialize RNG + // create a cache pointer for multi thread physics + NCrystal::CachePtr dummy_cache; + auto nc_energy = NCrystal::NeutronEnergy {p.E()}; + auto outcome = ptr_->sampleScatter( + dummy_cache, rng, nc_energy, {p.u().x, p.u().y, p.u().z}); + // Modify attributes of particle - p.E() = neutron_state[0]; + p.E() = outcome.ekin.get(); Direction u_old {p.u()}; - p.u() = Direction(neutron_state[1], neutron_state[2], neutron_state[3]); + p.u() = + Direction(outcome.direction[0], outcome.direction[1], outcome.direction[2]); p.mu() = u_old.dot(p.u()); p.event_mt() = ELASTIC; } +NCrystalMat::operator bool() const +{ + return ptr_.get(); +} +#endif + //============================================================================== // Functions //============================================================================== diff --git a/src/ncrystal_load.cpp b/src/ncrystal_load.cpp deleted file mode 100644 index b69f3a27f..000000000 --- a/src/ncrystal_load.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "openmc/ncrystal_load.h" - -#include // for isspace -#include // for strtoul -#include // for shared_ptr -#include // for mutex, lock_guard -#include - -#include -#include // for popen, pclose - -#include "openmc/error.h" - -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include // for LoadLibrary, GetProcAddress -#else -#include // for dlopen, dlsym, dlerror -#endif - -namespace openmc { -namespace { - -struct NCrystalConfig { - std::string shlibpath; - unsigned long intversion = 0; - std::string symbol_namespace; -}; - -NCrystalConfig query_ncrystal_config() -{ -#ifdef _WIN32 - FILE* pipe = _popen("ncrystal-config --show " - "intversion shlibpath namespace", - "r"); -#else - FILE* pipe = popen("ncrystal-config --show " - "intversion shlibpath namespace 2>/dev/null", - "r"); -#endif - if (!pipe) - return {}; // failure - auto readLine = [pipe](std::string& tgt) -> bool { - // Read line and discard trailing whitespace (including newline chars). - char buffer[4096]; - if (fgets(buffer, sizeof(buffer), pipe) == NULL) - return false; - tgt = buffer; - while (!tgt.empty() && std::isspace(tgt.back())) - tgt.pop_back(); - return true; - }; - auto parseIntVersion = [](const std::string& s) { - char* str_end = nullptr; - unsigned long v = std::strtoul(s.c_str(), &str_end, 10); - return (v >= 2002000 && v < 999999999 && str_end == s.c_str() + s.size()) - ? v - : 0; - }; - - NCrystalConfig res; - if (!readLine(res.shlibpath) || - !(res.intversion = parseIntVersion(res.shlibpath)) || - !readLine(res.shlibpath) || res.shlibpath.empty() || - !readLine(res.symbol_namespace)) { - res.intversion = 0; // failure - } - -#ifdef _WIN32 - auto returnCode = _pclose(pipe); -#else - auto returnCode = pclose(pipe); -#endif - if (returnCode == 0 && res.intversion >= 2002000) - return res; - return {}; // failure -} - -struct NCrystalAPIDB { - std::mutex mtx; - std::shared_ptr api; - using FctSignature = void* (*)(int); - FctSignature ncrystal_access_virtapi_fct = nullptr; -}; - -void* load_virtapi_raw(unsigned interface_id, NCrystalAPIDB& db) -{ - if (!db.ncrystal_access_virtapi_fct) { - auto cfg = query_ncrystal_config(); - if (!(cfg.intversion >= 4001000)) { - // This is the most likely error message people will see: - fatal_error("Could not locate a functioning and recent enough" - " NCrystal installation (required since geometry" - " contains NCrystal materials)."); - } -#ifdef _WIN32 - auto handle = LoadLibrary(cfg.shlibpath.c_str()); -#else - dlerror(); // clear previous errors - void* handle = dlopen(cfg.shlibpath.c_str(), RTLD_LOCAL | RTLD_LAZY); -#endif - if (!handle) - fatal_error("Loading of the NCrystal library failed"); - - std::string symbol = - fmt::format("ncrystal{}_access_virtual_api", cfg.symbol_namespace); - -#ifdef _WIN32 - void* addr = (void*)(intptr_t)GetProcAddress(handle, symbol.c_str()); - if (!addr) - fatal_error("GetProcAddress(" - "ncrystal_access_virtual_api) failed"); -#else - dlerror(); // clear previous errors - void* addr = dlsym(handle, symbol.c_str()); - if (!addr) - fatal_error("dlsym(ncrystal_access_virtual_api) failed"); -#endif - db.ncrystal_access_virtapi_fct = - reinterpret_cast(addr); - } - - void* result = (*db.ncrystal_access_virtapi_fct)(interface_id); - if (!result) - fatal_error("NCrystal installation does not support required interface."); - - return result; -} - -NCrystalAPIDB& get_ncrystal_api_db() -{ - static NCrystalAPIDB db; - return db; -} -} // namespace - -std::shared_ptr load_ncrystal_api() -{ - auto& db = get_ncrystal_api_db(); - std::lock_guard lock(db.mtx); - if (!db.api) { - void* raw_api = load_virtapi_raw(NCrystalAPI::interface_id, db); - if (!raw_api) - fatal_error("Problems loading NCrystal."); - db.api = *reinterpret_cast*>(raw_api); - } - return db.api; -} -} // namespace openmc diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 17d6e952c..04ec11073 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -17,11 +17,11 @@ #include -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xview.hpp" #include // for sort, min_element -#include -#include // for to_string, stoi +#include // for to_string, stoi namespace openmc { @@ -30,8 +30,8 @@ namespace openmc { //============================================================================== namespace data { -array energy_min {0.0, 0.0, 0.0, 0.0}; -array energy_max {INFTY, INFTY, INFTY, INFTY}; +array energy_min {0.0, 0.0}; +array energy_max {INFTY, INFTY}; double temperature_min {INFTY}; double temperature_max {0.0}; std::unordered_map nuclide_map; @@ -86,7 +86,7 @@ Nuclide::Nuclide(hid_t group, const vector& temperature) for (const auto& name : dset_names) { double T; read_dataset(kT_group, name.c_str(), T); - temps_available.push_back(std::round(T / K_BOLTZMANN)); + temps_available.push_back(T / K_BOLTZMANN); } std::sort(temps_available.begin(), temps_available.end()); @@ -158,12 +158,9 @@ Nuclide::Nuclide(hid_t group, const vector& temperature) } } } else { - fatal_error(fmt::format( - "Nuclear data library does not contain cross sections " - "for {} at or near {} K. Available temperatures " - "are {} K. Consider making use of openmc.Settings.temperature " - "to specify how intermediate temperatures are treated.", - name_, std::to_string(T_desired), concatenate(temps_available))); + fatal_error( + "Nuclear data library does not contain cross sections for " + name_ + + " at or near " + std::to_string(T_desired) + " K."); } } break; @@ -176,8 +173,8 @@ Nuclide::Nuclide(hid_t group, const vector& temperature) for (int j = 0; j < temps_available.size() - 1; ++j) { if (temps_available[j] <= T_desired && T_desired < temps_available[j + 1]) { - int T_j = temps_available[j]; - int T_j1 = temps_available[j + 1]; + int T_j = std::round(temps_available[j]); + int T_j1 = std::round(temps_available[j + 1]); if (!contains(temps_to_read, T_j)) { temps_to_read.push_back(T_j); } @@ -194,14 +191,14 @@ Nuclide::Nuclide(hid_t group, const vector& temperature) if (std::abs(T_desired - temps_available.front()) <= settings::temperature_tolerance) { if (!contains(temps_to_read, temps_available.front())) { - temps_to_read.push_back(temps_available.front()); + temps_to_read.push_back(std::round(temps_available.front())); } continue; } if (std::abs(T_desired - temps_available.back()) <= settings::temperature_tolerance) { if (!contains(temps_to_read, temps_available.back())) { - temps_to_read.push_back(temps_available.back()); + temps_to_read.push_back(std::round(temps_available.back())); } continue; } @@ -247,8 +244,7 @@ Nuclide::Nuclide(hid_t group, const vector& temperature) for (auto name : group_names(rxs_group)) { if (starts_with(name, "reaction_")) { hid_t rx_group = open_group(rxs_group, name.c_str()); - reactions_.push_back( - make_unique(rx_group, temps_to_read, name_)); + reactions_.push_back(make_unique(rx_group, temps_to_read)); // Check for 0K elastic scattering const auto& rx = reactions_.back(); @@ -360,7 +356,8 @@ void Nuclide::create_derived( { for (const auto& grid : grid_) { // Allocate and initialize cross section - xs_.push_back(tensor::zeros({grid.energy.size(), 5})); + array shape {grid.energy.size(), 5}; + xs_.emplace_back(shape, 0.0); } reaction_index_.fill(C_NONE); @@ -373,15 +370,16 @@ void Nuclide::create_derived( for (int t = 0; t < kTs_.size(); ++t) { int j = rx->xs_[t].threshold; int n = rx->xs_[t].value.size(); - auto xs = tensor::Tensor( - rx->xs_[t].value.data(), rx->xs_[t].value.size()); + auto xs = xt::adapt(rx->xs_[t].value); + for (const auto& p : rx->products_) { - if (p.particle_.is_photon()) { + if (p.particle_ == ParticleType::photon) { + auto pprod = xt::view(xs_[t], xt::range(j, j + n), XS_PHOTON_PROD); for (int k = 0; k < n; ++k) { double E = grid_[t].energy[k + j]; - // For fission, artificially increase the photon yield to - // account for delayed photons + // For fission, artificially increase the photon yield to account + // for delayed photons double f = 1.0; if (settings::delayed_photon_scaling) { if (is_fission(rx->mt_)) { @@ -393,7 +391,7 @@ void Nuclide::create_derived( } } - xs_[t](j + k, XS_PHOTON_PROD) += f * xs[k] * (*p.yield_)(E); + pprod[k] += f * xs[k] * (*p.yield_)(E); } } } @@ -403,17 +401,20 @@ void Nuclide::create_derived( continue; // Add contribution to total cross section - xs_[t].slice(tensor::range(j, j + n), XS_TOTAL) += xs; + auto total = xt::view(xs_[t], xt::range(j, j + n), XS_TOTAL); + total += xs; // Add contribution to absorption cross section + auto absorption = xt::view(xs_[t], xt::range(j, j + n), XS_ABSORPTION); if (is_disappearance(rx->mt_)) { - xs_[t].slice(tensor::range(j, j + n), XS_ABSORPTION) += xs; + absorption += xs; } if (is_fission(rx->mt_)) { fissionable_ = true; - xs_[t].slice(tensor::range(j, j + n), XS_FISSION) += xs; - xs_[t].slice(tensor::range(j, j + n), XS_ABSORPTION) += xs; + auto fission = xt::view(xs_[t], xt::range(j, j + n), XS_FISSION); + fission += xs; + absorption += xs; // Keep track of fission reactions if (t == 0) { @@ -464,8 +465,8 @@ void Nuclide::create_derived( } } } else { - // Otherwise, assume that any that have 0 K elastic scattering data - // are resonant + // Otherwise, assume that any that have 0 K elastic scattering data are + // resonant resonant_ = !energy_0K_.empty(); } @@ -495,7 +496,7 @@ void Nuclide::create_derived( void Nuclide::init_grid() { - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); double E_min = data::energy_min[neutron]; double E_max = data::energy_max[neutron]; int M = settings::n_log_bins; @@ -504,7 +505,7 @@ void Nuclide::init_grid() double spacing = std::log(E_max / E_min) / M; // Create equally log-spaced energy grid - auto umesh = tensor::linspace(0.0, M * spacing, M + 1); + auto umesh = xt::linspace(0.0, M * spacing, M + 1); for (auto& grid : grid_) { // Resize array for storing grid indices @@ -546,7 +547,7 @@ double Nuclide::nu(double E, EmissionMode mode, int group) const for (int i = 1; i < rx->products_.size(); ++i) { // Skip any non-neutron products const auto& product = rx->products_[i]; - if (!product.particle_.is_neutron()) + if (product.particle_ != ParticleType::neutron) continue; // Evaluate yield @@ -776,8 +777,8 @@ void Nuclide::calculate_xs( } for (int j = 0; j < DEPLETION_RX.size(); ++j) { - // If reaction is present and energy is greater than threshold, set - // the reaction xs appropriately + // If reaction is present and energy is greater than threshold, set the + // reaction xs appropriately int i_rx = reaction_index_[DEPLETION_RX[j]]; if (i_rx >= 0) { const auto& rx = reactions_[i_rx]; @@ -814,9 +815,9 @@ void Nuclide::calculate_xs( // Initialize URR probability table treatment to false micro.use_ptable = false; - // If there is S(a,b) data for this nuclide, we need to set the - // sab_scatter and sab_elastic cross sections and correct the total and - // elastic cross sections. + // If there is S(a,b) data for this nuclide, we need to set the sab_scatter + // and sab_elastic cross sections and correct the total and elastic cross + // sections. if (i_sab >= 0) this->calculate_sab_xs(i_sab, sab_frac, p); @@ -979,8 +980,8 @@ void Nuclide::calculate_urr_xs(int i_temp, Particle& p) const } // Set elastic, absorption, fission, total, and capture x/s. Note that the - // total x/s is calculated as a sum of partials instead of the - // table-provided value + // total x/s is calculated as a sum of partials instead of the table-provided + // value micro.elastic = elastic; micro.absorption = capture + fission; micro.fission = fission; @@ -995,19 +996,19 @@ void Nuclide::calculate_urr_xs(int i_temp, Particle& p) const } } -std::pair Nuclide::find_temperature(double T) const +std::pair Nuclide::find_temperature(double T) const { - assert(T >= 0.0); + Expects(T >= 0.0); // Determine temperature index - int64_t i_temp = 0; + gsl::index i_temp = 0; double f = 0.0; double kT = K_BOLTZMANN * T; - int64_t n = kTs_.size(); + gsl::index n = kTs_.size(); switch (settings::temperature_method) { case TemperatureMethod::NEAREST: { double max_diff = INFTY; - for (int64_t t = 0; t < n; ++t) { + for (gsl::index t = 0; t < n; ++t) { double diff = std::abs(kTs_[t] - kT); if (diff < max_diff) { i_temp = t; @@ -1034,17 +1035,17 @@ std::pair Nuclide::find_temperature(double T) const f = (kT - kTs_[i_temp]) / (kTs_[i_temp + 1] - kTs_[i_temp]); } - assert(i_temp >= 0 && i_temp < n); + Ensures(i_temp >= 0 && i_temp < n); return {i_temp, f}; } double Nuclide::collapse_rate(int MT, double temperature, - span energy, span flux) const + gsl::span energy, gsl::span flux) const { - assert(MT > 0); - assert(energy.size() > 0); - assert(energy.size() == flux.size() + 1); + Expects(MT > 0); + Expects(energy.size() > 0); + Expects(energy.size() == flux.size() + 1); int i_rx = reaction_index_[MT]; if (i_rx < 0) @@ -1052,7 +1053,7 @@ double Nuclide::collapse_rate(int MT, double temperature, const auto& rx = reactions_[i_rx]; // Determine temperature index - int64_t i_temp; + gsl::index i_temp; double f; std::tie(i_temp, f) = this->find_temperature(temperature); @@ -1108,7 +1109,7 @@ extern "C" size_t nuclides_size() extern "C" int openmc_load_nuclide(const char* name, const double* temps, int n) { if (data::nuclide_map.find(name) == data::nuclide_map.end() || - data::nuclide_map.at(name) >= data::nuclides.size()) { + data::nuclide_map.at(name) >= data::elements.size()) { LibraryKey key {Library::Type::neutron, name}; const auto& it = data::library_map.find(key); if (it == data::library_map.end()) { @@ -1209,6 +1210,7 @@ extern "C" int openmc_nuclide_collapse_rate(int index, int MT, *xs = data::nuclides[index]->collapse_rate( MT, temperature, {energy, energy + n + 1}, {flux, flux + n}); } catch (const std::out_of_range& e) { + fmt::print("Caught error\n"); set_errmsg(e.what()); return OPENMC_E_OUT_OF_BOUNDS; } diff --git a/src/output.cpp b/src/output.cpp index 04a8caa60..5fdbea130 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -17,7 +17,7 @@ #ifdef _OPENMP #include #endif -#include "openmc/tensor.h" +#include "xtensor/xview.hpp" #include "openmc/capi.h" #include "openmc/cell.h" @@ -44,12 +44,6 @@ namespace openmc { -#ifdef OPENMC_ENABLE_STRICT_FP -const bool STRICT_FP_ENABLED = true; -#else -const bool STRICT_FP_ENABLED = false; -#endif - //============================================================================== void title() @@ -81,12 +75,13 @@ void title() // Write version information fmt::print( " | The OpenMC Monte Carlo Code\n" - " Copyright | 2011-2026 MIT, UChicago Argonne LLC, and contributors\n" + " Copyright | 2011-2024 MIT, UChicago Argonne LLC, and contributors\n" " License | https://docs.openmc.org/en/latest/license.html\n" - " Version | {}.{}.{}{}{}\n", - VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE, VERSION_DEV ? "-dev" : "", - VERSION_COMMIT_COUNT); - fmt::print(" Commit Hash | {}\n", VERSION_COMMIT_HASH); + " Version | {}.{}.{}{}\n", + VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE, VERSION_DEV ? "-dev" : ""); +#ifdef GIT_SHA1 + fmt::print(" Git SHA1 | {}\n", GIT_SHA1); +#endif // Write the date and time fmt::print(" Date/Time | {}\n", time_stamp()); @@ -161,21 +156,21 @@ std::string time_stamp() void print_particle(Particle& p) { // Display particle type and ID. - switch (p.type().pdg_number()) { - case PDG_NEUTRON: + switch (p.type()) { + case ParticleType::neutron: fmt::print("Neutron "); break; - case PDG_PHOTON: + case ParticleType::photon: fmt::print("Photon "); break; - case PDG_ELECTRON: + case ParticleType::electron: fmt::print("Electron "); break; - case PDG_POSITRON: + case ParticleType::positron: fmt::print("Positron "); break; default: - fmt::print("Particle {} ", p.type().str()); + fmt::print("Unknown Particle "); } fmt::print("{}\n", p.id()); @@ -183,32 +178,31 @@ void print_particle(Particle& p) for (auto i = 0; i < p.n_coord(); i++) { fmt::print(" Level {}\n", i); - if (p.coord(i).cell() != C_NONE) { - const Cell& c {*model::cells[p.coord(i).cell()]}; + if (p.coord(i).cell != C_NONE) { + const Cell& c {*model::cells[p.coord(i).cell]}; fmt::print(" Cell = {}\n", c.id_); } - if (p.coord(i).universe() != C_NONE) { - const Universe& u {*model::universes[p.coord(i).universe()]}; + if (p.coord(i).universe != C_NONE) { + const Universe& u {*model::universes[p.coord(i).universe]}; fmt::print(" Universe = {}\n", u.id_); } - if (p.coord(i).lattice() != C_NONE) { - const Lattice& lat {*model::lattices[p.coord(i).lattice()]}; + if (p.coord(i).lattice != C_NONE) { + const Lattice& lat {*model::lattices[p.coord(i).lattice]}; fmt::print(" Lattice = {}\n", lat.id_); - fmt::print(" Lattice position = ({},{},{})\n", - p.coord(i).lattice_index()[0], p.coord(i).lattice_index()[1], - p.coord(i).lattice_index()[2]); + fmt::print(" Lattice position = ({},{},{})\n", p.coord(i).lattice_i[0], + p.coord(i).lattice_i[1], p.coord(i).lattice_i[2]); } - fmt::print(" r = {}\n", p.coord(i).r()); - fmt::print(" u = {}\n", p.coord(i).u()); + fmt::print(" r = {}\n", p.coord(i).r); + fmt::print(" u = {}\n", p.coord(i).u); } // Display miscellaneous info. - if (p.surface() != SURFACE_NONE) { + if (p.surface() != 0) { // Surfaces identifiers are >= 1, but indices are >= 0 so we need -1 - const Surface& surf {*model::surfaces[p.surface_index()]}; + const Surface& surf {*model::surfaces[std::abs(p.surface()) - 1]}; fmt::print(" Surface = {}\n", (p.surface() > 0) ? surf.id_ : -surf.id_); } fmt::print(" Weight = {}\n", p.wgt()); @@ -287,7 +281,6 @@ void print_usage() " -t, --track Write tracks for all particles (up to " "max_tracks)\n" " -e, --event Run using event-based parallelism\n" - " -q, --verbosity Output verbosity\n" " -v, --version Show version information\n" " -h, --help Show this message\n"); } @@ -298,10 +291,12 @@ void print_usage() void print_version() { if (mpi::master) { - fmt::print("OpenMC version {}.{}.{}{}{}\n", VERSION_MAJOR, VERSION_MINOR, - VERSION_RELEASE, VERSION_DEV ? "-dev" : "", VERSION_COMMIT_COUNT); - fmt::print("Commit hash: {}\n", VERSION_COMMIT_HASH); - fmt::print("Copyright (c) 2011-2026 MIT, UChicago Argonne LLC, and " + fmt::print("OpenMC version {}.{}.{}\n", VERSION_MAJOR, VERSION_MINOR, + VERSION_RELEASE); +#ifdef GIT_SHA1 + fmt::print("Git SHA1: {}\n", GIT_SHA1); +#endif + fmt::print("Copyright (c) 2011-2024 MIT, UChicago Argonne LLC, and " "contributors\nMIT/X license at " "\n"); } @@ -321,8 +316,9 @@ void print_build_info() std::string png(n); std::string profiling(n); std::string coverage(n); + std::string mcpl(n); + std::string ncrystal(n); std::string uwuw(n); - std::string strict_fp(n); #ifdef PHDF5 phdf5 = y; @@ -330,12 +326,18 @@ void print_build_info() #ifdef OPENMC_MPI mpi = y; #endif -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC dagmc = y; #endif -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH libmesh = y; #endif +#ifdef OPENMC_MCPL + mcpl = y; +#endif +#ifdef NCRYSTAL + ncrystal = y; +#endif #ifdef USE_LIBPNG png = y; #endif @@ -345,12 +347,9 @@ void print_build_info() #ifdef COVERAGEBUILD coverage = y; #endif -#ifdef OPENMC_UWUW_ENABLED +#ifdef UWUW uwuw = y; #endif -#ifdef OPENMC_ENABLE_STRICT_FP - strict_fp = y; -#endif // Wraps macro variables in quotes #define STRINGIFY(x) STRINGIFY2(x) @@ -365,10 +364,11 @@ void print_build_info() fmt::print("PNG support: {}\n", png); fmt::print("DAGMC support: {}\n", dagmc); fmt::print("libMesh support: {}\n", libmesh); + fmt::print("MCPL support: {}\n", mcpl); + fmt::print("NCrystal support: {}\n", ncrystal); fmt::print("Coverage testing: {}\n", coverage); fmt::print("Profiling flags: {}\n", profiling); fmt::print("UWUW support: {}\n", uwuw); - fmt::print("Strict FP: {}\n", strict_fp); } } @@ -501,14 +501,6 @@ void print_runtime() show_rate("Calculation Rate (inactive)", speed_inactive); } show_rate("Calculation Rate (active)", speed_active); - - // Display track rate when weight windows are enabled - if (settings::weight_windows_on) { - double speed_tracks = - simulation::simulation_tracks_completed / time_active.elapsed(); - fmt::print( - " {:<33} = {:.6} tracks/second\n", "Track Rate (active)", speed_tracks); - } } //============================================================================== @@ -609,9 +601,6 @@ const std::unordered_map score_names = { {SCORE_FISS_Q_RECOV, "Recoverable fission power"}, {SCORE_CURRENT, "Current"}, {SCORE_PULSE_HEIGHT, "pulse-height"}, - {SCORE_IFP_TIME_NUM, "IFP lifetime numerator"}, - {SCORE_IFP_BETA_NUM, "IFP delayed fraction numerator"}, - {SCORE_IFP_DENOM, "IFP common denominator"}, }; //! Create an ASCII output file showing all tally results. @@ -621,15 +610,8 @@ void write_tallies() if (model::tallies.empty()) return; - // Tag tallies.out written during the forward solve of an adjoint run - const char* forward = - (FlatSourceDomain::solve_ == RandomRaySolve::FORWARD_FOR_ADJOINT) - ? "forward." - : ""; - // Set filename for tallies_out - std::string filename = - fmt::format("{}tallies.{}out", settings::path_output, forward); + std::string filename = fmt::format("{}tallies.out", settings::path_output); // Open the tallies.out file. std::ofstream tallies_out; diff --git a/src/particle.cpp b/src/particle.cpp index 10e8f213d..7d30e26bd 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -8,13 +8,11 @@ #include "openmc/bank.h" #include "openmc/capi.h" #include "openmc/cell.h" -#include "openmc/collision_track.h" #include "openmc/constants.h" #include "openmc/dagmc.h" #include "openmc/error.h" #include "openmc/geometry.h" #include "openmc/hdf5_interface.h" -#include "openmc/lattice.h" #include "openmc/material.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" @@ -34,7 +32,7 @@ #include "openmc/track_output.h" #include "openmc/weight_windows.h" -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC #include "DagMC.hpp" #endif @@ -46,117 +44,76 @@ namespace openmc { double Particle::speed() const { - if (settings::run_CE) { - // Determine mass in eV/c^2 - double mass = this->mass(); + // Determine mass in eV/c^2 + double mass; + switch (this->type()) { + case ParticleType::neutron: + mass = MASS_NEUTRON_EV; + break; + case ParticleType::photon: + mass = 0.0; + break; + case ParticleType::electron: + case ParticleType::positron: + mass = MASS_ELECTRON_EV; + break; + } - // Equivalent to C * sqrt(1-(m/(m+E))^2) without problem at E<E() * (this->E() + 2 * mass)) / - (this->E() + mass); + if (this->E() < 1.0e-9 * mass) { + // If the energy is much smaller than the mass, revert to non-relativistic + // formula. The 1e-9 criterion is specifically chosen as the point below + // which the error from using the non-relativistic formula is less than the + // round-off eror when using the relativistic formula (see analysis at + // https://gist.github.com/paulromano/da3b473fe3df33de94b265bdff0c7817) + return C_LIGHT * std::sqrt(2 * this->E() / mass); } else { - auto mat = this->material(); - if (mat == MATERIAL_VOID) - return 1.0 / data::mg.default_inverse_velocity_[this->g()]; - auto& macro_xs = data::mg.macro_xs_[mat]; - int macro_t = this->mg_xs_cache().t; - int macro_a = macro_xs.get_angle_index(this->u()); - return 1.0 / macro_xs.get_xs( - MgxsType::INVERSE_VELOCITY, this->g(), macro_t, macro_a); + // Calculate inverse of Lorentz factor + const double inv_gamma = mass / (this->E() + mass); + + // Calculate speed via v = c * sqrt(1 - γ^-2) + return C_LIGHT * std::sqrt(1 - inv_gamma * inv_gamma); } } -double Particle::mass() const +void Particle::move_distance(double length) { - switch (type().pdg_number()) { - case PDG_NEUTRON: - return MASS_NEUTRON_EV; - case PDG_ELECTRON: - case PDG_POSITRON: - return MASS_ELECTRON_EV; - default: - return this->type().mass() * AMU_EV; + for (int j = 0; j < n_coord(); ++j) { + coord(j).r += length * coord(j).u; } } -bool Particle::create_secondary( +void Particle::create_secondary( double wgt, Direction u, double E, ParticleType type) { // If energy is below cutoff for this particle, don't create secondary // particle - int idx = type.transport_index(); - if (idx == C_NONE) { - return false; - } - if (E < settings::energy_cutoff[idx]) { - return false; + if (E < settings::energy_cutoff[static_cast(type)]) { + return; } - // Increment number of secondaries created (for ParticleProductionFilter) - n_secondaries()++; + secondary_bank().emplace_back(); - SourceSite bank; + auto& bank {secondary_bank().back()}; bank.particle = type; bank.wgt = wgt; bank.r = r(); bank.u = u; bank.E = settings::run_CE ? E : g(); bank.time = time(); - bank_second_E() += bank.E; - bank.parent_id = current_work(); - if (settings::use_shared_secondary_bank) { - bank.progeny_id = n_progeny()++; - } - bank.wgt_born = wgt_born(); - bank.wgt_ww_born = wgt_ww_born(); - bank.n_split = n_split(); - local_secondary_bank().emplace_back(bank); - return true; -} - -void Particle::split(double wgt) -{ - SourceSite bank; - bank.particle = type(); - bank.wgt = wgt; - bank.r = r(); - bank.u = u(); - bank.E = settings::run_CE ? E() : g(); - bank.time = time(); - - // Convert signed index to a signed surface ID - if (surface() == SURFACE_NONE) { - bank.surf_id = SURFACE_NONE; - } else { - int surf_id = model::surfaces[surface_index()]->id_; - bank.surf_id = (surface() > 0) ? surf_id : -surf_id; - } - - bank.wgt_born = wgt_born(); - bank.wgt_ww_born = wgt_ww_born(); - bank.n_split = n_split(); - bank.parent_id = current_work(); - if (settings::use_shared_secondary_bank) { - bank.progeny_id = n_progeny()++; - } - - local_secondary_bank().emplace_back(bank); + n_bank_second() += 1; } void Particle::from_source(const SourceSite* src) { // Reset some attributes clear(); - surface() = SURFACE_NONE; + surface() = 0; cell_born() = C_NONE; material() = C_NONE; n_collision() = 0; fission() = false; zero_flux_derivs(); - lifetime() = 0.0; -#ifdef OPENMC_DAGMC_ENABLED - history().reset(); -#endif // Copy attributes from source bank site type() = src->particle; @@ -179,18 +136,6 @@ void Particle::from_source(const SourceSite* src) E_last() = E(); time() = src->time; time_last() = src->time; - parent_nuclide() = src->parent_nuclide; - delayed_group() = src->delayed_group; - - // Convert signed surface ID to signed index - if (src->surf_id != SURFACE_NONE) { - int index_plus_one = model::surface_map[std::abs(src->surf_id)] + 1; - surface() = (src->surf_id > 0) ? index_plus_one : -index_plus_one; - } - - wgt_born() = src->wgt_born; - wgt_ww_born() = src->wgt_ww_born; - n_split() = src->n_split; } void Particle::event_calculate_xs() @@ -213,7 +158,7 @@ void Particle::event_calculate_xs() // If the cell hasn't been determined based on the particle's location, // initiate a search for the current cell. This generally happens at the // beginning of the history and again for any secondary particles - if (lowest_coord().cell() == C_NONE) { + if (lowest_coord().cell == C_NONE) { if (!exhaustive_find_cell(*this)) { mark_as_lost( "Could not find the cell containing particle " + std::to_string(id())); @@ -222,11 +167,11 @@ void Particle::event_calculate_xs() // Set birth cell attribute if (cell_born() == C_NONE) - cell_born() = lowest_coord().cell(); + cell_born() = lowest_coord().cell; // Initialize last cells from current cell for (int j = 0; j < n_coord(); ++j) { - cell_last(j) = coord(j).cell(); + cell_last(j) = coord(j).cell; } n_coord_last() = n_coord(); } @@ -241,8 +186,7 @@ void Particle::event_calculate_xs() // Calculate microscopic and macroscopic cross sections if (material() != MATERIAL_VOID) { if (settings::run_CE) { - if (material() != material_last() || sqrtkT() != sqrtkT_last() || - density_mult() != density_mult_last()) { + if (material() != material_last() || sqrtkT() != sqrtkT_last()) { // If the material is the same as the last material and the // temperature hasn't changed, we don't need to lookup cross // sections again. @@ -271,33 +215,35 @@ void Particle::event_advance() boundary() = distance_to_boundary(*this); // Sample a distance to collision - if (type() == ParticleType::electron() || - type() == ParticleType::positron()) { - collision_distance() = material() == MATERIAL_VOID ? INFINITY : 0.0; + if (type() == ParticleType::electron || type() == ParticleType::positron) { + collision_distance() = 0.0; } else if (macro_xs().total == 0.0) { collision_distance() = INFINITY; } else { collision_distance() = -std::log(prn(current_seed())) / macro_xs().total; } - double speed = this->speed(); - double time_cutoff = settings::time_cutoff[type().transport_index()]; - double distance_cutoff = - (time_cutoff < INFTY) ? (time_cutoff - time()) * speed : INFTY; - - // Select smaller of the three distances - double distance = - std::min({boundary().distance(), collision_distance(), distance_cutoff}); + // Select smaller of the two distances + double distance = std::min(boundary().distance, collision_distance()); // Advance particle in space and time - this->move_distance(distance); - double dt = distance / speed; - this->time() += dt; - this->lifetime() += dt; + // Short-term solution until the surface source is revised and we can use + // this->move_distance(distance) + for (int j = 0; j < n_coord(); ++j) { + coord(j).r += distance * coord(j).u; + } + this->time() += distance / this->speed(); - // Score timed track-length tallies - if (!model::active_timed_tracklength_tallies.empty()) { - score_timed_tracklength_tally(*this, distance); + // Kill particle if its time exceeds the cutoff + bool hit_time_boundary = false; + double time_cutoff = settings::time_cutoff[static_cast(type())]; + if (time() > time_cutoff) { + double dt = time() - time_cutoff; + time() = time_cutoff; + + double push_back_distance = speed() * dt; + this->move_distance(-push_back_distance); + hit_time_boundary = true; } // Score track-length tallies @@ -306,7 +252,8 @@ void Particle::event_advance() } // Score track-length estimate of k-eff - if (settings::run_mode == RunMode::EIGENVALUE && type().is_neutron()) { + if (settings::run_mode == RunMode::EIGENVALUE && + type() == ParticleType::neutron) { keff_tally_tracklength() += wgt() * distance * macro_xs().nu_fission; } @@ -316,7 +263,7 @@ void Particle::event_advance() } // Set particle weight to zero if it hit the time boundary - if (distance == distance_cutoff) { + if (hit_time_boundary) { wgt() = 0.0; } } @@ -325,69 +272,51 @@ void Particle::event_cross_surface() { // Saving previous cell data for (int j = 0; j < n_coord(); ++j) { - cell_last(j) = coord(j).cell(); + cell_last(j) = coord(j).cell; } n_coord_last() = n_coord(); // Set surface that particle is on and adjust coordinate levels - surface() = boundary().surface(); - n_coord() = boundary().coord_level(); + surface() = boundary().surface_index; + n_coord() = boundary().coord_level; - if (boundary().lattice_translation()[0] != 0 || - boundary().lattice_translation()[1] != 0 || - boundary().lattice_translation()[2] != 0) { + if (boundary().lattice_translation[0] != 0 || + boundary().lattice_translation[1] != 0 || + boundary().lattice_translation[2] != 0) { // Particle crosses lattice boundary - int i_lattice = coord(boundary().coord_level() - 1).lattice(); bool verbose = settings::verbosity >= 10 || trace(); cross_lattice(*this, boundary(), verbose); event() = TallyEvent::LATTICE; - - // Score cell to cell partial currents - if (!model::active_surface_tallies.empty()) { - auto& lat {*model::lattices[i_lattice]}; - bool is_valid; - Direction normal = - lat.get_normal(boundary().lattice_translation(), is_valid); - if (is_valid) { - normal /= normal.norm(); - score_surface_tally(*this, model::active_surface_tallies, normal); - } - } - } else { - - const auto& surf {*model::surfaces[surface_index()].get()}; - // Particle crosses surface + // TODO: off-by-one + const auto& surf {model::surfaces[std::abs(surface()) - 1].get()}; // If BC, add particle to surface source before crossing surface - if (surf.surf_source_ && surf.bc_) { - add_surf_source_to_bank(*this, surf); + if (surf->surf_source_ && surf->bc_) { + add_surf_source_to_bank(*this, *surf); } - this->cross_surface(surf); + cross_surface(*surf); // If no BC, add particle to surface source after crossing surface - if (surf.surf_source_ && !surf.bc_) { - add_surf_source_to_bank(*this, surf); + if (surf->surf_source_ && !surf->bc_) { + add_surf_source_to_bank(*this, *surf); } if (settings::weight_window_checkpoint_surface) { apply_weight_windows(*this); } event() = TallyEvent::SURFACE; - - // Score cell to cell partial currents - if (!model::active_surface_tallies.empty()) { - Direction normal = surf.normal(r()); - normal /= normal.norm(); - score_surface_tally(*this, model::active_surface_tallies, normal); - } + } + // Score cell to cell partial currents + if (!model::active_surface_tallies.empty()) { + score_surface_tally(*this, model::active_surface_tallies); } } void Particle::event_collide() { - // Score collision estimate of keff - if (settings::run_mode == RunMode::EIGENVALUE && type().is_neutron()) { + if (settings::run_mode == RunMode::EIGENVALUE && + type() == ParticleType::neutron) { keff_tally_collision() += wgt() * macro_xs().nu_fission / macro_xs().total; } @@ -396,10 +325,10 @@ void Particle::event_collide() // pre-collision direction to figure out what mesh surfaces were crossed if (!model::active_meshsurf_tallies.empty()) - score_meshsurface_tally(*this, model::active_meshsurf_tallies); + score_surface_tally(*this, model::active_meshsurf_tallies); // Clear surface component - surface() = SURFACE_NONE; + surface() = 0; if (settings::run_CE) { collision(*this); @@ -407,11 +336,6 @@ void Particle::event_collide() collision_mg(*this); } - // Collision track feature to recording particle interaction - if (settings::collision_track) { - collision_track_record(*this); - } - // Score collision estimator tallies -- this is done after a collision // has occurred rather than before because we need information on the // outgoing energy for any tallies with an outgoing energy filter @@ -425,19 +349,15 @@ void Particle::event_collide() } } - if (!model::active_pulse_height_tallies.empty() && type().is_photon()) { + if (!model::active_pulse_height_tallies.empty() && + type() == ParticleType::photon) { pht_collision_energy(); } // Reset banked weight during collision n_bank() = 0; - bank_second_E() = 0.0; + n_bank_second() = 0; wgt_bank() = 0.0; - - // Clear number of secondaries in this collision. This is - // distinct from the number of created neutrons n_bank() above! - n_secondaries() = 0; - zero_delayed_bank(); // Reset fission logical @@ -453,14 +373,14 @@ void Particle::event_collide() // Set all directions to base level -- right now, after a collision, only // the base level directions are changed for (int j = 0; j < n_coord() - 1; ++j) { - if (coord(j + 1).rotated()) { + if (coord(j + 1).rotated) { // If next level is rotated, apply rotation matrix - const auto& m {model::cells[coord(j).cell()]->rotation_}; - const auto& u {coord(j).u()}; - coord(j + 1).u() = u.rotate(m); + const auto& m {model::cells[coord(j).cell]->rotation_}; + const auto& u {coord(j).u}; + coord(j + 1).u = u.rotate(m); } else { // Otherwise, copy this level's direction - coord(j + 1).u() = coord(j).u(); + coord(j + 1).u = coord(j).u; } } @@ -468,116 +388,88 @@ void Particle::event_collide() if (!model::active_tallies.empty()) score_collision_derivative(*this); -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC history().reset(); #endif } -void Particle::event_revive_from_secondary(const SourceSite& site) -{ - // Write final position for the previous track (skip if this is a freshly - // constructed particle with no prior track, e.g., Phase 2 of shared - // secondary transport) - if (write_track() && n_event() > 0) { - write_particle_track(*this); - } - - from_source(&site); - - n_event() = 0; - if (!settings::use_shared_secondary_bank) { - n_tracks()++; - } - bank_second_E() = 0.0; - - // Subtract secondary particle energy from interim pulse-height results. - // In shared secondary mode, this subtraction was already done on the parent - // particle during create_secondary(), so skip it here. - if (!settings::use_shared_secondary_bank && - !model::active_pulse_height_tallies.empty() && this->type().is_photon()) { - // Since the birth cell of the particle has not been set we - // have to determine it before the energy of the secondary particle can be - // removed from the pulse-height of this cell. - if (lowest_coord().cell() == C_NONE) { - bool verbose = settings::verbosity >= 10 || trace(); - if (!exhaustive_find_cell(*this, verbose)) { - mark_as_lost("Could not find the cell containing particle " + - std::to_string(id())); - return; - } - // Set birth cell attribute - if (cell_born() == C_NONE) - cell_born() = lowest_coord().cell(); - - // Initialize last cells from current cell - for (int j = 0; j < n_coord(); ++j) { - cell_last(j) = coord(j).cell(); - } - n_coord_last() = n_coord(); - } - pht_secondary_particles(); - } - - // Enter new particle in particle track file - if (write_track()) - add_particle_track(*this); -} - -void Particle::event_check_limit_and_revive() +void Particle::event_revive_from_secondary() { // If particle has too many events, display warning and kill it - n_event()++; + ++n_event(); if (n_event() == settings::max_particle_events) { warning("Particle " + std::to_string(id()) + " underwent maximum number of events."); wgt() = 0.0; } - // In non-shared-secondary mode, revive from local secondary bank - if (!alive() && !settings::use_shared_secondary_bank && - !local_secondary_bank().empty()) { - SourceSite& site = local_secondary_bank().back(); - event_revive_from_secondary(site); - local_secondary_bank().pop_back(); + // Check for secondary particles if this particle is dead + if (!alive()) { + // Write final position for this particle + if (write_track()) { + write_particle_track(*this); + } + + // If no secondary particles, break out of event loop + if (secondary_bank().empty()) + return; + + from_source(&secondary_bank().back()); + secondary_bank().pop_back(); + n_event() = 0; + + // Subtract secondary particle energy from interim pulse-height results + if (!model::active_pulse_height_tallies.empty() && + this->type() == ParticleType::photon) { + // Since the birth cell of the particle has not been set we + // have to determine it before the energy of the secondary particle can be + // removed from the pulse-height of this cell. + if (lowest_coord().cell == C_NONE) { + bool verbose = settings::verbosity >= 10 || trace(); + if (!exhaustive_find_cell(*this, verbose)) { + mark_as_lost("Could not find the cell containing particle " + + std::to_string(id())); + return; + } + // Set birth cell attribute + if (cell_born() == C_NONE) + cell_born() = lowest_coord().cell; + + // Initialize last cells from current cell + for (int j = 0; j < n_coord(); ++j) { + cell_last(j) = coord(j).cell; + } + n_coord_last() = n_coord(); + } + pht_secondary_particles(); + } + + // Enter new particle in particle track file + if (write_track()) + add_particle_track(*this); } } void Particle::event_death() { -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC history().reset(); #endif // Finish particle track output. if (write_track()) { - write_particle_track(*this); finalize_particle_track(*this); } - // Contribute tally reduction variables to global accumulator - const auto k_absorption = keff_tally_absorption(); - const auto k_collision = keff_tally_collision(); - const auto k_tracklength = keff_tally_tracklength(); - const auto leakage = keff_tally_leakage(); - - if (settings::run_mode == RunMode::EIGENVALUE) { - if (k_absorption != 0.0) { +// Contribute tally reduction variables to global accumulator #pragma omp atomic - global_tally_absorption += k_absorption; - } - if (k_collision != 0.0) { + global_tally_absorption += keff_tally_absorption(); #pragma omp atomic - global_tally_collision += k_collision; - } - if (k_tracklength != 0.0) { + global_tally_collision += keff_tally_collision(); #pragma omp atomic - global_tally_tracklength += k_tracklength; - } - } - if (leakage != 0.0) { + global_tally_tracklength += keff_tally_tracklength(); #pragma omp atomic - global_tally_leakage += leakage; - } + global_tally_leakage += keff_tally_leakage(); // Reset particle tallies once accumulated keff_tally_absorption() = 0.0; @@ -589,17 +481,11 @@ void Particle::event_death() score_pulse_height_tally(*this, model::active_pulse_height_tallies); } - // Accumulate track count for this particle history - if (!settings::use_shared_secondary_bank) { -#pragma omp atomic - simulation::simulation_tracks_completed += n_tracks(); - } - // Record the number of progeny created by this particle. // This data will be used to efficiently sort the fission bank. - if (settings::run_mode == RunMode::EIGENVALUE || - settings::use_shared_secondary_bank) { - simulation::progeny_per_particle[current_work()] = n_progeny(); + if (settings::run_mode == RunMode::EIGENVALUE) { + int64_t offset = id() - 1 - simulation::work_index[mpi::rank]; + simulation::progeny_per_particle[offset] = n_progeny(); } } @@ -609,7 +495,7 @@ void Particle::pht_collision_energy() // determine index of cell in pulse_height_cells auto it = std::find(model::pulse_height_cells.begin(), - model::pulse_height_cells.end(), lowest_coord().cell()); + model::pulse_height_cells.end(), lowest_coord().cell); if (it != model::pulse_height_cells.end()) { int index = std::distance(model::pulse_height_cells.begin(), it); @@ -617,7 +503,7 @@ void Particle::pht_collision_energy() // If the energy of the particle is below the cutoff, it will not be sampled // so its energy is added to the pulse-height in the cell - int photon = ParticleType::photon().transport_index(); + int photon = static_cast(ParticleType::photon); if (E() < settings::energy_cutoff[photon]) { pht_storage()[index] += E(); } @@ -646,14 +532,13 @@ void Particle::cross_surface(const Surface& surf) } // if we're crossing a CSG surface, make sure the DAG history is reset -#ifdef OPENMC_DAGMC_ENABLED - if (surf.geom_type() == GeometryType::CSG) +#ifdef DAGMC + if (surf.geom_type_ == GeometryType::CSG) history().reset(); #endif // Handle any applicable boundary conditions. - if (surf.bc_ && settings::run_mode != RunMode::PLOTTING && - settings::run_mode != RunMode::VOLUME) { + if (surf.bc_ && settings::run_mode != RunMode::PLOTTING) { surf.bc_->handle_particle(*this, surf); return; } @@ -661,18 +546,17 @@ void Particle::cross_surface(const Surface& surf) // ========================================================================== // SEARCH NEIGHBOR LISTS FOR NEXT CELL -#ifdef OPENMC_DAGMC_ENABLED +#ifdef DAGMC // in DAGMC, we know what the next cell should be - if (surf.geom_type() == GeometryType::DAG) { - int32_t i_cell = next_cell(surface_index(), cell_last(n_coord() - 1), - lowest_coord().universe()) - + if (surf.geom_type_ == GeometryType::DAG) { + int32_t i_cell = next_cell(std::abs(surface()), cell_last(n_coord() - 1), + lowest_coord().universe) - 1; - // save material, temperature, and density multiplier + // save material and temp material_last() = material(); sqrtkT_last() = sqrtkT(); - density_mult_last() = density_mult(); // set new cell value - lowest_coord().cell() = i_cell; + lowest_coord().cell = i_cell; auto& cell = model::cells[i_cell]; cell_instance() = 0; @@ -681,7 +565,6 @@ void Particle::cross_surface(const Surface& surf) material() = cell->material(cell_instance()); sqrtkT() = cell->sqrtkT(cell_instance()); - density_mult() = cell->density_mult(cell_instance()); return; } #endif @@ -704,7 +587,7 @@ void Particle::cross_surface(const Surface& surf) // the particle is really traveling tangent to a surface, if we move it // forward a tiny bit it should fix the problem. - surface() = SURFACE_NONE; + surface() = 0; n_coord() = 1; r() += TINY_BIT * u(); @@ -731,7 +614,7 @@ void Particle::cross_vacuum_bc(const Surface& surf) // physically moving the particle forward slightly r() += TINY_BIT * u(); - score_meshsurface_tally(*this, model::active_meshsurf_tallies); + score_surface_tally(*this, model::active_meshsurf_tallies); } // Score to global leakage tally @@ -763,15 +646,13 @@ void Particle::cross_reflective_bc(const Surface& surf, Direction new_u) // with a mesh boundary if (!model::active_surface_tallies.empty()) { - Direction normal = surf.normal(r()); - normal /= normal.norm(); - score_surface_tally(*this, model::active_surface_tallies, normal); + score_surface_tally(*this, model::active_surface_tallies); } if (!model::active_meshsurf_tallies.empty()) { Position r {this->r()}; this->r() -= TINY_BIT * u(); - score_meshsurface_tally(*this, model::active_meshsurf_tallies); + score_surface_tally(*this, model::active_meshsurf_tallies); this->r() = r; } @@ -779,7 +660,7 @@ void Particle::cross_reflective_bc(const Surface& surf, Direction new_u) u() = new_u; // Reassign particle's cell and surface - coord(0).cell() = cell_last(0); + coord(0).cell = cell_last(0); surface() = -surface(); // If a reflective surface is coincident with a lattice or universe @@ -787,8 +668,7 @@ void Particle::cross_reflective_bc(const Surface& surf, Direction new_u) // the lower universes. // (unless we're using a dagmc model, which has exactly one universe) n_coord() = 1; - if (surf.geom_type() != GeometryType::DAG && - !neighbor_list_find_cell(*this)) { + if (surf.geom_type_ != GeometryType::DAG && !neighbor_list_find_cell(*this)) { mark_as_lost("Couldn't find particle after reflecting from surface " + std::to_string(surf.id_) + "."); return; @@ -821,7 +701,7 @@ void Particle::cross_periodic_bc( if (!model::active_meshsurf_tallies.empty()) { Position r {this->r()}; this->r() -= TINY_BIT * u(); - score_meshsurface_tally(*this, model::active_meshsurf_tallies); + score_surface_tally(*this, model::active_meshsurf_tallies); this->r() = r; } @@ -838,7 +718,9 @@ void Particle::cross_periodic_bc( if (!neighbor_list_find_cell(*this)) { mark_as_lost("Couldn't find particle after hitting periodic " "boundary on surface " + - std::to_string(surf.id_) + "."); + std::to_string(surf.id_) + + ". The normal vector " + "of one periodic surface may need to be reversed."); return; } @@ -918,29 +800,30 @@ void Particle::write_restart() const break; } write_dataset(file_id, "id", id()); - write_dataset(file_id, "type", type().pdg_number()); + write_dataset(file_id, "type", static_cast(type())); - // Get source site data for the particle that got lost int64_t i = current_work(); - SourceSite site; if (settings::run_mode == RunMode::EIGENVALUE) { - site = simulation::source_bank[i]; - } else if (settings::run_mode == RunMode::FIXED_SOURCE && - settings::use_shared_secondary_bank && - i < simulation::shared_secondary_bank_read.size()) { - site = simulation::shared_secondary_bank_read[i]; + // take source data from primary bank for eigenvalue simulation + write_dataset(file_id, "weight", simulation::source_bank[i - 1].wgt); + write_dataset(file_id, "energy", simulation::source_bank[i - 1].E); + write_dataset(file_id, "xyz", simulation::source_bank[i - 1].r); + write_dataset(file_id, "uvw", simulation::source_bank[i - 1].u); + write_dataset(file_id, "time", simulation::source_bank[i - 1].time); } else if (settings::run_mode == RunMode::FIXED_SOURCE) { - // Re-sample using the same seed used to generate the source particle. - // current_work() is 0-indexed, compute_particle_id expects 1-indexed. - int64_t id = compute_transport_seed(compute_particle_id(i + 1)); + // re-sample using rng random number seed used to generate source particle + int64_t id = (simulation::total_gen + overall_generation() - 1) * + settings::n_particles + + simulation::work_index[mpi::rank] + i; uint64_t seed = init_seed(id, STREAM_SOURCE); - site = sample_external_source(&seed); + // re-sample source site + auto site = sample_external_source(&seed); + write_dataset(file_id, "weight", site.wgt); + write_dataset(file_id, "energy", site.E); + write_dataset(file_id, "xyz", site.r); + write_dataset(file_id, "uvw", site.u); + write_dataset(file_id, "time", site.time); } - write_dataset(file_id, "weight", site.wgt); - write_dataset(file_id, "energy", site.E); - write_dataset(file_id, "xyz", site.r); - write_dataset(file_id, "uvw", site.u); - write_dataset(file_id, "time", site.time); // Close file file_close(file_id); @@ -955,12 +838,10 @@ void Particle::update_neutron_xs( // If the cache doesn't match, recalculate micro xs if (this->E() != micro.last_E || this->sqrtkT() != micro.last_sqrtkT || - i_sab != micro.index_sab || sab_frac != micro.sab_frac || - ncrystal_xs != micro.ncrystal_xs) { + i_sab != micro.index_sab || sab_frac != micro.sab_frac) { data::nuclides[i_nuclide]->calculate_xs(i_sab, i_grid, sab_frac, *this); // If NCrystal is being used, update micro cross section cache - micro.ncrystal_xs = ncrystal_xs; if (ncrystal_xs >= 0.0) { data::nuclides[i_nuclide]->calculate_elastic_xs(*this); ncrystal_update_micro(ncrystal_xs, micro); @@ -971,6 +852,37 @@ void Particle::update_neutron_xs( //============================================================================== // Non-method functions //============================================================================== + +std::string particle_type_to_str(ParticleType type) +{ + switch (type) { + case ParticleType::neutron: + return "neutron"; + case ParticleType::photon: + return "photon"; + case ParticleType::electron: + return "electron"; + case ParticleType::positron: + return "positron"; + } + UNREACHABLE(); +} + +ParticleType str_to_particle_type(std::string str) +{ + if (str == "neutron") { + return ParticleType::neutron; + } else if (str == "photon") { + return ParticleType::photon; + } else if (str == "electron") { + return ParticleType::electron; + } else if (str == "positron") { + return ParticleType::positron; + } else { + throw std::invalid_argument {fmt::format("Invalid particle name: {}", str)}; + } +} + void add_surf_source_to_bank(Particle& p, const Surface& surf) { if (simulation::current_batch <= settings::n_inactive || @@ -1008,7 +920,7 @@ void add_surf_source_to_bank(Particle& p, const Surface& surf) // Check if the cell of interest has been entered bool entered = false; for (int i = 0; i < p.n_coord(); ++i) { - if (p.coord(i).cell() == cell_idx) { + if (p.coord(i).cell == cell_idx) { entered = true; } } diff --git a/src/particle_data.cpp b/src/particle_data.cpp index 370ca12e4..d8a5bb9d9 100644 --- a/src/particle_data.cpp +++ b/src/particle_data.cpp @@ -15,11 +15,6 @@ namespace openmc { -void GeometryState::mark_as_lost(const char* message) -{ - fatal_error(message); -} - void GeometryState::mark_as_lost(const std::string& message) { mark_as_lost(message.c_str()); @@ -30,22 +25,27 @@ void GeometryState::mark_as_lost(const std::stringstream& message) mark_as_lost(message.str()); } +void GeometryState::mark_as_lost(const char* message) +{ + fatal_error(message); +} + void LocalCoord::rotate(const vector& rotation) { - r_ = r_.rotate(rotation); - u_ = u_.rotate(rotation); - rotated_ = true; + r = r.rotate(rotation); + u = u.rotate(rotation); + rotated = true; } void LocalCoord::reset() { - cell_ = C_NONE; - universe_ = C_NONE; - lattice_ = C_NONE; - lattice_index_[0] = 0; - lattice_index_[1] = 0; - lattice_index_[2] = 0; - rotated_ = false; + cell = C_NONE; + universe = C_NONE; + lattice = C_NONE; + lattice_i[0] = 0; + lattice_i[1] = 0; + lattice_i[2] = 0; + rotated = false; } GeometryState::GeometryState() @@ -56,40 +56,6 @@ GeometryState::GeometryState() clear(); } -void GeometryState::advance_to_boundary_from_void() -{ - auto root_coord = this->coord(0); - const auto& root_universe = model::universes[model::root_universe]; - boundary().reset(); - - for (auto c_i : root_universe->cells_) { - auto dist = - model::cells.at(c_i)->distance(root_coord.r(), root_coord.u(), 0, this); - if (dist.first < boundary().distance()) { - boundary().distance() = dist.first; - boundary().surface() = dist.second; - } - } - - // if no intersection or near-infinite intersection, reset - // boundary information - if (boundary().distance() > 1e300) { - boundary().distance() = INFTY; - boundary().surface() = SURFACE_NONE; - return; - } - - // move the particle up to (and just past) the boundary - move_distance(boundary().distance() + TINY_BIT); -} - -void GeometryState::move_distance(double length) -{ - for (int j = 0; j < n_coord(); ++j) { - coord(j).r() += length * coord(j).u(); - } -} - ParticleData::ParticleData() { zero_delayed_bank(); @@ -123,7 +89,7 @@ TrackState ParticleData::get_track_state() const state.E = this->E(); state.time = this->time(); state.wgt = this->wgt(); - state.cell_id = model::cells[this->lowest_coord().cell()]->id_; + state.cell_id = model::cells[this->lowest_coord().cell]->id_; state.cell_instance = this->cell_instance(); if (this->material() != MATERIAL_VOID) { state.material_id = model::materials[material()]->id_; diff --git a/src/particle_restart.cpp b/src/particle_restart.cpp index c226d51ec..6b7778211 100644 --- a/src/particle_restart.cpp +++ b/src/particle_restart.cpp @@ -1,7 +1,6 @@ #include "openmc/particle_restart.h" #include "openmc/array.h" -#include "openmc/bank.h" #include "openmc/constants.h" #include "openmc/hdf5_interface.h" #include "openmc/mgxs_interface.h" @@ -32,16 +31,6 @@ void read_particle_restart(Particle& p, RunMode& previous_run_mode) hid_t file_id = file_open(settings::path_particle_restart, 'r'); // Read data from file - bool legacy_particle_codes = true; - if (attribute_exists(file_id, "version")) { - array version; - read_attribute(file_id, "version", version); - if (version[0] > VERSION_PARTICLE_RESTART[0] || - (version[0] == VERSION_PARTICLE_RESTART[0] && version[1] >= 1)) { - legacy_particle_codes = false; - } - } - read_dataset(file_id, "current_batch", simulation::current_batch); read_dataset(file_id, "generations_per_batch", settings::gen_per_batch); read_dataset(file_id, "current_generation", simulation::current_gen); @@ -56,8 +45,7 @@ void read_particle_restart(Particle& p, RunMode& previous_run_mode) read_dataset(file_id, "id", p.id()); int type; read_dataset(file_id, "type", type); - p.type() = legacy_particle_codes ? legacy_particle_index_to_type(type) - : ParticleType {type}; + p.type() = static_cast(type); read_dataset(file_id, "weight", p.wgt()); read_dataset(file_id, "energy", p.E()); read_dataset(file_id, "xyz", p.r()); @@ -107,16 +95,20 @@ void run_particle_restart() // Set all tallies to 0 for now (just tracking errors) model::tallies.clear(); - // Allocate progeny_per_particle if needed for shared secondary mode - // (event_death() writes to this array). Set current_work to 0 since we - // only have one particle being restarted. - if (settings::use_shared_secondary_bank) { - p.current_work() = 0; - simulation::progeny_per_particle.resize(1, 0); - } - // Compute random number seed - int64_t particle_seed = compute_transport_seed(p.id()); + int64_t particle_seed; + switch (previous_run_mode) { + case RunMode::EIGENVALUE: + case RunMode::FIXED_SOURCE: + particle_seed = (simulation::total_gen + overall_generation() - 1) * + settings::n_particles + + p.id(); + break; + default: + throw std::runtime_error { + "Unexpected run mode: " + + std::to_string(static_cast(previous_run_mode))}; + } init_particle_seeds(particle_seed, p.seeds()); // Force calculation of cross-sections by setting last energy to zero diff --git a/src/particle_type.cpp b/src/particle_type.cpp deleted file mode 100644 index fe8f9fe2a..000000000 --- a/src/particle_type.cpp +++ /dev/null @@ -1,246 +0,0 @@ -#include "openmc/particle_type.h" - -#include -#include -#include - -#include "openmc/string_utils.h" - -namespace openmc { -namespace { - -constexpr const char* ATOMIC_SYMBOL[] = {"", "H", "He", "Li", "Be", "B", "C", - "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", - "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", - "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", - "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", - "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", - "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", - "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", - "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", - "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; - -constexpr int MAX_Z = - static_cast(sizeof(ATOMIC_SYMBOL) / sizeof(ATOMIC_SYMBOL[0])) - 1; - -bool is_integer_string(const std::string& s) -{ - if (s.empty()) - return false; - size_t i = 0; - if (s[0] == '-' || s[0] == '+') { - if (s.size() == 1) - return false; - i = 1; - } - for (; i < s.size(); ++i) { - if (!std::isdigit(static_cast(s[i]))) - return false; - } - return true; -} - -int atomic_number_from_symbol(std::string_view symbol) -{ - for (int z = 1; z <= MAX_Z; ++z) { - if (symbol == ATOMIC_SYMBOL[z]) { - return z; - } - } - return 0; -} - -bool parse_gnds_nuclide(std::string_view name, int& Z, int& A, int& m) -{ - if (name.empty()) - return false; - - size_t pos = 0; - if (!std::isupper(static_cast(name[pos]))) - return false; - - std::string symbol; - symbol += name[pos++]; - if (pos < name.size() && - std::islower(static_cast(name[pos]))) { - symbol += name[pos++]; - } - - if (pos >= name.size() || - !std::isdigit(static_cast(name[pos]))) { - return false; - } - - size_t a_start = pos; - while ( - pos < name.size() && std::isdigit(static_cast(name[pos]))) { - ++pos; - } - A = std::stoi(std::string {name.substr(a_start, pos - a_start)}); - if (A <= 0 || A > 999) - return false; - - m = 0; - if (pos < name.size()) { - if (name[pos] != '_' || pos + 2 >= name.size() || name[pos + 1] != 'm') { - return false; - } - pos += 2; - size_t m_start = pos; - while (pos < name.size() && - std::isdigit(static_cast(name[pos]))) { - ++pos; - } - if (m_start == pos) - return false; - m = std::stoi(std::string {name.substr(m_start, pos - m_start)}); - if (m < 0 || m > 9) - return false; - } - - if (pos != name.size()) - return false; - - Z = atomic_number_from_symbol(symbol); - return Z != 0; -} - -// Helper to convert nuclear PDG number to nuclide name -std::string nuclide_name_from_pdg(int32_t pdg) -{ - int32_t code = pdg; - int m = code % 10; - int A = (code / 10) % 1000; - int Z = (code / 10000) % 1000; - - if (Z <= 0 || Z > MAX_Z || A <= 0 || A > 999) { - throw std::invalid_argument { - "Invalid nuclear PDG number: " + std::to_string(pdg)}; - } - - std::string name = ATOMIC_SYMBOL[Z] + std::to_string(A); - if (m > 0) { - name += "_m" + std::to_string(m); - } - return name; -} - -} // namespace - -//============================================================================== -// ParticleType member function implementations -//============================================================================== - -ParticleType::ParticleType(std::string_view str) -{ - std::string s {str}; - strtrim(s); - if (s.empty()) { - throw std::invalid_argument {"Particle string is empty."}; - } - - std::string lower = s; - to_lower(lower); - - // Check for pdg: prefix - if (starts_with(lower, "pdg:")) { - std::string value_str = lower.substr(4); - if (!is_integer_string(value_str)) { - throw std::invalid_argument {"Invalid PDG number: " + value_str}; - } - pdg_number_ = std::stoi(value_str); - return; - } - - // Check for known particle names - if (lower == "neutron" || lower == "n") { - pdg_number_ = PDG_NEUTRON; - return; - } - if (lower == "photon" || lower == "gamma") { - pdg_number_ = PDG_PHOTON; - return; - } - if (lower == "electron") { - pdg_number_ = PDG_ELECTRON; - return; - } - if (lower == "positron") { - pdg_number_ = PDG_POSITRON; - return; - } - if (lower == "proton" || lower == "p" || lower == "h1") { - pdg_number_ = PDG_PROTON; - return; - } - if (lower == "deuteron" || lower == "d" || lower == "h2") { - pdg_number_ = PDG_DEUTERON; - return; - } - if (lower == "triton" || lower == "t" || lower == "h3") { - pdg_number_ = PDG_TRITON; - return; - } - if (lower == "alpha" || lower == "he4") { - pdg_number_ = PDG_ALPHA; - return; - } - - // Check for integer string - if (is_integer_string(s)) { - pdg_number_ = std::stoi(s); - return; - } - - // Try to parse as GNDS nuclide name - int Z = 0; - int A = 0; - int m = 0; - if (!parse_gnds_nuclide(s, Z, A, m)) { - throw std::invalid_argument {"Invalid nuclide name: " + s}; - } - pdg_number_ = 1000000000 + Z * 10000 + A * 10 + m; -} - -std::string ParticleType::str() const -{ - if (pdg_number_ == PDG_NEUTRON) - return "neutron"; - if (pdg_number_ == PDG_PHOTON) - return "photon"; - if (pdg_number_ == PDG_ELECTRON) - return "electron"; - if (pdg_number_ == PDG_POSITRON) - return "positron"; - if (pdg_number_ == PDG_PROTON) - return "proton"; - - if (is_nucleus()) { - return nuclide_name_from_pdg(pdg_number_); - } - - return "pdg:" + std::to_string(pdg_number_); -} - -//============================================================================== -// Free function implementations -//============================================================================== - -ParticleType legacy_particle_index_to_type(int index) -{ - switch (index) { - case 0: - return ParticleType {PDG_NEUTRON}; - case 1: - return ParticleType {PDG_PHOTON}; - case 2: - return ParticleType {PDG_ELECTRON}; - case 3: - return ParticleType {PDG_POSITRON}; - default: - throw std::invalid_argument { - "Invalid legacy particle index: " + std::to_string(index)}; - } -} - -} // namespace openmc diff --git a/src/photon.cpp b/src/photon.cpp index 6bbdc928f..08062a2e9 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -13,7 +13,11 @@ #include "openmc/search.h" #include "openmc/settings.h" -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xmath.hpp" +#include "xtensor/xoperation.hpp" +#include "xtensor/xslice.hpp" +#include "xtensor/xview.hpp" #include #include @@ -29,7 +33,7 @@ constexpr int PhotonInteraction::MAX_STACK_SIZE; namespace data { -tensor::Tensor compton_profile_pz; +xt::xtensor compton_profile_pz; std::unordered_map element_map; vector> elements; @@ -42,6 +46,8 @@ vector> elements; PhotonInteraction::PhotonInteraction(hid_t group) { + using namespace xt::placeholders; + // Set index of element in global vector index_ = data::elements.size(); @@ -90,7 +96,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) read_dataset(rgroup, "xs", pair_production_electron_); close_group(rgroup); } else { - pair_production_electron_ = tensor::zeros_like(energy_); + pair_production_electron_ = xt::zeros_like(energy_); } // Read pair production @@ -99,7 +105,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) read_dataset(rgroup, "xs", pair_production_nuclear_); close_group(rgroup); } else { - pair_production_nuclear_ = tensor::zeros_like(energy_); + pair_production_nuclear_ = xt::zeros_like(energy_); } // Read photoelectric @@ -113,7 +119,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) read_dataset(rgroup, "xs", heating_); close_group(rgroup); } else { - heating_ = tensor::zeros_like(energy_); + heating_ = xt::zeros_like(energy_); } // Read subshell photoionization cross section and atomic relaxation data @@ -127,7 +133,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) } shells_.resize(n_shell); - cross_sections_ = tensor::zeros({energy_.size(), n_shell}); + cross_sections_ = xt::zeros({energy_.size(), n_shell}); // Create mapping from designator to index std::unordered_map shell_map; @@ -154,26 +160,26 @@ PhotonInteraction::PhotonInteraction(hid_t group) hid_t tgroup = open_group(rgroup, designator.c_str()); - // Read binding energy if atomic relaxation data is present + // Read binding energy energy and number of electrons if atomic relaxation + // data is present if (attribute_exists(tgroup, "binding_energy")) { has_atomic_relaxation_ = true; read_attribute(tgroup, "binding_energy", shell.binding_energy); + read_attribute(tgroup, "num_electrons", shell.n_electrons); } // Read subshell cross section - tensor::Tensor xs; + xt::xtensor xs; dset = open_dataset(tgroup, "xs"); read_attribute(dset, "threshold_idx", shell.threshold); close_dataset(dset); read_dataset(tgroup, "xs", xs); auto cross_section = - cross_sections_.slice(tensor::range(static_cast(shell.threshold), - cross_sections_.shape(0)), - i); - cross_section = tensor::where(xs > 0, tensor::log(xs), 0); + xt::view(cross_sections_, xt::range(shell.threshold, _), i); + cross_section = xt::where(xs > 0, xt::log(xs), 0); - if (settings::atomic_relaxation && object_exists(tgroup, "transitions")) { + if (object_exists(tgroup, "transitions")) { // Determine dimensions of transitions dset = open_dataset(tgroup, "transitions"); auto dims = object_shape(dset); @@ -181,12 +187,11 @@ PhotonInteraction::PhotonInteraction(hid_t group) int n_transition = dims[0]; if (n_transition > 0) { - tensor::Tensor matrix; + xt::xtensor matrix; read_dataset(tgroup, "transitions", matrix); // Transition probability normalization - double norm = - tensor::Tensor(matrix.slice(tensor::all, 3)).sum(); + double norm = xt::sum(xt::col(matrix, 3))(); shell.transitions.resize(n_transition); for (int j = 0; j < n_transition; ++j) { @@ -205,8 +210,9 @@ PhotonInteraction::PhotonInteraction(hid_t group) // Check the maximum size of the atomic relaxation stack auto max_size = this->calc_max_stack_size(); if (max_size > MAX_STACK_SIZE && mpi::master) { - warning(fmt::format("The subshell vacancy stack in atomic relaxation can " - "grow up to {}, but the stack size limit is set to {}.", + warning(fmt::format( + "The subshell vacancy stack in atomic relaxation can grow up to {}, but " + "the stack size limit is set to {}.", max_size, MAX_STACK_SIZE)); } @@ -215,7 +221,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) // Read electron shell PDF and binding energies read_dataset(rgroup, "num_electrons", electron_pdf_); - electron_pdf_ /= electron_pdf_.sum(); + electron_pdf_ /= xt::sum(electron_pdf_); read_dataset(rgroup, "binding_energy", binding_energy_); // Read Compton profiles @@ -227,32 +233,10 @@ PhotonInteraction::PhotonInteraction(hid_t group) } close_group(rgroup); - // Map Compton subshell data to atomic relaxation data by finding the - // subshell with the equivalent binding energy - if (settings::atomic_relaxation && has_atomic_relaxation_) { - auto is_close = [](double a, double b) { - return std::abs(a - b) / a < FP_REL_PRECISION; - }; - subshell_map_ = tensor::Tensor(binding_energy_.shape(), -1); - for (int i = 0; i < binding_energy_.size(); ++i) { - double E_b = binding_energy_[i]; - if (i < n_shell && is_close(E_b, shells_[i].binding_energy)) { - subshell_map_[i] = i; - } else { - for (int j = 0; j < n_shell; ++j) { - if (is_close(E_b, shells_[j].binding_energy)) { - subshell_map_[i] = j; - break; - } - } - } - } - } - // Create Compton profile CDF auto n_profile = data::compton_profile_pz.size(); auto n_shell_compton = profile_pdf_.shape(0); - profile_cdf_ = tensor::Tensor({n_shell_compton, n_profile}); + profile_cdf_ = xt::empty({n_shell_compton, n_profile}); for (int i = 0; i < n_shell_compton; ++i) { double c = 0.0; profile_cdf_(i, 0) = 0.0; @@ -271,11 +255,11 @@ PhotonInteraction::PhotonInteraction(hid_t group) // Read bremsstrahlung scaled DCS rgroup = open_group(group, "bremsstrahlung"); read_dataset(rgroup, "dcs", dcs_); - auto n_e = dcs_.shape(0); - auto n_k = dcs_.shape(1); + auto n_e = dcs_.shape()[0]; + auto n_k = dcs_.shape()[1]; // Get energy grids used for bremsstrahlung DCS and for stopping powers - tensor::Tensor electron_energy; + xt::xtensor electron_energy; read_dataset(rgroup, "electron_energy", electron_energy); if (data::ttb_k_grid.size() == 0) { read_dataset(rgroup, "photon_energy", data::ttb_k_grid); @@ -288,7 +272,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) close_group(rgroup); // Truncate the bremsstrahlung data at the cutoff energy - int photon = ParticleType::photon().transport_index(); + int photon = static_cast(ParticleType::photon); const auto& E {electron_energy}; double cutoff = settings::energy_cutoff[photon]; if (cutoff > E(0)) { @@ -300,12 +284,12 @@ PhotonInteraction::PhotonInteraction(hid_t group) (std::log(E(i_grid + 1)) - std::log(E(i_grid))); // Interpolate bremsstrahlung DCS at the cutoff energy and truncate - tensor::Tensor dcs({n_e - i_grid, n_k}); + xt::xtensor dcs({n_e - i_grid, n_k}); for (int i = 0; i < n_k; ++i) { double y = std::exp( std::log(dcs_(i_grid, i)) + f * (std::log(dcs_(i_grid + 1, i)) - std::log(dcs_(i_grid, i)))); - tensor::View col_i = dcs.slice(tensor::all, i); + auto col_i = xt::view(dcs, xt::all(), i); col_i(0) = y; for (int j = i_grid + 1; j < n_e; ++j) { col_i(j - i_grid) = dcs_(j, i); @@ -313,11 +297,9 @@ PhotonInteraction::PhotonInteraction(hid_t group) } dcs_ = dcs; - tensor::Tensor frst({static_cast(1)}); - frst(0) = cutoff; - tensor::Tensor rest(electron_energy.slice( - tensor::range(i_grid + 1, electron_energy.size()))); - electron_energy = tensor::concatenate(frst, rest); + xt::xtensor frst {cutoff}; + electron_energy = xt::concatenate(xt::xtuple( + frst, xt::view(electron_energy, xt::range(i_grid + 1, n_e)))); } // Set incident particle energy grid @@ -326,8 +308,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) } // Calculate the radiative stopping power - stopping_power_radiative_ = - tensor::Tensor({data::ttb_e_grid.size()}); + stopping_power_radiative_ = xt::empty({data::ttb_e_grid.size()}); for (int i = 0; i < data::ttb_e_grid.size(); ++i) { // Integrate over reduced photon energy double c = 0.0; @@ -347,20 +328,15 @@ PhotonInteraction::PhotonInteraction(hid_t group) } // Take logarithm of energies and cross sections since they are log-log - // interpolated. Note that cross section libraries converted from ACE files - // represent zero as exp(-500) to avoid log-log interpolation errors. For - // values below exp(-499) we store the log as -900, for which exp(-900) - // evaluates to zero. - double limit = std::exp(-499.0); - energy_ = tensor::log(energy_); - coherent_ = tensor::where(coherent_ > limit, tensor::log(coherent_), -900.0); - incoherent_ = - tensor::where(incoherent_ > limit, tensor::log(incoherent_), -900.0); - photoelectric_total_ = tensor::where( - photoelectric_total_ > limit, tensor::log(photoelectric_total_), -900.0); - pair_production_total_ = tensor::where(pair_production_total_ > limit, - tensor::log(pair_production_total_), -900.0); - heating_ = tensor::where(heating_ > limit, tensor::log(heating_), -900.0); + // interpolated + energy_ = xt::log(energy_); + coherent_ = xt::where(coherent_ > 0.0, xt::log(coherent_), -500.0); + incoherent_ = xt::where(incoherent_ > 0.0, xt::log(incoherent_), -500.0); + photoelectric_total_ = xt::where( + photoelectric_total_ > 0.0, xt::log(photoelectric_total_), -500.0); + pair_production_total_ = xt::where( + pair_production_total_ > 0.0, xt::log(pair_production_total_), -500.0); + heating_ = xt::where(heating_ > 0.0, xt::log(heating_), -500.0); } PhotonInteraction::~PhotonInteraction() @@ -443,6 +419,13 @@ void PhotonInteraction::compton_scatter(double alpha, bool doppler, double E_out; this->compton_doppler(alpha, *mu, &E_out, i_shell, seed); *alpha_out = E_out / MASS_ELECTRON_EV; + + // It's possible for the Compton profile data to have more shells than + // there are in the ENDF data. Make sure the shell index doesn't end up + // out of bounds. + if (*i_shell >= shells_.size()) { + *i_shell = -1; + } } else { *i_shell = -1; } @@ -511,7 +494,7 @@ void PhotonInteraction::compton_doppler( c = prn(seed) * c_max; // Determine pz corresponding to sampled cdf value - tensor::View cdf_shell = profile_cdf_.slice(shell); + auto cdf_shell = xt::view(profile_cdf_, shell, xt::all()); int i = lower_bound_index(cdf_shell.cbegin(), cdf_shell.cend(), c); double pz_l = data::compton_profile_pz(i); double pz_r = data::compton_profile_pz(i + 1); @@ -607,8 +590,8 @@ void PhotonInteraction::calculate_xs(Particle& p) const // Calculate microscopic photoelectric cross section xs.photoelectric = 0.0; - tensor::View xs_lower = cross_sections_.slice(i_grid); - tensor::View xs_upper = cross_sections_.slice(i_grid + 1); + const auto& xs_lower = xt::row(cross_sections_, i_grid); + const auto& xs_upper = xt::row(cross_sections_, i_grid + 1); for (int i = 0; i < xs_upper.size(); ++i) if (xs_lower(i) != 0) @@ -783,9 +766,8 @@ void PhotonInteraction::pair_production(double alpha, double* E_electron, void PhotonInteraction::atomic_relaxation(int i_shell, Particle& p) const { - // Return if no atomic relaxation data is present or if the binding energy is - // larger than the incident particle energy - if (!has_atomic_relaxation_ || shells_[i_shell].binding_energy > p.E()) + // Return if no atomic relaxation data is present + if (!has_atomic_relaxation_) return; // Stack for unprocessed holes left by transitioning electrons @@ -804,7 +786,7 @@ void PhotonInteraction::atomic_relaxation(int i_shell, Particle& p) const if (shell.transitions.empty()) { Direction u = isotropic_direction(p.current_seed()); double E = shell.binding_energy; - p.create_secondary(p.wgt(), u, E, ParticleType::photon()); + p.create_secondary(p.wgt(), u, E, ParticleType::photon); continue; } @@ -832,13 +814,12 @@ void PhotonInteraction::atomic_relaxation(int i_shell, Particle& p) const holes[n_holes++] = transition.secondary_subshell; // Create auger electron - p.create_secondary( - p.wgt(), u, transition.energy, ParticleType::electron()); + p.create_secondary(p.wgt(), u, transition.energy, ParticleType::electron); } else { // Radiative transition -- get X-ray energy // Create fluorescent photon - p.create_secondary(p.wgt(), u, transition.energy, ParticleType::photon()); + p.create_secondary(p.wgt(), u, transition.energy, ParticleType::photon); } } } diff --git a/src/physics.cpp b/src/physics.cpp index 4a8b4d368..69e74f2ea 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -2,13 +2,11 @@ #include "openmc/bank.h" #include "openmc/bremsstrahlung.h" -#include "openmc/chain.h" #include "openmc/constants.h" #include "openmc/distribution_multi.h" #include "openmc/eigenvalue.h" #include "openmc/endf.h" #include "openmc/error.h" -#include "openmc/ifp.h" #include "openmc/material.h" #include "openmc/math_functions.h" #include "openmc/message_passing.h" @@ -30,9 +28,9 @@ #include -#include "openmc/tensor.h" #include // for max, min, max_element #include // for sqrt, exp, log, abs, copysign +#include namespace openmc { @@ -44,41 +42,29 @@ void collision(Particle& p) { // Add to collision counter for particle ++(p.n_collision()); - p.secondary_bank_index() = p.local_secondary_bank().size(); // Sample reaction for the material the particle is in - switch (p.type().pdg_number()) { - case PDG_NEUTRON: + switch (p.type()) { + case ParticleType::neutron: sample_neutron_reaction(p); break; - case PDG_PHOTON: + case ParticleType::photon: sample_photon_reaction(p); break; - case PDG_ELECTRON: + case ParticleType::electron: sample_electron_reaction(p); break; - case PDG_POSITRON: + case ParticleType::positron: sample_positron_reaction(p); break; - default: - fatal_error("Unsupported particle PDG for collision sampling."); } - if (settings::weight_windows_on) { - auto [ww_found, ww] = search_weight_window(p); - if (!ww_found && p.type() == ParticleType::neutron()) { - // if the weight window is not valid, apply russian roulette for neutrons - // (regardless of weight window collision checkpoint setting) - apply_russian_roulette(p); - } else if (settings::weight_window_checkpoint_collision) { - // if collision checkpointing is on, apply weight window - apply_weight_window(p, ww); - } - } + if (settings::weight_window_checkpoint_collision) + apply_weight_windows(p); // Kill particle if energy falls below cutoff - int type = p.type().transport_index(); - if (type != C_NONE && p.E() < settings::energy_cutoff[type]) { + int type = static_cast(p.type()); + if (p.E() < settings::energy_cutoff[type]) { p.wgt() = 0.0; } @@ -87,11 +73,11 @@ void collision(Particle& p) std::string msg; if (p.event() == TallyEvent::KILL) { msg = fmt::format(" Killed. Energy = {} eV.", p.E()); - } else if (p.type().is_neutron()) { + } else if (p.type() == ParticleType::neutron) { msg = fmt::format(" {} with {}. Energy = {} eV.", reaction_name(p.event_mt()), data::nuclides[p.event_nuclide()]->name_, p.E()); - } else if (p.type().is_photon()) { + } else if (p.type() == ParticleType::photon) { msg = fmt::format(" {} with {}. Energy = {} eV.", reaction_name(p.event_mt()), to_element(data::nuclides[p.event_nuclide()]->name_), p.E()); @@ -127,15 +113,13 @@ void sample_neutron_reaction(Particle& p) // Make sure particle population doesn't grow out of control for // subcritical multiplication problems. - if (p.local_secondary_bank().size() >= settings::max_secondaries && - !settings::use_shared_secondary_bank) { + if (p.secondary_bank().size() >= 10000) { fatal_error( "The secondary particle bank appears to be growing without " "bound. You are likely running a subcritical multiplication problem " "with k-effective close to or greater than one."); } } - p.event_mt() = rx.mt_; } // Create secondary photons @@ -166,9 +150,12 @@ void sample_neutron_reaction(Particle& p) advance_prn_seed(data::nuclides.size(), &p.seeds(STREAM_URR_PTABLE)); } - // Play russian roulette if there are no weight windows - if (!settings::weight_windows_on) - apply_russian_roulette(p); + // Play russian roulette if survival biasing is turned on + if (settings::survival_biasing) { + if (p.wgt() < settings::weight_cutoff) { + russian_roulette(p, settings::weight_survive); + } + } } void create_fission_sites(Particle& p, int i_nuclide, const Reaction& rx) @@ -212,26 +199,16 @@ void create_fission_sites(Particle& p, int i_nuclide, const Reaction& rx) // Initialize fission site object with particle data SourceSite site; site.r = p.r(); - site.particle = ParticleType::neutron(); + site.particle = ParticleType::neutron; site.time = p.time(); site.wgt = 1. / weight; + site.parent_id = p.id(); + site.progeny_id = p.n_progeny()++; site.surf_id = 0; // Sample delayed group and angle/energy for fission reaction sample_fission_neutron(i_nuclide, rx, &site, p); - // Reject site if it exceeds time cutoff - if (site.delayed_group > 0) { - double t_cutoff = settings::time_cutoff[site.particle.transport_index()]; - if (site.time > t_cutoff) { - continue; - } - } - - // Set parent and progeny IDs - site.parent_id = p.current_work(); - site.progeny_id = p.n_progeny()++; - // Store fission site in bank if (use_fission_bank) { int64_t idx = simulation::fission_bank.thread_safe_append(site); @@ -249,28 +226,24 @@ void create_fission_sites(Particle& p, int i_nuclide, const Reaction& rx) // Break out of loop as no more sites can be added to fission bank break; } - // Iterated Fission Probability (IFP) method - if (settings::ifp_on) { - ifp(p, idx); - } } else { - site.wgt_born = p.wgt_born(); - site.wgt_ww_born = p.wgt_ww_born(); - site.n_split = p.n_split(); - p.local_secondary_bank().push_back(site); - p.n_secondaries()++; + p.secondary_bank().push_back(site); } + // Set the delayed group on the particle as well + p.delayed_group() = site.delayed_group; + // Increment the number of neutrons born delayed - if (site.delayed_group > 0) { - nu_d[site.delayed_group - 1]++; + if (p.delayed_group() > 0) { + nu_d[p.delayed_group() - 1]++; } // Write fission particles to nuBank - NuBank& nu_bank_entry = p.nu_bank().emplace_back(); - nu_bank_entry.wgt = site.wgt; - nu_bank_entry.E = site.E; - nu_bank_entry.delayed_group = site.delayed_group; + p.nu_bank().emplace_back(); + NuBank* nu_bank_entry = &p.nu_bank().back(); + nu_bank_entry->wgt = site.wgt; + nu_bank_entry->E = site.E; + nu_bank_entry->delayed_group = site.delayed_group; } // If shared fission bank was full, and no fissions could be added, @@ -297,7 +270,7 @@ void sample_photon_reaction(Particle& p) // Kill photon if below energy cutoff -- an extra check is made here because // photons with energy below the cutoff may have been produced by neutrons // reactions or atomic relaxation - int photon = ParticleType::photon().transport_index(); + int photon = static_cast(ParticleType::photon); if (p.E() < settings::energy_cutoff[photon]) { p.E() = 0.0; p.wgt() = 0.0; @@ -320,8 +293,8 @@ void sample_photon_reaction(Particle& p) // Coherent (Rayleigh) scattering prob += micro.coherent; if (prob > cutoff) { - p.mu() = element.rayleigh_scatter(alpha, p.current_seed()); - p.u() = rotate_angle(p.u(), p.mu(), nullptr, p.current_seed()); + double mu = element.rayleigh_scatter(alpha, p.current_seed()); + p.u() = rotate_angle(p.u(), mu, nullptr, p.current_seed()); p.event() = TallyEvent::SCATTER; p.event_mt() = COHERENT; return; @@ -330,10 +303,10 @@ void sample_photon_reaction(Particle& p) // Incoherent (Compton) scattering prob += micro.incoherent; if (prob > cutoff) { - double alpha_out; + double alpha_out, mu; int i_shell; element.compton_scatter( - alpha, true, &alpha_out, &p.mu(), &i_shell, p.current_seed()); + alpha, true, &alpha_out, &mu, &i_shell, p.current_seed()); // Determine binding energy of shell. The binding energy is 0.0 if // doppler broadening is not used. @@ -347,26 +320,25 @@ void sample_photon_reaction(Particle& p) // Create Compton electron double phi = uniform_distribution(0., 2.0 * PI, p.current_seed()); double E_electron = (alpha - alpha_out) * MASS_ELECTRON_EV - e_b; - int electron = ParticleType::electron().transport_index(); + int electron = static_cast(ParticleType::electron); if (E_electron >= settings::energy_cutoff[electron]) { - double mu_electron = (alpha - alpha_out * p.mu()) / + double mu_electron = (alpha - alpha_out * mu) / std::sqrt(alpha * alpha + alpha_out * alpha_out - - 2.0 * alpha * alpha_out * p.mu()); + 2.0 * alpha * alpha_out * mu); Direction u = rotate_angle(p.u(), mu_electron, &phi, p.current_seed()); - p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron()); + p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron); } - // Allow electrons to fill orbital and produce Auger electrons and - // fluorescent photons. Since Compton subshell data does not match atomic - // relaxation data, use the mapping between the data to find the subshell - if (settings::atomic_relaxation && element.has_atomic_relaxation_ && - i_shell >= 0 && element.subshell_map_[i_shell] >= 0) { - element.atomic_relaxation(element.subshell_map_[i_shell], p); + // TODO: Compton subshell data does not match atomic relaxation data + // Allow electrons to fill orbital and produce auger electrons + // and fluorescent photons + if (i_shell >= 0) { + element.atomic_relaxation(i_shell, p); } phi += PI; p.E() = alpha_out * MASS_ELECTRON_EV; - p.u() = rotate_angle(p.u(), p.mu(), &phi, p.current_seed()); + p.u() = rotate_angle(p.u(), mu, &phi, p.current_seed()); p.event() = TallyEvent::SCATTER; p.event_mt() = INCOHERENT; return; @@ -380,9 +352,8 @@ void sample_photon_reaction(Particle& p) // cross sections int i_grid = micro.index_grid; double f = micro.interp_factor; - tensor::View xs_lower = element.cross_sections_.slice(i_grid); - tensor::View xs_upper = - element.cross_sections_.slice(i_grid + 1); + const auto& xs_lower = xt::row(element.cross_sections_, i_grid); + const auto& xs_upper = xt::row(element.cross_sections_, i_grid + 1); for (int i_shell = 0; i_shell < element.shells_.size(); ++i_shell) { const auto& shell {element.shells_[i_shell]}; @@ -428,13 +399,11 @@ void sample_photon_reaction(Particle& p) u.z = std::sqrt(1.0 - mu * mu) * std::sin(phi); // Create secondary electron - p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron()); + p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron); // Allow electrons to fill orbital and produce auger electrons // and fluorescent photons - if (settings::atomic_relaxation) { - element.atomic_relaxation(i_shell, p); - } + element.atomic_relaxation(i_shell, p); p.event() = TallyEvent::ABSORB; p.event_mt() = 533 + shell.index_subshell; p.wgt() = 0.0; @@ -455,11 +424,12 @@ void sample_photon_reaction(Particle& p) // Create secondary electron Direction u = rotate_angle(p.u(), mu_electron, nullptr, p.current_seed()); - p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron()); + p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron); // Create secondary positron u = rotate_angle(p.u(), mu_positron, nullptr, p.current_seed()); - p.create_secondary(p.wgt(), u, E_positron, ParticleType::positron()); + p.create_secondary(p.wgt(), u, E_positron, ParticleType::positron); + p.event() = TallyEvent::ABSORB; p.event_mt() = PAIR_PROD; p.wgt() = 0.0; @@ -494,8 +464,8 @@ void sample_positron_reaction(Particle& p) Direction u = isotropic_direction(p.current_seed()); // Create annihilation photon pair traveling in opposite directions - p.create_secondary(p.wgt(), u, MASS_ELECTRON_EV, ParticleType::photon()); - p.create_secondary(p.wgt(), -u, MASS_ELECTRON_EV, ParticleType::photon()); + p.create_secondary(p.wgt(), u, MASS_ELECTRON_EV, ParticleType::photon); + p.create_secondary(p.wgt(), -u, MASS_ELECTRON_EV, ParticleType::photon); p.E() = 0.0; p.wgt() = 0.0; @@ -515,7 +485,7 @@ int sample_nuclide(Particle& p) for (int i = 0; i < n; ++i) { // Get atom density int i_nuclide = mat->nuclide_[i]; - double atom_density = mat->atom_density(i, p.density_mult()); + double atom_density = mat->atom_density_[i]; // Increment probability to compare to cutoff prob += atom_density * p.neutron_xs(i_nuclide).total; @@ -540,7 +510,7 @@ int sample_element(Particle& p) for (int i = 0; i < mat->element_.size(); ++i) { // Find atom density int i_element = mat->element_[i]; - double atom_density = mat->atom_density(i, p.density_mult()); + double atom_density = mat->atom_density_[i]; // Determine microscopic cross section double sigma = atom_density * p.photon_xs(i_element).total; @@ -620,7 +590,7 @@ void sample_photon_product( continue; for (int j = 0; j < rx->products_.size(); ++j) { - if (rx->products_[j].particle_.is_photon()) { + if (rx->products_[j].particle_ == ParticleType::photon) { // For fission, artificially increase the photon yield to account // for delayed photons double f = 1.0; @@ -675,9 +645,7 @@ void absorption(Particle& p, int i_nuclide) p.wgt() = 0.0; p.event() = TallyEvent::ABSORB; - if (!p.fission()) { - p.event_mt() = N_DISAPPEAR; - } + p.event_mt() = N_DISAPPEAR; } } } @@ -865,7 +833,7 @@ Direction sample_target_velocity(const Nuclide& nuc, double E, Direction u, // otherwise, use free gas model } else { - if (E >= settings::free_gas_threshold * kT && nuc.awr_ > 1.0) { + if (E >= FREE_GAS_THRESHOLD * kT && nuc.awr_ > 1.0) { return {}; } else { sampling_method = ResScatMethod::cxs; @@ -1090,10 +1058,6 @@ void sample_fission_neutron( // set the delayed group for the particle born from fission site->delayed_group = group; - // Sample time of emission based on decay constant of precursor - double decay_rate = rx.products_[site->delayed_group].decay_rate_; - site->time -= std::log(prn(p.current_seed())) / decay_rate; - } else { // ==================================================================== // PROMPT NEUTRON SAMPLED @@ -1109,7 +1073,7 @@ void sample_fission_neutron( rx.products_[site->delayed_group].sample(E_in, site->E, mu, seed); // resample if energy is greater than maximum neutron energy - int neutron = ParticleType::neutron().transport_index(); + constexpr int neutron = static_cast(ParticleType::neutron); if (site->E < data::energy_max[neutron]) break; @@ -1169,7 +1133,7 @@ void inelastic_scatter(const Nuclide& nuc, const Reaction& rx, Particle& p) if (std::floor(yield) == yield && yield > 0) { // If yield is integral, create exactly that many secondary particles for (int i = 0; i < static_cast(std::round(yield)) - 1; ++i) { - p.create_secondary(p.wgt(), p.u(), p.E(), ParticleType::neutron()); + p.create_secondary(p.wgt(), p.u(), p.E(), ParticleType::neutron); } } else { // Otherwise, change weight of particle based on yield @@ -1182,21 +1146,9 @@ void sample_secondary_photons(Particle& p, int i_nuclide) // Sample the number of photons produced double y_t = p.neutron_xs(i_nuclide).photon_prod / p.neutron_xs(i_nuclide).total; - double photon_wgt = p.wgt(); - int y = 1; - - if (settings::use_decay_photons) { - // For decay photons, sample a single photon and modify the weight - if (y_t <= 0.0) - return; - photon_wgt *= y_t; - } else { - // For prompt photons, sample an integral number of photons with weight - // equal to the neutron's weight - y = static_cast(y_t); - if (prn(p.current_seed()) <= y_t - y) - ++y; - } + int y = static_cast(y_t); + if (prn(p.current_seed()) <= y_t - y) + ++y; // Sample each secondary photon for (int i = 0; i < y; ++i) { @@ -1219,30 +1171,15 @@ void sample_secondary_photons(Particle& p, int i_nuclide) // release and deposition. See D. P. Griesheimer, S. J. Douglass, and M. H. // Stedry, "Self-consistent energy normalization for quasistatic reactor // calculations", Proc. PHYSOR, Cambridge, UK, Mar 29-Apr 2, 2020. - double wgt = photon_wgt; + double wgt; if (settings::run_mode == RunMode::EIGENVALUE && !is_fission(rx->mt_)) { - wgt *= simulation::keff; + wgt = simulation::keff * p.wgt(); + } else { + wgt = p.wgt(); } // Create the secondary photon - bool created_photon = p.create_secondary(wgt, u, E, ParticleType::photon()); - - // Pre-add photon energy to pht_storage so pht_secondary_particles() - // subtraction results in net zero - if (created_photon && !model::active_pulse_height_tallies.empty()) { - auto it = std::find(model::pulse_height_cells.begin(), - model::pulse_height_cells.end(), p.lowest_coord().cell()); - if (it != model::pulse_height_cells.end()) { - int index = std::distance(model::pulse_height_cells.begin(), it); - p.pht_storage()[index] += E; - } - } - - // Tag secondary particle with parent nuclide - if (created_photon && settings::use_decay_photons) { - p.local_secondary_bank().back().parent_nuclide = - rx->products_[i_product].parent_nuclide_; - } + p.create_secondary(wgt, u, E, ParticleType::photon); } } diff --git a/src/physics_common.cpp b/src/physics_common.cpp index 10760ce2d..e25ae6b97 100644 --- a/src/physics_common.cpp +++ b/src/physics_common.cpp @@ -18,20 +18,4 @@ void russian_roulette(Particle& p, double weight_survive) } } -void apply_russian_roulette(Particle& p) -{ - // Exit if survival biasing is turned off - if (!settings::survival_biasing) - return; - - // if survival normalization is on, use normalized weight cutoff and - // normalized weight survive - if (settings::survival_normalization) { - if (p.wgt() < settings::weight_cutoff * p.wgt_born()) { - russian_roulette(p, settings::weight_survive * p.wgt_born()); - } - } else if (p.wgt() < settings::weight_cutoff) { - russian_roulette(p, settings::weight_survive); - } -} } // namespace openmc diff --git a/src/physics_mg.cpp b/src/physics_mg.cpp index 212ba765c..361cf5aff 100644 --- a/src/physics_mg.cpp +++ b/src/physics_mg.cpp @@ -2,7 +2,7 @@ #include -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" #include #include "openmc/bank.h" @@ -19,7 +19,6 @@ #include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/tallies/tally.h" -#include "openmc/weight_windows.h" namespace openmc { @@ -27,23 +26,10 @@ void collision_mg(Particle& p) { // Add to the collision counter for the particle p.n_collision()++; - p.secondary_bank_index() = p.local_secondary_bank().size(); // Sample the reaction type sample_reaction(p); - if (settings::weight_windows_on) { - auto [ww_found, ww] = search_weight_window(p); - if (!ww_found && p.type() == ParticleType::neutron()) { - // if the weight window is not valid, apply russian roulette - // (regardless of weight window collision checkpoint setting) - apply_russian_roulette(p); - } else if (settings::weight_window_checkpoint_collision) { - // if collision checkpointing is on, apply weight window - apply_weight_window(p, ww); - } - } - // Display information about collision if ((settings::verbosity >= 10) || p.trace()) { write_message(fmt::format(" Energy Group = {}", p.g()), 1); @@ -76,9 +62,12 @@ void sample_reaction(Particle& p) // Sample a scattering event to determine the energy of the exiting neutron scatter(p); - // Play russian roulette if there are no weight windows - if (!settings::weight_windows_on) - apply_russian_roulette(p); + // Play Russian roulette if survival biasing is turned on + if (settings::survival_biasing) { + if (p.wgt() < settings::weight_cutoff) { + russian_roulette(p, settings::weight_survive); + } + } } void scatter(Particle& p) @@ -137,9 +126,10 @@ void create_fission_sites(Particle& p) // Initialize fission site object with particle data SourceSite site; site.r = p.r(); - site.particle = ParticleType::neutron(); - site.time = p.time(); + site.particle = ParticleType::neutron; site.wgt = 1. / weight; + site.parent_id = p.id(); + site.progeny_id = p.n_progeny()++; // Sample the cosine of the angle, assuming fission neutrons are emitted // isotropically @@ -164,24 +154,6 @@ void create_fission_sites(Particle& p) // of the code, 0 is prompt. site.delayed_group = dg + 1; - // If delayed product production, sample time of emission - if (dg != -1) { - auto& macro_xs = data::mg.macro_xs_[p.material()]; - double decay_rate = - macro_xs.get_xs(MgxsType::DECAY_RATE, 0, nullptr, nullptr, &dg, 0, 0); - site.time -= std::log(prn(p.current_seed())) / decay_rate; - - // Reject site if it exceeds time cutoff - double t_cutoff = settings::time_cutoff[site.particle.transport_index()]; - if (site.time > t_cutoff) { - continue; - } - } - - // Set parent and progeny ID - site.parent_id = p.current_work(); - site.progeny_id = p.n_progeny()++; - // Store fission site in bank if (use_fission_bank) { int64_t idx = simulation::fission_bank.thread_safe_append(site); @@ -200,11 +172,7 @@ void create_fission_sites(Particle& p) break; } } else { - site.wgt_born = p.wgt_born(); - site.wgt_ww_born = p.wgt_ww_born(); - site.n_split = p.n_split(); - p.local_secondary_bank().push_back(site); - p.n_secondaries()++; + p.secondary_bank().push_back(site); } // Set the delayed group on the particle as well @@ -216,10 +184,11 @@ void create_fission_sites(Particle& p) } // Write fission particles to nuBank - NuBank& nu_bank_entry = p.nu_bank().emplace_back(); - nu_bank_entry.wgt = site.wgt; - nu_bank_entry.E = site.E; - nu_bank_entry.delayed_group = site.delayed_group; + p.nu_bank().emplace_back(); + NuBank* nu_bank_entry = &p.nu_bank().back(); + nu_bank_entry->wgt = site.wgt; + nu_bank_entry->E = site.E; + nu_bank_entry->delayed_group = site.delayed_group; } // If shared fission bank was full, and no fissions could be added, diff --git a/src/plot.cpp b/src/plot.cpp index 5c4eb9460..f29653f80 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -1,19 +1,18 @@ #include "openmc/plot.h" #include -#include #include #include #include -#include "openmc/tensor.h" +#include "xtensor/xmanipulation.hpp" +#include "xtensor/xview.hpp" #include #include #ifdef USE_LIBPNG #include #endif -#include "openmc/cell.h" #include "openmc/constants.h" #include "openmc/container_util.h" #include "openmc/dagmc.h" @@ -32,7 +31,6 @@ #include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/string_utils.h" -#include "openmc/tallies/filter.h" namespace openmc { @@ -44,123 +42,56 @@ constexpr int PLOT_LEVEL_LOWEST {-1}; //!< lower bound on plot universe level constexpr int32_t NOT_FOUND {-2}; constexpr int32_t OVERLAP {-3}; -IdData::IdData(size_t h_res, size_t v_res, bool /*include_filter*/) - : data_({v_res, h_res, 3}, NOT_FOUND) +IdData::IdData(size_t h_res, size_t v_res) : data_({v_res, h_res, 3}, NOT_FOUND) {} -void IdData::set_value(size_t y, size_t x, const Particle& p, int level, - Filter* /*filter*/, FilterMatch* /*match*/) +void IdData::set_value(size_t y, size_t x, const GeometryState& p, int level) { // set cell data if (p.n_coord() <= level) { data_(y, x, 0) = NOT_FOUND; data_(y, x, 1) = NOT_FOUND; } else { - data_(y, x, 0) = model::cells.at(p.coord(level).cell())->id_; + data_(y, x, 0) = model::cells.at(p.coord(level).cell)->id_; data_(y, x, 1) = level == p.n_coord() - 1 ? p.cell_instance() : cell_instance_at_level(p, level); } // set material data - Cell* c = model::cells.at(p.lowest_coord().cell()).get(); + Cell* c = model::cells.at(p.lowest_coord().cell).get(); if (p.material() == MATERIAL_VOID) { data_(y, x, 2) = MATERIAL_VOID; + return; } else if (c->type_ == Fill::MATERIAL) { Material* m = model::materials.at(p.material()).get(); data_(y, x, 2) = m->id_; } } -void IdData::set_overlap(size_t y, size_t x, int /*overlap_idx*/) +void IdData::set_overlap(size_t y, size_t x) { - for (size_t k = 0; k < data_.shape(2); ++k) - data_(y, x, k) = OVERLAP; + xt::view(data_, y, x, xt::all()) = OVERLAP; } -PropertyData::PropertyData(size_t h_res, size_t v_res, bool /*include_filter*/) +PropertyData::PropertyData(size_t h_res, size_t v_res) : data_({v_res, h_res, 2}, NOT_FOUND) {} -void PropertyData::set_value(size_t y, size_t x, const Particle& p, int level, - Filter* /*filter*/, FilterMatch* /*match*/) +void PropertyData::set_value( + size_t y, size_t x, const GeometryState& p, int level) { - Cell* c = model::cells.at(p.lowest_coord().cell()).get(); + Cell* c = model::cells.at(p.lowest_coord().cell).get(); data_(y, x, 0) = (p.sqrtkT() * p.sqrtkT()) / K_BOLTZMANN; - data_(y, x, 1) = c->density(p.cell_instance()); -} - -void PropertyData::set_overlap(size_t y, size_t x, int /*overlap_idx*/) -{ - data_(y, x) = OVERLAP; -} - -//============================================================================== -// RasterData implementation -//============================================================================== - -RasterData::RasterData(size_t h_res, size_t v_res, bool include_filter) - : id_data_({v_res, h_res, include_filter ? 4u : 3u}, NOT_FOUND), - property_data_({v_res, h_res, 2}, static_cast(NOT_FOUND)), - include_filter_(include_filter) -{} - -void RasterData::set_value(size_t y, size_t x, const Particle& p, int level, - Filter* filter, FilterMatch* match) -{ - // set cell data - if (p.n_coord() <= level) { - id_data_(y, x, 0) = NOT_FOUND; - id_data_(y, x, 1) = NOT_FOUND; - } else { - id_data_(y, x, 0) = model::cells.at(p.coord(level).cell())->id_; - id_data_(y, x, 1) = level == p.n_coord() - 1 - ? p.cell_instance() - : cell_instance_at_level(p, level); - } - - // set material data - Cell* c = model::cells.at(p.lowest_coord().cell()).get(); - if (p.material() == MATERIAL_VOID) { - id_data_(y, x, 2) = MATERIAL_VOID; - } else if (c->type_ == Fill::MATERIAL) { - Material* m = model::materials.at(p.material()).get(); - id_data_(y, x, 2) = m->id_; - } - - // set filter index (only if filter is being used) - if (include_filter_ && filter) { - filter->get_all_bins(p, TallyEstimator::COLLISION, *match); - if (match->bins_.empty()) { - id_data_(y, x, 3) = -1; - } else { - id_data_(y, x, 3) = match->bins_[0]; - } - match->bins_.clear(); - match->weights_.clear(); - } - - // set temperature (in K) - property_data_(y, x, 0) = (p.sqrtkT() * p.sqrtkT()) / K_BOLTZMANN; - - // set density (g/cm³) if (c->type_ != Fill::UNIVERSE && p.material() != MATERIAL_VOID) { Material* m = model::materials.at(p.material()).get(); - property_data_(y, x, 1) = c->density(p.cell_instance()); + data_(y, x, 1) = m->density_gpcc_; } } -void RasterData::set_overlap(size_t y, size_t x, int overlap_idx) +void PropertyData::set_overlap(size_t y, size_t x) { - // Set cell, instance, and material to OVERLAP, but preserve filter bin for - // tally plotting. Cell encodes the overlap index as a negative number so that - // it can be used to look up overlap information in the plotter. - id_data_(y, x, 0) = OVERLAP - overlap_idx - 1; - id_data_(y, x, 1) = OVERLAP; - id_data_(y, x, 2) = OVERLAP; - - property_data_(y, x, 0) = OVERLAP; - property_data_(y, x, 1) = OVERLAP; + data_(y, x) = OVERLAP; } //============================================================================== @@ -190,21 +121,11 @@ extern "C" int openmc_plot_geometry() return 0; } -void PlottableInterface::write_image(const ImageData& data) const -{ -#ifdef USE_LIBPNG - output_png(path_plot(), data); -#else - output_ppm(path_plot(), data); -#endif -} - void Plot::create_output() const { if (PlotType::slice == type_) { // create 2D image - ImageData image = create_image(); - write_image(image); + create_image(); } else if (PlotType::voxel == type_) { // create voxel file for 3D viewing create_voxel(); @@ -247,9 +168,9 @@ void Plot::print_info() const fmt::print("Basis: YZ\n"); break; } - fmt::print("Pixels: {} {}\n", pixels()[0], pixels()[1]); + fmt::print("Pixels: {} {}\n", pixels_[0], pixels_[1]); } else if (PlotType::voxel == type_) { - fmt::print("Voxels: {} {} {}\n", pixels()[0], pixels()[1], pixels()[2]); + fmt::print("Voxels: {} {} {}\n", pixels_[0], pixels_[1], pixels_[2]); } } @@ -277,31 +198,25 @@ void read_plots_xml() void read_plots_xml(pugi::xml_node root) { for (auto node : root.children("plot")) { - std::string plot_desc = ""; - if (check_for_node(node, "id")) { - plot_desc = get_node_value(node, "id", true); - } - + std::string id_string = get_node_value(node, "id", true); + int id = std::stoi(id_string); if (check_for_node(node, "type")) { std::string type_str = get_node_value(node, "type", true); - if (type_str == "slice") { + if (type_str == "slice") model::plots.emplace_back( std::make_unique(node, Plot::PlotType::slice)); - } else if (type_str == "voxel") { + else if (type_str == "voxel") model::plots.emplace_back( std::make_unique(node, Plot::PlotType::voxel)); - } else if (type_str == "wireframe_raytrace") { - model::plots.emplace_back( - std::make_unique(node)); - } else if (type_str == "solid_raytrace") { - model::plots.emplace_back(std::make_unique(node)); - } else { - fatal_error(fmt::format( - "Unsupported plot type '{}' in plot {}", type_str, plot_desc)); - } + else if (type_str == "projection") + model::plots.emplace_back(std::make_unique(node)); + else + fatal_error( + fmt::format("Unsupported plot type '{}' in plot {}", type_str, id)); + model::plot_map[model::plots.back()->id()] = model::plots.size() - 1; } else { - fatal_error(fmt::format("Must specify plot type in plot {}", plot_desc)); + fatal_error(fmt::format("Must specify plot type in plot {}", id)); } } } @@ -314,10 +229,11 @@ void free_memory_plot() // creates an image based on user input from a plots.xml // specification in the PNG/PPM format -ImageData Plot::create_image() const +void Plot::create_image() const { - size_t width = pixels()[0]; - size_t height = pixels()[1]; + + size_t width = pixels_[0]; + size_t height = pixels_[1]; ImageData data({width, height}, not_found_); @@ -346,56 +262,38 @@ ImageData Plot::create_image() const } data(x, y) = colors_[model::material_map[id]]; } // color_by if-else - } - } + } // x for loop + } // y for loop // draw mesh lines if present if (index_meshlines_mesh_ >= 0) { draw_mesh_lines(data); } - return data; +// create image file +#ifdef USE_LIBPNG + output_png(path_plot(), data); +#else + output_ppm(path_plot(), data); +#endif } void PlottableInterface::set_id(pugi::xml_node plot_node) { - int id {C_NONE}; + // Copy data into plots if (check_for_node(plot_node, "id")) { - id = std::stoi(get_node_value(plot_node, "id")); + id_ = std::stoi(get_node_value(plot_node, "id")); + } else { + fatal_error("Must specify plot id in plots XML file."); } - try { - set_id(id); - } catch (const std::runtime_error& e) { - fatal_error(e.what()); + // Check to make sure 'id' hasn't been used + if (model::plot_map.find(id_) != model::plot_map.end()) { + fatal_error( + fmt::format("Two or more plots use the same unique ID: {}", id_)); } } -void PlottableInterface::set_id(int id) -{ - if (id < 0 && id != C_NONE) { - throw std::runtime_error {fmt::format("Invalid plot ID: {}", id)}; - } - - if (id == C_NONE) { - id = 1; - for (const auto& p : model::plots) { - id = std::max(id, p->id() + 1); - } - } - - if (id_ == id) - return; - - // Check to make sure this ID doesn't already exist - if (model::plot_map.find(id) != model::plot_map.end()) { - throw std::runtime_error { - fmt::format("Two or more plots use the same unique ID: {}", id)}; - } - - id_ = id; -} - // Checks if png or ppm is already present bool file_extension_present( const std::string& filename, const std::string& extension) @@ -445,17 +343,17 @@ void Plot::set_output_path(pugi::xml_node plot_node) vector pxls = get_node_array(plot_node, "pixels"); if (PlotType::slice == type_) { if (pxls.size() == 2) { - pixels()[0] = pxls[0]; - pixels()[1] = pxls[1]; + pixels_[0] = pxls[0]; + pixels_[1] = pxls[1]; } else { fatal_error( fmt::format(" must be length 2 in slice plot {}", id())); } } else if (PlotType::voxel == type_) { if (pxls.size() == 3) { - pixels()[0] = pxls[0]; - pixels()[1] = pxls[1]; - pixels()[2] = pxls[2]; + pixels_[0] = pxls[0]; + pixels_[1] = pxls[1]; + pixels_[2] = pxls[2]; } else { fatal_error( fmt::format(" must be length 3 in voxel plot {}", id())); @@ -516,22 +414,6 @@ void Plot::set_width(pugi::xml_node plot_node) if (pl_width.size() == 2) { width_.x = pl_width[0]; width_.y = pl_width[1]; - switch (basis_) { - case PlotBasis::xy: - u_span_ = {width_.x, 0.0, 0.0}; - v_span_ = {0.0, width_.y, 0.0}; - break; - case PlotBasis::xz: - u_span_ = {width_.x, 0.0, 0.0}; - v_span_ = {0.0, 0.0, width_.y}; - break; - case PlotBasis::yz: - u_span_ = {0.0, width_.x, 0.0}; - v_span_ = {0.0, 0.0, width_.y}; - break; - default: - UNREACHABLE(); - } } else { fatal_error( fmt::format(" must be length 2 in slice plot {}", id())); @@ -560,31 +442,23 @@ void PlottableInterface::set_universe(pugi::xml_node plot_node) } } -void PlottableInterface::set_color_by(pugi::xml_node plot_node) +void PlottableInterface::set_default_colors(pugi::xml_node plot_node) { - // Copy plot color type + // Copy plot color type and initialize all colors randomly std::string pl_color_by = "cell"; if (check_for_node(plot_node, "color_by")) { pl_color_by = get_node_value(plot_node, "color_by", true); } if ("cell" == pl_color_by) { color_by_ = PlotColorBy::cells; + colors_.resize(model::cells.size()); } else if ("material" == pl_color_by) { color_by_ = PlotColorBy::mats; + colors_.resize(model::materials.size()); } else { fatal_error(fmt::format( "Unsupported plot color type '{}' in plot {}", pl_color_by, id())); } -} - -void PlottableInterface::set_default_colors() -{ - // Copy plot color type and initialize all colors randomly - if (PlotColorBy::cells == color_by_) { - colors_.resize(model::cells.size()); - } else if (PlotColorBy::mats == color_by_) { - colors_.resize(model::materials.size()); - } for (auto& c : colors_) { c = random_color(); @@ -831,8 +705,7 @@ PlottableInterface::PlottableInterface(pugi::xml_node plot_node) set_id(plot_node); set_bg_color(plot_node); set_universe(plot_node); - set_color_by(plot_node); - set_default_colors(); + set_default_colors(plot_node); set_user_colors(plot_node); set_mask(plot_node); set_overlap_color(plot_node); @@ -847,7 +720,7 @@ Plot::Plot(pugi::xml_node plot_node, PlotType type) set_width(plot_node); set_meshlines(plot_node); slice_level_ = level_; // Copy level employed in SlicePlotBase::get_map - show_overlaps_ = color_overlaps_; + slice_color_overlaps_ = color_overlaps_; } //============================================================================== @@ -865,14 +738,14 @@ void output_ppm(const std::string& filename, const ImageData& data) // Write header of << "P6\n"; - of << data.shape(0) << " " << data.shape(1) << "\n"; + of << data.shape()[0] << " " << data.shape()[1] << "\n"; of << "255\n"; of.close(); of.open(fname, std::ios::binary | std::ios::app); // Write color for each pixel - for (int y = 0; y < data.shape(1); y++) { - for (int x = 0; x < data.shape(0); x++) { + for (int y = 0; y < data.shape()[1]; y++) { + for (int x = 0; x < data.shape()[0]; x++) { RGBColor rgb = data(x, y); of << rgb.red << rgb.green << rgb.blue; } @@ -904,8 +777,8 @@ void output_png(const std::string& filename, const ImageData& data) png_init_io(png_ptr, fp); // Write header (8 bit colour depth) - int width = data.shape(0); - int height = data.shape(1); + int width = data.shape()[0]; + int height = data.shape()[1]; png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_write_info(png_ptr, info_ptr); @@ -944,39 +817,23 @@ void Plot::draw_mesh_lines(ImageData& data) const rgb = meshlines_color_; int ax1, ax2; - Position expected_u {}; - Position expected_v {}; switch (basis_) { case PlotBasis::xy: ax1 = 0; ax2 = 1; - expected_u = {width_[0], 0.0, 0.0}; - expected_v = {0.0, width_[1], 0.0}; break; case PlotBasis::xz: ax1 = 0; ax2 = 2; - expected_u = {width_[0], 0.0, 0.0}; - expected_v = {0.0, 0.0, width_[1]}; break; case PlotBasis::yz: ax1 = 1; ax2 = 2; - expected_u = {0.0, width_[0], 0.0}; - expected_v = {0.0, 0.0, width_[1]}; break; default: UNREACHABLE(); } - // Meshlines rely on axis-aligned indexing in global coordinates. - constexpr double rel_tol {1e-12}; - double span_tol = rel_tol * (1.0 + u_span_.norm() + v_span_.norm()); - if ((u_span_ - expected_u).norm() > span_tol || - (v_span_ - expected_v).norm() > span_tol) { - fatal_error("Meshlines are only supported for axis-aligned slice plots."); - } - Position ll_plot {origin_}; Position ur_plot {origin_}; @@ -995,27 +852,27 @@ void Plot::draw_mesh_lines(ImageData& data) const int ax2_min, ax2_max; if (axis_lines.second.size() > 0) { double frac = (axis_lines.second.back() - ll_plot[ax2]) / width[ax2]; - ax2_min = (1.0 - frac) * pixels()[1]; + ax2_min = (1.0 - frac) * pixels_[1]; if (ax2_min < 0) ax2_min = 0; frac = (axis_lines.second.front() - ll_plot[ax2]) / width[ax2]; - ax2_max = (1.0 - frac) * pixels()[1]; - if (ax2_max > pixels()[1]) - ax2_max = pixels()[1]; + ax2_max = (1.0 - frac) * pixels_[1]; + if (ax2_max > pixels_[1]) + ax2_max = pixels_[1]; } else { ax2_min = 0; - ax2_max = pixels()[1]; + ax2_max = pixels_[1]; } // Iterate across the first axis and draw lines. for (auto ax1_val : axis_lines.first) { double frac = (ax1_val - ll_plot[ax1]) / width[ax1]; - int ax1_ind = frac * pixels()[0]; + int ax1_ind = frac * pixels_[0]; for (int ax2_ind = ax2_min; ax2_ind < ax2_max; ++ax2_ind) { for (int plus = 0; plus <= meshlines_width_; plus++) { - if (ax1_ind + plus >= 0 && ax1_ind + plus < pixels()[0]) + if (ax1_ind + plus >= 0 && ax1_ind + plus < pixels_[0]) data(ax1_ind + plus, ax2_ind) = rgb; - if (ax1_ind - plus >= 0 && ax1_ind - plus < pixels()[0]) + if (ax1_ind - plus >= 0 && ax1_ind - plus < pixels_[0]) data(ax1_ind - plus, ax2_ind) = rgb; } } @@ -1025,27 +882,27 @@ void Plot::draw_mesh_lines(ImageData& data) const int ax1_min, ax1_max; if (axis_lines.first.size() > 0) { double frac = (axis_lines.first.front() - ll_plot[ax1]) / width[ax1]; - ax1_min = frac * pixels()[0]; + ax1_min = frac * pixels_[0]; if (ax1_min < 0) ax1_min = 0; frac = (axis_lines.first.back() - ll_plot[ax1]) / width[ax1]; - ax1_max = frac * pixels()[0]; - if (ax1_max > pixels()[0]) - ax1_max = pixels()[0]; + ax1_max = frac * pixels_[0]; + if (ax1_max > pixels_[0]) + ax1_max = pixels_[0]; } else { ax1_min = 0; - ax1_max = pixels()[0]; + ax1_max = pixels_[0]; } // Iterate across the second axis and draw lines. for (auto ax2_val : axis_lines.second) { double frac = (ax2_val - ll_plot[ax2]) / width[ax2]; - int ax2_ind = (1.0 - frac) * pixels()[1]; + int ax2_ind = (1.0 - frac) * pixels_[1]; for (int ax1_ind = ax1_min; ax1_ind < ax1_max; ++ax1_ind) { for (int plus = 0; plus <= meshlines_width_; plus++) { - if (ax2_ind + plus >= 0 && ax2_ind + plus < pixels()[1]) + if (ax2_ind + plus >= 0 && ax2_ind + plus < pixels_[1]) data(ax1_ind, ax2_ind + plus) = rgb; - if (ax2_ind - plus >= 0 && ax2_ind - plus < pixels()[1]) + if (ax2_ind - plus >= 0 && ax2_ind - plus < pixels_[1]) data(ax1_ind, ax2_ind - plus) = rgb; } } @@ -1066,9 +923,9 @@ void Plot::create_voxel() const { // compute voxel widths in each direction array vox; - vox[0] = width_[0] / static_cast(pixels()[0]); - vox[1] = width_[1] / static_cast(pixels()[1]); - vox[2] = width_[2] / static_cast(pixels()[2]); + vox[0] = width_[0] / static_cast(pixels_[0]); + vox[1] = width_[1] / static_cast(pixels_[1]); + vox[2] = width_[2] / static_cast(pixels_[2]); // initial particle position Position ll = origin_ - width_ / 2.; @@ -1090,30 +947,34 @@ void Plot::create_voxel() const // Write current date and time write_attribute(file_id, "date_and_time", time_stamp().c_str()); - array h5_pixels; - std::copy(pixels().begin(), pixels().end(), h5_pixels.begin()); - write_attribute(file_id, "num_voxels", h5_pixels); + array pixels; + std::copy(pixels_.begin(), pixels_.end(), pixels.begin()); + write_attribute(file_id, "num_voxels", pixels); write_attribute(file_id, "voxel_width", vox); write_attribute(file_id, "lower_left", ll); // Create dataset for voxel data -- note that the dimensions are reversed // since we want the order in the file to be z, y, x hsize_t dims[3]; - dims[0] = pixels()[2]; - dims[1] = pixels()[1]; - dims[2] = pixels()[0]; + dims[0] = pixels_[2]; + dims[1] = pixels_[1]; + dims[2] = pixels_[0]; hid_t dspace, dset, memspace; voxel_init(file_id, &(dims[0]), &dspace, &dset, &memspace); SlicePlotBase pltbase; + pltbase.width_ = width_; pltbase.origin_ = origin_; - pltbase.u_span_ = {width_.x, 0.0, 0.0}; - pltbase.v_span_ = {0.0, width_.y, 0.0}; - pltbase.pixels() = pixels(); - pltbase.show_overlaps_ = color_overlaps_; + pltbase.basis_ = PlotBasis::xy; + pltbase.pixels_ = pixels_; + pltbase.slice_color_overlaps_ = color_overlaps_; ProgressBar pb; - for (int z = 0; z < pixels()[2]; z++) { + for (int z = 0; z < pixels_[2]; z++) { + // update progress bar + pb.set_value( + 100. * static_cast(z) / static_cast((pixels_[2] - 1))); + // update z coordinate pltbase.origin_.z = ll.z + z * vox[2]; @@ -1122,21 +983,12 @@ void Plot::create_voxel() const // select only cell/material ID data and flip the y-axis int idx = color_by_ == PlotColorBy::cells ? 0 : 2; - // Extract 2D slice at index idx from 3D data - size_t rows = ids.data_.shape(0); - size_t cols = ids.data_.shape(1); - tensor::Tensor data_slice({rows, cols}); - for (size_t r = 0; r < rows; ++r) - for (size_t c = 0; c < cols; ++c) - data_slice(r, c) = ids.data_(r, c, idx); - tensor::Tensor data_flipped = data_slice.flip(0); + xt::xtensor data_slice = + xt::view(ids.data_, xt::all(), xt::all(), idx); + xt::xtensor data_flipped = xt::flip(data_slice, 0); // Write to HDF5 dataset voxel_write_slice(z, dspace, dset, memspace, data_flipped.data()); - - // update progress bar - pb.set_value( - 100. * static_cast(z + 1) / static_cast((pixels()[2]))); } voxel_finalize(dspace, dset, memspace); @@ -1182,14 +1034,18 @@ RGBColor random_color(void) int(prn(&model::plotter_seed) * 255), int(prn(&model::plotter_seed) * 255)}; } -RayTracePlot::RayTracePlot(pugi::xml_node node) : PlottableInterface(node) +ProjectionPlot::ProjectionPlot(pugi::xml_node node) : PlottableInterface(node) { + set_output_path(node); set_look_at(node); set_camera_position(node); set_field_of_view(node); set_pixels(node); + set_opacities(node); set_orthographic_width(node); - set_output_path(node); + set_wireframe_thickness(node); + set_wireframe_ids(node); + set_wireframe_color(node); if (check_for_node(node, "orthographic_width") && check_for_node(node, "field_of_view")) @@ -1197,40 +1053,9 @@ RayTracePlot::RayTracePlot(pugi::xml_node node) : PlottableInterface(node) "parameters."); } -void RayTracePlot::update_view() +void ProjectionPlot::set_wireframe_color(pugi::xml_node plot_node) { - // Get centerline vector for camera-to-model. We create vectors around this - // that form a pixel array, and then trace rays along that. - auto up = up_ / up_.norm(); - Direction looking_direction = look_at_ - camera_position_; - looking_direction /= looking_direction.norm(); - if (std::abs(std::abs(looking_direction.dot(up)) - 1.0) < 1e-9) - fatal_error("Up vector cannot align with vector between camera position " - "and look_at!"); - Direction cam_yaxis = looking_direction.cross(up); - cam_yaxis /= cam_yaxis.norm(); - Direction cam_zaxis = cam_yaxis.cross(looking_direction); - cam_zaxis /= cam_zaxis.norm(); - - // Cache the camera-to-model matrix - camera_to_model_ = {looking_direction.x, cam_yaxis.x, cam_zaxis.x, - looking_direction.y, cam_yaxis.y, cam_zaxis.y, looking_direction.z, - cam_yaxis.z, cam_zaxis.z}; -} - -WireframeRayTracePlot::WireframeRayTracePlot(pugi::xml_node node) - : RayTracePlot(node) -{ - set_opacities(node); - set_wireframe_thickness(node); - set_wireframe_ids(node); - set_wireframe_color(node); - update_view(); -} - -void WireframeRayTracePlot::set_wireframe_color(pugi::xml_node plot_node) -{ - // Copy plot wireframe color + // Copy plot background color if (check_for_node(plot_node, "wireframe_color")) { vector w_rgb = get_node_array(plot_node, "wireframe_color"); if (w_rgb.size() == 3) { @@ -1241,7 +1066,7 @@ void WireframeRayTracePlot::set_wireframe_color(pugi::xml_node plot_node) } } -void RayTracePlot::set_output_path(pugi::xml_node node) +void ProjectionPlot::set_output_path(pugi::xml_node node) { // Set output file path std::string filename; @@ -1262,7 +1087,33 @@ void RayTracePlot::set_output_path(pugi::xml_node node) path_plot_ = filename; } -bool WireframeRayTracePlot::trackstack_equivalent( +// Advances to the next boundary from outside the geometry +// Returns -1 if no intersection found, and the surface index +// if an intersection was found. +int ProjectionPlot::advance_to_boundary_from_void(GeometryState& p) +{ + constexpr double scoot = 1e-5; + double min_dist = {INFINITY}; + auto coord = p.coord(0); + Universe* uni = model::universes[model::root_universe].get(); + int intersected_surface = -1; + for (auto c_i : uni->cells_) { + auto dist = model::cells.at(c_i)->distance(coord.r, coord.u, 0, &p); + if (dist.first < min_dist) { + min_dist = dist.first; + intersected_surface = dist.second; + } + } + if (min_dist > 1e300) + return -1; + else { // advance the particle + for (int j = 0; j < p.n_coord(); ++j) + p.coord(j).r += (min_dist + scoot) * p.coord(j).u; + return std::abs(intersected_surface); + } +} + +bool ProjectionPlot::trackstack_equivalent( const std::vector& track1, const std::vector& track2) const { @@ -1272,7 +1123,7 @@ bool WireframeRayTracePlot::trackstack_equivalent( return false; for (int i = 0; i < track1.size(); ++i) { if (track1[i].id != track2[i].id || - track1[i].surface_index != track2[i].surface_index) { + track1[i].surface != track2[i].surface) { return false; } } @@ -1299,7 +1150,7 @@ bool WireframeRayTracePlot::trackstack_equivalent( if (t1_i == track1.size() && t2_i == track2.size()) break; // Check if surface different - if (track1[t1_i].surface_index != track2[t2_i].surface_index) + if (track1[t1_i].surface != track2[t2_i].surface) return false; // Pretty sure this should not be used: @@ -1307,7 +1158,7 @@ bool WireframeRayTracePlot::trackstack_equivalent( // t1_i != track1.size() - 1 && // track1[t1_i+1].id != track2[t2_i+1].id) return false; if (t2_i != 0 && t1_i != 0 && - track1[t1_i - 1].surface_index != track2[t2_i - 1].surface_index) + track1[t1_i - 1].surface != track2[t2_i - 1].surface) return false; // Check if neighboring cells are different @@ -1323,60 +1174,45 @@ bool WireframeRayTracePlot::trackstack_equivalent( } } -std::pair RayTracePlot::get_pixel_ray( - int horiz, int vert) const +void ProjectionPlot::create_output() const { - // Compute field of view in radians - constexpr double DEGREE_TO_RADIAN = PI / 180.0; + // Get centerline vector for camera-to-model. We create vectors around this + // that form a pixel array, and then trace rays along that. + auto up = up_ / up_.norm(); + Direction looking_direction = look_at_ - camera_position_; + looking_direction /= looking_direction.norm(); + if (std::abs(std::abs(looking_direction.dot(up)) - 1.0) < 1e-9) + fatal_error("Up vector cannot align with vector between camera position " + "and look_at!"); + Direction cam_yaxis = looking_direction.cross(up); + cam_yaxis /= cam_yaxis.norm(); + Direction cam_zaxis = cam_yaxis.cross(looking_direction); + cam_zaxis /= cam_zaxis.norm(); + + // Transformation matrix for directions + std::vector camera_to_model = {looking_direction.x, cam_yaxis.x, + cam_zaxis.x, looking_direction.y, cam_yaxis.y, cam_zaxis.y, + looking_direction.z, cam_yaxis.z, cam_zaxis.z}; + + // Now we convert to the polar coordinate system with the polar angle + // measuring the angle from the vector up_. Phi is the rotation about up_. For + // now, up_ is hard-coded to be +z. + constexpr double DEGREE_TO_RADIAN = M_PI / 180.0; double horiz_fov_radians = horizontal_field_of_view_ * DEGREE_TO_RADIAN; - double p0 = static_cast(pixels()[0]); - double p1 = static_cast(pixels()[1]); + double p0 = static_cast(pixels_[0]); + double p1 = static_cast(pixels_[1]); double vert_fov_radians = horiz_fov_radians * p1 / p0; + double dphi = horiz_fov_radians / p0; + double dmu = vert_fov_radians / p1; - // focal_plane_dist can be changed to alter the perspective distortion - // effect. This is in units of cm. This seems to look good most of the - // time. TODO let this variable be set through XML. - constexpr double focal_plane_dist = 10.0; - const double dx = 2.0 * focal_plane_dist * std::tan(0.5 * horiz_fov_radians); - const double dy = p1 / p0 * dx; - - std::pair result; - - // Generate the starting position/direction of the ray - if (orthographic_width_ == C_NONE) { // perspective projection - Direction camera_local_vec; - camera_local_vec.x = focal_plane_dist; - camera_local_vec.y = -0.5 * dx + horiz * dx / p0; - camera_local_vec.z = 0.5 * dy - vert * dy / p1; - camera_local_vec /= camera_local_vec.norm(); - - result.first = camera_position_; - result.second = camera_local_vec.rotate(camera_to_model_); - } else { // orthographic projection - - double x_pix_coord = (static_cast(horiz) - p0 / 2.0) / p0; - double y_pix_coord = (static_cast(vert) - p1 / 2.0) / p1; - - result.first = camera_position_ + - camera_y_axis() * x_pix_coord * orthographic_width_ + - camera_z_axis() * y_pix_coord * orthographic_width_; - result.second = camera_x_axis(); - } - - return result; -} - -ImageData WireframeRayTracePlot::create_image() const -{ - size_t width = pixels()[0]; - size_t height = pixels()[1]; + size_t width = pixels_[0]; + size_t height = pixels_[1]; ImageData data({width, height}, not_found_); - // This array marks where the initial wireframe was drawn. We convolve it with - // a filter that gets adjusted with the wireframe thickness in order to - // thicken the lines. - tensor::Tensor wireframe_initial( - {static_cast(width), static_cast(height)}, 0); + // This array marks where the initial wireframe was drawn. + // We convolve it with a filter that gets adjusted with the + // wireframe thickness in order to thicken the lines. + xt::xtensor wireframe_initial({width, height}, 0); /* Holds all of the track segments for the current rendered line of pixels. * old_segments holds a copy of this_line_segments from the previous line. @@ -1393,73 +1229,154 @@ ImageData WireframeRayTracePlot::create_image() const std::vector>> this_line_segments( n_threads); for (int t = 0; t < n_threads; ++t) { - this_line_segments[t].resize(pixels()[0]); + this_line_segments[t].resize(pixels_[0]); } // The last thread writes to this, and the first thread reads from it. - std::vector> old_segments(pixels()[0]); + std::vector> old_segments(pixels_[0]); #pragma omp parallel { const int n_threads = num_threads(); const int tid = thread_num(); - int vert = tid; - for (int iter = 0; iter <= pixels()[1] / n_threads; iter++) { + GeometryState p; + p.u() = {1.0, 0.0, 0.0}; - // Save bottom line of current work chunk to compare against later. This - // used to be inside the below if block, but it causes a spurious line to - // be drawn at the bottom of the image. Not sure why, but moving it here - // fixes things. + int vert = tid; + for (int iter = 0; iter <= pixels_[1] / n_threads; iter++) { + + // Save bottom line of current work chunk to compare against later + // I used to have this inside the below if block, but it causes a + // spurious line to be drawn at the bottom of the image. Not sure + // why, but moving it here fixes things. if (tid == n_threads - 1) old_segments = this_line_segments[n_threads - 1]; - if (vert < pixels()[1]) { + if (vert < pixels_[1]) { - for (int horiz = 0; horiz < pixels()[0]; ++horiz) { + for (int horiz = 0; horiz < pixels_[0]; ++horiz) { - // RayTracePlot implements camera ray generation - std::pair ru = get_pixel_ray(horiz, vert); + // Projection mode below decides ray starting conditions + Position init_r; + Direction init_u; + + // Generate the starting position/direction of the ray + if (orthographic_width_ == 0.0) { // perspective projection + double this_phi = + -horiz_fov_radians / 2.0 + dphi * horiz + 0.5 * dphi; + double this_mu = + -vert_fov_radians / 2.0 + dmu * vert + M_PI / 2.0 + 0.5 * dmu; + Direction camera_local_vec; + camera_local_vec.x = std::cos(this_phi) * std::sin(this_mu); + camera_local_vec.y = std::sin(this_phi) * std::sin(this_mu); + camera_local_vec.z = std::cos(this_mu); + init_u = camera_local_vec.rotate(camera_to_model); + init_r = camera_position_; + } else { // orthographic projection + init_u = looking_direction; + + double x_pix_coord = (static_cast(horiz) - p0 / 2.0) / p0; + double y_pix_coord = (static_cast(vert) - p1 / 2.0) / p0; + + init_r = camera_position_; + init_r += cam_yaxis * x_pix_coord * orthographic_width_; + init_r += cam_zaxis * y_pix_coord * orthographic_width_; + } + + // Resets internal geometry state of particle + p.init_from_r_u(init_r, init_u); + + bool hitsomething = false; + bool intersection_found = true; + int loop_counter = 0; this_line_segments[tid][horiz].clear(); - ProjectionRay ray( - ru.first, ru.second, *this, this_line_segments[tid][horiz]); - ray.trace(); + int first_surface = + -1; // surface first passed when entering the model + bool first_inside_model = true; // false after entering the model + while (intersection_found) { + bool inside_cell = false; + + int32_t i_surface = std::abs(p.surface()) - 1; + if (i_surface > 0 && + model::surfaces[i_surface]->geom_type_ == GeometryType::DAG) { +#ifdef DAGMC + int32_t i_cell = next_cell(i_surface, + p.cell_last(p.n_coord() - 1), p.lowest_coord().universe); + inside_cell = i_cell >= 0; +#else + fatal_error( + "Not compiled for DAGMC, but somehow you have a DAGCell!"); +#endif + } else { + inside_cell = exhaustive_find_cell(p); + } + + if (inside_cell) { + + // This allows drawing wireframes with surface intersection + // edges on the model boundary for the same cell. + if (first_inside_model) { + this_line_segments[tid][horiz].emplace_back( + color_by_ == PlotColorBy::mats ? p.material() + : p.lowest_coord().cell, + 0.0, first_surface); + first_inside_model = false; + } + + hitsomething = true; + intersection_found = true; + auto dist = distance_to_boundary(p); + this_line_segments[tid][horiz].emplace_back( + color_by_ == PlotColorBy::mats ? p.material() + : p.lowest_coord().cell, + dist.distance, std::abs(dist.surface_index)); + + // Advance particle + for (int lev = 0; lev < p.n_coord(); ++lev) { + p.coord(lev).r += dist.distance * p.coord(lev).u; + } + p.surface() = dist.surface_index; + p.n_coord_last() = p.n_coord(); + p.n_coord() = dist.coord_level; + if (dist.lattice_translation[0] != 0 || + dist.lattice_translation[1] != 0 || + dist.lattice_translation[2] != 0) { + cross_lattice(p, dist); + } + + } else { + first_surface = advance_to_boundary_from_void(p); + intersection_found = + first_surface != -1; // -1 if no surface found + } + loop_counter++; + if (loop_counter > MAX_INTERSECTIONS) + fatal_error("Infinite loop in projection plot"); + } // Now color the pixel based on what we have intersected... // Loops backwards over intersections. Position current_color( not_found_.red, not_found_.green, not_found_.blue); const auto& segments = this_line_segments[tid][horiz]; - - // There must be at least two cell intersections to color, front and - // back of the cell. Maybe an infinitely thick cell could be present - // with no back, but why would you want to color that? It's easier to - // just skip that edge case and not even color it. - if (segments.size() <= 1) - continue; - - for (int i = segments.size() - 2; i >= 0; --i) { + for (unsigned i = segments.size(); i-- > 0;) { int colormap_idx = segments[i].id; RGBColor seg_color = colors_[colormap_idx]; Position seg_color_vec( seg_color.red, seg_color.green, seg_color.blue); - double mixing = - std::exp(-xs_[colormap_idx] * - (segments[i + 1].length - segments[i].length)); + double mixing = std::exp(-xs_[colormap_idx] * segments[i].length); current_color = current_color * mixing + (1.0 - mixing) * seg_color_vec; + RGBColor result; + result.red = static_cast(current_color.x); + result.green = static_cast(current_color.y); + result.blue = static_cast(current_color.z); + data(horiz, vert) = result; } - // save result converting from double-precision color coordinates to - // byte-sized - RGBColor result; - result.red = static_cast(current_color.x); - result.green = static_cast(current_color.y); - result.blue = static_cast(current_color.z); - data(horiz, vert) = result; - // Check to draw wireframe in horizontal direction. No inter-thread // comm. if (horiz > 0) { @@ -1478,7 +1395,7 @@ ImageData WireframeRayTracePlot::create_image() const // Now that the horizontal line has finished rendering, we can fill in // wireframe entries that require comparison among all the threads. Hence // the omp barrier being used. It has to be OUTSIDE any if blocks! - if (vert < pixels()[1]) { + if (vert < pixels_[1]) { // Loop over horizontal pixels, checking intersection stack of upper // neighbor @@ -1488,7 +1405,7 @@ ImageData WireframeRayTracePlot::create_image() const else top_cmp = &this_line_segments[tid - 1]; - for (int horiz = 0; horiz < pixels()[0]; ++horiz) { + for (int horiz = 0; horiz < pixels_[0]; ++horiz) { if (!trackstack_equivalent( this_line_segments[tid][horiz], (*top_cmp)[horiz])) { wireframe_initial(horiz, vert) = 1; @@ -1505,8 +1422,8 @@ ImageData WireframeRayTracePlot::create_image() const } // end omp parallel // Now thicken the wireframe lines and apply them to our image - for (int vert = 0; vert < pixels()[1]; ++vert) { - for (int horiz = 0; horiz < pixels()[0]; ++horiz) { + for (int vert = 0; vert < pixels_[1]; ++vert) { + for (int horiz = 0; horiz < pixels_[0]; ++horiz) { if (wireframe_initial(horiz, vert)) { if (wireframe_thickness_ == 1) data(horiz, vert) = wireframe_color_; @@ -1517,40 +1434,33 @@ ImageData WireframeRayTracePlot::create_image() const if (i * i + j * j < wireframe_thickness_ * wireframe_thickness_) { // Check if wireframe pixel is out of bounds - int w_i = std::max(std::min(horiz + i, pixels()[0] - 1), 0); - int w_j = std::max(std::min(vert + j, pixels()[1] - 1), 0); + int w_i = std::max(std::min(horiz + i, pixels_[0] - 1), 0); + int w_j = std::max(std::min(vert + j, pixels_[1] - 1), 0); data(w_i, w_j) = wireframe_color_; } } } } - return data; +#ifdef USE_LIBPNG + output_png(path_plot(), data); +#else + output_ppm(path_plot(), data); +#endif } -void WireframeRayTracePlot::create_output() const -{ - ImageData data = create_image(); - write_image(data); -} - -void RayTracePlot::print_info() const +void ProjectionPlot::print_info() const { + fmt::print("Plot Type: Projection\n"); fmt::print("Camera position: {} {} {}\n", camera_position_.x, camera_position_.y, camera_position_.z); fmt::print("Look at: {} {} {}\n", look_at_.x, look_at_.y, look_at_.z); fmt::print( "Horizontal field of view: {} degrees\n", horizontal_field_of_view_); - fmt::print("Pixels: {} {}\n", pixels()[0], pixels()[1]); + fmt::print("Pixels: {} {}\n", pixels_[0], pixels_[1]); } -void WireframeRayTracePlot::print_info() const -{ - fmt::print("Plot Type: Wireframe ray-traced\n"); - RayTracePlot::print_info(); -} - -void WireframeRayTracePlot::set_opacities(pugi::xml_node node) +void ProjectionPlot::set_opacities(pugi::xml_node node) { xs_.resize(colors_.size(), 1e6); // set to large value for opaque by default @@ -1580,7 +1490,7 @@ void WireframeRayTracePlot::set_opacities(pugi::xml_node node) } } -void RayTracePlot::set_orthographic_width(pugi::xml_node node) +void ProjectionPlot::set_orthographic_width(pugi::xml_node node) { if (check_for_node(node, "orthographic_width")) { double orthographic_width = @@ -1591,7 +1501,7 @@ void RayTracePlot::set_orthographic_width(pugi::xml_node node) } } -void WireframeRayTracePlot::set_wireframe_thickness(pugi::xml_node node) +void ProjectionPlot::set_wireframe_thickness(pugi::xml_node node) { if (check_for_node(node, "wireframe_thickness")) { int wireframe_thickness = @@ -1602,7 +1512,7 @@ void WireframeRayTracePlot::set_wireframe_thickness(pugi::xml_node node) } } -void WireframeRayTracePlot::set_wireframe_ids(pugi::xml_node node) +void ProjectionPlot::set_wireframe_ids(pugi::xml_node node) { if (check_for_node(node, "wireframe_ids")) { wireframe_ids_ = get_node_array(node, "wireframe_ids"); @@ -1617,29 +1527,29 @@ void WireframeRayTracePlot::set_wireframe_ids(pugi::xml_node node) std::sort(wireframe_ids_.begin(), wireframe_ids_.end()); } -void RayTracePlot::set_pixels(pugi::xml_node node) +void ProjectionPlot::set_pixels(pugi::xml_node node) { vector pxls = get_node_array(node, "pixels"); if (pxls.size() != 2) fatal_error( fmt::format(" must be length 2 in projection plot {}", id())); - pixels()[0] = pxls[0]; - pixels()[1] = pxls[1]; + pixels_[0] = pxls[0]; + pixels_[1] = pxls[1]; } -void RayTracePlot::set_camera_position(pugi::xml_node node) +void ProjectionPlot::set_camera_position(pugi::xml_node node) { vector camera_pos = get_node_array(node, "camera_position"); if (camera_pos.size() != 3) { - fatal_error(fmt::format( - "camera_position element must have three floating point values")); + fatal_error( + fmt::format("look_at element must have three floating point values")); } camera_position_.x = camera_pos[0]; camera_position_.y = camera_pos[1]; camera_position_.z = camera_pos[2]; } -void RayTracePlot::set_look_at(pugi::xml_node node) +void ProjectionPlot::set_look_at(pugi::xml_node node) { vector look_at = get_node_array(node, "look_at"); if (look_at.size() != 3) { @@ -1650,254 +1560,22 @@ void RayTracePlot::set_look_at(pugi::xml_node node) look_at_.z = look_at[2]; } -void RayTracePlot::set_field_of_view(pugi::xml_node node) +void ProjectionPlot::set_field_of_view(pugi::xml_node node) { // Defaults to 70 degree horizontal field of view (see .h file) - if (check_for_node(node, "horizontal_field_of_view")) { - double fov = - std::stod(get_node_value(node, "horizontal_field_of_view", true)); + if (check_for_node(node, "field_of_view")) { + double fov = std::stod(get_node_value(node, "field_of_view", true)); if (fov < 180.0 && fov > 0.0) { horizontal_field_of_view_ = fov; } else { - fatal_error(fmt::format("Horizontal field of view for plot {} " - "out-of-range. Must be in (0, 180) degrees.", - id())); + fatal_error(fmt::format( + "Field of view for plot {} out-of-range. Must be in (0, 180).", id())); } } } -SolidRayTracePlot::SolidRayTracePlot(pugi::xml_node node) : RayTracePlot(node) -{ - set_opaque_ids(node); - set_diffuse_fraction(node); - set_light_position(node); - update_view(); -} - -void SolidRayTracePlot::print_info() const -{ - fmt::print("Plot Type: Solid ray-traced\n"); - RayTracePlot::print_info(); -} - -ImageData SolidRayTracePlot::create_image() const -{ - size_t width = pixels()[0]; - size_t height = pixels()[1]; - ImageData data({width, height}, not_found_); - -#pragma omp parallel for schedule(dynamic) collapse(2) - for (int horiz = 0; horiz < pixels()[0]; ++horiz) { - for (int vert = 0; vert < pixels()[1]; ++vert) { - // RayTracePlot implements camera ray generation - std::pair ru = get_pixel_ray(horiz, vert); - PhongRay ray(ru.first, ru.second, *this); - ray.trace(); - data(horiz, vert) = ray.result_color(); - } - } - - return data; -} - -void SolidRayTracePlot::create_output() const -{ - ImageData data = create_image(); - write_image(data); -} - -void SolidRayTracePlot::set_opaque_ids(pugi::xml_node node) -{ - if (check_for_node(node, "opaque_ids")) { - auto opaque_ids_tmp = get_node_array(node, "opaque_ids"); - - // It is read in as actual ID values, but we have to convert to indices in - // mat/cell array - for (auto& x : opaque_ids_tmp) - x = color_by_ == PlotColorBy::mats ? model::material_map[x] - : model::cell_map[x]; - - opaque_ids_.insert(opaque_ids_tmp.begin(), opaque_ids_tmp.end()); - } -} - -void SolidRayTracePlot::set_light_position(pugi::xml_node node) -{ - if (check_for_node(node, "light_position")) { - auto light_pos_tmp = get_node_array(node, "light_position"); - - if (light_pos_tmp.size() != 3) - fatal_error("Light position must be given as 3D coordinates"); - - light_location_.x = light_pos_tmp[0]; - light_location_.y = light_pos_tmp[1]; - light_location_.z = light_pos_tmp[2]; - } else { - light_location_ = camera_position(); - } -} - -void SolidRayTracePlot::set_diffuse_fraction(pugi::xml_node node) -{ - if (check_for_node(node, "diffuse_fraction")) { - diffuse_fraction_ = std::stod(get_node_value(node, "diffuse_fraction")); - if (diffuse_fraction_ < 0.0 || diffuse_fraction_ > 1.0) { - fatal_error("Must have 0 <= diffuse fraction <= 1"); - } - } -} - -void ProjectionRay::on_intersection() -{ - // This records a tuple with the following info - // - // 1) ID (material or cell depending on color_by_) - // 2) Distance traveled by the ray through that ID - // 3) Index of the intersected surface (starting from 1) - - line_segments_.emplace_back( - plot_.color_by_ == PlottableInterface::PlotColorBy::mats - ? material() - : lowest_coord().cell(), - traversal_distance_, boundary().surface_index()); -} - -void PhongRay::on_intersection() -{ - // Check if we hit an opaque material or cell - int hit_id = plot_.color_by_ == PlottableInterface::PlotColorBy::mats - ? material() - : lowest_coord().cell(); - - // If we are reflected and have advanced beyond the camera, - // the ray is done. This is checked here because we should - // kill the ray even if the material is not opaque. - if (reflected_ && (r() - plot_.camera_position()).dot(u()) >= 0.0) { - stop(); - return; - } - - // Anything that's not opaque has zero impact on the plot. - if (plot_.opaque_ids_.find(hit_id) == plot_.opaque_ids_.end()) - return; - - if (!reflected_) { - // reflect the particle and set the color to be colored by - // the normal or the diffuse lighting contribution - reflected_ = true; - result_color_ = plot_.colors_[hit_id]; - // The ray has been advanced slightly past the boundary. Use an - // approximation to the actual hit point for stable normal/lighting. - Position r_hit = r() - TINY_BIT * u(); - Direction to_light = plot_.light_location_ - r_hit; - to_light /= to_light.norm(); - - // TODO - // Not sure what can cause a surface token to be invalid here, although it - // sometimes happens for a few pixels. It's very very rare, so proceed by - // coloring the pixel with the overlap color. It seems to happen only for a - // few pixels on the outer boundary of a hex lattice. - // - // We cannot detect it in the outer loop, and it only matters here, so - // that's why the error handling is a little different than for a lost - // ray. - if (surface() == 0) { - result_color_ = plot_.overlap_color_; - stop(); - return; - } - - // Get surface pointer - const auto& surf = model::surfaces.at(surface_index()); - - // The crossed surface may be on a higher coordinate level than the - // innermost local coordinates, so we check the surface's coordinate level - // to find the appropriate coordinate level to use for the normal - // calculation - int surf_level = boundary().coord_level() - 1; - // ensure surface level is within bounds of current coordinate stack - surf_level = std::max(0, std::min(surf_level, n_coord() - 1)); - - Position r_hit_level = - coord(surf_level).r() - TINY_BIT * coord(surf_level).u(); - Direction normal = surf->normal(r_hit_level); - normal /= normal.norm(); - - // Need to apply rotations to find the normal vector in - // the base level universe's coordinate system. - for (int lev = surf_level - 1; lev >= 0; --lev) { - if (coord(lev + 1).rotated()) { - const Cell& c {*model::cells[coord(lev).cell()]}; - normal = normal.inverse_rotate(c.rotation_); - } - } - - // use the normal opposed to the ray direction - if (normal.dot(u()) > 0.0) { - normal *= -1.0; - } - - // Facing away from the light means no lighting - double dotprod = normal.dot(to_light); - dotprod = std::max(0.0, dotprod); - - double modulation = - plot_.diffuse_fraction_ + (1.0 - plot_.diffuse_fraction_) * dotprod; - result_color_ *= modulation; - - // Now point the particle to the camera. We now begin - // checking to see if it's occluded by another surface - u() = to_light; - - orig_hit_id_ = hit_id; - - // OpenMC native CSG and DAGMC surfaces have some slight differences - // in how they interpret particles that are sitting on a surface. - // I don't know exactly why, but this makes everything work beautifully. - if (surf->geom_type() == GeometryType::DAG) { - surface() = 0; - } else { - surface() = -surface(); // go to other side - } - - // Must fully restart coordinate search. Why? Not sure. - clear(); - - // Note this could likely be faster if we cached the previous - // cell we were in before the reflection. This is the easiest - // way to fully initialize all the sub-universe coordinates and - // directions though. - bool found = exhaustive_find_cell(*this); - if (!found) { - fatal_error("Lost particle after reflection."); - } - - // Must recalculate distance to boundary due to the - // direction change - compute_distance(); - - } else { - // If it's not facing the light, we color with the diffuse contribution, so - // next we check if we're going to occlude the last reflected surface. if - // so, color by the diffuse contribution instead - - if (orig_hit_id_ == -1) - fatal_error("somehow a ray got reflected but not original ID set?"); - - result_color_ = plot_.colors_[orig_hit_id_]; - result_color_ *= plot_.diffuse_fraction_; - stop(); - } -} - extern "C" int openmc_id_map(const void* plot, int32_t* data_out) { - static bool warned {false}; - if (!warned) { - warning("openmc_id_map is deprecated and will be removed in a future " - "release. Use openmc_slice_data."); - warned = true; - } auto plt = reinterpret_cast(plot); if (!plt) { @@ -1905,7 +1583,7 @@ extern "C" int openmc_id_map(const void* plot, int32_t* data_out) return OPENMC_E_INVALID_ARGUMENT; } - if (plt->show_overlaps_ && model::overlap_check_count.size() == 0) { + if (plt->slice_color_overlaps_ && model::overlap_check_count.size() == 0) { model::overlap_check_count.resize(model::cells.size()); } @@ -1919,20 +1597,14 @@ extern "C" int openmc_id_map(const void* plot, int32_t* data_out) extern "C" int openmc_property_map(const void* plot, double* data_out) { - static bool warned {false}; - if (!warned) { - warning("openmc_property_map is deprecated and will be removed in a future " - "release. Use openmc_slice_data."); - warned = true; - } auto plt = reinterpret_cast(plot); if (!plt) { - set_errmsg("Invalid slice pointer passed to openmc_property_map"); + set_errmsg("Invalid slice pointer passed to openmc_id_map"); return OPENMC_E_INVALID_ARGUMENT; } - if (plt->show_overlaps_ && model::overlap_check_count.size() == 0) { + if (plt->slice_color_overlaps_ && model::overlap_check_count.size() == 0) { model::overlap_check_count.resize(model::cells.size()); } @@ -1944,678 +1616,4 @@ extern "C" int openmc_property_map(const void* plot, double* data_out) return 0; } -extern "C" int openmc_slice_data(const double origin[3], const double u_span[3], - const double v_span[3], const size_t pixels[2], bool color_overlaps, - int level, int32_t filter_index, int32_t* geom_data, double* property_data) -{ - // Validate span vectors - Direction u_span_pos {u_span[0], u_span[1], u_span[2]}; - Direction v_span_pos {v_span[0], v_span[1], v_span[2]}; - double u_norm = u_span_pos.norm(); - double v_norm = v_span_pos.norm(); - if (u_norm == 0.0 || v_norm == 0.0) { - set_errmsg("Slice span vectors must be non-zero."); - return OPENMC_E_INVALID_ARGUMENT; - } - - constexpr double ORTHO_REL_TOL = 1e-10; - double dot = u_span_pos.dot(v_span_pos); - if (std::abs(dot) > ORTHO_REL_TOL * u_norm * v_norm) { - set_errmsg("Slice span vectors must be orthogonal."); - return OPENMC_E_INVALID_ARGUMENT; - } - - // Validate filter index if provided - if (filter_index >= 0) { - if (int err = verify_filter(filter_index)) - return err; - } - - // Initialize overlap check vector if needed - if (color_overlaps && model::overlap_check_count.size() == 0) { - model::overlap_check_count.resize(model::cells.size()); - } - - try { - // Create a temporary SlicePlotBase object to reuse get_map logic - SlicePlotBase plot_params; - plot_params.origin_ = Position {origin[0], origin[1], origin[2]}; - plot_params.u_span_ = u_span_pos; - plot_params.v_span_ = v_span_pos; - plot_params.pixels_[0] = pixels[0]; - plot_params.pixels_[1] = pixels[1]; - plot_params.show_overlaps_ = color_overlaps; - plot_params.slice_level_ = level; - - // Clear overlap data structures on new slice call - model::overlap_keys.clear(); - model::overlap_key_index.clear(); - - // Use get_map to generate data - auto data = plot_params.get_map(filter_index); - std::copy(data.id_data_.begin(), data.id_data_.end(), geom_data); - - // Copy property data if requested - if (property_data != nullptr) { - std::copy( - data.property_data_.begin(), data.property_data_.end(), property_data); - } - } catch (const std::exception& e) { - set_errmsg(e.what()); - return OPENMC_E_UNASSIGNED; - } - - return 0; -} - -// Gets the number of overlaps that we need data for -extern "C" int openmc_slice_data_overlap_count(size_t* count) -{ - if (!count) { - set_errmsg("Null pointer passed for overlap count."); - return OPENMC_E_INVALID_ARGUMENT; - } - *count = model::overlap_keys.size(); - - return 0; -} - -// Plotter pre-allocates array size based on what is returned with -// overlap_count; populates an array of size 3*count -extern "C" int openmc_slice_data_overlap_info( - size_t count, int32_t* overlap_info) -{ - for (size_t i = 0; i < count; ++i) { - overlap_info[i * 3] = model::overlap_keys[i].universe_id; - overlap_info[i * 3 + 1] = model::overlap_keys[i].cell1_id; - overlap_info[i * 3 + 2] = model::overlap_keys[i].cell2_id; - } - - return 0; -} - -extern "C" int openmc_get_plot_index(int32_t id, int32_t* index) -{ - auto it = model::plot_map.find(id); - if (it == model::plot_map.end()) { - set_errmsg("No plot exists with ID=" + std::to_string(id) + "."); - return OPENMC_E_INVALID_ID; - } - - *index = it->second; - return 0; -} - -extern "C" int openmc_plot_get_id(int32_t index, int32_t* id) -{ - if (index < 0 || index >= model::plots.size()) { - set_errmsg("Index in plots array is out of bounds."); - return OPENMC_E_OUT_OF_BOUNDS; - } - - *id = model::plots[index]->id(); - return 0; -} - -extern "C" int openmc_plot_set_id(int32_t index, int32_t id) -{ - if (index < 0 || index >= model::plots.size()) { - set_errmsg("Index in plots array is out of bounds."); - return OPENMC_E_OUT_OF_BOUNDS; - } - - if (id < 0 && id != C_NONE) { - set_errmsg("Invalid plot ID."); - return OPENMC_E_INVALID_ARGUMENT; - } - - auto* plot = model::plots[index].get(); - int32_t old_id = plot->id(); - if (id == old_id) - return 0; - - model::plot_map.erase(old_id); - try { - plot->set_id(id); - } catch (const std::runtime_error& e) { - model::plot_map[old_id] = index; - set_errmsg(e.what()); - return OPENMC_E_INVALID_ID; - } - model::plot_map[plot->id()] = index; - return 0; -} - -extern "C" size_t openmc_plots_size() -{ - return model::plots.size(); -} - -int map_phong_domain_id( - const SolidRayTracePlot* plot, int32_t id, int32_t* index_out) -{ - if (!plot || !index_out) { - set_errmsg("Invalid plot pointer passed to map_phong_domain_id"); - return OPENMC_E_INVALID_ARGUMENT; - } - - if (plot->color_by_ == PlottableInterface::PlotColorBy::mats) { - auto it = model::material_map.find(id); - if (it == model::material_map.end()) { - set_errmsg("Invalid material ID for SolidRayTracePlot"); - return OPENMC_E_INVALID_ID; - } - *index_out = it->second; - return 0; - } - - if (plot->color_by_ == PlottableInterface::PlotColorBy::cells) { - auto it = model::cell_map.find(id); - if (it == model::cell_map.end()) { - set_errmsg("Invalid cell ID for SolidRayTracePlot"); - return OPENMC_E_INVALID_ID; - } - *index_out = it->second; - return 0; - } - - set_errmsg("Unsupported color_by for SolidRayTracePlot"); - return OPENMC_E_INVALID_TYPE; -} - -int get_solidraytrace_plot_by_index(int32_t index, SolidRayTracePlot** plot) -{ - if (!plot) { - set_errmsg("Null output pointer passed to get_solidraytrace_plot_by_index"); - return OPENMC_E_INVALID_ARGUMENT; - } - - if (index < 0 || index >= model::plots.size()) { - set_errmsg("Index in plots array is out of bounds."); - return OPENMC_E_OUT_OF_BOUNDS; - } - - auto* plottable = model::plots[index].get(); - auto* solid_plot = dynamic_cast(plottable); - if (!solid_plot) { - set_errmsg("Plot at index=" + std::to_string(index) + - " is not a solid raytrace plot."); - return OPENMC_E_INVALID_TYPE; - } - - *plot = solid_plot; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_create(int32_t* index) -{ - if (!index) { - set_errmsg( - "Null output pointer passed to openmc_solidraytrace_plot_create"); - return OPENMC_E_INVALID_ARGUMENT; - } - - try { - auto new_plot = std::make_unique(); - new_plot->set_id(); - int32_t new_plot_id = new_plot->id(); -#ifdef USE_LIBPNG - new_plot->path_plot() = fmt::format("plot_{}.png", new_plot_id); -#else - new_plot->path_plot() = fmt::format("plot_{}.ppm", new_plot_id); -#endif - int32_t new_plot_index = model::plots.size(); - model::plots.emplace_back(std::move(new_plot)); - model::plot_map[new_plot_id] = new_plot_index; - *index = new_plot_index; - } catch (const std::exception& e) { - set_errmsg(e.what()); - return OPENMC_E_ALLOCATE; - } - - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_pixels( - int32_t index, int32_t* width, int32_t* height) -{ - if (!width || !height) { - set_errmsg( - "Invalid arguments passed to openmc_solidraytrace_plot_get_pixels"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - *width = plt->pixels()[0]; - *height = plt->pixels()[1]; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_pixels( - int32_t index, int32_t width, int32_t height) -{ - if (width <= 0 || height <= 0) { - set_errmsg( - "Invalid arguments passed to openmc_solidraytrace_plot_set_pixels"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->pixels()[0] = width; - plt->pixels()[1] = height; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_color_by( - int32_t index, int32_t* color_by) -{ - if (!color_by) { - set_errmsg( - "Invalid arguments passed to openmc_solidraytrace_plot_get_color_by"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - if (plt->color_by_ == PlottableInterface::PlotColorBy::mats) { - *color_by = 0; - } else if (plt->color_by_ == PlottableInterface::PlotColorBy::cells) { - *color_by = 1; - } else { - set_errmsg("Unsupported color_by for SolidRayTracePlot"); - return OPENMC_E_INVALID_TYPE; - } - - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_color_by( - int32_t index, int32_t color_by) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - if (color_by == 0) { - plt->color_by_ = PlottableInterface::PlotColorBy::mats; - } else if (color_by == 1) { - plt->color_by_ = PlottableInterface::PlotColorBy::cells; - } else { - set_errmsg("Invalid color_by value for SolidRayTracePlot"); - return OPENMC_E_INVALID_ARGUMENT; - } - - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_default_colors(int32_t index) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->set_default_colors(); - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_all_opaque(int32_t index) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->opaque_ids().clear(); - if (plt->color_by_ == PlottableInterface::PlotColorBy::mats) { - for (int32_t i = 0; i < model::materials.size(); ++i) { - plt->opaque_ids().insert(i); - } - return 0; - } - - if (plt->color_by_ == PlottableInterface::PlotColorBy::cells) { - for (int32_t i = 0; i < model::cells.size(); ++i) { - plt->opaque_ids().insert(i); - } - return 0; - } - - set_errmsg("Unsupported color_by for SolidRayTracePlot"); - return OPENMC_E_INVALID_TYPE; -} - -extern "C" int openmc_solidraytrace_plot_set_opaque( - int32_t index, int32_t id, bool visible) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - int32_t domain_index = -1; - err = map_phong_domain_id(plt, id, &domain_index); - if (err) - return err; - - if (visible) { - plt->opaque_ids().insert(domain_index); - } else { - plt->opaque_ids().erase(domain_index); - } - - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_color( - int32_t index, int32_t id, uint8_t r, uint8_t g, uint8_t b) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - int32_t domain_index = -1; - err = map_phong_domain_id(plt, id, &domain_index); - if (err) - return err; - - if (domain_index < 0 || - static_cast(domain_index) >= plt->colors_.size()) { - set_errmsg("Color index out of range for SolidRayTracePlot"); - return OPENMC_E_OUT_OF_BOUNDS; - } - - plt->colors_[domain_index] = RGBColor(r, g, b); - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_camera_position( - int32_t index, double* x, double* y, double* z) -{ - if (!x || !y || !z) { - set_errmsg("Invalid arguments passed to " - "openmc_solidraytrace_plot_get_camera_position"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - const auto& camera_position = plt->camera_position(); - *x = camera_position.x; - *y = camera_position.y; - *z = camera_position.z; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_camera_position( - int32_t index, double x, double y, double z) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->camera_position() = {x, y, z}; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_look_at( - int32_t index, double* x, double* y, double* z) -{ - if (!x || !y || !z) { - set_errmsg( - "Invalid arguments passed to openmc_solidraytrace_plot_get_look_at"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - const auto& look_at = plt->look_at(); - *x = look_at.x; - *y = look_at.y; - *z = look_at.z; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_look_at( - int32_t index, double x, double y, double z) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->look_at() = {x, y, z}; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_up( - int32_t index, double* x, double* y, double* z) -{ - if (!x || !y || !z) { - set_errmsg("Invalid arguments passed to openmc_solidraytrace_plot_get_up"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - const auto& up = plt->up(); - *x = up.x; - *y = up.y; - *z = up.z; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_up( - int32_t index, double x, double y, double z) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->up() = {x, y, z}; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_light_position( - int32_t index, double* x, double* y, double* z) -{ - if (!x || !y || !z) { - set_errmsg("Invalid arguments passed to " - "openmc_solidraytrace_plot_get_light_position"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - const auto& light_position = plt->light_location(); - *x = light_position.x; - *y = light_position.y; - *z = light_position.z; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_light_position( - int32_t index, double x, double y, double z) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->light_location() = {x, y, z}; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_fov(int32_t index, double* fov) -{ - if (!fov) { - set_errmsg("Invalid arguments passed to openmc_solidraytrace_plot_get_fov"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - *fov = plt->horizontal_field_of_view(); - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_fov(int32_t index, double fov) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->horizontal_field_of_view() = fov; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_update_view(int32_t index) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - plt->update_view(); - return 0; -} - -extern "C" int openmc_solidraytrace_plot_create_image( - int32_t index, uint8_t* data_out, int32_t width, int32_t height) -{ - if (!data_out || width <= 0 || height <= 0) { - set_errmsg( - "Invalid arguments passed to openmc_solidraytrace_plot_create_image"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - if (plt->pixels()[0] != width || plt->pixels()[1] != height) { - set_errmsg( - "Requested image size does not match SolidRayTracePlot pixel settings"); - return OPENMC_E_INVALID_SIZE; - } - - ImageData data = plt->create_image(); - if (static_cast(data.shape()[0]) != width || - static_cast(data.shape()[1]) != height) { - set_errmsg("Unexpected image size from SolidRayTracePlot create_image"); - return OPENMC_E_INVALID_SIZE; - } - - for (int32_t y = 0; y < height; ++y) { - for (int32_t x = 0; x < width; ++x) { - const auto& color = data(x, y); - size_t idx = (static_cast(y) * width + x) * 3; - data_out[idx + 0] = color.red; - data_out[idx + 1] = color.green; - data_out[idx + 2] = color.blue; - } - } - - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_color( - int32_t index, int32_t id, uint8_t* r, uint8_t* g, uint8_t* b) -{ - if (!r || !g || !b) { - set_errmsg( - "Invalid arguments passed to openmc_solidraytrace_plot_get_color"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - int32_t domain_index = -1; - err = map_phong_domain_id(plt, id, &domain_index); - if (err) - return err; - - if (domain_index < 0 || - static_cast(domain_index) >= plt->colors_.size()) { - set_errmsg("Color index out of range for SolidRayTracePlot"); - return OPENMC_E_OUT_OF_BOUNDS; - } - - const auto& color = plt->colors_[domain_index]; - *r = color.red; - *g = color.green; - *b = color.blue; - return 0; -} - -extern "C" int openmc_solidraytrace_plot_get_diffuse_fraction( - int32_t index, double* diffuse_fraction) -{ - if (!diffuse_fraction) { - set_errmsg("Invalid arguments passed to " - "openmc_solidraytrace_plot_get_diffuse_fraction"); - return OPENMC_E_INVALID_ARGUMENT; - } - - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - *diffuse_fraction = plt->diffuse_fraction(); - return 0; -} - -extern "C" int openmc_solidraytrace_plot_set_diffuse_fraction( - int32_t index, double diffuse_fraction) -{ - SolidRayTracePlot* plt = nullptr; - int err = get_solidraytrace_plot_by_index(index, &plt); - if (err) - return err; - - if (diffuse_fraction < 0.0 || diffuse_fraction > 1.0) { - set_errmsg("Diffuse fraction must be between 0 and 1"); - return OPENMC_E_INVALID_ARGUMENT; - } - - plt->diffuse_fraction() = diffuse_fraction; - return 0; -} - } // namespace openmc diff --git a/src/position.cpp b/src/position.cpp index 0361e99a0..5b3613b28 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -75,6 +75,13 @@ Position Position::operator-() const return {-x, -y, -z}; } +Position Position::rotate(const vector& rotation) const +{ + return {x * rotation[0] + y * rotation[1] + z * rotation[2], + x * rotation[3] + y * rotation[4] + z * rotation[5], + x * rotation[6] + y * rotation[7] + z * rotation[8]}; +} + std::ostream& operator<<(std::ostream& os, Position r) { os << "(" << r.x << ", " << r.y << ", " << r.z << ")"; diff --git a/src/random_dist.cpp b/src/random_dist.cpp index b05b76f99..1aa35a689 100644 --- a/src/random_dist.cpp +++ b/src/random_dist.cpp @@ -12,11 +12,6 @@ double uniform_distribution(double a, double b, uint64_t* seed) return a + (b - a) * prn(seed); } -int64_t uniform_int_distribution(int64_t a, int64_t b, uint64_t* seed) -{ - return a + static_cast(prn(seed) * (b - a + 1)); -} - double maxwell_spectrum(double T, uint64_t* seed) { // Set the random numbers diff --git a/src/random_lcg.cpp b/src/random_lcg.cpp index f2a81fc1c..581d69617 100644 --- a/src/random_lcg.cpp +++ b/src/random_lcg.cpp @@ -10,54 +10,14 @@ int64_t master_seed {1}; // LCG parameters constexpr uint64_t prn_mult {6364136223846793005ULL}; // multiplication constexpr uint64_t prn_add {1442695040888963407ULL}; // additive factor, c -uint64_t prn_stride {DEFAULT_STRIDE}; // stride between particles - -namespace { - -struct SkipAheadCoefficients { - uint64_t multiplier; - uint64_t increment; -}; - -SkipAheadCoefficients future_seed_coefficients(uint64_t n) -{ - // The algorithm here to determine the parameters used to skip ahead is - // described in F. Brown, "Random Number Generation with Arbitrary Stride," - // Trans. Am. Nucl. Soc. (Nov. 1994). This algorithm is able to skip ahead in - // O(log2(N)) operations instead of O(N). Basically, it computes parameters G - // and C which can then be used to find x_N = G*x_0 + C mod 2^M. - - // Initialize constants - uint64_t g {prn_mult}; - uint64_t c {prn_add}; - uint64_t g_new {1}; - uint64_t c_new {0}; - - while (n > 0) { - // Check if the least significant bit is 1. - if (n & 1) { - g_new *= g; - c_new = c_new * g + c; - } - c *= (g + 1); - g *= g; - - // Move bits right, dropping least significant bit. - n >>= 1; - } - - return {g_new, c_new}; -} - -} // namespace +constexpr uint64_t prn_stride {152917LL}; // stride between particles //============================================================================== // PRN //============================================================================== // 64 bit implementation of the PCG-RXS-M-XS 64-bit state / 64-bit output -// geneator Adapted from: https://github.com/imneme/pcg-c, in particular -// https://github.com/imneme/pcg-c/blob/83252d9c23df9c82ecb42210afed61a7b42402d7/include/pcg_variants.h#L188-L192 +// geneator Adapted from: https://github.com/imneme/pcg-c // @techreport{oneill:pcg2014, // title = "PCG: A Family of Simple Fast Space-Efficient Statistically Good // Algorithms for Random Number Generation", author = "Melissa E. O'Neill", @@ -108,10 +68,9 @@ uint64_t init_seed(int64_t id, int offset) void init_particle_seeds(int64_t id, uint64_t* seeds) { - auto [multiplier, increment] = - future_seed_coefficients(static_cast(id) * prn_stride); for (int i = 0; i < N_STREAMS; i++) { - seeds[i] = multiplier * (master_seed + i) + increment; + seeds[i] = + future_seed(static_cast(id) * prn_stride, master_seed + i); } } @@ -130,9 +89,33 @@ void advance_prn_seed(int64_t n, uint64_t* seed) uint64_t future_seed(uint64_t n, uint64_t seed) { + // The algorithm here to determine the parameters used to skip ahead is + // described in F. Brown, "Random Number Generation with Arbitrary Stride," + // Trans. Am. Nucl. Soc. (Nov. 1994). This algorithm is able to skip ahead in + // O(log2(N)) operations instead of O(N). Basically, it computes parameters G + // and C which can then be used to find x_N = G*x_0 + C mod 2^M. + + // Initialize constants + uint64_t g {prn_mult}; + uint64_t c {prn_add}; + uint64_t g_new {1}; + uint64_t c_new {0}; + + while (n > 0) { + // Check if the least significant bit is 1. + if (n & 1) { + g_new *= g; + c_new = c_new * g + c; + } + c *= (g + 1); + g *= g; + + // Move bits right, dropping least significant bit. + n >>= 1; + } + // With G and C, we can now find the new seed. - auto [multiplier, increment] = future_seed_coefficients(n); - return multiplier * seed + increment; + return g_new * seed + c_new; } //============================================================================== @@ -149,14 +132,4 @@ extern "C" void openmc_set_seed(int64_t new_seed) master_seed = new_seed; } -extern "C" uint64_t openmc_get_stride() -{ - return prn_stride; -} - -extern "C" void openmc_set_stride(uint64_t new_stride) -{ - prn_stride = new_stride; -} - } // namespace openmc diff --git a/src/random_ray/flat_source_domain.cpp b/src/random_ray/flat_source_domain.cpp index 83128fdaa..7f5d76943 100644 --- a/src/random_ray/flat_source_domain.cpp +++ b/src/random_ray/flat_source_domain.cpp @@ -1,8 +1,6 @@ #include "openmc/random_ray/flat_source_domain.h" #include "openmc/cell.h" -#include "openmc/constants.h" -#include "openmc/eigenvalue.h" #include "openmc/geometry.h" #include "openmc/material.h" #include "openmc/message_passing.h" @@ -15,10 +13,8 @@ #include "openmc/tallies/tally.h" #include "openmc/tallies/tally_scoring.h" #include "openmc/timer.h" -#include "openmc/weight_windows.h" #include -#include namespace openmc { @@ -26,49 +22,73 @@ namespace openmc { // FlatSourceDomain implementation //============================================================================== -// Static Variable Declarations -RandomRayVolumeEstimator FlatSourceDomain::volume_estimator_ { - RandomRayVolumeEstimator::HYBRID}; -bool FlatSourceDomain::volume_normalized_flux_tallies_ {false}; -bool FlatSourceDomain::adjoint_requested_ {false}; -RandomRaySolve FlatSourceDomain::solve_ {RandomRaySolve::FORWARD}; -bool FlatSourceDomain::fw_cadis_local_ {false}; -double FlatSourceDomain::diagonal_stabilization_rho_ {1.0}; -std::unordered_map>> - FlatSourceDomain::mesh_domain_map_; -std::vector FlatSourceDomain::fw_cadis_local_targets_; - FlatSourceDomain::FlatSourceDomain() : negroups_(data::mg.num_energy_groups_) { // Count the number of source regions, compute the cell offset // indices, and store the material type The reason for the offsets is that // some cell types may not have material fills, and therefore do not // produce FSRs. Thus, we cannot index into the global arrays directly - int base_source_regions = 0; for (const auto& c : model::cells) { if (c->type_ != Fill::MATERIAL) { source_region_offsets_.push_back(-1); } else { - source_region_offsets_.push_back(base_source_regions); - base_source_regions += c->n_instances(); + source_region_offsets_.push_back(n_source_regions_); + n_source_regions_ += c->n_instances_; + n_source_elements_ += c->n_instances_ * negroups_; } } - // Initialize source regions. - bool is_linear = RandomRay::source_shape_ != RandomRaySourceShape::FLAT; - source_regions_ = SourceRegionContainer(negroups_, is_linear); + // Initialize cell-wise arrays + lock_.resize(n_source_regions_); + material_.resize(n_source_regions_); + position_recorded_.assign(n_source_regions_, 0); + position_.resize(n_source_regions_); + volume_.assign(n_source_regions_, 0.0); + volume_t_.assign(n_source_regions_, 0.0); + was_hit_.assign(n_source_regions_, 0); + + // Initialize element-wise arrays + scalar_flux_new_.assign(n_source_elements_, 0.0); + scalar_flux_final_.assign(n_source_elements_, 0.0); + source_.resize(n_source_elements_); + external_source_.assign(n_source_elements_, 0.0); + tally_task_.resize(n_source_elements_); + volume_task_.resize(n_source_regions_); + + if (settings::run_mode == RunMode::EIGENVALUE) { + // If in eigenvalue mode, set starting flux to guess of unity + scalar_flux_old_.assign(n_source_elements_, 1.0); + } else { + // If in fixed source mode, set starting flux to guess of zero + scalar_flux_old_.assign(n_source_elements_, 0.0); + } + + // Initialize material array + int64_t source_region_id = 0; + for (int i = 0; i < model::cells.size(); i++) { + Cell& cell = *model::cells[i]; + if (cell.type_ == Fill::MATERIAL) { + for (int j = 0; j < cell.n_instances_; j++) { + material_[source_region_id++] = cell.material(j); + } + } + } + + // Sanity check + if (source_region_id != n_source_regions_) { + fatal_error("Unexpected number of source regions"); + } // Initialize tally volumes - if (volume_normalized_flux_tallies_) { - tally_volumes_.resize(model::tallies.size()); - for (int i = 0; i < model::tallies.size(); i++) { - // Get the shape of the 3D result tensor - auto shape = model::tallies[i]->results().shape(); + tally_volumes_.resize(model::tallies.size()); + for (int i = 0; i < model::tallies.size(); i++) { + // Get the shape of the 3D result tensor + auto shape = model::tallies[i]->results().shape(); - // Create a new 2D tensor with the same size as the first - // two dimensions of the 3D tensor - tally_volumes_[i] = tensor::Tensor({shape[0], shape[1]}); - } + // Create a new 2D tensor with the same size as the first + // two dimensions of the 3D tensor + tally_volumes_[i] = + xt::xtensor::from_shape({shape[0], shape[1]}); } // Compute simulation domain volume based on ray source @@ -81,84 +101,86 @@ FlatSourceDomain::FlatSourceDomain() : negroups_(data::mg.num_energy_groups_) void FlatSourceDomain::batch_reset() { -// Reset scalar fluxes and iteration volume tallies to zero -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - source_regions_.volume(sr) = 0.0; - source_regions_.volume_sq(sr) = 0.0; - } - -#pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - source_regions_.scalar_flux_new(se) = 0.0; - } + // Reset scalar fluxes, iteration volume tallies, and region hit flags to + // zero + parallel_fill(scalar_flux_new_, 0.0f); + parallel_fill(volume_, 0.0); + parallel_fill(was_hit_, 0); } void FlatSourceDomain::accumulate_iteration_flux() { #pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - source_regions_.scalar_flux_final(se) += - source_regions_.scalar_flux_new(se); - } -} - -void FlatSourceDomain::update_single_neutron_source(SourceRegionHandle& srh) -{ - // Reset all source regions to zero (important for void regions) - for (int g = 0; g < negroups_; g++) { - srh.source(g) = 0.0; - } - - // Add scattering + fission source - int material = srh.material(); - int temp = srh.temperature_idx(); - double density_mult = srh.density_mult(); - if (material != MATERIAL_VOID) { - double inverse_k_eff = 1.0 / k_eff_; - const int material_offset = (material * ntemperature_ + temp) * negroups_; - const int scatter_offset = - (material * ntemperature_ + temp) * negroups_ * negroups_; - for (int g_out = 0; g_out < negroups_; g_out++) { - double sigma_t = sigma_t_[material_offset + g_out] * density_mult; - double scatter_source = 0.0; - double fission_source = 0.0; - - for (int g_in = 0; g_in < negroups_; g_in++) { - double scalar_flux = srh.scalar_flux_old(g_in); - double sigma_s = - sigma_s_[scatter_offset + g_out * negroups_ + g_in] * density_mult; - double nu_sigma_f = nu_sigma_f_[material_offset + g_in] * density_mult; - double chi = chi_[material_offset + g_out]; - - scatter_source += sigma_s * scalar_flux; - if (settings::create_fission_neutrons) { - fission_source += nu_sigma_f * scalar_flux * chi; - } - } - srh.source(g_out) = - (scatter_source + fission_source * inverse_k_eff) / sigma_t; - } - } - - // Add external source if in fixed source mode - if (settings::run_mode == RunMode::FIXED_SOURCE) { - for (int g = 0; g < negroups_; g++) { - srh.source(g) += srh.external_source(g); - } + for (int64_t se = 0; se < n_source_elements_; se++) { + scalar_flux_final_[se] += scalar_flux_new_[se]; } } // Compute new estimate of scattering + fission sources in each source region // based on the flux estimate from the previous iteration. -void FlatSourceDomain::update_all_neutron_sources() +void FlatSourceDomain::update_neutron_source(double k_eff) { simulation::time_update_src.start(); + double inverse_k_eff = 1.0 / k_eff; + + // Temperature and angle indices, if using multiple temperature + // data sets and/or anisotropic data sets. + // TODO: Currently assumes we are only using single temp/single angle data. + const int t = 0; + const int a = 0; + + // Add scattering source #pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - SourceRegionHandle srh = source_regions_.get_source_region_handle(sr); - update_single_neutron_source(srh); + for (int sr = 0; sr < n_source_regions_; sr++) { + int material = material_[sr]; + + for (int e_out = 0; e_out < negroups_; e_out++) { + float sigma_t = data::mg.macro_xs_[material].get_xs( + MgxsType::TOTAL, e_out, nullptr, nullptr, nullptr, t, a); + float scatter_source = 0.0f; + + for (int e_in = 0; e_in < negroups_; e_in++) { + float scalar_flux = scalar_flux_old_[sr * negroups_ + e_in]; + + float sigma_s = data::mg.macro_xs_[material].get_xs( + MgxsType::NU_SCATTER, e_in, &e_out, nullptr, nullptr, t, a); + scatter_source += sigma_s * scalar_flux; + } + + source_[sr * negroups_ + e_out] = scatter_source / sigma_t; + } + } + + if (settings::run_mode == RunMode::EIGENVALUE) { + // Add fission source if in eigenvalue mode +#pragma omp parallel for + for (int sr = 0; sr < n_source_regions_; sr++) { + int material = material_[sr]; + + for (int e_out = 0; e_out < negroups_; e_out++) { + float sigma_t = data::mg.macro_xs_[material].get_xs( + MgxsType::TOTAL, e_out, nullptr, nullptr, nullptr, t, a); + float fission_source = 0.0f; + + for (int e_in = 0; e_in < negroups_; e_in++) { + float scalar_flux = scalar_flux_old_[sr * negroups_ + e_in]; + float nu_sigma_f = data::mg.macro_xs_[material].get_xs( + MgxsType::NU_FISSION, e_in, nullptr, nullptr, nullptr, t, a); + float chi = data::mg.macro_xs_[material].get_xs( + MgxsType::CHI_PROMPT, e_in, &e_out, nullptr, nullptr, t, a); + fission_source += nu_sigma_f * scalar_flux * chi; + } + source_[sr * negroups_ + e_out] += + fission_source * inverse_k_eff / sigma_t; + } + } + } else { +// Add external source if in fixed source mode +#pragma omp parallel for + for (int se = 0; se < n_source_elements_; se++) { + source_[se] += external_source_[se]; + } } simulation::time_update_src.stop(); @@ -168,145 +190,72 @@ void FlatSourceDomain::update_all_neutron_sources() void FlatSourceDomain::normalize_scalar_flux_and_volumes( double total_active_distance_per_iteration) { - double normalization_factor = 1.0 / total_active_distance_per_iteration; + float normalization_factor = 1.0 / total_active_distance_per_iteration; double volume_normalization_factor = 1.0 / (total_active_distance_per_iteration * simulation::current_batch); -// Normalize scalar flux to total distance travelled by all rays this -// iteration +// Normalize scalar flux to total distance travelled by all rays this iteration #pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - source_regions_.scalar_flux_new(se) *= normalization_factor; + for (int64_t e = 0; e < scalar_flux_new_.size(); e++) { + scalar_flux_new_[e] *= normalization_factor; } // Accumulate cell-wise ray length tallies collected this iteration, then // update the simulation-averaged cell-wise volume estimates #pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - source_regions_.volume_t(sr) += source_regions_.volume(sr); - source_regions_.volume_sq_t(sr) += source_regions_.volume_sq(sr); - source_regions_.volume_naive(sr) = - source_regions_.volume(sr) * normalization_factor; - source_regions_.volume_sq(sr) = - source_regions_.volume_sq_t(sr) / source_regions_.volume_t(sr); - source_regions_.volume(sr) = - source_regions_.volume_t(sr) * volume_normalization_factor; + for (int64_t sr = 0; sr < n_source_regions_; sr++) { + volume_t_[sr] += volume_[sr]; + volume_[sr] = volume_t_[sr] * volume_normalization_factor; } } -void FlatSourceDomain::set_flux_to_flux_plus_source( - int64_t sr, double volume, int g) -{ - int material = source_regions_.material(sr); - int temp = source_regions_.temperature_idx(sr); - if (material == MATERIAL_VOID) { - source_regions_.scalar_flux_new(sr, g) /= volume; - if (settings::run_mode == RunMode::FIXED_SOURCE) { - source_regions_.scalar_flux_new(sr, g) += - 0.5f * source_regions_.external_source(sr, g) * - source_regions_.volume_sq(sr); - } - } else { - double sigma_t = - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - source_regions_.density_mult(sr); - source_regions_.scalar_flux_new(sr, g) /= (sigma_t * volume); - source_regions_.scalar_flux_new(sr, g) += source_regions_.source(sr, g); - } -} - -void FlatSourceDomain::set_flux_to_old_flux(int64_t sr, int g) -{ - source_regions_.scalar_flux_new(sr, g) = - source_regions_.scalar_flux_old(sr, g); -} - -void FlatSourceDomain::set_flux_to_source(int64_t sr, int g) -{ - source_regions_.scalar_flux_new(sr, g) = source_regions_.source(sr, g); -} - // Combine transport flux contributions and flat source contributions from the // previous iteration to generate this iteration's estimate of scalar flux. int64_t FlatSourceDomain::add_source_to_scalar_flux() { int64_t n_hits = 0; - double inverse_batch = 1.0 / simulation::current_batch; + + // Temperature and angle indices, if using multiple temperature + // data sets and/or anisotropic data sets. + // TODO: Currently assumes we are only using single temp/single + // angle data. + const int t = 0; + const int a = 0; #pragma omp parallel for reduction(+ : n_hits) - for (int64_t sr = 0; sr < n_source_regions(); sr++) { + for (int sr = 0; sr < n_source_regions_; sr++) { - double volume_simulation_avg = source_regions_.volume(sr); - double volume_iteration = source_regions_.volume_naive(sr); - - // Increment the number of hits if cell was hit this iteration - if (volume_iteration) { + // Check if this cell was hit this iteration + int was_cell_hit = was_hit_[sr]; + if (was_cell_hit) { n_hits++; } - // Set the SR to small status if its expected number of hits - // per iteration is less than 1.5 - if (source_regions_.n_hits(sr) * inverse_batch < MIN_HITS_PER_BATCH) { - source_regions_.is_small(sr) = 1; - } else { - source_regions_.is_small(sr) = 0; - } - - // The volume treatment depends on the volume estimator type - // and whether or not an external source is present in the cell. - double volume; - switch (volume_estimator_) { - case RandomRayVolumeEstimator::NAIVE: - volume = volume_iteration; - break; - case RandomRayVolumeEstimator::SIMULATION_AVERAGED: - volume = volume_simulation_avg; - break; - case RandomRayVolumeEstimator::HYBRID: - if (source_regions_.external_source_present(sr) || - source_regions_.is_small(sr)) { - volume = volume_iteration; - } else { - volume = volume_simulation_avg; - } - break; - default: - fatal_error("Invalid volume estimator type"); - } - + double volume = volume_[sr]; + int material = material_[sr]; for (int g = 0; g < negroups_; g++) { + int64_t idx = (sr * negroups_) + g; + // There are three scenarios we need to consider: - if (volume_iteration > 0.0) { + if (was_cell_hit) { // 1. If the FSR was hit this iteration, then the new flux is equal to // the flat source from the previous iteration plus the contributions // from rays passing through the source region (computed during the // transport sweep) - set_flux_to_flux_plus_source(sr, volume, g); - } else if (volume_simulation_avg > 0.0) { + float sigma_t = data::mg.macro_xs_[material].get_xs( + MgxsType::TOTAL, g, nullptr, nullptr, nullptr, t, a); + scalar_flux_new_[idx] /= (sigma_t * volume); + scalar_flux_new_[idx] += source_[idx]; + } else if (volume > 0.0) { // 2. If the FSR was not hit this iteration, but has been hit some - // previous iteration, then we need to make a choice about what - // to do. Naively we will usually want to set the flux to be equal - // to the reduced source. However, in fixed source problems where - // there is a strong external source present in the cell, and where - // the cell has a very low cross section, this approximation will - // cause a huge upward bias in the flux estimate of the cell (in these - // conditions, the flux estimate can be orders of magnitude too large). - // Thus, to avoid this bias, if any external source is present - // in the cell we will use the previous iteration's flux estimate. This - // injects a small degree of correlation into the simulation, but this - // is going to be trivial when the miss rate is a few percent or less. - if (source_regions_.external_source_present(sr)) { - set_flux_to_old_flux(sr, g); - } else { - set_flux_to_source(sr, g); - } - } - // Halt if NaN implosion is detected - if (!std::isfinite(source_regions_.scalar_flux_new(sr, g))) { - fatal_error("A source region scalar flux is not finite. " - "This indicates a numerical instability in the " - "simulation. Consider increasing ray density or adjusting " - "the source region mesh."); + // previous iteration, then we simply set the new scalar flux to be + // equal to the contribution from the flat source alone. + scalar_flux_new_[idx] = source_[idx]; + } else { + // If the FSR was not hit this iteration, and it has never been hit in + // any iteration (i.e., volume is zero), then we want to set this to 0 + // to avoid dividing anything by a zero volume. + scalar_flux_new_[idx] = 0.0f; } } } @@ -317,76 +266,47 @@ int64_t FlatSourceDomain::add_source_to_scalar_flux() // Generates new estimate of k_eff based on the differences between this // iteration's estimate of the scalar flux and the last iteration's estimate. -void FlatSourceDomain::compute_k_eff() +double FlatSourceDomain::compute_k_eff(double k_eff_old) const { double fission_rate_old = 0; double fission_rate_new = 0; - // Vector for gathering fission source terms for Shannon entropy calculation - vector p(n_source_regions(), 0.0f); + // Temperature and angle indices, if using multiple temperature + // data sets and/or anisotropic data sets. + // TODO: Currently assumes we are only using single temp/single + // angle data. + const int t = 0; + const int a = 0; #pragma omp parallel for reduction(+ : fission_rate_old, fission_rate_new) - for (int64_t sr = 0; sr < n_source_regions(); sr++) { + for (int sr = 0; sr < n_source_regions_; sr++) { // If simulation averaged volume is zero, don't include this cell - double volume = source_regions_.volume(sr); + double volume = volume_[sr]; if (volume == 0.0) { continue; } - int material = source_regions_.material(sr); - int temp = source_regions_.temperature_idx(sr); - if (material == MATERIAL_VOID) { - continue; - } + int material = material_[sr]; double sr_fission_source_old = 0; double sr_fission_source_new = 0; for (int g = 0; g < negroups_; g++) { - double nu_sigma_f = - nu_sigma_f_[(material * ntemperature_ + temp) * negroups_ + g] * - source_regions_.density_mult(sr); - sr_fission_source_old += - nu_sigma_f * source_regions_.scalar_flux_old(sr, g); - sr_fission_source_new += - nu_sigma_f * source_regions_.scalar_flux_new(sr, g); + int64_t idx = (sr * negroups_) + g; + double nu_sigma_f = data::mg.macro_xs_[material].get_xs( + MgxsType::NU_FISSION, g, nullptr, nullptr, nullptr, t, a); + sr_fission_source_old += nu_sigma_f * scalar_flux_old_[idx]; + sr_fission_source_new += nu_sigma_f * scalar_flux_new_[idx]; } - // Compute total fission rates in FSR - sr_fission_source_old *= volume; - sr_fission_source_new *= volume; - - // Accumulate totals - fission_rate_old += sr_fission_source_old; - fission_rate_new += sr_fission_source_new; - - // Store total fission rate in the FSR for Shannon calculation - p[sr] = sr_fission_source_new; + fission_rate_old += sr_fission_source_old * volume; + fission_rate_new += sr_fission_source_new * volume; } - double k_eff_new = k_eff_ * (fission_rate_new / fission_rate_old); + double k_eff_new = k_eff_old * (fission_rate_new / fission_rate_old); - double H = 0.0; - // defining an inverse sum for better performance - double inverse_sum = 1 / fission_rate_new; - -#pragma omp parallel for reduction(+ : H) - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - // Only if FSR has non-negative and non-zero fission source - if (p[sr] > 0.0f) { - // Normalize to total weight of bank sites. p_i for better performance - float p_i = p[sr] * inverse_sum; - // Sum values to obtain Shannon entropy. - H -= p_i * std::log2(p_i); - } - } - - // Adds entropy value to shared entropy vector in openmc namespace. - simulation::entropy.push_back(H); - - fission_rate_ = fission_rate_new; - k_eff_ = k_eff_new; + return k_eff_new; } // This function is responsible for generating a mapping between random @@ -422,12 +342,7 @@ void FlatSourceDomain::compute_k_eff() // be passed back to the caller to alert them that this function doesn't // need to be called for the remainder of the simulation. -// It takes as an argument the starting index in the source region array, -// and it will operate from that index until the end of the array. This -// is useful as it can be called for both explicit user source regions or -// when a source region mesh is overlaid. - -void FlatSourceDomain::convert_source_regions_to_tallies(int64_t start_sr_id) +void FlatSourceDomain::convert_source_regions_to_tallies() { openmc::simulation::time_tallies.start(); @@ -436,11 +351,11 @@ void FlatSourceDomain::convert_source_regions_to_tallies(int64_t start_sr_id) // Attempt to generate mapping for all source regions #pragma omp parallel for - for (int64_t sr = start_sr_id; sr < n_source_regions(); sr++) { + for (int sr = 0; sr < n_source_regions_; sr++) { // If this source region has not been hit by a ray yet, then // we aren't going to be able to map it, so skip it. - if (!source_regions_.position_recorded(sr)) { + if (!position_recorded_[sr]) { all_source_regions_mapped = false; continue; } @@ -449,9 +364,8 @@ void FlatSourceDomain::convert_source_regions_to_tallies(int64_t start_sr_id) // crossing through this source region is used to estabilish // the spatial location of the source region Particle p; - p.r() = source_regions_.position(sr); - p.r_last() = source_regions_.position(sr); - p.u() = {1.0, 0.0, 0.0}; + p.r() = position_[sr]; + p.r_last() = position_[sr]; bool found = exhaustive_find_cell(p); // Loop over energy groups (so as to support energy filters) @@ -467,14 +381,14 @@ void FlatSourceDomain::convert_source_regions_to_tallies(int64_t start_sr_id) // If this task has already been populated, we don't need to do // it again. - if (source_regions_.tally_task(sr, g).size() > 0) { + if (tally_task_[source_element].size() > 0) { continue; } // Loop over all active tallies. This logic is essentially identical // to what happens when scanning for applicable tallies during // MC transport. - for (int i_tally = 0; i_tally < model::tallies.size(); i_tally++) { + for (auto i_tally : model::active_tallies) { Tally& tally {*model::tallies[i_tally]}; // Initialize an iterator over valid filter bin combinations. @@ -491,16 +405,17 @@ void FlatSourceDomain::convert_source_regions_to_tallies(int64_t start_sr_id) auto filter_weight = filter_iter.weight_; // Loop over scores - for (int score = 0; score < tally.scores_.size(); score++) { - auto score_bin = tally.scores_[score]; + for (auto score_index = 0; score_index < tally.scores_.size(); + score_index++) { + auto score_bin = tally.scores_[score_index]; // If a valid tally, filter, and score combination has been found, // then add it to the list of tally tasks for this source element. - TallyTask task(i_tally, filter_index, score, score_bin); - source_regions_.tally_task(sr, g).push_back(task); + TallyTask task(i_tally, filter_index, score_index, score_bin); + tally_task_[source_element].push_back(task); // Also add this task to the list of volume tasks for this source // region. - source_regions_.volume_task(sr).insert(task); + volume_task_[sr].insert(task); } } } @@ -517,88 +432,13 @@ void FlatSourceDomain::convert_source_regions_to_tallies(int64_t start_sr_id) // Set the volume accumulators to zero for all tallies void FlatSourceDomain::reset_tally_volumes() { - if (volume_normalized_flux_tallies_) { #pragma omp parallel for - for (int i = 0; i < tally_volumes_.size(); i++) { - auto& tensor = tally_volumes_[i]; - tensor.fill(0.0); // Set all elements of the tensor to 0.0 - } + for (int i = 0; i < tally_volumes_.size(); i++) { + auto& tensor = tally_volumes_[i]; + tensor.fill(0.0); // Set all elements of the tensor to 0.0 } } -// In fixed source mode, due to the way that volumetric fixed sources are -// converted and applied as volumetric sources in one or more source regions, -// we need to perform an additional normalization step to ensure that the -// reported scalar fluxes are in units per source neutron. This allows for -// direct comparison of reported tallies to Monte Carlo flux results. -// This factor needs to be computed at each iteration, as it is based on the -// volume estimate of each FSR, which improves over the course of the -// simulation -double FlatSourceDomain::compute_fixed_source_normalization_factor() const -{ - // Eigenvalue mode normalization - if (settings::run_mode == RunMode::EIGENVALUE) { - // Normalize fluxes by total number of fission neutrons produced. This - // ensures consistent scaling of the eigenvector such that its magnitude is - // comparable to the eigenvector produced by the Monte Carlo solver. - // Multiplying by the eigenvalue is unintuitive, but it is necessary. - // If the eigenvalue is 1.2, per starting source neutron, you will - // generate 1.2 neutrons. Thus if we normalize to generating only ONE - // neutron in total for the whole domain, then we don't actually have enough - // flux to generate the required 1.2 neutrons. We only know the flux - // required to generate 1 neutron (which would have required less than one - // starting neutron). Thus, you have to scale the flux up by the eigenvalue - // such that 1.2 neutrons are generated, so as to be consistent with the - // bookkeeping in MC which is all done per starting source neutron (not per - // neutron produced). - return k_eff_ / (fission_rate_ * simulation_volume_); - } - - // If we are in adjoint mode of a fixed source problem, the external - // source is already normalized, such that all resulting fluxes are - // also normalized. - if (solve_ == RandomRaySolve::ADJOINT) { - return 1.0; - } - - // Fixed source mode normalization - - // Step 1 is to sum over all source regions and energy groups to get the - // total external source strength in the simulation. - double simulation_external_source_strength = 0.0; -#pragma omp parallel for reduction(+ : simulation_external_source_strength) - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - int material = source_regions_.material(sr); - int temp = source_regions_.temperature_idx(sr); - double volume = source_regions_.volume(sr) * simulation_volume_; - for (int g = 0; g < negroups_; g++) { - // For non-void regions, we store the external source pre-divided by - // sigma_t. We need to multiply non-void regions back up by sigma_t - // to get the total source strength in the expected units. - double sigma_t = 1.0; - if (material != MATERIAL_VOID) { - sigma_t = sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - source_regions_.density_mult(sr); - } - simulation_external_source_strength += - source_regions_.external_source(sr, g) * sigma_t * volume; - } - } - - // Step 2 is to determine the total user-specified external source strength - double user_external_source_strength = 0.0; - for (auto& ext_source : model::external_sources) { - user_external_source_strength += ext_source->strength(); - } - - // The correction factor is the ratio of the user-specified external source - // strength to the simulation external source strength. - double source_normalization_factor = - user_external_source_strength / simulation_external_source_strength; - - return source_normalization_factor; -} - // Tallying in random ray is not done directly during transport, rather, // it is done only once after each power iteration. This is made possible // by way of a mapping data structure that relates spatial source regions @@ -615,35 +455,36 @@ void FlatSourceDomain::random_ray_tally() // Reset our tally volumes to zero reset_tally_volumes(); - double source_normalization_factor = - compute_fixed_source_normalization_factor(); + // Temperature and angle indices, if using multiple temperature + // data sets and/or anisotropic data sets. + // TODO: Currently assumes we are only using single temp/single + // angle data. + const int t = 0; + const int a = 0; // We loop over all source regions and energy groups. For each // element, we check if there are any scores needed and apply // them. #pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { + for (int sr = 0; sr < n_source_regions_; sr++) { // The fsr.volume_ is the unitless fractional simulation averaged volume // (i.e., it is the FSR's fraction of the overall simulation volume). The - // simulation_volume_ is the total 3D physical volume in cm^3 of the - // entire global simulation domain (as defined by the ray source box). - // Thus, the FSR's true 3D spatial volume in cm^3 is found by multiplying - // its fraction of the total volume by the total volume. Not important in - // eigenvalue solves, but useful in fixed source solves for returning the - // flux shape with a magnitude that makes sense relative to the fixed - // source strength. - double volume = source_regions_.volume(sr) * simulation_volume_; + // simulation_volume_ is the total 3D physical volume in cm^3 of the entire + // global simulation domain (as defined by the ray source box). Thus, the + // FSR's true 3D spatial volume in cm^3 is found by multiplying its fraction + // of the total volume by the total volume. Not important in eigenvalue + // solves, but useful in fixed source solves for returning the flux shape + // with a magnitude that makes sense relative to the fixed source strength. + double volume = volume_[sr] * simulation_volume_; - double material = source_regions_.material(sr); - int temp = source_regions_.temperature_idx(sr); - double density_mult = source_regions_.density_mult(sr); + double material = material_[sr]; for (int g = 0; g < negroups_; g++) { - double flux = - source_regions_.scalar_flux_new(sr, g) * source_normalization_factor; + int idx = sr * negroups_ + g; + double flux = scalar_flux_new_[idx]; // Determine numerical score value - for (auto& task : source_regions_.tally_task(sr, g)) { - double score = 0.0; + for (auto& task : tally_task_[idx]) { + double score; switch (task.score_type) { case SCORE_FLUX: @@ -651,67 +492,50 @@ void FlatSourceDomain::random_ray_tally() break; case SCORE_TOTAL: - if (material != MATERIAL_VOID) { - score = - flux * volume * - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - density_mult; - } + score = flux * volume * + data::mg.macro_xs_[material].get_xs( + MgxsType::TOTAL, g, NULL, NULL, NULL, t, a); break; case SCORE_FISSION: - if (material != MATERIAL_VOID) { - score = - flux * volume * - sigma_f_[(material * ntemperature_ + temp) * negroups_ + g] * - density_mult; - } + score = flux * volume * + data::mg.macro_xs_[material].get_xs( + MgxsType::FISSION, g, NULL, NULL, NULL, t, a); break; case SCORE_NU_FISSION: - if (material != MATERIAL_VOID) { - score = - flux * volume * - nu_sigma_f_[(material * ntemperature_ + temp) * negroups_ + g] * - density_mult; - } + score = flux * volume * + data::mg.macro_xs_[material].get_xs( + MgxsType::NU_FISSION, g, NULL, NULL, NULL, t, a); break; case SCORE_EVENTS: score = 1.0; break; - case SCORE_KAPPA_FISSION: - score = - flux * volume * - kappa_fission_[(material * ntemperature_ + temp) * negroups_ + g] * - density_mult; - break; - default: fatal_error("Invalid score specified in tallies.xml. Only flux, " - "total, fission, nu-fission, kappa-fission, and events " - "are supported in random ray mode."); + "total, fission, nu-fission, and events are supported in " + "random ray mode."); break; } + // Apply score to the appropriate tally bin Tally& tally {*model::tallies[task.tally_idx]}; #pragma omp atomic tally.results_(task.filter_idx, task.score_idx, TallyResult::VALUE) += score; - } - } + } // end tally task loop + } // end energy group loop // For flux tallies, the total volume of the spatial region is needed // for normalizing the flux. We store this volume in a separate tensor. // We only contribute to each volume tally bin once per FSR. - if (volume_normalized_flux_tallies_) { - for (const auto& task : source_regions_.volume_task(sr)) { - if (task.score_type == SCORE_FLUX) { + for (const auto& task : volume_task_[sr]) { + if (task.score_type == SCORE_FLUX) { #pragma omp atomic - tally_volumes_[task.tally_idx](task.filter_idx, task.score_idx) += - volume; - } + tally_volumes_[task.tally_idx](task.filter_idx, task.score_idx) += + volume; } } } // end FSR loop @@ -721,18 +545,16 @@ void FlatSourceDomain::random_ray_tally() // and then scores. For each score, we check the tally data structure to // see what index that score corresponds to. If that score is a flux score, // then we divide it by volume. - if (volume_normalized_flux_tallies_) { - for (int i = 0; i < model::tallies.size(); i++) { - Tally& tally {*model::tallies[i]}; + for (int i = 0; i < model::tallies.size(); i++) { + Tally& tally {*model::tallies[i]}; #pragma omp parallel for - for (int64_t bin = 0; bin < tally.n_filter_bins(); bin++) { - for (int score_idx = 0; score_idx < tally.n_scores(); score_idx++) { - auto score_type = tally.scores_[score_idx]; - if (score_type == SCORE_FLUX) { - double vol = tally_volumes_[i](bin, score_idx); - if (vol > 0.0) { - tally.results_(bin, score_idx, TallyResult::VALUE) /= vol; - } + for (int bin = 0; bin < tally.n_filter_bins(); bin++) { + for (int score_idx = 0; score_idx < tally.n_scores(); score_idx++) { + auto score_type = tally.scores_[score_idx]; + if (score_type == SCORE_FLUX) { + double vol = tally_volumes_[i](bin, score_idx); + if (vol > 0.0) { + tally.results_(bin, score_idx, TallyResult::VALUE) /= vol; } } } @@ -742,11 +564,97 @@ void FlatSourceDomain::random_ray_tally() openmc::simulation::time_tallies.stop(); } -double FlatSourceDomain::evaluate_flux_at_point( - Position r, int64_t sr, int g) const +void FlatSourceDomain::all_reduce_replicated_source_regions() { - return source_regions_.scalar_flux_final(sr, g) / - (settings::n_batches - settings::n_inactive); +#ifdef OPENMC_MPI + + // If we only have 1 MPI rank, no need + // to reduce anything. + if (mpi::n_procs <= 1) + return; + + simulation::time_bank_sendrecv.start(); + + // The "position_recorded" variable needs to be allreduced (and maxed), + // as whether or not a cell was hit will affect some decisions in how the + // source is calculated in the next iteration so as to avoid dividing + // by zero. We take the max rather than the sum as the hit values are + // expected to be zero or 1. + MPI_Allreduce(MPI_IN_PLACE, position_recorded_.data(), n_source_regions_, + MPI_INT, MPI_MAX, mpi::intracomm); + + // The position variable is more complicated to reduce than the others, + // as we do not want the sum of all positions in each cell, rather, we + // want to just pick any single valid position. Thus, we perform a gather + // and then pick the first valid position we find for all source regions + // that have had a position recorded. This operation does not need to + // be broadcast back to other ranks, as this value is only used for the + // tally conversion operation, which is only performed on the master rank. + // While this is expensive, it only needs to be done for active batches, + // and only if we have not mapped all the tallies yet. Once tallies are + // fully mapped, then the position vector is fully populated, so this + // operation can be skipped. + + // First, we broadcast the fully mapped tally status variable so that + // all ranks are on the same page + int mapped_all_tallies_i = static_cast(mapped_all_tallies_); + MPI_Bcast(&mapped_all_tallies_i, 1, MPI_INT, 0, mpi::intracomm); + + // Then, we perform the gather of position data, if needed + if (simulation::current_batch > settings::n_inactive && + !mapped_all_tallies_i) { + + // Master rank will gather results and pick valid positions + if (mpi::master) { + // Initialize temporary vector for receiving positions + vector> all_position; + all_position.resize(mpi::n_procs); + for (int i = 0; i < mpi::n_procs; i++) { + all_position[i].resize(n_source_regions_); + } + + // Copy master rank data into gathered vector for convenience + all_position[0] = position_; + + // Receive all data into gather vector + for (int i = 1; i < mpi::n_procs; i++) { + MPI_Recv(all_position[i].data(), n_source_regions_ * 3, MPI_DOUBLE, i, + 0, mpi::intracomm, MPI_STATUS_IGNORE); + } + + // Scan through gathered data and pick first valid cell posiiton + for (int sr = 0; sr < n_source_regions_; sr++) { + if (position_recorded_[sr] == 1) { + for (int i = 0; i < mpi::n_procs; i++) { + if (all_position[i][sr].x != 0.0 || all_position[i][sr].y != 0.0 || + all_position[i][sr].z != 0.0) { + position_[sr] = all_position[i][sr]; + break; + } + } + } + } + } else { + // Other ranks just send in their data + MPI_Send(position_.data(), n_source_regions_ * 3, MPI_DOUBLE, 0, 0, + mpi::intracomm); + } + } + + // For the rest of the source region data, we simply perform an all reduce, + // as these values will be needed on all ranks for transport during the + // next iteration. + MPI_Allreduce(MPI_IN_PLACE, volume_.data(), n_source_regions_, MPI_DOUBLE, + MPI_SUM, mpi::intracomm); + + MPI_Allreduce(MPI_IN_PLACE, was_hit_.data(), n_source_regions_, MPI_INT, + MPI_SUM, mpi::intracomm); + + MPI_Allreduce(MPI_IN_PLACE, scalar_flux_new_.data(), n_source_elements_, + MPI_FLOAT, MPI_SUM, mpi::intracomm); + + simulation::time_bank_sendrecv.stop(); +#endif } // Outputs all basic material, FSR ID, multigroup flux, and @@ -767,21 +675,21 @@ void FlatSourceDomain::output_to_vtk() const print_plot(); // Outer loop over plots - for (int plt = 0; plt < model::plots.size(); plt++) { + for (int p = 0; p < model::plots.size(); p++) { // Get handle to OpenMC plot object and extract params - Plot* openmc_plot = dynamic_cast(model::plots[plt].get()); + Plot* openmc_plot = dynamic_cast(model::plots[p].get()); // Random ray plots only support voxel plots if (!openmc_plot) { warning(fmt::format("Plot {} is invalid plot type -- only voxel plotting " "is allowed in random ray mode.", - plt)); + p)); continue; } else if (openmc_plot->type_ != Plot::PlotType::voxel) { warning(fmt::format("Plot {} is invalid plot type -- only voxel plotting " "is allowed in random ray mode.", - plt)); + p)); continue; } @@ -796,12 +704,6 @@ void FlatSourceDomain::output_to_vtk() const double z_delta = width.z / Nz; std::string filename = openmc_plot->path_plot(); - // Tag plots written during the forward solve of an adjoint run - if (solve_ == RandomRaySolve::FORWARD_FOR_ADJOINT) { - auto dot = filename.find_last_of('.'); - filename = filename.substr(0, dot) + ".forward" + filename.substr(dot); - } - // Perform sanity checks on file size uint64_t bytes = Nx * Ny * Nz * (negroups_ + 1 + 1 + 1) * sizeof(float); write_message(5, "Processing plot {}: {}... (Estimated size is {} MB)", @@ -815,10 +717,8 @@ void FlatSourceDomain::output_to_vtk() const // Relate voxel spatial locations to random ray source regions vector voxel_indices(Nx * Ny * Nz); - vector voxel_positions(Nx * Ny * Nz); - vector weight_windows(Nx * Ny * Nz); - float min_weight = 1e20; -#pragma omp parallel for collapse(3) reduction(min : min_weight) + +#pragma omp parallel for collapse(3) for (int z = 0; z < Nz; z++) { for (int y = 0; y < Ny; y++) { for (int x = 0; x < Nx; x++) { @@ -828,44 +728,15 @@ void FlatSourceDomain::output_to_vtk() const sample.x = ll.x + x_delta / 2.0 + x * x_delta; Particle p; p.r() = sample; - p.r_last() = sample; - p.E() = 1.0; - p.E_last() = 1.0; - p.u() = {1.0, 0.0, 0.0}; - bool found = exhaustive_find_cell(p); - if (!found) { - voxel_indices[z * Ny * Nx + y * Nx + x] = -1; - voxel_positions[z * Ny * Nx + y * Nx + x] = sample; - weight_windows[z * Ny * Nx + y * Nx + x] = 0.0; - continue; - } - - SourceRegionKey sr_key = lookup_source_region_key(p); - int64_t sr = -1; - auto it = source_region_map_.find(sr_key); - if (it != source_region_map_.end()) { - sr = it->second; - } - - voxel_indices[z * Ny * Nx + y * Nx + x] = sr; - voxel_positions[z * Ny * Nx + y * Nx + x] = sample; - - if (variance_reduction::weight_windows.size() == 1) { - auto [ww_found, ww] = - variance_reduction::weight_windows[0]->get_weight_window(p); - float weight = ww.lower_weight; - weight_windows[z * Ny * Nx + y * Nx + x] = weight; - if (weight < min_weight) - min_weight = weight; - } + int i_cell = p.lowest_coord().cell; + int64_t source_region_idx = + source_region_offsets_[i_cell] + p.cell_instance(); + voxel_indices[z * Ny * Nx + y * Nx + x] = source_region_idx; } } } - double source_normalization_factor = - compute_fixed_source_normalization_factor(); - // Open file for writing std::FILE* plot = std::fopen(filename.c_str(), "wb"); @@ -875,51 +746,23 @@ void FlatSourceDomain::output_to_vtk() const std::fprintf(plot, "BINARY\n"); std::fprintf(plot, "DATASET STRUCTURED_POINTS\n"); std::fprintf(plot, "DIMENSIONS %d %d %d\n", Nx, Ny, Nz); - std::fprintf(plot, "ORIGIN %lf %lf %lf\n", ll.x, ll.y, ll.z); + std::fprintf(plot, "ORIGIN 0 0 0\n"); std::fprintf(plot, "SPACING %lf %lf %lf\n", x_delta, y_delta, z_delta); std::fprintf(plot, "POINT_DATA %d\n", Nx * Ny * Nz); - int64_t num_neg = 0; - int64_t num_samples = 0; - float min_flux = 0.0; - float max_flux = -1.0e20; // Plot multigroup flux data for (int g = 0; g < negroups_; g++) { std::fprintf(plot, "SCALARS flux_group_%d float\n", g); std::fprintf(plot, "LOOKUP_TABLE default\n"); - for (int i = 0; i < Nx * Ny * Nz; i++) { - int64_t fsr = voxel_indices[i]; + for (int fsr : voxel_indices) { int64_t source_element = fsr * negroups_ + g; - float flux = 0; - if (fsr >= 0) { - flux = evaluate_flux_at_point(voxel_positions[i], fsr, g); - if (flux < 0.0) - flux = FlatSourceDomain::evaluate_flux_at_point( - voxel_positions[i], fsr, g); - } - if (flux < 0.0) { - num_neg++; - if (flux < min_flux) { - min_flux = flux; - } - } - if (flux > max_flux) - max_flux = flux; - num_samples++; + float flux = scalar_flux_final_[source_element]; + flux /= (settings::n_batches - settings::n_inactive); flux = convert_to_big_endian(flux); std::fwrite(&flux, sizeof(float), 1, plot); } } - // Slightly negative fluxes can be normal when sampling corners of linear - // source regions. However, very common and high magnitude negative fluxes - // may indicate numerical instability. - if (num_neg > 0) { - warning(fmt::format("{} plot samples ({:.4f}%) contained negative fluxes " - "(minumum found = {:.2e} maximum_found = {:.2e})", - num_neg, (100.0 * num_neg) / num_samples, min_flux, max_flux)); - } - // Plot FSRs std::fprintf(plot, "SCALARS FSRs float\n"); std::fprintf(plot, "LOOKUP_TABLE default\n"); @@ -933,73 +776,27 @@ void FlatSourceDomain::output_to_vtk() const std::fprintf(plot, "SCALARS Materials int\n"); std::fprintf(plot, "LOOKUP_TABLE default\n"); for (int fsr : voxel_indices) { - int mat = -1; - if (fsr >= 0) - mat = source_regions_.material(fsr); + int mat = material_[fsr]; mat = convert_to_big_endian(mat); std::fwrite(&mat, sizeof(int), 1, plot); } // Plot fission source - if (settings::run_mode == RunMode::EIGENVALUE) { - std::fprintf(plot, "SCALARS total_fission_source float\n"); - std::fprintf(plot, "LOOKUP_TABLE default\n"); - for (int i = 0; i < Nx * Ny * Nz; i++) { - int64_t fsr = voxel_indices[i]; - float total_fission = 0.0; - if (fsr >= 0) { - int mat = source_regions_.material(fsr); - int temp = source_regions_.temperature_idx(fsr); - if (mat != MATERIAL_VOID) { - for (int g = 0; g < negroups_; g++) { - int64_t source_element = fsr * negroups_ + g; - float flux = evaluate_flux_at_point(voxel_positions[i], fsr, g); - double sigma_f = - sigma_f_[(mat * ntemperature_ + temp) * negroups_ + g] * - source_regions_.density_mult(fsr); - total_fission += sigma_f * flux; - } - } - } - total_fission = convert_to_big_endian(total_fission); - std::fwrite(&total_fission, sizeof(float), 1, plot); - } - } else { - std::fprintf(plot, "SCALARS external_source float\n"); - std::fprintf(plot, "LOOKUP_TABLE default\n"); - for (int i = 0; i < Nx * Ny * Nz; i++) { - int64_t fsr = voxel_indices[i]; - int mat = source_regions_.material(fsr); - int temp = source_regions_.temperature_idx(fsr); - float total_external = 0.0f; - if (fsr >= 0) { - for (int g = 0; g < negroups_; g++) { - // External sources are already divided by sigma_t, so we need to - // multiply it back to get the true external source. - double sigma_t = 1.0; - if (mat != MATERIAL_VOID) { - sigma_t = sigma_t_[(mat * ntemperature_ + temp) * negroups_ + g] * - source_regions_.density_mult(fsr); - } - total_external += source_regions_.external_source(fsr, g) * sigma_t; - } - } - total_external = convert_to_big_endian(total_external); - std::fwrite(&total_external, sizeof(float), 1, plot); - } - } - - // Plot weight window data - if (variance_reduction::weight_windows.size() == 1) { - std::fprintf(plot, "SCALARS weight_window_lower float\n"); - std::fprintf(plot, "LOOKUP_TABLE default\n"); - for (int i = 0; i < Nx * Ny * Nz; i++) { - float weight = weight_windows[i]; - if (weight == 0.0) - weight = min_weight; - weight = convert_to_big_endian(weight); - std::fwrite(&weight, sizeof(float), 1, plot); + std::fprintf(plot, "SCALARS total_fission_source float\n"); + std::fprintf(plot, "LOOKUP_TABLE default\n"); + for (int fsr : voxel_indices) { + float total_fission = 0.0; + int mat = material_[fsr]; + for (int g = 0; g < negroups_; g++) { + int64_t source_element = fsr * negroups_ + g; + float flux = scalar_flux_final_[source_element]; + flux /= (settings::n_batches - settings::n_inactive); + float Sigma_f = data::mg.macro_xs_[mat].get_xs( + MgxsType::FISSION, g, nullptr, nullptr, nullptr, 0, 0); + total_fission += Sigma_f * flux; } + total_fission = convert_to_big_endian(total_fission); + std::fwrite(&total_fission, sizeof(float), 1, plot); } std::fclose(plot); @@ -1007,28 +804,21 @@ void FlatSourceDomain::output_to_vtk() const } void FlatSourceDomain::apply_external_source_to_source_region( - int src_idx, SourceRegionHandle& srh) + Discrete* discrete, double strength_factor, int64_t source_region) { - auto s = - (solve_ == RandomRaySolve::ADJOINT && !model::adjoint_sources.empty()) - ? model::adjoint_sources[src_idx].get() - : model::external_sources[src_idx].get(); - auto is = dynamic_cast(s); - auto discrete = dynamic_cast(is->energy()); - double strength_factor = is->strength(); const auto& discrete_energies = discrete->x(); const auto& discrete_probs = discrete->prob(); - srh.external_source_present() = 1; - - for (int i = 0; i < discrete_energies.size(); i++) { - int g = data::mg.get_group_index(discrete_energies[i]); - srh.external_source(g) += discrete_probs[i] * strength_factor; + for (int e = 0; e < discrete_energies.size(); e++) { + int g = data::mg.get_group_index(discrete_energies[e]); + external_source_[source_region * negroups_ + g] += + discrete_probs[e] * strength_factor; } } void FlatSourceDomain::apply_external_source_to_cell_instances(int32_t i_cell, - int src_idx, int target_material_id, const vector& instances) + Discrete* discrete, double strength_factor, int target_material_id, + const vector& instances) { Cell& cell = *model::cells[i_cell]; @@ -1037,816 +827,106 @@ void FlatSourceDomain::apply_external_source_to_cell_instances(int32_t i_cell, for (int j : instances) { int cell_material_idx = cell.material(j); - int cell_material_id; - if (cell_material_idx == MATERIAL_VOID) { - cell_material_id = MATERIAL_VOID; - } else { - cell_material_id = model::materials[cell_material_idx]->id(); - } + int cell_material_id = model::materials[cell_material_idx]->id(); if (target_material_id == C_NONE || cell_material_id == target_material_id) { int64_t source_region = source_region_offsets_[i_cell] + j; - external_volumetric_source_map_[source_region].push_back(src_idx); + apply_external_source_to_source_region( + discrete, strength_factor, source_region); } } } void FlatSourceDomain::apply_external_source_to_cell_and_children( - int32_t i_cell, int src_idx, int32_t target_material_id) + int32_t i_cell, Discrete* discrete, double strength_factor, + int32_t target_material_id) { Cell& cell = *model::cells[i_cell]; if (cell.type_ == Fill::MATERIAL) { - vector instances(cell.n_instances()); + vector instances(cell.n_instances_); std::iota(instances.begin(), instances.end(), 0); apply_external_source_to_cell_instances( - i_cell, src_idx, target_material_id, instances); + i_cell, discrete, strength_factor, target_material_id, instances); } else if (target_material_id == C_NONE) { std::unordered_map> cell_instance_list = cell.get_contained_cells(0, nullptr); for (const auto& pair : cell_instance_list) { int32_t i_child_cell = pair.first; - apply_external_source_to_cell_instances( - i_child_cell, src_idx, target_material_id, pair.second); + apply_external_source_to_cell_instances(i_child_cell, discrete, + strength_factor, target_material_id, pair.second); } } } void FlatSourceDomain::count_external_source_regions() { - n_external_source_regions_ = 0; #pragma omp parallel for reduction(+ : n_external_source_regions_) - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - if (source_regions_.external_source_present(sr)) { + for (int sr = 0; sr < n_source_regions_; sr++) { + float total = 0.f; + for (int e = 0; e < negroups_; e++) { + int64_t se = sr * negroups_ + e; + total += external_source_[se]; + } + if (total != 0.f) { n_external_source_regions_++; } } } -void FlatSourceDomain::convert_external_sources(bool use_adjoint_sources) +void FlatSourceDomain::convert_external_sources() { - // Determine whether forward or (local) adjoint sources are desired - const auto& sources = - use_adjoint_sources ? model::adjoint_sources : model::external_sources; - // Loop over external sources - for (int es = 0; es < sources.size(); es++) { - - // Extract source information - Source* s = sources[es].get(); + for (int es = 0; es < model::external_sources.size(); es++) { + Source* s = model::external_sources[es].get(); IndependentSource* is = dynamic_cast(s); Discrete* energy = dynamic_cast(is->energy()); const std::unordered_set& domain_ids = is->domain_ids(); + double strength_factor = is->strength(); - // If there is no domain constraint specified, then this must be a point - // source. In this case, we need to find the source region that contains the - // point source and apply or relate it to the external source. - if (is->domain_ids().size() == 0) { - - // Extract the point source coordinate and find the base source region at - // that point - auto sp = dynamic_cast(is->space()); - GeometryState gs; - gs.r() = sp->r(); - gs.r_last() = sp->r(); - gs.u() = {1.0, 0.0, 0.0}; - bool found = exhaustive_find_cell(gs); - if (!found) { - fatal_error(fmt::format("Could not find cell containing external " - "point source at {}", - sp->r())); + if (is->domain_type() == Source::DomainType::MATERIAL) { + for (int32_t material_id : domain_ids) { + for (int i_cell = 0; i_cell < model::cells.size(); i_cell++) { + apply_external_source_to_cell_and_children( + i_cell, energy, strength_factor, material_id); + } } - SourceRegionKey key = lookup_source_region_key(gs); - - // With the source region and mesh bin known, we can use the - // accompanying SourceRegionKey as a key into a map that stores the - // corresponding external source index for the point source. Notably, we - // do not actually apply the external source to any source regions here, - // as if mesh subdivision is enabled, they haven't actually been - // discovered & initilized yet. When discovered, they will read from the - // external_source_map to determine if there are any external source - // terms that should be applied. - external_point_source_map_[key].push_back(es); - - } else { - // If not a point source, then use the volumetric domain constraints to - // determine which source regions to apply the external source to. - if (is->domain_type() == Source::DomainType::MATERIAL) { - for (int32_t material_id : domain_ids) { - for (int i_cell = 0; i_cell < model::cells.size(); i_cell++) { - apply_external_source_to_cell_and_children(i_cell, es, material_id); - } - } - } else if (is->domain_type() == Source::DomainType::CELL) { - for (int32_t cell_id : domain_ids) { - int32_t i_cell = model::cell_map[cell_id]; - apply_external_source_to_cell_and_children(i_cell, es, C_NONE); - } - } else if (is->domain_type() == Source::DomainType::UNIVERSE) { - for (int32_t universe_id : domain_ids) { - int32_t i_universe = model::universe_map[universe_id]; - Universe& universe = *model::universes[i_universe]; - for (int32_t i_cell : universe.cells_) { - apply_external_source_to_cell_and_children(i_cell, es, C_NONE); - } + } else if (is->domain_type() == Source::DomainType::CELL) { + for (int32_t cell_id : domain_ids) { + int32_t i_cell = model::cell_map[cell_id]; + apply_external_source_to_cell_and_children( + i_cell, energy, strength_factor, C_NONE); + } + } else if (is->domain_type() == Source::DomainType::UNIVERSE) { + for (int32_t universe_id : domain_ids) { + int32_t i_universe = model::universe_map[universe_id]; + Universe& universe = *model::universes[i_universe]; + for (int32_t i_cell : universe.cells_) { + apply_external_source_to_cell_and_children( + i_cell, energy, strength_factor, C_NONE); } } } } // End loop over external sources -} -void FlatSourceDomain::flux_swap() -{ - source_regions_.flux_swap(); -} - -void FlatSourceDomain::flatten_xs() -{ // Temperature and angle indices, if using multiple temperature // data sets and/or anisotropic data sets. - // TODO: Currently assumes we are only using single angle data. + // TODO: Currently assumes we are only using single temp/single angle data. + const int t = 0; const int a = 0; - n_materials_ = data::mg.macro_xs_.size(); - ntemperature_ = 1; - for (int i = 0; i < n_materials_; i++) { - ntemperature_ = - std::max(ntemperature_, data::mg.macro_xs_[i].n_temperature_points()); - } - - for (int i = 0; i < n_materials_; i++) { - auto& m = data::mg.macro_xs_[i]; - for (int t = 0; t < ntemperature_; t++) { - for (int g_out = 0; g_out < negroups_; g_out++) { - if (m.exists_in_model && t < m.n_temperature_points()) { - double sigma_t = - m.get_xs(MgxsType::TOTAL, g_out, NULL, NULL, NULL, t, a); - sigma_t_.push_back(sigma_t); - - if (sigma_t < MINIMUM_MACRO_XS) { - Material* mat = model::materials[i].get(); - warning(fmt::format( - "Material \"{}\" (id: {}) has a group {} total cross section " - "({:.3e}) below the minimum threshold " - "({:.3e}). Material will be treated as pure void.", - mat->name(), mat->id(), g_out, sigma_t, MINIMUM_MACRO_XS)); - } - - double nu_sigma_f = - m.get_xs(MgxsType::NU_FISSION, g_out, NULL, NULL, NULL, t, a); - nu_sigma_f_.push_back(nu_sigma_f); - - double sigma_f = - m.get_xs(MgxsType::FISSION, g_out, NULL, NULL, NULL, t, a); - sigma_f_.push_back(sigma_f); - - double chi = - m.get_xs(MgxsType::CHI_PROMPT, g_out, &g_out, NULL, NULL, t, a); - if (!std::isfinite(chi)) { - // MGXS interface may return NaN in some cases, such as when - // material is fissionable but has very small sigma_f. - chi = 0.0; - } - chi_.push_back(chi); - - double kappa_fission = - m.get_xs(MgxsType::KAPPA_FISSION, g_out, NULL, NULL, NULL, t, a); - kappa_fission_.push_back(kappa_fission); - - for (int g_in = 0; g_in < negroups_; g_in++) { - double sigma_s = - m.get_xs(MgxsType::NU_SCATTER, g_in, &g_out, NULL, NULL, t, a); - sigma_s_.push_back(sigma_s); - // For transport corrected XS data, diagonal elements may be - // negative. In this case, set a flag to enable transport - // stabilization for the simulation. - if (g_out == g_in && sigma_s < 0.0) - is_transport_stabilization_needed_ = true; - } - } else { - sigma_t_.push_back(0); - nu_sigma_f_.push_back(0); - sigma_f_.push_back(0); - chi_.push_back(0); - kappa_fission_.push_back(0); - for (int g_in = 0; g_in < negroups_; g_in++) { - sigma_s_.push_back(0); - } - } - } - } - } -} - -void FlatSourceDomain::set_fw_adjoint_sources() -{ - // Set the adjoint external source to 1/forward_flux. If the forward flux is - // negative, zero, or extremely close to zero, set the adjoint source to zero, - // as this is likely a very small source region that we don't need to bother - // trying to vector particles towards. In the case of flux "being extremely - // close to zero", we define this as being a fixed fraction of the maximum - // forward flux, below which we assume the flux would be physically - // undetectable. - - // First, find the maximum forward flux value - double max_flux = 0.0; -#pragma omp parallel for reduction(max : max_flux) - for (int64_t se = 0; se < n_source_elements(); se++) { - double flux = source_regions_.scalar_flux_final(se); - if (flux > max_flux) { - max_flux = flux; - } - } - - // Then, compute the adjoint source for each source region +// Divide the fixed source term by sigma t (to save time when applying each +// iteration) #pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - for (int g = 0; g < negroups_; g++) { - double flux = source_regions_.scalar_flux_final(sr, g); - if (flux <= ZERO_FLUX_CUTOFF * max_flux) { - source_regions_.external_source(sr, g) = 0.0; - } else { - source_regions_.external_source(sr, g) = 1.0 / flux; - if (!std::isfinite(source_regions_.external_source(sr, g))) { - // If the flux is NaN or Inf, set the adjoint source to zero - source_regions_.external_source(sr, g) = 0.0; - } - } - if (flux > 0.0) { - source_regions_.external_source_present(sr) = 1; - } - source_regions_.scalar_flux_final(sr, g) = 0.0; + for (int sr = 0; sr < n_source_regions_; sr++) { + int material = material_[sr]; + for (int e = 0; e < negroups_; e++) { + float sigma_t = data::mg.macro_xs_[material].get_xs( + MgxsType::TOTAL, e, nullptr, nullptr, nullptr, t, a); + external_source_[sr * negroups_ + e] /= sigma_t; } } - - // "Small" source regions in OpenMC are defined as those that are hit by - // MIN_HITS_PER_BATCH rays or fewer each batch. These regions typically have - // very small volumes combined with a low aspect ratio, and are often - // generated when applying a source region mesh that clips the edge of a - // curved surface. As perhaps only a few rays will visit these regions over - // the entire forward simulation, the forward flux estimates are extremely - // noisy and unreliable. In some cases, the noise may make the forward fluxes - // extremely low, leading to unphysically large adjoint source terms, - // resulting in weight windows that aggressively try to drive particles - // towards these regions. To fix this, we simply filter out any "small" source - // regions from consideration. If a source region is "small", we - // set its adjoint source to zero. This adds negligible bias to the adjoint - // flux solution, as the true total adjoint source contribution from small - // regions is likely to be negligible. -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - if (source_regions_.is_small(sr)) { - for (int g = 0; g < negroups_; g++) { - source_regions_.external_source(sr, g) = 0.0; - } - source_regions_.external_source_present(sr) = 0; - } - } - - // Divide the fixed source term by sigma t (to save time when applying each - // iteration) -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - int material = source_regions_.material(sr); - int temp = source_regions_.temperature_idx(sr); - if (material == MATERIAL_VOID) { - continue; - } - for (int g = 0; g < negroups_; g++) { - double sigma_t = - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - source_regions_.density_mult(sr); - source_regions_.external_source(sr, g) /= sigma_t; - if (!std::isfinite(source_regions_.external_source(sr, g))) { - // If the flux is NaN or Inf, set the adjoint source to zero - source_regions_.external_source(sr, g) = 0.0; - } - } - } - - if (fw_cadis_local_) { -// Only external sources that have a non-mesh type tally task should remain -// non-zero. Everything else gets zero'd out. -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - - // If there is already no external source, don't need to do anything - if (source_regions_.external_source_present(sr) == 0) { - continue; - } - - // If there is an adjoint source term here, then we need to check it. - - // We will track if ANY group has a valid local FW-CADIS source term - bool has_any_sources = false; - - // Now, loop over groups - for (int g = 0; g < negroups_; g++) { - - // If there are no tally tasks associated with this source element - // then it is not a local FW-CADIS source, so we continue to the next - // group - if (source_regions_.tally_task(sr, g).empty()) { - source_regions_.external_source(sr, g) = 0.0; - continue; - } - - // If there are tally tasks, we can through them and check if - // any of them are local FW-CADIS targets. - - // We track if ANY of the tasks are local FW-CADIS target tallies - bool local_fw_cadis_target_region = false; - - // Now we loop through - for (const auto& task : source_regions_.tally_task(sr, g)) { - Tally& tally {*model::tallies[task.tally_idx]}; - const auto t_id = tally.id(); - - // Search for target tallies - if (std::find(fw_cadis_local_targets_.begin(), - fw_cadis_local_targets_.end(), - t_id) != fw_cadis_local_targets_.end()) { - local_fw_cadis_target_region = true; - break; - } - } - - // If ANY of the tasks is a local FW-CADIS target, - // Then we keep the source term and set that this - // source region has a valid FW-CADIS source term. - // Otherwise, we zero out the source term. - if (local_fw_cadis_target_region) { - has_any_sources = true; - } else { - source_regions_.external_source(sr, g) = 0.0; - } - } // End loop over groups - - // If there were any valid FW-CADIS source terms for any - // of the groups, then the SR as a whole counts as a source - if (has_any_sources) { - source_regions_.external_source_present(sr) = 1; - } else { - source_regions_.external_source_present(sr) = 0; - } - } // End loop over source regions - } // End local FW-CADIS logic -} - -void FlatSourceDomain::set_local_adjoint_sources() -{ - // Set the external source to user-specified adjoint sources. - convert_external_sources(true); -} - -void FlatSourceDomain::transpose_scattering_matrix() -{ - // Transpose the inner two dimensions for each material -#pragma omp parallel for - for (int m = 0; m < n_materials_; ++m) { - for (int t = 0; t < ntemperature_; t++) { - int material_offset = (m * ntemperature_ + t) * negroups_ * negroups_; - for (int i = 0; i < negroups_; ++i) { - for (int j = i + 1; j < negroups_; ++j) { - // Calculate indices of the elements to swap - int idx1 = material_offset + i * negroups_ + j; - int idx2 = material_offset + j * negroups_ + i; - - // Swap the elements to transpose the matrix - std::swap(sigma_s_[idx1], sigma_s_[idx2]); - } - } - } - } -} - -void FlatSourceDomain::serialize_final_fluxes(vector& flux) -{ - // Ensure array is correct size - flux.resize(n_source_regions() * negroups_); -// Serialize the final fluxes for output -#pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - flux[se] = source_regions_.scalar_flux_final(se); - } -} - -void FlatSourceDomain::apply_mesh_to_cell_instances(int32_t i_cell, - int32_t mesh_idx, int target_material_id, const vector& instances, - bool is_target_void) -{ - Cell& cell = *model::cells[i_cell]; - if (cell.type_ != Fill::MATERIAL) - return; - for (int32_t j : instances) { - int cell_material_idx = cell.material(j); - int cell_material_id = (cell_material_idx == C_NONE) - ? C_NONE - : model::materials[cell_material_idx]->id(); - - if ((target_material_id == C_NONE && !is_target_void) || - cell_material_id == target_material_id) { - int64_t sr = source_region_offsets_[i_cell] + j; - // Check if the key is already present in the mesh_map_ - if (mesh_map_.find(sr) != mesh_map_.end()) { - fatal_error(fmt::format("Source region {} already has mesh idx {} " - "applied, but trying to apply mesh idx {}", - sr, mesh_map_[sr], mesh_idx)); - } - // If the SR has not already been assigned, then we can write to it - mesh_map_[sr] = mesh_idx; - } - } -} - -void FlatSourceDomain::apply_mesh_to_cell_and_children(int32_t i_cell, - int32_t mesh_idx, int32_t target_material_id, bool is_target_void) -{ - Cell& cell = *model::cells[i_cell]; - - if (cell.type_ == Fill::MATERIAL) { - vector instances(cell.n_instances()); - std::iota(instances.begin(), instances.end(), 0); - apply_mesh_to_cell_instances( - i_cell, mesh_idx, target_material_id, instances, is_target_void); - } else if (target_material_id == C_NONE && !is_target_void) { - for (int j = 0; j < cell.n_instances(); j++) { - std::unordered_map> cell_instance_list = - cell.get_contained_cells(j, nullptr); - for (const auto& pair : cell_instance_list) { - int32_t i_child_cell = pair.first; - apply_mesh_to_cell_instances(i_child_cell, mesh_idx, target_material_id, - pair.second, is_target_void); - } - } - } -} - -void FlatSourceDomain::apply_meshes() -{ - // Skip if there are no mappings between mesh IDs and domains - if (mesh_domain_map_.empty()) - return; - - // Loop over meshes - for (int mesh_idx = 0; mesh_idx < model::meshes.size(); mesh_idx++) { - Mesh* mesh = model::meshes[mesh_idx].get(); - int mesh_id = mesh->id(); - - // Skip if mesh id is not present in the map - if (mesh_domain_map_.find(mesh_id) == mesh_domain_map_.end()) - continue; - - // Loop over domains associated with the mesh - for (auto& domain : mesh_domain_map_[mesh_id]) { - Source::DomainType domain_type = domain.first; - int domain_id = domain.second; - - if (domain_type == Source::DomainType::MATERIAL) { - for (int i_cell = 0; i_cell < model::cells.size(); i_cell++) { - if (domain_id == C_NONE) { - apply_mesh_to_cell_and_children(i_cell, mesh_idx, domain_id, true); - } else { - apply_mesh_to_cell_and_children(i_cell, mesh_idx, domain_id, false); - } - } - } else if (domain_type == Source::DomainType::CELL) { - int32_t i_cell = model::cell_map[domain_id]; - apply_mesh_to_cell_and_children(i_cell, mesh_idx, C_NONE, false); - } else if (domain_type == Source::DomainType::UNIVERSE) { - int32_t i_universe = model::universe_map[domain_id]; - Universe& universe = *model::universes[i_universe]; - for (int32_t i_cell : universe.cells_) { - apply_mesh_to_cell_and_children(i_cell, mesh_idx, C_NONE, false); - } - } - } - } -} - -SourceRegionHandle FlatSourceDomain::get_subdivided_source_region_handle( - SourceRegionKey sr_key, Position r, Direction u) -{ - // Case 1: Check if the source region key is already present in the permanent - // map. This is the most common condition, as any source region visited in a - // previous power iteration will already be present in the permanent map. If - // the source region key is found, we translate the key into a specific 1D - // source region index and return a handle its position in the - // source_regions_ vector. - auto it = source_region_map_.find(sr_key); - if (it != source_region_map_.end()) { - int64_t sr = it->second; - return source_regions_.get_source_region_handle(sr); - } - - // Case 2: Check if the source region key is present in the temporary (thread - // safe) map. This is a common occurrence in the first power iteration when - // the source region has already been visited already by some other ray. We - // begin by locking the temporary map before any operations are performed. The - // lock is not global over the full data structure -- it will be dependent on - // which key is used. - discovered_source_regions_.lock(sr_key); - - // If the key is found in the temporary map, then we return a handle to the - // source region that is stored in the temporary map. - if (discovered_source_regions_.contains(sr_key)) { - SourceRegionHandle handle {discovered_source_regions_[sr_key]}; - discovered_source_regions_.unlock(sr_key); - return handle; - } - - // Case 3: The source region key is not present anywhere, but it is only due - // to floating point artifacts. These artifacts occur when the overlaid mesh - // overlaps with actual geometry surfaces. In these cases, roundoff error may - // result in the ray tracer detecting an additional (very short) segment - // though a mesh bin that is actually past the physical source region - // boundary. This is a result of the the multi-level ray tracing treatment in - // OpenMC, which depending on the number of universes in the hierarchy etc can - // result in the wrong surface being selected as the nearest. This can happen - // in a lattice when there are two directions that both are very close in - // distance, within the tolerance of FP_REL_PRECISION, and the are thus - // treated as being equivalent so alternative logic is used. However, when we - // go and ray trace on this with the mesh tracer we may go past the surface - // bounding the current source region. - // - // To filter out this case, before we create the new source region, we double - // check that the actual starting point of this segment (r) is still in the - // same geometry source region that we started in. If an artifact is detected, - // we discard the segment (and attenuation through it) as it is not really a - // valid source region and will have only an infinitessimally small cell - // combined with the mesh bin. Thankfully, this is a fairly rare condition, - // and only triggers for very short ray lengths. It can be fixed by decreasing - // the value of FP_REL_PRECISION in constants.h, but this may have unknown - // consequences for the general ray tracer, so for now we do the below sanity - // checks before generating phantom source regions. A significant extra cost - // is incurred in instantiating the GeometryState object and doing a cell - // lookup, but again, this is going to be an extremely rare thing to check - // after the first power iteration has completed. - - // Sanity check on source region id - GeometryState gs; - gs.r() = r + TINY_BIT * u; - gs.u() = {1.0, 0.0, 0.0}; - exhaustive_find_cell(gs); - int64_t sr_found = lookup_base_source_region_idx(gs); - if (sr_found != sr_key.base_source_region_id) { - discovered_source_regions_.unlock(sr_key); - SourceRegionHandle handle; - handle.is_numerical_fp_artifact_ = true; - return handle; - } - - // Sanity check on mesh bin - int mesh_idx = lookup_mesh_idx(sr_key.base_source_region_id); - if (mesh_idx == C_NONE) { - if (sr_key.mesh_bin != 0) { - discovered_source_regions_.unlock(sr_key); - SourceRegionHandle handle; - handle.is_numerical_fp_artifact_ = true; - return handle; - } - } else { - Mesh* mesh = model::meshes[mesh_idx].get(); - int bin_found = mesh->get_bin(r + TINY_BIT * u); - if (bin_found != sr_key.mesh_bin) { - discovered_source_regions_.unlock(sr_key); - SourceRegionHandle handle; - handle.is_numerical_fp_artifact_ = true; - return handle; - } - } - - // Case 4: The source region key is valid, but is not present anywhere. This - // condition only occurs the first time the source region is discovered - // (typically in the first power iteration). In this case, we need to handle - // creation of the new source region and its storage into the parallel map. - // Additionally, we need to determine the source region's material, initialize - // the starting scalar flux guess, and apply any known external sources. - - // Call the basic constructor for the source region and store in the parallel - // map. - bool is_linear = RandomRay::source_shape_ != RandomRaySourceShape::FLAT; - SourceRegion* sr_ptr = - discovered_source_regions_.emplace(sr_key, {negroups_, is_linear}); - SourceRegionHandle handle {*sr_ptr}; - - // Determine the material - int gs_i_cell = gs.lowest_coord().cell(); - Cell& cell = *model::cells[gs_i_cell]; - int material = cell.material(gs.cell_instance()); - int temp = 0; - - // If material total XS is extremely low, just set it to void to avoid - // problems with 1/Sigma_t - if (material != MATERIAL_VOID) { - temp = data::mg.macro_xs_[material].get_temperature_index( - cell.sqrtkT(gs.cell_instance())); - for (int g = 0; g < negroups_; g++) { - double sigma_t = - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g]; - if (sigma_t < MINIMUM_MACRO_XS) { - material = MATERIAL_VOID; - temp = 0; - break; - } - } - } - - handle.material() = material; - handle.temperature_idx() = temp; - - handle.density_mult() = cell.density_mult(gs.cell_instance()); - - // Store the mesh index (if any) assigned to this source region - handle.mesh() = mesh_idx; - - if (settings::run_mode == RunMode::FIXED_SOURCE) { - // Determine if there are any volumetric sources, and apply them. - // Volumetric sources are specifc only to the base SR idx. - auto it_vol = - external_volumetric_source_map_.find(sr_key.base_source_region_id); - if (it_vol != external_volumetric_source_map_.end()) { - const vector& vol_sources = it_vol->second; - for (int src_idx : vol_sources) { - apply_external_source_to_source_region(src_idx, handle); - } - } - - // Determine if there are any point sources, and apply them. - // Point sources are specific to the source region key. - auto it_point = external_point_source_map_.find(sr_key); - if (it_point != external_point_source_map_.end()) { - const vector& point_sources = it_point->second; - for (int src_idx : point_sources) { - apply_external_source_to_source_region(src_idx, handle); - } - } - - // Divide external source term by sigma_t - if (material != C_NONE) { - for (int g = 0; g < negroups_; g++) { - double sigma_t = - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - handle.density_mult(); - handle.external_source(g) /= sigma_t; - } - } - } - - // Compute the combined source term - update_single_neutron_source(handle); - - // Unlock the parallel map. Note: we may be tempted to release - // this lock earlier, and then just use the source region's lock to protect - // the flux/source initialization stages above. However, the rest of the code - // only protects updates to the new flux and volume fields, and assumes that - // the source is constant for the duration of transport. Thus, using just the - // source region's lock by itself would result in other threads potentially - // reading from the source before it is computed, as they won't use the lock - // when only reading from the SR's source. It would be expensive to protect - // those operations, whereas generating the SR is only done once, so we just - // hold the map's bucket lock until the source region is fully initialized. - discovered_source_regions_.unlock(sr_key); - - return handle; -} - -void FlatSourceDomain::finalize_discovered_source_regions() -{ - // Extract keys for entries with a valid volume. - vector keys; - for (const auto& pair : discovered_source_regions_) { - if (pair.second.volume_ > 0.0) { - keys.push_back(pair.first); - } - } - - if (!keys.empty()) { - // Sort the keys, so as to ensure reproducible ordering given that source - // regions may have been added to discovered_source_regions_ in an arbitrary - // order due to shared memory threading. - std::sort(keys.begin(), keys.end()); - - // Remember the index of the first new source region - int64_t start_sr_id = source_regions_.n_source_regions(); - - // Append the source regions in the sorted key order. - for (const auto& key : keys) { - const SourceRegion& sr = discovered_source_regions_[key]; - source_region_map_[key] = source_regions_.n_source_regions(); - source_regions_.push_back(sr); - } - - // Map all new source regions to tallies - convert_source_regions_to_tallies(start_sr_id); - } - - discovered_source_regions_.clear(); -} - -// This is the "diagonal stabilization" technique developed by Gunow et al. in: -// -// Geoffrey Gunow, Benoit Forget, Kord Smith, Stabilization of multi-group -// neutron transport with transport-corrected cross-sections, Annals of Nuclear -// Energy, Volume 126, 2019, Pages 211-219, ISSN 0306-4549, -// https://doi.org/10.1016/j.anucene.2018.10.036. -void FlatSourceDomain::apply_transport_stabilization() -{ - // Don't do anything if all in-group scattering - // cross sections are positive - if (!is_transport_stabilization_needed_) { - return; - } - - // Apply the stabilization factor to all source elements -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - int material = source_regions_.material(sr); - int temp = source_regions_.temperature_idx(sr); - double density_mult = source_regions_.density_mult(sr); - if (material == MATERIAL_VOID) { - continue; - } - for (int g = 0; g < negroups_; g++) { - // Only apply stabilization if the diagonal (in-group) scattering XS is - // negative - double sigma_s = - sigma_s_[((material * ntemperature_ + temp) * negroups_ + g) * - negroups_ + - g] * - density_mult; - if (sigma_s < 0.0) { - double sigma_t = - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - density_mult; - double phi_new = source_regions_.scalar_flux_new(sr, g); - double phi_old = source_regions_.scalar_flux_old(sr, g); - - // Equation 18 in the above Gunow et al. 2019 paper. For a default - // rho of 1.0, this ensures there are no negative diagonal elements - // in the iteration matrix. A lesser rho could be used (or exposed - // as a user input parameter) to reduce the negative impact on - // convergence rate though would need to be experimentally tested to see - // if it doesn't become unstable. rho = 1.0 is good as it gives the - // highest assurance of stability, and the impacts on convergence rate - // are pretty mild. - double D = diagonal_stabilization_rho_ * sigma_s / sigma_t; - - // Equation 16 in the above Gunow et al. 2019 paper - source_regions_.scalar_flux_new(sr, g) = - (phi_new - D * phi_old) / (1.0 - D); - } - } - } -} - -// Determines the base source region index (i.e., a material filled cell -// instance) that corresponds to a particular location in the geometry. Requires -// that the "gs" object passed in has already been initialized and has called -// find_cell etc. -int64_t FlatSourceDomain::lookup_base_source_region_idx( - const GeometryState& gs) const -{ - int i_cell = gs.lowest_coord().cell(); - int64_t sr = source_region_offsets_[i_cell] + gs.cell_instance(); - return sr; -} - -// Determines the index of the mesh (if any) that has been applied -// to a particular base source region index. -int FlatSourceDomain::lookup_mesh_idx(int64_t sr) const -{ - int mesh_idx = C_NONE; - auto mesh_it = mesh_map_.find(sr); - if (mesh_it != mesh_map_.end()) { - mesh_idx = mesh_it->second; - } - return mesh_idx; -} - -// Determines the source region key that corresponds to a particular location in -// the geometry. This takes into account both the base source region index as -// well as the mesh bin if a mesh is applied to this source region for -// subdivision. -SourceRegionKey FlatSourceDomain::lookup_source_region_key( - const GeometryState& gs) const -{ - int64_t sr = lookup_base_source_region_idx(gs); - int64_t mesh_bin = lookup_mesh_bin(sr, gs.r()); - return SourceRegionKey {sr, mesh_bin}; -} - -// Determines the mesh bin that corresponds to a particular base source region -// index and position. -int64_t FlatSourceDomain::lookup_mesh_bin(int64_t sr, Position r) const -{ - int mesh_idx = lookup_mesh_idx(sr); - int mesh_bin = 0; - if (mesh_idx != C_NONE) { - mesh_bin = model::meshes[mesh_idx]->get_bin(r); - } - return mesh_bin; } } // namespace openmc diff --git a/src/random_ray/linear_source_domain.cpp b/src/random_ray/linear_source_domain.cpp deleted file mode 100644 index b4701ed1f..000000000 --- a/src/random_ray/linear_source_domain.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "openmc/random_ray/linear_source_domain.h" - -#include "openmc/cell.h" -#include "openmc/geometry.h" -#include "openmc/material.h" -#include "openmc/message_passing.h" -#include "openmc/mgxs_interface.h" -#include "openmc/output.h" -#include "openmc/plot.h" -#include "openmc/random_ray/random_ray.h" -#include "openmc/simulation.h" -#include "openmc/tallies/filter.h" -#include "openmc/tallies/tally.h" -#include "openmc/tallies/tally_scoring.h" -#include "openmc/timer.h" - -namespace openmc { - -//============================================================================== -// LinearSourceDomain implementation -//============================================================================== - -void LinearSourceDomain::batch_reset() -{ - FlatSourceDomain::batch_reset(); -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - source_regions_.centroid_iteration(sr) = {0.0, 0.0, 0.0}; - source_regions_.mom_matrix(sr) = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - } -#pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - source_regions_.flux_moments_new(se) = {0.0, 0.0, 0.0}; - } -} - -void LinearSourceDomain::update_single_neutron_source(SourceRegionHandle& srh) -{ - // Reset all source regions to zero (important for void regions) - for (int g = 0; g < negroups_; g++) { - srh.source(g) = 0.0; - } - - // Add scattering + fission source - int material = srh.material(); - int temp = srh.temperature_idx(); - double density_mult = srh.density_mult(); - if (material != MATERIAL_VOID) { - double inverse_k_eff = 1.0 / k_eff_; - MomentMatrix invM = srh.mom_matrix().inverse(); - - for (int g_out = 0; g_out < negroups_; g_out++) { - double sigma_t = - sigma_t_[(material * ntemperature_ + temp) * negroups_ + g_out] * - density_mult; - - double scatter_flat = 0.0f; - double fission_flat = 0.0f; - MomentArray scatter_linear = {0.0, 0.0, 0.0}; - MomentArray fission_linear = {0.0, 0.0, 0.0}; - - for (int g_in = 0; g_in < negroups_; g_in++) { - // Handles for the flat and linear components of the flux - double flux_flat = srh.scalar_flux_old(g_in); - MomentArray flux_linear = srh.flux_moments_old(g_in); - - // Handles for cross sections - double sigma_s = - sigma_s_[((material * ntemperature_ + temp) * negroups_ + g_out) * - negroups_ + - g_in] * - density_mult; - double nu_sigma_f = - nu_sigma_f_[(material * ntemperature_ + temp) * negroups_ + g_in] * - density_mult; - double chi = - chi_[(material * ntemperature_ + temp) * negroups_ + g_out]; - - // Compute source terms for flat and linear components of the flux - scatter_flat += sigma_s * flux_flat; - scatter_linear += sigma_s * flux_linear; - if (settings::create_fission_neutrons) { - fission_flat += nu_sigma_f * flux_flat * chi; - fission_linear += nu_sigma_f * flux_linear * chi; - } - } - - // Compute the flat source term - srh.source(g_out) = - (scatter_flat + fission_flat * inverse_k_eff) / sigma_t; - - // Compute the linear source terms. In the first 10 iterations when the - // centroids and spatial moments are not well known, we will leave the - // source gradients as zero so as to avoid causing any numerical - // instability. If a negative source is encountered, this region must be - // very small/noisy or have poorly developed spatial moments, so we zero - // the source gradients (effectively making this a flat source region - // temporarily), so as to improve stability. - if (simulation::current_batch > 10 && srh.source(g_out) >= 0.0) { - srh.source_gradients(g_out) = - invM * ((scatter_linear + fission_linear * inverse_k_eff) / sigma_t); - } else { - srh.source_gradients(g_out) = {0.0, 0.0, 0.0}; - } - } - } - - // Add external source if in fixed source mode - if (settings::run_mode == RunMode::FIXED_SOURCE) { - for (int g = 0; g < negroups_; g++) { - srh.source(g) += srh.external_source(g); - } - } -} - -void LinearSourceDomain::normalize_scalar_flux_and_volumes( - double total_active_distance_per_iteration) -{ - double normalization_factor = 1.0 / total_active_distance_per_iteration; - double volume_normalization_factor = - 1.0 / (total_active_distance_per_iteration * simulation::current_batch); - -// Normalize flux to total distance travelled by all rays this iteration -#pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - source_regions_.scalar_flux_new(se) *= normalization_factor; - source_regions_.flux_moments_new(se) *= normalization_factor; - } - -// Accumulate cell-wise ray length tallies collected this iteration, then -// update the simulation-averaged cell-wise volume estimates -#pragma omp parallel for - for (int64_t sr = 0; sr < n_source_regions(); sr++) { - source_regions_.centroid_t(sr) += source_regions_.centroid_iteration(sr); - source_regions_.mom_matrix_t(sr) += source_regions_.mom_matrix(sr); - source_regions_.volume_t(sr) += source_regions_.volume(sr); - source_regions_.volume_sq_t(sr) += source_regions_.volume_sq(sr); - source_regions_.volume_naive(sr) = - source_regions_.volume(sr) * normalization_factor; - source_regions_.volume(sr) = - source_regions_.volume_t(sr) * volume_normalization_factor; - source_regions_.volume_sq(sr) = - source_regions_.volume_sq_t(sr) / source_regions_.volume_t(sr); - if (source_regions_.volume_t(sr) > 0.0) { - double inv_volume = 1.0 / source_regions_.volume_t(sr); - source_regions_.centroid(sr) = source_regions_.centroid_t(sr); - source_regions_.centroid(sr) *= inv_volume; - source_regions_.mom_matrix(sr) = source_regions_.mom_matrix_t(sr); - source_regions_.mom_matrix(sr) *= inv_volume; - } - } -} - -void LinearSourceDomain::set_flux_to_flux_plus_source( - int64_t sr, double volume, int g) -{ - int material = source_regions_.material(sr); - if (material == MATERIAL_VOID) { - FlatSourceDomain::set_flux_to_flux_plus_source(sr, volume, g); - } else { - source_regions_.scalar_flux_new(sr, g) /= volume; - source_regions_.scalar_flux_new(sr, g) += source_regions_.source(sr, g); - } - // If a source region is small, then the moments are likely noisy, so we zero - // them. This is reasonable, given that small regions can get by with a flat - // source approximation anyhow. - if (source_regions_.is_small(sr)) { - source_regions_.flux_moments_new(sr, g) = {0.0, 0.0, 0.0}; - } else { - source_regions_.flux_moments_new(sr, g) *= (1.0 / volume); - } -} - -void LinearSourceDomain::set_flux_to_old_flux(int64_t sr, int g) -{ - source_regions_.scalar_flux_new(sr, g) = - source_regions_.scalar_flux_old(sr, g); - source_regions_.flux_moments_new(sr, g) = - source_regions_.flux_moments_old(sr, g); -} - -void LinearSourceDomain::accumulate_iteration_flux() -{ - // Accumulate scalar flux - FlatSourceDomain::accumulate_iteration_flux(); - - // Accumulate scalar flux moments -#pragma omp parallel for - for (int64_t se = 0; se < n_source_elements(); se++) { - source_regions_.flux_moments_t(se) += source_regions_.flux_moments_new(se); - } -} - -double LinearSourceDomain::evaluate_flux_at_point( - Position r, int64_t sr, int g) const -{ - double phi_flat = FlatSourceDomain::evaluate_flux_at_point(r, sr, g); - - Position local_r = r - source_regions_.centroid(sr); - MomentArray phi_linear = source_regions_.flux_moments_t(sr, g); - phi_linear *= 1.0 / (settings::n_batches - settings::n_inactive); - - MomentMatrix invM = source_regions_.mom_matrix(sr).inverse(); - MomentArray phi_solved = invM * phi_linear; - - return phi_flat + phi_solved.dot(local_r); -} - -} // namespace openmc diff --git a/src/random_ray/moment_matrix.cpp b/src/random_ray/moment_matrix.cpp deleted file mode 100644 index 0324a1494..000000000 --- a/src/random_ray/moment_matrix.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "openmc/random_ray/moment_matrix.h" -#include "openmc/error.h" - -#include - -namespace openmc { - -//============================================================================== -// UpperTriangular implementation -//============================================================================== - -// Inverts a 3x3 smmetric matrix labeled as: -// -// | a b c | -// | b d e | -// | c e f | -// -// We first check the determinant to ensure it is non-zero before proceeding -// with the inversion. If the determinant is zero, we return a matrix of zeros. -// Inversion is calculated by computing the adjoint matrix first, and then the -// inverse can be computed as: A^-1 = 1/det(A) * adj(A) -MomentMatrix MomentMatrix::inverse() const -{ - MomentMatrix inv; - - // Check if the determinant is zero - double det = determinant(); - if (det < std::abs(1.0e-10)) { - // Set the inverse to zero. In effect, this will - // result in all the linear terms of the source becoming - // zero, leaving just the flat source. - inv.set_to_zero(); - return inv; - } - - // Compute the adjoint matrix - inv.a = d * f - e * e; - inv.b = c * e - b * f; - inv.c = b * e - c * d; - inv.d = a * f - c * c; - inv.e = b * c - a * e; - inv.f = a * d - b * b; - - // A^-1 = 1/det(A) * adj(A) - inv *= 1.0 / det; - - return inv; -} - -// Computes the determinant of a 3x3 symmetric -// matrix, with elements labeled as follows: -// -// | a b c | -// | b d e | -// | c e f | -double MomentMatrix::determinant() const -{ - return a * (d * f - e * e) - b * (b * f - c * e) + c * (b * e - c * d); -} - -// Compute a 3x3 spatial moment matrix based on a single ray crossing. -// The matrix is symmetric, and is defined as: -// -// | a b c | -// | b d e | -// | c e f | -// -// The estimate of the obect's spatial moments matrix is computed based on the -// midpoint of the ray's crossing, the direction of the ray, and the distance -// the ray traveled through the 3D object. -void MomentMatrix::compute_spatial_moments_matrix( - const Position& r, const Direction& u, const double& distance) -{ - constexpr double one_over_twelve = 1.0 / 12.0; - const double distance2_12 = distance * distance * one_over_twelve; - a = r[0] * r[0] + u[0] * u[0] * distance2_12; - b = r[0] * r[1] + u[0] * u[1] * distance2_12; - c = r[0] * r[2] + u[0] * u[2] * distance2_12; - d = r[1] * r[1] + u[1] * u[1] * distance2_12; - e = r[1] * r[2] + u[1] * u[2] * distance2_12; - f = r[2] * r[2] + u[2] * u[2] * distance2_12; -} - -} // namespace openmc \ No newline at end of file diff --git a/src/random_ray/random_ray.cpp b/src/random_ray/random_ray.cpp index dde5023e4..63d728cce 100644 --- a/src/random_ray/random_ray.cpp +++ b/src/random_ray/random_ray.cpp @@ -1,19 +1,12 @@ #include "openmc/random_ray/random_ray.h" -#include "openmc/constants.h" #include "openmc/geometry.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/random_ray/flat_source_domain.h" -#include "openmc/random_ray/linear_source_domain.h" #include "openmc/search.h" #include "openmc/settings.h" #include "openmc/simulation.h" - -#include - -#include "openmc/distribution_spatial.h" -#include "openmc/random_dist.h" #include "openmc/source.h" namespace openmc { @@ -67,169 +60,6 @@ float cjosey_exponential(float tau) return num / den; } -// The below two functions (exponentialG and exponentialG2) were developed -// by Colin Josey. The implementation of these functions is closely based -// on the OpenMOC versions of these functions. The OpenMOC license is given -// below: - -// Copyright (C) 2012-2023 Massachusetts Institute of Technology and OpenMOC -// contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -// Computes y = 1/x-(1-exp(-x))/x**2 using a 5/6th order rational -// approximation. It is accurate to 2e-7 over [0, 1e5]. Developed by Colin -// Josey using Remez's algorithm, with original implementation in OpenMOC at: -// https://github.com/mit-crpg/OpenMOC/blob/develop/src/exponentials.h -float exponentialG(float tau) -{ - // Numerator coefficients in rational approximation for 1/x - (1 - exp(-x)) / - // x^2 - constexpr float d0n = 0.5f; - constexpr float d1n = 0.176558112351595f; - constexpr float d2n = 0.04041584305811143f; - constexpr float d3n = 0.006178333902037397f; - constexpr float d4n = 0.0006429894635552992f; - constexpr float d5n = 0.00006064409107557148f; - - // Denominator coefficients in rational approximation for 1/x - (1 - exp(-x)) - // / x^2 - constexpr float d0d = 1.0f; - constexpr float d1d = 0.6864462055546078f; - constexpr float d2d = 0.2263358514260129f; - constexpr float d3d = 0.04721469893686252f; - constexpr float d4d = 0.006883236664917246f; - constexpr float d5d = 0.0007036272419147752f; - constexpr float d6d = 0.00006064409107557148f; - - float x = tau; - - float num = d5n; - num = num * x + d4n; - num = num * x + d3n; - num = num * x + d2n; - num = num * x + d1n; - num = num * x + d0n; - - float den = d6d; - den = den * x + d5d; - den = den * x + d4d; - den = den * x + d3d; - den = den * x + d2d; - den = den * x + d1d; - den = den * x + d0d; - - return num / den; -} - -// Computes G2 : y = 2/3 - (1 + 2/x) * (1/x + 0.5 - (1 + 1/x) * (1-exp(-x)) / -// x) using a 5/5th order rational approximation. It is accurate to 1e-6 over -// [0, 1e6]. Developed by Colin Josey using Remez's algorithm, with original -// implementation in OpenMOC at: -// https://github.com/mit-crpg/OpenMOC/blob/develop/src/exponentials.h -float exponentialG2(float tau) -{ - - // Coefficients for numerator in rational approximation - constexpr float g1n = -0.08335775885589858f; - constexpr float g2n = -0.003603942303847604f; - constexpr float g3n = 0.0037673183263550827f; - constexpr float g4n = 0.00001124183494990467f; - constexpr float g5n = 0.00016837426505799449f; - - // Coefficients for denominator in rational approximation - constexpr float g1d = 0.7454048371823628f; - constexpr float g2d = 0.23794300531408347f; - constexpr float g3d = 0.05367250964303789f; - constexpr float g4d = 0.006125197988351906f; - constexpr float g5d = 0.0010102514456857377f; - - float x = tau; - - float num = g5n; - num = num * x + g4n; - num = num * x + g3n; - num = num * x + g2n; - num = num * x + g1n; - num = num * x; - - float den = g5d; - den = den * x + g4d; - den = den * x + g3d; - den = den * x + g2d; - den = den * x + g1d; - den = den * x + 1.0f; - - return num / den; -} - -// Implementation of the Fisher-Yates shuffle algorithm. -// Algorithm adapted from: -// https://en.cppreference.com/w/cpp/algorithm/random_shuffle#Version_3 -void fisher_yates_shuffle(vector& arr, uint64_t* seed) -{ - // Loop over the array from the last element down to the second - for (int i = arr.size() - 1; i > 0; --i) { - // Generate a random index in the range [0, i] - int j = uniform_int_distribution(0, i, seed); - std::swap(arr[i], arr[j]); - } -} - -// Function to generate randomized Halton sequence samples -// -// Algorithm adapted from: -// A. B. Owen. A randomized halton algorithm in r. Arxiv, 6 2017. -// URL https://arxiv.org/abs/1706.02808 -vector rhalton(int dim, uint64_t* seed, int64_t skip = 0) -{ - if (dim > 10) { - fatal_error("Halton sampling dimension too large"); - } - int64_t b, res, dig; - double b2r, ans; - const std::array primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; - vector halton(dim, 0.0); - - vector perm; - for (int D = 0; D < dim; ++D) { - b = primes[D]; - perm.resize(b); - b2r = 1.0 / b; - res = skip; - ans = 0.0; - - while ((1.0 - b2r) < 1.0) { - std::iota(perm.begin(), perm.end(), 0); - fisher_yates_shuffle(perm, seed); - dig = res % b; - ans += perm[dig] * b2r; - res = (res - dig) / b; - b2r /= b; - } - - halton[D] = ans; - } - - return halton; -} - //============================================================================== // RandomRay implementation //============================================================================== @@ -238,19 +68,12 @@ vector rhalton(int dim, uint64_t* seed, int64_t skip = 0) double RandomRay::distance_inactive_; double RandomRay::distance_active_; unique_ptr RandomRay::ray_source_; -RandomRaySourceShape RandomRay::source_shape_ {RandomRaySourceShape::FLAT}; -RandomRaySampleMethod RandomRay::sample_method_ {RandomRaySampleMethod::PRNG}; RandomRay::RandomRay() : angular_flux_(data::mg.num_energy_groups_), delta_psi_(data::mg.num_energy_groups_), negroups_(data::mg.num_energy_groups_) -{ - if (source_shape_ == RandomRaySourceShape::LINEAR || - source_shape_ == RandomRaySourceShape::LINEAR_XY) { - delta_moments_.resize(negroups_); - } -} +{} RandomRay::RandomRay(uint64_t ray_id, FlatSourceDomain* domain) : RandomRay() { @@ -266,12 +89,6 @@ uint64_t RandomRay::transport_history_based_single_ray() if (!alive()) break; event_cross_surface(); - // If ray has too many events, display warning and kill it - if (n_event() >= settings::max_particle_events) { - warning("Ray " + std::to_string(id()) + - " underwent maximum number of events, terminating ray."); - wgt() = 0.0; - } } return n_event(); @@ -280,15 +97,11 @@ uint64_t RandomRay::transport_history_based_single_ray() // Transports ray across a single source region void RandomRay::event_advance_ray() { - // If geometry debug mode is on, check for cell overlaps - if (settings::check_overlaps) - check_cell_overlap(*this); - // Find the distance to the nearest boundary boundary() = distance_to_boundary(*this); - double distance = boundary().distance(); + double distance = boundary().distance; - if (distance < 0.0) { + if (distance <= 0.0) { mark_as_lost("Negative transport distance detected for particle " + std::to_string(id())); return; @@ -325,7 +138,7 @@ void RandomRay::event_advance_ray() wgt() = 0.0; } - attenuate_flux(distance_alive, true, distance_dead); + attenuate_flux(distance_alive, true); distance_travelled_ = distance_alive; } else { distance_travelled_ += distance; @@ -335,81 +148,7 @@ void RandomRay::event_advance_ray() // Advance particle for (int j = 0; j < n_coord(); ++j) { - coord(j).r() += distance * coord(j).u(); - } -} - -void RandomRay::attenuate_flux(double distance, bool is_active, double offset) -{ - // Lookup base source region index - int64_t sr = domain_->lookup_base_source_region_idx(*this); - - // Perform ray tracing across mesh - // Determine the mesh index for the base source region, if any - int mesh_idx = domain_->lookup_mesh_idx(sr); - - if (mesh_idx == C_NONE) { - // If there's no mesh being applied to this cell, then - // we just attenuate the flux as normal, and set - // the mesh bin to 0 - attenuate_flux_inner(distance, is_active, sr, 0, r()); - } else { - // If there is a mesh being applied to this cell, then - // we loop over all the bin crossings and attenuate - // separately. - Mesh* mesh = model::meshes[mesh_idx].get(); - - // We adjust the start and end positions of the ray slightly - // to accomodate for floating point precision issues that tend - // to occur at mesh boundaries that overlap with geometry lattice - // boundaries. - Position start = r() + (offset + TINY_BIT) * u(); - Position end = start + (distance - 2.0 * TINY_BIT) * u(); - double reduced_distance = (end - start).norm(); - - // Ray trace through the mesh and record bins and lengths - mesh_bins_.resize(0); - mesh_fractional_lengths_.resize(0); - mesh->bins_crossed(start, end, u(), mesh_bins_, mesh_fractional_lengths_); - - // Loop over all mesh bins and attenuate flux - for (int b = 0; b < mesh_bins_.size(); b++) { - double physical_length = reduced_distance * mesh_fractional_lengths_[b]; - attenuate_flux_inner( - physical_length, is_active, sr, mesh_bins_[b], start); - start += physical_length * u(); - } - } -} - -void RandomRay::attenuate_flux_inner( - double distance, bool is_active, int64_t sr, int mesh_bin, Position r) -{ - SourceRegionKey sr_key {sr, mesh_bin}; - SourceRegionHandle srh; - srh = domain_->get_subdivided_source_region_handle(sr_key, r, u()); - if (srh.is_numerical_fp_artifact_) { - return; - } - - switch (source_shape_) { - case RandomRaySourceShape::FLAT: - if (srh.material() == MATERIAL_VOID) { - attenuate_flux_flat_source_void(srh, distance, is_active, r); - } else { - attenuate_flux_flat_source(srh, distance, is_active, r); - } - break; - case RandomRaySourceShape::LINEAR: - case RandomRaySourceShape::LINEAR_XY: - if (srh.material() == MATERIAL_VOID) { - attenuate_flux_linear_source_void(srh, distance, is_active, r); - } else { - attenuate_flux_linear_source(srh, distance, is_active, r); - } - break; - default: - fatal_error("Unknown source shape for random ray transport."); + coord(j).r += distance * coord(j).u; } } @@ -426,352 +165,80 @@ void RandomRay::attenuate_flux_inner( // than use of many atomic operations corresponding to each energy group // individually (at least on CPU). Several other bookkeeping tasks are also // performed when inside the lock. -void RandomRay::attenuate_flux_flat_source( - SourceRegionHandle& srh, double distance, bool is_active, Position r) +void RandomRay::attenuate_flux(double distance, bool is_active) { // The number of geometric intersections is counted for reporting purposes n_event()++; - // Get material - int material = srh.material(); - int temp = srh.temperature_idx(); + // Determine source region index etc. + int i_cell = lowest_coord().cell; + + // The source region is the spatial region index + int64_t source_region = + domain_->source_region_offsets_[i_cell] + cell_instance(); + + // The source element is the energy-specific region index + int64_t source_element = source_region * negroups_; + int material = this->material(); + + // Temperature and angle indices, if using multiple temperature + // data sets and/or anisotropic data sets. + // TODO: Currently assumes we are only using single temp/single + // angle data. + const int t = 0; + const int a = 0; // MOC incoming flux attenuation + source contribution/attenuation equation for (int g = 0; g < negroups_; g++) { - float sigma_t = - domain_->sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - srh.density_mult(); + float sigma_t = data::mg.macro_xs_[material].get_xs( + MgxsType::TOTAL, g, NULL, NULL, NULL, t, a); float tau = sigma_t * distance; float exponential = cjosey_exponential(tau); // exponential = 1 - exp(-tau) - float new_delta_psi = (angular_flux_[g] - srh.source(g)) * exponential; + float new_delta_psi = + (angular_flux_[g] - domain_->source_[source_element + g]) * exponential; delta_psi_[g] = new_delta_psi; angular_flux_[g] -= new_delta_psi; } - // If ray is in the active phase (not in dead zone), make contributions to - // source region bookkeeping - - // Aquire lock for source region - srh.lock(); - - if (is_active) { - // Accumulate delta psi into new estimate of source region flux for - // this iteration - for (int g = 0; g < negroups_; g++) { - srh.scalar_flux_new(g) += delta_psi_[g]; - } - - // Accomulate volume (ray distance) into this iteration's estimate - // of the source region's volume - srh.volume() += distance; - - srh.n_hits() += 1; - } - - // Tally valid position inside the source region (e.g., midpoint of - // the ray) if not done already - if (!srh.position_recorded()) { - Position midpoint = r + u() * (distance / 2.0); - srh.position() = midpoint; - srh.position_recorded() = 1; - } - - // Release lock - srh.unlock(); -} - -// Alternative flux attenuation function for true void regions. -void RandomRay::attenuate_flux_flat_source_void( - SourceRegionHandle& srh, double distance, bool is_active, Position r) -{ - // The number of geometric intersections is counted for reporting purposes - n_event()++; - - int material = srh.material(); - // If ray is in the active phase (not in dead zone), make contributions to // source region bookkeeping if (is_active) { // Aquire lock for source region - srh.lock(); + domain_->lock_[source_region].lock(); // Accumulate delta psi into new estimate of source region flux for // this iteration for (int g = 0; g < negroups_; g++) { - srh.scalar_flux_new(g) += angular_flux_[g] * distance; + domain_->scalar_flux_new_[source_element + g] += delta_psi_[g]; + } + + // If the source region hasn't been hit yet this iteration, + // indicate that it now has + if (domain_->was_hit_[source_region] == 0) { + domain_->was_hit_[source_region] = 1; } // Accomulate volume (ray distance) into this iteration's estimate // of the source region's volume - srh.volume() += distance; - srh.volume_sq() += distance * distance; - srh.n_hits() += 1; + domain_->volume_[source_region] += distance; // Tally valid position inside the source region (e.g., midpoint of // the ray) if not done already - if (!srh.position_recorded()) { - Position midpoint = r + u() * (distance / 2.0); - srh.position() = midpoint; - srh.position_recorded() = 1; + if (!domain_->position_recorded_[source_region]) { + Position midpoint = r() + u() * (distance / 2.0); + domain_->position_[source_region] = midpoint; + domain_->position_recorded_[source_region] = 1; } // Release lock - srh.unlock(); - } - - // Add source to incoming angular flux, assuming void region - if (settings::run_mode == RunMode::FIXED_SOURCE) { - for (int g = 0; g < negroups_; g++) { - angular_flux_[g] += srh.external_source(g) * distance; - } - } -} - -void RandomRay::attenuate_flux_linear_source( - SourceRegionHandle& srh, double distance, bool is_active, Position r) -{ - // The number of geometric intersections is counted for reporting purposes - n_event()++; - - int material = srh.material(); - int temp = srh.temperature_idx(); - - Position& centroid = srh.centroid(); - Position midpoint = r + u() * (distance / 2.0); - - // Determine the local position of the midpoint and the ray origin - // relative to the source region's centroid - Position rm_local; - Position r0_local; - - // In the first few iterations of the simulation, the source region - // may not yet have had any ray crossings, in which case there will - // be no estimate of its centroid. We detect this by checking if it has - // any accumulated volume. If its volume is zero, just use the midpoint - // of the ray as the region's centroid. - if (srh.volume_t()) { - rm_local = midpoint - centroid; - r0_local = r - centroid; - } else { - rm_local = {0.0, 0.0, 0.0}; - r0_local = -u() * 0.5 * distance; - } - double distance_2 = distance * distance; - - // Linear Source MOC incoming flux attenuation + source - // contribution/attenuation equation - for (int g = 0; g < negroups_; g++) { - - // Compute tau, the optical thickness of the ray segment - float sigma_t = - domain_->sigma_t_[(material * ntemperature_ + temp) * negroups_ + g] * - srh.density_mult(); - float tau = sigma_t * distance; - - // If tau is very small, set it to zero to avoid numerical issues. - // The following computations will still work with tau = 0. - if (tau < 1.0e-8f) { - tau = 0.0f; - } - - // Compute linear source terms, spatial and directional (dir), - // calculated from the source gradients dot product with local centroid - // and direction, respectively. - float spatial_source = - srh.source(g) + rm_local.dot(srh.source_gradients(g)); - float dir_source = u().dot(srh.source_gradients(g)); - - float gn = exponentialG(tau); - float f1 = 1.0f - tau * gn; - float f2 = (2.0f * gn - f1) * distance_2; - float new_delta_psi = (angular_flux_[g] - spatial_source) * f1 * distance - - 0.5 * dir_source * f2; - - float h1 = f1 - gn; - float g1 = 0.5f - h1; - float g2 = exponentialG2(tau); - g1 = g1 * spatial_source; - g2 = g2 * dir_source * distance * 0.5f; - h1 = h1 * angular_flux_[g]; - h1 = (g1 + g2 + h1) * distance_2; - spatial_source = spatial_source * distance + new_delta_psi; - - // Store contributions for this group into arrays, so that they can - // be accumulated into the source region's estimates inside of the locked - // region. - delta_psi_[g] = new_delta_psi; - delta_moments_[g] = r0_local * spatial_source + u() * h1; - - // Update the angular flux for this group - angular_flux_[g] -= new_delta_psi * sigma_t; - - // If 2D mode is enabled, the z-component of the flux moments is forced - // to zero - if (source_shape_ == RandomRaySourceShape::LINEAR_XY) { - delta_moments_[g].z = 0.0; - } - } - - // Compute an estimate of the spatial moments matrix for the source - // region based on parameters from this ray's crossing - MomentMatrix moment_matrix_estimate; - moment_matrix_estimate.compute_spatial_moments_matrix( - rm_local, u(), distance); - - // Aquire lock for source region - srh.lock(); - - // If ray is in the active phase (not in dead zone), make contributions to - // source region bookkeeping - - if (is_active) { - // Accumulate deltas into the new estimate of source region flux for this - // iteration - for (int g = 0; g < negroups_; g++) { - srh.scalar_flux_new(g) += delta_psi_[g]; - srh.flux_moments_new(g) += delta_moments_[g]; - } - - // Accumulate the volume (ray segment distance), centroid, and spatial - // momement estimates into the running totals for the iteration for this - // source region. The centroid and spatial momements estimates are scaled - // by the ray segment length as part of length averaging of the estimates. - srh.volume() += distance; - srh.centroid_iteration() += midpoint * distance; - moment_matrix_estimate *= distance; - srh.mom_matrix() += moment_matrix_estimate; - - srh.n_hits() += 1; - } - - // Tally valid position inside the source region (e.g., midpoint of - // the ray) if not done already - if (!srh.position_recorded()) { - srh.position() = midpoint; - srh.position_recorded() = 1; - } - - // Release lock - srh.unlock(); -} - -// If traveling through a void region, the source term is either zero -// or an external source. As all external sources are currently assumed -// to be flat, we don't really need this function and could instead just call -// the "attenuate_flux_flat_source_void" function and get the same numerical and -// tally results. However, computation of the flux moments in void regions is -// nonetheless useful as this information is still used by the plotter when -// estimating the flux at specific pixel coordinates. Thus, plots will look -// nicer/more accurate if we record flux moments, so this function is useful. -void RandomRay::attenuate_flux_linear_source_void( - SourceRegionHandle& srh, double distance, bool is_active, Position r) -{ - // The number of geometric intersections is counted for reporting purposes - n_event()++; - - Position& centroid = srh.centroid(); - Position midpoint = r + u() * (distance / 2.0); - - // Determine the local position of the midpoint and the ray origin - // relative to the source region's centroid - Position rm_local; - Position r0_local; - - // In the first few iterations of the simulation, the source region - // may not yet have had any ray crossings, in which case there will - // be no estimate of its centroid. We detect this by checking if it has - // any accumulated volume. If its volume is zero, just use the midpoint - // of the ray as the region's centroid. - if (srh.volume_t()) { - rm_local = midpoint - centroid; - r0_local = r - centroid; - } else { - rm_local = {0.0, 0.0, 0.0}; - r0_local = -u() * 0.5 * distance; - } - double distance_2 = distance * distance; - - // Compared to linear flux attenuation through solid regions, - // transport through a void region is greatly simplified. Here we - // compute the updated flux moments. - for (int g = 0; g < negroups_; g++) { - float spatial_source = 0.f; - if (settings::run_mode == RunMode::FIXED_SOURCE) { - spatial_source = srh.external_source(g); - } - float new_delta_psi = (angular_flux_[g] - spatial_source) * distance; - float h1 = 0.5f; - h1 = h1 * angular_flux_[g]; - h1 = h1 * distance_2; - spatial_source = spatial_source * distance + new_delta_psi; - - // Store contributions for this group into arrays, so that they can - // be accumulated into the source region's estimates inside of the locked - // region. - delta_moments_[g] = r0_local * spatial_source + u() * h1; - - // If 2D mode is enabled, the z-component of the flux moments is forced - // to zero - if (source_shape_ == RandomRaySourceShape::LINEAR_XY) { - delta_moments_[g].z = 0.0; - } - } - - // If ray is in the active phase (not in dead zone), make contributions to - // source region bookkeeping - if (is_active) { - // Compute an estimate of the spatial moments matrix for the source - // region based on parameters from this ray's crossing - MomentMatrix moment_matrix_estimate; - moment_matrix_estimate.compute_spatial_moments_matrix( - rm_local, u(), distance); - - // Aquire lock for source region - srh.lock(); - - // Accumulate delta psi into new estimate of source region flux for - // this iteration, and update flux momements - for (int g = 0; g < negroups_; g++) { - srh.scalar_flux_new(g) += angular_flux_[g] * distance; - srh.flux_moments_new(g) += delta_moments_[g]; - } - - // Accumulate the volume (ray segment distance), centroid, and spatial - // momement estimates into the running totals for the iteration for this - // source region. The centroid and spatial momements estimates are scaled by - // the ray segment length as part of length averaging of the estimates. - srh.volume() += distance; - srh.volume_sq() += distance_2; - srh.centroid_iteration() += midpoint * distance; - moment_matrix_estimate *= distance; - srh.mom_matrix() += moment_matrix_estimate; - - // Tally valid position inside the source region (e.g., midpoint of - // the ray) if not done already - if (!srh.position_recorded()) { - srh.position() = midpoint; - srh.position_recorded() = 1; - } - - srh.n_hits() += 1; - - // Release lock - srh.unlock(); - } - - // Add source to incoming angular flux, assuming void region - if (settings::run_mode == RunMode::FIXED_SOURCE) { - for (int g = 0; g < negroups_; g++) { - angular_flux_[g] += srh.external_source(g) * distance; - } + domain_->lock_[source_region].unlock(); } } void RandomRay::initialize_ray(uint64_t ray_id, FlatSourceDomain* domain) { domain_ = domain; - ntemperature_ = domain->ntemperature_; // Reset particle event counter n_event() = 0; @@ -781,54 +248,8 @@ void RandomRay::initialize_ray(uint64_t ray_id, FlatSourceDomain* domain) wgt() = 1.0; // set identifier for particle - id() = ray_id; + id() = simulation::work_index[mpi::rank] + ray_id; - // generate source site using sample method - SourceSite site; - switch (sample_method_) { - case RandomRaySampleMethod::PRNG: - site = sample_prng(); - break; - case RandomRaySampleMethod::HALTON: - site = sample_halton(); - break; - case RandomRaySampleMethod::S2: - site = sample_s2(); - break; - default: - fatal_error("Unknown sample method for random ray transport."); - } - - site.E = 0.0; - this->from_source(&site); - - // Locate ray - if (lowest_coord().cell() == C_NONE) { - if (!exhaustive_find_cell(*this)) { - this->mark_as_lost( - "Could not find the cell containing particle " + std::to_string(id())); - } - - // Set birth cell attribute - if (cell_born() == C_NONE) - cell_born() = lowest_coord().cell(); - } - - SourceRegionKey sr_key = domain_->lookup_source_region_key(*this); - SourceRegionHandle srh = - domain_->get_subdivided_source_region_handle(sr_key, r(), u()); - - // Initialize ray's starting angular flux to starting location's isotropic - // source - if (!srh.is_numerical_fp_artifact_) { - for (int g = 0; g < negroups_; g++) { - angular_flux_[g] = srh.source(g); - } - } -} - -SourceSite RandomRay::sample_prng() -{ // set random number seed int64_t particle_seed = (simulation::current_batch - 1) * settings::n_particles + id(); @@ -837,67 +258,32 @@ SourceSite RandomRay::sample_prng() // Sample from ray source distribution SourceSite site {ray_source_->sample(current_seed())}; + site.E = lower_bound_index( + data::mg.rev_energy_bins_.begin(), data::mg.rev_energy_bins_.end(), site.E); + site.E = negroups_ - site.E - 1.; + this->from_source(&site); - return site; -} + // Locate ray + if (lowest_coord().cell == C_NONE) { + if (!exhaustive_find_cell(*this)) { + this->mark_as_lost( + "Could not find the cell containing particle " + std::to_string(id())); + } -SourceSite RandomRay::sample_halton() -{ - SourceSite site; + // Set birth cell attribute + if (cell_born() == C_NONE) + cell_born() = lowest_coord().cell; + } - // Set random number seed - int64_t batch_seed = (simulation::current_batch - 1) * settings::n_particles; - int64_t skip = id(); - init_particle_seeds(batch_seed, seeds()); - stream() = STREAM_TRACKING; + // Initialize ray's starting angular flux to starting location's isotropic + // source + int i_cell = lowest_coord().cell; + int64_t source_region_idx = + domain_->source_region_offsets_[i_cell] + cell_instance(); - // Calculate next samples in LDS across 5 dimensions - vector samples = rhalton(5, current_seed(), skip = skip); - - // Get spatial box of ray_source_ - SpatialBox* sb = dynamic_cast( - dynamic_cast(RandomRay::ray_source_.get())->space()); - - // Sample spatial distribution - Position xi {samples[0], samples[1], samples[2]}; - // make a small shift in position to avoid geometry floating point issues - Position shift {FP_COINCIDENT, FP_COINCIDENT, FP_COINCIDENT}; - site.r = (sb->lower_left() + shift) + - xi * ((sb->upper_right() - shift) - (sb->lower_left() + shift)); - - // Sample Polar cosine and azimuthal angles - double mu = 2.0 * samples[3] - 1.0; - double azi = 2.0 * PI * samples[4]; - // Convert to Cartesian coordinates - double c = std::sqrt(1.0 - mu * mu); - site.u.x = mu; - site.u.y = std::cos(azi) * c; - site.u.z = std::sin(azi) * c; - - return site; -} - -SourceSite RandomRay::sample_s2() -{ - // set random number seed - int64_t particle_seed = - (simulation::current_batch - 1) * settings::n_particles + id(); - init_particle_seeds(particle_seed, seeds()); - stream() = STREAM_TRACKING; - - // Get spatial component of the ray_source_ - SpatialDistribution* space = - dynamic_cast(RandomRay::ray_source_.get())->space(); - - SourceSite site; - - // Sample spatial distribution - site.r = space->sample(current_seed()).first; - - // Sample either left or right for S2 (flashlight) transport. - site.u = {prn(current_seed()) < 0.5 ? -1.0 : 1.0, 0.0, 0.0}; - - return site; + for (int g = 0; g < negroups_; g++) { + angular_flux_[g] = domain_->source_[source_region_idx * negroups_ + g]; + } } } // namespace openmc diff --git a/src/random_ray/random_ray_simulation.cpp b/src/random_ray/random_ray_simulation.cpp index 6d6f2c743..17866c302 100644 --- a/src/random_ray/random_ray_simulation.cpp +++ b/src/random_ray/random_ray_simulation.cpp @@ -1,13 +1,11 @@ #include "openmc/random_ray/random_ray_simulation.h" -#include "openmc/capi.h" #include "openmc/eigenvalue.h" #include "openmc/geometry.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/output.h" #include "openmc/plot.h" -#include "openmc/random_ray/flat_source_domain.h" #include "openmc/random_ray/random_ray.h" #include "openmc/simulation.h" #include "openmc/source.h" @@ -15,7 +13,6 @@ #include "openmc/tallies/tally.h" #include "openmc/tallies/tally_scoring.h" #include "openmc/timer.h" -#include "openmc/weight_windows.h" namespace openmc { @@ -23,6 +20,37 @@ namespace openmc { // Non-member functions //============================================================================== +void openmc_run_random_ray() +{ + // Initialize OpenMC general data structures + openmc_simulation_init(); + + // Validate that inputs meet requirements for random ray mode + if (mpi::master) + validate_random_ray_inputs(); + + // Initialize Random Ray Simulation Object + RandomRaySimulation sim; + + // Begin main simulation timer + simulation::time_total.start(); + + // Execute random ray simulation + sim.simulate(); + + // End main simulation timer + openmc::simulation::time_total.stop(); + + // Finalize OpenMC + openmc_simulation_finalize(); + + // Reduce variables across MPI ranks + sim.reduce_simulation_statistics(); + + // Output all simulation results + sim.output_simulation_results(); +} + // Enforces restrictions on inputs in random ray mode. While there are // many features that don't make sense in random ray mode, and are therefore // unsupported, we limit our testing/enforcement operations only to inputs @@ -41,12 +69,11 @@ void validate_random_ray_inputs() case SCORE_FISSION: case SCORE_NU_FISSION: case SCORE_EVENTS: - case SCORE_KAPPA_FISSION: break; default: fatal_error( - "Invalid score specified. Only flux, total, fission, nu-fission, " - "kappa-fission, and event scores are supported in random ray mode."); + "Invalid score specified. Only flux, total, fission, nu-fission, and " + "event scores are supported in random ray mode."); } } @@ -62,7 +89,6 @@ void validate_random_ray_inputs() case FilterType::MATERIAL: case FilterType::MESH: case FilterType::UNIVERSE: - case FilterType::PARTICLE: break; default: fatal_error("Invalid filter specified. Only cell, cell_instance, " @@ -79,22 +105,9 @@ void validate_random_ray_inputs() fatal_error("Anisotropic MGXS detected. Only isotropic XS data sets " "supported in random ray mode."); } - for (int g = 0; g < data::mg.num_energy_groups_; g++) { - if (material.exists_in_model) { - // Temperature and angle indices, if using multiple temperature - // data sets and/or anisotropic data sets. - // TODO: Currently assumes we are only using single temp/single angle - // data. - const int t = 0; - const int a = 0; - double sigma_t = - material.get_xs(MgxsType::TOTAL, g, NULL, NULL, NULL, t, a); - if (sigma_t <= 0.0) { - fatal_error("No zero or negative total macroscopic cross sections " - "allowed in random ray mode. If the intention is to make " - "a void material, use a cell fill of 'None' instead."); - } - } + if (material.get_xsdata().size() > 1) { + fatal_error("Non-isothermal MGXS detected. Only isothermal XS data sets " + "supported in random ray mode."); } } @@ -161,19 +174,10 @@ void validate_random_ray_inputs() "allowed in random ray mode."); } - // Validate that a domain ID was specified OR that it is a point source - auto sp = dynamic_cast(is->space()); - if (is->domain_ids().size() == 0 && !sp) { - fatal_error("Fixed sources must be point source or spatially " - "constrained by domain id (cell, material, or universe) in " - "random ray mode."); - } else if (is->domain_ids().size() > 0 && sp) { - // If both a domain constraint and a point source location are - // specified, notify user that domain constraint takes precedence. - warning("Fixed source has both a domain constraint and a point " - "type spatial distribution. The domain constraint takes " - "precedence in random ray mode -- point source coordinate " - "will be ignored."); + // Validate that a domain ID was specified + if (is->domain_ids().size() == 0) { + fatal_error("Fixed sources must be specified by domain " + "id (cell, material, or universe) in random ray mode."); } // Check that a discrete energy distribution was used @@ -187,76 +191,25 @@ void validate_random_ray_inputs() } } - // Validate adjoint sources - /////////////////////////////////////////////////////////////////// - if (FlatSourceDomain::adjoint_requested_ && !model::adjoint_sources.empty()) { - for (int i = 0; i < model::adjoint_sources.size(); i++) { - Source* s = model::adjoint_sources[i].get(); - - // Check for independent source - IndependentSource* is = dynamic_cast(s); - - if (!is) { - fatal_error( - "Only IndependentSource adjoint source types are allowed in " - "random ray mode"); - } - - // Check for isotropic source - UnitSphereDistribution* angle_dist = is->angle(); - Isotropic* id = dynamic_cast(angle_dist); - if (!id) { - fatal_error( - "Invalid source definition -- only isotropic adjoint sources are " - "allowed in random ray mode."); - } - - // Validate that a domain ID was specified OR that it is a point source - auto sp = dynamic_cast(is->space()); - if (is->domain_ids().size() == 0 && !sp) { - fatal_error("Adjoint sources must be point source or spatially " - "constrained by domain id (cell, material, or universe) in " - "random ray mode."); - } else if (is->domain_ids().size() > 0 && sp) { - // If both a domain constraint and a point source location are - // specified, notify user that domain constraint takes precedence. - warning("Adjoint source has both a domain constraint and a point " - "type spatial distribution. The domain constraint takes " - "precedence in random ray mode -- point source coordinate " - "will be ignored."); - } - - // Check that a discrete energy distribution was used - Distribution* d = is->energy(); - Discrete* dd = dynamic_cast(d); - if (!dd) { - fatal_error( - "Only discrete (multigroup) energy distributions are allowed for " - "adjoint sources in random ray mode."); - } - } - } - // Validate plotting files /////////////////////////////////////////////////////////////////// for (int p = 0; p < model::plots.size(); p++) { // Get handle to OpenMC plot object - const auto& openmc_plottable = model::plots[p]; - Plot* openmc_plot = dynamic_cast(openmc_plottable.get()); + Plot* openmc_plot = dynamic_cast(model::plots[p].get()); // Random ray plots only support voxel plots if (!openmc_plot) { warning(fmt::format( "Plot {} will not be used for end of simulation data plotting -- only " "voxel plotting is allowed in random ray mode.", - openmc_plottable->id())); + p)); continue; } else if (openmc_plot->type_ != Plot::PlotType::voxel) { warning(fmt::format( "Plot {} will not be used for end of simulation data plotting -- only " "voxel plotting is allowed in random ray mode.", - openmc_plottable->id())); + p)); continue; } } @@ -266,37 +219,12 @@ void validate_random_ray_inputs() #ifdef OPENMC_MPI if (mpi::n_procs > 1) { warning( - "MPI parallelism is not supported by the random ray solver. All work " - "will be performed by rank 0. Domain decomposition may be implemented in " - "the future to provide efficient MPI scaling."); + "Domain replication in random ray is supported, but suffers from poor " + "scaling of source all-reduce operations. Performance may severely " + "degrade beyond just a few MPI ranks. Domain decomposition may be " + "implemented in the future to provide efficient scaling."); } #endif - - // Warn about instability resulting from linear sources in small regions - // when generating weight windows with FW-CADIS and an overlaid mesh. - /////////////////////////////////////////////////////////////////// - if (RandomRay::source_shape_ == RandomRaySourceShape::LINEAR && - variance_reduction::weight_windows.size() > 0) { - warning( - "Linear sources may result in negative fluxes in small source regions " - "generated by mesh subdivision. Negative sources may result in low " - "quality FW-CADIS weight windows. We recommend you use flat source " - "mode when generating weight windows with an overlaid mesh tally."); - } -} - -void openmc_finalize_random_ray() -{ - FlatSourceDomain::volume_estimator_ = RandomRayVolumeEstimator::HYBRID; - FlatSourceDomain::volume_normalized_flux_tallies_ = false; - FlatSourceDomain::adjoint_requested_ = false; - FlatSourceDomain::solve_ = RandomRaySolve::FORWARD; - FlatSourceDomain::fw_cadis_local_ = false; - FlatSourceDomain::fw_cadis_local_targets_.clear(); - FlatSourceDomain::mesh_domain_map_.clear(); - RandomRay::ray_source_.reset(); - RandomRay::source_shape_ = RandomRaySourceShape::FLAT; - RandomRay::sample_method_ = RandomRaySampleMethod::PRNG; } //============================================================================== @@ -313,198 +241,104 @@ RandomRaySimulation::RandomRaySimulation() // Random ray mode does not have an inner loop over generations within a // batch, so set the current gen to 1 simulation::current_gen = 1; - - switch (RandomRay::source_shape_) { - case RandomRaySourceShape::FLAT: - domain_ = make_unique(); - break; - case RandomRaySourceShape::LINEAR: - case RandomRaySourceShape::LINEAR_XY: - domain_ = make_unique(); - break; - default: - fatal_error("Unknown random ray source shape"); - } - - // Convert OpenMC native MGXS into a more efficient format - // internal to the random ray solver - domain_->flatten_xs(); -} - -void RandomRaySimulation::apply_fixed_sources_and_mesh_domains() -{ - domain_->apply_meshes(); - if (settings::run_mode == RunMode::FIXED_SOURCE) { - // Transfer external source user inputs onto random ray source regions - domain_->convert_external_sources(false); - domain_->count_external_source_regions(); - } -} - -void RandomRaySimulation::prepare_fw_fixed_sources_adjoint() -{ - // Prepare adjoint fixed sources using forward flux - domain_->source_regions_.adjoint_reset(); - if (settings::run_mode == RunMode::FIXED_SOURCE) { - domain_->set_fw_adjoint_sources(); - } -} - -void RandomRaySimulation::prepare_local_fixed_sources_adjoint() -{ - if (settings::run_mode == RunMode::FIXED_SOURCE) { - domain_->set_local_adjoint_sources(); - } -} - -void RandomRaySimulation::prepare_adjoint_simulation(bool from_forward) -{ - reset_timers(); - - if (mpi::master) - header("ADJOINT FLUX SOLVE", 3); - - if (from_forward) { - // The forward solve has already run. Re-initialize OpenMC's general data - // structures for the adjoint solve and derive the adjoint source from the - // forward flux. - openmc_simulation_init(); - - prepare_fw_fixed_sources_adjoint(); - } else { - // Initialize adjoint fixed sources - domain_->apply_meshes(); - prepare_local_fixed_sources_adjoint(); - domain_->count_external_source_regions(); - } - - domain_->k_eff_ = 1.0; - - // Transpose scattering matrix - domain_->transpose_scattering_matrix(); - - // Swap nu_sigma_f and chi - domain_->nu_sigma_f_.swap(domain_->chi_); } void RandomRaySimulation::simulate() { - // Begin main simulation timer - simulation::time_total.start(); - - // Reset per-solve accumulators, as simulate() may run more than once on the - // same object (e.g. forward then adjoint when generating weight windows) - avg_miss_rate_ = 0.0; - total_geometric_intersections_ = 0; + if (settings::run_mode == RunMode::FIXED_SOURCE) { + // Transfer external source user inputs onto random ray source regions + domain_.convert_external_sources(); + domain_.count_external_source_regions(); + } // Random ray power iteration loop while (simulation::current_batch < settings::n_batches) { + // Initialize the current batch initialize_batch(); initialize_generation(); - // MPI not supported in random ray solver, so all work is done by rank 0 - // TODO: Implement domain decomposition for MPI parallelism - if (mpi::master) { + // Reset total starting particle weight used for normalizing tallies + simulation::total_weight = 1.0; - // Reset total starting particle weight used for normalizing tallies - simulation::total_weight = 1.0; + // Update source term (scattering + fission) + domain_.update_neutron_source(k_eff_); - // Update source term (scattering + fission) - domain_->update_all_neutron_sources(); + // Reset scalar fluxes, iteration volume tallies, and region hit flags to + // zero + domain_.batch_reset(); - // Reset scalar fluxes, iteration volume tallies, and region hit flags - // to zero - domain_->batch_reset(); - - // At the beginning of the simulation, if mesh subdivision is in use, we - // need to swap the main source region container into the base container, - // as the main source region container will be used to hold the true - // subdivided source regions. The base container will therefore only - // contain the external source region information, the mesh indices, - // material properties, and initial guess values for the flux/source. - - // Start timer for transport - simulation::time_transport.start(); + // Start timer for transport + simulation::time_transport.start(); // Transport sweep over all random rays for the iteration #pragma omp parallel for schedule(dynamic) \ reduction(+ : total_geometric_intersections_) - for (int i = 0; i < settings::n_particles; i++) { - RandomRay ray(i, domain_.get()); - total_geometric_intersections_ += - ray.transport_history_based_single_ray(); + for (int i = 0; i < simulation::work_per_rank; i++) { + RandomRay ray(i, &domain_); + total_geometric_intersections_ += + ray.transport_history_based_single_ray(); + } + + simulation::time_transport.stop(); + + // If using multiple MPI ranks, perform all reduce on all transport results + domain_.all_reduce_replicated_source_regions(); + + // Normalize scalar flux and update volumes + domain_.normalize_scalar_flux_and_volumes( + settings::n_particles * RandomRay::distance_active_); + + // Add source to scalar flux, compute number of FSR hits + int64_t n_hits = domain_.add_source_to_scalar_flux(); + + if (settings::run_mode == RunMode::EIGENVALUE) { + // Compute random ray k-eff + k_eff_ = domain_.compute_k_eff(k_eff_); + + // Store random ray k-eff into OpenMC's native k-eff variable + global_tally_tracklength = k_eff_; + } + + // Execute all tallying tasks, if this is an active batch + if (simulation::current_batch > settings::n_inactive && mpi::master) { + + // Generate mapping between source regions and tallies + if (!domain_.mapped_all_tallies_) { + domain_.convert_source_regions_to_tallies(); } - simulation::time_transport.stop(); + // Use above mapping to contribute FSR flux data to appropriate tallies + domain_.random_ray_tally(); - // Add any newly discovered source regions to the main source region - // container. - domain_->finalize_discovered_source_regions(); + // Add this iteration's scalar flux estimate to final accumulated estimate + domain_.accumulate_iteration_flux(); + } - // Normalize scalar flux and update volumes - domain_->normalize_scalar_flux_and_volumes( - settings::n_particles * RandomRay::distance_active_); + // Set phi_old = phi_new + domain_.scalar_flux_old_.swap(domain_.scalar_flux_new_); - // Add source to scalar flux, compute number of FSR hits - int64_t n_hits = domain_->add_source_to_scalar_flux(); - - // Apply transport stabilization factors - domain_->apply_transport_stabilization(); - - if (settings::run_mode == RunMode::EIGENVALUE) { - // Compute random ray k-eff - domain_->compute_k_eff(); - - // Store random ray k-eff into OpenMC's native k-eff variable - global_tally_tracklength = domain_->k_eff_; - } - - // Execute all tallying tasks, if this is an active batch - if (simulation::current_batch > settings::n_inactive) { - - // Add this iteration's scalar flux estimate to final accumulated - // estimate - domain_->accumulate_iteration_flux(); - - // Use above mapping to contribute FSR flux data to appropriate - // tallies - domain_->random_ray_tally(); - } - - // Set phi_old = phi_new - domain_->flux_swap(); - - // Check for any obvious insabilities/nans/infs - instability_check(n_hits, domain_->k_eff_, avg_miss_rate_); - } // End MPI master work + // Check for any obvious insabilities/nans/infs + instability_check(n_hits, k_eff_, avg_miss_rate_); // Finalize the current batch finalize_generation(); finalize_batch(); } // End random ray power iteration loop +} - domain_->count_external_source_regions(); - - // End main simulation timer - simulation::time_total.stop(); - - // Normalize and save the final forward flux - double source_normalization_factor = - domain_->compute_fixed_source_normalization_factor() / - (settings::n_batches - settings::n_inactive); - -#pragma omp parallel for - for (uint64_t se = 0; se < domain_->n_source_elements(); se++) { - domain_->source_regions_.scalar_flux_final(se) *= - source_normalization_factor; +void RandomRaySimulation::reduce_simulation_statistics() +{ + // Reduce number of intersections +#ifdef OPENMC_MPI + if (mpi::n_procs > 1) { + uint64_t total_geometric_intersections_reduced = 0; + MPI_Reduce(&total_geometric_intersections_, + &total_geometric_intersections_reduced, 1, MPI_UNSIGNED_LONG, MPI_SUM, 0, + mpi::intracomm); + total_geometric_intersections_ = total_geometric_intersections_reduced; } - - // Finalize OpenMC - openmc_simulation_finalize(); - - // Output all simulation results - output_simulation_results(); +#endif } void RandomRaySimulation::output_simulation_results() const @@ -513,9 +347,9 @@ void RandomRaySimulation::output_simulation_results() const if (mpi::master) { print_results_random_ray(total_geometric_intersections_, avg_miss_rate_ / settings::n_batches, negroups_, - domain_->n_source_regions(), domain_->n_external_source_regions_); + domain_.n_source_regions_, domain_.n_external_source_regions_); if (model::plots.size() > 0) { - domain_->output_to_vtk(); + domain_.output_to_vtk(); } } } @@ -525,28 +359,25 @@ void RandomRaySimulation::output_simulation_results() const void RandomRaySimulation::instability_check( int64_t n_hits, double k_eff, double& avg_miss_rate) const { - double percent_missed = ((domain_->n_source_regions() - n_hits) / - static_cast(domain_->n_source_regions())) * + double percent_missed = ((domain_.n_source_regions_ - n_hits) / + static_cast(domain_.n_source_regions_)) * 100.0; avg_miss_rate += percent_missed; - if (mpi::master) { - if (percent_missed > 10.0) { - warning(fmt::format( - "Very high FSR miss rate detected ({:.3f}%). Instability may occur. " - "Increase ray density by adding more rays and/or active distance.", - percent_missed)); - } else if (percent_missed > 1.0) { - warning( - fmt::format("Elevated FSR miss rate detected ({:.3f}%). Increasing " - "ray density by adding more rays and/or active " - "distance may improve simulation efficiency.", - percent_missed)); - } + if (percent_missed > 10.0) { + warning(fmt::format( + "Very high FSR miss rate detected ({:.3f}%). Instability may occur. " + "Increase ray density by adding more rays and/or active distance.", + percent_missed)); + } else if (percent_missed > 0.01) { + warning(fmt::format("Elevated FSR miss rate detected ({:.3f}%). Increasing " + "ray density by adding more rays and/or active " + "distance may improve simulation efficiency.", + percent_missed)); + } - if (k_eff > 10.0 || k_eff < 0.01 || !(std::isfinite(k_eff))) { - fatal_error(fmt::format("Instability detected: k-eff = {:.5f}", k_eff)); - } + if (k_eff > 10.0 || k_eff < 0.01 || !(std::isfinite(k_eff))) { + fatal_error("Instability detected"); } } @@ -568,85 +399,23 @@ void RandomRaySimulation::print_results_random_ray( header("Simulation Statistics", 4); fmt::print( " Total Iterations = {}\n", settings::n_batches); + fmt::print(" Flat Source Regions (FSRs) = {}\n", n_source_regions); fmt::print( - " Number of Rays per Iteration = {}\n", settings::n_particles); - fmt::print(" Inactive Distance = {} cm\n", - RandomRay::distance_inactive_); - fmt::print(" Active Distance = {} cm\n", - RandomRay::distance_active_); - fmt::print(" Source Regions (SRs) = {}\n", n_source_regions); - fmt::print( - " SRs Containing External Sources = {}\n", n_external_source_regions); + " FSRs Containing External Sources = {}\n", n_external_source_regions); fmt::print(" Total Geometric Intersections = {:.4e}\n", static_cast(total_geometric_intersections)); fmt::print(" Avg per Iteration = {:.4e}\n", static_cast(total_geometric_intersections) / settings::n_batches); - fmt::print(" Avg per Iteration per SR = {:.2f}\n", + fmt::print(" Avg per Iteration per FSR = {:.2f}\n", static_cast(total_geometric_intersections) / static_cast(settings::n_batches) / n_source_regions); - fmt::print(" Avg SR Miss Rate per Iteration = {:.4f}%\n", avg_miss_rate); + fmt::print(" Avg FSR Miss Rate per Iteration = {:.4f}%\n", avg_miss_rate); fmt::print(" Energy Groups = {}\n", negroups); fmt::print( " Total Integrations = {:.4e}\n", total_integrations); fmt::print(" Avg per Iteration = {:.4e}\n", total_integrations / settings::n_batches); - std::string estimator; - switch (domain_->volume_estimator_) { - case RandomRayVolumeEstimator::SIMULATION_AVERAGED: - estimator = "Simulation Averaged"; - break; - case RandomRayVolumeEstimator::NAIVE: - estimator = "Naive"; - break; - case RandomRayVolumeEstimator::HYBRID: - estimator = "Hybrid"; - break; - default: - fatal_error("Invalid volume estimator type"); - } - fmt::print(" Volume Estimator Type = {}\n", estimator); - - std::string adjoint_true = - (FlatSourceDomain::solve_ == RandomRaySolve::ADJOINT) ? "ON" : "OFF"; - fmt::print(" Adjoint Flux Mode = {}\n", adjoint_true); - - std::string shape; - switch (RandomRay::source_shape_) { - case RandomRaySourceShape::FLAT: - shape = "Flat"; - break; - case RandomRaySourceShape::LINEAR: - shape = "Linear"; - break; - case RandomRaySourceShape::LINEAR_XY: - shape = "Linear XY"; - break; - default: - fatal_error("Invalid random ray source shape"); - } - fmt::print(" Source Shape = {}\n", shape); - std::string sample_method; - switch (RandomRay::sample_method_) { - case RandomRaySampleMethod::PRNG: - sample_method = "PRNG"; - break; - case RandomRaySampleMethod::HALTON: - sample_method = "Halton"; - break; - case RandomRaySampleMethod::S2: - sample_method = "PRNG S2"; - break; - } - fmt::print(" Sample Method = {}\n", sample_method); - - if (domain_->is_transport_stabilization_needed_) { - fmt::print(" Transport XS Stabilization Used = YES (rho = {:.3f})\n", - FlatSourceDomain::diagonal_stabilization_rho_); - } else { - fmt::print(" Transport XS Stabilization Used = NO\n"); - } - header("Timing Statistics", 4); show_time("Total time for initialization", time_initialize.elapsed()); show_time("Reading cross sections", time_read_xs.elapsed(), 1); @@ -673,56 +442,3 @@ void RandomRaySimulation::print_results_random_ray( } } // namespace openmc - -//============================================================================== -// C API functions -//============================================================================== - -void openmc_run_random_ray() -{ - using namespace openmc; - - // Determine which solves to run. If adjoint results are requested and no - // user-defined adjoint source is present, an initial forward solve is needed - // to construct the adjoint source from the forward flux (FW-CADIS). If the - // user has defined an adjoint source, the forward solve is skipped and only - // the adjoint solve is run. - const bool run_adjoint = FlatSourceDomain::adjoint_requested_; - const bool have_adjoint_source = !model::adjoint_sources.empty(); - const bool run_forward = !(run_adjoint && have_adjoint_source); - - // Set the initial solve type - if (!run_forward) { - FlatSourceDomain::solve_ = RandomRaySolve::ADJOINT; - } else if (run_adjoint) { - FlatSourceDomain::solve_ = RandomRaySolve::FORWARD_FOR_ADJOINT; - } else { - FlatSourceDomain::solve_ = RandomRaySolve::FORWARD; - } - - // Initialize OpenMC general data structures - openmc_simulation_init(); - - // Validate that inputs meet requirements for random ray mode - if (mpi::master) - validate_random_ray_inputs(); - - // Initialize Random Ray Simulation Object - RandomRaySimulation sim; - - // Run the forward solve - if (run_forward) { - // When an adjoint solve follows, report this as the initial forward solve - if (run_adjoint && mpi::master) - header("FORWARD FLUX SOLVE", 3); - sim.apply_fixed_sources_and_mesh_domains(); - sim.simulate(); - } - - // Run the adjoint solve - if (run_adjoint) { - FlatSourceDomain::solve_ = RandomRaySolve::ADJOINT; - sim.prepare_adjoint_simulation(run_forward); - sim.simulate(); - } -} diff --git a/src/random_ray/source_region.cpp b/src/random_ray/source_region.cpp deleted file mode 100644 index 78543c5ab..000000000 --- a/src/random_ray/source_region.cpp +++ /dev/null @@ -1,268 +0,0 @@ -#include "openmc/random_ray/source_region.h" - -#include "openmc/error.h" -#include "openmc/message_passing.h" -#include "openmc/simulation.h" - -namespace openmc { - -//============================================================================== -// SourceRegionHandle implementation -//============================================================================== -SourceRegionHandle::SourceRegionHandle(SourceRegion& sr) - : negroups_(sr.scalar_flux_old_.size()), material_(&sr.material_), - temperature_idx_(&sr.temperature_idx_), density_mult_(&sr.density_mult_), - is_small_(&sr.is_small_), n_hits_(&sr.n_hits_), - is_linear_(sr.source_gradients_.size() > 0), lock_(&sr.lock_), - volume_(&sr.volume_), volume_t_(&sr.volume_t_), volume_sq_(&sr.volume_sq_), - volume_sq_t_(&sr.volume_sq_t_), volume_naive_(&sr.volume_naive_), - position_recorded_(&sr.position_recorded_), - external_source_present_(&sr.external_source_present_), - position_(&sr.position_), centroid_(&sr.centroid_), - centroid_iteration_(&sr.centroid_iteration_), centroid_t_(&sr.centroid_t_), - mom_matrix_(&sr.mom_matrix_), mom_matrix_t_(&sr.mom_matrix_t_), - volume_task_(&sr.volume_task_), mesh_(&sr.mesh_), - parent_sr_(&sr.parent_sr_), scalar_flux_old_(sr.scalar_flux_old_.data()), - scalar_flux_new_(sr.scalar_flux_new_.data()), source_(sr.source_.data()), - external_source_(sr.external_source_.data()), - scalar_flux_final_(sr.scalar_flux_final_.data()), - source_gradients_(sr.source_gradients_.data()), - flux_moments_old_(sr.flux_moments_old_.data()), - flux_moments_new_(sr.flux_moments_new_.data()), - flux_moments_t_(sr.flux_moments_t_.data()), - tally_task_(sr.tally_task_.data()) -{} - -//============================================================================== -// SourceRegion implementation -//============================================================================== -SourceRegion::SourceRegion(int negroups, bool is_linear) -{ - if (settings::run_mode == RunMode::EIGENVALUE) { - // If in eigenvalue mode, set starting flux to guess of 1 - scalar_flux_old_.assign(negroups, 1.0); - } else { - // If in fixed source mode, set starting flux to guess of zero - // and initialize external source arrays - scalar_flux_old_.assign(negroups, 0.0); - external_source_.assign(negroups, 0.0); - } - - scalar_flux_new_.assign(negroups, 0.0); - source_.assign(negroups, 0.0); - scalar_flux_final_.assign(negroups, 0.0); - - tally_task_.resize(negroups); - if (is_linear) { - source_gradients_.resize(negroups); - flux_moments_old_.resize(negroups); - flux_moments_new_.resize(negroups); - flux_moments_t_.resize(negroups); - } -} - -//============================================================================== -// SourceRegionContainer implementation -//============================================================================== - -void SourceRegionContainer::push_back(const SourceRegion& sr) -{ - n_source_regions_++; - - // Scalar fields - material_.push_back(sr.material_); - temperature_idx_.push_back(sr.temperature_idx_); - density_mult_.push_back(sr.density_mult_); - is_small_.push_back(sr.is_small_); - n_hits_.push_back(sr.n_hits_); - lock_.push_back(sr.lock_); - volume_.push_back(sr.volume_); - volume_t_.push_back(sr.volume_t_); - volume_sq_.push_back(sr.volume_sq_); - volume_sq_t_.push_back(sr.volume_sq_t_); - volume_naive_.push_back(sr.volume_naive_); - position_recorded_.push_back(sr.position_recorded_); - external_source_present_.push_back(sr.external_source_present_); - position_.push_back(sr.position_); - volume_task_.push_back(sr.volume_task_); - mesh_.push_back(sr.mesh_); - parent_sr_.push_back(sr.parent_sr_); - - // Only store these fields if is_linear_ is true - if (is_linear_) { - centroid_.push_back(sr.centroid_); - centroid_iteration_.push_back(sr.centroid_iteration_); - centroid_t_.push_back(sr.centroid_t_); - mom_matrix_.push_back(sr.mom_matrix_); - mom_matrix_t_.push_back(sr.mom_matrix_t_); - } - - // Energy-dependent fields - for (int g = 0; g < negroups_; ++g) { - scalar_flux_old_.push_back(sr.scalar_flux_old_[g]); - scalar_flux_new_.push_back(sr.scalar_flux_new_[g]); - scalar_flux_final_.push_back(sr.scalar_flux_final_[g]); - source_.push_back(sr.source_[g]); - if (settings::run_mode == RunMode::FIXED_SOURCE) { - external_source_.push_back(sr.external_source_[g]); - } - - // Only store these fields if is_linear_ is true - if (is_linear_) { - source_gradients_.push_back(sr.source_gradients_[g]); - flux_moments_old_.push_back(sr.flux_moments_old_[g]); - flux_moments_new_.push_back(sr.flux_moments_new_[g]); - flux_moments_t_.push_back(sr.flux_moments_t_[g]); - } - - // Tally tasks - tally_task_.emplace_back(sr.tally_task_[g]); - } -} - -void SourceRegionContainer::assign( - int n_source_regions, const SourceRegion& source_region) -{ - // Clear existing data - n_source_regions_ = 0; - material_.clear(); - temperature_idx_.clear(); - density_mult_.clear(); - is_small_.clear(); - n_hits_.clear(); - lock_.clear(); - volume_.clear(); - volume_t_.clear(); - volume_sq_.clear(); - volume_sq_t_.clear(); - volume_naive_.clear(); - position_recorded_.clear(); - external_source_present_.clear(); - position_.clear(); - mesh_.clear(); - parent_sr_.clear(); - - if (is_linear_) { - centroid_.clear(); - centroid_iteration_.clear(); - centroid_t_.clear(); - mom_matrix_.clear(); - mom_matrix_t_.clear(); - } - - scalar_flux_old_.clear(); - scalar_flux_new_.clear(); - scalar_flux_final_.clear(); - source_.clear(); - external_source_.clear(); - - if (is_linear_) { - source_gradients_.clear(); - flux_moments_old_.clear(); - flux_moments_new_.clear(); - flux_moments_t_.clear(); - } - - tally_task_.clear(); - volume_task_.clear(); - - // Fill with copies of source_region - for (int i = 0; i < n_source_regions; ++i) { - push_back(source_region); - } -} - -void SourceRegionContainer::flux_swap() -{ - scalar_flux_old_.swap(scalar_flux_new_); - if (is_linear_) { - flux_moments_old_.swap(flux_moments_new_); - } -} - -SourceRegionHandle SourceRegionContainer::get_source_region_handle(int64_t sr) -{ - SourceRegionHandle handle; - handle.negroups_ = negroups(); - handle.material_ = &material(sr); - handle.temperature_idx_ = &temperature_idx(sr); - handle.density_mult_ = &density_mult(sr); - handle.is_small_ = &is_small(sr); - handle.n_hits_ = &n_hits(sr); - handle.is_linear_ = is_linear(); - handle.lock_ = &lock(sr); - handle.volume_ = &volume(sr); - handle.volume_t_ = &volume_t(sr); - handle.volume_sq_ = &volume_sq(sr); - handle.volume_sq_t_ = &volume_sq_t(sr); - handle.volume_naive_ = &volume_naive(sr); - handle.position_recorded_ = &position_recorded(sr); - handle.external_source_present_ = &external_source_present(sr); - handle.position_ = &position(sr); - handle.volume_task_ = &volume_task(sr); - handle.mesh_ = &mesh(sr); - handle.parent_sr_ = &parent_sr(sr); - handle.scalar_flux_old_ = &scalar_flux_old(sr, 0); - handle.scalar_flux_new_ = &scalar_flux_new(sr, 0); - handle.source_ = &source(sr, 0); - if (settings::run_mode == RunMode::FIXED_SOURCE) { - handle.external_source_ = &external_source(sr, 0); - } else { - handle.external_source_ = nullptr; - } - handle.scalar_flux_final_ = &scalar_flux_final(sr, 0); - handle.tally_task_ = &tally_task(sr, 0); - - if (handle.is_linear_) { - handle.centroid_ = ¢roid(sr); - handle.centroid_iteration_ = ¢roid_iteration(sr); - handle.centroid_t_ = ¢roid_t(sr); - handle.mom_matrix_ = &mom_matrix(sr); - handle.mom_matrix_t_ = &mom_matrix_t(sr); - handle.source_gradients_ = &source_gradients(sr, 0); - handle.flux_moments_old_ = &flux_moments_old(sr, 0); - handle.flux_moments_new_ = &flux_moments_new(sr, 0); - handle.flux_moments_t_ = &flux_moments_t(sr, 0); - } - - return handle; -} - -void SourceRegionContainer::adjoint_reset() -{ - std::fill(n_hits_.begin(), n_hits_.end(), 0); - std::fill(volume_.begin(), volume_.end(), 0.0); - std::fill(volume_t_.begin(), volume_t_.end(), 0.0); - std::fill(volume_sq_.begin(), volume_sq_.end(), 0.0); - std::fill(volume_sq_t_.begin(), volume_sq_t_.end(), 0.0); - std::fill(volume_naive_.begin(), volume_naive_.end(), 0.0); - std::fill( - external_source_present_.begin(), external_source_present_.end(), 0); - std::fill(external_source_.begin(), external_source_.end(), 0.0); - std::fill(centroid_.begin(), centroid_.end(), Position {0.0, 0.0, 0.0}); - std::fill(centroid_iteration_.begin(), centroid_iteration_.end(), - Position {0.0, 0.0, 0.0}); - std::fill(centroid_t_.begin(), centroid_t_.end(), Position {0.0, 0.0, 0.0}); - std::fill(mom_matrix_.begin(), mom_matrix_.end(), - MomentMatrix {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); - std::fill(mom_matrix_t_.begin(), mom_matrix_t_.end(), - MomentMatrix {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); - if (settings::run_mode == RunMode::FIXED_SOURCE) { - std::fill(scalar_flux_old_.begin(), scalar_flux_old_.end(), 0.0); - } else { - std::fill(scalar_flux_old_.begin(), scalar_flux_old_.end(), 1.0); - } - std::fill(scalar_flux_new_.begin(), scalar_flux_new_.end(), 0.0); - std::fill(source_.begin(), source_.end(), 0.0f); - std::fill(external_source_.begin(), external_source_.end(), 0.0f); - std::fill(source_gradients_.begin(), source_gradients_.end(), - MomentArray {0.0, 0.0, 0.0}); - std::fill(flux_moments_old_.begin(), flux_moments_old_.end(), - MomentArray {0.0, 0.0, 0.0}); - std::fill(flux_moments_new_.begin(), flux_moments_new_.end(), - MomentArray {0.0, 0.0, 0.0}); - std::fill(flux_moments_t_.begin(), flux_moments_t_.end(), - MomentArray {0.0, 0.0, 0.0}); -} - -} // namespace openmc diff --git a/src/ray.cpp b/src/ray.cpp deleted file mode 100644 index 3d848e3a3..000000000 --- a/src/ray.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include "openmc/ray.h" - -#include "openmc/error.h" -#include "openmc/geometry.h" -#include "openmc/settings.h" - -namespace openmc { - -void Ray::compute_distance() -{ - boundary() = distance_to_boundary(*this); -} - -void Ray::trace() -{ - // To trace the ray from its origin all the way through the model, we have - // to proceed in two phases. In the first, the ray may or may not be found - // inside the model. If the ray is already in the model, phase one can be - // skipped. Otherwise, the ray has to be advanced to the boundary of the - // model where all the cells are defined. Importantly, this is assuming that - // the model is convex, which is a very reasonable assumption for any - // radiation transport model. - // - // After phase one is done, we can starting tracing from cell to cell within - // the model. This step can use neighbor lists to accelerate the ray tracing. - - bool inside_cell; - // Check for location if the particle is already known - if (lowest_coord().cell() == C_NONE) { - // The geometry position of the particle is either unknown or outside of the - // edge of the model. - if (lowest_coord().universe() == C_NONE) { - // Attempt to initialize the particle. We may have to - // enter a loop to move it up to the edge of the model. - inside_cell = exhaustive_find_cell(*this, settings::verbosity >= 10); - } else { - // It has been already calculated that the current position is outside of - // the edge of the model. - inside_cell = false; - } - } else { - // Availability of the cell means that the particle is located inside the - // edge. - inside_cell = true; - } - - // Advance to the boundary of the model - while (!inside_cell) { - advance_to_boundary_from_void(); - inside_cell = exhaustive_find_cell(*this, settings::verbosity >= 10); - - // If true this means no surface was intersected. See cell.cpp and search - // for numeric_limits to see where we return it. - if (surface() == std::numeric_limits::max()) { - warning(fmt::format("Lost a ray, r = {}, u = {}", r(), u())); - return; - } - - // Exit this loop and enter into cell-to-cell ray tracing (which uses - // neighbor lists) - if (inside_cell) - break; - - // if there is no intersection with the model, we're done - if (boundary().surface() == SURFACE_NONE) - return; - - event_counter_++; - if (event_counter_ > MAX_INTERSECTIONS) { - warning("Likely infinite loop in ray traced plot"); - return; - } - } - - // Call the specialized logic for this type of ray. This is for the - // intersection for the first intersection if we had one. - if (boundary().surface() != SURFACE_NONE) { - // set the geometry state's surface attribute to be used for - // surface normal computation - surface() = boundary().surface(); - on_intersection(); - if (stop_) - return; - } - - // reset surface attribute to zero after the first intersection so that it - // doesn't perturb surface crossing logic from here on out - surface() = 0; - - // This is the ray tracing loop within the model. It exits after exiting - // the model, which is equivalent to assuming that the model is convex. - // It would be nice to factor out the on_intersection at the end of this - // loop and then do "while (inside_cell)", but we can't guarantee it's - // on a surface in that case. There might be some other way to set it - // up that is perhaps a little more elegant, but this is what works just - // fine. - while (true) { - - compute_distance(); - - // There are no more intersections to process - // if we hit the edge of the model, so stop - // the particle in that case. Also, just exit - // if a negative distance was somehow computed. - if (boundary().distance() == INFTY || boundary().distance() == INFINITY || - boundary().distance() < 0) { - return; - } - - // See below comment where call_on_intersection is checked in an - // if statement for an explanation of this. - bool call_on_intersection {true}; - if (boundary().distance() < 10 * TINY_BIT) { - call_on_intersection = false; - } - - // DAGMC surfaces expect us to go a little bit further than the advance - // distance to properly check cell inclusion. - boundary().distance() += TINY_BIT; - - // Advance particle, prepare for next intersection - for (int lev = 0; lev < n_coord(); ++lev) { - coord(lev).r() += boundary().distance() * coord(lev).u(); - } - surface() = boundary().surface(); - // Initialize last cells from the current cell, because the cell() variable - // does not contain the data for the case of a single-segment ray - for (int j = 0; j < n_coord(); ++j) { - cell_last(j) = coord(j).cell(); - } - n_coord_last() = n_coord(); - n_coord() = boundary().coord_level(); - if (boundary().lattice_translation()[0] != 0 || - boundary().lattice_translation()[1] != 0 || - boundary().lattice_translation()[2] != 0) { - cross_lattice(*this, boundary(), settings::verbosity >= 10); - } - - // Record how far the ray has traveled - traversal_distance_ += boundary().distance(); - inside_cell = neighbor_list_find_cell(*this, settings::verbosity >= 10); - - // Call the specialized logic for this type of ray. Note that we do not - // call this if the advance distance is very small. Unfortunately, it seems - // darn near impossible to get the particle advanced to the model boundary - // and through it without sometimes accidentally calling on_intersection - // twice. This incorrectly shades the region as occluded when it might not - // actually be. By screening out intersection distances smaller than a - // threshold 10x larger than the scoot distance used to advance up to the - // model boundary, we can avoid that situation. - if (call_on_intersection) { - on_intersection(); - if (stop_) - return; - } - - if (!inside_cell) - return; - - event_counter_++; - if (event_counter_ > MAX_INTERSECTIONS) { - warning("Likely infinite loop in ray traced plot"); - return; - } - } -} - -} // namespace openmc diff --git a/src/reaction.cpp b/src/reaction.cpp index c02e0cc40..0643cb08b 100644 --- a/src/reaction.cpp +++ b/src/reaction.cpp @@ -1,20 +1,17 @@ #include "openmc/reaction.h" -#include // for remove_if #include #include #include // for move #include -#include "openmc/chain.h" #include "openmc/constants.h" #include "openmc/endf.h" #include "openmc/hdf5_interface.h" #include "openmc/random_lcg.h" #include "openmc/search.h" #include "openmc/secondary_uncorrelated.h" -#include "openmc/settings.h" namespace openmc { @@ -22,8 +19,7 @@ namespace openmc { // Reaction implementation //============================================================================== -Reaction::Reaction( - hid_t group, const vector& temperatures, std::string name) +Reaction::Reaction(hid_t group, const vector& temperatures) { read_attribute(group, "Q_value", q_value_); read_attribute(group, "mt", mt_); @@ -67,36 +63,10 @@ Reaction::Reaction( close_group(pgroup); } } - - if (settings::use_decay_photons) { - // Remove photon products for D1S method - products_.erase(std::remove_if(products_.begin(), products_.end(), - [](const auto& p) { return p.particle_.is_photon(); }), - products_.end()); - - // Determine product for D1S method - auto nuclide_it = data::chain_nuclide_map.find(name); - if (nuclide_it != data::chain_nuclide_map.end()) { - const auto& chain_nuc = data::chain_nuclides[nuclide_it->second]; - const auto& rx_products = chain_nuc->reaction_products(); - auto product_it = rx_products.find(mt_); - if (product_it != rx_products.end()) { - auto decay_products = product_it->second; - for (const auto& decay_product : decay_products) { - auto product_it = data::chain_nuclide_map.find(decay_product.name); - if (product_it != data::chain_nuclide_map.end()) { - const auto& product_nuc = data::chain_nuclides[product_it->second]; - if (product_nuc->photon_energy()) { - products_.emplace_back(decay_product); - } - } - } - } - } - } } -double Reaction::xs(int64_t i_temp, int64_t i_grid, double interp_factor) const +double Reaction::xs( + gsl::index i_temp, gsl::index i_grid, double interp_factor) const { // If energy is below threshold, return 0. Otherwise interpolate between // nearest grid points @@ -112,8 +82,9 @@ double Reaction::xs(const NuclideMicroXS& micro) const return this->xs(micro.index_temp, micro.index_grid, micro.interp_factor); } -double Reaction::collapse_rate(int64_t i_temp, span energy, - span flux, const vector& grid) const +double Reaction::collapse_rate(gsl::index i_temp, + gsl::span energy, gsl::span flux, + const vector& grid) const { // Find index corresponding to first energy const auto& xs = xs_[i_temp].value; @@ -201,13 +172,9 @@ std::unordered_map REACTION_NAME_MAP { {SCORE_FISS_Q_PROMPT, "fission-q-prompt"}, {SCORE_FISS_Q_RECOV, "fission-q-recoverable"}, {SCORE_PULSE_HEIGHT, "pulse-height"}, - {SCORE_IFP_TIME_NUM, "ifp-time-numerator"}, - {SCORE_IFP_BETA_NUM, "ifp-beta-numerator"}, - {SCORE_IFP_DENOM, "ifp-denominator"}, // Normal ENDF-based reactions {TOTAL_XS, "(n,total)"}, {ELASTIC, "(n,elastic)"}, - {N_NONELASTIC, "(n,nonelastic)"}, {N_LEVEL, "(n,level)"}, {N_2ND, "(n,2nd)"}, {N_2N, "(n,2n)"}, @@ -309,7 +276,6 @@ std::unordered_map REACTION_NAME_MAP { {N_XA, "(n,Xa)"}, {HEATING, "heating"}, {DAMAGE_ENERGY, "damage-energy"}, - {PHOTON_TOTAL, "photon-total"}, {COHERENT, "coherent-scatter"}, {INCOHERENT, "incoherent-scatter"}, {PAIR_PROD_ELEC, "pair-production-electron"}, @@ -347,24 +313,13 @@ void initialize_maps() // Create photoelectric subshells for (int mt = 534; mt <= 572; ++mt) { REACTION_NAME_MAP[mt] = - fmt::format("photoelectric-{}", SUBSHELLS[mt - 534]); + fmt::format("photoelectric, {} subshell", SUBSHELLS[mt - 534]); } // Invert name map to create type map for (const auto& kv : REACTION_NAME_MAP) { REACTION_TYPE_MAP[kv.second] = kv.first; } - - // Alternate names - REACTION_TYPE_MAP["elastic"] = ELASTIC; - REACTION_TYPE_MAP["n2n"] = N_2N; - REACTION_TYPE_MAP["n3n"] = N_3N; - REACTION_TYPE_MAP["n4n"] = N_4N; - REACTION_TYPE_MAP["H1-production"] = N_XP; - REACTION_TYPE_MAP["H2-production"] = N_XD; - REACTION_TYPE_MAP["H3-production"] = N_XT; - REACTION_TYPE_MAP["He3-production"] = N_X3HE; - REACTION_TYPE_MAP["He4-production"] = N_XA; } std::string reaction_name(int mt) @@ -382,42 +337,62 @@ std::string reaction_name(int mt) } } -int reaction_tally_mt(std::string name) +int reaction_type(std::string name) { - // All "total" scores should map to the special SCORE_TOTAL - if (name == "total" || name == "(n,total)" || name == "photon-total") - return SCORE_TOTAL; - - // All fission scores should map to the special SCORE_FISSION - if (name == "fission" || name == "(n,fission)") - return SCORE_FISSION; - - // Delegate everything else to reaction_mt() - return reaction_mt(name); -} - -int reaction_mt(const std::string& name) -{ - // Initialize maps if needed + // Initialize remainder of name map and all of type map if (REACTION_TYPE_MAP.empty()) initialize_maps(); - // Look up directly in type map (no score indirection) + // (n,total) exists in REACTION_TYPE_MAP for MT=1, but we need this to return + // the special SCORE_TOTAL score + if (name == "(n,total)") + return SCORE_TOTAL; + + // Check if type map has an entry for this reaction name auto it = REACTION_TYPE_MAP.find(name); if (it != REACTION_TYPE_MAP.end()) { - int mt = it->second; - return mt; + return it->second; } - // Assume the given string is an MT number + // Alternate names for several reactions + if (name == "elastic") { + return ELASTIC; + } else if (name == "n2n") { + return N_2N; + } else if (name == "n3n") { + return N_3N; + } else if (name == "n4n") { + return N_4N; + } else if (name == "H1-production") { + return N_XP; + } else if (name == "H2-production") { + return N_XD; + } else if (name == "H3-production") { + return N_XT; + } else if (name == "He3-production") { + return N_X3HE; + } else if (name == "He4-production") { + return N_XA; + } + + // Assume the given string is a reaction MT number. Make sure it's a natural + // number then return. int MT = 0; try { MT = std::stoi(name); } catch (const std::invalid_argument& ex) { - throw std::invalid_argument("Unknown reaction name \"" + name + "\"."); + throw std::invalid_argument( + "Invalid tally score \"" + name + + "\". See the docs " + "for details: " + "https://docs.openmc.org/en/stable/usersguide/tallies.html#scores"); } if (MT < 1) - throw std::invalid_argument("Unknown reaction name \"" + name + "\"."); + throw std::invalid_argument( + "Invalid tally score \"" + name + + "\". See the docs " + "for details: " + "https://docs.openmc.org/en/stable/usersguide/tallies.html#scores"); return MT; } diff --git a/src/reaction_product.cpp b/src/reaction_product.cpp index a1c937861..4cef8d3a9 100644 --- a/src/reaction_product.cpp +++ b/src/reaction_product.cpp @@ -1,6 +1,5 @@ #include "openmc/reaction_product.h" -#include #include // for string #include @@ -27,7 +26,7 @@ ReactionProduct::ReactionProduct(hid_t group) // Read particle type std::string temp; read_attribute(group, "particle", temp); - particle_ = ParticleType {temp}; + particle_ = str_to_particle_type(temp); // Read emission mode and decay rate read_attribute(group, "emission_mode", temp); @@ -43,7 +42,7 @@ ReactionProduct::ReactionProduct(hid_t group) if (emission_mode_ == EmissionMode::delayed) { if (attribute_exists(group, "decay_rate")) { read_attribute(group, "decay_rate", decay_rate_); - } else if (particle_.is_neutron()) { + } else if (particle_ == ParticleType::neutron) { warning(fmt::format("Decay rate doesn't exist for delayed neutron " "emission ({}).", object_name(group))); @@ -84,33 +83,9 @@ ReactionProduct::ReactionProduct(hid_t group) } } -ReactionProduct::ReactionProduct(const ChainNuclide::Product& product) +void ReactionProduct::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { - particle_ = ParticleType::photon(); - emission_mode_ = EmissionMode::delayed; - - // Get chain nuclide object for radionuclide - parent_nuclide_ = data::chain_nuclide_map.at(product.name); - const auto& chain_nuc = data::chain_nuclides[parent_nuclide_].get(); - - // Determine decay constant in [s^-1] - decay_rate_ = chain_nuc->decay_constant(); - - // Determine number of photons per decay and set yield - double photon_per_sec = chain_nuc->photon_energy()->integral(); - double photon_per_decay = photon_per_sec / decay_rate_; - vector coef = {product.branching_ratio * photon_per_decay}; - yield_ = make_unique(coef); - - // Set decay photon angle-energy distribution - distribution_.push_back( - make_unique(chain_nuc->photon_energy())); -} - -AngleEnergy& ReactionProduct::sample_dist(double E_in, uint64_t* seed) const -{ - assert(!distribution_.empty()); - auto n = applicability_.size(); if (n > 1) { double prob = 0.0; @@ -120,24 +95,15 @@ AngleEnergy& ReactionProduct::sample_dist(double E_in, uint64_t* seed) const prob += applicability_[i](E_in); // If i-th distribution is sampled, sample energy from the distribution - if (c <= prob) - return *distribution_[i]; + if (c <= prob) { + distribution_[i]->sample(E_in, E_out, mu, seed); + break; + } } + } else { + // If only one distribution is present, go ahead and sample it + distribution_[0]->sample(E_in, E_out, mu, seed); } - - return *distribution_.back(); -} - -void ReactionProduct::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - sample_dist(E_in, seed).sample(E_in, E_out, mu, seed); -} - -double ReactionProduct::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - return sample_dist(E_in, seed).sample_energy_and_pdf(E_in, mu, E_out, seed); } } // namespace openmc diff --git a/src/scattdata.cpp b/src/scattdata.cpp index 9aa09956d..813f9e19b 100644 --- a/src/scattdata.cpp +++ b/src/scattdata.cpp @@ -4,7 +4,8 @@ #include #include -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xview.hpp" #include "openmc/constants.h" #include "openmc/error.h" @@ -18,8 +19,8 @@ namespace openmc { // ScattData base-class methods //============================================================================== -void ScattData::base_init(int order, const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_energy, +void ScattData::base_init(int order, const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_energy, const double_2dvec& in_mult) { size_t groups = in_energy.size(); @@ -36,12 +37,22 @@ void ScattData::base_init(int order, const tensor::Tensor& in_gmin, mult[gin] = in_mult[gin]; // Make sure the multiplicity does not have 0s + unsigned long int num_converted = 0; for (int go = 0; go < mult[gin].size(); go++) { if (mult[gin][go] == 0.) { + num_converted += 1; mult[gin][go] = 1.; } } + if (num_converted > 0) { + // Raise a warning to the user if we did have to do the conversion + std::string msg = + std::to_string(num_converted) + + " entries in the Multiplicity Matrix were changed from 0 to 1"; + warning(msg); + } + // Make sure the energy is normalized double norm = std::accumulate(energy[gin].begin(), energy[gin].end(), 0.); @@ -62,26 +73,23 @@ void ScattData::base_init(int order, const tensor::Tensor& in_gmin, void ScattData::base_combine(size_t max_order, size_t order_dim, const vector& those_scatts, const vector& scalars, - tensor::Tensor& in_gmin, tensor::Tensor& in_gmax, + xt::xtensor& in_gmin, xt::xtensor& in_gmax, double_2dvec& sparse_mult, double_3dvec& sparse_scatter) { size_t groups = those_scatts[0]->energy.size(); // Now allocate and zero our storage spaces - tensor::Tensor this_nuscatt_matrix = - tensor::zeros({groups, groups, order_dim}); - tensor::Tensor this_nuscatt_P0 = - tensor::zeros({groups, groups}); - tensor::Tensor this_scatt_P0 = - tensor::zeros({groups, groups}); - tensor::Tensor this_mult = tensor::ones({groups, groups}); + xt::xtensor this_nuscatt_matrix({groups, groups, order_dim}, 0.); + xt::xtensor this_nuscatt_P0({groups, groups}, 0.); + xt::xtensor this_scatt_P0({groups, groups}, 0.); + xt::xtensor this_mult({groups, groups}, 1.); // Build the dense scattering and multiplicity matrices for (int i = 0; i < those_scatts.size(); i++) { ScattData* that = those_scatts[i]; // Build the dense matrix for that object - tensor::Tensor that_matrix = that->get_matrix(max_order); + xt::xtensor that_matrix = that->get_matrix(max_order); // Now add that to this for the nu-scatter matrix this_nuscatt_matrix += scalars[i] * that_matrix; @@ -99,7 +107,7 @@ void ScattData::base_combine(size_t max_order, size_t order_dim, // Now we have the dense nuscatt and scatt, we can easily compute the // multiplicity matrix by dividing the two and fixing any nans - this_mult = tensor::nan_to_num(this_nuscatt_P0 / this_scatt_P0); + this_mult = xt::nan_to_num(this_nuscatt_P0 / this_scatt_P0); // We have the data, now we need to convert to a jagged array and then use // the initialize function to store it on the object. @@ -108,7 +116,7 @@ void ScattData::base_combine(size_t max_order, size_t order_dim, int gmin_; for (gmin_ = 0; gmin_ < groups; gmin_++) { bool non_zero = false; - for (int l = 0; l < this_nuscatt_matrix.shape(2); l++) { + for (int l = 0; l < this_nuscatt_matrix.shape()[2]; l++) { if (this_nuscatt_matrix(gin, gmin_, l) != 0.) { non_zero = true; break; @@ -120,7 +128,7 @@ void ScattData::base_combine(size_t max_order, size_t order_dim, int gmax_; for (gmax_ = groups - 1; gmax_ >= 0; gmax_--) { bool non_zero = false; - for (int l = 0; l < this_nuscatt_matrix.shape(2); l++) { + for (int l = 0; l < this_nuscatt_matrix.shape()[2]; l++) { if (this_nuscatt_matrix(gin, gmax_, l) != 0.) { non_zero = true; break; @@ -145,8 +153,8 @@ void ScattData::base_combine(size_t max_order, size_t order_dim, sparse_mult[gin].resize(gmax_ - gmin_ + 1); int i_gout = 0; for (int gout = gmin_; gout <= gmax_; gout++) { - sparse_scatter[gin][i_gout].resize(this_nuscatt_matrix.shape(2)); - for (int l = 0; l < this_nuscatt_matrix.shape(2); l++) { + sparse_scatter[gin][i_gout].resize(this_nuscatt_matrix.shape()[2]); + for (int l = 0; l < this_nuscatt_matrix.shape()[2]; l++) { sparse_scatter[gin][i_gout][l] = this_nuscatt_matrix(gin, gout, l); } sparse_mult[gin][i_gout] = this_mult(gin, gout); @@ -229,8 +237,8 @@ double ScattData::get_xs( // ScattDataLegendre methods //============================================================================== -void ScattDataLegendre::init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, +void ScattDataLegendre::init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) { size_t groups = coeffs.size(); @@ -241,7 +249,7 @@ void ScattDataLegendre::init(const tensor::Tensor& in_gmin, // Get the scattering cross section value by summing the un-normalized P0 // coefficient in the variable matrix over all outgoing groups. - scattxs = tensor::zeros({groups}); + scattxs = xt::zeros({groups}); for (int gin = 0; gin < groups; gin++) { int num_groups = in_gmax[gin] - in_gmin[gin] + 1; for (int i_gout = 0; i_gout < num_groups; i_gout++) { @@ -388,8 +396,8 @@ void ScattDataLegendre::combine( size_t groups = those_scatts[0]->energy.size(); - tensor::Tensor in_gmin({groups}, 0); - tensor::Tensor in_gmax({groups}, 0); + xt::xtensor in_gmin({groups}, 0); + xt::xtensor in_gmax({groups}, 0); double_3dvec sparse_scatter(groups); double_2dvec sparse_mult(groups); @@ -406,13 +414,12 @@ void ScattDataLegendre::combine( //============================================================================== -tensor::Tensor ScattDataLegendre::get_matrix(size_t max_order) +xt::xtensor ScattDataLegendre::get_matrix(size_t max_order) { // Get the sizes and initialize the data to 0 size_t groups = energy.size(); size_t order_dim = max_order + 1; - tensor::Tensor matrix = - tensor::zeros({groups, groups, order_dim}); + xt::xtensor matrix({groups, groups, order_dim}, 0.); for (int gin = 0; gin < groups; gin++) { for (int i_gout = 0; i_gout < energy[gin].size(); i_gout++) { @@ -430,8 +437,8 @@ tensor::Tensor ScattDataLegendre::get_matrix(size_t max_order) // ScattDataHistogram methods //============================================================================== -void ScattDataHistogram::init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, +void ScattDataHistogram::init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) { size_t groups = coeffs.size(); @@ -442,7 +449,7 @@ void ScattDataHistogram::init(const tensor::Tensor& in_gmin, // Get the scattering cross section value by summing the distribution // over all the histogram bins in angle and outgoing energy groups - scattxs = tensor::zeros({groups}); + scattxs = xt::zeros({groups}); for (int gin = 0; gin < groups; gin++) { for (int i_gout = 0; i_gout < matrix[gin].size(); i_gout++) { scattxs[gin] += std::accumulate( @@ -471,7 +478,7 @@ void ScattDataHistogram::init(const tensor::Tensor& in_gmin, ScattData::base_init(order, in_gmin, in_gmax, in_energy, in_mult); // Build the angular distribution mu values - mu = tensor::linspace(-1., 1., order + 1); + mu = xt::linspace(-1., 1., order + 1); dmu = 2. / order; // Calculate f(mu) and integrate it so we can avoid rejection sampling @@ -516,7 +523,7 @@ double ScattDataHistogram::calc_f(int gin, int gout, double mu) int imu; if (mu == 1.) { // use size -2 to have the index one before the end - imu = this->mu.shape(0) - 2; + imu = this->mu.shape()[0] - 2; } else { imu = std::floor((mu + 1.) / dmu + 1.) - 1; } @@ -562,13 +569,13 @@ void ScattDataHistogram::sample( //============================================================================== -tensor::Tensor ScattDataHistogram::get_matrix(size_t max_order) +xt::xtensor ScattDataHistogram::get_matrix(size_t max_order) { // Get the sizes and initialize the data to 0 size_t groups = energy.size(); // We ignore the requested order for Histogram and Tabular representations size_t order_dim = get_order(); - tensor::Tensor matrix({groups, groups, order_dim}, 0); + xt::xtensor matrix({groups, groups, order_dim}, 0); for (int gin = 0; gin < groups; gin++) { for (int i_gout = 0; i_gout < energy[gin].size(); i_gout++) { @@ -603,8 +610,8 @@ void ScattDataHistogram::combine( size_t groups = those_scatts[0]->energy.size(); - tensor::Tensor in_gmin({groups}, 0); - tensor::Tensor in_gmax({groups}, 0); + xt::xtensor in_gmin({groups}, 0); + xt::xtensor in_gmax({groups}, 0); double_3dvec sparse_scatter(groups); double_2dvec sparse_mult(groups); @@ -623,8 +630,8 @@ void ScattDataHistogram::combine( // ScattDataTabular methods //============================================================================== -void ScattDataTabular::init(const tensor::Tensor& in_gmin, - const tensor::Tensor& in_gmax, const double_2dvec& in_mult, +void ScattDataTabular::init(const xt::xtensor& in_gmin, + const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs) { size_t groups = coeffs.size(); @@ -634,12 +641,12 @@ void ScattDataTabular::init(const tensor::Tensor& in_gmin, double_3dvec matrix = coeffs; // Build the angular distribution mu values - mu = tensor::linspace(-1., 1., order); + mu = xt::linspace(-1., 1., order); dmu = 2. / (order - 1); // Get the scattering cross section value by integrating the distribution // over all mu points and then combining over all outgoing groups - scattxs = tensor::zeros({groups}); + scattxs = xt::zeros({groups}); for (int gin = 0; gin < groups; gin++) { for (int i_gout = 0; i_gout < matrix[gin].size(); i_gout++) { for (int imu = 1; imu < order; imu++) { @@ -716,7 +723,7 @@ double ScattDataTabular::calc_f(int gin, int gout, double mu) int imu; if (mu == 1.) { // use size -2 to have the index one before the end - imu = this->mu.shape(0) - 2; + imu = this->mu.shape()[0] - 2; } else { imu = std::floor((mu + 1.) / dmu + 1.) - 1; } @@ -737,7 +744,7 @@ void ScattDataTabular::sample( sample_energy(gin, gout, i_gout, seed); // Determine the outgoing cosine bin - int NP = this->mu.shape(0); + int NP = this->mu.shape()[0]; double xi = prn(seed); double c_k = dist[gin][i_gout][0]; @@ -779,14 +786,13 @@ void ScattDataTabular::sample( //============================================================================== -tensor::Tensor ScattDataTabular::get_matrix(size_t max_order) +xt::xtensor ScattDataTabular::get_matrix(size_t max_order) { // Get the sizes and initialize the data to 0 size_t groups = energy.size(); // We ignore the requested order for Histogram and Tabular representations size_t order_dim = get_order(); - tensor::Tensor matrix = - tensor::zeros({groups, groups, order_dim}); + xt::xtensor matrix({groups, groups, order_dim}, 0.); for (int gin = 0; gin < groups; gin++) { for (int i_gout = 0; i_gout < energy[gin].size(); i_gout++) { @@ -820,8 +826,8 @@ void ScattDataTabular::combine( size_t groups = those_scatts[0]->energy.size(); - tensor::Tensor in_gmin({groups}, 0); - tensor::Tensor in_gmax({groups}, 0); + xt::xtensor in_gmin({groups}, 0); + xt::xtensor in_gmax({groups}, 0); double_3dvec sparse_scatter(groups); double_2dvec sparse_mult(groups); @@ -858,7 +864,7 @@ void convert_legendre_to_tabular(ScattDataLegendre& leg, ScattDataTabular& tab) tab.scattxs = leg.scattxs; // Build mu and dmu - tab.mu = tensor::linspace(-1., 1., n_mu); + tab.mu = xt::linspace(-1., 1., n_mu); tab.dmu = 2. / (n_mu - 1); // Calculate f(mu) and integrate it so we can avoid rejection sampling diff --git a/src/secondary_correlated.cpp b/src/secondary_correlated.cpp index 32701791a..0e4891dd3 100644 --- a/src/secondary_correlated.cpp +++ b/src/secondary_correlated.cpp @@ -5,11 +5,11 @@ #include // for size_t #include // for back_inserter -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" +#include "xtensor/xview.hpp" #include "openmc/endf.h" #include "openmc/hdf5_interface.h" -#include "openmc/math_functions.h" #include "openmc/random_lcg.h" #include "openmc/search.h" @@ -25,11 +25,11 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) hid_t dset = open_dataset(group, "energy"); // Get interpolation parameters - tensor::Tensor temp; + xt::xarray temp; read_attribute(dset, "interpolation", temp); - tensor::View temp_b = temp.slice(0); // breakpoints - tensor::View temp_i = temp.slice(1); // interpolation parameters + auto temp_b = xt::view(temp, 0); // view of breakpoints + auto temp_i = xt::view(temp, 1); // view of interpolation parameters std::copy(temp_b.begin(), temp_b.end(), std::back_inserter(breakpoints_)); for (const auto i : temp_i) @@ -50,12 +50,12 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) read_attribute(dset, "interpolation", interp); read_attribute(dset, "n_discrete_lines", n_discrete); - tensor::Tensor eout; + xt::xarray eout; read_dataset(dset, eout); close_dataset(dset); // Read angle distributions - tensor::Tensor mu; + xt::xarray mu; read_dataset(group, "mu", mu); for (int i = 0; i < n_energy; ++i) { @@ -65,7 +65,7 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) if (i < n_energy - 1) { n = offsets[i + 1] - j; } else { - n = eout.shape(1) - j; + n = eout.shape()[1] - j; } // Assign interpolation scheme and number of discrete lines @@ -74,9 +74,9 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) d.n_discrete = n_discrete[i]; // Copy data - d.e_out = eout.slice(0, tensor::range(j, j + n)); - d.p = eout.slice(1, tensor::range(j, j + n)); - d.c = eout.slice(2, tensor::range(j, j + n)); + d.e_out = xt::view(eout, 0, xt::range(j, j + n)); + d.p = xt::view(eout, 1, xt::range(j, j + n)); + d.c = xt::view(eout, 2, xt::range(j, j + n)); // To get answers that match ACE data, for now we still use the tabulated // CDF values that were passed through to the HDF5 library. At a later @@ -118,10 +118,10 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) // Determine offset and size of distribution int offset_mu = std::lround(eout(4, offsets[i] + j)); int m; - if (offsets[i] + j + 1 < eout.shape(1)) { + if (offsets[i] + j + 1 < eout.shape()[1]) { m = std::lround(eout(4, offsets[i] + j + 1)) - offset_mu; } else { - m = mu.shape(1) - offset_mu; + m = mu.shape()[1] - offset_mu; } // For incoherent inelastic thermal scattering, the angle distributions @@ -132,12 +132,9 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) interp_mu = 1; auto interp = int2interp(interp_mu); - tensor::View xs = - mu.slice(0, tensor::range(offset_mu, offset_mu + m)); - tensor::View ps = - mu.slice(1, tensor::range(offset_mu, offset_mu + m)); - tensor::View cs = - mu.slice(2, tensor::range(offset_mu, offset_mu + m)); + auto xs = xt::view(mu, 0, xt::range(offset_mu, offset_mu + m)); + auto ps = xt::view(mu, 1, xt::range(offset_mu, offset_mu + m)); + auto cs = xt::view(mu, 2, xt::range(offset_mu, offset_mu + m)); vector x {xs.begin(), xs.end()}; vector p {ps.begin(), ps.end()}; @@ -155,13 +152,25 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) distribution_.push_back(std::move(d)); } // incoming energies } -Distribution& CorrelatedAngleEnergy::sample_dist( - double E_in, double& E_out, uint64_t* seed) const + +void CorrelatedAngleEnergy::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { - // Find energy bin and calculate interpolation factor + // Find energy bin and calculate interpolation factor -- if the energy is + // outside the range of the tabulated energies, choose the first or last bins + auto n_energy_in = energy_.size(); int i; double r; - get_energy_index(energy_, E_in, i, r); + if (E_in < energy_[0]) { + i = 0; + r = 0.0; + } else if (E_in > energy_[n_energy_in - 1]) { + i = n_energy_in - 2; + r = 1.0; + } else { + i = lower_bound_index(energy_.begin(), energy_.end(), E_in); + r = (E_in - energy_[i]) / (energy_[i + 1] - energy_[i]); + } // Sample between the ith and [i+1]th bin int l = r > prn(seed) ? i + 1 : i; @@ -248,22 +257,10 @@ Distribution& CorrelatedAngleEnergy::sample_dist( // Find correlated angular distribution for closest outgoing energy bin if (r1 - c_k < c_k1 - r1 || distribution_[l].interpolation == Interpolation::histogram) { - return *distribution_[l].angle[k]; + mu = distribution_[l].angle[k]->sample(seed); } else { - return *distribution_[l].angle[k + 1]; + mu = distribution_[l].angle[k + 1]->sample(seed); } } -void CorrelatedAngleEnergy::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - mu = sample_dist(E_in, E_out, seed).sample(seed).first; -} - -double CorrelatedAngleEnergy::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - return sample_dist(E_in, E_out, seed).evaluate(mu); -} - } // namespace openmc diff --git a/src/secondary_kalbach.cpp b/src/secondary_kalbach.cpp index 018ce1c8a..4a7878343 100644 --- a/src/secondary_kalbach.cpp +++ b/src/secondary_kalbach.cpp @@ -5,10 +5,10 @@ #include // for size_t #include // for back_inserter -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" +#include "xtensor/xview.hpp" #include "openmc/hdf5_interface.h" -#include "openmc/math_functions.h" #include "openmc/random_dist.h" #include "openmc/random_lcg.h" #include "openmc/search.h" @@ -26,11 +26,11 @@ KalbachMann::KalbachMann(hid_t group) hid_t dset = open_dataset(group, "energy"); // Get interpolation parameters - tensor::Tensor temp; + xt::xarray temp; read_attribute(dset, "interpolation", temp); - tensor::View temp_b = temp.slice(0); // breakpoints - tensor::View temp_i = temp.slice(1); // interpolation parameters + auto temp_b = xt::view(temp, 0); // view of breakpoints + auto temp_i = xt::view(temp, 1); // view of interpolation parameters std::copy(temp_b.begin(), temp_b.end(), std::back_inserter(breakpoints_)); for (const auto i : temp_i) @@ -51,7 +51,7 @@ KalbachMann::KalbachMann(hid_t group) read_attribute(dset, "interpolation", interp); read_attribute(dset, "n_discrete_lines", n_discrete); - tensor::Tensor eout; + xt::xarray eout; read_dataset(dset, eout); close_dataset(dset); @@ -62,7 +62,7 @@ KalbachMann::KalbachMann(hid_t group) if (i < n_energy - 1) { n = offsets[i + 1] - j; } else { - n = eout.shape(1) - j; + n = eout.shape()[1] - j; } // Assign interpolation scheme and number of discrete lines @@ -71,11 +71,11 @@ KalbachMann::KalbachMann(hid_t group) d.n_discrete = n_discrete[i]; // Copy data - d.e_out = eout.slice(0, tensor::range(j, j + n)); - d.p = eout.slice(1, tensor::range(j, j + n)); - d.c = eout.slice(2, tensor::range(j, j + n)); - d.r = eout.slice(3, tensor::range(j, j + n)); - d.a = eout.slice(4, tensor::range(j, j + n)); + d.e_out = xt::view(eout, 0, xt::range(j, j + n)); + d.p = xt::view(eout, 1, xt::range(j, j + n)); + d.c = xt::view(eout, 2, xt::range(j, j + n)); + d.r = xt::view(eout, 3, xt::range(j, j + n)); + d.a = xt::view(eout, 4, xt::range(j, j + n)); // To get answers that match ACE data, for now we still use the tabulated // CDF values that were passed through to the HDF5 library. At a later @@ -114,13 +114,24 @@ KalbachMann::KalbachMann(hid_t group) } // incoming energies } -void KalbachMann::sample_params( - double E_in, double& E_out, double& km_a, double& km_r, uint64_t* seed) const +void KalbachMann::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { - // Find energy bin and calculate interpolation factor + // Find energy bin and calculate interpolation factor -- if the energy is + // outside the range of the tabulated energies, choose the first or last bins + auto n_energy_in = energy_.size(); int i; double r; - get_energy_index(energy_, E_in, i, r); + if (E_in < energy_[0]) { + i = 0; + r = 0.0; + } else if (E_in > energy_[n_energy_in - 1]) { + i = n_energy_in - 2; + r = 1.0; + } else { + i = lower_bound_index(energy_.begin(), energy_.end(), E_in); + r = (E_in - energy_[i]) / (energy_[i + 1] - energy_[i]); + } // Sample between the ith and [i+1]th bin int l = r > prn(seed) ? i + 1 : i; @@ -170,6 +181,7 @@ void KalbachMann::sample_params( double E_l_k = distribution_[l].e_out[k]; double p_l_k = distribution_[l].p[k]; + double km_r, km_a; if (distribution_[l].interpolation == Interpolation::histogram) { // Histogram interpolation if (p_l_k > 0.0 && k >= n_discrete) { @@ -215,13 +227,6 @@ void KalbachMann::sample_params( E_out = E_1 + (E_out - E_i1_1) * (E_K - E_1) / (E_i1_K - E_i1_1); } } -} - -void KalbachMann::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - double km_r, km_a; - sample_params(E_in, E_out, km_a, km_r, seed); // Sampled correlated angle from Kalbach-Mann parameters if (prn(seed) > km_r) { @@ -232,15 +237,5 @@ void KalbachMann::sample( mu = std::log(r1 * std::exp(km_a) + (1.0 - r1) * std::exp(-km_a)) / km_a; } } -double KalbachMann::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - double km_r, km_a; - sample_params(E_in, E_out, km_a, km_r, seed); - - // https://docs.openmc.org/en/latest/methods/neutron_physics.html#equation-KM-pdf-angle - return km_a / (2 * std::sinh(km_a)) * - (std::cosh(km_a * mu) + km_r * std::sinh(km_a * mu)); -} } // namespace openmc diff --git a/src/secondary_nbody.cpp b/src/secondary_nbody.cpp index 72f0b0b92..da0bb81c4 100644 --- a/src/secondary_nbody.cpp +++ b/src/secondary_nbody.cpp @@ -22,8 +22,13 @@ NBodyPhaseSpace::NBodyPhaseSpace(hid_t group) read_attribute(group, "q_value", Q_); } -double NBodyPhaseSpace::sample_energy(double E_in, uint64_t* seed) const +void NBodyPhaseSpace::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { + // By definition, the distribution of the angle is isotropic for an N-body + // phase space distribution + mu = uniform_distribution(-1., 1., seed); + // Determine E_max parameter double Ap = mass_ratio_; double E_max = (Ap - 1.0) / Ap * (A_ / (A_ + 1.0) * E_in + Q_); @@ -54,29 +59,12 @@ double NBodyPhaseSpace::sample_energy(double E_in, uint64_t* seed) const std::log(r5) * std::pow(std::cos(PI / 2.0 * r6), 2); break; default: - fatal_error("N-body phase space with >5 bodies."); + throw std::runtime_error {"N-body phase space with >5 bodies."}; } // Now determine v and E_out double v = x / (x + y); - return E_max * v; -} - -void NBodyPhaseSpace::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - // By definition, the distribution of the angle is isotropic for an N-body - // phase space distribution - mu = uniform_distribution(-1., 1., seed); - - E_out = sample_energy(E_in, seed); -} - -double NBodyPhaseSpace::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - E_out = sample_energy(E_in, seed); - return 0.5; + E_out = E_max * v; } } // namespace openmc diff --git a/src/secondary_thermal.cpp b/src/secondary_thermal.cpp index b0f601809..0b8e1ab42 100644 --- a/src/secondary_thermal.cpp +++ b/src/secondary_thermal.cpp @@ -1,43 +1,46 @@ #include "openmc/secondary_thermal.h" #include "openmc/hdf5_interface.h" -#include "openmc/math_functions.h" #include "openmc/random_lcg.h" #include "openmc/search.h" -#include "openmc/vector.h" -#include "openmc/tensor.h" +#include + +#include "xtensor/xview.hpp" -#include #include // for log, exp namespace openmc { +// Helper function to get index on incident energy grid +void get_energy_index( + const vector& energies, double E, int& i, double& f) +{ + // Get index and interpolation factor for elastic grid + i = 0; + f = 0.0; + if (E >= energies.front()) { + i = lower_bound_index(energies.begin(), energies.end(), E); + if (i + 1 < energies.size()) + f = (E - energies[i]) / (energies[i + 1] - energies[i]); + } +} + //============================================================================== // CoherentElasticAE implementation //============================================================================== -CoherentElasticAE::CoherentElasticAE(const CoherentElasticXS& xs) : xs_ {xs} -{ - const auto& bragg = xs_.bragg_edges(); - auto n = bragg.size(); - bragg_edges_ = tensor::Tensor(bragg.data(), n); - - const auto& factors = xs_.factors(); - factors_diff_ = tensor::zeros({n}); - factors_diff_.slice(0) = factors[0]; - for (int i = 1; i < n; ++i) { - factors_diff_.slice(i) = factors[i] - factors[i - 1]; - } -} +CoherentElasticAE::CoherentElasticAE(const CoherentElasticXS& xs) : xs_ {xs} {} void CoherentElasticAE::sample( double E_in, double& E_out, double& mu, uint64_t* seed) const { // Energy doesn't change in elastic scattering (ENDF-102, Eq. 7-1) E_out = E_in; + const auto& energies {xs_.bragg_edges()}; - assert(E_in >= energies.front()); + + Expects(E_in >= energies.front()); const int i = lower_bound_index(energies.begin(), energies.end(), E_in); @@ -53,25 +56,6 @@ void CoherentElasticAE::sample( mu = 1.0 - 2.0 * energies[k] / E_in; } -double CoherentElasticAE::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - // Energy doesn't change in elastic scattering (ENDF-102, Eq. 7-1) - E_out = E_in; - const auto& factors = xs_.factors(); - - if (E_in < bragg_edges_.front()) - return 0.0; - - const int i = - lower_bound_index(bragg_edges_.begin(), bragg_edges_.end(), E_in); - double E = 0.5 * (1 - mu) * E_in; - double C = 0.5 * E_in / factors[i]; - - return C * get_pdf_discrete(bragg_edges_.slice(tensor::range(i + 1)), - factors_diff_.slice(tensor::range(i + 1)), E, 0.0, E_in); -} - //============================================================================== // IncoherentElasticAE implementation //============================================================================== @@ -84,21 +68,12 @@ IncoherentElasticAE::IncoherentElasticAE(hid_t group) void IncoherentElasticAE::sample( double E_in, double& E_out, double& mu, uint64_t* seed) const { - E_out = E_in; - // Sample angle by inverting the distribution in ENDF-102, Eq. 7.4 double c = 2 * E_in * debye_waller_; mu = std::log(1.0 + prn(seed) * (std::exp(2.0 * c) - 1)) / c - 1.0; -} -double IncoherentElasticAE::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - E_out = E_in; - // Sample angle by inverting the distribution in ENDF-102, Eq. 7.4 - double c = 2 * E_in * debye_waller_; - double A = c / (1 - std::exp(-2.0 * c)); // normalization factor - return A * std::exp(-c * (1 - mu)); + // Energy doesn't change in elastic scattering (ENDF-102, Eq. 7.4) + E_out = E_in; } //============================================================================== @@ -124,7 +99,7 @@ void IncoherentElasticAEDiscrete::sample( // incoming energies. // Sample outgoing cosine bin - int n_mu = mu_out_.shape(1); + int n_mu = mu_out_.shape()[1]; int k = prn(seed) * n_mu; // Rather than use the sampled discrete mu directly, it is smeared over @@ -155,20 +130,6 @@ void IncoherentElasticAEDiscrete::sample( E_out = E_in; } -double IncoherentElasticAEDiscrete::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - // Get index and interpolation factor for elastic grid - int i; - double f; - get_energy_index(energy_, E_in, i, f); - // Energy doesn't change in elastic scattering - E_out = E_in; - - return get_pdf_discrete_interpolated( - mu_out_.slice(i, tensor::all), mu_out_.slice(i + 1, tensor::all), f, mu); -} - //============================================================================== // IncoherentInelasticAEDiscrete implementation //============================================================================== @@ -182,8 +143,8 @@ IncoherentInelasticAEDiscrete::IncoherentInelasticAEDiscrete( read_dataset(group, "skewed", skewed_); } -void IncoherentInelasticAEDiscrete::sample_params( - double E_in, double& E_out, int& j, uint64_t* seed) const +void IncoherentInelasticAEDiscrete::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { // Get index and interpolation factor for inelastic grid int i; @@ -197,7 +158,8 @@ void IncoherentInelasticAEDiscrete::sample_params( // for the second and second to last bins, relative to a normal bin // probability of 1). Otherwise, each bin is equally probable. - int n = energy_out_.shape(1); + int j; + int n = energy_out_.shape()[1]; if (!skewed_) { // All bins equally likely j = prn(seed) * n; @@ -228,21 +190,9 @@ void IncoherentInelasticAEDiscrete::sample_params( // Outgoing energy E_out = (1 - f) * E_ij + f * E_i1j; -} - -void IncoherentInelasticAEDiscrete::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - // Get index and interpolation factor for inelastic grid - int i; - double f; - get_energy_index(energy_, E_in, i, f); - - int j; - sample_params(E_in, E_out, j, seed); // Sample outgoing cosine bin - int m = mu_out_.shape(2); + int m = mu_out_.shape()[2]; int k = prn(seed) * m; // Determine outgoing cosine corresponding to E_in[i] and E_in[i+1] @@ -253,20 +203,6 @@ void IncoherentInelasticAEDiscrete::sample( mu = (1 - f) * mu_ijk + f * mu_i1jk; } -double IncoherentInelasticAEDiscrete::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - // Get index and interpolation factor for inelastic grid - int i; - double f; - get_energy_index(energy_, E_in, i, f); - int j; - sample_params(E_in, E_out, j, seed); - - return get_pdf_discrete_interpolated(mu_out_.slice(i, j, tensor::all), - mu_out_.slice(i + 1, j, tensor::all), f, mu); -} - //============================================================================== // IncoherentInelasticAE implementation //============================================================================== @@ -296,11 +232,11 @@ IncoherentInelasticAE::IncoherentInelasticAE(hid_t group) // On first pass, allocate space for angles if (j == 0) { auto n_mu = adist->x().size(); - d.mu = tensor::Tensor({d.n_e_out, n_mu}); + d.mu = xt::empty({d.n_e_out, n_mu}); } // Copy outgoing angles - tensor::View mu_j = d.mu.slice(j); + auto mu_j = xt::view(d.mu, j); std::copy(adist->x().begin(), adist->x().end(), mu_j.begin()); } } @@ -309,23 +245,24 @@ IncoherentInelasticAE::IncoherentInelasticAE(hid_t group) } } -void IncoherentInelasticAE::sample_params( - double E_in, double& E_out, double& f, int& l, int& j, uint64_t* seed) const +void IncoherentInelasticAE::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { // Get index and interpolation factor for inelastic grid int i; - double f0; - get_energy_index(energy_, E_in, i, f0); + double f; + get_energy_index(energy_, E_in, i, f); // Pick closer energy based on interpolation factor - l = f0 > 0.5 ? i + 1 : i; + int l = f > 0.5 ? i + 1 : i; // Determine outgoing energy bin // (First reset n_energy_out to the right value) - int n = distribution_[l].n_e_out; + auto n = distribution_[l].n_e_out; double r1 = prn(seed); double c_j = distribution_[l].e_out_cdf[0]; double c_j1; + std::size_t j; for (j = 0; j < n - 1; ++j) { c_j1 = distribution_[l].e_out_cdf[j + 1]; if (r1 < c_j1) @@ -363,23 +300,15 @@ void IncoherentInelasticAE::sample_params( E_out += E_in - E_l; } - f = (r1 - c_j) / (c_j1 - c_j); -} -void IncoherentInelasticAE::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - double f; - int l, j; - sample_params(E_in, E_out, f, l, j, seed); - // Sample outgoing cosine bin - int n_mu = distribution_[l].mu.shape(1); + int n_mu = distribution_[l].mu.shape()[1]; std::size_t k = prn(seed) * n_mu; // Rather than use the sampled discrete mu directly, it is smeared over // a bin of width 0.5*min(mu[k] - mu[k-1], mu[k+1] - mu[k]) centered on the // discrete mu value itself. const auto& mu_l = distribution_[l].mu; + f = (r1 - c_j) / (c_j1 - c_j); // Interpolate kth mu value between distributions at energies j and j+1 mu = mu_l(j, k) + f * (mu_l(j + 1, k) - mu_l(j, k)); @@ -403,19 +332,6 @@ void IncoherentInelasticAE::sample( mu += std::min(mu - mu_left, mu_right - mu) * (prn(seed) - 0.5); } -double IncoherentInelasticAE::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - double f; - int l, j; - sample_params(E_in, E_out, f, l, j, seed); - - const auto& mu_l = distribution_[l].mu; - - return get_pdf_discrete_interpolated( - mu_l.slice(j, tensor::all), mu_l.slice(j + 1, tensor::all), f, mu); -} - //============================================================================== // MixedElasticAE implementation //============================================================================== @@ -438,30 +354,18 @@ MixedElasticAE::MixedElasticAE( close_group(incoherent_group); } -const AngleEnergy& MixedElasticAE::sample_dist( - double E_in, uint64_t* seed) const +void MixedElasticAE::sample( + double E_in, double& E_out, double& mu, uint64_t* seed) const { // Evaluate coherent and incoherent elastic cross sections double xs_coh = coherent_xs_(E_in); double xs_incoh = incoherent_xs_(E_in); if (prn(seed) * (xs_coh + xs_incoh) < xs_coh) { - return coherent_dist_; + coherent_dist_.sample(E_in, E_out, mu, seed); } else { - return *incoherent_dist_; + incoherent_dist_->sample(E_in, E_out, mu, seed); } } -void MixedElasticAE::sample( - double E_in, double& E_out, double& mu, uint64_t* seed) const -{ - sample_dist(E_in, seed).sample(E_in, E_out, mu, seed); -} - -double MixedElasticAE::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - return sample_dist(E_in, seed).sample_energy_and_pdf(E_in, mu, E_out, seed); -} - } // namespace openmc diff --git a/src/secondary_uncorrelated.cpp b/src/secondary_uncorrelated.cpp index ec2af7102..5cbb76fb9 100644 --- a/src/secondary_uncorrelated.cpp +++ b/src/secondary_uncorrelated.cpp @@ -65,22 +65,4 @@ void UncorrelatedAngleEnergy::sample( E_out = energy_->sample(E_in, seed); } -double UncorrelatedAngleEnergy::sample_energy_and_pdf( - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - // Sample outgoing energy - if (energy_ != nullptr) { - E_out = energy_->sample(E_in, seed); - } else { - E_out = E_in; - } - - if (!angle_.empty()) { - return angle_.evaluate(E_in, mu); - } else { - // no angle distribution given => assume isotropic for all energies - return 0.5; - } -} - } // namespace openmc diff --git a/src/settings.cpp b/src/settings.cpp index 15a7b9c27..6c3226b04 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,5 +1,4 @@ #include "openmc/settings.h" -#include "openmc/random_ray/flat_source_domain.h" #include // for ceil, pow #include // for numeric_limits @@ -11,7 +10,6 @@ #endif #include "openmc/capi.h" -#include "openmc/collision_track.h" #include "openmc/constants.h" #include "openmc/container_util.h" #include "openmc/distribution.h" @@ -27,7 +25,6 @@ #include "openmc/plot.h" #include "openmc/random_lcg.h" #include "openmc/random_ray/random_ray.h" -#include "openmc/reaction.h" #include "openmc/simulation.h" #include "openmc/source.h" #include "openmc/string_utils.h" @@ -47,7 +44,6 @@ namespace settings { // Default values for boolean flags bool assume_separate {false}; bool check_overlaps {false}; -bool collision_track {false}; bool cmfd_run {false}; bool confidence_intervals {false}; bool create_delayed_neutrons {true}; @@ -55,14 +51,12 @@ bool create_fission_neutrons {true}; bool delayed_photon_scaling {true}; bool entropy_on {false}; bool event_based {false}; -bool ifp_on {false}; bool legendre_to_tabular {true}; bool material_cell_offsets {true}; bool output_summary {true}; bool output_tallies {true}; bool particle_restart_run {false}; bool photon_transport {false}; -bool atomic_relaxation {true}; bool reduce_tallies {true}; bool res_scat_on {false}; bool restart_run {false}; @@ -75,15 +69,11 @@ bool surf_source_write {false}; bool surf_mcpl_write {false}; bool surf_source_read {false}; bool survival_biasing {false}; -bool survival_normalization {false}; bool temperature_multipole {false}; bool trigger_on {false}; bool trigger_predict {false}; -bool uniform_source_sampling {false}; bool ufs_on {false}; bool urr_ptables_on {true}; -bool use_decay_photons {false}; -bool use_shared_secondary_bank {false}; bool weight_windows_on {false}; bool weight_window_checkpoint_surface {false}; bool weight_window_checkpoint_collision {true}; @@ -98,7 +88,6 @@ std::string path_sourcepoint; std::string path_statepoint; const char* path_statepoint_c {path_statepoint.c_str()}; std::string weight_windows_file; -std::string properties_file; int32_t n_inactive {0}; int32_t max_lost_particles {10}; @@ -113,14 +102,11 @@ int max_particle_events {1000000}; ElectronTreatment electron_treatment {ElectronTreatment::TTB}; array energy_cutoff {0.0, 1000.0, 0.0, 0.0}; array time_cutoff {INFTY, INFTY, INFTY, INFTY}; -int ifp_n_generation {-1}; -IFPParameter ifp_parameter {IFPParameter::None}; int legendre_to_tabular_points {C_NONE}; int max_order {0}; int n_log_bins {8000}; int n_batches; int n_max_batches; -int max_secondaries {10000}; int max_history_splits {10'000'000}; int max_tracks {1000}; ResScatMethod res_scat_method {ResScatMethod::rvs}; @@ -131,16 +117,10 @@ RunMode run_mode {RunMode::UNSET}; SolverType solver_type {SolverType::MONTE_CARLO}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; -double source_rejection_fraction {0.05}; -double free_gas_threshold {400.0}; std::unordered_set source_write_surf_id; -CollisionTrackConfig collision_track_config {}; -int64_t ssw_max_particles; -int64_t ssw_max_files; +int64_t max_surface_particles; int64_t ssw_cell_id {C_NONE}; SSWCellType ssw_cell_type {SSWCellType::None}; -double surface_grazing_cutoff {0.001}; -double surface_grazing_ratio {0.5}; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; double temperature_default {293.6}; @@ -150,7 +130,7 @@ int trace_gen; int64_t trace_particle; vector> track_identifiers; int trigger_batch_interval {1}; -int verbosity {-1}; +int verbosity {7}; double weight_cutoff {0.25}; double weight_survive {1.0}; @@ -281,103 +261,14 @@ void get_run_parameters(pugi::xml_node node_base) } else { fatal_error("Specify random ray inactive distance in settings XML"); } - if (check_for_node(random_ray_node, "ray_source")) { - xml_node ray_source_node = random_ray_node.child("ray_source"); - xml_node source_node = ray_source_node.child("source"); + if (check_for_node(random_ray_node, "source")) { + xml_node source_node = random_ray_node.child("source"); // Get point to list of elements and make sure there is at least // one RandomRay::ray_source_ = Source::create(source_node); } else { fatal_error("Specify random ray source in settings XML"); } - if (check_for_node(random_ray_node, "volume_estimator")) { - std::string temp_str = - get_node_value(random_ray_node, "volume_estimator", true, true); - if (temp_str == "simulation_averaged") { - FlatSourceDomain::volume_estimator_ = - RandomRayVolumeEstimator::SIMULATION_AVERAGED; - } else if (temp_str == "naive") { - FlatSourceDomain::volume_estimator_ = RandomRayVolumeEstimator::NAIVE; - } else if (temp_str == "hybrid") { - FlatSourceDomain::volume_estimator_ = RandomRayVolumeEstimator::HYBRID; - } else { - fatal_error("Unrecognized volume estimator: " + temp_str); - } - } - if (check_for_node(random_ray_node, "source_shape")) { - std::string temp_str = - get_node_value(random_ray_node, "source_shape", true, true); - if (temp_str == "flat") { - RandomRay::source_shape_ = RandomRaySourceShape::FLAT; - } else if (temp_str == "linear") { - RandomRay::source_shape_ = RandomRaySourceShape::LINEAR; - } else if (temp_str == "linear_xy") { - RandomRay::source_shape_ = RandomRaySourceShape::LINEAR_XY; - } else { - fatal_error("Unrecognized source shape: " + temp_str); - } - } - if (check_for_node(random_ray_node, "volume_normalized_flux_tallies")) { - FlatSourceDomain::volume_normalized_flux_tallies_ = - get_node_value_bool(random_ray_node, "volume_normalized_flux_tallies"); - } - if (check_for_node(random_ray_node, "adjoint")) { - FlatSourceDomain::adjoint_requested_ = - get_node_value_bool(random_ray_node, "adjoint"); - } - if (check_for_node(random_ray_node, "sample_method")) { - std::string temp_str = - get_node_value(random_ray_node, "sample_method", true, true); - if (temp_str == "prng") { - RandomRay::sample_method_ = RandomRaySampleMethod::PRNG; - } else if (temp_str == "halton") { - RandomRay::sample_method_ = RandomRaySampleMethod::HALTON; - } else if (temp_str == "s2") { - RandomRay::sample_method_ = RandomRaySampleMethod::S2; - } else { - fatal_error("Unrecognized sample method: " + temp_str); - } - } - if (check_for_node(random_ray_node, "source_region_meshes")) { - pugi::xml_node node_source_region_meshes = - random_ray_node.child("source_region_meshes"); - for (pugi::xml_node node_mesh : - node_source_region_meshes.children("mesh")) { - int mesh_id = std::stoi(node_mesh.attribute("id").value()); - for (pugi::xml_node node_domain : node_mesh.children("domain")) { - int domain_id = std::stoi(node_domain.attribute("id").value()); - std::string domain_type = node_domain.attribute("type").value(); - Source::DomainType type; - if (domain_type == "material") { - type = Source::DomainType::MATERIAL; - } else if (domain_type == "cell") { - type = Source::DomainType::CELL; - } else if (domain_type == "universe") { - type = Source::DomainType::UNIVERSE; - } else { - throw std::runtime_error("Unknown domain type: " + domain_type); - } - FlatSourceDomain::mesh_domain_map_[mesh_id].emplace_back( - type, domain_id); - } - } - } - if (check_for_node(random_ray_node, "diagonal_stabilization_rho")) { - FlatSourceDomain::diagonal_stabilization_rho_ = std::stod( - get_node_value(random_ray_node, "diagonal_stabilization_rho")); - if (FlatSourceDomain::diagonal_stabilization_rho_ < 0.0 || - FlatSourceDomain::diagonal_stabilization_rho_ > 1.0) { - fatal_error("Random ray diagonal stabilization rho factor must be " - "between 0 and 1"); - } - } - if (check_for_node(random_ray_node, "adjoint_source")) { - pugi::xml_node adj_source_node = random_ray_node.child("adjoint_source"); - for (pugi::xml_node source_node : adj_source_node.children("source")) { - // Find any local adjoint sources - model::adjoint_sources.push_back(Source::create(source_node)); - } - } } } @@ -411,10 +302,8 @@ void read_settings_xml() xml_node root = doc.document_element(); // Verbosity - if (check_for_node(root, "verbosity") && verbosity == -1) { + if (check_for_node(root, "verbosity")) { verbosity = std::stoi(get_node_value(root, "verbosity")); - } else if (verbosity == -1) { - verbosity = 7; } // To this point, we haven't displayed any output since we didn't know what @@ -562,20 +451,6 @@ void read_settings_xml(pugi::xml_node root) } else if (rel_max_lost_particles <= 0.0 || rel_max_lost_particles >= 1.0) { fatal_error("Relative max lost particles must be between zero and one."); } - - // Check for user value for the number of generation of the Iterated Fission - // Probability (IFP) method - if (check_for_node(root, "ifp_n_generation")) { - ifp_n_generation = std::stoi(get_node_value(root, "ifp_n_generation")); - if (ifp_n_generation <= 0) { - fatal_error("'ifp_n_generation' must be greater than 0."); - } - // Avoid tallying 0 if IFP logs are not complete when active cycles start - if (ifp_n_generation > n_inactive) { - fatal_error("'ifp_n_generation' must be lower than or equal to the " - "number of inactive cycles."); - } - } } // Copy plotting random number seed if specified @@ -590,12 +465,6 @@ void read_settings_xml(pugi::xml_node root) openmc_set_seed(seed); } - // Copy random number stride if specified - if (check_for_node(root, "stride")) { - auto stride = std::stoull(get_node_value(root, "stride")); - openmc_set_stride(stride); - } - // Check for electron treatment if (check_for_node(root, "electron_treatment")) { auto temp_str = get_node_value(root, "electron_treatment", true, true); @@ -618,11 +487,6 @@ void read_settings_xml(pugi::xml_node root) } } - // Check for atomic relaxation - if (check_for_node(root, "atomic_relaxation")) { - atomic_relaxation = get_node_value_bool(root, "atomic_relaxation"); - } - // Number of bins for logarithmic grid if (check_for_node(root, "log_grid_bins")) { n_log_bins = std::stoi(get_node_value(root, "log_grid_bins")); @@ -674,36 +538,11 @@ void read_settings_xml(pugi::xml_node root) UPtrDist {new Discrete(T, p, 1)})); } - // Build probability mass function for sampling external sources - vector source_strengths; - for (auto& s : model::external_sources) { - source_strengths.push_back(s->strength()); - } - model::external_sources_probability.assign(source_strengths); - // Check if we want to write out source if (check_for_node(root, "write_initial_source")) { write_initial_source = get_node_value_bool(root, "write_initial_source"); } - // Get relative number of lost particles - if (check_for_node(root, "source_rejection_fraction")) { - source_rejection_fraction = - std::stod(get_node_value(root, "source_rejection_fraction")); - } - - if (check_for_node(root, "free_gas_threshold")) { - free_gas_threshold = std::stod(get_node_value(root, "free_gas_threshold")); - } - - // Surface grazing - if (check_for_node(root, "surface_grazing_cutoff")) - surface_grazing_cutoff = - std::stod(get_node_value(root, "surface_grazing_cutoff")); - if (check_for_node(root, "surface_grazing_ratio")) - surface_grazing_ratio = - std::stod(get_node_value(root, "surface_grazing_ratio")); - // Survival biasing if (check_for_node(root, "survival_biasing")) { survival_biasing = get_node_value_bool(root, "survival_biasing"); @@ -723,10 +562,6 @@ void read_settings_xml(pugi::xml_node root) if (check_for_node(node_cutoff, "weight_avg")) { weight_survive = std::stod(get_node_value(node_cutoff, "weight_avg")); } - if (check_for_node(node_cutoff, "survival_normalization")) { - survival_normalization = - get_node_value_bool(node_cutoff, "survival_normalization"); - } if (check_for_node(node_cutoff, "energy_neutron")) { energy_cutoff[0] = std::stod(get_node_value(node_cutoff, "energy_neutron")); @@ -761,14 +596,6 @@ void read_settings_xml(pugi::xml_node root) } } - // read properties from file - if (check_for_node(root, "properties_file")) { - properties_file = get_node_value(root, "properties_file"); - if (!file_exists(properties_file)) { - fatal_error(fmt::format("File '{}' does not exist.", properties_file)); - } - } - // Particle trace if (check_for_node(root, "trace")) { auto temp = get_node_array(root, "trace"); @@ -800,37 +627,30 @@ void read_settings_xml(pugi::xml_node root) } } - // Shannon entropy - if (solver_type == SolverType::RANDOM_RAY) { - if (check_for_node(root, "entropy_mesh")) { - fatal_error("Random ray uses FSRs to compute the Shannon entropy. " - "No user-defined entropy mesh is supported."); + // Shannon Entropy mesh + if (check_for_node(root, "entropy_mesh")) { + int temp = std::stoi(get_node_value(root, "entropy_mesh")); + if (model::mesh_map.find(temp) == model::mesh_map.end()) { + fatal_error(fmt::format( + "Mesh {} specified for Shannon entropy does not exist.", temp)); } + + auto* m = + dynamic_cast(model::meshes[model::mesh_map.at(temp)].get()); + if (!m) + fatal_error("Only regular meshes can be used as an entropy mesh"); + simulation::entropy_mesh = m; + + // Turn on Shannon entropy calculation entropy_on = true; - } else if (solver_type == SolverType::MONTE_CARLO) { - if (check_for_node(root, "entropy_mesh")) { - int temp = std::stoi(get_node_value(root, "entropy_mesh")); - if (model::mesh_map.find(temp) == model::mesh_map.end()) { - fatal_error(fmt::format( - "Mesh {} specified for Shannon entropy does not exist.", temp)); - } - auto* m = dynamic_cast( - model::meshes[model::mesh_map.at(temp)].get()); - if (!m) - fatal_error("Only regular meshes can be used as an entropy mesh"); - simulation::entropy_mesh = m; - - // Turn on Shannon entropy calculation - entropy_on = true; - - } else if (check_for_node(root, "entropy")) { - fatal_error( - "Specifying a Shannon entropy mesh via the element " - "is deprecated. Please create a mesh using and then reference " - "it by specifying its ID in an element."); - } + } else if (check_for_node(root, "entropy")) { + fatal_error( + "Specifying a Shannon entropy mesh via the element " + "is deprecated. Please create a mesh using and then reference " + "it by specifying its ID in an element."); } + // Uniform fission source weighting mesh if (check_for_node(root, "ufs_mesh")) { auto temp = std::stoi(get_node_value(root, "ufs_mesh")); @@ -905,6 +725,12 @@ void read_settings_xml(pugi::xml_node root) } if (check_for_node(node_sp, "mcpl")) { source_mcpl_write = get_node_value_bool(node_sp, "mcpl"); + + // Make sure MCPL support is enabled + if (source_mcpl_write && !MCPL_ENABLED) { + fatal_error( + "Your build of OpenMC does not support writing MCPL source files."); + } } if (check_for_node(node_sp, "overwrite_latest")) { source_latest = get_node_value_bool(node_sp, "overwrite_latest"); @@ -917,12 +743,6 @@ void read_settings_xml(pugi::xml_node root) sourcepoint_batch = statepoint_batch; } - // Check is the user specified to convert strength to statistical weight - if (check_for_node(root, "uniform_source_sampling")) { - uniform_source_sampling = - get_node_value_bool(root, "uniform_source_sampling"); - } - // Check if the user has specified to write surface source if (check_for_node(root, "surf_source_write")) { surf_source_write = true; @@ -941,22 +761,22 @@ void read_settings_xml(pugi::xml_node root) // Get maximum number of particles to be banked per surface if (check_for_node(node_ssw, "max_particles")) { - ssw_max_particles = std::stoll(get_node_value(node_ssw, "max_particles")); + max_surface_particles = + std::stoll(get_node_value(node_ssw, "max_particles")); } else { fatal_error("A maximum number of particles needs to be specified " "using the 'max_particles' parameter to store surface " "source points."); } - // Get maximum number of surface source files to be created - if (check_for_node(node_ssw, "max_source_files")) { - ssw_max_files = std::stoll(get_node_value(node_ssw, "max_source_files")); - } else { - ssw_max_files = 1; - } - if (check_for_node(node_ssw, "mcpl")) { surf_mcpl_write = get_node_value_bool(node_ssw, "mcpl"); + + // Make sure MCPL support is enabled + if (surf_mcpl_write && !MCPL_ENABLED) { + fatal_error("Your build of OpenMC does not support writing MCPL " + "surface source files."); + } } // Get cell information if (check_for_node(node_ssw, "cell")) { @@ -981,72 +801,8 @@ void read_settings_xml(pugi::xml_node root) } } - // Check if the user has specified to write specific collisions - if (check_for_node(root, "collision_track")) { - settings::collision_track = true; - // Get collision track node - xml_node node_ct = root.child("collision_track"); - collision_track_config = CollisionTrackConfig {}; - - // Determine cell ids at which crossing particles are to be banked - if (check_for_node(node_ct, "cell_ids")) { - auto temp = get_node_array(node_ct, "cell_ids"); - for (const auto& b : temp) { - collision_track_config.cell_ids.insert(b); - } - } - if (check_for_node(node_ct, "reactions")) { - auto temp = get_node_array(node_ct, "reactions"); - for (const auto& b : temp) { - int reaction_int = reaction_mt(b); - if (reaction_int > 0) { - collision_track_config.mt_numbers.insert(reaction_int); - } - } - } - if (check_for_node(node_ct, "universe_ids")) { - auto temp = get_node_array(node_ct, "universe_ids"); - for (const auto& b : temp) { - collision_track_config.universe_ids.insert(b); - } - } - if (check_for_node(node_ct, "material_ids")) { - auto temp = get_node_array(node_ct, "material_ids"); - for (const auto& b : temp) { - collision_track_config.material_ids.insert(b); - } - } - if (check_for_node(node_ct, "nuclides")) { - auto temp = get_node_array(node_ct, "nuclides"); - for (const auto& b : temp) { - collision_track_config.nuclides.insert(b); - } - } - if (check_for_node(node_ct, "deposited_E_threshold")) { - collision_track_config.deposited_energy_threshold = - std::stod(get_node_value(node_ct, "deposited_E_threshold")); - } - // Get maximum number of particles to be banked per collision - if (check_for_node(node_ct, "max_collisions")) { - collision_track_config.max_collisions = - std::stoll(get_node_value(node_ct, "max_collisions")); - } else { - warning("A maximum number of collisions needs to be specified. " - "By default the code sets 'max_collisions' parameter equals to " - "1000."); - } - // Get maximum number of collision_track files to be created - if (check_for_node(node_ct, "max_collision_track_files")) { - collision_track_config.max_files = - std::stoll(get_node_value(node_ct, "max_collision_track_files")); - } - if (check_for_node(node_ct, "mcpl")) { - collision_track_config.mcpl_write = get_node_value_bool(node_ct, "mcpl"); - } - } - - // If source is not separate and is to be written out in the statepoint - // file, make sure that the sourcepoint batch numbers are contained in the + // If source is not separate and is to be written out in the statepoint file, + // make sure that the sourcepoint batch numbers are contained in the // statepoint list if (!source_separate) { for (const auto& b : sourcepoint_batch) { @@ -1247,7 +1003,6 @@ void read_settings_xml(pugi::xml_node root) // read weight windows from file if (check_for_node(root, "weight_windows_file")) { weight_windows_file = get_node_value(root, "weight_windows_file"); - weight_windows_on = true; } // read settings for weight windows value, this will override @@ -1256,11 +1011,6 @@ void read_settings_xml(pugi::xml_node root) weight_windows_on = get_node_value_bool(root, "weight_windows_on"); } - if (check_for_node(root, "max_secondaries")) { - settings::max_secondaries = - std::stoi(get_node_value(root, "max_secondaries")); - } - if (check_for_node(root, "max_history_splits")) { settings::max_history_splits = std::stoi(get_node_value(root, "max_history_splits")); @@ -1278,24 +1028,14 @@ void read_settings_xml(pugi::xml_node root) variance_reduction::weight_windows_generators.emplace_back( std::make_unique(node_wwg)); } - // if any of the weight windows are intended to be generated otf, make - // sure they're applied + // if any of the weight windows are intended to be generated otf, make sure + // they're applied for (const auto& wwg : variance_reduction::weight_windows_generators) { if (wwg->on_the_fly_) { settings::weight_windows_on = true; break; } } - // If any weight window generators have local FW-CADIS target tallies, - // user-defined adjoint sources cannot be used at the same time. - if (!model::adjoint_sources.empty()) { - for (const auto& wwg : variance_reduction::weight_windows_generators) { - if (!wwg->targets_.empty()) { - fatal_error("Cannot use both user-defined adjoint sources and " - "FW-CADIS target tallies at the same time."); - } - } - } } // Set up weight window checkpoints @@ -1310,39 +1050,6 @@ void read_settings_xml(pugi::xml_node root) get_node_value_bool(ww_checkpoints, "surface"); } } - - if (weight_windows_on) { - if (!weight_window_checkpoint_surface && - !weight_window_checkpoint_collision) - fatal_error( - "Weight Windows are enabled but there are no valid checkpoints."); - } - - if (check_for_node(root, "use_decay_photons")) { - settings::use_decay_photons = - get_node_value_bool(root, "use_decay_photons"); - } - - // If weight windows are on, also enable shared secondary bank (unless - // explicitly disabled by user). - if (check_for_node(root, "shared_secondary_bank")) { - bool val = get_node_value_bool(root, "shared_secondary_bank"); - if (val && run_mode == RunMode::EIGENVALUE) { - warning( - "Shared secondary bank is not supported in eigenvalue calculations. " - "Setting will be ignored."); - } else { - settings::use_shared_secondary_bank = val; - } - } else if (settings::weight_windows_on) { - if (run_mode == RunMode::EIGENVALUE) { - warning( - "Shared secondary bank is not supported in eigenvalue calculations. " - "Particle local secondary banks will be used instead."); - } else if (run_mode == RunMode::FIXED_SOURCE) { - settings::use_shared_secondary_bank = true; - } - } } void free_memory_settings() @@ -1365,6 +1072,11 @@ extern "C" int openmc_set_n_batches( return OPENMC_E_INVALID_ARGUMENT; } + if (simulation::current_batch >= n_batches) { + set_errmsg("Number of batches must be greater than current batch."); + return OPENMC_E_INVALID_ARGUMENT; + } + if (!settings::trigger_on) { // Set n_batches and n_max_batches to same value settings::n_batches = n_batches; diff --git a/src/simulation.cpp b/src/simulation.cpp index 03f40a726..2d5d75aa4 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -2,22 +2,19 @@ #include "openmc/bank.h" #include "openmc/capi.h" -#include "openmc/collision_track.h" #include "openmc/container_util.h" #include "openmc/eigenvalue.h" #include "openmc/error.h" #include "openmc/event.h" #include "openmc/geometry_aux.h" -#include "openmc/ifp.h" #include "openmc/material.h" +#include "openmc/mcpl_interface.h" #include "openmc/message_passing.h" #include "openmc/nuclide.h" -#include "openmc/openmp_interface.h" #include "openmc/output.h" #include "openmc/particle.h" #include "openmc/photon.h" #include "openmc/random_lcg.h" -#include "openmc/random_ray/flat_source_domain.h" #include "openmc/settings.h" #include "openmc/source.h" #include "openmc/state_point.h" @@ -32,7 +29,7 @@ #ifdef _OPENMP #include #endif -#include "openmc/tensor.h" +#include "xtensor/xview.hpp" #ifdef OPENMC_MPI #include @@ -42,7 +39,6 @@ #include #include -#include #include //============================================================================== @@ -89,7 +85,7 @@ int openmc_simulation_init() } // Determine how much work each process should do - calculate_work(settings::n_particles); + calculate_work(); // Allocate source, fission and surface source banks. allocate_banks(); @@ -121,11 +117,8 @@ int openmc_simulation_init() // Reset global variables -- this is done before loading state point (as that // will potentially populate k_generation and entropy) simulation::current_batch = 0; - simulation::ct_current_file = 1; - simulation::ssw_current_file = 1; simulation::k_generation.clear(); simulation::entropy.clear(); - reset_source_rejection_counters(); openmc_reset(); // If this is a restart run, load the state point data and binary source @@ -203,12 +196,9 @@ int openmc_simulation_finalize() if (settings::output_tallies && mpi::master) write_tallies(); - // If weight window generators are present in this simulation, write a - // weight windows file. This is skipped during the forward solve of an - // adjoint (FW-CADIS) run, where only the adjoint-derived weight windows - // are meaningful. - if (variance_reduction::weight_windows_generators.size() > 0 && - FlatSourceDomain::solve_ != RandomRaySolve::FORWARD_FOR_ADJOINT) { + // If weight window generators are present in this simulation, + // write a weight windows file + if (variance_reduction::weight_windows_generators.size() > 0) { openmc_weight_windows_export(); } @@ -220,20 +210,6 @@ int openmc_simulation_finalize() // Stop timers and show timing statistics simulation::time_finalize.stop(); simulation::time_total.stop(); - -#ifdef OPENMC_MPI - // Reduce track count across ranks for correct reporting. In shared secondary - // bank mode, all ranks already have the global count; in non-shared mode, - // each rank only has its own count. - if (settings::weight_windows_on && !settings::use_shared_secondary_bank) { - int64_t total_tracks; - MPI_Reduce(&simulation::simulation_tracks_completed, &total_tracks, 1, - MPI_INT64_T, MPI_SUM, 0, mpi::intracomm); - if (mpi::master) - simulation::simulation_tracks_completed = total_tracks; - } -#endif - if (mpi::master) { if (settings::solver_type != SolverType::RANDOM_RAY) { if (settings::verbosity >= 6) @@ -274,17 +250,9 @@ int openmc_next_batch(int* status) // Transport loop if (settings::event_based) { - if (settings::use_shared_secondary_bank) { - transport_event_based_shared_secondary(); - } else { - transport_event_based(); - } + transport_event_based(); } else { - if (settings::use_shared_secondary_bank) { - transport_history_based_shared_secondary(); - } else { - transport_history_based(); - } + transport_history_based(); } // Accumulate time for transport @@ -327,7 +295,6 @@ namespace openmc { namespace simulation { -int ct_current_file; int current_batch; int current_gen; bool initialized {false}; @@ -341,7 +308,6 @@ int n_lost_particles {0}; bool need_depletion_rx {false}; int restart_batch; bool satisfy_triggers {false}; -int ssw_current_file; int total_gen {0}; double total_weight; int64_t work_per_rank; @@ -352,98 +318,8 @@ const RegularMesh* ufs_mesh {nullptr}; vector k_generation; vector work_index; -int64_t simulation_tracks_completed {0}; - } // namespace simulation -namespace { - -//! Collect thread-local secondary banks into the shared secondary bank in -//! sorted order. -//! -//! \param thread_banks Secondary banks produced by each OpenMP thread -void collect_sorted_history_secondary_banks( - vector>& thread_banks) -{ - // Count the total number of all secondary sites produced - int64_t n_collected = 0; - for (const auto& bank : thread_banks) { - n_collected += bank.size(); - } - - // Count the expected number of progeny from per-parent progeny counts - int64_t n_progeny = 0; - for (int64_t count : simulation::progeny_per_particle) { - n_progeny += count; - } - - if (n_collected != n_progeny) { - fatal_error("Mismatch detected between sum of all particle progeny and " - "secondary bank size during collection."); - } - - // Convert per-parent progeny counts to offsets into the sorted bank - std::exclusive_scan(simulation::progeny_per_particle.begin(), - simulation::progeny_per_particle.end(), - simulation::progeny_per_particle.begin(), 0); - - // Allocate the shared bank once for the complete generation - simulation::shared_secondary_bank_write.resize(0); - simulation::shared_secondary_bank_write.extend_uninitialized(n_progeny); - - // Place each secondary according to its parent and progeny identifiers - for (const auto& bank : thread_banks) { - for (const auto& site : bank) { - if (site.parent_id < 0 || - site.parent_id >= - static_cast(simulation::progeny_per_particle.size())) { - fatal_error(fmt::format("Invalid parent_id {} for banked site " - "(expected range [0, {})).", - site.parent_id, simulation::progeny_per_particle.size())); - } - int64_t idx = - simulation::progeny_per_particle[site.parent_id] + site.progeny_id; - if (idx < 0 || idx >= n_progeny) { - fatal_error("Mismatch detected between sum of all particle progeny and " - "secondary bank size during collection."); - } - simulation::shared_secondary_bank_write[idx] = site; - } - } -} - -//! Collect particle-local secondary banks into the shared secondary bank. -//! -//! \param n_particles Number of particles in the active event-based buffer -void collect_event_secondary_banks(int64_t n_particles) -{ - // Compute offsets for each particle's local secondary bank. - vector offsets(n_particles); - int64_t total = 0; - for (int64_t i = 0; i < n_particles; ++i) { - offsets[i] = total; - total += simulation::particles[i].local_secondary_bank().size(); - } - - // Extend the shared bank once for all collected secondaries - int64_t bank_offset = - simulation::shared_secondary_bank_write.extend_uninitialized(total); - - // Copy each local bank into its assigned range and clear the local storage -#pragma omp parallel for schedule(static) - for (int64_t i = 0; i < n_particles; ++i) { - auto& local_bank = simulation::particles[i].local_secondary_bank(); - if (!local_bank.empty()) { - std::copy(local_bank.cbegin(), local_bank.cend(), - simulation::shared_secondary_bank_write.data() + bank_offset + - offsets[i]); - local_bank.clear(); - } - } -} - -} // namespace - //============================================================================== // Non-member functions //============================================================================== @@ -457,21 +333,11 @@ void allocate_banks() // Allocate fission bank init_fission_bank(3 * simulation::work_per_rank); - - // Allocate IFP bank - if (settings::ifp_on) { - resize_simulation_ifp_banks(); - } } if (settings::surf_source_write) { // Allocate surface source bank - simulation::surf_source_bank.reserve(settings::ssw_max_particles); - } - - if (settings::collision_track) { - // Allocate collision track bank - collision_track_reserve_bank(); + simulation::surf_source_bank.reserve(settings::max_surface_particles); } } @@ -479,6 +345,7 @@ void initialize_batch() { // Increment current batch ++simulation::current_batch; + if (settings::run_mode == RunMode::FIXED_SOURCE) { if (settings::solver_type == SolverType::RANDOM_RAY && simulation::current_batch < settings::n_inactive + 1) { @@ -532,7 +399,7 @@ void finalize_batch() // Reset global tally results if (simulation::current_batch <= settings::n_inactive) { - simulation::global_tallies.fill(0.0); + xt::view(simulation::global_tallies, xt::all()) = 0.0; simulation::n_realizations = 0; } @@ -571,55 +438,45 @@ void finalize_batch() int w = std::to_string(settings::n_max_batches).size(); std::string source_point_filename = fmt::format("{0}source.{1:0{2}}", settings::path_output, simulation::current_batch, w); - span bankspan(simulation::source_bank); - write_source_point(source_point_filename, bankspan, - simulation::work_index, settings::source_mcpl_write); + gsl::span bankspan(simulation::source_bank); + if (settings::source_mcpl_write) { + write_mcpl_source_point( + source_point_filename.c_str(), bankspan, simulation::work_index); + } else { + write_source_point( + source_point_filename.c_str(), bankspan, simulation::work_index); + } } // Write a continously-overwritten source point if requested. if (settings::source_latest) { + + // note: correct file extension appended automatically auto filename = settings::path_output + "source"; - span bankspan(simulation::source_bank); - write_source_point(filename, bankspan, simulation::work_index, - settings::source_mcpl_write); + gsl::span bankspan(simulation::source_bank); + if (settings::source_mcpl_write) { + write_mcpl_source_point( + filename.c_str(), bankspan, simulation::work_index); + } else { + write_source_point(filename.c_str(), bankspan, simulation::work_index); + } } } // Write out surface source if requested. if (settings::surf_source_write && - simulation::ssw_current_file <= settings::ssw_max_files) { - bool last_batch = (simulation::current_batch == settings::n_batches); - if (simulation::surf_source_bank.full() || last_batch) { - // Determine appropriate filename - auto filename = fmt::format("{}surface_source.{}", settings::path_output, - simulation::current_batch); - if (settings::ssw_max_files == 1 || - (simulation::ssw_current_file == 1 && last_batch)) { - filename = settings::path_output + "surface_source"; - } - - // Get span of source bank and calculate parallel index vector - auto surf_work_index = mpi::calculate_parallel_index_vector( - simulation::surf_source_bank.size()); - span surfbankspan(simulation::surf_source_bank.begin(), - simulation::surf_source_bank.size()); - - // Write surface source file - write_source_point( - filename, surfbankspan, surf_work_index, settings::surf_mcpl_write); - - // Reset surface source bank and increment counter - simulation::surf_source_bank.clear(); - if (!last_batch && settings::ssw_max_files >= 1) { - simulation::surf_source_bank.reserve(settings::ssw_max_particles); - } - ++simulation::ssw_current_file; + simulation::current_batch == settings::n_batches) { + auto filename = settings::path_output + "surface_source"; + auto surf_work_index = + mpi::calculate_parallel_index_vector(simulation::surf_source_bank.size()); + gsl::span surfbankspan(simulation::surf_source_bank.begin(), + simulation::surf_source_bank.size()); + if (settings::surf_mcpl_write) { + write_mcpl_source_point(filename.c_str(), surfbankspan, surf_work_index); + } else { + write_source_point(filename.c_str(), surfbankspan, surf_work_index); } } - // Write collision track file if requested - if (settings::collision_track) { - collision_track_flush_bank(); - } } void initialize_generation() @@ -665,7 +522,7 @@ void finalize_generation() // If using shared memory, stable sort the fission bank (by parent IDs) // so as to allow for reproducibility regardless of which order particles // are run in. - sort_bank(simulation::fission_bank, true); + sort_fission_bank(); // Distribute fission bank across processors evenly synchronize_bank(); @@ -674,8 +531,7 @@ void finalize_generation() if (settings::run_mode == RunMode::EIGENVALUE) { // Calculate shannon entropy - if (settings::entropy_on && - settings::solver_type == SolverType::MONTE_CARLO) + if (settings::entropy_on) shannon_entropy(); // Collect results and statistics @@ -689,35 +545,26 @@ void finalize_generation() } } -void sample_source_particle(Particle& p, int64_t index_source) +void initialize_history(Particle& p, int64_t index_source) { - // Sample a particle from the source bank + // set defaults if (settings::run_mode == RunMode::EIGENVALUE) { + // set defaults for eigenvalue simulations from primary bank p.from_source(&simulation::source_bank[index_source - 1]); } else if (settings::run_mode == RunMode::FIXED_SOURCE) { // initialize random number seed - int64_t id = compute_transport_seed(compute_particle_id(index_source)); + int64_t id = (simulation::total_gen + overall_generation() - 1) * + settings::n_particles + + simulation::work_index[mpi::rank] + index_source; uint64_t seed = init_seed(id, STREAM_SOURCE); // sample from external source distribution or custom library then set auto site = sample_external_source(&seed); p.from_source(&site); } -} - -void initialize_particle_track( - Particle& p, int64_t index_source, bool is_secondary) -{ - // Note: index_source is 1-based (first particle = 1), but current_work() is - // stored as 0-based for direct use as an array index into - // progeny_per_particle, source_bank, ifp banks, etc. - if (!is_secondary) { - sample_source_particle(p, index_source); - } - - p.current_work() = index_source - 1; + p.current_work() = index_source; // set identifier for particle - p.id() = compute_particle_id(index_source); + p.id() = simulation::work_index[mpi::rank] + index_source; // set progeny count to zero p.n_progeny() = 0; @@ -725,23 +572,19 @@ void initialize_particle_track( // Reset particle event counter p.n_event() = 0; - // Initialize track counter (1 for this primary/secondary track) - p.n_tracks() = 1; - // Reset split counter p.n_split() = 0; // Reset weight window ratio p.ww_factor() = 0.0; - // set particle history start weight - p.wgt_born() = p.wgt(); - // Reset pulse_height_storage std::fill(p.pht_storage().begin(), p.pht_storage().end(), 0); // set random number seed - int64_t particle_seed = compute_transport_seed(p.id()); + int64_t particle_seed = + (simulation::total_gen + overall_generation() - 1) * settings::n_particles + + p.id(); init_particle_seeds(particle_seed, p.seeds()); // set particle trace @@ -754,22 +597,14 @@ void initialize_particle_track( // Set particle track. p.write_track() = check_track_criteria(p); - // Set the particle's initial weight window value. - if (!is_secondary) { - p.wgt_ww_born() = -1.0; - apply_weight_windows(p); - } - // Display message if high verbosity or trace is on if (settings::verbosity >= 9 || p.trace()) { write_message("Simulating Particle {}", p.id()); } - // Add particle's starting weight to count for normalizing tallies later - if (!is_secondary) { +// Add paricle's starting weight to count for normalizing tallies later #pragma omp atomic - simulation::total_weight += p.wgt(); - } + simulation::total_weight += p.wgt(); // Force calculation of cross-sections by setting last energy to zero if (settings::run_CE) { @@ -787,34 +622,13 @@ int overall_generation() return settings::gen_per_batch * (current_batch - 1) + current_gen; } -int64_t compute_particle_id(int64_t index_source) -{ - if (settings::use_shared_secondary_bank) { - return simulation::work_index[mpi::rank] + index_source + - simulation::simulation_tracks_completed; - } else { - return simulation::work_index[mpi::rank] + index_source; - } -} - -int64_t compute_transport_seed(int64_t particle_id) -{ - if (settings::use_shared_secondary_bank) { - return particle_id; - } else { - return (simulation::total_gen + overall_generation() - 1) * - settings::n_particles + - particle_id; - } -} - -void calculate_work(int64_t n_particles) +void calculate_work() { // Determine minimum amount of particles to simulate on each processor - int64_t min_work = n_particles / mpi::n_procs; + int64_t min_work = settings::n_particles / mpi::n_procs; // Determine number of processors that have one extra particle - int64_t remainder = n_particles % mpi::n_procs; + int64_t remainder = settings::n_particles % mpi::n_procs; int64_t i_bank = 0; simulation::work_index.resize(mpi::n_procs + 1); @@ -836,12 +650,11 @@ void calculate_work(int64_t n_particles) void initialize_data() { // Determine minimum/maximum energy for incident neutron/photon data - data::energy_max = {INFTY, INFTY, INFTY, INFTY}; - data::energy_min = {0.0, 0.0, 0.0, 0.0}; - + data::energy_max = {INFTY, INFTY}; + data::energy_min = {0.0, 0.0}; for (const auto& nuc : data::nuclides) { if (nuc->grid_.size() >= 1) { - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); data::energy_min[neutron] = std::max(data::energy_min[neutron], nuc->grid_[0].energy.front()); data::energy_max[neutron] = @@ -852,7 +665,7 @@ void initialize_data() if (settings::photon_transport) { for (const auto& elem : data::elements) { if (elem->energy_.size() >= 1) { - int photon = ParticleType::photon().transport_index(); + int photon = static_cast(ParticleType::photon); int n = elem->energy_.size(); data::energy_min[photon] = std::max(data::energy_min[photon], std::exp(elem->energy_(1))); @@ -865,22 +678,12 @@ void initialize_data() // Determine if minimum/maximum energy for bremsstrahlung is greater/less // than the current minimum/maximum if (data::ttb_e_grid.size() >= 1) { - int photon = ParticleType::photon().transport_index(); - int electron = ParticleType::electron().transport_index(); - int positron = ParticleType::positron().transport_index(); + int photon = static_cast(ParticleType::photon); int n_e = data::ttb_e_grid.size(); - - const std::vector charged = {electron, positron}; - for (auto t : charged) { - data::energy_min[t] = std::exp(data::ttb_e_grid(1)); - data::energy_max[t] = std::exp(data::ttb_e_grid(n_e - 1)); - } - data::energy_min[photon] = - std::max(data::energy_min[photon], data::energy_min[electron]); - - data::energy_max[photon] = - std::min(data::energy_max[photon], data::energy_max[electron]); + std::max(data::energy_min[photon], std::exp(data::ttb_e_grid(1))); + data::energy_max[photon] = std::min( + data::energy_max[photon], std::exp(data::ttb_e_grid(n_e - 1))); } } } @@ -891,7 +694,7 @@ void initialize_data() // grid has not been allocated if (nuc->grid_.size() > 0) { double max_E = nuc->grid_[0].energy.back(); - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); if (max_E == data::energy_max[neutron]) { write_message(7, "Maximum neutron transport energy: {} eV for {}", data::energy_max[neutron], nuc->name_); @@ -908,7 +711,7 @@ void initialize_data() for (auto& nuc : data::nuclides) { nuc->init_grid(); } - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); simulation::log_spacing = std::log(data::energy_max[neutron] / data::energy_min[neutron]) / settings::n_log_bins; @@ -963,146 +766,27 @@ void transport_history_based_single_particle(Particle& p) p.event_advance(); } if (p.alive()) { - if (p.collision_distance() > p.boundary().distance()) { + if (p.collision_distance() > p.boundary().distance) { p.event_cross_surface(); } else if (p.alive()) { p.event_collide(); } } - p.event_check_limit_and_revive(); + p.event_revive_from_secondary(); } p.event_death(); } void transport_history_based() { -#pragma omp parallel - { +#pragma omp parallel for schedule(runtime) + for (int64_t i_work = 1; i_work <= simulation::work_per_rank; ++i_work) { Particle p; -#pragma omp for schedule(runtime) - for (int64_t i_work = 1; i_work <= simulation::work_per_rank; ++i_work) { - initialize_particle_track(p, i_work, false); - transport_history_based_single_particle(p); - } + initialize_history(p, i_work); + transport_history_based_single_particle(p); } } -// The shared secondary bank transport algorithm works in two phases. In the -// first phase, all primary particles are sampled then transported, and their -// secondary particles are deposited into a shared secondary bank. The second -// phase occurs in a loop, where all secondary tracks in the shared secondary -// bank are transported. Any secondary particles generated during this phase are -// deposited back into the shared secondary bank. The shared secondary bank is -// sorted for consistent ordering and load balanced across MPI ranks. This loop -// continues until there are no more secondary tracks left to transport. -void transport_history_based_shared_secondary() -{ - // Clear shared secondary banks from any prior use - simulation::shared_secondary_bank_read.clear(); - simulation::shared_secondary_bank_write.clear(); - - if (mpi::master) { - write_message(fmt::format(" Primary source particles: {}", - settings::n_particles), - 6); - } - - simulation::progeny_per_particle.resize(simulation::work_per_rank); - std::fill(simulation::progeny_per_particle.begin(), - simulation::progeny_per_particle.end(), 0); - - vector> thread_banks(num_threads()); - - // Phase 1: Transport primary particles and deposit first generation of - // secondaries in the shared secondary bank -#pragma omp parallel - { - auto& thread_bank = thread_banks[thread_num()]; - Particle p; - -#pragma omp for schedule(runtime) - for (int64_t i = 1; i <= simulation::work_per_rank; i++) { - initialize_particle_track(p, i, false); - transport_history_based_single_particle(p); - for (auto& site : p.local_secondary_bank()) { - thread_bank.push_back(site); - } - p.local_secondary_bank().clear(); - } - } - collect_sorted_history_secondary_banks(thread_banks); - thread_banks.clear(); - - simulation::simulation_tracks_completed += settings::n_particles; - - // Phase 2: Now that the secondary bank has been populated, enter loop over - // all secondary generations - int n_generation_depth = 1; - int64_t alive_secondary = 1; - while (alive_secondary) { - - // Synchronize the shared secondary bank amongst all MPI ranks, such - // that each MPI rank has an approximately equal number of secondary - // tracks. Also reports the total number of secondaries alive across - // all MPI ranks. - alive_secondary = synchronize_global_secondary_bank( - simulation::shared_secondary_bank_write); - - // Recalculate work for each MPI rank based on number of alive secondary - // tracks - calculate_work(alive_secondary); - - // Display the number of secondary tracks in this generation. This - // is useful for user monitoring so as to see if the secondary population is - // exploding and to determine how many generations of secondaries are being - // transported. - if (mpi::master) { - write_message(fmt::format(" Secondary generation {:<2} tracks: {}", - n_generation_depth, alive_secondary), - 6); - } - - simulation::shared_secondary_bank_read = - std::move(simulation::shared_secondary_bank_write); - simulation::shared_secondary_bank_write = SharedArray(); - simulation::progeny_per_particle.resize( - simulation::shared_secondary_bank_read.size()); - std::fill(simulation::progeny_per_particle.begin(), - simulation::progeny_per_particle.end(), 0); - thread_banks.resize(num_threads()); - - // Transport all secondary tracks from the shared secondary bank -#pragma omp parallel - { - auto& thread_bank = thread_banks[thread_num()]; - Particle p; - -#pragma omp for schedule(runtime) - for (int64_t i = 1; i <= simulation::shared_secondary_bank_read.size(); - i++) { - initialize_particle_track(p, i, true); - SourceSite& site = simulation::shared_secondary_bank_read[i - 1]; - p.event_revive_from_secondary(site); - transport_history_based_single_particle(p); - for (auto& secondary_site : p.local_secondary_bank()) { - thread_bank.push_back(secondary_site); - } - p.local_secondary_bank().clear(); - } - } // End of transport loop over tracks in shared secondary bank - simulation::shared_secondary_bank_write = - std::move(simulation::shared_secondary_bank_read); - simulation::shared_secondary_bank_read = SharedArray(); - collect_sorted_history_secondary_banks(thread_banks); - thread_banks.clear(); - n_generation_depth++; - simulation::simulation_tracks_completed += alive_secondary; - } // End of loop over secondary generations - - // Reset work so that fission bank etc works correctly - calculate_work(settings::n_particles); -} - void transport_event_based() { int64_t remaining_work = simulation::work_per_rank; @@ -1120,7 +804,33 @@ void transport_event_based() // Initialize all particle histories for this subiteration process_init_events(n_particles, source_offset); - process_transport_events(); + + // Event-based transport loop + while (true) { + // Determine which event kernel has the longest queue + int64_t max = std::max({simulation::calculate_fuel_xs_queue.size(), + simulation::calculate_nonfuel_xs_queue.size(), + simulation::advance_particle_queue.size(), + simulation::surface_crossing_queue.size(), + simulation::collision_queue.size()}); + + // Execute event with the longest queue + if (max == 0) { + break; + } else if (max == simulation::calculate_fuel_xs_queue.size()) { + process_calculate_xs_events(simulation::calculate_fuel_xs_queue); + } else if (max == simulation::calculate_nonfuel_xs_queue.size()) { + process_calculate_xs_events(simulation::calculate_nonfuel_xs_queue); + } else if (max == simulation::advance_particle_queue.size()) { + process_advance_particle_events(); + } else if (max == simulation::surface_crossing_queue.size()) { + process_surface_crossing_events(); + } else if (max == simulation::collision_queue.size()) { + process_collision_events(); + } + } + + // Execute death event for all particles process_death_events(n_particles); // Adjust remaining work and source offset variables @@ -1129,110 +839,4 @@ void transport_event_based() } } -void transport_event_based_shared_secondary() -{ - // Clear shared secondary banks from any prior use - simulation::shared_secondary_bank_read.clear(); - simulation::shared_secondary_bank_write.clear(); - - if (mpi::master) { - write_message(fmt::format(" Primary source particles: {}", - settings::n_particles), - 6); - } - - simulation::progeny_per_particle.resize(simulation::work_per_rank); - std::fill(simulation::progeny_per_particle.begin(), - simulation::progeny_per_particle.end(), 0); - - // Phase 1: Transport primary particles using event-based processing and - // deposit first generation of secondaries in the shared secondary bank - int64_t remaining_work = simulation::work_per_rank; - int64_t source_offset = 0; - - while (remaining_work > 0) { - int64_t n_particles = - std::min(remaining_work, settings::max_particles_in_flight); - - process_init_events(n_particles, source_offset); - process_transport_events(); - process_death_events(n_particles); - - collect_event_secondary_banks(n_particles); - - remaining_work -= n_particles; - source_offset += n_particles; - } - - simulation::simulation_tracks_completed += settings::n_particles; - - // Phase 2: Now that the secondary bank has been populated, enter loop over - // all secondary generations - int n_generation_depth = 1; - int64_t alive_secondary = 1; - while (alive_secondary) { - - // Sort the shared secondary bank by parent ID then progeny ID to - // ensure reproducibility. - sort_bank(simulation::shared_secondary_bank_write, false); - - // Synchronize the shared secondary bank amongst all MPI ranks, such - // that each MPI rank has an approximately equal number of secondary - // tracks. - alive_secondary = synchronize_global_secondary_bank( - simulation::shared_secondary_bank_write); - - // Recalculate work for each MPI rank based on number of alive secondary - // tracks - calculate_work(alive_secondary); - - if (mpi::master) { - write_message(fmt::format(" Secondary generation {:<2} tracks: {}", - n_generation_depth, alive_secondary), - 6); - } - - simulation::shared_secondary_bank_read = - std::move(simulation::shared_secondary_bank_write); - simulation::shared_secondary_bank_write = SharedArray(); - simulation::progeny_per_particle.resize( - simulation::shared_secondary_bank_read.size()); - std::fill(simulation::progeny_per_particle.begin(), - simulation::progeny_per_particle.end(), 0); - - // Ensure particle buffer is large enough for this secondary generation - int64_t sec_buffer_length = std::min( - static_cast(simulation::shared_secondary_bank_read.size()), - settings::max_particles_in_flight); - if (sec_buffer_length > - static_cast(simulation::particles.size())) { - init_event_queues(sec_buffer_length); - } - - // Transport secondary tracks using event-based processing - int64_t sec_remaining = simulation::shared_secondary_bank_read.size(); - int64_t sec_offset = 0; - - while (sec_remaining > 0) { - int64_t n_particles = - std::min(sec_remaining, settings::max_particles_in_flight); - - process_init_secondary_events( - n_particles, sec_offset, simulation::shared_secondary_bank_read); - process_transport_events(); - process_death_events(n_particles); - - collect_event_secondary_banks(n_particles); - - sec_remaining -= n_particles; - sec_offset += n_particles; - } // End of subiteration loop over secondary tracks - n_generation_depth++; - simulation::simulation_tracks_completed += alive_secondary; - } // End of loop over secondary generations - - // Reset work so that fission bank etc works correctly - calculate_work(settings::n_particles); -} - } // namespace openmc diff --git a/src/source.cpp b/src/source.cpp index 12bbdf84e..15fe8433b 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -4,34 +4,29 @@ #define HAS_DYNAMIC_LINKING #endif -#include // for max -#include // for sin, cos, abs -#include // for move +#include // for move #ifdef HAS_DYNAMIC_LINKING #include // for dlopen, dlsym, dlclose, dlerror #endif -#include "openmc/tensor.h" +#include "xtensor/xadapt.hpp" #include #include "openmc/bank.h" #include "openmc/capi.h" #include "openmc/cell.h" -#include "openmc/constants.h" #include "openmc/container_util.h" #include "openmc/error.h" #include "openmc/file_utils.h" #include "openmc/geometry.h" #include "openmc/hdf5_interface.h" #include "openmc/material.h" -#include "openmc/math_functions.h" #include "openmc/mcpl_interface.h" #include "openmc/memory.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" -#include "openmc/random_dist.h" #include "openmc/random_lcg.h" #include "openmc/search.h" #include "openmc/settings.h" @@ -42,23 +37,6 @@ namespace openmc { -std::atomic source_n_accept {0}; -std::atomic source_n_reject {0}; - -namespace { - -void validate_particle_type(ParticleType type, const std::string& context) -{ - if (type.is_transportable()) - return; - - fatal_error( - fmt::format("Unsupported source particle type '{}' (PDG {}) in {}.", - type.str(), type.pdg_number(), context)); -} - -} // namespace - //============================================================================== // Global variables //============================================================================== @@ -66,12 +44,7 @@ void validate_particle_type(ParticleType type, const std::string& context) namespace model { vector> external_sources; - -vector> adjoint_sources; - -DiscreteIndex external_sources_probability; - -} // namespace model +} //============================================================================== // Source implementation @@ -105,8 +78,6 @@ unique_ptr Source::create(pugi::xml_node node) return make_unique(node); } else if (source_type == "mesh") { return make_unique(node); - } else if (source_type == "tokamak") { - return make_unique(node); } else { fatal_error(fmt::format("Invalid source type '{}' found.", source_type)); } @@ -183,28 +154,12 @@ void Source::read_constraints(pugi::xml_node node) } } -void check_rejection_fraction(int64_t n_reject, int64_t n_accept) -{ - // Don't check unless we've hit a minimum number of total sites rejected - if (n_reject < EXTSRC_REJECT_THRESHOLD) - return; - - // Compute fraction of accepted sites and compare against minimum - double fraction = static_cast(n_accept) / n_reject; - if (fraction <= settings::source_rejection_fraction) { - fatal_error(fmt::format( - "Too few source sites satisfied the constraints (minimum source " - "rejection fraction = {}). Please check your source definition or " - "set a lower value of Settings.source_rejection_fraction.", - settings::source_rejection_fraction)); - } -} - SourceSite Source::sample_with_constraints(uint64_t* seed) const { bool accepted = false; - int64_t n_local_reject = 0; - SourceSite site {}; + static int n_reject = 0; + static int n_accept = 0; + SourceSite site; while (!accepted) { // Sample a source site without considering constraints yet @@ -218,12 +173,12 @@ SourceSite Source::sample_with_constraints(uint64_t* seed) const satisfies_energy_constraints(site.E) && satisfies_time_constraints(site.time); if (!accepted) { - ++n_local_reject; - - // Check per-particle rejection limit - if (n_local_reject >= MAX_SOURCE_REJECTIONS_PER_SAMPLE) { - fatal_error("Exceeded maximum number of source rejections per " - "sample. Please check your source definition."); + ++n_reject; + if (n_reject >= EXTSRC_REJECT_THRESHOLD && + static_cast(n_accept) / n_reject <= + EXTSRC_REJECT_FRACTION) { + fatal_error("More than 95% of external source sites sampled were " + "rejected. Please check your source definition."); } // For the "kill" strategy, accept particle but set weight to 0 so that @@ -236,13 +191,8 @@ SourceSite Source::sample_with_constraints(uint64_t* seed) const } } - // Flush local rejection count, update accept counter, and check overall - // rejection fraction - if (n_local_reject > 0) { - source_n_reject += n_local_reject; - } - ++source_n_accept; - check_rejection_fraction(source_n_reject, source_n_accept); + // Increment number of accepted samples + ++n_accept; return site; } @@ -273,17 +223,14 @@ bool Source::satisfies_spatial_constraints(Position r) const if (!domain_ids_.empty()) { if (domain_type_ == DomainType::MATERIAL) { auto mat_index = geom_state.material(); - if (mat_index == MATERIAL_VOID) { - accepted = false; - } else { + if (mat_index != MATERIAL_VOID) { accepted = contains(domain_ids_, model::materials[mat_index]->id()); } } else { for (int i = 0; i < geom_state.n_coord(); i++) { - auto id = - (domain_type_ == DomainType::CELL) - ? model::cells[geom_state.coord(i).cell()].get()->id_ - : model::universes[geom_state.coord(i).universe()].get()->id_; + auto id = (domain_type_ == DomainType::CELL) + ? model::cells[geom_state.coord(i).cell]->id_ + : model::universes[geom_state.coord(i).universe]->id_; if ((accepted = contains(domain_ids_, id))) break; } @@ -318,15 +265,16 @@ IndependentSource::IndependentSource(pugi::xml_node node) : Source(node) { // Check for particle type if (check_for_node(node, "particle")) { - auto temp_str = get_node_value(node, "particle", false, true); - particle_ = ParticleType(temp_str); - if (particle_ == ParticleType::photon() || - particle_ == ParticleType::electron() || - particle_ == ParticleType::positron()) { + auto temp_str = get_node_value(node, "particle", true, true); + if (temp_str == "neutron") { + particle_ = ParticleType::neutron; + } else if (temp_str == "photon") { + particle_ = ParticleType::photon; settings::photon_transport = true; + } else { + fatal_error(std::string("Unknown source particle type: ") + temp_str); } } - validate_particle_type(particle_, "IndependentSource"); // Check for external source file if (check_for_node(node, "file")) { @@ -361,19 +309,6 @@ IndependentSource::IndependentSource(pugi::xml_node node) : Source(node) if (check_for_node(node, "energy")) { pugi::xml_node node_dist = node.child("energy"); energy_ = distribution_from_xml(node_dist); - - // For decay photon sources, use the absolute photon emission rate in - // [photons/s] as the source strength - if (dynamic_cast(energy_.get())) { - if (strength_ != 1.0) { - warning(fmt::format( - "Source strength of {} is ignored because the source uses a " - "DecaySpectrum energy distribution. The source strength will be " - "set from the DecaySpectrum emission rate.", - strength_)); - } - strength_ = energy_->integral(); - } } else { // Default to a Watt spectrum with parameters 0.988 MeV and 2.249 MeV^-1 energy_ = UPtrDist {new Watt(0.988e6, 2.249e-6)}; @@ -394,93 +329,75 @@ IndependentSource::IndependentSource(pugi::xml_node node) : Source(node) SourceSite IndependentSource::sample(uint64_t* seed) const { - SourceSite site {}; + SourceSite site; site.particle = particle_; - double r_wgt = 1.0; - double E_wgt = 1.0; // Repeat sampling source location until a good site has been accepted bool accepted = false; - int64_t n_local_reject = 0; + static int n_reject = 0; + static int n_accept = 0; while (!accepted) { // Sample spatial distribution - auto [r, r_wgt_temp] = space_->sample(seed); - site.r = r; - r_wgt = r_wgt_temp; + site.r = space_->sample(seed); // Check if sampled position satisfies spatial constraints accepted = satisfies_spatial_constraints(site.r); // Check for rejection if (!accepted) { - ++n_local_reject; - if (n_local_reject >= MAX_SOURCE_REJECTIONS_PER_SAMPLE) { - fatal_error("Exceeded maximum number of source rejections per " - "sample. Please check your source definition."); + ++n_reject; + if (n_reject >= EXTSRC_REJECT_THRESHOLD && + static_cast(n_accept) / n_reject <= EXTSRC_REJECT_FRACTION) { + fatal_error("More than 95% of external source sites sampled were " + "rejected. Please check your external source's spatial " + "definition."); } } } // Sample angle - auto [u, u_wgt] = angle_->sample(seed); - site.u = u; - - site.wgt = r_wgt * u_wgt; + site.u = angle_->sample(seed); // Sample energy and time for neutron and photon sources if (settings::solver_type != SolverType::RANDOM_RAY) { // Check for monoenergetic source above maximum particle energy - auto p = particle_.transport_index(); + auto p = static_cast(particle_); auto energy_ptr = dynamic_cast(energy_.get()); - auto decay_spectrum = dynamic_cast(energy_.get()); if (energy_ptr) { - auto energies = - tensor::Tensor(energy_ptr->x().data(), energy_ptr->x().size()); - if ((energies > data::energy_max[p]).any()) { + auto energies = xt::adapt(energy_ptr->x()); + if (xt::any(energies > data::energy_max[p])) { fatal_error("Source energy above range of energies of at least " "one cross section table"); } } while (true) { - // Sample energy spectrum. For decay photon sources, also get the parent - // nuclide index to store in the source site for tallying purposes. - if (decay_spectrum) { - auto sample = decay_spectrum->sample_with_parent(seed); - site.E = sample.energy; - E_wgt = sample.weight; - site.parent_nuclide = sample.parent_nuclide; - } else { - auto [E, E_wgt_temp] = energy_->sample(seed); - site.E = E; - E_wgt = E_wgt_temp; - } + // Sample energy spectrum + site.E = energy_->sample(seed); // Resample if energy falls above maximum particle energy - if (site.E < data::energy_max[p] && + if (site.E < data::energy_max[p] and (satisfies_energy_constraints(site.E))) break; - ++n_local_reject; - if (n_local_reject >= MAX_SOURCE_REJECTIONS_PER_SAMPLE) { - fatal_error("Exceeded maximum number of source rejections per " - "sample. Please check your source definition."); + n_reject++; + if (n_reject >= EXTSRC_REJECT_THRESHOLD && + static_cast(n_accept) / n_reject <= EXTSRC_REJECT_FRACTION) { + fatal_error( + "More than 95% of external source sites sampled were " + "rejected. Please check your external source energy spectrum " + "definition."); } } // Sample particle creation time - auto [time, time_wgt] = time_->sample(seed); - site.time = time; - - site.wgt *= (E_wgt * time_wgt); + site.time = time_->sample(seed); } - // Flush local rejection count into global counter - if (n_local_reject > 0) { - source_n_reject += n_local_reject; - } + // Increment number of accepted samples + ++n_accept; return site; } @@ -492,7 +409,11 @@ SourceSite IndependentSource::sample(uint64_t* seed) const FileSource::FileSource(pugi::xml_node node) : Source(node) { auto path = get_node_value(node, "file", false, true); - load_sites_from_file(path); + if (ends_with(path, ".mcpl") || ends_with(path, ".mcpl.gz")) { + sites_ = mcpl_source_sites(path); + } else { + this->load_sites_from_file(path); + } } FileSource::FileSource(const std::string& path) @@ -502,45 +423,30 @@ FileSource::FileSource(const std::string& path) void FileSource::load_sites_from_file(const std::string& path) { - // If MCPL file, use the dedicated file reader - if (ends_with(path, ".mcpl") || ends_with(path, ".mcpl.gz")) { - sites_ = mcpl_source_sites(path); - } else { - // Check if source file exists - if (!file_exists(path)) { - fatal_error(fmt::format("Source file '{}' does not exist.", path)); - } - - write_message(6, "Reading source file from {}...", path); - - // Open the binary file - hid_t file_id = file_open(path, 'r', true); - - // Check to make sure this is a source file - std::string filetype; - read_attribute(file_id, "filetype", filetype); - if (filetype != "source" && filetype != "statepoint") { - fatal_error("Specified starting source file not a source file type."); - } - - // Read in the source particles - read_source_bank(file_id, sites_, false); - - // Close file - file_close(file_id); + // Check if source file exists + if (!file_exists(path)) { + fatal_error(fmt::format("Source file '{}' does not exist.", path)); } - // Make sure particles in source file have valid types. If any particle is a - // photon, electron, or positron, enable photon transport so that the - // appropriate cross sections are loaded. - for (const auto& site : this->sites_) { - validate_particle_type(site.particle, "FileSource"); - if (site.particle == ParticleType::photon() || - site.particle == ParticleType::electron() || - site.particle == ParticleType::positron()) { - settings::photon_transport = true; - } + // Read the source from a binary file instead of sampling from some + // assumed source distribution + write_message(6, "Reading source file from {}...", path); + + // Open the binary file + hid_t file_id = file_open(path, 'r', true); + + // Check to make sure this is a source file + std::string filetype; + read_attribute(file_id, "filetype", filetype); + if (filetype != "source" && filetype != "statepoint") { + fatal_error("Specified starting source file not a source file type."); } + + // Read in the source particles + read_source_bank(file_id, sites_, false); + + // Close file + file_close(file_id); } SourceSite FileSource::sample(uint64_t* seed) const @@ -614,15 +520,6 @@ CompiledSourceWrapper::~CompiledSourceWrapper() #endif } -//============================================================================== -// MeshElementSpatial implementation -//============================================================================== - -std::pair MeshElementSpatial::sample(uint64_t* seed) const -{ - return {model::meshes[mesh_index_]->sample_element(elem_index_, seed), 1.0}; -} - //============================================================================== // MeshSource implementation //============================================================================== @@ -637,28 +534,10 @@ MeshSource::MeshSource(pugi::xml_node node) : Source(node) // read all source distributions and populate strengths vector for MeshSpatial // object for (auto source_node : node.children("source")) { - auto src = Source::create(source_node); - if (auto ptr = dynamic_cast(src.get())) { - src.release(); - sources_.emplace_back(ptr); - } else { - fatal_error( - "The source assigned to each element must be an IndependentSource."); - } + sources_.emplace_back(Source::create(source_node)); strengths.push_back(sources_.back()->strength()); } - // Set spatial distributions for each mesh element - for (int elem_index = 0; elem_index < sources_.size(); ++elem_index) { - sources_[elem_index]->set_space( - std::make_unique(mesh_idx, elem_index)); - } - - // Make sure sources use valid particle types - for (const auto& src : sources_) { - validate_particle_type(src->particle_type(), "MeshSource"); - } - // the number of source distributions should either be one or equal to the // number of mesh elements if (sources_.size() > 1 && sources_.size() != mesh->n_bins()) { @@ -672,476 +551,28 @@ MeshSource::MeshSource(pugi::xml_node node) : Source(node) SourceSite MeshSource::sample(uint64_t* seed) const { - // Sample a mesh element based on the relative strengths + // Sample the CDF defined in initialization above int32_t element = space_->sample_element_index(seed); - // Sample the distribution for the specific mesh element; note that the - // spatial distribution has been set for each element using MeshElementSpatial - return source(element)->sample_with_constraints(seed); -} + // Sample position and apply rejection on spatial domains + Position r; + do { + r = space_->mesh()->sample_element(element, seed); + } while (!this->satisfies_spatial_constraints(r)); -//============================================================================== -// TokamakSource implementation -//============================================================================== + SourceSite site; + while (true) { + // Sample source for the chosen element and replace the position + site = source(element)->sample_with_constraints(seed); + site.r = r; -TokamakSource::TokamakSource(pugi::xml_node node) : Source(node) -{ - // Read geometry parameters - major_radius_ = std::stod(get_node_value(node, "major_radius")); - minor_radius_ = std::stod(get_node_value(node, "minor_radius")); - elongation_ = std::stod(get_node_value(node, "elongation")); - triangularity_ = std::stod(get_node_value(node, "triangularity")); - shafranov_shift_ = std::stod(get_node_value(node, "shafranov_shift")); - - // Read optional vertical shift - if (check_for_node(node, "vertical_shift")) { - vertical_shift_ = std::stod(get_node_value(node, "vertical_shift")); - } else { - vertical_shift_ = 0.0; - } - - // Read optional toroidal angle bounds - if (check_for_node(node, "phi_start")) { - phi_start_ = std::stod(get_node_value(node, "phi_start")); - } else { - phi_start_ = 0.0; - } - if (check_for_node(node, "phi_extent")) { - phi_extent_ = std::stod(get_node_value(node, "phi_extent")); - } else { - phi_extent_ = 2.0 * PI; - } - if (check_for_node(node, "n_alpha")) { - n_alpha_ = std::stoi(get_node_value(node, "n_alpha")); - } else { - n_alpha_ = 101; // Default - } - - // Read emission profile - r_over_a_ = get_node_array(node, "r_over_a"); - emission_density_ = get_node_array(node, "emission_density"); - - // Read energy distribution(s) - for (auto energy_node : node.children("energy")) { - energy_dists_.push_back(distribution_from_xml(energy_node)); - } - - // Read optional time distribution; default to a delta distribution at t=0 - // for the same behavior as IndependentSource - if (check_for_node(node, "time")) { - time_ = distribution_from_xml(node.child("time")); - } else { - double T[] {0.0}; - double p[] {1.0}; - time_ = UPtrDist {new Discrete {T, p, 1}}; - } - - // Validate inputs - if (emission_density_.size() != r_over_a_.size()) { - fatal_error("TokamakSource: emission_density and r_over_a must have the " - "same length."); - } - if (r_over_a_.size() < 2) { - fatal_error( - "TokamakSource: At least 2 radial points are required for profiles."); - } - if (r_over_a_.front() != 0.0) { - fatal_error("TokamakSource: r_over_a must start at 0."); - } - if (r_over_a_.back() != 1.0) { - fatal_error("TokamakSource: r_over_a must end at 1."); - } - for (size_t i = 1; i < r_over_a_.size(); ++i) { - if (r_over_a_[i] <= r_over_a_[i - 1]) { - fatal_error("TokamakSource: r_over_a must be strictly increasing."); - } - } - for (size_t i = 0; i < emission_density_.size(); ++i) { - if (emission_density_[i] < 0.0) { - fatal_error("TokamakSource: emission_density values cannot be negative."); - } - } - if (major_radius_ <= 0.0) { - fatal_error("TokamakSource: major_radius must be > 0."); - } - if (minor_radius_ <= 0.0) { - fatal_error("TokamakSource: minor_radius must be > 0."); - } - if (minor_radius_ >= major_radius_) { - fatal_error("TokamakSource: minor_radius must be less than major_radius."); - } - if (elongation_ <= 0.0) { - fatal_error("TokamakSource: elongation must be > 0."); - } - if (triangularity_ < -1.0 || triangularity_ > 1.0) { - fatal_error("TokamakSource: triangularity must be in the range [-1, 1]."); - } - if (shafranov_shift_ < 0.0) { - fatal_error("TokamakSource: shafranov_shift must be >= 0."); - } - if (shafranov_shift_ >= 0.5 * minor_radius_) { - fatal_error("TokamakSource: shafranov_shift must be less than half the " - "minor radius."); - } - if (phi_extent_ <= 0.0 || phi_extent_ > 2.0 * PI) { - fatal_error("TokamakSource: phi_extent must be > 0 and <= 2*pi."); - } - if (n_alpha_ <= 2) { - fatal_error("TokamakSource: n_alpha must be > 2."); - } - if (n_alpha_ < 51) { - warning("TokamakSource: n_alpha values below 51 may introduce noticeable " - "discretization bias in source sampling."); - } - if (energy_dists_.empty()) { - fatal_error("TokamakSource: At least one energy distribution is required."); - } - if (energy_dists_.size() != 1 && energy_dists_.size() != r_over_a_.size()) { - fatal_error("TokamakSource: energy distributions must be either 1 (for all " - "r) or match the number of r_over_a points."); - } - - // Compute normalized geometry parameters - epsilon_ = minor_radius_ / major_radius_; - delta_tilde_ = shafranov_shift_ / minor_radius_; - - // Initialize isotropic angular distribution - angle_ = UPtrAngle {new Isotropic()}; - - precompute_sampling_distributions(); -} - -void TokamakSource::precompute_sampling_distributions() -{ - // Use precomputed normalized geometry parameters - double eps = epsilon_; // Inverse aspect ratio (a/R0) - double Dt = delta_tilde_; // Normalized Shafranov shift (Delta/a) - double delta = triangularity_; - - //========================================================================== - // RADIAL CDF (computed first since it's simpler and sampled first) - //========================================================================== - // The marginal radial PDF is obtained by analytically integrating the joint - // distribution f(r_tilde, alpha) over alpha. The result is: - // - // p(r_tilde) ~ S(r_tilde) * [(1 + eps*Dt)*r_tilde - // - (3/8)*c1*eps*r_tilde^2 - // - 2*eps*Dt*r_tilde^3] - // - // where the Bessel function coefficients are: - // c0 = J_0(delta) + J_2(delta) - // c1 = (J_1(2*delta) + J_3(2*delta)) / c0 - // - // For delta -> 0, c0 -> 1 and c1 -> 0, giving the circular cross-section - // limit. - - // Compute Bessel function coefficients. openmc::cyl_bessel_j handles - // negative arguments (negative triangularity) via the parity relation - // J_n(-x) = (-1)^n * J_n(x). - double J0_d = cyl_bessel_j(0, delta); - double J2_d = cyl_bessel_j(2, delta); - double J1_2d = cyl_bessel_j(1, 2.0 * delta); - double J3_2d = cyl_bessel_j(3, 2.0 * delta); - double c0 = J0_d + J2_d; - double c1 = (J1_2d + J3_2d) / c0; - - // Coefficients for the radial polynomial: A*r - B*r^2 - C*r^3 - radial_poly_a_ = 1.0 + eps * Dt; - radial_poly_b_ = 0.375 * c1 * eps; // 3/8 * c1 * eps - radial_poly_c_ = 2.0 * eps * Dt; - - // Build a refined radial grid that retains the user-specified grid points. - // The emission density is interpreted as linear-linear between those points. - constexpr int MIN_SUBINTERVALS = 8; - constexpr double MAX_GRID_SPACING = 1.0e-3; - vector radial_grid {r_over_a_.front()}; - vector radial_emission {emission_density_.front()}; - for (size_t i = 1; i < r_over_a_.size(); ++i) { - double r_lo = r_over_a_[i - 1]; - double r_hi = r_over_a_[i]; - double s_lo = emission_density_[i - 1]; - double s_hi = emission_density_[i]; - int n_subintervals = std::max(MIN_SUBINTERVALS, - static_cast(std::ceil((r_hi - r_lo) / MAX_GRID_SPACING))); - for (int j = 1; j <= n_subintervals; ++j) { - double t = static_cast(j) / n_subintervals; - radial_grid.push_back(r_lo + t * (r_hi - r_lo)); - radial_emission.push_back(s_lo + t * (s_hi - s_lo)); - } - } - - vector radial_pdf(radial_grid.size()); - for (size_t i = 0; i < radial_grid.size(); ++i) { - double r = radial_grid[i]; - // p(r) ~ S(r) * [A*r - B*r^2 - C*r^3] - double geometric_factor = - radial_poly_a_ * r - radial_poly_b_ * r * r - radial_poly_c_ * r * r * r; - radial_pdf[i] = radial_emission[i] * std::max(0.0, geometric_factor); - } - - // Check that the refined profile contains positive probability mass before - // constructing the normalized tabular distribution. - double total = 0.0; - for (size_t i = 1; i < radial_grid.size(); ++i) { - total += 0.5 * (radial_pdf[i - 1] + radial_pdf[i]) * - (radial_grid[i] - radial_grid[i - 1]); - } - if (total <= 0.0) { - fatal_error( - "TokamakSource: Integrated emission density is zero or negative. " - "Check emission_density profile."); - } - radial_dist_ = make_unique(radial_grid.data(), radial_pdf.data(), - radial_grid.size(), Interpolation::lin_lin); - - //========================================================================== - // POLOIDAL CDFs (for conditional sampling of alpha given r) - //========================================================================== - // The conditional distribution P(alpha | r) is a mixture: - // P(alpha | r) ~ sum_k w_k(r) * I_hat_k * p_k(alpha) - // where: - // - w_k(r) are the "dynamic" Bernstein weight functions (depend on r) - // - I_hat_k are the "static" normalized integrals (precomputed constants) - // - p_k(alpha) are the normalized basis distributions (precomputed CDFs) - // - // The static weights I_hat_k = I_k / (2*pi*c0) are: - // I_hat_0 = 1 + eps*Dt - // I_hat_1 = 1 + eps*Dt - (3/16)*c1*eps - // I_hat_2 = 1 - (3/8)*c1*eps - // I_hat_3 = 1 + eps*Dt - // I_hat_4 = 1 + (1/2)*eps*Dt - (3/16)*c1*eps - // I_hat_5 = 1 - eps*Dt - (3/8)*c1*eps - - // Compute static weights analytically - poloidal_integrals_[0] = 1.0 + eps * Dt; - poloidal_integrals_[1] = 1.0 + eps * Dt - 0.1875 * c1 * eps; // 3/16 = 0.1875 - poloidal_integrals_[2] = 1.0 - 0.375 * c1 * eps; // 3/8 = 0.375 - poloidal_integrals_[3] = 1.0 + eps * Dt; - poloidal_integrals_[4] = 1.0 + 0.5 * eps * Dt - 0.1875 * c1 * eps; - poloidal_integrals_[5] = 1.0 - eps * Dt - 0.375 * c1 * eps; - - // Build the alpha grid on [0, pi] (half domain due to up-down symmetry) - int n_alpha = n_alpha_; - vector alpha_grid(n_alpha); - double dalpha = PI / (n_alpha - 1); - for (int i = 0; i < n_alpha; ++i) { - alpha_grid[i] = i * dalpha; - } - - // Compute basis function values g_k(alpha) for tabular distributions - // Using Bernstein form: - // R_tilde = b0*(1-r)^2 + 2*b1*r*(1-r) + b2*r^2 - // J_tilde = b3*(1-r) + b4*r - // with: - // b0(alpha) = 1 + eps*Dt - // b1(alpha) = b0 + (eps/2)*cos(psi), psi = alpha + delta*sin(alpha) - // b2(alpha) = 1 + eps*cos(psi) - // b3(alpha) = cos(delta*sin(alpha)) - // + (delta/4)*(cos(alpha - delta*sin(alpha)) - // - cos(3*alpha + delta*sin(alpha))) - // b4(alpha) = b3(alpha) - 2*Dt*cos(alpha) - - array, N_POLOIDAL_BASIS> basis; - for (int k = 0; k < N_POLOIDAL_BASIS; ++k) { - basis[k].resize(n_alpha); - } - - for (int i = 0; i < n_alpha; ++i) { - double alpha = alpha_grid[i]; - double sin_alpha = std::sin(alpha); - double cos_alpha = std::cos(alpha); - double delta_sin_alpha = delta * sin_alpha; - double psi = alpha + delta_sin_alpha; - double cos_psi = std::cos(psi); - - // Bernstein coefficients b0-b4 - double b0 = 1.0 + eps * Dt; - double b1 = b0 + 0.5 * eps * cos_psi; - double b2 = 1.0 + eps * cos_psi; - double b3 = - std::cos(delta_sin_alpha) + 0.25 * delta * - (std::cos(alpha - delta_sin_alpha) - - std::cos(3.0 * alpha + delta_sin_alpha)); - double b4 = b3 - 2.0 * Dt * cos_alpha; - - // 6 basis functions g_k(alpha) = b_i * b_j - basis[0][i] = b0 * b3; // w0 = (1-r)^3 - basis[1][i] = b1 * b3; // w1 = 2*r*(1-r)^2 - basis[2][i] = b2 * b3; // w2 = r^2*(1-r) - basis[3][i] = b0 * b4; // w3 = r*(1-r)^2 - basis[4][i] = b1 * b4; // w4 = 2*r^2*(1-r) - basis[5][i] = b2 * b4; // w5 = r^3 - } - - // Build a linear-linear distribution for each basis function p_k(alpha) - for (int k = 0; k < N_POLOIDAL_BASIS; ++k) { - poloidal_dists_[k] = make_unique( - alpha_grid.data(), basis[k].data(), n_alpha, Interpolation::lin_lin); - } -} - -double TokamakSource::sample_r_over_a(uint64_t* seed) const -{ - return radial_dist_->sample(seed).first; -} - -double TokamakSource::mixture_weight(int k, double r) const -{ - double s = 1.0 - r; - switch (k) { - case 0: - return s * s * s * poloidal_integrals_[0]; - case 1: - return 2.0 * r * s * s * poloidal_integrals_[1]; - case 2: - return r * r * s * poloidal_integrals_[2]; - case 3: - return r * s * s * poloidal_integrals_[3]; - case 4: - return 2.0 * r * r * s * poloidal_integrals_[4]; - case 5: - return r * r * r * poloidal_integrals_[5]; - default: - UNREACHABLE(); - } -} - -double TokamakSource::sample_poloidal_angle(double r_norm, uint64_t* seed) const -{ - // Sample from the conditional distribution P(alpha | r_tilde) using - // mixture sampling with 6 precomputed basis distributions. - // - // The conditional is: P(alpha | r) ~ sum_k w_k(r) * I_hat_k * p_k(alpha) - // where: - // - w_k(r) are the "dynamic" Bernstein weight functions - // - I_hat_k are the "static" normalized integrals (precomputed in - // poloidal_integrals_) - // - p_k(alpha) are the normalized, precomputed basis distributions - // - // The normalization sum_k w_k(r) * I_hat_k equals the radial geometric - // polynomial evaluated at r, which is known analytically. - // - // Algorithm: - // 1. Compute total from analytical normalization - // 2. Lazily evaluate mixture weights with early exit to select component k - // 3. Sample alpha from the selected basis distribution - - // Analytical normalization: sum_k w_k(r) * I_hat_k - double total = - radial_poly_a_ - radial_poly_b_ * r_norm - radial_poly_c_ * r_norm * r_norm; - double xi = prn(seed) * total; - - // Sample component via lazy evaluation with early exit - // Order optimized for peaked emission profiles: 0, 1, 4, 5, 3, 2 - constexpr int order[] = {0, 1, 4, 5, 3, 2}; - double cumsum = 0.0; - int component = order[N_POLOIDAL_BASIS - 1]; - for (int i = 0; i < N_POLOIDAL_BASIS; ++i) { - cumsum += mixture_weight(order[i], r_norm); - if (xi < cumsum) { - component = order[i]; + // Apply other rejections + if (satisfies_energy_constraints(site.E) && + satisfies_time_constraints(site.time)) { break; } } - // Sample alpha from [0, pi] - double alpha = poloidal_dists_[component]->sample(seed).first; - - // Exploit up-down symmetry: randomly flip to [pi, 2*pi] with 50% probability - // This is equivalent to flipping the sign of Z in the final position - if (prn(seed) >= 0.5) { - alpha = 2.0 * PI - alpha; - } - return alpha; -} - -std::pair TokamakSource::sample_energy( - double r_norm, uint64_t* seed) const -{ - if (energy_dists_.size() == 1) { - // Single distribution for all r - return energy_dists_[0]->sample(seed); - } - - // Multiple distributions: stochastic selection between bracketing r points - // Find the interval containing r_norm - size_t i = lower_bound_index(r_over_a_.begin(), r_over_a_.end(), r_norm); - - // Handle boundary cases - if (i >= energy_dists_.size() - 1) { - return energy_dists_.back()->sample(seed); - } - - // Stochastic interpolation: randomly select one of the two bracketing - // distributions based on distance to each - double t = (r_norm - r_over_a_[i]) / (r_over_a_[i + 1] - r_over_a_[i]); - size_t idx = (prn(seed) < t) ? i + 1 : i; - return energy_dists_[idx]->sample(seed); -} - -Position TokamakSource::flux_to_cartesian( - double r, double alpha, double phi) const -{ - // Flux surface parameterization: - // R = R0 + r*cos(alpha + delta*sin(alpha)) + Delta*(1 - (r/a)^2) - // Z = kappa * r * sin(alpha) - // x = R * cos(phi) - // y = R * sin(phi) - // z = Z - - double psi = alpha + triangularity_ * std::sin(alpha); - double r_over_a_sq = (r * r) / (minor_radius_ * minor_radius_); - - double R = - major_radius_ + r * std::cos(psi) + shafranov_shift_ * (1.0 - r_over_a_sq); - double Z = elongation_ * r * std::sin(alpha); - - double x = R * std::cos(phi); - double y = R * std::sin(phi); - double z = Z; - - return {x, y, z}; -} - -SourceSite TokamakSource::sample(uint64_t* seed) const -{ - SourceSite site; - site.particle = ParticleType::neutron(); - site.wgt = 1.0; - site.delayed_group = 0; - - // 1. Sample r/a from radial CDF - double r_norm = sample_r_over_a(seed); - double r = r_norm * minor_radius_; - - // 2. Sample poloidal angle from conditional distribution P(alpha|r) - double alpha = sample_poloidal_angle(r_norm, seed); - - // 3. Sample toroidal angle uniformly in [phi_start, phi_start + phi_extent] - double phi = phi_start_ + phi_extent_ * prn(seed); - - // 4. Convert to Cartesian coordinates - site.r = flux_to_cartesian(r, alpha, phi); - - // 4a. Apply vertical shift if non-zero - if (vertical_shift_ != 0.0) { - site.r.z += vertical_shift_; - } - - // 5. Sample isotropic direction - site.u = angle_->sample(seed).first; - - // 6. Sample energy from distribution(s), applying the importance weight so - // that biased distributions are handled correctly - auto [E, E_wgt] = sample_energy(r_norm, seed); - site.E = E; - - // 7. Sample particle creation time - auto [time, time_wgt] = time_->sample(seed); - site.time = time; - - site.wgt *= E_wgt * time_wgt; - return site; } @@ -1177,29 +608,26 @@ void initialize_source() SourceSite sample_external_source(uint64_t* seed) { + // Determine total source strength + double total_strength = 0.0; + for (auto& s : model::external_sources) + total_strength += s->strength(); + // Sample from among multiple source distributions int i = 0; - int n_sources = model::external_sources.size(); - if (n_sources > 1) { - if (settings::uniform_source_sampling) { - i = prn(seed) * n_sources; - } else { - i = model::external_sources_probability.sample(seed); + if (model::external_sources.size() > 1) { + double xi = prn(seed) * total_strength; + double c = 0.0; + for (; i < model::external_sources.size(); ++i) { + c += model::external_sources[i]->strength(); + if (xi < c) + break; } } // Sample source site from i-th source distribution SourceSite site {model::external_sources[i]->sample_with_constraints(seed)}; - // For uniform source sampling, multiply the weight by the ratio of the actual - // probability of sampling source i to the biased probability of sampling - // source i, which is (strength_i / total_strength) / (1 / n) - if (n_sources > 1 && settings::uniform_source_sampling) { - double total_strength = model::external_sources_probability.integral(); - site.wgt *= - model::external_sources[i]->strength() * n_sources / total_strength; - } - // If running in MG, convert site.E to group if (!settings::run_CE) { site.E = lower_bound_index(data::mg.rev_energy_bins_.begin(), @@ -1213,14 +641,6 @@ SourceSite sample_external_source(uint64_t* seed) void free_memory_source() { model::external_sources.clear(); - model::adjoint_sources.clear(); - reset_source_rejection_counters(); -} - -void reset_source_rejection_counters() -{ - source_n_accept = 0; - source_n_reject = 0; } //============================================================================== @@ -1241,15 +661,8 @@ extern "C" int openmc_sample_external_source( } auto sites_array = static_cast(sites); - - // Derive independent per-particle seeds from the base seed so that - // each iteration has its own RNG state for thread-safe parallel sampling. - uint64_t base_seed = *seed; - -#pragma omp parallel for schedule(static) for (size_t i = 0; i < n; ++i) { - uint64_t particle_seed = init_seed(base_seed + i, STREAM_SOURCE); - sites_array[i] = sample_external_source(&particle_seed); + sites_array[i] = sample_external_source(seed); } return 0; } diff --git a/src/state_point.cpp b/src/state_point.cpp index 02c68bf60..c7b7d6ad8 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -4,25 +4,22 @@ #include // for int64_t #include -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" // for empty_like +#include "xtensor/xview.hpp" #include #include "openmc/bank.h" -#include "openmc/bank_io.h" #include "openmc/capi.h" #include "openmc/constants.h" #include "openmc/eigenvalue.h" #include "openmc/error.h" #include "openmc/file_utils.h" #include "openmc/hdf5_interface.h" -#include "openmc/mcpl_interface.h" #include "openmc/mesh.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" #include "openmc/output.h" -#include "openmc/particle_type.h" -#include "openmc/random_ray/flat_source_domain.h" #include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/tallies/derivative.h" @@ -47,20 +44,16 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) // Determine width for zero padding int w = std::to_string(settings::n_max_batches).size(); - // Tag statepoints written during the forward solve of an adjoint run - const char* forward = - (FlatSourceDomain::solve_ == RandomRaySolve::FORWARD_FOR_ADJOINT) - ? "forward." - : ""; - // Set filename for state point - filename_ = fmt::format("{0}statepoint.{3}{1:0{2}}.h5", - settings::path_output, simulation::current_batch, w, forward); + filename_ = fmt::format("{0}statepoint.{1:0{2}}.h5", settings::path_output, + simulation::current_batch, w); } // If a file name was specified, ensure it has .h5 file extension const auto extension = get_file_extension(filename_); - if (extension != "h5") { + if (extension == "") { + filename_.append(".h5"); + } else if (extension != "h5") { warning("openmc_statepoint_write was passed a file extension differing " "from .h5, but an hdf5 file will be written."); } @@ -97,9 +90,6 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) // Write out random number seed write_dataset(file_id, "seed", openmc_get_seed()); - // Write out random number stride - write_dataset(file_id, "stride", openmc_get_stride()); - // Write run information write_dataset(file_id, "energy_mode", settings::run_CE ? "continuous-energy" : "multi-group"); @@ -209,12 +199,6 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) write_attribute(tally_group, "multiply_density", 0); } - if (tally->higher_moments()) { - write_attribute(tally_group, "higher_moments", 1); - } else { - write_attribute(tally_group, "higher_moments", 0); - } - if (tally->estimator_ == TallyEstimator::ANALOG) { write_dataset(tally_group, "estimator", "analog"); } else if (tally->estimator_ == TallyEstimator::TRACKLENGTH) { @@ -278,13 +262,12 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) for (const auto& tally : model::tallies) { if (!tally->writable_) continue; - - // Write results for each bin + // Write sum and sum_sq for each bin std::string name = "tally " + std::to_string(tally->id_); hid_t tally_group = open_group(tallies_group, name.c_str()); auto& results = tally->results_; - write_tally_results(tally_group, results.shape(0), results.shape(1), - results.shape(2), results.data()); + write_tally_results(tally_group, results.shape()[0], + results.shape()[1], results.data()); close_group(tally_group); } } else { @@ -355,7 +338,7 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) file_close(file_id); } -#if defined(OPENMC_LIBMESH_ENABLED) || defined(OPENMC_DAGMC_ENABLED) +#if defined(LIBMESH) || defined(DAGMC) // write unstructured mesh tally files write_unstructured_mesh_results(); #endif @@ -417,11 +400,6 @@ extern "C" int openmc_statepoint_load(const char* filename) read_dataset(file_id, "seed", seed); openmc_set_seed(seed); - // Read and overwrite random number stride - uint64_t stride; - read_dataset(file_id, "stride", stride); - openmc_set_stride(stride); - // It is not impossible for a state point to be generated from a CE run but // to be loaded in to an MG run (or vice versa), check to prevent that. read_dataset(file_id, "energy_mode", word); @@ -451,8 +429,7 @@ extern "C" int openmc_statepoint_load(const char* filename) // Read batch number to restart at read_dataset(file_id, "current_batch", simulation::restart_batch); - if (settings::restart_run && - simulation::restart_batch >= settings::n_max_batches) { + if (simulation::restart_batch >= settings::n_max_batches) { warning(fmt::format( "The number of batches specified for simulation ({}) is smaller " "than or equal to the number of batches in the restart statepoint file " @@ -523,9 +500,8 @@ extern "C" int openmc_statepoint_load(const char* filename) tally->writable_ = false; } else { auto& results = tally->results_; - read_tally_results(tally_group, results.shape(0), results.shape(1), - results.shape(2), results.data()); - + read_tally_results(tally_group, results.shape()[0], + results.shape()[1], results.data()); read_dataset(tally_group, "n_realizations", tally->n_realizations_); close_group(tally_group); } @@ -561,7 +537,7 @@ extern "C" int openmc_statepoint_load(const char* filename) return 0; } -hid_t h5banktype(bool memory) +hid_t h5banktype() { // Create compound type for position hid_t postype = H5Tcreate(H5T_COMPOUND, sizeof(struct Position)); @@ -576,10 +552,7 @@ hid_t h5banktype(bool memory) // - openmc/statepoint.py // - docs/source/io_formats/statepoint.rst // - docs/source/io_formats/source.rst - auto n = sizeof(SourceSite); - if (!memory) - n = 2 * sizeof(struct Position) + 3 * sizeof(double) + 3 * sizeof(int); - hid_t banktype = H5Tcreate(H5T_COMPOUND, n); + hid_t banktype = H5Tcreate(H5T_COMPOUND, sizeof(struct SourceSite)); H5Tinsert(banktype, "r", HOFFSET(SourceSite, r), postype); H5Tinsert(banktype, "u", HOFFSET(SourceSite, u), postype); H5Tinsert(banktype, "E", HOFFSET(SourceSite, E), H5T_NATIVE_DOUBLE); @@ -595,32 +568,7 @@ hid_t h5banktype(bool memory) return banktype; } -void write_source_point(std::string filename, span source_bank, - const vector& bank_index, bool use_mcpl) -{ - std::string ext = use_mcpl ? "mcpl" : "h5"; - - int total_surf_particles = source_bank.size(); -#ifdef OPENMC_MPI - int num_particles = source_bank.size(); - MPI_Allreduce( - &num_particles, &total_surf_particles, 1, MPI_INT, MPI_SUM, mpi::intracomm); -#endif - - write_message("Creating source file {}.{} with {} particles ...", filename, - ext, total_surf_particles, 5); - - // Dispatch to appropriate function based on file type - if (use_mcpl) { - filename.append(".mcpl"); - write_mcpl_source_point(filename.c_str(), source_bank, bank_index); - } else { - filename.append(".h5"); - write_h5_source_point(filename.c_str(), source_bank, bank_index); - } -} - -void write_h5_source_point(const char* filename, span source_bank, +void write_source_point(const char* filename, gsl::span source_bank, const vector& bank_index) { // When using parallel HDF5, the file is written to collectively by all @@ -638,7 +586,9 @@ void write_h5_source_point(const char* filename, span source_bank, std::string filename_(filename); const auto extension = get_file_extension(filename_); - if (extension != "h5") { + if (extension == "") { + filename_.append(".h5"); + } else if (extension != "h5") { warning("write_source_point was passed a file extension differing " "from .h5, but an hdf5 file will be written."); } @@ -647,7 +597,6 @@ void write_h5_source_point(const char* filename, span source_bank, if (mpi::master || parallel) { file_id = file_open(filename_.c_str(), 'w', true); write_attribute(file_id, "filetype", "source"); - write_attribute(file_id, "version", VERSION_STATEPOINT); } // Get pointer to source bank and write to file @@ -657,22 +606,99 @@ void write_h5_source_point(const char* filename, span source_bank, file_close(file_id); } -void write_source_bank(hid_t group_id, span source_bank, +void write_source_bank(hid_t group_id, gsl::span source_bank, const vector& bank_index) { - hid_t membanktype = h5banktype(true); - hid_t filebanktype = h5banktype(false); + hid_t banktype = h5banktype(); + + // Set total and individual process dataspace sizes for source bank + int64_t dims_size = bank_index.back(); + int64_t count_size = bank_index[mpi::rank + 1] - bank_index[mpi::rank]; + +#ifdef PHDF5 + // Set size of total dataspace for all procs and rank + hsize_t dims[] {static_cast(dims_size)}; + hid_t dspace = H5Screate_simple(1, dims, nullptr); + hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + + // Create another data space but for each proc individually + hsize_t count[] {static_cast(count_size)}; + hid_t memspace = H5Screate_simple(1, count, nullptr); + + // Select hyperslab for this dataspace + hsize_t start[] {static_cast(bank_index[mpi::rank])}; + H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); + + // Set up the property list for parallel writing + hid_t plist = H5Pcreate(H5P_DATASET_XFER); + H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); + + // Write data to file in parallel + H5Dwrite(dset, banktype, memspace, dspace, plist, source_bank.data()); + + // Free resources + H5Sclose(dspace); + H5Sclose(memspace); + H5Dclose(dset); + H5Pclose(plist); -#ifdef OPENMC_MPI - write_bank_dataset("source_bank", group_id, source_bank, bank_index, - membanktype, filebanktype, mpi::source_site); #else - write_bank_dataset("source_bank", group_id, source_bank, bank_index, - membanktype, filebanktype); + + if (mpi::master) { + // Create dataset big enough to hold all source sites + hsize_t dims[] {static_cast(dims_size)}; + hid_t dspace = H5Screate_simple(1, dims, nullptr); + hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + // Save source bank sites since the array is overwritten below +#ifdef OPENMC_MPI + vector temp_source {source_bank.begin(), source_bank.end()}; #endif - H5Tclose(membanktype); - H5Tclose(filebanktype); + for (int i = 0; i < mpi::n_procs; ++i) { + // Create memory space + hsize_t count[] {static_cast(bank_index[i + 1] - bank_index[i])}; + hid_t memspace = H5Screate_simple(1, count, nullptr); + +#ifdef OPENMC_MPI + // Receive source sites from other processes + if (i > 0) + MPI_Recv(source_bank.data(), count[0], mpi::source_site, i, i, + mpi::intracomm, MPI_STATUS_IGNORE); +#endif + + // Select hyperslab for this dataspace + dspace = H5Dget_space(dset); + hsize_t start[] {static_cast(bank_index[i])}; + H5Sselect_hyperslab( + dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); + + // Write data to hyperslab + H5Dwrite( + dset, banktype, memspace, dspace, H5P_DEFAULT, source_bank.data()); + + H5Sclose(memspace); + H5Sclose(dspace); + } + + // Close all ids + H5Dclose(dset); + +#ifdef OPENMC_MPI + // Restore state of source bank + std::copy(temp_source.begin(), temp_source.end(), source_bank.begin()); +#endif + } else { +#ifdef OPENMC_MPI + MPI_Send(source_bank.data(), count_size, mpi::source_site, 0, mpi::rank, + mpi::intracomm); +#endif + } +#endif + + H5Tclose(banktype); } // Determine member names of a compound HDF5 datatype @@ -693,17 +719,7 @@ std::string dtype_member_names(hid_t dtype_id) void read_source_bank( hid_t group_id, vector& sites, bool distribute) { - bool legacy_particle_codes = true; - if (attribute_exists(group_id, "version")) { - array version; - read_attribute(group_id, "version", version); - if (version[0] > VERSION_STATEPOINT[0] || - (version[0] == VERSION_STATEPOINT[0] && version[1] >= 2)) { - legacy_particle_codes = false; - } - } - - hid_t banktype = h5banktype(true); + hid_t banktype = h5banktype(); // Open the dataset hid_t dset = H5Dopen(group_id, "source_bank", H5P_DEFAULT); @@ -764,12 +780,6 @@ void read_source_bank( H5Sclose(memspace); H5Dclose(dset); H5Tclose(banktype); - - if (legacy_particle_codes) { - for (auto& site : sites) { - site.particle = legacy_particle_index_to_type(site.particle.pdg_number()); - } - } } void write_unstructured_mesh_results() @@ -841,7 +851,7 @@ void write_unstructured_mesh_results() // construct result vectors vector mean_vec(umesh->n_bins()), std_dev_vec(umesh->n_bins()); - for (int j = 0; j < tally->results_.shape(0); j++) { + for (int j = 0; j < tally->results_.shape()[0]; j++) { // get the volume for this bin double volume = umesh->volume(j); // compute the mean @@ -903,7 +913,7 @@ void write_tally_results_nr(hid_t file_id) #ifdef OPENMC_MPI // Reduce global tallies - tensor::Tensor gt_reduced({N_GLOBAL_TALLIES, 3}); + xt::xtensor gt_reduced = xt::empty_like(gt); MPI_Reduce(gt.data(), gt_reduced.data(), gt.size(), MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm); @@ -932,18 +942,13 @@ void write_tally_results_nr(hid_t file_id) write_attribute(file_id, "tallies_present", 1); } - // Copy the SUM and SUM_SQ columns from the tally results into a - // contiguous array for MPI reduction - const int r_start = static_cast(TallyResult::SUM); - const int r_end = static_cast(TallyResult::SUM_SQ) + 1; - const size_t r_count = r_end - r_start; - const size_t ni = t->results_.shape(0); - const size_t nj = t->results_.shape(1); - tensor::Tensor values({ni, nj, r_count}); - for (size_t i = 0; i < ni; i++) - for (size_t j = 0; j < nj; j++) - for (size_t r = 0; r < r_count; r++) - values(i, j, r) = t->results_(i, j, r_start + r); + // Get view of accumulated tally values + auto values_view = xt::view(t->results_, xt::all(), xt::all(), + xt::range(static_cast(TallyResult::SUM), + static_cast(TallyResult::SUM_SQ) + 1)); + + // Make copy of tally values in contiguous array + xt::xtensor values = values_view; if (mpi::master) { // Open group for tally @@ -957,27 +962,23 @@ void write_tally_results_nr(hid_t file_id) MPI_SUM, 0, mpi::intracomm); #endif - // At the end of the simulation, store the reduced results back - // into the tally results array + // At the end of the simulation, store the results back in the + // regular TallyResults array if (simulation::current_batch == settings::n_max_batches || simulation::satisfy_triggers) { - for (size_t i = 0; i < ni; i++) - for (size_t j = 0; j < nj; j++) - for (size_t r = 0; r < r_count; r++) - t->results_(i, j, r_start + r) = values(i, j, r); + values_view = values; } - // Put reduced values into a full-sized copy for writing to HDF5 - tensor::Tensor results_copy = tensor::zeros_like(t->results_); - for (size_t i = 0; i < ni; i++) - for (size_t j = 0; j < nj; j++) - for (size_t r = 0; r < r_count; r++) - results_copy(i, j, r_start + r) = values(i, j, r); + // Put in temporary tally result + xt::xtensor results_copy = xt::zeros_like(t->results_); + auto copy_view = xt::view(results_copy, xt::all(), xt::all(), + xt::range(static_cast(TallyResult::SUM), + static_cast(TallyResult::SUM_SQ) + 1)); + copy_view = values; // Write reduced tally results to file auto shape = results_copy.shape(); - write_tally_results( - tally_group, shape[0], shape[1], shape[2], results_copy.data()); + write_tally_results(tally_group, shape[0], shape[1], results_copy.data()); close_group(tally_group); } else { diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 74f048e8d..3b1c1b4a6 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -2,6 +2,7 @@ #include // for equal #include // for tolower, isspace +#include namespace openmc { @@ -35,7 +36,7 @@ void to_lower(std::string& str) str[i] = std::tolower(str[i]); } -int word_count(const std::string& str) +int word_count(std::string const& str) { std::stringstream stream(str); std::string dum; diff --git a/src/surface.cpp b/src/surface.cpp index 81b756dea..50ef2a128 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -7,9 +7,9 @@ #include #include +#include #include "openmc/array.h" -#include "openmc/cell.h" #include "openmc/container_util.h" #include "openmc/error.h" #include "openmc/external/quartic_solver.h" @@ -141,7 +141,7 @@ Direction Surface::reflect(Position r, Direction u, GeometryState* p) const } Direction Surface::diffuse_reflect( - Position r, Direction u, uint64_t* seed) const + Position r, Direction u, uint64_t* seed, GeometryState* p) const { // Diffuse reflect direction according to the normal. // cosine distribution @@ -165,27 +165,14 @@ void Surface::to_hdf5(hid_t group_id) const { hid_t surf_group = create_group(group_id, fmt::format("surface {}", id_)); - if (geom_type() == GeometryType::DAG) { + if (geom_type_ == GeometryType::DAG) { write_string(surf_group, "geom_type", "dagmc", false); - } else if (geom_type() == GeometryType::CSG) { + } else if (geom_type_ == GeometryType::CSG) { write_string(surf_group, "geom_type", "csg", false); if (bc_) { write_string(surf_group, "boundary_type", bc_->type(), false); bc_->to_hdf5(surf_group); - - // write periodic surface ID - if (bc_->type() == "periodic") { - auto pbc = dynamic_cast(bc_.get()); - Surface& surf1 {*model::surfaces[pbc->i_surf()]}; - Surface& surf2 {*model::surfaces[pbc->j_surf()]}; - - if (id_ == surf1.id_) { - write_dataset(surf_group, "periodic_surface_id", surf2.id_); - } else { - write_dataset(surf_group, "periodic_surface_id", surf1.id_); - } - } } else { write_string(surf_group, "boundary_type", "transmission", false); } @@ -200,6 +187,15 @@ void Surface::to_hdf5(hid_t group_id) const close_group(surf_group); } +CSGSurface::CSGSurface() : Surface {} +{ + geom_type_ = GeometryType::CSG; +}; +CSGSurface::CSGSurface(pugi::xml_node surf_node) : Surface {surf_node} +{ + geom_type_ = GeometryType::CSG; +}; + //============================================================================== // Generic functions for x-, y-, and z-, planes. //============================================================================== @@ -222,7 +218,7 @@ double axis_aligned_plane_distance( // SurfaceXPlane implementation //============================================================================== -SurfaceXPlane::SurfaceXPlane(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceXPlane::SurfaceXPlane(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_}); } @@ -252,9 +248,9 @@ void SurfaceXPlane::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceXPlane::bounding_box(bool pos_side) const { if (pos_side) { - return {{x0_, -INFTY, -INFTY}, {INFTY, INFTY, INFTY}}; + return {x0_, INFTY, -INFTY, INFTY, -INFTY, INFTY}; } else { - return {{-INFTY, -INFTY, -INFTY}, {x0_, INFTY, INFTY}}; + return {-INFTY, x0_, -INFTY, INFTY, -INFTY, INFTY}; } } @@ -262,7 +258,7 @@ BoundingBox SurfaceXPlane::bounding_box(bool pos_side) const // SurfaceYPlane implementation //============================================================================== -SurfaceYPlane::SurfaceYPlane(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceYPlane::SurfaceYPlane(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&y0_}); } @@ -292,9 +288,9 @@ void SurfaceYPlane::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceYPlane::bounding_box(bool pos_side) const { if (pos_side) { - return {{-INFTY, y0_, -INFTY}, {INFTY, INFTY, INFTY}}; + return {-INFTY, INFTY, y0_, INFTY, -INFTY, INFTY}; } else { - return {{-INFTY, -INFTY, -INFTY}, {INFTY, y0_, INFTY}}; + return {-INFTY, INFTY, -INFTY, y0_, -INFTY, INFTY}; } } @@ -302,7 +298,7 @@ BoundingBox SurfaceYPlane::bounding_box(bool pos_side) const // SurfaceZPlane implementation //============================================================================== -SurfaceZPlane::SurfaceZPlane(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceZPlane::SurfaceZPlane(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&z0_}); } @@ -332,9 +328,9 @@ void SurfaceZPlane::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceZPlane::bounding_box(bool pos_side) const { if (pos_side) { - return {{-INFTY, -INFTY, z0_}, {INFTY, INFTY, INFTY}}; + return {-INFTY, INFTY, -INFTY, INFTY, z0_, INFTY}; } else { - return {{-INFTY, -INFTY, -INFTY}, {INFTY, INFTY, z0_}}; + return {-INFTY, INFTY, -INFTY, INFTY, -INFTY, z0_}; } } @@ -342,7 +338,7 @@ BoundingBox SurfaceZPlane::bounding_box(bool pos_side) const // SurfacePlane implementation //============================================================================== -SurfacePlane::SurfacePlane(pugi::xml_node surf_node) : Surface(surf_node) +SurfacePlane::SurfacePlane(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&A_, &B_, &C_, &D_}); } @@ -461,7 +457,7 @@ Direction axis_aligned_cylinder_normal( //============================================================================== SurfaceXCylinder::SurfaceXCylinder(pugi::xml_node surf_node) - : Surface(surf_node) + : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&y0_, &z0_, &radius_}); } @@ -493,8 +489,8 @@ void SurfaceXCylinder::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceXCylinder::bounding_box(bool pos_side) const { if (!pos_side) { - return {{-INFTY, y0_ - radius_, z0_ - radius_}, - {INFTY, y0_ + radius_, z0_ + radius_}}; + return {-INFTY, INFTY, y0_ - radius_, y0_ + radius_, z0_ - radius_, + z0_ + radius_}; } else { return {}; } @@ -504,7 +500,7 @@ BoundingBox SurfaceXCylinder::bounding_box(bool pos_side) const //============================================================================== SurfaceYCylinder::SurfaceYCylinder(pugi::xml_node surf_node) - : Surface(surf_node) + : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &z0_, &radius_}); } @@ -536,8 +532,8 @@ void SurfaceYCylinder::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceYCylinder::bounding_box(bool pos_side) const { if (!pos_side) { - return {{x0_ - radius_, -INFTY, z0_ - radius_}, - {x0_ + radius_, INFTY, z0_ + radius_}}; + return {x0_ - radius_, x0_ + radius_, -INFTY, INFTY, z0_ - radius_, + z0_ + radius_}; } else { return {}; } @@ -548,7 +544,7 @@ BoundingBox SurfaceYCylinder::bounding_box(bool pos_side) const //============================================================================== SurfaceZCylinder::SurfaceZCylinder(pugi::xml_node surf_node) - : Surface(surf_node) + : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &radius_}); } @@ -580,8 +576,8 @@ void SurfaceZCylinder::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceZCylinder::bounding_box(bool pos_side) const { if (!pos_side) { - return {{x0_ - radius_, y0_ - radius_, -INFTY}, - {x0_ + radius_, y0_ + radius_, INFTY}}; + return {x0_ - radius_, x0_ + radius_, y0_ - radius_, y0_ + radius_, -INFTY, + INFTY}; } else { return {}; } @@ -591,7 +587,7 @@ BoundingBox SurfaceZCylinder::bounding_box(bool pos_side) const // SurfaceSphere implementation //============================================================================== -SurfaceSphere::SurfaceSphere(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceSphere::SurfaceSphere(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &radius_}); } @@ -658,8 +654,8 @@ void SurfaceSphere::to_hdf5_inner(hid_t group_id) const BoundingBox SurfaceSphere::bounding_box(bool pos_side) const { if (!pos_side) { - return {{x0_ - radius_, y0_ - radius_, z0_ - radius_}, - {x0_ + radius_, y0_ + radius_, z0_ + radius_}}; + return {x0_ - radius_, x0_ + radius_, y0_ - radius_, y0_ + radius_, + z0_ - radius_, z0_ + radius_}; } else { return {}; } @@ -757,7 +753,7 @@ Direction axis_aligned_cone_normal( // SurfaceXCone implementation //============================================================================== -SurfaceXCone::SurfaceXCone(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceXCone::SurfaceXCone(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &radius_sq_}); } @@ -789,7 +785,7 @@ void SurfaceXCone::to_hdf5_inner(hid_t group_id) const // SurfaceYCone implementation //============================================================================== -SurfaceYCone::SurfaceYCone(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceYCone::SurfaceYCone(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &radius_sq_}); } @@ -821,7 +817,7 @@ void SurfaceYCone::to_hdf5_inner(hid_t group_id) const // SurfaceZCone implementation //============================================================================== -SurfaceZCone::SurfaceZCone(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceZCone::SurfaceZCone(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &radius_sq_}); } @@ -853,7 +849,7 @@ void SurfaceZCone::to_hdf5_inner(hid_t group_id) const // SurfaceQuadric implementation //============================================================================== -SurfaceQuadric::SurfaceQuadric(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceQuadric::SurfaceQuadric(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs( surf_node, id_, {&A_, &B_, &C_, &D_, &E_, &F_, &G_, &H_, &J_, &K_}); @@ -1013,7 +1009,7 @@ double torus_distance(double x1, double x2, double x3, double u1, double u2, // SurfaceXTorus implementation //============================================================================== -SurfaceXTorus::SurfaceXTorus(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceXTorus::SurfaceXTorus(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &A_, &B_, &C_}); } @@ -1066,7 +1062,7 @@ Direction SurfaceXTorus::normal(Position r) const // SurfaceYTorus implementation //============================================================================== -SurfaceYTorus::SurfaceYTorus(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceYTorus::SurfaceYTorus(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &A_, &B_, &C_}); } @@ -1119,7 +1115,7 @@ Direction SurfaceYTorus::normal(Position r) const // SurfaceZTorus implementation //============================================================================== -SurfaceZTorus::SurfaceZTorus(pugi::xml_node surf_node) : Surface(surf_node) +SurfaceZTorus::SurfaceZTorus(pugi::xml_node surf_node) : CSGSurface(surf_node) { read_coeffs(surf_node, id_, {&x0_, &y0_, &z0_, &A_, &B_, &C_}); } @@ -1170,10 +1166,7 @@ Direction SurfaceZTorus::normal(Position r) const //============================================================================== -void read_surfaces(pugi::xml_node node, - std::set>& periodic_pairs, - std::unordered_map& albedo_map, - std::unordered_map& periodic_sense_map) +void read_surfaces(pugi::xml_node node) { // Count the number of surfaces int n_surfaces = 0; @@ -1184,6 +1177,8 @@ void read_surfaces(pugi::xml_node node, // Loop over XML surface elements and populate the array. Keep track of // periodic surfaces and their albedos. model::surfaces.reserve(n_surfaces); + std::set> periodic_pairs; + std::unordered_map albedo_map; { pugi::xml_node surf_node; int i_surf; @@ -1246,7 +1241,6 @@ void read_surfaces(pugi::xml_node node, if (check_for_node(surf_node, "boundary")) { std::string surf_bc = get_node_value(surf_node, "boundary", true, true); if (surf_bc == "periodic") { - periodic_sense_map[model::surfaces.back()->id_] = 0; // Check for surface albedo. Skip sanity check as it is already done // in the Surface class's constructor. if (check_for_node(surf_node, "albedo")) { @@ -1278,28 +1272,6 @@ void read_surfaces(pugi::xml_node node, fmt::format("Two or more surfaces use the same unique ID: {}", id)); } } -} - -void prepare_boundary_conditions(std::set>& periodic_pairs, - std::unordered_map& albedo_map, - std::unordered_map& periodic_sense_map) -{ - // Fill the senses map for periodic surfaces - auto n_periodic = periodic_sense_map.size(); - for (const auto& cell : model::cells) { - if (n_periodic == 0) - break; // Early exit once all periodic surfaces found - - for (auto s : cell->surfaces()) { - auto surf_idx = std::abs(s) - 1; - auto id = model::surfaces[surf_idx]->id_; - - if (periodic_sense_map.count(id)) { - periodic_sense_map[id] = std::copysign(1, s); - --n_periodic; - } - } - } // Resolve unpaired periodic surfaces. A lambda function is used with // std::find_if to identify the unpaired surfaces. @@ -1357,50 +1329,10 @@ void prepare_boundary_conditions(std::set>& periodic_pairs, // condition. Otherwise, it is a rotational periodic BC. if (std::abs(1.0 - dot_prod) < FP_PRECISION) { surf1.bc_ = make_unique(i_surf, j_surf); - surf2.bc_ = make_unique(j_surf, i_surf); + surf2.bc_ = make_unique(i_surf, j_surf); } else { - // check that both normals have at least one 0 component - if (std::abs(norm1.x) > FP_PRECISION && - std::abs(norm1.y) > FP_PRECISION && - std::abs(norm1.z) > FP_PRECISION) { - fatal_error(fmt::format( - "The normal ({}) of the periodic surface ({}) does not contain any " - "component with a zero value. A RotationalPeriodicBC requires one " - "component which is zero for both plane normals.", - norm1, i_surf)); - } - if (std::abs(norm2.x) > FP_PRECISION && - std::abs(norm2.y) > FP_PRECISION && - std::abs(norm2.z) > FP_PRECISION) { - fatal_error(fmt::format( - "The normal ({}) of the periodic surface ({}) does not contain any " - "component with a zero value. A RotationalPeriodicBC requires one " - "component which is zero for both plane normals.", - norm2, j_surf)); - } - // find common zero component, which indicates the periodic axis - RotationalPeriodicBC::PeriodicAxis axis; - if (std::abs(norm1.x) <= FP_PRECISION && - std::abs(norm2.x) <= FP_PRECISION) { - axis = RotationalPeriodicBC::PeriodicAxis::x; - } else if (std::abs(norm1.y) <= FP_PRECISION && - std::abs(norm2.y) <= FP_PRECISION) { - axis = RotationalPeriodicBC::PeriodicAxis::y; - } else if (std::abs(norm1.z) <= FP_PRECISION && - std::abs(norm2.z) <= FP_PRECISION) { - axis = RotationalPeriodicBC::PeriodicAxis::z; - } else { - fatal_error(fmt::format( - "There is no component which is 0.0 in both normal vectors. This " - "indicates that the two planes are not periodic about the X, Y, or Z " - "axis, which is not supported.")); - } - auto i_sign = periodic_sense_map[periodic_pair.first]; - auto j_sign = periodic_sense_map[periodic_pair.second]; - surf1.bc_ = make_unique( - i_sign * (i_surf + 1), j_sign * (j_surf + 1), axis); - surf2.bc_ = make_unique( - j_sign * (j_surf + 1), i_sign * (i_surf + 1), axis); + surf1.bc_ = make_unique(i_surf, j_surf); + surf2.bc_ = make_unique(i_surf, j_surf); } // If albedo data is present in albedo map, set the boundary albedo. diff --git a/src/tallies/filter.cpp b/src/tallies/filter.cpp index badb91077..ff7a3416b 100644 --- a/src/tallies/filter.cpp +++ b/src/tallies/filter.cpp @@ -1,8 +1,7 @@ #include "openmc/tallies/filter.h" #include // for max -#include -#include // for strcpy +#include // for strcpy #include #include @@ -25,21 +24,15 @@ #include "openmc/tallies/filter_materialfrom.h" #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/filter_meshborn.h" -#include "openmc/tallies/filter_meshmaterial.h" #include "openmc/tallies/filter_meshsurface.h" #include "openmc/tallies/filter_mu.h" -#include "openmc/tallies/filter_musurface.h" -#include "openmc/tallies/filter_parent_nuclide.h" #include "openmc/tallies/filter_particle.h" -#include "openmc/tallies/filter_particle_production.h" #include "openmc/tallies/filter_polar.h" -#include "openmc/tallies/filter_reaction.h" #include "openmc/tallies/filter_sph_harm.h" #include "openmc/tallies/filter_sptl_legendre.h" #include "openmc/tallies/filter_surface.h" #include "openmc/tallies/filter_time.h" #include "openmc/tallies/filter_universe.h" -#include "openmc/tallies/filter_weight.h" #include "openmc/tallies/filter_zernike.h" #include "openmc/xml_interface.h" @@ -136,24 +129,14 @@ Filter* Filter::create(const std::string& type, int32_t id) return Filter::create(id); } else if (type == "meshborn") { return Filter::create(id); - } else if (type == "meshmaterial") { - return Filter::create(id); } else if (type == "meshsurface") { return Filter::create(id); } else if (type == "mu") { return Filter::create(id); - } else if (type == "musurface") { - return Filter::create(id); - } else if (type == "parentnuclide") { - return Filter::create(id); } else if (type == "particle") { return Filter::create(id); - } else if (type == "particleproduction") { - return Filter::create(id); } else if (type == "polar") { return Filter::create(id); - } else if (type == "reaction") { - return Filter::create(id); } else if (type == "surface") { return Filter::create(id); } else if (type == "spatiallegendre") { @@ -164,8 +147,6 @@ Filter* Filter::create(const std::string& type, int32_t id) return Filter::create(id); } else if (type == "universe") { return Filter::create(id); - } else if (type == "weight") { - return Filter::create(id); } else if (type == "zernike") { return Filter::create(id); } else if (type == "zernikeradial") { @@ -178,7 +159,7 @@ Filter* Filter::create(const std::string& type, int32_t id) void Filter::set_id(int32_t id) { - assert(id >= 0 || id == C_NONE); + Expects(id >= 0 || id == C_NONE); // Clear entry in filter map if an ID was already assigned before if (id_ != C_NONE) { diff --git a/src/tallies/filter_azimuthal.cpp b/src/tallies/filter_azimuthal.cpp index 6525f326d..e77aa8bdc 100644 --- a/src/tallies/filter_azimuthal.cpp +++ b/src/tallies/filter_azimuthal.cpp @@ -34,14 +34,14 @@ void AzimuthalFilter::from_xml(pugi::xml_node node) this->set_bins(bins); } -void AzimuthalFilter::set_bins(span bins) +void AzimuthalFilter::set_bins(gsl::span bins) { // Clear existing bins bins_.clear(); bins_.reserve(bins.size()); // Copy bins, ensuring they are valid - for (int64_t i = 0; i < bins.size(); ++i) { + for (gsl::index i = 0; i < bins.size(); ++i) { if (i > 0 && bins[i] <= bins[i - 1]) { throw std::runtime_error { "Azimuthal bins must be monotonically increasing."}; diff --git a/src/tallies/filter_cell.cpp b/src/tallies/filter_cell.cpp index 7a6394956..794d2ae08 100644 --- a/src/tallies/filter_cell.cpp +++ b/src/tallies/filter_cell.cpp @@ -1,7 +1,5 @@ #include "openmc/tallies/filter_cell.h" -#include - #include #include "openmc/capi.h" @@ -27,7 +25,7 @@ void CellFilter::from_xml(pugi::xml_node node) this->set_cells(cells); } -void CellFilter::set_cells(span cells) +void CellFilter::set_cells(gsl::span cells) { // Clear existing cells cells_.clear(); @@ -36,8 +34,8 @@ void CellFilter::set_cells(span cells) // Update cells and mapping for (auto& index : cells) { - assert(index >= 0); - assert(index < model::cells.size()); + Expects(index >= 0); + Expects(index < model::cells.size()); cells_.push_back(index); map_[index] = cells_.size() - 1; } @@ -49,7 +47,7 @@ void CellFilter::get_all_bins( const Particle& p, TallyEstimator estimator, FilterMatch& match) const { for (int i = 0; i < p.n_coord(); i++) { - auto search = map_.find(p.coord(i).cell()); + auto search = map_.find(p.coord(i).cell); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_cell_instance.cpp b/src/tallies/filter_cell_instance.cpp index 928bfb6c5..3e78a5bbe 100644 --- a/src/tallies/filter_cell_instance.cpp +++ b/src/tallies/filter_cell_instance.cpp @@ -1,6 +1,5 @@ #include "openmc/tallies/filter_cell_instance.h" -#include #include #include @@ -9,12 +8,11 @@ #include "openmc/cell.h" #include "openmc/error.h" #include "openmc/geometry.h" -#include "openmc/tensor.h" #include "openmc/xml_interface.h" namespace openmc { -CellInstanceFilter::CellInstanceFilter(span instances) +CellInstanceFilter::CellInstanceFilter(gsl::span instances) { this->set_cell_instances(instances); } @@ -23,26 +21,26 @@ void CellInstanceFilter::from_xml(pugi::xml_node node) { // Get cell IDs/instances auto cells = get_node_array(node, "bins"); - assert(cells.size() % 2 == 0); + Expects(cells.size() % 2 == 0); // Convert into vector of CellInstance vector instances; - for (int64_t i = 0; i < cells.size() / 2; ++i) { + for (gsl::index i = 0; i < cells.size() / 2; ++i) { int32_t cell_id = cells[2 * i]; - int64_t instance = cells[2 * i + 1]; + gsl::index instance = cells[2 * i + 1]; auto search = model::cell_map.find(cell_id); if (search == model::cell_map.end()) { throw std::runtime_error {fmt::format( "Could not find cell {} specified on tally filter.", cell_id)}; } - int64_t index = search->second; + gsl::index index = search->second; instances.push_back({index, instance}); } this->set_cell_instances(instances); } -void CellInstanceFilter::set_cell_instances(span instances) +void CellInstanceFilter::set_cell_instances(gsl::span instances) { // Clear existing cells cell_instances_.clear(); @@ -52,8 +50,8 @@ void CellInstanceFilter::set_cell_instances(span instances) // Update cells and mapping for (auto& x : instances) { - assert(x.index_cell >= 0); - assert(x.index_cell < model::cells.size()); + Expects(x.index_cell >= 0); + Expects(x.index_cell < model::cells.size()); cell_instances_.push_back(x); cells_.insert(x.index_cell); map_[x] = cell_instances_.size() - 1; @@ -74,8 +72,8 @@ void CellInstanceFilter::set_cell_instances(span instances) void CellInstanceFilter::get_all_bins( const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - int64_t index_cell = p.lowest_coord().cell(); - int64_t instance = p.cell_instance(); + gsl::index index_cell = p.lowest_coord().cell; + gsl::index instance = p.cell_instance(); if (cells_.count(index_cell) > 0) { auto search = map_.find({index_cell, instance}); @@ -90,13 +88,13 @@ void CellInstanceFilter::get_all_bins( return; for (int i = 0; i < p.n_coord() - 1; i++) { - int64_t index_cell = p.coord(i).cell(); + gsl::index index_cell = p.coord(i).cell; // if this cell isn't used on the filter, move on if (cells_.count(index_cell) == 0) continue; // if this cell is used in the filter, check the instance as well - int64_t instance = cell_instance_at_level(p, i); + gsl::index instance = cell_instance_at_level(p, i); auto search = map_.find({index_cell, instance}); if (search != map_.end()) { match.bins_.push_back(search->second); @@ -109,8 +107,8 @@ void CellInstanceFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); size_t n = cell_instances_.size(); - tensor::Tensor data({n, 2}); - for (int64_t i = 0; i < n; ++i) { + xt::xtensor data({n, 2}); + for (gsl::index i = 0; i < n; ++i) { const auto& x = cell_instances_[i]; data(i, 0) = model::cells[x.index_cell]->id_; data(i, 1) = x.instance; diff --git a/src/tallies/filter_collision.cpp b/src/tallies/filter_collision.cpp index c614c3c83..fbb186a23 100644 --- a/src/tallies/filter_collision.cpp +++ b/src/tallies/filter_collision.cpp @@ -19,7 +19,7 @@ void CollisionFilter::from_xml(pugi::xml_node node) this->set_bins(bins); } -void CollisionFilter::set_bins(span bins) +void CollisionFilter::set_bins(gsl::span bins) { // Clear existing bins bins_.clear(); @@ -27,7 +27,7 @@ void CollisionFilter::set_bins(span bins) map_.clear(); // Copy bins - for (int64_t i = 0; i < bins.size(); ++i) { + for (gsl::index i = 0; i < bins.size(); ++i) { bins_.push_back(bins[i]); map_[bins[i]] = i; } diff --git a/src/tallies/filter_delayedgroup.cpp b/src/tallies/filter_delayedgroup.cpp index 46adf529b..c6ec21766 100644 --- a/src/tallies/filter_delayedgroup.cpp +++ b/src/tallies/filter_delayedgroup.cpp @@ -11,7 +11,7 @@ void DelayedGroupFilter::from_xml(pugi::xml_node node) this->set_groups(groups); } -void DelayedGroupFilter::set_groups(span groups) +void DelayedGroupFilter::set_groups(gsl::span groups) { // Clear existing groups groups_.clear(); @@ -27,7 +27,7 @@ void DelayedGroupFilter::set_groups(span groups) } else if (group > MAX_DELAYED_GROUPS) { throw std::invalid_argument { "Encountered delayedgroup bin with index " + std::to_string(group) + - " which is greater than MAX_DELAYED_GROUPS (" + + " which is greater than MAX_DELATED_GROUPS (" + std::to_string(MAX_DELAYED_GROUPS) + ")"}; } groups_.push_back(group); @@ -39,10 +39,6 @@ void DelayedGroupFilter::set_groups(span groups) void DelayedGroupFilter::get_all_bins( const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - // Note that the bin is set to zero here, but bins outside zero are - // tallied to regardless. This is because that logic has to be handled - // in the scoring code instead where looping over the delayed - // group takes place (tally_scoring.cpp). match.bins_.push_back(0); match.weights_.push_back(1.0); } diff --git a/src/tallies/filter_distribcell.cpp b/src/tallies/filter_distribcell.cpp index f511a6816..c754dbd44 100644 --- a/src/tallies/filter_distribcell.cpp +++ b/src/tallies/filter_distribcell.cpp @@ -1,7 +1,5 @@ #include "openmc/tallies/filter_distribcell.h" -#include - #include #include "openmc/cell.h" @@ -31,10 +29,10 @@ void DistribcellFilter::from_xml(pugi::xml_node node) void DistribcellFilter::set_cell(int32_t cell) { - assert(cell >= 0); - assert(cell < model::cells.size()); + Expects(cell >= 0); + Expects(cell < model::cells.size()); cell_ = cell; - n_bins_ = model::cells[cell]->n_instances(); + n_bins_ = model::cells[cell]->n_instances_; } void DistribcellFilter::get_all_bins( @@ -43,18 +41,18 @@ void DistribcellFilter::get_all_bins( int offset = 0; auto distribcell_index = model::cells[cell_]->distribcell_index_; for (int i = 0; i < p.n_coord(); i++) { - auto& c {*model::cells[p.coord(i).cell()]}; + auto& c {*model::cells[p.coord(i).cell]}; if (c.type_ == Fill::UNIVERSE) { offset += c.offset_[distribcell_index]; } else if (c.type_ == Fill::LATTICE) { - auto& lat {*model::lattices[p.coord(i + 1).lattice()]}; - const auto& i_xyz {p.coord(i + 1).lattice_index()}; + auto& lat {*model::lattices[p.coord(i + 1).lattice]}; + const auto& i_xyz {p.coord(i + 1).lattice_i}; if (lat.are_valid_indices(i_xyz)) { offset += lat.offset(distribcell_index, i_xyz) + c.offset_[distribcell_index]; } } - if (cell_ == p.coord(i).cell()) { + if (cell_ == p.coord(i).cell) { match.bins_.push_back(offset); match.weights_.push_back(1.0); return; diff --git a/src/tallies/filter_energy.cpp b/src/tallies/filter_energy.cpp index 566b5710a..4767dd175 100644 --- a/src/tallies/filter_energy.cpp +++ b/src/tallies/filter_energy.cpp @@ -21,14 +21,14 @@ void EnergyFilter::from_xml(pugi::xml_node node) this->set_bins(bins); } -void EnergyFilter::set_bins(span bins) +void EnergyFilter::set_bins(gsl::span bins) { // Clear existing bins bins_.clear(); bins_.reserve(bins.size()); // Copy bins, ensuring they are valid - for (int64_t i = 0; i < bins.size(); ++i) { + for (gsl::index i = 0; i < bins.size(); ++i) { if (i > 0 && bins[i] <= bins[i - 1]) { throw std::runtime_error { "Energy bins must be monotonically increasing."}; @@ -46,7 +46,7 @@ void EnergyFilter::set_bins(span bins) if (!settings::run_CE) { if (n_bins_ == data::mg.num_energy_groups_) { matches_transport_groups_ = true; - for (int64_t i = 0; i < n_bins_ + 1; ++i) { + for (gsl::index i = 0; i < n_bins_ + 1; ++i) { if (data::mg.rev_energy_bins_[i] != bins_[i]) { matches_transport_groups_ = false; break; @@ -60,8 +60,13 @@ void EnergyFilter::get_all_bins( const Particle& p, TallyEstimator estimator, FilterMatch& match) const { if (p.g() != C_NONE && matches_transport_groups_) { - match.bins_.push_back(data::mg.num_energy_groups_ - p.g_last() - 1); + if (estimator == TallyEstimator::TRACKLENGTH) { + match.bins_.push_back(data::mg.num_energy_groups_ - p.g() - 1); + } else { + match.bins_.push_back(data::mg.num_energy_groups_ - p.g_last() - 1); + } match.weights_.push_back(1.0); + } else { // Get the pre-collision energy of the particle. auto E = p.E_last(); diff --git a/src/tallies/filter_energyfunc.cpp b/src/tallies/filter_energyfunc.cpp index fc4ba0ff9..93ae24b2a 100644 --- a/src/tallies/filter_energyfunc.cpp +++ b/src/tallies/filter_energyfunc.cpp @@ -36,7 +36,7 @@ void EnergyFunctionFilter::from_xml(pugi::xml_node node) } void EnergyFunctionFilter::set_data( - span energy, span y) + gsl::span energy, gsl::span y) { // Check for consistent sizes with new data if (energy.size() != y.size()) { @@ -48,7 +48,7 @@ void EnergyFunctionFilter::set_data( y_.reserve(y.size()); // Copy over energy values, ensuring they are valid - for (int64_t i = 0; i < energy.size(); ++i) { + for (gsl::index i = 0; i < energy.size(); ++i) { if (i > 0 && energy[i] <= energy[i - 1]) { throw std::runtime_error { "Energy bins must be monotonically increasing."}; diff --git a/src/tallies/filter_material.cpp b/src/tallies/filter_material.cpp index 215c9af72..6669ab2fa 100644 --- a/src/tallies/filter_material.cpp +++ b/src/tallies/filter_material.cpp @@ -1,7 +1,5 @@ #include "openmc/tallies/filter_material.h" -#include - #include #include "openmc/capi.h" @@ -26,7 +24,7 @@ void MaterialFilter::from_xml(pugi::xml_node node) this->set_materials(mats); } -void MaterialFilter::set_materials(span materials) +void MaterialFilter::set_materials(gsl::span materials) { // Clear existing materials materials_.clear(); @@ -35,8 +33,8 @@ void MaterialFilter::set_materials(span materials) // Update materials and mapping for (auto& index : materials) { - assert(index >= 0); - assert(index < model::materials.size()); + Expects(index >= 0); + Expects(index < model::materials.size()); materials_.push_back(index); map_[index] = materials_.size() - 1; } diff --git a/src/tallies/filter_mesh.cpp b/src/tallies/filter_mesh.cpp index a0698992d..5b01da1f6 100644 --- a/src/tallies/filter_mesh.cpp +++ b/src/tallies/filter_mesh.cpp @@ -1,12 +1,12 @@ #include "openmc/tallies/filter_mesh.h" #include +#include #include "openmc/capi.h" #include "openmc/constants.h" #include "openmc/error.h" #include "openmc/mesh.h" -#include "openmc/position.h" #include "openmc/xml_interface.h" namespace openmc { @@ -31,10 +31,6 @@ void MeshFilter::from_xml(pugi::xml_node node) if (check_for_node(node, "translation")) { set_translation(get_node_array(node, "translation")); } - // Read the rotation transform. - if (check_for_node(node, "rotation")) { - set_rotation(get_node_array(node, "rotation")); - } } void MeshFilter::get_all_bins( @@ -50,12 +46,6 @@ void MeshFilter::get_all_bins( last_r -= translation(); r -= translation(); } - // apply rotation if present - if (!rotation_.empty()) { - last_r = last_r.rotate(rotation_); - r = r.rotate(rotation_); - u = u.rotate(rotation_); - } if (estimator != TallyEstimator::TRACKLENGTH) { auto bin = model::meshes[mesh_]->get_bin(r); @@ -76,9 +66,6 @@ void MeshFilter::to_statepoint(hid_t filter_group) const if (translated_) { write_dataset(filter_group, "translation", translation_); } - if (rotated_) { - write_dataset(filter_group, "rotation", rotation_); - } } std::string MeshFilter::text_label(int bin) const @@ -93,7 +80,7 @@ void MeshFilter::set_mesh(int32_t mesh) // perform any additional perparation for mesh tallies here mesh_ = mesh; n_bins_ = model::meshes[mesh_]->n_bins(); - model::meshes[mesh_]->prepare_for_point_location(); + model::meshes[mesh_]->prepare_for_tallies(); } void MeshFilter::set_translation(const Position& translation) @@ -107,40 +94,6 @@ void MeshFilter::set_translation(const double translation[3]) this->set_translation({translation[0], translation[1], translation[2]}); } -void MeshFilter::set_rotation(const vector& rot) -{ - rotated_ = true; - - // Compute and store the inverse rotation matrix for the angles given. - rotation_.clear(); - rotation_.reserve(rot.size() == 9 ? 9 : 12); - if (rot.size() == 3) { - double phi = -rot[0] * PI / 180.0; - double theta = -rot[1] * PI / 180.0; - double psi = -rot[2] * PI / 180.0; - rotation_.push_back(std::cos(theta) * std::cos(psi)); - rotation_.push_back(-std::cos(phi) * std::sin(psi) + - std::sin(phi) * std::sin(theta) * std::cos(psi)); - rotation_.push_back(std::sin(phi) * std::sin(psi) + - std::cos(phi) * std::sin(theta) * std::cos(psi)); - rotation_.push_back(std::cos(theta) * std::sin(psi)); - rotation_.push_back(std::cos(phi) * std::cos(psi) + - std::sin(phi) * std::sin(theta) * std::sin(psi)); - rotation_.push_back(-std::sin(phi) * std::cos(psi) + - std::cos(phi) * std::sin(theta) * std::sin(psi)); - rotation_.push_back(-std::sin(theta)); - rotation_.push_back(std::sin(phi) * std::cos(theta)); - rotation_.push_back(std::cos(phi) * std::cos(theta)); - - // When user specifies angles, write them at end of vector - rotation_.push_back(rot[0]); - rotation_.push_back(rot[1]); - rotation_.push_back(rot[2]); - } else { - std::copy(rot.begin(), rot.end(), std::back_inserter(rotation_)); - } -} - //============================================================================== // C-API functions //============================================================================== @@ -249,48 +202,4 @@ extern "C" int openmc_mesh_filter_set_translation( return 0; } -//! Return the rotation matrix of a mesh filter -extern "C" int openmc_mesh_filter_get_rotation( - int32_t index, double rot[], size_t* n) -{ - // Make sure this is a valid index to an allocated filter - if (int err = verify_filter(index)) - return err; - - // Check the filter type - const auto& filter = model::tally_filters[index]; - if (filter->type() != FilterType::MESH) { - set_errmsg("Tried to get a rotation from a non-mesh filter."); - return OPENMC_E_INVALID_TYPE; - } - // Get rotation from the mesh filter and set value - auto mesh_filter = dynamic_cast(filter.get()); - *n = mesh_filter->rotation().size(); - std::memcpy(rot, mesh_filter->rotation().data(), - *n * sizeof(mesh_filter->rotation()[0])); - return 0; -} - -//! Set the flattened rotation matrix of a mesh filter -extern "C" int openmc_mesh_filter_set_rotation( - int32_t index, const double rot[], size_t rot_len) -{ - // Make sure this is a valid index to an allocated filter - if (int err = verify_filter(index)) - return err; - - const auto& filter = model::tally_filters[index]; - // Check the filter type - if (filter->type() != FilterType::MESH) { - set_errmsg("Tried to set a rotation from a non-mesh filter."); - return OPENMC_E_INVALID_TYPE; - } - - // Get a pointer to the filter and downcast - auto mesh_filter = dynamic_cast(filter.get()); - std::vector vec_rot(rot, rot + rot_len); - mesh_filter->set_rotation(vec_rot); - return 0; -} - } // namespace openmc diff --git a/src/tallies/filter_meshmaterial.cpp b/src/tallies/filter_meshmaterial.cpp deleted file mode 100644 index b45bb4164..000000000 --- a/src/tallies/filter_meshmaterial.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "openmc/tallies/filter_meshmaterial.h" - -#include -#include // for move - -#include - -#include "openmc/capi.h" -#include "openmc/constants.h" -#include "openmc/container_util.h" -#include "openmc/error.h" -#include "openmc/material.h" -#include "openmc/mesh.h" -#include "openmc/tensor.h" -#include "openmc/xml_interface.h" - -namespace openmc { - -void MeshMaterialFilter::from_xml(pugi::xml_node node) -{ - // Get mesh ID - auto mesh = get_node_array(node, "mesh"); - if (mesh.size() != 1) { - fatal_error( - "Only one mesh can be specified per " + type_str() + " mesh filter."); - } - - auto id = mesh[0]; - auto search = model::mesh_map.find(id); - if (search == model::mesh_map.end()) { - fatal_error( - fmt::format("Could not find mesh {} specified on tally filter.", id)); - } - set_mesh(search->second); - - // Get pairs of (element index, material) and set the bins - auto bins = get_node_array(node, "bins"); - this->set_bins(bins); - - if (check_for_node(node, "translation")) { - set_translation(get_node_array(node, "translation")); - } -} - -void MeshMaterialFilter::set_bins(span bins) -{ - if (bins.size() % 2 != 0) { - fatal_error( - fmt::format("Size of mesh material bins is not even: {}", bins.size())); - } - - // Create a vector of ElementMat pairs from the flat vector of bins - vector element_mats; - for (int64_t i = 0; i < bins.size() / 2; ++i) { - int32_t element = bins[2 * i]; - int32_t mat_id = bins[2 * i + 1]; - auto search = model::material_map.find(mat_id); - if (search == model::material_map.end()) { - fatal_error(fmt::format( - "Could not find material {} specified on tally filter.", mat_id)); - } - int32_t mat_index = search->second; - element_mats.push_back({element, mat_index}); - } - - this->set_bins(std::move(element_mats)); -} - -void MeshMaterialFilter::set_bins(vector&& bins) -{ - // Swap internal bins_ with the provided vector to avoid copying - bins_.swap(bins); - - // Clear and update the mapping and vector of materials - materials_.clear(); - map_.clear(); - for (std::size_t i = 0; i < bins_.size(); ++i) { - const auto& x = bins_[i]; - assert(x.index_mat >= 0); - assert(x.index_mat < model::materials.size()); - materials_.insert(x.index_mat); - map_[x] = i; - } - - n_bins_ = bins_.size(); -} - -void MeshMaterialFilter::set_mesh(int32_t mesh) -{ - // perform any additional perparation for mesh tallies here - mesh_ = mesh; - model::meshes[mesh_]->prepare_for_point_location(); -} - -void MeshMaterialFilter::set_translation(const Position& translation) -{ - translated_ = true; - translation_ = translation; -} - -void MeshMaterialFilter::set_translation(const double translation[3]) -{ - this->set_translation({translation[0], translation[1], translation[2]}); -} - -void MeshMaterialFilter::get_all_bins( - const Particle& p, TallyEstimator estimator, FilterMatch& match) const -{ - // If current material is not in any bins, don't bother checking - if (!contains(materials_, p.material())) { - return; - } - - Position last_r = p.r_last(); - Position r = p.r(); - Position u = p.u(); - - // apply translation if present - if (translated_) { - last_r -= translation(); - r -= translation(); - } - - if (estimator != TallyEstimator::TRACKLENGTH) { - int32_t index_element = model::meshes[mesh_]->get_bin(r); - if (index_element >= 0) { - auto search = map_.find({index_element, p.material()}); - if (search != map_.end()) { - match.bins_.push_back(search->second); - match.weights_.push_back(1.0); - } - } - } else { - // First determine which elements the particle crosses (may or may not - // actually match bins so we have to adjust bins_/weight_ after) - int32_t n_start = match.bins_.size(); - model::meshes[mesh_]->bins_crossed( - last_r, r, u, match.bins_, match.weights_); - int32_t n_end = match.bins_.size(); - - // Go through bins and weights and check which ones are actually a match - // based on the (element, material) pair. For matches, overwrite the bin. - int i = 0; - for (int j = n_start; j < n_end; ++j) { - int32_t index_element = match.bins_[j]; - double weight = match.weights_[j]; - auto search = map_.find({index_element, p.material()}); - if (search != map_.end()) { - match.bins_[n_start + i] = search->second; - match.weights_[n_start + i] = weight; - ++i; - } - } - - // Resize the vectors to remove the unmatched bins - match.bins_.resize(n_start + i); - } -} - -void MeshMaterialFilter::to_statepoint(hid_t filter_group) const -{ - Filter::to_statepoint(filter_group); - write_dataset(filter_group, "mesh", model::meshes[mesh_]->id_); - - size_t n = bins_.size(); - tensor::Tensor data({n, 2}); - for (int64_t i = 0; i < n; ++i) { - const auto& x = bins_[i]; - data(i, 0) = x.index_element; - data(i, 1) = model::materials[x.index_mat]->id_; - } - write_dataset(filter_group, "bins", data); - - if (translated_) { - write_dataset(filter_group, "translation", translation_); - } -} - -std::string MeshMaterialFilter::text_label(int bin) const -{ - auto& x = bins_[bin]; - auto& mesh = *model::meshes.at(mesh_); - return fmt::format("Mesh {}, {}, Material {}", mesh.id(), - mesh.bin_label(x.index_element), model::materials[x.index_mat]->id_); -} - -} // namespace openmc diff --git a/src/tallies/filter_mu.cpp b/src/tallies/filter_mu.cpp index 63915a533..95bb3b210 100644 --- a/src/tallies/filter_mu.cpp +++ b/src/tallies/filter_mu.cpp @@ -31,14 +31,14 @@ void MuFilter::from_xml(pugi::xml_node node) this->set_bins(bins); } -void MuFilter::set_bins(span bins) +void MuFilter::set_bins(gsl::span bins) { // Clear existing bins bins_.clear(); bins_.reserve(bins.size()); // Copy bins, ensuring they are valid - for (int64_t i = 0; i < bins.size(); ++i) { + for (gsl::index i = 0; i < bins.size(); ++i) { if (i > 0 && bins[i] <= bins[i - 1]) { throw std::runtime_error {"Mu bins must be monotonically increasing."}; } diff --git a/src/tallies/filter_musurface.cpp b/src/tallies/filter_musurface.cpp deleted file mode 100644 index 340149d4c..000000000 --- a/src/tallies/filter_musurface.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "openmc/tallies/filter_musurface.h" - -#include // for abs, copysign - -#include "openmc/search.h" -#include "openmc/surface.h" -#include "openmc/tallies/tally_scoring.h" - -namespace openmc { - -void MuSurfaceFilter::get_all_bins( - const Particle& p, TallyEstimator estimator, FilterMatch& match) const -{ - // Get surface normal (and make sure it is a unit vector) - const auto surf {model::surfaces[p.surface_index()].get()}; - auto n = surf->normal(p.r()); - n /= n.norm(); - - // Determine whether normal should be pointing in or out - if (p.surface() < 0) - n *= -1; - - // Determine cosine of angle between normal and particle direction - double mu = p.u().dot(n); - if (std::abs(mu) > 1.0) - mu = std::copysign(1.0, mu); - - // Find matching bin - if (mu >= bins_.front() && mu <= bins_.back()) { - auto bin = lower_bound_index(bins_.begin(), bins_.end(), mu); - match.bins_.push_back(bin); - match.weights_.push_back(1.0); - } -} - -} // namespace openmc diff --git a/src/tallies/filter_parent_nuclide.cpp b/src/tallies/filter_parent_nuclide.cpp deleted file mode 100644 index d04941075..000000000 --- a/src/tallies/filter_parent_nuclide.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "openmc/tallies/filter_parent_nuclide.h" - -#include // for int64_t - -#include - -#include "openmc/capi.h" -#include "openmc/chain.h" -#include "openmc/search.h" -#include "openmc/settings.h" -#include "openmc/xml_interface.h" - -namespace openmc { - -//============================================================================== -// ParentNuclideFilter implementation -//============================================================================== - -void ParentNuclideFilter::from_xml(pugi::xml_node node) -{ - nuclides_ = get_node_array(node, "bins"); - - // Convert nuclides to indices in data::chain_nuclides - std::vector bins; - for (const auto& nuclide : nuclides_) { - auto it = data::chain_nuclide_map.find(nuclide); - if (it != data::chain_nuclide_map.end()) { - bins.push_back(it->second); - } else { - // The default value of parent_nuclide is -1, so to prevent a score to - // this bin assign the value -2. - bins.push_back(-2); - } - } - this->set_bins(bins); -} - -void ParentNuclideFilter::set_bins(span bins) -{ - // Clear existing bins - bins_.clear(); - bins_.reserve(bins.size()); - map_.clear(); - - // Set bins based on chain nuclide indexing - for (int64_t i = 0; i < bins.size(); ++i) { - bins_.push_back(bins[i]); - map_[bins[i]] = i; - } - - n_bins_ = bins_.size(); -} - -void ParentNuclideFilter::get_all_bins( - const Particle& p, TallyEstimator estimator, FilterMatch& match) const -{ - // Get the particle's parent nuclide - int parent_nuclide = p.parent_nuclide(); - - // Find bin matching parent nuclide - auto search = map_.find(parent_nuclide); - if (search != map_.end()) { - match.bins_.push_back(search->second); - match.weights_.push_back(1.0); - } -} - -void ParentNuclideFilter::to_statepoint(hid_t filter_group) const -{ - Filter::to_statepoint(filter_group); - write_dataset(filter_group, "bins", nuclides_); -} - -std::string ParentNuclideFilter::text_label(int bin) const -{ - return fmt::format("Parent Nuclide {}", nuclides_[bin]); -} - -} // namespace openmc diff --git a/src/tallies/filter_particle.cpp b/src/tallies/filter_particle.cpp index 031068f3a..56d93a47f 100644 --- a/src/tallies/filter_particle.cpp +++ b/src/tallies/filter_particle.cpp @@ -13,12 +13,12 @@ void ParticleFilter::from_xml(pugi::xml_node node) // Convert to vector of ParticleType vector types; for (auto& p : particles) { - types.emplace_back(p); + types.push_back(str_to_particle_type(p)); } this->set_particles(types); } -void ParticleFilter::set_particles(span particles) +void ParticleFilter::set_particles(gsl::span particles) { // Clear existing particles particles_.clear(); @@ -47,7 +47,7 @@ void ParticleFilter::to_statepoint(hid_t filter_group) const Filter::to_statepoint(filter_group); vector particles; for (auto p : particles_) { - particles.push_back(p.str()); + particles.push_back(particle_type_to_str(p)); } write_dataset(filter_group, "bins", particles); } @@ -55,10 +55,10 @@ void ParticleFilter::to_statepoint(hid_t filter_group) const std::string ParticleFilter::text_label(int bin) const { const auto& p = particles_.at(bin); - return fmt::format("Particle: {}", p.str()); + return fmt::format("Particle: {}", particle_type_to_str(p)); } -extern "C" int openmc_particle_filter_get_bins(int32_t idx, int32_t bins[]) +extern "C" int openmc_particle_filter_get_bins(int32_t idx, int bins[]) { if (int err = verify_filter(idx)) return err; @@ -68,7 +68,7 @@ extern "C" int openmc_particle_filter_get_bins(int32_t idx, int32_t bins[]) if (pf) { const auto& particles = pf->particles(); for (int i = 0; i < particles.size(); i++) { - bins[i] = particles[i].pdg_number(); + bins[i] = static_cast(particles[i]); } } else { set_errmsg("The filter at the specified index is not a ParticleFilter"); diff --git a/src/tallies/filter_particle_production.cpp b/src/tallies/filter_particle_production.cpp deleted file mode 100644 index 899809679..000000000 --- a/src/tallies/filter_particle_production.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "openmc/tallies/filter_particle_production.h" - -#include - -#include "openmc/search.h" -#include "openmc/xml_interface.h" - -namespace openmc { - -//============================================================================== -// ParticleProductionFilter implementation -//============================================================================== - -void ParticleProductionFilter::get_all_bins( - const Particle& p, TallyEstimator estimator, FilterMatch& match) const -{ - int start_idx = p.secondary_bank_index(); - int end_idx = start_idx + p.n_secondaries(); - - // Loop over secondary bank entries - for (int bank_idx = start_idx; bank_idx < end_idx; bank_idx++) { - const auto& site = p.local_secondary_bank(bank_idx); - - // Find which particle-type slot this secondary belongs to - auto it = type_to_index_.find(site.particle.pdg_number()); - if (it == type_to_index_.end()) - continue; - - int particle_idx = it->second; - if (energy_bins_.empty()) { - // No energy binning, just particle type - match.bins_.push_back(particle_idx); - match.weights_.push_back(site.wgt); - } else { - // Bin the energy - if (site.E >= energy_bins_.front() && site.E <= energy_bins_.back()) { - int n_energies = static_cast(energy_bins_.size()) - 1; - auto energy_idx = - lower_bound_index(energy_bins_.begin(), energy_bins_.end(), site.E); - match.bins_.push_back(particle_idx * n_energies + energy_idx); - match.weights_.push_back(site.wgt); - } - } - } -} - -std::string ParticleProductionFilter::text_label(int bin) const -{ - if (energy_bins_.empty()) { - return fmt::format("Secondary {}", secondary_types_.at(bin).str()); - } else { - int n_energies = static_cast(energy_bins_.size()) - 1; - int particle_idx = bin / n_energies; - int energy_idx = bin % n_energies; - return fmt::format("Secondary {}, Energy [{}, {})", - secondary_types_.at(particle_idx).str(), energy_bins_.at(energy_idx), - energy_bins_.at(energy_idx + 1)); - } -} - -void ParticleProductionFilter::from_xml(pugi::xml_node node) -{ - // Read energy bins if present (optional) - if (check_for_node(node, "energies")) { - auto bins = get_node_array(node, "energies"); - for (int64_t i = 1; i < bins.size(); ++i) { - if (bins[i] <= bins[i - 1]) { - throw std::runtime_error { - "Energy bins must be monotonically increasing."}; - } - } - energy_bins_.assign(bins.begin(), bins.end()); - } - - // Read particle types (required) - auto names = get_node_array(node, "particles"); - for (const auto& name : names) { - int idx = secondary_types_.size(); - secondary_types_.emplace_back(name); - type_to_index_[secondary_types_.back().pdg_number()] = idx; - } - - // Compute total bins - if (energy_bins_.empty()) { - n_bins_ = secondary_types_.size(); - } else { - n_bins_ = secondary_types_.size() * (energy_bins_.size() - 1); - } -} - -void ParticleProductionFilter::to_statepoint(hid_t filter_group) const -{ - Filter::to_statepoint(filter_group); - - // Write energy bins if present - if (!energy_bins_.empty()) { - write_dataset(filter_group, "energies", energy_bins_); - } - - // Write particle types - vector names; - for (const auto& pt : secondary_types_) { - names.push_back(pt.str()); - } - write_dataset(filter_group, "particles", names); -} - -} // namespace openmc diff --git a/src/tallies/filter_polar.cpp b/src/tallies/filter_polar.cpp index 29be6a437..d132ccf42 100644 --- a/src/tallies/filter_polar.cpp +++ b/src/tallies/filter_polar.cpp @@ -32,14 +32,14 @@ void PolarFilter::from_xml(pugi::xml_node node) this->set_bins(bins); } -void PolarFilter::set_bins(span bins) +void PolarFilter::set_bins(gsl::span bins) { // Clear existing bins bins_.clear(); bins_.reserve(bins.size()); // Copy bins, ensuring they are valid - for (int64_t i = 0; i < bins.size(); ++i) { + for (gsl::index i = 0; i < bins.size(); ++i) { if (i > 0 && bins[i] <= bins[i - 1]) { throw std::runtime_error {"Polar bins must be monotonically increasing."}; } diff --git a/src/tallies/filter_reaction.cpp b/src/tallies/filter_reaction.cpp deleted file mode 100644 index 8ee9f3ce8..000000000 --- a/src/tallies/filter_reaction.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "openmc/tallies/filter_reaction.h" - -#include - -#include "openmc/capi.h" -#include "openmc/endf.h" -#include "openmc/error.h" -#include "openmc/reaction.h" -#include "openmc/xml_interface.h" - -namespace openmc { - -//============================================================================== -// ReactionFilter implementation -//============================================================================== - -void ReactionFilter::from_xml(pugi::xml_node node) -{ - // Read bins as reaction name strings - auto bins_str = get_node_array(node, "bins"); - - // Convert reaction names to MT numbers - vector bins_mt; - bins_mt.reserve(bins_str.size()); - for (const auto& name : bins_str) { - bins_mt.push_back(reaction_mt(name)); - } - - this->set_bins(bins_mt); -} - -void ReactionFilter::set_bins(span bins) -{ - // Clear existing bins - bins_.clear(); - bins_.reserve(bins.size()); - - // Copy bins and build lookup map - for (int64_t i = 0; i < bins.size(); ++i) { - bins_.push_back(bins[i]); - } - - n_bins_ = bins_.size(); -} - -void ReactionFilter::get_all_bins( - const Particle& p, TallyEstimator estimator, FilterMatch& match) const -{ - // Get the event MT number from the particle - int event_mt = p.event_mt(); - - // Check each bin, considering summation rules - for (int64_t i = 0; i < bins_.size(); ++i) { - if (mt_matches(event_mt, bins_[i])) { - match.bins_.push_back(i); - match.weights_.push_back(1.0); - } - } -} - -void ReactionFilter::to_statepoint(hid_t filter_group) const -{ - Filter::to_statepoint(filter_group); - - // Write bins as reaction name strings for human readability - vector names; - names.reserve(bins_.size()); - for (auto mt : bins_) { - names.push_back(reaction_name(mt)); - } - write_dataset(filter_group, "bins", names); -} - -std::string ReactionFilter::text_label(int bin) const -{ - return reaction_name(bins_[bin]); -} - -} // namespace openmc diff --git a/src/tallies/filter_sph_harm.cpp b/src/tallies/filter_sph_harm.cpp index 1989e6ef1..359df379b 100644 --- a/src/tallies/filter_sph_harm.cpp +++ b/src/tallies/filter_sph_harm.cpp @@ -1,9 +1,9 @@ #include "openmc/tallies/filter_sph_harm.h" -#include #include // For pair #include +#include #include "openmc/capi.h" #include "openmc/error.h" @@ -25,15 +25,12 @@ void SphericalHarmonicsFilter::set_order(int order) if (order < 0) { throw std::invalid_argument { "Spherical harmonics order must be non-negative."}; - } else if (order > 10) { - throw std::invalid_argument {"Spherical harmonics orders greater than 10 " - "are currently not supported!"}; } order_ = order; n_bins_ = (order_ + 1) * (order_ + 1); } -void SphericalHarmonicsFilter::set_cosine(const std::string& cosine) +void SphericalHarmonicsFilter::set_cosine(gsl::cstring_span cosine) { if (cosine == "scatter") { cosine_ = SphericalHarmonicsCosine::scatter; @@ -42,7 +39,7 @@ void SphericalHarmonicsFilter::set_cosine(const std::string& cosine) } else { throw std::invalid_argument {fmt::format("Unrecognized cosine type, \"{}\" " "in spherical harmonics filter", - cosine)}; + gsl::to_string(cosine))}; } } @@ -90,7 +87,7 @@ void SphericalHarmonicsFilter::to_statepoint(hid_t filter_group) const std::string SphericalHarmonicsFilter::text_label(int bin) const { - assert(bin >= 0 && bin < n_bins_); + Expects(bin >= 0 && bin < n_bins_); for (int n = 0; n < order_ + 1; n++) { if (bin < (n + 1) * (n + 1)) { int m = (bin - n * n) - n; diff --git a/src/tallies/filter_surface.cpp b/src/tallies/filter_surface.cpp index 4a636f1aa..a84d17728 100644 --- a/src/tallies/filter_surface.cpp +++ b/src/tallies/filter_surface.cpp @@ -1,7 +1,5 @@ #include "openmc/tallies/filter_surface.h" -#include - #include #include "openmc/error.h" @@ -28,7 +26,7 @@ void SurfaceFilter::from_xml(pugi::xml_node node) this->set_surfaces(surfaces); } -void SurfaceFilter::set_surfaces(span surfaces) +void SurfaceFilter::set_surfaces(gsl::span surfaces) { // Clear existing surfaces surfaces_.clear(); @@ -37,8 +35,8 @@ void SurfaceFilter::set_surfaces(span surfaces) // Update surfaces and mapping for (auto& index : surfaces) { - assert(index >= 0); - assert(index < model::surfaces.size()); + Expects(index >= 0); + Expects(index < model::surfaces.size()); surfaces_.push_back(index); map_[index] = surfaces_.size() - 1; } @@ -49,10 +47,14 @@ void SurfaceFilter::set_surfaces(span surfaces) void SurfaceFilter::get_all_bins( const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - auto search = map_.find(p.surface_index()); + auto search = map_.find(std::abs(p.surface()) - 1); if (search != map_.end()) { match.bins_.push_back(search->second); - match.weights_.push_back(1.0); + if (p.surface() < 0) { + match.weights_.push_back(-1.0); + } else { + match.weights_.push_back(1.0); + } } } diff --git a/src/tallies/filter_time.cpp b/src/tallies/filter_time.cpp index 948d1347a..0378aa28d 100644 --- a/src/tallies/filter_time.cpp +++ b/src/tallies/filter_time.cpp @@ -21,7 +21,7 @@ void TimeFilter::from_xml(pugi::xml_node node) this->set_bins(bins); } -void TimeFilter::set_bins(span bins) +void TimeFilter::set_bins(gsl::span bins) { // Clear existing bins bins_.clear(); diff --git a/src/tallies/filter_universe.cpp b/src/tallies/filter_universe.cpp index f4b22decd..96ad0212d 100644 --- a/src/tallies/filter_universe.cpp +++ b/src/tallies/filter_universe.cpp @@ -1,7 +1,5 @@ #include "openmc/tallies/filter_universe.h" -#include - #include #include "openmc/cell.h" @@ -26,7 +24,7 @@ void UniverseFilter::from_xml(pugi::xml_node node) this->set_universes(universes); } -void UniverseFilter::set_universes(span universes) +void UniverseFilter::set_universes(gsl::span universes) { // Clear existing universes universes_.clear(); @@ -35,8 +33,8 @@ void UniverseFilter::set_universes(span universes) // Update universes and mapping for (auto& index : universes) { - assert(index >= 0); - assert(index < model::universes.size()); + Expects(index >= 0); + Expects(index < model::universes.size()); universes_.push_back(index); map_[index] = universes_.size() - 1; } @@ -48,7 +46,7 @@ void UniverseFilter::get_all_bins( const Particle& p, TallyEstimator estimator, FilterMatch& match) const { for (int i = 0; i < p.n_coord(); i++) { - auto search = map_.find(p.coord(i).universe()); + auto search = map_.find(p.coord(i).universe); if (search != map_.end()) { match.bins_.push_back(search->second); match.weights_.push_back(1.0); diff --git a/src/tallies/filter_weight.cpp b/src/tallies/filter_weight.cpp deleted file mode 100644 index 31f4bd1bf..000000000 --- a/src/tallies/filter_weight.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "openmc/tallies/filter_weight.h" - -#include // for is_sorted -#include // for runtime_error - -#include - -#include "openmc/search.h" -#include "openmc/xml_interface.h" - -namespace openmc { - -//============================================================================== -// WeightFilter implementation -//============================================================================== - -void WeightFilter::from_xml(pugi::xml_node node) -{ - auto bins = get_node_array(node, "bins"); - this->set_bins(bins); -} - -void WeightFilter::set_bins(span bins) -{ - if (!std::is_sorted(bins.begin(), bins.end())) { - throw std::runtime_error {"Weight bins must be monotonically increasing."}; - } - - // Clear existing bins - bins_.clear(); - bins_.reserve(bins.size()); - - // Copy bins - bins_.insert(bins_.end(), bins.begin(), bins.end()); - n_bins_ = bins_.size() - 1; -} - -void WeightFilter::get_all_bins( - const Particle& p, TallyEstimator estimator, FilterMatch& match) const -{ - // Get particle weight - double wgt = p.wgt_last(); - - // Bin the weight - if (wgt >= bins_.front() && wgt <= bins_.back()) { - auto bin = lower_bound_index(bins_.begin(), bins_.end(), wgt); - match.bins_.push_back(bin); - match.weights_.push_back(1.0); - } -} - -void WeightFilter::to_statepoint(hid_t filter_group) const -{ - Filter::to_statepoint(filter_group); - write_dataset(filter_group, "bins", bins_); -} - -std::string WeightFilter::text_label(int bin) const -{ - return fmt::format("Weight [{}, {}]", bins_[bin], bins_[bin + 1]); -} - -} // namespace openmc diff --git a/src/tallies/filter_zernike.cpp b/src/tallies/filter_zernike.cpp index af5b595aa..eb4c8bdfd 100644 --- a/src/tallies/filter_zernike.cpp +++ b/src/tallies/filter_zernike.cpp @@ -1,11 +1,11 @@ #include "openmc/tallies/filter_zernike.h" -#include #include #include #include // For pair #include +#include #include "openmc/capi.h" #include "openmc/error.h" @@ -57,7 +57,7 @@ void ZernikeFilter::to_statepoint(hid_t filter_group) const std::string ZernikeFilter::text_label(int bin) const { - assert(bin >= 0 && bin < n_bins_); + Expects(bin >= 0 && bin < n_bins_); for (int n = 0; n < order_ + 1; n++) { int last = (n + 1) * (n + 2) / 2; if (bin < last) { diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 085633247..674987b8f 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -2,7 +2,6 @@ #include "openmc/array.h" #include "openmc/capi.h" -#include "openmc/cell.h" #include "openmc/constants.h" #include "openmc/container_util.h" #include "openmc/error.h" @@ -28,21 +27,19 @@ #include "openmc/tallies/filter_legendre.h" #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/filter_meshborn.h" -#include "openmc/tallies/filter_meshmaterial.h" #include "openmc/tallies/filter_meshsurface.h" #include "openmc/tallies/filter_particle.h" #include "openmc/tallies/filter_sph_harm.h" #include "openmc/tallies/filter_surface.h" -#include "openmc/tallies/filter_time.h" #include "openmc/xml_interface.h" -#include "openmc/tensor.h" +#include "xtensor/xadapt.hpp" +#include "xtensor/xbuilder.hpp" // for empty_like +#include "xtensor/xview.hpp" #include -#include // for max, set_union -#include -#include // for size_t -#include // for back_inserter +#include // for max +#include // for size_t #include namespace openmc { @@ -58,17 +55,15 @@ vector> tallies; vector active_tallies; vector active_analog_tallies; vector active_tracklength_tallies; -vector active_timed_tracklength_tallies; vector active_collision_tallies; vector active_meshsurf_tallies; vector active_surface_tallies; vector active_pulse_height_tallies; -vector pulse_height_cells; -vector time_grid; +vector pulse_height_cells; } // namespace model namespace simulation { -tensor::StaticTensor2D global_tallies; +xt::xtensor_fixed> global_tallies; int32_t n_realizations {0}; } // namespace simulation @@ -106,9 +101,6 @@ Tally::Tally(pugi::xml_node node) multiply_density_ = get_node_value_bool(node, "multiply_density"); } - if (check_for_node(node, "higher_moments")) { - higher_moments_ = get_node_value_bool(node, "higher_moments"); - } // ======================================================================= // READ DATA FOR FILTERS @@ -148,7 +140,7 @@ Tally::Tally(pugi::xml_node node) // Check for the presence of certain filter types bool has_energyout = energyout_filter_ >= 0; int particle_filter_index = C_NONE; - for (int64_t j = 0; j < filters_.size(); ++j) { + for (gsl::index j = 0; j < filters_.size(); ++j) { int i_filter = filters_[j]; const auto& f = model::tally_filters[i_filter].get(); @@ -170,12 +162,6 @@ Tally::Tally(pugi::xml_node node) filt_type == FilterType::ZERNIKE || filt_type == FilterType::ZERNIKE_RADIAL) { estimator_ = TallyEstimator::COLLISION; - } else if (filt_type == FilterType::PARTICLE_PRODUCTION) { - estimator_ = TallyEstimator::ANALOG; - } else if (filt_type == FilterType::REACTION) { - if (estimator_ == TallyEstimator::TRACKLENGTH) { - estimator_ = TallyEstimator::COLLISION; - } } } @@ -193,71 +179,13 @@ Tally::Tally(pugi::xml_node node) fatal_error(fmt::format("No scores specified on tally {}.", id_)); } - // Set IFP if needed - if (!settings::ifp_on) { - // Determine if this tally has an IFP score - bool has_ifp_score = false; - for (int score : scores_) { - if (score == SCORE_IFP_TIME_NUM || score == SCORE_IFP_BETA_NUM || - score == SCORE_IFP_DENOM) { - has_ifp_score = true; - break; - } - } - - // Check for errors - if (has_ifp_score) { - if (settings::run_mode == RunMode::EIGENVALUE) { - if (settings::ifp_n_generation < 0) { - settings::ifp_n_generation = DEFAULT_IFP_N_GENERATION; - warning(fmt::format( - "{} generations will be used for IFP (default value). It can be " - "changed using the 'ifp_n_generation' settings.", - settings::ifp_n_generation)); - } - if (settings::ifp_n_generation > settings::n_inactive) { - fatal_error("'ifp_n_generation' must be lower than or equal to the " - "number of inactive cycles."); - } - settings::ifp_on = true; - } else if (settings::run_mode == RunMode::FIXED_SOURCE) { - fatal_error( - "Iterated Fission Probability can only be used in an eigenvalue " - "calculation."); - } - } - } - - // Set IFP parameters if needed - if (settings::ifp_on) { - for (int score : scores_) { - switch (score) { - case SCORE_IFP_TIME_NUM: - if (settings::ifp_parameter == IFPParameter::None) { - settings::ifp_parameter = IFPParameter::GenerationTime; - } else if (settings::ifp_parameter == IFPParameter::BetaEffective) { - settings::ifp_parameter = IFPParameter::Both; - } - break; - case SCORE_IFP_BETA_NUM: - case SCORE_IFP_DENOM: - if (settings::ifp_parameter == IFPParameter::None) { - settings::ifp_parameter = IFPParameter::BetaEffective; - } else if (settings::ifp_parameter == IFPParameter::GenerationTime) { - settings::ifp_parameter = IFPParameter::Both; - } - break; - } - } - } - // Check if tally is compatible with particle type if (!settings::photon_transport) { for (int score : scores_) { switch (score) { case SCORE_PULSE_HEIGHT: - fatal_error("For pulse-height tallies, photon transport needs to be " - "activated."); + fatal_error( + "For pulse-height tallies, photon transport needs to be activated."); break; } } @@ -294,12 +222,12 @@ Tally::Tally(pugi::xml_node node) const auto& f = model::tally_filters[particle_filter_index].get(); auto pf = dynamic_cast(f); for (auto p : pf->particles()) { - if (!p.is_neutron()) { + if (p != ParticleType::neutron) { warning(fmt::format( "Particle filter other than NEUTRON used with " "photon transport turned off. All tallies for particle type {}" " will have no scores", - p.str())); + static_cast(p))); } } } @@ -331,8 +259,7 @@ Tally::Tally(pugi::xml_node node) if (has_energyout && i_nuc == -1) { fatal_error(fmt::format( "Error on tally {}: Cannot use a " - "'nuclide_density' or 'temperature' derivative on a tally with " - "an " + "'nuclide_density' or 'temperature' derivative on a tally with an " "outgoing energy filter and 'total' nuclide rate. Instead, tally " "each nuclide in the material individually.", id_)); @@ -390,7 +317,7 @@ Tally::Tally(pugi::xml_node node) } } -#ifdef OPENMC_LIBMESH_ENABLED +#ifdef LIBMESH // ensure a tracklength tally isn't used with a libMesh filter for (auto i : this->filters_) { auto df = dynamic_cast(model::tally_filters[i].get()); @@ -418,7 +345,7 @@ Tally* Tally::create(int32_t id) void Tally::set_id(int32_t id) { - assert(id >= 0 || id == C_NONE); + Expects(id >= 0 || id == C_NONE); // Clear entry in tally map if an ID was already assigned before if (id_ != C_NONE) { @@ -474,7 +401,7 @@ bool Tally::has_filter(FilterType filter_type) const return false; } -void Tally::set_filters(span filters) +void Tally::set_filters(gsl::span filters) { // Clear old data. filters_.clear(); @@ -501,18 +428,22 @@ void Tally::add_filter(Filter* filter) energyout_filter_ = filters_.size(); } else if (filter->type() == FilterType::DELAYED_GROUP) { delayedgroup_filter_ = filters_.size(); + } else if (filter->type() == FilterType::CELL) { + cell_filter_ = filters_.size(); + } else if (filter->type() == FilterType::ENERGY) { + energy_filter_ = filters_.size(); } filters_.push_back(filter_idx); } void Tally::set_strides() { - // Set the strides. Filters are traversed in reverse so that the last - // filter has the shortest stride in memory and the first filter has the - // longest stride. + // Set the strides. Filters are traversed in reverse so that the last filter + // has the shortest stride in memory and the first filter has the longest + // stride. auto n = filters_.size(); strides_.resize(n, 0); - int64_t stride = 1; + int stride = 1; for (int i = n - 1; i >= 0; --i) { strides_[i] = stride; stride *= model::tally_filters[filters_[i]]->n_bins(); @@ -540,8 +471,6 @@ void Tally::set_scores(const vector& scores) bool legendre_present = false; bool cell_present = false; bool cellfrom_present = false; - bool material_present = false; - bool materialfrom_present = false; bool surface_present = false; bool meshsurface_present = false; bool non_cell_energy_present = false; @@ -558,34 +487,23 @@ void Tally::set_scores(const vector& scores) cellfrom_present = true; } else if (filt->type() == FilterType::CELL) { cell_present = true; - } else if (filt->type() == FilterType::MATERIALFROM) { - materialfrom_present = true; - } else if (filt->type() == FilterType::MATERIAL) { - material_present = true; } else if (filt->type() == FilterType::SURFACE) { surface_present = true; } else if (filt->type() == FilterType::MESH_SURFACE) { meshsurface_present = true; } } - bool surface_types_present = - (surface_present || cellfrom_present || materialfrom_present); - bool non_meshsurface_types_present = - (surface_present || cell_present || cellfrom_present || material_present || - materialfrom_present); // Iterate over the given scores. for (auto score_str : scores) { - // Make sure a delayed group filter wasn't used with an incompatible - // score. + // Make sure a delayed group filter wasn't used with an incompatible score. if (delayedgroup_filter_ != C_NONE) { - if (score_str != "delayed-nu-fission" && score_str != "decay-rate" && - score_str != "ifp-beta-numerator") + if (score_str != "delayed-nu-fission" && score_str != "decay-rate") fatal_error("Cannot tally " + score_str + "with a delayedgroup filter"); } // Determine integer code for score - int score = reaction_tally_mt(score_str); + int score = reaction_type(score_str); switch (score) { case SCORE_FLUX: @@ -594,12 +512,6 @@ void Tally::set_scores(const vector& scores) fatal_error("Cannot tally flux for an individual nuclide."); if (energyout_present) fatal_error("Cannot tally flux with an outgoing energy filter."); - if (surface_types_present) { - if (meshsurface_present) - fatal_error("OpenMC does not support mesh surface fluxes yet"); - type_ = TallyType::SURFACE; - estimator_ = TallyEstimator::ANALOG; - } break; case SCORE_TOTAL: @@ -632,61 +544,47 @@ void Tally::set_scores(const vector& scores) case SCORE_CURRENT: // Check which type of current is desired: mesh or surface currents. - if (meshsurface_present) { - if (non_meshsurface_types_present) + if (surface_present || cell_present || cellfrom_present) { + if (meshsurface_present) fatal_error("Cannot tally mesh surface currents in the same tally as " "normal surface currents"); - type_ = TallyType::MESH_SURFACE; - } else { type_ = TallyType::SURFACE; estimator_ = TallyEstimator::ANALOG; + } else if (meshsurface_present) { + type_ = TallyType::MESH_SURFACE; + } else { + fatal_error("Cannot tally currents without surface type filters"); } break; case HEATING: - if (settings::photon_transport) { - // Photon heating requires a collision estimator (analog energy - // balance). However, if the tally only scores neutrons, we can keep the - // tracklength estimator since neutron heating uses kerma coefficients - // that support tracklength scoring. - bool neutron_only = false; - for (auto i_filt : filters_) { - auto pf = - dynamic_cast(model::tally_filters[i_filt].get()); - if (pf && pf->particles().size() == 1 && - pf->particles()[0].is_neutron()) { - neutron_only = true; - break; - } - } - if (!neutron_only) - estimator_ = TallyEstimator::COLLISION; - } + if (settings::photon_transport) + estimator_ = TallyEstimator::COLLISION; break; - case SCORE_PULSE_HEIGHT: { + case SCORE_PULSE_HEIGHT: if (non_cell_energy_present) { fatal_error("Pulse-height tallies are not compatible with filters " "other than CellFilter and EnergyFilter"); } type_ = TallyType::PULSE_HEIGHT; - // Collect all unique cell indices covered by this tally. - // If no CellFilter is present, all cells in the geometry are scored. - const auto* cell_filter_ptr = get_filter(); - int n = cell_filter_ptr ? cell_filter_ptr->n_bins() - : static_cast(model::cells.size()); - for (int i = 0; i < n; ++i) { - int32_t cell_index = cell_filter_ptr ? cell_filter_ptr->cells()[i] : i; - if (!contains(model::pulse_height_cells, cell_index)) - model::pulse_height_cells.push_back(cell_index); - } - break; - } - case SCORE_IFP_TIME_NUM: - case SCORE_IFP_BETA_NUM: - case SCORE_IFP_DENOM: - estimator_ = TallyEstimator::COLLISION; + // Collecting indices of all cells covered by the filters in the pulse + // height tally in global variable pulse_height_cells + for (const auto& i_filt : filters_) { + auto cell_filter = + dynamic_cast(model::tally_filters[i_filt].get()); + if (cell_filter) { + const auto& cells = cell_filter->cells(); + for (int i = 0; i < cell_filter->n_bins(); i++) { + int cell_index = cells[i]; + if (!contains(model::pulse_height_cells, cell_index)) { + model::pulse_height_cells.push_back(cell_index); + } + } + } + } + break; } @@ -712,20 +610,15 @@ void Tally::set_scores(const vector& scores) "in multi-group mode"); } - // Make sure mesh surface tallies contain only current score. - if (meshsurface_present) { - if ((scores_[0] != SCORE_CURRENT) || (scores_.size() > 1)) - fatal_error("Cannot tally score other than 'current' when using a " - "mesh-surface filter."); - } - - // Make sure surface tallies contain only surface type scores score. - if (type_ == TallyType::SURFACE) { - for (auto sc : scores_) - if ((sc != SCORE_CURRENT) && (sc != SCORE_FLUX)) - fatal_error("Cannot tally scores other than 'current' or 'flux' " - "when using surface filters."); + // Make sure current scores are not mixed in with volumetric scores. + if (type_ == TallyType::SURFACE || type_ == TallyType::MESH_SURFACE) { + if (scores_.size() != 1) + fatal_error("Cannot tally other scores in the same tally as surface " + "currents."); } + if ((surface_present || meshsurface_present) && scores_[0] != SCORE_CURRENT) + fatal_error("Cannot tally score other than 'current' when using a surface " + "or mesh-surface filter."); } void Tally::set_nuclides(pugi::xml_node node) @@ -821,7 +714,7 @@ void Tally::init_triggers(pugi::xml_node node) } else { int i_score = 0; for (; i_score < this->scores_.size(); ++i_score) { - if (this->scores_[i_score] == reaction_tally_mt(score_str)) + if (reaction_name(this->scores_[i_score]) == score_str) break; } if (i_score == this->scores_.size()) { @@ -839,20 +732,14 @@ void Tally::init_triggers(pugi::xml_node node) void Tally::init_results() { int n_scores = scores_.size() * nuclides_.size(); - if (higher_moments_) { - results_ = tensor::Tensor({static_cast(n_filter_bins_), - static_cast(n_scores), size_t {5}}); - } else { - results_ = tensor::Tensor({static_cast(n_filter_bins_), - static_cast(n_scores), size_t {3}}); - } + results_ = xt::empty({n_filter_bins_, n_scores, 3}); } void Tally::reset() { n_realizations_ = 0; if (results_.size() != 0) { - results_.fill(0.0); + xt::view(results_, xt::all()) = 0.0; } } @@ -865,51 +752,29 @@ void Tally::accumulate() // Calculate total source strength for normalization double total_source = 0.0; if (settings::run_mode == RunMode::FIXED_SOURCE) { - total_source = model::external_sources_probability.integral(); + for (const auto& s : model::external_sources) { + total_source += s->strength(); + } } else { total_source = 1.0; } - // Determine number of particles contributing to tally - double contributing_particles = settings::reduce_tallies - ? settings::n_particles - : simulation::work_per_rank; - // Account for number of source particles in normalization double norm = - total_source / (contributing_particles * settings::gen_per_batch); + total_source / (settings::n_particles * settings::gen_per_batch); if (settings::solver_type == SolverType::RANDOM_RAY) { norm = 1.0; } - // Accumulate each result - if (higher_moments_) { +// Accumulate each result #pragma omp parallel for - // filter bins (specific cell, energy bins) - for (int64_t i = 0; i < results_.shape(0); ++i) { - // score bins (flux, total reaction rate, fission reaction rate, etc.) - for (int j = 0; j < results_.shape(1); ++j) { - double val = results_(i, j, TallyResult::VALUE) * norm; - double val2 = val * val; - results_(i, j, TallyResult::VALUE) = 0.0; - results_(i, j, TallyResult::SUM) += val; - results_(i, j, TallyResult::SUM_SQ) += val2; - results_(i, j, TallyResult::SUM_THIRD) += val2 * val; - results_(i, j, TallyResult::SUM_FOURTH) += val2 * val2; - } - } - } else { -#pragma omp parallel for - // filter bins (specific cell, energy bins) - for (int64_t i = 0; i < results_.shape(0); ++i) { - // score bins (flux, total reaction rate, fission reaction rate, etc.) - for (int j = 0; j < results_.shape(1); ++j) { - double val = results_(i, j, TallyResult::VALUE) * norm; - results_(i, j, TallyResult::VALUE) = 0.0; - results_(i, j, TallyResult::SUM) += val; - results_(i, j, TallyResult::SUM_SQ) += val * val; - } + for (int i = 0; i < results_.shape()[0]; ++i) { + for (int j = 0; j < results_.shape()[1]; ++j) { + double val = results_(i, j, TallyResult::VALUE) * norm; + results_(i, j, TallyResult::VALUE) = 0.0; + results_(i, j, TallyResult::SUM) += val; + results_(i, j, TallyResult::SUM_SQ) += val * val; } } } @@ -924,18 +789,18 @@ int Tally::score_index(const std::string& score) const return -1; } -tensor::Tensor Tally::get_reshaped_data() const +xt::xarray Tally::get_reshaped_data() const { - vector shape; + std::vector shape; for (auto f : filters()) { shape.push_back(model::tally_filters[f]->n_bins()); } // add number of scores and nuclides to tally - shape.push_back(results_.shape(1)); - shape.push_back(results_.shape(2)); + shape.push_back(results_.shape()[1]); + shape.push_back(results_.shape()[2]); - tensor::Tensor reshaped_results = results_; + xt::xarray reshaped_results = results_; reshaped_results.reshape(shape); return reshaped_results; } @@ -1040,14 +905,13 @@ void reduce_tally_results() // Skip any tallies that are not active auto& tally {model::tallies[i_tally]}; - // Extract 2D view of the VALUE column from the 3D results tensor, - // then copy into a contiguous array for MPI reduction - const int val_idx = static_cast(TallyResult::VALUE); - tensor::View val_view = - tally->results_.slice(tensor::all, tensor::all, val_idx); - tensor::Tensor values(val_view); + // Get view of accumulated tally values + auto values_view = xt::view(tally->results_, xt::all(), xt::all(), + static_cast(TallyResult::VALUE)); - tensor::Tensor values_reduced(values.shape()); + // Make copy of tally values in contiguous array + xt::xtensor values = values_view; + xt::xtensor values_reduced = xt::empty_like(values); // Reduce contiguous set of tally results MPI_Reduce(values.data(), values_reduced.data(), values.size(), @@ -1055,23 +919,24 @@ void reduce_tally_results() // Transfer values on master and reset on other ranks if (mpi::master) { - val_view = values_reduced; + values_view = values_reduced; } else { - val_view = 0.0; + values_view = 0.0; } } } - // Note that global tallies are *always* reduced even when no_reduce option - // is on. + // Note that global tallies are *always* reduced even when no_reduce option is + // on. - // Get reference to global tallies + // Get view of global tally values auto& gt = simulation::global_tallies; - const int val_col = static_cast(TallyResult::VALUE); + auto gt_values_view = + xt::view(gt, xt::all(), static_cast(TallyResult::VALUE)); - // Copy VALUE column into contiguous array for MPI reduction - tensor::Tensor gt_values(gt.slice(tensor::all, val_col)); - tensor::Tensor gt_values_reduced({size_t {N_GLOBAL_TALLIES}}); + // Make copy of values in contiguous array + xt::xtensor gt_values = gt_values_view; + xt::xtensor gt_values_reduced = xt::empty_like(gt_values); // Reduce contiguous data MPI_Reduce(gt_values.data(), gt_values_reduced.data(), N_GLOBAL_TALLIES, @@ -1079,9 +944,9 @@ void reduce_tally_results() // Transfer values on master and reset on other ranks if (mpi::master) { - gt.slice(tensor::all, val_col) = gt_values_reduced; + gt_values_view = gt_values_reduced; } else { - gt.slice(tensor::all, val_col) = 0.0; + gt_values_view = 0.0; } // We also need to determine the total starting weight of particles from the @@ -1141,59 +1006,21 @@ void accumulate_tallies() } } -double distance_to_time_boundary(double time, double speed) -{ - if (model::time_grid.empty()) { - return INFTY; - } else if (time >= model::time_grid.back()) { - return INFTY; - } else { - double next_time = - *std::upper_bound(model::time_grid.begin(), model::time_grid.end(), time); - return (next_time - time) * speed; - } -} - -//! Add new points to the global time grid -// -//! \param grid Vector of new time points to add -void add_to_time_grid(vector grid) -{ - if (grid.empty()) - return; - - // Create new vector with enough space to hold old and new grid points - vector merged; - merged.reserve(model::time_grid.size() + grid.size()); - - // Merge and remove duplicates - std::set_union(model::time_grid.begin(), model::time_grid.end(), grid.begin(), - grid.end(), std::back_inserter(merged)); - - // Swap in the new grid - model::time_grid.swap(merged); -} - void setup_active_tallies() { model::active_tallies.clear(); model::active_analog_tallies.clear(); model::active_tracklength_tallies.clear(); - model::active_timed_tracklength_tallies.clear(); model::active_collision_tallies.clear(); model::active_meshsurf_tallies.clear(); model::active_surface_tallies.clear(); model::active_pulse_height_tallies.clear(); - model::time_grid.clear(); for (auto i = 0; i < model::tallies.size(); ++i) { const auto& tally {*model::tallies[i]}; if (tally.active_) { model::active_tallies.push_back(i); - bool mesh_present = (tally.get_filter() || - tally.get_filter()); - auto time_filter = tally.get_filter(); switch (tally.type_) { case TallyType::VOLUME: @@ -1202,12 +1029,7 @@ void setup_active_tallies() model::active_analog_tallies.push_back(i); break; case TallyEstimator::TRACKLENGTH: - if (time_filter && mesh_present) { - model::active_timed_tracklength_tallies.push_back(i); - add_to_time_grid(time_filter->bins()); - } else { - model::active_tracklength_tallies.push_back(i); - } + model::active_tracklength_tallies.push_back(i); break; case TallyEstimator::COLLISION: model::active_collision_tallies.push_back(i); @@ -1243,12 +1065,10 @@ void free_memory_tally() model::active_tallies.clear(); model::active_analog_tallies.clear(); model::active_tracklength_tallies.clear(); - model::active_timed_tracklength_tallies.clear(); model::active_collision_tallies.clear(); model::active_meshsurf_tallies.clear(); model::active_surface_tallies.clear(); model::active_pulse_height_tallies.clear(); - model::time_grid.clear(); model::tally_map.clear(); } @@ -1549,7 +1369,7 @@ extern "C" int openmc_tally_set_filters( try { // Convert indices to filter pointers vector filters; - for (int64_t i = 0; i < n; ++i) { + for (gsl::index i = 0; i < n; ++i) { int32_t i_filt = indices[i]; filters.push_back(model::tally_filters.at(i_filt).get()); } @@ -1587,8 +1407,8 @@ extern "C" int openmc_tally_get_n_realizations(int32_t index, int32_t* n) return 0; } -//! \brief Returns a pointer to a tally results array along with its shape. -//! This allows a user to obtain in-memory tally results from Python directly. +//! \brief Returns a pointer to a tally results array along with its shape. This +//! allows a user to obtain in-memory tally results from Python directly. extern "C" int openmc_tally_results( int32_t index, double** results, size_t* shape) { diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index 241cbf008..e798161ec 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -4,7 +4,6 @@ #include "openmc/capi.h" #include "openmc/constants.h" #include "openmc/error.h" -#include "openmc/ifp.h" #include "openmc/material.h" #include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" @@ -14,14 +13,12 @@ #include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/string_utils.h" -#include "openmc/surface.h" #include "openmc/tallies/derivative.h" #include "openmc/tallies/filter.h" #include "openmc/tallies/filter_cell.h" #include "openmc/tallies/filter_delayedgroup.h" #include "openmc/tallies/filter_energy.h" -#include #include namespace openmc { @@ -158,7 +155,7 @@ void score_fission_delayed_dg(int i_tally, int d_bin, double score, dg_match.bins_[i_bin] = d_bin; // Determine the filter scoring index - int64_t filter_index = 0; + auto filter_index = 0; double filter_weight = 1.; for (auto i = 0; i < tally.filters().size(); ++i) { auto i_filt = tally.filters(i); @@ -235,7 +232,7 @@ double score_fission_q(const Particle& p, int score_bin, const Tally& tally, double score {0.0}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); const Nuclide& nuc {*data::nuclides[j_nuclide]}; score += get_nuc_fission_q(nuc, p, score_bin) * atom_density * p.neutron_xs(j_nuclide).fission; @@ -327,56 +324,6 @@ double score_neutron_heating(const Particle& p, const Tally& tally, double flux, return score; } -//! Helper function to obtain reaction Q value for photons and charged particles -double get_reaction_q_value(const Particle& p) -{ - if (p.type().is_photon() && p.event_mt() == PAIR_PROD) { - // pair production - return -2 * MASS_ELECTRON_EV; - } else if (p.type() == ParticleType::positron()) { - // positron annihilation - return 2 * MASS_ELECTRON_EV; - } else { - return 0.0; - } -} - -//! Helper function to obtain particle heating [eV] - -double score_particle_heating(const Particle& p, const Tally& tally, - double flux, int rxn_bin, int i_nuclide, double atom_density) -{ - if (p.type().is_neutron()) - return score_neutron_heating( - p, tally, flux, rxn_bin, i_nuclide, atom_density); - if (i_nuclide == -1 || i_nuclide == p.event_nuclide() || - p.event_nuclide() == -1) { - // For pair production and positron annihilation, we need to account for the - // reaction Q value - double Q = get_reaction_q_value(p); - - // Get the pre-collision energy of the particle. - auto E = p.E_last(); - - // The energy deposited is the sum of the incident energy and the reaction - // Q-value less the energy of any outgoing particles - double score = E + Q - p.E() - p.bank_second_E(); - - score *= p.wgt_last(); - - // if no event_nuclide (charged particle) scale energy deposition by - // fractional charge density - if (i_nuclide != -1 && p.event_nuclide() == -1) { - const auto& mat {model::materials[p.material()]}; - int z = data::nuclides[i_nuclide]->Z_; - auto i = mat->mat_nuclide_index_[i_nuclide]; - score *= (z * mat->atom_density_[i] / mat->charge_density()); - } - return score; - } - return 0.0; -} - //! Helper function for nu-fission tallies with energyout filters. // //! In this case, we may need to score to multiple bins if there were multiple @@ -449,7 +396,7 @@ void score_fission_eout(Particle& p, int i_tally, int i_score, int score_bin) (score_bin == SCORE_PROMPT_NU_FISSION && g == 0)) { // Find the filter scoring index for this filter combination - int64_t filter_index = 0; + int filter_index = 0; double filter_weight = 1.0; for (auto j = 0; j < tally.filters().size(); ++j) { auto i_filt = tally.filters(j); @@ -497,7 +444,7 @@ void score_fission_eout(Particle& p, int i_tally, int i_score, int score_bin) } else { // Find the filter index and weight for this filter combination - int64_t filter_index = 0; + int filter_index = 0; double filter_weight = 1.; for (auto j = 0; j < tally.filters().size(); ++j) { auto i_filt = tally.filters(j); @@ -578,14 +525,16 @@ double get_nuclide_xs(const Particle& p, int i_nuclide, int score_bin) //! collision estimator. void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, - int64_t filter_index, double filter_weight, int i_nuclide, - double atom_density, double flux) + int filter_index, double filter_weight, int i_nuclide, double atom_density, + double flux) { Tally& tally {*model::tallies[i_tally]}; // Get the pre-collision energy of the particle. auto E = p.E_last(); + using Type = ParticleType; + for (auto i = 0; i < tally.scores_.size(); ++i) { auto score_bin = tally.scores_[i]; auto score_index = start_index + i; @@ -598,9 +547,9 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, case SCORE_TOTAL: if (i_nuclide >= 0) { - if (p.type().is_neutron()) { + if (p.type() == Type::neutron) { score = p.neutron_xs(i_nuclide).total * atom_density * flux; - } else if (p.type().is_photon()) { + } else if (p.type() == Type::photon) { score = p.photon_xs(i_nuclide).total * atom_density * flux; } } else { @@ -609,7 +558,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, break; case SCORE_INVERSE_VELOCITY: - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // Score inverse velocity in units of s/cm. @@ -617,11 +566,11 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, break; case SCORE_SCATTER: - if (!p.type().is_neutron() && !p.type().is_photon()) + if (p.type() != Type::neutron && p.type() != Type::photon) continue; if (i_nuclide >= 0) { - if (p.type().is_neutron()) { + if (p.type() == Type::neutron) { const auto& micro = p.neutron_xs(i_nuclide); score = (micro.total - micro.absorption) * atom_density * flux; } else { @@ -629,7 +578,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, score = (micro.coherent + micro.incoherent) * atom_density * flux; } } else { - if (p.type().is_neutron()) { + if (p.type() == Type::neutron) { score = (p.macro_xs().total - p.macro_xs().absorption) * flux; } else { score = (p.macro_xs().coherent + p.macro_xs().incoherent) * flux; @@ -638,11 +587,11 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, break; case SCORE_ABSORPTION: - if (!p.type().is_neutron() && !p.type().is_photon()) + if (p.type() != Type::neutron && p.type() != Type::photon) continue; if (i_nuclide >= 0) { - if (p.type().is_neutron()) { + if (p.type() == Type::neutron) { score = p.neutron_xs(i_nuclide).absorption * atom_density * flux; } else { const auto& xs = p.photon_xs(i_nuclide); @@ -650,7 +599,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, (xs.total - xs.coherent - xs.incoherent) * atom_density * flux; } } else { - if (p.type().is_neutron()) { + if (p.type() == Type::neutron) { score = p.macro_xs().absorption * flux; } else { score = @@ -696,7 +645,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); score += p.neutron_xs(j_nuclide).fission * data::nuclides[j_nuclide]->nu( E, ReactionProduct::EmissionMode::prompt) * @@ -743,7 +692,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); // Tally each delayed group bin individually for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { auto d = filt.groups()[d_bin]; @@ -763,7 +712,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); score += p.neutron_xs(j_nuclide).fission * data::nuclides[j_nuclide]->nu( E, ReactionProduct::EmissionMode::delayed) * @@ -806,7 +755,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, // this loop. for (auto d = 1; d < rxn.products_.size(); ++d) { const auto& product = rxn.products_[d]; - if (!product.particle_.is_neutron()) + if (product.particle_ != Type::neutron) continue; auto yield = nuc.nu(E, ReactionProduct::EmissionMode::delayed, d); @@ -824,7 +773,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); const auto& nuc {*data::nuclides[j_nuclide]}; if (nuc.fissionable_) { const auto& rxn {*nuc.fission_rx_[0]}; @@ -849,7 +798,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); const auto& nuc {*data::nuclides[j_nuclide]}; if (nuc.fissionable_) { const auto& rxn {*nuc.fission_rx_[0]}; @@ -860,7 +809,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, // this loop. for (auto d = 1; d < rxn.products_.size(); ++d) { const auto& product = rxn.products_[d]; - if (!product.particle_.is_neutron()) + if (product.particle_ != Type::neutron) continue; auto yield = @@ -893,7 +842,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); const auto& nuc {*data::nuclides[j_nuclide]}; if (nuc.fissionable_) { const auto& rxn {*nuc.fission_rx_[0]}; @@ -905,12 +854,13 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, break; case SCORE_EVENTS: - // Simply count the number of scoring events - score = 1.0; - break; +// Simply count the number of scoring events +#pragma omp atomic + tally.results_(filter_index, score_index, TallyResult::VALUE) += 1.0; + continue; case ELASTIC: - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; if (i_nuclide >= 0) { @@ -923,7 +873,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); if (p.neutron_xs(j_nuclide).elastic == CACHE_INVALID) data::nuclides[j_nuclide]->calculate_elastic_xs(p); score += p.neutron_xs(j_nuclide).elastic * atom_density * flux; @@ -940,64 +890,6 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, score_fission_q(p, score_bin, tally, flux, i_nuclide, atom_density); break; - case SCORE_IFP_TIME_NUM: - if (settings::ifp_on) { - if (p.type().is_neutron() && p.fission()) { - if (is_generation_time_or_both()) { - const auto& lifetimes = - simulation::ifp_source_lifetime_bank[p.current_work()]; - if (lifetimes.size() == settings::ifp_n_generation) { - score = lifetimes[0] * p.wgt_last(); - } - } - } - } - break; - - case SCORE_IFP_BETA_NUM: - if (settings::ifp_on) { - if (p.type().is_neutron() && p.fission()) { - if (is_beta_effective_or_both()) { - const auto& delayed_groups = - simulation::ifp_source_delayed_group_bank[p.current_work()]; - if (delayed_groups.size() == settings::ifp_n_generation) { - if (delayed_groups[0] > 0) { - score = p.wgt_last(); - if (tally.delayedgroup_filter_ != C_NONE) { - auto i_dg_filt = tally.filters()[tally.delayedgroup_filter_]; - const DelayedGroupFilter& filt { - *dynamic_cast( - model::tally_filters[i_dg_filt].get())}; - score_fission_delayed_dg(i_tally, delayed_groups[0] - 1, - score, score_index, p.filter_matches()); - continue; - } - } - } - } - } - } - break; - - case SCORE_IFP_DENOM: - if (settings::ifp_on) { - if (p.type().is_neutron() && p.fission()) { - int ifp_data_size; - if (is_beta_effective_or_both()) { - ifp_data_size = static_cast( - simulation::ifp_source_delayed_group_bank[p.current_work()] - .size()); - } else { - ifp_data_size = static_cast( - simulation::ifp_source_lifetime_bank[p.current_work()].size()); - } - if (ifp_data_size == settings::ifp_n_generation) { - score = p.wgt_last(); - } - } - } - break; - case N_2N: case N_3N: case N_4N: @@ -1010,7 +902,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, if (!simulation::need_depletion_rx) goto default_case; - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; int m; @@ -1032,7 +924,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); score += p.neutron_xs(j_nuclide).reaction[m] * atom_density * flux; } } @@ -1043,7 +935,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, case INCOHERENT: case PHOTOELECTRIC: case PAIR_PROD: - if (!p.type().is_photon()) + if (p.type() != Type::photon) continue; if (i_nuclide >= 0) { @@ -1064,8 +956,28 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, break; case HEATING: - score = score_particle_heating( - p, tally, flux, HEATING, i_nuclide, atom_density); + if (p.type() == Type::neutron) { + score = score_neutron_heating( + p, tally, flux, HEATING, i_nuclide, atom_density); + } else { + if (i_nuclide == -1 || i_nuclide == p.event_nuclide()) { + // The energy deposited is the difference between the pre-collision + // and post-collision energy... + score = E - p.E(); + + // ...less the energy of any secondary particles since they will be + // transported individually later + const auto& bank = p.secondary_bank(); + for (auto it = bank.end() - p.n_bank_second(); it < bank.end(); + ++it) { + score -= it->E; + } + + score *= p.wgt_last(); + } else { + score = 0.0; + } + } break; default: @@ -1073,7 +985,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, // The default block is really only meant for redundant neutron reactions // (e.g. 444, 901) - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // Any other cross section has to be calculated on-the-fly @@ -1086,7 +998,7 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, const Material& material {*model::materials[p.material()]}; for (auto i = 0; i < material.nuclide_.size(); ++i) { auto j_nuclide = material.nuclide_[i]; - auto atom_density = material.atom_density(i, p.density_mult()); + auto atom_density = material.atom_density_(i); score += get_nuclide_xs(p, j_nuclide, score_bin) * atom_density * flux; } @@ -1112,8 +1024,8 @@ void score_general_ce_nonanalog(Particle& p, int i_tally, int start_index, //! is not used for analog tallies. void score_general_ce_analog(Particle& p, int i_tally, int start_index, - int64_t filter_index, double filter_weight, int i_nuclide, - double atom_density, double flux) + int filter_index, double filter_weight, int i_nuclide, double atom_density, + double flux) { Tally& tally {*model::tallies[i_tally]}; @@ -1127,6 +1039,8 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, p.neutron_xs(p.event_nuclide()).total : 0.0; + using Type = ParticleType; + for (auto i = 0; i < tally.scores_.size(); ++i) { auto score_bin = tally.scores_[i]; auto score_index = start_index + i; @@ -1137,7 +1051,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, // All events score to a flux bin. We actually use a collision estimator // in place of an analog one since there is no way to count 'events' // exactly for the flux - if (p.type().is_neutron() || p.type().is_photon()) { + if (p.type() == Type::neutron || p.type() == Type::photon) { score = flux * p.wgt_last() / p.macro_xs().total; } else { score = 0.; @@ -1151,7 +1065,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, break; case SCORE_INVERSE_VELOCITY: - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // All events score to an inverse velocity bin. We actually use a @@ -1161,7 +1075,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, break; case SCORE_SCATTER: - if (!p.type().is_neutron() && !p.type().is_photon()) + if (p.type() != Type::neutron && p.type() != Type::photon) continue; // Skip any event where the particle didn't scatter @@ -1173,7 +1087,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, break; case SCORE_NU_SCATTER: - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // Only analog estimators are available. @@ -1198,7 +1112,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, break; case SCORE_ABSORPTION: - if (!p.type().is_neutron() && !p.type().is_photon()) + if (p.type() != Type::neutron && p.type() != Type::photon) continue; if (settings::survival_biasing) { @@ -1427,7 +1341,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, // this loop. for (auto d = 1; d < rxn.products_.size(); ++d) { const auto& product = rxn.products_[d]; - if (!product.particle_.is_neutron()) + if (product.particle_ != Type::neutron) continue; auto yield = nuc.nu(E, ReactionProduct::EmissionMode::delayed, d); @@ -1513,12 +1427,13 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, break; case SCORE_EVENTS: - // Simply count the number of scoring events - score = 1.0; - break; +// Simply count the number of scoring events +#pragma omp atomic + tally.results_(filter_index, score_index, TallyResult::VALUE) += 1.0; + continue; case ELASTIC: - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // Check if event MT matches @@ -1547,7 +1462,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, if (!simulation::need_depletion_rx) goto default_case; - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // Check if the event MT matches @@ -1560,7 +1475,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, case INCOHERENT: case PHOTOELECTRIC: case PAIR_PROD: - if (!p.type().is_photon()) + if (p.type() != Type::photon) continue; if (score_bin == PHOTOELECTRIC) { @@ -1578,8 +1493,23 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, break; case HEATING: - score = score_particle_heating( - p, tally, flux, HEATING, i_nuclide, atom_density); + if (p.type() == Type::neutron) { + score = score_neutron_heating( + p, tally, flux, HEATING, i_nuclide, atom_density); + } else { + // The energy deposited is the difference between the pre-collision and + // post-collision energy... + score = E - p.E(); + + // ...less the energy of any secondary particles since they will be + // transported individually later + const auto& bank = p.secondary_bank(); + for (auto it = bank.end() - p.n_bank_second(); it < bank.end(); ++it) { + score -= it->E; + } + + score *= p.wgt_last(); + } break; default: @@ -1587,7 +1517,7 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, // The default block is really only meant for redundant neutron reactions // (e.g. 444, 901) - if (!p.type().is_neutron()) + if (p.type() != Type::neutron) continue; // Any other score is assumed to be a MT number. Thus, we just need @@ -1615,8 +1545,8 @@ void score_general_ce_analog(Particle& p, int i_tally, int start_index, //! argument is really just used for filter weights. void score_general_mg(Particle& p, int i_tally, int start_index, - int64_t filter_index, double filter_weight, int i_nuclide, - double atom_density, double flux) + int filter_index, double filter_weight, int i_nuclide, double atom_density, + double flux) { auto& tally {*model::tallies[i_tally]}; @@ -1628,7 +1558,8 @@ void score_general_mg(Particle& p, int i_tally, int start_index, tally.estimator_ == TallyEstimator::COLLISION) { if (settings::survival_biasing) { // Determine weight that was absorbed - wgt_absorb = p.wgt_last() * p.macro_xs().absorption / p.macro_xs().total; + wgt_absorb = p.wgt_last() * p.neutron_xs(p.event_nuclide()).absorption / + p.neutron_xs(p.event_nuclide()).total; // Then we either are alive and had a scatter (and so g changed), // or are dead and g did not change @@ -2290,9 +2221,10 @@ void score_general_mg(Particle& p, int i_tally, int start_index, break; case SCORE_EVENTS: - // Simply count the number of scoring events - score = 1.0; - break; +// Simply count the number of scoring events +#pragma omp atomic + tally.results_(filter_index, score_index, TallyResult::VALUE) += 1.0; + continue; default: continue; @@ -2310,7 +2242,10 @@ void score_analog_tally_ce(Particle& p) // Since electrons/positrons are not transported, we assign a flux of zero. // Note that the heating score does NOT use the flux and will be non-zero for // electrons/positrons. - double flux = (p.type().is_neutron() || p.type().is_photon()) ? 1.0 : 0.0; + double flux = + (p.type() == ParticleType::neutron || p.type() == ParticleType::photon) + ? 1.0 + : 0.0; for (auto i_tally : model::active_analog_tallies) { const Tally& tally {*model::tallies[i_tally]}; @@ -2382,8 +2317,7 @@ void score_analog_tally_mg(Particle& p) model::materials[p.material()]->mat_nuclide_index_[i_nuclide]; if (j == C_NONE) continue; - atom_density = - model::materials[p.material()]->atom_density(j, p.density_mult()); + atom_density = model::materials[p.material()]->atom_density_(j); } score_general_mg(p, i_tally, i * tally.scores_.size(), filter_index, @@ -2404,13 +2338,15 @@ void score_analog_tally_mg(Particle& p) match.bins_present_ = false; } -void score_tracklength_tally_general( - Particle& p, double flux, const vector& tallies) +void score_tracklength_tally(Particle& p, double distance) { + // Determine the tracklength estimate of the flux + double flux = p.wgt() * distance; + // Set 'none' value for log union grid index int i_log_union = C_NONE; - for (auto i_tally : tallies) { + for (auto i_tally : model::active_tracklength_tallies) { const Tally& tally {*model::tallies[i_tally]}; // Initialize an iterator over valid filter bin combinations. If there are @@ -2435,22 +2371,23 @@ void score_tracklength_tally_general( if (p.material() != MATERIAL_VOID) { const auto& mat = model::materials[p.material()]; auto j = mat->mat_nuclide_index_[i_nuclide]; - if (j != C_NONE) - atom_density = mat->atom_density(j, p.density_mult()); - } - if (atom_density > 0) { - if (!tally.multiply_density()) - atom_density = 1.0; - } else if (!tally.multiply_density()) { - // Determine log union grid index - if (i_log_union == C_NONE) { - int neutron = ParticleType::neutron().transport_index(); - i_log_union = std::log(p.E() / data::energy_min[neutron]) / - simulation::log_spacing; + if (j == C_NONE) { + // Determine log union grid index + if (i_log_union == C_NONE) { + int neutron = static_cast(ParticleType::neutron); + i_log_union = std::log(p.E() / data::energy_min[neutron]) / + simulation::log_spacing; + } + + // Update micro xs cache + if (!tally.multiply_density()) { + p.update_neutron_xs(i_nuclide, i_log_union); + atom_density = 1.0; + } + } else { + atom_density = + tally.multiply_density() ? mat->atom_density_(j) : 1.0; } - // Update micro xs cache - p.update_neutron_xs(i_nuclide, i_log_union); - atom_density = 1.0; } } @@ -2478,62 +2415,11 @@ void score_tracklength_tally_general( match.bins_present_ = false; } -void score_timed_tracklength_tally(Particle& p, double total_distance) -{ - double speed = p.speed(); - double total_dt = total_distance / speed; - - // save particle last state - auto time_last = p.time_last(); - auto r_last = p.r_last(); - - // move particle back - p.move_distance(-total_distance); - p.time() -= total_dt; - p.lifetime() -= total_dt; - - double distance_traveled = 0.0; - while (distance_traveled < total_distance) { - - double distance = std::min(distance_to_time_boundary(p.time(), speed), - total_distance - distance_traveled); - double dt = distance / speed; - - // Save particle last state for tracklength tallies - p.time_last() = p.time(); - p.r_last() = p.r(); - - // Advance particle in space and time - p.move_distance(distance); - p.time() += dt; - p.lifetime() += dt; - - // Determine the tracklength estimate of the flux - double flux = p.wgt() * distance; - - score_tracklength_tally_general( - p, flux, model::active_timed_tracklength_tallies); - distance_traveled += distance; - } - - p.time_last() = time_last; - p.r_last() = r_last; -} - -void score_tracklength_tally(Particle& p, double distance) -{ - - // Determine the tracklength estimate of the flux - double flux = p.wgt() * distance; - - score_tracklength_tally_general(p, flux, model::active_tracklength_tallies); -} - void score_collision_tally(Particle& p) { // Determine the collision estimate of the flux double flux = 0.0; - if (p.type().is_neutron() || p.type().is_photon()) { + if (p.type() == ParticleType::neutron || p.type() == ParticleType::photon) { flux = p.wgt_last() / p.macro_xs().total; } @@ -2562,25 +2448,24 @@ void score_collision_tally(Particle& p) double atom_density = 0.; if (i_nuclide >= 0) { - if (p.material() != MATERIAL_VOID) { - const auto& mat = model::materials[p.material()]; - auto j = mat->mat_nuclide_index_[i_nuclide]; - if (j != C_NONE) - atom_density = mat->atom_density(j, p.density_mult()); - } - if (atom_density > 0) { - if (!tally.multiply_density()) - atom_density = 1.0; - } else if (!tally.multiply_density()) { + const auto& mat = model::materials[p.material()]; + auto j = mat->mat_nuclide_index_[i_nuclide]; + if (j == C_NONE) { // Determine log union grid index if (i_log_union == C_NONE) { - int neutron = ParticleType::neutron().transport_index(); + int neutron = static_cast(ParticleType::neutron); i_log_union = std::log(p.E() / data::energy_min[neutron]) / simulation::log_spacing; } + // Update micro xs cache - p.update_neutron_xs(i_nuclide, i_log_union); - atom_density = 1.0; + if (!tally.multiply_density()) { + p.update_neutron_xs(i_nuclide, i_log_union); + atom_density = 1.0; + } + } else { + atom_density = + tally.multiply_density() ? mat->atom_density_(j) : 1.0; } } @@ -2608,7 +2493,7 @@ void score_collision_tally(Particle& p) match.bins_present_ = false; } -void score_meshsurface_tally(Particle& p, const vector& tallies) +void score_surface_tally(Particle& p, const vector& tallies) { double current = p.wgt_last(); @@ -2652,69 +2537,6 @@ void score_meshsurface_tally(Particle& p, const vector& tallies) match.bins_present_ = false; } -void score_surface_tally( - Particle& p, const vector& tallies, const Direction& normal) -{ - double wgt = p.wgt_last(); - - double mu = std::clamp(p.u().dot(normal), -1.0, 1.0); - - // Sign for net current: +1 if crossing outward (in direction of normal), - // -1 if crossing inward - double current_sign = std::copysign(1.0, mu); - - // Determine absolute cosine of angle between particle direction and surface - // normal, needed for the surface-crossing flux estimator. - double abs_mu = std::abs(mu); - if (abs_mu < settings::surface_grazing_cutoff) - abs_mu = settings::surface_grazing_ratio * settings::surface_grazing_cutoff; - - for (auto i_tally : tallies) { - auto& tally {*model::tallies[i_tally]}; - - // Initialize an iterator over valid filter bin combinations. If there are - // no valid combinations, use a continue statement to ensure we skip the - // assume_separate break below. - auto filter_iter = FilterBinIter(tally, p); - auto end = FilterBinIter(tally, true, &p.filter_matches()); - if (filter_iter == end) - continue; - - // Loop over filter bins. - for (; filter_iter != end; ++filter_iter) { - auto filter_index = filter_iter.index_; - auto filter_weight = filter_iter.weight_; - - // Loop over scores. - for (auto score_index = 0; score_index < tally.scores_.size(); - ++score_index) { - auto score_bin = tally.scores_[score_index]; - double score; - if (score_bin == SCORE_CURRENT) { - // Net current: weight carries the sign of the crossing direction. - score = wgt * current_sign; - } else { - // SCORE_FLUX: surface-crossing estimator phi_S = sum(w / |mu|). - score = wgt / abs_mu; - } -#pragma omp atomic - tally.results_(filter_index, score_index, TallyResult::VALUE) += - score * filter_weight; - } - } - // If the user has specified that we can assume all tallies are spatially - // separate, this implies that once a tally has been scored to, we needn't - // check the others. This cuts down on overhead when there are many - // tallies specified - if (settings::assume_separate) - break; - } - - // Reset all the filter matches for the next tally event. - for (auto& match : p.filter_matches()) - match.bins_present_ = false; -} - void score_pulse_height_tally(Particle& p, const vector& tallies) { // The pulse height tally in OpenMC hijacks the logic of CellFilter and @@ -2727,62 +2549,67 @@ void score_pulse_height_tally(Particle& p, const vector& tallies) // Save original cell/energy information int orig_n_coord = p.n_coord(); - int orig_cell = p.coord(0).cell(); + int orig_cell = p.coord(0).cell; double orig_E_last = p.E_last(); - // Set particle in top level - p.n_coord() = 1; - for (auto i_tally : tallies) { auto& tally {*model::tallies[i_tally]}; - // Find CellFilter in the tally (if any) to determine cells to loop over - const auto* cell_filter = tally.get_filter(); - const auto& cells = - cell_filter ? cell_filter->cells() : model::pulse_height_cells; + // Determine all CellFilter in the tally + for (const auto& filter : tally.filters()) { + auto cell_filter = + dynamic_cast(model::tally_filters[filter].get()); + if (cell_filter != nullptr) { - for (auto cell_id : cells) { - // Temporarily change cell of particle - p.coord(0).cell() = cell_id; + const auto& cells = cell_filter->cells(); + // Loop over all cells in the CellFilter + for (auto cell_index = 0; cell_index < cells.size(); ++cell_index) { + int cell_id = cells[cell_index]; - // Determine index of cell in model::pulse_height_cells - auto it = std::find(model::pulse_height_cells.begin(), - model::pulse_height_cells.end(), cell_id); - int index = std::distance(model::pulse_height_cells.begin(), it); + // Temporarily change cell of particle + p.n_coord() = 1; + p.coord(0).cell = cell_id; - // Temporarily change energy of particle to pulse-height value - p.E_last() = p.pht_storage()[index]; + // Determine index of cell in model::pulse_height_cells + auto it = std::find(model::pulse_height_cells.begin(), + model::pulse_height_cells.end(), cell_id); + int index = std::distance(model::pulse_height_cells.begin(), it); - // Initialize an iterator over valid filter bin combinations. If - // there are no valid combinations, use a continue statement to ensure - // we skip the assume_separate break below. - auto filter_iter = FilterBinIter(tally, p); - auto end = FilterBinIter(tally, true, &p.filter_matches()); - if (filter_iter != end) { + // Temporarily change energy of particle to pulse-height value + p.E_last() = p.pht_storage()[index]; - // Loop over filter bins. - for (; filter_iter != end; ++filter_iter) { - auto filter_index = filter_iter.index_; - auto filter_weight = filter_iter.weight_; + // Initialize an iterator over valid filter bin combinations. If + // there are no valid combinations, use a continue statement to ensure + // we skip the assume_separate break below. + auto filter_iter = FilterBinIter(tally, p); + auto end = FilterBinIter(tally, true, &p.filter_matches()); + if (filter_iter == end) + continue; - // Loop over scores. - for (auto score_index = 0; score_index < tally.scores_.size(); - ++score_index) { + // Loop over filter bins. + for (; filter_iter != end; ++filter_iter) { + auto filter_index = filter_iter.index_; + auto filter_weight = filter_iter.weight_; + + // Loop over scores. + for (auto score_index = 0; score_index < tally.scores_.size(); + ++score_index) { #pragma omp atomic - tally.results_(filter_index, score_index, TallyResult::VALUE) += - filter_weight; + tally.results_(filter_index, score_index, TallyResult::VALUE) += + filter_weight; + } } + + // Reset all the filter matches for the next tally event. + for (auto& match : p.filter_matches()) + match.bins_present_ = false; } } - - // Reset all the filter matches for the next tally event. - for (auto& match : p.filter_matches()) - match.bins_present_ = false; } + // Restore cell/energy + p.n_coord() = orig_n_coord; + p.coord(0).cell = orig_cell; + p.E_last() = orig_E_last; } - // Restore cell/energy - p.n_coord() = orig_n_coord; - p.coord(0).cell() = orig_cell; - p.E_last() = orig_E_last; } } // namespace openmc diff --git a/src/tallies/trigger.cpp b/src/tallies/trigger.cpp index 7515f01a9..f1f83e298 100644 --- a/src/tallies/trigger.cpp +++ b/src/tallies/trigger.cpp @@ -28,7 +28,7 @@ KTrigger keff_trigger; //============================================================================== std::pair get_tally_uncertainty( - int i_tally, int score_index, int64_t filter_index) + int i_tally, int score_index, int filter_index) { const auto& tally {model::tallies[i_tally]}; @@ -71,7 +71,7 @@ void check_tally_triggers(double& ratio, int& tally_id, int& score) continue; const auto& results = t.results_; - for (int64_t filter_index = 0; filter_index < results.shape(0); + for (auto filter_index = 0; filter_index < results.shape()[0]; ++filter_index) { // Compute the tally uncertainty metrics. auto uncert_pair = diff --git a/src/thermal.cpp b/src/thermal.cpp index edfbddf23..741f89ed1 100644 --- a/src/thermal.cpp +++ b/src/thermal.cpp @@ -3,7 +3,12 @@ #include // for sort, move, min, max, find #include // for round, sqrt, abs -#include "openmc/tensor.h" +#include "xtensor/xarray.hpp" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xmath.hpp" +#include "xtensor/xsort.hpp" +#include "xtensor/xtensor.hpp" +#include "xtensor/xview.hpp" #include #include "openmc/constants.h" @@ -14,7 +19,6 @@ #include "openmc/secondary_correlated.h" #include "openmc/secondary_thermal.h" #include "openmc/settings.h" -#include "openmc/string_utils.h" namespace openmc { @@ -50,12 +54,12 @@ ThermalScattering::ThermalScattering( // Determine temperatures available auto dset_names = dataset_names(kT_group); auto n = dset_names.size(); - auto temps_available = tensor::Tensor({n}); + auto temps_available = xt::empty({n}); for (int i = 0; i < dset_names.size(); ++i) { // Read temperature value double T; read_dataset(kT_group, dset_names[i].data(), T); - temps_available[i] = std::round(T / K_BOLTZMANN); + temps_available[i] = T / K_BOLTZMANN; } std::sort(temps_available.begin(), temps_available.end()); @@ -77,7 +81,7 @@ ThermalScattering::ThermalScattering( // Determine actual temperatures to read for (const auto& T : temperature) { - auto i_closest = tensor::abs(temps_available - T).argmin(); + auto i_closest = xt::argmin(xt::abs(temps_available - T))[0]; auto temp_actual = temps_available[i_closest]; if (std::abs(temp_actual - T) < settings::temperature_tolerance) { if (std::find(temps_to_read.begin(), temps_to_read.end(), @@ -85,12 +89,9 @@ ThermalScattering::ThermalScattering( temps_to_read.push_back(std::round(temp_actual)); } } else { - fatal_error(fmt::format( - "Nuclear data library does not contain cross sections " - "for {} at or near {} K. Available temperatures " - "are {} K. Consider making use of openmc.Settings.temperature " - "to specify how intermediate temperatures are treated.", - name_, std::round(T), concatenate(temps_available))); + fatal_error(fmt::format("Nuclear data library does not contain cross " + "sections for {} at or near {} K.", + name_, std::round(T))); } } break; @@ -102,8 +103,8 @@ ThermalScattering::ThermalScattering( bool found = false; for (int j = 0; j < temps_available.size() - 1; ++j) { if (temps_available[j] <= T && T < temps_available[j + 1]) { - int T_j = temps_available[j]; - int T_j1 = temps_available[j + 1]; + int T_j = std::round(temps_available[j]); + int T_j1 = std::round(temps_available[j + 1]); if (std::find(temps_to_read.begin(), temps_to_read.end(), T_j) == temps_to_read.end()) { temps_to_read.push_back(T_j); @@ -121,14 +122,14 @@ ThermalScattering::ThermalScattering( if (std::abs(T - temps_available[0]) <= settings::temperature_tolerance) { if (std::find(temps_to_read.begin(), temps_to_read.end(), - temps_available[0]) == temps_to_read.end()) { - temps_to_read.push_back(temps_available[0]); + std::round(temps_available[0])) == temps_to_read.end()) { + temps_to_read.push_back(std::round(temps_available[0])); } } else if (std::abs(T - temps_available[n - 1]) <= settings::temperature_tolerance) { if (std::find(temps_to_read.begin(), temps_to_read.end(), - temps_available[n - 1]) == temps_to_read.end()) { - temps_to_read.push_back(temps_available[n - 1]); + std::round(temps_available[n - 1])) == temps_to_read.end()) { + temps_to_read.push_back(std::round(temps_available[n - 1])); } } else { fatal_error( @@ -291,21 +292,16 @@ void ThermalData::calculate_xs( *inelastic = (*inelastic_.xs)(E); } -AngleEnergy& ThermalData::sample_dist( - const NuclideMicroXS& micro_xs, double E, uint64_t* seed) const +void ThermalData::sample(const NuclideMicroXS& micro_xs, double E, + double* E_out, double* mu, uint64_t* seed) { // Determine whether inelastic or elastic scattering will occur if (prn(seed) < micro_xs.thermal_elastic / micro_xs.thermal) { - return *elastic_.distribution; + elastic_.distribution->sample(E, *E_out, *mu, seed); } else { - return *inelastic_.distribution; + inelastic_.distribution->sample(E, *E_out, *mu, seed); } -} -void ThermalData::sample(const NuclideMicroXS& micro_xs, double E, - double* E_out, double* mu, uint64_t* seed) const -{ - sample_dist(micro_xs, E, seed).sample(E, *E_out, *mu, seed); // Because of floating-point roundoff, it may be possible for mu to be // outside of the range [-1,1). In these cases, we just set mu to exactly // -1 or 1 @@ -313,13 +309,6 @@ void ThermalData::sample(const NuclideMicroXS& micro_xs, double E, *mu = std::copysign(1.0, *mu); } -double ThermalData::sample_energy_and_pdf(const NuclideMicroXS& micro_xs, - double E_in, double mu, double& E_out, uint64_t* seed) const -{ - return sample_dist(micro_xs, E_in, seed) - .sample_energy_and_pdf(E_in, mu, E_out, seed); -} - void free_memory_thermal() { data::thermal_scatt.clear(); diff --git a/src/track_output.cpp b/src/track_output.cpp index 02e092236..5c1436de7 100644 --- a/src/track_output.cpp +++ b/src/track_output.cpp @@ -8,7 +8,7 @@ #include "openmc/simulation.h" #include "openmc/vector.h" -#include "openmc/tensor.h" +#include "xtensor/xtensor.hpp" #include #include @@ -31,8 +31,8 @@ int n_tracks_written; //! Number of tracks written void add_particle_track(Particle& p) { - auto& track = p.tracks().emplace_back(); - track.particle = p.type(); + p.tracks().emplace_back(); + p.tracks().back().particle = p.type(); } void write_particle_track(Particle& p) @@ -122,7 +122,7 @@ void finalize_particle_track(Particle& p) int offset = 0; for (auto& track_i : p.tracks()) { offsets.push_back(offset); - particles.push_back(track_i.particle.pdg_number()); + particles.push_back(static_cast(track_i.particle)); offset += track_i.states.size(); tracks.insert(tracks.end(), track_i.states.begin(), track_i.states.end()); } diff --git a/src/universe.cpp b/src/universe.cpp index e1db80b99..b4ef6b4b2 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -45,14 +45,14 @@ bool Universe::find_cell(GeometryState& p) const Position r {p.r_local()}; Position u {p.u_local()}; auto surf = p.surface(); - int32_t i_univ = p.lowest_coord().universe(); + int32_t i_univ = p.lowest_coord().universe; for (auto i_cell : cells) { if (model::cells[i_cell]->universe_ != i_univ) continue; // Check if this cell contains the particle if (model::cells[i_cell]->contains(r, u, surf)) { - p.lowest_coord().cell() = i_cell; + p.lowest_coord().cell = i_cell; return true; } } @@ -61,7 +61,7 @@ bool Universe::find_cell(GeometryState& p) const BoundingBox Universe::bounding_box() const { - BoundingBox bbox = BoundingBox::inverted(); + BoundingBox bbox = {INFTY, -INFTY, INFTY, -INFTY, INFTY, -INFTY}; if (cells_.size() == 0) { return {}; } else { diff --git a/src/urr.cpp b/src/urr.cpp index b791eecb0..02cef2280 100644 --- a/src/urr.cpp +++ b/src/urr.cpp @@ -25,7 +25,7 @@ UrrData::UrrData(hid_t group_id) // Read URR tables. The HDF5 format is a little // different from how we want it laid out in memory. // This array used to be called "prob_". - tensor::Tensor tmp_prob; + xt::xtensor tmp_prob; read_dataset(group_id, "table", tmp_prob); auto shape = tmp_prob.shape(); @@ -38,7 +38,7 @@ UrrData::UrrData(hid_t group_id) xs_values_.resize({n_energy, n_cdf_values}); // Now fill in the values. Using manual loops here since we might - // not have fancy tensor slicing code written for GPU tensors. + // not have fancy xtensor slicing code written for GPU tensors. // The below enum gives how URR tables are laid out in our HDF5 tables. enum class URRTableParam { CUM_PROB, diff --git a/src/volume_calc.cpp b/src/volume_calc.cpp index f675ae78a..8b5c27f14 100644 --- a/src/volume_calc.cpp +++ b/src/volume_calc.cpp @@ -17,7 +17,8 @@ #include "openmc/timer.h" #include "openmc/xml_interface.h" -#include "openmc/tensor.h" +#include "xtensor/xadapt.hpp" +#include "xtensor/xview.hpp" #include #include // for copy @@ -178,7 +179,7 @@ vector VolumeCalculation::execute() const } else if (domain_type_ == TallyDomain::CELL) { for (int level = 0; level < p.n_coord(); ++level) { for (int i_domain = 0; i_domain < n; i_domain++) { - if (model::cells[p.coord(level).cell()]->id_ == + if (model::cells[p.coord(level).cell]->id_ == domain_ids_[i_domain]) { this->check_hit( p.material(), indices[i_domain], hits[i_domain]); @@ -189,7 +190,7 @@ vector VolumeCalculation::execute() const } else if (domain_type_ == TallyDomain::UNIVERSE) { for (int level = 0; level < p.n_coord(); ++level) { for (int i_domain = 0; i_domain < n; ++i_domain) { - if (model::universes[p.coord(level).universe()]->id_ == + if (model::universes[p.coord(level).universe]->id_ == domain_ids_[i_domain]) { check_hit(p.material(), indices[i_domain], hits[i_domain]); break; @@ -241,8 +242,7 @@ vector VolumeCalculation::execute() const // non-zero auto n_nuc = settings::run_CE ? data::nuclides.size() : data::mg.nuclides_.size(); - auto atoms = - tensor::zeros({static_cast(n_nuc), size_t {2}}); + xt::xtensor atoms({n_nuc, 2}, 0.0); #ifdef OPENMC_MPI if (mpi::master) { @@ -452,11 +452,9 @@ void VolumeCalculation::to_hdf5( } // Create array of total # of atoms with uncertainty for each nuclide - tensor::Tensor atom_data({static_cast(n_nuc), size_t {2}}); - for (size_t k = 0; k < static_cast(n_nuc); ++k) { - atom_data(k, 0) = result.atoms[k]; - atom_data(k, 1) = result.uncertainty[k]; - } + xt::xtensor atom_data({n_nuc, 2}); + xt::view(atom_data, xt::all(), 0) = xt::adapt(result.atoms); + xt::view(atom_data, xt::all(), 1) = xt::adapt(result.uncertainty); // Write results write_dataset(group_id, "nuclides", nucnames); diff --git a/src/weight_windows.cpp b/src/weight_windows.cpp index d3565eaaf..2eb930965 100644 --- a/src/weight_windows.cpp +++ b/src/weight_windows.cpp @@ -1,12 +1,16 @@ #include "openmc/weight_windows.h" #include -#include #include #include #include -#include "openmc/tensor.h" +#include "xtensor/xindex_view.hpp" +#include "xtensor/xio.hpp" +#include "xtensor/xmasked_view.hpp" +#include "xtensor/xnoalias.hpp" +#include "xtensor/xstrided_view.hpp" +#include "xtensor/xview.hpp" #include "openmc/error.h" #include "openmc/file_utils.h" @@ -18,10 +22,8 @@ #include "openmc/particle.h" #include "openmc/particle_data.h" #include "openmc/physics_common.h" -#include "openmc/random_ray/flat_source_domain.h" #include "openmc/search.h" #include "openmc/settings.h" -#include "openmc/simulation.h" #include "openmc/tallies/filter_energy.h" #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/filter_particle.h" @@ -29,6 +31,7 @@ #include "openmc/xml_interface.h" #include +#include namespace openmc { @@ -44,6 +47,92 @@ openmc::vector> weight_windows_generators; } // namespace variance_reduction +//============================================================================== +// Non-member functions +//============================================================================== + +void apply_weight_windows(Particle& p) +{ + if (!settings::weight_windows_on) + return; + + // WW on photon and neutron only + if (p.type() != ParticleType::neutron && p.type() != ParticleType::photon) + return; + + // skip dead or no energy + if (p.E() <= 0 || !p.alive()) + return; + + bool in_domain = false; + // TODO: this is a linear search - should do something more clever + WeightWindow weight_window; + for (const auto& ww : variance_reduction::weight_windows) { + weight_window = ww->get_weight_window(p); + if (weight_window.is_valid()) + break; + } + // particle is not in any of the ww domains, do nothing + if (!weight_window.is_valid()) + return; + + // get the paramters + double weight = p.wgt(); + + // first check to see if particle should be killed for weight cutoff + if (p.wgt() < weight_window.weight_cutoff) { + p.wgt() = 0.0; + return; + } + + // check if particle is far above current weight window + // only do this if the factor is not already set on the particle and a + // maximum lower bound ratio is specified + if (p.ww_factor() == 0.0 && weight_window.max_lb_ratio > 1.0 && + p.wgt() > weight_window.lower_weight * weight_window.max_lb_ratio) { + p.ww_factor() = + p.wgt() / (weight_window.lower_weight * weight_window.max_lb_ratio); + } + + // move weight window closer to the particle weight if needed + if (p.ww_factor() > 1.0) + weight_window.scale(p.ww_factor()); + + // if particle's weight is above the weight window split until they are within + // the window + if (weight > weight_window.upper_weight) { + // do not further split the particle if above the limit + if (p.n_split() >= settings::max_history_splits) + return; + + double n_split = std::ceil(weight / weight_window.upper_weight); + double max_split = weight_window.max_split; + n_split = std::min(n_split, max_split); + + p.n_split() += n_split; + + // Create secondaries and divide weight among all particles + int i_split = std::round(n_split); + for (int l = 0; l < i_split - 1; l++) { + p.create_secondary(weight / n_split, p.u(), p.E(), p.type()); + } + // remaining weight is applied to current particle + p.wgt() = weight / n_split; + + } else if (weight <= weight_window.lower_weight) { + // if the particle weight is below the window, play Russian roulette + double weight_survive = + std::min(weight * weight_window.max_split, weight_window.survival_weight); + russian_roulette(p, weight_survive); + } // else particle is in the window, continue as normal +} + +void free_memory_weight_windows() +{ + variance_reduction::ww_map.clear(); + variance_reduction::weight_windows.clear(); +} + //============================================================================== // WeightWindowSettings implementation //============================================================================== @@ -58,8 +147,8 @@ WeightWindows::WeightWindows(int32_t id) WeightWindows::WeightWindows(pugi::xml_node node) { // Make sure required elements are present - const vector required_elems { - "id", "particle_type", "lower_ww_bounds", "upper_ww_bounds"}; + const vector required_elems {"id", "particle_type", + "energy_bounds", "lower_ww_bounds", "upper_ww_bounds"}; for (const auto& elem : required_elems) { if (!check_for_node(node, elem.c_str())) { fatal_error(fmt::format("Must specify <{}> for weight windows.", elem)); @@ -72,11 +161,11 @@ WeightWindows::WeightWindows(pugi::xml_node node) // get the particle type auto particle_type_str = std::string(get_node_value(node, "particle_type")); - particle_type_ = ParticleType {particle_type_str}; + particle_type_ = openmc::str_to_particle_type(particle_type_str); // Determine associated mesh int32_t mesh_id = std::stoi(get_node_value(node, "mesh")); - set_mesh(model::mesh_map.at(mesh_id)); + mesh_idx_ = model::mesh_map.at(mesh_id); // energy bounds if (check_for_node(node, "energy_bounds")) @@ -145,7 +234,7 @@ WeightWindows* WeightWindows::from_hdf5( std::string particle_type; read_dataset(ww_group, "particle_type", particle_type); - wws->particle_type_ = ParticleType {particle_type}; + wws->particle_type_ = openmc::str_to_particle_type(particle_type); read_dataset(ww_group, "energy_bounds", wws->energy_bounds_); @@ -158,12 +247,8 @@ WeightWindows* WeightWindows::from_hdf5( } wws->set_mesh(model::mesh_map[mesh_id]); - wws->lower_ww_ = - tensor::Tensor({static_cast(wws->bounds_size()[0]), - static_cast(wws->bounds_size()[1])}); - wws->upper_ww_ = - tensor::Tensor({static_cast(wws->bounds_size()[0]), - static_cast(wws->bounds_size()[1])}); + wws->lower_ww_ = xt::empty(wws->bounds_size()); + wws->upper_ww_ = xt::empty(wws->bounds_size()); read_dataset(ww_group, "lower_ww_bounds", wws->lower_ww_); read_dataset(ww_group, "upper_ww_bounds", wws->upper_ww_); @@ -181,10 +266,7 @@ void WeightWindows::set_defaults() { // set energy bounds to the min/max energy supported by the data if (energy_bounds_.size() == 0) { - int p_type = particle_type_.transport_index(); - if (p_type == C_NONE) { - fatal_error("Weight windows particle is not supported for transport."); - } + int p_type = static_cast(particle_type_); energy_bounds_.push_back(data::energy_min[p_type]); energy_bounds_.push_back(data::energy_max[p_type]); } @@ -198,17 +280,15 @@ void WeightWindows::allocate_ww_bounds() "Size of weight window bounds is zero for WeightWindows {}", id()); warning(msg); } - lower_ww_ = tensor::Tensor( - {static_cast(shape[0]), static_cast(shape[1])}); + lower_ww_ = xt::empty(shape); lower_ww_.fill(-1); - upper_ww_ = tensor::Tensor( - {static_cast(shape[0]), static_cast(shape[1])}); + upper_ww_ = xt::empty(shape); upper_ww_.fill(-1); } void WeightWindows::set_id(int32_t id) { - assert(id >= 0 || id == C_NONE); + Expects(id >= 0 || id == C_NONE); // Clear entry in mesh map in case one was already assigned if (id_ != C_NONE) { @@ -236,7 +316,7 @@ void WeightWindows::set_id(int32_t id) variance_reduction::ww_map[id] = index_; } -void WeightWindows::set_energy_bounds(span bounds) +void WeightWindows::set_energy_bounds(gsl::span bounds) { energy_bounds_.clear(); energy_bounds_.insert(energy_bounds_.begin(), bounds.begin(), bounds.end()); @@ -247,9 +327,10 @@ void WeightWindows::set_energy_bounds(span bounds) void WeightWindows::set_particle_type(ParticleType p_type) { - if (!p_type.is_neutron() && !p_type.is_photon()) - fatal_error(fmt::format( - "Particle type '{}' cannot be applied to weight windows.", p_type.str())); + if (p_type != ParticleType::neutron && p_type != ParticleType::photon) + fatal_error( + fmt::format("Particle type '{}' cannot be applied to weight windows.", + particle_type_to_str(p_type))); particle_type_ = p_type; } @@ -259,7 +340,6 @@ void WeightWindows::set_mesh(int32_t mesh_idx) fatal_error(fmt::format("Could not find a mesh for index {}", mesh_idx)); mesh_idx_ = mesh_idx; - model::meshes[mesh_idx_]->prepare_for_point_location(); allocate_ww_bounds(); } @@ -273,28 +353,27 @@ void WeightWindows::set_mesh(const Mesh* mesh) set_mesh(model::mesh_map[mesh->id_]); } -std::pair WeightWindows::get_weight_window( - const Particle& p) const +WeightWindow WeightWindows::get_weight_window(const Particle& p) const { // check for particle type if (particle_type_ != p.type()) { - return {false, {}}; + return {}; } - // particle energy - double E = p.E(); - - // check to make sure energy is in range, expects sorted energy values - if (E < energy_bounds_.front() || E > energy_bounds_.back()) - return {false, {}}; - // Get mesh index for particle's position const auto& mesh = this->mesh(); int mesh_bin = mesh->get_bin(p.r()); // particle is outside the weight window mesh if (mesh_bin < 0) - return {false, {}}; + return {}; + + // particle energy + double E = p.E(); + + // check to make sure energy is in range, expects sorted energy values + if (E < energy_bounds_.front() || E > energy_bounds_.back()) + return {}; // get the mesh bin in energy group int energy_bin = @@ -309,7 +388,7 @@ std::pair WeightWindows::get_weight_window( ww.max_lb_ratio = max_lb_ratio_; ww.max_split = max_split_; ww.weight_cutoff = weight_cutoff_; - return {true, ww}; + return ww; } std::array WeightWindows::bounds_size() const @@ -348,8 +427,8 @@ void WeightWindows::check_bounds(const T& bounds) const } } -void WeightWindows::set_bounds(const tensor::Tensor& lower_bounds, - const tensor::Tensor& upper_bounds) +void WeightWindows::set_bounds(const xt::xtensor& lower_bounds, + const xt::xtensor& upper_bounds) { this->check_bounds(lower_bounds, upper_bounds); @@ -360,7 +439,7 @@ void WeightWindows::set_bounds(const tensor::Tensor& lower_bounds, } void WeightWindows::set_bounds( - const tensor::Tensor& lower_bounds, double ratio) + const xt::xtensor& lower_bounds, double ratio) { this->check_bounds(lower_bounds); @@ -371,60 +450,47 @@ void WeightWindows::set_bounds( } void WeightWindows::set_bounds( - span lower_bounds, span upper_bounds) + gsl::span lower_bounds, gsl::span upper_bounds) { check_bounds(lower_bounds, upper_bounds); auto shape = this->bounds_size(); - lower_ww_ = tensor::Tensor( - {static_cast(shape[0]), static_cast(shape[1])}); - upper_ww_ = tensor::Tensor( - {static_cast(shape[0]), static_cast(shape[1])}); + lower_ww_ = xt::empty(shape); + upper_ww_ = xt::empty(shape); - // Copy weight window values from input spans into the tensors - std::copy(lower_bounds.data(), lower_bounds.data() + lower_ww_.size(), - lower_ww_.data()); - std::copy(upper_bounds.data(), upper_bounds.data() + upper_ww_.size(), - upper_ww_.data()); + // set new weight window values + xt::view(lower_ww_, xt::all()) = + xt::adapt(lower_bounds.data(), lower_ww_.shape()); + xt::view(upper_ww_, xt::all()) = + xt::adapt(upper_bounds.data(), upper_ww_.shape()); } -void WeightWindows::set_bounds(span lower_bounds, double ratio) +void WeightWindows::set_bounds( + gsl::span lower_bounds, double ratio) { this->check_bounds(lower_bounds); auto shape = this->bounds_size(); - lower_ww_ = tensor::Tensor( - {static_cast(shape[0]), static_cast(shape[1])}); - upper_ww_ = tensor::Tensor( - {static_cast(shape[0]), static_cast(shape[1])}); + lower_ww_ = xt::empty(shape); + upper_ww_ = xt::empty(shape); - // Copy lower bounds into both arrays, then scale upper by ratio - std::copy(lower_bounds.data(), lower_bounds.data() + lower_ww_.size(), - lower_ww_.data()); - std::copy(lower_bounds.data(), lower_bounds.data() + upper_ww_.size(), - upper_ww_.data()); + // set new weight window values + xt::view(lower_ww_, xt::all()) = + xt::adapt(lower_bounds.data(), lower_ww_.shape()); + xt::view(upper_ww_, xt::all()) = + xt::adapt(lower_bounds.data(), upper_ww_.shape()); upper_ww_ *= ratio; } -void WeightWindows::update_weights(const Tally* tally, const std::string& value, - double threshold, double ratio, WeightWindowUpdateMethod method) +void WeightWindows::update_magic( + const Tally* tally, const std::string& value, double threshold, double ratio) { /////////////////////////// // Setup and checks /////////////////////////// this->check_tally_update_compatibility(tally); - // Dimensions of weight window arrays - int e_bins = lower_ww_.shape(0); - int64_t mesh_bins = lower_ww_.shape(1); - - // Initialize weight window arrays to -1.0 by default -#pragma omp parallel for collapse(2) schedule(static) - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - lower_ww_(e, m) = -1.0; - upper_ww_(e, m) = -1.0; - } - } + lower_ww_.fill(-1); + upper_ww_.fill(-1); // determine which value to use const std::set allowed_values = {"mean", "rel_err"}; @@ -446,17 +512,15 @@ void WeightWindows::update_weights(const Tally* tally, const std::string& value, /////////////////////////// // Extract tally data // - // At the end of this section, mean and rel_err are - // 2D tensors of tally data (n_e_groups, n_mesh_bins) + // At the end of this section, the mean and rel_err array + // is a 2D view of tally data (n_e_groups, n_mesh_bins) // /////////////////////////// - // build a shape for the tally results, this will always be + // build a shape for a view of the tally results, this will always be // dimension 5 (3 filter dimensions, 1 score dimension, 1 results dimension) - // Look for the size of the last dimension of the results tensor - const auto& results = tally->results(); - const int results_dim = static_cast(results.shape(2)); - std::array shape = {1, 1, 1, tally->n_scores(), results_dim}; + std::array shape = { + 1, 1, 1, tally->n_scores(), static_cast(TallyResult::SIZE)}; // set the shape for the filters applied on the tally for (int i = 0; i < tally->filters().size(); i++) { @@ -492,61 +556,42 @@ void WeightWindows::update_weights(const Tally* tally, const std::string& value, std::find(filter_types.begin(), filter_types.end(), FilterType::MESH) - filter_types.begin(); - // determine the index of the particle within its filter + // get a fully reshaped view of the tally according to tally ordering of + // filters + auto tally_values = xt::reshape_view(tally->results(), shape); + + // get a that is (particle, energy, mesh, scores, values) + auto transposed_view = xt::transpose(tally_values, transpose); + + // determine the dimension and index of the particle data int particle_idx = 0; if (tally->has_filter(FilterType::PARTICLE)) { + // get the particle filter auto pf = tally->get_filter(); const auto& particles = pf->particles(); + // find the index of the particle that matches these weight windows auto p_it = std::find(particles.begin(), particles.end(), this->particle_type_); + // if the particle filter doesn't have particle data for the particle + // used on this weight windows instance, report an error if (p_it == particles.end()) { auto msg = fmt::format("Particle type '{}' not present on Filter {} for " "Tally {} used to update WeightWindows {}", - this->particle_type_.str(), pf->id(), tally->id(), this->id()); + particle_type_to_str(this->particle_type_), pf->id(), tally->id(), + this->id()); fatal_error(msg); } + // use the index of the particle in the filter to down-select data later particle_idx = p_it - particles.begin(); } - // The tally results array is 3D: (n_filter_combos, n_scores, n_result_types). - // The first dimension is a row-major flattening of up to 3 filter dimensions - // (particle, energy, mesh) whose storage order depends on which filters the - // tally has. We need to map our desired indices (particle, energy, mesh) - // into the correct flat filter combination index. - // - // transpose[i] tells us which storage position holds dimension i: - // i=0 -> particle, i=1 -> energy, i=2 -> mesh - // shape[j] gives the number of bins for filter storage position j. - - // Row-major strides for the 3 filter dimensions - const int stride0 = shape[1] * shape[2]; - const int stride1 = shape[2]; - - tensor::Tensor sum( - {static_cast(e_bins), static_cast(mesh_bins)}); - tensor::Tensor sum_sq( - {static_cast(e_bins), static_cast(mesh_bins)}); - - const int i_sum = static_cast(TallyResult::SUM); - const int i_sum_sq = static_cast(TallyResult::SUM_SQ); - - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - // Place particle, energy, and mesh indices into their storage positions - std::array idx = {0, 0, 0}; - idx[transpose[0]] = particle_idx; - idx[transpose[1]] = e; - idx[transpose[2]] = static_cast(m); - - // Compute flat filter combination index (row-major over filter dims) - int flat = idx[0] * stride0 + idx[1] * stride1 + idx[2]; - - sum(e, m) = results(flat, score_index, i_sum); - sum_sq(e, m) = results(flat, score_index, i_sum_sq); - } - } + // down-select data based on particle and score + auto sum = xt::view(transposed_view, particle_idx, xt::all(), xt::all(), + score_index, static_cast(TallyResult::SUM)); + auto sum_sq = xt::view(transposed_view, particle_idx, xt::all(), xt::all(), + score_index, static_cast(TallyResult::SUM_SQ)); int n = tally->n_realizations_; ////////////////////////////////////////////// @@ -564,117 +609,47 @@ void WeightWindows::update_weights(const Tally* tally, const std::string& value, auto& new_bounds = this->lower_ww_; auto& rel_err = this->upper_ww_; + // noalias avoids memory allocation here + xt::noalias(new_bounds) = sum / n; + + xt::noalias(rel_err) = + xt::sqrt(((sum_sq / n) - xt::square(new_bounds)) / (n - 1)) / new_bounds; + xt::filter(rel_err, sum <= 0.0).fill(INFTY); + + if (value == "rel_err") + xt::noalias(new_bounds) = 1 / rel_err; + // get mesh volumes auto mesh_vols = this->mesh()->volumes(); - // Calculate mean (new_bounds) and relative error -#pragma omp parallel for collapse(2) schedule(static) + int e_bins = new_bounds.shape()[0]; for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - // Calculate mean - new_bounds(e, m) = sum(e, m) / n; - // Calculate relative error - if (sum(e, m) > 0.0) { - double mean_val = new_bounds(e, m); - double variance = (sum_sq(e, m) / n - mean_val * mean_val) / (n - 1); - rel_err(e, m) = std::sqrt(variance) / mean_val; - } else { - rel_err(e, m) = INFTY; - } - if (value == "rel_err") { - new_bounds(e, m) = 1.0 / rel_err(e, m); - } + // select all + auto group_view = xt::view(new_bounds, e); + + // divide by volume of mesh elements + for (int i = 0; i < group_view.size(); i++) { + group_view[i] /= mesh_vols[i]; } + + double group_max = *std::max_element(group_view.begin(), group_view.end()); + // normalize values in this energy group by the maximum value for this + // group + if (group_max > 0.0) + group_view /= 2.0 * group_max; } - // Divide by volume of mesh elements -#pragma omp parallel for collapse(2) schedule(static) - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - new_bounds(e, m) /= mesh_vols[m]; - } - } + // make sure that values where the mean is zero are set s.t. the weight window + // value will be ignored + xt::filter(new_bounds, sum <= 0.0).fill(-1.0); - if (method == WeightWindowUpdateMethod::MAGIC) { - // For MAGIC, weight windows are proportional to the forward fluxes. - // We normalize weight windows independently for each energy group. + // make sure the weight windows are ignored for any locations where the + // relative error is higher than the specified relative error threshold + xt::filter(new_bounds, rel_err > threshold).fill(-1.0); - // Find group maximum and normalize (per energy group) - for (int e = 0; e < e_bins; e++) { - double group_max = 0.0; - - // Find maximum value across all elements in this energy group -#pragma omp parallel for schedule(static) reduction(max : group_max) - for (int64_t m = 0; m < mesh_bins; m++) { - if (new_bounds(e, m) > group_max) { - group_max = new_bounds(e, m); - } - } - - // Normalize values in this energy group by the maximum value - if (group_max > 0.0) { - double norm_factor = 1.0 / (2.0 * group_max); -#pragma omp parallel for schedule(static) - for (int64_t m = 0; m < mesh_bins; m++) { - new_bounds(e, m) *= norm_factor; - } - } - } - } else { - // For (FW-)CADIS, weight windows are inversely proportional to the adjoint - // fluxes. We normalize the weight windows across all energy groups. -#pragma omp parallel for collapse(2) schedule(static) - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - // Take the inverse, but are careful not to divide by zero - if (new_bounds(e, m) != 0.0) { - new_bounds(e, m) = 1.0 / new_bounds(e, m); - } else { - new_bounds(e, m) = 0.0; - } - } - } - - // Find the maximum value across all elements - double max_val = 0.0; -#pragma omp parallel for collapse(2) schedule(static) reduction(max : max_val) - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - if (new_bounds(e, m) > max_val) { - max_val = new_bounds(e, m); - } - } - } - - // Parallel normalization - if (max_val > 0.0) { - double norm_factor = 1.0 / (2.0 * max_val); -#pragma omp parallel for collapse(2) schedule(static) - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - new_bounds(e, m) *= norm_factor; - } - } - } - } - - // Final processing -#pragma omp parallel for collapse(2) schedule(static) - for (int e = 0; e < e_bins; e++) { - for (int64_t m = 0; m < mesh_bins; m++) { - // Values where the mean is zero should be ignored - if (sum(e, m) <= 0.0) { - new_bounds(e, m) = -1.0; - } - // Values where the relative error is higher than the threshold should be - // ignored - else if (rel_err(e, m) > threshold) { - new_bounds(e, m) = -1.0; - } - // Set the upper bounds - upper_ww_(e, m) = ratio * lower_ww_(e, m); - } - } + // update the bounds of this weight window class + // noalias avoids additional memory allocation + xt::noalias(upper_ww_) = ratio * lower_ww_; } void WeightWindows::check_tally_update_compatibility(const Tally* tally) @@ -741,7 +716,8 @@ void WeightWindows::to_hdf5(hid_t group) const hid_t ww_group = create_group(group, fmt::format("weight_windows_{}", id())); write_dataset(ww_group, "mesh", this->mesh()->id()); - write_dataset(ww_group, "particle_type", particle_type_.str()); + write_dataset( + ww_group, "particle_type", openmc::particle_type_to_str(particle_type_)); write_dataset(ww_group, "energy_bounds", energy_bounds_); write_dataset(ww_group, "lower_ww_bounds", lower_ww_); write_dataset(ww_group, "upper_ww_bounds", upper_ww_); @@ -760,7 +736,7 @@ WeightWindowsGenerator::WeightWindowsGenerator(pugi::xml_node node) int32_t mesh_idx = model::mesh_map[mesh_id]; max_realizations_ = std::stoi(get_node_value(node, "max_realizations")); - int32_t active_batches = settings::n_batches - settings::n_inactive; + int active_batches = settings::n_batches - settings::n_inactive; if (max_realizations_ > active_batches) { auto msg = fmt::format("The maximum number of specified tally realizations ({}) is " @@ -768,8 +744,8 @@ WeightWindowsGenerator::WeightWindowsGenerator(pugi::xml_node node) max_realizations_, active_batches); warning(msg); } - auto tmp_str = get_node_value(node, "particle_type", false, true); - auto particle_type = ParticleType {tmp_str}; + auto tmp_str = get_node_value(node, "particle_type", true, true); + auto particle_type = str_to_particle_type(tmp_str); update_interval_ = std::stoi(get_node_value(node, "update_interval")); on_the_fly_ = get_node_value_bool(node, "on_the_fly"); @@ -778,68 +754,43 @@ WeightWindowsGenerator::WeightWindowsGenerator(pugi::xml_node node) if (check_for_node(node, "energy_bounds")) { e_bounds = get_node_array(node, "energy_bounds"); } else { - int p_type = particle_type.transport_index(); - if (p_type == C_NONE) { - fatal_error("Weight windows particle is not supported for transport."); - } + int p_type = static_cast(particle_type); e_bounds.push_back(data::energy_min[p_type]); e_bounds.push_back(data::energy_max[p_type]); } - // set method - std::string method_string = get_node_value(node, "method"); - if (method_string == "magic") { - method_ = WeightWindowUpdateMethod::MAGIC; - if (settings::solver_type == SolverType::RANDOM_RAY && - FlatSourceDomain::adjoint_requested_) { - fatal_error("Random ray weight window generation with MAGIC cannot be " - "done in adjoint mode."); + // set method and parameters for updates + method_ = get_node_value(node, "method"); + if (method_ == "magic") { + // parse non-default update parameters if specified + if (check_for_node(node, "update_parameters")) { + pugi::xml_node params_node = node.child("update_parameters"); + if (check_for_node(params_node, "value")) + tally_value_ = get_node_value(params_node, "value"); + if (check_for_node(params_node, "threshold")) + threshold_ = std::stod(get_node_value(params_node, "threshold")); + if (check_for_node(params_node, "ratio")) { + ratio_ = std::stod(get_node_value(params_node, "ratio")); + } } - } else if (method_string == "fw_cadis") { - method_ = WeightWindowUpdateMethod::FW_CADIS; - if (settings::solver_type != SolverType::RANDOM_RAY) { - fatal_error("FW-CADIS can only be run in random ray solver mode."); - } - FlatSourceDomain::adjoint_requested_ = true; - if (check_for_node(node, "targets")) { - FlatSourceDomain::fw_cadis_local_ = true; - targets_ = get_node_array(node, "targets"); - FlatSourceDomain::fw_cadis_local_targets_.insert( - std::end(FlatSourceDomain::fw_cadis_local_targets_), - std::begin(targets_), std::end(targets_)); + // check update parameter values + if (tally_value_ != "mean" && tally_value_ != "rel_err") { + fatal_error(fmt::format("Unsupported tally value '{}' specified for " + "weight window generation.", + tally_value_)); } + if (threshold_ <= 0.0) + fatal_error(fmt::format("Invalid relative error threshold '{}' (<= 0.0) " + "specified for weight window generation", + ratio_)); + if (ratio_ <= 1.0) + fatal_error(fmt::format("Invalid weight window ratio '{}' (<= 1.0) " + "specified for weight window generation")); } else { fatal_error(fmt::format( - "Unknown weight window update method '{}' specified", method_string)); + "Unknown weight window update method '{}' specified", method_)); } - // parse non-default update parameters if specified - if (check_for_node(node, "update_parameters")) { - pugi::xml_node params_node = node.child("update_parameters"); - if (check_for_node(params_node, "value")) - tally_value_ = get_node_value(params_node, "value"); - if (check_for_node(params_node, "threshold")) - threshold_ = std::stod(get_node_value(params_node, "threshold")); - if (check_for_node(params_node, "ratio")) { - ratio_ = std::stod(get_node_value(params_node, "ratio")); - } - } - - // check update parameter values - if (tally_value_ != "mean" && tally_value_ != "rel_err") { - fatal_error(fmt::format("Unsupported tally value '{}' specified for " - "weight window generation.", - tally_value_)); - } - if (threshold_ <= 0.0) - fatal_error(fmt::format("Invalid relative error threshold '{}' (<= 0.0) " - "specified for weight window generation", - ratio_)); - if (ratio_ <= 1.0) - fatal_error(fmt::format("Invalid weight window ratio '{}' (<= 1.0) " - "specified for weight window generation", - ratio_)); - // create a matching weight windows object auto wws = WeightWindows::create(); ww_idx_ = wws->index(); @@ -866,8 +817,7 @@ void WeightWindowsGenerator::create_tally() for (const auto& f : model::tally_filters) { if (f->type() == FilterType::MESH) { const auto* mesh_filter = dynamic_cast(f.get()); - if (mesh_filter->mesh() == mesh_idx && !mesh_filter->translated() && - !mesh_filter->rotated()) { + if (mesh_filter->mesh() == mesh_idx && !mesh_filter->translated()) { ww_tally->add_filter(f.get()); found_mesh_filter = true; break; @@ -903,19 +853,13 @@ void WeightWindowsGenerator::update() const Tally* tally = model::tallies[tally_idx_].get(); - // If in random ray mode, only update on the last batch - if (settings::solver_type == SolverType::RANDOM_RAY) { - if (simulation::current_batch != settings::n_batches) { - return; - } - // If in Monte Carlo mode and beyond the number of max realizations or - // not at the correct update interval, skip the update - } else if (max_realizations_ < tally->n_realizations_ || - tally->n_realizations_ % update_interval_ != 0) { + // if we're beyond the number of max realizations or not at the corrrect + // update interval, skip the update + if (max_realizations_ < tally->n_realizations_ || + tally->n_realizations_ % update_interval_ != 0) return; - } - wws->update_weights(tally, tally_value_, threshold_, ratio_, method_); + wws->update_magic(tally, tally_value_, threshold_, ratio_); // if we're not doing on the fly generation, reset the tally results once // we're done with the update @@ -930,134 +874,6 @@ void WeightWindowsGenerator::update() const // Non-member functions //============================================================================== -std::pair search_weight_window(const Particle& p) -{ - // TODO: this is a linear search - should do something more clever - for (const auto& ww : variance_reduction::weight_windows) { - auto [ww_found, weight_window] = ww->get_weight_window(p); - if (ww_found) - return {true, weight_window}; - } - return {false, {}}; -} - -void apply_weight_windows(Particle& p) -{ - if (!settings::weight_windows_on) - return; - - // Random ray rays are not Monte Carlo particles and must not be biased by - // weight windows; the solver generates weight windows but never applies them - if (settings::solver_type == SolverType::RANDOM_RAY) - return; - - // WW on photon and neutron only - if (!p.type().is_neutron() && !p.type().is_photon()) - return; - - // skip dead or no energy - if (p.E() <= 0 || !p.alive()) - return; - - auto [ww_found, ww] = search_weight_window(p); - if (ww_found && ww.is_valid()) { - apply_weight_window(p, ww); - } else { - if (p.wgt_ww_born() == -1.0) - p.wgt_ww_born() = 1.0; - } -} - -void apply_weight_window(Particle& p, WeightWindow weight_window) -{ - if (!weight_window.is_valid()) - return; - - // skip dead or no energy - if (p.E() <= 0 || !p.alive()) - return; - - // If particle has not yet had its birth weight window value set, set it to - // the current weight window. - if (p.wgt_ww_born() == -1.0) - p.wgt_ww_born() = - (weight_window.lower_weight + weight_window.upper_weight) / 2; - - // Normalize weight windows based on particle's starting weight - // and the value of the weight window the particle was born in. - weight_window.scale(p.wgt_born() / p.wgt_ww_born()); - - // get the paramters - double weight = p.wgt(); - - // first check to see if particle should be killed for weight cutoff - if (p.wgt() < weight_window.weight_cutoff) { - p.wgt() = 0.0; - return; - } - - // check if particle is far above current weight window - // only do this if the factor is not already set on the particle and a - // maximum lower bound ratio is specified - if (p.ww_factor() == 0.0 && weight_window.max_lb_ratio > 1.0 && - p.wgt() > weight_window.lower_weight * weight_window.max_lb_ratio) { - p.ww_factor() = - p.wgt() / (weight_window.lower_weight * weight_window.max_lb_ratio); - } - - // move weight window closer to the particle weight if needed - if (p.ww_factor() > 1.0) - weight_window.scale(p.ww_factor()); - - // If the particle's weight is above the weight window, split it until the - // resulting particles are within the window. The comparisons use a relative - // dead band so that the branch taken is insensitive to bit-level differences - // in the window bounds (see WEIGHT_WINDOW_REL_TOL). - if (weight > weight_window.upper_weight * (1.0 + WEIGHT_WINDOW_REL_TOL)) { - // do not further split the particle if above the limit - if (p.n_split() >= settings::max_history_splits) - return; - - // Dividing by the same dead-banded bound used in the branch condition - // keeps the number of splits stable when the weight-to-bound ratio sits - // within rounding of an exact integer, which the weight window arithmetic - // itself can produce (e.g., a roulette survivor assigned weight * - // max_split, later split against an upper bound that is an exact multiple - // of the same lower bound). Ratios within the dead band of an integer - // consistently round down, and the branch condition guarantees the ratio - // exceeds one; the lower clamp of 2 makes the always-splits invariant - // explicit. - double n_split = std::max(2.0, - std::ceil( - weight / ((1.0 + WEIGHT_WINDOW_REL_TOL) * weight_window.upper_weight))); - double max_split = weight_window.max_split; - n_split = std::min(n_split, max_split); - - p.n_split() += n_split; - - // Create secondaries and divide weight among all particles - int i_split = std::round(n_split); - for (int l = 0; l < i_split - 1; l++) { - p.split(weight / n_split); - } - // remaining weight is applied to current particle - p.wgt() = weight / n_split; - - } else if (weight < - weight_window.lower_weight * (1.0 - WEIGHT_WINDOW_REL_TOL)) { - // if the particle weight is below the window, play Russian roulette - double weight_survive = - std::min(weight * weight_window.max_split, weight_window.survival_weight); - russian_roulette(p, weight_survive); - } // else particle is in the window, continue as normal -} - -void free_memory_weight_windows() -{ - variance_reduction::ww_map.clear(); - variance_reduction::weight_windows.clear(); -} - void finalize_variance_reduction() { for (const auto& wwg : variance_reduction::weight_windows_generators) { @@ -1127,7 +943,7 @@ extern "C" int openmc_weight_windows_update_magic(int32_t ww_idx, // get the WeightWindows object const auto& wws = variance_reduction::weight_windows.at(ww_idx); - wws->update_weights(tally, value, threshold, ratio); + wws->update_magic(tally, value, threshold, ratio); return 0; } @@ -1171,25 +987,23 @@ extern "C" int openmc_weight_windows_get_energy_bounds( return 0; } -extern "C" int openmc_weight_windows_set_particle( - int32_t index, int32_t particle) +extern "C" int openmc_weight_windows_set_particle(int32_t index, int particle) { if (int err = verify_ww_index(index)) return err; const auto& wws = variance_reduction::weight_windows.at(index); - wws->set_particle_type(ParticleType {particle}); + wws->set_particle_type(static_cast(particle)); return 0; } -extern "C" int openmc_weight_windows_get_particle( - int32_t index, int32_t* particle) +extern "C" int openmc_weight_windows_get_particle(int32_t index, int* particle) { if (int err = verify_ww_index(index)) return err; const auto& wws = variance_reduction::weight_windows.at(index); - *particle = wws->particle_type().pdg_number(); + *particle = static_cast(wws->particle_type()); return 0; } @@ -1213,8 +1027,7 @@ extern "C" int openmc_weight_windows_set_bounds(int32_t index, return err; const auto& wws = variance_reduction::weight_windows[index]; - wws->set_bounds(span(lower_bounds, size), - span(upper_bounds, size)); + wws->set_bounds({lower_bounds, size}, {upper_bounds, size}); return 0; } @@ -1402,10 +1215,6 @@ extern "C" int openmc_weight_windows_import(const char* filename) hid_t weight_windows_group = open_group(ww_file, "weight_windows"); - hid_t mesh_group = open_group(ww_file, "meshes"); - - read_meshes(mesh_group); - std::vector names = group_names(weight_windows_group); for (const auto& name : names) { diff --git a/src/wmp.cpp b/src/wmp.cpp index 6f72e1ba4..e9c4fb5e3 100644 --- a/src/wmp.cpp +++ b/src/wmp.cpp @@ -33,22 +33,22 @@ WindowedMultipole::WindowedMultipole(hid_t group) // Read the "data" array. Use its shape to figure out the number of poles // and residue types in this data. read_dataset(group, "data", data_); - int n_residues = data_.shape(1) - 1; + int n_residues = data_.shape()[1] - 1; // Check to see if this data includes fission residues. fissionable_ = (n_residues == 3); // Read the "windows" array and use its shape to figure out the number of // windows. - tensor::Tensor windows; + xt::xtensor windows; read_dataset(group, "windows", windows); - int n_windows = windows.shape(0); + int n_windows = windows.shape()[0]; windows -= 1; // Adjust to 0-based indices // Read the "broaden_poly" arrays. - tensor::Tensor broaden_poly; + xt::xtensor broaden_poly; read_dataset(group, "broaden_poly", broaden_poly); - if (n_windows != broaden_poly.shape(0)) { + if (n_windows != broaden_poly.shape()[0]) { fatal_error("broaden_poly array shape is not consistent with the windows " "array shape in WMP library for " + name_ + "."); @@ -56,12 +56,12 @@ WindowedMultipole::WindowedMultipole(hid_t group) // Read the "curvefit" array. read_dataset(group, "curvefit", curvefit_); - if (n_windows != curvefit_.shape(0)) { + if (n_windows != curvefit_.shape()[0]) { fatal_error("curvefit array shape is not consistent with the windows " "array shape in WMP library for " + name_ + "."); } - fit_order_ = curvefit_.shape(1) - 1; + fit_order_ = curvefit_.shape()[1] - 1; // Check the code is compiling to work with sufficiently high fit order if (fit_order_ + 1 > MAX_POLY_COEFFICIENTS) { diff --git a/src/xml_interface.cpp b/src/xml_interface.cpp index 840d3f5b8..6ce465baf 100644 --- a/src/xml_interface.cpp +++ b/src/xml_interface.cpp @@ -4,7 +4,6 @@ #include "openmc/error.h" #include "openmc/string_utils.h" -#include "openmc/vector.h" namespace openmc { @@ -49,24 +48,6 @@ bool get_node_value_bool(pugi::xml_node node, const char* name) return false; } -vector get_node_position_array( - pugi::xml_node node, const char* name, bool lowercase) -{ - vector coords = get_node_array(node, name, lowercase); - if (coords.size() % 3 != 0) { - fatal_error(fmt::format( - "Incorect number of coordinates in Position array ({}) for \"{}\"", - coords.size(), name)); - } - vector positions; - positions.reserve(coords.size() / 3); - auto it = coords.begin(); - for (size_t i = 0; i < coords.size(); i += 3) { - positions.push_back({coords[i], coords[i + 1], coords[i + 2]}); - } - return positions; -} - Position get_node_position( pugi::xml_node node, const char* name, bool lowercase) { diff --git a/src/xsdata.cpp b/src/xsdata.cpp index 33d063a7b..1929f51e6 100644 --- a/src/xsdata.cpp +++ b/src/xsdata.cpp @@ -5,7 +5,10 @@ #include #include -#include "openmc/tensor.h" +#include "xtensor/xbuilder.hpp" +#include "xtensor/xindex_view.hpp" +#include "xtensor/xmath.hpp" +#include "xtensor/xview.hpp" #include "openmc/constants.h" #include "openmc/error.h" @@ -34,32 +37,32 @@ XsData::XsData(bool fissionable, AngleDistributionType scatter_format, } // allocate all [temperature][angle][in group] quantities vector shape {n_ang, n_g_}; - total = tensor::zeros(shape); - absorption = tensor::zeros(shape); - inverse_velocity = tensor::zeros(shape); + total = xt::zeros(shape); + absorption = xt::zeros(shape); + inverse_velocity = xt::zeros(shape); if (fissionable) { - fission = tensor::zeros(shape); - nu_fission = tensor::zeros(shape); - prompt_nu_fission = tensor::zeros(shape); - kappa_fission = tensor::zeros(shape); + fission = xt::zeros(shape); + nu_fission = xt::zeros(shape); + prompt_nu_fission = xt::zeros(shape); + kappa_fission = xt::zeros(shape); } // allocate decay_rate; [temperature][angle][delayed group] shape[1] = n_dg_; - decay_rate = tensor::zeros(shape); + decay_rate = xt::zeros(shape); if (fissionable) { shape = {n_ang, n_dg_, n_g_}; // allocate delayed_nu_fission; [temperature][angle][delay group][in group] - delayed_nu_fission = tensor::zeros(shape); + delayed_nu_fission = xt::zeros(shape); // chi_prompt; [temperature][angle][in group][out group] shape = {n_ang, n_g_, n_g_}; - chi_prompt = tensor::zeros(shape); + chi_prompt = xt::zeros(shape); // chi_delayed; [temperature][angle][delay group][in group][out group] shape = {n_ang, n_dg_, n_g_, n_g_}; - chi_delayed = tensor::zeros(shape); + chi_delayed = xt::zeros(shape); } for (int a = 0; a < n_ang; a++) { @@ -82,30 +85,28 @@ void XsData::from_hdf5(hid_t xsdata_grp, bool fissionable, { // Reconstruct the dimension information so it doesn't need to be passed size_t n_ang = n_pol * n_azi; - size_t energy_groups = total.shape(1); + size_t energy_groups = total.shape()[1]; // Set the fissionable-specific data if (fissionable) { fission_from_hdf5(xsdata_grp, n_ang, is_isotropic); } // Get the non-fission-specific data - read_nd_tensor(xsdata_grp, "decay-rate", decay_rate); - read_nd_tensor(xsdata_grp, "absorption", absorption, true); - read_nd_tensor(xsdata_grp, "inverse-velocity", inverse_velocity); + read_nd_vector(xsdata_grp, "decay-rate", decay_rate); + read_nd_vector(xsdata_grp, "absorption", absorption, true); + read_nd_vector(xsdata_grp, "inverse-velocity", inverse_velocity); // Get scattering data scatter_from_hdf5( xsdata_grp, n_ang, scatter_format, final_scatter_format, order_data); - // Replace zero absorption values with a small number to avoid - // division by zero in tally methods - for (size_t i = 0; i < absorption.size(); i++) - if (absorption.data()[i] == 0.0) - absorption.data()[i] = 1.e-10; + // Check absorption to ensure it is not 0 since it is often the + // denominator in tally methods + xt::filtration(absorption, xt::equal(absorption, 0.)) = 1.e-10; // Get or calculate the total x/s if (object_exists(xsdata_grp, "total")) { - read_nd_tensor(xsdata_grp, "total", total); + read_nd_vector(xsdata_grp, "total", total); } else { for (size_t a = 0; a < n_ang; a++) { for (size_t gin = 0; gin < energy_groups; gin++) { @@ -114,11 +115,8 @@ void XsData::from_hdf5(hid_t xsdata_grp, bool fissionable, } } - // Replace zero total cross sections with a small number to avoid - // division by zero in tally methods - for (size_t i = 0; i < total.size(); i++) - if (total.data()[i] == 0.0) - total.data()[i] = 1.e-10; + // Fix if total is 0, since it is in the denominator when tallying + xt::filtration(total, xt::equal(total, 0.)) = 1.e-10; } //============================================================================== @@ -129,30 +127,21 @@ void XsData::fission_vector_beta_from_hdf5( // Data is provided as nu-fission and chi with a beta for delayed info // Get chi - tensor::Tensor temp_chi = tensor::zeros({n_ang, n_g_}); - read_nd_tensor(xsdata_grp, "chi", temp_chi, true); + xt::xtensor temp_chi({n_ang, n_g_}, 0.); + read_nd_vector(xsdata_grp, "chi", temp_chi, true); - // Normalize chi so it sums to 1 over outgoing groups for each angle - for (size_t a = 0; a < n_ang; a++) { - tensor::View row = temp_chi.slice(a); - row /= row.sum(); - } + // Normalize chi by summing over the outgoing groups for each incoming angle + temp_chi /= xt::view(xt::sum(temp_chi, {1}), xt::all(), xt::newaxis()); - // Replicate the energy spectrum across all incoming groups — the - // spectrum is independent of the incoming neutron energy - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - chi_prompt.slice(a, gin) = temp_chi.slice(a); - - // Same spectrum for delayed neutrons, replicated across delayed groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t gin = 0; gin < n_g_; gin++) - chi_delayed.slice(a, d, gin) = temp_chi.slice(a); + // Now every incoming group in prompt_chi and delayed_chi is the normalized + // chi we just made + chi_prompt = xt::view(temp_chi, xt::all(), xt::newaxis(), xt::all()); + chi_delayed = + xt::view(temp_chi, xt::all(), xt::newaxis(), xt::newaxis(), xt::all()); // Get nu-fission - tensor::Tensor temp_nufiss = tensor::zeros({n_ang, n_g_}); - read_nd_tensor(xsdata_grp, "nu-fission", temp_nufiss, true); + xt::xtensor temp_nufiss({n_ang, n_g_}, 0.); + read_nd_vector(xsdata_grp, "nu-fission", temp_nufiss, true); // Get beta (strategy will depend upon the number of dimensions in beta) hid_t beta_dset = open_dataset(xsdata_grp, "beta"); @@ -162,39 +151,26 @@ void XsData::fission_vector_beta_from_hdf5( if (!is_isotropic) ndim_target += 2; if (beta_ndims == ndim_target) { - tensor::Tensor temp_beta = tensor::zeros({n_ang, n_dg_}); - read_nd_tensor(xsdata_grp, "beta", temp_beta, true); + xt::xtensor temp_beta({n_ang, n_dg_}, 0.); + read_nd_vector(xsdata_grp, "beta", temp_beta, true); - // prompt_nu_fission = (1 - sum_of_beta) * nu_fission - auto beta_sum = temp_beta.sum(1); - for (size_t a = 0; a < n_ang; a++) - for (size_t g = 0; g < n_g_; g++) - prompt_nu_fission(a, g) = temp_nufiss(a, g) * (1.0 - beta_sum(a)); + // Set prompt_nu_fission = (1. - beta_total)*nu_fission + prompt_nu_fission = temp_nufiss * (1. - xt::sum(temp_beta, {1})); - // Delayed nu-fission is the outer product of the delayed neutron - // fraction (beta) and the fission production rate (nu-fission) - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t g = 0; g < n_g_; g++) - delayed_nu_fission(a, d, g) = temp_beta(a, d) * temp_nufiss(a, g); + // Set delayed_nu_fission as beta * nu_fission + delayed_nu_fission = + xt::view(temp_beta, xt::all(), xt::all(), xt::newaxis()) * + xt::view(temp_nufiss, xt::all(), xt::newaxis(), xt::all()); } else if (beta_ndims == ndim_target + 1) { - tensor::Tensor temp_beta = - tensor::zeros({n_ang, n_dg_, n_g_}); - read_nd_tensor(xsdata_grp, "beta", temp_beta, true); + xt::xtensor temp_beta({n_ang, n_dg_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "beta", temp_beta, true); - // prompt_nu_fission = (1 - sum_of_beta) * nu_fission - // Here beta is energy-dependent, so sum over delayed groups (axis 1) - auto beta_sum = temp_beta.sum(1); - for (size_t a = 0; a < n_ang; a++) - for (size_t g = 0; g < n_g_; g++) - prompt_nu_fission(a, g) = temp_nufiss(a, g) * (1.0 - beta_sum(a, g)); + // Set prompt_nu_fission = (1. - beta_total)*nu_fission + prompt_nu_fission = temp_nufiss * (1. - xt::sum(temp_beta, {1})); - // Delayed nu-fission: beta is already energy-dependent [n_ang, n_dg, n_g], - // so scale each delayed group's beta by the total nu-fission for that group - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t g = 0; g < n_g_; g++) - delayed_nu_fission(a, d, g) = temp_beta(a, d, g) * temp_nufiss(a, g); + // Set delayed_nu_fission as beta * nu_fission + delayed_nu_fission = + temp_beta * xt::view(temp_nufiss, xt::all(), xt::newaxis(), xt::all()); } } @@ -203,42 +179,29 @@ void XsData::fission_vector_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang) // Data is provided separately as prompt + delayed nu-fission and chi // Get chi-prompt - tensor::Tensor temp_chi_p = tensor::zeros({n_ang, n_g_}); - read_nd_tensor(xsdata_grp, "chi-prompt", temp_chi_p, true); + xt::xtensor temp_chi_p({n_ang, n_g_}, 0.); + read_nd_vector(xsdata_grp, "chi-prompt", temp_chi_p, true); - // Normalize prompt chi so it sums to 1 over outgoing groups for each angle - for (size_t a = 0; a < n_ang; a++) { - tensor::View row = temp_chi_p.slice(a); - row /= row.sum(); - } + // Normalize chi by summing over the outgoing groups for each incoming angle + temp_chi_p /= xt::view(xt::sum(temp_chi_p, {1}), xt::all(), xt::newaxis()); // Get chi-delayed - tensor::Tensor temp_chi_d = - tensor::zeros({n_ang, n_dg_, n_g_}); - read_nd_tensor(xsdata_grp, "chi-delayed", temp_chi_d, true); + xt::xtensor temp_chi_d({n_ang, n_dg_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "chi-delayed", temp_chi_d, true); - // Normalize delayed chi so it sums to 1 over outgoing groups for each - // angle and delayed group - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) { - tensor::View row = temp_chi_d.slice(a, d); - row /= row.sum(); - } + // Normalize chi by summing over the outgoing groups for each incoming angle + temp_chi_d /= + xt::view(xt::sum(temp_chi_d, {2}), xt::all(), xt::all(), xt::newaxis()); - // Replicate the prompt spectrum across all incoming groups - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - chi_prompt.slice(a, gin) = temp_chi_p.slice(a); - - // Replicate the delayed spectrum across all incoming groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t gin = 0; gin < n_g_; gin++) - chi_delayed.slice(a, d, gin) = temp_chi_d.slice(a, d); + // Now assign the prompt and delayed chis by replicating for each incoming + // group + chi_prompt = xt::view(temp_chi_p, xt::all(), xt::newaxis(), xt::all()); + chi_delayed = + xt::view(temp_chi_d, xt::all(), xt::all(), xt::newaxis(), xt::all()); // Get prompt and delayed nu-fission directly - read_nd_tensor(xsdata_grp, "prompt-nu-fission", prompt_nu_fission, true); - read_nd_tensor(xsdata_grp, "delayed-nu-fission", delayed_nu_fission, true); + read_nd_vector(xsdata_grp, "prompt-nu-fission", prompt_nu_fission, true); + read_nd_vector(xsdata_grp, "delayed-nu-fission", delayed_nu_fission, true); } void XsData::fission_vector_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang) @@ -247,22 +210,17 @@ void XsData::fission_vector_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang) // Therefore, the code only considers the data as prompt. // Get chi - tensor::Tensor temp_chi = tensor::zeros({n_ang, n_g_}); - read_nd_tensor(xsdata_grp, "chi", temp_chi, true); + xt::xtensor temp_chi({n_ang, n_g_}, 0.); + read_nd_vector(xsdata_grp, "chi", temp_chi, true); - // Normalize chi so it sums to 1 over outgoing groups for each angle - for (size_t a = 0; a < n_ang; a++) { - tensor::View row = temp_chi.slice(a); - row /= row.sum(); - } + // Normalize chi by summing over the outgoing groups for each incoming angle + temp_chi /= xt::view(xt::sum(temp_chi, {1}), xt::all(), xt::newaxis()); - // Replicate the energy spectrum across all incoming groups - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - chi_prompt.slice(a, gin) = temp_chi.slice(a); + // Now every incoming group in self.chi is the normalized chi we just made + chi_prompt = xt::view(temp_chi, xt::all(), xt::newaxis(), xt::all()); // Get nu-fission directly - read_nd_tensor(xsdata_grp, "nu-fission", prompt_nu_fission, true); + read_nd_vector(xsdata_grp, "nu-fission", prompt_nu_fission, true); } //============================================================================== @@ -273,9 +231,8 @@ void XsData::fission_matrix_beta_from_hdf5( // Data is provided as nu-fission and chi with a beta for delayed info // Get nu-fission matrix - tensor::Tensor temp_matrix = - tensor::zeros({n_ang, n_g_, n_g_}); - read_nd_tensor(xsdata_grp, "nu-fission", temp_matrix, true); + xt::xtensor temp_matrix({n_ang, n_g_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "nu-fission", temp_matrix, true); // Get beta (strategy will depend upon the number of dimensions in beta) hid_t beta_dset = open_dataset(xsdata_grp, "beta"); @@ -285,92 +242,65 @@ void XsData::fission_matrix_beta_from_hdf5( if (!is_isotropic) ndim_target += 2; if (beta_ndims == ndim_target) { - tensor::Tensor temp_beta = tensor::zeros({n_ang, n_dg_}); - read_nd_tensor(xsdata_grp, "beta", temp_beta, true); + xt::xtensor temp_beta({n_ang, n_dg_}, 0.); + read_nd_vector(xsdata_grp, "beta", temp_beta, true); - auto beta_sum = temp_beta.sum(1); - auto matrix_gout_sum = temp_matrix.sum(2); + xt::xtensor temp_beta_sum({n_ang}, 0.); + temp_beta_sum = xt::sum(temp_beta, {1}); - // prompt_nu_fission = sum_gout(matrix) * (1 - beta_total) - for (size_t a = 0; a < n_ang; a++) - for (size_t g = 0; g < n_g_; g++) - prompt_nu_fission(a, g) = matrix_gout_sum(a, g) * (1.0 - beta_sum(a)); + // prompt_nu_fission is the sum of this matrix over outgoing groups and + // multiplied by (1 - beta_sum) + prompt_nu_fission = xt::sum(temp_matrix, {2}) * (1. - temp_beta_sum); - // chi_prompt = (1 - beta_total) * nu-fission matrix (unnormalized) - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_prompt(a, gin, gout) = - (1.0 - beta_sum(a)) * temp_matrix(a, gin, gout); + // Store chi-prompt + chi_prompt = + xt::view(1.0 - temp_beta_sum, xt::all(), xt::newaxis(), xt::newaxis()) * + temp_matrix; - // Delayed nu-fission is the outer product of the delayed neutron - // fraction (beta) and the total fission rate summed over outgoing groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t g = 0; g < n_g_; g++) - delayed_nu_fission(a, d, g) = temp_beta(a, d) * matrix_gout_sum(a, g); + // delayed_nu_fission is the sum of this matrix over outgoing groups and + // multiplied by beta + delayed_nu_fission = + xt::view(temp_beta, xt::all(), xt::all(), xt::newaxis()) * + xt::view(xt::sum(temp_matrix, {2}), xt::all(), xt::newaxis(), xt::all()); - // chi_delayed = beta * nu-fission matrix, expanded across delayed groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_delayed(a, d, gin, gout) = - temp_beta(a, d) * temp_matrix(a, gin, gout); + // Store chi-delayed + chi_delayed = + xt::view(temp_beta, xt::all(), xt::all(), xt::newaxis(), xt::newaxis()) * + xt::view(temp_matrix, xt::all(), xt::newaxis(), xt::all(), xt::all()); } else if (beta_ndims == ndim_target + 1) { - tensor::Tensor temp_beta = - tensor::zeros({n_ang, n_dg_, n_g_}); - read_nd_tensor(xsdata_grp, "beta", temp_beta, true); + xt::xtensor temp_beta({n_ang, n_dg_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "beta", temp_beta, true); - auto beta_sum = temp_beta.sum(1); - auto matrix_gout_sum = temp_matrix.sum(2); + xt::xtensor temp_beta_sum({n_ang, n_g_}, 0.); + temp_beta_sum = xt::sum(temp_beta, {1}); - // prompt_nu_fission = sum_gout(matrix) * (1 - beta_total) - // Here beta is energy-dependent, so beta_sum is 2D [n_ang, n_g] - for (size_t a = 0; a < n_ang; a++) - for (size_t g = 0; g < n_g_; g++) - prompt_nu_fission(a, g) = - matrix_gout_sum(a, g) * (1.0 - beta_sum(a, g)); + // prompt_nu_fission is the sum of this matrix over outgoing groups and + // multiplied by (1 - beta_sum) + prompt_nu_fission = xt::sum(temp_matrix, {2}) * (1. - temp_beta_sum); - // chi_prompt = (1 - beta_sum) * nu-fission matrix (unnormalized) - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_prompt(a, gin, gout) = - (1.0 - beta_sum(a, gin)) * temp_matrix(a, gin, gout); + // Store chi-prompt + chi_prompt = + xt::view(1.0 - temp_beta_sum, xt::all(), xt::all(), xt::newaxis()) * + temp_matrix; - // Delayed nu-fission: beta is energy-dependent [n_ang, n_dg, n_g], - // scale by total fission rate summed over outgoing groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t g = 0; g < n_g_; g++) - delayed_nu_fission(a, d, g) = - temp_beta(a, d, g) * matrix_gout_sum(a, g); + // delayed_nu_fission is the sum of this matrix over outgoing groups and + // multiplied by beta + delayed_nu_fission = temp_beta * xt::view(xt::sum(temp_matrix, {2}), + xt::all(), xt::newaxis(), xt::all()); - // chi_delayed = beta * nu-fission matrix, expanded across delayed groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_delayed(a, d, gin, gout) = - temp_beta(a, d, gin) * temp_matrix(a, gin, gout); + // Store chi-delayed + chi_delayed = + xt::view(temp_beta, xt::all(), xt::all(), xt::all(), xt::newaxis()) * + xt::view(temp_matrix, xt::all(), xt::newaxis(), xt::all(), xt::all()); } - // Normalize chi_prompt so it sums to 1 over outgoing groups - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) { - tensor::View row = chi_prompt.slice(a, gin); - row /= row.sum(); - } + // Normalize both chis + chi_prompt /= + xt::view(xt::sum(chi_prompt, {2}), xt::all(), xt::all(), xt::newaxis()); - // Normalize chi_delayed so it sums to 1 over outgoing groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t gin = 0; gin < n_g_; gin++) { - tensor::View row = chi_delayed.slice(a, d, gin); - row /= row.sum(); - } + chi_delayed /= xt::view( + xt::sum(chi_delayed, {3}), xt::all(), xt::all(), xt::all(), xt::newaxis()); } void XsData::fission_matrix_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang) @@ -378,36 +308,28 @@ void XsData::fission_matrix_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang) // Data is provided separately as prompt + delayed nu-fission and chi // Get the prompt nu-fission matrix - tensor::Tensor temp_matrix_p = - tensor::zeros({n_ang, n_g_, n_g_}); - read_nd_tensor(xsdata_grp, "prompt-nu-fission", temp_matrix_p, true); + xt::xtensor temp_matrix_p({n_ang, n_g_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "prompt-nu-fission", temp_matrix_p, true); // prompt_nu_fission is the sum over outgoing groups - prompt_nu_fission = temp_matrix_p.sum(2); + prompt_nu_fission = xt::sum(temp_matrix_p, {2}); - // chi_prompt is the nu-fission matrix normalized over outgoing groups - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_prompt(a, gin, gout) = - temp_matrix_p(a, gin, gout) / prompt_nu_fission(a, gin); + // chi_prompt is this matrix but normalized over outgoing groups, which we + // have already stored in prompt_nu_fission + chi_prompt = temp_matrix_p / + xt::view(prompt_nu_fission, xt::all(), xt::all(), xt::newaxis()); // Get the delayed nu-fission matrix - tensor::Tensor temp_matrix_d = - tensor::zeros({n_ang, n_dg_, n_g_, n_g_}); - read_nd_tensor(xsdata_grp, "delayed-nu-fission", temp_matrix_d, true); + xt::xtensor temp_matrix_d({n_ang, n_dg_, n_g_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "delayed-nu-fission", temp_matrix_d, true); // delayed_nu_fission is the sum over outgoing groups - delayed_nu_fission = temp_matrix_d.sum(3); + delayed_nu_fission = xt::sum(temp_matrix_d, {3}); - // chi_delayed is the delayed nu-fission matrix normalized over outgoing - // groups - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg_; d++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_delayed(a, d, gin, gout) = - temp_matrix_d(a, d, gin, gout) / delayed_nu_fission(a, d, gin); + // chi_prompt is this matrix but normalized over outgoing groups, which we + // have already stored in prompt_nu_fission + chi_delayed = temp_matrix_d / xt::view(delayed_nu_fission, xt::all(), + xt::all(), xt::all(), xt::newaxis()); } void XsData::fission_matrix_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang) @@ -416,19 +338,16 @@ void XsData::fission_matrix_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang) // Therefore, the code only considers the data as prompt. // Get nu-fission matrix - tensor::Tensor temp_matrix = - tensor::zeros({n_ang, n_g_, n_g_}); - read_nd_tensor(xsdata_grp, "nu-fission", temp_matrix, true); + xt::xtensor temp_matrix({n_ang, n_g_, n_g_}, 0.); + read_nd_vector(xsdata_grp, "nu-fission", temp_matrix, true); // prompt_nu_fission is the sum over outgoing groups - prompt_nu_fission = temp_matrix.sum(2); + prompt_nu_fission = xt::sum(temp_matrix, {2}); - // chi_prompt is the nu-fission matrix normalized over outgoing groups - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g_; gin++) - for (size_t gout = 0; gout < n_g_; gout++) - chi_prompt(a, gin, gout) = - temp_matrix(a, gin, gout) / prompt_nu_fission(a, gin); + // chi_prompt is this matrix but normalized over outgoing groups, which we + // have already stored in prompt_nu_fission + chi_prompt = temp_matrix / + xt::view(prompt_nu_fission, xt::all(), xt::all(), xt::newaxis()); } //============================================================================== @@ -437,8 +356,8 @@ void XsData::fission_from_hdf5( hid_t xsdata_grp, size_t n_ang, bool is_isotropic) { // Get the fission and kappa_fission data xs; these are optional - read_nd_tensor(xsdata_grp, "fission", fission); - read_nd_tensor(xsdata_grp, "kappa-fission", kappa_fission); + read_nd_vector(xsdata_grp, "fission", fission); + read_nd_vector(xsdata_grp, "kappa-fission", kappa_fission); // Get the data; the strategy for doing so depends on if the data is provided // as a nu-fission matrix or a set of chi and nu-fission vectors @@ -469,7 +388,7 @@ void XsData::fission_from_hdf5( if (n_dg_ == 0) { nu_fission = prompt_nu_fission; } else { - nu_fission = prompt_nu_fission + delayed_nu_fission.sum(1); + nu_fission = prompt_nu_fission + xt::sum(delayed_nu_fission, {1}); } } @@ -485,10 +404,10 @@ void XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, hid_t scatt_grp = open_group(xsdata_grp, "scatter_data"); // Get the outgoing group boundary indices - tensor::Tensor gmin = tensor::zeros({n_ang, n_g_}); - read_nd_tensor(scatt_grp, "g_min", gmin, true); - tensor::Tensor gmax = tensor::zeros({n_ang, n_g_}); - read_nd_tensor(scatt_grp, "g_max", gmax, true); + xt::xtensor gmin({n_ang, n_g_}, 0.); + read_nd_vector(scatt_grp, "g_min", gmin, true); + xt::xtensor gmax({n_ang, n_g_}, 0.); + read_nd_vector(scatt_grp, "g_max", gmax, true); // Make gmin and gmax start from 0 vice 1 as they do in the library gmin -= 1; @@ -496,11 +415,11 @@ void XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, // Now use this info to find the length of a vector to hold the flattened // data. - size_t length = order_data * (gmax - gmin + 1).sum(); + size_t length = order_data * xt::sum(gmax - gmin + 1)(); double_4dvec input_scatt(n_ang, double_3dvec(n_g_)); - tensor::Tensor temp_arr = tensor::zeros({length}); - read_nd_tensor(scatt_grp, "scatter_matrix", temp_arr, true); + xt::xtensor temp_arr({length}, 0.); + read_nd_vector(scatt_grp, "scatter_matrix", temp_arr, true); // Compare the number of orders given with the max order of the problem; // strip off the superfluous orders if needed @@ -532,7 +451,7 @@ void XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, double_3dvec temp_mult(n_ang, double_2dvec(n_g_)); if (object_exists(scatt_grp, "multiplicity_matrix")) { temp_arr.resize({length / order_data}); - read_nd_tensor(scatt_grp, "multiplicity_matrix", temp_arr); + read_nd_vector(scatt_grp, "multiplicity_matrix", temp_arr); // convert the flat temp_arr to a jagged array for passing to scatt data size_t temp_idx = 0; @@ -562,8 +481,8 @@ void XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, final_scatter_format == AngleDistributionType::TABULAR) { for (size_t a = 0; a < n_ang; a++) { ScattDataLegendre legendre_scatt; - tensor::Tensor in_gmin(gmin.slice(a)); - tensor::Tensor in_gmax(gmax.slice(a)); + xt::xtensor in_gmin = xt::view(gmin, a, xt::all()); + xt::xtensor in_gmax = xt::view(gmax, a, xt::all()); legendre_scatt.init(in_gmin, in_gmax, temp_mult[a], input_scatt[a]); @@ -577,8 +496,8 @@ void XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, // We are sticking with the current representation // Initialize the ScattData object with this data for (size_t a = 0; a < n_ang; a++) { - tensor::Tensor in_gmin(gmin.slice(a)); - tensor::Tensor in_gmax(gmax.slice(a)); + xt::xtensor in_gmin = xt::view(gmin, a, xt::all()); + xt::xtensor in_gmax = xt::view(gmax, a, xt::all()); scatter[a]->init(in_gmin, in_gmax, temp_mult[a], input_scatt[a]); } } @@ -600,67 +519,33 @@ void XsData::combine( if (i == 0) { inverse_velocity = that->inverse_velocity; } - if (!that->prompt_nu_fission.empty()) { + if (that->prompt_nu_fission.shape()[0] > 0) { nu_fission += scalar * that->nu_fission; prompt_nu_fission += scalar * that->prompt_nu_fission; kappa_fission += scalar * that->kappa_fission; fission += scalar * that->fission; delayed_nu_fission += scalar * that->delayed_nu_fission; - // Accumulate chi_prompt weighted by total prompt nu-fission - // (summed over energy groups) for this constituent - { - auto pnf_sum = that->prompt_nu_fission.sum(1); - size_t n_ang = chi_prompt.shape(0); - size_t n_g = chi_prompt.shape(1); - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g; gin++) - for (size_t gout = 0; gout < n_g; gout++) - chi_prompt(a, gin, gout) += - scalar * pnf_sum(a) * that->chi_prompt(a, gin, gout); - } - // Accumulate chi_delayed weighted by total delayed nu-fission - // (summed over energy groups) for this constituent - { - auto dnf_sum = that->delayed_nu_fission.sum(2); - size_t n_ang = chi_delayed.shape(0); - size_t n_dg = chi_delayed.shape(1); - size_t n_g = chi_delayed.shape(2); - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg; d++) - for (size_t gin = 0; gin < n_g; gin++) - for (size_t gout = 0; gout < n_g; gout++) - chi_delayed(a, d, gin, gout) += - scalar * dnf_sum(a, d) * that->chi_delayed(a, d, gin, gout); - } + chi_prompt += scalar * + xt::view(xt::sum(that->prompt_nu_fission, {1}), xt::all(), + xt::newaxis(), xt::newaxis()) * + that->chi_prompt; + chi_delayed += scalar * + xt::view(xt::sum(that->delayed_nu_fission, {2}), xt::all(), + xt::all(), xt::newaxis(), xt::newaxis()) * + that->chi_delayed; } decay_rate += scalar * that->decay_rate; } - // Normalize chi_prompt so it sums to 1 over outgoing groups - { - size_t n_ang = chi_prompt.shape(0); - size_t n_g = chi_prompt.shape(1); - for (size_t a = 0; a < n_ang; a++) - for (size_t gin = 0; gin < n_g; gin++) { - tensor::View row = chi_prompt.slice(a, gin); - row /= row.sum(); - } - } - // Normalize chi_delayed so it sums to 1 over outgoing groups - { - size_t n_ang = chi_delayed.shape(0); - size_t n_dg = chi_delayed.shape(1); - size_t n_g = chi_delayed.shape(2); - for (size_t a = 0; a < n_ang; a++) - for (size_t d = 0; d < n_dg; d++) - for (size_t gin = 0; gin < n_g; gin++) { - tensor::View row = chi_delayed.slice(a, d, gin); - row /= row.sum(); - } - } + // Ensure the chi_prompt and chi_delayed are normalized to 1 for each + // azimuthal angle and delayed group (for chi_delayed) + chi_prompt /= + xt::view(xt::sum(chi_prompt, {2}), xt::all(), xt::all(), xt::newaxis()); + chi_delayed /= xt::view( + xt::sum(chi_delayed, {3}), xt::all(), xt::all(), xt::all(), xt::newaxis()); // Allow the ScattData object to combine itself - for (size_t a = 0; a < total.shape(0); a++) { + for (size_t a = 0; a < total.shape()[0]; a++) { // Build vector of the scattering objects to incorporate vector those_scatts(those_xs.size()); for (size_t i = 0; i < those_xs.size(); i++) { diff --git a/tests/chain_ni.xml b/tests/chain_ni.xml deleted file mode 100644 index fc96d3d8b..000000000 --- a/tests/chain_ni.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - 557.6039 640.4896 655.72 678.8113 5847.93 5858.68 6448.81 6450.12 6499.05 6499.18 126000.0 4.281895544855688e-11 8.113092795419058e-12 2.881383486075155e-13 8.900165070824795e-12 6.680021392530635e-10 1.3098276096378766e-09 7.960187308411459e-11 1.5666266690172673e-10 2.8061406316612144e-14 4.106367573258232e-14 1.0245835494664239e-17 - - - 105210.0 231210.0 1.040592667426837e-17 8.004558980206438e-09 - - - 36.67648 65.20168 562.7812 610.8647 5155.619 5764.491 6377.571 2.257651440763611e-08 2.654244519541021e-09 1.1943434358627441e-08 2.0711244046714524e-10 3.863926291321637e-09 9.499586470057554e-10 5.918783030777615e-11 - - - - - - - - - - - - - - - - - - 780.0 6915.0 6930.0 7649.0 142651.0 189000.0 192343.0 334800.0 382000.0 1099245.0 1291590.0 1481700.0 1.0526870077721752e-12 1.0971242349369013e-11 2.1648606887732874e-11 3.9280951004469605e-12 1.8390802445841403e-09 1.622717862868359e-12 5.553301130705051e-09 4.868153588605077e-10 3.245435725736718e-11 1.018706213911803e-07 7.789045741768123e-08 1.0637817101025909e-10 - - - 750.0 6070.0 83569.95 130946.9 134942.1 141725.4 184634.1 191417.4 273599.0 327091.1 333874.4 465943.0 1091536.0 1283881.0 1565200.0 1.4515384373262843e-10 5.994999523918275e-11 1.4063554811525778e-10 2.3619560003972782e-09 2.703447959538686e-11 2.7218387619845277e-12 4.520385317374064e-11 4.498173915871091e-12 8.16767990977074e-08 8.519268780058884e-13 8.275861100628631e-14 9.574035390923319e-08 1.6299297619569002e-11 8.567950315944936e-12 3.245435725736718e-10 - - - - - - 120340.0 177610.0 297900.0 333000.0 349700.0 440500.0 542600.0 561400.0 603300.0 618400.0 657300.0 686000.0 696900.0 748100.0 769400.0 806300.0 925600.0 945400.0 978000.0 984100.0 989200.0 1027420.0 1097800.0 1205070.0 1275000.0 1285700.0 1381400.0 1403900.0 1538800.0 1618900.0 1645950.0 1659300.0 1837200.0 1879400.0 1889000.0 1899300.0 1972700.0 1999800.0 2011600.0 2177100.0 2230800.0 2484400.0 2754400.0 2920000.0 3191000.0 3204200.0 3239100.0 3364900.0 0.00010275887633317896 3.874515009283797e-05 0.00042956579450755135 4.2956579450755134e-06 3.116457724858706e-06 4.21142935791717e-06 1.263428807375151e-06 1.0949716330584643e-06 1.431885981691838e-06 1.802491765188549e-05 4.2956579450755134e-06 7.749030018567594e-06 2.1899432661169287e-06 1.558228862429353e-05 3.116457724858706e-06 3.7060578349671097e-06 6.569829798350785e-06 2.105714678958585e-06 1.431885981691838e-06 1.1792002202168078e-05 1.1792002202168078e-05 0.0008254401541517653 1.3476573945334946e-05 0.000842285871583434 1.1792002202168078e-05 7.159429908459189e-06 7.749030018567594e-06 2.2741718532752718e-06 5.306400990975635e-06 7.075201321300846e-06 0.00013476573945334945 1.4992688514185127e-05 2.6953147890669893e-06 5.053715229500604e-06 3.4533720734920796e-06 1.431885981691838e-06 1.1792002202168076e-06 2.526857614750302e-06 8.507087302992683e-05 4.042972183600483e-06 2.105714678958585e-06 2.3584004404336153e-06 1.4824231339868439e-05 1.3476573945334947e-06 1.6003431560085245e-06 8.422858715834341e-07 1.0949716330584643e-06 8.422858715834341e-07 - - - 613000.0 738800.1 773300.1 786899.9 873600.1 977699.9 1057900.0 1113610.0 1223500.0 1493500.0 1546600.0 1675000.0 1747100.0 1966500.0 2024800.0 2089000.0 2332110.0 2359120.0 2652590.0 2692270.0 2772900.0 2950510.0 3978000.0 7.969724371709087e-07 1.032441566335041e-06 1.1773456458206606e-05 1.5214928345990077e-06 1.267910695499173e-06 2.535821390998346e-05 1.267910695499173e-06 2.1735611922842964e-05 1.3947017650490904e-05 2.227900222091404e-06 2.173561192284297e-06 2.8980815897123955e-05 1.0867805961421485e-06 9.056504967851236e-05 1.7931879836345447e-05 4.709382583282643e-06 0.00014490407948561978 2.4452563413198337e-06 0.0004890512682639667 3.622601987140494e-07 0.0006882943775566939 0.00028980815897123956 9.056504967851236e-05 - - - - - - 619.9594 707.9362 726.02 741.741 6349.85 6362.71 7015.36 7016.95 7070.49 7070.66 510998.9 810759.2 863951.0 1674725.0 5.276288639112756e-10 1.3715809425619083e-10 3.759818598537813e-12 1.1767757246637665e-10 8.777123989590544e-09 1.719716697150835e-08 1.057271626846154e-09 2.0783510382283326e-09 5.201844116739253e-13 7.595270495013994e-13 3.374000922877054e-08 1.1259402850084962e-07 7.768987966558623e-10 5.854889482044179e-10 - - - 632864.1 1496834.0 2307600.0 1.3699223176071195e-09 1.1185811981783752e-07 8.491254034754873e-13 - - - 40.23492 70.00108 628.9213 675.1537 5583.843 6258.984 6938.274 803647.2 809913.1 810759.2 856839.0 863104.9 863951.0 1667613.0 1673879.0 1674725.0 2.3068291731266982e-07 2.4528685530196402e-08 1.3309519902564132e-07 1.9030055102434398e-09 4.481805021434518e-08 1.1035282426757231e-08 6.934054278993223e-10 3.366561452175404e-11 3.231448617974384e-12 4.640000480603615e-13 1.6314869068937087e-13 1.553797593311725e-14 2.2436836794554425e-15 3.3782714575729324e-14 3.2026247731116077e-15 4.614238015862169e-16 - - - - - - - - - - 751.0021 852.3381 876.89 883.6421 7417.82 7435.78 8222.319 8224.59 8287.88 8288.141 347140.0 826100.0 1173228.0 1332492.0 2158570.0 2505692.0 7.0614888325101086e-15 3.3564685966506987e-15 5.761418570090495e-17 2.3600648888691433e-15 1.3290046971181013e-13 2.5954235427719607e-13 1.6253028424014347e-14 3.186921843254948e-14 1.3932264913028456e-17 2.024904561736029e-17 3.125208966828774e-13 3.1668784197198245e-13 4.160694871171375e-09 4.166220240624728e-09 5.000334346926039e-14 8.333890578210064e-17 - - - 47.97734 78.78671 772.594 818.3802 6497.883 7313.626 8133.5 318151.8 1164895.0 1172220.0 1173228.0 1324159.0 1331484.0 1332492.0 1491392.0 2497359.0 2504684.0 2505692.0 2.430147074908485e-12 3.047352927658078e-13 1.6375715794161468e-12 1.653965175572544e-14 5.18885111875044e-13 1.2976030141139345e-13 8.558901456876446e-15 4.161944954758106e-09 6.241042306757062e-13 6.095415902793419e-14 8.94050113917305e-15 4.736991738545178e-13 4.616171159887578e-14 6.779692031857936e-15 5.000334346926038e-12 6.46709908869101e-21 6.3170890582832295e-22 9.678980517533168e-23 - - - - - - 751.028 852.3382 876.89 883.6886 7417.82 7435.78 8222.319 8224.59 8287.88 8288.141 67415.0 841700.0 909200.0 7.866502846971466e-08 3.756939402646081e-08 6.436568219422988e-10 2.637348005677196e-08 1.4671031864629482e-06 2.8654120987125446e-06 1.794509040062992e-07 3.5187803327436886e-07 1.538314140492697e-10 2.235774236842793e-10 9.880497991981766e-05 9.262966867482906e-07 4.219796017408879e-06 - - - 48.00067 78.83981 772.8435 818.5774 6498.158 7313.756 8133.501 59082.2 66406.9 67415.0 413499.9 833367.2 840691.9 841700.0 900867.2 908191.9 909200.0 1255285.0 2.6847340674754763e-05 3.3502043712197297e-06 1.814135374119958e-05 1.8444716489566865e-07 5.715307736044776e-06 1.430796977323619e-06 9.449890224831685e-08 1.2103610040177662e-05 1.246919266677299e-06 1.902588515965013e-07 5.134423559703298e-06 2.917834563257115e-10 2.862256762052218e-11 4.385088515066407e-12 9.241353278125446e-10 9.030363477255e-11 1.3801262380678854e-11 0.00011155702097900803 - - - - - - 1128900.0 1172900.0 1886300.0 1985000.0 2083000.0 2097000.0 2301800.0 2345900.0 3158200.0 3271000.0 3369500.0 3519000.0 4063100.0 0.0008553051126342747 0.006430865508528381 3.2154327542641905e-05 0.00012218644466203924 2.5723462034113525e-05 7.07395205938122e-05 0.0011318323295009952 0.0001028938481364541 6.430865508528381e-05 1.1254014639924668e-05 2.8938894788377717e-05 6.430865508528381e-06 2.5723462034113525e-05 - - - 1251800.0 1796100.0 1945400.0 2044800.0 2059000.0 2156900.0 2255700.0 3013160.0 4142070.0 5315000.0 2.5415396620531326e-05 0.00010782289475376927 2.9266214290308802e-05 9.318978760861486e-05 2.5415396620531326e-05 0.00018483924814931876 3.080654135821979e-05 0.0019870219176051766 0.005221708760218255 1.925408834888737e-05 - - - - - - 931100.0 1346100.0 0.11552453009332422 0.23104906018664845 - - - 5029800.0 5960900.0 7307000.0 0.11552453009332422 0.11552453009332422 2.079441541679836 - - - - - - 683.2094 778.5527 799.73 813.244 6873.16 6888.41 7606.53 7608.44 7666.77 7666.98 127164.0 161860.0 304100.0 379940.0 510998.9 541900.0 673440.0 696000.0 755300.0 906980.0 1046680.0 1224000.0 1279990.0 1350520.0 1377630.0 1603280.0 1730440.0 1757550.0 1897420.0 1919520.0 2133040.0 2730910.0 2804200.0 3177280.0 1.8638833690911883e-08 6.653293496572297e-09 1.4203876186268797e-10 5.409592966721624e-09 3.0832339673226584e-07 6.028687625463321e-07 3.74301586798566e-08 7.349918311628966e-08 2.4690572137876036e-11 3.5966442331457405e-11 9.014158418349326e-07 1.2284000197554473e-09 1.0604892256881559e-10 3.6233381877678664e-09 4.684800934777033e-06 1.9884172981652923e-10 2.6556417693274235e-09 4.860575617737382e-11 2.916345370642429e-10 3.3140288302754875e-09 7.246676375535733e-09 3.402402932416167e-09 5.2140720263001e-10 1.0604892256881559e-10 4.418705107033983e-06 2.1209784513763118e-10 2.827971268501749e-09 3.110768395351924e-07 1.502359736391554e-09 6.628057660550975e-07 1.546546787461894e-09 1.0737453410092578e-09 5.30244612844078e-09 6.009438945566218e-10 - - - 84790.04 154079.8 457929.9 531290.1 1129120.0 1342650.0 1504620.0 1757390.0 1884550.0 1.124957970946228e-09 3.2450710700371965e-09 1.5738594689680403e-08 1.0762819048956704e-09 1.8388736063544118e-09 6.652395693576253e-07 3.0611837094017556e-07 9.194368031772059e-07 3.488451400289987e-06 - - - 43.92123 75.12743 700.3887 749.9867 6033.611 6776.5 7523.621 119455.1 126238.4 127164.0 154151.1 160934.4 161860.0 665731.1 672514.4 673440.0 747591.1 754374.4 755300.0 1216291.0 1223074.0 1224000.0 1369921.0 1376704.0 1377630.0 1749841.0 1756624.0 1757550.0 1889711.0 1896494.0 1897420.0 1911811.0 1918594.0 1919520.0 2125331.0 2132114.0 2133040.0 7.252641897852818e-06 9.885065183674125e-07 4.453862207006767e-06 5.575973168934215e-08 1.3531437967587472e-06 3.3801747364315905e-07 2.1887831296943824e-08 1.739732899248527e-08 1.7397323584033486e-09 2.636641229198142e-10 1.272622225762379e-11 1.2627950688719498e-12 1.9160584871075314e-13 9.58686478614484e-13 9.268187990163621e-14 1.4090839543995835e-14 8.632381215411233e-14 8.34074667834699e-15 1.2155339619769639e-15 3.6814000810433283e-13 3.538499049712814e-14 5.158725716665081e-15 4.21544467211042e-10 4.0607899933642303e-11 2.1687004665322787e-10 1.822910020070542e-11 1.7482517516525527e-12 6.153697369032366e-11 7.181277376570916e-14 6.8808054292926055e-15 3.195035376537882e-13 3.115187100458958e-11 2.9826259472479385e-12 1.482406852545487e-10 6.031532471101388e-14 5.768616813006974e-15 4.833646927113489e-13 - - - - - - - - - - - - 1072500.0 2.890064045563861e-13 - - - 44.06754 75.28693 701.5928 750.7433 6035.851 6777.615 7523.68 6.689278658453111e-13 8.913674252402247e-14 4.1657845563004787e-13 5.378516121164032e-15 1.2583954438026756e-13 3.16650156158609e-14 2.0701132819599697e-15 - - - 683.3271 778.5529 799.73 813.5109 6873.16 6888.41 7606.53 7608.44 7666.77 7666.98 510998.9 1.7758787515451584e-15 6.581346326607483e-16 1.368589539770362e-17 5.248596182059754e-16 2.920762305855841e-14 5.711006429349971e-14 3.5457762265416177e-15 6.962612245690403e-15 2.338949640535961e-18 3.4071167337635547e-18 2.1386473937172572e-19 - - - - - - - - - - - - - - - - - - - - - - - - - - - - 66945.0 2.1704054025041888e-10 - - - - - - - - - - - - 820.0389 927.6652 951.42 959.5527 7984.67 8005.709 8862.7 8865.34 8933.11 8933.4 366270.0 507900.0 609500.0 770600.0 852700.0 954500.0 1115530.0 1481840.0 1623420.0 1724920.0 6.930967733828076e-11 4.4848940639261224e-11 6.225110448569713e-13 3.0091057755445835e-11 1.4120610720530457e-09 2.7533685191404717e-09 1.7112326402414573e-10 3.3482649978514024e-10 1.9318959861680173e-13 2.7929997279698636e-13 3.6755804457910027e-06 2.2374667416695354e-07 1.181887674027053e-07 7.92135402897521e-08 7.398075516810562e-08 1.3533064969775417e-09 1.1800832653644161e-05 1.804408662636722e-05 3.807302278163484e-07 3.0494506398560603e-07 - - - 56.92597 90.91714 855.942 897.216 6991.356 7880.445 8773.007 357291.1 365173.4 366270.0 412919.9 498921.1 506803.4 507900.0 514460.0 600521.1 608403.4 609500.0 656069.9 761621.1 769503.4 770600.0 1022350.0 1106551.0 1114434.0 1115530.0 1472861.0 1480743.0 1481840.0 1614441.0 1622324.0 1623420.0 1715941.0 1723824.0 1724920.0 2137900.0 2.167548391930537e-08 2.8616659297729836e-09 1.5876524466163717e-08 5.919283450210211e-11 4.8238674145478966e-09 1.1910611683428657e-09 8.251524863747208e-11 6.6528004309537836e-09 6.652800430953784e-10 9.941708721258623e-11 4.2452174979371803e-07 1.968970885650002e-10 1.9600207433178643e-11 2.840463936760989e-12 6.807646077773136e-07 6.748578656939676e-11 6.701302996997783e-12 9.996408692926368e-13 2.172327512457944e-05 2.732867560693677e-11 2.7011821751739386e-12 4.0351373644973695e-13 7.786723266486576e-06 1.953037934211798e-09 1.9247158318161006e-10 3.950919133474779e-11 1.818843931937816e-09 1.7899733933356285e-10 1.4705028396157966e-09 3.076300301948419e-11 3.022997962967563e-12 4.574485034565062e-11 2.213900812679635e-11 2.1742581302894385e-12 5.0020380532292804e-11 4.589424322094249e-05 - - - diff --git a/tests/conftest.py b/tests/conftest.py index 8dda9f756..639d669f3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,51 +1,7 @@ -import os -import hashlib import pytest -import openmc -import openmc.lib from tests.regression_tests import config as regression_config -# MD5 hash of the official NNDC HDF5 cross_sections.xml file. -# Generated via: md5sum /path/to/nndc_hdf5/cross_sections.xml -_NNDC_XS_MD5 = "2d00773012eda670bc9f95d96a31c989" - -# Collected during pytest_configure, displayed at start and end of session -_environment_warnings = [] - - -def _check_build_environment(): - """Check STRICT_FP and cross section data, collecting any warnings.""" - if not openmc.lib._strict_fp_enabled(): - _environment_warnings.append( - "OpenMC was NOT built with -DOPENMC_ENABLE_STRICT_FP=on. " - "Regression test results may not match reference values due to " - "compiler floating-point optimizations. Rebuild with " - "-DOPENMC_ENABLE_STRICT_FP=on for reproducible results." - ) - - xs_path = os.environ.get("OPENMC_CROSS_SECTIONS") - if not xs_path: - _environment_warnings.append( - "OPENMC_CROSS_SECTIONS environment variable is not set. " - "Regression tests require the NNDC HDF5 cross section data." - ) - elif not os.path.isfile(xs_path): - _environment_warnings.append( - f"OPENMC_CROSS_SECTIONS ({xs_path}) is not a valid file path. " - "Regression tests require the NNDC HDF5 cross section data." - ) - else: - with open(xs_path, "rb") as f: - md5 = hashlib.md5(f.read()).hexdigest() - if md5 != _NNDC_XS_MD5: - _environment_warnings.append( - f"OPENMC_CROSS_SECTIONS ({xs_path}) does not match the " - "official NNDC HDF5 dataset. Regression tests expect the " - "NNDC data; results may differ with other cross section " - "libraries." - ) - def pytest_addoption(parser): parser.addoption('--exe') @@ -63,28 +19,6 @@ def pytest_configure(config): if config.getoption(opt) is not None: regression_config[opt] = config.getoption(opt) - _check_build_environment() - - -def _print_environment_warnings(terminalreporter): - """Print environment warnings as a visible section.""" - if _environment_warnings: - terminalreporter.section("OpenMC Environment Warnings") - for msg in _environment_warnings: - terminalreporter.line(f"WARNING: {msg}", yellow=True) - terminalreporter.line("") - - -def pytest_sessionstart(session): - """Print environment warnings at the start of the test session.""" - _print_environment_warnings(session.config.pluginmanager.get_plugin( - "terminalreporter")) - - -def pytest_terminal_summary(terminalreporter, exitstatus, config): - """Reprint environment warnings at the end so they aren't missed.""" - _print_environment_warnings(terminalreporter) - @pytest.fixture def run_in_tmpdir(tmpdir): @@ -93,29 +27,3 @@ def run_in_tmpdir(tmpdir): yield finally: orig.chdir() - -@pytest.fixture(scope="module") -def endf_data(): - return os.environ['OPENMC_ENDF_DATA'] - -@pytest.fixture(scope='session', autouse=True) -def resolve_paths(): - with openmc.config.patch('resolve_paths', False): - yield - - -@pytest.fixture(scope='session', autouse=True) -def disable_depletion_multiprocessing_under_mpi(): - """Fork-based depletion multiprocessing may deadlock if MPI is active.""" - if not regression_config['mpi']: - yield - return - - from openmc.deplete import pool - - original_setting = pool.USE_MULTIPROCESSING - pool.USE_MULTIPROCESSING = False - try: - yield - finally: - pool.USE_MULTIPROCESSING = original_setting diff --git a/tests/cpp_unit_tests/CMakeLists.txt b/tests/cpp_unit_tests/CMakeLists.txt index 3eb88f023..f0f5f2853 100644 --- a/tests/cpp_unit_tests/CMakeLists.txt +++ b/tests/cpp_unit_tests/CMakeLists.txt @@ -4,11 +4,6 @@ set(TEST_NAMES test_tally test_interpolate test_math - test_mcpl_stat_sum - test_mesh - test_ray - test_region - test_tensor # Add additional unit test files here ) diff --git a/tests/cpp_unit_tests/test_distribution.cpp b/tests/cpp_unit_tests/test_distribution.cpp index 479e7c8a7..e1a212db5 100644 --- a/tests/cpp_unit_tests/test_distribution.cpp +++ b/tests/cpp_unit_tests/test_distribution.cpp @@ -1,6 +1,4 @@ #include "openmc/distribution.h" -#include "openmc/distribution_spatial.h" -#include "openmc/position.h" #include "openmc/random_lcg.h" #include #include @@ -30,7 +28,7 @@ TEST_CASE("Test alias method sampling of a discrete distribution") int counter = 0; for (size_t i = 0; i < n_samples; i++) { - auto sample = dist.sample(&seed).first; + auto sample = dist.sample(&seed); std += sample * sample / n_samples; dist_mean += sample; @@ -63,7 +61,7 @@ TEST_CASE("Test alias sampling method for pugixml constructor") // Initialize discrete distribution and seed openmc::Discrete dist(energy); uint64_t seed = openmc::init_seed(0, 0); - auto sample = dist.sample(&seed).first; + auto sample = dist.sample(&seed); // Assertions REQUIRE(dist.x().size() == 3); @@ -81,139 +79,3 @@ TEST_CASE("Test alias sampling method for pugixml constructor") REQUIRE(dist.alias()[i] == correct_alias[i]); } } - -TEST_CASE("Test sampling a large linear-linear tabular distribution") -{ - constexpr int n_points = 10001; - constexpr int n_samples = 200000; - openmc::vector x(n_points); - openmc::vector p(n_points); - for (int i = 0; i < n_points; ++i) { - x[i] = static_cast(i) / (n_points - 1); - p[i] = 2.0 * x[i]; - } - - openmc::Tabular dist( - x.data(), p.data(), n_points, openmc::Interpolation::lin_lin); - uint64_t seed = openmc::init_seed(0, 0); - - double mean = 0.0; - for (int i = 0; i < n_samples; ++i) { - mean += dist.sample(&seed).first; - } - mean /= n_samples; - - // The normalized PDF is 2x on [0, 1], which has a mean of 2/3. - REQUIRE_THAT(mean, Catch::Matchers::WithinAbs(2.0 / 3.0, 0.003)); -} - -TEST_CASE("Test construction of SpatialBox with parameters") -{ - openmc::Position ll {-1, -2, -3}; - openmc::Position ur {30, 15, 5}; - openmc::SpatialBox box(ll, ur); - - REQUIRE(box.lower_left() == openmc::Position {-1, -2, -3}); - REQUIRE(box.upper_right() == openmc::Position {30, 15, 5}); - REQUIRE_FALSE(box.only_fissionable()); -} - -TEST_CASE("Test Normal distribution") -{ - // Test untruncated normal distribution - openmc::Normal normal_unbounded(0.0, 1.0); - - // Check PDF at mean (should be 1/sqrt(2*pi) ≈ 0.3989) - REQUIRE_THAT( - normal_unbounded.evaluate(0.0), Catch::Matchers::WithinRel(0.3989, 0.001)); - - // Check that it's not truncated - REQUIRE_FALSE(normal_unbounded.is_truncated()); - - // Check accessors - REQUIRE(normal_unbounded.mean_value() == 0.0); - REQUIRE(normal_unbounded.std_dev() == 1.0); - REQUIRE(normal_unbounded.lower() == -openmc::INFTY); - REQUIRE(normal_unbounded.upper() == openmc::INFTY); -} - -TEST_CASE("Test truncated Normal distribution") -{ - // Create a truncated normal: mean=0, std=1, bounds=[-1, 1] - openmc::Normal normal_truncated(0.0, 1.0, -1.0, 1.0); - - // Check that it's truncated - REQUIRE(normal_truncated.is_truncated()); - - // Check accessors - REQUIRE(normal_truncated.lower() == -1.0); - REQUIRE(normal_truncated.upper() == 1.0); - - // PDF should be zero outside bounds - REQUIRE(normal_truncated.evaluate(-2.0) == 0.0); - REQUIRE(normal_truncated.evaluate(2.0) == 0.0); - - // PDF inside bounds should be higher than untruncated (due to - // renormalization) - openmc::Normal normal_unbounded(0.0, 1.0); - REQUIRE(normal_truncated.evaluate(0.0) > normal_unbounded.evaluate(0.0)); - - // The truncated PDF at mean should be approximately 0.3989 / 0.6827 ≈ 0.584 - // (0.6827 is the probability mass of N(0,1) in [-1,1]) - REQUIRE_THAT( - normal_truncated.evaluate(0.0), Catch::Matchers::WithinRel(0.584, 0.01)); -} - -TEST_CASE("Test truncated Normal sampling") -{ - constexpr int n_samples = 10000; - openmc::Normal normal_truncated(0.0, 1.0, -1.0, 1.0); - uint64_t seed = openmc::init_seed(0, 0); - - // Sample and verify all samples are within bounds - for (int i = 0; i < n_samples; ++i) { - auto [x, w] = normal_truncated.sample(&seed); - REQUIRE(x >= -1.0); - REQUIRE(x <= 1.0); - REQUIRE(w == 1.0); // Unbiased sampling should have weight 1 - } -} - -TEST_CASE("Test one-sided truncated Normal") -{ - // Test lower-bounded only (positive half-normal) - openmc::Normal lower_bounded(0.0, 1.0, 0.0, openmc::INFTY); - REQUIRE(lower_bounded.is_truncated()); - REQUIRE(lower_bounded.evaluate(-1.0) == 0.0); - REQUIRE(lower_bounded.evaluate(1.0) > 0.0); - - // PDF at 0 should be approximately 2 * 0.3989 ≈ 0.798 (half-normal) - REQUIRE_THAT( - lower_bounded.evaluate(0.0), Catch::Matchers::WithinRel(0.798, 0.01)); - - // Test upper-bounded only - openmc::Normal upper_bounded(0.0, 1.0, -openmc::INFTY, 0.0); - REQUIRE(upper_bounded.is_truncated()); - REQUIRE(upper_bounded.evaluate(1.0) == 0.0); - REQUIRE(upper_bounded.evaluate(-1.0) > 0.0); -} - -TEST_CASE("Test Normal XML constructor with truncation") -{ - // XML doc node for truncated Normal - pugi::xml_document doc; - pugi::xml_node energy = doc.append_child("energy"); - energy.append_child("type") - .append_child(pugi::node_pcdata) - .set_value("normal"); - energy.append_child("parameters") - .append_child(pugi::node_pcdata) - .set_value("1.0e6 1.0e5 0.8e6 1.2e6"); - - openmc::Normal dist(energy); - REQUIRE(dist.mean_value() == 1.0e6); - REQUIRE(dist.std_dev() == 1.0e5); - REQUIRE(dist.lower() == 0.8e6); - REQUIRE(dist.upper() == 1.2e6); - REQUIRE(dist.is_truncated()); -} diff --git a/tests/cpp_unit_tests/test_file_utils.cpp b/tests/cpp_unit_tests/test_file_utils.cpp index 8b0d99d76..3b7a74346 100644 --- a/tests/cpp_unit_tests/test_file_utils.cpp +++ b/tests/cpp_unit_tests/test_file_utils.cpp @@ -30,12 +30,3 @@ TEST_CASE("Test file_exists") // Note: not clear how to portably test where a file should exist. REQUIRE(!file_exists("./should_not_exist/really_do_not_make_this_please")); } - -TEST_CASE("Test dir_name") -{ - REQUIRE(dir_name("") == ""); - REQUIRE(dir_name("/") == "/"); - REQUIRE(dir_name("hello") == ""); - REQUIRE(dir_name("hello/world") == "hello"); - REQUIRE(dir_name("/path/to/dir/") == "/path/to/dir"); -} diff --git a/tests/cpp_unit_tests/test_math.cpp b/tests/cpp_unit_tests/test_math.cpp index 7467aa1fe..1ad7c4b70 100644 --- a/tests/cpp_unit_tests/test_math.cpp +++ b/tests/cpp_unit_tests/test_math.cpp @@ -46,21 +46,6 @@ TEST_CASE("Test t_percentile") } } -TEST_CASE("Test cylindrical Bessel functions") -{ - constexpr double x = 2.0; - constexpr double expected[] {0.22389077914123567, 0.57672480775687339, - 0.35283402861563773, 0.12894324947440205}; - - for (int n = 0; n < 4; ++n) { - REQUIRE_THAT(openmc::cyl_bessel_j(n, x), - Catch::Matchers::WithinRel(expected[n], 1.0e-14)); - REQUIRE_THAT(openmc::cyl_bessel_j(n, -x), - Catch::Matchers::WithinRel( - (n % 2 == 0 ? 1.0 : -1.0) * expected[n], 1.0e-14)); - } -} - TEST_CASE("Test calc_pn") { // The reference solutions come from scipy.special.eval_legendre @@ -370,24 +355,3 @@ TEST_CASE("Test broaden_wmp_polynomials") REQUIRE_THAT(ref_val, Catch::Matchers::Approx(test_val)); } } - -TEST_CASE("Test isclose") -{ - using openmc::isclose; - - // Identical values are always close, regardless of tolerances. - REQUIRE(isclose(1.0, 1.0, 0.0, 0.0)); - REQUIRE(isclose(0.0, 0.0, 0.0, 0.0)); - - // Absolute tolerance governs comparisons near zero. - REQUIRE(isclose(0.0, 1e-15, 0.0, 1e-14)); - REQUIRE_FALSE(isclose(0.0, 1e-13, 0.0, 1e-14)); - - // Relative tolerance scales with the magnitude of the operands. - REQUIRE(isclose(1.0e12, 1.0e12 + 1.0, 1e-12, 0.0)); - REQUIRE_FALSE(isclose(1.0e12, 1.0e12 + 10.0, 1e-12, 0.0)); - - // The looser of the two tolerances wins. - REQUIRE(isclose(1.0, 1.0 + 1e-13, 0.0, 1e-12)); - REQUIRE(isclose(1.0e6, 1.0e6 + 1e-4, 1e-9, 0.0)); -} diff --git a/tests/cpp_unit_tests/test_mcpl_stat_sum.cpp b/tests/cpp_unit_tests/test_mcpl_stat_sum.cpp deleted file mode 100644 index d0c26f26c..000000000 --- a/tests/cpp_unit_tests/test_mcpl_stat_sum.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include - -#include "openmc/bank.h" -#include "openmc/mcpl_interface.h" - -// Test the MCPL stat:sum functionality (issue #3514) -TEST_CASE("MCPL stat:sum field") -{ - // Check if MCPL interface is available - if (!openmc::is_mcpl_interface_available()) { - SKIP("MCPL library not available"); - } - - SECTION("stat:sum field is written to MCPL files") - { - // Create a temporary filename - std::string filename = "test_stat_sum.mcpl"; - - // Create some test particles - std::vector source_bank(100); - std::vector bank_index = {0, 100}; // 100 particles total - - // Initialize test particles - for (int i = 0; i < 100; ++i) { - source_bank[i].particle = openmc::ParticleType::neutron(); - source_bank[i].r = {i * 0.1, i * 0.2, i * 0.3}; - source_bank[i].u = {0.0, 0.0, 1.0}; - source_bank[i].E = 2.0e6; // 2 MeV - source_bank[i].time = 0.0; - source_bank[i].wgt = 1.0; - } - - // Write the MCPL file - openmc::write_mcpl_source_point(filename.c_str(), source_bank, bank_index); - - // Verify the file was created - FILE* f = std::fopen(filename.c_str(), "r"); - REQUIRE(f != nullptr); - std::fclose(f); - - // Read the file back to check stat:sum - // Note: This would require mcpl_open_file and checking the header - // Since we can't easily read MCPL headers in C++ without the full MCPL API, - // we rely on the Python test to verify the actual content - - // Clean up - std::remove(filename.c_str()); - } - - SECTION("stat:sum uses correct particle count") - { - std::string filename = "test_count.mcpl"; - - // Test with different particle counts - std::vector test_counts = {1, 10, 100, 1000}; - - for (int count : test_counts) { - std::vector source_bank(count); - std::vector bank_index = {0, count}; - - // Initialize particles - for (int i = 0; i < count; ++i) { - source_bank[i].particle = openmc::ParticleType::neutron(); - source_bank[i].r = {0.0, 0.0, 0.0}; - source_bank[i].u = {0.0, 0.0, 1.0}; - source_bank[i].E = 1.0e6; - source_bank[i].time = 0.0; - source_bank[i].wgt = 1.0; - } - - // Write MCPL file - openmc::write_mcpl_source_point( - filename.c_str(), source_bank, bank_index); - - // The stat:sum should equal count (verified by Python test) - // Here we just verify the file was created successfully - FILE* f = std::fopen(filename.c_str(), "r"); - REQUIRE(f != nullptr); - std::fclose(f); - - // Clean up - std::remove(filename.c_str()); - } - } - - SECTION("stat:sum handles empty particle bank") - { - std::string filename = "test_empty.mcpl"; - - // Create empty particle bank - std::vector source_bank; - std::vector bank_index = {0}; - - // This should still create a valid MCPL file with stat:sum = 0 - openmc::write_mcpl_source_point(filename.c_str(), source_bank, bank_index); - - // Verify file was created - FILE* f = std::fopen(filename.c_str(), "r"); - REQUIRE(f != nullptr); - std::fclose(f); - - // Clean up - std::remove(filename.c_str()); - } -} diff --git a/tests/cpp_unit_tests/test_mesh.cpp b/tests/cpp_unit_tests/test_mesh.cpp deleted file mode 100644 index 24c4f7737..000000000 --- a/tests/cpp_unit_tests/test_mesh.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "openmc/hdf5_interface.h" -#include "openmc/mesh.h" - -using namespace openmc; - -TEST_CASE("Test mesh hdf5 roundtrip - regular") -{ - // The XML data as a string - std::string xml_string = R"( - - 3 4 5 - -2 -3 -5 - 2 3 5 - - )"; - - // Create a pugixml document object - pugi::xml_document doc; - - // Load the XML from the string - pugi::xml_parse_result result = doc.load_string(xml_string.c_str()); - - pugi::xml_node root = doc.child("mesh"); - - auto mesh = RegularMesh(root); - - hid_t file_id = file_open("mesh.h5", 'w'); - - mesh.to_hdf5(file_id); - - file_close(file_id); - - hid_t file_id2 = file_open("mesh.h5", 'r'); - - hid_t group = open_group(file_id2, "mesh 1"); - - auto mesh2 = RegularMesh(group); - - file_close(file_id2); - - remove("mesh.h5"); - - REQUIRE(mesh2.shape_ == mesh.shape_); - - REQUIRE(mesh2.lower_left() == mesh.lower_left()); - - REQUIRE(mesh2.upper_right() == mesh.upper_right()); -} - -TEST_CASE("Test mesh hdf5 roundtrip - rectilinear") -{ - // The XML data as a string - std::string xml_string = R"( - - 0.0 1.0 5.0 10.0 - -10.0 -5.0 0.0 - -100.0 0.0 100.0 - - )"; - - // Create a pugixml document object - pugi::xml_document doc; - - // Load the XML from the string - pugi::xml_parse_result result = doc.load_string(xml_string.c_str()); - - pugi::xml_node root = doc.child("mesh"); - - auto mesh = RectilinearMesh(root); - - hid_t file_id = file_open("mesh.h5", 'w'); - - mesh.to_hdf5(file_id); - - file_close(file_id); - - hid_t file_id2 = file_open("mesh.h5", 'r'); - - hid_t group = open_group(file_id2, "mesh 1"); - - auto mesh2 = RectilinearMesh(group); - - file_close(file_id2); - - remove("mesh.h5"); - - REQUIRE(mesh2.shape_ == mesh.shape_); - - REQUIRE(mesh2.grid_ == mesh.grid_); -} - -TEST_CASE("Test mesh hdf5 roundtrip - cylindrical") -{ - // The XML data as a string - std::string xml_string = R"( - - 0.1 0.2 0.5 1.0 - 0.0 6.283185307179586 - 0.1 0.2 0.4 0.6 1.0 - 0 0 0 - - )"; - - // Create a pugixml document object - pugi::xml_document doc; - - // Load the XML from the string - pugi::xml_parse_result result = doc.load_string(xml_string.c_str()); - - pugi::xml_node root = doc.child("mesh"); - - auto mesh = CylindricalMesh(root); - - hid_t file_id = file_open("mesh.h5", 'w'); - - mesh.to_hdf5(file_id); - - file_close(file_id); - - hid_t file_id2 = file_open("mesh.h5", 'r'); - - hid_t group = open_group(file_id2, "mesh 1"); - - auto mesh2 = CylindricalMesh(group); - - file_close(file_id2); - - remove("mesh.h5"); - - REQUIRE(mesh2.shape_ == mesh.shape_); - - REQUIRE(mesh2.grid_ == mesh.grid_); -} - -TEST_CASE("Test mesh hdf5 roundtrip - spherical") -{ - // The XML data as a string - std::string xml_string = R"( - - 0.1 0.2 0.5 1.0 - 0.0 3.141592653589793 - 0.0 6.283185307179586 - 0.0 0.0 0.0 - ' - )"; - - // Create a pugixml document object - pugi::xml_document doc; - - // Load the XML from the string - pugi::xml_parse_result result = doc.load_string(xml_string.c_str()); - - pugi::xml_node root = doc.child("mesh"); - - auto mesh = SphericalMesh(root); - - hid_t file_id = file_open("mesh.h5", 'w'); - - mesh.to_hdf5(file_id); - - file_close(file_id); - - hid_t file_id2 = file_open("mesh.h5", 'r'); - - hid_t group = open_group(file_id2, "mesh 1"); - - auto mesh2 = SphericalMesh(group); - - file_close(file_id2); - - remove("mesh.h5"); - - REQUIRE(mesh2.shape_ == mesh.shape_); - - REQUIRE(mesh2.grid_ == mesh.grid_); -} - -TEST_CASE("Test multiple meshes HDF5 roundtrip - spherical") -{ - // The XML data as a string - std::string xml_string = R"( - - - 0.1 0.2 0.5 1.0 - 0.0 3.141592653589793 - 0.0 6.283185307179586 - 0.0 0.0 0.0 - - - 3 4 5 - -2 -3 -5 - 2 3 5 - - - )"; - - // Create a pugixml document object - pugi::xml_document doc; - - // Load the XML from the string - pugi::xml_parse_result result = doc.load_string(xml_string.c_str()); - - pugi::xml_node root = doc.child("meshes"); - - read_meshes(root); - - const auto spherical_mesh_xml = - dynamic_cast(model::meshes[0].get()); - const auto regular_mesh_xml = - dynamic_cast(model::meshes[1].get()); - - hid_t file_id = file_open("meshes.h5", 'w'); - - hid_t root_group = create_group(file_id, "root"); - - open_group(file_id, "root"); - - meshes_to_hdf5(root_group); - - close_group(root_group); - - file_close(file_id); - - hid_t file_id2 = file_open("meshes.h5", 'r'); - - hid_t root_group_read = open_group(file_id2, "root"); - - hid_t mesh_group_read = open_group(root_group_read, "meshes"); - - read_meshes(mesh_group_read); - - // increment mesh IDs to avoid collision during read - for (auto& mesh : model::meshes) { - mesh->set_id(mesh->id() + 10); - } - - const auto spherical_mesh_hdf5 = dynamic_cast( - model::meshes[model::mesh_map[spherical_mesh_xml->id_]].get()); - const auto regular_mesh_hdf5 = dynamic_cast( - model::meshes[model::mesh_map[regular_mesh_xml->id_]].get()); - - remove("meshes.h5"); - - REQUIRE(spherical_mesh_hdf5->shape_ == spherical_mesh_xml->shape_); - REQUIRE(spherical_mesh_hdf5->grid_ == spherical_mesh_xml->grid_); - - REQUIRE(regular_mesh_hdf5->shape_ == regular_mesh_xml->shape_); - REQUIRE(regular_mesh_hdf5->lower_left() == regular_mesh_xml->lower_left()); - REQUIRE(regular_mesh_hdf5->upper_right() == regular_mesh_xml->upper_right()); -} diff --git a/tests/cpp_unit_tests/test_ray.cpp b/tests/cpp_unit_tests/test_ray.cpp deleted file mode 100644 index c043c4d25..000000000 --- a/tests/cpp_unit_tests/test_ray.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include -#include - -#include -#include -#include - -#include "openmc/geometry.h" -#include "openmc/geometry_aux.h" -#include "openmc/ray.h" -#include "openmc/settings.h" -#include "openmc/surface.h" - -namespace { - -using Catch::Matchers::WithinAbs; - -constexpr double DISTANCE_TOLERANCE = 1.0e-12; - -class SphericalShellFixture { -public: - SphericalShellFixture() - : run_mode_(openmc::settings::run_mode), - root_universe_(openmc::model::root_universe), - n_coord_levels_(openmc::model::n_coord_levels) - { - openmc::settings::run_mode = openmc::RunMode::PLOTTING; - - constexpr auto geometry = R"( - - - - - - - )"; - - auto result = document_.load_string(geometry); - REQUIRE(result); - openmc::read_geometry_xml(document_.document_element()); - openmc::finalize_geometry(); - openmc::finalize_cell_densities(); - } - - ~SphericalShellFixture() - { - openmc::free_memory_geometry(); - openmc::free_memory_surfaces(); - openmc::model::universe_level_counts.clear(); - openmc::model::root_universe = root_universe_; - openmc::model::n_coord_levels = n_coord_levels_; - openmc::settings::run_mode = run_mode_; - } - -private: - pugi::xml_document document_; - openmc::RunMode run_mode_; - int root_universe_; - int n_coord_levels_; -}; - -class RecordingRay : public openmc::Ray { -public: - using Ray::Ray; - - void on_intersection() override - { - intersections.emplace_back( - traversal_distance_, boundary().surface_index() + 1); - } - - openmc::vector> intersections; -}; - -} // namespace - -TEST_CASE_METHOD(SphericalShellFixture, "Trace a single chord through a sphere") -{ - constexpr double impact_parameter = 1.5; - const double half_chord = - std::sqrt(4.0 - impact_parameter * impact_parameter); - - RecordingRay ray({-3.0, impact_parameter, 0.0}, {1.0, 0.0, 0.0}); - ray.trace(); - - REQUIRE(ray.intersections.size() == 2); - CHECK(ray.intersections[0].second == 2); - CHECK_THAT(ray.intersections[0].first, WithinAbs(0.0, DISTANCE_TOLERANCE)); - CHECK(ray.intersections[1].second == 2); - CHECK_THAT(ray.intersections[1].first, - WithinAbs(2.0 * half_chord, DISTANCE_TOLERANCE)); -} - -TEST_CASE_METHOD( - SphericalShellFixture, "Trace both segments of a spherical shell") -{ - constexpr double impact_parameter = 0.5; - const double outer = std::sqrt(4.0 - impact_parameter * impact_parameter); - const double inner = std::sqrt(1.0 - impact_parameter * impact_parameter); - - RecordingRay ray({-3.0, impact_parameter, 0.0}, {1.0, 0.0, 0.0}); - ray.trace(); - - REQUIRE(ray.intersections.size() == 4); - CHECK(ray.intersections[0].second == 2); - CHECK_THAT(ray.intersections[0].first, WithinAbs(0.0, DISTANCE_TOLERANCE)); - CHECK(ray.intersections[1].second == 1); - CHECK_THAT( - ray.intersections[1].first, WithinAbs(outer - inner, DISTANCE_TOLERANCE)); - CHECK(ray.intersections[2].second == 1); - CHECK_THAT( - ray.intersections[2].first, WithinAbs(outer + inner, DISTANCE_TOLERANCE)); - CHECK(ray.intersections[3].second == 2); - CHECK_THAT( - ray.intersections[3].first, WithinAbs(2.0 * outer, DISTANCE_TOLERANCE)); -} diff --git a/tests/cpp_unit_tests/test_region.cpp b/tests/cpp_unit_tests/test_region.cpp deleted file mode 100644 index b3d9a1427..000000000 --- a/tests/cpp_unit_tests/test_region.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include - -#include "openmc/cell.h" -#include "openmc/surface.h" - -#include - -namespace { - -// Helper class to set up and tear down test surfaces -class SurfaceFixture { -public: - SurfaceFixture() - { - pugi::xml_document doc; - pugi::xml_node surf_node = doc.append_child("surface"); - surf_node.set_name("surface"); - surf_node.append_attribute("id") = "0"; - surf_node.append_attribute("type") = "x-plane"; - surf_node.append_attribute("coeffs") = "1"; - - for (int i = 1; i < 10; ++i) { - surf_node.attribute("id") = i; - openmc::model::surfaces.push_back( - std::make_unique(surf_node)); - openmc::model::surface_map[i] = i - 1; - } - } - - ~SurfaceFixture() - { - openmc::model::surfaces.clear(); - openmc::model::surface_map.clear(); - } -}; - -} // anonymous namespace - -TEST_CASE("Test region simplification") -{ - SurfaceFixture fixture; - - SECTION("Original bug case from issue #3685") - { - // Input: "-1 2 (-3 4) | (-5 6)" was being incorrectly interpreted - auto region = openmc::Region("(-1 2 (-3 4) | (-5 6))", 0); - REQUIRE(region.str() == " ( ( -1 2 ( -3 4 ) ) | ( -5 6 ) )"); - } - - SECTION("Simple union - no extra parentheses needed") - { - auto region = openmc::Region("1 | 2", 0); - REQUIRE(region.str() == " 1 | 2"); - } - - SECTION("Intersection then union") - { - // Intersection should have higher precedence, so (1 2) grouped - auto region = openmc::Region("1 2 | 3", 0); - REQUIRE(region.str() == " ( 1 2 ) | 3"); - } - - SECTION("Union then intersection") - { - // The (2 3) intersection should be grouped - auto region = openmc::Region("1 | 2 3", 0); - REQUIRE(region.str() == " 1 | ( 2 3 )"); - } - - SECTION("Nested parentheses preserved") - { - // These parentheses are meaningful and should be preserved - auto region = openmc::Region("(1 | 2) (3 | 4)", 0); - REQUIRE(region.str() == " ( 1 | 2 ) ( 3 | 4 )"); - } - - SECTION("Deep nesting") - { - auto region = openmc::Region("((1 2) | (3 4)) 5", 0); - REQUIRE(region.str() == " ( ( 1 2 ) | ( 3 4 ) ) 5"); - } - - SECTION("Multiple unions") - { - auto region = openmc::Region("1 | 2 | 3", 0); - REQUIRE(region.str() == " 1 | 2 | 3"); - } - - SECTION("Multiple intersections") - { - auto region = openmc::Region("1 2 3", 0); - // Simple cell - no operators in output - REQUIRE(region.str() == " 1 2 3"); - } - - SECTION("Complex mixed expression") - { - auto region = openmc::Region("1 2 | 3 4 | 5 6", 0); - REQUIRE(region.str() == " ( 1 2 ) | ( 3 4 ) | ( 5 6 )"); - } -} diff --git a/tests/cpp_unit_tests/test_tally.cpp b/tests/cpp_unit_tests/test_tally.cpp index 03322e764..964d30cc4 100644 --- a/tests/cpp_unit_tests/test_tally.cpp +++ b/tests/cpp_unit_tests/test_tally.cpp @@ -1,4 +1,3 @@ -#include "openmc/tallies/filter_energy.h" #include "openmc/tallies/tally.h" #include @@ -47,34 +46,10 @@ TEST_CASE("Test add/set_filter") REQUIRE(model::filter_map[cell_filter->id()] == tally->filters(0)); REQUIRE(model::filter_map[particle_filter->id()] == tally->filters(1)); - // set filters with a duplicate filter, should only add the filter to the - // tally once + // set filters with a duplicate filter, should only add the filter to the tally once filters = {cell_filter, cell_filter}; tally->set_filters(filters); REQUIRE(tally->filters().size() == 1); REQUIRE(model::filter_map[cell_filter->id()] == tally->filters(0)); -} -// Regression test for 64-bit tally filter-bin counts (mesh x groups > 2^31). -TEST_CASE("Tally filter-bin count does not overflow 32 bits") -{ - // Two energy filters whose bin counts multiply to 2.5e9, above INT32_MAX. - constexpr int64_t bins_per_filter = 50000; - - // Only the bin count matters here, so the edge values are an arbitrary ramp. - std::vector edges(bins_per_filter + 1); - for (int64_t i = 0; i < bins_per_filter + 1; ++i) - edges[i] = static_cast(i); - - Tally* tally = Tally::create(); - for (int i = 0; i < 2; ++i) { - Filter* filter = Filter::create("energy"); - dynamic_cast(filter)->set_bins(edges); - tally->add_filter(filter); - } - tally->set_strides(); - - // set_strides() previously accumulated this product in a 32-bit int. - REQUIRE(tally->n_filter_bins() == bins_per_filter * bins_per_filter); - REQUIRE(tally->n_filter_bins() > 2147483647); } \ No newline at end of file diff --git a/tests/cpp_unit_tests/test_tensor.cpp b/tests/cpp_unit_tests/test_tensor.cpp deleted file mode 100644 index 0936d866a..000000000 --- a/tests/cpp_unit_tests/test_tensor.cpp +++ /dev/null @@ -1,1008 +0,0 @@ -#include -#include - -#include -#include - -#include "openmc/tensor.h" - -using namespace openmc; -using namespace openmc::tensor; - -// ============================================================================ -// Tensor constructors -// ============================================================================ - -TEST_CASE("Tensor default constructor") -{ - Tensor t; - REQUIRE(t.size() == 0); - REQUIRE(t.empty()); - REQUIRE(t.shape().empty()); -} - -TEST_CASE("Tensor shape constructor") -{ - Tensor t1({5}); - REQUIRE(t1.size() == 5); - REQUIRE(t1.shape().size() == 1); - REQUIRE(t1.shape(0) == 5); - - Tensor t2({3, 4}); - REQUIRE(t2.size() == 12); - REQUIRE(t2.shape().size() == 2); - REQUIRE(t2.shape(0) == 3); - REQUIRE(t2.shape(1) == 4); - - Tensor t3({2, 3, 4}); - REQUIRE(t3.size() == 24); - REQUIRE(t3.shape().size() == 3); -} - -TEST_CASE("Tensor shape + fill constructor") -{ - Tensor t({2, 3}, 7.0); - REQUIRE(t.size() == 6); - for (size_t i = 0; i < t.size(); ++i) - REQUIRE(t[i] == 7.0); -} - -TEST_CASE("Tensor pointer constructor") -{ - double vals[] = {1.0, 2.0, 3.0, 4.0}; - Tensor t(vals, 4); - REQUIRE(t.size() == 4); - REQUIRE(t.shape(0) == 4); - REQUIRE(t[0] == 1.0); - REQUIRE(t[1] == 2.0); - REQUIRE(t[2] == 3.0); - REQUIRE(t[3] == 4.0); -} - -TEST_CASE("Tensor copy and move") -{ - Tensor a({2, 3}, 5.0); - Tensor b(a); - REQUIRE(b.size() == 6); - REQUIRE(b(0, 0) == 5.0); - // Modifying copy doesn't affect original - b(0, 0) = 99.0; - REQUIRE(a(0, 0) == 5.0); - - Tensor c(std::move(b)); - REQUIRE(c(0, 0) == 99.0); - REQUIRE(c.size() == 6); -} - -// ============================================================================ -// Tensor indexing -// ============================================================================ - -TEST_CASE("Tensor 1D indexing") -{ - Tensor t({4}, 0); - t[0] = 10; - t[1] = 20; - t[2] = 30; - t[3] = 40; - REQUIRE(t(0) == 10); - REQUIRE(t(1) == 20); - REQUIRE(t(2) == 30); - REQUIRE(t(3) == 40); -} - -TEST_CASE("Tensor 2D indexing (row-major)") -{ - // Layout: [[1, 2, 3], [4, 5, 6]] - Tensor t({2, 3}, 0); - int val = 1; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - t(i, j) = val++; - - REQUIRE(t(0, 0) == 1); - REQUIRE(t(0, 2) == 3); - REQUIRE(t(1, 0) == 4); - REQUIRE(t(1, 2) == 6); - // Flat index should match row-major order - REQUIRE(t[0] == 1); - REQUIRE(t[3] == 4); - REQUIRE(t[5] == 6); -} - -TEST_CASE("Tensor 3D indexing") -{ - // 2x3x4 tensor - Tensor t({2, 3, 4}, 0); - t(1, 2, 3) = 42; - // Flat index: 1*12 + 2*4 + 3 = 23 - REQUIRE(t[23] == 42); - REQUIRE(t(1, 2, 3) == 42); -} - -// ============================================================================ -// Tensor assignment -// ============================================================================ - -TEST_CASE("Tensor initializer_list assignment") -{ - Tensor t; - t = {1.0, 2.0, 3.0}; - REQUIRE(t.size() == 3); - REQUIRE(t.shape(0) == 3); - REQUIRE(t[0] == 1.0); - REQUIRE(t[2] == 3.0); -} - -// ============================================================================ -// Tensor mutation -// ============================================================================ - -TEST_CASE("Tensor resize") -{ - Tensor t({2, 3}, 1.0); - REQUIRE(t.size() == 6); - t.resize({4, 5}); - REQUIRE(t.size() == 20); - REQUIRE(t.shape(0) == 4); - REQUIRE(t.shape(1) == 5); -} - -TEST_CASE("Tensor reshape") -{ - Tensor t({12}, 0); - for (size_t i = 0; i < 12; ++i) - t[i] = static_cast(i); - - t.reshape({3, 4}); - REQUIRE(t.shape(0) == 3); - REQUIRE(t.shape(1) == 4); - REQUIRE(t.size() == 12); - // Data unchanged, just reinterpreted - REQUIRE(t(0, 0) == 0); - REQUIRE(t(1, 0) == 4); // row 1, col 0 = flat index 4 - REQUIRE(t(2, 3) == 11); // row 2, col 3 = flat index 11 -} - -TEST_CASE("Tensor fill") -{ - Tensor t({3, 3}, 0.0); - t.fill(42.0); - for (size_t i = 0; i < t.size(); ++i) - REQUIRE(t[i] == 42.0); -} - -// ============================================================================ -// Tensor iterators -// ============================================================================ - -TEST_CASE("Tensor iterators") -{ - Tensor t({4}, 0); - t = {10, 20, 30, 40}; - int sum = 0; - for (auto val : t) - sum += val; - REQUIRE(sum == 100); -} - -// ============================================================================ -// Tensor reductions -// ============================================================================ - -TEST_CASE("Tensor sum (full)") -{ - Tensor t({3}, 0.0); - t = {1.0, 2.0, 3.0}; - REQUIRE(t.sum() == 6.0); -} - -TEST_CASE("Tensor sum (axis) on 2D") -{ - // [[1, 2, 3], - // [4, 5, 6]] - Tensor t({2, 3}, 0); - int v = 1; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - t(i, j) = v++; - - // Sum along axis 0 -> [5, 7, 9] - Tensor s0 = t.sum(0); - REQUIRE(s0.size() == 3); - REQUIRE(s0[0] == 5); - REQUIRE(s0[1] == 7); - REQUIRE(s0[2] == 9); - - // Sum along axis 1 -> [6, 15] - Tensor s1 = t.sum(1); - REQUIRE(s1.size() == 2); - REQUIRE(s1[0] == 6); - REQUIRE(s1[1] == 15); -} - -TEST_CASE("Tensor sum (axis) on 3D") -{ - // 2x3x2 tensor filled with sequential values 1..12 - Tensor t({2, 3, 2}, 0); - int v = 1; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - for (size_t k = 0; k < 2; ++k) - t(i, j, k) = v++; - - // Sum along axis 1 (middle) -> 2x2, each sums 3 values - // [0,0]: t(0,0,0)+t(0,1,0)+t(0,2,0) = 1+3+5 = 9 - // [0,1]: t(0,0,1)+t(0,1,1)+t(0,2,1) = 2+4+6 = 12 - // [1,0]: t(1,0,0)+t(1,1,0)+t(1,2,0) = 7+9+11 = 27 - // [1,1]: t(1,0,1)+t(1,1,1)+t(1,2,1) = 8+10+12 = 30 - Tensor s = t.sum(1); - REQUIRE(s.shape(0) == 2); - REQUIRE(s.shape(1) == 2); - REQUIRE(s(0, 0) == 9); - REQUIRE(s(0, 1) == 12); - REQUIRE(s(1, 0) == 27); - REQUIRE(s(1, 1) == 30); -} - -TEST_CASE("Tensor prod") -{ - Tensor t({4}, 0); - t = {1, 2, 3, 4}; - REQUIRE(t.prod() == 24); -} - -TEST_CASE("Tensor any and all") -{ - Tensor t({4}, false); - REQUIRE(!t.any()); - REQUIRE(!t.all()); - - // Set one element true - t.data()[0] = true; - REQUIRE(t.any()); - REQUIRE(!t.all()); - - // Set all true - for (size_t i = 0; i < t.size(); ++i) - t.data()[i] = true; - REQUIRE(t.any()); - REQUIRE(t.all()); -} - -TEST_CASE("Tensor argmin") -{ - Tensor t({5}, 0.0); - t = {3.0, 1.0, 4.0, 0.5, 2.0}; - REQUIRE(t.argmin() == 3); -} - -TEST_CASE("Tensor flip") -{ - Tensor t({5}, 0); - t = {1, 2, 3, 4, 5}; - Tensor f = t.flip(0); - REQUIRE(f[0] == 5); - REQUIRE(f[1] == 4); - REQUIRE(f[2] == 3); - REQUIRE(f[3] == 2); - REQUIRE(f[4] == 1); -} - -TEST_CASE("Tensor flip 2D") -{ - // [[1, 2], [3, 4], [5, 6]] - Tensor t({3, 2}, 0); - t(0, 0) = 1; - t(0, 1) = 2; - t(1, 0) = 3; - t(1, 1) = 4; - t(2, 0) = 5; - t(2, 1) = 6; - - // Flip axis 0 reverses rows -> [[5,6],[3,4],[1,2]] - Tensor f = t.flip(0); - REQUIRE(f(0, 0) == 5); - REQUIRE(f(0, 1) == 6); - REQUIRE(f(1, 0) == 3); - REQUIRE(f(2, 0) == 1); -} - -// ============================================================================ -// Tensor operators -// ============================================================================ - -TEST_CASE("Tensor scalar compound assignment") -{ - Tensor t({3}, 0.0); - t = {2.0, 4.0, 6.0}; - - t += 1.0; - REQUIRE(t[0] == 3.0); - REQUIRE(t[1] == 5.0); - - t -= 1.0; - REQUIRE(t[0] == 2.0); - - t *= 3.0; - REQUIRE(t[0] == 6.0); - REQUIRE(t[1] == 12.0); - - t /= 2.0; - REQUIRE(t[0] == 3.0); - REQUIRE(t[1] == 6.0); -} - -TEST_CASE("Tensor element-wise arithmetic") -{ - Tensor a({3}, 0.0); - Tensor b({3}, 0.0); - a = {1.0, 2.0, 3.0}; - b = {4.0, 5.0, 6.0}; - - Tensor c = a + b; - REQUIRE(c[0] == 5.0); - REQUIRE(c[1] == 7.0); - REQUIRE(c[2] == 9.0); - - c = a - b; - REQUIRE(c[0] == -3.0); - - c = a / b; - REQUIRE(c[0] == 0.25); - - c = a * b; - REQUIRE(c[0] == 4.0); -} - -TEST_CASE("Tensor scalar arithmetic") -{ - Tensor a({3}, 0.0); - a = {1.0, 2.0, 3.0}; - - Tensor b = a + 10.0; - REQUIRE(b[0] == 11.0); - REQUIRE(b[2] == 13.0); - - b = a - 1.0; - REQUIRE(b[0] == 0.0); - - b = a * 2.0; - REQUIRE(b[0] == 2.0); - REQUIRE(b[2] == 6.0); - - // Non-member scalar * tensor (commutativity) - b = 2.0 * a; - REQUIRE(b[0] == 2.0); - REQUIRE(b[2] == 6.0); - - // Non-member scalar + tensor - b = 10.0 + a; - REQUIRE(b[0] == 11.0); -} - -TEST_CASE("Tensor compound arithmetic with tensor") -{ - Tensor a({3}, 0.0); - Tensor b({3}, 0.0); - a = {1.0, 2.0, 3.0}; - b = {10.0, 20.0, 30.0}; - a += b; - REQUIRE(a[0] == 11.0); - REQUIRE(a[1] == 22.0); - REQUIRE(a[2] == 33.0); - - a = {1.0, 2.0, 3.0}; - b -= a; - REQUIRE(b[0] == 9.0); - REQUIRE(b[1] == 18.0); - REQUIRE(b[2] == 27.0); - - b = {10.0, 20.0, 30.0}; - a *= b; - REQUIRE(a[0] == 10.0); - REQUIRE(a[1] == 40.0); - REQUIRE(a[2] == 90.0); - - a = {1.0, 2.0, 3.0}; - b /= a; - REQUIRE(b[0] == 10.0); - REQUIRE(b[1] == 10.0); - REQUIRE(b[2] == 10.0); -} - -TEST_CASE("Tensor comparison operators") -{ - Tensor t({4}, 0.0); - t = {1.0, 2.0, 3.0, 4.0}; - - Tensor r = t < 3.0; - REQUIRE(r.data()[0] == true); - REQUIRE(r.data()[1] == true); - REQUIRE(r.data()[2] == false); - REQUIRE(r.data()[3] == false); - - r = t >= 3.0; - REQUIRE(r.data()[0] == false); - REQUIRE(r.data()[2] == true); - REQUIRE(r.data()[3] == true); - - r = t <= 2.0; - REQUIRE(r.data()[0] == true); - REQUIRE(r.data()[1] == true); - REQUIRE(r.data()[2] == false); - - r = t > 3.0; - REQUIRE(r.data()[0] == false); - REQUIRE(r.data()[3] == true); -} - -TEST_CASE("Tensor element-wise comparison") -{ - Tensor a({3}, 0.0); - Tensor b({3}, 0.0); - a = {1.0, 5.0, 3.0}; - b = {2.0, 4.0, 3.0}; - - Tensor r = a < b; - REQUIRE(r.data()[0] == true); - REQUIRE(r.data()[1] == false); - REQUIRE(r.data()[2] == false); -} - -TEST_CASE("Tensor mixed-type multiply") -{ - Tensor a({3}, 0); - Tensor b({3}, 0.0); - a = {2, 3, 4}; - b = {1.5, 2.5, 3.5}; - - Tensor c = a * b; - REQUIRE(c[0] == 3.0); - REQUIRE(c[1] == 7.5); - REQUIRE(c[2] == 14.0); -} - -TEST_CASE("Tensor mixed-type divide") -{ - Tensor a({3}, 0.0); - Tensor b({3}, 0); - a = {10.0, 20.0, 30.0}; - b = {2, 4, 5}; - - Tensor c = a / b; - REQUIRE(c[0] == 5.0); - REQUIRE(c[1] == 5.0); - REQUIRE(c[2] == 6.0); -} - -// ============================================================================ -// Tensor bool specialization -// ============================================================================ - -TEST_CASE("Tensor storage") -{ - // Tensor uses unsigned char internally to avoid std::vector proxy - Tensor t({4}, false); - t.data()[0] = true; - t.data()[2] = true; - REQUIRE(t.any()); - REQUIRE(!t.all()); - REQUIRE(t.data()[0] == true); - REQUIRE(t.data()[1] == false); -} - -// ============================================================================ -// View (via Tensor accessors) -// ============================================================================ - -TEST_CASE("Tensor slice axis 0 (2D)") -{ - // [[1, 2, 3], [4, 5, 6]] - Tensor t({2, 3}, 0); - int v = 1; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - t(i, j) = v++; - - auto r0 = t.slice(0); - REQUIRE(r0.size() == 3); - REQUIRE(r0[0] == 1); - REQUIRE(r0[1] == 2); - REQUIRE(r0[2] == 3); - - auto r1 = t.slice(1); - REQUIRE(r1[0] == 4); - REQUIRE(r1[1] == 5); - REQUIRE(r1[2] == 6); - - // Writing through view modifies the tensor - r0[1] = 99; - REQUIRE(t(0, 1) == 99); -} - -TEST_CASE("Tensor slice axis 1 (2D)") -{ - // [[1, 2], [3, 4], [5, 6]] - Tensor t({3, 2}, 0); - t(0, 0) = 1; - t(0, 1) = 2; - t(1, 0) = 3; - t(1, 1) = 4; - t(2, 0) = 5; - t(2, 1) = 6; - - auto c0 = t.slice(all, 0); - REQUIRE(c0.size() == 3); - REQUIRE(c0[0] == 1); - REQUIRE(c0[1] == 3); - REQUIRE(c0[2] == 5); - - auto c1 = t.slice(all, 1); - REQUIRE(c1[0] == 2); - REQUIRE(c1[1] == 4); - REQUIRE(c1[2] == 6); - - // Write through column view - c1[0] = 77; - REQUIRE(t(0, 1) == 77); -} - -TEST_CASE("Tensor slice with range") -{ - Tensor t({6}, 0); - t = {10, 20, 30, 40, 50, 60}; - - // range(start, end) - auto s = t.slice(range(1, 4)); - REQUIRE(s.size() == 3); - REQUIRE(s[0] == 20); - REQUIRE(s[1] == 30); - REQUIRE(s[2] == 40); - - // range(end) from start — range(3) means [0, 3) - auto s2 = t.slice(range(3)); - REQUIRE(s2.size() == 3); - REQUIRE(s2[0] == 10); - REQUIRE(s2[2] == 30); - - // range(start, SIZE_MAX) to end - auto s3 = t.slice(range(3, 6)); - REQUIRE(s3.size() == 3); - REQUIRE(s3[0] == 40); - REQUIRE(s3[2] == 60); - - // Write through slice - s[0] = 99; - REQUIRE(t[1] == 99); -} - -TEST_CASE("Tensor flat view") -{ - Tensor t({2, 3}, 0); - int v = 1; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - t(i, j) = v++; - - auto f = t.flat(); - REQUIRE(f.size() == 6); - REQUIRE(f[0] == 1); - REQUIRE(f[5] == 6); -} - -TEST_CASE("Tensor slice on 3D") -{ - // 2x3x4 tensor - Tensor t({2, 3, 4}, 0); - int v = 0; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - for (size_t k = 0; k < 4; ++k) - t(i, j, k) = v++; - - // slice(1) -> fix axis 0 at 1 -> 3x4 view - auto s = t.slice(1); - REQUIRE(s.size() == 12); - // t(1,0,0) = 12, t(1,0,1) = 13, ... - REQUIRE(s(0, 0) == 12); - REQUIRE(s(0, 1) == 13); - REQUIRE(s(2, 3) == 23); - - // slice(all, 2) -> fix axis 1 at 2 -> 2x4 view - auto s2 = t.slice(all, 2); - REQUIRE(s2.size() == 8); - // t(0,2,0)=8, t(0,2,1)=9, t(1,2,0)=20 - REQUIRE(s2(0, 0) == 8); - REQUIRE(s2(0, 1) == 9); - REQUIRE(s2(1, 0) == 20); -} - -TEST_CASE("Tensor multi-axis slice") -{ - // 2x3x4 tensor with sequential values - Tensor t({2, 3, 4}, 0); - int v = 0; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - for (size_t k = 0; k < 4; ++k) - t(i, j, k) = v++; - - // slice(1, 2) -> fix axes 0 and 1 -> 1D view of 4 elements - // Equivalent to numpy t[1, 2, :] -> t(1,2,0..3) = [20, 21, 22, 23] - auto s = t.slice(1, 2); - REQUIRE(s.size() == 4); - REQUIRE(s[0] == 20); - REQUIRE(s[1] == 21); - REQUIRE(s[3] == 23); - - // slice(all, 1, range(1, 3)) -> keep axis 0, fix axis 1, range on axis 2 - // Equivalent to numpy t[:, 1, 1:3] - // t(0,1,1)=5, t(0,1,2)=6, t(1,1,1)=17, t(1,1,2)=18 - auto s2 = t.slice(all, 1, range(1, 3)); - REQUIRE(s2.size() == 4); - REQUIRE(s2.ndim() == 2); - REQUIRE(s2(0, 0) == 5); - REQUIRE(s2(0, 1) == 6); - REQUIRE(s2(1, 0) == 17); - REQUIRE(s2(1, 1) == 18); - - // slice(0, range(0, 2)) -> fix axis 0 at 0, range on axis 1 - // Equivalent to numpy t[0, 0:2, :] -> shape (2, 4) - auto s3 = t.slice(0, range(0, 2)); - REQUIRE(s3.ndim() == 2); - REQUIRE(s3.shape(0) == 2); - REQUIRE(s3.shape(1) == 4); - REQUIRE(s3(0, 0) == 0); // t(0,0,0) - REQUIRE(s3(1, 3) == 7); // t(0,1,3) -} - -// ============================================================================ -// View assignment and arithmetic -// ============================================================================ - -TEST_CASE("View scalar assignment (fill)") -{ - Tensor t({2, 3}, 0.0); - auto r = t.slice(0); - r = 7.0; - REQUIRE(t(0, 0) == 7.0); - REQUIRE(t(0, 1) == 7.0); - REQUIRE(t(0, 2) == 7.0); - REQUIRE(t(1, 0) == 0.0); // Other row unchanged -} - -TEST_CASE("View initializer_list assignment") -{ - Tensor t({2, 3}, 0.0); - auto r = t.slice(1); - r = {10.0, 20.0, 30.0}; - REQUIRE(t(1, 0) == 10.0); - REQUIRE(t(1, 1) == 20.0); - REQUIRE(t(1, 2) == 30.0); -} - -TEST_CASE("View copy assignment (deep copy)") -{ - Tensor t({2, 3}, 0.0); - t.slice(0) = {1.0, 2.0, 3.0}; - t.slice(1) = {4.0, 5.0, 6.0}; - - // Copy row 0 into row 1 - t.slice(1) = t.slice(0); - REQUIRE(t(1, 0) == 1.0); - REQUIRE(t(1, 1) == 2.0); - REQUIRE(t(1, 2) == 3.0); -} - -TEST_CASE("View compound operators") -{ - Tensor t({2, 3}, 0.0); - t.slice(0) = {1.0, 2.0, 3.0}; - - t.slice(0) *= 2.0; - REQUIRE(t(0, 0) == 2.0); - REQUIRE(t(0, 1) == 4.0); - - t.slice(0) /= 2.0; - REQUIRE(t(0, 0) == 1.0); - REQUIRE(t(0, 1) == 2.0); -} - -TEST_CASE("View assignment from tensor") -{ - Tensor t({2, 3}, 0.0); - Tensor vals({3}, 0.0); - vals = {7.0, 8.0, 9.0}; - - t.slice(1) = vals; - REQUIRE(t(1, 0) == 7.0); - REQUIRE(t(1, 1) == 8.0); - REQUIRE(t(1, 2) == 9.0); -} - -TEST_CASE("View compound addition from tensor") -{ - Tensor t({2, 3}, 0.0); - t.slice(0) = {1.0, 2.0, 3.0}; - Tensor vals({3}, 0.0); - vals = {10.0, 20.0, 30.0}; - - t.slice(0) += vals; - REQUIRE(t(0, 0) == 11.0); - REQUIRE(t(0, 1) == 22.0); - REQUIRE(t(0, 2) == 33.0); -} - -TEST_CASE("View sum") -{ - Tensor t({2, 3}, 0.0); - t.slice(0) = {1.0, 2.0, 3.0}; - t.slice(1) = {4.0, 5.0, 6.0}; - - REQUIRE(t.slice(0).sum() == 6.0); - REQUIRE(t.slice(1).sum() == 15.0); -} - -TEST_CASE("View iteration") -{ - Tensor t({2, 3}, 0); - t.slice(0) = {1, 2, 3}; - - int sum = 0; - for (auto val : t.slice(0)) - sum += val; - REQUIRE(sum == 6); -} - -TEST_CASE("View sub-slice") -{ - Tensor t({6}, 0); - t = {10, 20, 30, 40, 50, 60}; - - auto s = t.slice(range(1, 5)); // [20, 30, 40, 50] - auto ss = s.slice(range(1, 3)); // [30, 40] - REQUIRE(ss.size() == 2); - REQUIRE(ss[0] == 30); - REQUIRE(ss[1] == 40); -} - -TEST_CASE("Tensor from View") -{ - Tensor t({2, 3}, 0.0); - t.slice(0) = {1.0, 2.0, 3.0}; - - // Construct a new tensor from a view (copies data) - Tensor t2(t.slice(0)); - REQUIRE(t2.size() == 3); - REQUIRE(t2[0] == 1.0); - REQUIRE(t2[2] == 3.0); - - // Modifying the new tensor doesn't affect the original - t2[0] = 99.0; - REQUIRE(t(0, 0) == 1.0); -} - -// ============================================================================ -// Const View -// ============================================================================ - -TEST_CASE("Const tensor produces const views") -{ - Tensor t({2, 3}, 0.0); - int v = 1; - for (size_t i = 0; i < 2; ++i) - for (size_t j = 0; j < 3; ++j) - t(i, j) = v++; - - const Tensor& ct = t; - auto r = ct.slice(0); // View - REQUIRE(r[0] == 1.0); - REQUIRE(r[2] == 3.0); - - auto c = ct.slice(all, 1); - REQUIRE(c[0] == 2.0); - REQUIRE(c[1] == 5.0); -} - -// ============================================================================ -// StaticTensor2D -// ============================================================================ - -TEST_CASE("StaticTensor2D basics") -{ - StaticTensor2D t; - REQUIRE(t.size() == 12); - REQUIRE(t.shape()[0] == 3); - REQUIRE(t.shape()[1] == 4); - - // Default-initialized to zero - REQUIRE(t(0, 0) == 0.0); - - t(1, 2) = 42.0; - REQUIRE(t(1, 2) == 42.0); - // Flat data: row 1, col 2 = index 1*4 + 2 = 6 - REQUIRE(t.data()[6] == 42.0); -} - -TEST_CASE("StaticTensor2D fill") -{ - StaticTensor2D t; - t.fill(5); - for (size_t i = 0; i < t.size(); ++i) - REQUIRE(t.data()[i] == 5); -} - -TEST_CASE("StaticTensor2D iteration") -{ - StaticTensor2D t; - t.fill(1); - int sum = 0; - for (auto val : t) - sum += val; - REQUIRE(sum == 6); -} - -TEST_CASE("StaticTensor2D slice") -{ - StaticTensor2D t; - t(0, 0) = 1; - t(0, 1) = 2; - t(1, 0) = 3; - t(1, 1) = 4; - t(2, 0) = 5; - t(2, 1) = 6; - - // slice(1) = row 1 (fix axis 0 at 1) - auto r1 = t.slice(1); - REQUIRE(r1.size() == 2); - REQUIRE(r1[0] == 3); - REQUIRE(r1[1] == 4); - - // slice(all, 0) = column 0 (fix axis 1 at 0) - auto c0 = t.slice(all, 0); - REQUIRE(c0.size() == 3); - REQUIRE(c0[0] == 1); - REQUIRE(c0[1] == 3); - REQUIRE(c0[2] == 5); -} - -TEST_CASE("StaticTensor2D flat view") -{ - StaticTensor2D t; - t(0, 0) = 1.0; - t(0, 1) = 2.0; - t(1, 0) = 3.0; - t(1, 1) = 4.0; - - auto f = t.flat(); - REQUIRE(f.size() == 4); - f = 0.0; - REQUIRE(t(0, 0) == 0.0); - REQUIRE(t(1, 1) == 0.0); -} - -// ============================================================================ -// Non-member functions -// ============================================================================ - -TEST_CASE("zeros") -{ - auto t = zeros({3, 4}); - REQUIRE(t.size() == 12); - for (size_t i = 0; i < t.size(); ++i) - REQUIRE(t[i] == 0.0); -} - -TEST_CASE("zeros_like") -{ - Tensor a({2, 5}, 7.0); - auto b = zeros_like(a); - REQUIRE(b.size() == 10); - REQUIRE(b.shape(0) == 2); - REQUIRE(b.shape(1) == 5); - for (size_t i = 0; i < b.size(); ++i) - REQUIRE(b[i] == 0.0); -} - -TEST_CASE("full_like") -{ - Tensor a({4}, 0); - auto b = full_like(a, 42); - REQUIRE(b.size() == 4); - for (size_t i = 0; i < b.size(); ++i) - REQUIRE(b[i] == 42); -} - -TEST_CASE("linspace") -{ - auto t = linspace(0.0, 1.0, 5); - REQUIRE(t.size() == 5); - REQUIRE(t[0] == 0.0); - REQUIRE(t[4] == 1.0); - REQUIRE_THAT(t[1], Catch::Matchers::WithinRel(0.25, 1e-12)); - REQUIRE_THAT(t[2], Catch::Matchers::WithinRel(0.5, 1e-12)); - REQUIRE_THAT(t[3], Catch::Matchers::WithinRel(0.75, 1e-12)); -} - -TEST_CASE("concatenate") -{ - Tensor a({3}, 0); - Tensor b({2}, 0); - a = {1, 2, 3}; - b = {4, 5}; - - auto c = concatenate(a, b); - REQUIRE(c.size() == 5); - REQUIRE(c[0] == 1); - REQUIRE(c[2] == 3); - REQUIRE(c[3] == 4); - REQUIRE(c[4] == 5); -} - -TEST_CASE("log") -{ - Tensor t({3}, 0.0); - t = {1.0, std::exp(1.0), std::exp(2.0)}; - - auto r = log(t); - REQUIRE_THAT(r[0], Catch::Matchers::WithinAbs(0.0, 1e-12)); - REQUIRE_THAT(r[1], Catch::Matchers::WithinAbs(1.0, 1e-12)); - REQUIRE_THAT(r[2], Catch::Matchers::WithinAbs(2.0, 1e-12)); -} - -TEST_CASE("abs") -{ - Tensor t({4}, 0.0); - t = {-3.0, -1.0, 0.0, 2.0}; - - auto r = abs(t); - REQUIRE(r[0] == 3.0); - REQUIRE(r[1] == 1.0); - REQUIRE(r[2] == 0.0); - REQUIRE(r[3] == 2.0); -} - -TEST_CASE("where") -{ - Tensor cond({4}, false); - cond.data()[0] = true; - cond.data()[2] = true; - - Tensor vals({4}, 0.0); - vals = {10.0, 20.0, 30.0, 40.0}; - - auto r = where(cond, vals, -1.0); - REQUIRE(r[0] == 10.0); - REQUIRE(r[1] == -1.0); - REQUIRE(r[2] == 30.0); - REQUIRE(r[3] == -1.0); -} - -TEST_CASE("nan_to_num") -{ - Tensor t({4}, 0.0); - t[0] = 1.0; - t[1] = std::nan(""); - t[2] = std::numeric_limits::infinity(); - t[3] = -std::numeric_limits::infinity(); - - auto r = nan_to_num(t); - REQUIRE(r[0] == 1.0); - REQUIRE(r[1] == 0.0); // NaN -> 0 - REQUIRE(r[2] == std::numeric_limits::max()); // +inf -> max - REQUIRE(r[3] == std::numeric_limits::lowest()); // -inf -> lowest -} - -// ============================================================================ -// is_tensor trait -// ============================================================================ - -TEST_CASE("is_tensor trait") -{ - REQUIRE(is_tensor>::value); - REQUIRE(is_tensor>::value); - REQUIRE(is_tensor>::value); - REQUIRE(!is_tensor::value); - REQUIRE(!is_tensor>::value); -} diff --git a/tests/dummy_operator.py b/tests/dummy_operator.py index 873633525..1bb00129d 100644 --- a/tests/dummy_operator.py +++ b/tests/dummy_operator.py @@ -24,7 +24,7 @@ DepletionSolutionTuple = namedtuple( predictor_solution = DepletionSolutionTuple( PredictorIntegrator, np.array([1.0, 2.46847546272295, 4.11525874568034]), - np.array([1.0, 0.986431226850467, 0.0])) + np.array([1.0, 0.986431226850467, -0.0581692232513460])) cecm_solution = DepletionSolutionTuple( @@ -243,4 +243,4 @@ class DummyOperator(TransportOperator): Maps cell name to index in global geometry. """ - return self.volume, self.nuc_list, self.local_mats, self.burnable_mats, {"1": ""} + return self.volume, self.nuc_list, self.local_mats, self.burnable_mats diff --git a/tests/fns_flux_709.npy b/tests/fns_flux_709.npy deleted file mode 100644 index 62c612842..000000000 Binary files a/tests/fns_flux_709.npy and /dev/null differ diff --git a/tests/regression_tests/__init__.py b/tests/regression_tests/__init__.py index e1cb56f1d..ba48fc01e 100644 --- a/tests/regression_tests/__init__.py +++ b/tests/regression_tests/__init__.py @@ -12,17 +12,6 @@ config = { } -def assert_same_mats(res_ref, res_test): - for mat in res_ref[0].index_mat: - assert mat in res_test[0].index_mat, f"Material {mat} not in new results." - for nuc in res_ref[0].index_nuc: - assert nuc in res_test[0].index_nuc, f"Nuclide {nuc} not in new results." - for mat in res_test[0].index_mat: - assert mat in res_ref[0].index_mat, f"Material {mat} not in old results." - for nuc in res_test[0].index_nuc: - assert nuc in res_ref[0].index_nuc, f"Nuclide {nuc} not in old results." - - def assert_atoms_equal(res_ref, res_test, tol=1e-5): for mat in res_test[0].index_mat: for nuc in res_test[0].index_nuc: diff --git a/tests/regression_tests/adj_cell_rotation/inputs_true.dat b/tests/regression_tests/adj_cell_rotation/inputs_true.dat index 18c0552ce..7e2a0cf62 100644 --- a/tests/regression_tests/adj_cell_rotation/inputs_true.dat +++ b/tests/regression_tests/adj_cell_rotation/inputs_true.dat @@ -1,35 +1,35 @@ - - - + + + - - + + - - - - - - - - - - + + + + + + + + + + eigenvalue 10000 10 5 - + -4.0 -4.0 -4.0 4.0 4.0 4.0 diff --git a/tests/regression_tests/adj_cell_rotation/results_true.dat b/tests/regression_tests/adj_cell_rotation/results_true.dat index ddb1546b5..b3df12e71 100644 --- a/tests/regression_tests/adj_cell_rotation/results_true.dat +++ b/tests/regression_tests/adj_cell_rotation/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.368327E-01 1.953533E-03 +4.403987E-01 1.514158E-03 diff --git a/tests/regression_tests/albedo_box/results_true.dat b/tests/regression_tests/albedo_box/results_true.dat index dca80abcd..0f571f245 100644 --- a/tests/regression_tests/albedo_box/results_true.dat +++ b/tests/regression_tests/albedo_box/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.593206E+00 2.925742E-03 +1.590800E+00 4.251788E-03 diff --git a/tests/regression_tests/asymmetric_lattice/inputs_true.dat b/tests/regression_tests/asymmetric_lattice/inputs_true.dat index ee3d68907..302ef24c2 100644 --- a/tests/regression_tests/asymmetric_lattice/inputs_true.dat +++ b/tests/regression_tests/asymmetric_lattice/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + - + @@ -47,7 +47,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -149,7 +149,7 @@ - + @@ -157,7 +157,7 @@ - + 1.26 1.26 17 17 @@ -190,25 +190,25 @@ 8 8 8 7 7 7 - - - - - - - - - - - - + + + + + + + + + + + + eigenvalue 100 10 5 - + -32 -32 0 32 32 32 diff --git a/tests/regression_tests/asymmetric_lattice/results_true.dat b/tests/regression_tests/asymmetric_lattice/results_true.dat index 3d6b610a6..741327d80 100644 --- a/tests/regression_tests/asymmetric_lattice/results_true.dat +++ b/tests/regression_tests/asymmetric_lattice/results_true.dat @@ -1 +1 @@ -cc76769636be4f681137598cf366e978d7347425a1dfa1b293d17a28381b2b62595fb7f0d2f126dd06972ff9e79089a18dd53aba45fa2b1f316515b91fe6495a \ No newline at end of file +b0ca1fb0436732188b1a199b3250ca9a33782f8fc379b0f7ff9c582e0c794b0a0470df063cafd0b05e802b26f61eaaf9ff5c0a8a672a933246acf49eed3ebf9f \ No newline at end of file diff --git a/tests/regression_tests/atomic_relaxation/inputs_true.dat b/tests/regression_tests/atomic_relaxation/inputs_true.dat deleted file mode 100644 index 637e04285..000000000 --- a/tests/regression_tests/atomic_relaxation/inputs_true.dat +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - fixed source - 10000 - 1 - - - 1000000.0 1.0 - - - led - false - true - - - - photon electron - - - 1 - flux heating - - - diff --git a/tests/regression_tests/atomic_relaxation/results_true.dat b/tests/regression_tests/atomic_relaxation/results_true.dat deleted file mode 100644 index 6f100dac8..000000000 --- a/tests/regression_tests/atomic_relaxation/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -1.956204E+00 -3.826732E+00 -7.918768E+04 -6.270688E+09 -0.000000E+00 -0.000000E+00 -9.208123E+05 -8.478953E+11 diff --git a/tests/regression_tests/atomic_relaxation/test.py b/tests/regression_tests/atomic_relaxation/test.py deleted file mode 100644 index 0d2413f59..000000000 --- a/tests/regression_tests/atomic_relaxation/test.py +++ /dev/null @@ -1,41 +0,0 @@ -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - mat = openmc.Material() - mat.add_nuclide('Pb208', 1.0) - mat.set_density('g/cm3', 11.35) - - sphere = openmc.Sphere(r=1.0e9, boundary_type='reflective') - inside_sphere = openmc.Cell(fill=mat, region=-sphere) - model = openmc.Model() - model.geometry = openmc.Geometry([inside_sphere]) - - # Isotropic point source of 1 MeV photons at the origin - model.settings.source = openmc.IndependentSource( - particle='photon', - energy=openmc.stats.delta_function(1.0e6) - ) - - # Fixed-source photon transport with atomic relaxation disabled - model.settings.particles = 10000 - model.settings.batches = 1 - model.settings.photon_transport = True - model.settings.electron_treatment = 'led' - model.settings.atomic_relaxation = False - model.settings.run_mode = 'fixed source' - - tally = openmc.Tally() - tally.filters = [openmc.ParticleFilter(['photon', 'electron'])] - tally.scores = ['flux', 'heating'] - model.tallies = [tally] - return model - - -def test_atomic_relaxation(model): - harness = PyAPITestHarness('statepoint.1.h5', model=model) - harness.main() diff --git a/tests/regression_tests/cmfd_feed/results_true.dat b/tests/regression_tests/cmfd_feed/results_true.dat index 1ef9624d4..f5f22d9ac 100644 --- a/tests/regression_tests/cmfd_feed/results_true.dat +++ b/tests/regression_tests/cmfd_feed/results_true.dat @@ -1,117 +1,117 @@ k-combined: -1.181723E+00 9.944883E-03 +1.164262E+00 9.207592E-03 tally 1: -1.169899E+01 -1.373251E+01 -2.142380E+01 -4.605511E+01 -2.968085E+01 -8.838716E+01 -3.561418E+01 -1.271206E+02 -3.777783E+01 -1.428817E+02 -3.805832E+01 -1.450213E+02 -3.439836E+01 -1.184892E+02 -2.852438E+01 -8.161896E+01 -2.088423E+01 -4.376204E+01 -1.076670E+01 -1.168108E+01 +1.156972E+01 +1.339924E+01 +2.136306E+01 +4.567185E+01 +2.859527E+01 +8.195821E+01 +3.470754E+01 +1.207851E+02 +3.766403E+01 +1.422263E+02 +3.778821E+01 +1.432660E+02 +3.573197E+01 +1.278854E+02 +2.849979E+01 +8.135515E+01 +2.073803E+01 +4.303374E+01 +1.112117E+01 +1.242944E+01 tally 2: -2.321241E+01 -2.702156E+01 -1.620912E+01 -1.317752E+01 -4.197404E+01 -8.845008E+01 -2.982666E+01 -4.469221E+01 -5.810089E+01 -1.695857E+02 -4.134123E+01 -8.588866E+01 -6.982488E+01 -2.447068E+02 -4.966939E+01 -1.238763E+02 -7.428421E+01 -2.767613E+02 -5.287955E+01 -1.403163E+02 -7.447402E+01 -2.785012E+02 -5.324628E+01 -1.423393E+02 -6.895164E+01 -2.381937E+02 -4.916366E+01 -1.211701E+02 -5.679253E+01 -1.617881E+02 -4.043125E+01 -8.204061E+01 -4.218618E+01 -8.933666E+01 -2.978592E+01 -4.456592E+01 -2.196426E+01 -2.435867E+01 -1.525576E+01 -1.175879E+01 +2.388054E+01 +2.875255E+01 +1.667791E+01 +1.403426E+01 +4.224771E+01 +8.942109E+01 +2.993088E+01 +4.490335E+01 +5.689839E+01 +1.625557E+02 +4.043633E+01 +8.212299E+01 +6.764024E+01 +2.297126E+02 +4.807902E+01 +1.161468E+02 +7.314835E+01 +2.684645E+02 +5.203584E+01 +1.359261E+02 +7.375727E+01 +2.733105E+02 +5.252944E+01 +1.386205E+02 +6.909571E+01 +2.397721E+02 +4.922548E+01 +1.217465E+02 +5.685978E+01 +1.621746E+02 +4.051938E+01 +8.237277E+01 +4.185562E+01 +8.784067E+01 +2.983570E+01 +4.467414E+01 +2.238373E+01 +2.520356E+01 +1.566758E+01 +1.234103E+01 tally 3: -1.563788E+01 -1.226528E+01 -1.053289E+00 -5.666942E-02 -2.870755E+01 -4.139654E+01 -1.838017E+00 -1.710528E-01 -3.978616E+01 -7.955764E+01 -2.560657E+00 -3.334449E-01 -4.780385E+01 -1.147770E+02 -3.139243E+00 -4.967628E-01 -5.106650E+01 -1.308704E+02 -3.170056E+00 -5.078920E-01 -5.123992E+01 -1.318586E+02 -3.211706E+00 -5.205979E-01 -4.729862E+01 -1.121695E+02 -3.068662E+00 -4.749488E-01 -3.898816E+01 -7.630564E+01 -2.516911E+00 -3.199696E-01 -2.865357E+01 -4.125742E+01 -1.852314E+00 -1.741116E-01 -1.467340E+01 -1.088460E+01 -9.268633E-01 -4.450662E-02 +1.609520E+01 +1.307542E+01 +1.033429E+00 +5.510889E-02 +2.877073E+01 +4.149542E+01 +1.964219E+00 +1.954692E-01 +3.896816E+01 +7.629752E+01 +2.484053E+00 +3.103733E-01 +4.634285E+01 +1.079367E+02 +2.974750E+00 +4.468223E-01 +5.007964E+01 +1.259202E+02 +3.181802E+00 +5.103621E-01 +5.058915E+01 +1.286193E+02 +3.249442E+00 +5.337712E-01 +4.744464E+01 +1.131026E+02 +3.067644E+00 +4.736335E-01 +3.900632E+01 +7.634433E+01 +2.443552E+00 +3.028060E-01 +2.874166E+01 +4.146375E+01 +1.810421E+00 +1.671667E-01 +1.509222E+01 +1.145579E+01 +1.014919E+00 +5.391053E-02 tally 4: -3.029754E+00 -4.613561E-01 +3.148231E+00 +4.974555E-01 0.000000E+00 0.000000E+00 -2.832501E+00 -4.049252E-01 -5.517243E+00 -1.527794E+00 +2.805439E+00 +3.982239E-01 +5.574031E+00 +1.561105E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -128,14 +128,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.517243E+00 -1.527794E+00 -2.832501E+00 -4.049252E-01 -5.117178E+00 -1.316972E+00 -7.333303E+00 -2.701677E+00 +5.574031E+00 +1.561105E+00 +2.805439E+00 +3.982239E-01 +5.171038E+00 +1.344877E+00 +7.372031E+00 +2.725420E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -152,14 +152,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.333303E+00 -2.701677E+00 -5.117178E+00 -1.316972E+00 -7.248464E+00 -2.641591E+00 -8.817788E+00 -3.905530E+00 +7.372031E+00 +2.725420E+00 +5.171038E+00 +1.344877E+00 +6.946847E+00 +2.424850E+00 +8.496610E+00 +3.627542E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -176,14 +176,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.817788E+00 -3.905530E+00 -7.248464E+00 -2.641591E+00 -8.646465E+00 -3.749847E+00 -9.460948E+00 -4.495388E+00 +8.496610E+00 +3.627542E+00 +6.946847E+00 +2.424850E+00 +8.479501E+00 +3.607280E+00 +9.261869E+00 +4.305912E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -200,14 +200,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.460948E+00 -4.495388E+00 -8.646465E+00 -3.749847E+00 -9.379341E+00 -4.415049E+00 -9.278640E+00 -4.320720E+00 +9.261869E+00 +4.305912E+00 +8.479501E+00 +3.607280E+00 +9.232858E+00 +4.278432E+00 +9.306384E+00 +4.348594E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -224,14 +224,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.278640E+00 -4.320720E+00 -9.379341E+00 -4.415049E+00 -9.465746E+00 -4.498591E+00 -8.656146E+00 -3.760545E+00 +9.306384E+00 +4.348594E+00 +9.232858E+00 +4.278432E+00 +9.299764E+00 +4.347828E+00 +8.511976E+00 +3.639893E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -248,14 +248,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.656146E+00 -3.760545E+00 -9.465746E+00 -4.498591E+00 -8.589782E+00 -3.700308E+00 -6.996002E+00 -2.456935E+00 +8.511976E+00 +3.639893E+00 +9.299764E+00 +4.347828E+00 +8.726086E+00 +3.819567E+00 +7.147277E+00 +2.562747E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -272,14 +272,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.996002E+00 -2.456935E+00 -8.589782E+00 -3.700308E+00 -7.352050E+00 -2.714808E+00 -5.105164E+00 -1.312559E+00 +7.147277E+00 +2.562747E+00 +8.726086E+00 +3.819567E+00 +7.218790E+00 +2.612243E+00 +5.018287E+00 +1.263077E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -296,14 +296,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.105164E+00 -1.312559E+00 -7.352050E+00 -2.714808E+00 -5.442756E+00 -1.486776E+00 -2.697305E+00 -3.675580E-01 +5.018287E+00 +1.263077E+00 +7.218790E+00 +2.612243E+00 +5.443494E+00 +1.487018E+00 +2.732334E+00 +3.773047E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -320,12 +320,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.697305E+00 -3.675580E-01 -5.442756E+00 -1.486776E+00 -3.017025E+00 -4.571443E-01 +2.732334E+00 +3.773047E-01 +5.443494E+00 +1.487018E+00 +3.044773E+00 +4.655756E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -345,144 +345,144 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -1.563588E+01 -1.226217E+01 -2.209027E+00 -2.507131E-01 -2.870034E+01 -4.137550E+01 -3.726620E+00 -7.021948E-01 -3.977762E+01 -7.952285E+01 -5.304975E+00 -1.427333E+00 -4.779747E+01 -1.147456E+02 -6.528302E+00 -2.151715E+00 -5.105366E+01 -1.308037E+02 -6.986782E+00 -2.467487E+00 -5.123380E+01 -1.318264E+02 -6.845633E+00 -2.383542E+00 -4.729296E+01 -1.121433E+02 -6.252695E+00 -1.977351E+00 -3.898236E+01 -7.628315E+01 -5.461495E+00 -1.528579E+00 -2.864576E+01 -4.123538E+01 -3.857301E+00 -7.581323E-01 -1.467047E+01 -1.088031E+01 -2.277024E+00 -2.679801E-01 +1.609029E+01 +1.306718E+01 +2.230601E+00 +2.559496E-01 +2.876780E+01 +4.148686E+01 +3.835952E+00 +7.456562E-01 +3.895738E+01 +7.625344E+01 +4.841024E+00 +1.197335E+00 +4.633595E+01 +1.079043E+02 +6.236821E+00 +1.963311E+00 +5.007472E+01 +1.258967E+02 +6.749745E+00 +2.297130E+00 +5.058336E+01 +1.285894E+02 +6.727612E+00 +2.315656E+00 +4.743869E+01 +1.130735E+02 +6.338193E+00 +2.042159E+00 +3.899838E+01 +7.631289E+01 +5.187573E+00 +1.359733E+00 +2.873434E+01 +4.144233E+01 +3.815610E+00 +7.367619E-01 +1.509020E+01 +1.145268E+01 +2.125767E+00 +2.341894E-01 cmfd indices 1.000000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.169107E+00 -1.175079E+00 -1.173912E+00 -1.175368E+00 -1.174026E+00 -1.181745E+00 -1.182261E+00 -1.183559E+00 -1.178691E+00 -1.179222E+00 -1.179017E+00 -1.172979E+00 -1.175043E+00 -1.173458E+00 -1.174152E+00 -1.171451E+00 +1.129918E+00 +1.143848E+00 +1.147976E+00 +1.151534E+00 +1.152378E+00 +1.148219E+00 +1.150402E+00 +1.154647E+00 +1.156159E+00 +1.160048E+00 +1.167441E+00 +1.168163E+00 +1.168629E+00 +1.164120E+00 +1.165051E+00 +1.169177E+00 cmfd entropy -3.207640E+00 -3.210547E+00 -3.212218E+00 -3.209573E+00 -3.211619E+00 -3.212126E+00 -3.213163E+00 -3.214288E+00 -3.215737E+00 -3.213677E+00 -3.214925E+00 -3.215612E+00 -3.216708E+00 -3.221454E+00 -3.219048E+00 -3.218387E+00 +3.224769E+00 +3.225945E+00 +3.227421E+00 +3.226174E+00 +3.224429E+00 +3.227049E+00 +3.230710E+00 +3.230315E+00 +3.226825E+00 +3.226655E+00 +3.226588E+00 +3.224155E+00 +3.223246E+00 +3.222640E+00 +3.223920E+00 +3.222838E+00 cmfd balance -4.88208E-03 -4.75139E-03 -3.15783E-03 -3.67091E-03 -2.99797E-03 -2.91060E-03 -2.06576E-03 -1.83482E-03 -1.56292E-03 -1.58659E-03 -2.32986E-03 -1.47376E-03 -1.46673E-03 -1.22627E-03 -1.31963E-03 -1.26456E-03 +3.90454E-03 +4.08089E-03 +3.46511E-03 +4.09535E-03 +2.62009E-03 +2.23559E-03 +2.54033E-03 +2.12799E-03 +2.25864E-03 +1.85766E-03 +1.49916E-03 +1.63471E-03 +1.48377E-03 +1.59800E-03 +1.37354E-03 +1.32853E-03 cmfd dominance ratio -5.467E-01 -5.453E-01 -5.458E-01 -5.436E-01 -5.442E-01 -5.406E-01 -5.401E-01 -5.413E-01 -4.995E-01 -5.396E-01 -5.409E-01 -5.414E-01 -5.423E-01 -5.456E-01 -5.442E-01 +5.539E-01 +5.537E-01 +5.536E-01 +5.515E-01 +5.512E-01 +5.514E-01 +5.518E-01 +5.507E-01 +5.500E-01 +5.497E-01 +5.477E-01 +5.461E-01 +5.444E-01 +5.445E-01 +5.454E-01 5.441E-01 cmfd openmc source comparison -9.587418E-03 -8.150978E-03 -6.677661E-03 -6.334727E-03 -5.153692E-03 -5.082964E-03 -4.633153E-03 -4.037383E-03 -3.528742E-03 -4.559089E-03 -3.517370E-03 -3.306117E-03 -2.913809E-03 -1.906045E-03 -1.932794E-03 -1.711341E-03 +9.875240E-03 +1.106163E-02 +9.847628E-03 +6.065921E-03 +5.772039E-03 +4.615656E-03 +4.244331E-03 +3.694299E-03 +3.545814E-03 +3.213063E-03 +3.467537E-03 +3.383489E-03 +3.697591E-03 +3.937358E-03 +3.369124E-03 +3.190359E-03 cmfd source -4.496492E-02 -7.869674E-02 -1.100280E-01 -1.354045E-01 -1.363339E-01 -1.380533E-01 -1.314512E-01 -1.077480E-01 -7.847306E-02 -3.884630E-02 +4.360494E-02 +8.397599E-02 +1.074181E-01 +1.294531E-01 +1.385611E-01 +1.407934E-01 +1.325191E-01 +1.044311E-01 +7.660359E-02 +4.263941E-02 diff --git a/tests/regression_tests/cmfd_feed_2g/results_true.dat b/tests/regression_tests/cmfd_feed_2g/results_true.dat index e66eae13c..2b61d9f4e 100644 --- a/tests/regression_tests/cmfd_feed_2g/results_true.dat +++ b/tests/regression_tests/cmfd_feed_2g/results_true.dat @@ -1,112 +1,112 @@ k-combined: -1.027434E+00 6.509170E-03 +1.035567E+00 9.463160E-03 tally 1: -1.162758E+02 -1.352562E+03 -1.138125E+02 -1.295815E+03 -1.143712E+02 -1.308316E+03 -1.150293E+02 -1.323834E+03 +1.146535E+02 +1.315267E+03 +1.157458E+02 +1.340166E+03 +1.140491E+02 +1.301364E+03 +1.146589E+02 +1.315433E+03 tally 2: -4.284580E+01 -9.207089E+01 -6.335165E+01 -2.014931E+02 -1.894187E+02 -1.818190E+03 -1.033212E+02 -5.340768E+02 -4.282771E+01 -9.186295E+01 -6.295029E+01 -1.983895E+02 -1.834276E+02 -1.684375E+03 -1.022482E+02 -5.228403E+02 -4.330690E+01 -9.402038E+01 -6.395965E+01 -2.053163E+02 -1.851113E+02 -1.714198E+03 -1.030809E+02 -5.314535E+02 -4.337097E+01 -9.426435E+01 -6.417590E+01 -2.063443E+02 -1.846817E+02 -1.706518E+03 -1.027233E+02 -5.279582E+02 +4.319968E+01 +9.360083E+01 +6.373035E+01 +2.038056E+02 +1.889646E+02 +1.812892E+03 +1.024866E+02 +5.254528E+02 +4.323262E+01 +9.360200E+01 +6.363111E+01 +2.028178E+02 +1.849746E+02 +1.711533E+03 +1.034532E+02 +5.352768E+02 +4.296541E+01 +9.249656E+01 +6.346919E+01 +2.018659E+02 +1.888697E+02 +1.812037E+03 +1.025707E+02 +5.262261E+02 +4.691085E+01 +1.269707E+02 +6.299377E+01 +1.990497E+02 +1.853864E+02 +1.719984E+03 +1.023015E+02 +5.235858E+02 tally 3: -5.992726E+01 -1.803120E+02 +6.034963E+01 +1.827718E+02 0.000000E+00 0.000000E+00 -2.172646E-02 -4.414237E-05 -4.181401E+00 -8.912796E-01 -3.536506E+00 -6.287425E-01 +1.865665E-02 +4.244195E-05 +4.170941E+00 +8.769372E-01 +3.453368E+00 +5.989168E-01 0.000000E+00 0.000000E+00 -9.824432E+01 -4.828691E+02 -9.116848E-01 -4.231247E-02 -5.955090E+01 -1.775522E+02 +9.743205E+01 +4.749420E+02 +8.570316E-01 +3.807993E-02 +6.005903E+01 +1.807233E+02 0.000000E+00 0.000000E+00 -1.893222E-02 -3.288000E-05 -4.048183E+00 -8.291130E-01 -3.384041E+00 -5.742363E-01 +1.885450E-02 +3.653402E-05 +4.323863E+00 +9.447512E-01 +3.465465E+00 +6.022861E-01 0.000000E+00 0.000000E+00 -9.734253E+01 -4.738861E+02 -9.157632E-01 -4.329280E-02 -6.045835E+01 -1.835255E+02 +9.843481E+01 +4.846158E+02 +9.048150E-01 +4.205551E-02 +5.996660E+01 +1.802150E+02 0.000000E+00 0.000000E+00 -1.501842E-02 -1.896931E-05 -4.289989E+00 -9.251538E-01 -3.481357E+00 -6.071667E-01 +1.221444E-02 +2.263445E-05 +4.301287E+00 +9.309882E-01 +3.456076E+00 +5.992144E-01 0.000000E+00 0.000000E+00 -9.799829E+01 -4.803591E+02 -8.899390E-01 -4.078750E-02 -6.064531E+01 -1.842746E+02 +9.761231E+01 +4.765834E+02 +8.434644E-01 +3.728180E-02 +5.961891E+01 +1.783106E+02 0.000000E+00 0.000000E+00 -1.495496E-02 -3.082640E-05 -4.321537E+00 -9.371611E-01 -3.453767E+00 -5.983727E-01 +1.500709E-02 +3.541280E-05 +4.155669E+00 +8.713442E-01 +3.455342E+00 +6.006426E-01 0.000000E+00 0.000000E+00 -9.771776E+01 -4.777781E+02 -8.975444E-01 -4.157471E-02 +9.726798E+01 +4.733393E+02 +9.202611E-01 +4.390503E-02 tally 4: 0.000000E+00 0.000000E+00 @@ -116,14 +116,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.840487E+00 -3.915792E+00 -3.700362E+01 -6.851588E+01 -8.756789E+00 -3.844443E+00 -3.672366E+01 -6.747174E+01 +8.943264E+00 +4.008855E+00 +3.661063E+01 +6.704808E+01 +8.945553E+00 +4.011707E+00 +3.696832E+01 +6.835286E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -132,14 +132,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.860460E+00 -3.940908E+00 -3.704658E+01 -6.864069E+01 -8.832046E+00 -3.916611E+00 -3.736239E+01 -6.982147E+01 +8.844569E+00 +3.924591E+00 +3.666726E+01 +6.726522E+01 +8.769637E+00 +3.855006E+00 +3.654115E+01 +6.680777E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -156,14 +156,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.756789E+00 -3.844443E+00 -3.672366E+01 -6.747174E+01 -8.840487E+00 -3.915792E+00 -3.700362E+01 -6.851588E+01 +8.945553E+00 +4.011707E+00 +3.696832E+01 +6.835286E+01 +8.943264E+00 +4.008855E+00 +3.661063E+01 +6.704808E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -180,14 +180,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.892576E+00 -3.964978E+00 -3.703525E+01 -6.860645E+01 -8.824229E+00 -3.906925E+00 -3.685909E+01 -6.796123E+01 +8.648474E+00 +3.752219E+00 +3.689442E+01 +6.808997E+01 +8.757378E+00 +3.850408E+00 +3.716920E+01 +6.909715E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -212,22 +212,22 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.050876E+00 -4.111409E+00 -3.656082E+01 -6.687580E+01 -9.042402E+00 -4.105842E+00 -3.687247E+01 -6.801050E+01 -8.832046E+00 -3.916611E+00 -3.736239E+01 -6.982147E+01 -8.860460E+00 -3.940908E+00 -3.704658E+01 -6.864069E+01 +8.783669E+00 +3.870748E+00 +3.687358E+01 +6.802581E+01 +8.755250E+00 +3.846298E+00 +3.660278E+01 +6.704349E+01 +8.769637E+00 +3.855006E+00 +3.654115E+01 +6.680777E+01 +8.844569E+00 +3.924591E+00 +3.666726E+01 +6.726522E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -252,14 +252,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.042402E+00 -4.105842E+00 -3.687247E+01 -6.801050E+01 -9.050876E+00 -4.111409E+00 -3.656082E+01 -6.687580E+01 +8.755250E+00 +3.846298E+00 +3.660278E+01 +6.704349E+01 +8.783669E+00 +3.870748E+00 +3.687358E+01 +6.802581E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -268,14 +268,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.824229E+00 -3.906925E+00 -3.685909E+01 -6.796123E+01 -8.892576E+00 -3.964978E+00 -3.703525E+01 -6.860645E+01 +8.757378E+00 +3.850408E+00 +3.716920E+01 +6.909715E+01 +8.648474E+00 +3.752219E+00 +3.689442E+01 +6.808997E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -301,133 +301,133 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -5.994898E+01 -1.804403E+02 -1.017670E+02 -5.181130E+02 -1.354160E+01 -9.220935E+00 -4.648971E+01 -1.081636E+02 -5.956983E+01 -1.776668E+02 -1.007226E+02 -5.073592E+02 -1.347883E+01 -9.120344E+00 -4.609907E+01 -1.063127E+02 -6.047337E+01 -1.836168E+02 -1.014777E+02 -5.150557E+02 -1.390508E+01 -9.722899E+00 -4.629251E+01 -1.072027E+02 -6.066027E+01 -1.843661E+02 -1.011648E+02 -5.120629E+02 -1.365982E+01 -9.372236E+00 -4.602994E+01 -1.060579E+02 +6.036829E+01 +1.828885E+02 +1.008777E+02 +5.091033E+02 +1.353211E+01 +9.188155E+00 +4.618716E+01 +1.067410E+02 +6.007789E+01 +1.808371E+02 +1.018892E+02 +5.192269E+02 +1.357961E+01 +9.247052E+00 +4.618560E+01 +1.067058E+02 +5.997882E+01 +1.802895E+02 +1.010597E+02 +5.108478E+02 +1.374955E+01 +9.502494E+00 +4.619500E+01 +1.067547E+02 +5.963392E+01 +1.783999E+02 +1.007134E+02 +5.074700E+02 +1.319398E+01 +8.734106E+00 +4.586295E+01 +1.052870E+02 cmfd indices 2.000000E+00 2.000000E+00 1.000000E+00 2.000000E+00 k cmfd -1.013488E+00 -1.024396E+00 -1.015533E+00 -1.009319E+00 -1.012726E+00 -1.014831E+00 -1.021757E+00 -1.022002E+00 -1.023619E+00 -1.020953E+00 -1.023910E+00 -1.027657E+00 -1.024501E+00 -1.023838E+00 -1.025464E+00 -1.022802E+00 +1.018115E+00 +1.022665E+00 +1.020323E+00 +1.020653E+00 +1.021036E+00 +1.020623E+00 +1.021482E+00 +1.025450E+00 +1.027292E+00 +1.028065E+00 +1.027065E+00 +1.024275E+00 +1.025309E+00 +1.026039E+00 +1.026700E+00 +1.023865E+00 cmfd entropy -1.998974E+00 -1.998742E+00 -1.999128E+00 -1.998952E+00 -1.998951E+00 -1.999439E+00 -1.999626E+00 -1.999826E+00 -1.999513E+00 -1.999451E+00 -1.999514E+00 -1.999590E+00 -1.999563E+00 -1.999604E+00 -1.999742E+00 -1.999736E+00 +1.998965E+00 +1.999214E+00 +1.999348E+00 +1.999366E+00 +1.999564E+00 +1.999453E+00 +1.999533E+00 +1.999630E+00 +1.999739E+00 +1.999588E+00 +1.999581E+00 +1.999719E+00 +1.999773E+00 +1.999764E+00 +1.999821E+00 +1.999843E+00 cmfd balance -9.79896E-04 -4.24873E-04 -8.05696E-04 -1.92071E-03 -3.70731E-04 -2.81424E-04 -8.28991E-04 -6.12217E-04 -5.29185E-04 -4.97799E-04 -3.09154E-04 -1.73703E-04 -2.56689E-04 -2.64938E-04 -1.96305E-04 -1.82702E-04 +5.73174E-04 +7.55398E-04 +1.46671E-03 +6.39625E-04 +8.19008E-04 +1.93449E-03 +1.15900E-03 +1.01690E-03 +5.62788E-04 +6.90450E-04 +6.01060E-04 +5.73418E-04 +4.37190E-04 +4.82966E-04 +4.09700E-04 +3.45096E-04 cmfd dominance ratio -6.304E-03 -6.246E-03 -6.159E-03 -6.249E-03 -6.101E-03 -6.155E-03 -6.010E-03 -6.177E-03 -6.349E-03 -6.241E-03 -6.244E-03 -6.249E-03 -6.270E-03 -6.272E-03 -6.278E-03 -6.290E-03 +6.264E-03 +6.142E-03 +5.987E-03 +6.082E-03 +5.895E-03 +5.939E-03 +5.910E-03 +5.948E-03 +6.013E-03 +6.017E-03 +6.024E-03 +6.008E-03 +5.976E-03 +5.987E-03 +5.967E-03 +5.929E-03 cmfd openmc source comparison -4.046094E-05 -5.979431E-05 -3.836521E-05 -4.577591E-05 -5.012911E-05 -2.114677E-05 -2.074571E-05 -3.042280E-05 -2.408163E-05 -2.434542E-05 -1.190699E-05 -9.499301E-06 -2.354221E-05 -2.937924E-05 -1.889875E-05 -1.913866E-05 +4.832872E-05 +6.552342E-05 +7.516800E-05 +7.916087E-05 +9.022260E-05 +8.574478E-05 +7.891622E-05 +7.281636E-05 +7.750571E-05 +6.565408E-05 +6.078665E-05 +5.834343E-05 +4.758176E-05 +5.723990E-05 +4.994116E-05 +4.116808E-05 cmfd source -2.489706E-01 -2.426801E-01 -2.532142E-01 -2.551351E-01 +2.455663E-01 +2.553511E-01 +2.512257E-01 +2.478570E-01 0.000000E+00 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat b/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat index b39f82f96..8fd8cdbb8 100644 --- a/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat +++ b/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat @@ -1,117 +1,117 @@ k-combined: -1.170835E+00 5.423480E-03 +1.167865E+00 7.492213E-03 tally 1: -1.205100E+01 -1.456707E+01 -2.183882E+01 -4.781179E+01 -2.844010E+01 -8.102358E+01 -3.356334E+01 -1.130832E+02 -3.660829E+01 -1.344973E+02 -3.697740E+01 -1.371500E+02 -3.400119E+01 -1.160196E+02 -2.839868E+01 -8.083199E+01 -2.140398E+01 -4.615447E+01 -1.118179E+01 -1.262942E+01 +1.146860E+01 +1.318884E+01 +2.161527E+01 +4.685283E+01 +2.951158E+01 +8.733566E+01 +3.521610E+01 +1.242821E+02 +3.774236E+01 +1.426501E+02 +3.727918E+01 +1.391158E+02 +3.377176E+01 +1.143839E+02 +2.904497E+01 +8.452907E+01 +2.090871E+01 +4.384549E+01 +1.078642E+01 +1.168086E+01 tally 2: -1.218245E+00 -1.484121E+00 -8.387442E-01 -7.034918E-01 -2.142134E+00 -4.588738E+00 -1.526727E+00 -2.330895E+00 -2.736157E+00 -7.486556E+00 -1.973921E+00 -3.896363E+00 -3.606244E+00 -1.300500E+01 -2.537580E+00 -6.439313E+00 -3.668958E+00 -1.346126E+01 -2.599095E+00 -6.755294E+00 -3.647982E+00 -1.330777E+01 -2.539750E+00 -6.450332E+00 -3.118921E+00 -9.727669E+00 -2.186447E+00 -4.780549E+00 -2.881110E+00 -8.300795E+00 -2.042635E+00 -4.172360E+00 -2.045602E+00 -4.184486E+00 -1.458384E+00 -2.126884E+00 -1.022124E+00 -1.044738E+00 -7.112678E-01 -5.059018E-01 +1.136810E+00 +1.292338E+00 +7.987303E-01 +6.379700E-01 +2.266938E+00 +5.139009E+00 +1.613483E+00 +2.603328E+00 +3.046349E+00 +9.280239E+00 +2.182459E+00 +4.763126E+00 +3.568068E+00 +1.273111E+01 +2.532456E+00 +6.413333E+00 +3.989504E+00 +1.591614E+01 +2.848301E+00 +8.112818E+00 +3.853133E+00 +1.484663E+01 +2.718493E+00 +7.390202E+00 +3.478138E+00 +1.209745E+01 +2.467281E+00 +6.087476E+00 +2.952220E+00 +8.715605E+00 +2.103261E+00 +4.423706E+00 +1.917459E+00 +3.676649E+00 +1.378369E+00 +1.899902E+00 +1.048240E+00 +1.098807E+00 +7.511947E-01 +5.642934E-01 tally 3: -8.048428E-01 -6.477720E-01 -6.603741E-02 -4.360940E-03 -1.466886E+00 -2.151755E+00 -1.002354E-01 -1.004713E-02 -1.909238E+00 -3.645189E+00 -1.202824E-01 -1.446786E-02 -2.443130E+00 -5.968886E+00 -1.627351E-01 -2.648270E-02 -2.492602E+00 -6.213064E+00 -1.910368E-01 -3.649506E-02 -2.437262E+00 -5.940245E+00 -1.568389E-01 -2.459843E-02 -2.104091E+00 -4.427200E+00 -1.450465E-01 -2.103848E-02 -1.965900E+00 -3.864762E+00 -1.367918E-01 -1.871199E-02 -1.402871E+00 -1.968047E+00 -1.061316E-01 -1.126391E-02 -6.832689E-01 -4.668565E-01 -4.599034E-02 -2.115112E-03 +7.701233E-01 +5.930898E-01 +4.481585E-02 +2.008461E-03 +1.547307E+00 +2.394158E+00 +1.226539E-01 +1.504398E-02 +2.106373E+00 +4.436806E+00 +1.450618E-01 +2.104294E-02 +2.437654E+00 +5.942157E+00 +1.521380E-01 +2.314598E-02 +2.754639E+00 +7.588038E+00 +1.745460E-01 +3.046629E-02 +2.623852E+00 +6.884601E+00 +1.851602E-01 +3.428432E-02 +2.376886E+00 +5.649588E+00 +1.615729E-01 +2.610582E-02 +2.021856E+00 +4.087900E+00 +1.533174E-01 +2.350622E-02 +1.333190E+00 +1.777397E+00 +7.076188E-02 +5.007243E-03 +7.258527E-01 +5.268622E-01 +3.656030E-02 +1.336656E-03 tally 4: -1.497312E-01 -2.241943E-02 +1.667432E-01 +2.780328E-02 0.000000E+00 0.000000E+00 -1.535839E-01 -2.358801E-02 -2.882052E-01 -8.306225E-02 +1.292567E-01 +1.670730E-02 +2.813370E-01 +7.915052E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -128,14 +128,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.882052E-01 -8.306225E-02 -1.535839E-01 -2.358801E-02 -2.526805E-01 -6.384743E-02 -3.616220E-01 -1.307705E-01 +2.813370E-01 +7.915052E-02 +1.292567E-01 +1.670730E-02 +2.670549E-01 +7.131835E-02 +4.055324E-01 +1.644566E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -152,14 +152,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.616220E-01 -1.307705E-01 -2.526805E-01 -6.384743E-02 -3.594306E-01 -1.291904E-01 -4.229730E-01 -1.789062E-01 +4.055324E-01 +1.644566E-01 +2.670549E-01 +7.131835E-02 +3.848125E-01 +1.480807E-01 +4.809430E-01 +2.313062E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -176,14 +176,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.229730E-01 -1.789062E-01 -3.594306E-01 -1.291904E-01 -3.973299E-01 -1.578711E-01 -4.255879E-01 -1.811250E-01 +4.809430E-01 +2.313062E-01 +3.848125E-01 +1.480807E-01 +4.543918E-01 +2.064719E-01 +5.106133E-01 +2.607260E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -200,14 +200,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.255879E-01 -1.811250E-01 -3.973299E-01 -1.578711E-01 -4.633933E-01 -2.147333E-01 -4.672837E-01 -2.183540E-01 +5.106133E-01 +2.607260E-01 +4.543918E-01 +2.064719E-01 +4.543120E-01 +2.063994E-01 +4.626328E-01 +2.140291E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -224,14 +224,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.672837E-01 -2.183540E-01 -4.633933E-01 -2.147333E-01 -4.251073E-01 -1.807162E-01 -3.842922E-01 -1.476805E-01 +4.626328E-01 +2.140291E-01 +4.543120E-01 +2.063994E-01 +4.827759E-01 +2.330726E-01 +4.442622E-01 +1.973689E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -248,14 +248,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.842922E-01 -1.476805E-01 -4.251073E-01 -1.807162E-01 -4.045096E-01 -1.636280E-01 -3.192860E-01 -1.019436E-01 +4.442622E-01 +1.973689E-01 +4.827759E-01 +2.330726E-01 +4.630420E-01 +2.144079E-01 +3.886524E-01 +1.510507E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -272,14 +272,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.192860E-01 -1.019436E-01 -4.045096E-01 -1.636280E-01 -3.738326E-01 -1.397508E-01 -2.598153E-01 -6.750398E-02 +3.886524E-01 +1.510507E-01 +4.630420E-01 +2.144079E-01 +3.535870E-01 +1.250237E-01 +2.530312E-01 +6.402478E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -296,14 +296,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.598153E-01 -6.750398E-02 -3.738326E-01 -1.397508E-01 -2.453191E-01 -6.018146E-02 -1.098964E-01 -1.207721E-02 +2.530312E-01 +6.402478E-02 +3.535870E-01 +1.250237E-01 +2.465524E-01 +6.078808E-02 +1.197152E-01 +1.433173E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -320,12 +320,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.098964E-01 -1.207721E-02 -2.453191E-01 -6.018146E-02 -1.458094E-01 -2.126039E-02 +1.197152E-01 +1.433173E-02 +2.465524E-01 +6.078808E-02 +1.369631E-01 +1.875888E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -345,119 +345,119 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -8.048428E-01 -6.477720E-01 -1.018934E-01 -1.038226E-02 -1.466886E+00 -2.151755E+00 -1.414681E-01 -2.001322E-02 -1.909238E+00 -3.645189E+00 -2.450211E-01 -6.003535E-02 -2.443130E+00 -5.968886E+00 -3.360056E-01 -1.128997E-01 -2.492602E+00 -6.213064E+00 -3.266277E-01 -1.066856E-01 -2.437262E+00 -5.940245E+00 -2.878100E-01 -8.283461E-02 -2.104091E+00 -4.427200E+00 -3.440457E-01 -1.183675E-01 -1.965900E+00 -3.864762E+00 -2.880615E-01 -8.297945E-02 -1.401955E+00 -1.965478E+00 -1.646479E-01 -2.710892E-02 -6.832689E-01 -4.668565E-01 -1.147413E-01 -1.316557E-02 +7.701233E-01 +5.930898E-01 +1.386250E-01 +1.921688E-02 +1.547307E+00 +2.394158E+00 +2.630277E-01 +6.918357E-02 +2.106373E+00 +4.436806E+00 +2.807880E-01 +7.884187E-02 +2.435849E+00 +5.933361E+00 +3.322060E-01 +1.103608E-01 +2.753634E+00 +7.582501E+00 +3.825922E-01 +1.463768E-01 +2.623852E+00 +6.884601E+00 +3.888710E-01 +1.512206E-01 +2.376886E+00 +5.649588E+00 +3.196217E-01 +1.021581E-01 +2.021856E+00 +4.087900E+00 +2.897881E-01 +8.397715E-02 +1.333190E+00 +1.777397E+00 +1.627110E-01 +2.647486E-02 +7.258527E-01 +5.268622E-01 +9.348666E-02 +8.739755E-03 cmfd indices 1.000000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.181376E+00 -1.176656E+00 -1.161939E+00 -1.163552E+00 -1.163035E+00 -1.170382E+00 -1.160597E+00 -1.154301E+00 -1.159007E+00 -1.148290E+00 -1.157088E+00 +1.149077E+00 +1.156751E+00 +1.158648E+00 +1.159506E+00 +1.156567E+00 +1.160259E+00 +1.150345E+00 +1.149846E+00 +1.151606E+00 +1.164544E+00 +1.174648E+00 cmfd entropy -3.246419E+00 -3.246511E+00 -3.252247E+00 -3.240919E+00 -3.237600E+00 -3.233990E+00 -3.234226E+00 -3.229356E+00 -3.224272E+00 -3.225381E+00 -3.226778E+00 +3.216173E+00 +3.228717E+00 +3.220402E+00 +3.214352E+00 +3.215636E+00 +3.213599E+00 +3.212854E+00 +3.213131E+00 +3.213196E+00 +3.205474E+00 +3.202869E+00 cmfd balance -4.18486E-03 -1.72126E-03 -1.10899E-03 -1.88170E-03 -1.31646E-03 -1.34128E-03 -1.57944E-03 -2.11251E-03 -1.79912E-03 -1.86000E-03 -1.47765E-03 +3.08825E-03 +1.42345E-03 +1.21253E-03 +1.17694E-03 +1.05901E-03 +9.29611E-04 +1.35587E-03 +1.13579E-03 +1.14964E-03 +1.29313E-03 +1.46566E-03 cmfd dominance ratio 5.524E-01 -5.597E-01 -5.622E-01 -5.544E-01 -5.541E-01 -5.519E-01 -5.532E-01 -5.550E-01 -5.484E-01 -5.497E-01 -5.500E-01 +5.614E-01 +5.522E-01 +5.487E-01 +5.482E-01 +5.446E-01 +5.437E-01 +5.429E-01 +5.407E-01 +5.380E-01 +5.377E-01 cmfd openmc source comparison -1.905464E-03 -4.145126E-03 -2.465876E-03 -2.346755E-03 -1.848120E-03 -3.263822E-03 -3.641639E-03 -4.031509E-03 -4.999010E-03 -6.640746E-03 -5.691414E-03 +1.586045E-02 +6.953134E-03 +6.860419E-03 +6.198467E-03 +5.142854E-03 +4.373354E-03 +5.564831E-03 +4.184765E-03 +1.867780E-03 +2.734784E-03 +2.523985E-03 cmfd source -4.951338E-02 -8.478025E-02 -1.083132E-01 -1.301432E-01 -1.341190E-01 -1.445825E-01 -1.255119E-01 -1.063303E-01 -7.830158E-02 -3.840469E-02 +4.241440E-02 +8.226026E-02 +1.180811E-01 +1.328433E-01 +1.412410E-01 +1.424902E-01 +1.269340E-01 +1.096490E-01 +6.953251E-02 +3.455422E-02 diff --git a/tests/regression_tests/cmfd_feed_ng/results_true.dat b/tests/regression_tests/cmfd_feed_ng/results_true.dat index 4ea1515f1..153238bfe 100644 --- a/tests/regression_tests/cmfd_feed_ng/results_true.dat +++ b/tests/regression_tests/cmfd_feed_ng/results_true.dat @@ -1,208 +1,208 @@ k-combined: -1.008852E+00 9.028695E-03 +1.005987E+00 1.354263E-02 tally 1: -1.151271E+02 -1.325871E+03 -1.143934E+02 -1.309051E+03 -1.142507E+02 -1.306616E+03 -1.140242E+02 -1.300786E+03 +1.140273E+02 +1.301245E+03 +1.147962E+02 +1.319049E+03 +1.151426E+02 +1.326442E+03 +1.149265E+02 +1.321518E+03 tally 2: -3.403617E+01 -7.260478E+01 -5.031678E+01 -1.588977E+02 -1.003700E+01 -6.373741E+00 -8.514575E+00 -4.571811E+00 -1.413036E+02 -1.264708E+03 -7.321799E+01 -3.353408E+02 -3.354839E+01 -7.052647E+01 -4.895930E+01 -1.501243E+02 -9.972495E+00 -6.271276E+00 -8.436263E+00 -4.481319E+00 -1.353506E+02 -1.146040E+03 -7.309382E+01 -3.341751E+02 -3.389861E+01 -7.205501E+01 -5.005946E+01 -1.571210E+02 -1.041650E+01 -6.810868E+00 -8.839753E+00 -4.897617E+00 -1.344145E+02 -1.130242E+03 -7.270373E+01 -3.307223E+02 -3.347928E+01 -7.040185E+01 -4.940585E+01 -1.535767E+02 -9.898649E+00 -6.175319E+00 -8.406032E+00 -4.442856E+00 -1.374544E+02 -1.182191E+03 -7.334301E+01 -3.365399E+02 +3.462748E+01 +7.542476E+01 +5.129219E+01 +1.658142E+02 +1.034704E+01 +6.730603E+00 +8.672967E+00 +4.715295E+00 +1.344669E+02 +1.132019E+03 +7.262519E+01 +3.300787E+02 +3.447358E+01 +7.459545E+01 +5.075836E+01 +1.619570E+02 +1.080516E+01 +7.366369E+00 +8.908065E+00 +4.991975E+00 +1.354224E+02 +1.146824E+03 +7.300078E+01 +3.332531E+02 +3.432298E+01 +7.388666E+01 +5.096378E+01 +1.627979E+02 +1.053664E+01 +7.029789E+00 +8.826624E+00 +4.904429E+00 +1.388389E+02 +1.207280E+03 +7.376623E+01 +3.403211E+02 +4.383841E+01 +1.943331E+02 +5.165881E+01 +1.675923E+02 +1.059646E+01 +7.048052E+00 +8.763673E+00 +4.823505E+00 +1.378179E+02 +1.188104E+03 +7.431708E+01 +3.453746E+02 tally 3: -4.755532E+01 -1.419592E+02 +4.858880E+01 +1.488705E+02 0.000000E+00 0.000000E+00 -1.628248E-02 -3.680742E-05 +8.148667E-03 +1.337050E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -3.347160E+00 -7.104290E-01 -2.453669E+00 -3.797470E-01 +3.347376E+00 +7.045574E-01 +2.433484E+00 +3.727266E-01 0.000000E+00 0.000000E+00 -5.925795E+00 -2.220734E+00 +6.095478E+00 +2.332622E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -9.542527E-02 -1.118856E-03 -3.018759E-01 -6.371059E-03 +1.235421E-01 +1.205155E-03 +3.647699E-01 +8.953589E-03 0.000000E+00 0.000000E+00 -2.501316E+00 -3.938401E-01 +2.673965E+00 +4.517972E-01 0.000000E+00 0.000000E+00 -6.926265E+01 -3.001504E+02 -6.765221E-01 -2.991787E-02 -4.605523E+01 -1.328435E+02 +6.841105E+01 +2.929195E+02 +5.902473E-01 +2.307683E-02 +4.792291E+01 +1.444397E+02 0.000000E+00 0.000000E+00 -1.687782E-02 -3.921162E-05 +2.183275E-02 +8.061011E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -3.481608E+00 -7.705602E-01 -2.439374E+00 -3.779705E-01 +3.435826E+00 +7.480244E-01 +2.450829E+00 +3.800327E-01 0.000000E+00 0.000000E+00 -5.855806E+00 -2.162361E+00 +6.331358E+00 +2.530492E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.016677E-01 -9.263706E-04 -3.264878E-01 -7.385168E-03 +1.012941E-01 +8.217580E-04 +2.981274E-01 +5.863186E-03 0.000000E+00 0.000000E+00 -2.519730E+00 -3.986182E-01 +2.535628E+00 +4.048310E-01 0.000000E+00 0.000000E+00 -6.920950E+01 -2.996184E+02 -5.985719E-01 -2.368062E-02 -4.730723E+01 -1.403550E+02 +6.912003E+01 +2.987684E+02 +5.984862E-01 +2.386115E-02 +4.822881E+01 +1.458309E+02 0.000000E+00 0.000000E+00 -6.800415E-03 -1.163614E-05 +1.525590E-02 +3.794082E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -3.347607E+00 -7.085691E-01 -2.556997E+00 -4.109118E-01 +3.314494E+00 +6.944527E-01 +2.424209E+00 +3.691360E-01 0.000000E+00 0.000000E+00 -6.171063E+00 -2.391770E+00 +6.254897E+00 +2.474317E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -7.942016E-02 -5.628747E-04 -3.456912E-01 -7.940086E-03 +1.112542E-01 +1.051688E-03 +3.234880E-01 +7.156753E-03 0.000000E+00 0.000000E+00 -2.684459E+00 -4.546338E-01 +2.474142E+00 +3.837496E-01 0.000000E+00 0.000000E+00 -6.850588E+01 -2.936078E+02 -6.458806E-01 -2.672541E-02 -4.673301E+01 -1.374202E+02 +6.987095E+01 +3.053358E+02 +5.928782E-01 +2.368116E-02 +4.885415E+01 +1.499856E+02 0.000000E+00 0.000000E+00 -1.504681E-02 -4.202606E-05 +1.262416E-02 +2.486286E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -3.139138E+00 -6.206027E-01 -2.341735E+00 -3.454035E-01 +3.426826E+00 +7.480396E-01 +2.487209E+00 +3.903882E-01 0.000000E+00 0.000000E+00 -5.923755E+00 -2.216341E+00 +6.127303E+00 +2.364605E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -7.030156E-02 -4.283974E-04 -3.247594E-01 -7.133772E-03 +9.439007E-02 +1.082564E-03 +2.963491E-01 +5.652952E-03 0.000000E+00 0.000000E+00 -2.559691E+00 -4.119674E-01 +2.620696E+00 +4.311792E-01 0.000000E+00 0.000000E+00 -6.938051E+01 -3.012078E+02 -5.159565E-01 -1.730381E-02 +7.030725E+01 +3.091241E+02 +5.986966E-01 +2.352487E-02 tally 4: 0.000000E+00 0.000000E+00 @@ -216,18 +216,18 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.028166E+00 -3.103666E+00 -2.028371E+00 -2.606104E-01 -2.715466E+01 -4.614452E+01 -6.981028E+00 -3.059096E+00 -2.032450E+00 -2.610410E-01 -2.734281E+01 -4.675062E+01 +7.028624E+00 +3.105990E+00 +2.154648E+00 +2.948865E-01 +2.714077E+01 +4.607926E+01 +7.035506E+00 +3.118549E+00 +2.085916E+00 +2.730884E-01 +2.750091E+01 +4.731304E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -240,18 +240,18 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.969559E+00 -3.054867E+00 -2.042871E+00 -2.624815E-01 -2.766332E+01 -4.787778E+01 -7.022610E+00 -3.098329E+00 -2.109973E+00 -2.824233E-01 -2.733826E+01 -4.676309E+01 +7.170567E+00 +3.240715E+00 +2.131758E+00 +2.862355E-01 +2.747702E+01 +4.722977E+01 +7.068817E+00 +3.139275E+00 +2.095865E+00 +2.762179E-01 +2.737835E+01 +4.688689E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -276,18 +276,18 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.981028E+00 -3.059096E+00 -2.032450E+00 -2.610410E-01 -2.734281E+01 -4.675062E+01 -7.028166E+00 -3.103666E+00 -2.028371E+00 -2.606104E-01 -2.715466E+01 -4.614452E+01 +7.035506E+00 +3.118549E+00 +2.085916E+00 +2.730884E-01 +2.750091E+01 +4.731304E+01 +7.028624E+00 +3.105990E+00 +2.154648E+00 +2.948865E-01 +2.714077E+01 +4.607926E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -312,18 +312,18 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.782152E+00 -2.885448E+00 -1.951138E+00 -2.400912E-01 -2.739652E+01 -4.697696E+01 -6.873220E+00 -2.965563E+00 -1.999066E+00 -2.521586E-01 -2.732700E+01 -4.670990E+01 +7.103896E+00 +3.171147E+00 +2.095666E+00 +2.756673E-01 +2.711842E+01 +4.600196E+01 +7.197270E+00 +3.255501E+00 +2.046179E+00 +2.630301E-01 +2.729901E+01 +4.662030E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -360,30 +360,30 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.933695E+00 -3.028826E+00 -2.080336E+00 -2.719620E-01 -2.726925E+01 -4.650782E+01 -6.836291E+00 -2.935998E+00 -2.124868E+00 -2.841370E-01 -2.709685E+01 -4.591604E+01 -7.022610E+00 -3.098329E+00 -2.109973E+00 -2.824233E-01 -2.733826E+01 -4.676309E+01 -6.969559E+00 -3.054867E+00 -2.042871E+00 -2.624815E-01 -2.766332E+01 -4.787778E+01 +7.240906E+00 +3.296285E+00 +2.130816E+00 +2.850713E-01 +2.761433E+01 +4.771548E+01 +7.126427E+00 +3.199209E+00 +2.177254E+00 +2.998765E-01 +2.754936E+01 +4.748447E+01 +7.068817E+00 +3.139275E+00 +2.095865E+00 +2.762179E-01 +2.737835E+01 +4.688689E+01 +7.170567E+00 +3.240715E+00 +2.131758E+00 +2.862355E-01 +2.747702E+01 +4.722977E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -420,18 +420,18 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.836291E+00 -2.935998E+00 -2.124868E+00 -2.841370E-01 -2.709685E+01 -4.591604E+01 -6.933695E+00 -3.028826E+00 -2.080336E+00 -2.719620E-01 -2.726925E+01 -4.650782E+01 +7.126427E+00 +3.199209E+00 +2.177254E+00 +2.998765E-01 +2.754936E+01 +4.748447E+01 +7.240906E+00 +3.296285E+00 +2.130816E+00 +2.850713E-01 +2.761433E+01 +4.771548E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -444,18 +444,18 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.873220E+00 -2.965563E+00 -1.999066E+00 -2.521586E-01 -2.732700E+01 -4.670990E+01 -6.782152E+00 -2.885448E+00 -1.951138E+00 -2.400912E-01 -2.739652E+01 -4.697696E+01 +7.197270E+00 +3.255501E+00 +2.046179E+00 +2.630301E-01 +2.729901E+01 +4.662030E+01 +7.103896E+00 +3.171147E+00 +2.095666E+00 +2.756673E-01 +2.711842E+01 +4.600196E+01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -493,124 +493,124 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -4.757160E+01 -1.420561E+02 -8.379464E+00 -4.426892E+00 -7.205748E+01 -3.248178E+02 -1.047742E+01 -6.922945E+00 -3.879420E+00 -9.517577E-01 -3.297227E+01 -6.802001E+01 -4.607211E+01 -1.329402E+02 -8.295180E+00 -4.334618E+00 -7.205259E+01 -3.247324E+02 -1.059307E+01 -7.039382E+00 -3.783039E+00 -9.030658E-01 -3.288052E+01 -6.762048E+01 -4.731403E+01 -1.403940E+02 -8.728060E+00 -4.774750E+00 -7.152809E+01 -3.200993E+02 -1.074636E+01 -7.270116E+00 -4.007351E+00 -1.010562E+00 -3.249303E+01 -6.611829E+01 -4.674806E+01 -1.375015E+02 -8.265491E+00 -4.296947E+00 -7.226174E+01 -3.267127E+02 -1.079228E+01 -7.340408E+00 -3.843888E+00 -9.273339E-01 -3.300391E+01 -6.823122E+01 +4.859695E+01 +1.489217E+02 +8.528963E+00 +4.561881E+00 +7.144500E+01 +3.194467E+02 +1.120265E+01 +7.944038E+00 +4.009821E+00 +1.012575E+00 +3.235456E+01 +6.558658E+01 +4.794474E+01 +1.445671E+02 +8.782187E+00 +4.852477E+00 +7.195036E+01 +3.237389E+02 +1.075572E+01 +7.333822E+00 +4.084680E+00 +1.054714E+00 +3.267154E+01 +6.675266E+01 +4.824407E+01 +1.459220E+02 +8.679106E+00 +4.742342E+00 +7.266858E+01 +3.302641E+02 +1.094872E+01 +7.536318E+00 +3.935828E+00 +9.749543E-01 +3.319517E+01 +6.894791E+01 +4.886677E+01 +1.500624E+02 +8.614512E+00 +4.662618E+00 +7.321408E+01 +3.352172E+02 +1.095123E+01 +7.574359E+00 +3.885927E+00 +9.539315E-01 +3.334065E+01 +6.953215E+01 cmfd indices 2.000000E+00 2.000000E+00 1.000000E+00 3.000000E+00 k cmfd -1.011190E+00 -1.010705E+00 -1.014132E+00 -1.015900E+00 -1.019132E+00 -1.022616E+00 -1.023007E+00 -1.022300E+00 -1.014692E+00 -1.007628E+00 -1.006204E+00 +1.026473E+00 +1.024183E+00 +1.023151E+00 +1.025047E+00 +1.019801E+00 +1.020492E+00 +1.015249E+00 +1.016714E+00 +1.016047E+00 +1.019687E+00 +1.020955E+00 cmfd entropy -1.999167E+00 -1.999076E+00 -1.998507E+00 -1.997924E+00 -1.997814E+00 -1.997752E+00 -1.997882E+00 -1.998074E+00 -1.998109E+00 -1.998301E+00 -1.998581E+00 +1.999640E+00 +1.999556E+00 +1.999484E+00 +1.999718E+00 +1.999697E+00 +1.999657E+00 +1.999883E+00 +1.999902E+00 +1.999977E+00 +1.999977E+00 +1.999906E+00 cmfd balance -9.30124E-04 -2.56632E-04 -3.62598E-04 -4.17543E-04 -5.25720E-04 -4.90208E-04 -3.61304E-04 -2.24090E-04 -1.86602E-04 -1.78395E-04 -6.42497E-05 +8.10090E-04 +1.28103E-03 +7.97200E-04 +5.82188E-04 +7.20670E-04 +7.31475E-04 +5.71904E-04 +6.14057E-04 +6.00142E-04 +5.47870E-04 +3.53604E-04 cmfd dominance ratio -4.194E-03 -4.234E-03 -4.149E-03 -4.209E-03 -4.185E-03 -4.197E-03 -4.175E-03 -4.105E-03 -4.056E-03 -4.122E-03 -4.113E-03 +3.977E-03 +4.018E-03 +3.950E-03 +3.866E-03 +3.840E-03 +3.888E-03 +3.867E-03 +3.896E-03 +3.924E-03 +3.885E-03 +3.913E-03 cmfd openmc source comparison -2.078995E-05 -2.415218E-05 -3.311536E-05 -3.598613E-05 -3.156455E-05 -2.737017E-05 -2.468500E-05 -2.514215E-05 -1.601626E-05 -1.424027E-05 -4.201148E-06 +4.787501E-05 +4.450525E-05 +2.532345E-05 +3.844307E-05 +4.821504E-05 +4.840760E-05 +3.739246E-05 +3.957960E-05 +4.521480E-05 +4.072007E-05 +2.532636E-05 cmfd source -2.558585E-01 -2.597562E-01 -2.529866E-01 -2.313986E-01 +2.486236E-01 +2.531628E-01 +2.460219E-01 +2.521918E-01 0.000000E+00 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/cmfd_feed_rectlin/results_true.dat b/tests/regression_tests/cmfd_feed_rectlin/results_true.dat index a98f3fbd3..600b5d152 100644 --- a/tests/regression_tests/cmfd_feed_rectlin/results_true.dat +++ b/tests/regression_tests/cmfd_feed_rectlin/results_true.dat @@ -1,149 +1,149 @@ k-combined: -1.157362E+00 9.651846E-03 +1.160561E+00 1.029736E-02 tally 1: -1.160989E+01 -1.351117E+01 -2.127132E+01 -4.540172E+01 -2.903242E+01 -8.450044E+01 -3.443549E+01 -1.188763E+02 -3.678332E+01 -1.355586E+02 -3.760088E+01 -1.418740E+02 -3.433077E+01 -1.181837E+02 -2.861986E+01 -8.231285E+01 -2.182277E+01 -4.792086E+01 -1.138713E+01 -1.304425E+01 +1.089904E+01 +1.193573E+01 +2.026534E+01 +4.113383E+01 +2.723584E+01 +7.440537E+01 +3.309956E+01 +1.101184E+02 +3.659327E+01 +1.341221E+02 +3.780158E+01 +1.430045E+02 +3.520883E+01 +1.241772E+02 +2.961801E+01 +8.784675E+01 +2.182029E+01 +4.781083E+01 +1.180347E+01 +1.399970E+01 tally 2: -8.861425E+00 -3.953963E+00 -6.090757E+00 -1.866235E+00 -3.309260E+01 -5.493482E+01 -2.330765E+01 -2.725350E+01 -2.295343E+01 -2.647375E+01 -1.629166E+01 -1.334081E+01 -5.714234E+01 -1.640293E+02 -4.054051E+01 -8.261123E+01 -3.331786E+01 -5.565082E+01 -2.366345E+01 -2.807637E+01 -7.034800E+01 -2.485209E+02 -5.001286E+01 -1.256087E+02 -3.651223E+01 -6.686058E+01 -2.606851E+01 -3.408881E+01 -3.729833E+01 -6.997492E+01 -2.657970E+01 -3.553107E+01 -7.212382E+01 -2.611253E+02 -5.124647E+01 -1.318756E+02 -3.304529E+01 -5.486643E+01 -2.347504E+01 -2.771353E+01 -5.711252E+01 -1.640619E+02 -4.060288E+01 -8.298231E+01 -2.384078E+01 -2.855909E+01 -1.684046E+01 -1.426180E+01 -3.329487E+01 -5.573544E+01 -2.349871E+01 -2.776487E+01 -8.676886E+00 -3.814132E+00 -5.980976E+00 -1.815143E+00 +8.794706E+00 +3.939413E+00 +6.131113E+00 +1.913116E+00 +3.265522E+01 +5.364042E+01 +2.304238E+01 +2.672742E+01 +2.250225E+01 +2.541491E+01 +1.601668E+01 +1.288405E+01 +5.525355E+01 +1.531915E+02 +3.929637E+01 +7.748545E+01 +3.222711E+01 +5.216630E+01 +2.285375E+01 +2.623641E+01 +7.051908E+01 +2.495413E+02 +5.010064E+01 +1.259701E+02 +3.728726E+01 +6.974440E+01 +2.652872E+01 +3.530919E+01 +3.747306E+01 +7.058235E+01 +2.681415E+01 +3.613314E+01 +7.296802E+01 +2.669214E+02 +5.202502E+01 +1.356733E+02 +3.333947E+01 +5.579355E+01 +2.361733E+01 +2.800800E+01 +5.785916E+01 +1.680561E+02 +4.093282E+01 +8.410711E+01 +2.377151E+01 +2.842464E+01 +1.681789E+01 +1.423646E+01 +3.422028E+01 +5.880493E+01 +2.415199E+01 +2.930240E+01 +8.890608E+00 +3.986356E+00 +6.140159E+00 +1.897764E+00 tally 3: -5.847135E+00 -1.719612E+00 -3.960040E-01 -8.297721E-03 -2.245534E+01 -2.530222E+01 -1.468678E+00 -1.094031E-01 -1.571194E+01 -1.240597E+01 -1.004169E+00 -5.156464E-02 -3.901605E+01 -7.652715E+01 -2.648696E+00 -3.571840E-01 -2.275978E+01 -2.597555E+01 -1.456067E+00 -1.075035E-01 -4.821184E+01 -1.167725E+02 -3.105774E+00 -4.859873E-01 -2.519281E+01 -3.183845E+01 -1.595498E+00 -1.292133E-01 -2.560583E+01 -3.297409E+01 -1.673871E+00 -1.429651E-01 -4.930025E+01 -1.220909E+02 -3.206604E+00 -5.220919E-01 -2.255825E+01 -2.560134E+01 -1.422870E+00 -1.027151E-01 -3.910818E+01 -7.698933E+01 -2.568903E+00 -3.333385E-01 -1.620292E+01 -1.321173E+01 -1.068678E+00 -5.798793E-02 -2.264343E+01 -2.578648E+01 -1.503553E+00 -1.158411E-01 -5.751110E+00 -1.676910E+00 -3.450582E-01 -6.411784E-03 +5.925339E+00 +1.788596E+00 +3.912632E-01 +8.061838E-03 +2.215544E+01 +2.471404E+01 +1.465191E+00 +1.092622E-01 +1.542988E+01 +1.195626E+01 +1.022876E+00 +5.356825E-02 +3.792029E+01 +7.218149E+01 +2.370476E+00 +2.839465E-01 +2.200154E+01 +2.432126E+01 +1.360836E+00 +9.402424E-02 +4.824980E+01 +1.168447E+02 +3.124366E+00 +4.907460E-01 +2.557420E+01 +3.282066E+01 +1.725855E+00 +1.519830E-01 +2.577963E+01 +3.341077E+01 +1.654042E+00 +1.386845E-01 +5.008220E+01 +1.257610E+02 +3.223857E+00 +5.237360E-01 +2.273380E+01 +2.595325E+01 +1.438369E+00 +1.050840E-01 +3.938822E+01 +7.789691E+01 +2.648324E+00 +3.559703E-01 +1.623604E+01 +1.327214E+01 +1.058882E+00 +5.680630E-02 +2.325730E+01 +2.717892E+01 +1.584276E+00 +1.275868E-01 +5.937929E+00 +1.774847E+00 +3.866918E-01 +7.994353E-03 tally 4: -3.051764E+00 -4.671879E-01 +3.063235E+00 +4.714106E-01 0.000000E+00 0.000000E+00 -1.407008E+00 -1.004485E-01 -4.354708E+00 -9.506434E-01 +1.425705E+00 +1.043616E-01 +4.355515E+00 +9.538346E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -160,14 +160,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.354708E+00 -9.506434E-01 -1.407008E+00 -1.004485E-01 -3.852730E+00 -7.498016E-01 -6.382605E+00 -2.043123E+00 +4.355515E+00 +9.538346E-01 +1.425705E+00 +1.043616E-01 +3.859174E+00 +7.519499E-01 +6.350310E+00 +2.024214E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -184,14 +184,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.382605E+00 -2.043123E+00 -3.852730E+00 -7.498016E-01 -5.061607E+00 -1.288306E+00 -7.281209E+00 -2.659444E+00 +6.350310E+00 +2.024214E+00 +3.859174E+00 +7.519499E-01 +4.993073E+00 +1.258264E+00 +7.194275E+00 +2.596886E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -208,14 +208,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.281209E+00 -2.659444E+00 -5.061607E+00 -1.288306E+00 -7.096602E+00 -2.527474E+00 -8.632232E+00 -3.736665E+00 +7.194275E+00 +2.596886E+00 +4.993073E+00 +1.258264E+00 +6.786617E+00 +2.312259E+00 +8.306978E+00 +3.459668E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -232,14 +232,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.632232E+00 -3.736665E+00 -7.096602E+00 -2.527474E+00 -7.759456E+00 -3.019026E+00 -8.968687E+00 -4.037738E+00 +8.306978E+00 +3.459668E+00 +6.786617E+00 +2.312259E+00 +7.603410E+00 +2.905228E+00 +8.791222E+00 +3.882935E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -256,14 +256,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.968687E+00 -4.037738E+00 -7.759456E+00 -3.019026E+00 -8.749025E+00 -3.839161E+00 -9.126289E+00 -4.176440E+00 +8.791222E+00 +3.882935E+00 +7.603410E+00 +2.905228E+00 +8.867113E+00 +3.938503E+00 +9.302808E+00 +4.340042E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -280,14 +280,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.126289E+00 -4.176440E+00 -8.749025E+00 -3.839161E+00 -9.259277E+00 -4.304020E+00 -9.165726E+00 -4.216173E+00 +9.302808E+00 +4.340042E+00 +8.867113E+00 +3.938503E+00 +9.270113E+00 +4.306513E+00 +9.263471E+00 +4.302184E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -304,14 +304,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.165726E+00 -4.216173E+00 -9.259277E+00 -4.304020E+00 -9.433925E+00 -4.473551E+00 -8.910566E+00 -3.991458E+00 +9.263471E+00 +4.302184E+00 +9.270113E+00 +4.306513E+00 +9.348712E+00 +4.388570E+00 +8.977713E+00 +4.047349E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -328,14 +328,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.910566E+00 -3.991458E+00 -9.433925E+00 -4.473551E+00 -9.099397E+00 -4.154062E+00 -7.770126E+00 -3.029928E+00 +8.977713E+00 +4.047349E+00 +9.348712E+00 +4.388570E+00 +9.234380E+00 +4.280666E+00 +8.036978E+00 +3.239853E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -352,14 +352,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.770126E+00 -3.029928E+00 -9.099397E+00 -4.154062E+00 -8.575842E+00 -3.694998E+00 -6.934243E+00 -2.418570E+00 +8.036978E+00 +3.239853E+00 +9.234380E+00 +4.280666E+00 +8.713633E+00 +3.808850E+00 +7.160878E+00 +2.572915E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -376,14 +376,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.934243E+00 -2.418570E+00 -8.575842E+00 -3.694998E+00 -7.437526E+00 -2.780629E+00 -5.136923E+00 -1.331553E+00 +7.160878E+00 +2.572915E+00 +8.713633E+00 +3.808850E+00 +7.378538E+00 +2.732122E+00 +5.145728E+00 +1.329190E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -400,14 +400,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.136923E+00 -1.331553E+00 -7.437526E+00 -2.780629E+00 -6.648582E+00 -2.216687E+00 -4.050691E+00 -8.279789E-01 +5.145728E+00 +1.329190E+00 +7.378538E+00 +2.732122E+00 +6.660125E+00 +2.228506E+00 +4.087925E+00 +8.435381E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -424,14 +424,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.050691E+00 -8.279789E-01 -6.648582E+00 -2.216687E+00 -4.390906E+00 -9.686686E-01 -1.391624E+00 -9.861955E-02 +4.087925E+00 +8.435381E-01 +6.660125E+00 +2.228506E+00 +4.466295E+00 +1.002320E+00 +1.468481E+00 +1.099604E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -448,12 +448,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.391624E+00 -9.861955E-02 -4.390906E+00 -9.686686E-01 -3.113477E+00 -4.874296E-01 +1.468481E+00 +1.099604E-01 +4.466295E+00 +1.002320E+00 +3.139355E+00 +4.955456E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -473,164 +473,164 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -5.846103E+00 -1.718959E+00 -8.952028E-01 -4.184063E-02 -2.245226E+01 -2.529524E+01 -3.092645E+00 -4.848878E-01 -1.571095E+01 -1.240426E+01 -2.178244E+00 -2.438479E-01 -3.900638E+01 -7.648853E+01 -5.265574E+00 -1.401505E+00 -2.275895E+01 -2.597348E+01 -3.067909E+00 -4.810969E-01 -4.820213E+01 -1.167232E+02 -6.403602E+00 -2.070034E+00 -2.519091E+01 -3.183360E+01 -3.463531E+00 -6.097568E-01 -2.560388E+01 -3.296889E+01 -3.456252E+00 -6.101655E-01 -4.929539E+01 -1.220666E+02 -6.629094E+00 -2.223366E+00 -2.255498E+01 -2.559363E+01 -2.833426E+00 -4.150907E-01 -3.909813E+01 -7.694976E+01 -5.582222E+00 -1.584757E+00 -1.620082E+01 -1.320814E+01 -2.282196E+00 -2.703156E-01 -2.263498E+01 -2.576758E+01 -3.162736E+00 -5.145038E-01 -5.750110E+00 -1.676357E+00 -9.181679E-01 -4.562885E-02 +5.925339E+00 +1.788596E+00 +8.954773E-01 +4.217679E-02 +2.215054E+01 +2.470273E+01 +2.944747E+00 +4.443186E-01 +1.542658E+01 +1.195085E+01 +1.950262E+00 +1.946340E-01 +3.791137E+01 +7.214779E+01 +4.955741E+00 +1.254830E+00 +2.200054E+01 +2.431894E+01 +3.031040E+00 +4.685971E-01 +4.823946E+01 +1.167941E+02 +6.226321E+00 +1.956308E+00 +2.556930E+01 +3.280828E+01 +3.582546E+00 +6.505962E-01 +2.577249E+01 +3.339204E+01 +3.316825E+00 +5.676842E-01 +5.007249E+01 +1.257124E+02 +6.462364E+00 +2.120157E+00 +2.273285E+01 +2.595106E+01 +2.960964E+00 +4.496277E-01 +3.937362E+01 +7.783849E+01 +5.339336E+00 +1.449257E+00 +1.623315E+01 +1.326746E+01 +2.289661E+00 +2.698618E-01 +2.325250E+01 +2.716827E+01 +3.253010E+00 +5.413837E-01 +5.937929E+00 +1.774847E+00 +9.208589E-01 +4.421403E-02 cmfd indices 1.400000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.166740E+00 -1.184008E+00 -1.166534E+00 -1.155559E+00 -1.164960E+00 -1.163229E+00 -1.165897E+00 -1.170104E+00 -1.170207E+00 -1.168091E+00 -1.170940E+00 -1.174589E+00 -1.174609E+00 -1.171505E+00 -1.174456E+00 -1.178370E+00 +1.125528E+00 +1.145509E+00 +1.158948E+00 +1.171983E+00 +1.180649E+00 +1.184072E+00 +1.188112E+00 +1.183095E+00 +1.182269E+00 +1.175467E+00 +1.175184E+00 +1.172637E+00 +1.171593E+00 +1.175439E+00 +1.174650E+00 +1.176474E+00 cmfd entropy -3.594757E+00 -3.587018E+00 -3.590385E+00 -3.595101E+00 -3.592151E+00 -3.600294E+00 -3.602102E+00 -3.604941E+00 -3.605897E+00 -3.604880E+00 -3.601658E+00 -3.602551E+00 -3.600160E+00 -3.604540E+00 -3.604094E+00 -3.602509E+00 +3.607059E+00 +3.604890E+00 +3.601329E+00 +3.597776E+00 +3.597360E+00 +3.597387E+00 +3.595379E+00 +3.596995E+00 +3.600901E+00 +3.601832E+00 +3.601426E+00 +3.604521E+00 +3.602848E+00 +3.603875E+00 +3.605213E+00 +3.606699E+00 cmfd balance -5.52960E-03 -5.42154E-03 -3.62152E-03 -2.92850E-03 -4.08642E-03 -2.07444E-03 -2.03704E-03 -2.06886E-03 -2.09646E-03 -1.94256E-03 -2.02728E-03 -1.89830E-03 -1.83910E-03 -1.48140E-03 -1.47034E-03 -1.64452E-03 +4.46212E-03 +4.66648E-03 +5.04274E-03 +5.21553E-03 +3.92498E-03 +2.97185E-03 +2.79785E-03 +2.66951E-03 +2.17472E-03 +1.98009E-03 +1.77035E-03 +1.51281E-03 +1.52807E-03 +1.33341E-03 +1.18155E-03 +1.07752E-03 cmfd dominance ratio -6.046E-01 -6.015E-01 -6.059E-01 -6.060E-01 -6.061E-01 -6.109E-01 -6.110E-01 -6.108E-01 -6.120E-01 -6.124E-01 -6.109E-01 -6.090E-01 -6.116E-01 +6.136E-01 +6.127E-01 6.137E-01 -6.117E-01 -6.131E-01 +6.102E-01 +6.067E-01 +6.061E-01 +6.031E-01 +6.046E-01 +6.071E-01 +6.089E-01 +6.073E-01 +6.080E-01 +6.080E-01 +6.090E-01 +6.092E-01 +6.094E-01 cmfd openmc source comparison -1.035187E-02 -9.394886E-03 -6.879487E-03 -7.236029E-03 -6.543528E-03 -3.600620E-03 -2.859638E-03 -2.230047E-03 -2.180643E-03 -1.638534E-03 -1.764349E-03 -1.621487E-03 -1.221762E-03 -1.626297E-03 -1.951813E-03 -9.584126E-04 +1.043027E-02 +1.278226E-02 +1.184867E-02 +1.017186E-02 +1.099696E-02 +7.955341E-03 +8.360344E-03 +6.875508E-03 +4.824018E-03 +4.915363E-03 +5.371647E-03 +4.593100E-03 +4.894955E-03 +4.928253E-03 +4.292171E-03 +4.018545E-03 cmfd source -1.677059E-02 -6.229453E-02 -4.278394E-02 -1.134852E-01 -6.231020E-02 -1.327286E-01 -6.808362E-02 -7.130954E-02 -1.362127E-01 -6.048013E-02 -1.094460E-01 -4.546687E-02 -6.403310E-02 -1.459510E-02 +1.600876E-02 +6.000305E-02 +4.248071E-02 +9.935789E-02 +5.768092E-02 +1.338593E-01 +7.417398E-02 +7.102984E-02 +1.382563E-01 +6.181889E-02 +1.142473E-01 +4.571447E-02 +6.864655E-02 +1.672206E-02 diff --git a/tests/regression_tests/cmfd_feed_ref_d/results_true.dat b/tests/regression_tests/cmfd_feed_ref_d/results_true.dat index 34cde1a46..9cc26b8cf 100644 --- a/tests/regression_tests/cmfd_feed_ref_d/results_true.dat +++ b/tests/regression_tests/cmfd_feed_ref_d/results_true.dat @@ -1,117 +1,117 @@ k-combined: -1.162249E+00 5.812620E-03 +1.167869E+00 7.492916E-03 tally 1: -1.153831E+01 -1.338142E+01 -2.155552E+01 -4.659071E+01 -2.813997E+01 -7.941672E+01 -3.270996E+01 -1.073664E+02 -3.639852E+01 -1.329148E+02 -3.729637E+01 -1.393474E+02 -3.443129E+01 -1.186461E+02 -2.832690E+01 -8.040998E+01 -2.177527E+01 -4.771147E+01 -1.146822E+01 -1.328252E+01 +1.146821E+01 +1.318787E+01 +2.161476E+01 +4.685066E+01 +2.951084E+01 +8.733116E+01 +3.521523E+01 +1.242762E+02 +3.774181E+01 +1.426460E+02 +3.727924E+01 +1.391162E+02 +3.377236E+01 +1.143877E+02 +2.904590E+01 +8.453427E+01 +2.090941E+01 +4.384824E+01 +1.078680E+01 +1.168172E+01 tally 2: -1.024353E+00 -1.049299E+00 -6.991057E-01 -4.887487E-01 -2.200432E+00 -4.841901E+00 -1.561655E+00 -2.438768E+00 -2.910400E+00 -8.470426E+00 -2.095155E+00 -4.389674E+00 -3.466006E+00 -1.201320E+01 -2.480456E+00 -6.152662E+00 -3.711781E+00 -1.377732E+01 -2.646019E+00 -7.001418E+00 -3.953648E+00 -1.563133E+01 -2.832759E+00 -8.024524E+00 -3.597870E+00 -1.294467E+01 -2.555396E+00 -6.530048E+00 -2.860871E+00 -8.184585E+00 -2.032282E+00 -4.130169E+00 -2.006740E+00 -4.027007E+00 -1.408150E+00 -1.982886E+00 -1.035163E+00 -1.071562E+00 -7.084068E-01 -5.018402E-01 +1.136805E+00 +1.292326E+00 +7.987282E-01 +6.379667E-01 +2.266961E+00 +5.139112E+00 +1.613498E+00 +2.603376E+00 +3.046379E+00 +9.280427E+00 +2.182480E+00 +4.763219E+00 +3.568101E+00 +1.273134E+01 +2.532478E+00 +6.413444E+00 +3.989532E+00 +1.591637E+01 +2.848319E+00 +8.112921E+00 +3.853139E+00 +1.484668E+01 +2.718497E+00 +7.390223E+00 +3.478134E+00 +1.209742E+01 +2.467279E+00 +6.087465E+00 +2.952214E+00 +8.715569E+00 +2.103257E+00 +4.423688E+00 +1.917446E+00 +3.676599E+00 +1.378361E+00 +1.899878E+00 +1.048230E+00 +1.098785E+00 +7.511876E-01 +5.642828E-01 tally 3: -6.713566E-01 -4.507196E-01 -5.581718E-02 -3.115557E-03 -1.508976E+00 -2.277009E+00 -1.139601E-01 -1.298690E-02 -2.035529E+00 -4.143377E+00 -1.221001E-01 -1.490843E-02 -2.385217E+00 -5.689262E+00 -1.500087E-01 -2.250260E-02 -2.546286E+00 -6.483574E+00 -1.546601E-01 -2.391975E-02 -2.726427E+00 -7.433407E+00 -1.686144E-01 -2.843081E-02 -2.466613E+00 -6.084179E+00 -1.558230E-01 -2.428079E-02 -1.951251E+00 -3.807379E+00 -1.197744E-01 -1.434590E-02 -1.347903E+00 -1.816842E+00 -9.419149E-02 -8.872037E-03 -6.840490E-01 -4.679231E-01 -5.000289E-02 -2.500289E-03 +7.701212E-01 +5.930866E-01 +4.481580E-02 +2.008456E-03 +1.547321E+00 +2.394203E+00 +1.226538E-01 +1.504395E-02 +2.106393E+00 +4.436893E+00 +1.450617E-01 +2.104289E-02 +2.437675E+00 +5.942260E+00 +1.521379E-01 +2.314593E-02 +2.754657E+00 +7.588135E+00 +1.745458E-01 +3.046622E-02 +2.623856E+00 +6.884619E+00 +1.851600E-01 +3.428423E-02 +2.376884E+00 +5.649579E+00 +1.615728E-01 +2.610576E-02 +2.021851E+00 +4.087882E+00 +1.533172E-01 +2.350617E-02 +1.333182E+00 +1.777374E+00 +7.076179E-02 +5.007231E-03 +7.258458E-01 +5.268521E-01 +3.656026E-02 +1.336653E-03 tally 4: -1.561665E-01 -2.438798E-02 +1.667426E-01 +2.780308E-02 0.000000E+00 0.000000E+00 -1.307011E-01 -1.708276E-02 -2.703168E-01 -7.307115E-02 +1.292556E-01 +1.670700E-02 +2.813401E-01 +7.915227E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -128,14 +128,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.703168E-01 -7.307115E-02 -1.307011E-01 -1.708276E-02 -2.637619E-01 -6.957033E-02 -3.685390E-01 -1.358210E-01 +2.813401E-01 +7.915227E-02 +1.292556E-01 +1.670700E-02 +2.670582E-01 +7.132006E-02 +4.055365E-01 +1.644599E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -152,14 +152,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.685390E-01 -1.358210E-01 -2.637619E-01 -6.957033E-02 -3.887017E-01 -1.510890E-01 -4.439407E-01 -1.970834E-01 +4.055365E-01 +1.644599E-01 +2.670582E-01 +7.132006E-02 +3.848164E-01 +1.480837E-01 +4.809472E-01 +2.313102E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -176,14 +176,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.439407E-01 -1.970834E-01 -3.887017E-01 -1.510890E-01 -4.456116E-01 -1.985697E-01 -4.737035E-01 -2.243950E-01 +4.809472E-01 +2.313102E-01 +3.848164E-01 +1.480837E-01 +4.543959E-01 +2.064756E-01 +5.106174E-01 +2.607301E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -200,14 +200,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.737035E-01 -2.243950E-01 -4.456116E-01 -1.985697E-01 -4.760577E-01 -2.266309E-01 -4.703245E-01 -2.212052E-01 +5.106174E-01 +2.607301E-01 +4.543959E-01 +2.064756E-01 +4.543155E-01 +2.064026E-01 +4.626331E-01 +2.140294E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -224,14 +224,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.703245E-01 -2.212052E-01 -4.760577E-01 -2.266309E-01 -4.878056E-01 -2.379543E-01 -4.373120E-01 -1.912418E-01 +4.626331E-01 +2.140294E-01 +4.543155E-01 +2.064026E-01 +4.827763E-01 +2.330729E-01 +4.442611E-01 +1.973679E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -248,14 +248,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.373120E-01 -1.912418E-01 -4.878056E-01 -2.379543E-01 -4.262194E-01 -1.816630E-01 -3.334152E-01 -1.111657E-01 +4.442611E-01 +1.973679E-01 +4.827763E-01 +2.330729E-01 +4.630415E-01 +2.144074E-01 +3.886521E-01 +1.510505E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -272,14 +272,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.334152E-01 -1.111657E-01 -4.262194E-01 -1.816630E-01 -3.560156E-01 -1.267471E-01 -2.409954E-01 -5.807879E-02 +3.886521E-01 +1.510505E-01 +4.630415E-01 +2.144074E-01 +3.535862E-01 +1.250232E-01 +2.530293E-01 +6.402384E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -296,14 +296,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.409954E-01 -5.807879E-02 -3.560156E-01 -1.267471E-01 -2.646501E-01 -7.003965E-02 -1.327244E-01 -1.761576E-02 +2.530293E-01 +6.402384E-02 +3.535862E-01 +1.250232E-01 +2.465508E-01 +6.078730E-02 +1.197139E-01 +1.433141E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -320,12 +320,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.327244E-01 -1.761576E-02 -2.646501E-01 -7.003965E-02 -1.480567E-01 -2.192079E-02 +1.197139E-01 +1.433141E-02 +2.465508E-01 +6.078730E-02 +1.369614E-01 +1.875841E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -345,119 +345,119 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -6.713566E-01 -4.507196E-01 -9.805793E-02 -9.615358E-03 -1.508976E+00 -2.277009E+00 -1.968348E-01 -3.874394E-02 -2.032573E+00 -4.131353E+00 -2.120922E-01 -4.498309E-02 -2.385217E+00 -5.689262E+00 -2.863031E-01 -8.196946E-02 -2.545200E+00 -6.478041E+00 -3.278920E-01 -1.075131E-01 -2.726427E+00 -7.433407E+00 -3.770758E-01 -1.421861E-01 -2.466613E+00 -6.084179E+00 -3.593230E-01 -1.291130E-01 -1.951251E+00 -3.807379E+00 -2.474112E-01 -6.121229E-02 -1.347903E+00 -1.816842E+00 -2.127109E-01 -4.524594E-02 -6.823620E-01 -4.656179E-01 -1.249863E-01 -1.562159E-02 +7.701212E-01 +5.930866E-01 +1.386254E-01 +1.921700E-02 +1.547321E+00 +2.394203E+00 +2.630318E-01 +6.918571E-02 +2.106393E+00 +4.436893E+00 +2.807911E-01 +7.884363E-02 +2.435870E+00 +5.933464E+00 +3.322093E-01 +1.103630E-01 +2.753652E+00 +7.582597E+00 +3.825961E-01 +1.463797E-01 +2.623856E+00 +6.884619E+00 +3.888719E-01 +1.512213E-01 +2.376884E+00 +5.649579E+00 +3.196211E-01 +1.021576E-01 +2.021851E+00 +4.087882E+00 +2.897873E-01 +8.397667E-02 +1.333182E+00 +1.777374E+00 +1.627096E-01 +2.647441E-02 +7.258458E-01 +5.268521E-01 +9.348575E-02 +8.739586E-03 cmfd indices 1.000000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.181365E+00 -1.176693E+00 -1.161946E+00 -1.163565E+00 -1.163043E+00 -1.169908E+00 -1.149155E+00 -1.142379E+00 -1.152957E+00 -1.137602E+00 -1.141883E+00 +1.149087E+00 +1.156777E+00 +1.158641E+00 +1.159507E+00 +1.156564E+00 +1.160257E+00 +1.150344E+00 +1.149854E+00 +1.151616E+00 +1.164575E+00 +1.174683E+00 cmfd entropy -3.246422E+00 -3.246496E+00 -3.252238E+00 -3.240920E+00 -3.237606E+00 -3.234301E+00 -3.234103E+00 -3.229918E+00 -3.226983E+00 -3.221321E+00 -3.223622E+00 +3.216202E+00 +3.228703E+00 +3.220414E+00 +3.214361E+00 +3.215642E+00 +3.213607E+00 +3.212862E+00 +3.213128E+00 +3.213189E+00 +3.205465E+00 +3.202859E+00 cmfd balance -4.18486E-03 -1.72126E-03 -1.10906E-03 -1.88158E-03 -1.31626E-03 -1.30818E-03 -1.77315E-03 -2.16148E-03 -1.67789E-03 -2.31333E-03 -1.94932E-03 +3.08825E-03 +1.42554E-03 +1.21448E-03 +1.17859E-03 +1.06034E-03 +9.30949E-04 +1.35713E-03 +1.13694E-03 +1.14938E-03 +1.29296E-03 +1.46518E-03 cmfd dominance ratio +5.503E-01 +5.596E-01 5.505E-01 -5.580E-01 -5.610E-01 -5.526E-01 -5.519E-01 -5.499E-01 -5.504E-01 -5.504E-01 -5.475E-01 -5.465E-01 -5.477E-01 +5.471E-01 +5.468E-01 +5.427E-01 +5.421E-01 +5.412E-01 +5.389E-01 +5.371E-01 +5.329E-01 cmfd openmc source comparison -1.902234E-03 -4.110960E-03 -2.452031E-03 -2.337951E-03 -1.838979E-03 -3.138637E-03 -2.684401E-03 -2.912891E-03 -2.823494E-03 -6.391584E-03 -5.904139E-03 +1.571006E-02 +6.945629E-03 +6.838511E-03 +6.183655E-03 +5.138825E-03 +4.362701E-03 +5.558586E-03 +4.188314E-03 +1.837101E-03 +2.737321E-03 +2.529244E-03 cmfd source -4.488002E-02 -8.895136E-02 -1.085930E-01 -1.229651E-01 -1.330479E-01 -1.497140E-01 -1.309102E-01 -1.028556E-01 -7.738878E-02 -4.069397E-02 +4.240947E-02 +8.226746E-02 +1.180848E-01 +1.328470E-01 +1.412449E-01 +1.424870E-01 +1.269297E-01 +1.096476E-01 +6.953001E-02 +3.455212E-02 diff --git a/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat b/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat index 2e31b35ba..5ff4a132f 100644 --- a/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat +++ b/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat @@ -1,117 +1,117 @@ k-combined: -1.158333E+00 1.402684E-02 +1.173626E+00 1.098719E-02 tally 1: -1.169478E+01 -1.373162E+01 -2.192038E+01 -4.844559E+01 -2.913292E+01 -8.542569E+01 -3.446069E+01 -1.201782E+02 -3.624088E+01 -1.320213E+02 -3.569791E+01 -1.278170E+02 -3.340601E+01 -1.119165E+02 -2.908648E+01 -8.514603E+01 -2.175458E+01 -4.767916E+01 -1.171268E+01 -1.378033E+01 +1.101892E+01 +1.218768E+01 +2.036233E+01 +4.152577E+01 +2.937587E+01 +8.637268E+01 +3.502389E+01 +1.231700E+02 +3.804803E+01 +1.453948E+02 +3.822561E+01 +1.465677E+02 +3.456290E+01 +1.198651E+02 +2.904088E+01 +8.470264E+01 +2.111529E+01 +4.463713E+01 +1.147633E+01 +1.326012E+01 tally 2: -1.132414E+00 -1.282361E+00 -7.822980E-01 -6.119901E-01 -2.124428E+00 -4.513196E+00 -1.490832E+00 -2.222581E+00 -3.158472E+00 -9.975946E+00 -2.221665E+00 -4.935795E+00 -3.994786E+00 -1.595831E+01 -2.828109E+00 -7.998199E+00 -3.491035E+00 -1.218732E+01 -2.461223E+00 -6.057617E+00 -3.461784E+00 -1.198395E+01 -2.473337E+00 -6.117398E+00 -3.027132E+00 -9.163527E+00 -2.150455E+00 -4.624458E+00 -2.471217E+00 -6.106911E+00 -1.737168E+00 -3.017752E+00 -1.880969E+00 -3.538044E+00 -1.316574E+00 -1.733367E+00 -1.233103E+00 -1.520543E+00 -8.543318E-01 -7.298828E-01 +1.010478E+00 +1.021066E+00 +6.902031E-01 +4.763804E-01 +1.899891E+00 +3.609584E+00 +1.322615E+00 +1.749312E+00 +2.756419E+00 +7.597845E+00 +1.955934E+00 +3.825676E+00 +3.818740E+00 +1.458278E+01 +2.704746E+00 +7.315652E+00 +3.920857E+00 +1.537312E+01 +2.843144E+00 +8.083470E+00 +3.835060E+00 +1.470768E+01 +2.728705E+00 +7.445831E+00 +3.510590E+00 +1.232424E+01 +2.497237E+00 +6.236191E+00 +2.717388E+00 +7.384198E+00 +1.903638E+00 +3.623837E+00 +2.207863E+00 +4.874659E+00 +1.563588E+00 +2.444808E+00 +1.289027E+00 +1.661591E+00 +9.022714E-01 +8.140937E-01 tally 3: -7.540113E-01 -5.685330E-01 -6.367610E-02 -4.054646E-03 -1.436984E+00 -2.064922E+00 -8.961822E-02 -8.031425E-03 -2.132240E+00 -4.546449E+00 -1.356065E-01 -1.838913E-02 -2.726356E+00 -7.433016E+00 -1.780572E-01 -3.170438E-02 -2.379700E+00 -5.662970E+00 -1.544735E-01 -2.386206E-02 -2.383471E+00 -5.680933E+00 -1.568319E-01 -2.459624E-02 -2.047271E+00 -4.191318E+00 -1.662654E-01 -2.764418E-02 -1.673107E+00 -2.799287E+00 -1.132020E-01 -1.281468E-02 -1.271576E+00 -1.616906E+00 -7.546797E-02 -5.695415E-03 -8.249906E-01 -6.806094E-01 -5.660098E-02 -3.203671E-03 +6.593197E-01 +4.347024E-01 +5.216387E-02 +2.721069E-03 +1.266446E+00 +1.603885E+00 +8.298797E-02 +6.887003E-03 +1.888709E+00 +3.567222E+00 +1.398940E-01 +1.957033E-02 +2.616078E+00 +6.843867E+00 +1.588627E-01 +2.523735E-02 +2.733300E+00 +7.470927E+00 +1.944290E-01 +3.780262E-02 +2.643656E+00 +6.988917E+00 +1.612338E-01 +2.599633E-02 +2.410643E+00 +5.811199E+00 +1.754603E-01 +3.078631E-02 +1.838012E+00 +3.378288E+00 +1.126265E-01 +1.268473E-02 +1.500033E+00 +2.250100E+00 +1.102554E-01 +1.215626E-02 +8.750096E-01 +7.656418E-01 +6.757592E-02 +4.566505E-03 tally 4: -1.551630E-01 -2.407556E-02 +1.490605E-01 +2.221904E-02 0.000000E+00 0.000000E+00 -1.487992E-01 -2.214121E-02 -2.878091E-01 -8.283409E-02 +1.139233E-01 +1.297851E-02 +2.549497E-01 +6.499934E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -128,14 +128,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.878091E-01 -8.283409E-02 -1.487992E-01 -2.214121E-02 -2.936596E-01 -8.623595E-02 -3.954149E-01 -1.563529E-01 +2.549497E-01 +6.499934E-02 +1.139233E-01 +1.297851E-02 +2.191337E-01 +4.801958E-02 +3.295187E-01 +1.085826E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -152,14 +152,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.954149E-01 -1.563529E-01 -2.936596E-01 -8.623595E-02 -3.991153E-01 -1.592930E-01 -4.758410E-01 -2.264247E-01 +3.295187E-01 +1.085826E-01 +2.191337E-01 +4.801958E-02 +3.872400E-01 +1.499548E-01 +4.595835E-01 +2.112170E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -176,14 +176,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.758410E-01 -2.264247E-01 -3.991153E-01 -1.592930E-01 -4.850882E-01 -2.353106E-01 -5.210840E-01 -2.715285E-01 +4.595835E-01 +2.112170E-01 +3.872400E-01 +1.499548E-01 +4.668106E-01 +2.179121E-01 +5.112307E-01 +2.613569E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -200,14 +200,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.210840E-01 -2.715285E-01 -4.850882E-01 -2.353106E-01 -4.790245E-01 -2.294645E-01 -4.570092E-01 -2.088574E-01 +5.112307E-01 +2.613569E-01 +4.668106E-01 +2.179121E-01 +4.716605E-01 +2.224636E-01 +4.916148E-01 +2.416851E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -224,14 +224,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -4.570092E-01 -2.088574E-01 -4.790245E-01 -2.294645E-01 -4.505886E-01 -2.030301E-01 -3.884038E-01 -1.508575E-01 +4.916148E-01 +2.416851E-01 +4.716605E-01 +2.224636E-01 +4.696777E-01 +2.205972E-01 +4.365150E-01 +1.905453E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -248,14 +248,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.884038E-01 -1.508575E-01 -4.505886E-01 -2.030301E-01 -3.986999E-01 -1.589616E-01 -3.220889E-01 -1.037412E-01 +4.365150E-01 +1.905453E-01 +4.696777E-01 +2.205972E-01 +4.179902E-01 +1.747158E-01 +3.350564E-01 +1.122628E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -272,14 +272,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -3.220889E-01 -1.037412E-01 -3.986999E-01 -1.589616E-01 -3.319083E-01 -1.101631E-01 -2.101261E-01 -4.415297E-02 +3.350564E-01 +1.122628E-01 +4.179902E-01 +1.747158E-01 +3.743487E-01 +1.401370E-01 +2.400661E-01 +5.763172E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -296,14 +296,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.101261E-01 -4.415297E-02 -3.319083E-01 -1.101631E-01 -2.795459E-01 -7.814588E-02 -1.306499E-01 -1.706938E-02 +2.400661E-01 +5.763172E-02 +3.743487E-01 +1.401370E-01 +3.063657E-01 +9.385994E-02 +1.605078E-01 +2.576275E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -320,12 +320,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.306499E-01 -1.706938E-02 -2.795459E-01 -7.814588E-02 -1.585507E-01 -2.513833E-02 +1.605078E-01 +2.576275E-02 +3.063657E-01 +9.385994E-02 +1.700639E-01 +2.892174E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -345,119 +345,119 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -7.530237E-01 -5.670447E-01 -1.178984E-01 -1.390004E-02 -1.436984E+00 -2.064922E+00 -1.458395E-01 -2.126916E-02 -2.132240E+00 -4.546449E+00 -2.950109E-01 -8.703141E-02 -2.726356E+00 -7.433016E+00 -3.397288E-01 -1.154157E-01 -2.379700E+00 -5.662970E+00 -3.113206E-01 -9.692053E-02 -2.383471E+00 -5.680933E+00 -3.455611E-01 -1.194125E-01 -2.047271E+00 -4.191318E+00 -2.910986E-01 -8.473841E-02 -1.673107E+00 -2.799287E+00 -2.381996E-01 -5.673907E-02 -1.270672E+00 -1.614606E+00 -1.795241E-01 -3.222889E-02 -8.249906E-01 -6.806094E-01 -1.201397E-01 -1.443354E-02 +6.593197E-01 +4.347024E-01 +1.314196E-01 +1.727112E-02 +1.266446E+00 +1.603885E+00 +2.002491E-01 +4.009970E-02 +1.888709E+00 +3.567222E+00 +2.444522E-01 +5.975686E-02 +2.616078E+00 +6.843867E+00 +3.234935E-01 +1.046481E-01 +2.733300E+00 +7.470927E+00 +3.309500E-01 +1.095279E-01 +2.643656E+00 +6.988917E+00 +4.025014E-01 +1.620074E-01 +2.410643E+00 +5.811199E+00 +3.050040E-01 +9.302747E-02 +1.838012E+00 +3.378288E+00 +2.800764E-01 +7.844279E-02 +1.500033E+00 +2.250100E+00 +2.324765E-01 +5.404531E-02 +8.750096E-01 +7.656418E-01 +1.256919E-01 +1.579844E-02 cmfd indices 1.000000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.184474E+00 -1.188170E+00 -1.165127E+00 -1.135010E+00 -1.145439E+00 -1.158451E+00 -1.154420E+00 -1.179615E+00 -1.197843E+00 -1.181252E+00 -1.186316E+00 +1.166297E+00 +1.148237E+00 +1.162472E+00 +1.187078E+00 +1.188411E+00 +1.194879E+00 +1.216739E+00 +1.216829E+00 +1.196596E+00 +1.199223E+00 +1.211817E+00 cmfd entropy -3.243654E+00 -3.244091E+00 -3.249203E+00 -3.249952E+00 -3.245538E+00 -3.240838E+00 -3.238919E+00 -3.223131E+00 -3.216002E+00 -3.220324E+00 -3.224804E+00 +3.215349E+00 +3.225577E+00 +3.223357E+00 +3.208828E+00 +3.211072E+00 +3.206578E+00 +3.195799E+00 +3.198236E+00 +3.220074E+00 +3.230249E+00 +3.238015E+00 cmfd balance -4.21104E-03 -1.38052E-03 -1.34642E-03 -2.39255E-03 -2.07426E-03 -1.27927E-03 -2.26249E-03 -2.72103E-03 -2.71504E-03 -2.19156E-03 -1.91989E-03 +2.07468E-03 +2.39687E-03 +1.51020E-03 +2.07618E-03 +1.89367E-03 +2.00902E-03 +2.54856E-03 +2.43636E-03 +2.48527E-03 +3.07775E-03 +3.37967E-03 cmfd dominance ratio -5.520E-01 -5.535E-01 -5.628E-01 -5.696E-01 -5.723E-01 -5.651E-01 -5.648E-01 -5.555E-01 -5.448E-01 -5.488E-01 +5.505E-01 +5.558E-01 +5.584E-01 +5.477E-01 +5.477E-01 +5.426E-01 +5.335E-01 +5.305E-01 +5.427E-01 5.484E-01 +5.465E-01 cmfd openmc source comparison -1.713810E-03 -2.429503E-03 -4.526209E-03 -7.978149E-03 -3.320012E-03 -3.880041E-03 -1.580215E-02 -1.663452E-02 -1.878103E-02 -7.436342E-03 -3.724478E-03 +5.598628E-03 +1.162952E-02 +1.083004E-02 +1.037470E-02 +5.649750E-03 +5.137914E-03 +3.868209E-03 +1.208756E-02 +5.398131E-03 +8.119598E-03 +4.573105E-03 cmfd source -4.688167E-02 -9.066303E-02 -1.150679E-01 -1.430247E-01 -1.370466E-01 -1.267615E-01 -1.244218E-01 -1.048774E-01 -7.083441E-02 -4.042108E-02 +4.219187E-02 +8.692096E-02 +1.061389E-01 +1.199181E-01 +1.377328E-01 +1.326161E-01 +1.345872E-01 +1.112871E-01 +7.569533E-02 +5.291175E-02 diff --git a/tests/regression_tests/cmfd_nofeed/results_true.dat b/tests/regression_tests/cmfd_nofeed/results_true.dat index ea1a0230b..756aa4570 100644 --- a/tests/regression_tests/cmfd_nofeed/results_true.dat +++ b/tests/regression_tests/cmfd_nofeed/results_true.dat @@ -1,117 +1,117 @@ k-combined: -1.169143E+00 7.248013E-03 +1.172893E+00 8.095197E-03 tally 1: -1.115130E+01 -1.249933E+01 -2.147608E+01 -4.643964E+01 -2.923697E+01 -8.598273E+01 -3.439175E+01 -1.189653E+02 -3.729169E+01 -1.395456E+02 -3.709975E+01 -1.380839E+02 -3.415420E+01 -1.168226E+02 -2.895696E+01 -8.419764E+01 -2.140382E+01 -4.646784E+01 -1.125483E+01 -1.275812E+01 +1.156995E+01 +1.347019E+01 +2.120053E+01 +4.531200E+01 +2.995993E+01 +8.997889E+01 +3.498938E+01 +1.226414E+02 +3.794510E+01 +1.442188E+02 +3.798115E+01 +1.446436E+02 +3.415954E+01 +1.171635E+02 +2.960329E+01 +8.785532E+01 +2.182231E+01 +4.782353E+01 +1.147379E+01 +1.321150E+01 tally 2: -2.275147E+01 -2.604974E+01 -1.587800E+01 -1.271197E+01 -4.191959E+01 -8.846441E+01 -2.966500E+01 -4.430669E+01 -5.699815E+01 -1.637359E+02 -4.037600E+01 -8.219353E+01 -6.656851E+01 -2.228703E+02 -4.718000E+01 -1.119941E+02 -7.334215E+01 -2.701014E+02 -5.223500E+01 -1.370726E+02 -7.394394E+01 -2.748295E+02 -5.273400E+01 -1.397334E+02 -6.931604E+01 -2.406234E+02 -4.949000E+01 -1.226886E+02 -5.799672E+01 -1.687992E+02 -4.142300E+01 -8.612116E+01 -4.320102E+01 -9.402138E+01 -3.068300E+01 -4.749148E+01 -2.295257E+01 -2.657057E+01 -1.606200E+01 -1.301453E+01 +2.345900E+01 +2.783672E+01 +1.627300E+01 +1.339749E+01 +4.127267E+01 +8.563716E+01 +2.934800E+01 +4.334439E+01 +5.742644E+01 +1.658158E+02 +4.092600E+01 +8.423842E+01 +6.740126E+01 +2.279288E+02 +4.796500E+01 +1.154602E+02 +7.340327E+01 +2.701349E+02 +5.235900E+01 +1.374186E+02 +7.387392E+01 +2.740829E+02 +5.277400E+01 +1.398425E+02 +6.733428E+01 +2.274414E+02 +4.800100E+01 +1.156206E+02 +5.794970E+01 +1.685421E+02 +4.124600E+01 +8.540686E+01 +4.257013E+01 +9.092401E+01 +3.014500E+01 +4.566369E+01 +2.300274E+01 +2.659051E+01 +1.613400E+01 +1.307448E+01 tally 3: -1.528200E+01 -1.177982E+01 -1.040687E+00 -5.586386E-02 -2.857900E+01 -4.113603E+01 -1.871515E+00 -1.774689E-01 -3.888800E+01 -7.626262E+01 -2.534433E+00 -3.274088E-01 -4.541400E+01 -1.037867E+02 -2.926509E+00 -4.319780E-01 -5.034500E+01 -1.273517E+02 -3.215813E+00 -5.215716E-01 -5.076100E+01 -1.295218E+02 -3.194424E+00 -5.165993E-01 -4.768100E+01 -1.138949E+02 -3.058255E+00 -4.732131E-01 -3.995800E+01 -8.015691E+01 -2.454286E+00 -3.044948E-01 -2.957000E+01 -4.412743E+01 -1.938963E+00 -1.908501E-01 -1.544000E+01 -1.202869E+01 -1.038073E+00 -5.487827E-02 +1.564900E+01 +1.239852E+01 +1.086873E+00 +6.047264E-02 +2.821700E+01 +4.006730E+01 +1.855830E+00 +1.755984E-01 +3.946300E+01 +7.833997E+01 +2.523142E+00 +3.210725E-01 +4.622500E+01 +1.072588E+02 +2.919735E+00 +4.340292E-01 +5.033400E+01 +1.270010E+02 +3.243022E+00 +5.318534E-01 +5.082400E+01 +1.297502E+02 +3.313898E+00 +5.546608E-01 +4.623700E+01 +1.072944E+02 +2.887766E+00 +4.203084E-01 +3.975000E+01 +7.934279E+01 +2.567158E+00 +3.333121E-01 +2.903500E+01 +4.237270E+01 +1.852070E+00 +1.733821E-01 +1.557800E+01 +1.219084E+01 +9.951884E-01 +5.121758E-02 tally 4: -3.086000E+00 -4.780160E-01 +3.111000E+00 +4.872850E-01 0.000000E+00 0.000000E+00 -2.739000E+00 -3.790990E-01 -5.478000E+00 -1.505928E+00 +2.794000E+00 +3.972060E-01 +5.520000E+00 +1.535670E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -128,14 +128,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.478000E+00 -1.505928E+00 -2.739000E+00 -3.790990E-01 -5.094000E+00 -1.310476E+00 -7.282000E+00 -2.669810E+00 +5.520000E+00 +1.535670E+00 +2.794000E+00 +3.972060E-01 +5.071000E+00 +1.305697E+00 +7.303000E+00 +2.685365E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -152,14 +152,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.282000E+00 -2.669810E+00 -5.094000E+00 -1.310476E+00 -6.987000E+00 -2.461137E+00 -8.487000E+00 -3.624153E+00 +7.303000E+00 +2.685365E+00 +5.071000E+00 +1.305697E+00 +7.015000E+00 +2.471981E+00 +8.545000E+00 +3.670539E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -176,14 +176,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.487000E+00 -3.624153E+00 -6.987000E+00 -2.461137E+00 -8.250000E+00 -3.421824E+00 -9.022000E+00 -4.088536E+00 +8.545000E+00 +3.670539E+00 +7.015000E+00 +2.471981E+00 +8.431000E+00 +3.570057E+00 +9.224000E+00 +4.268004E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -200,14 +200,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.022000E+00 -4.088536E+00 -8.250000E+00 -3.421824E+00 -9.300000E+00 -4.344142E+00 -9.262000E+00 -4.308946E+00 +9.224000E+00 +4.268004E+00 +8.431000E+00 +3.570057E+00 +9.217000E+00 +4.259749E+00 +9.305000E+00 +4.340149E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -224,14 +224,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.262000E+00 -4.308946E+00 -9.300000E+00 -4.344142E+00 -9.267000E+00 -4.310941E+00 -8.487000E+00 -3.613257E+00 +9.305000E+00 +4.340149E+00 +9.217000E+00 +4.259749E+00 +9.374000E+00 +4.415290E+00 +8.611000E+00 +3.718227E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -248,14 +248,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.487000E+00 -3.613257E+00 -9.267000E+00 -4.310941E+00 -8.682000E+00 -3.778194E+00 -7.123000E+00 -2.544345E+00 +8.611000E+00 +3.718227E+00 +9.374000E+00 +4.415290E+00 +8.515000E+00 +3.639945E+00 +7.056000E+00 +2.501658E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -272,14 +272,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.123000E+00 -2.544345E+00 -8.682000E+00 -3.778194E+00 -7.421000E+00 -2.773897E+00 -5.198000E+00 -1.369216E+00 +7.056000E+00 +2.501658E+00 +8.515000E+00 +3.639945E+00 +7.385000E+00 +2.737677E+00 +5.194000E+00 +1.356022E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -296,14 +296,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.198000E+00 -1.369216E+00 -7.421000E+00 -2.773897E+00 -5.567000E+00 -1.561013E+00 -2.763000E+00 -3.882750E-01 +5.194000E+00 +1.356022E+00 +7.385000E+00 +2.737677E+00 +5.436000E+00 +1.481654E+00 +2.756000E+00 +3.843860E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -320,12 +320,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.763000E+00 -3.882750E-01 -5.567000E+00 -1.561013E+00 -3.106000E+00 -4.853380E-01 +2.756000E+00 +3.843860E-01 +5.436000E+00 +1.481654E+00 +3.030000E+00 +4.643920E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -345,144 +345,144 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -1.527700E+01 -1.177204E+01 -2.285003E+00 -2.661382E-01 -2.857200E+01 -4.111506E+01 -4.126099E+00 -8.737996E-01 -3.887800E+01 -7.622094E+01 -5.121343E+00 -1.333837E+00 -4.540600E+01 -1.037492E+02 -6.160114E+00 -1.913665E+00 -5.033400E+01 -1.272949E+02 -6.859861E+00 -2.384476E+00 -5.075800E+01 -1.295055E+02 -6.929393E+00 -2.443364E+00 -4.767500E+01 -1.138658E+02 -6.385463E+00 -2.080293E+00 -3.995300E+01 -8.013651E+01 -5.620641E+00 -1.603844E+00 -2.956200E+01 -4.410395E+01 -3.952701E+00 -7.877105E-01 -1.543500E+01 -1.202080E+01 -2.203583E+00 -2.512936E-01 +1.564300E+01 +1.238861E+01 +2.090227E+00 +2.262627E-01 +2.821400E+01 +4.005826E+01 +3.870834E+00 +7.614623E-01 +3.945400E+01 +7.830326E+01 +5.290557E+00 +1.422339E+00 +4.621500E+01 +1.072116E+02 +6.144745E+00 +1.903309E+00 +5.032900E+01 +1.269756E+02 +6.867524E+00 +2.373593E+00 +5.081000E+01 +1.296784E+02 +6.456283E+00 +2.130767E+00 +4.623000E+01 +1.072613E+02 +5.931623E+00 +1.776451E+00 +3.974500E+01 +7.932288E+01 +5.339603E+00 +1.456812E+00 +2.902800E+01 +4.235232E+01 +4.102240E+00 +8.519551E-01 +1.557800E+01 +1.219084E+01 +2.137954E+00 +2.347770E-01 cmfd indices 1.000000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.169107E+00 -1.173852E+00 -1.181921E+00 -1.187733E+00 -1.185766E+00 -1.177020E+00 -1.181200E+00 -1.180088E+00 -1.180676E+00 -1.174948E+00 -1.174167E+00 -1.174935E+00 -1.169912E+00 -1.169058E+00 -1.170366E+00 -1.169774E+00 +1.129918E+00 +1.148352E+00 +1.143137E+00 +1.145795E+00 +1.147285E+00 +1.148588E+00 +1.148151E+00 +1.162118E+00 +1.165380E+00 +1.162851E+00 +1.163379E+00 +1.166986E+00 +1.167838E+00 +1.171743E+00 +1.170398E+00 +1.169773E+00 cmfd entropy -3.207640E+00 -3.212075E+00 -3.215463E+00 -3.219545E+00 -3.225225E+00 -3.227103E+00 -3.229048E+00 -3.228263E+00 -3.229077E+00 -3.229932E+00 -3.229351E+00 -3.228195E+00 -3.228493E+00 -3.227823E+00 -3.225830E+00 -3.227270E+00 +3.224769E+00 +3.222795E+00 +3.221174E+00 +3.222164E+00 +3.221025E+00 +3.220967E+00 +3.223497E+00 +3.219213E+00 +3.221679E+00 +3.222084E+00 +3.222281E+00 +3.222540E+00 +3.224614E+00 +3.224193E+00 +3.224925E+00 +3.224367E+00 cmfd balance -4.88208E-03 -4.63702E-03 -3.41158E-03 -2.99755E-03 -2.78360E-03 -3.31542E-03 -2.64344E-03 -2.04609E-03 -1.84340E-03 -1.65450E-03 -1.70816E-03 -1.69952E-03 -1.51417E-03 -1.32738E-03 -1.41435E-03 -1.01462E-03 +3.90454E-03 +4.33180E-03 +3.77057E-03 +3.16391E-03 +3.11765E-03 +2.59886E-03 +2.81060E-03 +3.25473E-03 +2.68544E-03 +2.01716E-03 +1.89350E-03 +1.79159E-03 +1.51353E-03 +1.48514E-03 +1.50207E-03 +1.44045E-03 cmfd dominance ratio -5.467E-01 -5.468E-01 -5.448E-01 -5.457E-01 -5.457E-01 -5.485E-01 -5.500E-01 -5.497E-01 -5.495E-01 -5.499E-01 -5.502E-01 -5.485E-01 -5.492E-01 -5.483E-01 +5.539E-01 +5.522E-01 +5.491E-01 +5.511E-01 +5.506E-01 +5.523E-01 +5.523E-01 5.473E-01 +5.478E-01 +5.461E-01 +5.462E-01 +5.459E-01 +5.475E-01 +5.463E-01 5.466E-01 +5.469E-01 cmfd openmc source comparison -9.587418E-03 -7.785087E-03 -6.798967E-03 -5.947641E-03 -4.980801E-03 -4.272665E-03 -4.073759E-03 -4.305612E-03 -3.572759E-03 -3.785830E-03 -3.766828E-03 -3.495462E-03 -3.017281E-03 -2.857633E-03 -2.858606E-03 -2.449010E-03 +9.875240E-03 +1.119358E-02 +8.513903E-03 +7.728971E-03 +5.993771E-03 +5.837301E-03 +4.861789E-03 +5.624038E-03 +4.297229E-03 +4.029732E-03 +3.669197E-03 +3.598834E-03 +3.023310E-03 +3.347346E-03 +2.943658E-03 +2.764986E-03 cmfd source -4.390084E-02 -7.966902E-02 -1.087889E-01 -1.263915E-01 -1.394331E-01 -1.383156E-01 -1.319970E-01 -1.051339E-01 -8.248244E-02 -4.388774E-02 +4.561921E-02 +7.896381E-02 +1.084687E-01 +1.264057E-01 +1.408942E-01 +1.438180E-01 +1.247333E-01 +1.100896E-01 +7.897187E-02 +4.203556E-02 diff --git a/tests/regression_tests/cmfd_restart/results_true.dat b/tests/regression_tests/cmfd_restart/results_true.dat index 1ef9624d4..f5f22d9ac 100644 --- a/tests/regression_tests/cmfd_restart/results_true.dat +++ b/tests/regression_tests/cmfd_restart/results_true.dat @@ -1,117 +1,117 @@ k-combined: -1.181723E+00 9.944883E-03 +1.164262E+00 9.207592E-03 tally 1: -1.169899E+01 -1.373251E+01 -2.142380E+01 -4.605511E+01 -2.968085E+01 -8.838716E+01 -3.561418E+01 -1.271206E+02 -3.777783E+01 -1.428817E+02 -3.805832E+01 -1.450213E+02 -3.439836E+01 -1.184892E+02 -2.852438E+01 -8.161896E+01 -2.088423E+01 -4.376204E+01 -1.076670E+01 -1.168108E+01 +1.156972E+01 +1.339924E+01 +2.136306E+01 +4.567185E+01 +2.859527E+01 +8.195821E+01 +3.470754E+01 +1.207851E+02 +3.766403E+01 +1.422263E+02 +3.778821E+01 +1.432660E+02 +3.573197E+01 +1.278854E+02 +2.849979E+01 +8.135515E+01 +2.073803E+01 +4.303374E+01 +1.112117E+01 +1.242944E+01 tally 2: -2.321241E+01 -2.702156E+01 -1.620912E+01 -1.317752E+01 -4.197404E+01 -8.845008E+01 -2.982666E+01 -4.469221E+01 -5.810089E+01 -1.695857E+02 -4.134123E+01 -8.588866E+01 -6.982488E+01 -2.447068E+02 -4.966939E+01 -1.238763E+02 -7.428421E+01 -2.767613E+02 -5.287955E+01 -1.403163E+02 -7.447402E+01 -2.785012E+02 -5.324628E+01 -1.423393E+02 -6.895164E+01 -2.381937E+02 -4.916366E+01 -1.211701E+02 -5.679253E+01 -1.617881E+02 -4.043125E+01 -8.204061E+01 -4.218618E+01 -8.933666E+01 -2.978592E+01 -4.456592E+01 -2.196426E+01 -2.435867E+01 -1.525576E+01 -1.175879E+01 +2.388054E+01 +2.875255E+01 +1.667791E+01 +1.403426E+01 +4.224771E+01 +8.942109E+01 +2.993088E+01 +4.490335E+01 +5.689839E+01 +1.625557E+02 +4.043633E+01 +8.212299E+01 +6.764024E+01 +2.297126E+02 +4.807902E+01 +1.161468E+02 +7.314835E+01 +2.684645E+02 +5.203584E+01 +1.359261E+02 +7.375727E+01 +2.733105E+02 +5.252944E+01 +1.386205E+02 +6.909571E+01 +2.397721E+02 +4.922548E+01 +1.217465E+02 +5.685978E+01 +1.621746E+02 +4.051938E+01 +8.237277E+01 +4.185562E+01 +8.784067E+01 +2.983570E+01 +4.467414E+01 +2.238373E+01 +2.520356E+01 +1.566758E+01 +1.234103E+01 tally 3: -1.563788E+01 -1.226528E+01 -1.053289E+00 -5.666942E-02 -2.870755E+01 -4.139654E+01 -1.838017E+00 -1.710528E-01 -3.978616E+01 -7.955764E+01 -2.560657E+00 -3.334449E-01 -4.780385E+01 -1.147770E+02 -3.139243E+00 -4.967628E-01 -5.106650E+01 -1.308704E+02 -3.170056E+00 -5.078920E-01 -5.123992E+01 -1.318586E+02 -3.211706E+00 -5.205979E-01 -4.729862E+01 -1.121695E+02 -3.068662E+00 -4.749488E-01 -3.898816E+01 -7.630564E+01 -2.516911E+00 -3.199696E-01 -2.865357E+01 -4.125742E+01 -1.852314E+00 -1.741116E-01 -1.467340E+01 -1.088460E+01 -9.268633E-01 -4.450662E-02 +1.609520E+01 +1.307542E+01 +1.033429E+00 +5.510889E-02 +2.877073E+01 +4.149542E+01 +1.964219E+00 +1.954692E-01 +3.896816E+01 +7.629752E+01 +2.484053E+00 +3.103733E-01 +4.634285E+01 +1.079367E+02 +2.974750E+00 +4.468223E-01 +5.007964E+01 +1.259202E+02 +3.181802E+00 +5.103621E-01 +5.058915E+01 +1.286193E+02 +3.249442E+00 +5.337712E-01 +4.744464E+01 +1.131026E+02 +3.067644E+00 +4.736335E-01 +3.900632E+01 +7.634433E+01 +2.443552E+00 +3.028060E-01 +2.874166E+01 +4.146375E+01 +1.810421E+00 +1.671667E-01 +1.509222E+01 +1.145579E+01 +1.014919E+00 +5.391053E-02 tally 4: -3.029754E+00 -4.613561E-01 +3.148231E+00 +4.974555E-01 0.000000E+00 0.000000E+00 -2.832501E+00 -4.049252E-01 -5.517243E+00 -1.527794E+00 +2.805439E+00 +3.982239E-01 +5.574031E+00 +1.561105E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -128,14 +128,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.517243E+00 -1.527794E+00 -2.832501E+00 -4.049252E-01 -5.117178E+00 -1.316972E+00 -7.333303E+00 -2.701677E+00 +5.574031E+00 +1.561105E+00 +2.805439E+00 +3.982239E-01 +5.171038E+00 +1.344877E+00 +7.372031E+00 +2.725420E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -152,14 +152,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.333303E+00 -2.701677E+00 -5.117178E+00 -1.316972E+00 -7.248464E+00 -2.641591E+00 -8.817788E+00 -3.905530E+00 +7.372031E+00 +2.725420E+00 +5.171038E+00 +1.344877E+00 +6.946847E+00 +2.424850E+00 +8.496610E+00 +3.627542E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -176,14 +176,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.817788E+00 -3.905530E+00 -7.248464E+00 -2.641591E+00 -8.646465E+00 -3.749847E+00 -9.460948E+00 -4.495388E+00 +8.496610E+00 +3.627542E+00 +6.946847E+00 +2.424850E+00 +8.479501E+00 +3.607280E+00 +9.261869E+00 +4.305912E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -200,14 +200,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.460948E+00 -4.495388E+00 -8.646465E+00 -3.749847E+00 -9.379341E+00 -4.415049E+00 -9.278640E+00 -4.320720E+00 +9.261869E+00 +4.305912E+00 +8.479501E+00 +3.607280E+00 +9.232858E+00 +4.278432E+00 +9.306384E+00 +4.348594E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -224,14 +224,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -9.278640E+00 -4.320720E+00 -9.379341E+00 -4.415049E+00 -9.465746E+00 -4.498591E+00 -8.656146E+00 -3.760545E+00 +9.306384E+00 +4.348594E+00 +9.232858E+00 +4.278432E+00 +9.299764E+00 +4.347828E+00 +8.511976E+00 +3.639893E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -248,14 +248,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -8.656146E+00 -3.760545E+00 -9.465746E+00 -4.498591E+00 -8.589782E+00 -3.700308E+00 -6.996002E+00 -2.456935E+00 +8.511976E+00 +3.639893E+00 +9.299764E+00 +4.347828E+00 +8.726086E+00 +3.819567E+00 +7.147277E+00 +2.562747E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -272,14 +272,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -6.996002E+00 -2.456935E+00 -8.589782E+00 -3.700308E+00 -7.352050E+00 -2.714808E+00 -5.105164E+00 -1.312559E+00 +7.147277E+00 +2.562747E+00 +8.726086E+00 +3.819567E+00 +7.218790E+00 +2.612243E+00 +5.018287E+00 +1.263077E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -296,14 +296,14 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -5.105164E+00 -1.312559E+00 -7.352050E+00 -2.714808E+00 -5.442756E+00 -1.486776E+00 -2.697305E+00 -3.675580E-01 +5.018287E+00 +1.263077E+00 +7.218790E+00 +2.612243E+00 +5.443494E+00 +1.487018E+00 +2.732334E+00 +3.773047E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -320,12 +320,12 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -2.697305E+00 -3.675580E-01 -5.442756E+00 -1.486776E+00 -3.017025E+00 -4.571443E-01 +2.732334E+00 +3.773047E-01 +5.443494E+00 +1.487018E+00 +3.044773E+00 +4.655756E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -345,144 +345,144 @@ tally 4: 0.000000E+00 0.000000E+00 tally 5: -1.563588E+01 -1.226217E+01 -2.209027E+00 -2.507131E-01 -2.870034E+01 -4.137550E+01 -3.726620E+00 -7.021948E-01 -3.977762E+01 -7.952285E+01 -5.304975E+00 -1.427333E+00 -4.779747E+01 -1.147456E+02 -6.528302E+00 -2.151715E+00 -5.105366E+01 -1.308037E+02 -6.986782E+00 -2.467487E+00 -5.123380E+01 -1.318264E+02 -6.845633E+00 -2.383542E+00 -4.729296E+01 -1.121433E+02 -6.252695E+00 -1.977351E+00 -3.898236E+01 -7.628315E+01 -5.461495E+00 -1.528579E+00 -2.864576E+01 -4.123538E+01 -3.857301E+00 -7.581323E-01 -1.467047E+01 -1.088031E+01 -2.277024E+00 -2.679801E-01 +1.609029E+01 +1.306718E+01 +2.230601E+00 +2.559496E-01 +2.876780E+01 +4.148686E+01 +3.835952E+00 +7.456562E-01 +3.895738E+01 +7.625344E+01 +4.841024E+00 +1.197335E+00 +4.633595E+01 +1.079043E+02 +6.236821E+00 +1.963311E+00 +5.007472E+01 +1.258967E+02 +6.749745E+00 +2.297130E+00 +5.058336E+01 +1.285894E+02 +6.727612E+00 +2.315656E+00 +4.743869E+01 +1.130735E+02 +6.338193E+00 +2.042159E+00 +3.899838E+01 +7.631289E+01 +5.187573E+00 +1.359733E+00 +2.873434E+01 +4.144233E+01 +3.815610E+00 +7.367619E-01 +1.509020E+01 +1.145268E+01 +2.125767E+00 +2.341894E-01 cmfd indices 1.000000E+01 1.000000E+00 1.000000E+00 1.000000E+00 k cmfd -1.169107E+00 -1.175079E+00 -1.173912E+00 -1.175368E+00 -1.174026E+00 -1.181745E+00 -1.182261E+00 -1.183559E+00 -1.178691E+00 -1.179222E+00 -1.179017E+00 -1.172979E+00 -1.175043E+00 -1.173458E+00 -1.174152E+00 -1.171451E+00 +1.129918E+00 +1.143848E+00 +1.147976E+00 +1.151534E+00 +1.152378E+00 +1.148219E+00 +1.150402E+00 +1.154647E+00 +1.156159E+00 +1.160048E+00 +1.167441E+00 +1.168163E+00 +1.168629E+00 +1.164120E+00 +1.165051E+00 +1.169177E+00 cmfd entropy -3.207640E+00 -3.210547E+00 -3.212218E+00 -3.209573E+00 -3.211619E+00 -3.212126E+00 -3.213163E+00 -3.214288E+00 -3.215737E+00 -3.213677E+00 -3.214925E+00 -3.215612E+00 -3.216708E+00 -3.221454E+00 -3.219048E+00 -3.218387E+00 +3.224769E+00 +3.225945E+00 +3.227421E+00 +3.226174E+00 +3.224429E+00 +3.227049E+00 +3.230710E+00 +3.230315E+00 +3.226825E+00 +3.226655E+00 +3.226588E+00 +3.224155E+00 +3.223246E+00 +3.222640E+00 +3.223920E+00 +3.222838E+00 cmfd balance -4.88208E-03 -4.75139E-03 -3.15783E-03 -3.67091E-03 -2.99797E-03 -2.91060E-03 -2.06576E-03 -1.83482E-03 -1.56292E-03 -1.58659E-03 -2.32986E-03 -1.47376E-03 -1.46673E-03 -1.22627E-03 -1.31963E-03 -1.26456E-03 +3.90454E-03 +4.08089E-03 +3.46511E-03 +4.09535E-03 +2.62009E-03 +2.23559E-03 +2.54033E-03 +2.12799E-03 +2.25864E-03 +1.85766E-03 +1.49916E-03 +1.63471E-03 +1.48377E-03 +1.59800E-03 +1.37354E-03 +1.32853E-03 cmfd dominance ratio -5.467E-01 -5.453E-01 -5.458E-01 -5.436E-01 -5.442E-01 -5.406E-01 -5.401E-01 -5.413E-01 -4.995E-01 -5.396E-01 -5.409E-01 -5.414E-01 -5.423E-01 -5.456E-01 -5.442E-01 +5.539E-01 +5.537E-01 +5.536E-01 +5.515E-01 +5.512E-01 +5.514E-01 +5.518E-01 +5.507E-01 +5.500E-01 +5.497E-01 +5.477E-01 +5.461E-01 +5.444E-01 +5.445E-01 +5.454E-01 5.441E-01 cmfd openmc source comparison -9.587418E-03 -8.150978E-03 -6.677661E-03 -6.334727E-03 -5.153692E-03 -5.082964E-03 -4.633153E-03 -4.037383E-03 -3.528742E-03 -4.559089E-03 -3.517370E-03 -3.306117E-03 -2.913809E-03 -1.906045E-03 -1.932794E-03 -1.711341E-03 +9.875240E-03 +1.106163E-02 +9.847628E-03 +6.065921E-03 +5.772039E-03 +4.615656E-03 +4.244331E-03 +3.694299E-03 +3.545814E-03 +3.213063E-03 +3.467537E-03 +3.383489E-03 +3.697591E-03 +3.937358E-03 +3.369124E-03 +3.190359E-03 cmfd source -4.496492E-02 -7.869674E-02 -1.100280E-01 -1.354045E-01 -1.363339E-01 -1.380533E-01 -1.314512E-01 -1.077480E-01 -7.847306E-02 -3.884630E-02 +4.360494E-02 +8.397599E-02 +1.074181E-01 +1.294531E-01 +1.385611E-01 +1.407934E-01 +1.325191E-01 +1.044311E-01 +7.660359E-02 +4.263941E-02 diff --git a/tests/regression_tests/collision_track/case_1_Reactions/collision_track_true.h5 b/tests/regression_tests/collision_track/case_1_Reactions/collision_track_true.h5 deleted file mode 100644 index c31546213..000000000 Binary files a/tests/regression_tests/collision_track/case_1_Reactions/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_1_Reactions/inputs_true.dat b/tests/regression_tests/collision_track/case_1_Reactions/inputs_true.dat deleted file mode 100644 index 005a56020..000000000 --- a/tests/regression_tests/collision_track/case_1_Reactions/inputs_true.dat +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - (n,fission) 101 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/case_2_Cell_ID/collision_track_true.h5 b/tests/regression_tests/collision_track/case_2_Cell_ID/collision_track_true.h5 deleted file mode 100644 index 850bba841..000000000 Binary files a/tests/regression_tests/collision_track/case_2_Cell_ID/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_2_Cell_ID/inputs_true.dat b/tests/regression_tests/collision_track/case_2_Cell_ID/inputs_true.dat deleted file mode 100644 index 8d46c3d3b..000000000 --- a/tests/regression_tests/collision_track/case_2_Cell_ID/inputs_true.dat +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - 22 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/case_3_Material_ID/collision_track_true.h5 b/tests/regression_tests/collision_track/case_3_Material_ID/collision_track_true.h5 deleted file mode 100644 index 777d91f08..000000000 Binary files a/tests/regression_tests/collision_track/case_3_Material_ID/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_3_Material_ID/inputs_true.dat b/tests/regression_tests/collision_track/case_3_Material_ID/inputs_true.dat deleted file mode 100644 index 322e74f49..000000000 --- a/tests/regression_tests/collision_track/case_3_Material_ID/inputs_true.dat +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - 1 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/case_4_Nuclide_ID/collision_track_true.h5 b/tests/regression_tests/collision_track/case_4_Nuclide_ID/collision_track_true.h5 deleted file mode 100644 index 527705297..000000000 Binary files a/tests/regression_tests/collision_track/case_4_Nuclide_ID/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_4_Nuclide_ID/inputs_true.dat b/tests/regression_tests/collision_track/case_4_Nuclide_ID/inputs_true.dat deleted file mode 100644 index 6202bcacc..000000000 --- a/tests/regression_tests/collision_track/case_4_Nuclide_ID/inputs_true.dat +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - O16 U235 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/case_5_Universe_ID/collision_track_true.h5 b/tests/regression_tests/collision_track/case_5_Universe_ID/collision_track_true.h5 deleted file mode 100644 index 65419d5ea..000000000 Binary files a/tests/regression_tests/collision_track/case_5_Universe_ID/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_5_Universe_ID/inputs_true.dat b/tests/regression_tests/collision_track/case_5_Universe_ID/inputs_true.dat deleted file mode 100644 index c06061210..000000000 --- a/tests/regression_tests/collision_track/case_5_Universe_ID/inputs_true.dat +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - 22 - 77 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/case_6_deposited_energy_threshold/collision_track_true.h5 b/tests/regression_tests/collision_track/case_6_deposited_energy_threshold/collision_track_true.h5 deleted file mode 100644 index 507665a60..000000000 Binary files a/tests/regression_tests/collision_track/case_6_deposited_energy_threshold/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_6_deposited_energy_threshold/inputs_true.dat b/tests/regression_tests/collision_track/case_6_deposited_energy_threshold/inputs_true.dat deleted file mode 100644 index 434f6b434..000000000 --- a/tests/regression_tests/collision_track/case_6_deposited_energy_threshold/inputs_true.dat +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - 550000.0 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/case_7_all_parameters_used_together/collision_track_true.h5 b/tests/regression_tests/collision_track/case_7_all_parameters_used_together/collision_track_true.h5 deleted file mode 100644 index b7ff67c48..000000000 Binary files a/tests/regression_tests/collision_track/case_7_all_parameters_used_together/collision_track_true.h5 and /dev/null differ diff --git a/tests/regression_tests/collision_track/case_7_all_parameters_used_together/inputs_true.dat b/tests/regression_tests/collision_track/case_7_all_parameters_used_together/inputs_true.dat deleted file mode 100644 index 1449c3596..000000000 --- a/tests/regression_tests/collision_track/case_7_all_parameters_used_together/inputs_true.dat +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 80 - 5 - 4 - - - -2.0 -2.0 -2.0 2.0 2.0 2.0 - - - true - - - - 22 33 - elastic 18 (n,disappear) - 77 - 1 11 - U238 U235 H1 U234 - 100000.0 - 100 - - 1 - - diff --git a/tests/regression_tests/collision_track/test.py b/tests/regression_tests/collision_track/test.py deleted file mode 100644 index 2f9de9ac0..000000000 --- a/tests/regression_tests/collision_track/test.py +++ /dev/null @@ -1,222 +0,0 @@ -"""Test the 'collision_track' setting. - -Results -------- - -All results are generated using only 1 MPI process. - -All results are generated using 1 thread except for "test_consistency_low_realization_number". -This specific test verifies that when the number of realization (i.e., point being candidate -to be stored) is lower than the capacity, results are reproducible even with multiple -threads (i.e., there is no potential thread competition that would produce different -results in that case). - -All results are generated using the history-based mode except for cases e01 to e03. - -All results are visually verified using the '_visualize.py' script in the regression test folder. - -OpenMC models -------------- - -Four OpenMC models with CSG-only geometries are used to cover the transmission, vacuum, -reflective and periodic Boundary Conditions (BC): - -- model_1: cylindrical core in 2 boxes (vacuum and transmission BC), - -# Test cases for simulation parameters using CSG-only geometries -# ============================================================ -# Each test case is defined by a combination of folder name, model name, and specific parameters. -# Below is a summary of the parameters used in the test cases: -# -# - max_collisions: Maximum number of particles to track in the simulation. -# - reactions: List of MT numbers (reaction types- 2 for scattering, 18 for fission, 101 for absorbtion). -# - cell_ids: IDs of specific cells in the model. -# - mat_ids: Material IDs for filtering particles. -# - nuclides: Nuclides for filtering particles. -# - univ_ids: Universe IDs for filtering particles. -# - E_threshold: Energy threshold for filtering particles (optional). -# -# The test cases are designed to validate the behavior of the simulation under various configurations. - -*: BC stands for Boundary Conditions, T for Transmission, R for Reflective, and V for Vacuum. - -An additional case, called 'case-a01', is used to check that the results are comparable when -the number of threads is set to 2 if the number of realization is lower than the capacity. - - -*: BC stands for Boundary Conditions, T for Transmission, and V for Vacuum. - -Notes: - -- The test cases list is non-exhaustive compared to the number of possible combinations. - Test cases have been selected based on use and internal code logic. - - - -TODO: - -- Test with a lattice. - -""" - -import openmc -import pytest - -from tests.testing_harness import CollisionTrackTestHarness -from tests.regression_tests import config - - -@pytest.fixture(scope="module") -def model_1(): - """Cylindrical core contained in a first box which is contained in a larger box. - A lower universe is used to describe the interior of the first box which - contains the core and its surrounding space. - - """ - openmc.reset_auto_ids() - model = openmc.Model() - - # ============================================================================= - # Materials - # ============================================================================= - - fuel = openmc.Material(material_id=1) - fuel.add_nuclide("U234", 0.0004524) - fuel.add_nuclide("U235", 0.0506068) - fuel.add_nuclide("U238", 0.9487090) - fuel.add_nuclide("U236", 0.0002318) - fuel.add_nuclide("O16", 2.0) - fuel.set_density("g/cm3", 11.0) - - water = openmc.Material(material_id=11) - water.add_nuclide("H1", 2.0) - water.add_nuclide("O16", 1.0) - water.set_density("g/cm3", 1.0) - - # ============================================================================= - # Geometry - # ============================================================================= - - # ----------------------------------------------------------------------------- - # Cylindrical core - # ----------------------------------------------------------------------------- - - # Parameters - core_radius = 2.0 - core_height = 4.0 - - # Surfaces - core_cylinder = openmc.ZCylinder(r=core_radius) - core_lower_plane = openmc.ZPlane(-core_height / 2.0) - core_upper_plane = openmc.ZPlane(core_height / 2.0) - - # Region - core_region = -core_cylinder & +core_lower_plane & -core_upper_plane - - # Cells - core = openmc.Cell(fill=fuel, region=core_region, cell_id=22) - outside_core_region = +core_cylinder | -core_lower_plane | +core_upper_plane - outside_core = openmc.Cell( - fill=water, region=outside_core_region, cell_id=33) - - # Universe - inside_box1_universe = openmc.Universe( - cells=[core, outside_core], universe_id=77) - - # ----------------------------------------------------------------------------- - # Box 1 - # ----------------------------------------------------------------------------- - - # Parameters - box1_size = 6.0 - - # Surfaces - box1_rpp = openmc.model.RectangularParallelepiped( - -box1_size / 2.0, box1_size / 2.0, - -box1_size / 2.0, box1_size / 2.0, - -box1_size / 2.0, box1_size / 2.0, - ) - - # Cell - box1 = openmc.Cell(fill=inside_box1_universe, region=-box1_rpp, cell_id=5) - - # ----------------------------------------------------------------------------- - # Box 2 - # ----------------------------------------------------------------------------- - - # Parameters - box2_size = 8 - - # Surfaces - box2_rpp = openmc.model.RectangularParallelepiped( - -box2_size / 2.0, box2_size / 2.0, - -box2_size / 2.0, box2_size / 2.0, - -box2_size / 2.0, box2_size / 2.0, - boundary_type="vacuum" - ) - - # Cell - box2 = openmc.Cell(fill=water, region=-box2_rpp & +box1_rpp, cell_id=8) - - # Register geometry - model.geometry = openmc.Geometry([box1, box2]) - - # ============================================================================= - # Settings - # ============================================================================= - - model.settings = openmc.Settings() - model.settings.particles = 80 - model.settings.batches = 5 - model.settings.inactive = 4 - model.settings.seed = 1 - - bounds = [ - -core_radius, - -core_radius, - -core_height / 2.0, - core_radius, - core_radius, - core_height / 2.0, - ] - distribution = openmc.stats.Box(bounds[:3], bounds[3:]) - model.settings.source = openmc.IndependentSource( - space=distribution, constraints={'fissionable': True}) - - return model - - -@pytest.mark.parametrize( - "folder, model_name, parameter", - [("case_1_Reactions", "model_1", {"max_collisions": 100, "reactions": ["(n,fission)", 101]}), - ("case_2_Cell_ID", "model_1", { - "max_collisions": 100, "cell_ids": [22]}), - ("case_3_Material_ID", "model_1", { - "max_collisions": 100, "material_ids": [1]}), - ("case_4_Nuclide_ID", "model_1", { - "max_collisions": 100, "nuclides": ["O16", "U235"]}), - ("case_5_Universe_ID", "model_1", { - "max_collisions": 100, "cell_ids": [22], "universe_ids": [77]}), - ("case_6_deposited_energy_threshold", "model_1", { - "max_collisions": 100, "deposited_E_threshold": 5.5e5}), - ("case_7_all_parameters_used_together", "model_1", { - "max_collisions": 100, - "reactions": ["elastic", 18, "(n,disappear)"], - "material_ids": [1, 11], - "universe_ids": [77], - "nuclides": ["U238", "U235", "H1", "U234"], - "cell_ids": [22, 33], - "deposited_E_threshold": 1e5}) - ], -) -def test_collision_track_several_cases( - folder, model_name, parameter, request -): - # Since for these tests the actual number of collisions recorded is < max_collisions, - # we can run them with 1 or 2 threads, and in history or event mode. - model = request.getfixturevalue(model_name) - model.settings.collision_track = parameter - harness = CollisionTrackTestHarness( - "statepoint.5.h5", model=model, workdir=folder - ) - harness.main() diff --git a/tests/regression_tests/complex_cell/results_true.dat b/tests/regression_tests/complex_cell/results_true.dat index ddedb07ff..3ce3d7cbc 100644 --- a/tests/regression_tests/complex_cell/results_true.dat +++ b/tests/regression_tests/complex_cell/results_true.dat @@ -1,11 +1,11 @@ k-combined: -2.603220E-01 1.429366E-03 +2.564169E-01 4.095378E-03 tally 1: -2.624819E+00 -1.378200E+00 -2.730035E+00 -1.492361E+00 -1.013707E+00 -2.055807E-01 -1.123257E-01 +2.607144E+00 +1.360414E+00 +2.681079E+00 +1.439354E+00 +9.627534E-01 +1.855496E-01 +1.123751E-01 2.530233E-03 diff --git a/tests/regression_tests/confidence_intervals/results_true.dat b/tests/regression_tests/confidence_intervals/results_true.dat index 8ca256624..6a906d07e 100644 --- a/tests/regression_tests/confidence_intervals/results_true.dat +++ b/tests/regression_tests/confidence_intervals/results_true.dat @@ -1,5 +1,5 @@ k-combined: -2.850178E-01 9.646334E-03 +2.759923E-01 6.988588E-03 tally 1: -6.234169E+01 -4.884167E+02 +6.167984E+01 +4.772717E+02 diff --git a/tests/regression_tests/conftest.py b/tests/regression_tests/conftest.py index 1cdf414e7..b4a764476 100644 --- a/tests/regression_tests/conftest.py +++ b/tests/regression_tests/conftest.py @@ -1,12 +1,12 @@ import numpy as np import openmc -from packaging.version import parse +from pkg_resources import parse_version import pytest @pytest.fixture(scope='module', autouse=True) def numpy_version_requirement(): - assert parse(np.__version__) >= parse("1.14"), \ + assert parse_version(np.__version__) >= parse_version("1.14"), \ "Regression tests require NumPy 1.14 or greater" diff --git a/tests/regression_tests/cpp_driver/driver.cpp b/tests/regression_tests/cpp_driver/driver.cpp index a6c3e6510..48ed7f317 100644 --- a/tests/regression_tests/cpp_driver/driver.cpp +++ b/tests/regression_tests/cpp_driver/driver.cpp @@ -2,8 +2,6 @@ #include #endif -#include - #include "openmc/capi.h" #include "openmc/cell.h" #include "openmc/error.h" @@ -17,16 +15,14 @@ using namespace openmc; -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { #ifdef OPENMC_MPI MPI_Comm world {MPI_COMM_WORLD}; int err = openmc_init(argc, argv, &world); #else int err = openmc_init(argc, argv, nullptr); #endif - if (err) - fatal_error(openmc_err_msg); + if (err) fatal_error(openmc_err_msg); // create a new cell filter auto cell_filter = Filter::create(); @@ -34,7 +30,7 @@ int main(int argc, char** argv) // add all cells to the cell filter std::vector cell_indices; for (auto& entry : openmc::model::cell_map) { - cell_indices.push_back(entry.second); + cell_indices.push_back(entry.second); } // enable distribcells offsets for all cells prepare_distribcell(&cell_indices); @@ -43,6 +39,7 @@ int main(int argc, char** argv) std::sort(cell_indices.begin(), cell_indices.end()); cell_filter->set_cells(cell_indices); + // create a new tally auto tally = Tally::create(); std::vector filters = {cell_filter}; @@ -63,19 +60,14 @@ int main(int argc, char** argv) } } - // set a higher temperature for only one of the lattice cells (ID is 4 in the - // model) + // set a higher temperature for only one of the lattice cells (ID is 4 in the model) model::cells[model::cell_map[4]]->set_temperature(400.0, 3, true); - // set the density of another lattice cell to 2 - model::cells[model::cell_map[4]]->set_density(2.0, 2, true); - // the summary file will be used to check that // temperatures were set correctly so clear // error output can be provided #ifdef OPENMC_MPI - if (openmc::mpi::master) - openmc::write_summary(); + if (openmc::mpi::master) openmc::write_summary(); #else openmc::write_summary(); #endif diff --git a/tests/regression_tests/cpp_driver/inputs_true.dat b/tests/regression_tests/cpp_driver/inputs_true.dat index fd450428a..5d067cb68 100644 --- a/tests/regression_tests/cpp_driver/inputs_true.dat +++ b/tests/regression_tests/cpp_driver/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - + + - - - + + + - - + + 4.0 4.0 2 2 @@ -29,12 +29,12 @@ 2 2 2 2 - - - - - - + + + + + + eigenvalue diff --git a/tests/regression_tests/cpp_driver/results_true.dat b/tests/regression_tests/cpp_driver/results_true.dat index 09f188db6..c2b0b8d6f 100644 --- a/tests/regression_tests/cpp_driver/results_true.dat +++ b/tests/regression_tests/cpp_driver/results_true.dat @@ -1,13 +1,13 @@ k-combined: -1.874924E+00 2.180236E-02 +1.933305E+00 1.300360E-02 tally 1: -9.484447E+01 -1.002269E+03 -2.746252E+01 -8.406603E+01 -9.833099E+01 -1.076376E+03 -2.206380E+02 -5.417609E+03 -2.206380E+02 -5.417609E+03 +9.552846E+01 +1.019358E+03 +2.887973E+01 +9.308509E+01 +9.732441E+01 +1.059022E+03 +2.217326E+02 +5.486892E+03 +2.217326E+02 +5.486892E+03 diff --git a/tests/regression_tests/create_fission_neutrons/inputs_true.dat b/tests/regression_tests/create_fission_neutrons/inputs_true.dat index 47e8c3830..9e44a0224 100644 --- a/tests/regression_tests/create_fission_neutrons/inputs_true.dat +++ b/tests/regression_tests/create_fission_neutrons/inputs_true.dat @@ -1,30 +1,30 @@ - - - - + + + + - - - - - - - + + + + + + + fixed source 100 10 - + -1 -1 -1 1 1 1 - + false diff --git a/tests/regression_tests/dagmc/external/inputs_true.dat b/tests/regression_tests/dagmc/external/inputs_true.dat index 8a6c6fe74..31f4c1f88 100644 --- a/tests/regression_tests/dagmc/external/inputs_true.dat +++ b/tests/regression_tests/dagmc/external/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 0 - + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/dagmc/external/main.cpp b/tests/regression_tests/dagmc/external/main.cpp index e78ab03fa..3765cf79a 100644 --- a/tests/regression_tests/dagmc/external/main.cpp +++ b/tests/regression_tests/dagmc/external/main.cpp @@ -100,9 +100,6 @@ int main(int argc, char* argv[]) } } - // Finalize cell densities - openmc::finalize_cell_densities(); - // Run OpenMC openmc_err = openmc_run(); if (openmc_err) diff --git a/tests/regression_tests/dagmc/external/results_true.dat b/tests/regression_tests/dagmc/external/results_true.dat index 9a6b481b7..cda656937 100644 --- a/tests/regression_tests/dagmc/external/results_true.dat +++ b/tests/regression_tests/dagmc/external/results_true.dat @@ -1,5 +1,5 @@ k-combined: -1.083415E+00 5.991738E-02 +9.118190E-01 3.615552E-02 tally 1: -8.862860E+00 -1.602117E+01 +8.430103E+00 +1.442878E+01 diff --git a/tests/regression_tests/dagmc/external/test.py b/tests/regression_tests/dagmc/external/test.py index 3580bfa11..57bc9ea7f 100644 --- a/tests/regression_tests/dagmc/external/test.py +++ b/tests/regression_tests/dagmc/external/test.py @@ -32,7 +32,7 @@ def cpp_driver(request): target_link_libraries(main OpenMC::libopenmc) target_compile_features(main PUBLIC cxx_std_14) set(CMAKE_CXX_FLAGS "-pedantic-errors") - add_compile_definitions(OPENMC_DAGMC_ENABLED=1) + add_compile_definitions(DAGMC=1) """.format(openmc_dir))) # Create temporary build directory and change to there diff --git a/tests/regression_tests/dagmc/legacy/inputs_true.dat b/tests/regression_tests/dagmc/legacy/inputs_true.dat index ad2f8e54d..b06516cb1 100644 --- a/tests/regression_tests/dagmc/legacy/inputs_true.dat +++ b/tests/regression_tests/dagmc/legacy/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 0 - + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/dagmc/legacy/results_true.dat b/tests/regression_tests/dagmc/legacy/results_true.dat index 9a6b481b7..cda656937 100644 --- a/tests/regression_tests/dagmc/legacy/results_true.dat +++ b/tests/regression_tests/dagmc/legacy/results_true.dat @@ -1,5 +1,5 @@ k-combined: -1.083415E+00 5.991738E-02 +9.118190E-01 3.615552E-02 tally 1: -8.862860E+00 -1.602117E+01 +8.430103E+00 +1.442878E+01 diff --git a/tests/regression_tests/dagmc/legacy/test.py b/tests/regression_tests/dagmc/legacy/test.py index b6b1e376b..884264f30 100644 --- a/tests/regression_tests/dagmc/legacy/test.py +++ b/tests/regression_tests/dagmc/legacy/test.py @@ -104,4 +104,5 @@ def test_surf_source(model): def test_dagmc(model): harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() \ No newline at end of file + harness.main() + diff --git a/tests/regression_tests/dagmc/refl/inputs_true.dat b/tests/regression_tests/dagmc/refl/inputs_true.dat index 58cb9e66f..979eeb492 100644 --- a/tests/regression_tests/dagmc/refl/inputs_true.dat +++ b/tests/regression_tests/dagmc/refl/inputs_true.dat @@ -3,14 +3,14 @@ - + eigenvalue 100 5 0 - + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/dagmc/refl/results_true.dat b/tests/regression_tests/dagmc/refl/results_true.dat index b49a4a7a4..533c62a90 100644 --- a/tests/regression_tests/dagmc/refl/results_true.dat +++ b/tests/regression_tests/dagmc/refl/results_true.dat @@ -1,5 +1,5 @@ k-combined: -2.047107E+00 8.605767E-02 +2.035173E+00 3.967029E-02 tally 1: -1.145034E+01 -2.636875E+01 +1.064492E+01 +2.301019E+01 diff --git a/tests/regression_tests/dagmc/universes/inputs_true.dat b/tests/regression_tests/dagmc/universes/inputs_true.dat index be1a17383..4b5be3612 100644 --- a/tests/regression_tests/dagmc/universes/inputs_true.dat +++ b/tests/regression_tests/dagmc/universes/inputs_true.dat @@ -1,33 +1,33 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - + + 24.0 24.0 2 2 @@ -36,26 +36,18 @@ 1 1 1 1 - - - - - - + + + + + + eigenvalue 100 10 5 - - - -10.0 -10.0 -24.0 10.0 10.0 24.0 - - - true - - false diff --git a/tests/regression_tests/dagmc/universes/results_true.dat b/tests/regression_tests/dagmc/universes/results_true.dat index aacb7d1ab..76cbc9db0 100644 --- a/tests/regression_tests/dagmc/universes/results_true.dat +++ b/tests/regression_tests/dagmc/universes/results_true.dat @@ -1,13 +1,13 @@ k-combined: -9.719586E-01 3.630894E-02 +9.887663E-01 1.510336E-02 tally 1: -4.463288E+00 -4.136647E+00 -4.769631E+00 -4.622840E+00 -4.315273E+00 -3.871129E+00 -4.091804E+00 -3.582192E+00 +4.340758E+00 +4.265459E+00 +4.712319E+00 +4.654778E+00 +4.151897E+00 +3.588090E+00 +2.965925E+00 +1.852746E+00 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/dagmc/universes/test.py b/tests/regression_tests/dagmc/universes/test.py index d68c6b11c..057a7b0d4 100644 --- a/tests/regression_tests/dagmc/universes/test.py +++ b/tests/regression_tests/dagmc/universes/test.py @@ -11,87 +11,81 @@ pytestmark = pytest.mark.skipif( reason="DAGMC CAD geometry is not enabled.") -@pytest.fixture -def pin_lattice_model(): - ### MATERIALS ### - fuel = openmc.Material(name='no-void fuel') - fuel.set_density('g/cc', 10.29769) - fuel.add_nuclide('U234', 0.93120485) - fuel.add_nuclide('U235', 0.00055815) - fuel.add_nuclide('U238', 0.022408) - fuel.add_nuclide('O16', 0.045829) +class DAGMCUniverseTest(PyAPITestHarness): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) - cladding = openmc.Material(name='clad') - cladding.set_density('g/cc', 6.55) - cladding.add_nuclide('Zr90', 0.021827) - cladding.add_nuclide('Zr91', 0.00476) - cladding.add_nuclide('Zr92', 0.0072758) - cladding.add_nuclide('Zr94', 0.0073734) - cladding.add_nuclide('Zr96', 0.0011879) + ### MATERIALS ### + fuel = openmc.Material(name='no-void fuel') + fuel.set_density('g/cc', 10.29769) + fuel.add_nuclide('U234', 0.93120485) + fuel.add_nuclide('U235', 0.00055815) + fuel.add_nuclide('U238', 0.022408) + fuel.add_nuclide('O16', 0.045829) - water = openmc.Material(name='water') - water.set_density('g/cc', 0.740582) - water.add_nuclide('H1', 0.049457) - water.add_nuclide('O16', 0.024672) - water.add_nuclide('B10', 8.0042e-06) - water.add_nuclide('B11', 3.2218e-05) - water.add_s_alpha_beta('c_H_in_H2O') + cladding = openmc.Material(name='clad') + cladding.set_density('g/cc', 6.55) + cladding.add_nuclide('Zr90', 0.021827) + cladding.add_nuclide('Zr91', 0.00476) + cladding.add_nuclide('Zr92', 0.0072758) + cladding.add_nuclide('Zr94', 0.0073734) + cladding.add_nuclide('Zr96', 0.0011879) - model = openmc.Model() - model.materials = openmc.Materials([fuel, cladding, water]) + water = openmc.Material(name='water') + water.set_density('g/cc', 0.740582) + water.add_nuclide('H1', 0.049457) + water.add_nuclide('O16', 0.024672) + water.add_nuclide('B10', 8.0042e-06) + water.add_nuclide('B11', 3.2218e-05) + water.add_s_alpha_beta('c_H_in_H2O') - ### GEOMETRY ### - # create the DAGMC universe - pincell_univ = openmc.DAGMCUniverse(filename='dagmc.h5m', auto_geom_ids=True) + self._model.materials = openmc.Materials([fuel, cladding, water]) - # creates another DAGMC universe, this time with within a bounded cell - bound_pincell_universe = openmc.DAGMCUniverse(filename='dagmc.h5m').bounded_universe() - # uses the bound_dag_cell as the root argument to test the type checks in openmc.Geometry - bound_pincell_geometry = openmc.Geometry(root=bound_pincell_universe) - # assigns the bound_dag_geometry to the model to test the type checks in model.Geometry setter - model.geometry = bound_pincell_geometry + ### GEOMETRY ### + # create the DAGMC universe + pincell_univ = openmc.DAGMCUniverse(filename='dagmc.h5m', auto_geom_ids=True) - # create a 2 x 2 lattice using the DAGMC pincell - pitch = np.asarray((24.0, 24.0)) - lattice = openmc.RectLattice() - lattice.pitch = pitch - lattice.universes = [[pincell_univ] * 2] * 2 - lattice.lower_left = -pitch + # creates another DAGMC universe, this time with within a bounded cell + bound_pincell_universe = openmc.DAGMCUniverse(filename='dagmc.h5m').bounded_universe() + # uses the bound_dag_cell as the root argument to test the type checks in openmc.Geometry + bound_pincell_geometry = openmc.Geometry(root=bound_pincell_universe) + # assigns the bound_dag_geometry to the model to test the type checks in model.Geometry setter + self._model.geometry = bound_pincell_geometry - left = openmc.XPlane(x0=-pitch[0], name='left', boundary_type='reflective') - right = openmc.XPlane(x0=pitch[0], name='right', boundary_type='reflective') - front = openmc.YPlane(y0=-pitch[1], name='front', boundary_type='reflective') - back = openmc.YPlane(y0=pitch[1], name='back', boundary_type='reflective') - # clip the DAGMC geometry at +/- 10 cm w/ CSG planes - bottom = openmc.ZPlane(z0=-10.0, name='bottom', boundary_type='reflective') - top = openmc.ZPlane(z0=10.0, name='top', boundary_type='reflective') + # create a 2 x 2 lattice using the DAGMC pincell + pitch = np.asarray((24.0, 24.0)) + lattice = openmc.RectLattice() + lattice.pitch = pitch + lattice.universes = [[pincell_univ] * 2] * 2 + lattice.lower_left = -pitch - bounding_region = +left & -right & +front & -back & +bottom & -top - bounding_cell = openmc.Cell(fill=lattice, region=bounding_region) + left = openmc.XPlane(x0=-pitch[0], name='left', boundary_type='reflective') + right = openmc.XPlane(x0=pitch[0], name='right', boundary_type='reflective') + front = openmc.YPlane(y0=-pitch[1], name='front', boundary_type='reflective') + back = openmc.YPlane(y0=pitch[1], name='back', boundary_type='reflective') + # clip the DAGMC geometry at +/- 10 cm w/ CSG planes + bottom = openmc.ZPlane(z0=-10.0, name='bottom', boundary_type='reflective') + top = openmc.ZPlane(z0=10.0, name='top', boundary_type='reflective') - model.geometry = openmc.Geometry([bounding_cell]) + bounding_region = +left & -right & +front & -back & +bottom & -top + bounding_cell = openmc.Cell(fill=lattice, region=bounding_region) - # add a cell instance tally - tally = openmc.Tally(name='cell instance tally') - # using scattering - cell_instance_filter = openmc.CellInstanceFilter(((4, 0), (4, 1), (4, 2), (4, 3), (4, 4))) - tally.filters = [cell_instance_filter] - tally.scores = ['scatter'] - model.tallies = [tally] + self._model.geometry = openmc.Geometry([bounding_cell]) - # settings - model.settings.particles = 100 - model.settings.batches = 10 - model.settings.inactive = 5 - model.settings.output = {'summary' : False} - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box((-10., -10., -24.), (10., 10., 24.)), - constraints={'fissionable': True}, - ) + # add a cell instance tally + tally = openmc.Tally(name='cell instance tally') + # using scattering + cell_instance_filter = openmc.CellInstanceFilter(((4, 0), (4, 1), (4, 2), (4, 3), (4, 4))) + tally.filters = [cell_instance_filter] + tally.scores = ['scatter'] + self._model.tallies = [tally] - return model + # settings + self._model.settings.particles = 100 + self._model.settings.batches = 10 + self._model.settings.inactive = 5 + self._model.settings.output = {'summary' : False} - -def test_univ(pin_lattice_model): - harness = PyAPITestHarness('statepoint.10.h5', model=pin_lattice_model) +def test_univ(): + harness = DAGMCUniverseTest('statepoint.10.h5', model=openmc.Model()) harness.main() diff --git a/tests/regression_tests/dagmc/uwuw/inputs_true.dat b/tests/regression_tests/dagmc/uwuw/inputs_true.dat index 01082cb23..d7e4a12aa 100644 --- a/tests/regression_tests/dagmc/uwuw/inputs_true.dat +++ b/tests/regression_tests/dagmc/uwuw/inputs_true.dat @@ -3,14 +3,14 @@ - + eigenvalue 100 5 0 - + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/density/results_true.dat b/tests/regression_tests/density/results_true.dat index 42dc0c19f..c8e3b1ede 100644 --- a/tests/regression_tests/density/results_true.dat +++ b/tests/regression_tests/density/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.082191E+00 3.064029E-02 +1.110057E+00 1.303260E-02 diff --git a/tests/regression_tests/deplete_no_transport/test.py b/tests/regression_tests/deplete_no_transport/test.py index 5550ad048..54c29cd5b 100644 --- a/tests/regression_tests/deplete_no_transport/test.py +++ b/tests/regression_tests/deplete_no_transport/test.py @@ -10,7 +10,7 @@ import openmc.deplete from openmc.deplete import IndependentOperator, MicroXS from tests.regression_tests import config, assert_atoms_equal, \ - assert_reaction_rates_equal, assert_same_mats + assert_reaction_rates_equal @pytest.fixture(scope="module") @@ -76,8 +76,6 @@ def test_against_self(run_in_tmpdir, dt = [360] # single step # Perform simulation using the predictor algorithm - if config['mpi'] and multiproc: - pytest.skip("Multiprocessing depletion is disabled when MPI is enabled.") openmc.deplete.pool.USE_MULTIPROCESSING = multiproc openmc.deplete.PredictorIntegrator(op, dt, @@ -103,7 +101,7 @@ def test_against_self(run_in_tmpdir, res_ref = openmc.deplete.Results(path_reference) # Assert same mats - assert_same_mats(res_ref, res_test) + _assert_same_mats(res_test, res_ref) tol = 1.0e-14 assert_atoms_equal(res_ref, res_test, tol) @@ -137,8 +135,6 @@ def test_against_coupled(run_in_tmpdir, dt = [dt] # single step # Perform simulation using the predictor algorithm - if config['mpi'] and multiproc: - pytest.skip("Multiprocessing depletion is disabled when MPI is enabled.") openmc.deplete.pool.USE_MULTIPROCESSING = multiproc openmc.deplete.PredictorIntegrator( op, dt, power=174, timestep_units=time_units).integrate() @@ -159,7 +155,7 @@ def test_against_coupled(run_in_tmpdir, res_ref = openmc.deplete.Results(path_reference) # Assert same mats - assert_same_mats(res_test, res_ref) + _assert_same_mats(res_test, res_ref) assert_atoms_equal(res_ref, res_test, atom_tol) assert_reaction_rates_equal(res_ref, res_test, rx_tol) @@ -176,7 +172,6 @@ def _create_operator(from_nuclides, for nuc, dens in fuel.get_nuclide_atom_densities().items(): nuclides[nuc] = dens - openmc.reset_auto_ids() op = IndependentOperator.from_nuclides(fuel.volume, nuclides, flux, @@ -192,3 +187,20 @@ def _create_operator(from_nuclides, normalization_mode=normalization_mode) return op + + +def _assert_same_mats(res_ref, res_test): + for mat in res_ref[0].index_mat: + assert mat in res_test[0].index_mat, \ + f"Material {mat} not in new results." + for nuc in res_ref[0].index_nuc: + assert nuc in res_test[0].index_nuc, \ + f"Nuclide {nuc} not in new results." + + for mat in res_test[0].index_mat: + assert mat in res_ref[0].index_mat, \ + f"Material {mat} not in old results." + for nuc in res_test[0].index_nuc: + assert nuc in res_ref[0].index_nuc, \ + f"Nuclide {nuc} not in old results." + diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 index 9757c9791..5fdc656d9 100644 Binary files a/tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 and b/tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 differ diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 index 08d4d3eed..65bfc19a9 100644 Binary files a/tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 and b/tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 differ diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_minutes.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_minutes.h5 index 41b5235bb..294cb589f 100644 Binary files a/tests/regression_tests/deplete_no_transport/test_reference_coupled_minutes.h5 and b/tests/regression_tests/deplete_no_transport/test_reference_coupled_minutes.h5 differ diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 index 53d80aff0..ed62e4610 100644 Binary files a/tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 and b/tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 differ diff --git a/tests/regression_tests/deplete_no_transport/test_reference_fission_q.h5 b/tests/regression_tests/deplete_no_transport/test_reference_fission_q.h5 index fe695692d..9d32d89fe 100644 Binary files a/tests/regression_tests/deplete_no_transport/test_reference_fission_q.h5 and b/tests/regression_tests/deplete_no_transport/test_reference_fission_q.h5 differ diff --git a/tests/regression_tests/deplete_no_transport/test_reference_source_rate.h5 b/tests/regression_tests/deplete_no_transport/test_reference_source_rate.h5 index c9c7e9e36..3f3b4aa2a 100644 Binary files a/tests/regression_tests/deplete_no_transport/test_reference_source_rate.h5 and b/tests/regression_tests/deplete_no_transport/test_reference_source_rate.h5 differ diff --git a/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_refuel.h5 b/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_refuel.h5 deleted file mode 100644 index a335e3b47..000000000 Binary files a/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_refuel.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_rotation.h5 b/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_rotation.h5 deleted file mode 100644 index c8b4f67ff..000000000 Binary files a/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_rotation.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_translation.h5 b/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_translation.h5 deleted file mode 100644 index 35285321b..000000000 Binary files a/tests/regression_tests/deplete_with_keff_search_control/ref_depletion_with_translation.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_keff_search_control/test.py b/tests/regression_tests/deplete_with_keff_search_control/test.py deleted file mode 100644 index 82e601280..000000000 --- a/tests/regression_tests/deplete_with_keff_search_control/test.py +++ /dev/null @@ -1,140 +0,0 @@ -""" Tests for KeffSearchControl class """ - -from hmac import new -from pathlib import Path -import shutil -import sys - -import pytest -import numpy as np - -import openmc -import openmc.lib -from openmc.deplete import CoupledOperator - -from tests.regression_tests import config - -@pytest.fixture -def model(): - f = openmc.Material(name='f') - f.set_density('g/cm3', 10.29769) - f.add_element('U', 1., enrichment=2.4) - f.add_element('O', 2.) - - h = openmc.Material(name='h') - h.set_density('g/cm3', 0.001598) - h.add_element('He', 2.4044e-4) - - w = openmc.Material(name='w') - w.set_density('g/cm3', 0.740582) - w.add_element('H', 2) - w.add_element('O', 1) - - # Define overall material - materials = openmc.Materials([f, h, w]) - - # Define surfaces - radii = [0.5, 0.8, 1] - height = 80 - surf_in = openmc.ZCylinder(r=radii[0]) - surf_mid = openmc.ZCylinder(r=radii[1]) - surf_out = openmc.ZCylinder(r=radii[2], boundary_type='reflective') - surf_top = openmc.ZPlane(z0=height/2, boundary_type='vacuum') - surf_bot = openmc.ZPlane(z0=-height/2, boundary_type='vacuum') - - surf_trans = openmc.ZPlane(z0=0) - surf_rot1 = openmc.XPlane(x0=0) - surf_rot2 = openmc.YPlane(y0=0) - - # Define cells - cell_f = openmc.Cell(name='fuel_cell', fill=f, - region=-surf_in & -surf_top & +surf_bot) - cell_g = openmc.Cell(fill=h, - region = +surf_in & -surf_mid & -surf_top & +surf_bot & +surf_rot2) - - # Define unbounded cells for rotation universe - cell_w = openmc.Cell(fill=w, region = -surf_rot1) - cell_h = openmc.Cell(fill=h, region = +surf_rot1) - universe_rot = openmc.Universe(cells=(cell_w, cell_h)) - cell_rot = openmc.Cell(name="rot_cell", fill=universe_rot, - region = +surf_in & -surf_mid & -surf_top & +surf_bot & -surf_rot2) - - # Define unbounded cells for translation universe - cell_w = openmc.Cell(fill=w, region=+surf_in & -surf_trans ) - cell_h = openmc.Cell(fill=h, region=+surf_in & +surf_trans) - universe_trans = openmc.Universe(cells=(cell_w, cell_h)) - cell_trans = openmc.Cell(name="trans_cell", fill=universe_trans, - region=+surf_mid & -surf_out & -surf_top & +surf_bot) - - # Define overall geometry - geometry = openmc.Geometry([cell_f, cell_g, cell_rot, cell_trans]) - - # Set material volume for depletion fuel. - f.volume = np.pi * radii[0]**2 * height - - settings = openmc.Settings() - settings.particles = 1000 - settings.inactive = 10 - settings.batches = 50 - - return openmc.Model(geometry, materials, settings) - - -def translate_cell(position): - cell_trans = [cell for cell in openmc.lib.cells.values() if cell.name == 'trans_cell'][0] - openmc.lib.cells[cell_trans.id].translation = [0, 0, position] - - -def rotate_cell(angle): - cell_rot = [cell for cell in openmc.lib.cells.values() if cell.name == 'rot_cell'][0] - openmc.lib.cells[cell_rot.id].rotation = [0, 0, angle] - - -def set_u235_density(u235_density): - fuel = [material for material in openmc.lib.materials.values() - if material.name == 'f'][0] - nuclides = openmc.lib.materials[fuel.id].nuclides - densities = openmc.lib.materials[fuel.id].densities - nuc_idx = nuclides.index('U235') - densities[nuc_idx] = u235_density - openmc.lib.materials[fuel.id].set_densities(nuclides, densities) - - -@pytest.mark.parametrize("function, x0, x1, bracket, ref_result", [ - (translate_cell, -11, -5, (-15, 0), 'depletion_with_translation'), - (rotate_cell, -80, -50, (-90, 0), 'depletion_with_rotation'), - (set_u235_density, 2e-4, 1e-3, (1e-4, 2e-3), 'depletion_with_refuel') -]) -def test_keff_search_control(run_in_tmpdir, model, function, x0, x1, bracket, ref_result): - chain_file = Path(__file__).parents[2] / 'chain_simple.xml' - model.settings.verbosity = 1 - op = CoupledOperator(model, chain_file) - - integrator = openmc.deplete.PredictorIntegrator( - op, [1], 174., timestep_units = 'd') - integrator.add_keff_search_control( - function=function, - x0=x0, - x1=x1, - bracket=bracket, - output=True, - k_tol=0.1, - sigma_final=5e-2) - - integrator.integrate() - - # Get path to test and reference results - path_test = op.output_dir / 'depletion_results.h5' - path_reference = Path(__file__).with_name(f'ref_{ref_result}.h5') - - # If updating results, do so and return - if config['update']: - shutil.copyfile(str(path_test), str(path_reference)) - return - - # Load the reference/test results - res_test = openmc.deplete.Results(path_test) - res_ref = openmc.deplete.Results(path_reference) - - # Use high tolerance here - assert res_test[0].keff_search_root == pytest.approx(res_ref[0].keff_search_root, rel=2) diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_ext_source.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_ext_source.h5 deleted file mode 100644 index 2f9951a42..000000000 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_ext_source.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_feed.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_feed.h5 index 25ab31041..b9be76345 100644 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_feed.h5 and b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_feed.h5 differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_redox.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_redox.h5 deleted file mode 100644 index c7f002ba1..000000000 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_redox.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal.h5 index c3121a953..4b24bed52 100644 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal.h5 and b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal.h5 differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal_and_redox.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal_and_redox.h5 deleted file mode 100644 index 80ce771fc..000000000 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal_and_redox.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer.h5 index 2a4c227bb..51173f778 100644 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer.h5 and b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer.h5 differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer_and_redox.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer_and_redox.h5 deleted file mode 100644 index 6847fd7df..000000000 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer_and_redox.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_feed.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_feed.h5 index af6733340..d53adc7d8 100644 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_feed.h5 and b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_feed.h5 differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_removal.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_removal.h5 index 59c65427c..921755e15 100644 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_removal.h5 and b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_removal.h5 differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_ext_source.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_ext_source.h5 deleted file mode 100644 index cceb7fc78..000000000 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_ext_source.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_transfer.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_transfer.h5 index a1c0e5b41..469149f67 100644 Binary files a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_transfer.h5 and b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_transfer.h5 differ diff --git a/tests/regression_tests/deplete_with_transfer_rates/test.py b/tests/regression_tests/deplete_with_transfer_rates/test.py index 461287f6e..9bd5a052b 100644 --- a/tests/regression_tests/deplete_with_transfer_rates/test.py +++ b/tests/regression_tests/deplete_with_transfer_rates/test.py @@ -1,7 +1,8 @@ -""" ExternalRates depletion test suite """ +""" TransferRates depletion test suite """ from pathlib import Path import shutil +import sys import numpy as np import pytest @@ -12,9 +13,9 @@ from openmc.deplete import CoupledOperator from tests.regression_tests import config, assert_reaction_rates_equal, \ assert_atoms_equal + @pytest.fixture def model(): - openmc.reset_auto_ids() f = openmc.Material(name="f") f.add_element("U", 1, percent_type="ao", enrichment=4.25) f.add_element("O", 2) @@ -39,13 +40,12 @@ def model(): geometry = openmc.Geometry([cell_f, cell_w]) settings = openmc.Settings() - settings.particles = 150 + settings.particles = 100 settings.inactive = 0 settings.batches = 10 return openmc.Model(geometry, materials, settings) - @pytest.mark.parametrize("rate, dest_mat, power, ref_result", [ (1e-5, None, 0.0, 'no_depletion_only_removal'), (-1e-5, None, 0.0, 'no_depletion_only_feed'), @@ -53,9 +53,6 @@ def model(): (-1e-5, None, 174.0, 'depletion_with_feed'), (-1e-5, 'w', 0.0, 'no_depletion_with_transfer'), (1e-5, 'w', 174.0, 'depletion_with_transfer'), - (0.0, None, 174.0, 'depletion_with_redox'), - (1e-5, None, 174.0, 'depletion_with_removal_and_redox'), - (1e-5, 'w', 174.0, 'depletion_with_transfer_and_redox'), ]) def test_transfer_rates(run_in_tmpdir, model, rate, dest_mat, power, ref_result): """Tests transfer_rates depletion class with transfer rates""" @@ -63,18 +60,13 @@ def test_transfer_rates(run_in_tmpdir, model, rate, dest_mat, power, ref_result) chain_file = Path(__file__).parents[2] / 'chain_simple.xml' transfer_elements = ['Xe'] - os = {'I': -1, 'Xe':0, 'Cs': 1, 'Gd': 3, 'U': 4} op = CoupledOperator(model, chain_file) op.round_number = True integrator = openmc.deplete.PredictorIntegrator( op, [1], power, timestep_units = 'd') - if rate != 0.0: - integrator.add_transfer_rate('f', transfer_elements, rate, - destination_material=dest_mat) - if 'redox' in ref_result.split('_'): - integrator.add_redox('f', {'Gd157':1}, os) - + integrator.add_transfer_rate('f', transfer_elements, rate, + destination_material=dest_mat) integrator.integrate() # Get path to test and reference results @@ -90,39 +82,5 @@ def test_transfer_rates(run_in_tmpdir, model, rate, dest_mat, power, ref_result) res_ref = openmc.deplete.Results(path_reference) res_test = openmc.deplete.Results(path_test) - assert_atoms_equal(res_ref, res_test, tol=1e-3) - assert_reaction_rates_equal(res_ref, res_test, tol=1e-3) - -@pytest.mark.parametrize("rate, power, ref_result", [ - (1e-1, 0.0, 'no_depletion_with_ext_source'), - (1e-1, 174., 'depletion_with_ext_source'), -]) -def test_external_source_rates(run_in_tmpdir, model, rate, power, ref_result): - """Tests external_rates depletion class with external source rates""" - - chain_file = Path(__file__).parents[2] / 'chain_simple.xml' - - external_source_vector = {'U': 1} - - op = CoupledOperator(model, chain_file) - op.round_number = True - integrator = openmc.deplete.PredictorIntegrator( - op, [1], power, timestep_units='d') - integrator.add_external_source_rate('f', external_source_vector, rate) - integrator.integrate() - - # Get path to test and reference results - path_test = op.output_dir / 'depletion_results.h5' - path_reference = Path(__file__).with_name(f'ref_{ref_result}.h5') - - # If updating results, do so and return - if config['update']: - shutil.copyfile(str(path_test), str(path_reference)) - return - - # Load the reference/test results - res_ref = openmc.deplete.Results(path_reference) - res_test = openmc.deplete.Results(path_test) - - assert_atoms_equal(res_ref, res_test, tol=1e-3) - assert_reaction_rates_equal(res_ref, res_test, tol=1e-3) + assert_atoms_equal(res_ref, res_test, 1e-6) + assert_reaction_rates_equal(res_ref, res_test) diff --git a/tests/regression_tests/deplete_with_transport/last_step_reference_materials.xml b/tests/regression_tests/deplete_with_transport/last_step_reference_materials.xml index 2dca55992..f61595dd9 100644 --- a/tests/regression_tests/deplete_with_transport/last_step_reference_materials.xml +++ b/tests/regression_tests/deplete_with_transport/last_step_reference_materials.xml @@ -1,1049 +1,1049 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + diff --git a/tests/regression_tests/deplete_with_transport/test.py b/tests/regression_tests/deplete_with_transport/test.py index a2be22c56..0f7ebf00f 100644 --- a/tests/regression_tests/deplete_with_transport/test.py +++ b/tests/regression_tests/deplete_with_transport/test.py @@ -65,8 +65,6 @@ def test_full(run_in_tmpdir, problem, multiproc): power = 2.337e15*4*JOULE_PER_EV*1e6 # MeV/second cm from CASMO # Perform simulation using the predictor algorithm - if config['mpi'] and multiproc: - pytest.skip("Multiprocessing depletion is disabled when MPI is enabled.") openmc.deplete.pool.USE_MULTIPROCESSING = multiproc openmc.deplete.PredictorIntegrator(op, dt, power).integrate() diff --git a/tests/regression_tests/deplete_with_transport/test_reference.h5 b/tests/regression_tests/deplete_with_transport/test_reference.h5 index cc616e791..e8478250b 100644 Binary files a/tests/regression_tests/deplete_with_transport/test_reference.h5 and b/tests/regression_tests/deplete_with_transport/test_reference.h5 differ diff --git a/tests/regression_tests/diff_tally/inputs_true.dat b/tests/regression_tests/diff_tally/inputs_true.dat index 19356b64a..3ec4154e8 100644 --- a/tests/regression_tests/diff_tally/inputs_true.dat +++ b/tests/regression_tests/diff_tally/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + - + @@ -47,7 +47,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -149,8 +149,8 @@ - - + + @@ -174,9 +174,9 @@ - + - + 1.26 1.26 17 17 @@ -277,30 +277,30 @@ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + eigenvalue 100 3 0 - + -160 -160 -183 160 160 183 @@ -429,10 +429,10 @@ nu-fission scatter 5 - - - - - + + + + + diff --git a/tests/regression_tests/diff_tally/results_true.dat b/tests/regression_tests/diff_tally/results_true.dat index a88081b7c..14729c821 100644 --- a/tests/regression_tests/diff_tally/results_true.dat +++ b/tests/regression_tests/diff_tally/results_true.dat @@ -1,27 +1,27 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. -3,,density,flux,-9.2822822e+00,1.6880315e+00 -3,,density,flux,-2.0591270e+01,3.0043477e+00 -1,,density,flux,-2.9765141e-01,5.2949290e-02 -1,,density,flux,-4.0095723e-01,1.1716168e-01 -1,O16,nuclide_density,flux,-1.4245069e+01,6.3028710e+00 -1,O16,nuclide_density,flux,-2.5098326e+01,5.7525657e+00 -1,U235,nuclide_density,flux,-2.1513560e+03,6.7234014e+02 -1,U235,nuclide_density,flux,-2.4222736e+03,7.7715656e+02 -1,,temperature,flux,-1.1242141e-04,8.1692839e-05 -1,,temperature,flux,6.1357500e-06,7.4812624e-05 -3,,density,total,-4.2880614e+00,7.0021512e-01 -3,,density,absorption,-5.0324695e-01,4.9079615e-02 -3,,density,scatter,-3.7848144e+00,6.5868388e-01 -3,,density,fission,-2.7732455e-01,6.4647487e-02 -3,,density,nu-fission,-6.7990282e-01,1.5692707e-01 -3,,density,total,-3.8043572e-01,9.6222860e-02 -3,,density,absorption,-3.3518262e-01,8.6810436e-02 -3,,density,scatter,-4.5253106e-02,9.5205809e-03 -3,,density,fission,-2.6400028e-01,6.8175997e-02 -3,,density,nu-fission,-6.4353897e-01,1.6613026e-01 -3,,density,total,-3.2070285e-01,2.8328990e+00 -3,,density,absorption,2.5921007e-02,2.2141808e-02 -3,,density,scatter,-3.4662385e-01,2.8171749e+00 +3,,density,flux,-8.7368155e+00,1.5577812e+00 +3,,density,flux,-1.4842625e+01,2.2947682e+00 +1,,density,flux,-2.0922686e-01,4.9935069e-02 +1,,density,flux,-3.4582490e-01,1.7454386e-01 +1,O16,nuclide_density,flux,1.1301782e+01,2.2440389e+01 +1,O16,nuclide_density,flux,3.2481563e+00,3.2342885e+01 +1,U235,nuclide_density,flux,-1.5048665e+03,5.9045681e+02 +1,U235,nuclide_density,flux,-1.6193231e+03,9.7230073e+02 +1,,temperature,flux,-1.0891931e-04,2.3076849e-04 +1,,temperature,flux,-1.3563853e-04,2.0952841e-04 +3,,density,total,-3.9155374e+00,5.4862771e-01 +3,,density,absorption,-4.9210534e-01,3.4700776e-02 +3,,density,scatter,-3.4234320e+00,5.1443821e-01 +3,,density,fission,-3.1088949e-01,8.0540906e-02 +3,,density,nu-fission,-7.6137447e-01,1.9548876e-01 +3,,density,total,-3.8615156e-01,1.0175701e-01 +3,,density,absorption,-3.4458071e-01,9.3381192e-02 +3,,density,scatter,-4.1570854e-02,8.6942039e-03 +3,,density,fission,-2.9864832e-01,8.4711885e-02 +3,,density,nu-fission,-7.2797006e-01,2.0640455e-01 +3,,density,total,1.0491251e+01,9.1787723e+00 +3,,density,absorption,2.9819000e-01,3.0887165e-01 +3,,density,scatter,1.0193061e+01,8.8715930e+00 3,,density,fission,0.0000000e+00,0.0000000e+00 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 3,,density,total,0.0000000e+00,0.0000000e+00 @@ -29,19 +29,19 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. 3,,density,scatter,0.0000000e+00,0.0000000e+00 3,,density,fission,0.0000000e+00,0.0000000e+00 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 -1,,density,total,4.0321800e-01,3.5365140e-02 -1,,density,absorption,4.8426976e-03,8.3784362e-03 -1,,density,scatter,3.9837530e-01,2.9076664e-02 -1,,density,fission,-5.4793062e-03,7.1720201e-03 -1,,density,nu-fission,-1.2481616e-02,1.7542625e-02 -1,,density,total,-3.6063021e-03,7.1950060e-03 -1,,density,absorption,-8.2666439e-03,6.9274342e-03 -1,,density,scatter,4.6603417e-03,4.1803496e-04 -1,,density,fission,-7.6315741e-03,7.1774359e-03 -1,,density,nu-fission,-1.8551295e-02,1.7493106e-02 -1,,density,total,-6.2852725e-01,1.9776006e-01 -1,,density,absorption,-1.4850233e-02,4.3086611e-03 -1,,density,scatter,-6.1367701e-01,1.9363188e-01 +1,,density,total,4.7128871e-01,5.7197095e-02 +1,,density,absorption,2.1981833e-02,1.7427232e-02 +1,,density,scatter,4.4930687e-01,4.0030120e-02 +1,,density,fission,6.0712328e-03,1.3719512e-02 +1,,density,nu-fission,1.5474650e-02,3.3437103e-02 +1,,density,total,1.2203418e-02,1.5798741e-02 +1,,density,absorption,7.0228085e-03,1.5294984e-02 +1,,density,scatter,5.1806097e-03,5.0807003e-04 +1,,density,fission,4.1074923e-03,1.3759608e-02 +1,,density,nu-fission,1.0046778e-02,3.3529881e-02 +1,,density,total,-5.2100220e-01,2.7618985e-01 +1,,density,absorption,-1.1039048e-02,6.2043549e-03 +1,,density,scatter,-5.0996315e-01,2.7027892e-01 1,,density,fission,0.0000000e+00,0.0000000e+00 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 1,,density,total,0.0000000e+00,0.0000000e+00 @@ -49,19 +49,19 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. 1,,density,scatter,0.0000000e+00,0.0000000e+00 1,,density,fission,0.0000000e+00,0.0000000e+00 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 -1,O16,nuclide_density,total,4.2608989e+01,2.6322158e+00 -1,O16,nuclide_density,absorption,-5.9877963e-01,4.2139216e-01 -1,O16,nuclide_density,scatter,4.3207769e+01,2.5312922e+00 -1,O16,nuclide_density,fission,-9.2838585e-01,4.3505041e-01 -1,O16,nuclide_density,nu-fission,-2.2834786e+00,1.0634300e+00 -1,O16,nuclide_density,total,-1.1195412e+00,3.3033730e-01 -1,O16,nuclide_density,absorption,-1.0650267e+00,3.2780477e-01 -1,O16,nuclide_density,scatter,-5.4514540e-02,2.4911965e-02 -1,O16,nuclide_density,fission,-8.6787386e-01,4.4270048e-01 -1,O16,nuclide_density,nu-fission,-2.1159252e+00,1.0787495e+00 -1,O16,nuclide_density,total,-3.1004750e+01,8.0776339e+00 -1,O16,nuclide_density,absorption,-5.0354237e-01,2.6144390e-01 -1,O16,nuclide_density,scatter,-3.0501208e+01,7.8176703e+00 +1,O16,nuclide_density,total,5.5744608e+01,1.3811361e+01 +1,O16,nuclide_density,absorption,2.1284059e+00,3.3353171e+00 +1,O16,nuclide_density,scatter,5.3616202e+01,1.0494347e+01 +1,O16,nuclide_density,fission,6.6058671e-01,1.9263932e+00 +1,O16,nuclide_density,nu-fission,1.5973305e+00,4.6977280e+00 +1,O16,nuclide_density,total,9.8433784e-01,2.4053581e+00 +1,O16,nuclide_density,absorption,9.1167507e-01,2.2565683e+00 +1,O16,nuclide_density,scatter,7.2662768e-02,1.5198625e-01 +1,O16,nuclide_density,fission,6.8845700e-01,1.9451444e+00 +1,O16,nuclide_density,nu-fission,1.6768628e+00,4.7395897e+00 +1,O16,nuclide_density,total,8.1604245e+00,3.7248338e+01 +1,O16,nuclide_density,absorption,2.4903834e-01,4.5609671e-01 +1,O16,nuclide_density,scatter,7.9113862e+00,3.6811434e+01 1,O16,nuclide_density,fission,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,total,0.0000000e+00,0.0000000e+00 @@ -69,19 +69,19 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. 1,O16,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,fission,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 -1,U235,nuclide_density,total,-5.3578869e+02,3.4044374e+02 -1,U235,nuclide_density,absorption,2.0769087e+02,1.0873543e+02 -1,U235,nuclide_density,scatter,-7.4347956e+02,2.5966153e+02 -1,U235,nuclide_density,fission,2.8982867e+02,8.5348425e+01 -1,U235,nuclide_density,nu-fission,7.0772332e+02,2.0847449e+02 -1,U235,nuclide_density,total,4.8356107e+02,1.0276621e+02 -1,U235,nuclide_density,absorption,3.6683548e+02,9.6924085e+01 -1,U235,nuclide_density,scatter,1.1672558e+02,6.1773010e+00 -1,U235,nuclide_density,fission,2.8941699e+02,8.4475937e+01 -1,U235,nuclide_density,nu-fission,7.0639136e+02,2.0594285e+02 -1,U235,nuclide_density,total,-4.6777522e+03,1.5037171e+03 -1,U235,nuclide_density,absorption,-1.1585081e+02,3.8299177e+01 -1,U235,nuclide_density,scatter,-4.5619014e+03,1.4660078e+03 +1,U235,nuclide_density,total,-2.8654443e+02,3.3721470e+02 +1,U235,nuclide_density,absorption,2.0329180e+02,1.0522263e+02 +1,U235,nuclide_density,scatter,-4.8983623e+02,2.3237977e+02 +1,U235,nuclide_density,fission,2.6089045e+02,7.2578344e+01 +1,U235,nuclide_density,nu-fission,6.3692044e+02,1.7710877e+02 +1,U235,nuclide_density,total,4.5611633e+02,9.1682367e+01 +1,U235,nuclide_density,absorption,3.3831545e+02,8.5035501e+01 +1,U235,nuclide_density,scatter,1.1780088e+02,7.4128809e+00 +1,U235,nuclide_density,fission,2.6094461e+02,7.2102445e+01 +1,U235,nuclide_density,nu-fission,6.3705705e+02,1.7578950e+02 +1,U235,nuclide_density,total,-4.1342174e+03,1.4666097e+03 +1,U235,nuclide_density,absorption,-1.1329170e+02,3.5066579e+01 +1,U235,nuclide_density,scatter,-4.0209257e+03,1.4320401e+03 1,U235,nuclide_density,fission,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,total,0.0000000e+00,0.0000000e+00 @@ -89,19 +89,19 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. 1,U235,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,fission,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 -1,,temperature,total,8.2134941e-05,1.3941434e-05 -1,,temperature,absorption,4.1502002e-05,3.5967068e-05 -1,,temperature,scatter,4.0632939e-05,2.6595574e-05 -1,,temperature,fission,3.1768469e-06,2.1582455e-05 -1,,temperature,nu-fission,7.7368345e-06,5.2593375e-05 -1,,temperature,total,1.0834099e-06,2.6707333e-05 -1,,temperature,absorption,1.6240165e-06,2.6844372e-05 -1,,temperature,scatter,-5.4060665e-07,2.5905412e-07 -1,,temperature,fission,3.1674458e-06,2.1588836e-05 -1,,temperature,nu-fission,7.7134913e-06,5.2609321e-05 -1,,temperature,total,9.5175179e-05,1.0549922e-04 -1,,temperature,absorption,4.3553888e-06,2.9261613e-06 -1,,temperature,scatter,9.0819790e-05,1.0362538e-04 +1,,temperature,total,5.3733744e-05,1.1785516e-04 +1,,temperature,absorption,-1.3987780e-05,1.9819801e-05 +1,,temperature,scatter,6.7721524e-05,9.9934995e-05 +1,,temperature,fission,-1.4882696e-05,1.6930666e-05 +1,,temperature,nu-fission,-3.6272065e-05,4.1250892e-05 +1,,temperature,total,-1.8119796e-05,2.2651409e-05 +1,,temperature,absorption,-1.7632076e-05,2.1825006e-05 +1,,temperature,scatter,-4.8771972e-07,1.4270133e-06 +1,,temperature,fission,-1.4890811e-05,1.6935899e-05 +1,,temperature,nu-fission,-3.6292215e-05,4.1263951e-05 +1,,temperature,total,-2.0776498e-04,2.9286552e-04 +1,,temperature,absorption,-3.9068381e-06,3.4912438e-06 +1,,temperature,scatter,-2.0385814e-04,2.8941307e-04 1,,temperature,fission,0.0000000e+00,0.0000000e+00 1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 1,,temperature,total,0.0000000e+00,0.0000000e+00 @@ -109,68 +109,68 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. 1,,temperature,scatter,0.0000000e+00,0.0000000e+00 1,,temperature,fission,0.0000000e+00,0.0000000e+00 1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 -3,,density,absorption,-5.4897740e-01,8.6529144e-02 -3,,density,absorption,1.3410763e-01,5.6235628e-02 -1,,density,absorption,2.9551566e-02,1.5215007e-02 -1,,density,absorption,-8.6382033e-03,5.5181454e-03 -1,O16,nuclide_density,absorption,2.7111116e-01,9.6922067e-01 -1,O16,nuclide_density,absorption,-7.3785997e-01,7.7252792e-01 -1,U235,nuclide_density,absorption,2.7361252e+02,1.6168134e+02 -1,U235,nuclide_density,absorption,-9.6885408e+01,1.9390948e+01 -1,,temperature,absorption,1.0054736e-05,4.2876538e-05 -1,,temperature,absorption,-1.8280609e-06,1.0133065e-05 +3,,density,absorption,-4.5579543e-01,5.5532252e-02 +3,,density,absorption,-1.3526251e-02,1.3917291e-01 +1,,density,absorption,3.8695654e-02,1.5823093e-02 +1,,density,absorption,-1.8171150e-02,1.2999773e-03 +1,O16,nuclide_density,absorption,2.0992238e+00,2.7230754e+00 +1,O16,nuclide_density,absorption,-6.8956953e-01,3.3064989e-01 +1,U235,nuclide_density,absorption,2.5000417e+02,7.3334295e+01 +1,U235,nuclide_density,absorption,-1.0832917e+02,1.1517513e+01 +1,,temperature,absorption,1.1819459e-05,4.2090670e-05 +1,,temperature,absorption,-7.2302974e-06,1.5200299e-05 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 -3,,density,scatter,-5.4273849e-01,1.8081153e-01 +3,,density,scatter,-7.6858714e-01,3.2467801e-01 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 -3,,density,scatter,1.3451827e-02,7.2870304e-03 -3,,density,nu-fission,-8.4200508e-01,3.4267126e-01 -3,,density,scatter,-3.1963455e+00,5.0369564e-01 -3,,density,nu-fission,-8.2934702e-01,3.4526131e-01 -3,,density,scatter,-7.0221960e-02,6.8067882e-02 +3,,density,scatter,3.2513857e-04,3.2513857e-04 +3,,density,nu-fission,-6.4963717e-01,1.8008086e-01 +3,,density,scatter,-2.6911548e+00,2.6336008e-01 +3,,density,nu-fission,-6.3014524e-01,1.8056453e-01 +3,,density,scatter,-3.4247012e-02,2.2649385e-02 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 -3,,density,scatter,1.1368387e+00,1.2091778e+00 +3,,density,scatter,1.0254549e+01,1.1054242e+01 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 3,,density,scatter,0.0000000e+00,0.0000000e+00 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 -3,,density,scatter,-1.5916491e+00,2.3551913e+00 +3,,density,scatter,2.5022850e-01,2.1207285e+00 3,,density,nu-fission,0.0000000e+00,0.0000000e+00 3,,density,scatter,0.0000000e+00,0.0000000e+00 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 -1,,density,scatter,-1.8655633e-03,2.4061808e-02 +1,,density,scatter,8.1153611e-03,3.1226564e-02 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 -1,,density,scatter,-1.7672807e-04,7.4702879e-04 -1,,density,nu-fission,4.4506944e-03,3.1478180e-02 -1,,density,scatter,3.7553200e-01,2.3420342e-02 -1,,density,nu-fission,-1.3567324e-03,3.0610901e-02 -1,,density,scatter,6.9330560e-03,4.6649873e-03 +1,,density,scatter,2.3728497e-04,9.7166041e-04 +1,,density,nu-fission,2.6248459e-02,3.9328080e-02 +1,,density,scatter,4.2447769e-01,1.2580873e-02 +1,,density,nu-fission,1.9600074e-02,3.8118776e-02 +1,,density,scatter,8.0978391e-03,2.6585488e-03 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 -1,,density,scatter,-5.1560927e-01,1.4846253e-01 +1,,density,scatter,-3.8358302e-01,2.1525401e-01 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 1,,density,scatter,0.0000000e+00,0.0000000e+00 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 -1,,density,scatter,-1.0427977e-01,6.6396271e-02 +1,,density,scatter,-1.1924803e-01,9.1254221e-02 1,,density,nu-fission,0.0000000e+00,0.0000000e+00 1,,density,scatter,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 -1,O16,nuclide_density,scatter,4.6587151e-02,9.0232672e-02 -1,O16,nuclide_density,nu-fission,-2.1162226e+00,2.4773842e+00 -1,O16,nuclide_density,scatter,6.6533325e-01,2.4693113e-01 +1,O16,nuclide_density,scatter,-1.6577061e-01,1.0793192e-01 +1,O16,nuclide_density,nu-fission,2.4995074e+00,5.7946039e+00 +1,O16,nuclide_density,scatter,5.5800956e-01,5.7675606e-01 1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 1,O16,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 -1,U235,nuclide_density,scatter,2.8979849e+01,2.0235325e+01 -1,U235,nuclide_density,nu-fission,8.1210341e+02,2.9252040e+02 -1,U235,nuclide_density,scatter,1.0307302e+02,4.4919960e+01 +1,U235,nuclide_density,scatter,5.8641633e+00,2.9488422e+00 +1,U235,nuclide_density,nu-fission,6.7444160e+02,1.1308014e+02 +1,U235,nuclide_density,scatter,1.1592472e+02,2.8886339e+01 1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 1,U235,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 -1,,temperature,scatter,-3.3782154e-06,3.8240314e-06 -1,,temperature,nu-fission,-6.8920903e-05,4.4384761e-05 -1,,temperature,scatter,1.6325729e-07,2.3270228e-06 +1,,temperature,scatter,-7.7511866e-07,6.4761261e-07 +1,,temperature,nu-fission,-9.5466386e-05,3.1033330e-05 +1,,temperature,scatter,-2.7127084e-06,2.0699253e-07 1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 1,,temperature,scatter,0.0000000e+00,0.0000000e+00 1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 diff --git a/tests/regression_tests/distribmat/inputs_true.dat b/tests/regression_tests/distribmat/inputs_true.dat index 8087d7564..ade86999d 100644 --- a/tests/regression_tests/distribmat/inputs_true.dat +++ b/tests/regression_tests/distribmat/inputs_true.dat @@ -2,26 +2,24 @@ - - - + + + - - - + + + - - - + + + - - 2 void 3 2 - + - + 2.0 2.0 1 @@ -31,30 +29,30 @@ 11 11 11 11 - - - - - + + + + + eigenvalue 1000 5 0 - + -1 -1 -1 1 1 1 - + 400 400 0 0 0 7 7 - + 400 400 0 0 0 7 7 diff --git a/tests/regression_tests/distribmat/results_true.dat b/tests/regression_tests/distribmat/results_true.dat index 166fd4662..af7b27fe7 100644 --- a/tests/regression_tests/distribmat/results_true.dat +++ b/tests/regression_tests/distribmat/results_true.dat @@ -1,5 +1,5 @@ k-combined: -1.246391E+00 1.414798E-02 +1.257344E+00 6.246360E-04 Cell ID = 11 Name = diff --git a/tests/regression_tests/distribmat/test.py b/tests/regression_tests/distribmat/test.py index dd09eec36..02f7e773e 100644 --- a/tests/regression_tests/distribmat/test.py +++ b/tests/regression_tests/distribmat/test.py @@ -73,7 +73,7 @@ class DistribmatTestHarness(PyAPITestHarness): # Plots #################### - plot1 = openmc.SlicePlot(plot_id=1) + plot1 = openmc.Plot(plot_id=1) plot1.basis = 'xy' plot1.color_by = 'cell' plot1.filename = 'cellplot' @@ -81,7 +81,7 @@ class DistribmatTestHarness(PyAPITestHarness): plot1.width = (7, 7) plot1.pixels = (400, 400) - plot2 = openmc.SlicePlot(plot_id=2) + plot2 = openmc.Plot(plot_id=2) plot2.basis = 'xy' plot2.color_by = 'material' plot2.filename = 'matplot' diff --git a/tests/regression_tests/eigenvalue_genperbatch/inputs_true.dat b/tests/regression_tests/eigenvalue_genperbatch/inputs_true.dat index 15b810a62..a3e67d62f 100644 --- a/tests/regression_tests/eigenvalue_genperbatch/inputs_true.dat +++ b/tests/regression_tests/eigenvalue_genperbatch/inputs_true.dat @@ -1,14 +1,14 @@ - - - + + + - + eigenvalue @@ -16,7 +16,7 @@ 7 3 3 - + -4.0 -4.0 -4.0 4.0 4.0 4.0 diff --git a/tests/regression_tests/eigenvalue_genperbatch/results_true.dat b/tests/regression_tests/eigenvalue_genperbatch/results_true.dat index d171c5e87..3f7ea801a 100644 --- a/tests/regression_tests/eigenvalue_genperbatch/results_true.dat +++ b/tests/regression_tests/eigenvalue_genperbatch/results_true.dat @@ -1,5 +1,5 @@ k-combined: -2.975937E-01 1.293390E-03 +3.037481E-01 1.247474E-04 tally 1: -3.173222E+01 -2.517683E+02 +3.211129E+01 +2.578396E+02 diff --git a/tests/regression_tests/eigenvalue_no_inactive/results_true.dat b/tests/regression_tests/eigenvalue_no_inactive/results_true.dat index 3ba7485a9..2b1021608 100644 --- a/tests/regression_tests/eigenvalue_no_inactive/results_true.dat +++ b/tests/regression_tests/eigenvalue_no_inactive/results_true.dat @@ -1,2 +1,2 @@ k-combined: -3.072780E-01 6.882841E-03 +2.998284E-01 7.587782E-03 diff --git a/tests/regression_tests/electron_heating/inputs_true.dat b/tests/regression_tests/electron_heating/inputs_true.dat deleted file mode 100644 index ec8e5a837..000000000 --- a/tests/regression_tests/electron_heating/inputs_true.dat +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - fixed source - 10000 - 1 - - - 10000000.0 1.0 - - - - 1000.0 - - - - - heating - - - diff --git a/tests/regression_tests/electron_heating/results_true.dat b/tests/regression_tests/electron_heating/results_true.dat deleted file mode 100644 index 4f54ceaa4..000000000 --- a/tests/regression_tests/electron_heating/results_true.dat +++ /dev/null @@ -1,3 +0,0 @@ -tally 1: -1.000000E+07 -1.000000E+14 diff --git a/tests/regression_tests/electron_heating/test.py b/tests/regression_tests/electron_heating/test.py deleted file mode 100644 index e7a58560c..000000000 --- a/tests/regression_tests/electron_heating/test.py +++ /dev/null @@ -1,40 +0,0 @@ -import pytest -import openmc - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def water_model(): - # Define materals and geometry - water = openmc.Material() - water.add_nuclide("H1", 2.0) - water.add_nuclide("O16", 1.0) - water.set_density("g/cc", 1.0) - sphere = openmc.Sphere(r=1.0, boundary_type="reflective") - sph = openmc.Cell(fill=water, region=-sphere) - geometry = openmc.Geometry([sph]) - source = openmc.IndependentSource( - energy=openmc.stats.delta_function(10.0e6), - particle="electron" - ) - - # Define settings - settings = openmc.Settings() - settings.particles = 10000 - settings.batches = 1 - settings.cutoff = {"energy_photon": 1000.0} - settings.run_mode = "fixed source" - settings.source = source - - # Define tallies - tally = openmc.Tally() - tally.scores = ["heating"] - tallies = openmc.Tallies([tally]) - - return openmc.Model(geometry=geometry, settings=settings, tallies=tallies) - - -def test_electron_heating_calc(water_model): - harness = PyAPITestHarness("statepoint.1.h5", water_model) - harness.main() diff --git a/tests/regression_tests/energy_cutoff/inputs_true.dat b/tests/regression_tests/energy_cutoff/inputs_true.dat index 557cb7a3b..af8f86b67 100644 --- a/tests/regression_tests/energy_cutoff/inputs_true.dat +++ b/tests/regression_tests/energy_cutoff/inputs_true.dat @@ -2,28 +2,28 @@ - - + + - - - - - - - + + + + + + + fixed source 100 10 - + -1 -1 -1 1 1 1 - + 4.0 diff --git a/tests/regression_tests/energy_grid/results_true.dat b/tests/regression_tests/energy_grid/results_true.dat index 3a042d882..deab1e28b 100644 --- a/tests/regression_tests/energy_grid/results_true.dat +++ b/tests/regression_tests/energy_grid/results_true.dat @@ -1,2 +1,2 @@ k-combined: -3.218009E-01 4.687417E-03 +3.152586E-01 1.458068E-03 diff --git a/tests/regression_tests/energy_laws/inputs_true.dat b/tests/regression_tests/energy_laws/inputs_true.dat index 8c5191217..4d8e825d1 100644 --- a/tests/regression_tests/energy_laws/inputs_true.dat +++ b/tests/regression_tests/energy_laws/inputs_true.dat @@ -1,18 +1,18 @@ - - - - - - - + + + + + + + - + eigenvalue diff --git a/tests/regression_tests/energy_laws/results_true.dat b/tests/regression_tests/energy_laws/results_true.dat index 780278683..534a299b5 100644 --- a/tests/regression_tests/energy_laws/results_true.dat +++ b/tests/regression_tests/energy_laws/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.458770E+00 9.422203E-03 +2.444000E+00 1.044626E-02 diff --git a/tests/regression_tests/entropy/results_true.dat b/tests/regression_tests/entropy/results_true.dat index 92d7f091d..1c8b2908b 100644 --- a/tests/regression_tests/entropy/results_true.dat +++ b/tests/regression_tests/entropy/results_true.dat @@ -1,13 +1,13 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 entropy: 7.688862E+00 -8.226316E+00 -8.308355E+00 -8.243413E+00 -8.369345E+00 -8.304865E+00 -8.230689E+00 -8.338304E+00 -8.270630E+00 -8.386598E+00 +8.237960E+00 +8.314772E+00 +8.285254E+00 +8.271486E+00 +8.291355E+00 +8.253349E+00 +8.336726E+00 +8.284741E+00 +8.328102E+00 diff --git a/tests/regression_tests/external_moab/inputs_true.dat b/tests/regression_tests/external_moab/inputs_true.dat index ed035f897..23b656bce 100644 --- a/tests/regression_tests/external_moab/inputs_true.dat +++ b/tests/regression_tests/external_moab/inputs_true.dat @@ -1,63 +1,63 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 100 10 - + 0.0 0.0 0.0 - + 15000000.0 1.0 - + test_mesh_tets.h5m diff --git a/tests/regression_tests/external_moab/test.py b/tests/regression_tests/external_moab/test.py index 2d64eb14b..ce4e78a2c 100644 --- a/tests/regression_tests/external_moab/test.py +++ b/tests/regression_tests/external_moab/test.py @@ -39,7 +39,7 @@ def cpp_driver(request): target_link_libraries(main OpenMC::libopenmc) target_compile_features(main PUBLIC cxx_std_14) set(CMAKE_CXX_FLAGS "-pedantic-errors") - add_compile_definitions(OPENMC_DAGMC_ENABLED=1) + add_compile_definitions(DAGMC=1) """.format(openmc_dir))) # Create temporary build directory and change to there diff --git a/tests/regression_tests/filter_cellfrom/inputs_true.dat b/tests/regression_tests/filter_cellfrom/inputs_true.dat index 20d0d69d4..b85f63c6e 100644 --- a/tests/regression_tests/filter_cellfrom/inputs_true.dat +++ b/tests/regression_tests/filter_cellfrom/inputs_true.dat @@ -1,54 +1,54 @@ - - - - - - - + + + + + + + - - - + + + - - - - - + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 2000 15 5 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/filter_cellfrom/results_true.dat b/tests/regression_tests/filter_cellfrom/results_true.dat index 408a4965b..5dd43e1f3 100644 --- a/tests/regression_tests/filter_cellfrom/results_true.dat +++ b/tests/regression_tests/filter_cellfrom/results_true.dat @@ -1,53 +1,53 @@ k-combined: -9.035025E-02 2.654309E-03 +9.640806E-02 2.655206E-03 tally 1: -5.994069E+00 -3.594398E+00 +6.025999E+00 +3.635317E+00 tally 2: -4.559707E-04 -2.080739E-08 +4.523606E-04 +2.051522E-08 tally 3: -5.994525E+00 -3.594945E+00 +6.026452E+00 +3.635862E+00 tally 4: 0.000000E+00 0.000000E+00 tally 5: -1.473892E+00 -2.187509E-01 +1.530903E+00 +2.357048E-01 tally 6: -5.223875E-05 -2.992861E-10 +4.992646E-05 +2.600391E-10 tally 7: -1.473945E+00 -2.187663E-01 +1.530953E+00 +2.357201E-01 tally 8: -1.885798E+01 -3.558423E+01 +1.889115E+01 +3.574727E+01 tally 9: -7.467961E+00 -5.580255E+00 +7.556902E+00 +5.717680E+00 tally 10: -5.082094E-04 -2.584432E-08 +5.022871E-04 +2.531352E-08 tally 11: -7.468470E+00 -5.581014E+00 +7.557405E+00 +5.718440E+00 tally 12: -1.885798E+01 -3.558423E+01 +1.889115E+01 +3.574727E+01 tally 13: 0.000000E+00 0.000000E+00 tally 14: -2.739543E-04 -7.600983E-09 +2.663407E-04 +7.161725E-09 tally 15: -2.739543E-04 -7.600983E-09 +2.663407E-04 +7.161725E-09 tally 16: -7.881296E+01 -6.221087E+02 +8.025710E+01 +6.459305E+02 tally 17: -1.051397E+02 -1.106292E+03 +1.067059E+02 +1.140939E+03 diff --git a/tests/regression_tests/filter_cellinstance/inputs_true.dat b/tests/regression_tests/filter_cellinstance/inputs_true.dat index 2677d7ad2..b17cc0eb5 100644 --- a/tests/regression_tests/filter_cellinstance/inputs_true.dat +++ b/tests/regression_tests/filter_cellinstance/inputs_true.dat @@ -1,22 +1,22 @@ - - - + + + - - + + - + - + 2 2 4 4 @@ -27,19 +27,19 @@ 3 3 2 3 3 3 3 2 - - - - - - + + + + + + eigenvalue 1000 5 0 - + 0.0 0.0 0.0 diff --git a/tests/regression_tests/filter_cellinstance/results_true.dat b/tests/regression_tests/filter_cellinstance/results_true.dat index 152986595..079b7d3d2 100644 --- a/tests/regression_tests/filter_cellinstance/results_true.dat +++ b/tests/regression_tests/filter_cellinstance/results_true.dat @@ -1,84 +1,84 @@ k-combined: -1.097679E+00 8.074294E-03 +1.050139E+00 1.886614E-02 tally 1: -7.125168E-02 -1.412152E-03 -1.254059E-01 -4.145686E-03 -1.609454E-01 -6.174116E-03 -1.444278E-01 -4.523981E-03 -3.363588E-01 -2.342988E-02 -1.751677E-01 -7.108034E-03 -1.384074E-01 -3.949804E-03 -2.856450E-01 -1.824185E-02 -9.680810E-02 -2.256338E-03 -1.691663E-01 -6.456530E-03 -1.160968E-01 -3.233815E-03 -7.334131E-02 -1.456688E-03 -1.168548E+01 -3.210924E+01 -2.860162E+01 -1.876786E+02 -2.857267E+01 -1.996553E+02 -1.050245E+01 -2.569953E+01 -1.168548E+01 -3.210924E+01 -2.860162E+01 -1.876786E+02 -2.857267E+01 -1.996553E+02 -1.050245E+01 -2.569953E+01 +9.724996E-02 +2.784804E-03 +1.146976E-01 +3.173782E-03 +1.698297E-01 +6.569993E-03 +1.158802E-01 +2.959280E-03 +2.533354E-01 +1.539905E-02 +1.908717E-01 +8.360058E-03 +1.738899E-01 +6.713494E-03 +3.172247E-01 +2.124184E-02 +1.363012E-01 +4.653519E-03 +1.698720E-01 +6.753819E-03 +9.934671E-02 +2.371660E-03 +6.038075E-02 +1.204656E-03 +1.038793E+01 +2.590382E+01 +2.841397E+01 +1.865709E+02 +2.786916E+01 +1.923869E+02 +1.085149E+01 +2.907194E+01 +1.038793E+01 +2.590382E+01 +2.841397E+01 +1.865709E+02 +2.786916E+01 +1.923869E+02 +1.085149E+01 +2.907194E+01 tally 2: -1.050245E+01 -2.569953E+01 -2.857267E+01 -1.996553E+02 -2.860162E+01 -1.876786E+02 -1.168548E+01 -3.210924E+01 -1.050245E+01 -2.569953E+01 -2.857267E+01 -1.996553E+02 -2.860162E+01 -1.876786E+02 -1.168548E+01 -3.210924E+01 -7.334131E-02 -1.456688E-03 -1.160968E-01 -3.233815E-03 -1.691663E-01 -6.456530E-03 -9.680810E-02 -2.256338E-03 -2.856450E-01 -1.824185E-02 -1.384074E-01 -3.949804E-03 -1.751677E-01 -7.108034E-03 -3.363588E-01 -2.342988E-02 -1.444278E-01 -4.523981E-03 -1.609454E-01 -6.174116E-03 -1.254059E-01 -4.145686E-03 -7.125168E-02 -1.412152E-03 +1.085149E+01 +2.907194E+01 +2.786916E+01 +1.923869E+02 +2.841397E+01 +1.865709E+02 +1.038793E+01 +2.590382E+01 +1.085149E+01 +2.907194E+01 +2.786916E+01 +1.923869E+02 +2.841397E+01 +1.865709E+02 +1.038793E+01 +2.590382E+01 +6.038075E-02 +1.204656E-03 +9.934671E-02 +2.371660E-03 +1.698720E-01 +6.753819E-03 +1.363012E-01 +4.653519E-03 +3.172247E-01 +2.124184E-02 +1.738899E-01 +6.713494E-03 +1.908717E-01 +8.360058E-03 +2.533354E-01 +1.539905E-02 +1.158802E-01 +2.959280E-03 +1.698297E-01 +6.569993E-03 +1.146976E-01 +3.173782E-03 +9.724996E-02 +2.784804E-03 diff --git a/tests/regression_tests/filter_distribcell/case-3/results_true.dat b/tests/regression_tests/filter_distribcell/case-3/results_true.dat index 77f2a2a87..f30e858f0 100644 --- a/tests/regression_tests/filter_distribcell/case-3/results_true.dat +++ b/tests/regression_tests/filter_distribcell/case-3/results_true.dat @@ -1 +1 @@ -93c1efbc586874a715982d26609e9e79232de25a0b73093a00938d658440644f0ee6bb823902a6ef1b7a2a855e67b2da0a0e767ef550f9ffa4dea723e35af6f5 \ No newline at end of file +1d09084dc41305687d53d1e800fb3d0ac3949aa4e1cb0bfbb327d0ec1ad4b74fc97ee73da84b910529296b858aab9b8a5d0924d17ca2cc373625e1a9e197aa94 \ No newline at end of file diff --git a/tests/regression_tests/filter_distribcell/case-4/results_true.dat b/tests/regression_tests/filter_distribcell/case-4/results_true.dat index ed84838ee..228456c58 100644 --- a/tests/regression_tests/filter_distribcell/case-4/results_true.dat +++ b/tests/regression_tests/filter_distribcell/case-4/results_true.dat @@ -1,12 +1,12 @@ k-combined: -1.069692E-01 INF +1.068596E-01 INF tally 1: 1.812612E-02 3.285561E-04 2.870442E-02 8.239436E-04 -1.824058E-02 -3.327188E-04 +1.807689E-02 +3.267740E-04 2.660796E-02 7.079835E-04 1.961572E-02 diff --git a/tests/regression_tests/filter_energyfun/inputs_true.dat b/tests/regression_tests/filter_energyfun/inputs_true.dat index b7a70290f..4b7b74d28 100644 --- a/tests/regression_tests/filter_energyfun/inputs_true.dat +++ b/tests/regression_tests/filter_energyfun/inputs_true.dat @@ -1,14 +1,14 @@ - - - + + + - + eigenvalue diff --git a/tests/regression_tests/filter_energyfun/results_true.dat b/tests/regression_tests/filter_energyfun/results_true.dat index d64de58a6..0aadac82e 100644 --- a/tests/regression_tests/filter_energyfun/results_true.dat +++ b/tests/regression_tests/filter_energyfun/results_true.dat @@ -1,10 +1,10 @@ energyfunction nuclide score mean std. dev. -0 448ee8dfd19c4f Am241 ((n,gamma) / (n,gamma)) 1.74e-01 5.44e-03 +0 448ee8dfd19c4f Am241 ((n,gamma) / (n,gamma)) 1.74e-01 6.83e-03 energyfunction nuclide score mean std. dev. -0 37e006ae6b2e74 Am241 (n,gamma) 8.35e-02 1.83e-03 +0 37e006ae6b2e74 Am241 (n,gamma) 8.16e-02 2.24e-03 energyfunction nuclide score mean std. dev. -0 b4e2ac84068d2d Am241 (n,gamma) 8.39e-02 1.84e-03 +0 b4e2ac84068d2d Am241 (n,gamma) 8.19e-02 2.25e-03 energyfunction nuclide score mean std. dev. -0 dacf88242512ea Am241 (n,gamma) 8.14e-02 1.78e-03 +0 dacf88242512ea Am241 (n,gamma) 7.95e-02 2.19e-03 energyfunction nuclide score mean std. dev. -0 fe168c70d9e078 Am241 (n,gamma) 1.09e-01 2.41e-03 +0 fe168c70d9e078 Am241 (n,gamma) 1.06e-01 2.96e-03 diff --git a/tests/regression_tests/filter_mesh/inputs_true.dat b/tests/regression_tests/filter_mesh/inputs_true.dat index 10f70a720..a58d58bab 100644 --- a/tests/regression_tests/filter_mesh/inputs_true.dat +++ b/tests/regression_tests/filter_mesh/inputs_true.dat @@ -1,28 +1,28 @@ - - - + + + - - + + - - - - - - - - - - - + + + + + + + + + + + eigenvalue @@ -54,8 +54,8 @@ 0.0 0.4411764705882353 0.8823529411764706 1.3235294117647058 1.7647058823529411 2.2058823529411766 2.6470588235294117 3.0882352941176467 3.5294117647058822 3.9705882352941178 4.411764705882353 4.852941176470588 5.294117647058823 5.735294117647059 6.1764705882352935 6.617647058823529 7.0588235294117645 7.5 0.0 0.3490658503988659 0.6981317007977318 1.0471975511965976 1.3962634015954636 1.7453292519943295 2.0943951023931953 2.443460952792061 2.792526803190927 3.141592653589793 3.490658503988659 3.839724354387525 4.1887902047863905 4.537856055185257 4.886921905584122 5.235987755982989 5.585053606381854 5.93411945678072 6.283185307179586 - 0.0 0.9375 1.875 2.8125 3.75 4.6875 5.625 6.5625 7.5 8.4375 9.375 10.3125 11.25 12.1875 13.125 14.0625 15.0 - 0.0 0.0 -7.5 + -7.5 -6.5625 -5.625 -4.6875 -3.75 -2.8125 -1.875 -0.9375 0.0 0.9375 1.875 2.8125 3.75 4.6875 5.625 6.5625 7.5 + 0.0 0.0 0.0 0.0 0.4411764705882353 0.8823529411764706 1.3235294117647058 1.7647058823529411 2.2058823529411766 2.6470588235294117 3.0882352941176467 3.5294117647058822 3.9705882352941178 4.411764705882353 4.852941176470588 5.294117647058823 5.735294117647059 6.1764705882352935 6.617647058823529 7.0588235294117645 7.5 diff --git a/tests/regression_tests/filter_mesh/results_true.dat b/tests/regression_tests/filter_mesh/results_true.dat index 34e99c17e..a91eadb35 100644 --- a/tests/regression_tests/filter_mesh/results_true.dat +++ b/tests/regression_tests/filter_mesh/results_true.dat @@ -1 +1 @@ -e07ed2bc8893c69721abf61b123336f1f6128a3bee6ec63b84d1f549f31707a74a6ce885091ccc0eac6b7f16f7cab39ede4784584c08825829e108de878ea5fb \ No newline at end of file +bd55ee25094f9ad04fda4439f58ef0fed718632c88b9fde411a484dc624dedcd45dee643e14d8b107d8b92757737b8bb3d9a667de5482457d6d8346afffdf657 \ No newline at end of file diff --git a/tests/regression_tests/filter_mesh/test.py b/tests/regression_tests/filter_mesh/test.py index 165ba2a0c..6214e0486 100644 --- a/tests/regression_tests/filter_mesh/test.py +++ b/tests/regression_tests/filter_mesh/test.py @@ -61,10 +61,9 @@ def model(): np.testing.assert_allclose(recti_mesh.volumes, recti_mesh_exp_vols) cyl_mesh = openmc.CylindricalMesh( - origin=(0, 0, -7.5), r_grid=np.linspace(0, 7.5, 18), phi_grid=np.linspace(0, 2*pi, 19), - z_grid=np.linspace(0, 15, 17), + z_grid=np.linspace(-7.5, 7.5, 17), ) dr = 0.5 * np.diff(np.linspace(0, 7.5, 18)**2) dp = np.full(cyl_mesh.dimension[1], 2*pi / 18) diff --git a/tests/regression_tests/filter_meshborn/inputs_true.dat b/tests/regression_tests/filter_meshborn/inputs_true.dat index a94646ec8..3ba38d56e 100644 --- a/tests/regression_tests/filter_meshborn/inputs_true.dat +++ b/tests/regression_tests/filter_meshborn/inputs_true.dat @@ -2,19 +2,19 @@ - - + + - + fixed source 2000 8 - + 0.0 -10.0 -10.0 10.0 10.0 10.0 diff --git a/tests/regression_tests/filter_musurface/__init__.py b/tests/regression_tests/filter_musurface/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/filter_musurface/inputs_true.dat b/tests/regression_tests/filter_musurface/inputs_true.dat deleted file mode 100644 index b457f5028..000000000 --- a/tests/regression_tests/filter_musurface/inputs_true.dat +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 5 - 0 - - - - 1 - - - -1.0 -0.5 0.0 0.5 1.0 - - - 1 2 - current flux - - - diff --git a/tests/regression_tests/filter_musurface/results_true.dat b/tests/regression_tests/filter_musurface/results_true.dat deleted file mode 100644 index 657c141a0..000000000 --- a/tests/regression_tests/filter_musurface/results_true.dat +++ /dev/null @@ -1,19 +0,0 @@ -k-combined: -1.202075E-01 1.113188E-02 -tally 1: -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.230000E-01 -1.791510E-01 -3.294304E+00 -2.314403E+00 -3.869000E+00 -3.002523E+00 -5.154125E+00 -5.314334E+00 diff --git a/tests/regression_tests/filter_musurface/test.py b/tests/regression_tests/filter_musurface/test.py deleted file mode 100644 index bfc12a47c..000000000 --- a/tests/regression_tests/filter_musurface/test.py +++ /dev/null @@ -1,40 +0,0 @@ -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - model = openmc.Model() - fuel = openmc.Material() - fuel.set_density('g/cm3', 10.0) - fuel.add_nuclide('U235', 1.0) - zr = openmc.Material() - zr.set_density('g/cm3', 1.0) - zr.add_nuclide('Zr90', 1.0) - - cyl1 = openmc.ZCylinder(r=1.0) - cyl2 = openmc.ZCylinder(r=3.0, boundary_type='vacuum') - cell1 = openmc.Cell(fill=fuel, region=-cyl1) - cell2 = openmc.Cell(fill=zr, region=+cyl1 & -cyl2) - model.geometry = openmc.Geometry([cell1, cell2]) - - model.settings.batches = 5 - model.settings.inactive = 0 - model.settings.particles = 1000 - - # Create a tally for current through the first surface binned by mu - surf_filter = openmc.SurfaceFilter([cyl1]) - mu_filter = openmc.MuSurfaceFilter([-1.0, -0.5, 0.0, 0.5, 1.0]) - tally = openmc.Tally() - tally.filters = [surf_filter, mu_filter] - tally.scores = ['current', 'flux'] - model.tallies.append(tally) - - return model - - -def test_filter_musurface(model): - harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() diff --git a/tests/regression_tests/filter_reaction/__init__.py b/tests/regression_tests/filter_reaction/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/filter_reaction/inputs_true.dat b/tests/regression_tests/filter_reaction/inputs_true.dat deleted file mode 100644 index 3ab9ab3fb..000000000 --- a/tests/regression_tests/filter_reaction/inputs_true.dat +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - eigenvalue - 1000 - 5 - - - - (n,elastic) (n,2n) (n,fission) (n,gamma) (n,total) - - - 1 - flux - - - diff --git a/tests/regression_tests/filter_reaction/results_true.dat b/tests/regression_tests/filter_reaction/results_true.dat deleted file mode 100644 index 61ec1c65f..000000000 --- a/tests/regression_tests/filter_reaction/results_true.dat +++ /dev/null @@ -1,13 +0,0 @@ -k-combined: -2.265297E+00 7.172807E-03 -tally 1: -8.364316E+01 -1.400120E+03 -1.412312E-01 -4.277446E-03 -5.471503E+00 -7.015849E+00 -0.000000E+00 -0.000000E+00 -1.349840E+02 -3.644648E+03 diff --git a/tests/regression_tests/filter_reaction/test.py b/tests/regression_tests/filter_reaction/test.py deleted file mode 100644 index 3c60fd517..000000000 --- a/tests/regression_tests/filter_reaction/test.py +++ /dev/null @@ -1,31 +0,0 @@ -import openmc - -from tests.testing_harness import PyAPITestHarness - - -def test_filter_reaction(): - model = openmc.Model() - - m = openmc.Material() - m.set_density('g/cm3', 10.0) - m.add_nuclide('U235', 1.0) - model.materials.append(m) - - s = openmc.Sphere(r=100.0, boundary_type='vacuum') - c = openmc.Cell(fill=m, region=-s) - model.geometry = openmc.Geometry([c]) - - # Create a tally with reaction filter - tally = openmc.Tally() - tally.filters = [openmc.ReactionFilter( - ['(n,elastic)', '(n,2n)', '(n,fission)', '(n,gamma)', 'total'] - )] - tally.scores = ['flux'] - model.tallies = openmc.Tallies([tally]) - - # Reduce particles for faster testing - model.settings.particles = 1000 - model.settings.batches = 5 - - harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() diff --git a/tests/regression_tests/filter_rotations/__init__.py b/tests/regression_tests/filter_rotations/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/filter_rotations/inputs_true.dat b/tests/regression_tests/filter_rotations/inputs_true.dat deleted file mode 100644 index 1ad2b9e86..000000000 --- a/tests/regression_tests/filter_rotations/inputs_true.dat +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 5 - 0 - - - - 3 4 5 - -9 -9 -9 - 9 9 9 - - - 3 4 5 - -9 -9 -9 - 9 9 9 - - - 1 - - - 2 - - - 1 - total - - - 2 - total - - - diff --git a/tests/regression_tests/filter_rotations/results_true.dat b/tests/regression_tests/filter_rotations/results_true.dat deleted file mode 100644 index 5c8b83b76..000000000 --- a/tests/regression_tests/filter_rotations/results_true.dat +++ /dev/null @@ -1,244 +0,0 @@ -k-combined: -7.729082E-01 3.775399E-02 -tally 1: -5.296804E-02 -5.661701E-04 -8.356446E-02 -1.412139E-03 -5.041335E-02 -5.143568E-04 -1.299348E-01 -3.467618E-03 -3.929702E-01 -3.147038E-02 -1.379707E-01 -3.888484E-03 -1.405034E-01 -4.473799E-03 -3.785796E-01 -2.940585E-02 -1.422010E-01 -4.113723E-03 -5.647073E-02 -6.735251E-04 -7.911154E-02 -1.329137E-03 -5.160755E-02 -5.361448E-04 -6.669424E-02 -9.090832E-04 -1.008621E-01 -2.134534E-03 -6.808932E-02 -9.355993E-04 -1.873006E-01 -7.135961E-03 -6.221575E-01 -7.819842E-02 -1.856653E-01 -6.954762E-03 -2.014929E-01 -8.327845E-03 -5.853251E-01 -6.945708E-02 -1.709645E-01 -5.917124E-03 -7.214913E-02 -1.058962E-03 -1.027720E-01 -2.138475E-03 -6.099853E-02 -7.493941E-04 -6.892071E-02 -9.630680E-04 -1.035459E-01 -2.173883E-03 -6.973870E-02 -9.904237E-04 -2.125703E-01 -9.112659E-03 -9.012205E-01 -2.163546E-01 -2.066426E-01 -8.617414E-03 -2.258950E-01 -1.039607E-02 -9.476792E-01 -2.350708E-01 -2.225585E-01 -1.017898E-02 -7.111503E-02 -1.036847E-03 -1.117012E-01 -2.530040E-03 -6.870474E-02 -9.551035E-04 -5.738897E-02 -6.699030E-04 -9.522335E-02 -1.835769E-03 -6.570917E-02 -8.656870E-04 -1.945592E-01 -7.593336E-03 -5.514753E-01 -6.122981E-02 -2.144202E-01 -9.421739E-03 -1.971631E-01 -7.944046E-03 -6.088996E-01 -7.442954E-02 -1.965447E-01 -7.765628E-03 -7.005494E-02 -1.012891E-03 -1.010633E-01 -2.084095E-03 -6.145926E-02 -7.694351E-04 -4.999479E-02 -5.129164E-04 -7.238243E-02 -1.062921E-03 -4.902309E-02 -4.852193E-04 -1.324655E-01 -3.642431E-03 -3.305312E-01 -2.265726E-02 -1.332993E-01 -3.728385E-03 -1.547469E-01 -4.894837E-03 -3.625944E-01 -2.747313E-02 -1.435761E-01 -4.334405E-03 -5.789603E-02 -7.065383E-04 -7.589559E-02 -1.205386E-03 -5.210018E-02 -5.790843E-04 -tally 2: -4.597932E-02 -4.246849E-04 -8.494738E-02 -1.467238E-03 -5.155072E-02 -5.373129E-04 -1.479395E-01 -4.468164E-03 -3.931843E-01 -3.141943E-02 -1.264081E-01 -3.243689E-03 -1.229742E-01 -3.276501E-03 -3.768427E-01 -2.927971E-02 -1.574908E-01 -5.079304E-03 -5.621044E-02 -6.877866E-04 -8.490616E-02 -1.510673E-03 -4.709600E-02 -4.576632E-04 -5.382674E-02 -5.890600E-04 -1.116560E-01 -2.599817E-03 -6.648634E-02 -8.862677E-04 -1.996861E-01 -8.137198E-03 -6.218616E-01 -7.805532E-02 -1.672379E-01 -5.667797E-03 -1.841275E-01 -6.936896E-03 -5.887874E-01 -7.031665E-02 -1.872574E-01 -7.086584E-03 -7.574698E-02 -1.160992E-03 -1.100173E-01 -2.453972E-03 -5.427866E-02 -5.955556E-04 -5.644318E-02 -6.503634E-04 -1.058628E-01 -2.254338E-03 -8.012794E-02 -1.297032E-03 -2.292757E-01 -1.064490E-02 -9.001874E-01 -2.153097E-01 -1.921874E-01 -7.537343E-03 -2.058642E-01 -8.537136E-03 -9.442653E-01 -2.359241E-01 -2.419900E-01 -1.202201E-02 -7.563876E-02 -1.169874E-03 -1.165428E-01 -2.750405E-03 -5.646354E-02 -6.408683E-04 -4.963879E-02 -4.975915E-04 -1.005478E-01 -2.046400E-03 -7.041191E-02 -1.002590E-03 -1.959123E-01 -7.727902E-03 -5.625596E-01 -6.366248E-02 -1.987313E-01 -8.108832E-03 -1.922194E-01 -7.602752E-03 -6.062527E-01 -7.384124E-02 -2.039506E-01 -8.379010E-03 -7.019905E-02 -1.034239E-03 -1.081383E-01 -2.344040E-03 -5.125142E-02 -5.430397E-04 -4.230495E-02 -3.666730E-04 -7.722275E-02 -1.208856E-03 -4.998937E-02 -5.049355E-04 -1.461632E-01 -4.456332E-03 -3.315459E-01 -2.288314E-02 -1.238273E-01 -3.205844E-03 -1.355317E-01 -3.754923E-03 -3.646520E-01 -2.766067E-02 -1.543013E-01 -5.044487E-03 -6.082173E-02 -7.636985E-04 -8.490569E-02 -1.506309E-03 -4.046126E-02 -3.495832E-04 diff --git a/tests/regression_tests/filter_rotations/test.py b/tests/regression_tests/filter_rotations/test.py deleted file mode 100644 index f5d63d6b4..000000000 --- a/tests/regression_tests/filter_rotations/test.py +++ /dev/null @@ -1,72 +0,0 @@ -import numpy as np - -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - - model = openmc.model.Model() - - fuel = openmc.Material() - fuel.set_density('g/cm3', 10.0) - fuel.add_nuclide('U235', 1.0) - zr = openmc.Material() - zr.set_density('g/cm3', 1.0) - zr.add_nuclide('Zr90', 1.0) - model.materials.extend([fuel, zr]) - - box1 = openmc.model.RectangularPrism(10.0, 10.0) - box2 = openmc.model.RectangularPrism(20.0, 20.0, boundary_type='reflective') - top = openmc.ZPlane(z0=10.0, boundary_type='vacuum') - bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum') - cell1 = openmc.Cell(fill=fuel, region=-box1 & +bottom & -top) - cell2 = openmc.Cell(fill=zr, region=+box1 & -box2 & +bottom & -top) - model.geometry = openmc.Geometry([cell1, cell2]) - - model.settings.batches = 5 - model.settings.inactive = 0 - model.settings.particles = 1000 - - rotation = np.array((0, 0, 10)) - - llc = np.array([-9, -9, -9]) - urc = np.array([9, 9, 9]) - - mesh_dims = (3, 4, 5) - - filters = [] - - # un-rotated meshes - reg_mesh = openmc.RegularMesh() - reg_mesh.dimension = mesh_dims - reg_mesh.lower_left = llc - reg_mesh.upper_right = urc - - filters.append(openmc.MeshFilter(reg_mesh)) - - # rotated meshes - rotated_reg_mesh = openmc.RegularMesh() - rotated_reg_mesh.dimension = mesh_dims - rotated_reg_mesh.lower_left = llc - rotated_reg_mesh.upper_right = urc - - filters.append(openmc.MeshFilter(rotated_reg_mesh)) - filters[-1].rotation = rotation - - # Create tallies - for f in filters: - tally = openmc.Tally() - tally.filters = [f] - tally.scores = ['total'] - model.tallies.append(tally) - - return model - - -def test_filter_mesh_rotations(model): - harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() diff --git a/tests/regression_tests/filter_translations/inputs_true.dat b/tests/regression_tests/filter_translations/inputs_true.dat index 41ae9b6dc..a80ccd876 100644 --- a/tests/regression_tests/filter_translations/inputs_true.dat +++ b/tests/regression_tests/filter_translations/inputs_true.dat @@ -1,28 +1,28 @@ - - - + + + - - + + - - - - - - - - - - - + + + + + + + + + + + eigenvalue @@ -57,10 +57,10 @@ 2 - + 3 - + 4 diff --git a/tests/regression_tests/filter_translations/results_true.dat b/tests/regression_tests/filter_translations/results_true.dat index a63586d2d..d257d71a6 100644 --- a/tests/regression_tests/filter_translations/results_true.dat +++ b/tests/regression_tests/filter_translations/results_true.dat @@ -1,342 +1,342 @@ k-combined: -7.729082E-01 3.775399E-02 +2.298294E-01 3.256961E-01 tally 1: -5.296804E-02 -5.661701E-04 -8.356446E-02 -1.412139E-03 -5.041335E-02 -5.143568E-04 -1.299348E-01 -3.467618E-03 -3.929702E-01 -3.147038E-02 -1.379707E-01 -3.888484E-03 -1.405034E-01 -4.473799E-03 -3.785796E-01 -2.940585E-02 -1.422010E-01 -4.113723E-03 -5.647073E-02 -6.735251E-04 -7.911154E-02 -1.329137E-03 -5.160755E-02 -5.361448E-04 -6.669424E-02 -9.090832E-04 -1.008621E-01 -2.134534E-03 -6.808932E-02 -9.355993E-04 -1.873006E-01 -7.135961E-03 -6.221575E-01 -7.819842E-02 -1.856653E-01 -6.954762E-03 -2.014929E-01 -8.327845E-03 -5.853251E-01 -6.945708E-02 -1.709645E-01 -5.917124E-03 -7.214913E-02 -1.058962E-03 -1.027720E-01 -2.138475E-03 -6.099853E-02 -7.493941E-04 -6.892071E-02 -9.630680E-04 -1.035459E-01 -2.173883E-03 -6.973870E-02 -9.904237E-04 -2.125703E-01 -9.112659E-03 -9.012205E-01 -2.163546E-01 -2.066426E-01 -8.617414E-03 -2.258950E-01 -1.039607E-02 -9.476792E-01 -2.350708E-01 -2.225585E-01 -1.017898E-02 -7.111503E-02 -1.036847E-03 -1.117012E-01 -2.530040E-03 -6.870474E-02 -9.551035E-04 -5.738897E-02 -6.699030E-04 -9.522335E-02 -1.835769E-03 -6.570917E-02 -8.656870E-04 -1.945592E-01 -7.593336E-03 -5.514753E-01 -6.122981E-02 -2.144202E-01 -9.421739E-03 -1.971631E-01 -7.944046E-03 -6.088996E-01 -7.442954E-02 -1.965447E-01 -7.765628E-03 -7.005494E-02 -1.012891E-03 -1.010633E-01 -2.084095E-03 -6.145926E-02 -7.694351E-04 -4.999479E-02 -5.129164E-04 -7.238243E-02 -1.062921E-03 -4.902309E-02 -4.852193E-04 -1.324655E-01 -3.642431E-03 -3.305312E-01 -2.265726E-02 -1.332993E-01 -3.728385E-03 -1.547469E-01 -4.894837E-03 -3.625944E-01 -2.747313E-02 -1.435761E-01 -4.334405E-03 -5.789603E-02 -7.065383E-04 -7.589559E-02 -1.205386E-03 -5.210018E-02 -5.790843E-04 +4.880089E-02 +4.894233E-04 +8.221192E-02 +1.373712E-03 +5.205261E-02 +5.584673E-04 +1.272758E-01 +3.371623E-03 +3.599375E-01 +2.655645E-02 +1.377572E-01 +3.835778E-03 +1.646205E-01 +5.916595E-03 +3.806765E-01 +2.947576E-02 +1.470573E-01 +4.360385E-03 +5.568294E-02 +6.368003E-04 +6.775790E-02 +9.447074E-04 +5.580909E-02 +6.303584E-04 +6.674847E-02 +9.080853E-04 +9.747628E-02 +1.934325E-03 +6.824062E-02 +9.908844E-04 +1.891692E-01 +7.211874E-03 +5.976566E-01 +7.206211E-02 +1.805640E-01 +6.599680E-03 +2.114692E-01 +9.202185E-03 +6.514433E-01 +8.523087E-02 +1.905740E-01 +7.287607E-03 +7.633486E-02 +1.216488E-03 +1.117747E-01 +2.538705E-03 +7.438042E-02 +1.127109E-03 +7.356007E-02 +1.090617E-03 +1.161258E-01 +2.734941E-03 +6.745417E-02 +9.371031E-04 +2.153323E-01 +9.293477E-03 +9.414362E-01 +2.261845E-01 +2.016933E-01 +8.270477E-03 +2.370758E-01 +1.150628E-02 +9.973982E-01 +2.489516E-01 +2.152505E-01 +9.424546E-03 +7.502684E-02 +1.208304E-03 +1.244515E-01 +3.168682E-03 +7.515812E-02 +1.151397E-03 +6.355178E-02 +8.423316E-04 +1.040915E-01 +2.224064E-03 +6.902234E-02 +9.843766E-04 +1.978591E-01 +7.894161E-03 +5.162186E-01 +5.357742E-02 +1.897326E-01 +7.231935E-03 +1.827950E-01 +6.839560E-03 +5.780661E-01 +6.799910E-02 +1.881215E-01 +7.093746E-03 +6.083700E-02 +7.861240E-04 +9.978991E-02 +2.022733E-03 +6.004653E-02 +7.428556E-04 +4.951220E-02 +4.952385E-04 +7.401227E-02 +1.124154E-03 +5.151090E-02 +5.339359E-04 +1.356118E-01 +3.711749E-03 +3.400140E-01 +2.367518E-02 +1.385305E-01 +4.060592E-03 +1.438711E-01 +4.191824E-03 +3.276170E-01 +2.210924E-02 +1.279501E-01 +3.435254E-03 +4.852204E-02 +4.919417E-04 +7.229090E-02 +1.062894E-03 +4.344414E-02 +3.825354E-04 tally 2: -2.572693E-01 -1.338921E-02 -2.567576E-01 -1.333558E-02 -6.127899E-01 -7.781914E-02 -6.163075E-01 -7.600273E-02 -2.566545E-01 -1.372553E-02 -2.509744E-01 -1.286275E-02 -3.366720E-01 -2.282560E-02 -3.216175E-01 -2.103222E-02 -1.118187E+00 -2.697988E-01 -1.050003E+00 -2.391098E-01 -3.407360E-01 -2.332214E-02 -3.150094E-01 -2.006040E-02 -3.130223E-01 -2.001074E-02 -3.238651E-01 -2.101351E-02 -1.061186E+00 -2.372828E-01 -1.099461E+00 -2.597134E-01 -3.445524E-01 -2.400393E-02 -3.429055E-01 -2.372392E-02 -2.299776E-01 -1.064851E-02 -2.208901E-01 -9.829109E-03 -6.015657E-01 -7.399276E-02 -5.851229E-01 -7.165716E-02 -2.583609E-01 -1.364046E-02 -2.456380E-01 -1.257735E-02 +2.379877E-01 +1.141258E-02 +2.376600E-01 +1.137350E-02 +6.546514E-01 +8.852321E-02 +5.823862E-01 +6.810779E-02 +2.692631E-01 +1.479426E-02 +2.360469E-01 +1.124950E-02 +3.534788E-01 +2.528363E-02 +3.247931E-01 +2.160130E-02 +1.181513E+00 +2.959140E-01 +1.078874E+00 +2.467321E-01 +3.743375E-01 +2.859905E-02 +3.468123E-01 +2.427809E-02 +3.203903E-01 +2.109786E-02 +3.315547E-01 +2.216053E-02 +1.039077E+00 +2.294722E-01 +1.091786E+00 +2.572834E-01 +3.615960E-01 +2.678347E-02 +3.323317E-01 +2.226424E-02 +2.519726E-01 +1.279098E-02 +2.332385E-01 +1.101251E-02 +5.587247E-01 +6.293355E-02 +5.426859E-01 +6.010041E-02 +2.332981E-01 +1.097940E-02 +2.239951E-01 +1.043440E-02 tally 3: -5.296804E-02 -5.661701E-04 -8.356446E-02 -1.412139E-03 -5.041335E-02 -5.143568E-04 -1.299348E-01 -3.467618E-03 -3.929702E-01 -3.147038E-02 -1.379707E-01 -3.888484E-03 -1.405034E-01 -4.473799E-03 -3.785796E-01 -2.940585E-02 -1.422010E-01 -4.113723E-03 -5.647073E-02 -6.735251E-04 -7.911154E-02 -1.329137E-03 -5.160755E-02 -5.361448E-04 -6.669424E-02 -9.090832E-04 -1.008621E-01 -2.134534E-03 -6.808932E-02 -9.355993E-04 -1.873006E-01 -7.135961E-03 -6.221575E-01 -7.819842E-02 -1.856653E-01 -6.954762E-03 -2.014929E-01 -8.327845E-03 -5.853251E-01 -6.945708E-02 -1.709645E-01 -5.917124E-03 -7.214913E-02 -1.058962E-03 -1.027720E-01 -2.138475E-03 -6.099853E-02 -7.493941E-04 -6.892071E-02 -9.630680E-04 -1.035459E-01 -2.173883E-03 -6.973870E-02 -9.904237E-04 -2.125703E-01 -9.112659E-03 -9.012205E-01 -2.163546E-01 -2.066426E-01 -8.617414E-03 -2.258950E-01 -1.039607E-02 -9.476792E-01 -2.350708E-01 -2.225585E-01 -1.017898E-02 -7.111503E-02 -1.036847E-03 -1.117012E-01 -2.530040E-03 -6.870474E-02 -9.551035E-04 -5.738897E-02 -6.699030E-04 -9.522335E-02 -1.835769E-03 -6.570917E-02 -8.656870E-04 -1.945592E-01 -7.593336E-03 -5.514753E-01 -6.122981E-02 -2.144202E-01 -9.421739E-03 -1.971631E-01 -7.944046E-03 -6.088996E-01 -7.442954E-02 -1.965447E-01 -7.765628E-03 -7.005494E-02 -1.012891E-03 -1.010633E-01 -2.084095E-03 -6.145926E-02 -7.694351E-04 -4.999479E-02 -5.129164E-04 -7.238243E-02 -1.062921E-03 -4.902309E-02 -4.852193E-04 -1.324655E-01 -3.642431E-03 -3.305312E-01 -2.265726E-02 -1.332993E-01 -3.728385E-03 -1.547469E-01 -4.894837E-03 -3.625944E-01 -2.747313E-02 -1.435761E-01 -4.334405E-03 -5.789603E-02 -7.065383E-04 -7.589559E-02 -1.205386E-03 -5.210018E-02 -5.790843E-04 +4.880089E-02 +4.894233E-04 +8.221192E-02 +1.373712E-03 +5.205261E-02 +5.584673E-04 +1.272758E-01 +3.371623E-03 +3.599375E-01 +2.655645E-02 +1.377572E-01 +3.835778E-03 +1.646205E-01 +5.916595E-03 +3.806765E-01 +2.947576E-02 +1.470573E-01 +4.360385E-03 +5.568294E-02 +6.368003E-04 +6.775790E-02 +9.447074E-04 +5.580909E-02 +6.303584E-04 +6.674847E-02 +9.080853E-04 +9.747628E-02 +1.934325E-03 +6.824062E-02 +9.908844E-04 +1.891692E-01 +7.211874E-03 +5.976566E-01 +7.206211E-02 +1.805640E-01 +6.599680E-03 +2.114692E-01 +9.202185E-03 +6.514433E-01 +8.523087E-02 +1.905740E-01 +7.287607E-03 +7.633486E-02 +1.216488E-03 +1.117747E-01 +2.538705E-03 +7.438042E-02 +1.127109E-03 +7.356007E-02 +1.090617E-03 +1.161258E-01 +2.734941E-03 +6.745417E-02 +9.371031E-04 +2.153323E-01 +9.293477E-03 +9.414362E-01 +2.261845E-01 +2.016933E-01 +8.270477E-03 +2.370758E-01 +1.150628E-02 +9.973982E-01 +2.489516E-01 +2.152505E-01 +9.424546E-03 +7.502684E-02 +1.208304E-03 +1.244515E-01 +3.168682E-03 +7.515812E-02 +1.151397E-03 +6.355178E-02 +8.423316E-04 +1.040915E-01 +2.224064E-03 +6.902234E-02 +9.843766E-04 +1.978591E-01 +7.894161E-03 +5.162186E-01 +5.357742E-02 +1.897326E-01 +7.231935E-03 +1.827950E-01 +6.839560E-03 +5.780661E-01 +6.799910E-02 +1.881215E-01 +7.093746E-03 +6.083700E-02 +7.861240E-04 +9.978991E-02 +2.022733E-03 +6.004653E-02 +7.428556E-04 +4.951220E-02 +4.952385E-04 +7.401227E-02 +1.124154E-03 +5.151090E-02 +5.339359E-04 +1.356118E-01 +3.711749E-03 +3.400140E-01 +2.367518E-02 +1.385305E-01 +4.060592E-03 +1.438711E-01 +4.191824E-03 +3.276170E-01 +2.210924E-02 +1.279501E-01 +3.435254E-03 +4.852204E-02 +4.919417E-04 +7.229090E-02 +1.062894E-03 +4.344414E-02 +3.825354E-04 tally 4: -2.572693E-01 -1.338921E-02 -2.567576E-01 -1.333558E-02 -6.127899E-01 -7.781914E-02 -6.163075E-01 -7.600273E-02 -2.566545E-01 -1.372553E-02 -2.509744E-01 -1.286275E-02 -3.366720E-01 -2.282560E-02 -3.216175E-01 -2.103222E-02 -1.118187E+00 -2.697988E-01 -1.050003E+00 -2.391098E-01 -3.407360E-01 -2.332214E-02 -3.150094E-01 -2.006040E-02 -3.130223E-01 -2.001074E-02 -3.238651E-01 -2.101351E-02 -1.061186E+00 -2.372828E-01 -1.099461E+00 -2.597134E-01 -3.445524E-01 -2.400393E-02 -3.429055E-01 -2.372392E-02 -2.299776E-01 -1.064851E-02 -2.208901E-01 -9.829109E-03 -6.015657E-01 -7.399276E-02 -5.851229E-01 -7.165716E-02 -2.583609E-01 -1.364046E-02 -2.456380E-01 -1.257735E-02 +2.379877E-01 +1.141258E-02 +2.376600E-01 +1.137350E-02 +6.546514E-01 +8.852321E-02 +5.823862E-01 +6.810779E-02 +2.692631E-01 +1.479426E-02 +2.360469E-01 +1.124950E-02 +3.534788E-01 +2.528363E-02 +3.247931E-01 +2.160130E-02 +1.181513E+00 +2.959140E-01 +1.078874E+00 +2.467321E-01 +3.743375E-01 +2.859905E-02 +3.468123E-01 +2.427809E-02 +3.203903E-01 +2.109786E-02 +3.315547E-01 +2.216053E-02 +1.039077E+00 +2.294722E-01 +1.091786E+00 +2.572834E-01 +3.615960E-01 +2.678347E-02 +3.323317E-01 +2.226424E-02 +2.519726E-01 +1.279098E-02 +2.332385E-01 +1.101251E-02 +5.587247E-01 +6.293355E-02 +5.426859E-01 +6.010041E-02 +2.332981E-01 +1.097940E-02 +2.239951E-01 +1.043440E-02 diff --git a/tests/regression_tests/fixed_source/inputs_true.dat b/tests/regression_tests/fixed_source/inputs_true.dat index a36741775..0fdb1466e 100644 --- a/tests/regression_tests/fixed_source/inputs_true.dat +++ b/tests/regression_tests/fixed_source/inputs_true.dat @@ -1,21 +1,21 @@ - - - - + + + + - + fixed source 100 10 - + 0.0 0.0 0.0 diff --git a/tests/regression_tests/ifp/__init__.py b/tests/regression_tests/ifp/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/ifp/groupwise/__init__.py b/tests/regression_tests/ifp/groupwise/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/ifp/groupwise/inputs_true.dat b/tests/regression_tests/ifp/groupwise/inputs_true.dat deleted file mode 100644 index 6d7e20717..000000000 --- a/tests/regression_tests/ifp/groupwise/inputs_true.dat +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - eigenvalue - 1000 - 20 - 5 - - - -10.0 -10.0 -10.0 10.0 10.0 10.0 - - - true - - - 5 - - - - 1 2 3 4 5 6 - - - ifp-time-numerator - - - 1 - ifp-beta-numerator - - - ifp-denominator - - - diff --git a/tests/regression_tests/ifp/groupwise/results_true.dat b/tests/regression_tests/ifp/groupwise/results_true.dat deleted file mode 100644 index ea66a8de3..000000000 --- a/tests/regression_tests/ifp/groupwise/results_true.dat +++ /dev/null @@ -1,21 +0,0 @@ -k-combined: -1.006559E+00 5.389391E-03 -tally 1: -9.109384E-08 -5.667165E-16 -tally 2: -3.000000E-03 -9.000000E-06 -0.000000E+00 -0.000000E+00 -2.100000E-02 -1.370000E-04 -2.800000E-02 -2.220000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -tally 3: -1.489000E+01 -1.480036E+01 diff --git a/tests/regression_tests/ifp/groupwise/test.py b/tests/regression_tests/ifp/groupwise/test.py deleted file mode 100644 index a1a0ebefb..000000000 --- a/tests/regression_tests/ifp/groupwise/test.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Test the Iterated Fission Probability (IFP) method to compute adjoint-weighted -kinetics parameters using dedicated tallies.""" - -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - -@pytest.fixture() -def ifp_model(): - # Material - material = openmc.Material(name="core") - material.add_nuclide("U235", 1.0) - material.set_density('g/cm3', 16.0) - - # Geometry - radius = 10.0 - sphere = openmc.Sphere(r=radius, boundary_type="vacuum") - cell = openmc.Cell(region=-sphere, fill=material) - geometry = openmc.Geometry([cell]) - - # Settings - settings = openmc.Settings() - settings.particles = 1000 - settings.batches = 20 - settings.inactive = 5 - settings.ifp_n_generation = 5 - - model = openmc.Model(settings=settings, geometry=geometry) - - space = openmc.stats.Box(*cell.bounding_box) - model.settings.source = openmc.IndependentSource( - space=space, constraints={'fissionable': True}) - model.add_kinetics_parameters_tallies(num_groups=6) - return model - - -def test_iterated_fission_probability(ifp_model): - harness = PyAPITestHarness("statepoint.20.h5", model=ifp_model) - harness.main() diff --git a/tests/regression_tests/ifp/total/__init__.py b/tests/regression_tests/ifp/total/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/ifp/total/inputs_true.dat b/tests/regression_tests/ifp/total/inputs_true.dat deleted file mode 100644 index 2d69b29ab..000000000 --- a/tests/regression_tests/ifp/total/inputs_true.dat +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - eigenvalue - 1000 - 20 - 5 - - - -10.0 -10.0 -10.0 10.0 10.0 10.0 - - - true - - - 5 - - - - ifp-time-numerator ifp-beta-numerator ifp-denominator - - - diff --git a/tests/regression_tests/ifp/total/results_true.dat b/tests/regression_tests/ifp/total/results_true.dat deleted file mode 100644 index 466ca1f01..000000000 --- a/tests/regression_tests/ifp/total/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -k-combined: -1.006559E+00 5.389391E-03 -tally 1: -9.109384E-08 -5.667165E-16 -5.200000E-02 -5.420000E-04 -1.489000E+01 -1.480036E+01 diff --git a/tests/regression_tests/ifp/total/test.py b/tests/regression_tests/ifp/total/test.py deleted file mode 100644 index 18b89cfc0..000000000 --- a/tests/regression_tests/ifp/total/test.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Test the Iterated Fission Probability (IFP) method to compute adjoint-weighted -kinetics parameters using dedicated tallies.""" - -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - -@pytest.fixture() -def ifp_model(): - model = openmc.Model() - - # Material - material = openmc.Material(name="core") - material.add_nuclide("U235", 1.0) - material.set_density('g/cm3', 16.0) - - # Geometry - radius = 10.0 - sphere = openmc.Sphere(r=radius, boundary_type="vacuum") - cell = openmc.Cell(region=-sphere, fill=material) - model.geometry = openmc.Geometry([cell]) - - # Settings - model.settings.particles = 1000 - model.settings.batches = 20 - model.settings.inactive = 5 - model.settings.ifp_n_generation = 5 - - space = openmc.stats.Box(*cell.bounding_box) - model.settings.source = openmc.IndependentSource( - space=space, constraints={'fissionable': True}) - - # Tally IFP scores - tally = openmc.Tally(name="ifp-scores") - tally.scores = ["ifp-time-numerator", "ifp-beta-numerator", "ifp-denominator"] - model.tallies = [tally] - - return model - - -def test_iterated_fission_probability(ifp_model): - harness = PyAPITestHarness("statepoint.20.h5", model=ifp_model) - harness.main() diff --git a/tests/regression_tests/infinite_cell/results_true.dat b/tests/regression_tests/infinite_cell/results_true.dat index 4cdbcaf88..2c4ce082d 100644 --- a/tests/regression_tests/infinite_cell/results_true.dat +++ b/tests/regression_tests/infinite_cell/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.603664E-02 1.050772E-03 +9.589951E-02 8.489144E-04 diff --git a/tests/regression_tests/iso_in_lab/inputs_true.dat b/tests/regression_tests/iso_in_lab/inputs_true.dat index adfcf7e51..bb6494ada 100644 --- a/tests/regression_tests/iso_in_lab/inputs_true.dat +++ b/tests/regression_tests/iso_in_lab/inputs_true.dat @@ -1,44 +1,44 @@ - - - - - - - + + + + + + + U234 U235 U238 Xe135 O16 - - - - - - + + + + + + Zr90 Zr91 Zr92 Zr94 Zr96 - - - - - + + + + + H1 O16 B10 B11 - - - - - + + + + + H1 O16 B10 B11 - + @@ -52,7 +52,7 @@ Fe54 Fe56 Fe57 Fe58 Ni58 Ni60 Mn55 Cr52 C0 Cu63 - + @@ -68,7 +68,7 @@ H1 O16 B10 B11 Fe54 Fe56 Fe57 Fe58 Ni58 Mn55 Cr52 - + @@ -84,7 +84,7 @@ H1 O16 B10 B11 Fe54 Fe56 Fe57 Fe58 Ni58 Mn55 Cr52 - + @@ -100,7 +100,7 @@ H1 O16 B10 B11 Fe54 Fe56 Fe57 Fe58 Ni58 Mn55 Cr52 - + @@ -116,7 +116,7 @@ H1 O16 B10 B11 Fe54 Fe56 Fe57 Fe58 Ni58 Mn55 Cr52 - + @@ -132,7 +132,7 @@ H1 O16 B10 B11 Fe54 Fe56 Fe57 Fe58 Ni58 Mn55 Cr52 - + @@ -146,7 +146,7 @@ H1 O16 B10 B11 Zr90 Zr91 Zr92 Zr94 Zr96 - + @@ -161,8 +161,8 @@ - - + + @@ -186,9 +186,9 @@ - + - + 1.26 1.26 17 17 @@ -289,30 +289,30 @@ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + eigenvalue 100 10 5 - + -160 -160 -183 160 160 183 diff --git a/tests/regression_tests/iso_in_lab/results_true.dat b/tests/regression_tests/iso_in_lab/results_true.dat index 0378ec86d..aaef22623 100644 --- a/tests/regression_tests/iso_in_lab/results_true.dat +++ b/tests/regression_tests/iso_in_lab/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.365837E-01 5.366122E-02 +9.015537E-01 1.086850E-01 diff --git a/tests/regression_tests/lattice/results_true.dat b/tests/regression_tests/lattice/results_true.dat index dca84bd6a..f3e937b36 100644 --- a/tests/regression_tests/lattice/results_true.dat +++ b/tests/regression_tests/lattice/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.182679E-01 5.270201E-02 +9.610829E-01 2.522714E-02 diff --git a/tests/regression_tests/lattice_corner_crossing/__init__.py b/tests/regression_tests/lattice_corner_crossing/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/lattice_corner_crossing/inputs_true.dat b/tests/regression_tests/lattice_corner_crossing/inputs_true.dat deleted file mode 100644 index 4b49b1403..000000000 --- a/tests/regression_tests/lattice_corner_crossing/inputs_true.dat +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - 10.0 10.0 - 2 2 - -10.0 -10.0 - -1 2 -2 1 - - - - - - - - - fixed source - 1000 - 10 - - - -0.7071067811865476 -0.7071067811865475 0.0 - - - - - - - 10 10 - -20.0 -20.0 - 20.0 20.0 - - - 1 - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/lattice_corner_crossing/results_true.dat b/tests/regression_tests/lattice_corner_crossing/results_true.dat deleted file mode 100644 index bd81cf535..000000000 --- a/tests/regression_tests/lattice_corner_crossing/results_true.dat +++ /dev/null @@ -1,201 +0,0 @@ -tally 1: -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.648775E-03 -7.016009E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.981847E-03 -8.891414E-06 -3.331677E-03 -1.110007E-05 -6.742237E-03 -4.545776E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.388206E-03 -1.925636E-05 -2.032104E-03 -4.129446E-06 -3.014946E-03 -9.089898E-06 -7.058968E-03 -4.982903E-05 -9.013188E-04 -8.123755E-07 -7.501461E-04 -5.627191E-07 -0.000000E+00 -0.000000E+00 -5.134898E-03 -2.636718E-05 -1.207302E-03 -1.457579E-06 -3.045925E-03 -9.277657E-06 -4.132399E-03 -1.707672E-05 -1.055271E-02 -5.829711E-05 -4.014909E-03 -1.611949E-05 -2.698215E-03 -7.280363E-06 -1.751215E-02 -1.073504E-04 -1.356908E-02 -9.589157E-05 -5.451466E-03 -2.971848E-05 -3.165676E-04 -1.002151E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.724938E-03 -1.387516E-05 -2.812863E-03 -7.278837E-06 -1.000700E+01 -1.001402E+01 -2.345904E-02 -2.127641E-04 -2.451653E-02 -1.750725E-04 -8.695904E-03 -5.553981E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.947565E-03 -2.447840E-05 -1.725721E-02 -8.878803E-05 -5.656444E+01 -3.199538E+02 -2.159961E-02 -1.034364E-04 -3.091063E-02 -5.543317E-04 -4.232209E-03 -1.791159E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.716170E-03 -2.224226E-05 -1.321855E-02 -5.288265E-05 -5.309576E-02 -7.984865E-04 -5.656179E+01 -3.199238E+02 -2.399311E-02 -2.936670E-04 -4.680753E-02 -9.526509E-04 -1.074699E-02 -1.154978E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.526425E-03 -2.048853E-05 -3.983003E-03 -9.553596E-06 -1.726789E-02 -9.579848E-05 -3.355605E-02 -3.331438E-04 -3.578422E-02 -3.560242E-04 -5.649209E+01 -3.191358E+02 -2.591495E-02 -4.169753E-04 -9.484744E-03 -8.065715E-05 -0.000000E+00 -0.000000E+00 -4.232587E-03 -9.113263E-06 -5.787378E-03 -2.194940E-05 -6.193626E-03 -2.357423E-05 -4.552787E-03 -6.987360E-06 -9.641308E-03 -3.506339E-05 -1.303892E-02 -4.378408E-05 -1.831744E-02 -8.836683E-05 -3.024725E+01 -9.148969E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.488204E-03 -2.214752E-06 -5.067487E-03 -1.520987E-05 -7.550927E-03 -2.993991E-05 -3.215559E-03 -1.033982E-05 -4.258525E-03 -1.205064E-05 -2.115487E-03 -4.475286E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 diff --git a/tests/regression_tests/lattice_corner_crossing/test.py b/tests/regression_tests/lattice_corner_crossing/test.py deleted file mode 100644 index 4684d144e..000000000 --- a/tests/regression_tests/lattice_corner_crossing/test.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -This test is designed to ensure that we account for potential corner crossings -in floating point precision. - -""" - -from math import pi, cos, sin - -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - model = openmc.Model() - - # Length of lattice on each side - lat_size = 20.0 - - # Angle that we're crossing the corner at - phi = pi/4.0 - - air = openmc.Material() - air.set_density('g/cm3', 0.001) - air.add_nuclide('N14', 1.0) - metal = openmc.Material() - metal.set_density('g/cm3', 7.0) - metal.add_nuclide('Fe56', 1.0) - - metal_cell = openmc.Cell(fill=metal) - metal_uni = openmc.Universe(cells=[metal_cell]) - - air_cell = openmc.Cell(fill=air) - air_uni = openmc.Universe(cells=[air_cell]) - - # Define a checkerboard lattice - lattice = openmc.RectLattice() - lattice.lower_left = (-lat_size/2.0, -lat_size/2.0) - lattice.pitch = (lat_size/2, lat_size/2) - lattice.universes = [ - [metal_uni, air_uni], - [air_uni, metal_uni] - ] - - box = openmc.model.RectangularPrism(lat_size, lat_size) - cyl = openmc.ZCylinder(r=lat_size, boundary_type='vacuum') - outside_lattice = openmc.Cell(region=-cyl & +box, fill=air) - inside_lattice = openmc.Cell(region=-box, fill=lattice) - - model.geometry = openmc.Geometry([outside_lattice, inside_lattice]) - - # Set all runtime parameters - model.settings.run_mode = 'fixed source' - model.settings.batches = 10 - model.settings.particles = 1000 - - # Define a source located outside the lattice and pointing straight into its - # corner at 45 degrees - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Point((-cos(phi), -sin(phi), 0.0)), - angle=openmc.stats.Monodirectional((cos(phi), sin(phi), 0.0)) - ) - - # Create a mesh tally - mesh = openmc.RegularMesh() - mesh.dimension = (10, 10) - mesh.lower_left = (-lat_size, -lat_size) - mesh.upper_right = (lat_size, lat_size) - mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally(tally_id=1) - tally.filters = [mesh_filter] - tally.scores = ['flux'] - tally.estimator = 'tracklength' - model.tallies = [tally] - - return model - - -def test_lattice_corner_crossing(model): - harness = PyAPITestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/lattice_distribmat/False/inputs_true.dat b/tests/regression_tests/lattice_distribmat/False/inputs_true.dat deleted file mode 100644 index 783989057..000000000 --- a/tests/regression_tests/lattice_distribmat/False/inputs_true.dat +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - 1.0 1.0 - 1 - 1 1 - -1.0 -1.0 - -1 - - - 1.0 1.0 - 1 - 1 1 - -1.0 0 - -1 - - - 1.0 1.0 - 1 - 1 1 - 0 -1.0 - -1 - - - 1.0 1.0 - 1 - 1 1 - 0 0 - -1 - - - - - - - - - - - - - - - eigenvalue - 1000 - 10 - 5 - - diff --git a/tests/regression_tests/lattice_distribmat/False/results_true.dat b/tests/regression_tests/lattice_distribmat/False/results_true.dat deleted file mode 100644 index 9ebbb43b8..000000000 --- a/tests/regression_tests/lattice_distribmat/False/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.848895E+00 1.480242E-02 diff --git a/tests/regression_tests/lattice_distribmat/True/inputs_true.dat b/tests/regression_tests/lattice_distribmat/True/inputs_true.dat deleted file mode 100644 index ab827dfde..000000000 --- a/tests/regression_tests/lattice_distribmat/True/inputs_true.dat +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 2 3 4 - - - 5 6 7 8 - - - - - - - - 1.0 1.0 - 8 - 1 1 - -1.0 -1.0 - -8 - - - 1.0 1.0 - 8 - 1 1 - -1.0 0 - -8 - - - 1.0 1.0 - 8 - 1 1 - 0 -1.0 - -8 - - - 1.0 1.0 - 8 - 1 1 - 0 0 - -8 - - - - - - - - - - - - - - - eigenvalue - 1000 - 10 - 5 - - diff --git a/tests/regression_tests/lattice_distribmat/True/results_true.dat b/tests/regression_tests/lattice_distribmat/True/results_true.dat deleted file mode 100644 index 9ebbb43b8..000000000 --- a/tests/regression_tests/lattice_distribmat/True/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.848895E+00 1.480242E-02 diff --git a/tests/regression_tests/lattice_distribmat/__init__.py b/tests/regression_tests/lattice_distribmat/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/lattice_distribmat/test.py b/tests/regression_tests/lattice_distribmat/test.py deleted file mode 100644 index 4d0b6e156..000000000 --- a/tests/regression_tests/lattice_distribmat/test.py +++ /dev/null @@ -1,83 +0,0 @@ -import numpy as np -import openmc -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - model = openmc.model.Model() - - uo2 = openmc.Material(name='UO2') - uo2.set_density('g/cm3', 10.0) - uo2.add_nuclide('U235', 1.0) - uo2.add_nuclide('O16', 2.0) - water = openmc.Material(name='light water') - water.add_nuclide('H1', 2.0) - water.add_nuclide('O16', 1.0) - water.set_density('g/cm3', 1.0) - water.add_s_alpha_beta('c_H_in_H2O') - model.materials.extend([uo2, water]) - - cyl = openmc.ZCylinder(r=0.4) - pin = openmc.model.pin([cyl], [uo2, water]) - d = 1.0 - - lattice00 = openmc.RectLattice() - lattice00.lower_left = (-d, -d) - lattice00.pitch = (d, d) - lattice00.outer = pin - lattice00.universes = [[pin]] - box00 = openmc.model.RectangularPrism(d, d, origin=(-d/2,-d/2)) - - lattice01 = openmc.RectLattice() - lattice01.lower_left = (-d, 0) - lattice01.pitch = (d, d) - lattice01.outer = pin - lattice01.universes = [[pin]] - box01 = openmc.model.RectangularPrism(d, d, origin=(-d/2,d/2)) - - lattice10 = openmc.RectLattice() - lattice10.lower_left = (0, -d) - lattice10.pitch = (d, d) - lattice10.outer = pin - lattice10.universes = [[pin]] - box10 = openmc.model.RectangularPrism(d, d, origin=(d/2,-d/2)) - - lattice11 = openmc.RectLattice() - lattice11.lower_left = (0, 0) - lattice11.pitch = (d, d) - lattice11.outer = pin - lattice11.universes = [[pin]] - box11 = openmc.model.RectangularPrism(d, d, origin=(d/2,d/2)) - - - cell00 = openmc.Cell(fill=lattice00, region = -box00) - cell01 = openmc.Cell(fill=lattice01, region = -box01) - cell10 = openmc.Cell(fill=lattice10, region = -box10) - cell11 = openmc.Cell(fill=lattice11, region = -box11) - - univ = openmc.Universe(cells=[cell00, cell01, cell10, cell11]) - - box = openmc.model.RectangularPrism(2*d, 2*d, boundary_type='reflective') - - main_cell = openmc.Cell(fill=univ, region=-box) - model.geometry = openmc.Geometry([main_cell]) - model.geometry.merge_surfaces = True - - model.settings.batches = 10 - model.settings.inactive = 5 - model.settings.particles = 1000 - - return model - -@pytest.mark.parametrize("distribmat", [False, True]) -def test_lattice(model, distribmat): - with change_directory(str(distribmat)): - openmc.reset_auto_ids() - if distribmat: - model.differentiate_mats(depletable_only=False) - harness = PyAPITestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/lattice_distribrho/__init__.py b/tests/regression_tests/lattice_distribrho/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/lattice_distribrho/inputs_true.dat b/tests/regression_tests/lattice_distribrho/inputs_true.dat deleted file mode 100644 index 99994af3d..000000000 --- a/tests/regression_tests/lattice_distribrho/inputs_true.dat +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - 10.0 20.0 10.0 20.0 - - - - - 1.0 1.0 - 2 2 - -1.0 -1.0 - -1 1 -1 1 - - - - - - - - - eigenvalue - 1000 - 10 - 5 - - diff --git a/tests/regression_tests/lattice_distribrho/results_true.dat b/tests/regression_tests/lattice_distribrho/results_true.dat deleted file mode 100644 index f7f3da8e6..000000000 --- a/tests/regression_tests/lattice_distribrho/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.900249E+00 8.157834E-03 diff --git a/tests/regression_tests/lattice_distribrho/test.py b/tests/regression_tests/lattice_distribrho/test.py deleted file mode 100644 index ec94fe96b..000000000 --- a/tests/regression_tests/lattice_distribrho/test.py +++ /dev/null @@ -1,51 +0,0 @@ -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - model = openmc.Model() - - uo2 = openmc.Material(name='UO2') - uo2.set_density('g/cm3', 10.0) - uo2.add_nuclide('U235', 1.0) - uo2.add_nuclide('O16', 2.0) - water = openmc.Material(name='light water') - water.add_nuclide('H1', 2.0) - water.add_nuclide('O16', 1.0) - water.set_density('g/cm3', 1.0) - water.add_s_alpha_beta('c_H_in_H2O') - model.materials.extend([uo2, water]) - - cyl = openmc.ZCylinder(r=0.4) - pin = openmc.model.pin([cyl], [uo2, water]) - d = 1.0 - - lattice = openmc.RectLattice() - lattice.lower_left = (-d, -d) - lattice.pitch = (d, d) - lattice.universes = [[pin, pin], - [pin, pin]] - box = openmc.model.RectangularPrism( - 2.0 * d, 2.0 * d, - origin=(0.0, 0.0), - boundary_type='reflective' - ) - - pin.cells[1].density = [10.0, 20.0, 10.0, 20.0] - - model.geometry = openmc.Geometry([openmc.Cell(fill=lattice, region=-box)]) - model.geometry.merge_surfaces = True - - model.settings.batches = 10 - model.settings.inactive = 5 - model.settings.particles = 1000 - - return model - - -def test_lattice_checkerboard(model): - harness = PyAPITestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/lattice_hex/results_true.dat b/tests/regression_tests/lattice_hex/results_true.dat index 46db641eb..789bacc40 100644 --- a/tests/regression_tests/lattice_hex/results_true.dat +++ b/tests/regression_tests/lattice_hex/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.595598E-01 9.089294E-03 +2.566607E-01 9.207770E-03 diff --git a/tests/regression_tests/lattice_hex_coincident/inputs_true.dat b/tests/regression_tests/lattice_hex_coincident/inputs_true.dat index fafc03da1..ac82de0ad 100644 --- a/tests/regression_tests/lattice_hex_coincident/inputs_true.dat +++ b/tests/regression_tests/lattice_hex_coincident/inputs_true.dat @@ -1,45 +1,45 @@ - + - + - - + + - - - - - + + + + + - - + + - - - - - + + + + + - - - - + + + + - - + + 1.4 3
0.0 0.0
@@ -50,25 +50,25 @@ 2 2 2
- - - - - - - - - - - - + + + + + + + + + + + +
eigenvalue 1000 5 2 - + -0.9899494936611666 -0.9899494936611666 0.0 0.9899494936611666 0.9899494936611666 10.0 diff --git a/tests/regression_tests/lattice_hex_coincident/results_true.dat b/tests/regression_tests/lattice_hex_coincident/results_true.dat index c798b66e4..c134e123f 100644 --- a/tests/regression_tests/lattice_hex_coincident/results_true.dat +++ b/tests/regression_tests/lattice_hex_coincident/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.931086E+00 5.968486E-02 +1.917792E+00 4.329425E-02 diff --git a/tests/regression_tests/lattice_hex_x/inputs_true.dat b/tests/regression_tests/lattice_hex_x/inputs_true.dat index b6536c6a8..252fbfc0b 100644 --- a/tests/regression_tests/lattice_hex_x/inputs_true.dat +++ b/tests/regression_tests/lattice_hex_x/inputs_true.dat @@ -1,32 +1,32 @@ - + - - - + + + - - - - + + + + - - - + + + - - - - - + + + + + @@ -42,8 +42,8 @@ - - + + 1.235 5.0 4
0.0 0.0 5.0
@@ -91,29 +91,29 @@ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
eigenvalue 1000 10 5 - + -13.62546635287517 -13.62546635287517 0.0 13.62546635287517 13.62546635287517 10.0 diff --git a/tests/regression_tests/lattice_hex_x/results_true.dat b/tests/regression_tests/lattice_hex_x/results_true.dat index 44f947283..174dc70cd 100644 --- a/tests/regression_tests/lattice_hex_x/results_true.dat +++ b/tests/regression_tests/lattice_hex_x/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.326294E+00 1.193578E-02 +1.367975E+00 2.264887E-02 diff --git a/tests/regression_tests/lattice_large_pitch/__init__.py b/tests/regression_tests/lattice_large_pitch/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/lattice_large_pitch/inputs_true.dat b/tests/regression_tests/lattice_large_pitch/inputs_true.dat deleted file mode 100644 index 4dd4f0bd7..000000000 --- a/tests/regression_tests/lattice_large_pitch/inputs_true.dat +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - 100.0 100.0 - 2 - 3 3 - -150.0 -150.0 - -1 2 1 -2 1 2 -1 2 1 - - - - - - - - fixed source - 1000 - 10 - - - - 6 6 - -150.0 -150.0 - 150.0 150.0 - - - 1 - - - 1 - flux - - - diff --git a/tests/regression_tests/lattice_large_pitch/results_true.dat b/tests/regression_tests/lattice_large_pitch/results_true.dat deleted file mode 100644 index 58c4e306d..000000000 --- a/tests/regression_tests/lattice_large_pitch/results_true.dat +++ /dev/null @@ -1,73 +0,0 @@ -tally 1: -1.749265E+01 -3.275925E+01 -4.159430E+01 -1.799568E+02 -7.027454E+01 -4.967568E+02 -6.789716E+01 -4.652258E+02 -4.272935E+01 -1.861129E+02 -2.073342E+01 -4.374279E+01 -4.028297E+01 -1.641642E+02 -6.734263E+01 -4.627171E+02 -1.037657E+02 -1.078682E+03 -1.108394E+02 -1.240927E+03 -7.236770E+01 -5.302034E+02 -4.356361E+01 -1.921990E+02 -6.731536E+01 -4.615977E+02 -9.850684E+01 -9.810272E+02 -5.164863E+02 -2.670336E+04 -5.097770E+02 -2.604770E+04 -1.064847E+02 -1.137536E+03 -7.052986E+01 -5.003220E+02 -7.065046E+01 -5.036723E+02 -1.044890E+02 -1.103250E+03 -5.121544E+02 -2.632389E+04 -5.065331E+02 -2.570752E+04 -1.044794E+02 -1.101249E+03 -6.569142E+01 -4.361120E+02 -4.739812E+01 -2.313289E+02 -7.402284E+01 -5.591689E+02 -1.066905E+02 -1.149521E+03 -1.038665E+02 -1.086813E+03 -7.160008E+01 -5.217744E+02 -4.219705E+01 -1.816100E+02 -2.089838E+01 -4.464899E+01 -4.154271E+01 -1.745866E+02 -7.081253E+01 -5.049997E+02 -6.673273E+01 -4.509038E+02 -4.184624E+01 -1.771546E+02 -1.853898E+01 -3.538608E+01 diff --git a/tests/regression_tests/lattice_large_pitch/test.py b/tests/regression_tests/lattice_large_pitch/test.py deleted file mode 100644 index 0f409badd..000000000 --- a/tests/regression_tests/lattice_large_pitch/test.py +++ /dev/null @@ -1,70 +0,0 @@ -"""Regression test for rectangular lattices with large pitch values. - -Large pitches used to trigger a segmentation fault in ``RectLattice::distance`` -because the boundary-crossing check compared a reconstructed crossing position -against an absolute tolerance that did not scale with the geometry (see #3852). -This test transports particles across a lattice with a large pitch to ensure the -crossing logic remains robust. - -""" - -import openmc -import pytest - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - model = openmc.Model() - - # Large pitch that previously caused floating-point cancellation - pitch = 100.0 - n = 3 - - air = openmc.Material() - air.set_density('g/cm3', 0.001) - air.add_nuclide('N14', 1.0) - metal = openmc.Material() - metal.set_density('g/cm3', 7.0) - metal.add_nuclide('Fe56', 1.0) - - metal_cell = openmc.Cell(fill=metal) - metal_uni = openmc.Universe(cells=[metal_cell]) - air_cell = openmc.Cell(fill=air) - air_uni = openmc.Universe(cells=[air_cell]) - - lattice = openmc.RectLattice() - lattice.lower_left = (-pitch*n/2, -pitch*n/2) - lattice.pitch = (pitch, pitch) - lattice.outer = air_uni - lattice.universes = [ - [metal_uni, air_uni, metal_uni], - [air_uni, metal_uni, air_uni], - [metal_uni, air_uni, metal_uni], - ] - - box = openmc.model.RectangularPrism(pitch*n, pitch*n, boundary_type='vacuum') - root_cell = openmc.Cell(region=-box, fill=lattice) - model.geometry = openmc.Geometry([root_cell]) - - model.settings.run_mode = 'fixed source' - model.settings.batches = 10 - model.settings.particles = 1000 - - mesh = openmc.RegularMesh() - mesh.dimension = (6, 6) - mesh.lower_left = (-pitch*n/2, -pitch*n/2) - mesh.upper_right = (pitch*n/2, pitch*n/2) - mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally(tally_id=1) - tally.filters = [mesh_filter] - tally.scores = ['flux'] - model.tallies = [tally] - - return model - - -def test_lattice_large_pitch(model): - harness = PyAPITestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/lattice_multiple/inputs_true.dat b/tests/regression_tests/lattice_multiple/inputs_true.dat index 06abef582..b249d97c4 100644 --- a/tests/regression_tests/lattice_multiple/inputs_true.dat +++ b/tests/regression_tests/lattice_multiple/inputs_true.dat @@ -1,15 +1,15 @@ - - - - + + + + - - - + + + @@ -18,8 +18,8 @@ - - + + 1.2 1.2 1 @@ -37,12 +37,12 @@ 4 4 4 4 - - - - - - + + + + + + eigenvalue diff --git a/tests/regression_tests/lattice_multiple/results_true.dat b/tests/regression_tests/lattice_multiple/results_true.dat index 0866932d2..7a06551bd 100644 --- a/tests/regression_tests/lattice_multiple/results_true.dat +++ b/tests/regression_tests/lattice_multiple/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.843982E+00 5.815875E-03 +1.859911E+00 8.282311E-03 diff --git a/tests/regression_tests/lattice_rotated/inputs_true.dat b/tests/regression_tests/lattice_rotated/inputs_true.dat index e53b93f93..1b7c74870 100644 --- a/tests/regression_tests/lattice_rotated/inputs_true.dat +++ b/tests/regression_tests/lattice_rotated/inputs_true.dat @@ -1,18 +1,18 @@ - - - + + + - - - + + + - - - + + + @@ -22,8 +22,8 @@ - - + + 1.25 @@ -51,18 +51,18 @@ 1 1 1 1 1 1 1 1 - - - - - + + + + + eigenvalue 1000 5 0 - + 0.0 0.0 0.0 diff --git a/tests/regression_tests/lattice_rotated/results_true.dat b/tests/regression_tests/lattice_rotated/results_true.dat index 9a96a9259..eeaa268fb 100644 --- a/tests/regression_tests/lattice_rotated/results_true.dat +++ b/tests/regression_tests/lattice_rotated/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.515246E-01 2.358354E-02 +4.426784E-01 6.627506E-03 diff --git a/tests/regression_tests/mg_basic/inputs_true.dat b/tests/regression_tests/mg_basic/inputs_true.dat index aa2c2fa0a..8c6faaf07 100644 --- a/tests/regression_tests/mg_basic/inputs_true.dat +++ b/tests/regression_tests/mg_basic/inputs_true.dat @@ -3,29 +3,29 @@ 2g.h5 - + - + - + - + - + - - + + @@ -35,20 +35,20 @@ - - - - - - - + + + + + + + eigenvalue 1000 10 5 - + 0.0 -1000.0 -1000.0 154.90833333333333 1000.0 1000.0 diff --git a/tests/regression_tests/mg_basic/results_true.dat b/tests/regression_tests/mg_basic/results_true.dat index 16980732d..15a9f2186 100644 --- a/tests/regression_tests/mg_basic/results_true.dat +++ b/tests/regression_tests/mg_basic/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.004679E+00 1.329350E-02 +1.009864E+00 1.107115E-02 diff --git a/tests/regression_tests/mg_basic_delayed/inputs_true.dat b/tests/regression_tests/mg_basic_delayed/inputs_true.dat index cc3f2cfb2..e0bcad15c 100644 --- a/tests/regression_tests/mg_basic_delayed/inputs_true.dat +++ b/tests/regression_tests/mg_basic_delayed/inputs_true.dat @@ -3,27 +3,27 @@ 2g.h5 - + - + - + - + - + - + @@ -34,20 +34,20 @@ - - - - - - - + + + + + + + eigenvalue 1000 10 5 - + 0.0 -1000.0 -1000.0 154.90833333333333 1000.0 1000.0 diff --git a/tests/regression_tests/mg_basic_delayed/results_true.dat b/tests/regression_tests/mg_basic_delayed/results_true.dat index f150030b9..6f7c79c1b 100644 --- a/tests/regression_tests/mg_basic_delayed/results_true.dat +++ b/tests/regression_tests/mg_basic_delayed/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.017078E+00 1.181139E-02 +1.024610E+00 9.643746E-03 diff --git a/tests/regression_tests/mg_convert/inputs_true.dat b/tests/regression_tests/mg_convert/inputs_true.dat index 3b1f511e6..4e51ec80c 100644 --- a/tests/regression_tests/mg_convert/inputs_true.dat +++ b/tests/regression_tests/mg_convert/inputs_true.dat @@ -3,23 +3,23 @@ mgxs.h5 - + - - - - - + + + + + eigenvalue 100 10 5 - + -5 -5 -5 5 5 5 diff --git a/tests/regression_tests/mg_convert/results_true.dat b/tests/regression_tests/mg_convert/results_true.dat index f8f748cc7..ff3d7bb91 100644 --- a/tests/regression_tests/mg_convert/results_true.dat +++ b/tests/regression_tests/mg_convert/results_true.dat @@ -1,24 +1,24 @@ k-combined: -9.926427E-01 3.067527E-03 +9.984888E-01 1.558301E-03 k-combined: -9.932868E-01 2.780271E-03 +1.001035E+00 7.622447E-04 k-combined: -9.926427E-01 3.067527E-03 +9.984888E-01 1.558301E-03 k-combined: -1.000000E+00 0.000000E+00 +9.991101E-01 2.776191E-03 k-combined: -9.902969E-01 1.654717E-02 +9.965954E-01 5.185046E-03 k-combined: -9.882796E-01 1.929843E-03 +9.987613E-01 4.806845E-04 k-combined: -1.000000E+00 0.000000E+00 +9.991101E-01 2.776191E-03 k-combined: -9.902953E-01 1.654291E-02 +9.965954E-01 5.185315E-03 k-combined: -9.882814E-01 1.927488E-03 +9.987610E-01 4.791528E-04 k-combined: -9.893153E-01 7.576652E-03 +9.944808E-01 4.458524E-03 k-combined: -9.926427E-01 3.067527E-03 +9.984888E-01 1.558301E-03 k-combined: -9.926427E-01 3.067527E-03 +9.984888E-01 1.558301E-03 diff --git a/tests/regression_tests/mg_convert/test.py b/tests/regression_tests/mg_convert/test.py index 0e50f3a74..8099c89a2 100755 --- a/tests/regression_tests/mg_convert/test.py +++ b/tests/regression_tests/mg_convert/test.py @@ -1,4 +1,3 @@ -from math import isnan import os import hashlib @@ -143,13 +142,10 @@ class MGXSTestHarness(PyAPITestHarness): openmc.run(openmc_exec=config['exe']) with openmc.StatePoint('statepoint.{}.h5'.format(batches)) as sp: - # Sometimes NaN results are produced; convert these to 0.0 - std_dev = 0.0 if isnan(sp.keff.s) else sp.keff.s - # Write out k-combined. outstr += 'k-combined:\n' form = '{:12.6E} {:12.6E}\n' - outstr += form.format(sp.keff.n, std_dev) + outstr += form.format(sp.keff.n, sp.keff.s) return outstr diff --git a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/__init__.py b/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/inputs_true.dat b/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/inputs_true.dat deleted file mode 100644 index 318fdc7b9..000000000 --- a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/inputs_true.dat +++ /dev/null @@ -1,65 +0,0 @@ - - - - 2g.h5 - - - - - - - - - - - - fixed source - 100 - 2 - 0 - - - 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0 - - - - false - - multi-group - - false - - true - - 1 - neutron - 0.0 0.625 20000000.0 - 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 - 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 - 3.0 - 10 - 1e-38 - - - 5 1 1 - 0.0 -1000.0 -1000.0 - 929.45 1000.0 1000.0 - - true - 100 - - - - 5 1 1 - 0.0 -1000.0 -1000.0 - 929.45 1000.0 1000.0 - - - 2 - - - 1 - flux - - - diff --git a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/results_true.dat b/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/results_true.dat deleted file mode 100644 index 38ff94417..000000000 --- a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/results_true.dat +++ /dev/null @@ -1,11 +0,0 @@ -tally 1: -1.765369E+04 -3.087787E+08 -1.708316E+04 -2.842002E+08 -9.444106E+03 -7.488341E+07 -2.066528E+03 -2.142445E+06 -8.689619E+02 -5.652099E+05 diff --git a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/test.py b/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/test.py deleted file mode 100644 index 336c8461f..000000000 --- a/tests/regression_tests/mg_fixed_source_ww_fission_shared_secondary/test.py +++ /dev/null @@ -1,91 +0,0 @@ -import os - -import numpy as np -import openmc -from openmc.examples import slab_mg - -from tests.testing_harness import PyAPITestHarness - - -def create_library(): - # Instantiate the energy group data and file object - groups = openmc.mgxs.EnergyGroups([0.0, 0.625, 20.0e6]) - - mg_cross_sections_file = openmc.MGXSLibrary(groups) - - # Make the base, isotropic data - nu = [2.50, 2.50] - fiss = np.array([0.002817, 0.097]) - capture = [0.008708, 0.02518] - absorption = np.add(capture, fiss) - scatter = np.array( - [[[0.31980, 0.06694], [0.004555, -0.0003972]], - [[0.00000, 0.00000], [0.424100, 0.05439000]]]) - total = [0.33588, 0.54628] - chi = [1., 0.] - - mat_1 = openmc.XSdata('mat_1', groups) - mat_1.order = 1 - mat_1.set_nu_fission(np.multiply(nu, fiss)) - mat_1.set_absorption(absorption) - mat_1.set_scatter_matrix(scatter) - mat_1.set_total(total) - mat_1.set_chi(chi) - mg_cross_sections_file.add_xsdata(mat_1) - - # Write the file - mg_cross_sections_file.export_to_hdf5('2g.h5') - - -class MGXSTestHarness(PyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = '2g.h5' - if os.path.exists(f): - os.remove(f) - - -def test_mg_fixed_source_ww_fission_shared_secondary(): - create_library() - model = slab_mg() - - # Override settings for fixed-source mode with shared secondary bank - model.settings.run_mode = 'fixed source' - model.settings.inactive = 0 - model.settings.batches = 2 - model.settings.particles = 100 - model.settings.create_fission_neutrons = True - model.settings.shared_secondary_bank = True - model.settings.max_history_splits = 100 - - # Add weight windows on a simple 1D mesh - ww_mesh = openmc.RegularMesh() - ww_mesh.lower_left = (0.0, -1000.0, -1000.0) - ww_mesh.upper_right = (929.45, 1000.0, 1000.0) - ww_mesh.dimension = (5, 1, 1) - - # Uniform lower bounds for 2 energy groups, 5 spatial bins - lower_bounds = np.full((2, 5, 1, 1), 0.5) - ww = openmc.WeightWindows( - ww_mesh, - lower_bounds.flatten(), - None, - 5.0, - [0.0, 0.625, 20.0e6], - 'neutron' - ) - model.settings.weight_windows = [ww] - - # Add a flux tally - mesh = openmc.RegularMesh() - mesh.lower_left = (0.0, -1000.0, -1000.0) - mesh.upper_right = (929.45, 1000.0, 1000.0) - mesh.dimension = (5, 1, 1) - - tally = openmc.Tally() - tally.filters = [openmc.MeshFilter(mesh)] - tally.scores = ['flux'] - model.tallies = [tally] - - harness = MGXSTestHarness('statepoint.2.h5', model) - harness.main() diff --git a/tests/regression_tests/mg_legendre/inputs_true.dat b/tests/regression_tests/mg_legendre/inputs_true.dat index 81362f20a..34ff7b630 100644 --- a/tests/regression_tests/mg_legendre/inputs_true.dat +++ b/tests/regression_tests/mg_legendre/inputs_true.dat @@ -3,21 +3,21 @@ 2g.h5 - + - - + + eigenvalue 1000 10 5 - + 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0 diff --git a/tests/regression_tests/mg_legendre/results_true.dat b/tests/regression_tests/mg_legendre/results_true.dat index 04d9c9874..e2989469c 100644 --- a/tests/regression_tests/mg_legendre/results_true.dat +++ b/tests/regression_tests/mg_legendre/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.009220E+00 9.571832E-03 +1.003646E+00 9.134747E-03 diff --git a/tests/regression_tests/mg_max_order/inputs_true.dat b/tests/regression_tests/mg_max_order/inputs_true.dat index c8f42d1a3..b6d70dc4c 100644 --- a/tests/regression_tests/mg_max_order/inputs_true.dat +++ b/tests/regression_tests/mg_max_order/inputs_true.dat @@ -3,21 +3,21 @@ 2g.h5 - + - - + + eigenvalue 1000 10 5 - + 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0 diff --git a/tests/regression_tests/mg_max_order/results_true.dat b/tests/regression_tests/mg_max_order/results_true.dat index 04d9c9874..e2989469c 100644 --- a/tests/regression_tests/mg_max_order/results_true.dat +++ b/tests/regression_tests/mg_max_order/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.009220E+00 9.571832E-03 +1.003646E+00 9.134747E-03 diff --git a/tests/regression_tests/mg_survival_biasing/inputs_true.dat b/tests/regression_tests/mg_survival_biasing/inputs_true.dat index bee69729d..6529c60d8 100644 --- a/tests/regression_tests/mg_survival_biasing/inputs_true.dat +++ b/tests/regression_tests/mg_survival_biasing/inputs_true.dat @@ -3,21 +3,21 @@ 2g.h5 - + - - + + eigenvalue 1000 10 5 - + 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0 diff --git a/tests/regression_tests/mg_survival_biasing/results_true.dat b/tests/regression_tests/mg_survival_biasing/results_true.dat index 4b26978ad..cddbdaceb 100644 --- a/tests/regression_tests/mg_survival_biasing/results_true.dat +++ b/tests/regression_tests/mg_survival_biasing/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.889968E-01 9.144186E-03 +9.878738E-01 8.326224E-03 diff --git a/tests/regression_tests/mg_tallies/inputs_true.dat b/tests/regression_tests/mg_tallies/inputs_true.dat index f4f154244..c526b65a2 100644 --- a/tests/regression_tests/mg_tallies/inputs_true.dat +++ b/tests/regression_tests/mg_tallies/inputs_true.dat @@ -3,21 +3,21 @@ 2g.h5 - + - - + + eigenvalue 1000 10 5 - + 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0 diff --git a/tests/regression_tests/mg_tallies/results_true.dat b/tests/regression_tests/mg_tallies/results_true.dat index c1591cca2..7484dd248 100644 --- a/tests/regression_tests/mg_tallies/results_true.dat +++ b/tests/regression_tests/mg_tallies/results_true.dat @@ -1,1324 +1,1324 @@ k-combined: -1.012390E+00 9.679132E-03 +1.003646E+00 9.134747E-03 tally 1: -1.342000E+00 -4.291640E-01 -7.000000E-02 -1.158000E-03 -2.919844E-02 -1.953371E-04 -5.372246E-02 -6.734832E-04 -2.939310E-07 -2.375686E-14 -5.372246E-02 -6.734832E-04 +5.220000E-01 +5.995400E-02 +1.400000E-02 +4.000000E-05 +6.718865E-03 +9.371695E-06 +1.106435E-02 +3.119729E-05 +1.216992E-07 +3.699412E-15 +1.106435E-02 +3.119729E-05 0.000000E+00 0.000000E+00 -5.839688E+06 -7.813485E+12 -1.342000E+00 -4.291640E-01 +1.343773E+06 +3.748678E+11 +5.220000E-01 +5.995400E-02 0.000000E+00 0.000000E+00 -3.915206E+00 -3.646810E+00 -2.701000E+00 -1.486587E+00 -1.340000E-01 -3.598000E-03 -5.583136E-02 -6.266530E-04 -1.267275E-01 -3.349463E-03 -7.209619E-07 -1.153253E-13 -1.267275E-01 -3.349463E-03 +1.520872E+00 +5.121226E-01 +2.564000E+00 +1.338762E+00 +1.160000E-01 +2.738000E-03 +4.593685E-02 +4.275719E-04 +1.360763E-01 +3.951569E-03 +8.079937E-07 +1.577355E-13 +1.350645E-01 +3.872739E-03 +1.011813E-03 +1.023765E-06 +9.187371E+06 +1.710288E+13 +2.564000E+00 +1.338762E+00 +8.595248E-04 +7.387829E-07 +7.412367E+00 +1.121746E+01 +2.184000E+00 +9.895940E-01 +1.080000E-01 +2.394000E-03 +4.782785E-02 +4.787428E-04 +1.140806E-01 +2.886440E-03 +6.242229E-07 +9.307161E-14 +1.130687E-01 +2.811706E-03 +1.011813E-03 +1.023765E-06 +9.565570E+06 +1.914971E+13 +2.184000E+00 +9.895940E-01 +3.312574E-05 +1.097314E-09 +6.331465E+00 +8.328826E+00 +5.970000E-01 +8.325100E-02 +3.500000E-02 +3.150000E-04 +1.514871E-02 +5.131352E-05 +3.795718E-02 +3.631435E-04 +2.299730E-07 +1.295603E-14 +3.795718E-02 +3.631435E-04 0.000000E+00 0.000000E+00 -1.116627E+07 -2.506612E+13 -2.701000E+00 -1.486587E+00 +3.029741E+06 +2.052541E+12 +5.970000E-01 +8.325100E-02 0.000000E+00 0.000000E+00 -7.844332E+00 -1.252301E+01 -2.791000E+00 -1.658877E+00 -1.240000E-01 -3.282000E-03 -5.173865E-02 -5.560435E-04 -1.292971E-01 -3.436301E-03 -6.920456E-07 -9.917496E-14 -1.263311E-01 -3.290664E-03 -2.965960E-03 -4.837204E-06 -1.034773E+07 -2.224174E+13 -2.791000E+00 -1.658877E+00 -7.133747E-04 -3.640977E-07 -8.120311E+00 -1.408288E+01 -3.169000E+00 -2.031747E+00 -1.620000E-01 -5.364000E-03 -6.707115E-02 -9.171975E-04 -1.648345E-01 -5.547084E-03 -1.008876E-06 -2.201766E-13 -1.638199E-01 -5.463700E-03 -1.014608E-03 -1.029429E-06 -1.341423E+07 -3.668790E+13 -3.169000E+00 -2.031747E+00 -8.618993E-04 -7.428703E-07 -9.158565E+00 -1.699756E+01 -3.660000E+00 -2.796494E+00 -1.580000E-01 -5.158000E-03 -6.719242E-02 -9.422093E-04 -1.591500E-01 -5.615224E-03 -8.020080E-07 -1.480166E-13 -1.581743E-01 -5.540021E-03 -9.756761E-04 -9.519438E-07 -1.343848E+07 -3.768837E+13 -3.660000E+00 -2.796494E+00 -2.954152E-04 -8.727014E-08 -1.067773E+01 -2.376726E+01 -2.527000E+00 -1.452369E+00 -1.140000E-01 -2.834000E-03 -4.984389E-02 -5.325247E-04 -1.111356E-01 -2.793586E-03 -7.289084E-07 -1.302125E-13 -1.111356E-01 -2.793586E-03 +1.714353E+00 +6.970480E-01 +1.852000E+00 +7.973360E-01 +7.900000E-02 +1.689000E-03 +2.755187E-02 +2.091740E-04 +5.453423E-02 +7.484037E-04 +2.368001E-07 +1.753710E-14 +5.453423E-02 +7.484037E-04 0.000000E+00 0.000000E+00 -9.968777E+06 -2.130099E+13 -2.527000E+00 -1.452369E+00 +5.510374E+06 +8.366961E+12 +1.852000E+00 +7.973360E-01 0.000000E+00 0.000000E+00 -7.323996E+00 -1.221424E+01 -3.204000E+00 -2.092834E+00 -1.500000E-01 -4.600000E-03 -6.029165E-02 -7.387235E-04 -1.410668E-01 -4.414885E-03 -8.384625E-07 -1.602532E-13 -1.400911E-01 -4.332066E-03 -9.756761E-04 -9.519438E-07 -1.205833E+07 -2.954894E+13 -3.204000E+00 -2.092834E+00 -3.194266E-05 -1.020333E-09 -9.309783E+00 -1.769870E+01 -3.463000E+00 -2.477679E+00 -1.670000E-01 -5.837000E-03 -6.829328E-02 -9.882225E-04 -1.758063E-01 -6.470636E-03 -9.887100E-07 -2.199856E-13 -1.737856E-01 -6.307226E-03 -2.020620E-03 -2.041459E-06 -1.365866E+07 -3.952890E+13 -3.463000E+00 -2.477679E+00 -4.276023E-04 -1.081885E-07 -1.003961E+01 -2.083120E+01 -2.970000E-01 -4.491300E-02 -1.500000E-02 -9.100000E-05 -4.215863E-03 -6.275840E-06 -6.040786E-03 -1.401662E-05 -2.142282E-08 -4.361920E-16 -6.040786E-03 -1.401662E-05 +5.449659E+00 +6.908544E+00 +4.177000E+00 +3.780409E+00 +1.760000E-01 +6.584000E-03 +7.049310E-02 +1.047700E-03 +2.082153E-01 +9.154274E-03 +1.090026E-06 +2.590031E-13 +2.082153E-01 +9.154274E-03 0.000000E+00 0.000000E+00 -8.431726E+05 -2.510336E+11 -2.970000E-01 -4.491300E-02 +1.409862E+07 +4.190799E+13 +4.177000E+00 +3.780409E+00 0.000000E+00 0.000000E+00 -8.785109E-01 -3.967096E-01 -1.250000E-01 -5.357000E-03 -2.000000E-03 -2.000000E-06 -4.888503E-04 -1.194873E-07 -2.028292E-03 -2.059943E-06 -8.582314E-09 -7.099216E-17 -2.028292E-03 -2.059943E-06 +1.213785E+01 +3.197979E+01 +2.287000E+00 +1.059809E+00 +1.040000E-01 +2.254000E-03 +4.025632E-02 +3.309459E-04 +9.479325E-02 +1.956154E-03 +4.705869E-07 +4.509695E-14 +9.479325E-02 +1.956154E-03 0.000000E+00 0.000000E+00 -9.777007E+04 -4.779493E+09 -1.250000E-01 -5.357000E-03 +8.051265E+06 +1.323783E+13 +2.287000E+00 +1.059809E+00 0.000000E+00 0.000000E+00 -3.698633E-01 -4.679347E-02 +6.680550E+00 +9.051488E+00 +6.398000E+00 +8.323220E+00 +2.580000E-01 +1.356600E-02 +1.070205E-01 +2.345401E-03 +2.825180E-01 +1.658268E-02 +1.510574E-06 +5.135513E-13 +2.805357E-01 +1.633928E-02 +1.982273E-03 +1.965559E-06 +2.140411E+07 +9.381603E+13 +6.398000E+00 +8.323220E+00 +6.001927E-04 +1.801940E-07 +1.863566E+01 +7.066273E+01 +1.167000E+00 +4.778410E-01 +5.100000E-02 +9.290000E-04 +1.851002E-02 +1.273765E-04 +3.405873E-02 +6.277248E-04 +1.688115E-07 +1.480555E-14 +3.195431E-02 +5.302962E-04 +2.104418E-03 +4.428574E-06 +3.702005E+06 +5.095061E+12 +1.167000E+00 +4.778410E-01 +3.530361E-04 +1.246345E-07 +3.428588E+00 +4.115657E+00 +3.630000E+00 +2.765806E+00 +1.490000E-01 +4.587000E-03 +5.894825E-02 +7.367371E-04 +1.434581E-01 +4.305327E-03 +7.603618E-07 +1.250071E-13 +1.414758E-01 +4.212618E-03 +1.982273E-03 +1.965559E-06 +1.178965E+07 +2.946948E+13 +3.630000E+00 +2.765806E+00 +4.160428E-04 +1.012741E-07 +1.059988E+01 +2.359174E+01 tally 2: -1.353006E+00 -4.298474E-01 -6.067126E-02 -9.182923E-04 -2.407597E-02 -1.589874E-04 -6.018994E-02 -9.936715E-04 -3.157310E-07 -3.268202E-14 -5.980833E-02 -9.811116E-04 -3.816044E-04 -3.994127E-08 -4.815195E+06 -6.359497E+12 -1.340228E+00 -4.256704E-01 -1.788012E-04 -8.768717E-09 -3.941968E+00 -3.631126E+00 -2.806910E+00 -1.600166E+00 -1.295488E-01 -3.449533E-03 -5.323702E-02 -5.945274E-04 -1.330925E-01 -3.715796E-03 -7.358638E-07 -1.182977E-13 -1.322487E-01 -3.668829E-03 -8.438073E-04 -1.493588E-07 -1.064740E+07 -2.378109E+13 -2.698926E+00 -1.484990E+00 -3.953669E-04 -3.279028E-08 -8.155605E+00 -1.349706E+01 -2.869647E+00 -1.739405E+00 -1.278179E-01 -3.407189E-03 -5.029332E-02 -5.252401E-04 -1.257333E-01 -3.282751E-03 -6.507109E-07 -8.979533E-14 -1.249362E-01 -3.241257E-03 -7.971497E-04 -1.319523E-07 -1.005866E+07 -2.100960E+13 -2.795871E+00 -1.662994E+00 -3.735055E-04 -2.896884E-08 -8.365907E+00 -1.480669E+01 -3.141043E+00 -1.981851E+00 -1.526263E-01 -4.699686E-03 -6.641498E-02 -9.211853E-04 -1.660374E-01 -5.757408E-03 -9.915981E-07 -2.229928E-13 -1.649848E-01 -5.684636E-03 -1.052678E-03 -2.314228E-07 -1.328300E+07 -3.684741E+13 -3.162533E+00 -2.024101E+00 -4.932336E-04 -5.080661E-08 -9.080077E+00 -1.658064E+01 -3.682383E+00 -2.808072E+00 -1.593265E-01 -5.346789E-03 -6.034523E-02 -7.901305E-04 -1.508631E-01 -4.938316E-03 -7.319663E-07 -1.246559E-13 -1.499066E-01 -4.875896E-03 -9.564725E-04 -1.984988E-07 -1.206905E+07 -3.160522E+13 -3.670108E+00 -2.815133E+00 -4.481564E-04 -4.357848E-08 -1.076370E+01 -2.396100E+01 -2.634850E+00 -1.584334E+00 -1.218122E-01 -3.391010E-03 -5.015643E-02 -5.871038E-04 -1.253911E-01 -3.669399E-03 -6.952485E-07 -1.202338E-13 -1.245961E-01 -3.623018E-03 -7.949798E-04 -1.474939E-07 -1.003129E+07 -2.348415E+13 -2.523640E+00 -1.451617E+00 -3.724888E-04 -3.238084E-08 -7.654439E+00 -1.338000E+01 -3.192584E+00 -2.071165E+00 -1.491327E-01 -4.485370E-03 -6.214556E-02 -7.933462E-04 -1.553639E-01 -4.958414E-03 -8.761442E-07 -1.691919E-13 -1.543789E-01 -4.895740E-03 -9.850078E-04 -1.993067E-07 -1.242911E+07 -3.173385E+13 -3.198836E+00 -2.085466E+00 -4.615266E-04 -4.375584E-08 -9.265396E+00 -1.747782E+01 -3.402213E+00 -2.415762E+00 -1.592235E-01 -5.219460E-03 -6.649290E-02 -9.066793E-04 -1.662323E-01 -5.666746E-03 -9.402303E-07 -1.840541E-13 -1.651783E-01 -5.595119E-03 -1.053913E-03 -2.277785E-07 -1.329858E+07 -3.626717E+13 -3.467276E+00 -2.484377E+00 -4.938123E-04 -5.000655E-08 -9.871966E+00 -2.037665E+01 -3.110378E-01 -5.227746E-02 -1.171121E-02 -6.542918E-05 -3.536640E-03 -5.149982E-06 -8.841599E-03 -3.218739E-05 -2.347065E-08 -5.243075E-16 -8.785544E-03 -3.178055E-05 -5.605578E-05 -1.293793E-09 -7.073280E+05 -2.059993E+11 -2.978788E-01 -4.498561E-02 -2.626500E-05 -2.840396E-10 -9.197485E-01 -4.619575E-01 -1.267544E-01 -5.491246E-03 -4.806410E-03 -8.161899E-06 -1.471497E-03 -8.779657E-07 -3.678743E-03 -5.487286E-06 -1.030812E-08 -1.028225E-16 -3.655420E-03 -5.417928E-06 -2.332325E-05 -2.205650E-10 -2.942995E+05 -3.511863E+10 -1.270281E-01 -5.517180E-03 -1.092814E-05 -4.842290E-11 -3.746117E-01 -4.790053E-02 +5.033991E-01 +5.701830E-02 +2.304219E-02 +1.162005E-04 +9.376617E-03 +1.933443E-05 +2.344154E-02 +1.208402E-04 +1.277674E-07 +3.888071E-15 +2.329292E-02 +1.193128E-04 +1.486195E-04 +4.857250E-09 +1.875323E+06 +7.733771E+11 +5.220000E-01 +5.995400E-02 +6.963583E-05 +1.066362E-09 +1.463809E+00 +4.840945E-01 +2.621546E+00 +1.396717E+00 +1.276380E-01 +3.311549E-03 +5.565805E-02 +6.598224E-04 +1.391451E-01 +4.123890E-03 +8.331879E-07 +1.660597E-13 +1.382629E-01 +4.071765E-03 +8.821806E-04 +1.657624E-07 +1.113161E+07 +2.639289E+13 +2.581000E+00 +1.357455E+00 +4.133468E-04 +3.639153E-08 +7.576783E+00 +1.169599E+01 +2.230626E+00 +1.033217E+00 +1.065165E-01 +2.416670E-03 +4.549248E-02 +4.740035E-04 +1.137312E-01 +2.962522E-03 +6.630810E-07 +1.170893E-13 +1.130101E-01 +2.925076E-03 +7.210562E-04 +1.190805E-07 +9.098495E+06 +1.896014E+13 +2.202000E+00 +1.007194E+00 +3.378518E-04 +2.614296E-08 +6.459596E+00 +8.662758E+00 +5.565395E-01 +7.242839E-02 +2.955239E-02 +1.840142E-04 +1.400990E-02 +4.103227E-05 +3.502476E-02 +2.564517E-04 +2.308081E-07 +1.205491E-14 +3.480270E-02 +2.532102E-04 +2.220571E-04 +1.030824E-08 +2.801981E+06 +1.641291E+12 +6.090000E-01 +8.636300E-02 +1.040451E-04 +2.263074E-09 +1.593637E+00 +6.040566E-01 +1.817267E+00 +7.710225E-01 +7.367627E-02 +1.267666E-03 +2.535616E-02 +1.551036E-04 +6.339039E-02 +9.693976E-04 +2.524798E-07 +1.896478E-14 +6.298850E-02 +9.571446E-04 +4.018954E-04 +3.896557E-08 +5.071232E+06 +6.204145E+12 +1.881000E+00 +8.206930E-01 +1.883086E-04 +8.554511E-09 +5.341905E+00 +6.666854E+00 +4.106914E+00 +3.704316E+00 +1.888617E-01 +7.777635E-03 +7.727973E-02 +1.309080E-03 +1.931993E-01 +8.181751E-03 +1.061590E-06 +2.554724E-13 +1.919744E-01 +8.078335E-03 +1.224884E-03 +3.288708E-07 +1.545595E+07 +5.236321E+13 +4.223000E+00 +3.850821E+00 +5.739211E-04 +7.220038E-08 +1.193698E+01 +3.133321E+01 +2.346339E+00 +1.119793E+00 +1.017476E-01 +2.080323E-03 +3.865443E-02 +3.024337E-04 +9.663608E-02 +1.890211E-03 +4.714003E-07 +4.853805E-14 +9.602340E-02 +1.866319E-03 +6.126731E-04 +7.597824E-08 +7.730886E+06 +1.209735E+13 +2.338000E+00 +1.106368E+00 +2.870687E-04 +1.668028E-08 +6.857029E+00 +9.581045E+00 +6.446883E+00 +8.447751E+00 +2.867793E-01 +1.670093E-02 +1.126541E-01 +2.611201E-03 +2.816352E-01 +1.632001E-02 +1.453669E-06 +4.585416E-13 +2.798496E-01 +1.611372E-02 +1.785568E-03 +6.559933E-07 +2.253081E+07 +1.044480E+14 +6.454000E+00 +8.471478E+00 +8.366302E-04 +1.440169E-07 +1.879692E+01 +7.185693E+01 +1.219419E+00 +5.127750E-01 +4.857020E-02 +8.389250E-04 +1.623897E-02 +1.008738E-04 +4.059741E-02 +6.304611E-04 +1.503579E-07 +1.146797E-14 +4.034003E-02 +6.224921E-04 +2.573878E-04 +2.534179E-08 +3.247793E+06 +4.034951E+12 +1.199000E+00 +4.975810E-01 +1.205994E-04 +5.563543E-09 +3.589772E+00 +4.434695E+00 +3.623361E+00 +2.780040E+00 +1.560708E-01 +5.162316E-03 +5.875078E-02 +7.419979E-04 +1.468770E-01 +4.637487E-03 +7.048177E-07 +1.136014E-13 +1.459458E-01 +4.578870E-03 +9.312005E-04 +1.864068E-07 +1.175016E+07 +2.967992E+13 +3.668000E+00 +2.824270E+00 +4.363151E-04 +4.092380E-08 +1.059543E+01 +2.377944E+01 tally 3: -1.098420E+02 -2.414277E+03 -4.993000E+00 -4.986021E+00 -2.023763E+00 -8.192234E-01 -5.037812E+00 -5.086734E+00 -2.745346E-05 -1.509092E-10 -5.002505E+00 -5.014944E+00 -3.530702E-02 -2.695026E-04 -4.047525E+08 -3.276894E+16 -1.098420E+02 -2.414277E+03 -1.059695E-02 -2.782849E-05 -3.195213E+02 -2.042961E+04 -1.048490E+02 -2.199887E+03 -1.048490E+02 -2.199887E+03 +1.092010E+02 +2.386227E+03 +4.975000E+00 +4.950147E+00 +2.009472E+00 +8.076733E-01 +5.000649E+00 +5.012321E+00 +2.728992E-05 +1.491241E-10 +4.964474E+00 +4.939215E+00 +3.617555E-02 +2.875519E-04 +4.018944E+08 +3.230693E+16 +1.092010E+02 +2.386227E+03 +1.333979E-02 +5.019969E-05 +3.176576E+02 +2.019260E+04 +1.042260E+02 +2.173864E+03 +1.042260E+02 +2.173864E+03 tally 4: -1.098420E+02 -2.414277E+03 -5.008447E+00 -5.018748E+00 -2.028674E+00 -8.234818E-01 -5.071684E+00 -5.146761E+00 -5.050718E-05 -5.107669E-10 -5.039530E+00 -5.081707E+00 -3.215450E-02 -2.068774E-04 -4.057347E+08 -3.293927E+16 -1.098420E+02 -2.414277E+03 -1.506603E-02 -4.541792E-05 -3.195213E+02 -2.042961E+04 +1.092010E+02 +2.386227E+03 +4.979068E+00 +4.959690E+00 +2.016700E+00 +8.137138E-01 +5.041749E+00 +5.085712E+00 +5.020635E-05 +5.047241E-10 +5.009785E+00 +5.021429E+00 +3.196471E-02 +2.044235E-04 +4.033399E+08 +3.254855E+16 +1.092010E+02 +2.386227E+03 +1.497710E-02 +4.487918E-05 +3.176576E+02 +2.019260E+04 tally 5: -1.103689E+02 -2.437562E+03 -5.035611E+00 -5.073005E+00 -2.041209E+00 -8.337913E-01 -5.103022E+00 -5.211196E+00 -2.765405E-05 -1.532759E-10 -5.070669E+00 -5.145327E+00 -3.235318E-02 -2.094674E-04 -4.082417E+08 -3.335165E+16 -1.098580E+02 -2.414983E+03 -1.515912E-02 -4.598653E-05 -3.210351E+02 -2.062463E+04 +1.097121E+02 +2.408636E+03 +5.009145E+00 +5.019563E+00 +2.032191E+00 +8.264420E-01 +5.080477E+00 +5.165263E+00 +2.756641E-05 +1.523527E-10 +5.048267E+00 +5.099975E+00 +3.221025E-02 +2.076211E-04 +4.064382E+08 +3.305768E+16 +1.093810E+02 +2.394075E+03 +1.509215E-02 +4.558119E-05 +3.191033E+02 +2.037736E+04 tally 6: -1.048490E+02 -2.199887E+03 -1.048490E+02 -2.199887E+03 -5.037812E+00 -5.086734E+00 +1.042260E+02 +2.173864E+03 +1.042260E+02 +2.173864E+03 +5.000649E+00 +5.012321E+00 tally 7: -6.546000E+00 -8.579894E+00 -1.462000E+00 -4.278220E-01 -1.160697E+00 -2.696537E-01 -2.879845E+00 -1.663297E+00 -2.723379E-05 -1.485067E-10 -2.862628E+00 -1.643479E+00 -1.721726E-02 -6.055382E-05 -2.321395E+08 -1.078615E+16 -6.546000E+00 -8.579894E+00 -6.709978E-03 -1.387848E-05 -1.198287E+01 -2.875089E+01 -5.084000E+00 -5.178800E+00 -5.084000E+00 -5.178800E+00 -1.032960E+02 -2.135240E+03 +6.507000E+00 +8.478423E+00 +1.444000E+00 +4.172780E-01 +1.146407E+00 +2.630079E-01 +2.867025E+00 +1.647980E+00 +2.707153E-05 +1.467503E-10 +2.848880E+00 +1.627146E+00 +1.814469E-02 +6.685238E-05 +2.292814E+08 +1.052031E+16 +6.507000E+00 +8.478423E+00 +9.467712E-03 +2.396878E-05 +1.191147E+01 +2.841087E+01 +5.063000E+00 +5.136983E+00 +5.063000E+00 +5.136983E+00 +1.026940E+02 +2.110535E+03 3.531000E+00 -2.493943E+00 +2.493861E+00 8.630652E-01 -1.489973E-01 -2.157967E+00 -9.345420E-01 -2.196703E-07 -9.656558E-15 -2.139877E+00 -9.185178E-01 -1.808977E-02 -8.744581E-05 +1.489924E-01 +2.133624E+00 +9.150435E-01 +2.183901E-07 +9.544829E-15 +2.115593E+00 +8.991467E-01 +1.803087E-02 +8.677353E-05 1.726130E+08 -5.959891E+15 -1.032960E+02 -2.135240E+03 -3.886968E-03 -5.976458E-06 -3.075384E+02 -1.892685E+04 -9.976500E+01 -1.991860E+03 -9.976500E+01 -1.991860E+03 +5.959695E+15 +1.026940E+02 +2.110535E+03 +3.872081E-03 +5.919692E-06 +3.057461E+02 +1.870786E+04 +9.916300E+01 +1.968002E+03 +9.916300E+01 +1.968002E+03 tally 8: -6.546000E+00 -8.579894E+00 -1.464067E+00 -4.291919E-01 -1.162338E+00 -2.705171E-01 -2.905845E+00 -1.690732E+00 -4.985316E-05 -4.976401E-10 -2.887422E+00 -1.669362E+00 -1.842307E-02 -6.796008E-05 -2.324676E+08 -1.082069E+16 -6.546000E+00 -8.579894E+00 -8.632151E-03 -1.491997E-05 -1.198287E+01 -2.875089E+01 -1.032960E+02 -2.135240E+03 -3.544380E+00 -2.513971E+00 -8.663357E-01 -1.501938E-01 -2.165839E+00 -9.387115E-01 -6.540142E-07 -8.559612E-14 -2.152108E+00 -9.268463E-01 -1.373143E-02 -3.773212E-05 -1.732671E+08 -6.007753E+15 -1.032960E+02 -2.135240E+03 -6.433878E-03 -8.283719E-06 -3.075384E+02 -1.892685E+04 +6.507000E+00 +8.478423E+00 +1.455344E+00 +4.241161E-01 +1.155413E+00 +2.673178E-01 +2.888532E+00 +1.670737E+00 +4.955615E-05 +4.917547E-10 +2.870219E+00 +1.649619E+00 +1.831331E-02 +6.715634E-05 +2.310826E+08 +1.069271E+16 +6.507000E+00 +8.478423E+00 +8.580723E-03 +1.474352E-05 +1.191147E+01 +2.841087E+01 +1.026940E+02 +2.110535E+03 +3.523724E+00 +2.484884E+00 +8.612868E-01 +1.484560E-01 +2.153217E+00 +9.278503E-01 +6.502027E-07 +8.460574E-14 +2.139566E+00 +9.161225E-01 +1.365140E-02 +3.729555E-05 +1.722574E+08 +5.938242E+15 +1.026940E+02 +2.110535E+03 +6.396382E-03 +8.187874E-06 +3.057461E+02 +1.870786E+04 tally 9: -6.593971E+00 -8.715030E+00 -1.474796E+00 -4.359519E-01 -1.170856E+00 -2.747779E-01 -2.927140E+00 -1.717362E+00 -2.743336E-05 -1.508457E-10 -2.908582E+00 -1.695655E+00 -1.855808E-02 -6.903047E-05 -2.341712E+08 -1.099112E+16 -6.547000E+00 -8.582573E+00 -8.695410E-03 -1.515497E-05 -1.207068E+01 -2.920373E+01 -1.037750E+02 -2.155274E+03 -3.560815E+00 -2.537559E+00 -8.703528E-01 -1.516031E-01 -2.175882E+00 -9.475192E-01 -2.206889E-07 -9.747163E-15 -2.162087E+00 -9.355427E-01 -1.379510E-02 -3.808615E-05 -1.740706E+08 -6.064123E+15 -1.033110E+02 -2.135863E+03 -6.463712E-03 -8.361443E-06 -3.089644E+02 -1.910444E+04 +6.573230E+00 +8.663027E+00 +1.470157E+00 +4.333505E-01 +1.167173E+00 +2.731383E-01 +2.917933E+00 +1.707114E+00 +2.734707E-05 +1.499456E-10 +2.899433E+00 +1.685536E+00 +1.849971E-02 +6.861856E-05 +2.334346E+08 +1.092553E+16 +6.518000E+00 +8.507644E+00 +8.668060E-03 +1.506454E-05 +1.203271E+01 +2.902947E+01 +1.031389E+02 +2.128993E+03 +3.538988E+00 +2.506616E+00 +8.650177E-01 +1.497544E-01 +2.162544E+00 +9.359650E-01 +2.193361E-07 +9.628305E-15 +2.148834E+00 +9.241346E-01 +1.371054E-02 +3.762172E-05 +1.730035E+08 +5.990176E+15 +1.028630E+02 +2.117467E+03 +6.424090E-03 +8.259483E-06 +3.070706E+02 +1.887148E+04 tally 10: -5.084000E+00 -5.178800E+00 -5.084000E+00 -5.178800E+00 +5.063000E+00 +5.136983E+00 +5.063000E+00 +5.136983E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.879845E+00 -1.663297E+00 -1.463000E+00 -4.284330E-01 -1.463000E+00 -4.284330E-01 +2.867025E+00 +1.647980E+00 +1.445000E+00 +4.178610E-01 +1.445000E+00 +4.178610E-01 0.000000E+00 0.000000E+00 -9.830200E+01 -1.933884E+03 -9.830200E+01 -1.933884E+03 -2.157967E+00 -9.345420E-01 +9.771800E+01 +1.911083E+03 +9.771800E+01 +1.911083E+03 +2.133624E+00 +9.150435E-01 tally 11: -1.342000E+00 -4.291640E-01 -7.000000E-02 -1.158000E-03 -2.919844E-02 -1.953371E-04 -5.372246E-02 -6.734832E-04 -2.939310E-07 -2.375686E-14 -5.372246E-02 -6.734832E-04 +5.220000E-01 +5.995400E-02 +1.400000E-02 +4.000000E-05 +6.718865E-03 +9.371695E-06 +1.106435E-02 +3.119729E-05 +1.216992E-07 +3.699412E-15 +1.106435E-02 +3.119729E-05 0.000000E+00 0.000000E+00 -5.839688E+06 -7.813485E+12 -1.342000E+00 -4.291640E-01 +1.343773E+06 +3.748678E+11 +5.220000E-01 +5.995400E-02 0.000000E+00 0.000000E+00 -2.701000E+00 -1.486587E+00 -1.340000E-01 -3.598000E-03 -5.583136E-02 -6.266530E-04 -1.267275E-01 -3.349463E-03 -7.209619E-07 -1.153253E-13 -1.267275E-01 -3.349463E-03 +2.564000E+00 +1.338762E+00 +1.160000E-01 +2.738000E-03 +4.593685E-02 +4.275719E-04 +1.360763E-01 +3.951569E-03 +8.079937E-07 +1.577355E-13 +1.350645E-01 +3.872739E-03 +1.011813E-03 +1.023765E-06 +9.187371E+06 +1.710288E+13 +2.564000E+00 +1.338762E+00 +8.595248E-04 +7.387829E-07 +2.184000E+00 +9.895940E-01 +1.080000E-01 +2.394000E-03 +4.782785E-02 +4.787428E-04 +1.140806E-01 +2.886440E-03 +6.242229E-07 +9.307161E-14 +1.130687E-01 +2.811706E-03 +1.011813E-03 +1.023765E-06 +9.565570E+06 +1.914971E+13 +2.184000E+00 +9.895940E-01 +3.312574E-05 +1.097314E-09 +5.970000E-01 +8.325100E-02 +3.500000E-02 +3.150000E-04 +1.514871E-02 +5.131352E-05 +3.795718E-02 +3.631435E-04 +2.299730E-07 +1.295603E-14 +3.795718E-02 +3.631435E-04 0.000000E+00 0.000000E+00 -1.116627E+07 -2.506612E+13 -2.701000E+00 -1.486587E+00 +3.029741E+06 +2.052541E+12 +5.970000E-01 +8.325100E-02 0.000000E+00 0.000000E+00 -2.791000E+00 -1.658877E+00 -1.240000E-01 -3.282000E-03 -5.173865E-02 -5.560435E-04 -1.292971E-01 -3.436301E-03 -6.920456E-07 -9.917496E-14 -1.263311E-01 -3.290664E-03 -2.965960E-03 -4.837204E-06 -1.034773E+07 -2.224174E+13 -2.791000E+00 -1.658877E+00 -7.133747E-04 -3.640977E-07 -3.169000E+00 -2.031747E+00 -1.620000E-01 -5.364000E-03 -6.707115E-02 -9.171975E-04 -1.648345E-01 -5.547084E-03 -1.008876E-06 -2.201766E-13 -1.638199E-01 -5.463700E-03 -1.014608E-03 -1.029429E-06 -1.341423E+07 -3.668790E+13 -3.169000E+00 -2.031747E+00 -8.618993E-04 -7.428703E-07 -3.660000E+00 -2.796494E+00 -1.580000E-01 -5.158000E-03 -6.719242E-02 -9.422093E-04 -1.591500E-01 -5.615224E-03 -8.020080E-07 -1.480166E-13 -1.581743E-01 -5.540021E-03 -9.756761E-04 -9.519438E-07 -1.343848E+07 -3.768837E+13 -3.660000E+00 -2.796494E+00 -2.954152E-04 -8.727014E-08 -2.527000E+00 -1.452369E+00 -1.140000E-01 -2.834000E-03 -4.984389E-02 -5.325247E-04 -1.111356E-01 -2.793586E-03 -7.289084E-07 -1.302125E-13 -1.111356E-01 -2.793586E-03 +1.852000E+00 +7.973360E-01 +7.900000E-02 +1.689000E-03 +2.755187E-02 +2.091740E-04 +5.453423E-02 +7.484037E-04 +2.368001E-07 +1.753710E-14 +5.453423E-02 +7.484037E-04 0.000000E+00 0.000000E+00 -9.968777E+06 -2.130099E+13 -2.527000E+00 -1.452369E+00 +5.510374E+06 +8.366961E+12 +1.852000E+00 +7.973360E-01 0.000000E+00 0.000000E+00 -3.204000E+00 -2.092834E+00 -1.500000E-01 -4.600000E-03 -6.029165E-02 -7.387235E-04 -1.410668E-01 -4.414885E-03 -8.384625E-07 -1.602532E-13 -1.400911E-01 -4.332066E-03 -9.756761E-04 -9.519438E-07 -1.205833E+07 -2.954894E+13 -3.204000E+00 -2.092834E+00 -3.194266E-05 -1.020333E-09 -3.463000E+00 -2.477679E+00 -1.670000E-01 -5.837000E-03 -6.829328E-02 -9.882225E-04 -1.758063E-01 -6.470636E-03 -9.887100E-07 -2.199856E-13 -1.737856E-01 -6.307226E-03 -2.020620E-03 -2.041459E-06 -1.365866E+07 -3.952890E+13 -3.463000E+00 -2.477679E+00 -4.276023E-04 -1.081885E-07 -2.970000E-01 -4.491300E-02 -1.500000E-02 -9.100000E-05 -4.215863E-03 -6.275840E-06 -6.040786E-03 -1.401662E-05 -2.142282E-08 -4.361920E-16 -6.040786E-03 -1.401662E-05 +4.177000E+00 +3.780409E+00 +1.760000E-01 +6.584000E-03 +7.049310E-02 +1.047700E-03 +2.082153E-01 +9.154274E-03 +1.090026E-06 +2.590031E-13 +2.082153E-01 +9.154274E-03 0.000000E+00 0.000000E+00 -8.431726E+05 -2.510336E+11 -2.970000E-01 -4.491300E-02 +1.409862E+07 +4.190799E+13 +4.177000E+00 +3.780409E+00 0.000000E+00 0.000000E+00 -1.250000E-01 -5.357000E-03 -2.000000E-03 -2.000000E-06 -4.888503E-04 -1.194873E-07 -2.028292E-03 -2.059943E-06 -8.582314E-09 -7.099216E-17 -2.028292E-03 -2.059943E-06 +2.287000E+00 +1.059809E+00 +1.040000E-01 +2.254000E-03 +4.025632E-02 +3.309459E-04 +9.479325E-02 +1.956154E-03 +4.705869E-07 +4.509695E-14 +9.479325E-02 +1.956154E-03 0.000000E+00 0.000000E+00 -9.777007E+04 -4.779493E+09 -1.250000E-01 -5.357000E-03 +8.051265E+06 +1.323783E+13 +2.287000E+00 +1.059809E+00 0.000000E+00 0.000000E+00 +6.398000E+00 +8.323220E+00 +2.580000E-01 +1.356600E-02 +1.070205E-01 +2.345401E-03 +2.825180E-01 +1.658268E-02 +1.510574E-06 +5.135513E-13 +2.805357E-01 +1.633928E-02 +1.982273E-03 +1.965559E-06 +2.140411E+07 +9.381603E+13 +6.398000E+00 +8.323220E+00 +6.001927E-04 +1.801940E-07 +1.167000E+00 +4.778410E-01 +5.100000E-02 +9.290000E-04 +1.851002E-02 +1.273765E-04 +3.405873E-02 +6.277248E-04 +1.688115E-07 +1.480555E-14 +3.195431E-02 +5.302962E-04 +2.104418E-03 +4.428574E-06 +3.702005E+06 +5.095061E+12 +1.167000E+00 +4.778410E-01 +3.530361E-04 +1.246345E-07 +3.630000E+00 +2.765806E+00 +1.490000E-01 +4.587000E-03 +5.894825E-02 +7.367371E-04 +1.434581E-01 +4.305327E-03 +7.603618E-07 +1.250071E-13 +1.414758E-01 +4.212618E-03 +1.982273E-03 +1.965559E-06 +1.178965E+07 +2.946948E+13 +3.630000E+00 +2.765806E+00 +4.160428E-04 +1.012741E-07 tally 12: -1.353006E+00 -4.298474E-01 -6.067126E-02 -9.182923E-04 -2.407597E-02 -1.589874E-04 -6.018994E-02 -9.936715E-04 -3.157310E-07 -3.268202E-14 -5.980833E-02 -9.811116E-04 -3.816044E-04 -3.994127E-08 -4.815195E+06 -6.359497E+12 -1.340228E+00 -4.256704E-01 -1.788012E-04 -8.768717E-09 -2.806910E+00 -1.600166E+00 -1.295488E-01 -3.449533E-03 -5.323702E-02 -5.945274E-04 -1.330925E-01 -3.715796E-03 -7.358638E-07 -1.182977E-13 -1.322487E-01 -3.668829E-03 -8.438073E-04 -1.493588E-07 -1.064740E+07 -2.378109E+13 -2.698926E+00 -1.484990E+00 -3.953669E-04 -3.279028E-08 -2.869647E+00 -1.739405E+00 -1.278179E-01 -3.407189E-03 -5.029332E-02 -5.252401E-04 -1.257333E-01 -3.282751E-03 -6.507109E-07 -8.979533E-14 -1.249362E-01 -3.241257E-03 -7.971497E-04 -1.319523E-07 -1.005866E+07 -2.100960E+13 -2.795871E+00 -1.662994E+00 -3.735055E-04 -2.896884E-08 -3.141043E+00 -1.981851E+00 -1.526263E-01 -4.699686E-03 -6.641498E-02 -9.211853E-04 -1.660374E-01 -5.757408E-03 -9.915981E-07 -2.229928E-13 -1.649848E-01 -5.684636E-03 -1.052678E-03 -2.314228E-07 -1.328300E+07 -3.684741E+13 -3.162533E+00 -2.024101E+00 -4.932336E-04 -5.080661E-08 -3.682383E+00 -2.808072E+00 -1.593265E-01 -5.346789E-03 -6.034523E-02 -7.901305E-04 -1.508631E-01 -4.938316E-03 -7.319663E-07 -1.246559E-13 -1.499066E-01 -4.875896E-03 -9.564725E-04 -1.984988E-07 -1.206905E+07 -3.160522E+13 -3.670108E+00 -2.815133E+00 -4.481564E-04 -4.357848E-08 -2.634850E+00 -1.584334E+00 -1.218122E-01 -3.391010E-03 -5.015643E-02 -5.871038E-04 -1.253911E-01 -3.669399E-03 -6.952485E-07 -1.202338E-13 -1.245961E-01 -3.623018E-03 -7.949798E-04 -1.474939E-07 -1.003129E+07 -2.348415E+13 -2.523640E+00 -1.451617E+00 -3.724888E-04 -3.238084E-08 -3.192584E+00 -2.071165E+00 -1.491327E-01 -4.485370E-03 -6.214556E-02 -7.933462E-04 -1.553639E-01 -4.958414E-03 -8.761442E-07 -1.691919E-13 -1.543789E-01 -4.895740E-03 -9.850078E-04 -1.993067E-07 -1.242911E+07 -3.173385E+13 -3.198836E+00 -2.085466E+00 -4.615266E-04 -4.375584E-08 -3.402213E+00 -2.415762E+00 -1.592235E-01 -5.219460E-03 -6.649290E-02 -9.066793E-04 -1.662323E-01 -5.666746E-03 -9.402303E-07 -1.840541E-13 -1.651783E-01 -5.595119E-03 -1.053913E-03 -2.277785E-07 -1.329858E+07 -3.626717E+13 -3.467276E+00 -2.484377E+00 -4.938123E-04 -5.000655E-08 -3.110378E-01 -5.227746E-02 -1.171121E-02 -6.542918E-05 -3.536640E-03 -5.149982E-06 -8.841599E-03 -3.218739E-05 -2.347065E-08 -5.243075E-16 -8.785544E-03 -3.178055E-05 -5.605578E-05 -1.293793E-09 -7.073280E+05 -2.059993E+11 -2.978788E-01 -4.498561E-02 -2.626500E-05 -2.840396E-10 -1.267544E-01 -5.491246E-03 -4.806410E-03 -8.161899E-06 -1.471497E-03 -8.779657E-07 -3.678743E-03 -5.487286E-06 -1.030812E-08 -1.028225E-16 -3.655420E-03 -5.417928E-06 -2.332325E-05 -2.205650E-10 -2.942995E+05 -3.511863E+10 -1.270281E-01 -5.517180E-03 -1.092814E-05 -4.842290E-11 +5.033991E-01 +5.701830E-02 +2.304219E-02 +1.162005E-04 +9.376617E-03 +1.933443E-05 +2.344154E-02 +1.208402E-04 +1.277674E-07 +3.888071E-15 +2.329292E-02 +1.193128E-04 +1.486195E-04 +4.857250E-09 +1.875323E+06 +7.733771E+11 +5.220000E-01 +5.995400E-02 +6.963583E-05 +1.066362E-09 +2.621546E+00 +1.396717E+00 +1.276380E-01 +3.311549E-03 +5.565805E-02 +6.598224E-04 +1.391451E-01 +4.123890E-03 +8.331879E-07 +1.660597E-13 +1.382629E-01 +4.071765E-03 +8.821806E-04 +1.657624E-07 +1.113161E+07 +2.639289E+13 +2.581000E+00 +1.357455E+00 +4.133468E-04 +3.639153E-08 +2.230626E+00 +1.033217E+00 +1.065165E-01 +2.416670E-03 +4.549248E-02 +4.740035E-04 +1.137312E-01 +2.962522E-03 +6.630810E-07 +1.170893E-13 +1.130101E-01 +2.925076E-03 +7.210562E-04 +1.190805E-07 +9.098495E+06 +1.896014E+13 +2.202000E+00 +1.007194E+00 +3.378518E-04 +2.614296E-08 +5.565395E-01 +7.242839E-02 +2.955239E-02 +1.840142E-04 +1.400990E-02 +4.103227E-05 +3.502476E-02 +2.564517E-04 +2.308081E-07 +1.205491E-14 +3.480270E-02 +2.532102E-04 +2.220571E-04 +1.030824E-08 +2.801981E+06 +1.641291E+12 +6.090000E-01 +8.636300E-02 +1.040451E-04 +2.263074E-09 +1.817267E+00 +7.710225E-01 +7.367627E-02 +1.267666E-03 +2.535616E-02 +1.551036E-04 +6.339039E-02 +9.693976E-04 +2.524798E-07 +1.896478E-14 +6.298850E-02 +9.571446E-04 +4.018954E-04 +3.896557E-08 +5.071232E+06 +6.204145E+12 +1.881000E+00 +8.206930E-01 +1.883086E-04 +8.554511E-09 +4.106914E+00 +3.704316E+00 +1.888617E-01 +7.777635E-03 +7.727973E-02 +1.309080E-03 +1.931993E-01 +8.181751E-03 +1.061590E-06 +2.554724E-13 +1.919744E-01 +8.078335E-03 +1.224884E-03 +3.288708E-07 +1.545595E+07 +5.236321E+13 +4.223000E+00 +3.850821E+00 +5.739211E-04 +7.220038E-08 +2.346339E+00 +1.119793E+00 +1.017476E-01 +2.080323E-03 +3.865443E-02 +3.024337E-04 +9.663608E-02 +1.890211E-03 +4.714003E-07 +4.853805E-14 +9.602340E-02 +1.866319E-03 +6.126731E-04 +7.597824E-08 +7.730886E+06 +1.209735E+13 +2.338000E+00 +1.106368E+00 +2.870687E-04 +1.668028E-08 +6.446883E+00 +8.447751E+00 +2.867793E-01 +1.670093E-02 +1.126541E-01 +2.611201E-03 +2.816352E-01 +1.632001E-02 +1.453669E-06 +4.585416E-13 +2.798496E-01 +1.611372E-02 +1.785568E-03 +6.559933E-07 +2.253081E+07 +1.044480E+14 +6.454000E+00 +8.471478E+00 +8.366302E-04 +1.440169E-07 +1.219419E+00 +5.127750E-01 +4.857020E-02 +8.389250E-04 +1.623897E-02 +1.008738E-04 +4.059741E-02 +6.304611E-04 +1.503579E-07 +1.146797E-14 +4.034003E-02 +6.224921E-04 +2.573878E-04 +2.534179E-08 +3.247793E+06 +4.034951E+12 +1.199000E+00 +4.975810E-01 +1.205994E-04 +5.563543E-09 +3.623361E+00 +2.780040E+00 +1.560708E-01 +5.162316E-03 +5.875078E-02 +7.419979E-04 +1.468770E-01 +4.637487E-03 +7.048177E-07 +1.136014E-13 +1.459458E-01 +4.578870E-03 +9.312005E-04 +1.864068E-07 +1.175016E+07 +2.967992E+13 +3.668000E+00 +2.824270E+00 +4.363151E-04 +4.092380E-08 tally 13: -1.098420E+02 -2.414277E+03 -4.993000E+00 -4.986021E+00 -2.023763E+00 -8.192234E-01 -5.037812E+00 -5.086734E+00 -2.745346E-05 -1.509092E-10 -5.002505E+00 -5.014944E+00 -3.530702E-02 -2.695026E-04 -4.047525E+08 -3.276894E+16 -1.098420E+02 -2.414277E+03 -1.059695E-02 -2.782849E-05 -1.048490E+02 -2.199887E+03 -1.048490E+02 -2.199887E+03 +1.092010E+02 +2.386227E+03 +4.975000E+00 +4.950147E+00 +2.009472E+00 +8.076733E-01 +5.000649E+00 +5.012321E+00 +2.728992E-05 +1.491241E-10 +4.964474E+00 +4.939215E+00 +3.617555E-02 +2.875519E-04 +4.018944E+08 +3.230693E+16 +1.092010E+02 +2.386227E+03 +1.333979E-02 +5.019969E-05 +1.042260E+02 +2.173864E+03 +1.042260E+02 +2.173864E+03 tally 14: -1.098420E+02 -2.414277E+03 -5.008447E+00 -5.018748E+00 -2.028674E+00 -8.234818E-01 -5.071684E+00 -5.146761E+00 -5.050718E-05 -5.107669E-10 -5.039530E+00 -5.081707E+00 -3.215450E-02 -2.068774E-04 -4.057347E+08 -3.293927E+16 -1.098420E+02 -2.414277E+03 -1.506603E-02 -4.541792E-05 +1.092010E+02 +2.386227E+03 +4.979068E+00 +4.959690E+00 +2.016700E+00 +8.137138E-01 +5.041749E+00 +5.085712E+00 +5.020635E-05 +5.047241E-10 +5.009785E+00 +5.021429E+00 +3.196471E-02 +2.044235E-04 +4.033399E+08 +3.254855E+16 +1.092010E+02 +2.386227E+03 +1.497710E-02 +4.487918E-05 tally 15: -1.103689E+02 -2.437562E+03 -5.035611E+00 -5.073005E+00 -2.041209E+00 -8.337913E-01 -5.103022E+00 -5.211196E+00 -2.765405E-05 -1.532759E-10 -5.070669E+00 -5.145327E+00 -3.235318E-02 -2.094674E-04 -4.082417E+08 -3.335165E+16 -1.098580E+02 -2.414983E+03 -1.515912E-02 -4.598653E-05 +1.097121E+02 +2.408636E+03 +5.009145E+00 +5.019563E+00 +2.032191E+00 +8.264420E-01 +5.080477E+00 +5.165263E+00 +2.756641E-05 +1.523527E-10 +5.048267E+00 +5.099975E+00 +3.221025E-02 +2.076211E-04 +4.064382E+08 +3.305768E+16 +1.093810E+02 +2.394075E+03 +1.509215E-02 +4.558119E-05 tally 16: -1.048490E+02 -2.199887E+03 -1.048490E+02 -2.199887E+03 -5.037812E+00 -5.086734E+00 +1.042260E+02 +2.173864E+03 +1.042260E+02 +2.173864E+03 +5.000649E+00 +5.012321E+00 tally 17: -6.546000E+00 -8.579894E+00 -1.462000E+00 -4.278220E-01 -1.160697E+00 -2.696537E-01 -2.879845E+00 -1.663297E+00 -2.723379E-05 -1.485067E-10 -2.862628E+00 -1.643479E+00 -1.721726E-02 -6.055382E-05 -2.321395E+08 -1.078615E+16 -6.546000E+00 -8.579894E+00 -6.709978E-03 -1.387848E-05 -5.084000E+00 -5.178800E+00 -5.084000E+00 -5.178800E+00 -1.032960E+02 -2.135240E+03 +6.507000E+00 +8.478423E+00 +1.444000E+00 +4.172780E-01 +1.146407E+00 +2.630079E-01 +2.867025E+00 +1.647980E+00 +2.707153E-05 +1.467503E-10 +2.848880E+00 +1.627146E+00 +1.814469E-02 +6.685238E-05 +2.292814E+08 +1.052031E+16 +6.507000E+00 +8.478423E+00 +9.467712E-03 +2.396878E-05 +5.063000E+00 +5.136983E+00 +5.063000E+00 +5.136983E+00 +1.026940E+02 +2.110535E+03 3.531000E+00 -2.493943E+00 +2.493861E+00 8.630652E-01 -1.489973E-01 -2.157967E+00 -9.345420E-01 -2.196703E-07 -9.656558E-15 -2.139877E+00 -9.185178E-01 -1.808977E-02 -8.744581E-05 +1.489924E-01 +2.133624E+00 +9.150435E-01 +2.183901E-07 +9.544829E-15 +2.115593E+00 +8.991467E-01 +1.803087E-02 +8.677353E-05 1.726130E+08 -5.959891E+15 -1.032960E+02 -2.135240E+03 -3.886968E-03 -5.976458E-06 -9.976500E+01 -1.991860E+03 -9.976500E+01 -1.991860E+03 +5.959695E+15 +1.026940E+02 +2.110535E+03 +3.872081E-03 +5.919692E-06 +9.916300E+01 +1.968002E+03 +9.916300E+01 +1.968002E+03 tally 18: -6.546000E+00 -8.579894E+00 -1.464067E+00 -4.291919E-01 -1.162338E+00 -2.705171E-01 -2.905845E+00 -1.690732E+00 -4.985316E-05 -4.976401E-10 -2.887422E+00 -1.669362E+00 -1.842307E-02 -6.796008E-05 -2.324676E+08 -1.082069E+16 -6.546000E+00 -8.579894E+00 -8.632151E-03 -1.491997E-05 -1.032960E+02 -2.135240E+03 -3.544380E+00 -2.513971E+00 -8.663357E-01 -1.501938E-01 -2.165839E+00 -9.387115E-01 -6.540142E-07 -8.559612E-14 -2.152108E+00 -9.268463E-01 -1.373143E-02 -3.773212E-05 -1.732671E+08 -6.007753E+15 -1.032960E+02 -2.135240E+03 -6.433878E-03 -8.283719E-06 +6.507000E+00 +8.478423E+00 +1.455344E+00 +4.241161E-01 +1.155413E+00 +2.673178E-01 +2.888532E+00 +1.670737E+00 +4.955615E-05 +4.917547E-10 +2.870219E+00 +1.649619E+00 +1.831331E-02 +6.715634E-05 +2.310826E+08 +1.069271E+16 +6.507000E+00 +8.478423E+00 +8.580723E-03 +1.474352E-05 +1.026940E+02 +2.110535E+03 +3.523724E+00 +2.484884E+00 +8.612868E-01 +1.484560E-01 +2.153217E+00 +9.278503E-01 +6.502027E-07 +8.460574E-14 +2.139566E+00 +9.161225E-01 +1.365140E-02 +3.729555E-05 +1.722574E+08 +5.938242E+15 +1.026940E+02 +2.110535E+03 +6.396382E-03 +8.187874E-06 tally 19: -6.593971E+00 -8.715030E+00 -1.474796E+00 -4.359519E-01 -1.170856E+00 -2.747779E-01 -2.927140E+00 -1.717362E+00 -2.743336E-05 -1.508457E-10 -2.908582E+00 -1.695655E+00 -1.855808E-02 -6.903047E-05 -2.341712E+08 -1.099112E+16 -6.547000E+00 -8.582573E+00 -8.695410E-03 -1.515497E-05 -1.037750E+02 -2.155274E+03 -3.560815E+00 -2.537559E+00 -8.703528E-01 -1.516031E-01 -2.175882E+00 -9.475192E-01 -2.206889E-07 -9.747163E-15 -2.162087E+00 -9.355427E-01 -1.379510E-02 -3.808615E-05 -1.740706E+08 -6.064123E+15 -1.033110E+02 -2.135863E+03 -6.463712E-03 -8.361443E-06 +6.573230E+00 +8.663027E+00 +1.470157E+00 +4.333505E-01 +1.167173E+00 +2.731383E-01 +2.917933E+00 +1.707114E+00 +2.734707E-05 +1.499456E-10 +2.899433E+00 +1.685536E+00 +1.849971E-02 +6.861856E-05 +2.334346E+08 +1.092553E+16 +6.518000E+00 +8.507644E+00 +8.668060E-03 +1.506454E-05 +1.031389E+02 +2.128993E+03 +3.538988E+00 +2.506616E+00 +8.650177E-01 +1.497544E-01 +2.162544E+00 +9.359650E-01 +2.193361E-07 +9.628305E-15 +2.148834E+00 +9.241346E-01 +1.371054E-02 +3.762172E-05 +1.730035E+08 +5.990176E+15 +1.028630E+02 +2.117467E+03 +6.424090E-03 +8.259483E-06 tally 20: -5.084000E+00 -5.178800E+00 -5.084000E+00 -5.178800E+00 +5.063000E+00 +5.136983E+00 +5.063000E+00 +5.136983E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.879845E+00 -1.663297E+00 -1.463000E+00 -4.284330E-01 -1.463000E+00 -4.284330E-01 +2.867025E+00 +1.647980E+00 +1.445000E+00 +4.178610E-01 +1.445000E+00 +4.178610E-01 0.000000E+00 0.000000E+00 -9.830200E+01 -1.933884E+03 -9.830200E+01 -1.933884E+03 -2.157967E+00 -9.345420E-01 +9.771800E+01 +1.911083E+03 +9.771800E+01 +1.911083E+03 +2.133624E+00 +9.150435E-01 diff --git a/tests/regression_tests/mg_temperature/build_2g.py b/tests/regression_tests/mg_temperature/build_2g.py index bca87364e..1fb723449 100644 --- a/tests/regression_tests/mg_temperature/build_2g.py +++ b/tests/regression_tests/mg_temperature/build_2g.py @@ -227,7 +227,7 @@ def analytical_solution_2g_therm(xsmin, xsmax=None, wgt=1.0): L = np.array([sa[0] + ss12, 0.0, -ss12, sa[1]]).reshape(2, 2) Q = np.array([nsf[0], nsf[1], 0.0, 0.0]).reshape(2, 2) arr = np.linalg.inv(L).dot(Q) - return np.amax(np.linalg.eigvals(arr).real) + return np.amax(np.linalg.eigvals(arr)) def build_inf_model(xsnames, xslibname, temperature, tempmethod='nearest'): diff --git a/tests/regression_tests/mg_temperature/results_true.dat b/tests/regression_tests/mg_temperature/results_true.dat index 6de4c6bb1..19364e1d9 100644 --- a/tests/regression_tests/mg_temperature/results_true.dat +++ b/tests/regression_tests/mg_temperature/results_true.dat @@ -1,40 +1,40 @@ micro, method: nearest, t: 300.0, k-combined: -1.439913E+00 4.285638E-04 +1.439563E+00 4.526076E-04 kanalyt 1.440410E+00 micro, method: nearest, t: 600.0, k-combined: -1.410750E+00 4.829834E-04 +1.409389E+00 4.684481E-04 kanalyt 1.410164E+00 micro, method: nearest, t: 900.0, k-combined: -1.408232E+00 4.946310E-04 +1.407593E+00 4.410387E-04 kanalyt 1.407830E+00 micro, method: interpolation, t: 520.0, k-combined: -1.418877E+00 4.651822E-04 +1.418259E+00 4.242856E-04 kanalyt 1.418514E+00 micro, method: interpolation, t: 600.0, k-combined: -1.410750E+00 4.829834E-04 +1.409389E+00 4.684481E-04 kanalyt 1.410164E+00 macro, method: nearest, t: 300.0, k-combined: -1.439913E+00 4.285638E-04 +1.439563E+00 4.526076E-04 kanalyt 1.440410E+00 macro, method: nearest, t: 600.0, k-combined: -1.410750E+00 4.829834E-04 +1.409389E+00 4.684481E-04 kanalyt 1.410164E+00 macro, method: nearest, t: 900.0, k-combined: -1.408232E+00 4.946310E-04 +1.407593E+00 4.410387E-04 kanalyt 1.407830E+00 macro, method: interpolation, t: 520.0, k-combined: -1.418877E+00 4.651822E-04 +1.418259E+00 4.242856E-04 kanalyt 1.418514E+00 macro, method: interpolation, t: 600, k-combined: -1.410750E+00 4.829834E-04 +1.409389E+00 4.684481E-04 kanalyt 1.410164E+00 diff --git a/tests/regression_tests/mg_temperature_multi/inputs_true.dat b/tests/regression_tests/mg_temperature_multi/inputs_true.dat index b84a6782b..0c452cd52 100644 --- a/tests/regression_tests/mg_temperature_multi/inputs_true.dat +++ b/tests/regression_tests/mg_temperature_multi/inputs_true.dat @@ -3,31 +3,31 @@ mgxs.h5 - + - + - - - - - - - - - + + + + + + + + + eigenvalue 1000 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mg_temperature_multi/results_true.dat b/tests/regression_tests/mg_temperature_multi/results_true.dat index 3e2f990c8..80c2f5622 100644 --- a/tests/regression_tests/mg_temperature_multi/results_true.dat +++ b/tests/regression_tests/mg_temperature_multi/results_true.dat @@ -1,8 +1,8 @@ k-combined: -1.309371E+00 6.765039E-03 +1.337115E+00 7.221249E-03 tally 1: -2.532303E+01 -1.282689E+02 +2.549066E+01 +1.299987E+02 tally 2: -9.336894E+01 -1.743765E+03 +9.276778E+01 +1.721791E+03 diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_multiplicity_matrix.dat b/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true.dat similarity index 80% rename from tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_multiplicity_matrix.dat rename to tests/regression_tests/mgxs_library_ce_to_mg/inputs_true.dat index 2f6dde1ab..6c071263f 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_multiplicity_matrix.dat +++ b/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_scatter_matrix.dat b/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_scatter_matrix.dat deleted file mode 100644 index 6e60f1b19..000000000 --- a/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_scatter_matrix.dat +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - - - - 7 - - - 0.0 0.625 20000000.0 - - - 0.0 0.625 20000000.0 - - - 3 - - - 8 - - - 9 - - - 43 44 - total - flux - tracklength - - - 43 44 - total - total - tracklength - - - 43 44 - total - flux - tracklength - - - 43 44 - total - absorption - tracklength - - - 43 44 - total - flux - analog - - - 43 44 49 - total - nu-fission - analog - - - 43 44 - total - flux - analog - - - 43 44 49 53 - total - scatter - analog - - - 54 44 - total - flux - tracklength - - - 54 44 - total - total - tracklength - - - 54 44 - total - flux - tracklength - - - 54 44 - total - absorption - tracklength - - - 54 44 - total - flux - analog - - - 54 44 49 - total - nu-fission - analog - - - 54 44 - total - flux - analog - - - 54 44 49 53 - total - scatter - analog - - - 65 44 - total - flux - tracklength - - - 65 44 - total - total - tracklength - - - 65 44 - total - flux - tracklength - - - 65 44 - total - absorption - tracklength - - - 65 44 - total - flux - analog - - - 65 44 49 - total - nu-fission - analog - - - 65 44 - total - flux - analog - - - 65 44 49 53 - total - scatter - analog - - - diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/results_true.dat b/tests/regression_tests/mgxs_library_ce_to_mg/results_true.dat index 7ce106314..d95659534 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg/results_true.dat +++ b/tests/regression_tests/mgxs_library_ce_to_mg/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.152065E+00 2.768158E-02 +1.158563E+00 3.354681E-02 diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/test.py b/tests/regression_tests/mgxs_library_ce_to_mg/test.py index b68fbd6c3..4dff67323 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg/test.py +++ b/tests/regression_tests/mgxs_library_ce_to_mg/test.py @@ -9,7 +9,7 @@ from tests.regression_tests import config class MGXSTestHarness(PyAPITestHarness): - def __init__(self, *args, scatter_mgxs_type=None, **kwargs): + def __init__(self, *args, **kwargs): # Generate inputs using parent class routine super().__init__(*args, **kwargs) @@ -19,8 +19,8 @@ class MGXSTestHarness(PyAPITestHarness): # Initialize MGXS Library for a few cross section types self.mgxs_lib = openmc.mgxs.Library(self._model.geometry) self.mgxs_lib.by_nuclide = False - self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix'] - self.mgxs_lib.mgxs_types += scatter_mgxs_type + self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix', + 'nu-scatter matrix', 'multiplicity matrix'] self.mgxs_lib.energy_groups = energy_groups self.mgxs_lib.correction = None self.mgxs_lib.legendre_order = 3 @@ -28,7 +28,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _run_openmc(self): # Initial run @@ -40,8 +40,8 @@ class MGXSTestHarness(PyAPITestHarness): # Build MG Inputs # Get data needed to execute Library calculations. - with openmc.StatePoint(self._sp_name) as sp: - self.mgxs_lib.load_from_statepoint(sp) + sp = openmc.StatePoint(self._sp_name) + self.mgxs_lib.load_from_statepoint(sp) self._model.mgxs_file, self._model.materials, \ self._model.geometry = self.mgxs_lib.create_mg_mode() @@ -55,6 +55,11 @@ class MGXSTestHarness(PyAPITestHarness): self._model.export_to_model_xml() self._model.mgxs_file.export_to_hdf5() + # Enforce closing statepoint and summary files so HDF5 + # does not throw an error during the next OpenMC execution + sp._f.close() + sp._summary._f.close() + # Re-run MG mode. if config['mpi']: mpi_args = [config['mpiexec'], '-n', config['mpi_np']] @@ -69,23 +74,9 @@ class MGXSTestHarness(PyAPITestHarness): os.remove(f) -def test_mgxs_library_ce_to_mg_multiplicity_matrix(): +def test_mgxs_library_ce_to_mg(): # Set the input set to use the pincell model model = pwr_pin_cell() - harness = MGXSTestHarness( - 'statepoint.10.h5', model, - inputs_true='inputs_true_multiplicity_matrix.dat', - scatter_mgxs_type=['nu-scatter matrix', 'multiplicity matrix'] - ) - harness.main() - - -def test_mgxs_library_ce_to_mg_scatter_matrix(): - # Set the input set to use the pincell model - model = pwr_pin_cell() - - harness = MGXSTestHarness('statepoint.10.h5', model, - inputs_true='inputs_true_scatter_matrix.dat', - scatter_mgxs_type=['scatter matrix']) + harness = MGXSTestHarness('statepoint.10.h5', model) harness.main() diff --git a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/inputs_true.dat b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/inputs_true.dat index e1f330cf9..ad3d50974 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/results_true.dat b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/results_true.dat index 50c8328c8..a4e9dafcc 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/results_true.dat +++ b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.139942E-01 1.181308E-02 +6.025533E-01 1.157401E-02 diff --git a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py index 489105f8f..ee0cdf0d9 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py @@ -28,7 +28,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _run_openmc(self): # Initial run @@ -40,8 +40,8 @@ class MGXSTestHarness(PyAPITestHarness): # Build MG Inputs # Get data needed to execute Library calculations. - with openmc.StatePoint(self._sp_name) as sp: - self.mgxs_lib.load_from_statepoint(sp) + sp = openmc.StatePoint(self._sp_name) + self.mgxs_lib.load_from_statepoint(sp) self._model.mgxs_file, self._model.materials, \ self._model.geometry = self.mgxs_lib.create_mg_mode() @@ -55,6 +55,11 @@ class MGXSTestHarness(PyAPITestHarness): self._model.export_to_model_xml() self._model.mgxs_file.export_to_hdf5() + # Enforce closing statepoint and summary files so HDF5 + # does not throw an error during the next OpenMC execution + sp._f.close() + sp._summary._f.close() + # Re-run MG mode. if config['mpi']: mpi_args = [config['mpiexec'], '-n', config['mpi_np']] diff --git a/tests/regression_tests/mgxs_library_condense/inputs_true.dat b/tests/regression_tests/mgxs_library_condense/inputs_true.dat index 4451d214c..8606e9fdd 100644 --- a/tests/regression_tests/mgxs_library_condense/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_condense/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_condense/results_true.dat b/tests/regression_tests/mgxs_library_condense/results_true.dat index 023d5afa2..ae5bff6e3 100644 --- a/tests/regression_tests/mgxs_library_condense/results_true.dat +++ b/tests/regression_tests/mgxs_library_condense/results_true.dat @@ -1,362 +1,362 @@ - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.702881 0.026175 -2 1 2 1 total 0.706921 0.029169 -1 2 1 1 total 0.707809 0.024766 -3 2 2 1 total 0.717967 0.024008 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.431023 0.028803 -2 1 2 1 total 0.451864 0.030748 -1 2 1 1 total 0.456990 0.026359 -3 2 2 1 total 0.450621 0.026744 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.431023 0.028803 -2 1 2 1 total 0.451864 0.030748 -1 2 1 1 total 0.456990 0.026359 -3 2 2 1 total 0.450621 0.026744 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.022398 0.001401 -2 1 2 1 total 0.022325 0.001371 -1 2 1 1 total 0.022942 0.000990 -3 2 2 1 total 0.022705 0.001322 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.022394 0.001401 -2 1 2 1 total 0.022321 0.001371 -1 2 1 1 total 0.022935 0.000990 -3 2 2 1 total 0.022699 0.001322 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.011562 0.001544 -2 1 2 1 total 0.011852 0.001418 -1 2 1 1 total 0.012168 0.000958 -3 2 2 1 total 0.011986 0.001418 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.010836 0.000803 -2 1 2 1 total 0.010473 0.000591 -1 2 1 1 total 0.010774 0.000415 -3 2 2 1 total 0.010719 0.000688 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.026602 0.001957 -2 1 2 1 total 0.025695 0.001442 -1 2 1 1 total 0.026454 0.001015 -3 2 2 1 total 0.026310 0.001678 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 2.098256e+06 155243.612264 -2 1 2 1 total 2.027699e+06 114334.400924 -1 2 1 1 total 2.086255e+06 80325.567787 -3 2 2 1 total 2.075596e+06 133128.805680 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.680483 0.025407 -2 1 2 1 total 0.684597 0.028126 -1 2 1 1 total 0.684867 0.024133 -3 2 2 1 total 0.695262 0.023087 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.678017 0.026288 -2 1 2 1 total 0.674888 0.033989 -1 2 1 1 total 0.681736 0.025618 -3 2 2 1 total 0.683701 0.023788 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.678017 0.026290 -1 1 1 1 1 P1 total 0.271858 0.011693 -2 1 1 1 1 P2 total 0.095219 0.002950 -3 1 1 1 1 P3 total 0.012808 0.004686 -8 1 2 1 1 P0 total 0.674888 0.033578 -9 1 2 1 1 P1 total 0.255058 0.009912 -10 1 2 1 1 P2 total 0.098001 0.005459 -11 1 2 1 1 P3 total 0.012058 0.005439 -4 2 1 1 1 P0 total 0.681736 0.025439 -5 2 1 1 1 P1 total 0.250820 0.009035 -6 2 1 1 1 P2 total 0.092563 0.006549 -7 2 1 1 1 P3 total 0.008511 0.003905 -12 2 2 1 1 P0 total 0.683701 0.024254 -13 2 2 1 1 P1 total 0.267345 0.011695 -14 2 2 1 1 P2 total 0.096222 0.005551 -15 2 2 1 1 P3 total 0.011515 0.003236 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.678017 0.026290 -1 1 1 1 1 P1 total 0.271858 0.011693 -2 1 1 1 1 P2 total 0.095219 0.002950 -3 1 1 1 1 P3 total 0.012808 0.004686 -8 1 2 1 1 P0 total 0.674888 0.033578 -9 1 2 1 1 P1 total 0.255058 0.009912 -10 1 2 1 1 P2 total 0.098001 0.005459 -11 1 2 1 1 P3 total 0.012058 0.005439 -4 2 1 1 1 P0 total 0.681736 0.025439 -5 2 1 1 1 P1 total 0.250820 0.009035 -6 2 1 1 1 P2 total 0.092563 0.006549 -7 2 1 1 1 P3 total 0.008511 0.003905 -12 2 2 1 1 P0 total 0.683701 0.024254 -13 2 2 1 1 P1 total 0.267345 0.011695 -14 2 2 1 1 P2 total 0.096222 0.005551 -15 2 2 1 1 P3 total 0.011515 0.003236 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 1.0 0.041785 -2 1 2 1 1 total 1.0 0.057717 -1 2 1 1 1 total 1.0 0.040074 -3 2 2 1 1 total 1.0 0.042758 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 0.028438 0.003513 -2 1 2 1 1 total 0.022222 0.001560 -1 2 1 1 1 total 0.025698 0.002756 -3 2 2 1 1 total 0.026501 0.002315 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 1.0 0.041785 -2 1 2 1 1 total 1.0 0.057717 -1 2 1 1 1 total 1.0 0.040074 -3 2 2 1 1 total 1.0 0.042758 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.680483 0.038131 -1 1 1 1 1 P1 total 0.272847 0.016111 -2 1 1 1 1 P2 total 0.095565 0.004869 -3 1 1 1 1 P3 total 0.012854 0.004731 -8 1 2 1 1 P0 total 0.684597 0.048501 -9 1 2 1 1 P1 total 0.258727 0.016473 -10 1 2 1 1 P2 total 0.099411 0.007470 -11 1 2 1 1 P3 total 0.012231 0.005552 -4 2 1 1 1 P0 total 0.684867 0.036546 -5 2 1 1 1 P1 total 0.251972 0.013220 -6 2 1 1 1 P2 total 0.092988 0.007474 -7 2 1 1 1 P3 total 0.008550 0.003936 -12 2 2 1 1 P0 total 0.695262 0.037640 -13 2 2 1 1 P1 total 0.271866 0.016280 -14 2 2 1 1 P2 total 0.097849 0.006919 -15 2 2 1 1 P3 total 0.011710 0.003325 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.680483 0.047566 -1 1 1 1 1 P1 total 0.272847 0.019737 -2 1 1 1 1 P2 total 0.095565 0.006297 -3 1 1 1 1 P3 total 0.012854 0.004762 -8 1 2 1 1 P0 total 0.684597 0.062559 -9 1 2 1 1 P1 total 0.258727 0.022234 -10 1 2 1 1 P2 total 0.099411 0.009420 -11 1 2 1 1 P3 total 0.012231 0.005597 -4 2 1 1 1 P0 total 0.684867 0.045704 -5 2 1 1 1 P1 total 0.251972 0.016635 -6 2 1 1 1 P2 total 0.092988 0.008352 -7 2 1 1 1 P3 total 0.008550 0.003951 -12 2 2 1 1 P0 total 0.695262 0.047964 -13 2 2 1 1 P1 total 0.271866 0.020004 -14 2 2 1 1 P2 total 0.097849 0.008086 -15 2 2 1 1 P3 total 0.011710 0.003363 - mesh 1 group out nuclide mean std. dev. - x y -0 1 1 1 total 1.0 0.142430 -2 1 2 1 total 1.0 0.112715 -1 2 1 1 total 1.0 0.192385 -3 2 2 1 total 1.0 0.109836 - mesh 1 group out nuclide mean std. dev. - x y -0 1 1 1 total 1.0 0.143959 -2 1 2 1 total 1.0 0.102504 -1 2 1 1 total 1.0 0.188381 -3 2 2 1 total 1.0 0.116230 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 5.060544e-07 3.651604e-08 -2 1 2 1 total 5.101988e-07 4.947639e-08 -1 2 1 1 total 5.206450e-07 2.814648e-08 -3 2 2 1 total 5.278759e-07 3.171554e-08 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.026414 0.001944 -2 1 2 1 total 0.025515 0.001432 -1 2 1 1 total 0.026267 0.001008 -3 2 2 1 total 0.026125 0.001667 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 0.028220 0.003510 -2 1 2 1 1 total 0.021754 0.001519 -1 2 1 1 1 total 0.025487 0.002676 -3 2 2 1 1 total 0.026281 0.002263 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.699306 0.028642 +2 1 2 1 1 total 0.687913 0.025966 +1 2 1 1 1 total 0.716035 0.018945 +3 2 2 1 1 total 0.702630 0.028574 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.443642 0.030984 +2 1 2 1 1 total 0.429968 0.028072 +1 2 1 1 1 total 0.461535 0.021345 +3 2 2 1 1 total 0.439454 0.031232 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.443642 0.030984 +2 1 2 1 1 total 0.429968 0.028072 +1 2 1 1 1 total 0.461535 0.021345 +3 2 2 1 1 total 0.439454 0.031232 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.021895 0.001041 +2 1 2 1 1 total 0.021903 0.001108 +1 2 1 1 1 total 0.024895 0.001401 +3 2 2 1 1 total 0.022105 0.001198 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.021883 0.001040 +2 1 2 1 1 total 0.021879 0.001108 +1 2 1 1 1 total 0.024875 0.001401 +3 2 2 1 1 total 0.022071 0.001197 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.011219 0.000958 +2 1 2 1 1 total 0.011437 0.001013 +1 2 1 1 1 total 0.012947 0.001437 +3 2 2 1 1 total 0.011756 0.001144 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.010676 0.000481 +2 1 2 1 1 total 0.010466 0.000446 +1 2 1 1 1 total 0.011948 0.000517 +3 2 2 1 1 total 0.010350 0.000547 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.026218 0.001180 +2 1 2 1 1 total 0.025724 0.001093 +1 2 1 1 1 total 0.029326 0.001262 +3 2 2 1 1 total 0.025451 0.001338 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 2.067337e+06 93152.452502 +2 1 2 1 1 total 2.026907e+06 86377.585629 +1 2 1 1 1 total 2.313358e+06 99980.823985 +3 2 2 1 1 total 2.004370e+06 105820.022073 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.677411 0.027731 +2 1 2 1 1 total 0.666009 0.025155 +1 2 1 1 1 total 0.691140 0.018119 +3 2 2 1 1 total 0.680525 0.027587 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.679832 0.030242 +2 1 2 1 1 total 0.663143 0.019259 +1 2 1 1 1 total 0.679503 0.027107 +3 2 2 1 1 total 0.681909 0.033506 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.679832 0.030426 +1 1 1 1 1 1 P1 total 0.255665 0.011704 +2 1 1 1 1 1 P2 total 0.087020 0.005603 +3 1 1 1 1 1 P3 total 0.006425 0.005919 +8 1 2 1 1 1 P0 total 0.663143 0.019088 +9 1 2 1 1 1 P1 total 0.257945 0.010887 +10 1 2 1 1 1 P2 total 0.095395 0.006988 +11 1 2 1 1 1 P3 total 0.009816 0.003950 +4 2 1 1 1 1 P0 total 0.679503 0.026695 +5 2 1 1 1 1 P1 total 0.254500 0.009901 +6 2 1 1 1 1 P2 total 0.093289 0.005481 +7 2 1 1 1 1 P3 total 0.004631 0.004081 +12 2 2 1 1 1 P0 total 0.681909 0.032740 +13 2 2 1 1 1 P1 total 0.263176 0.012659 +14 2 2 1 1 1 P2 total 0.093102 0.006603 +15 2 2 1 1 1 P3 total 0.007938 0.005673 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.679832 0.030426 +1 1 1 1 1 1 P1 total 0.255665 0.011704 +2 1 1 1 1 1 P2 total 0.087020 0.005603 +3 1 1 1 1 1 P3 total 0.006425 0.005919 +8 1 2 1 1 1 P0 total 0.663143 0.019088 +9 1 2 1 1 1 P1 total 0.257945 0.010887 +10 1 2 1 1 1 P2 total 0.095395 0.006988 +11 1 2 1 1 1 P3 total 0.009816 0.003950 +4 2 1 1 1 1 P0 total 0.679503 0.026695 +5 2 1 1 1 1 P1 total 0.254500 0.009901 +6 2 1 1 1 1 P2 total 0.093289 0.005481 +7 2 1 1 1 1 P3 total 0.004631 0.004081 +12 2 2 1 1 1 P0 total 0.681909 0.032740 +13 2 2 1 1 1 P1 total 0.263176 0.012659 +14 2 2 1 1 1 P2 total 0.093102 0.006603 +15 2 2 1 1 1 P3 total 0.007938 0.005673 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 1.0 0.041183 +2 1 2 1 1 1 total 1.0 0.021636 +1 2 1 1 1 1 total 1.0 0.046661 +3 2 2 1 1 1 total 1.0 0.041512 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.027090 0.002808 +2 1 2 1 1 1 total 0.031522 0.004261 +1 2 1 1 1 1 total 0.021855 0.001457 +3 2 2 1 1 1 total 0.028262 0.002358 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 1.0 0.041183 +2 1 2 1 1 1 total 1.0 0.021636 +1 2 1 1 1 1 total 1.0 0.046661 +3 2 2 1 1 1 total 1.0 0.041512 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.677411 0.039336 +1 1 1 1 1 1 P1 total 0.254754 0.014995 +2 1 1 1 1 1 P2 total 0.086711 0.006439 +3 1 1 1 1 1 P3 total 0.006402 0.005903 +8 1 2 1 1 1 P0 total 0.666009 0.028990 +9 1 2 1 1 1 P1 total 0.259060 0.013824 +10 1 2 1 1 1 P2 total 0.095807 0.007684 +11 1 2 1 1 1 P3 total 0.009858 0.003980 +4 2 1 1 1 1 P0 total 0.691140 0.036991 +5 2 1 1 1 1 P1 total 0.258859 0.013782 +6 2 1 1 1 1 P2 total 0.094887 0.006555 +7 2 1 1 1 1 P3 total 0.004710 0.004154 +12 2 2 1 1 1 P0 total 0.680525 0.039486 +13 2 2 1 1 1 P1 total 0.262642 0.015259 +14 2 2 1 1 1 P2 total 0.092913 0.007251 +15 2 2 1 1 1 P3 total 0.007921 0.005668 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.677411 0.048224 +1 1 1 1 1 1 P1 total 0.254754 0.018301 +2 1 1 1 1 1 P2 total 0.086711 0.007363 +3 1 1 1 1 1 P3 total 0.006402 0.005909 +8 1 2 1 1 1 P0 total 0.666009 0.032374 +9 1 2 1 1 1 P1 total 0.259060 0.014917 +10 1 2 1 1 1 P2 total 0.095807 0.007958 +11 1 2 1 1 1 P3 total 0.009858 0.003985 +4 2 1 1 1 1 P0 total 0.691140 0.049075 +5 2 1 1 1 1 P1 total 0.258859 0.018326 +6 2 1 1 1 1 P2 total 0.094887 0.007910 +7 2 1 1 1 1 P3 total 0.004710 0.004160 +12 2 2 1 1 1 P0 total 0.680525 0.048551 +13 2 2 1 1 1 P1 total 0.262642 0.018754 +14 2 2 1 1 1 P2 total 0.092913 0.008213 +15 2 2 1 1 1 P3 total 0.007921 0.005677 + mesh 1 group out nuclide mean std. dev. + x y z +0 1 1 1 1 total 1.0 0.103333 +2 1 2 1 1 total 1.0 0.118582 +1 2 1 1 1 total 1.0 0.112144 +3 2 2 1 1 total 1.0 0.130701 + mesh 1 group out nuclide mean std. dev. + x y z +0 1 1 1 1 total 1.0 0.103333 +2 1 2 1 1 total 1.0 0.118582 +1 2 1 1 1 total 1.0 0.112144 +3 2 2 1 1 total 1.0 0.130701 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 5.304285e-07 2.560239e-08 +2 1 2 1 1 total 4.940321e-07 2.410417e-08 +1 2 1 1 1 total 5.587365e-07 3.382787e-08 +3 2 2 1 1 total 5.232210e-07 2.482800e-08 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.026032 0.001172 +2 1 2 1 1 total 0.025542 0.001086 +1 2 1 1 1 total 0.029121 0.001254 +3 2 2 1 1 total 0.025271 0.001329 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.027090 0.002808 +2 1 2 1 1 1 total 0.031522 0.004261 +1 2 1 1 1 1 total 0.021855 0.001457 +3 2 2 1 1 1 total 0.028262 0.002358 mesh 1 group in nuclide mean std. dev. x y surf -3 1 1 x-max in 1 total 4.244 0.096333 -2 1 1 x-max out 1 total 4.378 0.107210 +3 1 1 x-max in 1 total 4.280 0.164469 +2 1 1 x-max out 1 total 4.250 0.107135 1 1 1 x-min in 1 total 0.000 0.000000 0 1 1 x-min out 1 total 0.000 0.000000 -7 1 1 y-max in 1 total 4.388 0.116508 -6 1 1 y-max out 1 total 4.284 0.129066 +7 1 1 y-max in 1 total 4.364 0.105622 +6 1 1 y-max out 1 total 4.412 0.158019 5 1 1 y-min in 1 total 0.000 0.000000 4 1 1 y-min out 1 total 0.000 0.000000 -19 1 2 x-max in 1 total 4.280 0.139971 -18 1 2 x-max out 1 total 4.152 0.117141 +19 1 2 x-max in 1 total 4.388 0.102470 +18 1 2 x-max out 1 total 4.428 0.140228 17 1 2 x-min in 1 total 0.000 0.000000 16 1 2 x-min out 1 total 0.000 0.000000 23 1 2 y-max in 1 total 0.000 0.000000 22 1 2 y-max out 1 total 0.000 0.000000 -21 1 2 y-min in 1 total 4.284 0.129066 -20 1 2 y-min out 1 total 4.388 0.116508 +21 1 2 y-min in 1 total 4.412 0.158019 +20 1 2 y-min out 1 total 4.364 0.105622 11 2 1 x-max in 1 total 0.000 0.000000 10 2 1 x-max out 1 total 0.000 0.000000 -9 2 1 x-min in 1 total 4.378 0.107210 -8 2 1 x-min out 1 total 4.244 0.096333 -15 2 1 y-max in 1 total 4.280 0.079070 -14 2 1 y-max out 1 total 4.416 0.093648 +9 2 1 x-min in 1 total 4.250 0.107135 +8 2 1 x-min out 1 total 4.280 0.164469 +15 2 1 y-max in 1 total 4.402 0.182565 +14 2 1 y-max out 1 total 4.346 0.148189 13 2 1 y-min in 1 total 0.000 0.000000 12 2 1 y-min out 1 total 0.000 0.000000 27 2 2 x-max in 1 total 0.000 0.000000 26 2 2 x-max out 1 total 0.000 0.000000 -25 2 2 x-min in 1 total 4.152 0.117141 -24 2 2 x-min out 1 total 4.280 0.139971 +25 2 2 x-min in 1 total 4.428 0.140228 +24 2 2 x-min out 1 total 4.388 0.102470 31 2 2 y-max in 1 total 0.000 0.000000 30 2 2 y-max out 1 total 0.000 0.000000 -29 2 2 y-min in 1 total 4.416 0.093648 -28 2 2 y-min out 1 total 4.280 0.079070 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.943198 0.067915 -2 1 2 1 total 0.895741 0.058714 -1 2 1 1 total 0.911011 0.068461 -3 2 2 1 total 0.927611 0.066426 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.943198 0.067915 -2 1 2 1 total 0.895741 0.058714 -1 2 1 1 total 0.911011 0.068461 -3 2 2 1 total 0.927611 0.066426 - mesh 1 delayedgroup group in nuclide mean std. dev. - x y -0 1 1 1 1 total 0.000006 4.453421e-07 -1 1 1 2 1 total 0.000032 2.303082e-06 -2 1 1 3 1 total 0.000031 2.202789e-06 -3 1 1 4 1 total 0.000072 4.961025e-06 -4 1 1 5 1 total 0.000032 2.071919e-06 -5 1 1 6 1 total 0.000013 8.662934e-07 -12 1 2 1 1 total 0.000006 3.282329e-07 -13 1 2 2 1 total 0.000031 1.701766e-06 -14 1 2 3 1 total 0.000030 1.629615e-06 -15 1 2 4 1 total 0.000070 3.675759e-06 -16 1 2 5 1 total 0.000031 1.536226e-06 -17 1 2 6 1 total 0.000013 6.423838e-07 -6 2 1 1 1 total 0.000006 2.308186e-07 -7 2 1 2 1 total 0.000032 1.211112e-06 -8 2 1 3 1 total 0.000031 1.169911e-06 -9 2 1 4 1 total 0.000072 2.685832e-06 -10 2 1 5 1 total 0.000032 1.187072e-06 -11 2 1 6 1 total 0.000013 4.939053e-07 -18 2 2 1 1 total 0.000006 3.819684e-07 -19 2 2 2 1 total 0.000032 1.976073e-06 -20 2 2 3 1 total 0.000031 1.889748e-06 -21 2 2 4 1 total 0.000072 4.252207e-06 -22 2 2 5 1 total 0.000032 1.765565e-06 -23 2 2 6 1 total 0.000013 7.386890e-07 - mesh 1 delayedgroup group out nuclide mean std. dev. - x y -0 1 1 1 1 total 0.0 0.000000 -1 1 1 2 1 total 0.0 0.000000 -2 1 1 3 1 total 0.0 0.000000 -3 1 1 4 1 total 1.0 1.414214 -4 1 1 5 1 total 0.0 0.000000 -5 1 1 6 1 total 0.0 0.000000 -12 1 2 1 1 total 0.0 0.000000 -13 1 2 2 1 total 0.0 0.000000 -14 1 2 3 1 total 0.0 0.000000 -15 1 2 4 1 total 1.0 0.869026 -16 1 2 5 1 total 0.0 0.000000 -17 1 2 6 1 total 0.0 0.000000 -6 2 1 1 1 total 0.0 0.000000 -7 2 1 2 1 total 0.0 0.000000 -8 2 1 3 1 total 0.0 0.000000 -9 2 1 4 1 total 1.0 1.414214 -10 2 1 5 1 total 0.0 0.000000 -11 2 1 6 1 total 0.0 0.000000 -18 2 2 1 1 total 0.0 0.000000 -19 2 2 2 1 total 0.0 0.000000 -20 2 2 3 1 total 0.0 0.000000 -21 2 2 4 1 total 1.0 1.414214 -22 2 2 5 1 total 0.0 0.000000 -23 2 2 6 1 total 0.0 0.000000 - mesh 1 delayedgroup group in nuclide mean std. dev. - x y -0 1 1 1 1 total 0.000227 0.000023 -1 1 1 2 1 total 0.001210 0.000119 -2 1 1 3 1 total 0.001176 0.000114 -3 1 1 4 1 total 0.002722 0.000261 -4 1 1 5 1 total 0.001204 0.000112 -5 1 1 6 1 total 0.000501 0.000047 -12 1 2 1 1 total 0.000227 0.000017 -13 1 2 2 1 total 0.001208 0.000087 -14 1 2 3 1 total 0.001174 0.000084 -15 1 2 4 1 total 0.002710 0.000192 -16 1 2 5 1 total 0.001194 0.000082 -17 1 2 6 1 total 0.000497 0.000034 -6 2 1 1 1 total 0.000227 0.000010 -7 2 1 2 1 total 0.001210 0.000053 -8 2 1 3 1 total 0.001177 0.000052 -9 2 1 4 1 total 0.002726 0.000119 -10 2 1 5 1 total 0.001208 0.000053 -11 2 1 6 1 total 0.000503 0.000022 -18 2 2 1 1 total 0.000227 0.000019 -19 2 2 2 1 total 0.001211 0.000102 -20 2 2 3 1 total 0.001178 0.000098 -21 2 2 4 1 total 0.002726 0.000223 -22 2 2 5 1 total 0.001207 0.000096 -23 2 2 6 1 total 0.000503 0.000040 - mesh 1 delayedgroup nuclide mean std. dev. - x y -0 1 1 1 total 0.013353 0.001345 -1 1 1 2 total 0.032619 0.003120 -2 1 1 3 total 0.121042 0.011142 -3 1 1 4 total 0.305503 0.026418 -4 1 1 5 total 0.860433 0.064665 -5 1 1 6 total 2.889963 0.219527 -12 1 2 1 total 0.013352 0.001049 -13 1 2 2 total 0.032626 0.002465 -14 1 2 3 total 0.121027 0.008891 -15 1 2 4 total 0.305351 0.021426 -16 1 2 5 total 0.859866 0.054490 -17 1 2 6 total 2.888034 0.184436 -6 2 1 1 total 0.013353 0.000612 -7 2 1 2 total 0.032616 0.001412 -8 2 1 3 total 0.121047 0.005039 -9 2 1 4 total 0.305559 0.012002 -10 2 1 5 total 0.860640 0.030707 -11 2 1 6 total 2.890664 0.103692 -18 2 2 1 total 0.013353 0.001132 -19 2 2 2 total 0.032617 0.002633 -20 2 2 3 total 0.121046 0.009426 -21 2 2 4 total 0.305545 0.022417 -22 2 2 5 total 0.860588 0.055030 -23 2 2 6 total 2.890489 0.186821 - mesh 1 delayedgroup group in group out nuclide mean std. dev. - x y -0 1 1 1 1 1 total 0.000000 0.000000 -1 1 1 2 1 1 total 0.000000 0.000000 -2 1 1 3 1 1 total 0.000000 0.000000 -3 1 1 4 1 1 total 0.000219 0.000219 -4 1 1 5 1 1 total 0.000000 0.000000 -5 1 1 6 1 1 total 0.000000 0.000000 -12 1 2 1 1 1 total 0.000000 0.000000 -13 1 2 2 1 1 total 0.000000 0.000000 -14 1 2 3 1 1 total 0.000000 0.000000 -15 1 2 4 1 1 total 0.000467 0.000287 -16 1 2 5 1 1 total 0.000000 0.000000 -17 1 2 6 1 1 total 0.000000 0.000000 -6 2 1 1 1 1 total 0.000000 0.000000 -7 2 1 2 1 1 total 0.000000 0.000000 -8 2 1 3 1 1 total 0.000000 0.000000 -9 2 1 4 1 1 total 0.000211 0.000211 -10 2 1 5 1 1 total 0.000000 0.000000 -11 2 1 6 1 1 total 0.000000 0.000000 -18 2 2 1 1 1 total 0.000000 0.000000 -19 2 2 2 1 1 total 0.000000 0.000000 -20 2 2 3 1 1 total 0.000000 0.000000 -21 2 2 4 1 1 total 0.000219 0.000219 -22 2 2 5 1 1 total 0.000000 0.000000 -23 2 2 6 1 1 total 0.000000 0.000000 +29 2 2 y-min in 1 total 4.346 0.148189 +28 2 2 y-min out 1 total 4.402 0.182565 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.950616 0.095874 +2 1 2 1 1 total 0.932532 0.086323 +1 2 1 1 1 total 0.885723 0.041074 +3 2 2 1 1 total 0.951783 0.101570 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.950616 0.095874 +2 1 2 1 1 total 0.932532 0.086323 +1 2 1 1 1 total 0.885723 0.041074 +3 2 2 1 1 total 0.951783 0.101570 + mesh 1 delayedgroup group in nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.000006 2.679142e-07 +1 1 1 1 2 1 total 0.000032 1.417723e-06 +2 1 1 1 3 1 total 0.000031 1.376260e-06 +3 1 1 1 4 1 total 0.000072 3.185580e-06 +4 1 1 1 5 1 total 0.000032 1.433425e-06 +5 1 1 1 6 1 total 0.000013 5.956400e-07 +12 1 2 1 1 1 total 0.000006 2.486865e-07 +13 1 2 1 2 1 total 0.000031 1.323941e-06 +14 1 2 1 3 1 total 0.000030 1.292803e-06 +15 1 2 1 4 1 total 0.000071 3.032740e-06 +16 1 2 1 5 1 total 0.000031 1.426193e-06 +17 1 2 1 6 1 total 0.000013 5.903673e-07 +6 2 1 1 1 1 total 0.000007 2.871910e-07 +7 2 1 1 2 1 total 0.000035 1.501590e-06 +8 2 1 1 3 1 total 0.000034 1.448170e-06 +9 2 1 1 4 1 total 0.000079 3.318195e-06 +10 2 1 1 5 1 total 0.000035 1.465737e-06 +11 2 1 1 6 1 total 0.000015 6.097547e-07 +18 2 2 1 1 1 total 0.000006 3.042761e-07 +19 2 2 1 2 1 total 0.000031 1.603780e-06 +20 2 2 1 3 1 total 0.000030 1.553523e-06 +21 2 2 1 4 1 total 0.000070 3.583849e-06 +22 2 2 1 5 1 total 0.000031 1.602620e-06 +23 2 2 1 6 1 total 0.000013 6.662067e-07 + mesh 1 delayedgroup group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.0 0.0 +1 1 1 1 2 1 total 0.0 0.0 +2 1 1 1 3 1 total 0.0 0.0 +3 1 1 1 4 1 total 0.0 0.0 +4 1 1 1 5 1 total 0.0 0.0 +5 1 1 1 6 1 total 0.0 0.0 +12 1 2 1 1 1 total 0.0 0.0 +13 1 2 1 2 1 total 0.0 0.0 +14 1 2 1 3 1 total 0.0 0.0 +15 1 2 1 4 1 total 0.0 0.0 +16 1 2 1 5 1 total 0.0 0.0 +17 1 2 1 6 1 total 0.0 0.0 +6 2 1 1 1 1 total 0.0 0.0 +7 2 1 1 2 1 total 0.0 0.0 +8 2 1 1 3 1 total 0.0 0.0 +9 2 1 1 4 1 total 0.0 0.0 +10 2 1 1 5 1 total 0.0 0.0 +11 2 1 1 6 1 total 0.0 0.0 +18 2 2 1 1 1 total 0.0 0.0 +19 2 2 1 2 1 total 0.0 0.0 +20 2 2 1 3 1 total 0.0 0.0 +21 2 2 1 4 1 total 0.0 0.0 +22 2 2 1 5 1 total 0.0 0.0 +23 2 2 1 6 1 total 0.0 0.0 + mesh 1 delayedgroup group in nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.000227 0.000011 +1 1 1 1 2 1 total 0.001212 0.000058 +2 1 1 1 3 1 total 0.001180 0.000057 +3 1 1 1 4 1 total 0.002734 0.000131 +4 1 1 1 5 1 total 0.001215 0.000059 +5 1 1 1 6 1 total 0.000506 0.000024 +12 1 2 1 1 1 total 0.000227 0.000010 +13 1 2 1 2 1 total 0.001213 0.000052 +14 1 2 1 3 1 total 0.001182 0.000051 +15 1 2 1 4 1 total 0.002744 0.000120 +16 1 2 1 5 1 total 0.001223 0.000056 +17 1 2 1 6 1 total 0.000509 0.000023 +6 2 1 1 1 1 total 0.000227 0.000013 +7 2 1 1 2 1 total 0.001207 0.000067 +8 2 1 1 3 1 total 0.001173 0.000065 +9 2 1 1 4 1 total 0.002710 0.000150 +10 2 1 1 5 1 total 0.001195 0.000066 +11 2 1 1 6 1 total 0.000498 0.000027 +18 2 2 1 1 1 total 0.000227 0.000014 +19 2 2 1 2 1 total 0.001212 0.000073 +20 2 2 1 3 1 total 0.001180 0.000071 +21 2 2 1 4 1 total 0.002740 0.000163 +22 2 2 1 5 1 total 0.001221 0.000073 +23 2 2 1 6 1 total 0.000508 0.000030 + mesh 1 delayedgroup nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.013354 0.000674 +1 1 1 1 2 total 0.032612 0.001720 +2 1 1 1 3 total 0.121057 0.006579 +3 1 1 1 4 total 0.305656 0.017398 +4 1 1 1 5 total 0.861000 0.053768 +5 1 1 1 6 total 2.891889 0.179407 +12 1 2 1 1 total 0.013354 0.000497 +13 1 2 1 2 total 0.032605 0.001150 +14 1 2 1 3 total 0.121071 0.004175 +15 1 2 1 4 total 0.305792 0.010484 +16 1 2 1 5 total 0.861500 0.032627 +17 1 2 1 6 total 2.893589 0.108347 +6 2 1 1 1 total 0.013352 0.000663 +7 2 1 1 2 total 0.032625 0.001570 +8 2 1 1 3 total 0.121029 0.005721 +9 2 1 1 4 total 0.305375 0.014144 +10 2 1 1 5 total 0.859955 0.039608 +11 2 1 1 6 total 2.888337 0.132844 +18 2 2 1 1 total 0.013354 0.000892 +19 2 2 1 2 total 0.032606 0.002209 +20 2 2 1 3 total 0.121069 0.008302 +21 2 2 1 4 total 0.305776 0.021416 +22 2 2 1 5 total 0.861442 0.063571 +23 2 2 1 6 total 2.893392 0.212640 + mesh 1 delayedgroup group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 1 total 0.0 0.0 +1 1 1 1 2 1 1 total 0.0 0.0 +2 1 1 1 3 1 1 total 0.0 0.0 +3 1 1 1 4 1 1 total 0.0 0.0 +4 1 1 1 5 1 1 total 0.0 0.0 +5 1 1 1 6 1 1 total 0.0 0.0 +12 1 2 1 1 1 1 total 0.0 0.0 +13 1 2 1 2 1 1 total 0.0 0.0 +14 1 2 1 3 1 1 total 0.0 0.0 +15 1 2 1 4 1 1 total 0.0 0.0 +16 1 2 1 5 1 1 total 0.0 0.0 +17 1 2 1 6 1 1 total 0.0 0.0 +6 2 1 1 1 1 1 total 0.0 0.0 +7 2 1 1 2 1 1 total 0.0 0.0 +8 2 1 1 3 1 1 total 0.0 0.0 +9 2 1 1 4 1 1 total 0.0 0.0 +10 2 1 1 5 1 1 total 0.0 0.0 +11 2 1 1 6 1 1 total 0.0 0.0 +18 2 2 1 1 1 1 total 0.0 0.0 +19 2 2 1 2 1 1 total 0.0 0.0 +20 2 2 1 3 1 1 total 0.0 0.0 +21 2 2 1 4 1 1 total 0.0 0.0 +22 2 2 1 5 1 1 total 0.0 0.0 +23 2 2 1 6 1 1 total 0.0 0.0 diff --git a/tests/regression_tests/mgxs_library_condense/test.py b/tests/regression_tests/mgxs_library_condense/test.py index bbc4c11bf..a7e60617f 100644 --- a/tests/regression_tests/mgxs_library_condense/test.py +++ b/tests/regression_tests/mgxs_library_condense/test.py @@ -36,7 +36,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_correction/inputs_true.dat b/tests/regression_tests/mgxs_library_correction/inputs_true.dat index bb463778f..ea2d1b714 100644 --- a/tests/regression_tests/mgxs_library_correction/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_correction/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_correction/results_true.dat b/tests/regression_tests/mgxs_library_correction/results_true.dat index b6aaad044..ff4bd9746 100644 --- a/tests/regression_tests/mgxs_library_correction/results_true.dat +++ b/tests/regression_tests/mgxs_library_correction/results_true.dat @@ -1,60 +1,60 @@ material group in group out nuclide mean std. dev. -3 1 1 1 total 0.353477 0.019952 -2 1 1 2 total 0.000522 0.000349 +3 1 1 1 total 0.342252 0.023795 +2 1 1 2 total 0.000695 0.000327 1 1 2 1 total 0.000000 0.000000 -0 1 2 2 total 0.414134 0.029955 +0 1 2 2 total 0.388426 0.020840 material group in group out nuclide mean std. dev. -3 1 1 1 total 0.353477 0.019952 -2 1 1 2 total 0.000522 0.000349 +3 1 1 1 total 0.342252 0.023795 +2 1 1 2 total 0.000695 0.000327 1 1 2 1 total 0.000000 0.000000 -0 1 2 2 total 0.414134 0.029955 +0 1 2 2 total 0.388426 0.020840 material group in group out nuclide mean std. dev. -3 1 1 1 total 0.356124 0.026110 -2 1 1 2 total 0.000526 0.000352 +3 1 1 1 total 0.343021 0.031016 +2 1 1 2 total 0.000697 0.000329 1 1 2 1 total 0.000000 0.000000 -0 1 2 2 total 0.413622 0.044755 +0 1 2 2 total 0.376544 0.025156 material group in group out nuclide mean std. dev. -3 1 1 1 total 0.356124 0.033873 -2 1 1 2 total 0.000526 0.000608 +3 1 1 1 total 0.343021 0.039761 +2 1 1 2 total 0.000697 0.000566 1 1 2 1 total 0.000000 0.000000 -0 1 2 2 total 0.413622 0.054899 +0 1 2 2 total 0.376544 0.032140 material group in group out nuclide mean std. dev. -3 2 1 1 total 0.261901 0.016456 +3 2 1 1 total 0.271174 0.022374 2 2 1 2 total 0.000000 0.000000 1 2 2 1 total 0.000000 0.000000 -0 2 2 2 total 0.322376 0.044195 +0 2 2 2 total 0.295401 0.032831 material group in group out nuclide mean std. dev. -3 2 1 1 total 0.261901 0.016456 +3 2 1 1 total 0.271174 0.022374 2 2 1 2 total 0.000000 0.000000 1 2 2 1 total 0.000000 0.000000 -0 2 2 2 total 0.322376 0.044195 +0 2 2 2 total 0.295401 0.032831 material group in group out nuclide mean std. dev. -3 2 1 1 total 0.266612 0.021169 +3 2 1 1 total 0.264654 0.028288 2 2 1 2 total 0.000000 0.000000 1 2 2 1 total 0.000000 0.000000 -0 2 2 2 total 0.321966 0.054140 +0 2 2 2 total 0.295178 0.032530 material group in group out nuclide mean std. dev. -3 2 1 1 total 0.266612 0.025384 +3 2 1 1 total 0.264654 0.036081 2 2 1 2 total 0.000000 0.000000 1 2 2 1 total 0.000000 0.000000 -0 2 2 2 total 0.321966 0.068014 +0 2 2 2 total 0.295178 0.044676 material group in group out nuclide mean std. dev. -3 3 1 1 total 0.259426 0.012116 -2 3 1 2 total 0.031650 0.000613 -1 3 2 1 total 0.000474 0.000475 -0 3 2 2 total 1.416407 0.162435 +3 3 1 1 total 0.257831 0.014436 +2 3 1 2 total 0.030826 0.000973 +1 3 2 1 total 0.000467 0.000467 +0 3 2 2 total 1.443057 0.119909 material group in group out nuclide mean std. dev. -3 3 1 1 total 0.259426 0.012116 -2 3 1 2 total 0.031650 0.000613 -1 3 2 1 total 0.000474 0.000475 -0 3 2 2 total 1.416407 0.162435 +3 3 1 1 total 0.257831 0.014436 +2 3 1 2 total 0.030826 0.000973 +1 3 2 1 total 0.000467 0.000467 +0 3 2 2 total 1.443057 0.119909 material group in group out nuclide mean std. dev. -3 3 1 1 total 0.266083 0.024503 -2 3 1 2 total 0.031973 0.001157 -1 3 2 1 total 0.000477 0.000480 -0 3 2 2 total 1.427932 0.269812 +3 3 1 1 total 0.267025 0.029512 +2 3 1 2 total 0.031268 0.001416 +1 3 2 1 total 0.000466 0.000467 +0 3 2 2 total 1.440250 0.164573 material group in group out nuclide mean std. dev. -3 3 1 1 total 0.266083 0.027910 -2 3 1 2 total 0.031973 0.001391 -1 3 2 1 total 0.000477 0.000827 -0 3 2 2 total 1.427932 0.328026 +3 3 1 1 total 0.267025 0.032860 +2 3 1 2 total 0.031268 0.001768 +1 3 2 1 total 0.000466 0.000808 +0 3 2 2 total 1.440250 0.212183 diff --git a/tests/regression_tests/mgxs_library_correction/test.py b/tests/regression_tests/mgxs_library_correction/test.py index 64e638e44..05eedfef8 100644 --- a/tests/regression_tests/mgxs_library_correction/test.py +++ b/tests/regression_tests/mgxs_library_correction/test.py @@ -29,7 +29,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_distribcell/inputs_true.dat b/tests/regression_tests/mgxs_library_distribcell/inputs_true.dat index e3826cc18..f1a605334 100644 --- a/tests/regression_tests/mgxs_library_distribcell/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_distribcell/inputs_true.dat @@ -1,38 +1,38 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - + + + + + + + 1.26 1.26 17 17 @@ -56,19 +56,19 @@ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 - - - - - - + + + + + + eigenvalue 100 10 5 - + -10.71 -10.71 -1 10.71 10.71 1 diff --git a/tests/regression_tests/mgxs_library_distribcell/results_true.dat b/tests/regression_tests/mgxs_library_distribcell/results_true.dat index 127df75c1..ef7cb2b96 100644 --- a/tests/regression_tests/mgxs_library_distribcell/results_true.dat +++ b/tests/regression_tests/mgxs_library_distribcell/results_true.dat @@ -1,97 +1,97 @@ sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.459656 0.010039 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.455527 0.009851 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.416327 0.01121 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.416327 0.01121 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.070545 0.002486 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.070348 0.002485 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.029374 0.002719 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.041172 0.001562 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.101218 0.003812 - sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 7.972654e+06 302079.851251 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.409242 0.011118 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.38911 0.00831 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.40929 0.011119 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.394876 0.014019 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.066934 0.002424 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.066764 0.002423 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.028358 0.002669 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.038576 0.001526 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.094817 0.003725 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 7.470225e+06 295170.385185 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.388593 0.008156 + sum(distribcell) group in nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.388874 0.013889 sum(distribcell) group in group out legendre nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.394876 0.014019 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.043329 0.004988 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.027490 0.003974 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.016004 0.003232 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.388711 0.013887 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.046285 0.005155 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.023632 0.003772 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.006997 0.003207 sum(distribcell) group in group out legendre nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.394876 0.014019 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.043329 0.004988 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.027490 0.003974 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.016004 0.003232 - sum(distribcell) group in group out nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 1.0 0.036306 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.388874 0.013889 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.046237 0.005156 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.023571 0.003775 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.007058 0.003207 sum(distribcell) group in group out nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.097856 0.006191 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 1.000418 0.036246 + sum(distribcell) group in group out nuclide mean std. dev. +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.092139 0.005956 sum(distribcell) group in group out nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 1.0 0.036306 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 1.0 0.036242 sum(distribcell) group in group out legendre nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.389110 0.016390 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.042696 0.005009 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.027088 0.003964 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.015770 0.003204 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.388593 0.016275 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.046271 0.005251 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.023624 0.003806 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.006995 0.003209 sum(distribcell) group in group out legendre nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.389110 0.021638 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.042696 0.005244 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.027088 0.004084 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.015770 0.003255 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P0 total 0.388755 0.021528 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P1 total 0.046290 0.005515 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P2 total 0.023634 0.003903 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 P3 total 0.006998 0.003221 sum(distribcell) group out nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 1.0 0.082469 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 1.0 0.084366 sum(distribcell) group out nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 1.0 0.082587 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 1.0 0.084331 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 5.626624e-07 2.235532e-08 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 5.253873e-07 2.168462e-08 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.100506 0.003787 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.094147 0.003701 sum(distribcell) group in group out nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.097658 0.006185 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.091593 0.005919 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.800653 0.021558 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.814514 0.022129 sum(distribcell) group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.800653 0.021558 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.814419 0.022125 sum(distribcell) delayedgroup group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.000023 8.667436e-07 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 0.000122 4.499059e-06 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 total 0.000119 4.311220e-06 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 total 0.000275 9.735290e-06 -4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 1 total 0.000122 4.078954e-06 -5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 1 total 0.000051 1.705327e-06 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.000021 8.473275e-07 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 0.000115 4.405467e-06 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 total 0.000112 4.225826e-06 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 total 0.000259 9.559952e-06 +4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 1 total 0.000115 4.025369e-06 +5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 1 total 0.000048 1.682226e-06 sum(distribcell) delayedgroup group out nuclide mean std. dev. 0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.0 0.000000 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 1.0 1.414214 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 total 0.0 0.000000 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 total 0.0 0.000000 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 0.0 0.000000 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 total 1.0 1.000002 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 total 1.0 1.414214 4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 1 total 0.0 0.000000 5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 1 total 0.0 0.000000 sum(distribcell) delayedgroup group in nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.000227 0.000011 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 0.001208 0.000059 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 total 0.001175 0.000056 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 total 0.002721 0.000129 -4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 1 total 0.001206 0.000055 -5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 1 total 0.000502 0.000023 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.000227 0.000012 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 0.001210 0.000062 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 total 0.001177 0.000060 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 total 0.002728 0.000136 +4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 1 total 0.001211 0.000059 +5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 1 total 0.000504 0.000025 sum(distribcell) delayedgroup nuclide mean std. dev. -0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.013353 0.000658 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 total 0.032616 0.001562 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 total 0.121048 0.005678 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 total 0.305568 0.013868 -4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 total 0.860675 0.036434 -5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 total 2.890786 0.122997 +0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.013353 0.000692 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 total 0.032613 0.001644 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 total 0.121054 0.005983 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 total 0.305630 0.014645 +4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 total 0.860903 0.038693 +5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 total 2.891558 0.130564 sum(distribcell) delayedgroup group in group out nuclide mean std. dev. 0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 1 total 0.000000 0.000000 -1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 1 total 0.000198 0.000198 -2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 1 total 0.000000 0.000000 -3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 1 total 0.000000 0.000000 +1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 1 total 0.000000 0.000000 +2 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 3 1 1 total 0.000362 0.000256 +3 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 4 1 1 total 0.000185 0.000185 4 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 5 1 1 total 0.000000 0.000000 5 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 6 1 1 total 0.000000 0.000000 diff --git a/tests/regression_tests/mgxs_library_distribcell/test.py b/tests/regression_tests/mgxs_library_distribcell/test.py index 464b309c0..fd6c8e938 100644 --- a/tests/regression_tests/mgxs_library_distribcell/test.py +++ b/tests/regression_tests/mgxs_library_distribcell/test.py @@ -36,7 +36,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) self._model.tallies.export_to_xml() def _get_results(self, hash_output=False): diff --git a/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat b/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat index 4451d214c..8606e9fdd 100644 --- a/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_hdf5/results_true.dat b/tests/regression_tests/mgxs_library_hdf5/results_true.dat index 14d7371fe..b2ef8eae9 100644 --- a/tests/regression_tests/mgxs_library_hdf5/results_true.dat +++ b/tests/regression_tests/mgxs_library_hdf5/results_true.dat @@ -1,201 +1,201 @@ domain=1 type=total -[5.66580451e-01 1.44262943e+00] -[1.96770003e-02 1.46112369e-01] +[5.52629207e-01 1.46792426e+00] +[2.73983948e-02 9.30468557e-02] domain=1 type=transport -[3.14856281e-01 1.05346368e+00] -[2.15203447e-02 1.60562179e-01] +[3.09650231e-01 1.14528468e+00] +[2.96126059e-02 1.01957125e-01] domain=1 type=nu-transport -[3.14856281e-01 1.05346368e+00] -[2.15203447e-02 1.60562179e-01] +[3.09650231e-01 1.14528468e+00] +[2.96126059e-02 1.01957125e-01] domain=1 type=absorption -[8.63921263e-03 9.70718967e-02] -[7.09849180e-04 9.96697703e-03] +[7.90251362e-03 9.52195503e-02] +[7.77996866e-04 5.32017792e-03] domain=1 type=reduced absorption -[8.63459183e-03 9.70718967e-02] -[7.09826160e-04 9.96697703e-03] +[7.88836875e-03 9.52195503e-02] +[7.77877367e-04 5.32017792e-03] domain=1 type=capture -[6.29732743e-03 4.01344183e-02] -[7.03181817e-04 9.43458504e-03] +[5.66271991e-03 4.03380329e-02] +[7.65494411e-04 4.41129849e-03] domain=1 type=fission -[2.34188519e-03 5.69374784e-02] -[1.04006997e-04 6.19904834e-03] +[2.23979371e-03 5.48815174e-02] +[1.44808204e-04 3.21965557e-03] domain=1 type=nu-fission -[5.93985124e-03 1.38739554e-01] -[2.57215008e-04 1.51052211e-02] +[5.70078167e-03 1.33729794e-01] +[3.71908758e-04 7.84533474e-03] domain=1 type=kappa-fission -[4.55876276e+05 1.10120160e+07] -[2.00450394e+04 1.19892945e+06] +[4.36283087e+05 1.06143820e+07] +[2.81939099e+04 6.22698786e+05] domain=1 type=scatter -[5.57941239e-01 1.34555753e+00] -[1.96103602e-02 1.38008873e-01] +[5.44726693e-01 1.37270471e+00] +[2.67443307e-02 8.86578418e-02] domain=1 type=nu-scatter -[5.53883536e-01 1.40126963e+00] -[1.89917740e-02 1.62647765e-01] +[5.46058885e-01 1.38608802e+00] +[2.72733439e-02 9.59957737e-02] domain=1 type=scatter matrix -[[[5.35878034e-01 2.51724170e-01 1.01011269e-01 1.03439439e-02] - [1.80055019e-02 5.80562809e-03 -1.57470166e-03 -2.27320020e-03]] +[[[5.25081070e-01 2.42978975e-01 9.65459393e-02 8.62265123e-03] + [2.09778151e-02 5.67750504e-03 -1.86093418e-03 -1.63034937e-03]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [1.40126963e+00 3.55339640e-01 7.06453615e-02 4.04065595e-02]]] -[[[1.86010787e-02 8.71440749e-03 3.01351835e-03 5.22968320e-03] - [1.36795874e-03 6.67372701e-04 3.26122899e-04 8.68935369e-04]] + [1.38608802e+00 2.92665071e-01 4.65545679e-02 3.43129413e-03]]] +[[[2.68584158e-02 1.12354079e-02 5.95151250e-03 5.08213314e-03] + [1.69810442e-03 1.03379654e-03 3.35798077e-04 8.28775769e-04]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [1.62647765e-01 6.23420543e-02 9.61788834e-03 8.80966610e-03]]] + [9.59957737e-02 3.98634629e-02 1.79245433e-02 2.53788407e-02]]] domain=1 type=nu-scatter matrix -[[[5.35878034e-01 2.51724170e-01 1.01011269e-01 1.03439439e-02] - [1.80055019e-02 5.80562809e-03 -1.57470166e-03 -2.27320020e-03]] +[[[5.25081070e-01 2.42978975e-01 9.65459393e-02 8.62265123e-03] + [2.09778151e-02 5.67750504e-03 -1.86093418e-03 -1.63034937e-03]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [1.40126963e+00 3.55339640e-01 7.06453615e-02 4.04065595e-02]]] -[[[1.86010787e-02 8.71440749e-03 3.01351835e-03 5.22968320e-03] - [1.36795874e-03 6.67372701e-04 3.26122899e-04 8.68935369e-04]] + [1.38608802e+00 2.92665071e-01 4.65545679e-02 3.43129413e-03]]] +[[[2.68584158e-02 1.12354079e-02 5.95151250e-03 5.08213314e-03] + [1.69810442e-03 1.03379654e-03 3.35798077e-04 8.28775769e-04]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [1.62647765e-01 6.23420543e-02 9.61788834e-03 8.80966610e-03]]] + [9.59957737e-02 3.98634629e-02 1.79245433e-02 2.53788407e-02]]] domain=1 type=multiplicity matrix [[1.00000000e+00 1.00000000e+00] [0.00000000e+00 1.00000000e+00]] -[[3.27047397e-02 1.01015254e-01] - [0.00000000e+00 1.16966513e-01]] +[[4.49973217e-02 9.94834121e-02] + [0.00000000e+00 8.90267353e-02]] domain=1 type=nu-fission matrix -[[7.11392182e-03 0.00000000e+00] - [1.52683850e-01 0.00000000e+00]] -[[1.05605314e-03 0.00000000e+00] - [2.58713491e-02 0.00000000e+00]] +[[6.79725552e-03 0.00000000e+00] + [1.34226308e-01 0.00000000e+00]] +[[1.39232734e-03 0.00000000e+00] + [1.55126210e-02 0.00000000e+00]] domain=1 type=scatter probability matrix -[[9.67492260e-01 3.25077399e-02] +[[9.61583236e-01 3.84167637e-02] [0.00000000e+00 1.00000000e+00]] -[[3.12124830e-02 2.43439942e-03] - [0.00000000e+00 1.16966513e-01]] +[[4.25251594e-02 2.94881301e-03] + [0.00000000e+00 8.90267353e-02]] domain=1 type=consistent scatter matrix -[[[5.39803830e-01 2.53568280e-01 1.01751269e-01 1.04197228e-02] - [1.81374087e-02 5.84815962e-03 -1.58623779e-03 -2.28985347e-03]] +[[[5.23800056e-01 2.42386192e-01 9.63104011e-02 8.60161499e-03] + [2.09266366e-02 5.66365392e-03 -1.85639416e-03 -1.62637189e-03]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [1.34555753e+00 3.41211940e-01 6.78366221e-02 3.88000634e-02]]] -[[[2.57534994e-02 1.20804286e-02 4.50621873e-03 5.27902298e-03] - [1.50041314e-03 6.98980912e-04 3.32589287e-04 8.78503928e-04]] + [1.37270471e+00 2.89839256e-01 4.61050623e-02 3.39816342e-03]]] +[[[3.46115177e-02 1.51137129e-02 7.17487890e-03 5.08248710e-03] + [1.90677851e-03 1.05813829e-03 3.43862086e-04 8.29548315e-04]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [2.09324012e-01 6.95175402e-02 1.16044952e-02 9.36549883e-03]]] + [1.50979688e-01 4.66032426e-02 1.81833349e-02 2.51354735e-02]]] domain=1 type=consistent nu-scatter matrix -[[[5.39803830e-01 2.53568280e-01 1.01751269e-01 1.04197228e-02] - [1.81374087e-02 5.84815962e-03 -1.58623779e-03 -2.28985347e-03]] +[[[5.23800056e-01 2.42386192e-01 9.63104011e-02 8.60161499e-03] + [2.09266366e-02 5.66365392e-03 -1.85639416e-03 -1.62637189e-03]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [1.34555753e+00 3.41211940e-01 6.78366221e-02 3.88000634e-02]]] -[[[3.12235732e-02 1.46529414e-02 5.60177820e-03 5.29001047e-03] - [2.36812824e-03 9.15185125e-04 3.69175618e-04 9.08445666e-04]] + [1.37270471e+00 2.89839256e-01 4.61050623e-02 3.39816342e-03]]] +[[[4.18746126e-02 1.86381616e-02 8.38211969e-03 5.09720340e-03] + [2.82310416e-03 1.19879975e-03 3.90317811e-04 8.45179676e-04]] [[0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] - [2.61890501e-01 8.01593794e-02 1.40578233e-02 1.04071518e-02]]] + [1.94240879e-01 5.32698778e-02 1.86408495e-02 2.51372940e-02]]] domain=1 type=chi [1.00000000e+00 0.00000000e+00] -[1.42429813e-01 0.00000000e+00] +[1.03333203e-01 0.00000000e+00] domain=1 type=chi-prompt [1.00000000e+00 0.00000000e+00] -[1.43958515e-01 0.00000000e+00] +[1.03333203e-01 0.00000000e+00] domain=1 type=inverse-velocity -[6.05275939e-08 2.92408191e-06] -[4.98534008e-09 2.95326306e-07] +[5.72461488e-08 3.00999757e-06] +[2.80644407e-09 1.80993426e-07] domain=1 type=prompt-nu-fission -[5.88433433e-03 1.37837093e-01] -[2.56012352e-04 1.50069660e-02] +[5.64594959e-03 1.32859920e-01] +[3.68364598e-04 7.79430310e-03] domain=1 type=prompt-nu-fission matrix -[[7.11392182e-03 0.00000000e+00] - [1.51190909e-01 0.00000000e+00]] -[[1.05605314e-03 0.00000000e+00] - [2.57973847e-02 0.00000000e+00]] +[[6.79725552e-03 0.00000000e+00] + [1.34226308e-01 0.00000000e+00]] +[[1.39232734e-03 0.00000000e+00] + [1.55126210e-02 0.00000000e+00]] domain=1 type=current -[[[0.00000000e+00 0.00000000e+00 3.71800000e+00 3.58600000e+00 - 0.00000000e+00 0.00000000e+00 3.62200000e+00 3.71800000e+00] - [0.00000000e+00 0.00000000e+00 6.60000000e-01 6.58000000e-01 - 0.00000000e+00 0.00000000e+00 6.62000000e-01 6.70000000e-01]] +[[[0.00000000e+00 0.00000000e+00 3.54200000e+00 3.59000000e+00 + 0.00000000e+00 0.00000000e+00 3.73400000e+00 3.69000000e+00] + [0.00000000e+00 0.00000000e+00 7.08000000e-01 6.90000000e-01 + 0.00000000e+00 0.00000000e+00 6.78000000e-01 6.74000000e-01]] - [[3.58600000e+00 3.71800000e+00 0.00000000e+00 0.00000000e+00 - 0.00000000e+00 0.00000000e+00 3.71200000e+00 3.60600000e+00] - [6.58000000e-01 6.60000000e-01 0.00000000e+00 0.00000000e+00 - 0.00000000e+00 0.00000000e+00 7.04000000e-01 6.74000000e-01]] + [[3.59000000e+00 3.54200000e+00 0.00000000e+00 0.00000000e+00 + 0.00000000e+00 0.00000000e+00 3.65200000e+00 3.73800000e+00] + [6.90000000e-01 7.08000000e-01 0.00000000e+00 0.00000000e+00 + 0.00000000e+00 0.00000000e+00 6.94000000e-01 6.64000000e-01]] - [[0.00000000e+00 0.00000000e+00 3.48600000e+00 3.60600000e+00 - 3.71800000e+00 3.62200000e+00 0.00000000e+00 0.00000000e+00] - [0.00000000e+00 0.00000000e+00 6.66000000e-01 6.74000000e-01 - 6.70000000e-01 6.62000000e-01 0.00000000e+00 0.00000000e+00]] + [[0.00000000e+00 0.00000000e+00 3.76000000e+00 3.66600000e+00 + 3.69000000e+00 3.73400000e+00 0.00000000e+00 0.00000000e+00] + [0.00000000e+00 0.00000000e+00 6.68000000e-01 7.22000000e-01 + 6.74000000e-01 6.78000000e-01 0.00000000e+00 0.00000000e+00]] - [[3.60600000e+00 3.48600000e+00 0.00000000e+00 0.00000000e+00 - 3.60600000e+00 3.71200000e+00 0.00000000e+00 0.00000000e+00] - [6.74000000e-01 6.66000000e-01 0.00000000e+00 0.00000000e+00 - 6.74000000e-01 7.04000000e-01 0.00000000e+00 0.00000000e+00]]] -[[[0.00000000e+00 0.00000000e+00 9.96192752e-02 8.73269718e-02 - 0.00000000e+00 0.00000000e+00 1.22531629e-01 1.08369737e-01] - [0.00000000e+00 0.00000000e+00 3.96232255e-02 4.06693988e-02 - 0.00000000e+00 0.00000000e+00 4.05462699e-02 4.27784993e-02]] + [[3.66600000e+00 3.76000000e+00 0.00000000e+00 0.00000000e+00 + 3.73800000e+00 3.65200000e+00 0.00000000e+00 0.00000000e+00] + [7.22000000e-01 6.68000000e-01 0.00000000e+00 0.00000000e+00 + 6.64000000e-01 6.94000000e-01 0.00000000e+00 0.00000000e+00]]] +[[[0.00000000e+00 0.00000000e+00 1.04230514e-01 1.61183126e-01 + 0.00000000e+00 0.00000000e+00 1.50419414e-01 1.00498756e-01] + [0.00000000e+00 0.00000000e+00 2.47790234e-02 3.27108545e-02 + 0.00000000e+00 0.00000000e+00 4.84148737e-02 3.24961536e-02]] - [[8.73269718e-02 9.96192752e-02 0.00000000e+00 0.00000000e+00 - 0.00000000e+00 0.00000000e+00 7.09506871e-02 5.27825729e-02] - [4.06693988e-02 3.96232255e-02 0.00000000e+00 0.00000000e+00 - 0.00000000e+00 0.00000000e+00 6.11228272e-02 5.88727441e-02]] + [[1.61183126e-01 1.04230514e-01 0.00000000e+00 0.00000000e+00 + 0.00000000e+00 0.00000000e+00 1.44201248e-01 1.81229137e-01] + [3.27108545e-02 2.47790234e-02 0.00000000e+00 0.00000000e+00 + 0.00000000e+00 0.00000000e+00 3.41467422e-02 2.20454077e-02]] - [[0.00000000e+00 0.00000000e+00 1.00279609e-01 1.31209756e-01 - 1.08369737e-01 1.22531629e-01 0.00000000e+00 0.00000000e+00] - [0.00000000e+00 0.00000000e+00 6.05475020e-02 4.87442304e-02 - 4.27784993e-02 4.05462699e-02 0.00000000e+00 0.00000000e+00]] + [[0.00000000e+00 0.00000000e+00 1.39355660e-01 9.70875893e-02 + 1.00498756e-01 1.50419414e-01 0.00000000e+00 0.00000000e+00] + [0.00000000e+00 0.00000000e+00 1.56204994e-02 3.27719392e-02 + 3.24961536e-02 4.84148737e-02 0.00000000e+00 0.00000000e+00]] - [[1.31209756e-01 1.00279609e-01 0.00000000e+00 0.00000000e+00 - 5.27825729e-02 7.09506871e-02 0.00000000e+00 0.00000000e+00] - [4.87442304e-02 6.05475020e-02 0.00000000e+00 0.00000000e+00 - 5.88727441e-02 6.11228272e-02 0.00000000e+00 0.00000000e+00]]] + [[9.70875893e-02 1.39355660e-01 0.00000000e+00 0.00000000e+00 + 1.81229137e-01 1.44201248e-01 0.00000000e+00 0.00000000e+00] + [3.27719392e-02 1.56204994e-02 0.00000000e+00 0.00000000e+00 + 2.20454077e-02 3.41467422e-02 0.00000000e+00 0.00000000e+00]]] domain=1 type=diffusion-coefficient -[1.05868408e+00 3.16416542e-01] -[7.23607812e-02 4.82261806e-02] +[1.07648340e+00 2.91048451e-01] +[1.02946730e-01 2.59101197e-02] domain=1 type=nu-diffusion-coefficient -[1.05868408e+00 3.16416542e-01] -[7.23607812e-02 4.82261806e-02] +[1.07648340e+00 2.91048451e-01] +[1.02946730e-01 2.59101197e-02] domain=1 type=delayed-nu-fission -[[1.33370452e-06 3.15928985e-05] - [8.06563789e-06 1.63072885e-04] - [8.37555675e-06 1.55683610e-04] - [2.14225848e-05 3.49055766e-04] - [1.15633419e-05 1.43108212e-04] - [4.74849054e-06 5.99475175e-05]] -[[5.58190638e-08 3.43966581e-06] - [2.80924725e-07 1.77545031e-05] - [2.81900859e-07 1.69499982e-05] - [7.44207592e-07 3.80033227e-05] - [4.95821820e-07 1.55808550e-05] - [2.00315983e-07 6.52676436e-06]] +[[1.27862358e-06 3.04521075e-05] + [7.84219053e-06 1.57184471e-04] + [8.19703020e-06 1.50062017e-04] + [2.11585246e-05 3.36451683e-04] + [1.15983232e-05 1.37940708e-04] + [4.75823112e-06 5.77828684e-05]] +[[8.24665595e-08 1.78649023e-06] + [5.11270396e-07 9.22131636e-06] + [5.43215007e-07 8.80347339e-06] + [1.44919046e-06 1.97381285e-05] + [8.56858673e-07 8.09236929e-06] + [3.49663884e-07 3.38986452e-06]] domain=1 type=chi-delayed [[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00] - [1.00000000e+00 0.00000000e+00] + [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00] - [1.41421356e+00 0.00000000e+00] + [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] domain=1 type=beta -[[2.24535003e-04 2.27713710e-04] - [1.35788550e-03 1.17538857e-03] - [1.41006170e-03 1.12212852e-03] - [3.60658609e-03 2.51590665e-03] - [1.94673931e-03 1.03148820e-03] - [7.99429201e-04 4.32086711e-04]] -[[1.15072629e-05 2.77827007e-05] - [6.20475481e-05 1.43405806e-04] - [6.31808205e-05 1.36907698e-04] - [1.64551758e-04 3.06958585e-04] - [1.01406915e-04 1.25848924e-04] - [4.11875799e-05 5.27176635e-05]] +[[2.24289169e-04 2.27713711e-04] + [1.37563425e-03 1.17538857e-03] + [1.43787829e-03 1.12212853e-03] + [3.71151288e-03 2.51590669e-03] + [2.03451453e-03 1.03148823e-03] + [8.34662928e-04 4.32086724e-04]] +[[1.75760869e-05 1.28957660e-05] + [1.08591736e-04 6.65640010e-05] + [1.14785004e-04 6.35478047e-05] + [3.03169937e-04 1.42479528e-04] + [1.75476030e-04 5.84147049e-05] + [7.17094876e-05 2.44697107e-05]] domain=1 type=decay-rate -[1.33525569e-02 3.26187089e-02 1.21041926e-01 3.05503129e-01 - 8.60433350e-01 2.88996258e+00] -[1.34484408e-03 3.11955840e-03 1.11418058e-02 2.64184722e-02 - 6.46651447e-02 2.19526509e-01] +[1.33535692e-02 3.26115957e-02 1.21057117e-01 3.05655911e-01 + 8.60999995e-01 2.89188863e+00] +[6.74373067e-04 1.71978136e-03 6.57917554e-03 1.73982053e-02 + 5.37683207e-02 1.79407115e-01] domain=1 type=delayed-nu-fission matrix [[[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] @@ -207,7 +207,7 @@ domain=1 type=delayed-nu-fission matrix [0.00000000e+00 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] - [1.49294023e-03 0.00000000e+00]] + [0.00000000e+00 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] @@ -224,7 +224,7 @@ domain=1 type=delayed-nu-fission matrix [0.00000000e+00 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] - [1.49788268e-03 0.00000000e+00]] + [0.00000000e+00 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] diff --git a/tests/regression_tests/mgxs_library_hdf5/test.py b/tests/regression_tests/mgxs_library_hdf5/test.py index 4fb4bf093..06625c25f 100644 --- a/tests/regression_tests/mgxs_library_hdf5/test.py +++ b/tests/regression_tests/mgxs_library_hdf5/test.py @@ -40,7 +40,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_histogram/inputs_true.dat b/tests/regression_tests/mgxs_library_histogram/inputs_true.dat index 94c656418..013fcd0fa 100644 --- a/tests/regression_tests/mgxs_library_histogram/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_histogram/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_histogram/results_true.dat b/tests/regression_tests/mgxs_library_histogram/results_true.dat index f927d057e..2fa94cef5 100644 --- a/tests/regression_tests/mgxs_library_histogram/results_true.dat +++ b/tests/regression_tests/mgxs_library_histogram/results_true.dat @@ -1,18 +1,18 @@ material group in group out mu bin nuclide mean std. dev. -33 1 1 1 1 total 0.029945 0.003043 -34 1 1 1 2 total 0.028378 0.003793 -35 1 1 1 3 total 0.033079 0.002866 -36 1 1 1 4 total 0.030119 0.002259 -37 1 1 1 5 total 0.033601 0.003739 -38 1 1 1 6 total 0.035516 0.001929 -39 1 1 1 7 total 0.032382 0.001744 -40 1 1 1 8 total 0.031860 0.002565 -41 1 1 1 9 total 0.038302 0.004757 -42 1 1 1 10 total 0.041784 0.003047 -43 1 1 1 11 total 0.057453 0.003686 -22 1 1 2 1 total 0.000174 0.000174 -23 1 1 2 2 total 0.000000 0.000000 -24 1 1 2 3 total 0.000174 0.000174 +33 1 1 1 1 total 0.032861 0.003703 +34 1 1 1 2 total 0.026428 0.003637 +35 1 1 1 3 total 0.029210 0.001648 +36 1 1 1 4 total 0.032513 0.004770 +37 1 1 1 5 total 0.030949 0.003129 +38 1 1 1 6 total 0.027124 0.004029 +39 1 1 1 7 total 0.030079 0.002186 +40 1 1 1 8 total 0.037034 0.002198 +41 1 1 1 9 total 0.038251 0.003825 +42 1 1 1 10 total 0.039294 0.003626 +43 1 1 1 11 total 0.062593 0.005934 +22 1 1 2 1 total 0.000000 0.000000 +23 1 1 2 2 total 0.000174 0.000174 +24 1 1 2 3 total 0.000348 0.000213 25 1 1 2 4 total 0.000174 0.000174 26 1 1 2 5 total 0.000000 0.000000 27 1 1 2 6 total 0.000000 0.000000 @@ -32,32 +32,32 @@ 19 1 2 1 9 total 0.000000 0.000000 20 1 2 1 10 total 0.000000 0.000000 21 1 2 1 11 total 0.000000 0.000000 -0 1 2 2 1 total 0.037212 0.004892 -1 1 2 2 2 total 0.039224 0.003682 -2 1 2 2 3 total 0.044253 0.005869 -3 1 2 2 4 total 0.043247 0.004970 -4 1 2 2 5 total 0.025144 0.006632 -5 1 2 2 6 total 0.037212 0.009199 -6 1 2 2 7 total 0.035201 0.008964 -7 1 2 2 8 total 0.041235 0.009733 -8 1 2 2 9 total 0.032184 0.002384 -9 1 2 2 10 total 0.026149 0.006714 -10 1 2 2 11 total 0.035201 0.008073 +0 1 2 2 1 total 0.032383 0.006826 +1 1 2 2 2 total 0.037146 0.001158 +2 1 2 2 3 total 0.036193 0.004463 +3 1 2 2 4 total 0.036193 0.007028 +4 1 2 2 5 total 0.038098 0.006769 +5 1 2 2 6 total 0.024764 0.004638 +6 1 2 2 7 total 0.034288 0.008049 +7 1 2 2 8 total 0.040003 0.007350 +8 1 2 2 9 total 0.032383 0.003211 +9 1 2 2 10 total 0.050480 0.005824 +10 1 2 2 11 total 0.045718 0.013291 material group in group out mu bin nuclide mean std. dev. -33 1 1 1 1 total 0.029945 0.003043 -34 1 1 1 2 total 0.028378 0.003793 -35 1 1 1 3 total 0.033079 0.002866 -36 1 1 1 4 total 0.030119 0.002259 -37 1 1 1 5 total 0.033601 0.003739 -38 1 1 1 6 total 0.035516 0.001929 -39 1 1 1 7 total 0.032382 0.001744 -40 1 1 1 8 total 0.031860 0.002565 -41 1 1 1 9 total 0.038302 0.004757 -42 1 1 1 10 total 0.041784 0.003047 -43 1 1 1 11 total 0.057453 0.003686 -22 1 1 2 1 total 0.000174 0.000174 -23 1 1 2 2 total 0.000000 0.000000 -24 1 1 2 3 total 0.000174 0.000174 +33 1 1 1 1 total 0.032861 0.003703 +34 1 1 1 2 total 0.026428 0.003637 +35 1 1 1 3 total 0.029210 0.001648 +36 1 1 1 4 total 0.032513 0.004770 +37 1 1 1 5 total 0.030949 0.003129 +38 1 1 1 6 total 0.027124 0.004029 +39 1 1 1 7 total 0.030079 0.002186 +40 1 1 1 8 total 0.037034 0.002198 +41 1 1 1 9 total 0.038251 0.003825 +42 1 1 1 10 total 0.039294 0.003626 +43 1 1 1 11 total 0.062593 0.005934 +22 1 1 2 1 total 0.000000 0.000000 +23 1 1 2 2 total 0.000174 0.000174 +24 1 1 2 3 total 0.000348 0.000213 25 1 1 2 4 total 0.000174 0.000174 26 1 1 2 5 total 0.000000 0.000000 27 1 1 2 6 total 0.000000 0.000000 @@ -77,33 +77,33 @@ 19 1 2 1 9 total 0.000000 0.000000 20 1 2 1 10 total 0.000000 0.000000 21 1 2 1 11 total 0.000000 0.000000 -0 1 2 2 1 total 0.037212 0.004892 -1 1 2 2 2 total 0.039224 0.003682 -2 1 2 2 3 total 0.044253 0.005869 -3 1 2 2 4 total 0.043247 0.004970 -4 1 2 2 5 total 0.025144 0.006632 -5 1 2 2 6 total 0.037212 0.009199 -6 1 2 2 7 total 0.035201 0.008964 -7 1 2 2 8 total 0.041235 0.009733 -8 1 2 2 9 total 0.032184 0.002384 -9 1 2 2 10 total 0.026149 0.006714 -10 1 2 2 11 total 0.035201 0.008073 +0 1 2 2 1 total 0.032383 0.006826 +1 1 2 2 2 total 0.037146 0.001158 +2 1 2 2 3 total 0.036193 0.004463 +3 1 2 2 4 total 0.036193 0.007028 +4 1 2 2 5 total 0.038098 0.006769 +5 1 2 2 6 total 0.024764 0.004638 +6 1 2 2 7 total 0.034288 0.008049 +7 1 2 2 8 total 0.040003 0.007350 +8 1 2 2 9 total 0.032383 0.003211 +9 1 2 2 10 total 0.050480 0.005824 +10 1 2 2 11 total 0.045718 0.013291 material group in group out mu bin nuclide mean std. dev. -33 1 1 1 1 total 0.030147 0.003165 -34 1 1 1 2 total 0.028570 0.003893 -35 1 1 1 3 total 0.033302 0.003016 -36 1 1 1 4 total 0.030322 0.002411 -37 1 1 1 5 total 0.033828 0.003868 -38 1 1 1 6 total 0.035756 0.002159 -39 1 1 1 7 total 0.032601 0.001955 -40 1 1 1 8 total 0.032075 0.002718 -41 1 1 1 9 total 0.038560 0.004896 -42 1 1 1 10 total 0.042066 0.003262 -43 1 1 1 11 total 0.057840 0.004013 -22 1 1 2 1 total 0.000175 0.000175 -23 1 1 2 2 total 0.000000 0.000000 -24 1 1 2 3 total 0.000175 0.000175 -25 1 1 2 4 total 0.000175 0.000175 +33 1 1 1 1 total 0.032927 0.003848 +34 1 1 1 2 total 0.026481 0.003736 +35 1 1 1 3 total 0.029268 0.001884 +36 1 1 1 4 total 0.032578 0.004885 +37 1 1 1 5 total 0.031010 0.003280 +38 1 1 1 6 total 0.027177 0.004124 +39 1 1 1 7 total 0.030139 0.002382 +40 1 1 1 8 total 0.037108 0.002485 +41 1 1 1 9 total 0.038327 0.004013 +42 1 1 1 10 total 0.039372 0.003833 +43 1 1 1 11 total 0.062717 0.006256 +22 1 1 2 1 total 0.000000 0.000000 +23 1 1 2 2 total 0.000174 0.000174 +24 1 1 2 3 total 0.000348 0.000214 +25 1 1 2 4 total 0.000174 0.000174 26 1 1 2 5 total 0.000000 0.000000 27 1 1 2 6 total 0.000000 0.000000 28 1 1 2 7 total 0.000000 0.000000 @@ -122,33 +122,33 @@ 19 1 2 1 9 total 0.000000 0.000000 20 1 2 1 10 total 0.000000 0.000000 21 1 2 1 11 total 0.000000 0.000000 -0 1 2 2 1 total 0.037164 0.005797 -1 1 2 2 2 total 0.039173 0.004933 -2 1 2 2 3 total 0.044195 0.006937 -3 1 2 2 4 total 0.043191 0.006147 -4 1 2 2 5 total 0.025111 0.006951 -5 1 2 2 6 total 0.037164 0.009702 -6 1 2 2 7 total 0.035155 0.009426 -7 1 2 2 8 total 0.041182 0.010317 -8 1 2 2 9 total 0.032142 0.003598 -9 1 2 2 10 total 0.026115 0.007055 -10 1 2 2 11 total 0.035155 0.008586 +0 1 2 2 1 total 0.031440 0.006860 +1 1 2 2 2 total 0.036063 0.002322 +2 1 2 2 3 total 0.035138 0.004763 +3 1 2 2 4 total 0.035138 0.007105 +4 1 2 2 5 total 0.036988 0.006894 +5 1 2 2 6 total 0.024042 0.004702 +6 1 2 2 7 total 0.033289 0.008036 +7 1 2 2 8 total 0.038837 0.007464 +8 1 2 2 9 total 0.031440 0.003585 +9 1 2 2 10 total 0.049009 0.006292 +10 1 2 2 11 total 0.044385 0.013144 material group in group out mu bin nuclide mean std. dev. -33 1 1 1 1 total 0.030147 0.003454 -34 1 1 1 2 total 0.028570 0.004107 -35 1 1 1 3 total 0.033302 0.003381 -36 1 1 1 4 total 0.030322 0.002783 -37 1 1 1 5 total 0.033828 0.004168 -38 1 1 1 6 total 0.035756 0.002711 -39 1 1 1 7 total 0.032601 0.002461 -40 1 1 1 8 total 0.032075 0.003090 -41 1 1 1 9 total 0.038560 0.005205 -42 1 1 1 10 total 0.042066 0.003790 -43 1 1 1 11 total 0.057840 0.004811 -22 1 1 2 1 total 0.000175 0.000234 -23 1 1 2 2 total 0.000000 0.000000 -24 1 1 2 3 total 0.000175 0.000234 -25 1 1 2 4 total 0.000175 0.000234 +33 1 1 1 1 total 0.032927 0.004236 +34 1 1 1 2 total 0.026481 0.003998 +35 1 1 1 3 total 0.029268 0.002455 +36 1 1 1 4 total 0.032578 0.005190 +37 1 1 1 5 total 0.031010 0.003679 +38 1 1 1 6 total 0.027177 0.004376 +39 1 1 1 7 total 0.030139 0.002881 +40 1 1 1 8 total 0.037108 0.003187 +41 1 1 1 9 total 0.038327 0.004511 +42 1 1 1 10 total 0.039372 0.004379 +43 1 1 1 11 total 0.062717 0.007108 +22 1 1 2 1 total 0.000000 0.000000 +23 1 1 2 2 total 0.000174 0.000209 +24 1 1 2 3 total 0.000348 0.000315 +25 1 1 2 4 total 0.000174 0.000209 26 1 1 2 5 total 0.000000 0.000000 27 1 1 2 6 total 0.000000 0.000000 28 1 1 2 7 total 0.000000 0.000000 @@ -167,29 +167,29 @@ 19 1 2 1 9 total 0.000000 0.000000 20 1 2 1 10 total 0.000000 0.000000 21 1 2 1 11 total 0.000000 0.000000 -0 1 2 2 1 total 0.037164 0.006511 -1 1 2 2 2 total 0.039173 0.005840 -2 1 2 2 3 total 0.044195 0.007782 -3 1 2 2 4 total 0.043191 0.007047 -4 1 2 2 5 total 0.025111 0.007234 -5 1 2 2 6 total 0.037164 0.010146 -6 1 2 2 7 total 0.035155 0.009835 -7 1 2 2 8 total 0.041182 0.010828 -8 1 2 2 9 total 0.032142 0.004419 -9 1 2 2 10 total 0.026115 0.007356 -10 1 2 2 11 total 0.035155 0.009032 +0 1 2 2 1 total 0.031440 0.007170 +1 1 2 2 2 total 0.036063 0.003334 +2 1 2 2 3 total 0.035138 0.005303 +3 1 2 2 4 total 0.035138 0.007478 +4 1 2 2 5 total 0.036988 0.007318 +5 1 2 2 6 total 0.024042 0.004965 +6 1 2 2 7 total 0.033289 0.008334 +7 1 2 2 8 total 0.038837 0.007896 +8 1 2 2 9 total 0.031440 0.004148 +9 1 2 2 10 total 0.049009 0.007083 +10 1 2 2 11 total 0.044385 0.013469 material group in group out mu bin nuclide mean std. dev. -33 2 1 1 1 total 0.025373 0.004281 -34 2 1 1 2 total 0.023909 0.004395 -35 2 1 1 3 total 0.019518 0.003911 -36 2 1 1 4 total 0.019518 0.003424 -37 2 1 1 5 total 0.020006 0.002901 -38 2 1 1 6 total 0.024885 0.005801 -39 2 1 1 7 total 0.019030 0.002566 -40 2 1 1 8 total 0.030741 0.001410 -41 2 1 1 9 total 0.034156 0.002902 -42 2 1 1 10 total 0.042939 0.004498 -43 2 1 1 11 total 0.054650 0.003865 +33 2 1 1 1 total 0.026798 0.002892 +34 2 1 1 2 total 0.021339 0.003475 +35 2 1 1 3 total 0.021835 0.003963 +36 2 1 1 4 total 0.018361 0.006133 +37 2 1 1 5 total 0.023820 0.003932 +38 2 1 1 6 total 0.025805 0.003808 +39 2 1 1 7 total 0.026798 0.002299 +40 2 1 1 8 total 0.029279 0.003939 +41 2 1 1 9 total 0.034738 0.004323 +42 2 1 1 10 total 0.032753 0.006086 +43 2 1 1 11 total 0.057069 0.003798 22 2 1 2 1 total 0.000000 0.000000 23 2 1 2 2 total 0.000000 0.000000 24 2 1 2 3 total 0.000000 0.000000 @@ -212,29 +212,29 @@ 19 2 2 1 9 total 0.000000 0.000000 20 2 2 1 10 total 0.000000 0.000000 21 2 2 1 11 total 0.000000 0.000000 -0 2 2 2 1 total 0.026892 0.012233 -1 2 2 2 2 total 0.034959 0.007449 -2 2 2 2 3 total 0.040337 0.009144 -3 2 2 2 4 total 0.021513 0.003750 -4 2 2 2 5 total 0.018824 0.005602 -5 2 2 2 6 total 0.026892 0.004806 -6 2 2 2 7 total 0.037648 0.012716 -7 2 2 2 8 total 0.026892 0.009768 -8 2 2 2 9 total 0.024202 0.005420 -9 2 2 2 10 total 0.018824 0.010183 -10 2 2 2 11 total 0.018824 0.007033 +0 2 2 2 1 total 0.032254 0.009449 +1 2 2 2 2 total 0.018815 0.005569 +2 2 2 2 3 total 0.032254 0.009449 +3 2 2 2 4 total 0.024191 0.006844 +4 2 2 2 5 total 0.013439 0.008563 +5 2 2 2 6 total 0.024191 0.005365 +6 2 2 2 7 total 0.043005 0.010420 +7 2 2 2 8 total 0.032254 0.012710 +8 2 2 2 9 total 0.034942 0.007365 +9 2 2 2 10 total 0.021503 0.007051 +10 2 2 2 11 total 0.018815 0.008193 material group in group out mu bin nuclide mean std. dev. -33 2 1 1 1 total 0.025373 0.004281 -34 2 1 1 2 total 0.023909 0.004395 -35 2 1 1 3 total 0.019518 0.003911 -36 2 1 1 4 total 0.019518 0.003424 -37 2 1 1 5 total 0.020006 0.002901 -38 2 1 1 6 total 0.024885 0.005801 -39 2 1 1 7 total 0.019030 0.002566 -40 2 1 1 8 total 0.030741 0.001410 -41 2 1 1 9 total 0.034156 0.002902 -42 2 1 1 10 total 0.042939 0.004498 -43 2 1 1 11 total 0.054650 0.003865 +33 2 1 1 1 total 0.026798 0.002892 +34 2 1 1 2 total 0.021339 0.003475 +35 2 1 1 3 total 0.021835 0.003963 +36 2 1 1 4 total 0.018361 0.006133 +37 2 1 1 5 total 0.023820 0.003932 +38 2 1 1 6 total 0.025805 0.003808 +39 2 1 1 7 total 0.026798 0.002299 +40 2 1 1 8 total 0.029279 0.003939 +41 2 1 1 9 total 0.034738 0.004323 +42 2 1 1 10 total 0.032753 0.006086 +43 2 1 1 11 total 0.057069 0.003798 22 2 1 2 1 total 0.000000 0.000000 23 2 1 2 2 total 0.000000 0.000000 24 2 1 2 3 total 0.000000 0.000000 @@ -257,29 +257,29 @@ 19 2 2 1 9 total 0.000000 0.000000 20 2 2 1 10 total 0.000000 0.000000 21 2 2 1 11 total 0.000000 0.000000 -0 2 2 2 1 total 0.026892 0.012233 -1 2 2 2 2 total 0.034959 0.007449 -2 2 2 2 3 total 0.040337 0.009144 -3 2 2 2 4 total 0.021513 0.003750 -4 2 2 2 5 total 0.018824 0.005602 -5 2 2 2 6 total 0.026892 0.004806 -6 2 2 2 7 total 0.037648 0.012716 -7 2 2 2 8 total 0.026892 0.009768 -8 2 2 2 9 total 0.024202 0.005420 -9 2 2 2 10 total 0.018824 0.010183 -10 2 2 2 11 total 0.018824 0.007033 +0 2 2 2 1 total 0.032254 0.009449 +1 2 2 2 2 total 0.018815 0.005569 +2 2 2 2 3 total 0.032254 0.009449 +3 2 2 2 4 total 0.024191 0.006844 +4 2 2 2 5 total 0.013439 0.008563 +5 2 2 2 6 total 0.024191 0.005365 +6 2 2 2 7 total 0.043005 0.010420 +7 2 2 2 8 total 0.032254 0.012710 +8 2 2 2 9 total 0.034942 0.007365 +9 2 2 2 10 total 0.021503 0.007051 +10 2 2 2 11 total 0.018815 0.008193 material group in group out mu bin nuclide mean std. dev. -33 2 1 1 1 total 0.025753 0.004484 -34 2 1 1 2 total 0.024267 0.004581 -35 2 1 1 3 total 0.019810 0.004060 -36 2 1 1 4 total 0.019810 0.003579 -37 2 1 1 5 total 0.020305 0.003071 -38 2 1 1 6 total 0.025258 0.005987 -39 2 1 1 7 total 0.019315 0.002734 -40 2 1 1 8 total 0.031201 0.001961 -41 2 1 1 9 total 0.034668 0.003301 -42 2 1 1 10 total 0.043582 0.004935 -43 2 1 1 11 total 0.055468 0.004591 +33 2 1 1 1 total 0.026249 0.003012 +34 2 1 1 2 total 0.020902 0.003500 +35 2 1 1 3 total 0.021388 0.003971 +36 2 1 1 4 total 0.017986 0.006048 +37 2 1 1 5 total 0.023333 0.003958 +38 2 1 1 6 total 0.025277 0.003858 +39 2 1 1 7 total 0.026249 0.002473 +40 2 1 1 8 total 0.028680 0.004017 +41 2 1 1 9 total 0.034027 0.004437 +42 2 1 1 10 total 0.032082 0.006091 +43 2 1 1 11 total 0.055901 0.004311 22 2 1 2 1 total 0.000000 0.000000 23 2 1 2 2 total 0.000000 0.000000 24 2 1 2 3 total 0.000000 0.000000 @@ -302,29 +302,29 @@ 19 2 2 1 9 total 0.000000 0.000000 20 2 2 1 10 total 0.000000 0.000000 21 2 2 1 11 total 0.000000 0.000000 -0 2 2 2 1 total 0.026854 0.012543 -1 2 2 2 2 total 0.034911 0.008307 -2 2 2 2 3 total 0.040281 0.010079 -3 2 2 2 4 total 0.021483 0.004382 -4 2 2 2 5 total 0.018798 0.005938 -5 2 2 2 6 total 0.026854 0.005579 -6 2 2 2 7 total 0.037596 0.013308 -7 2 2 2 8 total 0.026854 0.010161 -8 2 2 2 9 total 0.024169 0.005987 -9 2 2 2 10 total 0.018798 0.010362 -10 2 2 2 11 total 0.018798 0.007300 +0 2 2 2 1 total 0.032230 0.009604 +1 2 2 2 2 total 0.018801 0.005658 +2 2 2 2 3 total 0.032230 0.009604 +3 2 2 2 4 total 0.024172 0.006964 +4 2 2 2 5 total 0.013429 0.008588 +5 2 2 2 6 total 0.024172 0.005520 +6 2 2 2 7 total 0.042973 0.010671 +7 2 2 2 8 total 0.032230 0.012821 +8 2 2 2 9 total 0.034915 0.007601 +9 2 2 2 10 total 0.021486 0.007142 +10 2 2 2 11 total 0.018801 0.008251 material group in group out mu bin nuclide mean std. dev. -33 2 1 1 1 total 0.025753 0.004661 -34 2 1 1 2 total 0.024267 0.004736 -35 2 1 1 3 total 0.019810 0.004177 -36 2 1 1 4 total 0.019810 0.003711 -37 2 1 1 5 total 0.020305 0.003231 -38 2 1 1 6 total 0.025258 0.006117 -39 2 1 1 7 total 0.019315 0.002897 -40 2 1 1 8 total 0.031201 0.002497 -41 2 1 1 9 total 0.034668 0.003721 -42 2 1 1 10 total 0.043582 0.005386 -43 2 1 1 11 total 0.055468 0.005350 +33 2 1 1 1 total 0.026249 0.003460 +34 2 1 1 2 total 0.020902 0.003754 +35 2 1 1 3 total 0.021388 0.004206 +36 2 1 1 4 total 0.017986 0.006160 +37 2 1 1 5 total 0.023333 0.004238 +38 2 1 1 6 total 0.025277 0.004192 +39 2 1 1 7 total 0.026249 0.003003 +40 2 1 1 8 total 0.028680 0.004427 +41 2 1 1 9 total 0.034027 0.004956 +42 2 1 1 10 total 0.032082 0.006437 +43 2 1 1 11 total 0.055901 0.005636 22 2 1 2 1 total 0.000000 0.000000 23 2 1 2 2 total 0.000000 0.000000 24 2 1 2 3 total 0.000000 0.000000 @@ -347,40 +347,40 @@ 19 2 2 1 9 total 0.000000 0.000000 20 2 2 1 10 total 0.000000 0.000000 21 2 2 1 11 total 0.000000 0.000000 -0 2 2 2 1 total 0.026854 0.013054 -1 2 2 2 2 total 0.034911 0.009546 -2 2 2 2 3 total 0.040281 0.011446 -3 2 2 2 4 total 0.021483 0.005251 -4 2 2 2 5 total 0.018798 0.006456 -5 2 2 2 6 total 0.026854 0.006649 -6 2 2 2 7 total 0.037596 0.014239 -7 2 2 2 8 total 0.026854 0.010785 -8 2 2 2 9 total 0.024169 0.006815 -9 2 2 2 10 total 0.018798 0.010667 -10 2 2 2 11 total 0.018798 0.007727 +0 2 2 2 1 total 0.032230 0.010330 +1 2 2 2 2 total 0.018801 0.006077 +2 2 2 2 3 total 0.032230 0.010330 +3 2 2 2 4 total 0.024172 0.007526 +4 2 2 2 5 total 0.013429 0.008733 +5 2 2 2 6 total 0.024172 0.006213 +6 2 2 2 7 total 0.042973 0.011815 +7 2 2 2 8 total 0.032230 0.013373 +8 2 2 2 9 total 0.034915 0.008646 +9 2 2 2 10 total 0.021486 0.007579 +10 2 2 2 11 total 0.018801 0.008544 material group in group out mu bin nuclide mean std. dev. -33 3 1 1 1 total 0.007681 0.001043 -34 3 1 1 2 total 0.005645 0.000710 -35 3 1 1 3 total 0.007403 0.000552 -36 3 1 1 4 total 0.007866 0.000512 -37 3 1 1 5 total 0.007589 0.000524 -38 3 1 1 6 total 0.011198 0.001548 -39 3 1 1 7 total 0.039701 0.002533 -40 3 1 1 8 total 0.075978 0.001897 -41 3 1 1 9 total 0.112532 0.003677 -42 3 1 1 10 total 0.166670 0.005003 -43 3 1 1 11 total 0.210443 0.005656 -22 3 1 2 1 total 0.000463 0.000207 -23 3 1 2 2 total 0.000555 0.000227 -24 3 1 2 3 total 0.000740 0.000429 -25 3 1 2 4 total 0.001111 0.000236 -26 3 1 2 5 total 0.002128 0.000631 -27 3 1 2 6 total 0.003146 0.000645 -28 3 1 2 7 total 0.004905 0.000561 -29 3 1 2 8 total 0.005738 0.000742 -30 3 1 2 9 total 0.005090 0.000672 -31 3 1 2 10 total 0.005367 0.000561 -32 3 1 2 11 total 0.002406 0.000593 +33 3 1 1 1 total 0.007006 0.000692 +34 3 1 1 2 total 0.006819 0.000431 +35 3 1 1 3 total 0.005511 0.000591 +36 3 1 1 4 total 0.006165 0.000470 +37 3 1 1 5 total 0.007660 0.000919 +38 3 1 1 6 total 0.012237 0.000938 +39 3 1 1 7 total 0.040914 0.002235 +40 3 1 1 8 total 0.074356 0.001968 +41 3 1 1 9 total 0.121622 0.004662 +42 3 1 1 10 total 0.158707 0.004147 +43 3 1 1 11 total 0.200742 0.007791 +22 3 1 2 1 total 0.000187 0.000187 +23 3 1 2 2 total 0.001028 0.000096 +24 3 1 2 3 total 0.000841 0.000176 +25 3 1 2 4 total 0.000841 0.000310 +26 3 1 2 5 total 0.001308 0.000274 +27 3 1 2 6 total 0.003736 0.000538 +28 3 1 2 7 total 0.003830 0.000703 +29 3 1 2 8 total 0.006259 0.000452 +30 3 1 2 9 total 0.005231 0.000510 +31 3 1 2 10 total 0.005044 0.000440 +32 3 1 2 11 total 0.002522 0.000194 11 3 2 1 1 total 0.000000 0.000000 12 3 2 1 2 total 0.000000 0.000000 13 3 2 1 3 total 0.000000 0.000000 @@ -390,42 +390,42 @@ 17 3 2 1 7 total 0.000000 0.000000 18 3 2 1 8 total 0.000000 0.000000 19 3 2 1 9 total 0.000000 0.000000 -20 3 2 1 10 total 0.000000 0.000000 -21 3 2 1 11 total 0.000474 0.000475 -0 3 2 2 1 total 0.074402 0.007811 -1 3 2 2 2 total 0.103783 0.009042 -2 3 2 2 3 total 0.106153 0.012691 -3 3 2 2 4 total 0.115631 0.011475 -4 3 2 2 5 total 0.128900 0.014096 -5 3 2 2 6 total 0.169655 0.021010 -6 3 2 2 7 total 0.175816 0.016086 -7 3 2 2 8 total 0.217519 0.029631 -8 3 2 2 9 total 0.247374 0.021476 -9 3 2 2 10 total 0.299977 0.031756 -10 3 2 2 11 total 0.351157 0.027654 +20 3 2 1 10 total 0.000467 0.000467 +21 3 2 1 11 total 0.000000 0.000000 +0 3 2 2 1 total 0.084030 0.007630 +1 3 2 2 2 total 0.099902 0.010027 +2 3 2 2 3 total 0.112040 0.010928 +3 3 2 2 4 total 0.117642 0.008523 +4 3 2 2 5 total 0.139116 0.009002 +5 3 2 2 6 total 0.161057 0.013537 +6 3 2 2 7 total 0.180664 0.010135 +7 3 2 2 8 total 0.219411 0.014717 +8 3 2 2 9 total 0.239485 0.027005 +9 3 2 2 10 total 0.281033 0.021376 +10 3 2 2 11 total 0.369731 0.027200 material group in group out mu bin nuclide mean std. dev. -33 3 1 1 1 total 0.007681 0.001043 -34 3 1 1 2 total 0.005645 0.000710 -35 3 1 1 3 total 0.007403 0.000552 -36 3 1 1 4 total 0.007866 0.000512 -37 3 1 1 5 total 0.007589 0.000524 -38 3 1 1 6 total 0.011198 0.001548 -39 3 1 1 7 total 0.039701 0.002533 -40 3 1 1 8 total 0.075978 0.001897 -41 3 1 1 9 total 0.112532 0.003677 -42 3 1 1 10 total 0.166670 0.005003 -43 3 1 1 11 total 0.210443 0.005656 -22 3 1 2 1 total 0.000463 0.000207 -23 3 1 2 2 total 0.000555 0.000227 -24 3 1 2 3 total 0.000740 0.000429 -25 3 1 2 4 total 0.001111 0.000236 -26 3 1 2 5 total 0.002128 0.000631 -27 3 1 2 6 total 0.003146 0.000645 -28 3 1 2 7 total 0.004905 0.000561 -29 3 1 2 8 total 0.005738 0.000742 -30 3 1 2 9 total 0.005090 0.000672 -31 3 1 2 10 total 0.005367 0.000561 -32 3 1 2 11 total 0.002406 0.000593 +33 3 1 1 1 total 0.007006 0.000692 +34 3 1 1 2 total 0.006819 0.000431 +35 3 1 1 3 total 0.005511 0.000591 +36 3 1 1 4 total 0.006165 0.000470 +37 3 1 1 5 total 0.007660 0.000919 +38 3 1 1 6 total 0.012237 0.000938 +39 3 1 1 7 total 0.040914 0.002235 +40 3 1 1 8 total 0.074356 0.001968 +41 3 1 1 9 total 0.121622 0.004662 +42 3 1 1 10 total 0.158707 0.004147 +43 3 1 1 11 total 0.200742 0.007791 +22 3 1 2 1 total 0.000187 0.000187 +23 3 1 2 2 total 0.001028 0.000096 +24 3 1 2 3 total 0.000841 0.000176 +25 3 1 2 4 total 0.000841 0.000310 +26 3 1 2 5 total 0.001308 0.000274 +27 3 1 2 6 total 0.003736 0.000538 +28 3 1 2 7 total 0.003830 0.000703 +29 3 1 2 8 total 0.006259 0.000452 +30 3 1 2 9 total 0.005231 0.000510 +31 3 1 2 10 total 0.005044 0.000440 +32 3 1 2 11 total 0.002522 0.000194 11 3 2 1 1 total 0.000000 0.000000 12 3 2 1 2 total 0.000000 0.000000 13 3 2 1 3 total 0.000000 0.000000 @@ -435,42 +435,42 @@ 17 3 2 1 7 total 0.000000 0.000000 18 3 2 1 8 total 0.000000 0.000000 19 3 2 1 9 total 0.000000 0.000000 -20 3 2 1 10 total 0.000000 0.000000 -21 3 2 1 11 total 0.000474 0.000475 -0 3 2 2 1 total 0.074402 0.007811 -1 3 2 2 2 total 0.103783 0.009042 -2 3 2 2 3 total 0.106153 0.012691 -3 3 2 2 4 total 0.115631 0.011475 -4 3 2 2 5 total 0.128900 0.014096 -5 3 2 2 6 total 0.169655 0.021010 -6 3 2 2 7 total 0.175816 0.016086 -7 3 2 2 8 total 0.217519 0.029631 -8 3 2 2 9 total 0.247374 0.021476 -9 3 2 2 10 total 0.299977 0.031756 -10 3 2 2 11 total 0.351157 0.027654 +20 3 2 1 10 total 0.000467 0.000467 +21 3 2 1 11 total 0.000000 0.000000 +0 3 2 2 1 total 0.084030 0.007630 +1 3 2 2 2 total 0.099902 0.010027 +2 3 2 2 3 total 0.112040 0.010928 +3 3 2 2 4 total 0.117642 0.008523 +4 3 2 2 5 total 0.139116 0.009002 +5 3 2 2 6 total 0.161057 0.013537 +6 3 2 2 7 total 0.180664 0.010135 +7 3 2 2 8 total 0.219411 0.014717 +8 3 2 2 9 total 0.239485 0.027005 +9 3 2 2 10 total 0.281033 0.021376 +10 3 2 2 11 total 0.369731 0.027200 material group in group out mu bin nuclide mean std. dev. -33 3 1 1 1 total 0.007759 0.001080 -34 3 1 1 2 total 0.005703 0.000738 -35 3 1 1 3 total 0.007479 0.000602 -36 3 1 1 4 total 0.007946 0.000571 -37 3 1 1 5 total 0.007666 0.000578 -38 3 1 1 6 total 0.011312 0.001601 -39 3 1 1 7 total 0.040106 0.002833 -40 3 1 1 8 total 0.076753 0.003016 -41 3 1 1 9 total 0.113680 0.005068 -42 3 1 1 10 total 0.168370 0.007185 -43 3 1 1 11 total 0.212589 0.008616 -22 3 1 2 1 total 0.000467 0.000210 -23 3 1 2 2 total 0.000561 0.000230 -24 3 1 2 3 total 0.000748 0.000434 -25 3 1 2 4 total 0.001122 0.000241 -26 3 1 2 5 total 0.002150 0.000641 -27 3 1 2 6 total 0.003179 0.000659 -28 3 1 2 7 total 0.004955 0.000586 -29 3 1 2 8 total 0.005796 0.000770 -30 3 1 2 9 total 0.005142 0.000697 -31 3 1 2 10 total 0.005422 0.000590 -32 3 1 2 11 total 0.002431 0.000604 +33 3 1 1 1 total 0.007106 0.000737 +34 3 1 1 2 total 0.006917 0.000488 +35 3 1 1 3 total 0.005590 0.000624 +36 3 1 1 4 total 0.006254 0.000516 +37 3 1 1 5 total 0.007770 0.000964 +38 3 1 1 6 total 0.012412 0.001029 +39 3 1 1 7 total 0.041501 0.002618 +40 3 1 1 8 total 0.075421 0.003106 +41 3 1 1 9 total 0.123365 0.006125 +42 3 1 1 10 total 0.160981 0.006595 +43 3 1 1 11 total 0.203618 0.010185 +22 3 1 2 1 total 0.000190 0.000190 +23 3 1 2 2 total 0.001042 0.000103 +24 3 1 2 3 total 0.000853 0.000180 +25 3 1 2 4 total 0.000853 0.000316 +26 3 1 2 5 total 0.001327 0.000281 +27 3 1 2 6 total 0.003790 0.000559 +28 3 1 2 7 total 0.003885 0.000724 +29 3 1 2 8 total 0.006348 0.000500 +30 3 1 2 9 total 0.005306 0.000544 +31 3 1 2 10 total 0.005117 0.000475 +32 3 1 2 11 total 0.002558 0.000213 11 3 2 1 1 total 0.000000 0.000000 12 3 2 1 2 total 0.000000 0.000000 13 3 2 1 3 total 0.000000 0.000000 @@ -480,42 +480,42 @@ 17 3 2 1 7 total 0.000000 0.000000 18 3 2 1 8 total 0.000000 0.000000 19 3 2 1 9 total 0.000000 0.000000 -20 3 2 1 10 total 0.000000 0.000000 -21 3 2 1 11 total 0.000477 0.000479 -0 3 2 2 1 total 0.074833 0.009685 -1 3 2 2 2 total 0.104384 0.012046 -2 3 2 2 3 total 0.106768 0.015107 -3 3 2 2 4 total 0.116300 0.014515 -4 3 2 2 5 total 0.129646 0.017242 -5 3 2 2 6 total 0.170637 0.024765 -6 3 2 2 7 total 0.176834 0.020997 -7 3 2 2 8 total 0.218778 0.034093 -8 3 2 2 9 total 0.248807 0.028656 -9 3 2 2 10 total 0.301714 0.039263 -10 3 2 2 11 total 0.353191 0.038577 +20 3 2 1 10 total 0.000466 0.000467 +21 3 2 1 11 total 0.000000 0.000000 +0 3 2 2 1 total 0.083912 0.007782 +1 3 2 2 2 total 0.099762 0.010188 +2 3 2 2 3 total 0.111883 0.011115 +3 3 2 2 4 total 0.117477 0.008794 +4 3 2 2 5 total 0.138921 0.009363 +5 3 2 2 6 total 0.160831 0.013853 +6 3 2 2 7 total 0.180411 0.010676 +7 3 2 2 8 total 0.219104 0.015265 +8 3 2 2 9 total 0.239149 0.027341 +9 3 2 2 10 total 0.280639 0.021991 +10 3 2 2 11 total 0.369213 0.028038 material group in group out mu bin nuclide mean std. dev. -33 3 1 1 1 total 0.007759 0.001091 -34 3 1 1 2 total 0.005703 0.000746 -35 3 1 1 3 total 0.007479 0.000619 -36 3 1 1 4 total 0.007946 0.000592 -37 3 1 1 5 total 0.007666 0.000598 -38 3 1 1 6 total 0.011312 0.001616 -39 3 1 1 7 total 0.040106 0.002941 -40 3 1 1 8 total 0.076753 0.003373 -41 3 1 1 9 total 0.113680 0.005540 -42 3 1 1 10 total 0.168370 0.007913 -43 3 1 1 11 total 0.212589 0.009578 -22 3 1 2 1 total 0.000467 0.000211 -23 3 1 2 2 total 0.000561 0.000232 -24 3 1 2 3 total 0.000748 0.000436 -25 3 1 2 4 total 0.001122 0.000250 -26 3 1 2 5 total 0.002150 0.000653 -27 3 1 2 6 total 0.003179 0.000684 -28 3 1 2 7 total 0.004955 0.000654 -29 3 1 2 8 total 0.005796 0.000841 -30 3 1 2 9 total 0.005142 0.000759 -31 3 1 2 10 total 0.005422 0.000670 -32 3 1 2 11 total 0.002431 0.000620 +33 3 1 1 1 total 0.007106 0.000751 +34 3 1 1 2 total 0.006917 0.000509 +35 3 1 1 3 total 0.005590 0.000635 +36 3 1 1 4 total 0.006254 0.000532 +37 3 1 1 5 total 0.007770 0.000977 +38 3 1 1 6 total 0.012412 0.001060 +39 3 1 1 7 total 0.041501 0.002755 +40 3 1 1 8 total 0.075421 0.003475 +41 3 1 1 9 total 0.123365 0.006634 +42 3 1 1 10 total 0.160981 0.007387 +43 3 1 1 11 total 0.203618 0.011019 +22 3 1 2 1 total 0.000190 0.000190 +23 3 1 2 2 total 0.001042 0.000114 +24 3 1 2 3 total 0.000853 0.000185 +25 3 1 2 4 total 0.000853 0.000319 +26 3 1 2 5 total 0.001327 0.000288 +27 3 1 2 6 total 0.003790 0.000588 +28 3 1 2 7 total 0.003885 0.000748 +29 3 1 2 8 total 0.006348 0.000587 +30 3 1 2 9 total 0.005306 0.000601 +31 3 1 2 10 total 0.005117 0.000535 +32 3 1 2 11 total 0.002558 0.000246 11 3 2 1 1 total 0.000000 0.000000 12 3 2 1 2 total 0.000000 0.000000 13 3 2 1 3 total 0.000000 0.000000 @@ -525,16 +525,16 @@ 17 3 2 1 7 total 0.000000 0.000000 18 3 2 1 8 total 0.000000 0.000000 19 3 2 1 9 total 0.000000 0.000000 -20 3 2 1 10 total 0.000000 0.000000 -21 3 2 1 11 total 0.000477 0.000827 -0 3 2 2 1 total 0.074833 0.011051 -1 3 2 2 2 total 0.104384 0.014150 -2 3 2 2 3 total 0.106768 0.016908 -3 3 2 2 4 total 0.116300 0.016707 -4 3 2 2 5 total 0.129646 0.019553 -5 3 2 2 6 total 0.170637 0.027579 -6 3 2 2 7 total 0.176834 0.024476 -7 3 2 2 8 total 0.218778 0.037476 -8 3 2 2 9 total 0.248807 0.033680 -9 3 2 2 10 total 0.301714 0.044745 -10 3 2 2 11 total 0.353191 0.046035 +20 3 2 1 10 total 0.000466 0.000808 +21 3 2 1 11 total 0.000000 0.000000 +0 3 2 2 1 total 0.083912 0.008936 +1 3 2 2 2 total 0.099762 0.011448 +2 3 2 2 3 total 0.111883 0.012563 +3 3 2 2 4 total 0.117477 0.010731 +4 3 2 2 5 total 0.138921 0.011855 +5 3 2 2 6 total 0.160831 0.016211 +6 3 2 2 7 total 0.180411 0.014254 +7 3 2 2 8 total 0.219104 0.019093 +8 3 2 2 9 total 0.239149 0.030071 +9 3 2 2 10 total 0.280639 0.026447 +10 3 2 2 11 total 0.369213 0.034054 diff --git a/tests/regression_tests/mgxs_library_histogram/test.py b/tests/regression_tests/mgxs_library_histogram/test.py index 42fc1957a..b9905910a 100644 --- a/tests/regression_tests/mgxs_library_histogram/test.py +++ b/tests/regression_tests/mgxs_library_histogram/test.py @@ -30,7 +30,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_mesh/inputs_true.dat b/tests/regression_tests/mgxs_library_mesh/inputs_true.dat index 5a6e8a20a..bb9c99026 100644 --- a/tests/regression_tests/mgxs_library_mesh/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_mesh/inputs_true.dat @@ -1,28 +1,28 @@ - - - + + + - - + + - - - - - - - - - - - + + + + + + + + + + + eigenvalue diff --git a/tests/regression_tests/mgxs_library_mesh/results_true.dat b/tests/regression_tests/mgxs_library_mesh/results_true.dat index ec7620c5c..b1e8ac003 100644 --- a/tests/regression_tests/mgxs_library_mesh/results_true.dat +++ b/tests/regression_tests/mgxs_library_mesh/results_true.dat @@ -1,362 +1,362 @@ - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.103374 0.004981 -2 1 2 1 total 0.103852 0.004752 -1 2 1 1 total 0.103322 0.003613 -3 2 2 1 total 0.102889 0.003387 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.072760 0.005235 -2 1 2 1 total 0.074856 0.004972 -1 2 1 1 total 0.074583 0.004000 -3 2 2 1 total 0.072925 0.003485 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.072768 0.005236 -2 1 2 1 total 0.074864 0.004972 -1 2 1 1 total 0.074603 0.004002 -3 2 2 1 total 0.072881 0.003491 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.013309 0.000729 -2 1 2 1 total 0.013223 0.000707 -1 2 1 1 total 0.013222 0.000596 -3 2 2 1 total 0.013282 0.000564 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.013241 0.000728 -2 1 2 1 total 0.013142 0.000705 -1 2 1 1 total 0.013137 0.000596 -3 2 2 1 total 0.013221 0.000564 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.001281 0.000874 -2 1 2 1 total 0.001297 0.000731 -1 2 1 1 total 0.001281 0.000744 -3 2 2 1 total 0.001288 0.000719 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.012029 0.000664 -2 1 2 1 total 0.011926 0.000639 -1 2 1 1 total 0.011941 0.000545 -3 2 2 1 total 0.011994 0.000515 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.031361 0.001735 -2 1 2 1 total 0.031091 0.001675 -1 2 1 1 total 0.031169 0.001418 -3 2 2 1 total 0.031255 0.001366 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 2.326447e+06 128504.886535 -2 1 2 1 total 2.306518e+06 123638.096130 -1 2 1 1 total 2.309435e+06 105395.059055 -3 2 2 1 total 2.319667e+06 99692.620001 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.090065 0.004262 -2 1 2 1 total 0.090629 0.004086 -1 2 1 1 total 0.090100 0.003045 -3 2 2 1 total 0.089607 0.002828 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.090188 0.005151 -2 1 2 1 total 0.094339 0.004349 -1 2 1 1 total 0.088294 0.003953 -3 2 2 1 total 0.089633 0.002592 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.090122 0.005149 -1 1 1 1 1 P1 total 0.030614 0.001612 -2 1 1 1 1 P2 total 0.016490 0.000897 -3 1 1 1 1 P3 total 0.010163 0.000829 -8 1 2 1 1 P0 total 0.094307 0.004337 -9 1 2 1 1 P1 total 0.028996 0.001462 -10 1 2 1 1 P2 total 0.017486 0.000808 -11 1 2 1 1 P3 total 0.009753 0.000742 -4 2 1 1 1 P0 total 0.088198 0.003959 -5 2 1 1 1 P1 total 0.028739 0.001715 -6 2 1 1 1 P2 total 0.015608 0.000680 -7 2 1 1 1 P3 total 0.008232 0.000363 -12 2 2 1 1 P0 total 0.089536 0.002551 -13 2 2 1 1 P1 total 0.029964 0.000821 -14 2 2 1 1 P2 total 0.015742 0.001260 -15 2 2 1 1 P3 total 0.008944 0.000385 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.090188 0.005151 -1 1 1 1 1 P1 total 0.030606 0.001614 -2 1 1 1 1 P2 total 0.016462 0.000898 -3 1 1 1 1 P3 total 0.010173 0.000824 -8 1 2 1 1 P0 total 0.094339 0.004349 -9 1 2 1 1 P1 total 0.028988 0.001462 -10 1 2 1 1 P2 total 0.017473 0.000811 -11 1 2 1 1 P3 total 0.009763 0.000749 -4 2 1 1 1 P0 total 0.088294 0.003953 -5 2 1 1 1 P1 total 0.028719 0.001720 -6 2 1 1 1 P2 total 0.015571 0.000691 -7 2 1 1 1 P3 total 0.008255 0.000361 -12 2 2 1 1 P0 total 0.089633 0.002592 -13 2 2 1 1 P1 total 0.030008 0.000847 -14 2 2 1 1 P2 total 0.015748 0.001284 -15 2 2 1 1 P3 total 0.008951 0.000387 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 1.000736 0.060260 -2 1 2 1 1 total 1.000346 0.042656 -1 2 1 1 1 total 1.001091 0.052736 -3 2 2 1 1 total 1.001078 0.038212 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 0.031890 0.002523 -2 1 2 1 1 total 0.032714 0.001502 -1 2 1 1 1 total 0.030414 0.002369 -3 2 2 1 1 total 0.031051 0.001521 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 1.0 0.060234 -2 1 2 1 1 total 1.0 0.042523 -1 2 1 1 1 total 1.0 0.052777 -3 2 2 1 1 total 1.0 0.037842 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.090065 0.006899 -1 1 1 1 1 P1 total 0.030595 0.002243 -2 1 1 1 1 P2 total 0.016480 0.001229 -3 1 1 1 1 P3 total 0.010157 0.000977 -8 1 2 1 1 P0 total 0.090629 0.005616 -9 1 2 1 1 P1 total 0.027865 0.001820 -10 1 2 1 1 P2 total 0.016804 0.001044 -11 1 2 1 1 P3 total 0.009373 0.000813 -4 2 1 1 1 P0 total 0.090100 0.005647 -5 2 1 1 1 P1 total 0.029359 0.002172 -6 2 1 1 1 P2 total 0.015944 0.000984 -7 2 1 1 1 P3 total 0.008410 0.000523 -12 2 2 1 1 P0 total 0.089607 0.004415 -13 2 2 1 1 P1 total 0.029988 0.001459 -14 2 2 1 1 P2 total 0.015755 0.001411 -15 2 2 1 1 P3 total 0.008951 0.000528 - mesh 1 group in group out legendre nuclide mean std. dev. - x y -0 1 1 1 1 P0 total 0.090131 0.008782 -1 1 1 1 1 P1 total 0.030617 0.002905 -2 1 1 1 1 P2 total 0.016492 0.001581 -3 1 1 1 1 P3 total 0.010164 0.001154 -8 1 2 1 1 P0 total 0.090661 0.006820 -9 1 2 1 1 P1 total 0.027875 0.002174 -10 1 2 1 1 P2 total 0.016810 0.001267 -11 1 2 1 1 P3 total 0.009376 0.000906 -4 2 1 1 1 P0 total 0.090199 0.007385 -5 2 1 1 1 P1 total 0.029391 0.002669 -6 2 1 1 1 P2 total 0.015962 0.001295 -7 2 1 1 1 P3 total 0.008419 0.000686 -12 2 2 1 1 P0 total 0.089704 0.005591 -13 2 2 1 1 P1 total 0.030020 0.001856 -14 2 2 1 1 P2 total 0.015772 0.001536 -15 2 2 1 1 P3 total 0.008961 0.000629 - mesh 1 group out nuclide mean std. dev. - x y -0 1 1 1 total 1.0 0.098093 -2 1 2 1 total 1.0 0.042346 -1 2 1 1 total 1.0 0.104352 -3 2 2 1 total 1.0 0.067889 - mesh 1 group out nuclide mean std. dev. - x y -0 1 1 1 total 1.0 0.099401 -2 1 2 1 total 1.0 0.042085 -1 2 1 1 total 1.0 0.104135 -3 2 2 1 total 1.0 0.067307 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 8.547713e-10 3.477664e-11 -2 1 2 1 total 9.057083e-10 4.171858e-11 -1 2 1 1 total 8.666731e-10 2.371072e-11 -3 2 2 1 total 8.532016e-10 1.638929e-11 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 0.031163 0.001724 -2 1 2 1 total 0.030895 0.001664 -1 2 1 1 total 0.030973 0.001409 -3 2 2 1 total 0.031058 0.001358 - mesh 1 group in group out nuclide mean std. dev. - x y -0 1 1 1 1 total 0.031781 0.002541 -2 1 2 1 1 total 0.032490 0.001487 -1 2 1 1 1 total 0.030274 0.002354 -3 2 2 1 1 total 0.030882 0.001500 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.102539 0.004894 +2 1 2 1 1 total 0.106476 0.007513 +1 2 1 1 1 total 0.101207 0.004814 +3 2 2 1 1 total 0.101733 0.004445 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.073423 0.005232 +2 1 2 1 1 total 0.077906 0.007749 +1 2 1 1 1 total 0.071315 0.005181 +3 2 2 1 1 total 0.071983 0.004856 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.073443 0.005235 +2 1 2 1 1 total 0.077909 0.007749 +1 2 1 1 1 total 0.071315 0.005181 +3 2 2 1 1 total 0.071928 0.004865 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.013089 0.000762 +2 1 2 1 1 total 0.013802 0.000950 +1 2 1 1 1 total 0.012818 0.000708 +3 2 2 1 1 total 0.012954 0.000699 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.013016 0.000761 +2 1 2 1 1 total 0.013715 0.000947 +1 2 1 1 1 total 0.012740 0.000707 +3 2 2 1 1 total 0.012886 0.000698 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.001244 0.000926 +2 1 2 1 1 total 0.001345 0.000851 +1 2 1 1 1 total 0.001196 0.000768 +3 2 2 1 1 total 0.001234 0.000843 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.011844 0.000690 +2 1 2 1 1 total 0.012457 0.000852 +1 2 1 1 1 total 0.011622 0.000636 +3 2 2 1 1 total 0.011719 0.000633 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.030919 0.001784 +2 1 2 1 1 total 0.032495 0.002202 +1 2 1 1 1 total 0.030363 0.001664 +3 2 2 1 1 total 0.030565 0.001671 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 2.290786e+06 133521.277651 +2 1 2 1 1 total 2.409292e+06 164752.430241 +1 2 1 1 1 total 2.247742e+06 123005.689035 +3 2 2 1 1 total 2.266603e+06 122428.448367 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.089450 0.004147 +2 1 2 1 1 total 0.092674 0.006571 +1 2 1 1 1 total 0.088389 0.004152 +3 2 2 1 1 total 0.088779 0.003763 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.089555 0.004061 +2 1 2 1 1 total 0.092658 0.006216 +1 2 1 1 1 total 0.088293 0.004423 +3 2 2 1 1 total 0.088717 0.004937 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.089523 0.004070 +1 1 1 1 1 1 P1 total 0.029116 0.001851 +2 1 1 1 1 1 P2 total 0.016529 0.000827 +3 1 1 1 1 1 P3 total 0.009975 0.000731 +8 1 2 1 1 1 P0 total 0.092626 0.006233 +9 1 2 1 1 1 P1 total 0.028570 0.001899 +10 1 2 1 1 1 P2 total 0.015737 0.001986 +11 1 2 1 1 1 P3 total 0.008492 0.000859 +4 2 1 1 1 1 P0 total 0.088293 0.004423 +5 2 1 1 1 1 P1 total 0.029892 0.001916 +6 2 1 1 1 1 P2 total 0.016736 0.000714 +7 2 1 1 1 1 P3 total 0.009129 0.000509 +12 2 2 1 1 1 P0 total 0.088617 0.004889 +13 2 2 1 1 1 P1 total 0.029750 0.001954 +14 2 2 1 1 1 P2 total 0.016440 0.001320 +15 2 2 1 1 1 P3 total 0.009758 0.000538 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.089555 0.004061 +1 1 1 1 1 1 P1 total 0.029096 0.001859 +2 1 1 1 1 1 P2 total 0.016532 0.000828 +3 1 1 1 1 1 P3 total 0.009986 0.000734 +8 1 2 1 1 1 P0 total 0.092658 0.006216 +9 1 2 1 1 1 P1 total 0.028567 0.001899 +10 1 2 1 1 1 P2 total 0.015721 0.001995 +11 1 2 1 1 1 P3 total 0.008496 0.000857 +4 2 1 1 1 1 P0 total 0.088293 0.004423 +5 2 1 1 1 1 P1 total 0.029892 0.001916 +6 2 1 1 1 1 P2 total 0.016736 0.000714 +7 2 1 1 1 1 P3 total 0.009129 0.000509 +12 2 2 1 1 1 P0 total 0.088717 0.004937 +13 2 2 1 1 1 P1 total 0.029805 0.001977 +14 2 2 1 1 1 P2 total 0.016448 0.001327 +15 2 2 1 1 1 P3 total 0.009752 0.000534 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 1.000362 0.044694 +2 1 2 1 1 1 total 1.000346 0.059372 +1 2 1 1 1 1 total 1.000000 0.055277 +3 2 2 1 1 1 total 1.001132 0.057130 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.031634 0.002236 +2 1 2 1 1 1 total 0.032561 0.002344 +1 2 1 1 1 1 total 0.030820 0.002579 +3 2 2 1 1 1 total 0.029308 0.002507 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 1.0 0.044796 +2 1 2 1 1 1 total 1.0 0.059579 +1 2 1 1 1 1 total 1.0 0.055277 +3 2 2 1 1 1 total 1.0 0.056598 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.089450 0.005766 +1 1 1 1 1 1 P1 total 0.029092 0.002277 +2 1 1 1 1 1 P2 total 0.016516 0.001119 +3 1 1 1 1 1 P3 total 0.009967 0.000861 +8 1 2 1 1 1 P0 total 0.092674 0.008583 +9 1 2 1 1 1 P1 total 0.028585 0.002630 +10 1 2 1 1 1 P2 total 0.015745 0.002226 +11 1 2 1 1 1 P3 total 0.008496 0.001015 +4 2 1 1 1 1 P0 total 0.088389 0.006412 +5 2 1 1 1 1 P1 total 0.029924 0.002479 +6 2 1 1 1 1 P2 total 0.016754 0.001133 +7 2 1 1 1 1 P3 total 0.009139 0.000699 +12 2 2 1 1 1 P0 total 0.088779 0.006278 +13 2 2 1 1 1 P1 total 0.029804 0.002360 +14 2 2 1 1 1 P2 total 0.016470 0.001510 +15 2 2 1 1 1 P3 total 0.009776 0.000691 + mesh 1 group in group out legendre nuclide mean std. dev. + x y z +0 1 1 1 1 1 P0 total 0.089483 0.007018 +1 1 1 1 1 1 P1 total 0.029103 0.002623 +2 1 1 1 1 1 P2 total 0.016522 0.001341 +3 1 1 1 1 1 P3 total 0.009971 0.000970 +8 1 2 1 1 1 P0 total 0.092706 0.010197 +9 1 2 1 1 1 P1 total 0.028595 0.003131 +10 1 2 1 1 1 P2 total 0.015750 0.002415 +11 1 2 1 1 1 P3 total 0.008499 0.001134 +4 2 1 1 1 1 P0 total 0.088389 0.008061 +5 2 1 1 1 1 P1 total 0.029924 0.002980 +6 2 1 1 1 1 P2 total 0.016754 0.001463 +7 2 1 1 1 1 P3 total 0.009139 0.000863 +12 2 2 1 1 1 P0 total 0.088880 0.008076 +13 2 2 1 1 1 P1 total 0.029838 0.002912 +14 2 2 1 1 1 P2 total 0.016489 0.001781 +15 2 2 1 1 1 P3 total 0.009787 0.000889 + mesh 1 group out nuclide mean std. dev. + x y z +0 1 1 1 1 total 1.0 0.088672 +2 1 2 1 1 total 1.0 0.069731 +1 2 1 1 1 total 1.0 0.109718 +3 2 2 1 1 total 1.0 0.108376 + mesh 1 group out nuclide mean std. dev. + x y z +0 1 1 1 1 total 1.0 0.091154 +2 1 2 1 1 total 1.0 0.069438 +1 2 1 1 1 total 1.0 0.109233 +3 2 2 1 1 total 1.0 0.108119 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 8.424136e-10 3.612697e-11 +2 1 2 1 1 total 8.884166e-10 6.324091e-11 +1 2 1 1 1 total 8.415613e-10 4.520088e-11 +3 2 2 1 1 total 8.557929e-10 2.898037e-11 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.030724 0.001773 +2 1 2 1 1 total 0.032290 0.002188 +1 2 1 1 1 total 0.030172 0.001654 +3 2 2 1 1 total 0.030372 0.001661 + mesh 1 group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.031468 0.002273 +2 1 2 1 1 1 total 0.032418 0.002330 +1 2 1 1 1 1 total 0.030706 0.002559 +3 2 2 1 1 1 total 0.029134 0.002487 mesh 1 group in nuclide mean std. dev. x y surf -3 1 1 x-max in 1 total 0.1888 0.008218 -2 1 1 x-max out 1 total 0.1828 0.008212 +3 1 1 x-max in 1 total 0.1884 0.010255 +2 1 1 x-max out 1 total 0.1798 0.009646 1 1 1 x-min in 1 total 0.0000 0.000000 0 1 1 x-min out 1 total 0.0000 0.000000 -7 1 1 y-max in 1 total 0.1820 0.012534 -6 1 1 y-max out 1 total 0.1794 0.015302 +7 1 1 y-max in 1 total 0.1822 0.014739 +6 1 1 y-max out 1 total 0.1806 0.019423 5 1 1 y-min in 1 total 0.0000 0.000000 4 1 1 y-min out 1 total 0.0000 0.000000 -19 1 2 x-max in 1 total 0.1870 0.011696 -18 1 2 x-max out 1 total 0.1850 0.012919 +19 1 2 x-max in 1 total 0.1780 0.012514 +18 1 2 x-max out 1 total 0.1886 0.014979 17 1 2 x-min in 1 total 0.0000 0.000000 16 1 2 x-min out 1 total 0.0000 0.000000 23 1 2 y-max in 1 total 0.0000 0.000000 22 1 2 y-max out 1 total 0.0000 0.000000 -21 1 2 y-min in 1 total 0.1794 0.015302 -20 1 2 y-min out 1 total 0.1820 0.012534 +21 1 2 y-min in 1 total 0.1806 0.019423 +20 1 2 y-min out 1 total 0.1822 0.014739 11 2 1 x-max in 1 total 0.0000 0.000000 10 2 1 x-max out 1 total 0.0000 0.000000 -9 2 1 x-min in 1 total 0.1828 0.008212 -8 2 1 x-min out 1 total 0.1888 0.008218 -15 2 1 y-max in 1 total 0.1850 0.011256 -14 2 1 y-max out 1 total 0.1870 0.009597 +9 2 1 x-min in 1 total 0.1798 0.009646 +8 2 1 x-min out 1 total 0.1884 0.010255 +15 2 1 y-max in 1 total 0.1812 0.009583 +14 2 1 y-max out 1 total 0.1858 0.012018 13 2 1 y-min in 1 total 0.0000 0.000000 12 2 1 y-min out 1 total 0.0000 0.000000 27 2 2 x-max in 1 total 0.0000 0.000000 26 2 2 x-max out 1 total 0.0000 0.000000 -25 2 2 x-min in 1 total 0.1850 0.012919 -24 2 2 x-min out 1 total 0.1870 0.011696 +25 2 2 x-min in 1 total 0.1886 0.014979 +24 2 2 x-min out 1 total 0.1780 0.012514 31 2 2 y-max in 1 total 0.0000 0.000000 30 2 2 y-max out 1 total 0.0000 0.000000 -29 2 2 y-min in 1 total 0.1870 0.009597 -28 2 2 y-min out 1 total 0.1850 0.011256 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 4.581283 0.329623 -2 1 2 1 total 4.452968 0.295762 -1 2 1 1 total 4.469295 0.239674 -3 2 2 1 total 4.570894 0.218416 - mesh 1 group in nuclide mean std. dev. - x y -0 1 1 1 total 4.580746 0.329583 -2 1 2 1 total 4.452519 0.295716 -1 2 1 1 total 4.468066 0.239680 -3 2 2 1 total 4.573657 0.219069 - mesh 1 delayedgroup group in nuclide mean std. dev. - x y -0 1 1 1 1 total 0.000007 3.812309e-07 -1 1 1 2 1 total 0.000036 1.967797e-06 -2 1 1 3 1 total 0.000034 1.878630e-06 -3 1 1 4 1 total 0.000077 4.212043e-06 -4 1 1 5 1 total 0.000031 1.726878e-06 -5 1 1 6 1 total 0.000013 7.233832e-07 -12 1 2 1 1 total 0.000007 3.663985e-07 -13 1 2 2 1 total 0.000035 1.891236e-06 -14 1 2 3 1 total 0.000034 1.805539e-06 -15 1 2 4 1 total 0.000076 4.048166e-06 -16 1 2 5 1 total 0.000031 1.659691e-06 -17 1 2 6 1 total 0.000013 6.952388e-07 -6 2 1 1 1 total 0.000007 3.123173e-07 -7 2 1 2 1 total 0.000035 1.612086e-06 -8 2 1 3 1 total 0.000034 1.539037e-06 -9 2 1 4 1 total 0.000076 3.450649e-06 -10 2 1 5 1 total 0.000031 1.414717e-06 -11 2 1 6 1 total 0.000013 5.926201e-07 -18 2 2 1 1 total 0.000007 2.946716e-07 -19 2 2 2 1 total 0.000036 1.521004e-06 -20 2 2 3 1 total 0.000034 1.452083e-06 -21 2 2 4 1 total 0.000076 3.255689e-06 -22 2 2 5 1 total 0.000031 1.334787e-06 -23 2 2 6 1 total 0.000013 5.591374e-07 - mesh 1 delayedgroup group out nuclide mean std. dev. - x y -0 1 1 1 1 total 1.0 1.414214 -1 1 1 2 1 total 0.0 0.000000 -2 1 1 3 1 total 0.0 0.000000 -3 1 1 4 1 total 1.0 0.578922 -4 1 1 5 1 total 0.0 0.000000 -5 1 1 6 1 total 0.0 0.000000 -12 1 2 1 1 total 0.0 0.000000 -13 1 2 2 1 total 1.0 0.578922 -14 1 2 3 1 total 1.0 1.414214 -15 1 2 4 1 total 1.0 1.414214 -16 1 2 5 1 total 1.0 0.875472 -17 1 2 6 1 total 1.0 1.414214 -6 2 1 1 1 total 0.0 0.000000 -7 2 1 2 1 total 0.0 0.000000 -8 2 1 3 1 total 1.0 1.414214 -9 2 1 4 1 total 1.0 0.579392 -10 2 1 5 1 total 1.0 1.414214 -11 2 1 6 1 total 0.0 0.000000 -18 2 2 1 1 total 1.0 0.868163 -19 2 2 2 1 total 1.0 1.414214 -20 2 2 3 1 total 0.0 0.000000 -21 2 2 4 1 total 1.0 0.868969 -22 2 2 5 1 total 1.0 1.414214 -23 2 2 6 1 total 0.0 0.000000 - mesh 1 delayedgroup group in nuclide mean std. dev. - x y -0 1 1 1 1 total 0.000221 0.000015 -1 1 1 2 1 total 0.001140 0.000079 -2 1 1 3 1 total 0.001088 0.000075 -3 1 1 4 1 total 0.002440 0.000169 -4 1 1 5 1 total 0.001001 0.000069 -5 1 1 6 1 total 0.000419 0.000029 -12 1 2 1 1 total 0.000221 0.000013 -13 1 2 2 1 total 0.001139 0.000066 -14 1 2 3 1 total 0.001088 0.000063 -15 1 2 4 1 total 0.002439 0.000142 -16 1 2 5 1 total 0.001000 0.000058 -17 1 2 6 1 total 0.000419 0.000024 -6 2 1 1 1 total 0.000220 0.000013 -7 2 1 2 1 total 0.001138 0.000067 -8 2 1 3 1 total 0.001086 0.000064 -9 2 1 4 1 total 0.002435 0.000144 -10 2 1 5 1 total 0.000998 0.000059 -11 2 1 6 1 total 0.000418 0.000025 -18 2 2 1 1 total 0.000221 0.000013 -19 2 2 2 1 total 0.001141 0.000066 -20 2 2 3 1 total 0.001090 0.000063 -21 2 2 4 1 total 0.002443 0.000141 -22 2 2 5 1 total 0.001002 0.000058 -23 2 2 6 1 total 0.000420 0.000024 - mesh 1 delayedgroup nuclide mean std. dev. - x y -0 1 1 1 total 0.013336 0.000919 -1 1 1 2 total 0.032739 0.002257 -2 1 1 3 total 0.120780 0.008325 -3 1 1 4 total 0.302780 0.020871 -4 1 1 5 total 0.849490 0.058555 -5 1 1 6 total 2.853000 0.196656 -12 1 2 1 total 0.013336 0.000770 -13 1 2 2 total 0.032739 0.001891 -14 1 2 3 total 0.120780 0.006977 -15 1 2 4 total 0.302780 0.017490 -16 1 2 5 total 0.849490 0.049071 -17 1 2 6 total 2.853000 0.164804 -6 2 1 1 total 0.013336 0.000790 -7 2 1 2 total 0.032739 0.001940 -8 2 1 3 total 0.120780 0.007157 -9 2 1 4 total 0.302780 0.017942 -10 2 1 5 total 0.849490 0.050338 -11 2 1 6 total 2.853000 0.169061 -18 2 2 1 total 0.013336 0.000757 -19 2 2 2 total 0.032739 0.001858 -20 2 2 3 total 0.120780 0.006855 -21 2 2 4 total 0.302780 0.017186 -22 2 2 5 total 0.849490 0.048217 -23 2 2 6 total 2.853000 0.161935 - mesh 1 delayedgroup group in group out nuclide mean std. dev. - x y -0 1 1 1 1 1 total 0.000026 0.000026 -1 1 1 2 1 1 total 0.000000 0.000000 -2 1 1 3 1 1 total 0.000000 0.000000 -3 1 1 4 1 1 total 0.000083 0.000034 -4 1 1 5 1 1 total 0.000000 0.000000 -5 1 1 6 1 1 total 0.000000 0.000000 -12 1 2 1 1 1 total 0.000000 0.000000 -13 1 2 2 1 1 total 0.000081 0.000033 -14 1 2 3 1 1 total 0.000026 0.000026 -15 1 2 4 1 1 total 0.000026 0.000026 -16 1 2 5 1 1 total 0.000059 0.000036 -17 1 2 6 1 1 total 0.000033 0.000033 -6 2 1 1 1 1 total 0.000000 0.000000 -7 2 1 2 1 1 total 0.000000 0.000000 -8 2 1 3 1 1 total 0.000032 0.000032 -9 2 1 4 1 1 total 0.000080 0.000033 -10 2 1 5 1 1 total 0.000028 0.000028 -11 2 1 6 1 1 total 0.000000 0.000000 -18 2 2 1 1 1 total 0.000054 0.000033 -19 2 2 2 1 1 total 0.000029 0.000029 -20 2 2 3 1 1 total 0.000000 0.000000 -21 2 2 4 1 1 total 0.000054 0.000033 -22 2 2 5 1 1 total 0.000032 0.000032 -23 2 2 6 1 1 total 0.000000 0.000000 +29 2 2 y-min in 1 total 0.1858 0.012018 +28 2 2 y-min out 1 total 0.1812 0.009583 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 4.539911 0.323493 +2 1 2 1 1 total 4.278655 0.425575 +1 2 1 1 1 total 4.674097 0.339600 +3 2 2 1 1 total 4.630700 0.312366 + mesh 1 group in nuclide mean std. dev. + x y z +0 1 1 1 1 total 4.538654 0.323497 +2 1 2 1 1 total 4.278494 0.425550 +1 2 1 1 1 total 4.674097 0.339600 +3 2 2 1 1 total 4.634259 0.313464 + mesh 1 delayedgroup group in nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.000007 3.997262e-07 +1 1 1 1 2 1 total 0.000035 2.063264e-06 +2 1 1 1 3 1 total 0.000034 1.969771e-06 +3 1 1 1 4 1 total 0.000075 4.416388e-06 +4 1 1 1 5 1 total 0.000031 1.810657e-06 +5 1 1 1 6 1 total 0.000013 7.584779e-07 +12 1 2 1 1 1 total 0.000007 4.931656e-07 +13 1 2 1 2 1 total 0.000037 2.545569e-06 +14 1 2 1 3 1 total 0.000035 2.430221e-06 +15 1 2 1 4 1 total 0.000079 5.448757e-06 +16 1 2 1 5 1 total 0.000032 2.233913e-06 +17 1 2 1 6 1 total 0.000014 9.357785e-07 +6 2 1 1 1 1 total 0.000007 3.618632e-07 +7 2 1 1 2 1 total 0.000035 1.867826e-06 +8 2 1 1 3 1 total 0.000033 1.783189e-06 +9 2 1 1 4 1 total 0.000074 3.998058e-06 +10 2 1 1 5 1 total 0.000030 1.639147e-06 +11 2 1 1 6 1 total 0.000013 6.866331e-07 +18 2 2 1 1 1 total 0.000007 3.603080e-07 +19 2 2 1 2 1 total 0.000035 1.859799e-06 +20 2 2 1 3 1 total 0.000033 1.775526e-06 +21 2 2 1 4 1 total 0.000075 3.980875e-06 +22 2 2 1 5 1 total 0.000031 1.632103e-06 +23 2 2 1 6 1 total 0.000013 6.836821e-07 + mesh 1 delayedgroup group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.0 0.000000 +1 1 1 1 2 1 total 1.0 0.866877 +2 1 1 1 3 1 total 1.0 0.866877 +3 1 1 1 4 1 total 1.0 1.414214 +4 1 1 1 5 1 total 1.0 1.414214 +5 1 1 1 6 1 total 0.0 0.000000 +12 1 2 1 1 1 total 0.0 0.000000 +13 1 2 1 2 1 total 0.0 0.000000 +14 1 2 1 3 1 total 0.0 0.000000 +15 1 2 1 4 1 total 1.0 0.579346 +16 1 2 1 5 1 total 1.0 1.414214 +17 1 2 1 6 1 total 1.0 1.414214 +6 2 1 1 1 1 total 1.0 1.414214 +7 2 1 1 2 1 total 1.0 1.414214 +8 2 1 1 3 1 total 1.0 0.874781 +9 2 1 1 4 1 total 0.0 0.000000 +10 2 1 1 5 1 total 0.0 0.000000 +11 2 1 1 6 1 total 0.0 0.000000 +18 2 2 1 1 1 total 1.0 1.414214 +19 2 2 1 2 1 total 1.0 0.867902 +20 2 2 1 3 1 total 1.0 1.414214 +21 2 2 1 4 1 total 1.0 1.414214 +22 2 2 1 5 1 total 1.0 1.414214 +23 2 2 1 6 1 total 0.0 0.000000 + mesh 1 delayedgroup group in nuclide mean std. dev. + x y z +0 1 1 1 1 1 total 0.000221 0.000016 +1 1 1 1 2 1 total 0.001138 0.000084 +2 1 1 1 3 1 total 0.001087 0.000080 +3 1 1 1 4 1 total 0.002437 0.000180 +4 1 1 1 5 1 total 0.000999 0.000074 +5 1 1 1 6 1 total 0.000418 0.000031 +12 1 2 1 1 1 total 0.000221 0.000014 +13 1 2 1 2 1 total 0.001138 0.000073 +14 1 2 1 3 1 total 0.001087 0.000069 +15 1 2 1 4 1 total 0.002436 0.000155 +16 1 2 1 5 1 total 0.000999 0.000064 +17 1 2 1 6 1 total 0.000418 0.000027 +6 2 1 1 1 1 total 0.000220 0.000014 +7 2 1 1 2 1 total 0.001137 0.000070 +8 2 1 1 3 1 total 0.001086 0.000067 +9 2 1 1 4 1 total 0.002435 0.000150 +10 2 1 1 5 1 total 0.000998 0.000062 +11 2 1 1 6 1 total 0.000418 0.000026 +18 2 2 1 1 1 total 0.000221 0.000015 +19 2 2 1 2 1 total 0.001141 0.000078 +20 2 2 1 3 1 total 0.001089 0.000074 +21 2 2 1 4 1 total 0.002442 0.000167 +22 2 2 1 5 1 total 0.001001 0.000068 +23 2 2 1 6 1 total 0.000419 0.000029 + mesh 1 delayedgroup nuclide mean std. dev. + x y z +0 1 1 1 1 total 0.013336 0.000997 +1 1 1 1 2 total 0.032739 0.002447 +2 1 1 1 3 total 0.120780 0.009028 +3 1 1 1 4 total 0.302780 0.022633 +4 1 1 1 5 total 0.849490 0.063500 +5 1 1 1 6 total 2.853000 0.213262 +12 1 2 1 1 total 0.013336 0.000866 +13 1 2 1 2 total 0.032739 0.002126 +14 1 2 1 3 total 0.120780 0.007843 +15 1 2 1 4 total 0.302780 0.019661 +16 1 2 1 5 total 0.849490 0.055163 +17 1 2 1 6 total 2.853000 0.185263 +6 2 1 1 1 total 0.013336 0.000814 +7 2 1 1 2 total 0.032739 0.001999 +8 2 1 1 3 total 0.120780 0.007373 +9 2 1 1 4 total 0.302780 0.018483 +10 2 1 1 5 total 0.849490 0.051857 +11 2 1 1 6 total 2.853000 0.174163 +18 2 2 1 1 total 0.013336 0.000896 +19 2 2 1 2 total 0.032739 0.002200 +20 2 2 1 3 total 0.120780 0.008117 +21 2 2 1 4 total 0.302780 0.020349 +22 2 2 1 5 total 0.849490 0.057091 +23 2 2 1 6 total 2.853000 0.191738 + mesh 1 delayedgroup group in group out nuclide mean std. dev. + x y z +0 1 1 1 1 1 1 total 0.000000 0.000000 +1 1 1 1 2 1 1 total 0.000056 0.000034 +2 1 1 1 3 1 1 total 0.000056 0.000034 +3 1 1 1 4 1 1 total 0.000029 0.000029 +4 1 1 1 5 1 1 total 0.000026 0.000026 +5 1 1 1 6 1 1 total 0.000000 0.000000 +12 1 2 1 1 1 1 total 0.000000 0.000000 +13 1 2 1 2 1 1 total 0.000000 0.000000 +14 1 2 1 3 1 1 total 0.000000 0.000000 +15 1 2 1 4 1 1 total 0.000079 0.000033 +16 1 2 1 5 1 1 total 0.000032 0.000032 +17 1 2 1 6 1 1 total 0.000032 0.000032 +6 2 1 1 1 1 1 total 0.000029 0.000029 +7 2 1 1 2 1 1 total 0.000027 0.000027 +8 2 1 1 3 1 1 total 0.000058 0.000036 +9 2 1 1 4 1 1 total 0.000000 0.000000 +10 2 1 1 5 1 1 total 0.000000 0.000000 +11 2 1 1 6 1 1 total 0.000000 0.000000 +18 2 2 1 1 1 1 total 0.000027 0.000027 +19 2 2 1 2 1 1 total 0.000056 0.000035 +20 2 2 1 3 1 1 total 0.000028 0.000028 +21 2 2 1 4 1 1 total 0.000030 0.000030 +22 2 2 1 5 1 1 total 0.000033 0.000033 +23 2 2 1 6 1 1 total 0.000000 0.000000 diff --git a/tests/regression_tests/mgxs_library_mesh/test.py b/tests/regression_tests/mgxs_library_mesh/test.py index c1a5980b5..89c68a75a 100644 --- a/tests/regression_tests/mgxs_library_mesh/test.py +++ b/tests/regression_tests/mgxs_library_mesh/test.py @@ -57,7 +57,7 @@ def model(): model.mgxs_lib.build_library() # Add tallies - model.mgxs_lib.add_to_tallies(model.tallies, merge=False) + model.mgxs_lib.add_to_tallies_file(model.tallies, merge=False) return model diff --git a/tests/regression_tests/mgxs_library_no_nuclides/inputs_true.dat b/tests/regression_tests/mgxs_library_no_nuclides/inputs_true.dat index af09268cd..5cad36b7e 100644 --- a/tests/regression_tests/mgxs_library_no_nuclides/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_no_nuclides/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_no_nuclides/results_true.dat b/tests/regression_tests/mgxs_library_no_nuclides/results_true.dat index aec8e8bbc..c0dba7c0f 100644 --- a/tests/regression_tests/mgxs_library_no_nuclides/results_true.dat +++ b/tests/regression_tests/mgxs_library_no_nuclides/results_true.dat @@ -1,227 +1,227 @@ total material group in nuclide mean std. dev. -1 1 1 total 0.422772 0.014069 -0 1 2 total 0.661309 0.049458 +1 1 1 total 0.413814 0.018434 +0 1 2 total 0.663001 0.012535 transport material group in nuclide mean std. dev. -1 1 1 total 0.383831 0.015331 -0 1 2 total 0.679181 0.050786 +1 1 1 total 0.369730 0.019494 +0 1 2 total 0.643777 0.018246 nu-transport material group in nuclide mean std. dev. -1 1 1 total 0.383831 0.015331 -0 1 2 total 0.679181 0.050786 +1 1 1 total 0.369730 0.019494 +0 1 2 total 0.643777 0.018246 absorption material group in nuclide mean std. dev. -1 1 1 total 0.027181 0.001539 -0 1 2 total 0.265559 0.020699 +1 1 1 total 0.026013 0.001851 +0 1 2 total 0.267233 0.007475 reduced absorption material group in nuclide mean std. dev. -1 1 1 total 0.027162 0.001538 -0 1 2 total 0.265559 0.020699 +1 1 1 total 0.025932 0.001850 +0 1 2 total 0.267233 0.007475 capture material group in nuclide mean std. dev. -1 1 1 total 0.019717 0.001492 -0 1 2 total 0.072029 0.019378 +1 1 1 total 0.018869 0.001758 +0 1 2 total 0.072358 0.008204 fission material group in nuclide mean std. dev. -1 1 1 total 0.007464 0.000222 -0 1 2 total 0.193530 0.015119 +1 1 1 total 0.007144 0.000317 +0 1 2 total 0.194875 0.005528 nu-fission material group in nuclide mean std. dev. -1 1 1 total 0.018925 0.000543 -0 1 2 total 0.471574 0.036840 +1 1 1 total 0.018243 0.000827 +0 1 2 total 0.474851 0.013471 kappa-fission material group in nuclide mean std. dev. -1 1 1 total 1.453014e+06 4.287190e+04 -0 1 2 total 3.742974e+07 2.924022e+06 +1 1 1 total 1.391782e+06 6.192598e+04 +0 1 2 total 3.768981e+07 1.069211e+06 scatter material group in nuclide mean std. dev. -1 1 1 total 0.395591 0.013417 -0 1 2 total 0.395750 0.029309 +1 1 1 total 0.387802 0.017462 +0 1 2 total 0.395768 0.007541 nu-scatter material group in nuclide mean std. dev. -1 1 1 total 0.392941 0.019689 -0 1 2 total 0.396262 0.027471 +1 1 1 total 0.387032 0.024325 +0 1 2 total 0.407651 0.016266 scatter matrix material group in group out legendre nuclide mean std. dev. -12 1 1 1 P0 total 0.392419 0.019837 -13 1 1 1 P1 total 0.038941 0.006089 -14 1 1 1 P2 total 0.019512 0.003548 -15 1 1 1 P3 total 0.012951 0.002399 -8 1 1 2 P0 total 0.000522 0.000349 -9 1 1 2 P1 total -0.000301 0.000185 -10 1 1 2 P2 total 0.000045 0.000147 -11 1 1 2 P3 total 0.000069 0.000162 +12 1 1 1 P0 total 0.386336 0.024297 +13 1 1 1 P1 total 0.044084 0.006343 +14 1 1 1 P2 total 0.027336 0.006403 +15 1 1 1 P3 total 0.011672 0.004897 +8 1 1 2 P0 total 0.000695 0.000327 +9 1 1 2 P1 total -0.000359 0.000201 +10 1 1 2 P2 total -0.000047 0.000081 +11 1 1 2 P3 total 0.000239 0.000099 4 1 2 1 P0 total 0.000000 0.000000 5 1 2 1 P1 total 0.000000 0.000000 6 1 2 1 P2 total 0.000000 0.000000 7 1 2 1 P3 total 0.000000 0.000000 -0 1 2 2 P0 total 0.396262 0.027471 -1 1 2 2 P1 total -0.016133 0.010911 -2 1 2 2 P2 total -0.001147 0.010536 -3 1 2 2 P3 total 0.005359 0.008143 +0 1 2 2 P0 total 0.407651 0.016266 +1 1 2 2 P1 total 0.021192 0.013171 +2 1 2 2 P2 total 0.010327 0.017230 +3 1 2 2 P3 total 0.005148 0.013732 nu-scatter matrix material group in group out legendre nuclide mean std. dev. -12 1 1 1 P0 total 0.392419 0.019837 -13 1 1 1 P1 total 0.038941 0.006089 -14 1 1 1 P2 total 0.019512 0.003548 -15 1 1 1 P3 total 0.012951 0.002399 -8 1 1 2 P0 total 0.000522 0.000349 -9 1 1 2 P1 total -0.000301 0.000185 -10 1 1 2 P2 total 0.000045 0.000147 -11 1 1 2 P3 total 0.000069 0.000162 +12 1 1 1 P0 total 0.386336 0.024297 +13 1 1 1 P1 total 0.044084 0.006343 +14 1 1 1 P2 total 0.027336 0.006403 +15 1 1 1 P3 total 0.011672 0.004897 +8 1 1 2 P0 total 0.000695 0.000327 +9 1 1 2 P1 total -0.000359 0.000201 +10 1 1 2 P2 total -0.000047 0.000081 +11 1 1 2 P3 total 0.000239 0.000099 4 1 2 1 P0 total 0.000000 0.000000 5 1 2 1 P1 total 0.000000 0.000000 6 1 2 1 P2 total 0.000000 0.000000 7 1 2 1 P3 total 0.000000 0.000000 -0 1 2 2 P0 total 0.396262 0.027471 -1 1 2 2 P1 total -0.016133 0.010911 -2 1 2 2 P2 total -0.001147 0.010536 -3 1 2 2 P3 total 0.005359 0.008143 +0 1 2 2 P0 total 0.407651 0.016266 +1 1 2 2 P1 total 0.021192 0.013171 +2 1 2 2 P2 total 0.010327 0.017230 +3 1 2 2 P3 total 0.005148 0.013732 multiplicity matrix material group in group out nuclide mean std. dev. -3 1 1 1 total 1.0 0.054620 -2 1 1 2 total 1.0 0.942809 +3 1 1 1 total 1.0 0.064268 +2 1 1 2 total 1.0 0.661438 1 1 2 1 total 0.0 0.000000 -0 1 2 2 total 1.0 0.080341 +0 1 2 2 total 1.0 0.050545 nu-fission matrix material group in group out nuclide mean std. dev. -3 1 1 1 total 0.019257 0.001831 +3 1 1 1 total 0.024633 0.002205 2 1 1 2 total 0.000000 0.000000 -1 1 2 1 total 0.459401 0.022054 +1 1 2 1 total 0.435159 0.014743 0 1 2 2 total 0.000000 0.000000 scatter probability matrix material group in group out nuclide mean std. dev. -3 1 1 1 total 0.998671 0.054518 -2 1 1 2 total 0.001329 0.000888 +3 1 1 1 total 0.998203 0.064101 +2 1 1 2 total 0.001797 0.000844 1 1 2 1 total 0.000000 0.000000 -0 1 2 2 total 1.000000 0.080341 +0 1 2 2 total 1.000000 0.050545 consistent scatter matrix material group in group out legendre nuclide mean std. dev. -12 1 1 1 P0 total 0.395065 0.025390 -13 1 1 1 P1 total 0.039204 0.006325 -14 1 1 1 P2 total 0.019644 0.003656 -15 1 1 1 P3 total 0.013039 0.002470 -8 1 1 2 P0 total 0.000526 0.000352 -9 1 1 2 P1 total -0.000303 0.000186 -10 1 1 2 P2 total 0.000045 0.000148 -11 1 1 2 P3 total 0.000069 0.000163 +12 1 1 1 P0 total 0.387105 0.030361 +13 1 1 1 P1 total 0.044172 0.006684 +14 1 1 1 P2 total 0.027391 0.006543 +15 1 1 1 P3 total 0.011695 0.004937 +8 1 1 2 P0 total 0.000697 0.000329 +9 1 1 2 P1 total -0.000360 0.000202 +10 1 1 2 P2 total -0.000047 0.000082 +11 1 1 2 P3 total 0.000239 0.000100 4 1 2 1 P0 total 0.000000 0.000000 5 1 2 1 P1 total 0.000000 0.000000 6 1 2 1 P2 total 0.000000 0.000000 7 1 2 1 P3 total 0.000000 0.000000 -0 1 2 2 P0 total 0.395750 0.043243 -1 1 2 2 P1 total -0.016112 0.010982 -2 1 2 2 P2 total -0.001146 0.010523 -3 1 2 2 P3 total 0.005353 0.008145 +0 1 2 2 P0 total 0.395768 0.021378 +1 1 2 2 P1 total 0.020575 0.012809 +2 1 2 2 P2 total 0.010026 0.016732 +3 1 2 2 P3 total 0.004998 0.013333 consistent nu-scatter matrix material group in group out legendre nuclide mean std. dev. -12 1 1 1 P0 total 0.395065 0.033321 -13 1 1 1 P1 total 0.039204 0.006677 -14 1 1 1 P2 total 0.019644 0.003810 -15 1 1 1 P3 total 0.013039 0.002571 -8 1 1 2 P0 total 0.000526 0.000608 -9 1 1 2 P1 total -0.000303 0.000341 -10 1 1 2 P2 total 0.000045 0.000154 -11 1 1 2 P3 total 0.000069 0.000175 +12 1 1 1 P0 total 0.387105 0.039252 +13 1 1 1 P1 total 0.044172 0.007262 +14 1 1 1 P2 total 0.027391 0.006776 +15 1 1 1 P3 total 0.011695 0.004994 +8 1 1 2 P0 total 0.000697 0.000566 +9 1 1 2 P1 total -0.000360 0.000313 +10 1 1 2 P2 total -0.000047 0.000087 +11 1 1 2 P3 total 0.000239 0.000187 4 1 2 1 P0 total 0.000000 0.000000 5 1 2 1 P1 total 0.000000 0.000000 6 1 2 1 P2 total 0.000000 0.000000 7 1 2 1 P3 total 0.000000 0.000000 -0 1 2 2 P0 total 0.395750 0.053673 -1 1 2 2 P1 total -0.016112 0.011058 -2 1 2 2 P2 total -0.001146 0.010523 -3 1 2 2 P3 total 0.005353 0.008157 +0 1 2 2 P0 total 0.395768 0.029278 +1 1 2 2 P1 total 0.020575 0.012851 +2 1 2 2 P2 total 0.010026 0.016739 +3 1 2 2 P3 total 0.004998 0.013335 chi material group out nuclide mean std. dev. -1 1 1 total 1.0 0.015644 +1 1 1 total 1.0 0.039887 0 1 2 total 0.0 0.000000 chi-prompt material group out nuclide mean std. dev. -1 1 1 total 1.0 0.017529 +1 1 1 total 1.0 0.039887 0 1 2 total 0.0 0.000000 inverse-velocity material group in nuclide mean std. dev. -1 1 1 total 6.047675e-08 4.367288e-09 -0 1 2 total 2.861927e-06 2.241423e-07 +1 1 1 total 5.956290e-08 2.255751e-09 +0 1 2 total 2.886630e-06 7.418452e-08 prompt-nu-fission material group in nuclide mean std. dev. -1 1 1 total 0.018748 0.00054 -0 1 2 total 0.468507 0.03660 +1 1 1 total 0.018067 0.000817 +0 1 2 total 0.471762 0.013383 prompt-nu-fission matrix material group in group out nuclide mean std. dev. -3 1 1 1 total 0.019049 0.001675 +3 1 1 1 total 0.024633 0.002205 2 1 1 2 total 0.000000 0.000000 -1 1 2 1 total 0.454399 0.022578 +1 1 2 1 total 0.435159 0.014743 0 1 2 2 total 0.000000 0.000000 diffusion-coefficient material group in nuclide mean std. dev. -1 1 1 total 0.868438 0.034686 -0 1 2 total 0.490787 0.036698 +1 1 1 total 0.901559 0.047536 +0 1 2 total 0.517778 0.014675 nu-diffusion-coefficient material group in nuclide mean std. dev. -1 1 1 total 0.868438 0.034686 -0 1 2 total 0.490787 0.036698 +1 1 1 total 0.901559 0.047536 +0 1 2 total 0.517778 0.014675 (n,elastic) material group in nuclide mean std. dev. -1 1 1 total 0.368341 0.013033 -0 1 2 total 0.395750 0.029309 +1 1 1 total 0.360179 0.016169 +0 1 2 total 0.395768 0.007541 (n,level) material group in nuclide mean std. dev. -1 1 1 total 0.000518 0.000016 +1 1 1 total 0.000568 0.000028 0 1 2 total 0.000000 0.000000 (n,2n) material group in nuclide mean std. dev. -1 1 1 total 0.000019 0.000012 +1 1 1 total 0.000079 0.000042 0 1 2 total 0.000000 0.000000 (n,na) - material group in nuclide mean std. dev. -1 1 1 total 0.0 0.0 -0 1 2 total 0.0 0.0 + material group in nuclide mean std. dev. +1 1 1 total 8.510945e-07 8.515320e-07 +0 1 2 total 0.000000e+00 0.000000e+00 (n,nc) material group in nuclide mean std. dev. -1 1 1 total 0.007599 0.000559 +1 1 1 total 0.008258 0.000928 0 1 2 total 0.000000 0.000000 (n,gamma) material group in nuclide mean std. dev. -1 1 1 total 0.019608 0.001470 -0 1 2 total 0.072029 0.005584 +1 1 1 total 0.018749 0.001838 +0 1 2 total 0.072358 0.001951 (n,a) material group in nuclide mean std. dev. -1 1 1 total 0.000109 0.00002 -0 1 2 total 0.000000 0.00000 +1 1 1 total 0.000119 0.000023 +0 1 2 total 0.000000 0.000000 (n,Xa) - material group in nuclide mean std. dev. -1 1 1 total 0.000109 0.00002 -0 1 2 total 0.000000 0.00000 + material group in nuclide mean std. dev. +1 1 1 total 0.00012 0.000022 +0 1 2 total 0.00000 0.000000 heating - material group in nuclide mean std. dev. -1 1 1 total 1.270644e+06 3.732629e+04 -0 1 2 total 3.241569e+07 2.530346e+06 + material group in nuclide mean std. dev. +1 1 1 total 1.216089e+06 54827.397330 +0 1 2 total 3.262993e+07 904277.817101 damage-energy material group in nuclide mean std. dev. -1 1 1 total 2405.735342 79.042000 -0 1 2 total 1362.470597 106.435803 +1 1 1 total 2317.176742 165.734097 +0 1 2 total 1371.933922 38.919660 (n,n1) material group in nuclide mean std. dev. -1 1 1 total 0.011931 0.000455 +1 1 1 total 0.012055 0.000759 0 1 2 total 0.000000 0.000000 (n,a0) material group in nuclide mean std. dev. -1 1 1 total 0.000108 0.00002 -0 1 2 total 0.000000 0.00000 +1 1 1 total 0.000109 0.000028 +0 1 2 total 0.000000 0.000000 (n,nc) matrix material group in group out nuclide mean std. dev. -3 1 1 1 total 0.005745 0.001068 +3 1 1 1 total 0.009563 0.001002 2 1 1 2 total 0.000000 0.000000 1 1 2 1 total 0.000000 0.000000 0 1 2 2 total 0.000000 0.000000 (n,n1) matrix material group in group out nuclide mean std. dev. -3 1 1 1 total 0.013232 0.001025 -2 1 1 2 total 0.000000 0.000000 -1 1 2 1 total 0.000000 0.000000 -0 1 2 2 total 0.000000 0.000000 +3 1 1 1 total 0.013909 0.00145 +2 1 1 2 total 0.000000 0.00000 +1 1 2 1 total 0.000000 0.00000 +0 1 2 2 total 0.000000 0.00000 (n,2n) matrix material group in group out nuclide mean std. dev. 3 1 1 1 total 0.0 0.0 @@ -230,104 +230,104 @@ damage-energy 0 1 2 2 total 0.0 0.0 delayed-nu-fission material delayedgroup group in nuclide mean std. dev. -1 1 1 1 total 0.000004 1.226367e-07 -3 1 2 1 total 0.000026 6.725093e-07 -5 1 3 1 total 0.000027 7.028316e-07 -7 1 4 1 total 0.000068 1.919534e-06 -9 1 5 1 total 0.000037 1.268939e-06 -11 1 6 1 total 0.000015 5.136452e-07 -0 1 1 2 total 0.000107 8.388866e-06 -2 1 2 2 total 0.000554 4.330076e-05 -4 1 3 2 total 0.000529 4.133869e-05 -6 1 4 2 total 0.001186 9.268481e-05 -8 1 5 2 total 0.000486 3.799954e-05 -10 1 6 2 total 0.000204 1.591787e-05 +1 1 1 1 total 0.000004 1.857100e-07 +3 1 2 1 total 0.000025 1.293123e-06 +5 1 3 1 total 0.000026 1.448812e-06 +7 1 4 1 total 0.000068 4.132525e-06 +9 1 5 1 total 0.000037 2.670208e-06 +11 1 6 1 total 0.000015 1.084541e-06 +0 1 1 2 total 0.000108 3.067510e-06 +2 1 2 2 total 0.000558 1.583355e-05 +4 1 3 2 total 0.000533 1.511609e-05 +6 1 4 2 total 0.001195 3.389154e-05 +8 1 5 2 total 0.000490 1.389508e-05 +10 1 6 2 total 0.000205 5.820598e-06 chi-delayed material delayedgroup group out nuclide mean std. dev. -1 1 1 1 total 0.0 0.000000 -3 1 2 1 total 0.0 0.000000 -5 1 3 1 total 0.0 0.000000 -7 1 4 1 total 1.0 0.433956 -9 1 5 1 total 0.0 0.000000 -11 1 6 1 total 0.0 0.000000 -0 1 1 2 total 0.0 0.000000 -2 1 2 2 total 0.0 0.000000 -4 1 3 2 total 0.0 0.000000 -6 1 4 2 total 0.0 0.000000 -8 1 5 2 total 0.0 0.000000 -10 1 6 2 total 0.0 0.000000 +1 1 1 1 total 0.0 0.0 +3 1 2 1 total 0.0 0.0 +5 1 3 1 total 0.0 0.0 +7 1 4 1 total 0.0 0.0 +9 1 5 1 total 0.0 0.0 +11 1 6 1 total 0.0 0.0 +0 1 1 2 total 0.0 0.0 +2 1 2 2 total 0.0 0.0 +4 1 3 2 total 0.0 0.0 +6 1 4 2 total 0.0 0.0 +8 1 5 2 total 0.0 0.0 +10 1 6 2 total 0.0 0.0 beta material delayedgroup group in nuclide mean std. dev. -1 1 1 1 total 0.000225 0.000006 -3 1 2 1 total 0.001359 0.000033 -5 1 3 1 total 0.001412 0.000034 -7 1 4 1 total 0.003611 0.000094 -9 1 5 1 total 0.001950 0.000064 -11 1 6 1 total 0.000801 0.000026 -0 1 1 2 total 0.000228 0.000019 -2 1 2 2 total 0.001175 0.000096 -4 1 3 2 total 0.001122 0.000092 -6 1 4 2 total 0.002516 0.000206 -8 1 5 2 total 0.001031 0.000085 -10 1 6 2 total 0.000432 0.000035 +1 1 1 1 total 0.000223 0.000009 +3 1 2 1 total 0.001375 0.000067 +5 1 3 1 total 0.001439 0.000076 +7 1 4 1 total 0.003724 0.000217 +9 1 5 1 total 0.002049 0.000142 +11 1 6 1 total 0.000840 0.000058 +0 1 1 2 total 0.000228 0.000008 +2 1 2 2 total 0.001175 0.000041 +4 1 3 2 total 0.001122 0.000040 +6 1 4 2 total 0.002516 0.000089 +8 1 5 2 total 0.001031 0.000036 +10 1 6 2 total 0.000432 0.000015 decay-rate material delayedgroup nuclide mean std. dev. -0 1 1 total 0.013352 0.000905 -1 1 2 total 0.032619 0.002094 -2 1 3 total 0.121041 0.007464 -3 1 4 total 0.305491 0.017639 -4 1 5 total 0.860388 0.042833 -5 1 6 total 2.889807 0.145503 +0 1 1 total 0.013353 0.000379 +1 1 2 total 0.032612 0.001002 +2 1 3 total 0.121056 0.003938 +3 1 4 total 0.305642 0.010892 +4 1 5 total 0.860947 0.036893 +5 1 6 total 2.891708 0.122310 delayed-nu-fission matrix - material delayedgroup group in group out nuclide mean std. dev. -3 1 1 1 1 total 0.000000 0.000000 -7 1 2 1 1 total 0.000000 0.000000 -11 1 3 1 1 total 0.000000 0.000000 -15 1 4 1 1 total 0.000207 0.000207 -19 1 5 1 1 total 0.000000 0.000000 -23 1 6 1 1 total 0.000000 0.000000 -2 1 1 1 2 total 0.000000 0.000000 -6 1 2 1 2 total 0.000000 0.000000 -10 1 3 1 2 total 0.000000 0.000000 -14 1 4 1 2 total 0.000000 0.000000 -18 1 5 1 2 total 0.000000 0.000000 -22 1 6 1 2 total 0.000000 0.000000 -1 1 1 2 1 total 0.000000 0.000000 -5 1 2 2 1 total 0.000000 0.000000 -9 1 3 2 1 total 0.000000 0.000000 -13 1 4 2 1 total 0.005002 0.001278 -17 1 5 2 1 total 0.000000 0.000000 -21 1 6 2 1 total 0.000000 0.000000 -0 1 1 2 2 total 0.000000 0.000000 -4 1 2 2 2 total 0.000000 0.000000 -8 1 3 2 2 total 0.000000 0.000000 -12 1 4 2 2 total 0.000000 0.000000 -16 1 5 2 2 total 0.000000 0.000000 -20 1 6 2 2 total 0.000000 0.000000 + material delayedgroup group in group out nuclide mean std. dev. +3 1 1 1 1 total 0.0 0.0 +7 1 2 1 1 total 0.0 0.0 +11 1 3 1 1 total 0.0 0.0 +15 1 4 1 1 total 0.0 0.0 +19 1 5 1 1 total 0.0 0.0 +23 1 6 1 1 total 0.0 0.0 +2 1 1 1 2 total 0.0 0.0 +6 1 2 1 2 total 0.0 0.0 +10 1 3 1 2 total 0.0 0.0 +14 1 4 1 2 total 0.0 0.0 +18 1 5 1 2 total 0.0 0.0 +22 1 6 1 2 total 0.0 0.0 +1 1 1 2 1 total 0.0 0.0 +5 1 2 2 1 total 0.0 0.0 +9 1 3 2 1 total 0.0 0.0 +13 1 4 2 1 total 0.0 0.0 +17 1 5 2 1 total 0.0 0.0 +21 1 6 2 1 total 0.0 0.0 +0 1 1 2 2 total 0.0 0.0 +4 1 2 2 2 total 0.0 0.0 +8 1 3 2 2 total 0.0 0.0 +12 1 4 2 2 total 0.0 0.0 +16 1 5 2 2 total 0.0 0.0 +20 1 6 2 2 total 0.0 0.0 total material group in nuclide mean std. dev. -1 2 1 total 0.320478 0.012201 -0 2 2 total 0.300681 0.029685 +1 2 1 total 0.313574 0.016009 +0 2 2 total 0.300858 0.005911 transport material group in nuclide mean std. dev. -1 2 1 total 0.267653 0.015887 -0 2 2 total 0.327250 0.035614 +1 2 1 total 0.266154 0.017348 +0 2 2 total 0.300597 0.011062 nu-transport material group in nuclide mean std. dev. -1 2 1 total 0.267653 0.015887 -0 2 2 total 0.327250 0.035614 +1 2 1 total 0.266154 0.017348 +0 2 2 total 0.300597 0.011062 absorption - material group in nuclide mean std. dev. -1 2 1 total 0.001040 0.000121 -0 2 2 total 0.005284 0.000548 + material group in nuclide mean std. dev. +1 2 1 total 0.00150 0.000118 +0 2 2 total 0.00542 0.000201 reduced absorption material group in nuclide mean std. dev. -1 2 1 total 0.001040 0.000121 -0 2 2 total 0.005284 0.000548 +1 2 1 total 0.001481 0.000119 +0 2 2 total 0.005420 0.000201 capture - material group in nuclide mean std. dev. -1 2 1 total 0.001040 0.000121 -0 2 2 total 0.005284 0.000548 + material group in nuclide mean std. dev. +1 2 1 total 0.00150 0.000118 +0 2 2 total 0.00542 0.000201 fission material group in nuclide mean std. dev. 1 2 1 total 0.0 0.0 @@ -342,18 +342,18 @@ kappa-fission 0 2 2 total 0.0 0.0 scatter material group in nuclide mean std. dev. -1 2 1 total 0.319438 0.012181 -0 2 2 total 0.295397 0.029142 +1 2 1 total 0.312074 0.015934 +0 2 2 total 0.295438 0.005743 nu-scatter material group in nuclide mean std. dev. -1 2 1 total 0.314727 0.014272 -0 2 2 total 0.295807 0.038170 +1 2 1 total 0.318594 0.023203 +0 2 2 total 0.295662 0.031486 scatter matrix material group in group out legendre nuclide mean std. dev. -12 2 1 1 P0 total 0.314727 0.014272 -13 2 1 1 P1 total 0.052826 0.010175 -14 2 1 1 P2 total 0.033176 0.002264 -15 2 1 1 P3 total 0.006129 0.004317 +12 2 1 1 P0 total 0.318594 0.023203 +13 2 1 1 P1 total 0.047420 0.006684 +14 2 1 1 P2 total 0.029426 0.008048 +15 2 1 1 P3 total 0.007335 0.004092 8 2 1 2 P0 total 0.000000 0.000000 9 2 1 2 P1 total 0.000000 0.000000 10 2 1 2 P2 total 0.000000 0.000000 @@ -362,16 +362,16 @@ scatter matrix 5 2 2 1 P1 total 0.000000 0.000000 6 2 2 1 P2 total 0.000000 0.000000 7 2 2 1 P3 total 0.000000 0.000000 -0 2 2 2 P0 total 0.295807 0.038170 -1 2 2 2 P1 total -0.026569 0.019676 -2 2 2 2 P2 total -0.005395 0.007578 -3 2 2 2 P3 total -0.005680 0.012737 +0 2 2 2 P0 total 0.295662 0.031486 +1 2 2 2 P1 total 0.000261 0.009350 +2 2 2 2 P2 total -0.004912 0.007866 +3 2 2 2 P3 total -0.018278 0.012339 nu-scatter matrix material group in group out legendre nuclide mean std. dev. -12 2 1 1 P0 total 0.314727 0.014272 -13 2 1 1 P1 total 0.052826 0.010175 -14 2 1 1 P2 total 0.033176 0.002264 -15 2 1 1 P3 total 0.006129 0.004317 +12 2 1 1 P0 total 0.318594 0.023203 +13 2 1 1 P1 total 0.047420 0.006684 +14 2 1 1 P2 total 0.029426 0.008048 +15 2 1 1 P3 total 0.007335 0.004092 8 2 1 2 P0 total 0.000000 0.000000 9 2 1 2 P1 total 0.000000 0.000000 10 2 1 2 P2 total 0.000000 0.000000 @@ -380,16 +380,16 @@ nu-scatter matrix 5 2 2 1 P1 total 0.000000 0.000000 6 2 2 1 P2 total 0.000000 0.000000 7 2 2 1 P3 total 0.000000 0.000000 -0 2 2 2 P0 total 0.295807 0.038170 -1 2 2 2 P1 total -0.026569 0.019676 -2 2 2 2 P2 total -0.005395 0.007578 -3 2 2 2 P3 total -0.005680 0.012737 +0 2 2 2 P0 total 0.295662 0.031486 +1 2 2 2 P1 total 0.000261 0.009350 +2 2 2 2 P2 total -0.004912 0.007866 +3 2 2 2 P3 total -0.018278 0.012339 multiplicity matrix material group in group out nuclide mean std. dev. -3 2 1 1 total 1.0 0.043852 +3 2 1 1 total 1.0 0.071770 2 2 1 2 total 0.0 0.000000 1 2 2 1 total 0.0 0.000000 -0 2 2 2 total 1.0 0.139361 +0 2 2 2 total 1.0 0.103652 nu-fission matrix material group in group out nuclide mean std. dev. 3 2 1 1 total 0.0 0.0 @@ -398,16 +398,16 @@ nu-fission matrix 0 2 2 2 total 0.0 0.0 scatter probability matrix material group in group out nuclide mean std. dev. -3 2 1 1 total 1.0 0.043852 +3 2 1 1 total 1.0 0.071770 2 2 1 2 total 0.0 0.000000 1 2 2 1 total 0.0 0.000000 -0 2 2 2 total 1.0 0.139361 +0 2 2 2 total 1.0 0.103652 consistent scatter matrix material group in group out legendre nuclide mean std. dev. -12 2 1 1 P0 total 0.319438 0.018563 -13 2 1 1 P1 total 0.053616 0.010510 -14 2 1 1 P2 total 0.033673 0.002604 -15 2 1 1 P3 total 0.006221 0.004387 +12 2 1 1 P0 total 0.312074 0.027487 +13 2 1 1 P1 total 0.046450 0.006939 +14 2 1 1 P2 total 0.028824 0.008012 +15 2 1 1 P3 total 0.007185 0.004024 8 2 1 2 P0 total 0.000000 0.000000 9 2 1 2 P1 total 0.000000 0.000000 10 2 1 2 P2 total 0.000000 0.000000 @@ -416,16 +416,16 @@ consistent scatter matrix 5 2 2 1 P1 total 0.000000 0.000000 6 2 2 1 P2 total 0.000000 0.000000 7 2 2 1 P3 total 0.000000 0.000000 -0 2 2 2 P0 total 0.295397 0.050438 -1 2 2 2 P1 total -0.026532 0.019872 -2 2 2 2 P2 total -0.005388 0.007591 -3 2 2 2 P3 total -0.005672 0.012735 +0 2 2 2 P0 total 0.295438 0.031157 +1 2 2 2 P1 total 0.000261 0.009343 +2 2 2 2 P2 total -0.004909 0.007859 +3 2 2 2 P3 total -0.018264 0.012327 consistent nu-scatter matrix material group in group out legendre nuclide mean std. dev. -12 2 1 1 P0 total 0.319438 0.023255 -13 2 1 1 P1 total 0.053616 0.010769 -14 2 1 1 P2 total 0.033673 0.002993 -15 2 1 1 P3 total 0.006221 0.004396 +12 2 1 1 P0 total 0.312074 0.035456 +13 2 1 1 P1 total 0.046450 0.007699 +14 2 1 1 P2 total 0.028824 0.008274 +15 2 1 1 P3 total 0.007185 0.004057 8 2 1 2 P0 total 0.000000 0.000000 9 2 1 2 P1 total 0.000000 0.000000 10 2 1 2 P2 total 0.000000 0.000000 @@ -434,10 +434,10 @@ consistent nu-scatter matrix 5 2 2 1 P1 total 0.000000 0.000000 6 2 2 1 P2 total 0.000000 0.000000 7 2 2 1 P3 total 0.000000 0.000000 -0 2 2 2 P0 total 0.295397 0.065105 -1 2 2 2 P1 total -0.026532 0.020213 -2 2 2 2 P2 total -0.005388 0.007628 -3 2 2 2 P3 total -0.005672 0.012759 +0 2 2 2 P0 total 0.295438 0.043686 +1 2 2 2 P1 total 0.000261 0.009343 +2 2 2 2 P2 total -0.004909 0.007876 +3 2 2 2 P3 total -0.018264 0.012471 chi material group out nuclide mean std. dev. 1 2 1 total 0.0 0.0 @@ -448,8 +448,8 @@ chi-prompt 0 2 2 total 0.0 0.0 inverse-velocity material group in nuclide mean std. dev. -1 2 1 total 6.068670e-08 4.861582e-09 -0 2 2 total 2.921021e-06 3.028269e-07 +1 2 1 total 6.076563e-08 2.727519e-09 +0 2 2 total 2.996176e-06 1.110139e-07 prompt-nu-fission material group in nuclide mean std. dev. 1 2 1 total 0.0 0.0 @@ -462,72 +462,72 @@ prompt-nu-fission matrix 0 2 2 2 total 0.0 0.0 diffusion-coefficient material group in nuclide mean std. dev. -1 2 1 total 1.245396 0.073923 -0 2 2 total 1.018589 0.110853 +1 2 1 total 1.252406 0.081631 +0 2 2 total 1.108904 0.040809 nu-diffusion-coefficient material group in nuclide mean std. dev. -1 2 1 total 1.245396 0.073923 -0 2 2 total 1.018589 0.110853 +1 2 1 total 1.252406 0.081631 +0 2 2 total 1.108904 0.040809 (n,elastic) material group in nuclide mean std. dev. -1 2 1 total 0.310592 0.012188 -0 2 2 total 0.295397 0.029142 +1 2 1 total 0.302664 0.015531 +0 2 2 total 0.295438 0.005743 (n,level) material group in nuclide mean std. dev. 1 2 1 total 0.0 0.0 0 2 2 total 0.0 0.0 (n,2n) - material group in nuclide mean std. dev. -1 2 1 total 0.0 0.0 -0 2 2 total 0.0 0.0 + material group in nuclide mean std. dev. +1 2 1 total 0.000019 0.000017 +0 2 2 total 0.000000 0.000000 (n,na) material group in nuclide mean std. dev. -1 2 1 total 2.157338e-13 1.864239e-13 +1 2 1 total 4.892570e-09 4.436228e-09 0 2 2 total 0.000000e+00 0.000000e+00 (n,nc) - material group in nuclide mean std. dev. -1 2 1 total 0.00187 0.000152 -0 2 2 total 0.00000 0.000000 + material group in nuclide mean std. dev. +1 2 1 total 0.001998 0.000408 +0 2 2 total 0.000000 0.000000 (n,gamma) material group in nuclide mean std. dev. -1 2 1 total 0.001038 0.000121 -0 2 2 total 0.005283 0.000548 +1 2 1 total 0.001497 0.000118 +0 2 2 total 0.005419 0.000201 (n,a) material group in nuclide mean std. dev. -1 2 1 total 7.402079e-07 3.197538e-08 -0 2 2 total 2.735682e-07 2.698845e-08 +1 2 1 total 9.546292e-07 9.180854e-08 +0 2 2 total 2.736059e-07 5.318732e-09 (n,Xa) material group in nuclide mean std. dev. -1 2 1 total 7.402081e-07 3.197534e-08 -0 2 2 total 2.735682e-07 2.698845e-08 +1 2 1 total 9.595218e-07 9.558005e-08 +0 2 2 total 2.736059e-07 5.318732e-09 heating material group in nuclide mean std. dev. -1 2 1 total 2479.710231 157.161879 -0 2 2 total 2.314706 0.265682 +1 2 1 total 2551.878627 212.765665 +0 2 2 total 2.332139 0.087384 damage-energy - material group in nuclide mean std. dev. -1 2 1 total 1566.139383 61.602407 -0 2 2 total 0.288739 0.029698 + material group in nuclide mean std. dev. +1 2 1 total 1585.677533 130.382718 +0 2 2 total 0.295108 0.010079 (n,n1) material group in nuclide mean std. dev. -1 2 1 total 0.002897 0.000181 +1 2 1 total 0.002835 0.000246 0 2 2 total 0.000000 0.000000 (n,a0) material group in nuclide mean std. dev. -1 2 1 total 6.646569e-07 2.959064e-08 -0 2 2 total 2.732927e-07 2.696126e-08 +1 2 1 total 7.169006e-07 6.251188e-08 +0 2 2 total 2.733303e-07 5.313375e-09 (n,nc) matrix material group in group out nuclide mean std. dev. -3 2 1 1 total 0.000488 0.000488 +3 2 1 1 total 0.001489 0.001491 2 2 1 2 total 0.000000 0.000000 1 2 2 1 total 0.000000 0.000000 0 2 2 2 total 0.000000 0.000000 (n,n1) matrix - material group in group out nuclide mean std. dev. -3 2 1 1 total 0.00244 0.001094 -2 2 1 2 total 0.00000 0.000000 -1 2 2 1 total 0.00000 0.000000 -0 2 2 2 total 0.00000 0.000000 + material group in group out nuclide mean std. dev. +3 2 1 1 total 0.001985 0.000507 +2 2 1 2 total 0.000000 0.000000 +1 2 2 1 total 0.000000 0.000000 +0 2 2 2 total 0.000000 0.000000 (n,2n) matrix material group in group out nuclide mean std. dev. 3 2 1 1 total 0.0 0.0 @@ -612,28 +612,28 @@ delayed-nu-fission matrix 20 2 6 2 2 total 0.0 0.0 total material group in nuclide mean std. dev. -1 3 1 total 0.692034 0.019973 -0 3 2 total 2.033425 0.189463 +1 3 1 total 0.682896 0.024140 +0 3 2 total 2.032938 0.085675 transport material group in nuclide mean std. dev. -1 3 1 total 0.298754 0.021602 -0 3 2 total 1.459465 0.197868 +1 3 1 total 0.298986 0.026905 +0 3 2 total 1.471887 0.096907 nu-transport material group in nuclide mean std. dev. -1 3 1 total 0.298754 0.021602 -0 3 2 total 1.459465 0.197868 +1 3 1 total 0.298986 0.026905 +0 3 2 total 1.471887 0.096907 absorption material group in nuclide mean std. dev. -1 3 1 total 0.000699 0.000035 -0 3 2 total 0.031056 0.003017 +1 3 1 total 0.000693 0.000020 +0 3 2 total 0.031171 0.001403 reduced absorption material group in nuclide mean std. dev. -1 3 1 total 0.000699 0.000035 -0 3 2 total 0.031056 0.003017 +1 3 1 total 0.000693 0.000020 +0 3 2 total 0.031171 0.001403 capture material group in nuclide mean std. dev. -1 3 1 total 0.000699 0.000035 -0 3 2 total 0.031056 0.003017 +1 3 1 total 0.000693 0.000020 +0 3 2 total 0.031171 0.001403 fission material group in nuclide mean std. dev. 1 3 1 total 0.0 0.0 @@ -648,54 +648,54 @@ kappa-fission 0 3 2 total 0.0 0.0 scatter material group in nuclide mean std. dev. -1 3 1 total 0.691336 0.019945 -0 3 2 total 2.002368 0.186454 +1 3 1 total 0.682202 0.024123 +0 3 2 total 2.001768 0.084281 nu-scatter material group in nuclide mean std. dev. -1 3 1 total 0.684356 0.011639 -0 3 2 total 1.990840 0.178205 +1 3 1 total 0.672567 0.017434 +0 3 2 total 2.004576 0.129211 scatter matrix material group in group out legendre nuclide mean std. dev. -12 3 1 1 P0 total 0.652706 0.011111 -13 3 1 1 P1 total 0.393203 0.008164 -14 3 1 1 P2 total 0.162146 0.003332 -15 3 1 1 P3 total 0.014967 0.004773 -8 3 1 2 P0 total 0.031650 0.000613 -9 3 1 2 P1 total 0.009845 0.000647 -10 3 1 2 P2 total -0.003284 0.000758 -11 3 1 2 P3 total -0.003971 0.000187 -4 3 2 1 P0 total 0.000474 0.000475 -5 3 2 1 P1 total 0.000396 0.000397 -6 3 2 1 P2 total 0.000260 0.000261 -7 3 2 1 P3 total 0.000099 0.000099 -0 3 2 2 P0 total 1.990366 0.178042 -1 3 2 2 P1 total 0.523546 0.053239 -2 3 2 2 P2 total 0.101180 0.015832 -3 3 2 2 P3 total 0.017873 0.005685 +12 3 1 1 P0 total 0.641741 0.016600 +13 3 1 1 P1 total 0.383841 0.011878 +14 3 1 1 P2 total 0.149909 0.005512 +15 3 1 1 P3 total 0.004238 0.002485 +8 3 1 2 P0 total 0.030826 0.000973 +9 3 1 2 P1 total 0.009943 0.000415 +10 3 1 2 P2 total -0.003002 0.000628 +11 3 1 2 P3 total -0.004234 0.000393 +4 3 2 1 P0 total 0.000467 0.000467 +5 3 2 1 P1 total 0.000345 0.000345 +6 3 2 1 P2 total 0.000149 0.000149 +7 3 2 1 P3 total -0.000047 0.000047 +0 3 2 2 P0 total 2.004109 0.129225 +1 3 2 2 P1 total 0.511363 0.043448 +2 3 2 2 P2 total 0.108599 0.014070 +3 3 2 2 P3 total 0.035733 0.021921 nu-scatter matrix material group in group out legendre nuclide mean std. dev. -12 3 1 1 P0 total 0.652706 0.011111 -13 3 1 1 P1 total 0.393203 0.008164 -14 3 1 1 P2 total 0.162146 0.003332 -15 3 1 1 P3 total 0.014967 0.004773 -8 3 1 2 P0 total 0.031650 0.000613 -9 3 1 2 P1 total 0.009845 0.000647 -10 3 1 2 P2 total -0.003284 0.000758 -11 3 1 2 P3 total -0.003971 0.000187 -4 3 2 1 P0 total 0.000474 0.000475 -5 3 2 1 P1 total 0.000396 0.000397 -6 3 2 1 P2 total 0.000260 0.000261 -7 3 2 1 P3 total 0.000099 0.000099 -0 3 2 2 P0 total 1.990366 0.178042 -1 3 2 2 P1 total 0.523546 0.053239 -2 3 2 2 P2 total 0.101180 0.015832 -3 3 2 2 P3 total 0.017873 0.005685 +12 3 1 1 P0 total 0.641741 0.016600 +13 3 1 1 P1 total 0.383841 0.011878 +14 3 1 1 P2 total 0.149909 0.005512 +15 3 1 1 P3 total 0.004238 0.002485 +8 3 1 2 P0 total 0.030826 0.000973 +9 3 1 2 P1 total 0.009943 0.000415 +10 3 1 2 P2 total -0.003002 0.000628 +11 3 1 2 P3 total -0.004234 0.000393 +4 3 2 1 P0 total 0.000467 0.000467 +5 3 2 1 P1 total 0.000345 0.000345 +6 3 2 1 P2 total 0.000149 0.000149 +7 3 2 1 P3 total -0.000047 0.000047 +0 3 2 2 P0 total 2.004109 0.129225 +1 3 2 2 P1 total 0.511363 0.043448 +2 3 2 2 P2 total 0.108599 0.014070 +3 3 2 2 P3 total 0.035733 0.021921 multiplicity matrix material group in group out nuclide mean std. dev. -3 3 1 1 total 1.0 0.020267 -2 3 1 2 total 1.0 0.024112 +3 3 1 1 total 1.0 0.022200 +2 3 1 2 total 1.0 0.033880 1 3 2 1 total 1.0 1.414214 -0 3 2 2 total 1.0 0.093189 +0 3 2 2 total 1.0 0.066922 nu-fission matrix material group in group out nuclide mean std. dev. 3 3 1 1 total 0.0 0.0 @@ -704,46 +704,46 @@ nu-fission matrix 0 3 2 2 total 0.0 0.0 scatter probability matrix material group in group out nuclide mean std. dev. -3 3 1 1 total 0.953753 0.018903 -2 3 1 2 total 0.046247 0.001011 -1 3 2 1 total 0.000238 0.000239 -0 3 2 2 total 0.999762 0.093156 +3 3 1 1 total 0.954167 0.020729 +2 3 1 2 total 0.045833 0.001296 +1 3 2 1 total 0.000233 0.000233 +0 3 2 2 total 0.999767 0.066899 consistent scatter matrix material group in group out legendre nuclide mean std. dev. -12 3 1 1 P0 total 0.659363 0.023079 -13 3 1 1 P1 total 0.397213 0.014683 -14 3 1 1 P2 total 0.163800 0.006035 -15 3 1 1 P3 total 0.015120 0.004843 -8 3 1 2 P0 total 0.031973 0.001157 -9 3 1 2 P1 total 0.009945 0.000721 -10 3 1 2 P2 total -0.003318 0.000772 -11 3 1 2 P3 total -0.004011 0.000225 -4 3 2 1 P0 total 0.000477 0.000480 -5 3 2 1 P1 total 0.000399 0.000401 -6 3 2 1 P2 total 0.000262 0.000264 -7 3 2 1 P3 total 0.000099 0.000100 -0 3 2 2 P0 total 2.001892 0.263710 -1 3 2 2 P1 total 0.526577 0.073894 -2 3 2 2 P2 total 0.101766 0.018719 -3 3 2 2 P3 total 0.017976 0.005976 +12 3 1 1 P0 total 0.650935 0.027014 +13 3 1 1 P1 total 0.389340 0.017459 +14 3 1 1 P2 total 0.152056 0.007457 +15 3 1 1 P3 total 0.004299 0.002525 +8 3 1 2 P0 total 0.031268 0.001416 +9 3 1 2 P1 total 0.010085 0.000533 +10 3 1 2 P2 total -0.003045 0.000645 +11 3 1 2 P3 total -0.004295 0.000423 +4 3 2 1 P0 total 0.000466 0.000467 +5 3 2 1 P1 total 0.000344 0.000345 +6 3 2 1 P2 total 0.000148 0.000149 +7 3 2 1 P3 total -0.000047 0.000047 +0 3 2 2 P0 total 2.001301 0.158219 +1 3 2 2 P1 total 0.510647 0.049275 +2 3 2 2 P2 total 0.108446 0.014900 +3 3 2 2 P3 total 0.035683 0.021951 consistent nu-scatter matrix material group in group out legendre nuclide mean std. dev. -12 3 1 1 P0 total 0.659363 0.026669 -13 3 1 1 P1 total 0.397213 0.016746 -14 3 1 1 P2 total 0.163800 0.006888 -15 3 1 1 P3 total 0.015120 0.004853 -8 3 1 2 P0 total 0.031973 0.001391 -9 3 1 2 P1 total 0.009945 0.000759 -10 3 1 2 P2 total -0.003318 0.000776 -11 3 1 2 P3 total -0.004011 0.000245 -4 3 2 1 P0 total 0.000477 0.000827 -5 3 2 1 P1 total 0.000399 0.000692 -6 3 2 1 P2 total 0.000262 0.000455 -7 3 2 1 P3 total 0.000099 0.000172 -0 3 2 2 P0 total 2.001892 0.323026 -1 3 2 2 P1 total 0.526577 0.088703 -2 3 2 2 P2 total 0.101766 0.020985 -3 3 2 2 P3 total 0.017976 0.006207 +12 3 1 1 P0 total 0.650935 0.030637 +13 3 1 1 P1 total 0.389340 0.019481 +14 3 1 1 P2 total 0.152056 0.008185 +15 3 1 1 P3 total 0.004299 0.002526 +8 3 1 2 P0 total 0.031268 0.001768 +9 3 1 2 P1 total 0.010085 0.000633 +10 3 1 2 P2 total -0.003045 0.000653 +11 3 1 2 P3 total -0.004295 0.000447 +4 3 2 1 P0 total 0.000466 0.000808 +5 3 2 1 P1 total 0.000344 0.000597 +6 3 2 1 P2 total 0.000148 0.000257 +7 3 2 1 P3 total -0.000047 0.000081 +0 3 2 2 P0 total 2.001301 0.207294 +1 3 2 2 P1 total 0.510647 0.059966 +2 3 2 2 P2 total 0.108446 0.016574 +3 3 2 2 P3 total 0.035683 0.022080 chi material group out nuclide mean std. dev. 1 3 1 total 0.0 0.0 @@ -754,8 +754,8 @@ chi-prompt 0 3 2 total 0.0 0.0 inverse-velocity material group in nuclide mean std. dev. -1 3 1 total 6.187551e-08 3.945367e-09 -0 3 2 total 2.984343e-06 2.898715e-07 +1 3 1 total 6.023693e-08 1.678511e-09 +0 3 2 total 2.995346e-06 1.347817e-07 prompt-nu-fission material group in nuclide mean std. dev. 1 3 1 total 0.0 0.0 @@ -768,60 +768,60 @@ prompt-nu-fission matrix 0 3 2 2 total 0.0 0.0 diffusion-coefficient material group in nuclide mean std. dev. -1 3 1 total 1.115746 0.080676 -0 3 2 total 0.228394 0.030965 +1 3 1 total 1.114881 0.100326 +0 3 2 total 0.226467 0.014910 nu-diffusion-coefficient material group in nuclide mean std. dev. -1 3 1 total 1.115746 0.080676 -0 3 2 total 0.228394 0.030965 +1 3 1 total 1.114881 0.100326 +0 3 2 total 0.226467 0.014910 (n,elastic) material group in nuclide mean std. dev. -1 3 1 total 0.691333 0.019945 -0 3 2 total 2.002368 0.186454 +1 3 1 total 0.682168 0.024125 +0 3 2 total 2.001768 0.084281 (n,level) material group in nuclide mean std. dev. -1 3 1 total 0.000003 0.000002 +1 3 1 total 0.000033 0.000019 0 3 2 total 0.000000 0.000000 (n,2n) material group in nuclide mean std. dev. 1 3 1 total 0.0 0.0 0 3 2 total 0.0 0.0 (n,na) - material group in nuclide mean std. dev. -1 3 1 total 0.0 0.0 -0 3 2 total 0.0 0.0 + material group in nuclide mean std. dev. +1 3 1 total 9.967562e-07 9.970492e-07 +0 3 2 total 0.000000e+00 0.000000e+00 (n,nc) - material group in nuclide mean std. dev. -1 3 1 total 0.0 0.0 -0 3 2 total 0.0 0.0 + material group in nuclide mean std. dev. +1 3 1 total 8.867935e-07 8.870902e-07 +0 3 2 total 0.000000e+00 0.000000e+00 (n,gamma) material group in nuclide mean std. dev. -1 3 1 total 0.000225 0.000014 -0 3 2 total 0.010815 0.001050 +1 3 1 total 0.000219 0.000006 +0 3 2 total 0.010855 0.000488 (n,a) material group in nuclide mean std. dev. -1 3 1 total 0.000474 0.000021 -0 3 2 total 0.020241 0.001966 +1 3 1 total 0.000474 0.000015 +0 3 2 total 0.020316 0.000914 (n,Xa) material group in nuclide mean std. dev. -1 3 1 total 0.000474 0.000021 -0 3 2 total 0.020242 0.001966 +1 3 1 total 0.000475 0.000015 +0 3 2 total 0.020316 0.000914 heating material group in nuclide mean std. dev. -1 3 1 total 74978.139095 3970.725596 -0 3 2 total 58539.697122 6443.645451 +1 3 1 total 77986.174023 6103.108384 +0 3 2 total 59060.658662 3576.641806 damage-energy material group in nuclide mean std. dev. -1 3 1 total 1161.596397 41.187452 -0 3 2 total 330.473159 32.100259 +1 3 1 total 1107.847239 59.901669 +0 3 2 total 331.691439 14.926212 (n,n1) - material group in nuclide mean std. dev. -1 3 1 total 2.912377e-07 3.897408e-08 -0 3 2 total 0.000000e+00 0.000000e+00 + material group in nuclide mean std. dev. +1 3 1 total 0.000001 3.988839e-07 +0 3 2 total 0.000000 0.000000e+00 (n,a0) material group in nuclide mean std. dev. -1 3 1 total 0.000082 0.000009 -0 3 2 total 0.001273 0.000124 +1 3 1 total 0.000084 0.000016 +0 3 2 total 0.001278 0.000058 (n,nc) matrix material group in group out nuclide mean std. dev. 3 3 1 1 total 0.0 0.0 diff --git a/tests/regression_tests/mgxs_library_no_nuclides/test.py b/tests/regression_tests/mgxs_library_no_nuclides/test.py index a02086af3..af14a5dc8 100644 --- a/tests/regression_tests/mgxs_library_no_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_no_nuclides/test.py @@ -39,7 +39,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_nuclides/inputs_true.dat b/tests/regression_tests/mgxs_library_nuclides/inputs_true.dat index c35e57f0e..9b3a22510 100644 --- a/tests/regression_tests/mgxs_library_nuclides/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_nuclides/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_nuclides/results_true.dat b/tests/regression_tests/mgxs_library_nuclides/results_true.dat index c05ec9b48..c2188997d 100644 --- a/tests/regression_tests/mgxs_library_nuclides/results_true.dat +++ b/tests/regression_tests/mgxs_library_nuclides/results_true.dat @@ -1 +1 @@ -d1e4ab2c0d85bb5da617db9c7a3731494114e2fd3ba75ae8eaa1f0a36648f73fcbcfb487390789b0124719cabdcbfa84af4bb118f11bdc548d1065e1b5af836a \ No newline at end of file +4ae3b5a70ad72b1be261aee3ab19e0261d1c12f4d4ca50b712d1ba76041bd5387c69fa9fa326619ad588db206cd9aaf464b0025d71ea9b8b1137af0102bca87f \ No newline at end of file diff --git a/tests/regression_tests/mgxs_library_nuclides/test.py b/tests/regression_tests/mgxs_library_nuclides/test.py index a10070358..8a7673565 100644 --- a/tests/regression_tests/mgxs_library_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_nuclides/test.py @@ -36,7 +36,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) def _get_results(self, hash_output=True): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_specific_nuclides/inputs_true.dat b/tests/regression_tests/mgxs_library_specific_nuclides/inputs_true.dat index dd9d1ceb0..1372741c9 100644 --- a/tests/regression_tests/mgxs_library_specific_nuclides/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_specific_nuclides/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + eigenvalue 100 10 5 - + -0.63 -0.63 -1 0.63 0.63 1 diff --git a/tests/regression_tests/mgxs_library_specific_nuclides/results_true.dat b/tests/regression_tests/mgxs_library_specific_nuclides/results_true.dat index 0c44eb132..eaf56b966 100644 --- a/tests/regression_tests/mgxs_library_specific_nuclides/results_true.dat +++ b/tests/regression_tests/mgxs_library_specific_nuclides/results_true.dat @@ -1 +1 @@ -efcd9fd6be2ed6c98bbe5279cbacdb287597fcbbc4ed49e164b07e0861f28877b1bef2ad82d70fdac95965f7ed0d0990f77c8545718836b1b55a16b4243208d0 \ No newline at end of file +08d5c199c51496f86fdd739bf7ee0e143a9a159da0f4d364ec970557e5c1fc92a202d906dcae91812e665fd2e88dd7db1e4913ef6b91f456f23b52093c83f483 \ No newline at end of file diff --git a/tests/regression_tests/mgxs_library_specific_nuclides/test.py b/tests/regression_tests/mgxs_library_specific_nuclides/test.py index 0ccbb83bd..61910e539 100644 --- a/tests/regression_tests/mgxs_library_specific_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_specific_nuclides/test.py @@ -37,7 +37,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies(self._model.tallies, merge=True) + self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=True) def _get_results(self, hash_output=True): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/microxs/test.py b/tests/regression_tests/microxs/test.py index 781be3ef7..a35150a1b 100644 --- a/tests/regression_tests/microxs/test.py +++ b/tests/regression_tests/microxs/test.py @@ -13,66 +13,55 @@ CHAIN_FILE = Path(__file__).parents[2] / "chain_simple.xml" @pytest.fixture(scope="module") def model(): fuel = openmc.Material(name="uo2") - fuel.add_nuclide("U235", 1.0) - fuel.add_nuclide("O16", 2.0) + fuel.add_element("U", 1, percent_type="ao", enrichment=4.25) + fuel.add_element("O", 2) fuel.set_density("g/cc", 10.4) - sphere = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere, fill=fuel) - geometry = openmc.Geometry([cell]) + clad = openmc.Material(name="clad") + clad.add_element("Zr", 1) + clad.set_density("g/cc", 6) + + water = openmc.Material(name="water") + water.add_element("O", 1) + water.add_element("H", 2) + water.set_density("g/cc", 1.0) + water.add_s_alpha_beta("c_H_in_H2O") + + radii = [0.42, 0.45] + fuel.volume = np.pi * radii[0] ** 2 + + materials = openmc.Materials([fuel, clad, water]) + + pin_surfaces = [openmc.ZCylinder(r=r) for r in radii] + pin_univ = openmc.model.pin(pin_surfaces, materials) + bound_box = openmc.model.RectangularPrism(1.24, 1.24, boundary_type="reflective") + root_cell = openmc.Cell(fill=pin_univ, region=-bound_box) + geometry = openmc.Geometry([root_cell]) settings = openmc.Settings() settings.particles = 1000 settings.inactive = 5 settings.batches = 10 - return openmc.Model(geometry, settings=settings) + return openmc.Model(geometry, materials, settings) -@pytest.mark.parametrize( - "domain_type, rr_mode", - [ - ("materials", "direct"), - ("materials", "flux"), - ("materials", "hybrid"), - ("mesh", "direct"), - ("mesh", "flux"), - ] -) -def test_from_model(model, domain_type, rr_mode): +@pytest.mark.parametrize("domain_type", ["materials", "mesh"]) +def test_from_model(model, domain_type): if domain_type == 'materials': - domains = list(model.geometry.get_all_materials().values()) + domains = model.materials[:1] elif domain_type == 'mesh': mesh = openmc.RegularMesh() - mesh.lower_left = (-10., -10.) - mesh.upper_right = (10., 10.) - mesh.dimension = (1, 1) + mesh.lower_left = (-0.62, -0.62) + mesh.upper_right = (0.62, 0.62) + mesh.dimension = (3, 3) domains = mesh - nuclides = ['U235', 'O16', 'Xe135'] - kwargs = { - 'chain_file': CHAIN_FILE, - 'path_statepoint': 'neutron_transport.h5', - } - if rr_mode == 'flux': - kwargs['reaction_rate_mode'] = 'flux' - kwargs['energies'] = 'CASMO-40' - elif rr_mode == 'hybrid': - kwargs['reaction_rate_mode'] = 'flux' - kwargs['energies'] = 'CASMO-40' - kwargs['reaction_rate_opts'] = { - 'nuclides': ['U235'], - 'reactions': ['fission'], - } - else: - kwargs['reaction_rate_mode'] = rr_mode - _, test_xs = get_microxs_and_flux(model, domains, nuclides, **kwargs) + nuclides = ['U234', 'U235', 'U238', 'U236', 'O16', 'O17', 'I135', 'Xe135', + 'Xe136', 'Cs135', 'Gd157', 'Gd156'] + _, test_xs = get_microxs_and_flux(model, domains, nuclides, chain_file=CHAIN_FILE) if config['update']: - test_xs[0].to_csv(f'test_reference_{domain_type}_{rr_mode}.csv') + test_xs[0].to_csv(f'test_reference_{domain_type}.csv') + + ref_xs = MicroXS.from_csv(f'test_reference_{domain_type}.csv') - # Make sure results match reference results - ref_xs = MicroXS.from_csv(f'test_reference_{domain_type}_{rr_mode}.csv') np.testing.assert_allclose(test_xs[0].data, ref_xs.data, rtol=1e-11) - - # Make sure statepoint file was saved - assert Path('neutron_transport.h5').exists() - Path('neutron_transport.h5').unlink() diff --git a/tests/regression_tests/microxs/test_reference_materials.csv b/tests/regression_tests/microxs/test_reference_materials.csv new file mode 100644 index 000000000..3e679f980 --- /dev/null +++ b/tests/regression_tests/microxs/test_reference_materials.csv @@ -0,0 +1,25 @@ +nuclides,reactions,groups,xs +U234,"(n,gamma)",1,21.418670317831076 +U234,fission,1,0.5014588470882162 +U235,"(n,gamma)",1,10.343944102483215 +U235,fission,1,47.46718472611895 +U238,"(n,gamma)",1,0.8741166723597229 +U238,fission,1,0.10829568455139067 +U236,"(n,gamma)",1,9.08348678468935 +U236,fission,1,0.3325287927011424 +O16,"(n,gamma)",1,7.548646353912426e-05 +O16,fission,1,0.0 +O17,"(n,gamma)",1,0.00040184862213103105 +O17,fission,1,0.0 +I135,"(n,gamma)",1,6.691256508942912 +I135,fission,1,0.0 +Xe135,"(n,gamma)",1,223998.6418566729 +Xe135,fission,1,0.0 +Xe136,"(n,gamma)",1,0.022934362666193503 +Xe136,fission,1,0.0 +Cs135,"(n,gamma)",1,2.2845395222353204 +Cs135,fission,1,0.0 +Gd157,"(n,gamma)",1,12582.07962003624 +Gd157,fission,1,0.0 +Gd156,"(n,gamma)",1,2.942112751533234 +Gd156,fission,1,0.0 diff --git a/tests/regression_tests/microxs/test_reference_materials_direct.csv b/tests/regression_tests/microxs/test_reference_materials_direct.csv deleted file mode 100644 index 4a63fed85..000000000 --- a/tests/regression_tests/microxs/test_reference_materials_direct.csv +++ /dev/null @@ -1,7 +0,0 @@ -nuclides,reactions,groups,xs -U235,"(n,gamma)",1,0.1475718536187164 -U235,fission,1,1.2504996049257149 -O16,"(n,gamma)",1,0.00010981236259441559 -O16,fission,1,0.0 -Xe135,"(n,gamma)",1,0.014570546772870611 -Xe135,fission,1,0.0 diff --git a/tests/regression_tests/microxs/test_reference_materials_flux.csv b/tests/regression_tests/microxs/test_reference_materials_flux.csv deleted file mode 100644 index 5eb29902e..000000000 --- a/tests/regression_tests/microxs/test_reference_materials_flux.csv +++ /dev/null @@ -1,7 +0,0 @@ -nuclides,reactions,groups,xs -U235,"(n,gamma)",1,0.15003016703758473 -U235,fission,1,1.2646269005413537 -O16,"(n,gamma)",1,0.00012069778439640301 -O16,fission,1,0.0 -Xe135,"(n,gamma)",1,0.014820264774863562 -Xe135,fission,1,0.0 diff --git a/tests/regression_tests/microxs/test_reference_materials_hybrid.csv b/tests/regression_tests/microxs/test_reference_materials_hybrid.csv deleted file mode 100644 index 6d17a5e2b..000000000 --- a/tests/regression_tests/microxs/test_reference_materials_hybrid.csv +++ /dev/null @@ -1,7 +0,0 @@ -nuclides,reactions,groups,xs -U235,"(n,gamma)",1,0.1500301670375847 -U235,fission,1,1.2578145727734291 -O16,"(n,gamma)",1,0.00012069778439640312 -O16,fission,1,0.0 -Xe135,"(n,gamma)",1,0.014820264774863558 -Xe135,fission,1,0.0 diff --git a/tests/regression_tests/microxs/test_reference_mesh.csv b/tests/regression_tests/microxs/test_reference_mesh.csv new file mode 100644 index 000000000..1882372b1 --- /dev/null +++ b/tests/regression_tests/microxs/test_reference_mesh.csv @@ -0,0 +1,25 @@ +nuclides,reactions,groups,xs +U234,"(n,gamma)",1,27.027171724208227 +U234,fission,1,0.04333740860093498 +U235,"(n,gamma)",1,12.683875995776193 +U235,fission,1,4.2596665957162605 +U238,"(n,gamma)",1,4.479719141496804 +U238,fission,1,0.009460665924409056 +U236,"(n,gamma)",1,8.469286849810802 +U236,fission,1,0.027373590840715795 +O16,"(n,gamma)",1,7.478160204479271e-05 +O16,fission,1,0.0 +O17,"(n,gamma)",1,0.0004743959164164789 +O17,fission,1,0.0 +I135,"(n,gamma)",1,8.33959524761822 +I135,fission,1,0.0 +Xe135,"(n,gamma)",1,282068.447252079 +Xe135,fission,1,0.0 +Xe136,"(n,gamma)",1,0.02888928065916194 +Xe136,fission,1,0.0 +Cs135,"(n,gamma)",1,2.5863526577468408 +Cs135,fission,1,0.0 +Gd157,"(n,gamma)",1,16518.24083307153 +Gd157,fission,1,0.0 +Gd156,"(n,gamma)",1,2.838514589417232 +Gd156,fission,1,0.0 diff --git a/tests/regression_tests/microxs/test_reference_mesh_direct.csv b/tests/regression_tests/microxs/test_reference_mesh_direct.csv deleted file mode 100644 index 60160ee51..000000000 --- a/tests/regression_tests/microxs/test_reference_mesh_direct.csv +++ /dev/null @@ -1,7 +0,0 @@ -nuclides,reactions,groups,xs -U235,"(n,gamma)",1,0.14757185361871633 -U235,fission,1,1.2504996049257142 -O16,"(n,gamma)",1,0.0001098123625944155 -O16,fission,1,0.0 -Xe135,"(n,gamma)",1,0.0145705467728706 -Xe135,fission,1,0.0 diff --git a/tests/regression_tests/microxs/test_reference_mesh_flux.csv b/tests/regression_tests/microxs/test_reference_mesh_flux.csv deleted file mode 100644 index 5eb29902e..000000000 --- a/tests/regression_tests/microxs/test_reference_mesh_flux.csv +++ /dev/null @@ -1,7 +0,0 @@ -nuclides,reactions,groups,xs -U235,"(n,gamma)",1,0.15003016703758473 -U235,fission,1,1.2646269005413537 -O16,"(n,gamma)",1,0.00012069778439640301 -O16,fission,1,0.0 -Xe135,"(n,gamma)",1,0.014820264774863562 -Xe135,fission,1,0.0 diff --git a/tests/regression_tests/model_xml/adj_cell_rotation_inputs_true.dat b/tests/regression_tests/model_xml/adj_cell_rotation_inputs_true.dat index 18c0552ce..7e2a0cf62 100644 --- a/tests/regression_tests/model_xml/adj_cell_rotation_inputs_true.dat +++ b/tests/regression_tests/model_xml/adj_cell_rotation_inputs_true.dat @@ -1,35 +1,35 @@ - - - + + + - - + + - - - - - - - - - - + + + + + + + + + + eigenvalue 10000 10 5 - + -4.0 -4.0 -4.0 4.0 4.0 4.0 diff --git a/tests/regression_tests/model_xml/energy_laws_inputs_true.dat b/tests/regression_tests/model_xml/energy_laws_inputs_true.dat index 8c5191217..4d8e825d1 100644 --- a/tests/regression_tests/model_xml/energy_laws_inputs_true.dat +++ b/tests/regression_tests/model_xml/energy_laws_inputs_true.dat @@ -1,18 +1,18 @@ - - - - - - - + + + + + + + - + eigenvalue diff --git a/tests/regression_tests/model_xml/lattice_multiple_inputs_true.dat b/tests/regression_tests/model_xml/lattice_multiple_inputs_true.dat index 06abef582..b249d97c4 100644 --- a/tests/regression_tests/model_xml/lattice_multiple_inputs_true.dat +++ b/tests/regression_tests/model_xml/lattice_multiple_inputs_true.dat @@ -1,15 +1,15 @@ - - - - + + + + - - - + + + @@ -18,8 +18,8 @@ - - + + 1.2 1.2 1 @@ -37,12 +37,12 @@ 4 4 4 4 - - - - - - + + + + + + eigenvalue diff --git a/tests/regression_tests/model_xml/photon_production_inputs_true.dat b/tests/regression_tests/model_xml/photon_production_inputs_true.dat index 0ae0079f4..ee6cb8862 100644 --- a/tests/regression_tests/model_xml/photon_production_inputs_true.dat +++ b/tests/regression_tests/model_xml/photon_production_inputs_true.dat @@ -2,28 +2,28 @@ - - + + - - - - - + + + + + fixed source 10000 1 - + 0 0 0 - + 14000000.0 1.0 @@ -41,16 +41,6 @@ neutron photon electron positron - - neutron - - - 0.0 20000000.0 - - - neutron photon - 0.0 100000.0 300000.0 500000.0 2000000.0 20000000.0 - 1 2 current @@ -73,10 +63,5 @@ total heating (n,gamma) analog - - 5 3 4 - events - analog -
diff --git a/tests/regression_tests/multipole/inputs_true.dat b/tests/regression_tests/multipole/inputs_true.dat index 3b78db77b..7bea66930 100644 --- a/tests/regression_tests/multipole/inputs_true.dat +++ b/tests/regression_tests/multipole/inputs_true.dat @@ -2,23 +2,21 @@ - - - + + + - - - + + + - - 500 700 0 800 - + - + 2.0 2.0 1 @@ -28,18 +26,18 @@ 11 11 11 11 - - - - - + + + + + eigenvalue 1000 5 0 - + -1 -1 -1 1 1 1 diff --git a/tests/regression_tests/multipole/results_true.dat b/tests/regression_tests/multipole/results_true.dat index 40b42b1a0..8e82655ce 100644 --- a/tests/regression_tests/multipole/results_true.dat +++ b/tests/regression_tests/multipole/results_true.dat @@ -1,36 +1,36 @@ k-combined: -1.315804E+00 7.070811E-02 +1.354889E+00 8.437211E-03 tally 1: -3.840178E+00 -2.953217E+00 -2.769369E+00 -1.535605E+00 -5.400560E-01 -5.840168E-02 -4.595308E-01 -4.237758E-02 +3.869969E+00 +3.000421E+00 +2.800393E+00 +1.570851E+00 +5.399091E-01 +5.842233E-02 +4.577147E-01 +4.203362E-02 0.000000E+00 0.000000E+00 -2.283789E+01 -1.044032E+02 +2.286465E+01 +1.045869E+02 0.000000E+00 0.000000E+00 -6.960971E-04 -9.704386E-08 -2.281620E+01 -1.042051E+02 -3.667073E-05 -1.048567E-09 -3.655557E+02 -2.676173E+04 -2.769369E+00 -1.535605E+00 -2.199058E+00 -9.681253E-01 -3.604950E+02 -2.602657E+04 -3.667073E-05 -1.048567E-09 +6.971793E-04 +9.724819E-08 +2.283955E+01 +1.043576E+02 +4.659256E-06 +2.170865E-11 +3.663230E+02 +2.685383E+04 +2.800393E+00 +1.570851E+00 +2.204999E+00 +9.728014E-01 +3.612213E+02 +2.611152E+04 +4.659256E-06 +2.170865E-11 Cell ID = 11 Name = @@ -38,6 +38,5 @@ Cell Region = -1 Rotation = None Temperature = [500. 700. 0. 800.] - Density = None Translation = None Volume = None diff --git a/tests/regression_tests/ncrystal/inputs_true.dat b/tests/regression_tests/ncrystal/inputs_true.dat index 81ee2e312..ecbc3c54f 100644 --- a/tests/regression_tests/ncrystal/inputs_true.dat +++ b/tests/regression_tests/ncrystal/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - + + fixed source 100000 10 - + 0 0 -20 - + 0.012 1.0 diff --git a/tests/regression_tests/ncrystal/results_true.dat b/tests/regression_tests/ncrystal/results_true.dat index 28c02c51c..3ef0306fd 100644 --- a/tests/regression_tests/ncrystal/results_true.dat +++ b/tests/regression_tests/ncrystal/results_true.dat @@ -106,8 +106,8 @@ 104 1 1.82e+00 1.83e+00 1 total current 1.10e-05 4.07e-06 105 1 1.83e+00 1.85e+00 1 total current 1.50e-05 4.01e-06 106 1 1.85e+00 1.87e+00 1 total current 1.90e-05 4.82e-06 -107 1 1.87e+00 1.88e+00 1 total current 2.30e-05 3.96e-06 -108 1 1.88e+00 1.90e+00 1 total current 2.00e-05 3.94e-06 +107 1 1.87e+00 1.88e+00 1 total current 2.20e-05 3.89e-06 +108 1 1.88e+00 1.90e+00 1 total current 2.10e-05 3.79e-06 109 1 1.90e+00 1.92e+00 1 total current 1.50e-05 3.42e-06 110 1 1.92e+00 1.94e+00 1 total current 2.20e-05 5.12e-06 111 1 1.94e+00 1.95e+00 1 total current 2.10e-05 5.86e-06 @@ -118,12 +118,12 @@ 116 1 2.02e+00 2.04e+00 1 total current 1.30e-05 3.35e-06 117 1 2.04e+00 2.06e+00 1 total current 1.90e-05 4.07e-06 118 1 2.06e+00 2.08e+00 1 total current 1.30e-05 3.00e-06 -119 1 2.08e+00 2.09e+00 1 total current 1.50e-05 4.28e-06 -120 1 2.09e+00 2.11e+00 1 total current 3.00e-05 4.94e-06 +119 1 2.08e+00 2.09e+00 1 total current 1.40e-05 4.00e-06 +120 1 2.09e+00 2.11e+00 1 total current 3.10e-05 5.47e-06 121 1 2.11e+00 2.13e+00 1 total current 2.30e-05 5.39e-06 122 1 2.13e+00 2.15e+00 1 total current 2.20e-05 4.67e-06 -123 1 2.15e+00 2.16e+00 1 total current 1.80e-05 4.67e-06 -124 1 2.16e+00 2.18e+00 1 total current 1.50e-05 4.01e-06 +123 1 2.15e+00 2.16e+00 1 total current 1.70e-05 4.48e-06 +124 1 2.16e+00 2.18e+00 1 total current 1.60e-05 4.00e-06 125 1 2.18e+00 2.20e+00 1 total current 1.80e-05 4.16e-06 126 1 2.20e+00 2.22e+00 1 total current 1.80e-05 4.42e-06 127 1 2.22e+00 2.23e+00 1 total current 1.80e-05 5.54e-06 @@ -135,7 +135,7 @@ 133 1 2.32e+00 2.34e+00 1 total current 2.30e-05 3.96e-06 134 1 2.34e+00 2.36e+00 1 total current 1.90e-05 3.48e-06 135 1 2.36e+00 2.37e+00 1 total current 1.60e-05 3.71e-06 -136 1 2.37e+00 2.39e+00 1 total current 1.70e-05 4.48e-06 +136 1 2.37e+00 2.39e+00 1 total current 1.60e-05 4.27e-06 137 1 2.39e+00 2.41e+00 1 total current 2.30e-05 4.48e-06 138 1 2.41e+00 2.43e+00 1 total current 2.10e-05 3.48e-06 139 1 2.43e+00 2.44e+00 1 total current 1.60e-05 2.21e-06 diff --git a/tests/regression_tests/ncrystal/test.py b/tests/regression_tests/ncrystal/test.py index 8da05e1cf..e1c1e5ed6 100644 --- a/tests/regression_tests/ncrystal/test.py +++ b/tests/regression_tests/ncrystal/test.py @@ -6,13 +6,12 @@ import numpy as np import openmc import openmc.lib import pytest -import shutil from tests.testing_harness import PyAPITestHarness pytestmark = pytest.mark.skipif( - not shutil.which('ncrystal-config'), - reason="NCrystal is not installed.") + not openmc.lib._ncrystal_enabled(), + reason="NCrystal materials are not enabled.") def pencil_beam_model(cfg, E0, N): diff --git a/tests/regression_tests/output/results_true.dat b/tests/regression_tests/output/results_true.dat index 97b997ae6..bbf03de94 100644 --- a/tests/regression_tests/output/results_true.dat +++ b/tests/regression_tests/output/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 diff --git a/tests/regression_tests/particle_production_fission/__init__.py b/tests/regression_tests/particle_production_fission/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/particle_production_fission/local/inputs_true.dat b/tests/regression_tests/particle_production_fission/local/inputs_true.dat deleted file mode 100644 index e93dfc36e..000000000 --- a/tests/regression_tests/particle_production_fission/local/inputs_true.dat +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - fixed source - 100 - 2 - - - 1000000.0 1.0 - - - true - false - - - - neutron - - - neutron - - - 2 1 - events - analog - - - diff --git a/tests/regression_tests/particle_production_fission/local/results_true.dat b/tests/regression_tests/particle_production_fission/local/results_true.dat deleted file mode 100644 index 2f5288eba..000000000 --- a/tests/regression_tests/particle_production_fission/local/results_true.dat +++ /dev/null @@ -1,3 +0,0 @@ -tally 1: -4.570000E+00 -1.047890E+01 diff --git a/tests/regression_tests/particle_production_fission/shared/inputs_true.dat b/tests/regression_tests/particle_production_fission/shared/inputs_true.dat deleted file mode 100644 index b50a39cd0..000000000 --- a/tests/regression_tests/particle_production_fission/shared/inputs_true.dat +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - fixed source - 100 - 2 - - - 1000000.0 1.0 - - - true - true - - - - neutron - - - neutron - - - 2 1 - events - analog - - - diff --git a/tests/regression_tests/particle_production_fission/shared/results_true.dat b/tests/regression_tests/particle_production_fission/shared/results_true.dat deleted file mode 100644 index 5a4dfc516..000000000 --- a/tests/regression_tests/particle_production_fission/shared/results_true.dat +++ /dev/null @@ -1,3 +0,0 @@ -tally 1: -5.180000E+00 -1.355140E+01 diff --git a/tests/regression_tests/particle_production_fission/test.py b/tests/regression_tests/particle_production_fission/test.py deleted file mode 100644 index 2ad6ca515..000000000 --- a/tests/regression_tests/particle_production_fission/test.py +++ /dev/null @@ -1,49 +0,0 @@ -import openmc -import pytest -from openmc.utility_funcs import change_directory - -from tests.testing_harness import PyAPITestHarness - - -@pytest.mark.parametrize("shared_secondary,subdir", [ - (False, "local"), - (True, "shared"), -]) -def test_particle_production_fission(shared_secondary, subdir): - """Fixed-source model with fissionable material to test that - ParticleProductionFilter correctly counts fission-born neutrons, - with both local and shared secondary bank modes.""" - with change_directory(subdir): - openmc.reset_auto_ids() - model = openmc.Model() - - mat = openmc.Material() - mat.set_density('g/cm3', 18.0) - mat.add_nuclide('U235', 1.0) - model.materials.append(mat) - - sph = openmc.Sphere(r=5.0, boundary_type='vacuum') - cell = openmc.Cell(fill=mat, region=-sph) - model.geometry = openmc.Geometry([cell]) - - source = openmc.IndependentSource() - source.energy = openmc.stats.delta_function(1.0e6) - - model.settings.particles = 100 - model.settings.run_mode = 'fixed source' - model.settings.batches = 2 - model.settings.source = source - model.settings.create_fission_neutrons = True - model.settings.shared_secondary_bank = shared_secondary - - # ParticleProductionFilter tracking fission neutron production - ppf = openmc.ParticleProductionFilter(['neutron']) - neutron_filter = openmc.ParticleFilter(['neutron']) - tally = openmc.Tally() - tally.filters = [neutron_filter, ppf] - tally.scores = ['events'] - tally.estimator = 'analog' - model.tallies = [tally] - - harness = PyAPITestHarness('statepoint.2.h5', model) - harness.main() diff --git a/tests/regression_tests/particle_restart_eigval/results_true.dat b/tests/regression_tests/particle_restart_eigval/results_true.dat index 3feeb5e74..bd81920ca 100644 --- a/tests/regression_tests/particle_restart_eigval/results_true.dat +++ b/tests/regression_tests/particle_restart_eigval/results_true.dat @@ -1,16 +1,16 @@ current batch: -8.000000E+00 +1.100000E+01 current generation: 1.000000E+00 particle id: -6.000000E+01 +2.540000E+02 run mode: eigenvalue particle weight: 1.000000E+00 particle energy: -2.028153E+06 +2.220048E+06 particle xyz: --3.678172E+01 -6.073321E+01 2.756488E+01 +-4.820850E+01 2.432936E+01 4.397668E+01 particle uvw: --3.284774E-01 -8.920284E-01 3.104639E-01 +-3.148565E-01 9.184190E-01 2.395245E-01 diff --git a/tests/regression_tests/particle_restart_eigval/settings.xml b/tests/regression_tests/particle_restart_eigval/settings.xml index de580e4c4..64b1a4dd4 100644 --- a/tests/regression_tests/particle_restart_eigval/settings.xml +++ b/tests/regression_tests/particle_restart_eigval/settings.xml @@ -6,7 +6,7 @@ 12 5 1200 - 1000000 + -10 -10 -5 10 10 5 diff --git a/tests/regression_tests/particle_restart_eigval/test.py b/tests/regression_tests/particle_restart_eigval/test.py index bad3f158c..f9d22edb8 100644 --- a/tests/regression_tests/particle_restart_eigval/test.py +++ b/tests/regression_tests/particle_restart_eigval/test.py @@ -2,5 +2,5 @@ from tests.testing_harness import ParticleRestartTestHarness def test_particle_restart_eigval(): - harness = ParticleRestartTestHarness('particle_8_60.h5') + harness = ParticleRestartTestHarness('particle_11_254.h5') harness.main() diff --git a/tests/regression_tests/particle_restart_fixed_shared_secondary/__init__.py b/tests/regression_tests/particle_restart_fixed_shared_secondary/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/particle_restart_fixed_shared_secondary/geometry.xml b/tests/regression_tests/particle_restart_fixed_shared_secondary/geometry.xml deleted file mode 100644 index c86e016c6..000000000 --- a/tests/regression_tests/particle_restart_fixed_shared_secondary/geometry.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/regression_tests/particle_restart_fixed_shared_secondary/results_true.dat b/tests/regression_tests/particle_restart_fixed_shared_secondary/results_true.dat deleted file mode 100644 index 0c84541f9..000000000 --- a/tests/regression_tests/particle_restart_fixed_shared_secondary/results_true.dat +++ /dev/null @@ -1,16 +0,0 @@ -current batch: -4.000000E+00 -current generation: -1.000000E+00 -particle id: -3.241000E+03 -run mode: -fixed source -particle weight: -1.000000E+00 -particle energy: -3.896365E+06 -particle xyz: -8.710681E-01 3.698823E+00 -2.286229E+00 -particle uvw: --5.882735E-01 4.665422E-01 -6.605093E-01 diff --git a/tests/regression_tests/particle_restart_fixed_shared_secondary/settings.xml b/tests/regression_tests/particle_restart_fixed_shared_secondary/settings.xml deleted file mode 100644 index 3a80fb17b..000000000 --- a/tests/regression_tests/particle_restart_fixed_shared_secondary/settings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - fixed source - 12 - 1000 - true - - - - -10 -10 -5 10 10 5 - - - - diff --git a/tests/regression_tests/particle_restart_fixed_shared_secondary/test.py b/tests/regression_tests/particle_restart_fixed_shared_secondary/test.py deleted file mode 100644 index 770010900..000000000 --- a/tests/regression_tests/particle_restart_fixed_shared_secondary/test.py +++ /dev/null @@ -1,6 +0,0 @@ -from tests.testing_harness import ParticleRestartTestHarness - - -def test_particle_restart_fixed_shared_secondary(): - harness = ParticleRestartTestHarness('particle_4_3241.h5') - harness.main() diff --git a/tests/regression_tests/periodic/inputs_true.dat b/tests/regression_tests/periodic/inputs_true.dat index 9183db3c4..65e1b5ce3 100644 --- a/tests/regression_tests/periodic/inputs_true.dat +++ b/tests/regression_tests/periodic/inputs_true.dat @@ -2,33 +2,33 @@ - - - + + + - - - + + + - - - - - - - + + + + + + + eigenvalue 1000 4 0 - + 0 0 0 5 5 0 diff --git a/tests/regression_tests/periodic/results_true.dat b/tests/regression_tests/periodic/results_true.dat index 626004b16..2189597e1 100644 --- a/tests/regression_tests/periodic/results_true.dat +++ b/tests/regression_tests/periodic/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.624889E+00 1.108153E-02 +1.623300E+00 2.572983E-02 diff --git a/tests/regression_tests/periodic_6fold/False-False/inputs_true.dat b/tests/regression_tests/periodic_6fold/False-False/inputs_true.dat deleted file mode 100644 index 075cffc12..000000000 --- a/tests/regression_tests/periodic_6fold/False-False/inputs_true.dat +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 4 - 0 - - - 0 0 0 5 5 0 - - - - diff --git a/tests/regression_tests/periodic_6fold/False-False/results_true.dat b/tests/regression_tests/periodic_6fold/False-False/results_true.dat deleted file mode 100644 index 04aa30878..000000000 --- a/tests/regression_tests/periodic_6fold/False-False/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.848492E+00 2.933785E-03 diff --git a/tests/regression_tests/periodic_6fold/False-True/inputs_true.dat b/tests/regression_tests/periodic_6fold/False-True/inputs_true.dat deleted file mode 100644 index cbc1e9100..000000000 --- a/tests/regression_tests/periodic_6fold/False-True/inputs_true.dat +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 4 - 0 - - - 0 0 0 5 5 0 - - - - diff --git a/tests/regression_tests/periodic_6fold/False-True/results_true.dat b/tests/regression_tests/periodic_6fold/False-True/results_true.dat deleted file mode 100644 index 04aa30878..000000000 --- a/tests/regression_tests/periodic_6fold/False-True/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.848492E+00 2.933785E-03 diff --git a/tests/regression_tests/periodic_6fold/True-False/inputs_true.dat b/tests/regression_tests/periodic_6fold/True-False/inputs_true.dat deleted file mode 100644 index 675a8b300..000000000 --- a/tests/regression_tests/periodic_6fold/True-False/inputs_true.dat +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 4 - 0 - - - 0 0 0 5 5 0 - - - - diff --git a/tests/regression_tests/periodic_6fold/True-False/results_true.dat b/tests/regression_tests/periodic_6fold/True-False/results_true.dat deleted file mode 100644 index 04aa30878..000000000 --- a/tests/regression_tests/periodic_6fold/True-False/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.848492E+00 2.933785E-03 diff --git a/tests/regression_tests/periodic_6fold/True-True/inputs_true.dat b/tests/regression_tests/periodic_6fold/True-True/inputs_true.dat deleted file mode 100644 index e5ac03b48..000000000 --- a/tests/regression_tests/periodic_6fold/True-True/inputs_true.dat +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 4 - 0 - - - 0 0 0 5 5 0 - - - - diff --git a/tests/regression_tests/periodic_6fold/True-True/results_true.dat b/tests/regression_tests/periodic_6fold/True-True/results_true.dat deleted file mode 100644 index 04aa30878..000000000 --- a/tests/regression_tests/periodic_6fold/True-True/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.848492E+00 2.933785E-03 diff --git a/tests/regression_tests/periodic_6fold/inputs_true.dat b/tests/regression_tests/periodic_6fold/inputs_true.dat new file mode 100644 index 000000000..f7f413d09 --- /dev/null +++ b/tests/regression_tests/periodic_6fold/inputs_true.dat @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + eigenvalue + 1000 + 4 + 0 + + + 0 0 0 5 5 0 + + + + diff --git a/tests/regression_tests/periodic_6fold/results_true.dat b/tests/regression_tests/periodic_6fold/results_true.dat new file mode 100644 index 000000000..e60182809 --- /dev/null +++ b/tests/regression_tests/periodic_6fold/results_true.dat @@ -0,0 +1,2 @@ +k-combined: +1.858730E+00 6.824588E-03 diff --git a/tests/regression_tests/periodic_6fold/test.py b/tests/regression_tests/periodic_6fold/test.py index bded1c465..272c65df5 100644 --- a/tests/regression_tests/periodic_6fold/test.py +++ b/tests/regression_tests/periodic_6fold/test.py @@ -1,16 +1,14 @@ from math import sin, cos, pi import openmc -from openmc.utility_funcs import change_directory import pytest from tests.testing_harness import PyAPITestHarness -@pytest.mark.parametrize("flip1", [False, True]) -@pytest.mark.parametrize("flip2", [False, True]) -def test_periodic(flip1, flip2): - model = openmc.Model() +@pytest.fixture +def model(): + model = openmc.model.Model() # Define materials water = openmc.Material() @@ -29,52 +27,31 @@ def test_periodic(flip1, flip2): # answers. theta1 = (-1/6 + 1/2) * pi theta2 = (1/6 - 1/2) * pi - if flip1: - plane1 = openmc.Plane(a=-cos(theta1), b=-sin(theta1), boundary_type='periodic') - else: - plane1 = openmc.Plane(a=cos(theta1), b=sin(theta1), boundary_type='periodic') - if flip2: - plane2 = openmc.Plane(a=-cos(theta2), b=-sin(theta2), boundary_type='periodic') - else: - plane2 = openmc.Plane(a=cos(theta2), b=sin(theta2), boundary_type='periodic') + plane1 = openmc.Plane(a=cos(theta1), b=sin(theta1), boundary_type='periodic') + plane2 = openmc.Plane(a=cos(theta2), b=sin(theta2), boundary_type='periodic') x_max = openmc.XPlane(5., boundary_type='reflective') z_cyl = openmc.ZCylinder(x0=3*cos(pi/6), y0=3*sin(pi/6), r=2.0) - match (flip1, flip2): - case (False, False): - outside_cyl = openmc.Cell(1, fill=water, region=( - +plane1 & +plane2 & -x_max & +z_cyl)) - inside_cyl = openmc.Cell(2, fill=fuel, region=( - +plane1 & +plane2 & -z_cyl)) - case (False, True): - outside_cyl = openmc.Cell(1, fill=water, region=( - +plane1 & -plane2 & -x_max & +z_cyl)) - inside_cyl = openmc.Cell(2, fill=fuel, region=( - +plane1 & -plane2 & -z_cyl)) - case (True, False): - outside_cyl = openmc.Cell(1, fill=water, region=( - -plane1 & +plane2 & -x_max & +z_cyl)) - inside_cyl = openmc.Cell(2, fill=fuel, region=( - -plane1 & +plane2 & -z_cyl)) - case (True, True): - outside_cyl = openmc.Cell(1, fill=water, region=( - -plane1 & -plane2 & -x_max & +z_cyl)) - inside_cyl = openmc.Cell(2, fill=fuel, region=( - -plane1 & -plane2 & -z_cyl)) + outside_cyl = openmc.Cell(1, fill=water, region=( + +plane1 & +plane2 & -x_max & +z_cyl)) + inside_cyl = openmc.Cell(2, fill=fuel, region=( + +plane1 & +plane2 & -z_cyl)) root_universe = openmc.Universe(0, cells=(outside_cyl, inside_cyl)) model.geometry = openmc.Geometry(root_universe) # Define settings + model.settings = openmc.Settings() model.settings.particles = 1000 model.settings.batches = 4 model.settings.inactive = 0 - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box((0, 0, 0), (5, 5, 0)) + model.settings.source = openmc.IndependentSource(space=openmc.stats.Box( + (0, 0, 0), (5, 5, 0)) ) + return model - with change_directory(f'{flip1}-{flip2}'): - harness = PyAPITestHarness('statepoint.4.h5', model) - harness.main() +def test_periodic(model): + harness = PyAPITestHarness('statepoint.4.h5', model) + harness.main() diff --git a/tests/regression_tests/periodic_cyls/__init__.py b/tests/regression_tests/periodic_cyls/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/periodic_cyls/test.py b/tests/regression_tests/periodic_cyls/test.py deleted file mode 100644 index a341e3799..000000000 --- a/tests/regression_tests/periodic_cyls/test.py +++ /dev/null @@ -1,91 +0,0 @@ -import openmc -import numpy as np -import pytest -from openmc.utility_funcs import change_directory -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def xcyl_model(): - model = openmc.Model() - # Define materials - fuel = openmc.Material() - fuel.add_nuclide('U235', 0.2) - fuel.add_nuclide('U238', 0.8) - fuel.set_density('g/cc', 19.1) - model.materials = openmc.Materials([fuel]) - - # Define geometry - # finite cylinder - x_min = openmc.XPlane(x0=0.0, boundary_type='reflective') - x_max = openmc.XPlane(x0=20.0, boundary_type='reflective') - x_cyl = openmc.XCylinder(r=20.0,boundary_type='vacuum') - # slice cylinder for periodic BC - periodic_bounding_yplane = openmc.YPlane(y0=0, boundary_type='periodic') - periodic_bounding_plane = openmc.Plane( - a=0.0, b=-np.sqrt(3) / 3, c=1, boundary_type='periodic', - ) - sixth_cyl_cell = openmc.Cell(1, fill=fuel, region = - +x_min &- x_max & -x_cyl & +periodic_bounding_yplane & +periodic_bounding_plane) - periodic_bounding_yplane.periodic_surface = periodic_bounding_plane - periodic_bounding_plane.periodic_surface = periodic_bounding_yplane - - model.geometry = openmc.Geometry([sixth_cyl_cell]) - - - # Define settings - model.settings.particles = 1000 - model.settings.batches = 4 - model.settings.inactive = 0 - model.settings.source = openmc.IndependentSource(space=openmc.stats.Box( - (0, 0, 0), (20, 20, 20)) - ) - return model - -@pytest.fixture -def ycyl_model(): - model = openmc.Model() - # Define materials - fuel = openmc.Material() - fuel.add_nuclide('U235', 0.2) - fuel.add_nuclide('U238', 0.8) - fuel.set_density('g/cc', 19.1) - model.materials = openmc.Materials([fuel]) - - # Define geometry - # finite cylinder - y_min = openmc.YPlane(y0=0.0, boundary_type='reflective') - y_max = openmc.YPlane(y0=20.0, boundary_type='reflective') - y_cyl = openmc.YCylinder(r=20.0,boundary_type='vacuum') - # slice cylinder for periodic BC - periodic_bounding_xplane = openmc.XPlane(x0=0, boundary_type='periodic') - periodic_bounding_plane = openmc.Plane( - a=-np.sqrt(3) / 3, b=0.0, c=1, boundary_type='periodic', - ) - sixth_cyl_cell = openmc.Cell(1, fill=fuel, region = - +y_min &- y_max & -y_cyl & +periodic_bounding_xplane & +periodic_bounding_plane) - periodic_bounding_xplane.periodic_surface = periodic_bounding_plane - periodic_bounding_plane.periodic_surface = periodic_bounding_xplane - model.geometry = openmc.Geometry([sixth_cyl_cell]) - - - # Define settings - model.settings.particles = 1000 - model.settings.batches = 4 - model.settings.inactive = 0 - model.settings.source = openmc.IndependentSource(space=openmc.stats.Box( - (0, 0, 0), (20, 20, 20)) - ) - return model - -def test_xcyl(xcyl_model): - with change_directory("xcyl_model"): - openmc.reset_auto_ids() - harness = PyAPITestHarness('statepoint.4.h5', xcyl_model) - harness.main() - -def test_ycyl(ycyl_model): - with change_directory("ycyl_model"): - openmc.reset_auto_ids() - harness = PyAPITestHarness('statepoint.4.h5', ycyl_model) - harness.main() \ No newline at end of file diff --git a/tests/regression_tests/periodic_cyls/xcyl_model/inputs_true.dat b/tests/regression_tests/periodic_cyls/xcyl_model/inputs_true.dat deleted file mode 100644 index 7d1ecf426..000000000 --- a/tests/regression_tests/periodic_cyls/xcyl_model/inputs_true.dat +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 4 - 0 - - - 0 0 0 20 20 20 - - - - diff --git a/tests/regression_tests/periodic_cyls/xcyl_model/results_true.dat b/tests/regression_tests/periodic_cyls/xcyl_model/results_true.dat deleted file mode 100644 index c7e3eb670..000000000 --- a/tests/regression_tests/periodic_cyls/xcyl_model/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.082283E+00 6.676373E-02 diff --git a/tests/regression_tests/periodic_cyls/ycyl_model/inputs_true.dat b/tests/regression_tests/periodic_cyls/ycyl_model/inputs_true.dat deleted file mode 100644 index f3ca7e0f4..000000000 --- a/tests/regression_tests/periodic_cyls/ycyl_model/inputs_true.dat +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - eigenvalue - 1000 - 4 - 0 - - - 0 0 0 20 20 20 - - - - diff --git a/tests/regression_tests/periodic_cyls/ycyl_model/results_true.dat b/tests/regression_tests/periodic_cyls/ycyl_model/results_true.dat deleted file mode 100644 index 562467f2c..000000000 --- a/tests/regression_tests/periodic_cyls/ycyl_model/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -1.082652E+00 3.316031E-02 diff --git a/tests/regression_tests/periodic_hex/inputs_true.dat b/tests/regression_tests/periodic_hex/inputs_true.dat index e65af3d94..188c8dfa9 100644 --- a/tests/regression_tests/periodic_hex/inputs_true.dat +++ b/tests/regression_tests/periodic_hex/inputs_true.dat @@ -1,19 +1,19 @@ - - - + + + - - - - - - + + + + + + eigenvalue diff --git a/tests/regression_tests/periodic_hex/results_true.dat b/tests/regression_tests/periodic_hex/results_true.dat index eff00b6e1..584089a15 100644 --- a/tests/regression_tests/periodic_hex/results_true.dat +++ b/tests/regression_tests/periodic_hex/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.285622E+00 2.576768E-03 +2.284468E+00 2.781588E-02 diff --git a/tests/regression_tests/photon_production/inputs_true.dat b/tests/regression_tests/photon_production/inputs_true.dat index 0ae0079f4..ee6cb8862 100644 --- a/tests/regression_tests/photon_production/inputs_true.dat +++ b/tests/regression_tests/photon_production/inputs_true.dat @@ -2,28 +2,28 @@ - - + + - - - - - + + + + + fixed source 10000 1 - + 0 0 0 - + 14000000.0 1.0 @@ -41,16 +41,6 @@ neutron photon electron positron - - neutron - - - 0.0 20000000.0 - - - neutron photon - 0.0 100000.0 300000.0 500000.0 2000000.0 20000000.0 - 1 2 current @@ -73,10 +63,5 @@ total heating (n,gamma) analog - - 5 3 4 - events - analog - diff --git a/tests/regression_tests/photon_production/results_true.dat b/tests/regression_tests/photon_production/results_true.dat index c4f5fafa2..398deeed8 100644 --- a/tests/regression_tests/photon_production/results_true.dat +++ b/tests/regression_tests/photon_production/results_true.dat @@ -1,8 +1,8 @@ tally 1: 8.610000E-01 7.413210E-01 -9.491000E-01 -9.007908E-01 +9.493000E-01 +9.011705E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -16,12 +16,12 @@ tally 2: 1.573004E+00 4.296434E-04 1.845934E-07 -2.350047E-01 -5.522722E-02 +2.337049E-01 +5.461796E-02 0.000000E+00 0.000000E+00 -2.350047E-01 -5.522722E-02 +2.337049E-01 +5.461796E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -53,40 +53,40 @@ tally 3: 4.104374E+12 4.296582E-04 1.846062E-07 -2.297000E-01 -5.276209E-02 -4.196651E+00 -1.761188E+01 +2.286000E-01 +5.225796E-02 +7.054033E+03 +4.975938E+07 0.000000E+00 0.000000E+00 -2.297000E-01 -5.276209E-02 -4.196651E+00 -1.761188E+01 +2.286000E-01 +5.225796E-02 +7.054033E+03 +4.975938E+07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.774484E+05 -3.148794E+10 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.774484E+05 -3.148794E+10 +0.000000E+00 +0.000000E+00 +1.764573E+05 +3.113718E+10 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.474427E+04 -2.173936E+08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.474427E+04 -2.173936E+08 +0.000000E+00 +0.000000E+00 +7.691658E+03 +5.916160E+07 0.000000E+00 0.000000E+00 tally 4: @@ -102,16 +102,16 @@ tally 4: 4.104374E+12 0.000000E+00 0.000000E+00 -2.297000E-01 -5.276209E-02 -4.196651E+00 -1.761188E+01 +2.286000E-01 +5.225796E-02 +7.054033E+03 +4.975938E+07 0.000000E+00 0.000000E+00 -2.297000E-01 -5.276209E-02 -4.196651E+00 -1.761188E+01 +2.286000E-01 +5.225796E-02 +7.054033E+03 +4.975938E+07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -122,8 +122,8 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.774484E+05 -3.148794E+10 +1.764573E+05 +3.113718E+10 0.000000E+00 0.000000E+00 0.000000E+00 @@ -134,28 +134,7 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.474427E+04 -2.173936E+08 +7.691658E+03 +5.916160E+07 0.000000E+00 0.000000E+00 -tally 5: -5.000000E-04 -2.500000E-07 -1.300000E-03 -1.690000E-06 -8.000000E-04 -6.400000E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -4.000000E-04 -8.200000E-03 -6.724000E-05 -5.280000E-02 -2.787840E-03 -3.546000E-01 -1.257412E-01 -5.063000E-01 -2.563397E-01 diff --git a/tests/regression_tests/photon_production/test.py b/tests/regression_tests/photon_production/test.py index 5ed5c5ecf..150448a12 100644 --- a/tests/regression_tests/photon_production/test.py +++ b/tests/regression_tests/photon_production/test.py @@ -25,8 +25,7 @@ def model(): inner_cyl_right.region = -cyl & +x_plane_center & -x_plane_right outer_cyl.region = ~(-cyl & +x_plane_left & -x_plane_right) inner_cyl_right.fill = mat - model.geometry = openmc.Geometry( - [inner_cyl_left, inner_cyl_right, outer_cyl]) + model.geometry = openmc.Geometry([inner_cyl_left, inner_cyl_right, outer_cyl]) source = openmc.IndependentSource() source.space = openmc.stats.Point((0, 0, 0)) @@ -39,19 +38,17 @@ def model(): model.settings.batches = 1 model.settings.photon_transport = True model.settings.electron_treatment = 'ttb' - model.settings.cutoff = {'energy_photon': 1000.0} + model.settings.cutoff = {'energy_photon' : 1000.0} model.settings.source = source surface_filter = openmc.SurfaceFilter(cyl) - particle_filter = openmc.ParticleFilter( - ['neutron', 'photon', 'electron', 'positron']) + particle_filter = openmc.ParticleFilter(['neutron', 'photon', 'electron', 'positron']) current_tally = openmc.Tally() current_tally.filters = [surface_filter, particle_filter] current_tally.scores = ['current'] tally_tracklength = openmc.Tally() tally_tracklength.filters = [particle_filter] - # heating doesn't work with tracklength - tally_tracklength.scores = ['total', '(n,gamma)'] + tally_tracklength.scores = ['total', '(n,gamma)'] # heating doesn't work with tracklength tally_tracklength.nuclides = ['Al27', 'total'] tally_tracklength.estimator = 'tracklength' tally_collision = openmc.Tally() @@ -64,25 +61,8 @@ def model(): tally_analog.scores = ['total', 'heating', '(n,gamma)'] tally_analog.nuclides = ['Al27', 'total'] tally_analog.estimator = 'analog' - - # This is an analog tally tracking the energy distribution of photons - # generated by neutrons. The sum of the tally should give the total - # number of photons generated per source neutron. - ene_filter = openmc.EnergyFilter([0.0, 20e6]) # incident neutron energy - - # Track source energies of secondary gammas - ene2_filter = openmc.ParticleProductionFilter( - ['neutron', 'photon'], [0.0, 100e3, 300e3, 500e3, 2e6, 20e6]) - - neutron_only = openmc.ParticleFilter(['neutron']) - tally_gam_ene = openmc.Tally() - tally_gam_ene.filters = [neutron_only, ene_filter, ene2_filter] - tally_gam_ene.scores = ['events'] - tally_gam_ene.estimator = 'analog' - model.tallies.extend([current_tally, tally_tracklength, - tally_collision, tally_analog, - tally_gam_ene]) + tally_collision, tally_analog]) return model diff --git a/tests/regression_tests/photon_production_fission/inputs_true.dat b/tests/regression_tests/photon_production_fission/inputs_true.dat index 11a194e3c..fa379b39e 100644 --- a/tests/regression_tests/photon_production_fission/inputs_true.dat +++ b/tests/regression_tests/photon_production_fission/inputs_true.dat @@ -1,21 +1,21 @@ - - - + + + - + eigenvalue 1000 5 2 - + 0 0 0 diff --git a/tests/regression_tests/photon_production_fission/results_true.dat b/tests/regression_tests/photon_production_fission/results_true.dat index af325d4b0..1aa08b147 100644 --- a/tests/regression_tests/photon_production_fission/results_true.dat +++ b/tests/regression_tests/photon_production_fission/results_true.dat @@ -1,12 +1,12 @@ k-combined: -2.297165E+00 1.955494E-02 +2.272421E+00 4.418825E-02 tally 1: -2.696393E+00 -2.423937E+00 +2.665301E+00 +2.369839E+00 0.000000E+00 0.000000E+00 -2.696393E+00 -2.423937E+00 +2.665301E+00 +2.369839E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -18,52 +18,52 @@ tally 1: 0.000000E+00 0.000000E+00 tally 2: -2.672029E+00 -2.380251E+00 -4.288244E+08 -6.130569E+16 +2.637532E+00 +2.320051E+00 +4.231377E+08 +5.971498E+16 0.000000E+00 0.000000E+00 -2.672029E+00 -2.380251E+00 -4.288244E+08 -6.130569E+16 +2.637532E+00 +2.320051E+00 +4.231377E+08 +5.971498E+16 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.711908E+05 -9.769096E+09 +2.448745E+06 +2.005297E+12 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.711908E+05 -9.769096E+09 +2.448745E+06 +2.005297E+12 0.000000E+00 0.000000E+00 tally 3: -2.649127E+00 -2.339294E+00 -4.288244E+08 -6.130569E+16 +2.660000E+00 +2.358558E+00 +4.231377E+08 +5.971498E+16 0.000000E+00 0.000000E+00 -2.649127E+00 -2.339294E+00 -4.288244E+08 -6.130569E+16 +2.660000E+00 +2.358558E+00 +4.231377E+08 +5.971498E+16 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.711908E+05 -9.769096E+09 +2.448745E+06 +2.005297E+12 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.711908E+05 -9.769096E+09 +2.448745E+06 +2.005297E+12 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/photon_source/inputs_true.dat b/tests/regression_tests/photon_source/inputs_true.dat index adaa5fb42..3d2e05243 100644 --- a/tests/regression_tests/photon_source/inputs_true.dat +++ b/tests/regression_tests/photon_source/inputs_true.dat @@ -2,22 +2,22 @@ - - - - - + + + + + - + fixed source 10000 1 - + 0 0 0 diff --git a/tests/regression_tests/photon_source/results_true.dat b/tests/regression_tests/photon_source/results_true.dat index 8d934afc6..fcc75cbca 100644 --- a/tests/regression_tests/photon_source/results_true.dat +++ b/tests/regression_tests/photon_source/results_true.dat @@ -1,5 +1,5 @@ tally 1: -2.263761E+02 -5.124615E+04 +2.263938E+02 +5.125417E+04 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/plot_projections/plots.xml b/tests/regression_tests/plot_projections/plots.xml index 50d129cd9..85689da14 100644 --- a/tests/regression_tests/plot_projections/plots.xml +++ b/tests/regression_tests/plot_projections/plots.xml @@ -1,7 +1,7 @@ - + 0. 0. 0. 20. 20. 20. 200 200 @@ -11,7 +11,7 @@ 70 - + 0. 0. 0. 10. 10. 0. 25 25 @@ -22,7 +22,7 @@ example1 - + 0. 0. 0. 20. 20. 20. 200 200 @@ -31,7 +31,7 @@ 2 - + 0. 0. 0. 0. 10.0 20. 200 200 @@ -39,7 +39,7 @@ example3.png - + 0. 0. 0. 10. 10. 10. 25 25 @@ -52,39 +52,4 @@ - - 0. 0. 0. - 10. 10. 10. - 200 200 - phong.png - 1 3 - - - - - - - 0. 0. 0. - 10. 10. 10. - 0.5 - 200 200 - phong_diffuse.png - 1 3 - - - - - - - 0. 0. 0. - 10. 10. 10. - 0. 10. 10. - 200 200 - phong_move_light.png - 1 3 - - - - - diff --git a/tests/regression_tests/plot_projections/results_true.dat b/tests/regression_tests/plot_projections/results_true.dat index d5c6a7a58..1a67da300 100644 --- a/tests/regression_tests/plot_projections/results_true.dat +++ b/tests/regression_tests/plot_projections/results_true.dat @@ -1 +1 @@ -6b90dfcf3059f86d623bb6496bb92d5b6ea2788b79639b61f865b31b503b84df9af64e59eacb04ccb02a225cfdb51bb7fa4b4f71e8e6ea20b2714266b34886ce \ No newline at end of file +24fb0f41ee018ea086962dbd6bcd0b536d11d4b34644bfef4f0e74f8b462fe41a84af39c7ff79046d5d7cfe209084eac54712fa0ec01038e97eb43df1abd0334 \ No newline at end of file diff --git a/tests/regression_tests/plot_projections/test.py b/tests/regression_tests/plot_projections/test.py index 37a6ecf28..cf18503f4 100644 --- a/tests/regression_tests/plot_projections/test.py +++ b/tests/regression_tests/plot_projections/test.py @@ -2,8 +2,5 @@ from tests.testing_harness import PlotTestHarness from tests.regression_tests import config def test_plot(): - harness = PlotTestHarness(('plot_1.png', 'example1.png', 'example2.png', - 'example3.png', 'orthographic_example1.png', - 'phong.png', 'phong_diffuse.png', - 'phong_move_light.png')) + harness = PlotTestHarness(('plot_1.png', 'example1.png', 'example2.png', 'example3.png', 'orthographic_example1.png')) harness.main() diff --git a/tests/regression_tests/ptables_off/results_true.dat b/tests/regression_tests/ptables_off/results_true.dat index 374274862..1652088ce 100644 --- a/tests/regression_tests/ptables_off/results_true.dat +++ b/tests/regression_tests/ptables_off/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.968228E-01 1.770320E-03 +2.978318E-01 1.560055E-03 diff --git a/tests/regression_tests/pulse_height/shared_photon/inputs_true.dat b/tests/regression_tests/pulse_height/inputs_true.dat similarity index 75% rename from tests/regression_tests/pulse_height/shared_photon/inputs_true.dat rename to tests/regression_tests/pulse_height/inputs_true.dat index 608410c50..544ddb097 100644 --- a/tests/regression_tests/pulse_height/shared_photon/inputs_true.dat +++ b/tests/regression_tests/pulse_height/inputs_true.dat @@ -2,28 +2,30 @@ - - - + + + - - - - + + + + fixed source 100 5 - + + + 0.0 0.0 0.0 + 1000000.0 1.0 true - true diff --git a/tests/regression_tests/pulse_height/local_neutron/inputs_true.dat b/tests/regression_tests/pulse_height/local_neutron/inputs_true.dat deleted file mode 100644 index e25de58b0..000000000 --- a/tests/regression_tests/pulse_height/local_neutron/inputs_true.dat +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - fixed source - 100 - 5 - - - 1000000.0 1.0 - - - true - false - - - - 1 - - - 0.0 10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 150000.0 160000.0 170000.0 180000.0 190000.0 200000.0 210000.0 220000.0 230000.0 240000.0 250000.0 260000.0 270000.0 280000.0 290000.0 300000.0 310000.0 320000.0 330000.0 340000.0 350000.0 360000.0 370000.0 380000.0 390000.0 400000.0 410000.0 420000.0 430000.0 440000.0 450000.0 460000.0 470000.0 480000.0 490000.0 500000.0 510000.0 520000.0 530000.0 540000.0 550000.0 560000.0 570000.0 580000.0 590000.0 600000.0 610000.0 620000.0 630000.0 640000.0 650000.0 660000.0 670000.0 680000.0 690000.0 700000.0 710000.0 720000.0 730000.0 740000.0 750000.0 760000.0 770000.0 780000.0 790000.0 800000.0 810000.0 820000.0 830000.0 840000.0 850000.0 860000.0 870000.0 880000.0 890000.0 900000.0 910000.0 920000.0 930000.0 940000.0 950000.0 960000.0 970000.0 980000.0 990000.0 1000000.0 - - - 1 2 - pulse-height - - - diff --git a/tests/regression_tests/pulse_height/local_neutron/results_true.dat b/tests/regression_tests/pulse_height/local_neutron/results_true.dat deleted file mode 100644 index ffa284d92..000000000 --- a/tests/regression_tests/pulse_height/local_neutron/results_true.dat +++ /dev/null @@ -1,201 +0,0 @@ -tally 1: -4.890000E+00 -4.784900E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -6.000000E-02 -1.800000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 diff --git a/tests/regression_tests/pulse_height/local_photon/inputs_true.dat b/tests/regression_tests/pulse_height/local_photon/inputs_true.dat deleted file mode 100644 index 84d033d85..000000000 --- a/tests/regression_tests/pulse_height/local_photon/inputs_true.dat +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - fixed source - 100 - 5 - - - 1000000.0 1.0 - - - true - false - - - - 1 - - - 0.0 10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 150000.0 160000.0 170000.0 180000.0 190000.0 200000.0 210000.0 220000.0 230000.0 240000.0 250000.0 260000.0 270000.0 280000.0 290000.0 300000.0 310000.0 320000.0 330000.0 340000.0 350000.0 360000.0 370000.0 380000.0 390000.0 400000.0 410000.0 420000.0 430000.0 440000.0 450000.0 460000.0 470000.0 480000.0 490000.0 500000.0 510000.0 520000.0 530000.0 540000.0 550000.0 560000.0 570000.0 580000.0 590000.0 600000.0 610000.0 620000.0 630000.0 640000.0 650000.0 660000.0 670000.0 680000.0 690000.0 700000.0 710000.0 720000.0 730000.0 740000.0 750000.0 760000.0 770000.0 780000.0 790000.0 800000.0 810000.0 820000.0 830000.0 840000.0 850000.0 860000.0 870000.0 880000.0 890000.0 900000.0 910000.0 920000.0 930000.0 940000.0 950000.0 960000.0 970000.0 980000.0 990000.0 1000000.0 - - - 1 2 - pulse-height - - - diff --git a/tests/regression_tests/pulse_height/local_photon/results_true.dat b/tests/regression_tests/pulse_height/results_true.dat similarity index 100% rename from tests/regression_tests/pulse_height/local_photon/results_true.dat rename to tests/regression_tests/pulse_height/results_true.dat diff --git a/tests/regression_tests/pulse_height/shared_neutron/inputs_true.dat b/tests/regression_tests/pulse_height/shared_neutron/inputs_true.dat deleted file mode 100644 index b13c53ef8..000000000 --- a/tests/regression_tests/pulse_height/shared_neutron/inputs_true.dat +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - fixed source - 100 - 5 - - - 1000000.0 1.0 - - - true - true - - - - 1 - - - 0.0 10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 150000.0 160000.0 170000.0 180000.0 190000.0 200000.0 210000.0 220000.0 230000.0 240000.0 250000.0 260000.0 270000.0 280000.0 290000.0 300000.0 310000.0 320000.0 330000.0 340000.0 350000.0 360000.0 370000.0 380000.0 390000.0 400000.0 410000.0 420000.0 430000.0 440000.0 450000.0 460000.0 470000.0 480000.0 490000.0 500000.0 510000.0 520000.0 530000.0 540000.0 550000.0 560000.0 570000.0 580000.0 590000.0 600000.0 610000.0 620000.0 630000.0 640000.0 650000.0 660000.0 670000.0 680000.0 690000.0 700000.0 710000.0 720000.0 730000.0 740000.0 750000.0 760000.0 770000.0 780000.0 790000.0 800000.0 810000.0 820000.0 830000.0 840000.0 850000.0 860000.0 870000.0 880000.0 890000.0 900000.0 910000.0 920000.0 930000.0 940000.0 950000.0 960000.0 970000.0 980000.0 990000.0 1000000.0 - - - 1 2 - pulse-height - - - diff --git a/tests/regression_tests/pulse_height/shared_neutron/results_true.dat b/tests/regression_tests/pulse_height/shared_neutron/results_true.dat deleted file mode 100644 index ffa284d92..000000000 --- a/tests/regression_tests/pulse_height/shared_neutron/results_true.dat +++ /dev/null @@ -1,201 +0,0 @@ -tally 1: -4.890000E+00 -4.784900E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -6.000000E-02 -1.800000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 diff --git a/tests/regression_tests/pulse_height/shared_photon/results_true.dat b/tests/regression_tests/pulse_height/shared_photon/results_true.dat deleted file mode 100644 index c57e8ff1c..000000000 --- a/tests/regression_tests/pulse_height/shared_photon/results_true.dat +++ /dev/null @@ -1,201 +0,0 @@ -tally 1: -4.140000E+00 -3.443000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -2.000000E-02 -4.000000E-04 -2.000000E-02 -4.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.000000E-02 -3.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.000000E-02 -6.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -2.000000E-02 -4.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-01 -8.600000E-03 diff --git a/tests/regression_tests/pulse_height/test.py b/tests/regression_tests/pulse_height/test.py index 371fcbd0f..90d960f66 100644 --- a/tests/regression_tests/pulse_height/test.py +++ b/tests/regression_tests/pulse_height/test.py @@ -1,54 +1,53 @@ import numpy as np import openmc import pytest -from openmc.utility_funcs import change_directory from tests.testing_harness import PyAPITestHarness -@pytest.mark.parametrize("shared_secondary,particle", [ - (False, "photon"), - (False, "neutron"), - (True, "photon"), - (True, "neutron") -]) -def test_pulse_height(shared_secondary, particle): - subdir = f"shared_{particle}" if shared_secondary else f"local_{particle}" - with change_directory(subdir): - openmc.reset_auto_ids() - model = openmc.Model() +@pytest.fixture +def sphere_model(): + + model = openmc.model.Model() - # Define materials - NaI = openmc.Material() - NaI.set_density('g/cm3', 3.7) - NaI.add_element('Na', 1.0) - NaI.add_element('I', 1.0) + # Define materials + NaI = openmc.Material() + NaI.set_density('g/cc', 3.7) + NaI.add_element('Na', 1.0) + NaI.add_element('I', 1.0) - # Define geometry: two spheres in each other - s1 = openmc.Sphere(r=1) - s2 = openmc.Sphere(r=2, boundary_type='vacuum') - inner_sphere = openmc.Cell(name='inner sphere', fill=NaI, region=-s1) - outer_sphere = openmc.Cell(name='outer sphere', region=+s1 & -s2) - model.geometry = openmc.Geometry([inner_sphere, outer_sphere]) + model.materials = openmc.Materials([NaI]) - # Define settings - model.settings.run_mode = 'fixed source' - model.settings.batches = 5 - model.settings.particles = 100 - model.settings.photon_transport = True - model.settings.shared_secondary_bank = shared_secondary - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(1e6), - particle=particle - ) + # Define geometry: two spheres in each other + s1 = openmc.Sphere(r=1) + s2 = openmc.Sphere(r=2, boundary_type='vacuum') + inner_sphere = openmc.Cell(name='inner sphere', fill=NaI, region=-s1) + outer_sphere = openmc.Cell(name='outer sphere', region=+s1 & -s2) + model.geometry = openmc.Geometry([inner_sphere, outer_sphere]) - # Define tallies - tally = openmc.Tally(name="pht tally") - tally.scores = ['pulse-height'] - cell_filter = openmc.CellFilter(inner_sphere) - energy_filter = openmc.EnergyFilter(np.linspace(0, 1e6, 101)) - tally.filters = [cell_filter, energy_filter] - model.tallies = [tally] + # Define settings + model.settings.run_mode = 'fixed source' + model.settings.batches = 5 + model.settings.particles = 100 + model.settings.photon_transport = True + model.settings.source = openmc.IndependentSource( + space=openmc.stats.Point(), + energy=openmc.stats.Discrete([1e6], [1]), + particle='photon' + ) - harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() + # Define tallies + tally = openmc.Tally(name="pht tally") + tally.scores = ['pulse-height'] + cell_filter = openmc.CellFilter(inner_sphere) + energy_filter = openmc.EnergyFilter(np.linspace(0, 1_000_000, 101)) + tally.filters = [cell_filter, energy_filter] + model.tallies = [tally] + + return model + + + +def test_pulse_height(sphere_model): + harness = PyAPITestHarness('statepoint.5.h5', sphere_model) + harness.main() diff --git a/tests/regression_tests/quadric_surfaces/results_true.dat b/tests/regression_tests/quadric_surfaces/results_true.dat index 6fb569f52..382c4241e 100644 --- a/tests/regression_tests/quadric_surfaces/results_true.dat +++ b/tests/regression_tests/quadric_surfaces/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.216213E+00 2.789559E-02 +1.193830E+00 1.824184E-02 diff --git a/tests/regression_tests/random_ray_adjoint_fixed_source/__init__.py b/tests/regression_tests/random_ray_adjoint_fixed_source/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_adjoint_fixed_source/inputs_true.dat b/tests/regression_tests/random_ray_adjoint_fixed_source/inputs_true.dat deleted file mode 100644 index 94e270976..000000000 --- a/tests/regression_tests/random_ray_adjoint_fixed_source/inputs_true.dat +++ /dev/null @@ -1,248 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 500 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - true - naive - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_adjoint_fixed_source/results_true.dat b/tests/regression_tests/random_ray_adjoint_fixed_source/results_true.dat deleted file mode 100644 index e9aa9015b..000000000 --- a/tests/regression_tests/random_ray_adjoint_fixed_source/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.790516E+04 -6.740859E+08 -tally 2: -6.885455E+04 -9.482551E+08 -tally 3: -1.956327E+05 -7.654468E+09 diff --git a/tests/regression_tests/random_ray_adjoint_fixed_source/test.py b/tests/regression_tests/random_ray_adjoint_fixed_source/test.py deleted file mode 100644 index 6c2790fa0..000000000 --- a/tests/regression_tests/random_ray_adjoint_fixed_source/test.py +++ /dev/null @@ -1,22 +0,0 @@ -import os - -from openmc.examples import random_ray_three_region_cube - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_adjoint_fixed_source(): - model = random_ray_three_region_cube() - model.settings.random_ray['adjoint'] = True - model.settings.random_ray['volume_estimator'] = 'naive' - model.settings.particles = 500 - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_adjoint_k_eff/__init__.py b/tests/regression_tests/random_ray_adjoint_k_eff/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_adjoint_k_eff/inputs_true.dat b/tests/regression_tests/random_ray_adjoint_k_eff/inputs_true.dat deleted file mode 100644 index 755afd6c4..000000000 --- a/tests/regression_tests/random_ray_adjoint_k_eff/inputs_true.dat +++ /dev/null @@ -1,112 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - true - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat b/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat deleted file mode 100644 index dfef53cd2..000000000 --- a/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -1.006640E+00 1.812969E-03 -tally 1: -1.208044E+00 -2.920182E-01 -4.854426E-01 -4.715453E-02 -0.000000E+00 -0.000000E+00 -1.149242E+00 -2.643067E-01 -1.750801E-01 -6.134563E-03 -0.000000E+00 -0.000000E+00 -1.077743E+00 -2.324814E-01 -3.492371E-02 -2.441363E-04 -0.000000E+00 -0.000000E+00 -9.285362E-01 -1.725808E-01 -3.098889E-02 -1.922297E-04 -1.963161E-07 -7.714727E-15 -8.778641E-01 -1.541719E-01 -1.028293E-02 -2.115448E-05 -5.402741E-04 -5.839789E-08 -8.730274E-01 -1.524358E-01 -1.301813E-03 -3.389450E-07 -6.542525E-01 -8.560964E-02 -9.328247E-01 -1.740366E-01 -1.226491E-02 -3.008584E-05 -9.997969E-01 -1.999204E-01 -9.784958E-01 -1.915688E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.017952E+00 -2.073461E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.027039E+00 -2.110955E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.598240E-01 -1.844004E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.937969E-01 -1.598332E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.752275E-01 -1.532052E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.248400E-01 -1.710699E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.254054E+00 -3.146708E-01 -5.124223E-01 -5.253093E-02 -0.000000E+00 -0.000000E+00 -1.183712E+00 -2.803961E-01 -1.834683E-01 -6.735381E-03 -0.000000E+00 -0.000000E+00 -1.093555E+00 -2.393604E-01 -3.601678E-02 -2.596341E-04 -0.000000E+00 -0.000000E+00 -9.242694E-01 -1.709967E-01 -3.130894E-02 -1.962084E-04 -1.983437E-07 -7.874400E-15 -8.742100E-01 -1.528879E-01 -1.041026E-02 -2.167970E-05 -5.469644E-04 -5.984780E-08 -8.724009E-01 -1.522171E-01 -1.322938E-03 -3.500386E-07 -6.648691E-01 -8.841161E-02 -9.353464E-01 -1.749781E-01 -1.251209E-02 -3.131171E-05 -1.019947E+00 -2.080664E-01 -1.209708E+00 -2.928214E-01 -4.976146E-01 -4.954258E-02 -0.000000E+00 -0.000000E+00 -1.149174E+00 -2.642694E-01 -1.791431E-01 -6.421530E-03 -0.000000E+00 -0.000000E+00 -1.076718E+00 -2.320295E-01 -3.567737E-02 -2.547314E-04 -0.000000E+00 -0.000000E+00 -9.272977E-01 -1.721077E-01 -3.161443E-02 -2.000179E-04 -2.002789E-07 -8.027290E-15 -8.778794E-01 -1.541769E-01 -1.051257E-02 -2.210729E-05 -5.523400E-04 -6.102818E-08 -8.730477E-01 -1.524429E-01 -1.331320E-03 -3.544869E-07 -6.690816E-01 -8.953516E-02 -9.334544E-01 -1.742707E-01 -1.255707E-02 -3.153710E-05 -1.023613E+00 -2.095641E-01 diff --git a/tests/regression_tests/random_ray_adjoint_k_eff/test.py b/tests/regression_tests/random_ray_adjoint_k_eff/test.py deleted file mode 100644 index 44cf1182a..000000000 --- a/tests/regression_tests/random_ray_adjoint_k_eff/test.py +++ /dev/null @@ -1,20 +0,0 @@ -import os - -from openmc.examples import random_ray_lattice - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_basic(): - model = random_ray_lattice() - model.settings.random_ray['adjoint'] = True - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_adjoint_local/__init__.py b/tests/regression_tests/random_ray_adjoint_local/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_adjoint_local/inputs_true.dat b/tests/regression_tests/random_ray_adjoint_local/inputs_true.dat deleted file mode 100644 index 9021d1675..000000000 --- a/tests/regression_tests/random_ray_adjoint_local/inputs_true.dat +++ /dev/null @@ -1,293 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - - - - - - fixed source - 500 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 800.0 - 100.0 - - - - 0.0 0.0 0.0 35.0 35.0 35.0 - - - - true - - - - - - true - - - - 100.0 1.0 - - - cell - 6 7 - - - - naive - - - 14 14 14 - 0.0 0.0 0.0 - 35.0 35.0 35.0 - - - - - 6 - - - 7 - - - 3 - - - 2 - - - 1 - - - 1 - flux - tracklength - - - 2 - flux - tracklength - - - 3 - flux - tracklength - - - 4 - flux - tracklength - - - 5 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_adjoint_local/results_true.dat b/tests/regression_tests/random_ray_adjoint_local/results_true.dat deleted file mode 100644 index daa948565..000000000 --- a/tests/regression_tests/random_ray_adjoint_local/results_true.dat +++ /dev/null @@ -1,15 +0,0 @@ -tally 1: -2.215273E+01 -9.815738E+01 -tally 2: -1.873933E+01 -7.023420E+01 -tally 3: -4.802282E-01 -4.612707E-02 -tally 4: -2.516720E-01 -1.271063E-02 -tally 5: -1.169938E-02 -3.277334E-05 diff --git a/tests/regression_tests/random_ray_adjoint_local/test.py b/tests/regression_tests/random_ray_adjoint_local/test.py deleted file mode 100644 index c11b8e847..000000000 --- a/tests/regression_tests/random_ray_adjoint_local/test.py +++ /dev/null @@ -1,35 +0,0 @@ -import os -import openmc - -from openmc.examples import random_ray_three_region_cube_with_detectors - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_adjoint_local(): - model = random_ray_three_region_cube_with_detectors() - - detector1_cells = model.geometry.get_cells_by_name("detector 1") - detector2_cells = model.geometry.get_cells_by_name("detector 2") - detector_cells = detector1_cells + detector2_cells - - strengths = [1.0] - midpoints = [100.0] - energy_distribution = openmc.stats.Discrete(x=midpoints, p=strengths) - - adj_source = openmc.IndependentSource(energy=energy_distribution, constraints={ - 'domains': detector_cells}, strength=3.14) - - model.settings.random_ray['adjoint'] = True - model.settings.random_ray['adjoint_source'] = adj_source - model.settings.random_ray['volume_estimator'] = 'naive' - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_auto_convert/__init__.py b/tests/regression_tests/random_ray_auto_convert/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_auto_convert/infinite_medium/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert/infinite_medium/inputs_true.dat deleted file mode 100644 index 81f8c98ca..000000000 --- a/tests/regression_tests/random_ray_auto_convert/infinite_medium/inputs_true.dat +++ /dev/null @@ -1,66 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert/infinite_medium/results_true.dat b/tests/regression_tests/random_ray_auto_convert/infinite_medium/results_true.dat deleted file mode 100644 index f984f3718..000000000 --- a/tests/regression_tests/random_ray_auto_convert/infinite_medium/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.479770E-01 1.624548E-02 diff --git a/tests/regression_tests/random_ray_auto_convert/material_wise/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert/material_wise/inputs_true.dat deleted file mode 100644 index 81f8c98ca..000000000 --- a/tests/regression_tests/random_ray_auto_convert/material_wise/inputs_true.dat +++ /dev/null @@ -1,66 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert/material_wise/results_true.dat b/tests/regression_tests/random_ray_auto_convert/material_wise/results_true.dat deleted file mode 100644 index 3bade01e0..000000000 --- a/tests/regression_tests/random_ray_auto_convert/material_wise/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.372542E-01 6.967831E-03 diff --git a/tests/regression_tests/random_ray_auto_convert/stochastic_slab/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert/stochastic_slab/inputs_true.dat deleted file mode 100644 index 81f8c98ca..000000000 --- a/tests/regression_tests/random_ray_auto_convert/stochastic_slab/inputs_true.dat +++ /dev/null @@ -1,66 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert/stochastic_slab/results_true.dat b/tests/regression_tests/random_ray_auto_convert/stochastic_slab/results_true.dat deleted file mode 100644 index 674dee4aa..000000000 --- a/tests/regression_tests/random_ray_auto_convert/stochastic_slab/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -6.413334E-01 2.083132E-02 diff --git a/tests/regression_tests/random_ray_auto_convert/test.py b/tests/regression_tests/random_ray_auto_convert/test.py deleted file mode 100644 index df90dfb5c..000000000 --- a/tests/regression_tests/random_ray_auto_convert/test.py +++ /dev/null @@ -1,55 +0,0 @@ -import os - -import openmc -from openmc.examples import pwr_pin_cell -from openmc import RegularMesh -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("method", ["material_wise", "stochastic_slab", "infinite_medium"]) -def test_random_ray_auto_convert(method): - with change_directory(method): - openmc.reset_auto_ids() - - # Start with a normal continuous energy model - model = pwr_pin_cell() - - # Convert to a multi-group model - model.convert_to_multigroup( - method=method, groups='CASMO-2', - particles=100, - overwrite_mgxs_library=False, mgxs_path="mgxs.h5" - ) - - # Convert to a random ray model - model.convert_to_random_ray() - - # Set the number of particles - model.settings.particles = 100 - - # Overlay a basic 2x2 mesh - n = 2 - mesh = RegularMesh() - mesh.dimension = (n, n) - bbox = model.geometry.bounding_box - mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1]) - mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1]) - model.settings.random_ray['source_region_meshes'] = [ - (mesh, [model.geometry.root_universe])] - - # Set the source shape to linear - model.settings.random_ray['source_shape'] = 'linear' - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_auto_convert_bootstrap/__init__.py b/tests/regression_tests/random_ray_auto_convert_bootstrap/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_auto_convert_bootstrap/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_bootstrap/inputs_true.dat deleted file mode 100644 index 825e8dbdb..000000000 --- a/tests/regression_tests/random_ray_auto_convert_bootstrap/inputs_true.dat +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fixed source - 20 - 10 - - - -60.0 -6.0 -6.0 -48.0 6.0 6.0 - - - - 2000000.0 1.0 - - - cell - 1 - - - weight_windows.h5 - - true - true - - 100000 - - - - 1 2 3 4 - - - 193 - flux - - - diff --git a/tests/regression_tests/random_ray_auto_convert_bootstrap/results_true.dat b/tests/regression_tests/random_ray_auto_convert_bootstrap/results_true.dat deleted file mode 100644 index f5d1b0506..000000000 --- a/tests/regression_tests/random_ray_auto_convert_bootstrap/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -9.500337E+01 -9.709273E+02 -2.417257E-04 -1.153221E-08 -9.046900E+02 -8.904339E+04 -1.034722E+02 -1.134807E+03 diff --git a/tests/regression_tests/random_ray_auto_convert_bootstrap/test.py b/tests/regression_tests/random_ray_auto_convert_bootstrap/test.py deleted file mode 100644 index 21dbb2c03..000000000 --- a/tests/regression_tests/random_ray_auto_convert_bootstrap/test.py +++ /dev/null @@ -1,101 +0,0 @@ -import copy -import os -from pathlib import Path - -import numpy as np -import openmc -import openmc.mgxs -from openmc.examples import sphere_with_shielded_pocket - -from tests.testing_harness import TolerantPyAPITestHarness - - -GROUPS = 'CASMO-4' - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - for f in ('mgxs.h5', 'weight_windows.h5'): - if os.path.exists(f): - os.remove(f) - - -def generate_weight_windows(model, mesh): - """Convert a multigroup model to random ray and run a FW-CADIS weight - window generation solve, producing weight_windows.h5.""" - model.convert_to_random_ray() - rr = model.settings.random_ray - rr['source_region_meshes'] = [(mesh, [model.geometry.root_universe])] - rr['distance_inactive'] = 100.0 - rr['distance_active'] = 400.0 - rr['source_shape'] = 'flat' - rr['sample_method'] = 'halton' - rr['volume_estimator'] = 'hybrid' - model.settings.particles = 1000 - model.settings.batches = 20 - model.settings.inactive = 15 - model.settings.weight_window_generators = openmc.WeightWindowGenerator( - method='fw_cadis', mesh=mesh, max_realizations=20, - energy_bounds=openmc.mgxs.EnergyGroups(GROUPS).group_edges) - model.run() - - -def test_random_ray_auto_convert_bootstrap(): - # Tests the weight window bootstrapped MGXS generation workflow, which - # consists of five OpenMC runs: a stochastic_slab MGXS generation, a random - # ray FW-CADIS weight window generation, a material_wise MGXS generation - # using those weight windows (which reach the steel pocket that an analog - # solve essentially never tallies), a second FW-CADIS generation using the - # bootstrapped library, and a final continuous energy Monte Carlo solve - # using the improved weight windows, whose tallies are compared against - # the reference results. - openmc.reset_auto_ids() - model = sphere_with_shielded_pocket() - - # Used by the continuous energy solves below; these have no effect on the - # random ray solves (random ray generates weight windows but never applies - # them). - model.settings.weight_window_checkpoints = { - 'collision': True, 'surface': True} - model.settings.max_history_splits = 100_000 - - # Overlay a ~10 cm source region / weight window mesh on the geometry - bbox = model.geometry.bounding_box - mesh = openmc.RegularMesh() - mesh.dimension = np.round( - (np.asarray(bbox.upper_right) - np.asarray(bbox.lower_left)) / 10.0 - ).astype(int) - mesh.lower_left = bbox.lower_left - mesh.upper_right = bbox.upper_right - - # Generate weight windows covering the whole problem with the - # stochastic_slab method and a random ray FW-CADIS solve - slab_model = copy.deepcopy(model) - slab_model.convert_to_multigroup( - method='stochastic_slab', groups=GROUPS, particles=50, - overwrite_mgxs_library=True, mgxs_path='mgxs.h5') - generate_weight_windows(slab_model, mesh) - - # Bootstrap the material-wise MGXS generation with those weight windows, - # then regenerate the weight windows from the higher-fidelity library - boot_model = copy.deepcopy(model) - boot_model.convert_to_multigroup( - groups=GROUPS, particles=1, - weight_windows_file=Path('weight_windows.h5').resolve(), - overwrite_mgxs_library=True, mgxs_path='mgxs.h5') - generate_weight_windows(boot_model, mesh) - - # Run the continuous energy model with the improved weight windows, - # tallying the flux in every region - model.settings.weight_windows_file = 'weight_windows.h5' - model.settings.particles = 20 - model.settings.batches = 10 - tally = openmc.Tally(name='flux') - tally.filters = [ - openmc.CellFilter(list(model.geometry.get_all_cells().values()))] - tally.scores = ['flux'] - model.tallies = openmc.Tallies([tally]) - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/__init__.py b/tests/regression_tests/random_ray_auto_convert_kappa_fission/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/inputs_true.dat deleted file mode 100644 index 48b0e8256..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/inputs_true.dat +++ /dev/null @@ -1,75 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - - - 1 - - - 61 - kappa-fission - - - diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/results_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/results_true.dat deleted file mode 100644 index 27b32d787..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/results_true.dat +++ /dev/null @@ -1,5 +0,0 @@ -k-combined: -7.479770E-01 1.624548E-02 -tally 1: -2.965503E+08 -1.762157E+16 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/inputs_true.dat deleted file mode 100644 index be738c3e0..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/inputs_true.dat +++ /dev/null @@ -1,75 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - - - 1 - - - 97 - kappa-fission - - - diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/results_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/results_true.dat deleted file mode 100644 index 5a379db7e..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/results_true.dat +++ /dev/null @@ -1,5 +0,0 @@ -k-combined: -7.372542E-01 6.967831E-03 -tally 1: -2.909255E+08 -1.693395E+16 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/inputs_true.dat deleted file mode 100644 index be738c3e0..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/inputs_true.dat +++ /dev/null @@ -1,75 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - - - 1 - - - 97 - kappa-fission - - - diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/results_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/results_true.dat deleted file mode 100644 index a60e5aa3c..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/results_true.dat +++ /dev/null @@ -1,5 +0,0 @@ -k-combined: -6.413334E-01 2.083132E-02 -tally 1: -2.541463E+08 -1.297259E+16 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py b/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py deleted file mode 100644 index 8fca0fce8..000000000 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py +++ /dev/null @@ -1,61 +0,0 @@ -import os - -import openmc -from openmc.examples import pwr_pin_cell -from openmc import RegularMesh -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("method", ["material_wise", "stochastic_slab", "infinite_medium"]) -def test_random_ray_auto_convert(method): - with change_directory(method): - openmc.reset_auto_ids() - - # Start with a normal continuous energy model - model = pwr_pin_cell() - - # Convert to a multi-group model - model.convert_to_multigroup( - method=method, groups='CASMO-2', - particles=100, - overwrite_mgxs_library=False, mgxs_path="mgxs.h5" - ) - - # Convert to a random ray model - model.convert_to_random_ray() - - # Set the number of particles - model.settings.particles = 100 - - # Overlay a basic 2x2 mesh - n = 2 - mesh = RegularMesh() - mesh.dimension = (n, n) - bbox = model.geometry.bounding_box - mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1]) - mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1]) - model.settings.random_ray['source_region_meshes'] = [ - (mesh, [model.geometry.root_universe])] - - # Set the source shape to linear - model.settings.random_ray['source_shape'] = 'linear' - - # Set a material tally - t = openmc.Tally(name = 'KF Tally') - t.filters = [openmc.MaterialFilter(bins=1)] - t.scores = ['kappa-fission'] - model.tallies.append(t) - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/__init__.py b/tests/regression_tests/random_ray_auto_convert_source_energy/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/model/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/model/inputs_true.dat deleted file mode 100644 index d2d8289ff..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/model/inputs_true.dat +++ /dev/null @@ -1,63 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - 7000000.0 1.0 - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/model/results_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/model/results_true.dat deleted file mode 100644 index 1fb09fd68..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/model/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.657815E-01 2.317564E-02 diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/user/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/user/inputs_true.dat deleted file mode 100644 index 81f8c98ca..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/user/inputs_true.dat +++ /dev/null @@ -1,66 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/user/results_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/user/results_true.dat deleted file mode 100644 index 073c5c99f..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/infinite_medium/user/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.827784E-01 2.062954E-02 diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/model/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/model/inputs_true.dat deleted file mode 100644 index d2d8289ff..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/model/inputs_true.dat +++ /dev/null @@ -1,63 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - 7000000.0 1.0 - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/model/results_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/model/results_true.dat deleted file mode 100644 index c5cdf8e29..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/model/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.479571E-01 2.398563E-02 diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/user/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/user/inputs_true.dat deleted file mode 100644 index 81f8c98ca..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/user/inputs_true.dat +++ /dev/null @@ -1,66 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/user/results_true.dat b/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/user/results_true.dat deleted file mode 100644 index c6cce2e39..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/stochastic_slab/user/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.620306E-01 2.175179E-02 diff --git a/tests/regression_tests/random_ray_auto_convert_source_energy/test.py b/tests/regression_tests/random_ray_auto_convert_source_energy/test.py deleted file mode 100644 index ddb620b27..000000000 --- a/tests/regression_tests/random_ray_auto_convert_source_energy/test.py +++ /dev/null @@ -1,67 +0,0 @@ -import os - -import openmc -from openmc.examples import pwr_pin_cell -from openmc import RegularMesh -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("source_type", ["model", "user"]) -@pytest.mark.parametrize("method", ["stochastic_slab", "infinite_medium"]) -def test_random_ray_auto_convert_source_energy(method, source_type): - dirname = f"{method}/{source_type}" - with change_directory(dirname): - openmc.reset_auto_ids() - - # Start with a normal continuous energy model - model = pwr_pin_cell() - - # Define the source energy distribution, using different methods - source_energy = None - if source_type == "model": - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(7.0e6) - ) - elif source_type == "user": - source_energy = openmc.stats.delta_function(1.0e4) - - # Convert to a multi-group model - model.convert_to_multigroup( - method=method, groups='CASMO-8', - particles=100, - overwrite_mgxs_library=False, mgxs_path="mgxs.h5", - source_energy=source_energy - ) - - # Convert to a random ray model - model.convert_to_random_ray() - - # Set the number of particles - model.settings.particles = 100 - - # Overlay a basic 2x2 mesh - n = 2 - mesh = RegularMesh() - mesh.dimension = (n, n) - bbox = model.geometry.bounding_box - mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1]) - mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1]) - model.settings.random_ray['source_region_meshes'] = [ - (mesh, [model.geometry.root_universe])] - - # Set the source shape to linear - model.settings.random_ray['source_shape'] = 'linear' - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/__init__.py b/tests/regression_tests/random_ray_auto_convert_temperature/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/infinite_medium/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_temperature/infinite_medium/inputs_true.dat deleted file mode 100644 index c49020d55..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/infinite_medium/inputs_true.dat +++ /dev/null @@ -1,72 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - 395.0 - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - nearest - true - 200.0 400.0 - 200.0 - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/infinite_medium/results_true.dat b/tests/regression_tests/random_ray_auto_convert_temperature/infinite_medium/results_true.dat deleted file mode 100644 index fee8bf670..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/infinite_medium/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.499800E-01 1.615317E-02 diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/material_wise/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_temperature/material_wise/inputs_true.dat deleted file mode 100644 index c49020d55..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/material_wise/inputs_true.dat +++ /dev/null @@ -1,72 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - 395.0 - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - nearest - true - 200.0 400.0 - 200.0 - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/material_wise/results_true.dat b/tests/regression_tests/random_ray_auto_convert_temperature/material_wise/results_true.dat deleted file mode 100644 index ef0a4b87a..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/material_wise/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.367927E-01 6.850805E-03 diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/stochastic_slab/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_temperature/stochastic_slab/inputs_true.dat deleted file mode 100644 index c49020d55..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/stochastic_slab/inputs_true.dat +++ /dev/null @@ -1,72 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - 395.0 - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - nearest - true - 200.0 400.0 - 200.0 - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/stochastic_slab/results_true.dat b/tests/regression_tests/random_ray_auto_convert_temperature/stochastic_slab/results_true.dat deleted file mode 100644 index a702ec851..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/stochastic_slab/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -6.431774E-01 2.076589E-02 diff --git a/tests/regression_tests/random_ray_auto_convert_temperature/test.py b/tests/regression_tests/random_ray_auto_convert_temperature/test.py deleted file mode 100644 index df2619000..000000000 --- a/tests/regression_tests/random_ray_auto_convert_temperature/test.py +++ /dev/null @@ -1,74 +0,0 @@ -import os - -import openmc -from openmc.examples import pwr_pin_cell -from openmc import RegularMesh -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("method", ["material_wise", "stochastic_slab", "infinite_medium"]) -def test_random_ray_auto_convert(method): - with change_directory(method): - openmc.reset_auto_ids() - - # Start with a normal continuous energy model - model = pwr_pin_cell() - - temp_settings = { - 'method' : 'nearest', - 'tolerance' : 200.0, - 'range' : (200.0, 400.0), - 'multipole' : True - } - - # Convert to a multi-group model - model.convert_to_multigroup( - method=method, groups='CASMO-2', - particles=100, temperature=temp_settings, - overwrite_mgxs_library=False, mgxs_path="mgxs.h5", - temperatures=[294.0, 394.0] - ) - - # Convert to a random ray model - model.convert_to_random_ray() - model.settings.temperature = temp_settings - - # Set all material temperatures to room temperature - for mat in model.geometry.get_all_materials().values(): - mat.temperature = 294.0 - - # Set the cell temperature of the fuel such that it moves up to the next - # temperature bin. - for cell in model.geometry.get_all_cells().values(): - if cell.name == "Fuel": - cell.temperature = [395.0] - - # Set the number of particles - model.settings.particles = 100 - - # Overlay a basic 2x2 mesh - n = 2 - mesh = RegularMesh() - mesh.dimension = (n, n) - bbox = model.geometry.bounding_box - mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1]) - mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1]) - model.settings.random_ray['source_region_meshes'] = [ - (mesh, [model.geometry.root_universe])] - - # Set the source shape to linear - model.settings.random_ray['source_shape'] = 'linear' - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/atomic_relaxation/__init__.py b/tests/regression_tests/random_ray_basic/__init__.py similarity index 100% rename from tests/regression_tests/atomic_relaxation/__init__.py rename to tests/regression_tests/random_ray_basic/__init__.py diff --git a/tests/regression_tests/random_ray_basic/inputs_true.dat b/tests/regression_tests/random_ray_basic/inputs_true.dat new file mode 100644 index 000000000..97b7906f7 --- /dev/null +++ b/tests/regression_tests/random_ray_basic/inputs_true.dat @@ -0,0 +1,108 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.126 0.126 + 10 10 + -0.63 -0.63 + +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 + + + 1.26 1.26 + 2 2 + -1.26 -1.26 + +2 2 +2 5 + + + + + + + + + + + + + + + + + + + + + eigenvalue + 100 + 10 + 5 + multi-group + + 100.0 + 20.0 + + + -1.26 -1.26 -1 1.26 1.26 1 + + + + + + + 2 2 + -1.26 -1.26 + 1.26 1.26 + + + 1 + + + 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 + + + 1 2 + flux fission nu-fission + analog + + + diff --git a/tests/regression_tests/random_ray_basic/results_true.dat b/tests/regression_tests/random_ray_basic/results_true.dat new file mode 100644 index 000000000..ee2e4000d --- /dev/null +++ b/tests/regression_tests/random_ray_basic/results_true.dat @@ -0,0 +1,171 @@ +k-combined: +8.400322E-01 8.023350E-03 +tally 1: +5.086560E+00 +5.180937E+00 +1.885166E+00 +7.115505E-01 +4.588117E+00 +4.214785E+00 +2.860401E+00 +1.639329E+00 +4.245221E-01 +3.610930E-02 +1.033202E+00 +2.138892E-01 +1.692631E+00 +5.793967E-01 +5.445818E-02 +5.996625E-04 +1.325403E-01 +3.552030E-03 +2.372249E+00 +1.146944E+00 +7.808143E-02 +1.242279E-03 +1.900346E-01 +7.358492E-03 +7.134949E+00 +1.034824E+01 +8.272648E-02 +1.391872E-03 +2.013422E-01 +8.244790E-03 +2.043539E+01 +8.389902E+01 +3.099367E-02 +1.930673E-04 +7.669167E-02 +1.182113E-03 +1.313212E+01 +3.449537E+01 +1.764293E-01 +6.225587E-03 +4.907293E-01 +4.816401E-02 +7.567717E+00 +1.145439E+01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.383194E+00 +2.290469E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.819673E+00 +6.726159E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.693683E+00 +1.480961E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.453759E+00 +1.128171E+01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.823561E+01 +6.681652E+01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.137517E+01 +2.588512E+01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.601917E+00 +4.242626E+00 +1.719723E+00 +5.923467E-01 +4.185463E+00 +3.508696E+00 +2.730305E+00 +1.494324E+00 +4.108214E-01 +3.383938E-02 +9.998572E-01 +2.004436E-01 +1.660852E+00 +5.570433E-01 +5.428709E-02 +5.947848E-04 +1.321239E-01 +3.523137E-03 +2.306069E+00 +1.082856E+00 +7.697032E-02 +1.206037E-03 +1.873304E-01 +7.143816E-03 +7.075194E+00 +1.017519E+01 +8.322052E-02 +1.408295E-03 +2.025446E-01 +8.342072E-03 +2.094832E+01 +8.816716E+01 +3.234739E-02 +2.101889E-04 +8.004135E-02 +1.286945E-03 +1.357413E+01 +3.685984E+01 +1.861680E-01 +6.934828E-03 +5.178169E-01 +5.365103E-02 +5.072150E+00 +5.151431E+00 +1.916644E+00 +7.358713E-01 +4.664727E+00 +4.358847E+00 +2.859465E+00 +1.638250E+00 +4.332944E-01 +3.763171E-02 +1.054552E+00 +2.229070E-01 +1.693008E+00 +5.796672E-01 +5.561096E-02 +6.247543E-04 +1.353459E-01 +3.700658E-03 +2.368860E+00 +1.143296E+00 +7.951820E-02 +1.286690E-03 +1.935314E-01 +7.621558E-03 +7.119587E+00 +1.030023E+01 +8.428176E-02 +1.442932E-03 +2.051275E-01 +8.547244E-03 +2.046758E+01 +8.418768E+01 +3.181946E-02 +2.034766E-04 +7.873502E-02 +1.245847E-03 +1.325834E+01 +3.515919E+01 +1.832838E-01 +6.720556E-03 +5.097947E-01 +5.199331E-02 diff --git a/tests/regression_tests/random_ray_basic/test.py b/tests/regression_tests/random_ray_basic/test.py new file mode 100644 index 000000000..1727a6371 --- /dev/null +++ b/tests/regression_tests/random_ray_basic/test.py @@ -0,0 +1,232 @@ +import os + +import numpy as np +import openmc + +from tests.testing_harness import TolerantPyAPITestHarness + + +class MGXSTestHarness(TolerantPyAPITestHarness): + def _cleanup(self): + super()._cleanup() + f = 'mgxs.h5' + if os.path.exists(f): + os.remove(f) + + +def random_ray_model() -> openmc.Model: + ############################################################################### + # Create multigroup data + + # Instantiate the energy group data + group_edges = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6] + groups = openmc.mgxs.EnergyGroups(group_edges) + + # Instantiate the 7-group (C5G7) cross section data + uo2_xsdata = openmc.XSdata('UO2', groups) + uo2_xsdata.order = 0 + uo2_xsdata.set_total( + [0.1779492, 0.3298048, 0.4803882, 0.5543674, 0.3118013, 0.3951678, + 0.5644058]) + uo2_xsdata.set_absorption([8.0248e-03, 3.7174e-03, 2.6769e-02, 9.6236e-02, + 3.0020e-02, 1.1126e-01, 2.8278e-01]) + scatter_matrix = np.array( + [[[0.1275370, 0.0423780, 0.0000094, 0.0000000, 0.0000000, 0.0000000, 0.0000000], + [0.0000000, 0.3244560, 0.0016314, 0.0000000, 0.0000000, 0.0000000, 0.0000000], + [0.0000000, 0.0000000, 0.4509400, 0.0026792, 0.0000000, 0.0000000, 0.0000000], + [0.0000000, 0.0000000, 0.0000000, 0.4525650, 0.0055664, 0.0000000, 0.0000000], + [0.0000000, 0.0000000, 0.0000000, 0.0001253, 0.2714010, 0.0102550, 0.0000000], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0012968, 0.2658020, 0.0168090], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0085458, 0.2730800]]]) + scatter_matrix = np.rollaxis(scatter_matrix, 0, 3) + uo2_xsdata.set_scatter_matrix(scatter_matrix) + uo2_xsdata.set_fission([7.21206e-03, 8.19301e-04, 6.45320e-03, + 1.85648e-02, 1.78084e-02, 8.30348e-02, + 2.16004e-01]) + uo2_xsdata.set_nu_fission([2.005998e-02, 2.027303e-03, 1.570599e-02, + 4.518301e-02, 4.334208e-02, 2.020901e-01, + 5.257105e-01]) + uo2_xsdata.set_chi([5.8791e-01, 4.1176e-01, 3.3906e-04, 1.1761e-07, 0.0000e+00, + 0.0000e+00, 0.0000e+00]) + + h2o_xsdata = openmc.XSdata('LWTR', groups) + h2o_xsdata.order = 0 + h2o_xsdata.set_total([0.15920605, 0.412969593, 0.59030986, 0.58435, + 0.718, 1.2544497, 2.650379]) + h2o_xsdata.set_absorption([6.0105e-04, 1.5793e-05, 3.3716e-04, + 1.9406e-03, 5.7416e-03, 1.5001e-02, + 3.7239e-02]) + scatter_matrix = np.array( + [[[0.0444777, 0.1134000, 0.0007235, 0.0000037, 0.0000001, 0.0000000, 0.0000000], + [0.0000000, 0.2823340, 0.1299400, 0.0006234, 0.0000480, 0.0000074, 0.0000010], + [0.0000000, 0.0000000, 0.3452560, 0.2245700, 0.0169990, 0.0026443, 0.0005034], + [0.0000000, 0.0000000, 0.0000000, 0.0910284, 0.4155100, 0.0637320, 0.0121390], + [0.0000000, 0.0000000, 0.0000000, 0.0000714, 0.1391380, 0.5118200, 0.0612290], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0022157, 0.6999130, 0.5373200], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1324400, 2.4807000]]]) + scatter_matrix = np.rollaxis(scatter_matrix, 0, 3) + h2o_xsdata.set_scatter_matrix(scatter_matrix) + + mg_cross_sections = openmc.MGXSLibrary(groups) + mg_cross_sections.add_xsdatas([uo2_xsdata, h2o_xsdata]) + mg_cross_sections.export_to_hdf5() + + ############################################################################### + # Create materials for the problem + + # Instantiate some Materials and register the appropriate macroscopic data + uo2 = openmc.Material(name='UO2 fuel') + uo2.set_density('macro', 1.0) + uo2.add_macroscopic('UO2') + + water = openmc.Material(name='Water') + water.set_density('macro', 1.0) + water.add_macroscopic('LWTR') + + # Instantiate a Materials collection and export to XML + materials = openmc.Materials([uo2, water]) + materials.cross_sections = "mgxs.h5" + + ############################################################################### + # Define problem geometry + + ######################################## + # Define an unbounded pincell universe + + pitch = 1.26 + + # Create a surface for the fuel outer radius + fuel_or = openmc.ZCylinder(r=0.54, name='Fuel OR') + inner_ring_a = openmc.ZCylinder(r=0.33, name='inner ring a') + inner_ring_b = openmc.ZCylinder(r=0.45, name='inner ring b') + outer_ring_a = openmc.ZCylinder(r=0.60, name='outer ring a') + outer_ring_b = openmc.ZCylinder(r=0.69, name='outer ring b') + + # Instantiate Cells + fuel_a = openmc.Cell(fill=uo2, region=-inner_ring_a, name='fuel inner a') + fuel_b = openmc.Cell(fill=uo2, region=+inner_ring_a & -inner_ring_b, name='fuel inner b') + fuel_c = openmc.Cell(fill=uo2, region=+inner_ring_b & -fuel_or, name='fuel inner c') + moderator_a = openmc.Cell(fill=water, region=+fuel_or & -outer_ring_a, name='moderator inner a') + moderator_b = openmc.Cell(fill=water, region=+outer_ring_a & -outer_ring_b, name='moderator outer b') + moderator_c = openmc.Cell(fill=water, region=+outer_ring_b, name='moderator outer c') + + # Create pincell universe + pincell_base = openmc.Universe() + + # Register Cells with Universe + pincell_base.add_cells([fuel_a, fuel_b, fuel_c, moderator_a, moderator_b, moderator_c]) + + # Create planes for azimuthal sectors + azimuthal_planes = [] + for i in range(8): + angle = 2 * i * openmc.pi / 8 + normal_vector = (-openmc.sin(angle), openmc.cos(angle), 0) + azimuthal_planes.append(openmc.Plane(a=normal_vector[0], b=normal_vector[1], c=normal_vector[2], d=0)) + + # Create a cell for each azimuthal sector + azimuthal_cells = [] + for i in range(8): + azimuthal_cell = openmc.Cell(name=f'azimuthal_cell_{i}') + azimuthal_cell.fill = pincell_base + azimuthal_cell.region = +azimuthal_planes[i] & -azimuthal_planes[(i+1) % 8] + azimuthal_cells.append(azimuthal_cell) + + # Create a geometry with the azimuthal universes + pincell = openmc.Universe(cells=azimuthal_cells) + + ######################################## + # Define a moderator lattice universe + + moderator_infinite = openmc.Cell(fill=water, name='moderator infinite') + mu = openmc.Universe() + mu.add_cells([moderator_infinite]) + + lattice = openmc.RectLattice() + lattice.lower_left = [-pitch/2.0, -pitch/2.0] + lattice.pitch = [pitch/10.0, pitch/10.0] + lattice.universes = np.full((10, 10), mu) + + mod_lattice_cell = openmc.Cell(fill=lattice) + + mod_lattice_uni = openmc.Universe() + + mod_lattice_uni.add_cells([mod_lattice_cell]) + + ######################################## + # Define 2x2 outer lattice + lattice2x2 = openmc.RectLattice() + lattice2x2.lower_left = (-pitch, -pitch) + lattice2x2.pitch = (pitch, pitch) + lattice2x2.universes = [ + [pincell, pincell], + [pincell, mod_lattice_uni] + ] + + ######################################## + # Define cell containing lattice and other stuff + box = openmc.model.RectangularPrism(pitch*2, pitch*2, boundary_type='reflective') + + assembly = openmc.Cell(fill=lattice2x2, region=-box, name='assembly') + + # Create a geometry with the top-level cell + geometry = openmc.Geometry([assembly]) + + ############################################################################### + # Define problem settings + + # Instantiate a Settings object, set all runtime parameters, and export to XML + settings = openmc.Settings() + settings.energy_mode = "multi-group" + settings.batches = 10 + settings.inactive = 5 + settings.particles = 100 + + # Create an initial uniform spatial source distribution over fissionable zones + lower_left = (-pitch, -pitch, -1) + upper_right = (pitch, pitch, 1) + uniform_dist = openmc.stats.Box(lower_left, upper_right) + rr_source = openmc.IndependentSource(space=uniform_dist) + + settings.random_ray['distance_active'] = 100.0 + settings.random_ray['distance_inactive'] = 20.0 + settings.random_ray['ray_source'] = rr_source + + ############################################################################### + # Define tallies + + # Create a mesh that will be used for tallying + mesh = openmc.RegularMesh() + mesh.dimension = (2, 2) + mesh.lower_left = (-pitch, -pitch) + mesh.upper_right = (pitch, pitch) + + # Create a mesh filter that can be used in a tally + mesh_filter = openmc.MeshFilter(mesh) + + # Create an energy group filter as well + energy_filter = openmc.EnergyFilter(group_edges) + + # Now use the mesh filter in a tally and indicate what scores are desired + tally = openmc.Tally(name="Mesh tally") + tally.filters = [mesh_filter, energy_filter] + tally.scores = ['flux', 'fission', 'nu-fission'] + tally.estimator = 'analog' + + # Instantiate a Tallies collection and export to XML + tallies = openmc.Tallies([tally]) + + ############################################################################### + # Exporting to OpenMC model + ############################################################################### + + model = openmc.Model() + model.geometry = geometry + model.materials = materials + model.settings = settings + model.tallies = tallies + return model + + +def test_random_ray_basic(): + harness = MGXSTestHarness('statepoint.10.h5', random_ray_model()) + harness.main() diff --git a/tests/regression_tests/random_ray_cell_density/__init__.py b/tests/regression_tests/random_ray_cell_density/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_cell_density/eigen/inputs_true.dat b/tests/regression_tests/random_ray_cell_density/eigen/inputs_true.dat deleted file mode 100644 index eacd54f83..000000000 --- a/tests/regression_tests/random_ray_cell_density/eigen/inputs_true.dat +++ /dev/null @@ -1,117 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 - - - 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 - - - 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_cell_density/eigen/results_true.dat b/tests/regression_tests/random_ray_cell_density/eigen/results_true.dat deleted file mode 100644 index 3e6ce4039..000000000 --- a/tests/regression_tests/random_ray_cell_density/eigen/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -7.606488E-01 9.025978E-03 -tally 1: -6.209503E-01 -7.732732E-02 -4.335729E-01 -3.769026E-02 -1.055230E+00 -2.232538E-01 -4.077492E-01 -3.335434E-02 -1.188353E-01 -2.833644E-03 -2.892214E-01 -1.678476E-02 -2.715245E-01 -1.488194E-02 -1.736084E-02 -6.079207E-05 -4.225281E-02 -3.600946E-04 -3.700491E-01 -2.796457E-02 -2.369715E-02 -1.145314E-04 -5.767413E-02 -6.784132E-04 -1.223083E+00 -3.058118E-01 -2.790791E-02 -1.593458E-04 -6.792309E-02 -9.438893E-04 -4.095779E+00 -3.377358E+00 -1.251201E-02 -3.153331E-05 -3.096010E-02 -1.930723E-04 -2.608638E+00 -1.361111E+00 -7.059742E-02 -9.968342E-04 -1.963632E-01 -7.711968E-03 -1.164050E+00 -2.710289E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.325486E-01 -5.675375E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.058117E-01 -1.905099E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.645650E-01 -4.428410E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.350036E+00 -3.718611E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.538916E+00 -2.521670E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.201812E+00 -9.698678E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -6.776093E-01 -9.211106E-02 -2.527022E-01 -1.280619E-02 -6.150266E-01 -7.585593E-02 -4.194143E-01 -3.528585E-02 -6.303447E-02 -7.972233E-04 -1.534133E-01 -4.722259E-03 -2.743408E-01 -1.520611E-02 -8.961769E-03 -1.621446E-05 -2.181115E-02 -9.604444E-05 -3.871710E-01 -3.063162E-02 -1.288801E-02 -3.392550E-05 -3.136683E-02 -2.009537E-04 -1.259769E+00 -3.241545E-01 -1.478360E-02 -4.466102E-05 -3.598077E-02 -2.645508E-04 -4.032169E+00 -3.273866E+00 -6.215187E-03 -7.776862E-06 -1.537904E-02 -4.761620E-05 -2.583647E+00 -1.335275E+00 -3.533526E-02 -2.498005E-04 -9.828323E-02 -1.932572E-03 -7.851145E-01 -1.234783E-01 -2.966638E-01 -1.763751E-02 -7.220204E-01 -1.044737E-01 -4.505673E-01 -4.067697E-02 -6.823342E-02 -9.332472E-04 -1.660665E-01 -5.527980E-03 -2.832534E-01 -1.626181E-02 -9.297014E-03 -1.749663E-05 -2.262707E-02 -1.036392E-04 -4.056699E-01 -3.370803E-02 -1.358439E-02 -3.774180E-05 -3.306168E-02 -2.235591E-04 -1.279744E+00 -3.345476E-01 -1.512005E-02 -4.668112E-05 -3.679962E-02 -2.765169E-04 -3.917888E+00 -3.090981E+00 -6.082371E-03 -7.449625E-06 -1.505040E-02 -4.561259E-05 -2.520906E+00 -1.271106E+00 -3.477796E-02 -2.419730E-04 -9.673314E-02 -1.872015E-03 diff --git a/tests/regression_tests/random_ray_cell_density/fs/inputs_true.dat b/tests/regression_tests/random_ray_cell_density/fs/inputs_true.dat deleted file mode 100644 index f369bae89..000000000 --- a/tests/regression_tests/random_ray_cell_density/fs/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_cell_density/fs/results_true.dat b/tests/regression_tests/random_ray_cell_density/fs/results_true.dat deleted file mode 100644 index e12f476e0..000000000 --- a/tests/regression_tests/random_ray_cell_density/fs/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -6.203077E-01 -7.706659E-02 -tally 2: -3.203448E-02 -2.058679E-04 -tally 3: -2.091970E-03 -8.765168E-07 diff --git a/tests/regression_tests/random_ray_cell_density/test.py b/tests/regression_tests/random_ray_cell_density/test.py deleted file mode 100644 index 48ebe0baa..000000000 --- a/tests/regression_tests/random_ray_cell_density/test.py +++ /dev/null @@ -1,43 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_lattice, random_ray_three_region_cube -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("run_mode", ["eigen", "fs"]) -def test_random_ray_basic(run_mode): - with change_directory(run_mode): - if run_mode == "eigen": - openmc.reset_auto_ids() - model = random_ray_lattice() - # Double the densities of the lower-left fuel pin -> cell instances [0, 8). - for id, cell in model.geometry.get_all_cells().items(): - if cell.fill.name == "UO2 fuel": - cell.density = [((i < 8) + 1.0) for i in range(24)] - - # Gold file was generated with manually scaled fuel cross sections. - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() - else: - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - # Increase the density in the source region. - for id, cell in model.geometry.get_all_cells().items(): - if cell.fill.name == "source": - cell.density = 1e3 - - # Gold file was generated with manually scaled source cross sections. - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_cell_temperature/__init__.py b/tests/regression_tests/random_ray_cell_temperature/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_cell_temperature/inputs_true.dat b/tests/regression_tests/random_ray_cell_temperature/inputs_true.dat deleted file mode 100644 index 99363ed87..000000000 --- a/tests/regression_tests/random_ray_cell_temperature/inputs_true.dat +++ /dev/null @@ -1,120 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - 395.0 395.0 395.0 395.0 395.0 395.0 395.0 395.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 - - - 395.0 395.0 395.0 395.0 395.0 395.0 395.0 395.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 - - - 395.0 395.0 395.0 395.0 395.0 395.0 395.0 395.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 295.0 - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - multi-group - nearest - 200.0 400.0 - 10.0 - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_cell_temperature/results_true.dat b/tests/regression_tests/random_ray_cell_temperature/results_true.dat deleted file mode 100644 index 50476beb6..000000000 --- a/tests/regression_tests/random_ray_cell_temperature/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -8.721099E-01 6.686066E-03 -tally 1: -1.530055E+00 -4.684582E-01 -2.918032E-01 -1.703772E-02 -7.101906E-01 -1.009209E-01 -7.732582E-01 -1.197247E-01 -5.787213E-02 -6.705930E-04 -1.408492E-01 -3.972179E-03 -4.223488E-01 -3.605283E-02 -6.818063E-03 -9.396342E-06 -1.659380E-02 -5.565812E-05 -5.958551E-01 -7.215230E-02 -9.932163E-03 -2.004773E-05 -2.417290E-02 -1.187504E-04 -1.685106E+00 -5.752729E-01 -9.834826E-03 -1.960236E-05 -2.393629E-02 -1.161151E-04 -4.400457E+00 -3.886563E+00 -3.318560E-03 -2.211175E-06 -8.211544E-03 -1.353859E-05 -2.814971E+00 -1.585202E+00 -1.876190E-02 -7.040316E-05 -5.218528E-02 -5.446713E-04 -1.970406E+00 -7.765020E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.643086E-01 -1.494764E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.421562E-01 -3.961223E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -6.421077E-01 -8.385255E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.717683E+00 -5.974687E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.024715E+00 -3.251629E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.507885E+00 -1.258277E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.237600E+00 -3.066006E-01 -4.632318E-01 -4.294997E-02 -1.127413E+00 -2.544090E-01 -7.085300E-01 -1.005838E-01 -1.066845E-01 -2.280854E-03 -2.596486E-01 -1.351037E-02 -4.080999E-01 -3.359223E-02 -1.334606E-02 -3.590848E-05 -3.248163E-02 -2.126996E-04 -5.587686E-01 -6.339264E-02 -1.868162E-02 -7.084921E-05 -4.546734E-02 -4.196670E-04 -1.647852E+00 -5.503007E-01 -1.940765E-02 -7.635704E-05 -4.723492E-02 -4.523030E-04 -4.672431E+00 -4.381400E+00 -7.228567E-03 -1.048470E-05 -1.788658E-02 -6.419579E-05 -3.054158E+00 -1.866081E+00 -4.202691E-02 -3.534383E-04 -1.168957E-01 -2.734362E-03 -1.313678E+00 -3.454374E-01 -4.964081E-01 -4.934325E-02 -1.208158E+00 -2.922789E-01 -7.298176E-01 -1.067017E-01 -1.106319E-01 -2.452869E-03 -2.692559E-01 -1.452928E-02 -4.129038E-01 -3.441066E-02 -1.357107E-02 -3.713729E-05 -3.302926E-02 -2.199783E-04 -5.677464E-01 -6.543807E-02 -1.908992E-02 -7.390190E-05 -4.646105E-02 -4.377492E-04 -1.651067E+00 -5.522453E-01 -1.956802E-02 -7.754346E-05 -4.762523E-02 -4.593308E-04 -4.583305E+00 -4.217589E+00 -7.135836E-03 -1.022408E-05 -1.765713E-02 -6.260005E-05 -2.988394E+00 -1.786305E+00 -4.141550E-02 -3.431964E-04 -1.151951E-01 -2.655125E-03 diff --git a/tests/regression_tests/random_ray_cell_temperature/test.py b/tests/regression_tests/random_ray_cell_temperature/test.py deleted file mode 100644 index ef36d9238..000000000 --- a/tests/regression_tests/random_ray_cell_temperature/test.py +++ /dev/null @@ -1,36 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_lattice, random_ray_three_region_cube -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_basic(): - openmc.reset_auto_ids() - model = random_ray_lattice(second_temp=True) - # Set the temperature of the lower-left pin to 395 K -> cell instances [0, 8). - # All other pins are set to 295. - for id, cell in model.geometry.get_all_cells().items(): - if cell.fill.name == "UO2 fuel": - cell.temperature = [(100.0 * (i < 8) + 295.0) for i in range(24)] - - model.settings.temperature = { - 'method' : 'nearest', - 'tolerance' : 10.0, - 'range' : (200.0, 400.0) - } - - # Gold file was generated with manually scaled fuel cross sections. - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_diagonal_stabilization/__init__.py b/tests/regression_tests/random_ray_diagonal_stabilization/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_diagonal_stabilization/inputs_true.dat b/tests/regression_tests/random_ray_diagonal_stabilization/inputs_true.dat deleted file mode 100644 index 0ea8c0177..000000000 --- a/tests/regression_tests/random_ray_diagonal_stabilization/inputs_true.dat +++ /dev/null @@ -1,67 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 20 - 15 - - - -0.63 -0.63 -1 0.63 0.63 1 - - - true - - - multi-group - - - - - -0.63 -0.63 -1.0 0.63 0.63 1.0 - - - - 30.0 - 150.0 - - - - - - linear - 0.5 - - - 2 2 - -0.63 -0.63 - 0.63 0.63 - - - diff --git a/tests/regression_tests/random_ray_diagonal_stabilization/results_true.dat b/tests/regression_tests/random_ray_diagonal_stabilization/results_true.dat deleted file mode 100644 index 034d7f7c6..000000000 --- a/tests/regression_tests/random_ray_diagonal_stabilization/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -7.134473E-01 1.422763E-02 diff --git a/tests/regression_tests/random_ray_diagonal_stabilization/test.py b/tests/regression_tests/random_ray_diagonal_stabilization/test.py deleted file mode 100644 index 4ea21ae1a..000000000 --- a/tests/regression_tests/random_ray_diagonal_stabilization/test.py +++ /dev/null @@ -1,63 +0,0 @@ -import os - -import openmc -from openmc.examples import pwr_pin_cell -from openmc import RegularMesh - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_diagonal_stabilization(): - # Start with a normal continuous energy model - model = pwr_pin_cell() - - # Convert to a multi-group model, with 70 group XS - # and transport correction enabled. This will generate - # MGXS data with some negatives on the diagonal, in order - # to trigger diagonal correction. - model.convert_to_multigroup( - method='material_wise', groups='CASMO-70', - particles=13, - overwrite_mgxs_library=True, mgxs_path="mgxs.h5", correction='P0' - ) - - # Convert to a random ray model - model.convert_to_random_ray() - - # Set the number of particles - model.settings.particles = 100 - - # Overlay a basic 2x2 mesh - n = 2 - mesh = RegularMesh() - mesh.dimension = (n, n) - bbox = model.geometry.bounding_box - mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1]) - mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1]) - model.settings.random_ray['source_region_meshes'] = [ - (mesh, [model.geometry.root_universe])] - - # Set the source shape to linear - model.settings.random_ray['source_shape'] = 'linear' - - # Explicitly set the diagonal stabilization rho (default is otherwise 1.0). - # Note that if we set this to 0.0 (thus distabling stabilization), the - # problem should fail due to instability, so this is actually a good test - # problem. - model.settings.random_ray['diagonal_stabilization_rho'] = 0.5 - - # If rho was 0.0, the instability would cause failure after iteration 14, - # so we go a little past that. - model.settings.inactive = 15 - model.settings.batches = 20 - - harness = MGXSTestHarness('statepoint.20.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_entropy/__init__.py b/tests/regression_tests/random_ray_entropy/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_entropy/geometry.xml b/tests/regression_tests/random_ray_entropy/geometry.xml deleted file mode 100644 index 4c87bbbfb..000000000 --- a/tests/regression_tests/random_ray_entropy/geometry.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - 12.5 12.5 12.5 - 8 8 8 - 0.0 0.0 0.0 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 - - - - - - - - diff --git a/tests/regression_tests/random_ray_entropy/materials.xml b/tests/regression_tests/random_ray_entropy/materials.xml deleted file mode 100644 index 5a6f93414..000000000 --- a/tests/regression_tests/random_ray_entropy/materials.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - mgxs.h5 - - - - - diff --git a/tests/regression_tests/random_ray_entropy/mgxs.h5 b/tests/regression_tests/random_ray_entropy/mgxs.h5 deleted file mode 100644 index 6ce80bf71..000000000 Binary files a/tests/regression_tests/random_ray_entropy/mgxs.h5 and /dev/null differ diff --git a/tests/regression_tests/random_ray_entropy/results_true.dat b/tests/regression_tests/random_ray_entropy/results_true.dat deleted file mode 100644 index 254254538..000000000 --- a/tests/regression_tests/random_ray_entropy/results_true.dat +++ /dev/null @@ -1,13 +0,0 @@ -k-combined: -1.000000E+00 0.000000E+00 -entropy: -8.863421E+00 -8.933584E+00 -8.960553E+00 -8.967921E+00 -8.976016E+00 -8.981856E+00 -8.983670E+00 -8.986584E+00 -8.987732E+00 -8.988186E+00 diff --git a/tests/regression_tests/random_ray_entropy/settings.xml b/tests/regression_tests/random_ray_entropy/settings.xml deleted file mode 100644 index 0d830417b..000000000 --- a/tests/regression_tests/random_ray_entropy/settings.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - eigenvalue - 100 - 10 - 5 - multi-group - - - - - 0.0 0.0 0.0 100.0 100.0 100.0 - - - - 40.0 - 400.0 - - diff --git a/tests/regression_tests/random_ray_entropy/test.py b/tests/regression_tests/random_ray_entropy/test.py deleted file mode 100644 index a3cba65ad..000000000 --- a/tests/regression_tests/random_ray_entropy/test.py +++ /dev/null @@ -1,33 +0,0 @@ -import glob -import os - -from openmc import StatePoint - -from tests.testing_harness import TestHarness - - -class EntropyTestHarness(TestHarness): - def _get_results(self): - """Digest info in the statepoint and return as a string.""" - # Read the statepoint file. - statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0] - with StatePoint(statepoint) as sp: - # Write out k-combined. - outstr = 'k-combined:\n' - outstr += '{:12.6E} {:12.6E}\n'.format(sp.keff.n, sp.keff.s) - - # Write out entropy data. - outstr += 'entropy:\n' - results = ['{:12.6E}'.format(x) for x in sp.entropy] - outstr += '\n'.join(results) + '\n' - - return outstr - -''' -# This test is adapted from "Monte Carlo power iteration: Entropy and spatial correlations," -M. Nowak et al. The cross sections are defined explicitly so that the value for entropy -is exactly 9 and the eigenvalue is exactly 1. -''' -def test_entropy(): - harness = EntropyTestHarness('statepoint.10.h5') - harness.main() diff --git a/tests/regression_tests/collision_track/__init__.py b/tests/regression_tests/random_ray_fixed_source/__init__.py similarity index 100% rename from tests/regression_tests/collision_track/__init__.py rename to tests/regression_tests/random_ray_fixed_source/__init__.py diff --git a/tests/regression_tests/random_ray_fixed_source/cell/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source/cell/inputs_true.dat new file mode 100644 index 000000000..99e67745a --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/cell/inputs_true.dat @@ -0,0 +1,204 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +1 1 +1 1 + +1 1 +1 1 + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +2 2 +2 2 + +2 2 +2 2 + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +3 3 +3 3 + +3 3 +3 3 + + + 10.0 10.0 10.0 + 6 10 6 + 0.0 0.0 0.0 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +8 8 8 8 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +7 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + + + + + + + + + + fixed source + 1000 + 10 + 5 + + + 100.0 1.0 + + + cell + 4 + + + multi-group + + 400.0 + 100.0 + + + 0.0 0.0 0.0 60.0 100.0 60.0 + + + + + + + 1 10 1 + 0.0 0.0 0.0 + 10.0 100.0 10.0 + + + 6 1 1 + 0.0 50.0 0.0 + 60.0 60.0 10.0 + + + 6 1 1 + 0.0 90.0 30.0 + 60.0 100.0 40.0 + + + 1 + + + 2 + + + 3 + + + 1 + flux + analog + + + 2 + flux + analog + + + 3 + flux + analog + + + diff --git a/tests/regression_tests/random_ray_fixed_source/cell/results_true.dat b/tests/regression_tests/random_ray_fixed_source/cell/results_true.dat new file mode 100644 index 000000000..df923ab23 --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/cell/results_true.dat @@ -0,0 +1,47 @@ +tally 1: +3.751048E+01 +2.841797E+02 +9.930788E+00 +1.988180E+01 +3.781121E+00 +3.005165E+00 +2.383139E+00 +1.232560E+00 +1.561884E+00 +6.440577E-01 +1.089787E+00 +3.724896E-01 +6.608456E-01 +1.285592E-01 +2.372611E-01 +1.601299E-02 +7.814803E-02 +1.765829E-03 +2.862108E-02 +2.460129E-04 +tally 2: +1.089787E+00 +3.724896E-01 +3.767926E-01 +3.724399E-02 +8.614121E-02 +1.526889E-03 +3.610725E-02 +2.629885E-04 +1.466261E-02 +4.536997E-05 +4.653106E-03 +4.381672E-06 +tally 3: +1.617918E-03 +6.317049E-07 +1.161473E-03 +2.789553E-07 +1.198879E-03 +3.189531E-07 +1.031737E-03 +2.207381E-07 +5.466329E-04 +6.166808E-08 +2.146062E-04 +9.937520E-09 diff --git a/tests/regression_tests/random_ray_fixed_source/material/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source/material/inputs_true.dat new file mode 100644 index 000000000..7fde0c419 --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/material/inputs_true.dat @@ -0,0 +1,204 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +1 1 +1 1 + +1 1 +1 1 + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +2 2 +2 2 + +2 2 +2 2 + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +3 3 +3 3 + +3 3 +3 3 + + + 10.0 10.0 10.0 + 6 10 6 + 0.0 0.0 0.0 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +8 8 8 8 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +7 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + + + + + + + + + + fixed source + 1000 + 10 + 5 + + + 100.0 1.0 + + + material + 1 + + + multi-group + + 400.0 + 100.0 + + + 0.0 0.0 0.0 60.0 100.0 60.0 + + + + + + + 1 10 1 + 0.0 0.0 0.0 + 10.0 100.0 10.0 + + + 6 1 1 + 0.0 50.0 0.0 + 60.0 60.0 10.0 + + + 6 1 1 + 0.0 90.0 30.0 + 60.0 100.0 40.0 + + + 1 + + + 2 + + + 3 + + + 1 + flux + analog + + + 2 + flux + analog + + + 3 + flux + analog + + + diff --git a/tests/regression_tests/random_ray_fixed_source/material/results_true.dat b/tests/regression_tests/random_ray_fixed_source/material/results_true.dat new file mode 100644 index 000000000..e3d528909 --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/material/results_true.dat @@ -0,0 +1,47 @@ +tally 1: +3.751047E+01 +2.841797E+02 +9.930788E+00 +1.988181E+01 +3.781121E+00 +3.005165E+00 +2.383139E+00 +1.232560E+00 +1.561884E+00 +6.440577E-01 +1.089787E+00 +3.724896E-01 +6.608456E-01 +1.285592E-01 +2.372611E-01 +1.601299E-02 +7.814803E-02 +1.765829E-03 +2.862108E-02 +2.460129E-04 +tally 2: +1.089787E+00 +3.724896E-01 +3.767925E-01 +3.724398E-02 +8.614120E-02 +1.526889E-03 +3.610725E-02 +2.629885E-04 +1.466261E-02 +4.536997E-05 +4.653106E-03 +4.381672E-06 +tally 3: +1.617918E-03 +6.317049E-07 +1.161473E-03 +2.789553E-07 +1.198879E-03 +3.189531E-07 +1.031737E-03 +2.207381E-07 +5.466329E-04 +6.166809E-08 +2.146062E-04 +9.937520E-09 diff --git a/tests/regression_tests/random_ray_fixed_source/test.py b/tests/regression_tests/random_ray_fixed_source/test.py new file mode 100644 index 000000000..41a6c35bb --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/test.py @@ -0,0 +1,339 @@ +import os + +import numpy as np +import openmc +from openmc.utility_funcs import change_directory +import pytest + +from tests.testing_harness import TolerantPyAPITestHarness + +def fill_3d_list(n, val): + """ + Generates a 3D list of dimensions nxnxn filled with copies of val. + + Parameters: + n (int): The dimension of the 3D list. + val (any): The value to fill the 3D list with. + + Returns: + list: A 3D list of dimensions nxnxn filled with val. + """ + return [[[val for _ in range(n)] for _ in range(n)] for _ in range(n)] + + +class MGXSTestHarness(TolerantPyAPITestHarness): + def _cleanup(self): + super()._cleanup() + f = 'mgxs.h5' + if os.path.exists(f): + os.remove(f) + +def create_random_ray_model(domain_type): + openmc.reset_auto_ids() + ############################################################################### + # Create multigroup data + + # Instantiate the energy group data + ebins = [1e-5, 20.0e6] + groups = openmc.mgxs.EnergyGroups(group_edges=ebins) + + # High scattering ratio means system is all scattering + # Low means fully absorbing + scattering_ratio = 0.5 + + source_total_xs = 0.1 + source_mat_data = openmc.XSdata('source', groups) + source_mat_data.order = 0 + source_mat_data.set_total([source_total_xs]) + source_mat_data.set_absorption([source_total_xs * (1.0 - scattering_ratio)]) + source_mat_data.set_scatter_matrix(np.rollaxis(np.array([[[source_total_xs * scattering_ratio]]]),0,3)) + + void_total_xs = 1.0e-4 + void_mat_data = openmc.XSdata('void', groups) + void_mat_data.order = 0 + void_mat_data.set_total([void_total_xs]) + void_mat_data.set_absorption([void_total_xs * (1.0 - scattering_ratio)]) + void_mat_data.set_scatter_matrix(np.rollaxis(np.array([[[void_total_xs * scattering_ratio]]]),0,3)) + + shield_total_xs = 0.1 + shield_mat_data = openmc.XSdata('shield', groups) + shield_mat_data.order = 0 + shield_mat_data.set_total([shield_total_xs]) + shield_mat_data.set_absorption([shield_total_xs * (1.0 - scattering_ratio)]) + shield_mat_data.set_scatter_matrix(np.rollaxis(np.array([[[shield_total_xs * scattering_ratio]]]),0,3)) + + mg_cross_sections_file = openmc.MGXSLibrary(groups) + mg_cross_sections_file.add_xsdatas([source_mat_data, void_mat_data, shield_mat_data]) + mg_cross_sections_file.export_to_hdf5() + + ############################################################################### + # Create materials for the problem + + # Instantiate some Macroscopic Data + source_data = openmc.Macroscopic('source') + void_data = openmc.Macroscopic('void') + shield_data = openmc.Macroscopic('shield') + + # Instantiate some Materials and register the appropriate Macroscopic objects + source_mat = openmc.Material(name='source') + source_mat.set_density('macro', 1.0) + source_mat.add_macroscopic(source_data) + + void_mat = openmc.Material(name='void') + void_mat.set_density('macro', 1.0) + void_mat.add_macroscopic(void_data) + + shield_mat = openmc.Material(name='shield') + shield_mat.set_density('macro', 1.0) + shield_mat.add_macroscopic(shield_data) + + # Instantiate a Materials collection and export to XML + materials_file = openmc.Materials([source_mat, void_mat, shield_mat]) + materials_file.cross_sections = "mgxs.h5" + + ############################################################################### + # Define problem geometry + + source_cell = openmc.Cell(fill=source_mat, name='infinite source region') + void_cell = openmc.Cell(fill=void_mat, name='infinite void region') + shield_cell = openmc.Cell(fill=shield_mat, name='infinite shield region') + + sub = openmc.Universe() + sub.add_cells([source_cell]) + + vub = openmc.Universe() + vub.add_cells([void_cell]) + + aub = openmc.Universe() + aub.add_cells([shield_cell]) + + # n controls the dimension of subdivision within each outer lattice element + # E.g., n = 10 results in 1cm cubic FSRs + n = 2 + delta = 10.0 / n + ll = [-5.0, -5.0, -5.0] + pitch = [delta, delta, delta] + + source_lattice = openmc.RectLattice() + source_lattice.lower_left = ll + source_lattice.pitch = pitch + source_lattice.universes = fill_3d_list(n, sub) + + void_lattice = openmc.RectLattice() + void_lattice.lower_left = ll + void_lattice.pitch = pitch + void_lattice.universes = fill_3d_list(n, vub) + + shield_lattice = openmc.RectLattice() + shield_lattice.lower_left = ll + shield_lattice.pitch = pitch + shield_lattice.universes = fill_3d_list(n, aub) + + source_lattice_cell = openmc.Cell(fill=source_lattice, name='source lattice cell') + su = openmc.Universe() + su.add_cells([source_lattice_cell]) + + void_lattice_cell = openmc.Cell(fill=void_lattice, name='void lattice cell') + vu = openmc.Universe() + vu.add_cells([void_lattice_cell]) + + shield_lattice_cell = openmc.Cell(fill=shield_lattice, name='shield lattice cell') + au = openmc.Universe() + au.add_cells([shield_lattice_cell]) + + z_base = [ + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [vu, vu, vu, vu, au, au], + [vu, au, au, au, au, au], + [vu, au, au, au, au, au], + [vu, au, au, au, au, au], + [vu, au, au, au, au, au], + [su, au, au, au, au, au] + ] + + z_col = [ + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, vu, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au] + ] + + z_high = [ + [au, au, au, vu, au, au], + [au, au, au, vu, au, au], + [au, au, au, vu, au, au], + [au, au, au, vu, au, au], + [au, au, au, vu, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au] + ] + + z_cap = [ + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au], + [au, au, au, au, au, au] + ] + + dogleg_pattern = [ + z_base, + z_col, + z_col, + z_high, + z_cap, + z_cap + ] + + x = 60.0 + x_dim = 6 + + y = 100.0 + y_dim = 10 + + z = 60.0 + z_dim = 6 + + lattice = openmc.RectLattice() + lattice.lower_left = [0.0, 0.0, 0.0] + lattice.pitch = [x/x_dim, y/y_dim, z/z_dim] + lattice.universes = dogleg_pattern + + lattice_cell = openmc.Cell(fill=lattice, name='dogleg lattice cell') + + lattice_uni = openmc.Universe() + lattice_uni.add_cells([lattice_cell]) + + x_low = openmc.XPlane(x0=0.0,boundary_type='reflective') + x_high = openmc.XPlane(x0=x,boundary_type='vacuum') + + y_low = openmc.YPlane(y0=0.0,boundary_type='reflective') + y_high = openmc.YPlane(y0=y,boundary_type='vacuum') + + z_low = openmc.ZPlane(z0=0.0,boundary_type='reflective') + z_high = openmc.ZPlane(z0=z,boundary_type='vacuum') + + full_domain = openmc.Cell(fill=lattice_uni, region=+x_low & -x_high & +y_low & -y_high & +z_low & -z_high, name='full domain') + + root = openmc.Universe(name='root universe') + root.add_cell(full_domain) + + # Create a geometry with the two cells and export to XML + geometry = openmc.Geometry(root) + + ############################################################################### + # Define problem settings + + # Instantiate a Settings object, set all runtime parameters, and export to XML + settings = openmc.Settings() + settings.energy_mode = "multi-group" + settings.batches = 10 + settings.inactive = 5 + settings.particles = 1000 + settings.run_mode = 'fixed source' + + settings.random_ray['distance_active'] = 400.0 + settings.random_ray['distance_inactive'] = 100.0 + + # Create an initial uniform spatial source for ray integration + lower_left = (0.0, 0.0, 0.0) + upper_right = (x, y, z) + uniform_dist = openmc.stats.Box(lower_left, upper_right) + settings.random_ray['ray_source']= openmc.IndependentSource(space=uniform_dist) + + # Create the neutron source in the bottom right of the moderator + strengths = [1.0] + midpoints = [100.0] + energy_distribution = openmc.stats.Discrete(x=midpoints,p=strengths) + if domain_type == 'cell': + domain = source_lattice_cell + elif domain_type == 'material': + domain = source_mat + elif domain_type == 'universe': + domain = sub + source = openmc.IndependentSource( + energy=energy_distribution, + constraints={'domains': [domain]} + ) + settings.source = [source] + + ############################################################################### + # Define tallies + + estimator = 'analog' + + # Case 3A + mesh_3A = openmc.RegularMesh() + mesh_3A.dimension = (1, y_dim, 1) + mesh_3A.lower_left = (0.0, 0.0, 0.0) + mesh_3A.upper_right = (10.0, y, 10.0) + mesh_filter_3A = openmc.MeshFilter(mesh_3A) + + tally_3A = openmc.Tally(name="Case 3A") + tally_3A.filters = [mesh_filter_3A] + tally_3A.scores = ['flux'] + tally_3A.estimator = estimator + + # Case 3B + mesh_3B = openmc.RegularMesh() + mesh_3B.dimension = (x_dim, 1, 1) + mesh_3B.lower_left = (0.0, 50.0, 0.0) + mesh_3B.upper_right = (x, 60.0, 10.0) + mesh_filter_3B = openmc.MeshFilter(mesh_3B) + + tally_3B = openmc.Tally(name="Case 3B") + tally_3B.filters = [mesh_filter_3B] + tally_3B.scores = ['flux'] + tally_3B.estimator = estimator + + # Case 3C + mesh_3C = openmc.RegularMesh() + mesh_3C.dimension = (x_dim, 1, 1) + mesh_3C.lower_left = (0.0, 90.0, 30.0) + mesh_3C.upper_right = (x, 100.0, 40.0) + mesh_filter_3C = openmc.MeshFilter(mesh_3C) + + tally_3C = openmc.Tally(name="Case 3C") + tally_3C.filters = [mesh_filter_3C] + tally_3C.scores = ['flux'] + tally_3C.estimator = estimator + + # Instantiate a Tallies collection and export to XML + tallies = openmc.Tallies([tally_3A, tally_3B, tally_3C]) + + ############################################################################### + # Assmble Model + + model = openmc.model.Model() + model.geometry = geometry + model.materials = materials_file + model.settings = settings + model.xs_data = mg_cross_sections_file + model.tallies = tallies + + return model + +@pytest.mark.parametrize("domain_type", ["cell", "material", "universe"]) +def test_random_ray_fixed_source(domain_type): + with change_directory(domain_type): + model = create_random_ray_model(domain_type) + + harness = MGXSTestHarness('statepoint.10.h5', model) + harness.main() diff --git a/tests/regression_tests/random_ray_fixed_source/universe/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source/universe/inputs_true.dat new file mode 100644 index 000000000..349917fee --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/universe/inputs_true.dat @@ -0,0 +1,204 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +1 1 +1 1 + +1 1 +1 1 + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +2 2 +2 2 + +2 2 +2 2 + + + 5.0 5.0 5.0 + 2 2 2 + -5.0 -5.0 -5.0 + +3 3 +3 3 + +3 3 +3 3 + + + 10.0 10.0 10.0 + 6 10 6 + 0.0 0.0 0.0 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +8 8 8 8 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +8 9 9 9 9 9 +7 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 8 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 + + + + + + + + + + fixed source + 1000 + 10 + 5 + + + 100.0 1.0 + + + universe + 1 + + + multi-group + + 400.0 + 100.0 + + + 0.0 0.0 0.0 60.0 100.0 60.0 + + + + + + + 1 10 1 + 0.0 0.0 0.0 + 10.0 100.0 10.0 + + + 6 1 1 + 0.0 50.0 0.0 + 60.0 60.0 10.0 + + + 6 1 1 + 0.0 90.0 30.0 + 60.0 100.0 40.0 + + + 1 + + + 2 + + + 3 + + + 1 + flux + analog + + + 2 + flux + analog + + + 3 + flux + analog + + + diff --git a/tests/regression_tests/random_ray_fixed_source/universe/results_true.dat b/tests/regression_tests/random_ray_fixed_source/universe/results_true.dat new file mode 100644 index 000000000..36d24e939 --- /dev/null +++ b/tests/regression_tests/random_ray_fixed_source/universe/results_true.dat @@ -0,0 +1,47 @@ +tally 1: +3.751047E+01 +2.841797E+02 +9.930788E+00 +1.988180E+01 +3.781121E+00 +3.005165E+00 +2.383139E+00 +1.232560E+00 +1.561884E+00 +6.440577E-01 +1.089787E+00 +3.724896E-01 +6.608456E-01 +1.285592E-01 +2.372611E-01 +1.601299E-02 +7.814803E-02 +1.765829E-03 +2.862107E-02 +2.460129E-04 +tally 2: +1.089787E+00 +3.724896E-01 +3.767926E-01 +3.724399E-02 +8.614120E-02 +1.526889E-03 +3.610725E-02 +2.629885E-04 +1.466261E-02 +4.536997E-05 +4.653106E-03 +4.381672E-06 +tally 3: +1.617918E-03 +6.317049E-07 +1.161473E-03 +2.789553E-07 +1.198879E-03 +3.189531E-07 +1.031737E-03 +2.207381E-07 +5.466329E-04 +6.166808E-08 +2.146062E-04 +9.937520E-09 diff --git a/tests/regression_tests/random_ray_fixed_source_domain/__init__.py b/tests/regression_tests/random_ray_fixed_source_domain/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_fixed_source_domain/cell/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_domain/cell/inputs_true.dat deleted file mode 100644 index d650bbaf9..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/cell/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - cell - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_domain/cell/results_true.dat b/tests/regression_tests/random_ray_fixed_source_domain/cell/results_true.dat deleted file mode 100644 index 6da51a711..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/cell/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.934460E-01 -7.058894E-02 -tally 2: -3.206214E-02 -2.063370E-04 -tally 3: -2.096411E-03 -8.804924E-07 diff --git a/tests/regression_tests/random_ray_fixed_source_domain/material/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_domain/material/inputs_true.dat deleted file mode 100644 index 98a51add1..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/material/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - material - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_domain/material/results_true.dat b/tests/regression_tests/random_ray_fixed_source_domain/material/results_true.dat deleted file mode 100644 index 6da51a711..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/material/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.934460E-01 -7.058894E-02 -tally 2: -3.206214E-02 -2.063370E-04 -tally 3: -2.096411E-03 -8.804924E-07 diff --git a/tests/regression_tests/random_ray_fixed_source_domain/test.py b/tests/regression_tests/random_ray_fixed_source_domain/test.py deleted file mode 100644 index 5885a9200..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/test.py +++ /dev/null @@ -1,51 +0,0 @@ -import os - -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("domain_type", ["cell", "material", "universe"]) -def test_random_ray_fixed_source(domain_type): - with change_directory(domain_type): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - - # Based on the parameter, we need to adjust - # the particle source constraints - source = model.settings.source[0] - constraints = source.constraints - - if domain_type == 'cell': - cells = model.geometry.get_all_cells() - for key, cell in cells.items(): - print(cell.name) - if cell.name == 'infinite source region': - constraints['domain_type'] = 'cell' - constraints['domain_ids'] = [cell.id] - elif domain_type == 'material': - materials = model.materials - for material in materials: - if material.name == 'source': - constraints['domain_type'] = 'material' - constraints['domain_ids'] = [material.id] - elif domain_type == 'universe': - universes = model.geometry.get_all_universes() - for key, universe in universes.items(): - if universe.name == 'source universe': - constraints['domain_type'] = 'universe' - constraints['domain_ids'] = [universe.id] - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_fixed_source_domain/universe/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_domain/universe/inputs_true.dat deleted file mode 100644 index 20deba664..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/universe/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_domain/universe/results_true.dat b/tests/regression_tests/random_ray_fixed_source_domain/universe/results_true.dat deleted file mode 100644 index 6da51a711..000000000 --- a/tests/regression_tests/random_ray_fixed_source_domain/universe/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.934460E-01 -7.058894E-02 -tally 2: -3.206214E-02 -2.063370E-04 -tally 3: -2.096411E-03 -8.804924E-07 diff --git a/tests/regression_tests/random_ray_fixed_source_linear/__init__.py b/tests/regression_tests/random_ray_fixed_source_linear/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_fixed_source_linear/linear/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_linear/linear/inputs_true.dat deleted file mode 100644 index 2268d82c3..000000000 --- a/tests/regression_tests/random_ray_fixed_source_linear/linear/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - linear - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_linear/linear/results_true.dat b/tests/regression_tests/random_ray_fixed_source_linear/linear/results_true.dat deleted file mode 100644 index e90d6bfdc..000000000 --- a/tests/regression_tests/random_ray_fixed_source_linear/linear/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.339086E+00 -2.747305E-01 -tally 2: -1.089827E-01 -6.069324E-04 -tally 3: -7.300831E-03 -2.715940E-06 diff --git a/tests/regression_tests/random_ray_fixed_source_linear/linear_xy/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_linear/linear_xy/inputs_true.dat deleted file mode 100644 index fe95baa7b..000000000 --- a/tests/regression_tests/random_ray_fixed_source_linear/linear_xy/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - linear_xy - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_linear/linear_xy/results_true.dat b/tests/regression_tests/random_ray_fixed_source_linear/linear_xy/results_true.dat deleted file mode 100644 index f4c8546aa..000000000 --- a/tests/regression_tests/random_ray_fixed_source_linear/linear_xy/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.335703E+00 -2.742866E-01 -tally 2: -1.081884E-01 -5.983316E-04 -tally 3: -7.295389E-03 -2.711859E-06 diff --git a/tests/regression_tests/random_ray_fixed_source_linear/test.py b/tests/regression_tests/random_ray_fixed_source_linear/test.py deleted file mode 100644 index 99211024e..000000000 --- a/tests/regression_tests/random_ray_fixed_source_linear/test.py +++ /dev/null @@ -1,29 +0,0 @@ -import os - -import numpy as np -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("shape", ["linear", "linear_xy"]) -def test_random_ray_fixed_source_linear(shape): - with change_directory(shape): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - model.settings.random_ray['source_shape'] = shape - model.settings.inactive = 20 - model.settings.batches = 40 - harness = MGXSTestHarness('statepoint.40.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_fixed_source_mesh/__init__.py b/tests/regression_tests/random_ray_fixed_source_mesh/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_fixed_source_mesh/flat/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_mesh/flat/inputs_true.dat deleted file mode 100644 index a5632ece9..000000000 --- a/tests/regression_tests/random_ray_fixed_source_mesh/flat/inputs_true.dat +++ /dev/null @@ -1,273 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 30 - 15 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - - - - - - - - flat - - - 24 24 24 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 36 36 36 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 30 30 30 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_mesh/flat/results_true.dat b/tests/regression_tests/random_ray_fixed_source_mesh/flat/results_true.dat deleted file mode 100644 index 0b0eaa447..000000000 --- a/tests/regression_tests/random_ray_fixed_source_mesh/flat/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -1.750296E+00 -2.051829E-01 -tally 2: -8.045199E-02 -4.384408E-04 -tally 3: -5.216828E-03 -1.840861E-06 diff --git a/tests/regression_tests/random_ray_fixed_source_mesh/linear/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_mesh/linear/inputs_true.dat deleted file mode 100644 index 9d22603c6..000000000 --- a/tests/regression_tests/random_ray_fixed_source_mesh/linear/inputs_true.dat +++ /dev/null @@ -1,273 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 30 - 15 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - - - - - - - - linear - - - 24 24 24 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 36 36 36 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 30 30 30 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_mesh/linear/results_true.dat b/tests/regression_tests/random_ray_fixed_source_mesh/linear/results_true.dat deleted file mode 100644 index 23754a157..000000000 --- a/tests/regression_tests/random_ray_fixed_source_mesh/linear/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -1.780361E+00 -2.137912E-01 -tally 2: -8.230400E-02 -4.596391E-04 -tally 3: -5.207797E-03 -1.834531E-06 diff --git a/tests/regression_tests/random_ray_fixed_source_mesh/test.py b/tests/regression_tests/random_ray_fixed_source_mesh/test.py deleted file mode 100644 index 0b93b2a7a..000000000 --- a/tests/regression_tests/random_ray_fixed_source_mesh/test.py +++ /dev/null @@ -1,53 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_three_region_cube -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def make_mesh(dim): - width = 30.0 - mesh = openmc.RegularMesh() - mesh.dimension = (dim, dim, dim) - mesh.lower_left = (0.0, 0.0, 0.0) - mesh.upper_right = (width, width, width) - return mesh - - -@pytest.mark.parametrize("shape", ["flat", "linear"]) -def test_random_ray_fixed_source_mesh(shape): - with change_directory(shape): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - - # We will apply three different mesh resolutions to three different domain types - source_universe = model.geometry.get_universes_by_name('source universe')[0] - void_cell = model.geometry.get_cells_by_name('infinite void region')[0] - absorber_mat = model.geometry.get_materials_by_name('absorber')[0] - - model.settings.random_ray['source_region_meshes'] = [ - (make_mesh(24), [source_universe]), - (make_mesh(36), [void_cell]), - (make_mesh(30), [absorber_mat]) - ] - - # We also test flat/linear source shapes to ensure they are both - # working correctly with the mesh overlay logic - model.settings.random_ray['source_shape'] = shape - - model.settings.inactive = 15 - model.settings.batches = 30 - - harness = MGXSTestHarness('statepoint.30.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_fixed_source_normalization/False/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_normalization/False/inputs_true.dat deleted file mode 100644 index de941f10f..000000000 --- a/tests/regression_tests/random_ray_fixed_source_normalization/False/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - false - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_normalization/False/results_true.dat b/tests/regression_tests/random_ray_fixed_source_normalization/False/results_true.dat deleted file mode 100644 index d8f78493c..000000000 --- a/tests/regression_tests/random_ray_fixed_source_normalization/False/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -6.840321E+01 -9.376316E+02 -tally 2: -4.976182E+02 -4.970407E+04 -tally 3: -2.382441E+01 -1.137148E+02 diff --git a/tests/regression_tests/random_ray_fixed_source_normalization/True/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_normalization/True/inputs_true.dat deleted file mode 100644 index 20deba664..000000000 --- a/tests/regression_tests/random_ray_fixed_source_normalization/True/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_fixed_source_normalization/True/results_true.dat b/tests/regression_tests/random_ray_fixed_source_normalization/True/results_true.dat deleted file mode 100644 index 6da51a711..000000000 --- a/tests/regression_tests/random_ray_fixed_source_normalization/True/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.934460E-01 -7.058894E-02 -tally 2: -3.206214E-02 -2.063370E-04 -tally 3: -2.096411E-03 -8.804924E-07 diff --git a/tests/regression_tests/random_ray_fixed_source_normalization/__init__.py b/tests/regression_tests/random_ray_fixed_source_normalization/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_fixed_source_normalization/test.py b/tests/regression_tests/random_ray_fixed_source_normalization/test.py deleted file mode 100644 index 3fa4ba2a6..000000000 --- a/tests/regression_tests/random_ray_fixed_source_normalization/test.py +++ /dev/null @@ -1,27 +0,0 @@ -import os - -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("normalize", [True, False]) -def test_random_ray_fixed_source(normalize): - with change_directory(str(normalize)): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - model.settings.random_ray['volume_normalized_flux_tallies'] = normalize - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_fixed_source_subcritical/__init__.py b/tests/regression_tests/random_ray_fixed_source_subcritical/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_fixed_source_subcritical/flat/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_subcritical/flat/inputs_true.dat deleted file mode 100644 index 943468a10..000000000 --- a/tests/regression_tests/random_ray_fixed_source_subcritical/flat/inputs_true.dat +++ /dev/null @@ -1,142 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 9 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 12 -12 13 - - - - - - - - - - - - - - - - - - - - - fixed source - 30 - 125 - 100 - - - 1.134 -1.26 -1.0 1.26 -1.134 1.0 - - - 2e-05 0.0735 20.0 200.0 2000.0 750000.0 2000000.0 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 - - - universe - 9 - - - multi-group - - 40.0 - 40.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - false - flat - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_fixed_source_subcritical/flat/results_true.dat b/tests/regression_tests/random_ray_fixed_source_subcritical/flat/results_true.dat deleted file mode 100644 index 4d2fb6c57..000000000 --- a/tests/regression_tests/random_ray_fixed_source_subcritical/flat/results_true.dat +++ /dev/null @@ -1,169 +0,0 @@ -tally 1: -1.591301E+02 -1.016825E+03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.916980E+01 -1.404518E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.036992E+01 -1.662864E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.464728E+01 -2.434669E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.260923E+01 -1.109616E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.443775E+01 -3.580658E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.708323E+01 -1.318058E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.004495E+02 -1.610586E+03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -7.321594E+01 -2.147152E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.573858E+01 -2.655227E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.944079E+01 -3.474938E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.758548E+01 -1.328297E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.536577E+01 -3.644652E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.824884E+01 -1.368347E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.073355E+02 -4.630895E+02 -1.263975E+01 -6.427678E+00 -3.076263E+01 -3.807359E+01 -4.995302E+01 -1.001379E+02 -2.355060E+00 -2.226283E-01 -5.731746E+00 -1.318712E+00 -1.959843E+01 -1.538887E+01 -2.005479E-01 -1.611455E-03 -4.880935E-01 -9.545263E-03 -2.315398E+01 -2.148264E+01 -2.441408E-01 -2.388612E-03 -5.941898E-01 -1.414866E-02 -5.319554E+01 -1.134034E+02 -1.967517E-01 -1.551313E-03 -4.788601E-01 -9.189243E-03 -1.192041E+02 -5.698491E+02 -5.811654E-02 -1.356369E-04 -1.438053E-01 -8.304781E-04 -8.044764E+01 -2.602455E+02 -3.474828E-01 -4.908566E-03 -9.665057E-01 -3.797493E-02 -1.561720E+02 -9.788256E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.840869E+01 -1.368656E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.029506E+01 -1.650985E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.467632E+01 -2.440891E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.301033E+01 -1.126277E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.608414E+01 -3.702737E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.881578E+01 -1.396463E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 diff --git a/tests/regression_tests/random_ray_fixed_source_subcritical/linear_xy/inputs_true.dat b/tests/regression_tests/random_ray_fixed_source_subcritical/linear_xy/inputs_true.dat deleted file mode 100644 index 650953c4b..000000000 --- a/tests/regression_tests/random_ray_fixed_source_subcritical/linear_xy/inputs_true.dat +++ /dev/null @@ -1,142 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 8 -8 8 8 8 8 8 8 8 8 9 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 12 -12 13 - - - - - - - - - - - - - - - - - - - - - fixed source - 30 - 125 - 100 - - - 1.134 -1.26 -1.0 1.26 -1.134 1.0 - - - 2e-05 0.0735 20.0 200.0 2000.0 750000.0 2000000.0 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 0.14285714285714285 - - - universe - 9 - - - multi-group - - 40.0 - 40.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - false - linear_xy - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_fixed_source_subcritical/linear_xy/results_true.dat b/tests/regression_tests/random_ray_fixed_source_subcritical/linear_xy/results_true.dat deleted file mode 100644 index bf602d3e2..000000000 --- a/tests/regression_tests/random_ray_fixed_source_subcritical/linear_xy/results_true.dat +++ /dev/null @@ -1,169 +0,0 @@ -tally 1: -1.583465E+02 -1.007029E+03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.891526E+01 -1.392807E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.028338E+01 -1.649224E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.453687E+01 -2.413498E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.235813E+01 -1.099243E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.394406E+01 -3.543513E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.676284E+01 -1.303104E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.007858E+02 -1.616216E+03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -7.319709E+01 -2.146301E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.566730E+01 -2.640697E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.934703E+01 -3.453026E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.737215E+01 -1.318580E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.495275E+01 -3.613373E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.799251E+01 -1.356178E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.066414E+02 -4.570291E+02 -1.254014E+01 -6.325641E+00 -3.052020E+01 -3.746918E+01 -4.977302E+01 -9.940548E+01 -2.345790E+00 -2.208444E-01 -5.709184E+00 -1.308146E+00 -1.953082E+01 -1.528292E+01 -1.998234E-01 -1.599792E-03 -4.863302E-01 -9.476180E-03 -2.307196E+01 -2.133059E+01 -2.432481E-01 -2.371074E-03 -5.920173E-01 -1.404478E-02 -5.299863E+01 -1.125576E+02 -1.959914E-01 -1.539191E-03 -4.770098E-01 -9.117441E-03 -1.186133E+02 -5.641060E+02 -5.781230E-02 -1.341759E-04 -1.430525E-01 -8.215327E-04 -7.995734E+01 -2.570099E+02 -3.452934E-01 -4.844059E-03 -9.604162E-01 -3.747587E-02 -1.556795E+02 -9.726232E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.816726E+01 -1.357531E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.018480E+01 -1.633551E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.453476E+01 -2.413615E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.269380E+01 -1.113102E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.550216E+01 -3.658264E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.846320E+01 -1.379625E+02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 diff --git a/tests/regression_tests/random_ray_fixed_source_subcritical/test.py b/tests/regression_tests/random_ray_fixed_source_subcritical/test.py deleted file mode 100644 index e2f3cf175..000000000 --- a/tests/regression_tests/random_ray_fixed_source_subcritical/test.py +++ /dev/null @@ -1,133 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_lattice -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("shape", ["flat", "linear_xy"]) -def test_random_ray_fixed_source_subcritical(shape): - with change_directory(shape): - openmc.reset_auto_ids() - - # The general strategy is to reuse the random_ray_lattice model, - # but redfine some of the geometry to make it a good - # subcritical multiplication problem. We then also add in - # a fixed source term. - - model = random_ray_lattice() - - # Begin by updating the random ray settings for fixed source - settings = model.settings - settings.random_ray['source_shape'] = shape - settings.run_mode = 'fixed source' - settings.particles = 30 - settings.random_ray['distance_active'] = 40.0 - settings.random_ray['distance_inactive'] = 40.0 - settings.random_ray['volume_normalized_flux_tallies'] = False - - # This problem needs about 2k iterations to converge, - # but for regression testing we only need a few hundred - # to ensure things are working as expected. With - # only 100 inactive batches, tallies will still be off - # by 3x or more. For validation against MGMC, be sure - # to increase the batch counts. - settings.batches = 125 - settings.inactive = 100 - - ######################################## - # Define the alternative geometry - - pitch = 1.26 - - for material in model.materials: - if material.name == 'Water': - water = material - - # The new geometry replaces two of the fuel pins with - # moderator, reducing k-eff to around 0.84. We also - # add a special universe in the corner of one of the moderator - # regions to use as a domain constraint for the source - moderator_infinite = openmc.Cell(fill=water, name='moderator infinite') - mu = openmc.Universe(cells=[moderator_infinite]) - - moderator_infinite2 = openmc.Cell(fill=water, name='moderator infinite 2') - mu2 = openmc.Universe(cells=[moderator_infinite2]) - - n_sub = 10 - - lattice = openmc.RectLattice() - lattice.lower_left = [-pitch/2.0, -pitch/2.0] - lattice.pitch = [pitch/n_sub, pitch/n_sub] - lattice.universes = [[mu] * n_sub for _ in range(n_sub)] - - lattice2 = openmc.RectLattice() - lattice2.lower_left = [-pitch/2.0, -pitch/2.0] - lattice2.pitch = [pitch/n_sub, pitch/n_sub] - lattice2.universes = [[mu] * n_sub for _ in range(n_sub)] - lattice2.universes[n_sub-1][n_sub-1] = mu2 - - mod_lattice_cell = openmc.Cell(fill=lattice) - mod_lattice_uni = openmc.Universe(cells=[mod_lattice_cell]) - - mod_lattice_cell2 = openmc.Cell(fill=lattice2) - mod_lattice_uni2 = openmc.Universe(cells=[mod_lattice_cell2]) - - lattice2x2 = openmc.RectLattice() - lattice2x2.lower_left = [-pitch, -pitch] - lattice2x2.pitch = [pitch, pitch] - - universes = model.geometry.get_all_universes() - for universe in universes.values(): - if universe.name == 'pincell': - pincell = universe - - lattice2x2.universes = [ - [pincell, mod_lattice_uni], - [mod_lattice_uni, mod_lattice_uni2] - ] - - box = openmc.model.RectangularPrism( - pitch*2, pitch*2, boundary_type='reflective') - - assembly = openmc.Cell(fill=lattice2x2, region=-box, name='assembly') - - root = openmc.Universe(name='root universe', cells=[assembly]) - model.geometry = openmc.Geometry(root) - - ######################################## - # Define the fixed source term - - s = 1.0 / 7.0 - strengths = [s, s, s, s, s, s, s] - midpoints = [2.0e-5, 0.0735, 20.0, 2.0e2, 2.0e3, 0.75e6, 2.0e6] - energy_distribution = openmc.stats.Discrete(x=midpoints, p=strengths) - - lower_left_src = [pitch - pitch/10.0, -pitch, -1.0] - upper_right_src = [pitch, -pitch + pitch/10.0, 1.0] - spatial_distribution = openmc.stats.Box( - lower_left_src, upper_right_src, only_fissionable=False) - - settings.source = openmc.IndependentSource( - space=spatial_distribution, - energy=energy_distribution, - constraints={'domains': [mu2]}, - strength=1.0 - ) - - ######################################## - # Run test - - harness = MGXSTestHarness('statepoint.125.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_halton_samples/__init__.py b/tests/regression_tests/random_ray_halton_samples/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_halton_samples/inputs_true.dat b/tests/regression_tests/random_ray_halton_samples/inputs_true.dat deleted file mode 100644 index 1b86d2dae..000000000 --- a/tests/regression_tests/random_ray_halton_samples/inputs_true.dat +++ /dev/null @@ -1,112 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - halton - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_halton_samples/results_true.dat b/tests/regression_tests/random_ray_halton_samples/results_true.dat deleted file mode 100644 index 256f8a744..000000000 --- a/tests/regression_tests/random_ray_halton_samples/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -8.388051E-01 7.383265E-03 -tally 1: -1.065839E+00 -2.274384E-01 -4.060094E-01 -3.300592E-02 -9.881457E-01 -1.955066E-01 -6.038893E-01 -7.306038E-02 -9.244411E-02 -1.712380E-03 -2.249905E-01 -1.014308E-02 -3.594916E-01 -2.614145E-02 -1.194318E-02 -2.882412E-05 -2.906731E-02 -1.707363E-04 -5.032954E-01 -5.161897E-02 -1.707007E-02 -5.933921E-05 -4.154514E-02 -3.514889E-04 -1.513147E+00 -4.652938E-01 -1.810962E-02 -6.665306E-05 -4.407572E-02 -3.948212E-04 -4.347893E+00 -3.798064E+00 -6.851785E-03 -9.430195E-06 -1.695426E-02 -5.773923E-05 -2.809071E+00 -1.578195E+00 -3.954523E-02 -3.127754E-04 -1.099931E-01 -2.419775E-03 -1.600493E+00 -5.123291E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -7.170555E-01 -1.028835E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.869491E-01 -3.041553E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.723683E-01 -6.680970E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.583046E+00 -5.085372E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.872447E+00 -3.013344E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.421670E+00 -1.172938E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.721128E-01 -1.894086E-01 -3.612242E-01 -2.615053E-02 -8.791475E-01 -1.548996E-01 -5.782742E-01 -6.705354E-02 -8.624040E-02 -1.491336E-03 -2.098919E-01 -8.833753E-03 -3.525265E-01 -2.510689E-02 -1.140473E-02 -2.627142E-05 -2.775683E-02 -1.556157E-04 -4.896481E-01 -4.881407E-02 -1.622698E-02 -5.360976E-05 -3.949322E-02 -3.175511E-04 -1.504743E+00 -4.601003E-01 -1.754995E-02 -6.262618E-05 -4.271358E-02 -3.709679E-04 -4.444922E+00 -3.970609E+00 -6.759184E-03 -9.185746E-06 -1.672513E-02 -5.624252E-05 -2.871068E+00 -1.648778E+00 -3.843643E-02 -2.955428E-04 -1.069090E-01 -2.286455E-03 -1.078620E+00 -2.328291E-01 -3.969671E-01 -3.153110E-02 -9.661384E-01 -1.867708E-01 -6.077864E-01 -7.399164E-02 -8.987086E-02 -1.618157E-03 -2.187277E-01 -9.584966E-03 -3.607158E-01 -2.633746E-02 -1.157185E-02 -2.709895E-05 -2.816358E-02 -1.605174E-04 -5.059289E-01 -5.218618E-02 -1.658585E-02 -5.611375E-05 -4.036663E-02 -3.323832E-04 -1.516801E+00 -4.675245E-01 -1.752096E-02 -6.241641E-05 -4.264304E-02 -3.697253E-04 -4.326588E+00 -3.759517E+00 -6.556454E-03 -8.628460E-06 -1.622349E-02 -5.283037E-05 -2.782815E+00 -1.548888E+00 -3.751781E-02 -2.815972E-04 -1.043539E-01 -2.178566E-03 diff --git a/tests/regression_tests/random_ray_halton_samples/test.py b/tests/regression_tests/random_ray_halton_samples/test.py deleted file mode 100644 index 478b65026..000000000 --- a/tests/regression_tests/random_ray_halton_samples/test.py +++ /dev/null @@ -1,19 +0,0 @@ -import os - -from openmc.examples import random_ray_lattice - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - -def test_random_ray_halton_samples(): - model = random_ray_lattice() - model.settings.random_ray['sample_method'] = 'halton' - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_k_eff/__init__.py b/tests/regression_tests/random_ray_k_eff/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_k_eff/inputs_true.dat b/tests/regression_tests/random_ray_k_eff/inputs_true.dat deleted file mode 100644 index 72b783344..000000000 --- a/tests/regression_tests/random_ray_k_eff/inputs_true.dat +++ /dev/null @@ -1,111 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_k_eff/results_true.dat b/tests/regression_tests/random_ray_k_eff/results_true.dat deleted file mode 100644 index ace18df8c..000000000 --- a/tests/regression_tests/random_ray_k_eff/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -8.400321E-01 8.023357E-03 -tally 1: -1.075769E+00 -2.317354E-01 -3.986991E-01 -3.182682E-02 -9.703538E-01 -1.885224E-01 -6.049423E-01 -7.331941E-02 -8.978161E-02 -1.614997E-03 -2.185105E-01 -9.566247E-03 -3.579852E-01 -2.591721E-02 -1.151770E-02 -2.682363E-05 -2.803176E-02 -1.588866E-04 -5.017326E-01 -5.130808E-02 -1.651428E-02 -5.557274E-05 -4.019245E-02 -3.291786E-04 -1.509054E+00 -4.629325E-01 -1.749679E-02 -6.226587E-05 -4.258421E-02 -3.688336E-04 -4.322054E+00 -3.753085E+00 -6.555113E-03 -8.636537E-06 -1.622017E-02 -5.287982E-05 -2.777351E+00 -1.542942E+00 -3.731363E-02 -2.784662E-04 -1.037860E-01 -2.154343E-03 -1.600522E+00 -5.123477E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -7.155116E-01 -1.024445E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.848568E-01 -3.008769E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.697160E-01 -6.624996E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.576480E+00 -5.046890E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.856827E+00 -2.989000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.405807E+00 -1.157889E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.732717E-01 -1.897670E-01 -3.637108E-01 -2.649544E-02 -8.851992E-01 -1.569426E-01 -5.774286E-01 -6.683395E-02 -8.688408E-02 -1.513473E-03 -2.114585E-01 -8.964883E-03 -3.512640E-01 -2.491729E-02 -1.148149E-02 -2.660532E-05 -2.794365E-02 -1.575935E-04 -4.877362E-01 -4.844138E-02 -1.627932E-02 -5.395212E-05 -3.962062E-02 -3.195790E-04 -1.496416E+00 -4.551920E-01 -1.760130E-02 -6.300084E-05 -4.283856E-02 -3.731872E-04 -4.430519E+00 -3.943947E+00 -6.841363E-03 -9.402132E-06 -1.692847E-02 -5.756741E-05 -2.870816E+00 -1.648662E+00 -3.937267E-02 -3.101707E-04 -1.095131E-01 -2.399624E-03 -1.072714E+00 -2.304093E-01 -4.053505E-01 -3.291277E-02 -9.865420E-01 -1.949549E-01 -6.047420E-01 -7.327008E-02 -9.163611E-02 -1.683034E-03 -2.230240E-01 -9.969255E-03 -3.580639E-01 -2.592902E-02 -1.176143E-02 -2.794541E-05 -2.862497E-02 -1.655313E-04 -5.010143E-01 -5.114429E-02 -1.681803E-02 -5.755790E-05 -4.093173E-02 -3.409375E-04 -1.505803E+00 -4.607828E-01 -1.782566E-02 -6.454911E-05 -4.338462E-02 -3.823584E-04 -4.328879E+00 -3.766055E+00 -6.729800E-03 -9.102372E-06 -1.665242E-02 -5.573204E-05 -2.804070E+00 -1.572690E+00 -3.876396E-02 -3.006259E-04 -1.078200E-01 -2.325780E-03 diff --git a/tests/regression_tests/random_ray_k_eff/test.py b/tests/regression_tests/random_ray_k_eff/test.py deleted file mode 100644 index 8dd0dd915..000000000 --- a/tests/regression_tests/random_ray_k_eff/test.py +++ /dev/null @@ -1,19 +0,0 @@ -import os - -from openmc.examples import random_ray_lattice - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_basic(): - model = random_ray_lattice() - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_k_eff_mesh/__init__.py b/tests/regression_tests/random_ray_k_eff_mesh/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_k_eff_mesh/inputs_true.dat b/tests/regression_tests/random_ray_k_eff_mesh/inputs_true.dat deleted file mode 100644 index f6e9c8e3e..000000000 --- a/tests/regression_tests/random_ray_k_eff_mesh/inputs_true.dat +++ /dev/null @@ -1,121 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 10 - 5 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - - - - - - - - 40 40 - -1.26 -1.26 - 1.26 1.26 - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat b/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat deleted file mode 100644 index 2ae8fad85..000000000 --- a/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -8.379203E-01 8.057199E-03 -tally 1: -1.073897E+00 -2.309328E-01 -3.974859E-01 -3.163415E-02 -9.674011E-01 -1.873811E-01 -6.045463E-01 -7.322367E-02 -8.969819E-02 -1.612011E-03 -2.183075E-01 -9.548557E-03 -3.578121E-01 -2.589198E-02 -1.151076E-02 -2.679073E-05 -2.801489E-02 -1.586917E-04 -5.015038E-01 -5.126076E-02 -1.650453E-02 -5.550572E-05 -4.016872E-02 -3.287816E-04 -1.508456E+00 -4.625615E-01 -1.748939E-02 -6.221267E-05 -4.256620E-02 -3.685184E-04 -4.320984E+00 -3.751237E+00 -6.554265E-03 -8.634389E-06 -1.621807E-02 -5.286667E-05 -2.776930E+00 -1.542475E+00 -3.730995E-02 -2.784113E-04 -1.037757E-01 -2.153918E-03 -1.603583E+00 -5.143065E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -7.159242E-01 -1.025623E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.847488E-01 -3.007151E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.695050E-01 -6.620177E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.575716E+00 -5.042003E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.855109E+00 -2.986316E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.405453E+00 -1.157547E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.701818E-01 -1.885724E-01 -3.619962E-01 -2.624740E-02 -8.810264E-01 -1.554734E-01 -5.767221E-01 -6.667165E-02 -8.675429E-02 -1.508976E-03 -2.111426E-01 -8.938242E-03 -3.510185E-01 -2.488161E-02 -1.147307E-02 -2.656498E-05 -2.792316E-02 -1.573545E-04 -4.874578E-01 -4.838573E-02 -1.626869E-02 -5.388082E-05 -3.959473E-02 -3.191567E-04 -1.495984E+00 -4.549294E-01 -1.759493E-02 -6.295564E-05 -4.282306E-02 -3.729194E-04 -4.430601E+00 -3.944093E+00 -6.841763E-03 -9.403281E-06 -1.692946E-02 -5.757445E-05 -2.870670E+00 -1.648496E+00 -3.937215E-02 -3.101637E-04 -1.095116E-01 -2.399569E-03 -1.071187E+00 -2.297540E-01 -4.043214E-01 -3.274592E-02 -9.840375E-01 -1.939666E-01 -6.043491E-01 -7.317500E-02 -9.155169E-02 -1.679939E-03 -2.228185E-01 -9.950920E-03 -3.578809E-01 -2.590208E-02 -1.175437E-02 -2.791136E-05 -2.860779E-02 -1.653296E-04 -5.007414E-01 -5.108824E-02 -1.680608E-02 -5.747571E-05 -4.090264E-02 -3.404506E-04 -1.505100E+00 -4.603562E-01 -1.781573E-02 -6.447733E-05 -4.336044E-02 -3.819332E-04 -4.328647E+00 -3.765700E+00 -6.730396E-03 -9.104085E-06 -1.665389E-02 -5.574253E-05 -2.803934E+00 -1.572540E+00 -3.876306E-02 -3.006136E-04 -1.078175E-01 -2.325685E-03 diff --git a/tests/regression_tests/random_ray_k_eff_mesh/test.py b/tests/regression_tests/random_ray_k_eff_mesh/test.py deleted file mode 100644 index cffdaf8bb..000000000 --- a/tests/regression_tests/random_ray_k_eff_mesh/test.py +++ /dev/null @@ -1,36 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_lattice - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_k_eff_mesh(): - model = random_ray_lattice() - - # The model already has some geometrical subdivisions - # up to a 10x10 grid in the moderator region. So, we - # increase the resolution 40x40 applied over the full - # 2x2 lattice. - pitch = 1.26 - dim = 40 - mesh = openmc.RegularMesh() - mesh.dimension = (dim, dim) - mesh.lower_left = (-pitch, -pitch) - mesh.upper_right = (pitch, pitch) - - root = model.geometry.root_universe - - model.settings.random_ray['source_region_meshes'] = [(mesh, [root])] - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_linear/__init__.py b/tests/regression_tests/random_ray_linear/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_linear/linear/inputs_true.dat b/tests/regression_tests/random_ray_linear/linear/inputs_true.dat deleted file mode 100644 index 269d9892e..000000000 --- a/tests/regression_tests/random_ray_linear/linear/inputs_true.dat +++ /dev/null @@ -1,112 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 40 - 20 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - linear - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_linear/linear/results_true.dat b/tests/regression_tests/random_ray_linear/linear/results_true.dat deleted file mode 100644 index 77d41f373..000000000 --- a/tests/regression_tests/random_ray_linear/linear/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -1.095967E+00 1.543581E-02 -tally 1: -5.425537E+00 -1.482137E+00 -1.974189E+00 -1.961888E-01 -4.804781E+00 -1.162101E+00 -3.866915E+00 -7.496163E-01 -5.662059E-01 -1.607180E-02 -1.378032E+00 -9.519943E-02 -2.904666E+00 -4.220197E-01 -9.289413E-02 -4.316514E-04 -2.260857E-01 -2.556836E-03 -3.717829E+00 -6.912286E-01 -1.220682E-01 -7.451721E-04 -2.970897E-01 -4.413940E-03 -9.665773E+00 -4.671720E+00 -1.120617E-01 -6.279393E-04 -2.727390E-01 -3.719615E-03 -2.117656E+01 -2.242614E+01 -3.204951E-02 -5.138445E-05 -7.930426E-02 -3.146169E-04 -1.133784E+01 -6.432186E+00 -1.537206E-01 -1.185474E-03 -4.275660E-01 -9.171376E-03 -8.917756E+00 -4.009380E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.736166E+00 -1.124858E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.057755E+00 -4.676344E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.048156E+00 -8.195089E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.707791E+00 -4.712281E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.874344E+01 -1.756722E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.595520E+00 -4.608366E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.701002E+00 -1.113069E+00 -1.733152E+00 -1.513360E-01 -4.218145E+00 -8.964208E-01 -3.641849E+00 -6.649342E-01 -5.413112E-01 -1.469131E-02 -1.317443E+00 -8.702223E-02 -2.858878E+00 -4.088359E-01 -9.288202E-02 -4.315389E-04 -2.260562E-01 -2.556170E-03 -3.649312E+00 -6.660131E-01 -1.216639E-01 -7.402611E-04 -2.961057E-01 -4.384849E-03 -9.664912E+00 -4.671059E+00 -1.138118E-01 -6.477188E-04 -2.769985E-01 -3.836780E-03 -2.157464E+01 -2.327600E+01 -3.312018E-02 -5.486221E-05 -8.195357E-02 -3.359106E-04 -1.145052E+01 -6.557893E+00 -1.570084E-01 -1.234420E-03 -4.367109E-01 -9.550040E-03 -5.371474E+00 -1.451702E+00 -1.994382E+00 -2.000414E-01 -4.853928E+00 -1.184921E+00 -3.839778E+00 -7.388780E-01 -5.741437E-01 -1.651648E-02 -1.397351E+00 -9.783345E-02 -2.890296E+00 -4.178220E-01 -9.447974E-02 -4.464346E-04 -2.299448E-01 -2.644403E-03 -3.695989E+00 -6.831063E-01 -1.240303E-01 -7.692555E-04 -3.018649E-01 -4.556594E-03 -9.622545E+00 -4.630042E+00 -1.140770E-01 -6.507108E-04 -2.776440E-01 -3.854503E-03 -2.115266E+01 -2.237450E+01 -3.276343E-02 -5.368742E-05 -8.107083E-02 -3.287176E-04 -1.136109E+01 -6.456700E+00 -1.576636E-01 -1.245524E-03 -4.385334E-01 -9.635950E-03 diff --git a/tests/regression_tests/random_ray_linear/linear_xy/inputs_true.dat b/tests/regression_tests/random_ray_linear/linear_xy/inputs_true.dat deleted file mode 100644 index 217e95516..000000000 --- a/tests/regression_tests/random_ray_linear/linear_xy/inputs_true.dat +++ /dev/null @@ -1,112 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.126 0.126 - 10 10 - -0.63 -0.63 - -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 - - - 1.26 1.26 - 2 2 - -1.26 -1.26 - -2 2 -2 5 - - - - - - - - - - - - - - - - - - - - - eigenvalue - 100 - 40 - 20 - multi-group - - 100.0 - 20.0 - - - - -1.26 -1.26 -1 1.26 1.26 1 - - - - true - linear_xy - - - - - 2 2 - -1.26 -1.26 - 1.26 1.26 - - - 1 - - - 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 - - - 1 2 - flux fission nu-fission - analog - - - diff --git a/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat b/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat deleted file mode 100644 index 052608b42..000000000 --- a/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat +++ /dev/null @@ -1,171 +0,0 @@ -k-combined: -1.104727E+00 1.593303E-02 -tally 1: -5.465547E+00 -1.504031E+00 -2.005120E+00 -2.024490E-01 -4.880060E+00 -1.199182E+00 -3.883466E+00 -7.559482E-01 -5.706123E-01 -1.632280E-02 -1.388756E+00 -9.668619E-02 -2.907681E+00 -4.228621E-01 -9.306046E-02 -4.331768E-04 -2.264905E-01 -2.565871E-03 -3.727441E+00 -6.948089E-01 -1.227027E-01 -7.529631E-04 -2.986338E-01 -4.460088E-03 -9.674219E+00 -4.679846E+00 -1.122358E-01 -6.299070E-04 -2.731629E-01 -3.731271E-03 -2.103996E+01 -2.213497E+01 -3.167421E-02 -5.016895E-05 -7.837561E-02 -3.071747E-04 -1.120119E+01 -6.274853E+00 -1.494396E-01 -1.117486E-03 -4.156586E-01 -8.645390E-03 -8.910289E+00 -4.001626E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.741600E+00 -1.127303E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.068401E+00 -4.708885E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.065045E+00 -8.263510E-01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.750251E+00 -4.753623E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.880773E+01 -1.768690E+01 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.642921E+00 -4.650165E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.723189E+00 -1.123179E+00 -1.746692E+00 -1.536860E-01 -4.251098E+00 -9.103405E-01 -3.651202E+00 -6.682179E-01 -5.431675E-01 -1.479058E-02 -1.321961E+00 -8.761024E-02 -2.860513E+00 -4.092640E-01 -9.290237E-02 -4.316867E-04 -2.261058E-01 -2.557045E-03 -3.655900E+00 -6.684112E-01 -1.219969E-01 -7.443277E-04 -2.969160E-01 -4.408937E-03 -9.672316E+00 -4.678082E+00 -1.138719E-01 -6.483917E-04 -2.771448E-01 -3.840766E-03 -2.148514E+01 -2.308100E+01 -3.286501E-02 -5.400774E-05 -8.132216E-02 -3.306788E-04 -1.137571E+01 -6.471140E+00 -1.544841E-01 -1.193653E-03 -4.296897E-01 -9.234647E-03 -5.408307E+00 -1.472183E+00 -2.019332E+00 -2.052123E-01 -4.914651E+00 -1.215551E+00 -3.859737E+00 -7.466141E-01 -5.785840E-01 -1.677554E-02 -1.408158E+00 -9.936796E-02 -2.901397E+00 -4.210234E-01 -9.492573E-02 -4.506531E-04 -2.310302E-01 -2.669390E-03 -3.714401E+00 -6.899411E-01 -1.249118E-01 -7.802521E-04 -3.040104E-01 -4.621732E-03 -9.663183E+00 -4.669215E+00 -1.146768E-01 -6.575767E-04 -2.791038E-01 -3.895173E-03 -2.112461E+01 -2.231346E+01 -3.262864E-02 -5.323508E-05 -8.073730E-02 -3.259479E-04 -1.128817E+01 -6.372070E+00 -1.551272E-01 -1.203670E-03 -4.314785E-01 -9.312148E-03 diff --git a/tests/regression_tests/random_ray_linear/test.py b/tests/regression_tests/random_ray_linear/test.py deleted file mode 100644 index 510c57de8..000000000 --- a/tests/regression_tests/random_ray_linear/test.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_lattice -from openmc.utility_funcs import change_directory -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("shape", ["linear", "linear_xy"]) -def test_random_ray_source(shape): - with change_directory(shape): - openmc.reset_auto_ids() - model = random_ray_lattice() - model.settings.random_ray['source_shape'] = shape - model.settings.inactive = 20 - model.settings.batches = 40 - harness = MGXSTestHarness('statepoint.40.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_low_density/__init__.py b/tests/regression_tests/random_ray_low_density/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_low_density/inputs_true.dat b/tests/regression_tests/random_ray_low_density/inputs_true.dat deleted file mode 100644 index 20deba664..000000000 --- a/tests/regression_tests/random_ray_low_density/inputs_true.dat +++ /dev/null @@ -1,246 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_low_density/results_true.dat b/tests/regression_tests/random_ray_low_density/results_true.dat deleted file mode 100644 index a4b3ee1bc..000000000 --- a/tests/regression_tests/random_ray_low_density/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.973607E-01 -7.155477E-02 -tally 2: -3.206216E-02 -2.063375E-04 -tally 3: -2.096415E-03 -8.804963E-07 diff --git a/tests/regression_tests/random_ray_low_density/test.py b/tests/regression_tests/random_ray_low_density/test.py deleted file mode 100644 index 1b4ffb781..000000000 --- a/tests/regression_tests/random_ray_low_density/test.py +++ /dev/null @@ -1,60 +0,0 @@ -import os - -import numpy as np -import openmc -from openmc.examples import random_ray_three_region_cube - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_low_density(): - model = random_ray_three_region_cube() - - # Rebuild the MGXS library to have a material with very - # low macroscopic cross sections - ebins = [1e-5, 20.0e6] - groups = openmc.mgxs.EnergyGroups(group_edges=ebins) - - void_sigma_a = 4.0e-6 - void_sigma_s = 3.0e-4 - void_mat_data = openmc.XSdata('void', groups) - void_mat_data.order = 0 - void_mat_data.set_total([void_sigma_a + void_sigma_s]) - void_mat_data.set_absorption([void_sigma_a]) - void_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[void_sigma_s]]]), 0, 3)) - - absorber_sigma_a = 0.75 - absorber_sigma_s = 0.25 - absorber_mat_data = openmc.XSdata('absorber', groups) - absorber_mat_data.order = 0 - absorber_mat_data.set_total([absorber_sigma_a + absorber_sigma_s]) - absorber_mat_data.set_absorption([absorber_sigma_a]) - absorber_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[absorber_sigma_s]]]), 0, 3)) - - multiplier = 0.0000001 - source_sigma_a = void_sigma_a * multiplier - source_sigma_s = void_sigma_s * multiplier - source_mat_data = openmc.XSdata('source', groups) - source_mat_data.order = 0 - source_mat_data.set_total([source_sigma_a + source_sigma_s]) - source_mat_data.set_absorption([source_sigma_a]) - source_mat_data.set_scatter_matrix( - np.rollaxis(np.array([[[source_sigma_s]]]), 0, 3)) - - mg_cross_sections_file = openmc.MGXSLibrary(groups) - mg_cross_sections_file.add_xsdatas( - [source_mat_data, void_mat_data, absorber_mat_data]) - mg_cross_sections_file.export_to_hdf5() - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_point_source_locator/__init__.py b/tests/regression_tests/random_ray_point_source_locator/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_point_source_locator/inputs_true.dat b/tests/regression_tests/random_ray_point_source_locator/inputs_true.dat deleted file mode 100644 index b4bd263f5..000000000 --- a/tests/regression_tests/random_ray_point_source_locator/inputs_true.dat +++ /dev/null @@ -1,255 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 30 - 15 - - - 2.5 2.5 2.5 - - - 100.0 1.0 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - - - - 30 30 30 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_point_source_locator/results_true.dat b/tests/regression_tests/random_ray_point_source_locator/results_true.dat deleted file mode 100644 index 8c6f358dd..000000000 --- a/tests/regression_tests/random_ray_point_source_locator/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.633923E+00 -2.948228E+00 -tally 2: -1.440456E-01 -3.293984E-03 -tally 3: -9.425207E-03 -1.089748E-05 diff --git a/tests/regression_tests/random_ray_point_source_locator/test.py b/tests/regression_tests/random_ray_point_source_locator/test.py deleted file mode 100644 index fd3d8a18f..000000000 --- a/tests/regression_tests/random_ray_point_source_locator/test.py +++ /dev/null @@ -1,44 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_three_region_cube - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_point_source_locator(): - model = random_ray_three_region_cube() - - # Overlay subdivided SR mesh to reduce resolution from 2.5cm -> 1cm - width = 30.0 - mesh = openmc.RegularMesh() - mesh.dimension = (30, 30, 30) - mesh.lower_left = (0.0, 0.0, 0.0) - mesh.upper_right = (width, width, width) - model.settings.random_ray['source_region_meshes'] = [ - (mesh, [model.geometry.root_universe]), - ] - - # Define a point source - strengths = [1.0] - midpoints = [100.0] - energy_distribution = openmc.stats.Discrete(x=midpoints, p=strengths) - spatial_distribution = openmc.stats.Point([2.5, 2.5, 2.5]) - source = openmc.IndependentSource( - energy=energy_distribution, space=spatial_distribution, strength=3.14) - model.settings.source = [source] - - # Settings - model.settings.inactive = 15 - model.settings.batches = 30 - - harness = MGXSTestHarness('statepoint.30.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_s2/__init__.py b/tests/regression_tests/random_ray_s2/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_s2/inputs_true.dat b/tests/regression_tests/random_ray_s2/inputs_true.dat deleted file mode 100644 index c0dc6292f..000000000 --- a/tests/regression_tests/random_ray_s2/inputs_true.dat +++ /dev/null @@ -1,71 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - fixed source - 100 - 30 - 10 - - - 0.0 -5.0 -5.0 40.0 5.0 5.0 - - - 1000.0 1.0 - - - material - 1 - - - multi-group - - 100.0 - 400.0 - - - - 0.0 -5.0 -5.0 40.0 5.0 5.0 - - - - flat - s2 - - - - - - - - 10 1 1 - 0.0 -5.0 -5.0 - 40.0 5.0 5.0 - - - - - 1 - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_s2/results_true.dat b/tests/regression_tests/random_ray_s2/results_true.dat deleted file mode 100644 index 5fb6f7904..000000000 --- a/tests/regression_tests/random_ray_s2/results_true.dat +++ /dev/null @@ -1,21 +0,0 @@ -tally 1: -1.153280E+01 -6.650271E+00 -1.413926E+01 -9.995935E+00 -1.579543E+01 -1.247479E+01 -1.676986E+01 -1.406141E+01 -1.722054E+01 -1.482734E+01 -1.722054E+01 -1.482734E+01 -1.676986E+01 -1.406141E+01 -1.579543E+01 -1.247479E+01 -1.413926E+01 -9.995935E+00 -1.153280E+01 -6.650271E+00 diff --git a/tests/regression_tests/random_ray_s2/test.py b/tests/regression_tests/random_ray_s2/test.py deleted file mode 100644 index 712d9c124..000000000 --- a/tests/regression_tests/random_ray_s2/test.py +++ /dev/null @@ -1,82 +0,0 @@ -import os - -import openmc -import openmc.model -import numpy as np - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_s2(): - NUM_SOURCE_REGIONS = 10 - L = 40.0 - - # Make the simple MGXS library and material. - groups = openmc.mgxs.EnergyGroups(group_edges=[1e-5, 20.0e6]) - - domain_mat_data = openmc.XSdata('domain', groups) - domain_mat_data.order = 0 - domain_mat_data.set_total([0.1]) - domain_mat_data.set_absorption([0.1]) - domain_mat_data.set_scatter_matrix(np.rollaxis(np.array([[[0.0]]]), 0, 3)) - mg_cross_sections_file = openmc.MGXSLibrary(groups) - mg_cross_sections_file.add_xsdatas([domain_mat_data]) - mg_cross_sections_file.export_to_hdf5() - - domain_data = openmc.Macroscopic('domain') - domain_mat = openmc.Material(name='domain') - domain_mat.set_density('macro', 1.0) - domain_mat.add_macroscopic(domain_data) - - container = openmc.model.RectangularPrism(width=10.0, height=10.0, axis='x', - origin=(0.0, 0.0), boundary_type='reflective') - left = openmc.XPlane(x0 = 0.0, boundary_type='vacuum') - right = openmc.XPlane(x0 = L, boundary_type='vacuum') - cell = [openmc.Cell(region = +left & -right & -container, fill = domain_mat)] - - model = openmc.model.Model() - model.geometry = openmc.Geometry(root=openmc.Universe(cells=cell)) - model.materials = openmc.Materials([domain_mat]) - model.materials.cross_sections = './mgxs.h5' - - mesh = openmc.RegularMesh() - mesh.dimension = (NUM_SOURCE_REGIONS, 1, 1) - mesh.lower_left = (0.0, -5.0, -5.0) - mesh.upper_right = (L, 5.0, 5.0) - - tally = openmc.Tally(name="LR") - tally.filters = [openmc.MeshFilter(mesh)] - tally.scores = ['flux'] - tally.estimator = 'tracklength' - model.tallies.append(tally) - - uniform_dist = openmc.stats.Box((0.0, -5.0, -5.0), (L, 5.0, 5.0)) - model.settings.source = [ - openmc.IndependentSource(space=uniform_dist, - energy=openmc.stats.Discrete(x = 1e3, p = 1.0), - constraints={'domains' : [domain_mat]}) - ] - model.settings.energy_mode = "multi-group" - model.settings.batches = 30 - model.settings.inactive = 10 - model.settings.particles = 100 - model.settings.run_mode = 'fixed source' - model.settings.random_ray['distance_inactive'] = 100.0 - model.settings.random_ray['distance_active'] = 400.0 - model.settings.random_ray['ray_source'] = openmc.IndependentSource(space=uniform_dist) - model.settings.random_ray['source_shape'] = 'flat' - model.settings.random_ray['sample_method'] = 's2' - model.settings.random_ray['source_region_meshes'] = [(mesh, [model.geometry.root_universe])] - - model.export_to_model_xml() - - harness = MGXSTestHarness('statepoint.30.h5', model) - harness.main() diff --git a/tests/regression_tests/deplete_with_keff_search_control/__init__.py b/tests/regression_tests/random_ray_vacuum/__init__.py similarity index 100% rename from tests/regression_tests/deplete_with_keff_search_control/__init__.py rename to tests/regression_tests/random_ray_vacuum/__init__.py diff --git a/tests/regression_tests/random_ray_vacuum/inputs_true.dat b/tests/regression_tests/random_ray_vacuum/inputs_true.dat new file mode 100644 index 000000000..4ef109420 --- /dev/null +++ b/tests/regression_tests/random_ray_vacuum/inputs_true.dat @@ -0,0 +1,108 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.126 0.126 + 10 10 + -0.63 -0.63 + +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 +3 3 3 3 3 3 3 3 3 3 + + + 1.26 1.26 + 2 2 + -1.26 -1.26 + +2 2 +2 5 + + + + + + + + + + + + + + + + + + + + + eigenvalue + 100 + 10 + 5 + multi-group + + 100.0 + 20.0 + + + -1.26 -1.26 -1 1.26 1.26 1 + + + + + + + 2 2 + -1.26 -1.26 + 1.26 1.26 + + + 1 + + + 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0 + + + 1 2 + flux fission nu-fission + analog + + + diff --git a/tests/regression_tests/random_ray_vacuum/results_true.dat b/tests/regression_tests/random_ray_vacuum/results_true.dat new file mode 100644 index 000000000..c25999aad --- /dev/null +++ b/tests/regression_tests/random_ray_vacuum/results_true.dat @@ -0,0 +1,171 @@ +k-combined: +1.010455E-01 1.585558E-02 +tally 1: +7.466984E-01 +1.245920E-01 +2.771079E-01 +1.714504E-02 +6.744252E-01 +1.015566E-01 +1.634870E-01 +6.288701E-03 +2.405120E-02 +1.362874E-04 +5.853580E-02 +8.072823E-04 +1.641162E-02 +6.568765E-05 +5.223801E-04 +6.753516E-08 +1.271369E-03 +4.000365E-07 +3.014736E-02 +1.922973E-04 +9.765325E-04 +2.043645E-07 +2.376685E-03 +1.210529E-06 +1.562379E-01 +4.906526E-03 +1.746664E-03 +6.141658E-07 +4.251084E-03 +3.638028E-06 +1.826385E+00 +6.678141E-01 +3.095716E-03 +1.920117E-06 +7.660132E-03 +1.175650E-05 +2.013809E+00 +8.136726E-01 +3.015545E-02 +1.832201E-04 +8.387586E-02 +1.417475E-03 +1.573069E+00 +5.388374E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.867849E-01 +1.864798E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.136372E-02 +1.035499E-04 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.973323E-02 +3.229766E-04 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.779974E-01 +6.350613E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.036886E+00 +2.151147E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.109991E+00 +2.468005E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +5.813217E-01 +7.704274E-02 +2.160141E-01 +1.062660E-02 +5.257350E-01 +6.294540E-02 +1.358032E-01 +4.462239E-03 +2.030839E-02 +1.002755E-04 +4.942655E-02 +5.939703E-04 +1.612888E-02 +6.604109E-05 +5.274425E-04 +7.250333E-08 +1.283689E-03 +4.294649E-07 +2.985723E-02 +1.925418E-04 +9.868482E-04 +2.142916E-07 +2.401791E-03 +1.269331E-06 +1.590678E-01 +5.110940E-03 +1.800903E-03 +6.566490E-07 +4.383091E-03 +3.889678E-06 +1.928611E+00 +7.475889E-01 +3.310101E-03 +2.209547E-06 +8.190613E-03 +1.352862E-05 +2.172777E+00 +9.544513E-01 +3.334566E-02 +2.267149E-04 +9.274926E-02 +1.753971E-03 +7.566911E-01 +1.278105E-01 +2.881892E-01 +1.854375E-02 +7.013949E-01 +1.098417E-01 +1.662732E-01 +6.495387E-03 +2.515274E-02 +1.488430E-04 +6.121675E-02 +8.816538E-04 +1.682747E-02 +6.933017E-05 +5.514441E-04 +7.567901E-08 +1.342104E-03 +4.482757E-07 +3.068773E-02 +1.997062E-04 +1.021094E-03 +2.240938E-07 +2.485139E-03 +1.327393E-06 +1.578722E-01 +5.013656E-03 +1.812622E-03 +6.620083E-07 +4.411613E-03 +3.921424E-06 +1.922798E+00 +7.400474E-01 +3.401690E-03 +2.320513E-06 +8.417243E-03 +1.420805E-05 +2.178318E+00 +9.546106E-01 +3.451316E-02 +2.421994E-04 +9.599661E-02 +1.873766E-03 diff --git a/tests/regression_tests/random_ray_vacuum/test.py b/tests/regression_tests/random_ray_vacuum/test.py new file mode 100644 index 000000000..e9ca22521 --- /dev/null +++ b/tests/regression_tests/random_ray_vacuum/test.py @@ -0,0 +1,235 @@ +import os + +import numpy as np +import openmc + +from tests.testing_harness import TolerantPyAPITestHarness + + +class MGXSTestHarness(TolerantPyAPITestHarness): + def _cleanup(self): + super()._cleanup() + f = 'mgxs.h5' + if os.path.exists(f): + os.remove(f) + + +def random_ray_model() -> openmc.Model: + ############################################################################### + # Create multigroup data + + # Instantiate the energy group data + group_edges = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6] + groups = openmc.mgxs.EnergyGroups(group_edges) + + # Instantiate the 7-group (C5G7) cross section data + uo2_xsdata = openmc.XSdata('UO2', groups) + uo2_xsdata.order = 0 + uo2_xsdata.set_total( + [0.1779492, 0.3298048, 0.4803882, 0.5543674, 0.3118013, 0.3951678, + 0.5644058]) + uo2_xsdata.set_absorption([8.0248e-03, 3.7174e-03, 2.6769e-02, 9.6236e-02, + 3.0020e-02, 1.1126e-01, 2.8278e-01]) + scatter_matrix = np.array( + [[[0.1275370, 0.0423780, 0.0000094, 0.0000000, 0.0000000, 0.0000000, 0.0000000], + [0.0000000, 0.3244560, 0.0016314, 0.0000000, 0.0000000, 0.0000000, 0.0000000], + [0.0000000, 0.0000000, 0.4509400, 0.0026792, 0.0000000, 0.0000000, 0.0000000], + [0.0000000, 0.0000000, 0.0000000, 0.4525650, 0.0055664, 0.0000000, 0.0000000], + [0.0000000, 0.0000000, 0.0000000, 0.0001253, 0.2714010, 0.0102550, 0.0000000], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0012968, 0.2658020, 0.0168090], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0085458, 0.2730800]]]) + scatter_matrix = np.rollaxis(scatter_matrix, 0, 3) + uo2_xsdata.set_scatter_matrix(scatter_matrix) + uo2_xsdata.set_fission([7.21206e-03, 8.19301e-04, 6.45320e-03, + 1.85648e-02, 1.78084e-02, 8.30348e-02, + 2.16004e-01]) + uo2_xsdata.set_nu_fission([2.005998e-02, 2.027303e-03, 1.570599e-02, + 4.518301e-02, 4.334208e-02, 2.020901e-01, + 5.257105e-01]) + uo2_xsdata.set_chi([5.8791e-01, 4.1176e-01, 3.3906e-04, 1.1761e-07, 0.0000e+00, + 0.0000e+00, 0.0000e+00]) + + h2o_xsdata = openmc.XSdata('LWTR', groups) + h2o_xsdata.order = 0 + h2o_xsdata.set_total([0.15920605, 0.412969593, 0.59030986, 0.58435, + 0.718, 1.2544497, 2.650379]) + h2o_xsdata.set_absorption([6.0105e-04, 1.5793e-05, 3.3716e-04, + 1.9406e-03, 5.7416e-03, 1.5001e-02, + 3.7239e-02]) + scatter_matrix = np.array( + [[[0.0444777, 0.1134000, 0.0007235, 0.0000037, 0.0000001, 0.0000000, 0.0000000], + [0.0000000, 0.2823340, 0.1299400, 0.0006234, 0.0000480, 0.0000074, 0.0000010], + [0.0000000, 0.0000000, 0.3452560, 0.2245700, 0.0169990, 0.0026443, 0.0005034], + [0.0000000, 0.0000000, 0.0000000, 0.0910284, 0.4155100, 0.0637320, 0.0121390], + [0.0000000, 0.0000000, 0.0000000, 0.0000714, 0.1391380, 0.5118200, 0.0612290], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0022157, 0.6999130, 0.5373200], + [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1324400, 2.4807000]]]) + scatter_matrix = np.rollaxis(scatter_matrix, 0, 3) + h2o_xsdata.set_scatter_matrix(scatter_matrix) + + mg_cross_sections = openmc.MGXSLibrary(groups) + mg_cross_sections.add_xsdatas([uo2_xsdata, h2o_xsdata]) + mg_cross_sections.export_to_hdf5() + + ############################################################################### + # Create materials for the problem + + # Instantiate some Materials and register the appropriate Macroscopic objects + uo2 = openmc.Material(name='UO2 fuel') + uo2.set_density('macro', 1.0) + uo2.add_macroscopic('UO2') + + water = openmc.Material(name='Water') + water.set_density('macro', 1.0) + water.add_macroscopic('LWTR') + + # Instantiate a Materials collection and export to XML + materials = openmc.Materials([uo2, water]) + materials.cross_sections = "mgxs.h5" + + ############################################################################### + # Define problem geometry + + ######################################## + # Define an unbounded pincell universe + + pitch = 1.26 + + # Create a surface for the fuel outer radius + fuel_or = openmc.ZCylinder(r=0.54, name='Fuel OR') + inner_ring_a = openmc.ZCylinder(r=0.33, name='inner ring a') + inner_ring_b = openmc.ZCylinder(r=0.45, name='inner ring b') + outer_ring_a = openmc.ZCylinder(r=0.60, name='outer ring a') + outer_ring_b = openmc.ZCylinder(r=0.69, name='outer ring b') + + # Instantiate Cells + fuel_a = openmc.Cell(fill=uo2, region=-inner_ring_a, name='fuel inner a') + fuel_b = openmc.Cell(fill=uo2, region=+inner_ring_a & -inner_ring_b, name='fuel inner b') + fuel_c = openmc.Cell(fill=uo2, region=+inner_ring_b & -fuel_or, name='fuel inner c') + moderator_a = openmc.Cell(fill=water, region=+fuel_or & -outer_ring_a, name='moderator inner a') + moderator_b = openmc.Cell(fill=water, region=+outer_ring_a & -outer_ring_b, name='moderator outer b') + moderator_c = openmc.Cell(fill=water, region=+outer_ring_b, name='moderator outer c') + + # Create pincell universe + pincell_base = openmc.Universe() + + # Register Cells with Universe + pincell_base.add_cells([fuel_a, fuel_b, fuel_c, moderator_a, moderator_b, moderator_c]) + + # Create planes for azimuthal sectors + azimuthal_planes = [] + for i in range(8): + angle = 2 * i * openmc.pi / 8 + normal_vector = (-openmc.sin(angle), openmc.cos(angle), 0) + azimuthal_planes.append(openmc.Plane(a=normal_vector[0], b=normal_vector[1], c=normal_vector[2], d=0)) + + # Create a cell for each azimuthal sector + azimuthal_cells = [] + for i in range(8): + azimuthal_cell = openmc.Cell(name=f'azimuthal_cell_{i}') + azimuthal_cell.fill = pincell_base + azimuthal_cell.region = +azimuthal_planes[i] & -azimuthal_planes[(i+1) % 8] + azimuthal_cells.append(azimuthal_cell) + + # Create a geometry with the azimuthal universes + pincell = openmc.Universe(cells=azimuthal_cells) + + ######################################## + # Define a moderator lattice universe + + moderator_infinite = openmc.Cell(fill=water, name='moderator infinite') + mu = openmc.Universe() + mu.add_cells([moderator_infinite]) + + lattice = openmc.RectLattice() + lattice.lower_left = [-pitch/2.0, -pitch/2.0] + lattice.pitch = [pitch/10.0, pitch/10.0] + lattice.universes = np.full((10, 10), mu) + + mod_lattice_cell = openmc.Cell(fill=lattice) + + mod_lattice_uni = openmc.Universe() + + mod_lattice_uni.add_cells([mod_lattice_cell]) + + ######################################## + # Define 2x2 outer lattice + lattice2x2 = openmc.RectLattice() + lattice2x2.lower_left = [-pitch, -pitch] + lattice2x2.pitch = [pitch, pitch] + lattice2x2.universes = [ + [pincell, pincell], + [pincell, mod_lattice_uni] + ] + + ######################################## + # Define cell containing lattice and other stuff + box = openmc.model.RectangularPrism(pitch*2, pitch*2, boundary_type='vacuum') + + assembly = openmc.Cell(fill=lattice2x2, region=-box, name='assembly') + + root = openmc.Universe(name='root universe') + root.add_cell(assembly) + + # Create a geometry with the two cells and export to XML + geometry = openmc.Geometry(root) + + ############################################################################### + # Define problem settings + + # Instantiate a Settings object, set all runtime parameters, and export to XML + settings = openmc.Settings() + settings.energy_mode = "multi-group" + settings.batches = 10 + settings.inactive = 5 + settings.particles = 100 + + # Create an initial uniform spatial source distribution over fissionable zones + lower_left = (-pitch, -pitch, -1) + upper_right = (pitch, pitch, 1) + uniform_dist = openmc.stats.Box(lower_left, upper_right) + rr_source = openmc.IndependentSource(space=uniform_dist) + + settings.random_ray['distance_active'] = 100.0 + settings.random_ray['distance_inactive'] = 20.0 + settings.random_ray['ray_source'] = rr_source + + ############################################################################### + # Define tallies + + # Create a mesh that will be used for tallying + mesh = openmc.RegularMesh() + mesh.dimension = (2, 2) + mesh.lower_left = (-pitch, -pitch) + mesh.upper_right = (pitch, pitch) + + # Create a mesh filter that can be used in a tally + mesh_filter = openmc.MeshFilter(mesh) + + # Create an energy group filter as well + energy_filter = openmc.EnergyFilter(group_edges) + + # Now use the mesh filter in a tally and indicate what scores are desired + tally = openmc.Tally(name="Mesh tally") + tally.filters = [mesh_filter, energy_filter] + tally.scores = ['flux', 'fission', 'nu-fission'] + tally.estimator = 'analog' + + # Instantiate a Tallies collection and export to XML + tallies = openmc.Tallies([tally]) + + ############################################################################### + # Exporting to OpenMC model + ############################################################################### + + model = openmc.Model() + model.geometry = geometry + model.materials = materials + model.settings = settings + model.tallies = tallies + return model + + +def test_random_ray_vacuum(): + harness = MGXSTestHarness('statepoint.10.h5', random_ray_model()) + harness.main() diff --git a/tests/regression_tests/random_ray_void/__init__.py b/tests/regression_tests/random_ray_void/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_void/flat/inputs_true.dat b/tests/regression_tests/random_ray_void/flat/inputs_true.dat deleted file mode 100644 index 66390c766..000000000 --- a/tests/regression_tests/random_ray_void/flat/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - flat - - - - - 1 - - - 2 - - - 3 - - - 6 - flux - tracklength - - - 5 - flux - tracklength - - - 4 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_void/flat/results_true.dat b/tests/regression_tests/random_ray_void/flat/results_true.dat deleted file mode 100644 index bd2f2d3b4..000000000 --- a/tests/regression_tests/random_ray_void/flat/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.354630E+00 -2.777456E-01 -tally 2: -1.056204E-01 -5.741779E-04 -tally 3: -7.286803E-03 -2.706427E-06 diff --git a/tests/regression_tests/random_ray_void/linear/inputs_true.dat b/tests/regression_tests/random_ray_void/linear/inputs_true.dat deleted file mode 100644 index 45228a039..000000000 --- a/tests/regression_tests/random_ray_void/linear/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - linear - - - - - 1 - - - 2 - - - 3 - - - 6 - flux - tracklength - - - 5 - flux - tracklength - - - 4 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_void/linear/results_true.dat b/tests/regression_tests/random_ray_void/linear/results_true.dat deleted file mode 100644 index befa507a5..000000000 --- a/tests/regression_tests/random_ray_void/linear/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.356818E+00 -2.782542E-01 -tally 2: -1.082843E-01 -6.028734E-04 -tally 3: -7.302705E-03 -2.718076E-06 diff --git a/tests/regression_tests/random_ray_void/test.py b/tests/regression_tests/random_ray_void/test.py deleted file mode 100644 index b48a7794d..000000000 --- a/tests/regression_tests/random_ray_void/test.py +++ /dev/null @@ -1,72 +0,0 @@ -import os - -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("shape", ["flat", "linear"]) -def test_random_ray_void(shape): - with change_directory(shape): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - - # There is some different logic for void depending on linear - # vs. flat, so we test both - model.settings.random_ray['source_shape'] = shape - - # As we are testing linear sources, need to have more than - # 10 inactive batches so the moments start getting computed - model.settings.inactive = 20 - model.settings.batches = 40 - - # Begin by getting handles to the cells, and setting the - # source and void areas to have no fill. We leave the absorber - # as solid. - absorber_cell = model.geometry.get_cells_by_name( - 'infinite absorber region', matching=True)[0] - void_cell = model.geometry.get_cells_by_name( - 'infinite void region', matching=True)[0] - source_cell = model.geometry.get_cells_by_name( - 'infinite source region', matching=True)[0] - - void_cell.fill = None - source_cell.fill = None - - # We also need to redefine all three tallies to use cell - # filters instead of material ones - estimator = 'tracklength' - absorber_filter = openmc.CellFilter(absorber_cell) - absorber_tally = openmc.Tally(name="Absorber Tally") - absorber_tally.filters = [absorber_filter] - absorber_tally.scores = ['flux'] - absorber_tally.estimator = estimator - - void_filter = openmc.CellFilter(void_cell) - void_tally = openmc.Tally(name="Void Tally") - void_tally.filters = [void_filter] - void_tally.scores = ['flux'] - void_tally.estimator = estimator - - source_filter = openmc.CellFilter(source_cell) - source_tally = openmc.Tally(name="Source Tally") - source_tally.filters = [source_filter] - source_tally.scores = ['flux'] - source_tally.estimator = estimator - - tallies = openmc.Tallies([source_tally, void_tally, absorber_tally]) - model.tallies = tallies - - harness = MGXSTestHarness('statepoint.40.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_volume_estimator/__init__.py b/tests/regression_tests/random_ray_volume_estimator/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_volume_estimator/hybrid/inputs_true.dat b/tests/regression_tests/random_ray_volume_estimator/hybrid/inputs_true.dat deleted file mode 100644 index 4d1af46b1..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/hybrid/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - hybrid - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_volume_estimator/hybrid/results_true.dat b/tests/regression_tests/random_ray_volume_estimator/hybrid/results_true.dat deleted file mode 100644 index 6da51a711..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/hybrid/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.934460E-01 -7.058894E-02 -tally 2: -3.206214E-02 -2.063370E-04 -tally 3: -2.096411E-03 -8.804924E-07 diff --git a/tests/regression_tests/random_ray_volume_estimator/naive/inputs_true.dat b/tests/regression_tests/random_ray_volume_estimator/naive/inputs_true.dat deleted file mode 100644 index a268d55d0..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/naive/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - naive - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_volume_estimator/naive/results_true.dat b/tests/regression_tests/random_ray_volume_estimator/naive/results_true.dat deleted file mode 100644 index f8d6d10b0..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/naive/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -5.935538E-01 -7.061433E-02 -tally 2: -3.263210E-02 -2.134164E-04 -tally 3: -2.107977E-03 -8.905227E-07 diff --git a/tests/regression_tests/random_ray_volume_estimator/simulation_averaged/inputs_true.dat b/tests/regression_tests/random_ray_volume_estimator/simulation_averaged/inputs_true.dat deleted file mode 100644 index 777ccaea5..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/simulation_averaged/inputs_true.dat +++ /dev/null @@ -1,247 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - simulation_averaged - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_volume_estimator/simulation_averaged/results_true.dat b/tests/regression_tests/random_ray_volume_estimator/simulation_averaged/results_true.dat deleted file mode 100644 index 5f2975860..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/simulation_averaged/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: --5.745886E+02 -9.758367E+04 -tally 2: -2.971927E-02 -1.827222E-04 -tally 3: -1.978393E-03 -7.951531E-07 diff --git a/tests/regression_tests/random_ray_volume_estimator/test.py b/tests/regression_tests/random_ray_volume_estimator/test.py deleted file mode 100644 index fba4bbbbe..000000000 --- a/tests/regression_tests/random_ray_volume_estimator/test.py +++ /dev/null @@ -1,30 +0,0 @@ -import os - -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("estimator", ["hybrid", - "simulation_averaged", - "naive" - ]) -def test_random_ray_volume_estimator(estimator): - with change_directory(estimator): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - model.settings.random_ray['volume_estimator'] = estimator - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/__init__.py b/tests/regression_tests/random_ray_volume_estimator_linear/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/hybrid/inputs_true.dat b/tests/regression_tests/random_ray_volume_estimator_linear/hybrid/inputs_true.dat deleted file mode 100644 index dd11567f6..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/hybrid/inputs_true.dat +++ /dev/null @@ -1,248 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - linear - hybrid - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/hybrid/results_true.dat b/tests/regression_tests/random_ray_volume_estimator_linear/hybrid/results_true.dat deleted file mode 100644 index e90d6bfdc..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/hybrid/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.339086E+00 -2.747305E-01 -tally 2: -1.089827E-01 -6.069324E-04 -tally 3: -7.300831E-03 -2.715940E-06 diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/naive/inputs_true.dat b/tests/regression_tests/random_ray_volume_estimator_linear/naive/inputs_true.dat deleted file mode 100644 index 6933fba43..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/naive/inputs_true.dat +++ /dev/null @@ -1,248 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - linear - naive - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/naive/results_true.dat b/tests/regression_tests/random_ray_volume_estimator_linear/naive/results_true.dat deleted file mode 100644 index 5258ffd9c..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/naive/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.339567E+00 -2.748423E-01 -tally 2: -1.085878E-01 -6.024509E-04 -tally 3: -7.299803E-03 -2.741867E-06 diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/simulation_averaged/inputs_true.dat b/tests/regression_tests/random_ray_volume_estimator_linear/simulation_averaged/inputs_true.dat deleted file mode 100644 index 3ccab1d21..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/simulation_averaged/inputs_true.dat +++ /dev/null @@ -1,248 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 40 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - linear - simulation_averaged - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/simulation_averaged/results_true.dat b/tests/regression_tests/random_ray_volume_estimator_linear/simulation_averaged/results_true.dat deleted file mode 100644 index 1e8aa9fb7..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/simulation_averaged/results_true.dat +++ /dev/null @@ -1,9 +0,0 @@ -tally 1: -2.670850E+02 -4.432939E+05 -tally 2: -1.116994E-01 -6.491358E-04 -tally 3: -7.564527E-03 -2.947794E-06 diff --git a/tests/regression_tests/random_ray_volume_estimator_linear/test.py b/tests/regression_tests/random_ray_volume_estimator_linear/test.py deleted file mode 100644 index 94a14f3ad..000000000 --- a/tests/regression_tests/random_ray_volume_estimator_linear/test.py +++ /dev/null @@ -1,32 +0,0 @@ -import os - -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import TolerantPyAPITestHarness - - -class MGXSTestHarness(TolerantPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("estimator", ["hybrid", - "simulation_averaged", - "naive" - ]) -def test_random_ray_volume_estimator_linear(estimator): - with change_directory(estimator): - openmc.reset_auto_ids() - model = random_ray_three_region_cube() - model.settings.random_ray['source_shape'] = 'linear' - model.settings.random_ray['volume_estimator'] = estimator - model.settings.inactive = 20 - model.settings.batches = 40 - harness = MGXSTestHarness('statepoint.40.h5', model) - harness.main() diff --git a/tests/regression_tests/reflective_plane/results_true.dat b/tests/regression_tests/reflective_plane/results_true.dat index a4d6edb67..a1acfaad7 100644 --- a/tests/regression_tests/reflective_plane/results_true.dat +++ b/tests/regression_tests/reflective_plane/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.279066E+00 4.793565E-03 +2.276857E+00 8.776678E-03 diff --git a/tests/regression_tests/resonance_scattering/inputs_true.dat b/tests/regression_tests/resonance_scattering/inputs_true.dat index ebe6a5dbe..dba4535c2 100644 --- a/tests/regression_tests/resonance_scattering/inputs_true.dat +++ b/tests/regression_tests/resonance_scattering/inputs_true.dat @@ -1,24 +1,24 @@ - - - - - - + + + + + + - + eigenvalue 1000 10 5 - + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/resonance_scattering/results_true.dat b/tests/regression_tests/resonance_scattering/results_true.dat index 72f0933b8..8316e720e 100644 --- a/tests/regression_tests/resonance_scattering/results_true.dat +++ b/tests/regression_tests/resonance_scattering/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.462428E+00 1.828903E-02 +1.462509E+00 2.205413E-02 diff --git a/tests/regression_tests/rotation/results_true.dat b/tests/regression_tests/rotation/results_true.dat index 6db3d329a..0fb8ba981 100644 --- a/tests/regression_tests/rotation/results_true.dat +++ b/tests/regression_tests/rotation/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.459219E-01 1.899168E-02 +4.175600E-01 1.117465E-02 diff --git a/tests/regression_tests/salphabeta/inputs_true.dat b/tests/regression_tests/salphabeta/inputs_true.dat index 56f4be375..ef0e843c2 100644 --- a/tests/regression_tests/salphabeta/inputs_true.dat +++ b/tests/regression_tests/salphabeta/inputs_true.dat @@ -1,36 +1,36 @@ - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + @@ -40,18 +40,18 @@ - - - - - + + + + + eigenvalue 400 5 0 - + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/salphabeta/results_true.dat b/tests/regression_tests/salphabeta/results_true.dat index 75a81075e..d5c7f66e9 100644 --- a/tests/regression_tests/salphabeta/results_true.dat +++ b/tests/regression_tests/salphabeta/results_true.dat @@ -1,2 +1,2 @@ k-combined: -8.628529E-01 3.120924E-02 +8.694866E-01 2.033328E-02 diff --git a/tests/regression_tests/score_current/inputs_true.dat b/tests/regression_tests/score_current/inputs_true.dat index 42c2d3df2..9ea8e5e4a 100644 --- a/tests/regression_tests/score_current/inputs_true.dat +++ b/tests/regression_tests/score_current/inputs_true.dat @@ -1,28 +1,28 @@ - - - + + + - - + + - - - - - - - - - - - + + + + + + + + + + + eigenvalue diff --git a/tests/regression_tests/score_current/results_true.dat b/tests/regression_tests/score_current/results_true.dat index 6bb74445c..ff939301d 100644 --- a/tests/regression_tests/score_current/results_true.dat +++ b/tests/regression_tests/score_current/results_true.dat @@ -1,652 +1,652 @@ k-combined: -7.729082E-01 3.775399E-02 +2.298294E-01 3.256961E-01 tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.200000E-01 -2.924000E-03 -1.740000E-01 -6.270000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.200000E-01 -3.044000E-03 -1.510000E-01 -4.615000E-03 -1.710000E-01 -6.067000E-03 -0.000000E+00 -0.000000E+00 -6.500000E-02 -9.390000E-04 -1.410000E-01 -4.001000E-03 -1.740000E-01 -6.270000E-03 -1.200000E-01 -2.924000E-03 -1.830000E-01 -6.879000E-03 -1.310000E-01 -3.541000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.750000E-01 -6.659000E-03 -2.820000E-01 -1.605400E-02 -1.980000E-01 -7.932000E-03 -0.000000E+00 -0.000000E+00 -9.400000E-02 -1.912000E-03 -2.200000E-01 -9.958000E-03 -1.310000E-01 -3.541000E-03 -1.830000E-01 -6.879000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +1.150000E-01 +2.753000E-03 +1.820000E-01 +6.756000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.110000E-01 -2.639000E-03 -1.360000E-01 -3.890000E-03 -1.770000E-01 -6.551000E-03 +2.601000E-03 +1.530000E-01 +4.865000E-03 +1.910000E-01 +7.535000E-03 0.000000E+00 0.000000E+00 -6.700000E-02 -9.310000E-04 -1.570000E-01 -4.975000E-03 +7.100000E-02 +1.079000E-03 +1.500000E-01 +4.606000E-03 +1.820000E-01 +6.756000E-03 +1.150000E-01 +2.753000E-03 +1.610000E-01 +5.383000E-03 +1.230000E-01 +3.141000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.951000E-03 +2.600000E-01 +1.366400E-02 +1.930000E-01 +7.573000E-03 +0.000000E+00 +0.000000E+00 +8.500000E-02 +1.533000E-03 +2.040000E-01 +8.426000E-03 +1.230000E-01 +3.141000E-03 +1.610000E-01 +5.383000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.250000E-01 +3.311000E-03 +1.620000E-01 +5.346000E-03 +1.860000E-01 +6.932000E-03 +0.000000E+00 +0.000000E+00 +7.100000E-02 +1.083000E-03 +1.630000E-01 +5.617000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.480000E-01 -4.910000E-03 -2.720000E-01 -1.490600E-02 -1.510000E-01 -4.615000E-03 -1.200000E-01 -3.044000E-03 1.800000E-01 -6.720000E-03 -1.050000E-01 -2.285000E-03 +7.002000E-03 +2.980000E-01 +1.815000E-02 +1.530000E-01 +4.865000E-03 +1.110000E-01 +2.601000E-03 +1.890000E-01 +7.605000E-03 +1.330000E-01 +3.743000E-03 1.790000E-01 -6.499000E-03 +6.495000E-03 +0.000000E+00 +0.000000E+00 +1.080000E-01 +2.718000E-03 +2.160000E-01 +9.662000E-03 +2.980000E-01 +1.815000E-02 +1.800000E-01 +7.002000E-03 +2.650000E-01 +1.435500E-02 +1.590000E-01 +5.285000E-03 +2.600000E-01 +1.366400E-02 +1.370000E-01 +3.951000E-03 +2.670000E-01 +1.469300E-02 +1.940000E-01 +7.678000E-03 +2.390000E-01 +1.155500E-02 +0.000000E+00 +0.000000E+00 +2.410000E-01 +1.255900E-02 +5.510000E-01 +7.358900E-02 +1.590000E-01 +5.285000E-03 +2.650000E-01 +1.435500E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.620000E-01 +5.346000E-03 +1.250000E-01 +3.311000E-03 +1.870000E-01 +7.083000E-03 +1.410000E-01 +3.999000E-03 +2.040000E-01 +8.438000E-03 0.000000E+00 0.000000E+00 9.300000E-02 -1.927000E-03 -2.160000E-01 -9.418000E-03 -2.720000E-01 -1.490600E-02 -1.480000E-01 -4.910000E-03 -2.680000E-01 -1.445800E-02 -1.480000E-01 -4.488000E-03 -2.820000E-01 -1.605400E-02 +1.829000E-03 +2.240000E-01 +1.015800E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.500000E-01 +4.522000E-03 +1.630000E-01 +5.439000E-03 +1.330000E-01 +3.743000E-03 +1.890000E-01 +7.605000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.650000E-01 +5.615000E-03 +0.000000E+00 +0.000000E+00 +7.100000E-02 +1.191000E-03 +1.550000E-01 +5.011000E-03 +1.630000E-01 +5.439000E-03 +1.500000E-01 +4.522000E-03 +1.680000E-01 +5.966000E-03 +1.290000E-01 +3.515000E-03 +1.940000E-01 +7.678000E-03 +2.670000E-01 +1.469300E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.810000E-01 +6.765000E-03 +0.000000E+00 +0.000000E+00 +1.080000E-01 +2.694000E-03 +2.070000E-01 +8.673000E-03 +1.290000E-01 +3.515000E-03 +1.680000E-01 +5.966000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.410000E-01 +3.999000E-03 +1.870000E-01 +7.083000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.870000E-01 +7.213000E-03 +0.000000E+00 +0.000000E+00 +8.200000E-02 +1.536000E-03 +1.760000E-01 +6.550000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 1.750000E-01 -6.659000E-03 -2.510000E-01 -1.283100E-02 -1.870000E-01 -7.731000E-03 -2.340000E-01 -1.105000E-02 -0.000000E+00 -0.000000E+00 -2.110000E-01 -9.215000E-03 -5.470000E-01 -7.228300E-02 -1.480000E-01 -4.488000E-03 -2.680000E-01 -1.445800E-02 +6.163000E-03 +2.570000E-01 +1.347100E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.560000E-01 +4.914000E-03 +2.350000E-01 +1.135900E-02 +1.500000E-01 +4.606000E-03 +7.100000E-02 +1.079000E-03 +1.530000E-01 +4.837000E-03 +5.600000E-02 +7.260000E-04 +2.570000E-01 +1.347100E-02 +1.750000E-01 +6.163000E-03 +2.460000E-01 +1.235000E-02 +1.420000E-01 +4.326000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.830000E-01 +7.133000E-03 +5.110000E-01 +5.696100E-02 +2.040000E-01 +8.426000E-03 +8.500000E-02 +1.533000E-03 +2.100000E-01 +8.928000E-03 +9.100000E-02 +1.807000E-03 +1.420000E-01 +4.326000E-03 +2.460000E-01 +1.235000E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.430000E-01 +4.207000E-03 +2.120000E-01 +9.278000E-03 +1.630000E-01 +5.617000E-03 +7.100000E-02 +1.083000E-03 +1.770000E-01 +6.293000E-03 +7.900000E-02 +1.495000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.300000E-01 +1.081000E-02 +5.200000E-01 +5.835000E-02 +2.350000E-01 +1.135900E-02 +1.560000E-01 +4.914000E-03 +2.370000E-01 +1.142300E-02 1.360000E-01 -3.890000E-03 -1.110000E-01 -2.639000E-03 -1.540000E-01 -4.804000E-03 -1.280000E-01 -3.302000E-03 -2.200000E-01 -9.834000E-03 -0.000000E+00 -0.000000E+00 -9.900000E-02 -2.127000E-03 -1.860000E-01 -7.198000E-03 +3.882000E-03 +2.160000E-01 +9.662000E-03 +1.080000E-01 +2.718000E-03 +2.090000E-01 +8.841000E-03 +1.030000E-01 +2.271000E-03 +5.200000E-01 +5.835000E-02 +2.300000E-01 +1.081000E-02 +5.110000E-01 +5.615900E-02 +2.430000E-01 +1.228300E-02 +5.110000E-01 +5.696100E-02 +1.830000E-01 +7.133000E-03 +5.130000E-01 +6.002100E-02 +2.420000E-01 +1.209200E-02 +5.510000E-01 +7.358900E-02 +2.410000E-01 +1.255900E-02 +5.140000E-01 +5.890200E-02 +2.100000E-01 +1.004600E-02 +2.430000E-01 +1.228300E-02 +5.110000E-01 +5.615900E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +2.120000E-01 +9.278000E-03 1.430000E-01 -4.337000E-03 -1.580000E-01 -5.104000E-03 -1.050000E-01 -2.285000E-03 -1.800000E-01 -6.720000E-03 +4.207000E-03 +2.380000E-01 +1.133600E-02 +1.640000E-01 +5.444000E-03 +2.240000E-01 +1.015800E-02 +9.300000E-02 +1.829000E-03 +1.950000E-01 +7.705000E-03 +1.030000E-01 +2.191000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.860000E-01 -7.178000E-03 -0.000000E+00 -0.000000E+00 -7.000000E-02 -1.020000E-03 -1.610000E-01 -5.237000E-03 -1.580000E-01 -5.104000E-03 -1.430000E-01 -4.337000E-03 -1.580000E-01 -5.254000E-03 -1.230000E-01 -3.091000E-03 -1.870000E-01 -7.731000E-03 -2.510000E-01 -1.283100E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.980000E-01 -7.934000E-03 -0.000000E+00 -0.000000E+00 -9.500000E-02 -1.949000E-03 -2.150000E-01 -9.289000E-03 -1.230000E-01 -3.091000E-03 -1.580000E-01 -5.254000E-03 +1.680000E-01 +5.878000E-03 +2.230000E-01 +1.049900E-02 +1.360000E-01 +3.882000E-03 +2.370000E-01 +1.142300E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.550000E-01 +5.011000E-03 +7.100000E-02 +1.191000E-03 +1.510000E-01 +4.845000E-03 +6.400000E-02 +9.460000E-04 +2.230000E-01 +1.049900E-02 +1.680000E-01 +5.878000E-03 +2.490000E-01 +1.255900E-02 1.280000E-01 -3.302000E-03 -1.540000E-01 -4.804000E-03 +3.448000E-03 +2.420000E-01 +1.209200E-02 +5.130000E-01 +6.002100E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.070000E-01 +8.673000E-03 +1.080000E-01 +2.694000E-03 +2.000000E-01 +8.202000E-03 +9.600000E-02 +2.024000E-03 +1.280000E-01 +3.448000E-03 +2.490000E-01 +1.255900E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.640000E-01 -5.424000E-03 -0.000000E+00 -0.000000E+00 -6.200000E-02 -8.020000E-04 -1.500000E-01 -4.588000E-03 +5.444000E-03 +2.380000E-01 +1.133600E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.700000E-01 -5.884000E-03 -2.280000E-01 -1.084800E-02 +1.760000E-01 +6.550000E-03 +8.200000E-02 +1.536000E-03 +1.670000E-01 +5.653000E-03 +4.900000E-02 +5.630000E-04 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.540000E-01 -4.856000E-03 -2.250000E-01 -1.047100E-02 -1.410000E-01 -4.001000E-03 -6.500000E-02 -9.390000E-04 -1.360000E-01 -3.852000E-03 -6.400000E-02 -8.700000E-04 -2.280000E-01 -1.084800E-02 -1.700000E-01 -5.884000E-03 -2.230000E-01 -1.001100E-02 -1.410000E-01 -4.185000E-03 +1.320000E-01 +3.626000E-03 +1.510000E-01 +4.831000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.980000E-01 -8.038000E-03 -5.030000E-01 -5.613900E-02 -2.200000E-01 -9.958000E-03 -9.400000E-02 -1.912000E-03 -2.140000E-01 -9.376000E-03 -7.300000E-02 -1.091000E-03 -1.410000E-01 -4.185000E-03 -2.230000E-01 -1.001100E-02 +1.370000E-01 +3.855000E-03 +1.610000E-01 +5.233000E-03 +5.600000E-02 +7.260000E-04 +1.530000E-01 +4.837000E-03 +1.610000E-01 +5.261000E-03 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.540000E-01 -4.808000E-03 -2.340000E-01 -1.119400E-02 -1.570000E-01 -4.975000E-03 -6.700000E-02 -9.310000E-04 -1.600000E-01 -5.134000E-03 -5.300000E-02 -6.110000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.310000E-01 -1.084100E-02 -5.390000E-01 -6.215100E-02 -2.250000E-01 -1.047100E-02 -1.540000E-01 -4.856000E-03 -2.280000E-01 -1.059800E-02 -1.600000E-01 -5.214000E-03 -2.160000E-01 -9.418000E-03 -9.300000E-02 -1.927000E-03 -2.510000E-01 -1.271500E-02 -1.030000E-01 -2.229000E-03 -5.390000E-01 -6.215100E-02 -2.310000E-01 -1.084100E-02 -4.700000E-01 -4.972200E-02 -2.190000E-01 -9.821000E-03 -5.030000E-01 -5.613900E-02 -1.980000E-01 -8.038000E-03 -5.100000E-01 -5.929000E-02 -2.140000E-01 -9.406000E-03 -5.470000E-01 -7.228300E-02 -2.110000E-01 -9.215000E-03 -5.160000E-01 -5.892200E-02 -2.550000E-01 -1.480500E-02 -2.190000E-01 -9.821000E-03 -4.700000E-01 -4.972200E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.340000E-01 -1.119400E-02 -1.540000E-01 -4.808000E-03 -2.170000E-01 -9.509000E-03 -1.600000E-01 -5.156000E-03 -1.860000E-01 -7.198000E-03 -9.900000E-02 -2.127000E-03 -2.290000E-01 -1.058700E-02 -9.000000E-02 -1.780000E-03 +1.510000E-01 +4.831000E-03 +1.320000E-01 +3.626000E-03 +1.490000E-01 +4.731000E-03 +1.320000E-01 +3.514000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.550000E-01 -4.913000E-03 -2.380000E-01 -1.153400E-02 +4.921000E-03 +2.410000E-01 +1.168300E-02 +9.100000E-02 +1.807000E-03 +2.100000E-01 +8.928000E-03 +2.090000E-01 +8.775000E-03 +0.000000E+00 +0.000000E+00 +1.320000E-01 +3.514000E-03 +1.490000E-01 +4.731000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.150000E-01 +2.891000E-03 +1.560000E-01 +5.154000E-03 +7.900000E-02 +1.495000E-03 +1.770000E-01 +6.293000E-03 1.600000E-01 -5.214000E-03 -2.280000E-01 -1.059800E-02 +5.352000E-03 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.610000E-01 -5.237000E-03 -7.000000E-02 -1.020000E-03 -1.410000E-01 -4.071000E-03 -6.100000E-02 -8.350000E-04 -2.380000E-01 -1.153400E-02 -1.550000E-01 -4.913000E-03 -2.320000E-01 -1.100400E-02 -1.460000E-01 -4.498000E-03 -2.140000E-01 -9.406000E-03 -5.100000E-01 -5.929000E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.150000E-01 -9.289000E-03 -9.500000E-02 -1.949000E-03 -1.870000E-01 -7.267000E-03 -1.030000E-01 -2.543000E-03 -1.460000E-01 -4.498000E-03 -2.320000E-01 -1.100400E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.600000E-01 -5.156000E-03 -2.170000E-01 -9.509000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.500000E-01 -4.588000E-03 -6.200000E-02 -8.020000E-04 -1.290000E-01 -3.487000E-03 -6.000000E-02 -8.060000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.090000E-01 -2.437000E-03 -1.650000E-01 -5.655000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.065000E-03 -1.570000E-01 -4.999000E-03 -6.400000E-02 -8.700000E-04 -1.360000E-01 -3.852000E-03 -1.750000E-01 -6.299000E-03 -0.000000E+00 -0.000000E+00 -1.650000E-01 -5.655000E-03 -1.090000E-01 -2.437000E-03 -1.480000E-01 -4.674000E-03 -1.320000E-01 -3.548000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.440000E-01 -4.282000E-03 -2.190000E-01 -9.683000E-03 -7.300000E-02 -1.091000E-03 -2.140000E-01 -9.376000E-03 -1.830000E-01 -6.803000E-03 -0.000000E+00 -0.000000E+00 -1.320000E-01 -3.548000E-03 -1.480000E-01 -4.674000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.350000E-01 -3.895000E-03 -1.430000E-01 -4.297000E-03 -5.300000E-02 -6.110000E-04 -1.600000E-01 -5.134000E-03 -1.380000E-01 -4.220000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.900000E-01 -7.412000E-03 -2.420000E-01 -1.208400E-02 -1.570000E-01 -4.999000E-03 -1.230000E-01 -3.065000E-03 -1.730000E-01 -6.279000E-03 -1.330000E-01 -3.621000E-03 -1.030000E-01 -2.229000E-03 -2.510000E-01 -1.271500E-02 -2.100000E-01 -8.970000E-03 -0.000000E+00 -0.000000E+00 -2.420000E-01 -1.208400E-02 -1.900000E-01 -7.412000E-03 -2.610000E-01 -1.399900E-02 -2.000000E-01 -8.410000E-03 -2.190000E-01 -9.683000E-03 -1.440000E-01 -4.282000E-03 -2.690000E-01 -1.478100E-02 -1.540000E-01 -4.986000E-03 -2.550000E-01 -1.480500E-02 -5.160000E-01 -5.892200E-02 +5.273000E-03 2.310000E-01 -1.098900E-02 -0.000000E+00 -0.000000E+00 -2.000000E-01 -8.410000E-03 -2.610000E-01 -1.399900E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.430000E-01 -4.297000E-03 -1.350000E-01 -3.895000E-03 +1.098100E-02 +1.610000E-01 +5.233000E-03 +1.370000E-01 +3.855000E-03 1.760000E-01 -6.534000E-03 -1.170000E-01 -2.807000E-03 -9.000000E-02 -1.780000E-03 -2.290000E-01 -1.058700E-02 -2.080000E-01 -8.854000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.305000E-03 -1.760000E-01 -6.598000E-03 -1.330000E-01 -3.621000E-03 -1.730000E-01 -6.279000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -6.100000E-02 -8.350000E-04 -1.410000E-01 -4.071000E-03 -1.800000E-01 -6.574000E-03 -0.000000E+00 -0.000000E+00 -1.760000E-01 -6.598000E-03 -1.230000E-01 -3.305000E-03 -1.690000E-01 -6.135000E-03 -1.220000E-01 -3.344000E-03 -1.540000E-01 -4.986000E-03 -2.690000E-01 -1.478100E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +6.482000E-03 +1.340000E-01 +3.882000E-03 1.030000E-01 -2.543000E-03 -1.870000E-01 -7.267000E-03 -1.690000E-01 -5.731000E-03 +2.271000E-03 +2.090000E-01 +8.841000E-03 +1.830000E-01 +6.761000E-03 0.000000E+00 0.000000E+00 -1.220000E-01 -3.344000E-03 -1.690000E-01 -6.135000E-03 +2.310000E-01 +1.098100E-02 +1.610000E-01 +5.273000E-03 +2.620000E-01 +1.380600E-02 +1.700000E-01 +5.970000E-03 +2.410000E-01 +1.168300E-02 +1.550000E-01 +4.921000E-03 +2.250000E-01 +1.014100E-02 +1.370000E-01 +3.805000E-03 +2.100000E-01 +1.004600E-02 +5.140000E-01 +5.890200E-02 +2.320000E-01 +1.093000E-02 0.000000E+00 0.000000E+00 +1.700000E-01 +5.970000E-03 +2.620000E-01 +1.380600E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.560000E-01 +5.154000E-03 +1.150000E-01 +2.891000E-03 +1.430000E-01 +4.163000E-03 +1.120000E-01 +2.640000E-03 +1.030000E-01 +2.191000E-03 +1.950000E-01 +7.705000E-03 +1.760000E-01 +6.392000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.200000E-02 +1.822000E-03 +1.370000E-01 +3.843000E-03 +1.340000E-01 +3.882000E-03 +1.760000E-01 +6.482000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.400000E-02 +9.460000E-04 +1.510000E-01 +4.845000E-03 +1.800000E-01 +6.520000E-03 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.843000E-03 +9.200000E-02 +1.822000E-03 +1.300000E-01 +3.604000E-03 +1.170000E-01 +2.789000E-03 +1.370000E-01 +3.805000E-03 +2.250000E-01 +1.014100E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.600000E-02 +2.024000E-03 +2.000000E-01 +8.202000E-03 +1.820000E-01 +6.660000E-03 0.000000E+00 0.000000E+00 1.170000E-01 -2.807000E-03 -1.760000E-01 -6.534000E-03 +2.789000E-03 +1.300000E-01 +3.604000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -6.000000E-02 -8.060000E-04 -1.290000E-01 -3.487000E-03 -1.790000E-01 -6.747000E-03 +1.120000E-01 +2.640000E-03 +1.430000E-01 +4.163000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.900000E-02 +5.630000E-04 +1.670000E-01 +5.653000E-03 +1.670000E-01 +5.701000E-03 0.000000E+00 0.000000E+00 tally 2: @@ -660,108 +660,12 @@ tally 2: 0.000000E+00 0.000000E+00 0.000000E+00 -1.200000E-01 -2.924000E-03 -0.000000E+00 -0.000000E+00 -1.740000E-01 -6.270000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.200000E-01 -3.044000E-03 -0.000000E+00 -0.000000E+00 -1.510000E-01 -4.615000E-03 -0.000000E+00 -0.000000E+00 -1.710000E-01 -6.067000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -6.500000E-02 -9.390000E-04 -0.000000E+00 -0.000000E+00 -1.410000E-01 -4.001000E-03 -0.000000E+00 -0.000000E+00 -1.740000E-01 -6.270000E-03 -0.000000E+00 -0.000000E+00 -1.200000E-01 -2.924000E-03 -0.000000E+00 -0.000000E+00 -1.830000E-01 -6.879000E-03 -0.000000E+00 -0.000000E+00 -1.310000E-01 -3.541000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.750000E-01 -6.659000E-03 -0.000000E+00 -0.000000E+00 -2.820000E-01 -1.605400E-02 -0.000000E+00 -0.000000E+00 -1.980000E-01 -7.932000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.400000E-02 -1.912000E-03 -0.000000E+00 -0.000000E+00 -2.200000E-01 -9.958000E-03 -0.000000E+00 -0.000000E+00 -1.310000E-01 -3.541000E-03 -0.000000E+00 -0.000000E+00 -1.830000E-01 -6.879000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +1.150000E-01 +2.753000E-03 0.000000E+00 0.000000E+00 +1.820000E-01 +6.756000E-03 0.000000E+00 0.000000E+00 0.000000E+00 @@ -773,27 +677,43 @@ tally 2: 0.000000E+00 0.000000E+00 1.110000E-01 -2.639000E-03 +2.601000E-03 0.000000E+00 0.000000E+00 -1.360000E-01 -3.890000E-03 +1.530000E-01 +4.865000E-03 0.000000E+00 0.000000E+00 -1.770000E-01 -6.551000E-03 +1.910000E-01 +7.535000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -6.700000E-02 -9.310000E-04 +7.100000E-02 +1.079000E-03 0.000000E+00 0.000000E+00 -1.570000E-01 -4.975000E-03 +1.500000E-01 +4.606000E-03 +0.000000E+00 +0.000000E+00 +1.820000E-01 +6.756000E-03 +0.000000E+00 +0.000000E+00 +1.150000E-01 +2.753000E-03 +0.000000E+00 +0.000000E+00 +1.610000E-01 +5.383000E-03 +0.000000E+00 +0.000000E+00 +1.230000E-01 +3.141000E-03 0.000000E+00 0.000000E+00 0.000000E+00 @@ -804,32 +724,208 @@ tally 2: 0.000000E+00 0.000000E+00 0.000000E+00 -1.480000E-01 -4.910000E-03 +1.370000E-01 +3.951000E-03 +0.000000E+00 +0.000000E+00 +2.600000E-01 +1.366400E-02 +0.000000E+00 +0.000000E+00 +1.930000E-01 +7.573000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +8.500000E-02 +1.533000E-03 +0.000000E+00 +0.000000E+00 +2.040000E-01 +8.426000E-03 +0.000000E+00 +0.000000E+00 +1.230000E-01 +3.141000E-03 +0.000000E+00 +0.000000E+00 +1.610000E-01 +5.383000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.250000E-01 +3.311000E-03 +0.000000E+00 +0.000000E+00 +1.620000E-01 +5.346000E-03 +0.000000E+00 +0.000000E+00 +1.860000E-01 +6.932000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.100000E-02 +1.083000E-03 +0.000000E+00 +0.000000E+00 +1.630000E-01 +5.617000E-03 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 -2.720000E-01 -1.490600E-02 0.000000E+00 0.000000E+00 -1.510000E-01 -4.615000E-03 0.000000E+00 0.000000E+00 -1.200000E-01 -3.044000E-03 0.000000E+00 0.000000E+00 1.800000E-01 -6.720000E-03 +7.002000E-03 0.000000E+00 0.000000E+00 -1.050000E-01 -2.285000E-03 +2.980000E-01 +1.815000E-02 +0.000000E+00 +0.000000E+00 +1.530000E-01 +4.865000E-03 +0.000000E+00 +0.000000E+00 +1.110000E-01 +2.601000E-03 +0.000000E+00 +0.000000E+00 +1.890000E-01 +7.605000E-03 +0.000000E+00 +0.000000E+00 +1.330000E-01 +3.743000E-03 0.000000E+00 0.000000E+00 1.790000E-01 -6.499000E-03 +6.495000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.080000E-01 +2.718000E-03 +0.000000E+00 +0.000000E+00 +2.160000E-01 +9.662000E-03 +0.000000E+00 +0.000000E+00 +2.980000E-01 +1.815000E-02 +0.000000E+00 +0.000000E+00 +1.800000E-01 +7.002000E-03 +0.000000E+00 +0.000000E+00 +2.650000E-01 +1.435500E-02 +0.000000E+00 +0.000000E+00 +1.590000E-01 +5.285000E-03 +0.000000E+00 +0.000000E+00 +2.600000E-01 +1.366400E-02 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.951000E-03 +0.000000E+00 +0.000000E+00 +2.670000E-01 +1.469300E-02 +0.000000E+00 +0.000000E+00 +1.940000E-01 +7.678000E-03 +0.000000E+00 +0.000000E+00 +2.390000E-01 +1.155500E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.410000E-01 +1.255900E-02 +0.000000E+00 +0.000000E+00 +5.510000E-01 +7.358900E-02 +0.000000E+00 +0.000000E+00 +1.590000E-01 +5.285000E-03 +0.000000E+00 +0.000000E+00 +2.650000E-01 +1.435500E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.620000E-01 +5.346000E-03 +0.000000E+00 +0.000000E+00 +1.250000E-01 +3.311000E-03 +0.000000E+00 +0.000000E+00 +1.870000E-01 +7.083000E-03 +0.000000E+00 +0.000000E+00 +1.410000E-01 +3.999000E-03 +0.000000E+00 +0.000000E+00 +2.040000E-01 +8.438000E-03 0.000000E+00 0.000000E+00 0.000000E+00 @@ -837,67 +933,171 @@ tally 2: 0.000000E+00 0.000000E+00 9.300000E-02 -1.927000E-03 +1.829000E-03 0.000000E+00 0.000000E+00 -2.160000E-01 -9.418000E-03 +2.240000E-01 +1.015800E-02 0.000000E+00 0.000000E+00 -2.720000E-01 -1.490600E-02 0.000000E+00 0.000000E+00 -1.480000E-01 -4.910000E-03 0.000000E+00 0.000000E+00 -2.680000E-01 -1.445800E-02 0.000000E+00 0.000000E+00 -1.480000E-01 -4.488000E-03 0.000000E+00 0.000000E+00 -2.820000E-01 -1.605400E-02 +1.500000E-01 +4.522000E-03 +0.000000E+00 +0.000000E+00 +1.630000E-01 +5.439000E-03 +0.000000E+00 +0.000000E+00 +1.330000E-01 +3.743000E-03 +0.000000E+00 +0.000000E+00 +1.890000E-01 +7.605000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.650000E-01 +5.615000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.100000E-02 +1.191000E-03 +0.000000E+00 +0.000000E+00 +1.550000E-01 +5.011000E-03 +0.000000E+00 +0.000000E+00 +1.630000E-01 +5.439000E-03 +0.000000E+00 +0.000000E+00 +1.500000E-01 +4.522000E-03 +0.000000E+00 +0.000000E+00 +1.680000E-01 +5.966000E-03 +0.000000E+00 +0.000000E+00 +1.290000E-01 +3.515000E-03 +0.000000E+00 +0.000000E+00 +1.940000E-01 +7.678000E-03 +0.000000E+00 +0.000000E+00 +2.670000E-01 +1.469300E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.810000E-01 +6.765000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.080000E-01 +2.694000E-03 +0.000000E+00 +0.000000E+00 +2.070000E-01 +8.673000E-03 +0.000000E+00 +0.000000E+00 +1.290000E-01 +3.515000E-03 +0.000000E+00 +0.000000E+00 +1.680000E-01 +5.966000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.410000E-01 +3.999000E-03 +0.000000E+00 +0.000000E+00 +1.870000E-01 +7.083000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.870000E-01 +7.213000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +8.200000E-02 +1.536000E-03 +0.000000E+00 +0.000000E+00 +1.760000E-01 +6.550000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 1.750000E-01 -6.659000E-03 +6.163000E-03 0.000000E+00 0.000000E+00 -2.510000E-01 -1.283100E-02 -0.000000E+00 -0.000000E+00 -1.870000E-01 -7.731000E-03 -0.000000E+00 -0.000000E+00 -2.340000E-01 -1.105000E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.110000E-01 -9.215000E-03 -0.000000E+00 -0.000000E+00 -5.470000E-01 -7.228300E-02 -0.000000E+00 -0.000000E+00 -1.480000E-01 -4.488000E-03 -0.000000E+00 -0.000000E+00 -2.680000E-01 -1.445800E-02 +2.570000E-01 +1.347100E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -908,36 +1108,228 @@ tally 2: 0.000000E+00 0.000000E+00 0.000000E+00 +1.560000E-01 +4.914000E-03 +0.000000E+00 +0.000000E+00 +2.350000E-01 +1.135900E-02 +0.000000E+00 +0.000000E+00 +1.500000E-01 +4.606000E-03 +0.000000E+00 +0.000000E+00 +7.100000E-02 +1.079000E-03 +0.000000E+00 +0.000000E+00 +1.530000E-01 +4.837000E-03 +0.000000E+00 +0.000000E+00 +5.600000E-02 +7.260000E-04 +0.000000E+00 +0.000000E+00 +2.570000E-01 +1.347100E-02 +0.000000E+00 +0.000000E+00 +1.750000E-01 +6.163000E-03 +0.000000E+00 +0.000000E+00 +2.460000E-01 +1.235000E-02 +0.000000E+00 +0.000000E+00 +1.420000E-01 +4.326000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.830000E-01 +7.133000E-03 +0.000000E+00 +0.000000E+00 +5.110000E-01 +5.696100E-02 +0.000000E+00 +0.000000E+00 +2.040000E-01 +8.426000E-03 +0.000000E+00 +0.000000E+00 +8.500000E-02 +1.533000E-03 +0.000000E+00 +0.000000E+00 +2.100000E-01 +8.928000E-03 +0.000000E+00 +0.000000E+00 +9.100000E-02 +1.807000E-03 +0.000000E+00 +0.000000E+00 +1.420000E-01 +4.326000E-03 +0.000000E+00 +0.000000E+00 +2.460000E-01 +1.235000E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.430000E-01 +4.207000E-03 +0.000000E+00 +0.000000E+00 +2.120000E-01 +9.278000E-03 +0.000000E+00 +0.000000E+00 +1.630000E-01 +5.617000E-03 +0.000000E+00 +0.000000E+00 +7.100000E-02 +1.083000E-03 +0.000000E+00 +0.000000E+00 +1.770000E-01 +6.293000E-03 +0.000000E+00 +0.000000E+00 +7.900000E-02 +1.495000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.300000E-01 +1.081000E-02 +0.000000E+00 +0.000000E+00 +5.200000E-01 +5.835000E-02 +0.000000E+00 +0.000000E+00 +2.350000E-01 +1.135900E-02 +0.000000E+00 +0.000000E+00 +1.560000E-01 +4.914000E-03 +0.000000E+00 +0.000000E+00 +2.370000E-01 +1.142300E-02 +0.000000E+00 +0.000000E+00 1.360000E-01 -3.890000E-03 +3.882000E-03 0.000000E+00 0.000000E+00 -1.110000E-01 -2.639000E-03 +2.160000E-01 +9.662000E-03 0.000000E+00 0.000000E+00 -1.540000E-01 -4.804000E-03 +1.080000E-01 +2.718000E-03 0.000000E+00 0.000000E+00 -1.280000E-01 -3.302000E-03 +2.090000E-01 +8.841000E-03 0.000000E+00 0.000000E+00 -2.200000E-01 -9.834000E-03 +1.030000E-01 +2.271000E-03 0.000000E+00 0.000000E+00 +5.200000E-01 +5.835000E-02 0.000000E+00 0.000000E+00 +2.300000E-01 +1.081000E-02 0.000000E+00 0.000000E+00 -9.900000E-02 -2.127000E-03 +5.110000E-01 +5.615900E-02 0.000000E+00 0.000000E+00 -1.860000E-01 -7.198000E-03 +2.430000E-01 +1.228300E-02 +0.000000E+00 +0.000000E+00 +5.110000E-01 +5.696100E-02 +0.000000E+00 +0.000000E+00 +1.830000E-01 +7.133000E-03 +0.000000E+00 +0.000000E+00 +5.130000E-01 +6.002100E-02 +0.000000E+00 +0.000000E+00 +2.420000E-01 +1.209200E-02 +0.000000E+00 +0.000000E+00 +5.510000E-01 +7.358900E-02 +0.000000E+00 +0.000000E+00 +2.410000E-01 +1.255900E-02 +0.000000E+00 +0.000000E+00 +5.140000E-01 +5.890200E-02 +0.000000E+00 +0.000000E+00 +2.100000E-01 +1.004600E-02 +0.000000E+00 +0.000000E+00 +2.430000E-01 +1.228300E-02 +0.000000E+00 +0.000000E+00 +5.110000E-01 +5.615900E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -948,116 +1340,140 @@ tally 2: 0.000000E+00 0.000000E+00 0.000000E+00 +2.120000E-01 +9.278000E-03 +0.000000E+00 +0.000000E+00 1.430000E-01 -4.337000E-03 +4.207000E-03 0.000000E+00 0.000000E+00 -1.580000E-01 -5.104000E-03 +2.380000E-01 +1.133600E-02 0.000000E+00 0.000000E+00 -1.050000E-01 -2.285000E-03 +1.640000E-01 +5.444000E-03 0.000000E+00 0.000000E+00 -1.800000E-01 -6.720000E-03 +2.240000E-01 +1.015800E-02 0.000000E+00 0.000000E+00 +9.300000E-02 +1.829000E-03 0.000000E+00 0.000000E+00 +1.950000E-01 +7.705000E-03 0.000000E+00 0.000000E+00 +1.030000E-01 +2.191000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.860000E-01 -7.178000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -7.000000E-02 -1.020000E-03 +1.680000E-01 +5.878000E-03 0.000000E+00 0.000000E+00 -1.610000E-01 -5.237000E-03 +2.230000E-01 +1.049900E-02 0.000000E+00 0.000000E+00 -1.580000E-01 -5.104000E-03 +1.360000E-01 +3.882000E-03 0.000000E+00 0.000000E+00 -1.430000E-01 -4.337000E-03 +2.370000E-01 +1.142300E-02 0.000000E+00 0.000000E+00 -1.580000E-01 -5.254000E-03 0.000000E+00 0.000000E+00 -1.230000E-01 -3.091000E-03 0.000000E+00 0.000000E+00 -1.870000E-01 -7.731000E-03 0.000000E+00 0.000000E+00 -2.510000E-01 -1.283100E-02 0.000000E+00 0.000000E+00 +1.550000E-01 +5.011000E-03 0.000000E+00 0.000000E+00 +7.100000E-02 +1.191000E-03 0.000000E+00 0.000000E+00 +1.510000E-01 +4.845000E-03 0.000000E+00 0.000000E+00 +6.400000E-02 +9.460000E-04 0.000000E+00 0.000000E+00 -1.980000E-01 -7.934000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.500000E-02 -1.949000E-03 -0.000000E+00 -0.000000E+00 -2.150000E-01 -9.289000E-03 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.091000E-03 -0.000000E+00 -0.000000E+00 -1.580000E-01 -5.254000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +2.230000E-01 +1.049900E-02 0.000000E+00 0.000000E+00 +1.680000E-01 +5.878000E-03 0.000000E+00 0.000000E+00 +2.490000E-01 +1.255900E-02 0.000000E+00 0.000000E+00 1.280000E-01 -3.302000E-03 +3.448000E-03 0.000000E+00 0.000000E+00 -1.540000E-01 -4.804000E-03 +2.420000E-01 +1.209200E-02 +0.000000E+00 +0.000000E+00 +5.130000E-01 +6.002100E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.070000E-01 +8.673000E-03 +0.000000E+00 +0.000000E+00 +1.080000E-01 +2.694000E-03 +0.000000E+00 +0.000000E+00 +2.000000E-01 +8.202000E-03 +0.000000E+00 +0.000000E+00 +9.600000E-02 +2.024000E-03 +0.000000E+00 +0.000000E+00 +1.280000E-01 +3.448000E-03 +0.000000E+00 +0.000000E+00 +2.490000E-01 +1.255900E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1069,35 +1485,37 @@ tally 2: 0.000000E+00 0.000000E+00 1.640000E-01 -5.424000E-03 +5.444000E-03 0.000000E+00 0.000000E+00 +2.380000E-01 +1.133600E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -6.200000E-02 -8.020000E-04 0.000000E+00 0.000000E+00 -1.500000E-01 -4.588000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.760000E-01 +6.550000E-03 0.000000E+00 0.000000E+00 +8.200000E-02 +1.536000E-03 0.000000E+00 0.000000E+00 +1.670000E-01 +5.653000E-03 0.000000E+00 0.000000E+00 -1.700000E-01 -5.884000E-03 +4.900000E-02 +5.630000E-04 0.000000E+00 0.000000E+00 -2.280000E-01 -1.084800E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1106,270 +1524,60 @@ tally 2: 0.000000E+00 0.000000E+00 0.000000E+00 +1.320000E-01 +3.626000E-03 0.000000E+00 0.000000E+00 -1.540000E-01 -4.856000E-03 +1.510000E-01 +4.831000E-03 0.000000E+00 0.000000E+00 -2.250000E-01 -1.047100E-02 0.000000E+00 0.000000E+00 -1.410000E-01 -4.001000E-03 0.000000E+00 0.000000E+00 -6.500000E-02 -9.390000E-04 0.000000E+00 0.000000E+00 -1.360000E-01 -3.852000E-03 0.000000E+00 0.000000E+00 -6.400000E-02 -8.700000E-04 +1.370000E-01 +3.855000E-03 0.000000E+00 0.000000E+00 -2.280000E-01 -1.084800E-02 +1.610000E-01 +5.233000E-03 0.000000E+00 0.000000E+00 -1.700000E-01 -5.884000E-03 +5.600000E-02 +7.260000E-04 0.000000E+00 0.000000E+00 -2.230000E-01 -1.001100E-02 +1.530000E-01 +4.837000E-03 0.000000E+00 0.000000E+00 -1.410000E-01 -4.185000E-03 +1.610000E-01 +5.261000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.510000E-01 +4.831000E-03 0.000000E+00 0.000000E+00 +1.320000E-01 +3.626000E-03 0.000000E+00 0.000000E+00 -1.980000E-01 -8.038000E-03 +1.490000E-01 +4.731000E-03 0.000000E+00 0.000000E+00 -5.030000E-01 -5.613900E-02 -0.000000E+00 -0.000000E+00 -2.200000E-01 -9.958000E-03 -0.000000E+00 -0.000000E+00 -9.400000E-02 -1.912000E-03 -0.000000E+00 -0.000000E+00 -2.140000E-01 -9.376000E-03 -0.000000E+00 -0.000000E+00 -7.300000E-02 -1.091000E-03 -0.000000E+00 -0.000000E+00 -1.410000E-01 -4.185000E-03 -0.000000E+00 -0.000000E+00 -2.230000E-01 -1.001100E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.540000E-01 -4.808000E-03 -0.000000E+00 -0.000000E+00 -2.340000E-01 -1.119400E-02 -0.000000E+00 -0.000000E+00 -1.570000E-01 -4.975000E-03 -0.000000E+00 -0.000000E+00 -6.700000E-02 -9.310000E-04 -0.000000E+00 -0.000000E+00 -1.600000E-01 -5.134000E-03 -0.000000E+00 -0.000000E+00 -5.300000E-02 -6.110000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.310000E-01 -1.084100E-02 -0.000000E+00 -0.000000E+00 -5.390000E-01 -6.215100E-02 -0.000000E+00 -0.000000E+00 -2.250000E-01 -1.047100E-02 -0.000000E+00 -0.000000E+00 -1.540000E-01 -4.856000E-03 -0.000000E+00 -0.000000E+00 -2.280000E-01 -1.059800E-02 -0.000000E+00 -0.000000E+00 -1.600000E-01 -5.214000E-03 -0.000000E+00 -0.000000E+00 -2.160000E-01 -9.418000E-03 -0.000000E+00 -0.000000E+00 -9.300000E-02 -1.927000E-03 -0.000000E+00 -0.000000E+00 -2.510000E-01 -1.271500E-02 -0.000000E+00 -0.000000E+00 -1.030000E-01 -2.229000E-03 -0.000000E+00 -0.000000E+00 -5.390000E-01 -6.215100E-02 -0.000000E+00 -0.000000E+00 -2.310000E-01 -1.084100E-02 -0.000000E+00 -0.000000E+00 -4.700000E-01 -4.972200E-02 -0.000000E+00 -0.000000E+00 -2.190000E-01 -9.821000E-03 -0.000000E+00 -0.000000E+00 -5.030000E-01 -5.613900E-02 -0.000000E+00 -0.000000E+00 -1.980000E-01 -8.038000E-03 -0.000000E+00 -0.000000E+00 -5.100000E-01 -5.929000E-02 -0.000000E+00 -0.000000E+00 -2.140000E-01 -9.406000E-03 -0.000000E+00 -0.000000E+00 -5.470000E-01 -7.228300E-02 -0.000000E+00 -0.000000E+00 -2.110000E-01 -9.215000E-03 -0.000000E+00 -0.000000E+00 -5.160000E-01 -5.892200E-02 -0.000000E+00 -0.000000E+00 -2.550000E-01 -1.480500E-02 -0.000000E+00 -0.000000E+00 -2.190000E-01 -9.821000E-03 -0.000000E+00 -0.000000E+00 -4.700000E-01 -4.972200E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.340000E-01 -1.119400E-02 -0.000000E+00 -0.000000E+00 -1.540000E-01 -4.808000E-03 -0.000000E+00 -0.000000E+00 -2.170000E-01 -9.509000E-03 -0.000000E+00 -0.000000E+00 -1.600000E-01 -5.156000E-03 -0.000000E+00 -0.000000E+00 -1.860000E-01 -7.198000E-03 -0.000000E+00 -0.000000E+00 -9.900000E-02 -2.127000E-03 -0.000000E+00 -0.000000E+00 -2.290000E-01 -1.058700E-02 -0.000000E+00 -0.000000E+00 -9.000000E-02 -1.780000E-03 +1.320000E-01 +3.514000E-03 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1381,19 +1589,75 @@ tally 2: 0.000000E+00 0.000000E+00 1.550000E-01 -4.913000E-03 +4.921000E-03 0.000000E+00 0.000000E+00 -2.380000E-01 -1.153400E-02 +2.410000E-01 +1.168300E-02 +0.000000E+00 +0.000000E+00 +9.100000E-02 +1.807000E-03 +0.000000E+00 +0.000000E+00 +2.100000E-01 +8.928000E-03 +0.000000E+00 +0.000000E+00 +2.090000E-01 +8.775000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.320000E-01 +3.514000E-03 +0.000000E+00 +0.000000E+00 +1.490000E-01 +4.731000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.150000E-01 +2.891000E-03 +0.000000E+00 +0.000000E+00 +1.560000E-01 +5.154000E-03 +0.000000E+00 +0.000000E+00 +7.900000E-02 +1.495000E-03 +0.000000E+00 +0.000000E+00 +1.770000E-01 +6.293000E-03 0.000000E+00 0.000000E+00 1.600000E-01 -5.214000E-03 +5.352000E-03 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 -2.280000E-01 -1.059800E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1405,523 +1669,243 @@ tally 2: 0.000000E+00 0.000000E+00 1.610000E-01 -5.237000E-03 -0.000000E+00 -0.000000E+00 -7.000000E-02 -1.020000E-03 -0.000000E+00 -0.000000E+00 -1.410000E-01 -4.071000E-03 -0.000000E+00 -0.000000E+00 -6.100000E-02 -8.350000E-04 -0.000000E+00 -0.000000E+00 -2.380000E-01 -1.153400E-02 -0.000000E+00 -0.000000E+00 -1.550000E-01 -4.913000E-03 -0.000000E+00 -0.000000E+00 -2.320000E-01 -1.100400E-02 -0.000000E+00 -0.000000E+00 -1.460000E-01 -4.498000E-03 -0.000000E+00 -0.000000E+00 -2.140000E-01 -9.406000E-03 -0.000000E+00 -0.000000E+00 -5.100000E-01 -5.929000E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.150000E-01 -9.289000E-03 -0.000000E+00 -0.000000E+00 -9.500000E-02 -1.949000E-03 -0.000000E+00 -0.000000E+00 -1.870000E-01 -7.267000E-03 -0.000000E+00 -0.000000E+00 -1.030000E-01 -2.543000E-03 -0.000000E+00 -0.000000E+00 -1.460000E-01 -4.498000E-03 -0.000000E+00 -0.000000E+00 -2.320000E-01 -1.100400E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.600000E-01 -5.156000E-03 -0.000000E+00 -0.000000E+00 -2.170000E-01 -9.509000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.500000E-01 -4.588000E-03 -0.000000E+00 -0.000000E+00 -6.200000E-02 -8.020000E-04 -0.000000E+00 -0.000000E+00 -1.290000E-01 -3.487000E-03 -0.000000E+00 -0.000000E+00 -6.000000E-02 -8.060000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.090000E-01 -2.437000E-03 -0.000000E+00 -0.000000E+00 -1.650000E-01 -5.655000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.065000E-03 -0.000000E+00 -0.000000E+00 -1.570000E-01 -4.999000E-03 -0.000000E+00 -0.000000E+00 -6.400000E-02 -8.700000E-04 -0.000000E+00 -0.000000E+00 -1.360000E-01 -3.852000E-03 -0.000000E+00 -0.000000E+00 -1.750000E-01 -6.299000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.650000E-01 -5.655000E-03 -0.000000E+00 -0.000000E+00 -1.090000E-01 -2.437000E-03 -0.000000E+00 -0.000000E+00 -1.480000E-01 -4.674000E-03 -0.000000E+00 -0.000000E+00 -1.320000E-01 -3.548000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.440000E-01 -4.282000E-03 -0.000000E+00 -0.000000E+00 -2.190000E-01 -9.683000E-03 -0.000000E+00 -0.000000E+00 -7.300000E-02 -1.091000E-03 -0.000000E+00 -0.000000E+00 -2.140000E-01 -9.376000E-03 -0.000000E+00 -0.000000E+00 -1.830000E-01 -6.803000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.320000E-01 -3.548000E-03 -0.000000E+00 -0.000000E+00 -1.480000E-01 -4.674000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.350000E-01 -3.895000E-03 -0.000000E+00 -0.000000E+00 -1.430000E-01 -4.297000E-03 -0.000000E+00 -0.000000E+00 -5.300000E-02 -6.110000E-04 -0.000000E+00 -0.000000E+00 -1.600000E-01 -5.134000E-03 -0.000000E+00 -0.000000E+00 -1.380000E-01 -4.220000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.900000E-01 -7.412000E-03 -0.000000E+00 -0.000000E+00 -2.420000E-01 -1.208400E-02 -0.000000E+00 -0.000000E+00 -1.570000E-01 -4.999000E-03 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.065000E-03 -0.000000E+00 -0.000000E+00 -1.730000E-01 -6.279000E-03 -0.000000E+00 -0.000000E+00 -1.330000E-01 -3.621000E-03 -0.000000E+00 -0.000000E+00 -1.030000E-01 -2.229000E-03 -0.000000E+00 -0.000000E+00 -2.510000E-01 -1.271500E-02 -0.000000E+00 -0.000000E+00 -2.100000E-01 -8.970000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.420000E-01 -1.208400E-02 -0.000000E+00 -0.000000E+00 -1.900000E-01 -7.412000E-03 -0.000000E+00 -0.000000E+00 -2.610000E-01 -1.399900E-02 -0.000000E+00 -0.000000E+00 -2.000000E-01 -8.410000E-03 -0.000000E+00 -0.000000E+00 -2.190000E-01 -9.683000E-03 -0.000000E+00 -0.000000E+00 -1.440000E-01 -4.282000E-03 -0.000000E+00 -0.000000E+00 -2.690000E-01 -1.478100E-02 -0.000000E+00 -0.000000E+00 -1.540000E-01 -4.986000E-03 -0.000000E+00 -0.000000E+00 -2.550000E-01 -1.480500E-02 -0.000000E+00 -0.000000E+00 -5.160000E-01 -5.892200E-02 +5.273000E-03 0.000000E+00 0.000000E+00 2.310000E-01 -1.098900E-02 +1.098100E-02 0.000000E+00 0.000000E+00 +1.610000E-01 +5.233000E-03 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-01 -8.410000E-03 -0.000000E+00 -0.000000E+00 -2.610000E-01 -1.399900E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.430000E-01 -4.297000E-03 -0.000000E+00 -0.000000E+00 -1.350000E-01 -3.895000E-03 +1.370000E-01 +3.855000E-03 0.000000E+00 0.000000E+00 1.760000E-01 -6.534000E-03 -0.000000E+00 -0.000000E+00 -1.170000E-01 -2.807000E-03 -0.000000E+00 -0.000000E+00 -9.000000E-02 -1.780000E-03 -0.000000E+00 -0.000000E+00 -2.290000E-01 -1.058700E-02 -0.000000E+00 -0.000000E+00 -2.080000E-01 -8.854000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.305000E-03 -0.000000E+00 -0.000000E+00 -1.760000E-01 -6.598000E-03 -0.000000E+00 -0.000000E+00 -1.330000E-01 -3.621000E-03 -0.000000E+00 -0.000000E+00 -1.730000E-01 -6.279000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -6.100000E-02 -8.350000E-04 -0.000000E+00 -0.000000E+00 -1.410000E-01 -4.071000E-03 -0.000000E+00 -0.000000E+00 -1.800000E-01 -6.574000E-03 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.760000E-01 -6.598000E-03 -0.000000E+00 -0.000000E+00 -1.230000E-01 -3.305000E-03 -0.000000E+00 -0.000000E+00 -1.690000E-01 -6.135000E-03 -0.000000E+00 -0.000000E+00 -1.220000E-01 -3.344000E-03 -0.000000E+00 -0.000000E+00 -1.540000E-01 -4.986000E-03 -0.000000E+00 -0.000000E+00 -2.690000E-01 -1.478100E-02 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +6.482000E-03 0.000000E+00 0.000000E+00 +1.340000E-01 +3.882000E-03 0.000000E+00 0.000000E+00 1.030000E-01 -2.543000E-03 +2.271000E-03 0.000000E+00 0.000000E+00 -1.870000E-01 -7.267000E-03 +2.090000E-01 +8.841000E-03 0.000000E+00 0.000000E+00 -1.690000E-01 -5.731000E-03 +1.830000E-01 +6.761000E-03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.220000E-01 -3.344000E-03 +2.310000E-01 +1.098100E-02 0.000000E+00 0.000000E+00 -1.690000E-01 -6.135000E-03 +1.610000E-01 +5.273000E-03 +0.000000E+00 +0.000000E+00 +2.620000E-01 +1.380600E-02 +0.000000E+00 +0.000000E+00 +1.700000E-01 +5.970000E-03 +0.000000E+00 +0.000000E+00 +2.410000E-01 +1.168300E-02 +0.000000E+00 +0.000000E+00 +1.550000E-01 +4.921000E-03 +0.000000E+00 +0.000000E+00 +2.250000E-01 +1.014100E-02 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.805000E-03 +0.000000E+00 +0.000000E+00 +2.100000E-01 +1.004600E-02 +0.000000E+00 +0.000000E+00 +5.140000E-01 +5.890200E-02 +0.000000E+00 +0.000000E+00 +2.320000E-01 +1.093000E-02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.700000E-01 +5.970000E-03 +0.000000E+00 +0.000000E+00 +2.620000E-01 +1.380600E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.560000E-01 +5.154000E-03 +0.000000E+00 +0.000000E+00 +1.150000E-01 +2.891000E-03 +0.000000E+00 +0.000000E+00 +1.430000E-01 +4.163000E-03 +0.000000E+00 +0.000000E+00 +1.120000E-01 +2.640000E-03 +0.000000E+00 +0.000000E+00 +1.030000E-01 +2.191000E-03 +0.000000E+00 +0.000000E+00 +1.950000E-01 +7.705000E-03 +0.000000E+00 +0.000000E+00 +1.760000E-01 +6.392000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.200000E-02 +1.822000E-03 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.843000E-03 +0.000000E+00 +0.000000E+00 +1.340000E-01 +3.882000E-03 +0.000000E+00 +0.000000E+00 +1.760000E-01 +6.482000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.400000E-02 +9.460000E-04 +0.000000E+00 +0.000000E+00 +1.510000E-01 +4.845000E-03 +0.000000E+00 +0.000000E+00 +1.800000E-01 +6.520000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.843000E-03 +0.000000E+00 +0.000000E+00 +9.200000E-02 +1.822000E-03 +0.000000E+00 +0.000000E+00 +1.300000E-01 +3.604000E-03 +0.000000E+00 +0.000000E+00 +1.170000E-01 +2.789000E-03 +0.000000E+00 +0.000000E+00 +1.370000E-01 +3.805000E-03 +0.000000E+00 +0.000000E+00 +2.250000E-01 +1.014100E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.600000E-02 +2.024000E-03 +0.000000E+00 +0.000000E+00 +2.000000E-01 +8.202000E-03 +0.000000E+00 +0.000000E+00 +1.820000E-01 +6.660000E-03 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.170000E-01 -2.807000E-03 +2.789000E-03 0.000000E+00 0.000000E+00 -1.760000E-01 -6.534000E-03 +1.300000E-01 +3.604000E-03 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1932,16 +1916,32 @@ tally 2: 0.000000E+00 0.000000E+00 0.000000E+00 -6.000000E-02 -8.060000E-04 +1.120000E-01 +2.640000E-03 0.000000E+00 0.000000E+00 -1.290000E-01 -3.487000E-03 -0.000000E+00 -0.000000E+00 -1.790000E-01 -6.747000E-03 +1.430000E-01 +4.163000E-03 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.900000E-02 +5.630000E-04 +0.000000E+00 +0.000000E+00 +1.670000E-01 +5.653000E-03 +0.000000E+00 +0.000000E+00 +1.670000E-01 +5.701000E-03 0.000000E+00 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/seed/results_true.dat b/tests/regression_tests/seed/results_true.dat index ff34071c1..bcd711825 100644 --- a/tests/regression_tests/seed/results_true.dat +++ b/tests/regression_tests/seed/results_true.dat @@ -1,2 +1,2 @@ k-combined: -3.015003E-01 5.094212E-03 +3.069730E-01 2.632099E-03 diff --git a/tests/regression_tests/source/inputs_true.dat b/tests/regression_tests/source/inputs_true.dat index 0c3764ba6..c1a616dd1 100644 --- a/tests/regression_tests/source/inputs_true.dat +++ b/tests/regression_tests/source/inputs_true.dat @@ -1,150 +1,150 @@ - - - + + + - + eigenvalue 1000 10 5 - + - + -4.0 -1.0 3.0 0.2 0.3 0.5 - + -2.0 0.0 2.0 0.2 0.3 0.2 - + -1.0 0.0 1.0 0.5 0.25 0.25 - + - + - + -4.0 -4.0 -4.0 4.0 4.0 4.0 - - + + - + 1.2 -2.3 0.781 - + 1.0 1.3894954943731377 1.93069772888325 2.6826957952797255 3.72759372031494 5.17947467923121 7.196856730011519 10.0 13.894954943731374 19.306977288832496 26.826957952797247 37.2759372031494 51.7947467923121 71.96856730011518 100.0 138.94954943731375 193.06977288832496 268.26957952797244 372.7593720314938 517.9474679231207 719.6856730011514 1000.0 1389.4954943731375 1930.6977288832495 2682.6957952797247 3727.593720314938 5179.474679231207 7196.856730011514 10000.0 13894.95494373136 19306.977288832495 26826.95795279722 37275.93720314938 51794.74679231213 71968.56730011514 100000.0 138949.5494373136 193069.77288832495 268269.5795279722 372759.3720314938 517947.4679231202 719685.6730011514 1000000.0 1389495.494373136 1930697.7288832497 2682695.7952797217 3727593.720314938 5179474.679231202 7196856.730011513 10000000.0 0.0 2.9086439299358713e-08 5.80533561806147e-08 8.67817193689187e-08 1.1515347785771536e-07 1.4305204600565115e-07 1.7036278261198208e-07 1.9697346200185813e-07 2.227747351856934e-07 2.4766057919761985e-07 2.715287327665956e-07 2.9428111652990295e-07 3.1582423606228735e-07 3.360695660646056e-07 3.549339141332686e-07 3.723397626156721e-07 3.882155871468592e-07 4.024961505584776e-07 4.151227709522976e-07 4.260435628367196e-07 4.3521365033538783e-07 4.4259535159179273e-07 4.4815833361210174e-07 4.5187973690993757e-07 4.5374426944091084e-07 4.5374426944091084e-07 4.5187973690993757e-07 4.4815833361210174e-07 4.4259535159179273e-07 4.352136503353879e-07 4.2604356283671966e-07 4.1512277095229767e-07 4.0249615055847764e-07 3.8821558714685926e-07 3.723397626156722e-07 3.5493391413326864e-07 3.360695660646057e-07 3.158242360622874e-07 2.942811165299031e-07 2.715287327665957e-07 2.4766057919762e-07 2.2277473518569352e-07 1.9697346200185819e-07 1.7036278261198226e-07 1.4305204600565126e-07 1.1515347785771556e-07 8.678171936891881e-08 5.805335618061493e-08 2.9086439299358858e-08 5.559621115282002e-23 - - - + + + 0.7071067811865476 0.0 -0.7071067811865475 0.3 0.4 0.3 - + - + 1.0 1.3894954943731377 1.93069772888325 2.6826957952797255 3.72759372031494 5.17947467923121 7.196856730011519 10.0 13.894954943731374 19.306977288832496 26.826957952797247 37.2759372031494 51.7947467923121 71.96856730011518 100.0 138.94954943731375 193.06977288832496 268.26957952797244 372.7593720314938 517.9474679231207 719.6856730011514 1000.0 1389.4954943731375 1930.6977288832495 2682.6957952797247 3727.593720314938 5179.474679231207 7196.856730011514 10000.0 13894.95494373136 19306.977288832495 26826.95795279722 37275.93720314938 51794.74679231213 71968.56730011514 100000.0 138949.5494373136 193069.77288832495 268269.5795279722 372759.3720314938 517947.4679231202 719685.6730011514 1000000.0 1389495.494373136 1930697.7288832497 2682695.7952797217 3727593.720314938 5179474.679231202 7196856.730011513 10000000.0 0.0 2.9086439299358713e-08 5.80533561806147e-08 8.67817193689187e-08 1.1515347785771536e-07 1.4305204600565115e-07 1.7036278261198208e-07 1.9697346200185813e-07 2.227747351856934e-07 2.4766057919761985e-07 2.715287327665956e-07 2.9428111652990295e-07 3.1582423606228735e-07 3.360695660646056e-07 3.549339141332686e-07 3.723397626156721e-07 3.882155871468592e-07 4.024961505584776e-07 4.151227709522976e-07 4.260435628367196e-07 4.3521365033538783e-07 4.4259535159179273e-07 4.4815833361210174e-07 4.5187973690993757e-07 4.5374426944091084e-07 4.5374426944091084e-07 4.5187973690993757e-07 4.4815833361210174e-07 4.4259535159179273e-07 4.352136503353879e-07 4.2604356283671966e-07 4.1512277095229767e-07 4.0249615055847764e-07 3.8821558714685926e-07 3.723397626156722e-07 3.5493391413326864e-07 3.360695660646057e-07 3.158242360622874e-07 2.942811165299031e-07 2.715287327665957e-07 2.4766057919762e-07 2.2277473518569352e-07 1.9697346200185819e-07 1.7036278261198226e-07 1.4305204600565126e-07 1.1515347785771556e-07 8.678171936891881e-08 5.805335618061493e-08 2.9086439299358858e-08 5.559621115282002e-23 - - - - - + + + + + -2.0 0.0 2.0 0.2 0.3 0.2 - + 1.0 1.3894954943731377 1.93069772888325 2.6826957952797255 3.72759372031494 5.17947467923121 7.196856730011519 10.0 13.894954943731374 19.306977288832496 26.826957952797247 37.2759372031494 51.7947467923121 71.96856730011518 100.0 138.94954943731375 193.06977288832496 268.26957952797244 372.7593720314938 517.9474679231207 719.6856730011514 1000.0 1389.4954943731375 1930.6977288832495 2682.6957952797247 3727.593720314938 5179.474679231207 7196.856730011514 10000.0 13894.95494373136 19306.977288832495 26826.95795279722 37275.93720314938 51794.74679231213 71968.56730011514 100000.0 138949.5494373136 193069.77288832495 268269.5795279722 372759.3720314938 517947.4679231202 719685.6730011514 1000000.0 1389495.494373136 1930697.7288832497 2682695.7952797217 3727593.720314938 5179474.679231202 7196856.730011513 10000000.0 0.0 2.9086439299358713e-08 5.80533561806147e-08 8.67817193689187e-08 1.1515347785771536e-07 1.4305204600565115e-07 1.7036278261198208e-07 1.9697346200185813e-07 2.227747351856934e-07 2.4766057919761985e-07 2.715287327665956e-07 2.9428111652990295e-07 3.1582423606228735e-07 3.360695660646056e-07 3.549339141332686e-07 3.723397626156721e-07 3.882155871468592e-07 4.024961505584776e-07 4.151227709522976e-07 4.260435628367196e-07 4.3521365033538783e-07 4.4259535159179273e-07 4.4815833361210174e-07 4.5187973690993757e-07 4.5374426944091084e-07 4.5374426944091084e-07 4.5187973690993757e-07 4.4815833361210174e-07 4.4259535159179273e-07 4.352136503353879e-07 4.2604356283671966e-07 4.1512277095229767e-07 4.0249615055847764e-07 3.8821558714685926e-07 3.723397626156722e-07 3.5493391413326864e-07 3.360695660646057e-07 3.158242360622874e-07 2.942811165299031e-07 2.715287327665957e-07 2.4766057919762e-07 2.2277473518569352e-07 1.9697346200185819e-07 1.7036278261198226e-07 1.4305204600565126e-07 1.1515347785771556e-07 8.678171936891881e-08 5.805335618061493e-08 2.9086439299358858e-08 5.559621115282002e-23 - - - - - + + + + + -2.0 0.0 2.0 0.2 0.3 0.2 - - + + - - + + - - + + 1.0 1.3894954943731377 1.93069772888325 2.6826957952797255 3.72759372031494 5.17947467923121 7.196856730011519 10.0 13.894954943731374 19.306977288832496 26.826957952797247 37.2759372031494 51.7947467923121 71.96856730011518 100.0 138.94954943731375 193.06977288832496 268.26957952797244 372.7593720314938 517.9474679231207 719.6856730011514 1000.0 1389.4954943731375 1930.6977288832495 2682.6957952797247 3727.593720314938 5179.474679231207 7196.856730011514 10000.0 13894.95494373136 19306.977288832495 26826.95795279722 37275.93720314938 51794.74679231213 71968.56730011514 100000.0 138949.5494373136 193069.77288832495 268269.5795279722 372759.3720314938 517947.4679231202 719685.6730011514 1000000.0 1389495.494373136 1930697.7288832497 2682695.7952797217 3727593.720314938 5179474.679231202 7196856.730011513 10000000.0 0.0 2.9086439299358713e-08 5.80533561806147e-08 8.67817193689187e-08 1.1515347785771536e-07 1.4305204600565115e-07 1.7036278261198208e-07 1.9697346200185813e-07 2.227747351856934e-07 2.4766057919761985e-07 2.715287327665956e-07 2.9428111652990295e-07 3.1582423606228735e-07 3.360695660646056e-07 3.549339141332686e-07 3.723397626156721e-07 3.882155871468592e-07 4.024961505584776e-07 4.151227709522976e-07 4.260435628367196e-07 4.3521365033538783e-07 4.4259535159179273e-07 4.4815833361210174e-07 4.5187973690993757e-07 4.5374426944091084e-07 4.5374426944091084e-07 4.5187973690993757e-07 4.4815833361210174e-07 4.4259535159179273e-07 4.352136503353879e-07 4.2604356283671966e-07 4.1512277095229767e-07 4.0249615055847764e-07 3.8821558714685926e-07 3.723397626156722e-07 3.5493391413326864e-07 3.360695660646057e-07 3.158242360622874e-07 2.942811165299031e-07 2.715287327665957e-07 2.4766057919762e-07 2.2277473518569352e-07 1.9697346200185819e-07 1.7036278261198226e-07 1.4305204600565126e-07 1.1515347785771556e-07 8.678171936891881e-08 5.805335618061493e-08 2.9086439299358858e-08 5.559621115282002e-23 - - - + + + 0.7071067811865476 0.0 -0.7071067811865475 0.3 0.4 0.3 - + - - + + - - + + - - + + 1.0 1.3894954943731377 1.93069772888325 2.6826957952797255 3.72759372031494 5.17947467923121 7.196856730011519 10.0 13.894954943731374 19.306977288832496 26.826957952797247 37.2759372031494 51.7947467923121 71.96856730011518 100.0 138.94954943731375 193.06977288832496 268.26957952797244 372.7593720314938 517.9474679231207 719.6856730011514 1000.0 1389.4954943731375 1930.6977288832495 2682.6957952797247 3727.593720314938 5179.474679231207 7196.856730011514 10000.0 13894.95494373136 19306.977288832495 26826.95795279722 37275.93720314938 51794.74679231213 71968.56730011514 100000.0 138949.5494373136 193069.77288832495 268269.5795279722 372759.3720314938 517947.4679231202 719685.6730011514 1000000.0 1389495.494373136 1930697.7288832497 2682695.7952797217 3727593.720314938 5179474.679231202 7196856.730011513 10000000.0 0.0 2.9086439299358713e-08 5.80533561806147e-08 8.67817193689187e-08 1.1515347785771536e-07 1.4305204600565115e-07 1.7036278261198208e-07 1.9697346200185813e-07 2.227747351856934e-07 2.4766057919761985e-07 2.715287327665956e-07 2.9428111652990295e-07 3.1582423606228735e-07 3.360695660646056e-07 3.549339141332686e-07 3.723397626156721e-07 3.882155871468592e-07 4.024961505584776e-07 4.151227709522976e-07 4.260435628367196e-07 4.3521365033538783e-07 4.4259535159179273e-07 4.4815833361210174e-07 4.5187973690993757e-07 4.5374426944091084e-07 4.5374426944091084e-07 4.5187973690993757e-07 4.4815833361210174e-07 4.4259535159179273e-07 4.352136503353879e-07 4.2604356283671966e-07 4.1512277095229767e-07 4.0249615055847764e-07 3.8821558714685926e-07 3.723397626156722e-07 3.5493391413326864e-07 3.360695660646057e-07 3.158242360622874e-07 2.942811165299031e-07 2.715287327665957e-07 2.4766057919762e-07 2.2277473518569352e-07 1.9697346200185819e-07 1.7036278261198226e-07 1.4305204600565126e-07 1.1515347785771556e-07 8.678171936891881e-08 5.805335618061493e-08 2.9086439299358858e-08 5.559621115282002e-23 - diff --git a/tests/regression_tests/source/results_true.dat b/tests/regression_tests/source/results_true.dat index c671463be..94d9ced15 100644 --- a/tests/regression_tests/source/results_true.dat +++ b/tests/regression_tests/source/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.942254E-01 2.571435E-03 +3.054101E-01 1.167865E-03 diff --git a/tests/regression_tests/source/test.py b/tests/regression_tests/source/test.py index 96efa77eb..c1f4dccff 100644 --- a/tests/regression_tests/source/test.py +++ b/tests/regression_tests/source/test.py @@ -11,7 +11,7 @@ class SourceTestHarness(PyAPITestHarness): super().__init__(*args, **kwargs) mat1 = openmc.Material(material_id=1, temperature=294) mat1.set_density('g/cm3', 4.5) - mat1.add_nuclide('U235', 1.0) + mat1.add_nuclide(openmc.Nuclide('U235'), 1.0) self._model.materials = openmc.Materials([mat1]) sphere = openmc.Sphere(surface_id=1, r=10.0, boundary_type='vacuum') diff --git a/tests/regression_tests/source_dlopen/inputs_true.dat b/tests/regression_tests/source_dlopen/inputs_true.dat index 9b4601d9f..28d1e06e2 100644 --- a/tests/regression_tests/source_dlopen/inputs_true.dat +++ b/tests/regression_tests/source_dlopen/inputs_true.dat @@ -2,23 +2,23 @@ - - - - - + + + + + - + fixed source 1000 10 0 - + diff --git a/tests/regression_tests/source_dlopen/source_sampling.cpp b/tests/regression_tests/source_dlopen/source_sampling.cpp index 678eea4be..fc61ef1fd 100644 --- a/tests/regression_tests/source_dlopen/source_sampling.cpp +++ b/tests/regression_tests/source_dlopen/source_sampling.cpp @@ -10,7 +10,7 @@ class CustomSource : public openmc::Source { { openmc::SourceSite particle; // wgt - particle.particle = openmc::ParticleType::neutron(); + particle.particle = openmc::ParticleType::neutron; particle.wgt = 1.0; // position diff --git a/tests/regression_tests/source_dlopen/test.py b/tests/regression_tests/source_dlopen/test.py index 0581d6dee..88ff9dd85 100644 --- a/tests/regression_tests/source_dlopen/test.py +++ b/tests/regression_tests/source_dlopen/test.py @@ -72,7 +72,8 @@ def model(): model.tallies = openmc.Tallies([tally]) # custom source from shared library - source = openmc.CompiledSource('build/libsource.so') + source = openmc.CompiledSource() + source.library = 'build/libsource.so' model.settings.source = source return model diff --git a/tests/regression_tests/source_file/results_true.dat b/tests/regression_tests/source_file/results_true.dat index 359e0526e..264e3d580 100644 --- a/tests/regression_tests/source_file/results_true.dat +++ b/tests/regression_tests/source_file/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.827397E-01 1.150437E-03 +2.983135E-01 5.116978E-03 diff --git a/tests/regression_tests/source_mcpl_file/results_true.dat b/tests/regression_tests/source_mcpl_file/results_true.dat index 3ba1a4520..264e3d580 100644 --- a/tests/regression_tests/source_mcpl_file/results_true.dat +++ b/tests/regression_tests/source_mcpl_file/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.827397E-01 1.150438E-03 +2.983135E-01 5.116978E-03 diff --git a/tests/regression_tests/source_mcpl_file/settings.xml b/tests/regression_tests/source_mcpl_file/settings.xml index bb08e6fd7..47b010bff 100644 --- a/tests/regression_tests/source_mcpl_file/settings.xml +++ b/tests/regression_tests/source_mcpl_file/settings.xml @@ -1,11 +1,12 @@ - eigenvalue - 10 - 5 - 1000 + + 10 + 5 + 1000 + -4 -4 -4 4 4 4 diff --git a/tests/regression_tests/source_mcpl_file/test.py b/tests/regression_tests/source_mcpl_file/test.py index 6e668ef19..84ec005ae 100644 --- a/tests/regression_tests/source_mcpl_file/test.py +++ b/tests/regression_tests/source_mcpl_file/test.py @@ -1,23 +1,23 @@ #!/usr/bin/env python +import openmc.lib import pytest import glob import os -import shutil -from tests.testing_harness import * +from tests.testing_harness import * pytestmark = pytest.mark.skipif( - shutil.which("mcpl-config") is None, - reason="mcpl-config command not found in PATH; MCPL is likely not available." -) + not openmc.lib._mcpl_enabled(), + reason="MCPL is not enabled.") settings1=""" - eigenvalue - 10 - 5 - 1000 + + 10 + 5 + 1000 + -4 -4 -4 4 4 4 @@ -28,10 +28,11 @@ settings1=""" settings2 = """ - eigenvalue - 10 - 5 - 1000 + + 10 + 5 + 1000 + source.10.{} diff --git a/tests/regression_tests/source_parameterized_dlopen/inputs_true.dat b/tests/regression_tests/source_parameterized_dlopen/inputs_true.dat index 088d65ada..6cf3473f9 100644 --- a/tests/regression_tests/source_parameterized_dlopen/inputs_true.dat +++ b/tests/regression_tests/source_parameterized_dlopen/inputs_true.dat @@ -2,23 +2,23 @@ - - - - - + + + + + - + fixed source 1000 10 0 - + diff --git a/tests/regression_tests/source_parameterized_dlopen/parameterized_source_sampling.cpp b/tests/regression_tests/source_parameterized_dlopen/parameterized_source_sampling.cpp index 81f3770c6..bf49af4c3 100644 --- a/tests/regression_tests/source_parameterized_dlopen/parameterized_source_sampling.cpp +++ b/tests/regression_tests/source_parameterized_dlopen/parameterized_source_sampling.cpp @@ -2,37 +2,36 @@ #include "openmc/source.h" class CustomSource : public openmc::Source { -public: - CustomSource(double energy) : energy_(energy) {} + public: + CustomSource(double energy) : energy_(energy) { } - // Samples from an instance of this class. - openmc::SourceSite sample(uint64_t* seed) const - { - openmc::SourceSite particle; - // wgt - particle.particle = openmc::ParticleType::neutron(); - particle.wgt = 1.0; - // position - particle.r.x = 0.0; - particle.r.y = 0.0; - particle.r.z = 0.0; - // angle - particle.u = {1.0, 0.0, 0.0}; - particle.E = this->energy_; - particle.delayed_group = 0; + // Samples from an instance of this class. + openmc::SourceSite sample(uint64_t* seed) const + { + openmc::SourceSite particle; + // wgt + particle.particle = openmc::ParticleType::neutron; + particle.wgt = 1.0; + // position + particle.r.x = 0.0; + particle.r.y = 0.0; + particle.r.z = 0.0; + // angle + particle.u = {1.0, 0.0, 0.0}; + particle.E = this->energy_; + particle.delayed_group = 0; - return particle; - } + return particle; + } -private: - double energy_; + private: + double energy_; }; -// A function to create a unique pointer to an instance of this class when -// generated via a plugin call using dlopen/dlsym. You must have external C -// linkage here otherwise dlopen will not find the file -extern "C" std::unique_ptr openmc_create_source( - std::string parameter) +// A function to create a unique pointer to an instance of this class when generated +// via a plugin call using dlopen/dlsym. +// You must have external C linkage here otherwise dlopen will not find the file +extern "C" std::unique_ptr openmc_create_source(std::string parameter) { double energy = std::stod(parameter); return std::make_unique(energy); diff --git a/tests/regression_tests/source_parameterized_dlopen/test.py b/tests/regression_tests/source_parameterized_dlopen/test.py index 151fb3735..1cc253528 100644 --- a/tests/regression_tests/source_parameterized_dlopen/test.py +++ b/tests/regression_tests/source_parameterized_dlopen/test.py @@ -71,7 +71,8 @@ def model(): model.tallies = openmc.Tallies([tally]) # custom source from shared library - source = openmc.CompiledSource('build/libsource.so') + source = openmc.CompiledSource() + source.library = 'build/libsource.so' source.parameters = '1e3' model.settings.source = source diff --git a/tests/regression_tests/sourcepoint_batch/results_true.dat b/tests/regression_tests/sourcepoint_batch/results_true.dat index 3665bdd08..2770f25ed 100644 --- a/tests/regression_tests/sourcepoint_batch/results_true.dat +++ b/tests/regression_tests/sourcepoint_batch/results_true.dat @@ -1,3 +1,3 @@ k-combined: -2.920435E-01 9.109227E-04 -1.101997E+00 -8.197502E+00 4.294606E+00 +3.074376E-01 3.049465E-03 +3.667754E+00 -7.701697E+00 2.213664E+00 diff --git a/tests/regression_tests/sourcepoint_latest/results_true.dat b/tests/regression_tests/sourcepoint_latest/results_true.dat index 97b997ae6..bbf03de94 100644 --- a/tests/regression_tests/sourcepoint_latest/results_true.dat +++ b/tests/regression_tests/sourcepoint_latest/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 diff --git a/tests/regression_tests/sourcepoint_restart/results_true.dat b/tests/regression_tests/sourcepoint_restart/results_true.dat index c20b5f2a0..b6d85872d 100644 --- a/tests/regression_tests/sourcepoint_restart/results_true.dat +++ b/tests/regression_tests/sourcepoint_restart/results_true.dat @@ -1,14 +1,46 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 tally 1: 1.300000E-02 -3.900000E-05 -5.833114E-03 -7.476880E-06 +4.700000E-05 +5.741381E-03 +9.030024E-06 0.000000E+00 0.000000E+00 -1.164000E-03 -5.072152E-07 +3.067112E-04 +9.407179E-08 +1.000000E-03 +1.000000E-06 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.600000E-02 +1.420000E-04 +1.268989E-02 +3.464490E-05 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +1.000000E-03 +1.000000E-06 +1.535009E-03 +1.224718E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +3.200000E-02 +2.760000E-04 +1.248507E-02 +3.714039E-05 +0.000000E+00 +0.000000E+00 +9.208601E-04 +4.708050E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -17,26 +49,42 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -2.100000E-02 -1.110000E-04 -1.108363E-02 -2.889480E-05 +1.900000E-02 +7.500000E-05 +8.218811E-03 +1.462963E-05 0.000000E+00 0.000000E+00 -5.861433E-04 -3.435640E-07 -2.000000E-03 -2.000000E-06 -2.043490E-03 -1.793389E-06 -2.000000E-03 -2.000000E-06 -2.930717E-04 -8.589100E-08 +9.070399E-04 +2.743247E-07 +0.000000E+00 +0.000000E+00 +9.047443E-04 +8.185622E-07 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +1.200000E-02 +5.000000E-05 +3.938144E-03 +5.245641E-06 +0.000000E+00 +0.000000E+00 +3.067112E-04 +9.407179E-08 +1.000000E-03 +1.000000E-06 +5.897816E-04 +3.478423E-07 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 2.000000E-02 -9.000000E-05 -9.334862E-03 -1.853104E-05 +1.260000E-04 +9.079852E-03 +2.657486E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -49,14 +97,62 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -2.500000E-02 -1.430000E-04 -1.110224E-02 -2.872840E-05 +3.100000E-02 +2.010000E-04 +1.336346E-02 +3.645780E-05 0.000000E+00 0.000000E+00 -5.833203E-04 -1.701353E-07 +2.102710E-03 +1.524522E-06 +1.000000E-03 +1.000000E-06 +9.083133E-04 +4.632477E-07 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +2.300000E-02 +1.090000E-04 +1.334578E-02 +3.590708E-05 +0.000000E+00 +0.000000E+00 +6.031628E-04 +3.638054E-07 +1.000000E-03 +1.000000E-06 +1.530605E-03 +1.035684E-06 +2.000000E-03 +2.000000E-06 +6.082927E-04 +1.850231E-07 +1.400000E-02 +4.200000E-05 +7.257468E-03 +1.221578E-05 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +0.000000E+00 +0.000000E+00 +8.980536E-04 +4.507660E-07 +2.000000E-03 +4.000000E-06 +0.000000E+00 +0.000000E+00 +9.000000E-03 +2.700000E-05 +5.193169E-03 +1.187321E-05 +0.000000E+00 +0.000000E+00 +3.054379E-04 +9.329231E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -65,14 +161,110 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -5.000000E-03 -1.100000E-05 -1.752967E-03 -1.027501E-06 +1.000000E-02 +2.400000E-05 +5.170002E-03 +7.361546E-06 0.000000E+00 0.000000E+00 -2.930717E-04 -8.589100E-08 +6.003287E-04 +1.802529E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.800000E-02 +1.720000E-04 +1.699195E-02 +6.267008E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.800000E-02 +1.980000E-04 +1.338750E-02 +4.565234E-05 +0.000000E+00 +0.000000E+00 +9.183134E-04 +4.676871E-07 +1.000000E-03 +1.000000E-06 +1.537188E-03 +2.362946E-06 +2.000000E-03 +4.000000E-06 +0.000000E+00 +0.000000E+00 +2.900000E-02 +1.950000E-04 +1.178615E-02 +3.130999E-05 +0.000000E+00 +0.000000E+00 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +1.179563E-03 +1.391369E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +1.500000E-02 +6.500000E-05 +5.706064E-03 +9.729293E-06 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.000000E-03 +9.000000E-06 +1.516642E-03 +1.579637E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +5.897816E-04 +3.478423E-07 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +2.900000E-02 +1.970000E-04 +1.274851E-02 +3.511219E-05 +0.000000E+00 +0.000000E+00 +9.057666E-04 +4.601298E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -83,60 +275,220 @@ tally 1: 0.000000E+00 1.800000E-02 7.600000E-05 -7.300761E-03 -1.254112E-05 +8.803642E-03 +1.730938E-05 +0.000000E+00 +0.000000E+00 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.900000E-02 +1.830000E-04 +1.245316E-02 +3.378176E-05 +0.000000E+00 +0.000000E+00 +6.016020E-04 +1.810324E-07 0.000000E+00 0.000000E+00 -5.841969E-04 -1.706438E-07 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -3.000000E-02 -1.820000E-04 -1.518122E-02 -4.757233E-05 0.000000E+00 0.000000E+00 -2.927374E-04 -8.569516E-08 -2.000000E-03 -2.000000E-06 -2.631167E-03 -3.503358E-06 1.000000E-03 1.000000E-06 -2.920435E-04 -8.528942E-08 -2.500000E-02 -1.390000E-04 -9.343205E-03 -1.910189E-05 +6.090190E-04 +1.854692E-07 0.000000E+00 0.000000E+00 -2.039724E-03 -1.271217E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.031628E-04 +3.638054E-07 1.000000E-03 1.000000E-06 -5.861433E-04 -3.435640E-07 +0.000000E+00 +0.000000E+00 +1.900000E-02 +8.700000E-05 +8.781239E-03 +1.676750E-05 +0.000000E+00 +0.000000E+00 +6.128755E-04 +1.878102E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.400000E-02 -1.340000E-04 -1.080336E-02 -2.533338E-05 0.000000E+00 0.000000E+00 -2.914595E-04 -8.494867E-08 +0.000000E+00 +0.000000E+00 +3.500000E-02 +2.930000E-04 +1.372494E-02 +4.750881E-05 +0.000000E+00 +0.000000E+00 +9.090396E-04 +2.755502E-07 +0.000000E+00 +0.000000E+00 +5.897816E-04 +3.478423E-07 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +3.700000E-02 +3.270000E-04 +1.492073E-02 +5.134793E-05 +0.000000E+00 +0.000000E+00 +6.134225E-04 +3.762872E-07 +1.000000E-03 +1.000000E-06 +3.074376E-04 +9.451786E-08 +1.000000E-03 +1.000000E-06 +6.148751E-04 +3.780714E-07 +3.500000E-02 +2.810000E-04 +1.728232E-02 +6.621096E-05 +0.000000E+00 +0.000000E+00 +1.214477E-03 +3.688425E-07 +0.000000E+00 +0.000000E+00 +1.481145E-03 +1.482321E-06 +1.000000E-03 +1.000000E-06 +3.015814E-04 +9.095135E-08 +8.000000E-03 +1.800000E-05 +3.359923E-03 +3.081200E-06 +0.000000E+00 +0.000000E+00 +3.067112E-04 +9.407179E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.000000E-03 +1.500000E-05 +3.660087E-03 +3.561493E-06 +0.000000E+00 +0.000000E+00 +9.203130E-04 +4.713637E-07 +1.000000E-03 +1.000000E-06 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.500000E-02 +2.630000E-04 +1.425810E-02 +4.231681E-05 +0.000000E+00 +0.000000E+00 +1.516059E-03 +4.597939E-07 +0.000000E+00 +0.000000E+00 +1.221752E-03 +1.492677E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +2.300000E-02 +1.110000E-04 +1.184871E-02 +2.918189E-05 +0.000000E+00 +0.000000E+00 +6.016020E-04 +1.810324E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.600000E-02 +6.600000E-05 +7.879913E-03 +1.566560E-05 +0.000000E+00 +0.000000E+00 +9.039098E-04 +2.724298E-07 +0.000000E+00 +0.000000E+00 +3.067112E-04 +9.407179E-08 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +9.000000E-03 +1.900000E-05 +4.256120E-03 +4.431220E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.000000E-03 +1.200000E-05 +2.739774E-03 +2.333986E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -146,13 +498,9 @@ tally 1: 0.000000E+00 0.000000E+00 1.400000E-02 -5.200000E-05 -6.711472E-03 -1.216306E-05 -0.000000E+00 -0.000000E+00 -5.847809E-04 -1.709846E-07 +6.800000E-05 +7.182805E-03 +1.822340E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -161,46 +509,50 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -1.700000E-02 -7.900000E-05 -6.413106E-03 -1.186604E-05 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.500000E-02 +6.300000E-05 +5.734575E-03 +9.207711E-06 0.000000E+00 0.000000E+00 +6.070193E-04 +1.842437E-07 0.000000E+00 0.000000E+00 -2.900000E-02 -1.770000E-04 -1.314196E-02 -3.678739E-05 -0.000000E+00 -0.000000E+00 -1.167073E-03 -5.110971E-07 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 +8.846723E-04 +7.826452E-07 1.000000E-03 1.000000E-06 0.000000E+00 0.000000E+00 -2.900000E-02 -1.830000E-04 -1.372758E-02 -4.360498E-05 +2.000000E-02 +8.800000E-05 +9.416733E-03 +2.020354E-05 0.000000E+00 0.000000E+00 -5.858090E-04 -1.715862E-07 +6.003287E-04 +1.802529E-07 +0.000000E+00 +0.000000E+00 +6.031628E-04 +3.638054E-07 +0.000000E+00 +0.000000E+00 +3.015814E-04 +9.095135E-08 +7.000000E-03 +1.500000E-05 +2.413278E-03 +1.439032E-06 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -209,110 +561,78 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -2.200000E-02 -1.000000E-04 -9.631311E-03 -2.001285E-05 +7.000000E-03 +1.500000E-05 +4.226919E-03 +4.173413E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.829191E-04 -3.397947E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.000000E-03 -1.800000E-05 -4.094439E-03 -4.622331E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.170949E-03 -1.371123E-06 +2.300000E-02 +1.590000E-04 +1.125341E-02 +3.890966E-05 +0.000000E+00 +0.000000E+00 +5.964722E-04 +1.779119E-07 +0.000000E+00 +0.000000E+00 +8.846723E-04 +7.826452E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.200000E-02 +2.260000E-04 +1.458976E-02 +4.416780E-05 +0.000000E+00 +0.000000E+00 +1.814806E-03 +9.096012E-07 +1.000000E-03 +1.000000E-06 +6.031628E-04 +3.638054E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.100000E-02 +2.050000E-04 +1.241089E-02 +3.545088E-05 +0.000000E+00 +0.000000E+00 +1.515620E-03 +1.191731E-06 +0.000000E+00 +0.000000E+00 +6.121491E-04 +1.873641E-07 1.000000E-03 1.000000E-06 0.000000E+00 0.000000E+00 -9.000000E-03 -5.100000E-05 -4.664405E-03 -1.087264E-05 +1.000000E-02 +2.600000E-05 +3.936862E-03 +3.749154E-06 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.200000E-02 -1.300000E-04 -9.644227E-03 -2.300481E-05 -0.000000E+00 -0.000000E+00 -8.771587E-04 -4.270487E-07 -0.000000E+00 -0.000000E+00 -2.927374E-04 -8.569516E-08 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.500000E-02 -1.630000E-04 -1.257283E-02 -3.946813E-05 -0.000000E+00 -0.000000E+00 -1.171259E-03 -8.583084E-07 -0.000000E+00 -0.000000E+00 -1.462299E-03 -1.112414E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.400000E-02 -1.400000E-04 -1.138156E-02 -3.565057E-05 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.000000E-03 -2.100000E-05 -4.383252E-03 -6.073597E-06 -0.000000E+00 -0.000000E+00 -8.707460E-04 -7.581986E-07 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -322,61 +642,9 @@ tally 1: 0.000000E+00 0.000000E+00 1.100000E-02 -3.500000E-05 -6.410606E-03 -1.066242E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -8.756564E-04 -4.254898E-07 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -1.600000E-02 -6.000000E-05 -7.287540E-03 -1.279808E-05 -0.000000E+00 -0.000000E+00 -5.822922E-04 -1.695337E-07 -0.000000E+00 -0.000000E+00 -1.172287E-03 -1.374256E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -3.400000E-02 -2.820000E-04 -1.603656E-02 -6.229803E-05 -0.000000E+00 -0.000000E+00 -1.460479E-03 -7.689660E-07 -1.000000E-03 -1.000000E-06 -1.165972E-03 -6.797578E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.900000E-02 -8.500000E-05 -7.880322E-03 -1.387762E-05 -0.000000E+00 -0.000000E+00 -8.755466E-04 -4.261064E-07 +4.700000E-05 +5.084641E-03 +9.248485E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -385,110 +653,50 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -8.000000E-03 -2.400000E-05 -4.666802E-03 -4.926489E-06 0.000000E+00 0.000000E+00 -5.829191E-04 -3.397947E-07 0.000000E+00 0.000000E+00 -8.759908E-04 -4.256857E-07 +2.500000E-02 +1.770000E-04 +1.021860E-02 +3.099521E-05 +0.000000E+00 +0.000000E+00 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +9.086007E-04 +4.570977E-07 2.000000E-03 2.000000E-06 -0.000000E+00 -0.000000E+00 +3.054379E-04 +9.329231E-08 1.500000E-02 -5.900000E-05 -8.180347E-03 -1.622409E-05 +5.300000E-05 +7.584986E-03 +1.188822E-05 0.000000E+00 0.000000E+00 -2.902487E-04 -8.424429E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.300000E-02 -1.390000E-04 -7.593262E-03 -1.708292E-05 -0.000000E+00 -0.000000E+00 -1.750169E-03 -1.193182E-06 +6.128755E-04 +1.878102E-07 1.000000E-03 1.000000E-06 -1.461465E-03 -7.684663E-07 -2.000000E-03 -4.000000E-06 -2.914595E-04 -8.494867E-08 -2.300000E-02 -1.350000E-04 -9.639670E-03 -2.161898E-05 -0.000000E+00 -0.000000E+00 -8.781869E-04 -4.288534E-07 -0.000000E+00 -0.000000E+00 -8.707460E-04 -7.581986E-07 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.100000E-02 -1.090000E-04 -9.045520E-03 -2.171457E-05 -0.000000E+00 -0.000000E+00 -5.851152E-04 -1.711804E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +6.108758E-04 +3.731692E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.800000E-02 -7.000000E-05 -1.167023E-02 -2.840320E-05 +8.600000E-05 +6.672457E-03 +1.369871E-05 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -5.854747E-04 -3.427806E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.000000E-03 -5.000000E-06 -1.171618E-03 -6.863446E-07 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 +6.141488E-04 +1.885896E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -497,26 +705,26 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -1.300000E-02 -4.500000E-05 -6.428153E-03 -9.064469E-06 +1.100000E-02 +2.700000E-05 +3.927884E-03 +3.728010E-06 +0.000000E+00 +0.000000E+00 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 -2.927374E-04 -8.569516E-08 -1.000000E-03 -1.000000E-06 -2.920435E-04 -8.528942E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.800000E-02 -9.000000E-05 -8.185938E-03 -1.967120E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -530,9 +738,13 @@ tally 1: 0.000000E+00 0.000000E+00 9.000000E-03 -2.300000E-05 -4.665341E-03 -5.426897E-06 +1.900000E-05 +4.217645E-03 +4.306910E-06 +0.000000E+00 +0.000000E+00 +6.128755E-04 +1.878102E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -541,78 +753,58 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.000000E-03 -4.000000E-06 -3.497088E-03 -3.563633E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.000000E-03 -9.000000E-06 -2.333045E-03 -1.870613E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.172287E-03 -1.374256E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.000000E-03 -2.200000E-05 -6.413648E-03 -1.136518E-05 -0.000000E+00 -0.000000E+00 -2.927374E-04 -8.569516E-08 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.000000E-02 -1.200000E-04 -7.007604E-03 -1.379504E-05 -0.000000E+00 -0.000000E+00 -5.851152E-04 -1.711804E-07 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 1.700000E-02 -7.900000E-05 -7.281401E-03 -1.600845E-05 +7.700000E-05 +7.235504E-03 +1.301737E-05 +0.000000E+00 +0.000000E+00 +3.054379E-04 +9.329231E-08 +0.000000E+00 +0.000000E+00 +1.531736E-03 +8.439742E-07 +3.000000E-03 +3.000000E-06 +3.074376E-04 +9.451786E-08 +9.000000E-03 +1.900000E-05 +3.018298E-03 +2.174671E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.141488E-04 +1.885896E-07 +1.000000E-03 +1.000000E-06 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.000000E-03 +2.000000E-06 +1.203204E-03 +7.241295E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -626,9 +818,9 @@ tally 1: 0.000000E+00 0.000000E+00 7.000000E-03 -1.900000E-05 -3.218959E-03 -4.543526E-06 +1.500000E-05 +4.818843E-03 +6.474375E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -641,12 +833,14 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -9.000000E-03 -1.900000E-05 -4.380921E-03 -4.182826E-06 +2.400000E-02 +1.180000E-04 +1.088639E-02 +2.567229E-05 0.000000E+00 0.000000E+00 +3.067112E-04 +9.407179E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -655,44 +849,38 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 +1.300000E-02 +5.100000E-05 +6.002667E-03 +1.149916E-05 0.000000E+00 0.000000E+00 -2.100000E-02 -1.050000E-04 -9.932207E-03 -2.153598E-05 +3.015814E-04 +9.095135E-08 0.000000E+00 0.000000E+00 -5.854747E-04 -3.427806E-07 +3.067112E-04 +9.407179E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 -1.800000E-02 -7.400000E-05 -7.301011E-03 -1.358176E-05 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.804973E-04 -3.369772E-07 -1.000000E-03 -1.000000E-06 0.000000E+00 0.000000E+00 -2.300000E-02 -1.610000E-04 -9.647933E-03 -2.657983E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -705,248 +893,60 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -9.000000E-03 -1.900000E-05 -2.915422E-03 -2.203274E-06 -0.000000E+00 -0.000000E+00 -8.775182E-04 -4.280701E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -2.920435E-04 -8.528942E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.000000E-03 -9.000000E-06 -2.044244E-03 -1.796182E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.800000E-02 -9.000000E-05 -6.718632E-03 -1.203946E-05 -0.000000E+00 -0.000000E+00 -2.927374E-04 -8.569516E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.100000E-02 -2.700000E-05 -4.675703E-03 -5.128811E-06 -0.000000E+00 -0.000000E+00 -2.914595E-04 -8.494867E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -2.914595E-04 -8.494867E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -2.920435E-04 -8.528942E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.000000E-03 -2.600000E-05 -4.670349E-03 -6.133014E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.500000E-02 -6.100000E-05 -8.751735E-03 -1.922421E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.400000E-02 -5.000000E-05 -6.126605E-03 -9.620966E-06 -0.000000E+00 -0.000000E+00 -5.835031E-04 -1.702381E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-03 -2.000000E-06 -5.847809E-04 -1.709846E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-03 -2.000000E-06 -8.719569E-04 -4.219258E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.000000E-03 -2.700000E-05 -4.085939E-03 -4.936434E-06 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.000000E-03 -2.500000E-05 -5.846700E-03 -9.739696E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.300000E-02 -3.900000E-05 -6.128455E-03 -1.013669E-05 +4.700000E-05 +5.486562E-03 +7.965488E-06 0.000000E+00 0.000000E+00 -5.851152E-04 -1.711804E-07 +3.054379E-04 +9.329231E-08 0.000000E+00 0.000000E+00 -1.172287E-03 -1.374256E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +8.000000E-03 +1.800000E-05 +3.334317E-03 +3.609712E-06 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.000000E-02 +1.080000E-04 +9.741552E-03 +2.552400E-05 +0.000000E+00 +0.000000E+00 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +1.800986E-03 +1.622276E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -962,11 +962,11 @@ tally 1: 0.000000E+00 0.000000E+00 tally 2: -5.554367E-01 -6.170503E-02 -6.055520E-01 -7.334109E-02 -3.526894E+00 -2.488065E+00 -3.925114E+01 -3.081807E+02 +5.818100E-01 +6.772558E-02 +6.344749E-01 +8.054355E-02 +3.690180E+00 +2.724752E+00 +4.102635E+01 +3.367908E+02 diff --git a/tests/regression_tests/electron_heating/__init__.py b/tests/regression_tests/statepoint_batch/__init__.py similarity index 100% rename from tests/regression_tests/electron_heating/__init__.py rename to tests/regression_tests/statepoint_batch/__init__.py diff --git a/tests/regression_tests/statepoint_batch/geometry.xml b/tests/regression_tests/statepoint_batch/geometry.xml new file mode 100644 index 000000000..bc56030e1 --- /dev/null +++ b/tests/regression_tests/statepoint_batch/geometry.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/regression_tests/particle_restart_fixed_shared_secondary/materials.xml b/tests/regression_tests/statepoint_batch/materials.xml similarity index 51% rename from tests/regression_tests/particle_restart_fixed_shared_secondary/materials.xml rename to tests/regression_tests/statepoint_batch/materials.xml index f3851d7ef..2472a7471 100644 --- a/tests/regression_tests/particle_restart_fixed_shared_secondary/materials.xml +++ b/tests/regression_tests/statepoint_batch/materials.xml @@ -2,8 +2,8 @@ - - + + diff --git a/tests/regression_tests/statepoint_batch/results_true.dat b/tests/regression_tests/statepoint_batch/results_true.dat new file mode 100644 index 000000000..f5c855d77 --- /dev/null +++ b/tests/regression_tests/statepoint_batch/results_true.dat @@ -0,0 +1,2 @@ +k-combined: +3.048864E-01 1.689118E-03 diff --git a/tests/regression_tests/statepoint_batch/settings.xml b/tests/regression_tests/statepoint_batch/settings.xml new file mode 100644 index 000000000..e2f8dad47 --- /dev/null +++ b/tests/regression_tests/statepoint_batch/settings.xml @@ -0,0 +1,17 @@ + + + + + + eigenvalue + 10 + 5 + 1000 + + + + -4 -4 -4 4 4 4 + + + + diff --git a/tests/regression_tests/statepoint_batch/test.py b/tests/regression_tests/statepoint_batch/test.py new file mode 100644 index 000000000..323b28fc6 --- /dev/null +++ b/tests/regression_tests/statepoint_batch/test.py @@ -0,0 +1,18 @@ +from tests.testing_harness import TestHarness + + +class StatepointTestHarness(TestHarness): + def __init__(self): + super().__init__(None) + + def _test_output_created(self): + """Make sure statepoint files have been created.""" + sps = ('statepoint.03.h5', 'statepoint.06.h5', 'statepoint.09.h5') + for sp in sps: + self._sp_name = sp + TestHarness._test_output_created(self) + + +def test_statepoint_batch(): + harness = StatepointTestHarness() + harness.main() diff --git a/tests/regression_tests/statepoint_restart/results_true.dat b/tests/regression_tests/statepoint_restart/results_true.dat index b919b3000..aebc971f4 100644 --- a/tests/regression_tests/statepoint_restart/results_true.dat +++ b/tests/regression_tests/statepoint_restart/results_true.dat @@ -1,18 +1,66 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 tally 1: 1.300000E-02 -3.900000E-05 +4.700000E-05 1.300000E-02 -3.900000E-05 -5.833114E-03 -7.476880E-06 +4.700000E-05 +5.741381E-03 +9.030024E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.164000E-03 -5.072152E-07 +3.067112E-04 +9.407179E-08 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.600000E-02 +1.420000E-04 +2.600000E-02 +1.420000E-04 +1.268989E-02 +3.464490E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +1.535009E-03 +1.224718E-06 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +3.200000E-02 +2.760000E-04 +3.200000E-02 +2.760000E-04 +1.248507E-02 +3.714039E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.208601E-04 +4.708050E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -25,36 +73,300 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -2.100000E-02 -1.110000E-04 -2.100000E-02 -1.110000E-04 -1.108363E-02 -2.889480E-05 +1.900000E-02 +7.500000E-05 +1.900000E-02 +7.500000E-05 +8.218811E-03 +1.462963E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.861433E-04 -3.435640E-07 +9.070399E-04 +2.743247E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.047443E-04 +8.185622E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +1.200000E-02 +5.000000E-05 +1.200000E-02 +5.000000E-05 +3.938144E-03 +5.245641E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.067112E-04 +9.407179E-08 +1.000000E-03 +1.000000E-06 +2.000000E-03 +4.000000E-06 +5.897816E-04 +3.478423E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +2.000000E-02 +1.260000E-04 +2.000000E-02 +1.260000E-04 +9.079852E-03 +2.657486E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.100000E-02 +2.010000E-04 +3.100000E-02 +2.010000E-04 +1.336346E-02 +3.645780E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.102710E-03 +1.524522E-06 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +9.083133E-04 +4.632477E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +2.300000E-02 +1.090000E-04 +2.300000E-02 +1.090000E-04 +1.334578E-02 +3.590708E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.031628E-04 +3.638054E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +1.530605E-03 +1.035684E-06 2.000000E-03 2.000000E-06 +2.000000E-03 +2.000000E-06 +6.082927E-04 +1.850231E-07 +1.400000E-02 +4.200000E-05 +1.400000E-02 +4.200000E-05 +7.257468E-03 +1.221578E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +8.980536E-04 +4.507660E-07 +2.000000E-03 +4.000000E-06 +2.000000E-03 +4.000000E-06 +0.000000E+00 +0.000000E+00 +9.000000E-03 +2.700000E-05 +9.000000E-03 +2.700000E-05 +5.193169E-03 +1.187321E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.054379E-04 +9.329231E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.000000E-02 +2.400000E-05 +1.000000E-02 +2.400000E-05 +5.170002E-03 +7.361546E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.003287E-04 +1.802529E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.800000E-02 +1.720000E-04 +2.800000E-02 +1.720000E-04 +1.699195E-02 +6.267008E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.800000E-02 +1.980000E-04 +2.800000E-02 +1.980000E-04 +1.338750E-02 +4.565234E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.183134E-04 +4.676871E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +1.537188E-03 +2.362946E-06 +2.000000E-03 +4.000000E-06 +2.000000E-03 +4.000000E-06 +0.000000E+00 +0.000000E+00 +2.900000E-02 +1.950000E-04 +2.900000E-02 +1.950000E-04 +1.178615E-02 +3.130999E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.179563E-03 +1.391369E-06 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +1.500000E-02 +6.500000E-05 +1.500000E-02 +6.500000E-05 +5.706064E-03 +9.729293E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 3.000000E-03 -5.000000E-06 -2.043490E-03 -1.793389E-06 -2.000000E-03 -2.000000E-06 -2.000000E-03 -2.000000E-06 -2.930717E-04 -8.589100E-08 -2.000000E-02 -9.000000E-05 -2.000000E-02 -9.000000E-05 -9.334862E-03 -1.853104E-05 +9.000000E-06 +3.000000E-03 +9.000000E-06 +1.516642E-03 +1.579637E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -65,50 +377,26 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 +5.897816E-04 +3.478423E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +2.900000E-02 +1.970000E-04 +2.900000E-02 +1.970000E-04 +1.274851E-02 +3.511219E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.500000E-02 -1.430000E-04 -2.500000E-02 -1.430000E-04 -1.110224E-02 -2.872840E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.833203E-04 -1.701353E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.000000E-03 -1.100000E-05 -5.000000E-03 -1.100000E-05 -1.752967E-03 -1.027501E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 +9.057666E-04 +4.601298E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -125,86 +413,326 @@ tally 1: 7.600000E-05 1.800000E-02 7.600000E-05 -7.300761E-03 -1.254112E-05 +8.803642E-03 +1.730938E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.841969E-04 -1.706438E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.900000E-02 +1.830000E-04 +2.900000E-02 +1.830000E-04 +1.245316E-02 +3.378176E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.016020E-04 +1.810324E-07 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -3.000000E-02 -1.820000E-04 -3.000000E-02 -1.820000E-04 -1.518122E-02 -4.757233E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.927374E-04 -8.569516E-08 -2.000000E-03 -2.000000E-06 -2.000000E-03 -2.000000E-06 -2.631167E-03 -3.503358E-06 1.000000E-03 1.000000E-06 1.000000E-03 1.000000E-06 -2.920435E-04 -8.528942E-08 -2.500000E-02 -1.390000E-04 -2.500000E-02 -1.390000E-04 -9.343205E-03 -1.910189E-05 +6.090190E-04 +1.854692E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.039724E-03 -1.271217E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.031628E-04 +3.638054E-07 1.000000E-03 1.000000E-06 1.000000E-03 1.000000E-06 -5.861433E-04 -3.435640E-07 +0.000000E+00 +0.000000E+00 +1.900000E-02 +8.700000E-05 +1.900000E-02 +8.700000E-05 +8.781239E-03 +1.676750E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.128755E-04 +1.878102E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.400000E-02 -1.340000E-04 -2.400000E-02 -1.340000E-04 -1.080336E-02 -2.533338E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.914595E-04 -8.494867E-08 +0.000000E+00 +0.000000E+00 +3.500000E-02 +2.930000E-04 +3.500000E-02 +2.930000E-04 +1.372494E-02 +4.750881E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.090396E-04 +2.755502E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +5.897816E-04 +3.478423E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +3.700000E-02 +3.270000E-04 +3.700000E-02 +3.270000E-04 +1.492073E-02 +5.134793E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.134225E-04 +3.762872E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +3.074376E-04 +9.451786E-08 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +6.148751E-04 +3.780714E-07 +3.500000E-02 +2.810000E-04 +3.500000E-02 +2.810000E-04 +1.728232E-02 +6.621096E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.214477E-03 +3.688425E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.481145E-03 +1.482321E-06 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +3.015814E-04 +9.095135E-08 +8.000000E-03 +1.800000E-05 +8.000000E-03 +1.800000E-05 +3.359923E-03 +3.081200E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.067112E-04 +9.407179E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.000000E-03 +1.500000E-05 +7.000000E-03 +1.500000E-05 +3.660087E-03 +3.561493E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.203130E-04 +4.713637E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.500000E-02 +2.630000E-04 +3.500000E-02 +2.630000E-04 +1.425810E-02 +4.231681E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.516059E-03 +4.597939E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.221752E-03 +1.492677E-06 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +2.300000E-02 +1.110000E-04 +2.300000E-02 +1.110000E-04 +1.184871E-02 +2.918189E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.016020E-04 +1.810324E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.600000E-02 +6.600000E-05 +1.600000E-02 +6.600000E-05 +7.879913E-03 +1.566560E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.039098E-04 +2.724298E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.067112E-04 +9.407179E-08 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +9.000000E-03 +1.900000E-05 +9.000000E-03 +1.900000E-05 +4.256120E-03 +4.431220E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.000000E-03 +1.200000E-05 +6.000000E-03 +1.200000E-05 +2.739774E-03 +2.333986E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -218,17 +746,11 @@ tally 1: 0.000000E+00 0.000000E+00 1.400000E-02 -5.200000E-05 +6.800000E-05 1.400000E-02 -5.200000E-05 -6.711472E-03 -1.216306E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.847809E-04 -1.709846E-07 +6.800000E-05 +7.182805E-03 +1.822340E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -241,66 +763,72 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -1.700000E-02 -7.900000E-05 -1.700000E-02 -7.900000E-05 -6.413106E-03 -1.186604E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +1.500000E-02 +6.300000E-05 +1.500000E-02 +6.300000E-05 +5.734575E-03 +9.207711E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -2.900000E-02 -1.770000E-04 -2.900000E-02 -1.770000E-04 -1.314196E-02 -3.678739E-05 +6.070193E-04 +1.842437E-07 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.167073E-03 -5.110971E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 +8.846723E-04 +7.826452E-07 1.000000E-03 1.000000E-06 1.000000E-03 1.000000E-06 0.000000E+00 0.000000E+00 -2.900000E-02 -1.830000E-04 -2.900000E-02 -1.830000E-04 -1.372758E-02 -4.360498E-05 +2.000000E-02 +8.800000E-05 +2.000000E-02 +8.800000E-05 +9.416733E-03 +2.020354E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.858090E-04 -1.715862E-07 +6.003287E-04 +1.802529E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.031628E-04 +3.638054E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.015814E-04 +9.095135E-08 +7.000000E-03 +1.500000E-05 +7.000000E-03 +1.500000E-05 +2.413278E-03 +1.439032E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -313,12 +841,12 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -2.200000E-02 -1.000000E-04 -2.200000E-02 -1.000000E-04 -9.631311E-03 -2.001285E-05 +7.000000E-03 +1.500000E-05 +7.000000E-03 +1.500000E-05 +4.226919E-03 +4.173413E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -329,20 +857,6 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -5.829191E-04 -3.397947E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.000000E-03 -1.800000E-05 -8.000000E-03 -1.800000E-05 -4.094439E-03 -4.622331E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -351,124 +865,90 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 +2.300000E-02 +1.590000E-04 +2.300000E-02 +1.590000E-04 +1.125341E-02 +3.890966E-05 0.000000E+00 0.000000E+00 -1.170949E-03 -1.371123E-06 +0.000000E+00 +0.000000E+00 +5.964722E-04 +1.779119E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +8.846723E-04 +7.826452E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.200000E-02 +2.260000E-04 +3.200000E-02 +2.260000E-04 +1.458976E-02 +4.416780E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.814806E-03 +9.096012E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +6.031628E-04 +3.638054E-07 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.100000E-02 +2.050000E-04 +3.100000E-02 +2.050000E-04 +1.241089E-02 +3.545088E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.515620E-03 +1.191731E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.121491E-04 +1.873641E-07 1.000000E-03 1.000000E-06 1.000000E-03 1.000000E-06 0.000000E+00 0.000000E+00 -9.000000E-03 -5.100000E-05 -9.000000E-03 -5.100000E-05 -4.664405E-03 -1.087264E-05 +1.000000E-02 +2.600000E-05 +1.000000E-02 +2.600000E-05 +3.936862E-03 +3.749154E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.200000E-02 -1.300000E-04 -2.200000E-02 -1.300000E-04 -9.644227E-03 -2.300481E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.771587E-04 -4.270487E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.927374E-04 -8.569516E-08 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.500000E-02 -1.630000E-04 -2.500000E-02 -1.630000E-04 -1.257283E-02 -3.946813E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.171259E-03 -8.583084E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.462299E-03 -1.112414E-06 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.400000E-02 -1.400000E-04 -2.400000E-02 -1.400000E-04 -1.138156E-02 -3.565057E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.000000E-03 -2.100000E-05 -9.000000E-03 -2.100000E-05 -4.383252E-03 -6.073597E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.707460E-04 -7.581986E-07 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -482,89 +962,11 @@ tally 1: 0.000000E+00 0.000000E+00 1.100000E-02 -3.500000E-05 +4.700000E-05 1.100000E-02 -3.500000E-05 -6.410606E-03 -1.066242E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -8.756564E-04 -4.254898E-07 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -1.600000E-02 -6.000000E-05 -1.600000E-02 -6.000000E-05 -7.287540E-03 -1.279808E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.822922E-04 -1.695337E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.172287E-03 -1.374256E-06 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -3.400000E-02 -2.820000E-04 -3.400000E-02 -2.820000E-04 -1.603656E-02 -6.229803E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.460479E-03 -7.689660E-07 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -1.165972E-03 -6.797578E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.900000E-02 -8.500000E-05 -1.900000E-02 -8.500000E-05 -7.880322E-03 -1.387762E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.755466E-04 -4.261064E-07 +4.700000E-05 +5.084641E-03 +9.248485E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -577,120 +979,54 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -8.000000E-03 -2.400000E-05 -8.000000E-03 -2.400000E-05 -4.666802E-03 -4.926489E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.829191E-04 -3.397947E-07 +0.000000E+00 +0.000000E+00 +2.500000E-02 +1.770000E-04 +2.500000E-02 +1.770000E-04 +1.021860E-02 +3.099521E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -8.759908E-04 -4.256857E-07 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.086007E-04 +4.570977E-07 2.000000E-03 2.000000E-06 2.000000E-03 2.000000E-06 -0.000000E+00 -0.000000E+00 +3.054379E-04 +9.329231E-08 1.500000E-02 -5.900000E-05 +5.300000E-05 1.500000E-02 -5.900000E-05 -8.180347E-03 -1.622409E-05 +5.300000E-05 +7.584986E-03 +1.188822E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.902487E-04 -8.424429E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.300000E-02 -1.390000E-04 -2.300000E-02 -1.390000E-04 -7.593262E-03 -1.708292E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.750169E-03 -1.193182E-06 +6.128755E-04 +1.878102E-07 1.000000E-03 1.000000E-06 1.000000E-03 1.000000E-06 -1.461465E-03 -7.684663E-07 -2.000000E-03 -4.000000E-06 -2.000000E-03 -4.000000E-06 -2.914595E-04 -8.494867E-08 -2.300000E-02 -1.350000E-04 -2.300000E-02 -1.350000E-04 -9.639670E-03 -2.161898E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.781869E-04 -4.288534E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.707460E-04 -7.581986E-07 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.100000E-02 -1.090000E-04 -2.100000E-02 -1.090000E-04 -9.045520E-03 -2.171457E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.851152E-04 -1.711804E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 +6.108758E-04 +3.731692E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -698,41 +1034,17 @@ tally 1: 0.000000E+00 0.000000E+00 1.800000E-02 -7.000000E-05 +8.600000E-05 1.800000E-02 -7.000000E-05 -1.167023E-02 -2.840320E-05 +8.600000E-05 +6.672457E-03 +1.369871E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -5.854747E-04 -3.427806E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.000000E-03 -5.000000E-06 -3.000000E-03 -5.000000E-06 -1.171618E-03 -6.863446E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 +6.141488E-04 +1.885896E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -745,36 +1057,36 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -1.300000E-02 -4.500000E-05 -1.300000E-02 -4.500000E-05 -6.428153E-03 -9.064469E-06 +1.100000E-02 +2.700000E-05 +1.100000E-02 +2.700000E-05 +3.927884E-03 +3.728010E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -2.927374E-04 -8.569516E-08 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -2.920435E-04 -8.528942E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.800000E-02 -9.000000E-05 -1.800000E-02 -9.000000E-05 -8.185938E-03 -1.967120E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -794,15 +1106,17 @@ tally 1: 0.000000E+00 0.000000E+00 9.000000E-03 -2.300000E-05 +1.900000E-05 9.000000E-03 -2.300000E-05 -4.665341E-03 -5.426897E-06 +1.900000E-05 +4.217645E-03 +4.306910E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +6.128755E-04 +1.878102E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -815,110 +1129,84 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -0.000000E+00 -0.000000E+00 -4.000000E-03 -4.000000E-06 -4.000000E-03 -4.000000E-06 -3.497088E-03 -3.563633E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.000000E-03 -9.000000E-06 -5.000000E-03 -9.000000E-06 -2.333045E-03 -1.870613E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.172287E-03 -1.374256E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.000000E-03 -2.200000E-05 -8.000000E-03 -2.200000E-05 -6.413648E-03 -1.136518E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.927374E-04 -8.569516E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 -2.000000E-02 -1.200000E-04 -2.000000E-02 -1.200000E-04 -7.007604E-03 -1.379504E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.851152E-04 -1.711804E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.861433E-04 -3.435640E-07 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -0.000000E+00 -0.000000E+00 1.700000E-02 -7.900000E-05 +7.700000E-05 1.700000E-02 -7.900000E-05 -7.281401E-03 -1.600845E-05 +7.700000E-05 +7.235504E-03 +1.301737E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.054379E-04 +9.329231E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.531736E-03 +8.439742E-07 +3.000000E-03 +3.000000E-06 +3.000000E-03 +3.000000E-06 +3.074376E-04 +9.451786E-08 +9.000000E-03 +1.900000E-05 +9.000000E-03 +1.900000E-05 +3.018298E-03 +2.174671E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +6.141488E-04 +1.885896E-07 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +3.074376E-04 +9.451786E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.000000E-03 +2.000000E-06 +2.000000E-03 +2.000000E-06 +1.203204E-03 +7.241295E-07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -938,11 +1226,11 @@ tally 1: 0.000000E+00 0.000000E+00 7.000000E-03 -1.900000E-05 +1.500000E-05 7.000000E-03 -1.900000E-05 -3.218959E-03 -4.543526E-06 +1.500000E-05 +4.818843E-03 +6.474375E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -961,16 +1249,18 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -9.000000E-03 -1.900000E-05 -9.000000E-03 -1.900000E-05 -4.380921E-03 -4.182826E-06 +2.400000E-02 +1.180000E-04 +2.400000E-02 +1.180000E-04 +1.088639E-02 +2.567229E-05 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +3.067112E-04 +9.407179E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -983,22 +1273,24 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 +1.300000E-02 +5.100000E-05 +1.300000E-02 +5.100000E-05 +6.002667E-03 +1.149916E-05 0.000000E+00 0.000000E+00 -2.100000E-02 -1.050000E-04 -2.100000E-02 -1.050000E-04 -9.932207E-03 -2.153598E-05 0.000000E+00 0.000000E+00 +3.015814E-04 +9.095135E-08 0.000000E+00 0.000000E+00 -5.854747E-04 -3.427806E-07 0.000000E+00 0.000000E+00 +3.067112E-04 +9.407179E-08 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1009,36 +1301,22 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -1.800000E-02 -7.400000E-05 -1.800000E-02 -7.400000E-05 -7.301011E-03 -1.358176E-05 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 +2.948908E-04 +8.696057E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.804973E-04 -3.369772E-07 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 0.000000E+00 0.000000E+00 -2.300000E-02 -1.610000E-04 -2.300000E-02 -1.610000E-04 -9.647933E-03 -2.657983E-05 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1057,332 +1335,6 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -9.000000E-03 -1.900000E-05 -9.000000E-03 -1.900000E-05 -2.915422E-03 -2.203274E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.775182E-04 -4.280701E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -2.920435E-04 -8.528942E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.000000E-03 -9.000000E-06 -5.000000E-03 -9.000000E-06 -2.044244E-03 -1.796182E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.800000E-02 -9.000000E-05 -1.800000E-02 -9.000000E-05 -6.718632E-03 -1.203946E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.927374E-04 -8.569516E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.100000E-02 -2.700000E-05 -1.100000E-02 -2.700000E-05 -4.675703E-03 -5.128811E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.914595E-04 -8.494867E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -2.914595E-04 -8.494867E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-03 -1.000000E-06 -1.000000E-03 -1.000000E-06 -2.920435E-04 -8.528942E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -8.000000E-03 -2.600000E-05 -8.000000E-03 -2.600000E-05 -4.670349E-03 -6.133014E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.500000E-02 -6.100000E-05 -1.500000E-02 -6.100000E-05 -8.751735E-03 -1.922421E-05 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.400000E-02 -5.000000E-05 -1.400000E-02 -5.000000E-05 -6.126605E-03 -9.620966E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -5.835031E-04 -1.702381E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-03 -2.000000E-06 -2.000000E-03 -2.000000E-06 -5.847809E-04 -1.709846E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-03 -2.000000E-06 -2.000000E-03 -2.000000E-06 -8.719569E-04 -4.219258E-07 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.000000E-03 -2.700000E-05 -9.000000E-03 -2.700000E-05 -4.085939E-03 -4.936434E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.930717E-04 -8.589100E-08 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -9.000000E-03 -2.500000E-05 -9.000000E-03 -2.500000E-05 -5.846700E-03 -9.739696E-06 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1394,23 +1346,21 @@ tally 1: 0.000000E+00 0.000000E+00 1.300000E-02 -3.900000E-05 +4.700000E-05 1.300000E-02 -3.900000E-05 -6.128455E-03 -1.013669E-05 +4.700000E-05 +5.486562E-03 +7.965488E-06 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -5.851152E-04 -1.711804E-07 +3.054379E-04 +9.329231E-08 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -1.172287E-03 -1.374256E-06 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1419,6 +1369,56 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 +8.000000E-03 +1.800000E-05 +8.000000E-03 +1.800000E-05 +3.334317E-03 +3.609712E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.948908E-04 +8.696057E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.000000E-02 +1.080000E-04 +2.000000E-02 +1.080000E-04 +9.741552E-03 +2.552400E-05 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.015814E-04 +9.095135E-08 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.800986E-03 +1.622276E-06 +1.000000E-03 +1.000000E-06 +1.000000E-03 +1.000000E-06 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 @@ -1442,11 +1442,11 @@ tally 1: 0.000000E+00 0.000000E+00 tally 2: -5.554367E-01 -6.170503E-02 -6.055520E-01 -7.334109E-02 -3.526894E+00 -2.488065E+00 -3.925114E+01 -3.081807E+02 +5.818100E-01 +6.772558E-02 +6.344749E-01 +8.054355E-02 +3.690180E+00 +2.724752E+00 +4.102635E+01 +3.367908E+02 diff --git a/tests/regression_tests/statepoint_sourcesep/results_true.dat b/tests/regression_tests/statepoint_sourcesep/results_true.dat index 97b997ae6..bbf03de94 100644 --- a/tests/regression_tests/statepoint_sourcesep/results_true.dat +++ b/tests/regression_tests/statepoint_sourcesep/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 diff --git a/tests/regression_tests/stride/__init__.py b/tests/regression_tests/stride/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/stride/inputs_true.dat b/tests/regression_tests/stride/inputs_true.dat deleted file mode 100644 index ebae53c05..000000000 --- a/tests/regression_tests/stride/inputs_true.dat +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - eigenvalue - 1000 - 10 - 5 - - - -4 -4 -4 4 4 4 - - - 1529170 - - diff --git a/tests/regression_tests/stride/results_true.dat b/tests/regression_tests/stride/results_true.dat deleted file mode 100644 index 825de3766..000000000 --- a/tests/regression_tests/stride/results_true.dat +++ /dev/null @@ -1,2 +0,0 @@ -k-combined: -2.953207E-01 2.874356E-03 diff --git a/tests/regression_tests/stride/test.py b/tests/regression_tests/stride/test.py deleted file mode 100644 index f911af1f5..000000000 --- a/tests/regression_tests/stride/test.py +++ /dev/null @@ -1,29 +0,0 @@ -import pytest -import openmc - -from tests.testing_harness import PyAPITestHarness - - -@pytest.fixture -def model(): - u = openmc.Material() - u.add_nuclide('U235', 1.0) - u.set_density('g/cm3', 4.5) - sph = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(fill=u, region=-sph) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - - model.settings.batches = 10 - model.settings.inactive = 5 - model.settings.particles = 1000 - model.settings.stride = 1_529_170 - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box([-4, -4, -4], [4, 4, 4]) - ) - return model - - -def test_seed(model): - harness = PyAPITestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/surface_source/inputs_true_read_h5.dat b/tests/regression_tests/surface_source/inputs_true_read.dat similarity index 74% rename from tests/regression_tests/surface_source/inputs_true_read_h5.dat rename to tests/regression_tests/surface_source/inputs_true_read.dat index 321c11d42..14a55f0bf 100644 --- a/tests/regression_tests/surface_source/inputs_true_read_h5.dat +++ b/tests/regression_tests/surface_source/inputs_true_read.dat @@ -7,10 +7,10 @@ - - - - + + + + fixed source diff --git a/tests/regression_tests/surface_source/inputs_true_read_mcpl.dat b/tests/regression_tests/surface_source/inputs_true_read_mcpl.dat deleted file mode 100644 index 2ee76f618..000000000 --- a/tests/regression_tests/surface_source/inputs_true_read_mcpl.dat +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - fixed source - 1000 - 10 - - surface_source_true.mcpl - - 1 - - - - 3 - - - 1 - flux - - - diff --git a/tests/regression_tests/surface_source/inputs_true_write_h5.dat b/tests/regression_tests/surface_source/inputs_true_write.dat similarity index 73% rename from tests/regression_tests/surface_source/inputs_true_write_h5.dat rename to tests/regression_tests/surface_source/inputs_true_write.dat index 10e3af0a7..5c85de631 100644 --- a/tests/regression_tests/surface_source/inputs_true_write_h5.dat +++ b/tests/regression_tests/surface_source/inputs_true_write.dat @@ -7,16 +7,16 @@ - - - - + + + + fixed source 1000 10 - + 0 0 0 diff --git a/tests/regression_tests/surface_source/inputs_true_write_mcpl.dat b/tests/regression_tests/surface_source/inputs_true_write_mcpl.dat deleted file mode 100644 index e9758144d..000000000 --- a/tests/regression_tests/surface_source/inputs_true_write_mcpl.dat +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - fixed source - 1000 - 10 - - - 0 0 0 - - - - 1 - true - 1000 - - 1 - - - - 3 - - - 1 - flux - - - diff --git a/tests/regression_tests/surface_source/surface_source_true.h5 b/tests/regression_tests/surface_source/surface_source_true.h5 index 02e94c90b..f2055d09d 100644 Binary files a/tests/regression_tests/surface_source/surface_source_true.h5 and b/tests/regression_tests/surface_source/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source/surface_source_true.mcpl b/tests/regression_tests/surface_source/surface_source_true.mcpl deleted file mode 100644 index ca4b7c2c4..000000000 Binary files a/tests/regression_tests/surface_source/surface_source_true.mcpl and /dev/null differ diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 13966b26d..81bba0c94 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -10,40 +10,11 @@ from tests.testing_harness import PyAPITestHarness from tests.regression_tests import config -def mcpl_to_array(filepath): - import mcpl - - source = [] - with mcpl.MCPLFile(filepath) as f: - for p in f.particles: - source.append( - [ - *tuple(p.position), - *tuple(p.direction), - 1.0e6 * p.ekin, - 1.0e-3 * p.time, - p.weight, - p.pdgcode, - ] - ) - return np.sort(np.array(source), axis=0) - - -def assert_structured_arrays_close(arr1, arr2, rtol=1e-5, atol=1e-8): - assert arr1.dtype == arr2.dtype - - for field in arr1.dtype.names: - data1, data2 = arr1[field], arr2[field] - if data1.dtype.names: - assert_structured_arrays_close(data1, data2, rtol=rtol, atol=atol) - else: - np.testing.assert_allclose(data1, data2, rtol=rtol, atol=atol) - - @pytest.fixture def model(request): openmc.reset_auto_ids() - operation, file_format = request.node.get_closest_marker("params").args + marker = request.node.get_closest_marker("surf_source_op") + surf_source_op = marker.args[0] openmc_model = openmc.model.Model() @@ -72,19 +43,15 @@ def model(request): openmc_model.settings.batches = 10 openmc_model.settings.seed = 1 - if operation == 'write': + if surf_source_op == 'write': point = openmc.stats.Point((0, 0, 0)) pt_src = openmc.IndependentSource(space=point) openmc_model.settings.source = pt_src - surf_source_write_settings = {'surface_ids': [1], - 'max_particles': 1000} - if file_format == "mcpl": - surf_source_write_settings["mcpl"] = True - - openmc_model.settings.surf_source_write = surf_source_write_settings - elif operation == 'read': - openmc_model.settings.surf_source_read = {'path': f"surface_source_true.{file_format}"} + openmc_model.settings.surf_source_write = {'surface_ids': [1], + 'max_particles': 1000} + elif surf_source_op == 'read': + openmc_model.settings.surf_source_read = {'path': 'surface_source_true.h5'} # Tallies tal = openmc.Tally() @@ -97,30 +64,28 @@ def model(request): class SurfaceSourceTestHarness(PyAPITestHarness): - def __init__(self, statepoint_name, model=None, inputs_true=None, file_format="h5"): - super().__init__(statepoint_name, model, inputs_true) - self.file_format = file_format - def _test_output_created(self): - """Make sure the surface_source file has also been created.""" + """Make sure surface_source.h5 has also been created.""" super()._test_output_created() + # Check if 'surface_source.h5' has been created. if self._model.settings.surf_source_write: - assert os.path.exists(f"surface_source.{self.file_format}"), \ + assert os.path.exists('surface_source.h5'), \ 'Surface source file does not exist.' def _compare_output(self): """Make sure the current surface_source.h5 agree with the reference.""" if self._model.settings.surf_source_write: - if self.file_format == "h5": - with h5py.File("surface_source_true.h5", 'r') as f: - source_true = np.sort(f['source_bank'][()]) - with h5py.File("surface_source.h5", 'r') as f: - source_test = np.sort(f['source_bank'][()]) - assert_structured_arrays_close(source_true, source_test, atol=1e-07) - elif self.file_format == "mcpl": - source_true = mcpl_to_array("surface_source_true.mcpl") - source_test = mcpl_to_array("surface_source.mcpl") - np.testing.assert_allclose(source_true, source_test, rtol=1e-5, atol=1e-7) + with h5py.File("surface_source_true.h5", 'r') as f: + source_true = f['source_bank'][()] + # Convert dtye from mixed to a float for comparison assertion + source_true.dtype = 'float64' + with h5py.File("surface_source.h5", 'r') as f: + source_test = f['source_bank'][()] + # Convert dtye from mixed to a float for comparison assertion + source_test.dtype = 'float64' + np.testing.assert_allclose(np.sort(source_true), + np.sort(source_test), + atol=1e-07) def execute_test(self): """Build input XMLs, run OpenMC, check output and results.""" @@ -141,56 +106,30 @@ class SurfaceSourceTestHarness(PyAPITestHarness): def _overwrite_results(self): """Overwrite the results_true with the results_test.""" shutil.copyfile('results_test.dat', 'results_true.dat') - if os.path.exists(f"surface_source.{self.file_format}"): - shutil.copyfile(f"surface_source.{self.file_format}", f"surface_source_true.{self.file_format}") + if os.path.exists('surface_source.h5'): + shutil.copyfile('surface_source.h5', 'surface_source_true.h5') def _cleanup(self): """Delete statepoints, tally, and test files.""" super()._cleanup() - fs = f"surface_source.{self.file_format}" + fs = 'surface_source.h5' if os.path.exists(fs): os.remove(fs) -@pytest.mark.params('write', 'h5') -def test_surface_source_write(model, monkeypatch, request): - monkeypatch.setitem(config, "mpi_np", "1") # Results generated with 1 MPI process - operation, file_format = request.node.get_closest_marker("params").args - harness = SurfaceSourceTestHarness( - "statepoint.10.h5", model, f"inputs_true_{operation}_{file_format}.dat", - file_format=file_format - ) +@pytest.mark.surf_source_op('write') +def test_surface_source_write(model, monkeypatch): + # Test result is based on 1 MPI process + monkeypatch.setitem(config, "mpi_np", "1") + harness = SurfaceSourceTestHarness('statepoint.10.h5', + model, + 'inputs_true_write.dat') harness.main() -@pytest.mark.params('read', 'h5') -def test_surface_source_read(model, request): - operation, file_format = request.node.get_closest_marker("params").args - harness = SurfaceSourceTestHarness( - "statepoint.10.h5", model, f"inputs_true_{operation}_{file_format}.dat", - file_format=file_format - ) - harness.main() - - -@pytest.mark.skipif(shutil.which("mcpl-config") is None, reason="MCPL is not available.") -@pytest.mark.params('write', 'mcpl') -def test_surface_source_write_mcpl(model, monkeypatch, request): - monkeypatch.setitem(config, "mpi_np", "1") # Results generated with 1 MPI process - operation, file_format = request.node.get_closest_marker("params").args - harness = SurfaceSourceTestHarness( - "statepoint.10.h5", model, f"inputs_true_{operation}_{file_format}.dat", - file_format=file_format - ) - harness.main() - - -@pytest.mark.skipif(shutil.which("mcpl-config") is None, reason="MCPL is not available.") -@pytest.mark.params('read', 'mcpl') -def test_surface_source_read_mcpl(model, request): - operation, file_format = request.node.get_closest_marker("params").args - harness = SurfaceSourceTestHarness( - "statepoint.10.h5", model, f"inputs_true_{operation}_{file_format}.dat", - file_format=file_format - ) +@pytest.mark.surf_source_op('read') +def test_surface_source_read(model): + harness = SurfaceSourceTestHarness('statepoint.10.h5', + model, + 'inputs_true_read.dat') harness.main() diff --git a/tests/regression_tests/surface_source_write/case-01/inputs_true.dat b/tests/regression_tests/surface_source_write/case-01/inputs_true.dat index 2a67b03dd..7368debd5 100644 --- a/tests/regression_tests/surface_source_write/case-01/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-01/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-01/results_true.dat b/tests/regression_tests/surface_source_write/case-01/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-01/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-01/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-01/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-01/surface_source_true.h5 index 3a2315acc..82dca4d03 100644 Binary files a/tests/regression_tests/surface_source_write/case-01/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-01/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-02/inputs_true.dat b/tests/regression_tests/surface_source_write/case-02/inputs_true.dat index 527f076b9..12f15499f 100644 --- a/tests/regression_tests/surface_source_write/case-02/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-02/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-02/results_true.dat b/tests/regression_tests/surface_source_write/case-02/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-02/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-02/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-02/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-02/surface_source_true.h5 index 2c2d5bc00..872efa070 100644 Binary files a/tests/regression_tests/surface_source_write/case-02/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-02/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-03/inputs_true.dat b/tests/regression_tests/surface_source_write/case-03/inputs_true.dat index 58c4e0a24..cd0f7deda 100644 --- a/tests/regression_tests/surface_source_write/case-03/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-03/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-03/results_true.dat b/tests/regression_tests/surface_source_write/case-03/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-03/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-03/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-03/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-03/surface_source_true.h5 index d14771f5a..04a6ac9a3 100644 Binary files a/tests/regression_tests/surface_source_write/case-03/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-03/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-04/inputs_true.dat b/tests/regression_tests/surface_source_write/case-04/inputs_true.dat index 46701aea7..ac3c03e37 100644 --- a/tests/regression_tests/surface_source_write/case-04/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-04/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-04/results_true.dat b/tests/regression_tests/surface_source_write/case-04/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-04/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-04/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-04/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-04/surface_source_true.h5 index d2acc6991..75c309eb4 100644 Binary files a/tests/regression_tests/surface_source_write/case-04/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-04/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-05/inputs_true.dat b/tests/regression_tests/surface_source_write/case-05/inputs_true.dat index c420d797c..143e85200 100644 --- a/tests/regression_tests/surface_source_write/case-05/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-05/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-05/results_true.dat b/tests/regression_tests/surface_source_write/case-05/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-05/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-05/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-05/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-05/surface_source_true.h5 index 553090b19..1a2f54d76 100644 Binary files a/tests/regression_tests/surface_source_write/case-05/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-05/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-06/inputs_true.dat b/tests/regression_tests/surface_source_write/case-06/inputs_true.dat index e02d5e90c..f2dc7ea35 100644 --- a/tests/regression_tests/surface_source_write/case-06/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-06/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-06/results_true.dat b/tests/regression_tests/surface_source_write/case-06/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-06/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-06/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-06/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-06/surface_source_true.h5 index 60a9f4f82..bef135e5a 100644 Binary files a/tests/regression_tests/surface_source_write/case-06/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-06/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-07/inputs_true.dat b/tests/regression_tests/surface_source_write/case-07/inputs_true.dat index a4588c8d0..a6107d16f 100644 --- a/tests/regression_tests/surface_source_write/case-07/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-07/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-07/results_true.dat b/tests/regression_tests/surface_source_write/case-07/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-07/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-07/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-07/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-07/surface_source_true.h5 index cb3079251..f84a5c4c5 100644 Binary files a/tests/regression_tests/surface_source_write/case-07/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-07/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-08/inputs_true.dat b/tests/regression_tests/surface_source_write/case-08/inputs_true.dat index ecf3a6a2e..b87e2b207 100644 --- a/tests/regression_tests/surface_source_write/case-08/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-08/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-08/results_true.dat b/tests/regression_tests/surface_source_write/case-08/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-08/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-08/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-08/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-08/surface_source_true.h5 index ed3aba907..1fd302a7c 100644 Binary files a/tests/regression_tests/surface_source_write/case-08/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-08/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-09/inputs_true.dat b/tests/regression_tests/surface_source_write/case-09/inputs_true.dat index 5d60f9dbe..f4f6ebd87 100644 --- a/tests/regression_tests/surface_source_write/case-09/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-09/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-09/results_true.dat b/tests/regression_tests/surface_source_write/case-09/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-09/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-09/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-09/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-09/surface_source_true.h5 index d62363f97..af832f060 100644 Binary files a/tests/regression_tests/surface_source_write/case-09/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-09/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-10/inputs_true.dat b/tests/regression_tests/surface_source_write/case-10/inputs_true.dat index 1940826c2..372e5c011 100644 --- a/tests/regression_tests/surface_source_write/case-10/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-10/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-10/results_true.dat b/tests/regression_tests/surface_source_write/case-10/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-10/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-10/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-10/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-10/surface_source_true.h5 index acaf39cb4..1512d8692 100644 Binary files a/tests/regression_tests/surface_source_write/case-10/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-10/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-11/inputs_true.dat b/tests/regression_tests/surface_source_write/case-11/inputs_true.dat index a4feff1b1..d5401dc87 100644 --- a/tests/regression_tests/surface_source_write/case-11/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-11/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-11/results_true.dat b/tests/regression_tests/surface_source_write/case-11/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-11/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-11/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-11/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-11/surface_source_true.h5 index 962f95fdd..0edb06c88 100644 Binary files a/tests/regression_tests/surface_source_write/case-11/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-11/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-12/inputs_true.dat b/tests/regression_tests/surface_source_write/case-12/inputs_true.dat index c069f425c..cb8f87741 100644 --- a/tests/regression_tests/surface_source_write/case-12/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-12/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-12/results_true.dat b/tests/regression_tests/surface_source_write/case-12/results_true.dat index ad927bdf3..d793a7e42 100644 --- a/tests/regression_tests/surface_source_write/case-12/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-12/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.929000E-02 8.212396E-03 +4.752377E-02 6.773395E-03 diff --git a/tests/regression_tests/surface_source_write/case-12/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-12/surface_source_true.h5 index 4b830d057..ea81a8250 100644 Binary files a/tests/regression_tests/surface_source_write/case-12/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-12/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-13/inputs_true.dat b/tests/regression_tests/surface_source_write/case-13/inputs_true.dat index 2a93fdb4d..23bbf0455 100644 --- a/tests/regression_tests/surface_source_write/case-13/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-13/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-13/results_true.dat b/tests/regression_tests/surface_source_write/case-13/results_true.dat index ad927bdf3..d793a7e42 100644 --- a/tests/regression_tests/surface_source_write/case-13/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-13/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.929000E-02 8.212396E-03 +4.752377E-02 6.773395E-03 diff --git a/tests/regression_tests/surface_source_write/case-13/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-13/surface_source_true.h5 index f53e2c3a2..08bd80985 100644 Binary files a/tests/regression_tests/surface_source_write/case-13/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-13/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-14/inputs_true.dat b/tests/regression_tests/surface_source_write/case-14/inputs_true.dat index 893f8ddc1..29acd94f2 100644 --- a/tests/regression_tests/surface_source_write/case-14/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-14/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-14/results_true.dat b/tests/regression_tests/surface_source_write/case-14/results_true.dat index ad927bdf3..d793a7e42 100644 --- a/tests/regression_tests/surface_source_write/case-14/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-14/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.929000E-02 8.212396E-03 +4.752377E-02 6.773395E-03 diff --git a/tests/regression_tests/surface_source_write/case-14/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-14/surface_source_true.h5 index ec049fec4..50cddcc70 100644 Binary files a/tests/regression_tests/surface_source_write/case-14/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-14/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-15/inputs_true.dat b/tests/regression_tests/surface_source_write/case-15/inputs_true.dat index 875a2fb0b..c775f2f52 100644 --- a/tests/regression_tests/surface_source_write/case-15/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-15/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-15/results_true.dat b/tests/regression_tests/surface_source_write/case-15/results_true.dat index ad927bdf3..d793a7e42 100644 --- a/tests/regression_tests/surface_source_write/case-15/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-15/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.929000E-02 8.212396E-03 +4.752377E-02 6.773395E-03 diff --git a/tests/regression_tests/surface_source_write/case-15/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-15/surface_source_true.h5 index fd5892096..3e15017a1 100644 Binary files a/tests/regression_tests/surface_source_write/case-15/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-15/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-16/inputs_true.dat b/tests/regression_tests/surface_source_write/case-16/inputs_true.dat index 347855e90..969a8f31e 100644 --- a/tests/regression_tests/surface_source_write/case-16/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-16/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-16/results_true.dat b/tests/regression_tests/surface_source_write/case-16/results_true.dat index cd0619c1f..a97be70ca 100644 --- a/tests/regression_tests/surface_source_write/case-16/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-16/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.403371E+00 1.456192E-02 +1.496403E+00 3.891283E-02 diff --git a/tests/regression_tests/surface_source_write/case-16/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-16/surface_source_true.h5 index 147ce0358..49f67e820 100644 Binary files a/tests/regression_tests/surface_source_write/case-16/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-16/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-17/inputs_true.dat b/tests/regression_tests/surface_source_write/case-17/inputs_true.dat index 95d0a6712..0a65db510 100644 --- a/tests/regression_tests/surface_source_write/case-17/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-17/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-17/results_true.dat b/tests/regression_tests/surface_source_write/case-17/results_true.dat index cd0619c1f..a97be70ca 100644 --- a/tests/regression_tests/surface_source_write/case-17/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-17/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.403371E+00 1.456192E-02 +1.496403E+00 3.891283E-02 diff --git a/tests/regression_tests/surface_source_write/case-17/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-17/surface_source_true.h5 index 436063aee..35878eeca 100644 Binary files a/tests/regression_tests/surface_source_write/case-17/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-17/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-18/inputs_true.dat b/tests/regression_tests/surface_source_write/case-18/inputs_true.dat index 807c72ae6..89df27b47 100644 --- a/tests/regression_tests/surface_source_write/case-18/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-18/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-18/results_true.dat b/tests/regression_tests/surface_source_write/case-18/results_true.dat index cd0619c1f..a97be70ca 100644 --- a/tests/regression_tests/surface_source_write/case-18/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-18/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.403371E+00 1.456192E-02 +1.496403E+00 3.891283E-02 diff --git a/tests/regression_tests/surface_source_write/case-18/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-18/surface_source_true.h5 index 436063aee..36da9e7a7 100644 Binary files a/tests/regression_tests/surface_source_write/case-18/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-18/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-19/inputs_true.dat b/tests/regression_tests/surface_source_write/case-19/inputs_true.dat index 42aa78a09..3ea7dbffe 100644 --- a/tests/regression_tests/surface_source_write/case-19/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-19/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-19/results_true.dat b/tests/regression_tests/surface_source_write/case-19/results_true.dat index cd0619c1f..a97be70ca 100644 --- a/tests/regression_tests/surface_source_write/case-19/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-19/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.403371E+00 1.456192E-02 +1.496403E+00 3.891283E-02 diff --git a/tests/regression_tests/surface_source_write/case-19/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-19/surface_source_true.h5 index eda3e030b..f4261451d 100644 Binary files a/tests/regression_tests/surface_source_write/case-19/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-19/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-20/inputs_true.dat b/tests/regression_tests/surface_source_write/case-20/inputs_true.dat index 4c7a3f11d..c3c768a3d 100644 --- a/tests/regression_tests/surface_source_write/case-20/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-20/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-20/results_true.dat b/tests/regression_tests/surface_source_write/case-20/results_true.dat index 44293cf09..7ccce7cc3 100644 --- a/tests/regression_tests/surface_source_write/case-20/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-20/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.266853E+00 4.552028E-02 +1.149925E+00 2.542255E-01 diff --git a/tests/regression_tests/surface_source_write/case-20/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-20/surface_source_true.h5 index 083ce90c8..fa8a4e628 100644 Binary files a/tests/regression_tests/surface_source_write/case-20/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-20/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-21/inputs_true.dat b/tests/regression_tests/surface_source_write/case-21/inputs_true.dat index 71f9aae6a..5dae8374d 100644 --- a/tests/regression_tests/surface_source_write/case-21/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-21/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-21/results_true.dat b/tests/regression_tests/surface_source_write/case-21/results_true.dat index 44293cf09..7ccce7cc3 100644 --- a/tests/regression_tests/surface_source_write/case-21/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-21/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.266853E+00 4.552028E-02 +1.149925E+00 2.542255E-01 diff --git a/tests/regression_tests/surface_source_write/case-21/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-21/surface_source_true.h5 index f7e886db4..ed87ce849 100644 Binary files a/tests/regression_tests/surface_source_write/case-21/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-21/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-a01/inputs_true.dat b/tests/regression_tests/surface_source_write/case-a01/inputs_true.dat index e9840be87..5cec1b76f 100644 --- a/tests/regression_tests/surface_source_write/case-a01/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-a01/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-a01/results_true.dat b/tests/regression_tests/surface_source_write/case-a01/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-a01/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-a01/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-a01/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-a01/surface_source_true.h5 index 807211e3a..4a8623567 100644 Binary files a/tests/regression_tests/surface_source_write/case-a01/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-a01/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d01/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d01/inputs_true.dat index 04703acfe..b5452080c 100644 --- a/tests/regression_tests/surface_source_write/case-d01/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d01/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d01/results_true.dat b/tests/regression_tests/surface_source_write/case-d01/results_true.dat index 26b9e30a3..7fb415cb1 100644 --- a/tests/regression_tests/surface_source_write/case-d01/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d01/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.288719E-01 6.877101E-03 +9.263843E-01 3.193920E-02 diff --git a/tests/regression_tests/surface_source_write/case-d01/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d01/surface_source_true.h5 index 9a66315ff..8f8cd604d 100644 Binary files a/tests/regression_tests/surface_source_write/case-d01/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d01/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d02/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d02/inputs_true.dat index d8b4e6803..d6ca4143c 100644 --- a/tests/regression_tests/surface_source_write/case-d02/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d02/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d02/results_true.dat b/tests/regression_tests/surface_source_write/case-d02/results_true.dat index 26b9e30a3..7fb415cb1 100644 --- a/tests/regression_tests/surface_source_write/case-d02/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d02/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.288719E-01 6.877101E-03 +9.263843E-01 3.193920E-02 diff --git a/tests/regression_tests/surface_source_write/case-d02/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d02/surface_source_true.h5 index 291062942..3abc471e0 100644 Binary files a/tests/regression_tests/surface_source_write/case-d02/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d02/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d03/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d03/inputs_true.dat index d769184aa..ba326c978 100644 --- a/tests/regression_tests/surface_source_write/case-d03/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d03/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d03/results_true.dat b/tests/regression_tests/surface_source_write/case-d03/results_true.dat index 26b9e30a3..7fb415cb1 100644 --- a/tests/regression_tests/surface_source_write/case-d03/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d03/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.288719E-01 6.877101E-03 +9.263843E-01 3.193920E-02 diff --git a/tests/regression_tests/surface_source_write/case-d03/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d03/surface_source_true.h5 index 0af7160d4..8435e8f17 100644 Binary files a/tests/regression_tests/surface_source_write/case-d03/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d03/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d04/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d04/inputs_true.dat index abefc2692..c309dd155 100644 --- a/tests/regression_tests/surface_source_write/case-d04/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d04/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d04/results_true.dat b/tests/regression_tests/surface_source_write/case-d04/results_true.dat index 26b9e30a3..7fb415cb1 100644 --- a/tests/regression_tests/surface_source_write/case-d04/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d04/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.288719E-01 6.877101E-03 +9.263843E-01 3.193920E-02 diff --git a/tests/regression_tests/surface_source_write/case-d04/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d04/surface_source_true.h5 index 90ab00748..6c45d92e6 100644 Binary files a/tests/regression_tests/surface_source_write/case-d04/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d04/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d05/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d05/inputs_true.dat index 8b46b2b4e..c49703f83 100644 --- a/tests/regression_tests/surface_source_write/case-d05/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d05/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d05/results_true.dat b/tests/regression_tests/surface_source_write/case-d05/results_true.dat index 26b9e30a3..7fb415cb1 100644 --- a/tests/regression_tests/surface_source_write/case-d05/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d05/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.288719E-01 6.877101E-03 +9.263843E-01 3.193920E-02 diff --git a/tests/regression_tests/surface_source_write/case-d05/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d05/surface_source_true.h5 index 2f5521679..24b04a862 100644 Binary files a/tests/regression_tests/surface_source_write/case-d05/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d05/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d06/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d06/inputs_true.dat index ca52cf455..48db2c30d 100644 --- a/tests/regression_tests/surface_source_write/case-d06/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d06/inputs_true.dat @@ -1,26 +1,26 @@ - - - + + + - - - + + + - + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d06/results_true.dat b/tests/regression_tests/surface_source_write/case-d06/results_true.dat index 26b9e30a3..7fb415cb1 100644 --- a/tests/regression_tests/surface_source_write/case-d06/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d06/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.288719E-01 6.877101E-03 +9.263843E-01 3.193920E-02 diff --git a/tests/regression_tests/surface_source_write/case-d06/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d06/surface_source_true.h5 index 27227ad49..3eb95bef9 100644 Binary files a/tests/regression_tests/surface_source_write/case-d06/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d06/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d07/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d07/inputs_true.dat index 40c439fe6..e2897125b 100644 --- a/tests/regression_tests/surface_source_write/case-d07/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d07/inputs_true.dat @@ -1,40 +1,40 @@ - - - + + + - - - + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d07/results_true.dat b/tests/regression_tests/surface_source_write/case-d07/results_true.dat index 5a4ea6689..63ea1a64d 100644 --- a/tests/regression_tests/surface_source_write/case-d07/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d07/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.947197E-01 3.711779E-02 +9.756086E-01 4.639209E-02 diff --git a/tests/regression_tests/surface_source_write/case-d07/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d07/surface_source_true.h5 index fd9f0dc57..0332f2dcf 100644 Binary files a/tests/regression_tests/surface_source_write/case-d07/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d07/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-d08/inputs_true.dat b/tests/regression_tests/surface_source_write/case-d08/inputs_true.dat index c81d21b97..185b8629b 100644 --- a/tests/regression_tests/surface_source_write/case-d08/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-d08/inputs_true.dat @@ -1,40 +1,40 @@ - - - + + + - - - + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + eigenvalue 100 5 1 - + -4 -4 -20 4 4 20 diff --git a/tests/regression_tests/surface_source_write/case-d08/results_true.dat b/tests/regression_tests/surface_source_write/case-d08/results_true.dat index 5a4ea6689..63ea1a64d 100644 --- a/tests/regression_tests/surface_source_write/case-d08/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-d08/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.947197E-01 3.711779E-02 +9.756086E-01 4.639209E-02 diff --git a/tests/regression_tests/surface_source_write/case-d08/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-d08/surface_source_true.h5 index fd9f0dc57..252559204 100644 Binary files a/tests/regression_tests/surface_source_write/case-d08/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-d08/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-e01/inputs_true.dat b/tests/regression_tests/surface_source_write/case-e01/inputs_true.dat index 46701aea7..ac3c03e37 100644 --- a/tests/regression_tests/surface_source_write/case-e01/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-e01/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-e01/results_true.dat b/tests/regression_tests/surface_source_write/case-e01/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-e01/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-e01/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-e01/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-e01/surface_source_true.h5 index bbfbd152b..3047519e8 100644 Binary files a/tests/regression_tests/surface_source_write/case-e01/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-e01/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-e02/inputs_true.dat b/tests/regression_tests/surface_source_write/case-e02/inputs_true.dat index a4588c8d0..a6107d16f 100644 --- a/tests/regression_tests/surface_source_write/case-e02/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-e02/inputs_true.dat @@ -1,47 +1,47 @@ - - - - - - - + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-e02/results_true.dat b/tests/regression_tests/surface_source_write/case-e02/results_true.dat index d4d1d1e5a..8979eb554 100644 --- a/tests/regression_tests/surface_source_write/case-e02/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-e02/results_true.dat @@ -1,2 +1,2 @@ k-combined: -5.642735E-02 1.494035E-02 +5.169123E-02 9.144814E-03 diff --git a/tests/regression_tests/surface_source_write/case-e02/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-e02/surface_source_true.h5 index bbfbd152b..806152853 100644 Binary files a/tests/regression_tests/surface_source_write/case-e02/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-e02/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/case-e03/inputs_true.dat b/tests/regression_tests/surface_source_write/case-e03/inputs_true.dat index 2a93fdb4d..23bbf0455 100644 --- a/tests/regression_tests/surface_source_write/case-e03/inputs_true.dat +++ b/tests/regression_tests/surface_source_write/case-e03/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + eigenvalue 100 5 1 - + -2.0 -2.0 -2.0 2.0 2.0 2.0 diff --git a/tests/regression_tests/surface_source_write/case-e03/results_true.dat b/tests/regression_tests/surface_source_write/case-e03/results_true.dat index ad927bdf3..d793a7e42 100644 --- a/tests/regression_tests/surface_source_write/case-e03/results_true.dat +++ b/tests/regression_tests/surface_source_write/case-e03/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.929000E-02 8.212396E-03 +4.752377E-02 6.773395E-03 diff --git a/tests/regression_tests/surface_source_write/case-e03/surface_source_true.h5 b/tests/regression_tests/surface_source_write/case-e03/surface_source_true.h5 index 22e108745..becc9254a 100644 Binary files a/tests/regression_tests/surface_source_write/case-e03/surface_source_true.h5 and b/tests/regression_tests/surface_source_write/case-e03/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source_write/test.py b/tests/regression_tests/surface_source_write/test.py index 094df1f8b..38581736e 100644 --- a/tests/regression_tests/surface_source_write/test.py +++ b/tests/regression_tests/surface_source_write/test.py @@ -608,6 +608,11 @@ def return_surface_source_data(filepath): """Read a surface source file and return a sorted array composed of flatten arrays of source data for each surface source point. + TODO: + + - use read_source_file from source.py instead. Or a dedicated function + to produce sorted list of source points for a given file. + Parameters ---------- filepath : str @@ -624,25 +629,27 @@ def return_surface_source_data(filepath): keys = [] # Read source file - source = openmc.read_source_file(filepath) + with h5py.File(filepath, "r") as f: + for point in f["source_bank"]: + r = point["r"] + u = point["u"] + e = point["E"] + time = point["time"] + wgt = point["wgt"] + delayed_group = point["delayed_group"] + surf_id = point["surf_id"] + particle = point["particle"] - for point in source: - r = point.r - u = point.u - e = point.E - time = point.time - wgt = point.wgt - delayed_group = point.delayed_group - surf_id = point.surf_id - particle = point.particle.pdg_number - key = ( - f"{r[0]:.10e} {r[1]:.10e} {r[2]:.10e} {u[0]:.10e} {u[1]:.10e} {u[2]:.10e}" - f"{e:.10e} {time:.10e} {wgt:.10e} {delayed_group} {surf_id} {particle}" - ) - keys.append(key) - values = [*r, *u, e, time, wgt, delayed_group, surf_id, particle] - assert len(values) == 12 - data.append(values) + key = ( + f"{r[0]:.10e} {r[1]:.10e} {r[2]:.10e} {u[0]:.10e} {u[1]:.10e} {u[2]:.10e}" + f"{e:.10e} {time:.10e} {wgt:.10e} {delayed_group} {surf_id} {particle}" + ) + + keys.append(key) + + values = [*r, *u, e, time, wgt, delayed_group, surf_id, particle] + assert len(values) == 12 + data.append(values) data = np.array(data) keys = np.array(keys) diff --git a/tests/regression_tests/surface_tally/inputs_true.dat b/tests/regression_tests/surface_tally/inputs_true.dat index 2b070c5a3..192c2e89f 100644 --- a/tests/regression_tests/surface_tally/inputs_true.dat +++ b/tests/regression_tests/surface_tally/inputs_true.dat @@ -1,35 +1,35 @@ - - - - - + + + + + - - - - + + + + - - - - - - - - + + + + + + + + eigenvalue 1000 10 0 - + -0.62992 -0.62992 -1 0.62992 0.62992 1 diff --git a/tests/regression_tests/surface_tally/results_true.dat b/tests/regression_tests/surface_tally/results_true.dat index e50102a88..8b27fa192 100644 --- a/tests/regression_tests/surface_tally/results_true.dat +++ b/tests/regression_tests/surface_tally/results_true.dat @@ -1,52 +1,52 @@ mean,std. dev. -2.4100000e-02,2.1052844e-03 -6.7900000e-02,2.3211587e-03 -1.6860000e-01,4.4800794e-03 -6.4710000e-01,9.1826527e-03 -2.2000000e-03,3.8873013e-04 -5.5000000e-03,1.0979779e-03 -1.2500000e-02,1.5438048e-03 -4.4700000e-02,1.9035055e-03 -2.4100000e-02,2.1052844e-03 -6.7900000e-02,2.3211587e-03 -1.6860000e-01,4.4800794e-03 -6.4710000e-01,9.1826527e-03 -2.2000000e-03,3.8873013e-04 -5.5000000e-03,1.0979779e-03 -1.2500000e-02,1.5438048e-03 -4.4700000e-02,1.9035055e-03 --7.3000000e-03,9.8938814e-04 --3.6600000e-02,2.5086517e-03 --4.1600000e-02,2.4864075e-03 --4.2380000e-01,9.6087923e-03 --1.0000000e-04,1.0000000e-04 --1.5000000e-03,4.5338235e-04 --3.0000000e-04,1.5275252e-04 --1.7300000e-02,1.4609738e-03 --7.3000000e-03,9.8938814e-04 --3.6600000e-02,2.5086517e-03 --4.1600000e-02,2.4864075e-03 --4.2380000e-01,9.6087923e-03 --1.0000000e-04,1.0000000e-04 --1.5000000e-03,4.5338235e-04 --3.0000000e-04,1.5275252e-04 --1.7300000e-02,1.4609738e-03 -1.6800000e-02,1.5902481e-03 -3.1300000e-02,3.8094911e-03 -1.2700000e-01,5.0990195e-03 -2.2330000e-01,9.3631073e-03 +2.1200000e-02,1.8366636e-03 +7.4900000e-02,2.2083176e-03 +1.6220000e-01,2.8079253e-03 +6.4010000e-01,8.6838931e-03 2.1000000e-03,3.7859389e-04 -4.0000000e-03,1.0540926e-03 -1.2200000e-02,1.6110728e-03 -2.7400000e-02,1.6613248e-03 +5.6000000e-03,6.8637534e-04 +1.1700000e-02,1.4456832e-03 +4.1700000e-02,2.7041121e-03 +2.1200000e-02,1.8366636e-03 +7.4900000e-02,2.2083176e-03 +1.6220000e-01,2.8079253e-03 +6.4010000e-01,8.6838931e-03 +2.1000000e-03,3.7859389e-04 +5.6000000e-03,6.8637534e-04 +1.1700000e-02,1.4456832e-03 +4.1700000e-02,2.7041121e-03 +5.2000000e-03,5.9254629e-04 +3.9200000e-02,2.5508169e-03 +4.0200000e-02,1.9310331e-03 +4.1360000e-01,8.0072190e-03 0.0000000e+00,0.0000000e+00 --3.2000000e-02,1.5634719e-03 +1.9000000e-03,3.7859389e-04 +1.0000000e-04,1.0000000e-04 +1.6400000e-02,1.2840907e-03 +-5.2000000e-03,5.9254629e-04 +-3.9200000e-02,2.5508169e-03 +-4.0200000e-02,1.9310331e-03 +-4.1360000e-01,8.0072190e-03 0.0000000e+00,0.0000000e+00 --3.5400000e-01,7.5938572e-03 +-1.9000000e-03,3.7859389e-04 +-1.0000000e-04,1.0000000e-04 +-1.6400000e-02,1.2840907e-03 +1.6000000e-02,2.1602469e-03 +3.5700000e-02,2.9441090e-03 +1.2200000e-01,3.5932035e-03 +2.2650000e-01,9.2463206e-03 +2.1000000e-03,3.7859389e-04 +3.7000000e-03,8.1717671e-04 +1.1600000e-02,1.4772347e-03 +2.5300000e-02,1.9723083e-03 0.0000000e+00,0.0000000e+00 --3.0000000e-03,6.4978629e-04 +-2.9700000e-02,2.4587711e-03 0.0000000e+00,0.0000000e+00 --2.1800000e-02,1.4892205e-03 +-3.5090000e-01,3.7161808e-03 +0.0000000e+00,0.0000000e+00 +-2.1000000e-03,4.8189441e-04 +0.0000000e+00,0.0000000e+00 +-2.1400000e-02,1.7397318e-03 0.0000000e+00,0.0000000e+00 0.0000000e+00,0.0000000e+00 0.0000000e+00,0.0000000e+00 diff --git a/tests/regression_tests/surface_tally/test.py b/tests/regression_tests/surface_tally/test.py index aa03a8aa2..e496ac0f6 100644 --- a/tests/regression_tests/surface_tally/test.py +++ b/tests/regression_tests/surface_tally/test.py @@ -169,6 +169,7 @@ class SurfaceTallyTestHarness(PyAPITestHarness): # Extract the relevant data as a CSV string. cols = ('mean', 'std. dev.') return df.to_csv(None, columns=cols, index=False, float_format='%.7e') + return outstr def test_surface_tally(): diff --git a/tests/regression_tests/survival_biasing/results_true.dat b/tests/regression_tests/survival_biasing/results_true.dat index 932414e98..740272201 100644 --- a/tests/regression_tests/survival_biasing/results_true.dat +++ b/tests/regression_tests/survival_biasing/results_true.dat @@ -1,20 +1,20 @@ k-combined: -9.517646E-01 1.303111E-02 +9.879232E-01 8.097582E-03 tally 1: -4.164635E+01 -3.470110E+02 -1.724300E+01 -5.949580E+01 -2.124917E+00 -9.034789E-01 -1.844790E+00 -6.809026E-01 -4.784396E+00 -4.579552E+00 -3.348849E-02 -2.243613E-04 -3.573090E+08 -2.554338E+16 +4.295331E+01 +3.691096E+02 +1.802724E+01 +6.501934E+01 +2.193500E+00 +9.627609E-01 +1.893529E+00 +7.174104E-01 +4.902380E+00 +4.808570E+00 +3.418014E-02 +2.337353E-04 +3.667128E+08 +2.690758E+16 tally 2: -1.724300E+01 -5.949580E+01 +1.802724E+01 +6.501934E+01 diff --git a/tests/regression_tests/tallies/inputs_true.dat b/tests/regression_tests/tallies/inputs_true.dat index 40829f865..2ce36c5df 100644 --- a/tests/regression_tests/tallies/inputs_true.dat +++ b/tests/regression_tests/tallies/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + - + @@ -47,7 +47,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -149,8 +149,8 @@ - - + + @@ -174,9 +174,9 @@ - + - + 1.26 1.26 17 17 @@ -277,30 +277,30 @@ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + eigenvalue 400 5 0 - + -160 -160 -183 160 160 183 @@ -342,7 +342,7 @@ 4 - + 4 diff --git a/tests/regression_tests/tallies/results_true.dat b/tests/regression_tests/tallies/results_true.dat index 1d3aca4b0..3dda0f9b2 100644 --- a/tests/regression_tests/tallies/results_true.dat +++ b/tests/regression_tests/tallies/results_true.dat @@ -1 +1 @@ -d01c3accd5b4de2aa166a77df28cfe42f5738a44c2480752fcfae7564a507362fff006b6dffb7b1dfe248e14bacef0070cabacea5d75c5996653e5605f7c7384 \ No newline at end of file +ddfbb0a6f5498eb8ff33bb10beb64e244b015861919eb4837bd82855e5fd87c3ff97dfa382d3d60afa81c48d9f857fba8e0b99263e7b35587f8adb75be1fc0ec \ No newline at end of file diff --git a/tests/regression_tests/tally_aggregation/inputs_true.dat b/tests/regression_tests/tally_aggregation/inputs_true.dat index 7351b230c..9f4f95655 100644 --- a/tests/regression_tests/tally_aggregation/inputs_true.dat +++ b/tests/regression_tests/tally_aggregation/inputs_true.dat @@ -1,24 +1,24 @@ - - - - - - + + + + + + - - - + + + - + 1.2 1.2 1 @@ -28,11 +28,11 @@ 1 1 1 1 - - - - - + + + + + eigenvalue diff --git a/tests/regression_tests/tally_aggregation/results_true.dat b/tests/regression_tests/tally_aggregation/results_true.dat index ee6263373..172adbfe1 100644 --- a/tests/regression_tests/tally_aggregation/results_true.dat +++ b/tests/regression_tests/tally_aggregation/results_true.dat @@ -1,97 +1,97 @@ -[[1.6242805e-05 6.2367673e-04] - [3.2895972e-01 1.7786452e-01] - [1.8044266e-02 7.0451122e-01]], [[1.6113947e-05 5.3572864e-04] - [3.1517504e-01 1.7132833e-01] - [1.8305682e-02 7.0072832e-01]], [[1.6472052e-05 5.5758006e-04] - [3.2362364e-01 1.7597163e-01] - [1.9107080e-02 7.2600440e-01]], [[1.6693277e-05 4.9204218e-04] - [3.2429262e-01 1.7600573e-01] - [1.9042489e-02 7.3053854e-01]][[2.9719061e-07 8.0925438e-05] - [8.9432259e-03 4.4057583e-03] - [5.2078407e-04 6.4387688e-03]], [[1.8572081e-07 2.5667235e-05] - [1.1641603e-02 5.7444311e-03] - [2.6983611e-04 6.9783224e-03]], [[2.4994113e-07 5.4993390e-05] - [6.0464041e-03 3.0764811e-03] - [2.6559118e-04 7.7279780e-03]], [[2.5965232e-07 3.9618775e-05] - [1.0409564e-02 5.1850104e-03] - [2.7831231e-04 7.4480576e-03]][[1.0329435e-06 8.0861229e-04] - [1.1265142e+00 5.5796079e-01] - [1.3965860e-06 5.0338828e-01]], [[2.2264172e-06 1.0828687e-03] - [1.4724979e-01 1.0226107e-01] - [2.2656045e-05 7.7618945e-01]], [[1.4789782e-05 2.2786630e-04] - [1.3149968e-02 2.9847169e-02] - [3.2638111e-04 1.1287326e+00]], [[4.7472938e-05 8.9680338e-05] - [5.1371041e-03 1.1101179e-02] - [7.4149084e-02 4.5347217e-01]][[1.7024771e-08 1.2878244e-05] - [1.8795566e-02 9.2705008e-03] - [2.2676749e-08 7.0878353e-03]], [[2.2018925e-07 1.0785388e-04] - [2.6715019e-03 1.6657928e-03] - [1.2479083e-05 8.6814018e-03]], [[2.0928485e-07 1.6600875e-06] - [1.1859535e-04 1.7969083e-04] - [1.5981387e-05 8.0489308e-03]], [[4.0016381e-07 7.6799157e-07] - [4.4157583e-05 9.4462925e-05] - [7.0115110e-04 3.8678806e-03]][[0.287433 0.2698042]], [[0.2751228 0.2598525]], [[0.280516 0.2648274]], [[0.2834448 0.2676736]], [[0.0370558 0.2148509]], [[0.0355217 0.2130189]], [[0.0385317 0.2292804]], [[0.0361655 0.2223832]], [[0.0033268 0.2855078]], [[0.0033498 0.2849403]], [[0.003359 0.2901157]], [[0.0034555 0.2982438]], [[0.0192046 0.1128364]], [[0.0195026 0.1147807]], [[0.0203405 0.1183102]], [[0.0202861 0.1187358]][[0.00889 0.0051934]], [[0.0115249 0.0072767]], [[0.0058841 0.0040289]], [[0.0103341 0.0063266]], [[0.0009734 0.0048865]], [[0.0016425 0.0038133]], [[0.0013902 0.0048875]], [[0.0012487 0.0039808]], [[1.8994140e-05 2.0410145e-03]], [[6.8277082e-05 3.4865782e-03]], [[6.1643568e-05 4.9220817e-03]], [[7.4147413e-05 4.9263295e-03]], [[0.0005213 0.0024208]], [[0.0002702 0.0014313]], [[0.0002665 0.0022006]], [[0.0002788 0.0014892]][[2.0601081e-04] - [4.2976789e-01] - [1.2726338e-01]], [[1.9802070e-04] - [4.1138025e-01] - [1.2339705e-01]], [[2.0174854e-04] - [4.1947542e-01] - [1.2566615e-01]], [[2.0386518e-04] - [4.2385140e-01] - [1.2706310e-01]], [[0.0003403] - [0.0624955] - [0.189071 ]], [[0.0002601] - [0.060449 ] - [0.1878314]], [[0.0002765] - [0.0652412] - [0.2022944]], [[0.0002082] - [0.0613252] - [0.1970153]], [[6.0336874e-05] - [1.0617692e-02] - [2.7815664e-01]], [[5.9823997e-05] - [1.0664059e-02] - [2.7756620e-01]], [[6.0873689e-05] - [1.0744209e-02] - [2.8266963e-01]], [[6.1621521e-05] - [1.0971177e-02] - [2.9066650e-01]], [[3.3297391e-05] - [3.9432037e-03] - [1.2806450e-01]], [[3.3863464e-05] - [4.0100180e-03] - [1.3023932e-01]], [[3.4930617e-05] - [4.1344613e-03] - [1.3448129e-01]], [[3.5061805e-05] - [4.1505999e-03] - [1.3483614e-01]][[5.8259835e-06] - [9.9096571e-03] - [2.7933778e-03]], [[8.0858909e-06] - [1.2843377e-02] - [4.5631248e-03]], [[4.3418585e-06] - [6.5638646e-03] - [2.7874612e-03]], [[6.9046376e-06] - [1.1531588e-02] - [3.7205377e-03]], [[8.0710599e-05] - [1.0889301e-03] - [4.8613465e-03]], [[2.4337121e-05] - [1.8861117e-03] - [3.6987509e-03]], [[5.4812439e-05] - [1.7085353e-03] - [4.7852139e-03]], [[3.9007791e-05] - [1.4998363e-03] - [3.8929646e-03]], [[7.5757577e-07] - [2.5845755e-05] - [2.0409391e-03]], [[1.0302346e-06] - [1.1907557e-04] - [3.4852130e-03]], [[9.1936614e-07] - [1.2974020e-04] - [4.9207575e-03]], [[5.6493555e-07] - [1.2113685e-04] - [4.9253980e-03]], [[5.4602210e-07] - [6.5233025e-05] - [2.4754550e-03]], [[3.2091909e-07] - [3.8472906e-05] - [1.4560974e-03]], [[4.8475651e-07] - [5.9108262e-05] - [2.2158781e-03]], [[3.3737822e-07] - [4.0544269e-05] - [1.5145628e-03]] \ No newline at end of file +[[1.6001087e-05 5.4190949e-04] + [3.2669968e-01 1.7730523e-01] + [1.8149266e-02 7.1525113e-01]], [[1.6239097e-05 5.7499676e-04] + [3.1268633e-01 1.7004165e-01] + [1.8873778e-02 7.0217885e-01]], [[1.6693071e-05 5.4106379e-04] + [3.3370208e-01 1.8051505e-01] + [1.9081306e-02 7.3647547e-01]], [[1.6725399e-05 5.1680146e-04] + [3.2854628e-01 1.7757185e-01] + [1.9529646e-02 7.1005198e-01]][[2.4751834e-07 4.3304565e-05] + [8.6840718e-03 4.3442535e-03] + [3.7054051e-04 6.5678133e-03]], [[4.0830852e-07 4.9612204e-05] + [1.2104241e-02 5.9708675e-03] + [7.1398189e-04 8.2408482e-03]], [[2.6546344e-07 2.5234256e-05] + [6.5083211e-03 3.2185071e-03] + [4.2935150e-04 5.1707774e-03]], [[2.7845203e-07 3.4453402e-05] + [3.3125427e-03 1.7749508e-03] + [6.0407731e-04 7.5353872e-03]][[1.0455251e-06 8.1938339e-04] + [1.1392765e+00 5.6434761e-01] + [1.4142831e-06 5.1213654e-01]], [[2.2009815e-06 1.0418935e-03] + [1.4422554e-01 1.0070647e-01] + [3.9488382e-05 7.9236390e-01]], [[1.4606612e-05 2.2374470e-04] + [1.2962842e-02 2.9268594e-02] + [3.1339824e-04 1.1056439e+00]], [[4.7805535e-05 8.9749934e-05] + [5.1694597e-03 1.1111105e-02] + [7.5279695e-02 4.5381305e-01]][[1.4955183e-08 1.1461548e-05] + [1.6454649e-02 8.1236707e-03] + [2.0028007e-08 6.8264819e-03]], [[1.6334486e-07 7.7617340e-05] + [2.1161584e-03 1.4078445e-03] + [1.4742097e-05 6.9350862e-03]], [[1.7444757e-07 1.9026095e-06] + [1.4084092e-04 2.0345990e-04] + [5.9546175e-06 8.6038812e-03]], [[5.6449127e-07 1.0110585e-06] + [5.9158873e-05 1.2485325e-04] + [1.0936497e-03 5.0836702e-03]][[0.2866239 0.2725595]], [[0.2729156 0.258831 ]], [[0.2920724 0.2755922]], [[0.287667 0.2703207]], [[0.035617 0.2232707]], [[0.0353082 0.2224423]], [[0.0370072 0.2288263]], [[0.0363348 0.219573 ]], [[0.0033013 0.2850034]], [[0.0032726 0.2771099]], [[0.0034234 0.2951295]], [[0.0032935 0.2778935]], [[0.0193227 0.1122647]], [[0.0200799 0.1144123]], [[0.0202971 0.1179836]], [[0.0207973 0.1203534]][[0.0086351 0.0061876]], [[0.0120688 0.0074831]], [[0.0064221 0.0035246]], [[0.0030483 0.0024267]], [[0.0009185 0.0033896]], [[0.0009223 0.0039584]], [[0.0010541 0.0038599]], [[0.0012934 0.0028331]], [[6.5126963e-05 2.8486593e-03]], [[7.1110242e-05 4.3424340e-03]], [[5.8911409e-05 2.4296178e-03]], [[8.4278765e-05 6.4182190e-03]], [[0.0003712 0.0020298]], [[0.0007152 0.0036115]], [[0.0004298 0.0019677]], [[0.0006046 0.0021965]][[2.0694650e-04] + [4.2868191e-01] + [1.3029457e-01]], [[1.9694048e-04] + [4.0809445e-01] + [1.2345525e-01]], [[2.1012645e-04] + [4.3670571e-01] + [1.3074883e-01]], [[2.0641548e-04] + [4.3014207e-01] + [1.2763930e-01]], [[0.0002584] + [0.0608867] + [0.1977426]], [[0.0003026] + [0.0602368] + [0.1972111]], [[0.0002509] + [0.0624699] + [0.2031126]], [[0.0002322] + [0.0613385] + [0.1943371]], [[5.9349736e-05] + [1.0506741e-02] + [2.7773865e-01]], [[5.7855564e-05] + [1.0389781e-02] + [2.6993483e-01]], [[6.1819700e-05] + [1.0910874e-02] + [2.8758020e-01]], [[5.9326317e-05] + [1.0424040e-02] + [2.7070367e-01]], [[3.3192167e-05] + [3.9295320e-03] + [1.2762462e-01]], [[3.3882691e-05] + [4.0069157e-03] + [1.3045143e-01]], [[3.4882103e-05] + [4.1306182e-03] + [1.3411514e-01]], [[3.5598508e-05] + [4.2134987e-03] + [1.3690156e-01]][[6.4505980e-06] + [9.6369034e-03] + [4.4700460e-03]], [[8.2880772e-06] + [1.3456171e-02] + [4.5368708e-03]], [[3.9384462e-06] + [7.1570638e-03] + [1.5629142e-03]], [[2.3565894e-06] + [3.4040401e-03] + [1.8956916e-03]], [[4.2806047e-05] + [1.1841015e-03] + [3.3058802e-03]], [[4.8905696e-05] + [1.0360139e-03] + [3.9298937e-03]], [[2.4911390e-05] + [1.2173305e-03] + [3.8114473e-03]], [[3.4347869e-05] + [1.5820360e-03] + [2.6824612e-03]], [[1.0809230e-06] + [1.0316180e-04] + [2.8475354e-03]], [[6.4150814e-07] + [1.1179425e-04] + [4.3415770e-03]], [[7.3848139e-07] + [9.3111666e-05] + [2.4285475e-03]], [[1.2349384e-06] + [1.7152843e-04] + [6.4164799e-03]], [[4.5871493e-07] + [5.4732075e-05] + [2.0627309e-03]], [[8.1649994e-07] + [9.7699188e-05] + [3.6803256e-03]], [[4.5174850e-07] + [5.3913784e-05] + [2.0133571e-03]], [[5.0962865e-07] + [6.0338032e-05] + [2.2773911e-03]] \ No newline at end of file diff --git a/tests/regression_tests/tally_arithmetic/inputs_true.dat b/tests/regression_tests/tally_arithmetic/inputs_true.dat index 2b5234c34..7669b4d03 100644 --- a/tests/regression_tests/tally_arithmetic/inputs_true.dat +++ b/tests/regression_tests/tally_arithmetic/inputs_true.dat @@ -1,24 +1,24 @@ - - - - - + + + + + - - - + + + - - + + eigenvalue diff --git a/tests/regression_tests/tally_arithmetic/results_true.dat b/tests/regression_tests/tally_arithmetic/results_true.dat index baa380587..143930dd4 100644 --- a/tests/regression_tests/tally_arithmetic/results_true.dat +++ b/tests/regression_tests/tally_arithmetic/results_true.dat @@ -1,49 +1,49 @@ -[2.29467e-07 1.47622e-13 2.02646e-04 1.30367e-10 2.20704e-07 1.76624e-07 - 1.94907e-04 1.55980e-04 6.32267e-03 4.06754e-09 3.26873e-03 2.10286e-09 - 6.08121e-03 4.86666e-03 3.14390e-03 2.51599e-03 1.89223e-07 1.06256e-13 - 1.67106e-04 9.38364e-11 1.53300e-07 1.20220e-07 1.35382e-04 1.06168e-04 - 5.21380e-03 2.92775e-09 2.69546e-03 1.51361e-09 4.22399e-03 3.31252e-03 - 2.18374e-03 1.71253e-03 2.21146e-07 1.41349e-13 1.95297e-04 1.24828e-10 - 2.11844e-07 1.69398e-07 1.87083e-04 1.49598e-04 6.09339e-03 3.89470e-09 - 3.15020e-03 2.01351e-09 5.83710e-03 4.66754e-03 3.01770e-03 2.41305e-03 - 1.92872e-07 1.05908e-13 1.70328e-04 9.35293e-11 1.59466e-07 1.25399e-07 - 1.40827e-04 1.10741e-04 5.31433e-03 2.91817e-09 2.74744e-03 1.50865e-09 - 4.39388e-03 3.45520e-03 2.27158e-03 1.78629e-03 2.44601e-03 4.71663e-05 - 1.09430e-02 2.11013e-04 1.23573e-04 2.76181e-05 5.52841e-04 1.23558e-04 - 2.71755e-02 5.24023e-04 4.76200e-02 9.18253e-04 1.37291e-03 3.06841e-04 - 2.40577e-03 5.37681e-04 2.29014e-03 4.44674e-05 1.02456e-02 1.98938e-04 - 1.12524e-04 2.48126e-05 5.03411e-04 1.11007e-04 2.54438e-02 4.94038e-04 - 4.45855e-02 8.65710e-04 1.25016e-03 2.75671e-04 2.19067e-03 4.83061e-04 - 2.38500e-03 4.58053e-05 1.06700e-02 2.04924e-04 1.22899e-04 2.95267e-05 - 5.49826e-04 1.32097e-04 2.64977e-02 5.08903e-04 4.64323e-02 8.91758e-04 - 1.36542e-03 3.28045e-04 2.39265e-03 5.74839e-04 2.17094e-03 4.21772e-05 - 9.71236e-03 1.88693e-04 1.09358e-04 2.46984e-05 4.89245e-04 1.10496e-04 - 2.41194e-02 4.68594e-04 4.22648e-02 8.21124e-04 1.21498e-03 2.74402e-04 - 2.12902e-03 4.80839e-04][2.29467e-07 1.47622e-13 2.02646e-04 1.30367e-10 2.20704e-07 1.76624e-07 - 1.94907e-04 1.55980e-04 6.32267e-03 4.06754e-09 3.26873e-03 2.10286e-09 - 6.08121e-03 4.86666e-03 3.14390e-03 2.51599e-03 1.89223e-07 1.06256e-13 - 1.67106e-04 9.38364e-11 1.53300e-07 1.20220e-07 1.35382e-04 1.06168e-04 - 5.21380e-03 2.92775e-09 2.69546e-03 1.51361e-09 4.22399e-03 3.31252e-03 - 2.18374e-03 1.71253e-03 2.21146e-07 1.41349e-13 1.95297e-04 1.24828e-10 - 2.11844e-07 1.69398e-07 1.87083e-04 1.49598e-04 6.09339e-03 3.89470e-09 - 3.15020e-03 2.01351e-09 5.83710e-03 4.66754e-03 3.01770e-03 2.41305e-03 - 1.92872e-07 1.05908e-13 1.70328e-04 9.35293e-11 1.59466e-07 1.25399e-07 - 1.40827e-04 1.10741e-04 5.31433e-03 2.91817e-09 2.74744e-03 1.50865e-09 - 4.39388e-03 3.45520e-03 2.27158e-03 1.78629e-03 2.44601e-03 4.71663e-05 - 1.09430e-02 2.11013e-04 1.23573e-04 2.76181e-05 5.52841e-04 1.23558e-04 - 2.71755e-02 5.24023e-04 4.76200e-02 9.18253e-04 1.37291e-03 3.06841e-04 - 2.40577e-03 5.37681e-04 2.29014e-03 4.44674e-05 1.02456e-02 1.98938e-04 - 1.12524e-04 2.48126e-05 5.03411e-04 1.11007e-04 2.54438e-02 4.94038e-04 - 4.45855e-02 8.65710e-04 1.25016e-03 2.75671e-04 2.19067e-03 4.83061e-04 - 2.38500e-03 4.58053e-05 1.06700e-02 2.04924e-04 1.22899e-04 2.95267e-05 - 5.49826e-04 1.32097e-04 2.64977e-02 5.08903e-04 4.64323e-02 8.91758e-04 - 1.36542e-03 3.28045e-04 2.39265e-03 5.74839e-04 2.17094e-03 4.21772e-05 - 9.71236e-03 1.88693e-04 1.09358e-04 2.46984e-05 4.89245e-04 1.10496e-04 - 2.41194e-02 4.68594e-04 4.22648e-02 8.21124e-04 1.21498e-03 2.74402e-04 - 2.12902e-03 4.80839e-04][0.00608 0.00487 0.00314 0.00252 0.00422 0.00331 0.00218 0.00171 0.00584 - 0.00467 0.00302 0.00241 0.00439 0.00346 0.00227 0.00179 0.00137 0.00031 - 0.00241 0.00054 0.00125 0.00028 0.00219 0.00048 0.00137 0.00033 0.00239 - 0.00057 0.00121 0.00027 0.00213 0.00048][0.0002 0.00019 0.00327 0.00314 0.00017 0.00014 0.0027 0.00218 0.0002 - 0.00019 0.00315 0.00302 0.00017 0.00014 0.00275 0.00227 0.01094 0.00055 - 0.04762 0.00241 0.01025 0.0005 0.04459 0.00219 0.01067 0.00055 0.04643 - 0.00239 0.00971 0.00049 0.04226 0.00213][0.00314 0.00218 0.00302 0.00227 0.00241 0.00219 0.00239 0.00213] \ No newline at end of file +[2.04229e-07 1.28343e-13 1.79333e-04 1.12698e-10 1.89952e-07 1.51210e-07 + 1.66796e-04 1.32777e-04 6.13215e-03 3.85362e-09 3.14746e-03 1.97795e-09 + 5.70345e-03 4.54021e-03 2.92742e-03 2.33037e-03 2.10575e-07 1.28419e-13 + 1.84905e-04 1.12764e-10 1.89188e-07 1.50221e-07 1.66125e-04 1.31908e-04 + 6.32269e-03 3.85587e-09 3.24526e-03 1.97911e-09 5.68054e-03 4.51051e-03 + 2.91566e-03 2.31512e-03 1.96696e-07 1.26388e-13 1.72718e-04 1.10981e-10 + 1.91283e-07 1.53449e-07 1.67964e-04 1.34743e-04 5.90596e-03 3.79491e-09 + 3.03136e-03 1.94782e-09 5.74342e-03 4.60742e-03 2.94794e-03 2.36486e-03 + 2.06016e-07 1.35264e-13 1.80901e-04 1.18775e-10 2.05873e-07 1.65814e-07 + 1.80776e-04 1.45600e-04 6.18579e-03 4.06142e-09 3.17499e-03 2.08461e-09 + 6.18150e-03 4.97869e-03 3.17279e-03 2.55542e-03 2.36089e-03 4.46651e-05 + 1.02263e-02 1.93469e-04 1.18179e-04 2.62375e-05 5.11897e-04 1.13649e-04 + 2.56040e-02 4.84394e-04 4.55595e-02 8.61927e-04 1.28165e-03 2.84546e-04 + 2.28056e-03 5.06320e-04 2.29877e-03 4.53056e-05 9.95724e-03 1.96244e-04 + 1.14803e-04 2.57898e-05 4.97276e-04 1.11710e-04 2.49302e-02 4.91340e-04 + 4.43606e-02 8.74289e-04 1.24504e-03 2.79691e-04 2.21542e-03 4.97680e-04 + 2.31940e-03 4.34238e-05 1.00466e-02 1.88093e-04 1.17620e-04 2.69280e-05 + 5.09479e-04 1.16640e-04 2.51540e-02 4.70932e-04 4.47588e-02 8.37974e-04 + 1.27560e-03 2.92034e-04 2.26979e-03 5.19644e-04 2.19212e-03 4.53914e-05 + 9.49530e-03 1.96615e-04 1.09609e-04 2.41615e-05 4.74778e-04 1.04657e-04 + 2.37736e-02 4.92271e-04 4.23026e-02 8.75944e-04 1.18871e-03 2.62032e-04 + 2.11519e-03 4.66257e-04][2.04229e-07 1.28343e-13 1.79333e-04 1.12698e-10 1.89952e-07 1.51210e-07 + 1.66796e-04 1.32777e-04 6.13215e-03 3.85362e-09 3.14746e-03 1.97795e-09 + 5.70345e-03 4.54021e-03 2.92742e-03 2.33037e-03 2.10575e-07 1.28419e-13 + 1.84905e-04 1.12764e-10 1.89188e-07 1.50221e-07 1.66125e-04 1.31908e-04 + 6.32269e-03 3.85587e-09 3.24526e-03 1.97911e-09 5.68054e-03 4.51051e-03 + 2.91566e-03 2.31512e-03 1.96696e-07 1.26388e-13 1.72718e-04 1.10981e-10 + 1.91283e-07 1.53449e-07 1.67964e-04 1.34743e-04 5.90596e-03 3.79491e-09 + 3.03136e-03 1.94782e-09 5.74342e-03 4.60742e-03 2.94794e-03 2.36486e-03 + 2.06016e-07 1.35264e-13 1.80901e-04 1.18775e-10 2.05873e-07 1.65814e-07 + 1.80776e-04 1.45600e-04 6.18579e-03 4.06142e-09 3.17499e-03 2.08461e-09 + 6.18150e-03 4.97869e-03 3.17279e-03 2.55542e-03 2.36089e-03 4.46651e-05 + 1.02263e-02 1.93469e-04 1.18179e-04 2.62375e-05 5.11897e-04 1.13649e-04 + 2.56040e-02 4.84394e-04 4.55595e-02 8.61927e-04 1.28165e-03 2.84546e-04 + 2.28056e-03 5.06320e-04 2.29877e-03 4.53056e-05 9.95724e-03 1.96244e-04 + 1.14803e-04 2.57898e-05 4.97276e-04 1.11710e-04 2.49302e-02 4.91340e-04 + 4.43606e-02 8.74289e-04 1.24504e-03 2.79691e-04 2.21542e-03 4.97680e-04 + 2.31940e-03 4.34238e-05 1.00466e-02 1.88093e-04 1.17620e-04 2.69280e-05 + 5.09479e-04 1.16640e-04 2.51540e-02 4.70932e-04 4.47588e-02 8.37974e-04 + 1.27560e-03 2.92034e-04 2.26979e-03 5.19644e-04 2.19212e-03 4.53914e-05 + 9.49530e-03 1.96615e-04 1.09609e-04 2.41615e-05 4.74778e-04 1.04657e-04 + 2.37736e-02 4.92271e-04 4.23026e-02 8.75944e-04 1.18871e-03 2.62032e-04 + 2.11519e-03 4.66257e-04][0.0057 0.00454 0.00293 0.00233 0.00568 0.00451 0.00292 0.00232 0.00574 + 0.00461 0.00295 0.00236 0.00618 0.00498 0.00317 0.00256 0.00128 0.00028 + 0.00228 0.00051 0.00125 0.00028 0.00222 0.0005 0.00128 0.00029 0.00227 + 0.00052 0.00119 0.00026 0.00212 0.00047][0.00018 0.00017 0.00315 0.00293 0.00018 0.00017 0.00325 0.00292 0.00017 + 0.00017 0.00303 0.00295 0.00018 0.00018 0.00317 0.00317 0.01023 0.00051 + 0.04556 0.00228 0.00996 0.0005 0.04436 0.00222 0.01005 0.00051 0.04476 + 0.00227 0.0095 0.00047 0.0423 0.00212][0.00293 0.00292 0.00295 0.00317 0.00228 0.00222 0.00227 0.00212] \ No newline at end of file diff --git a/tests/regression_tests/tally_assumesep/results_true.dat b/tests/regression_tests/tally_assumesep/results_true.dat index c9ccf0928..9d7cbf9c3 100644 --- a/tests/regression_tests/tally_assumesep/results_true.dat +++ b/tests/regression_tests/tally_assumesep/results_true.dat @@ -1,11 +1,11 @@ k-combined: -6.268465E-01 1.154810E-02 +5.683578E-01 1.129170E-02 tally 1: -7.828708E+00 -1.230478E+01 +6.753950E+00 +9.188305E+00 tally 2: -2.582239E-01 -1.360117E-02 +2.278558E-01 +1.052944E-02 tally 3: -1.339335E+01 -3.663458E+01 +1.179091E+01 +2.795539E+01 diff --git a/tests/regression_tests/tally_nuclides/results_true.dat b/tests/regression_tests/tally_nuclides/results_true.dat index 93a0e03fb..7f9641fc8 100644 --- a/tests/regression_tests/tally_nuclides/results_true.dat +++ b/tests/regression_tests/tally_nuclides/results_true.dat @@ -1,28 +1,28 @@ k-combined: -9.732610E-01 1.400780E-02 +1.132463E+00 5.721067E-02 tally 1: -7.123025E+00 -1.021136E+01 -1.619905E+00 -5.258592E-01 -1.561322E+00 -4.881841E-01 -5.503120E+00 -6.105683E+00 -7.123025E+00 -1.021136E+01 -1.619905E+00 -5.258592E-01 -1.561322E+00 -4.881841E-01 -5.503120E+00 -6.105683E+00 +7.310528E+00 +1.080411E+01 +1.664215E+00 +5.567756E-01 +1.609340E+00 +5.205634E-01 +5.646313E+00 +6.459724E+00 +7.310528E+00 +1.080411E+01 +1.664215E+00 +5.567756E-01 +1.609340E+00 +5.205634E-01 +5.646313E+00 +6.459724E+00 tally 2: -7.123025E+00 -1.021136E+01 -1.619905E+00 -5.258592E-01 -1.561322E+00 -4.881841E-01 -5.503120E+00 -6.105683E+00 +7.310528E+00 +1.080411E+01 +1.664215E+00 +5.567756E-01 +1.609340E+00 +5.205634E-01 +5.646313E+00 +6.459724E+00 diff --git a/tests/regression_tests/tally_slice_merge/inputs_true.dat b/tests/regression_tests/tally_slice_merge/inputs_true.dat index 7a992cc39..356962f8e 100644 --- a/tests/regression_tests/tally_slice_merge/inputs_true.dat +++ b/tests/regression_tests/tally_slice_merge/inputs_true.dat @@ -1,40 +1,40 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + - + @@ -47,7 +47,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -149,8 +149,8 @@ - - + + @@ -174,9 +174,9 @@ - + - + 1.26 1.26 17 17 @@ -277,30 +277,30 @@ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + eigenvalue 100 10 5 - + -160 -160 -183 160 160 183 @@ -308,7 +308,7 @@ - + 2 2 -50.0 -50.0 50.0 50.0 diff --git a/tests/regression_tests/tally_slice_merge/results_true.dat b/tests/regression_tests/tally_slice_merge/results_true.dat index 4b2cbdf1a..58b15fc18 100644 --- a/tests/regression_tests/tally_slice_merge/results_true.dat +++ b/tests/regression_tests/tally_slice_merge/results_true.dat @@ -1,45 +1,45 @@ cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 0.00e+00 6.25e-01 U235 fission 1.93e-01 1.92e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 0.00e+00 6.25e-01 U235 nu-fission 4.70e-01 4.67e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 0.00e+00 6.25e-01 U238 fission 2.65e-07 2.60e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 0.00e+00 6.25e-01 U238 nu-fission 6.60e-07 6.47e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 6.25e-01 2.00e+07 U235 fission 3.39e-02 1.53e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 6.25e-01 2.00e+07 U235 nu-fission 8.30e-02 3.75e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 6.25e-01 2.00e+07 U238 fission 1.70e-02 2.01e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 6.25e-01 2.00e+07 U238 nu-fission 4.76e-02 6.12e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 0.00e+00 6.25e-01 U235 fission 7.61e-02 5.84e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 0.00e+00 6.25e-01 U235 nu-fission 1.85e-01 1.42e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 0.00e+00 6.25e-01 U238 fission 1.06e-07 7.62e-09 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 0.00e+00 6.25e-01 U238 nu-fission 2.64e-07 1.90e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 6.25e-01 2.00e+07 U235 fission 1.69e-02 1.34e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 6.25e-01 2.00e+07 U235 nu-fission 4.15e-02 3.29e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 6.25e-01 2.00e+07 U238 fission 1.10e-02 1.69e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 27 6.25e-01 2.00e+07 U238 nu-fission 3.13e-02 5.35e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. -0 21 0.00e+00 6.25e-01 U235 fission 1.93e-01 1.92e-02 -1 21 0.00e+00 6.25e-01 U235 nu-fission 4.70e-01 4.67e-02 -2 21 0.00e+00 6.25e-01 U238 fission 2.65e-07 2.60e-08 -3 21 0.00e+00 6.25e-01 U238 nu-fission 6.60e-07 6.47e-08 -4 21 6.25e-01 2.00e+07 U235 fission 3.39e-02 1.53e-03 -5 21 6.25e-01 2.00e+07 U235 nu-fission 8.30e-02 3.75e-03 -6 21 6.25e-01 2.00e+07 U238 fission 1.70e-02 2.01e-03 -7 21 6.25e-01 2.00e+07 U238 nu-fission 4.76e-02 6.12e-03 -8 27 0.00e+00 6.25e-01 U235 fission 7.61e-02 5.84e-03 -9 27 0.00e+00 6.25e-01 U235 nu-fission 1.85e-01 1.42e-02 -10 27 0.00e+00 6.25e-01 U238 fission 1.06e-07 7.62e-09 -11 27 0.00e+00 6.25e-01 U238 nu-fission 2.64e-07 1.90e-08 -12 27 6.25e-01 2.00e+07 U235 fission 1.69e-02 1.34e-03 -13 27 6.25e-01 2.00e+07 U235 nu-fission 4.15e-02 3.29e-03 -14 27 6.25e-01 2.00e+07 U238 fission 1.10e-02 1.69e-03 -15 27 6.25e-01 2.00e+07 U238 nu-fission 3.13e-02 5.35e-03 +0 21 0.00e+00 6.25e-01 U235 fission 1.75e-01 1.20e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 0.00e+00 6.25e-01 U235 nu-fission 4.26e-01 2.92e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 0.00e+00 6.25e-01 U238 fission 2.41e-07 1.61e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 0.00e+00 6.25e-01 U238 nu-fission 6.00e-07 4.01e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 6.25e-01 2.00e+07 U235 fission 2.89e-02 2.07e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 6.25e-01 2.00e+07 U235 nu-fission 7.07e-02 5.06e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 6.25e-01 2.00e+07 U238 fission 1.41e-02 5.76e-04 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 6.25e-01 2.00e+07 U238 nu-fission 3.95e-02 1.90e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 0.00e+00 6.25e-01 U235 fission 1.51e-01 1.17e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 0.00e+00 6.25e-01 U235 nu-fission 3.69e-01 2.86e-02 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 0.00e+00 6.25e-01 U238 fission 2.07e-07 1.47e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 0.00e+00 6.25e-01 U238 nu-fission 5.17e-07 3.66e-08 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 6.25e-01 2.00e+07 U235 fission 2.57e-02 2.43e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 6.25e-01 2.00e+07 U235 nu-fission 6.30e-02 5.92e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 6.25e-01 2.00e+07 U238 fission 1.47e-02 1.41e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 27 6.25e-01 2.00e+07 U238 nu-fission 4.12e-02 4.02e-03 cell energy low [eV] energy high [eV] nuclide score mean std. dev. +0 21 0.00e+00 6.25e-01 U235 fission 1.75e-01 1.20e-02 +1 21 0.00e+00 6.25e-01 U235 nu-fission 4.26e-01 2.92e-02 +2 21 0.00e+00 6.25e-01 U238 fission 2.41e-07 1.61e-08 +3 21 0.00e+00 6.25e-01 U238 nu-fission 6.00e-07 4.01e-08 +4 21 6.25e-01 2.00e+07 U235 fission 2.89e-02 2.07e-03 +5 21 6.25e-01 2.00e+07 U235 nu-fission 7.07e-02 5.06e-03 +6 21 6.25e-01 2.00e+07 U238 fission 1.41e-02 5.76e-04 +7 21 6.25e-01 2.00e+07 U238 nu-fission 3.95e-02 1.90e-03 +8 27 0.00e+00 6.25e-01 U235 fission 1.51e-01 1.17e-02 +9 27 0.00e+00 6.25e-01 U235 nu-fission 3.69e-01 2.86e-02 +10 27 0.00e+00 6.25e-01 U238 fission 2.07e-07 1.47e-08 +11 27 0.00e+00 6.25e-01 U238 nu-fission 5.17e-07 3.66e-08 +12 27 6.25e-01 2.00e+07 U235 fission 2.57e-02 2.43e-03 +13 27 6.25e-01 2.00e+07 U235 nu-fission 6.30e-02 5.92e-03 +14 27 6.25e-01 2.00e+07 U238 fission 1.47e-02 1.41e-03 +15 27 6.25e-01 2.00e+07 U238 nu-fission 4.12e-02 4.02e-03 sum(distribcell) energy low [eV] energy high [eV] nuclide score mean std. dev. 0 (0, 100, 2000, 30000) 0.00e+00 6.25e-01 U235 fission 0.00e+00 0.00e+00 1 (0, 100, 2000, 30000) 0.00e+00 6.25e-01 U235 nu-fission 0.00e+00 0.00e+00 2 (0, 100, 2000, 30000) 0.00e+00 6.25e-01 U238 fission 0.00e+00 0.00e+00 3 (0, 100, 2000, 30000) 0.00e+00 6.25e-01 U238 nu-fission 0.00e+00 0.00e+00 -4 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U235 fission 0.00e+00 0.00e+00 -5 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U235 nu-fission 0.00e+00 0.00e+00 -6 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U238 fission 0.00e+00 0.00e+00 -7 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U238 nu-fission 0.00e+00 0.00e+00 +4 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U235 fission 9.53e-07 9.53e-07 +5 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U235 nu-fission 2.37e-06 2.37e-06 +6 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U238 fission 1.25e-08 1.25e-08 +7 (0, 100, 2000, 30000) 6.25e-01 2.00e+07 U238 nu-fission 3.15e-08 3.15e-08 8 (500, 5000, 50000) 0.00e+00 6.25e-01 U235 fission 0.00e+00 0.00e+00 9 (500, 5000, 50000) 0.00e+00 6.25e-01 U235 nu-fission 0.00e+00 0.00e+00 10 (500, 5000, 50000) 0.00e+00 6.25e-01 U238 fission 0.00e+00 0.00e+00 @@ -49,19 +49,19 @@ 14 (500, 5000, 50000) 6.25e-01 2.00e+07 U238 fission 0.00e+00 0.00e+00 15 (500, 5000, 50000) 6.25e-01 2.00e+07 U238 nu-fission 0.00e+00 0.00e+00 sum(mesh) energy low [eV] energy high [eV] nuclide score mean std. dev. -0 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U235 fission 1.94e-03 1.03e-03 -1 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U235 nu-fission 4.74e-03 2.50e-03 -2 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U238 fission 2.74e-09 1.42e-09 -3 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U238 nu-fission 6.83e-09 3.53e-09 -4 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U235 fission 9.02e-04 3.69e-04 -5 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U235 nu-fission 2.24e-03 9.12e-04 -6 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U238 fission 1.44e-03 8.42e-04 -7 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U238 nu-fission 4.37e-03 2.64e-03 -8 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U235 fission 1.27e-02 2.76e-03 -9 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U235 nu-fission 3.09e-02 6.72e-03 -10 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U238 fission 1.70e-08 3.57e-09 -11 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U238 nu-fission 4.25e-08 8.90e-09 -12 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U235 fission 1.43e-03 1.69e-04 -13 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U235 nu-fission 3.52e-03 4.20e-04 -14 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U238 fission 1.37e-03 2.98e-04 -15 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U238 nu-fission 4.16e-03 1.08e-03 +0 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U235 fission 6.73e-03 3.04e-03 +1 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U235 nu-fission 1.64e-02 7.40e-03 +2 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U238 fission 8.80e-09 3.84e-09 +3 ((1, 1), (1, 2)) 0.00e+00 6.25e-01 U238 nu-fission 2.19e-08 9.56e-09 +4 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U235 fission 9.89e-04 3.53e-04 +5 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U235 nu-fission 2.42e-03 8.60e-04 +6 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U238 fission 5.01e-04 2.13e-04 +7 ((1, 1), (1, 2)) 6.25e-01 2.00e+07 U238 nu-fission 1.36e-03 5.86e-04 +8 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U235 fission 1.63e-02 4.21e-03 +9 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U235 nu-fission 3.98e-02 1.02e-02 +10 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U238 fission 2.28e-08 5.90e-09 +11 ((2, 1), (2, 2)) 0.00e+00 6.25e-01 U238 nu-fission 5.67e-08 1.47e-08 +12 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U235 fission 1.79e-03 4.31e-04 +13 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U235 nu-fission 4.37e-03 1.05e-03 +14 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U238 fission 7.51e-04 2.51e-04 +15 ((2, 1), (2, 2)) 6.25e-01 2.00e+07 U238 nu-fission 2.02e-03 6.71e-04 diff --git a/tests/regression_tests/tally_slice_merge/test.py b/tests/regression_tests/tally_slice_merge/test.py index aec73979b..090e31448 100644 --- a/tests/regression_tests/tally_slice_merge/test.py +++ b/tests/regression_tests/tally_slice_merge/test.py @@ -149,9 +149,6 @@ class TallySliceMergeTestHarness(PyAPITestHarness): sum2 = mesh_tally.summation(filter_type=openmc.MeshFilter, filter_bins=[(2, 1), (2, 2)]) - mesh = mesh_tally.find_filter(openmc.MeshFilter).mesh - assert mesh.name == 'mesh' - # Merge the mesh tally slices merge_tally = sum1.merge(sum2) diff --git a/tests/regression_tests/time_cutoff/inputs_true.dat b/tests/regression_tests/time_cutoff/inputs_true.dat index e1102d475..7d3e94f50 100644 --- a/tests/regression_tests/time_cutoff/inputs_true.dat +++ b/tests/regression_tests/time_cutoff/inputs_true.dat @@ -4,13 +4,13 @@ - + fixed source 100 10 - + 0.0 0.0 0.0 diff --git a/tests/regression_tests/time_cutoff/results_true.dat b/tests/regression_tests/time_cutoff/results_true.dat index d3d5e1b3c..1cafceb77 100644 --- a/tests/regression_tests/time_cutoff/results_true.dat +++ b/tests/regression_tests/time_cutoff/results_true.dat @@ -1,5 +1,5 @@ tally 1: -1.383148E+02 -1.913099E+03 +2.000000E+03 +4.000000E+05 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/torus/inputs_true.dat b/tests/regression_tests/torus/inputs_true.dat index df4af1443..a5c7a8d7a 100644 --- a/tests/regression_tests/torus/inputs_true.dat +++ b/tests/regression_tests/torus/inputs_true.dat @@ -1,13 +1,13 @@ - - - + + + - - + + @@ -15,15 +15,15 @@ - - - - - - - - - + + + + + + + + + eigenvalue diff --git a/tests/regression_tests/torus/large_major/inputs_true.dat b/tests/regression_tests/torus/large_major/inputs_true.dat index 513a8c67e..fa7deb29a 100644 --- a/tests/regression_tests/torus/large_major/inputs_true.dat +++ b/tests/regression_tests/torus/large_major/inputs_true.dat @@ -2,27 +2,27 @@ - - + + - - + + - - - + + + fixed source 1000 10 - + -1000.0 0 0 diff --git a/tests/regression_tests/torus/results_true.dat b/tests/regression_tests/torus/results_true.dat index 84cd3c7a4..42fb209cc 100644 --- a/tests/regression_tests/torus/results_true.dat +++ b/tests/regression_tests/torus/results_true.dat @@ -1,2 +1,2 @@ k-combined: -7.666453E-01 1.478848E-02 +7.667201E-01 1.136882E-02 diff --git a/tests/regression_tests/trace/results_true.dat b/tests/regression_tests/trace/results_true.dat index 97b997ae6..bbf03de94 100644 --- a/tests/regression_tests/trace/results_true.dat +++ b/tests/regression_tests/trace/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 diff --git a/tests/regression_tests/track_output/results_true.dat b/tests/regression_tests/track_output/results_true.dat index 205ac3eec..148b54a30 100644 --- a/tests/regression_tests/track_output/results_true.dat +++ b/tests/regression_tests/track_output/results_true.dat @@ -143,74 +143,76 @@ neutron [((-9.469716e-01, -2.580266e-01, 1.414357e-01), (1.438873e-01, 2.365819e ((-3.920090e+00, -9.211794e-01, 2.908406e+00), (9.094673e-01, -3.659267e-01, -1.974002e-01), 9.547085e+00, 1.260840e-07, 1.000000e+00, 23, 2387, 1) ((-3.729948e+00, -9.976834e-01, 2.867135e+00), (-2.916959e-01, -6.494657e-01, -7.022164e-01), 8.590591e+00, 1.750036e-07, 1.000000e+00, 23, 2387, 1) ((-3.744933e+00, -1.031047e+00, 2.831062e+00), (-2.916959e-01, -6.494657e-01, -7.022164e-01), 8.590591e+00, 1.876753e-07, 0.000000e+00, 23, 2387, 1)] -neutron [((6.474155e+00, -5.192870e+00, 5.413003e+00), (-9.597810e-01, -1.081529e-01, -2.590820e-01), 9.900333e+05, 4.450859e-05, 1.000000e+00, 21, 2367, 2) - ((6.142109e+00, -5.230286e+00, 5.323371e+00), (-9.597810e-01, -1.081529e-01, -2.590820e-01), 9.900333e+05, 4.450884e-05, 1.000000e+00, 22, 2367, 3) - ((6.041244e+00, -5.241652e+00, 5.296144e+00), (-9.597810e-01, -1.081529e-01, -2.590820e-01), 9.900333e+05, 4.450892e-05, 1.000000e+00, 23, 2367, 1) - ((6.004037e+00, -5.245845e+00, 5.286100e+00), (-6.195407e-01, -7.332723e-01, -2.801446e-01), 5.512347e+05, 4.450895e-05, 1.000000e+00, 23, 2367, 1) - ((5.725160e+00, -5.575916e+00, 5.159997e+00), (-6.195407e-01, -7.332723e-01, -2.801446e-01), 5.512347e+05, 4.450939e-05, 1.000000e+00, 23, 2366, 1) - ((5.599064e+00, -5.725160e+00, 5.102979e+00), (-6.195407e-01, -7.332723e-01, -2.801446e-01), 5.512347e+05, 4.450958e-05, 1.000000e+00, 23, 2352, 1) - ((5.296886e+00, -6.082810e+00, 4.966340e+00), (-6.195407e-01, -7.332723e-01, -2.801446e-01), 5.512347e+05, 4.451006e-05, 1.000000e+00, 22, 2352, 3) - ((5.240003e+00, -6.150135e+00, 4.940619e+00), (-6.195407e-01, -7.332723e-01, -2.801446e-01), 5.512347e+05, 4.451015e-05, 1.000000e+00, 21, 2352, 2) - ((4.752072e+00, -6.727638e+00, 4.719986e+00), (3.721510e-02, -9.647240e-01, 2.606197e-01), 5.045933e+05, 4.451092e-05, 1.000000e+00, 21, 2352, 2) - ((4.764028e+00, -7.037568e+00, 4.803713e+00), (3.721510e-02, -9.647240e-01, 2.606197e-01), 5.045933e+05, 4.451124e-05, 1.000000e+00, 22, 2352, 3) - ((4.767580e+00, -7.129630e+00, 4.828584e+00), (3.721510e-02, -9.647240e-01, 2.606197e-01), 5.045933e+05, 4.451134e-05, 1.000000e+00, 23, 2352, 1) - ((4.776502e+00, -7.360920e+00, 4.891066e+00), (3.721510e-02, -9.647240e-01, 2.606197e-01), 5.045933e+05, 4.451158e-05, 1.000000e+00, 23, 2338, 1) - ((4.778286e+00, -7.407162e+00, 4.903559e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451163e-05, 1.000000e+00, 23, 2338, 1) - ((4.981926e+00, -7.580442e+00, 5.259893e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451239e-05, 1.000000e+00, 22, 2338, 3) - ((5.154144e+00, -7.726985e+00, 5.561246e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451303e-05, 1.000000e+00, 21, 2338, 2) - ((5.313757e+00, -7.862801e+00, 5.840540e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451362e-05, 1.000000e+00, 22, 2338, 3) - ((5.485976e+00, -8.009344e+00, 6.141893e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451426e-05, 1.000000e+00, 23, 2338, 1) - ((5.725160e+00, -8.212869e+00, 6.560424e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451515e-05, 1.000000e+00, 23, 2339, 1) - ((6.004950e+00, -8.450945e+00, 7.050007e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451618e-05, 1.000000e+00, 22, 2339, 3) - ((6.360530e+00, -8.753512e+00, 7.672210e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451750e-05, 1.000000e+00, 23, 2339, 1) - ((6.646303e+00, -8.996680e+00, 8.172263e+00), (4.571054e-01, -3.889563e-01, 7.998548e-01), 1.818775e+05, 4.451856e-05, 1.000000e+00, 23, 2326, 1) - ((6.702490e+00, -9.044491e+00, 8.270582e+00), (2.028534e-01, -9.607965e-01, -1.889990e-01), 1.805295e+04, 4.451877e-05, 1.000000e+00, 23, 2326, 1) - ((6.745127e+00, -9.246436e+00, 8.230857e+00), (2.028534e-01, -9.607965e-01, -1.889990e-01), 1.805295e+04, 4.451990e-05, 1.000000e+00, 22, 2326, 3) - ((6.767219e+00, -9.351070e+00, 8.210274e+00), (2.028534e-01, -9.607965e-01, -1.889990e-01), 1.805295e+04, 4.452049e-05, 1.000000e+00, 21, 2326, 2) - ((6.885344e+00, -9.910562e+00, 8.100216e+00), (-3.857824e-01, -3.006310e-01, -8.722344e-01), 1.795765e+04, 4.452362e-05, 1.000000e+00, 21, 2326, 2) - ((6.803615e+00, -9.974251e+00, 7.915431e+00), (-7.096135e-01, 6.778415e-01, 1.923009e-01), 1.779137e+04, 4.452476e-05, 1.000000e+00, 21, 2326, 2) - ((6.334815e+00, -9.526441e+00, 8.042473e+00), (-1.748210e-01, 9.821705e-01, -6.912779e-02), 1.729669e+04, 4.452835e-05, 1.000000e+00, 21, 2326, 2) - ((6.304853e+00, -9.358111e+00, 8.030625e+00), (-1.748210e-01, 9.821705e-01, -6.912779e-02), 1.729669e+04, 4.452929e-05, 1.000000e+00, 22, 2326, 3) - ((6.288777e+00, -9.267793e+00, 8.024268e+00), (-1.748210e-01, 9.821705e-01, -6.912779e-02), 1.729669e+04, 4.452979e-05, 1.000000e+00, 23, 2326, 1) - ((6.275105e+00, -9.190979e+00, 8.018862e+00), (-7.174952e-01, 5.897531e-01, -3.706642e-01), 9.207900e+03, 4.453022e-05, 1.000000e+00, 23, 2326, 1) - ((6.038719e+00, -8.996680e+00, 7.896743e+00), (-7.174952e-01, 5.897531e-01, -3.706642e-01), 9.207900e+03, 4.453271e-05, 1.000000e+00, 23, 2339, 1) - ((6.028805e+00, -8.988531e+00, 7.891621e+00), (-2.989803e-01, 4.300779e-01, -8.518473e-01), 5.653774e+03, 4.453281e-05, 1.000000e+00, 23, 2339, 1) - ((5.725160e+00, -8.551743e+00, 7.026484e+00), (-2.989803e-01, 4.300779e-01, -8.518473e-01), 5.653774e+03, 4.454257e-05, 1.000000e+00, 23, 2338, 1) - ((5.507324e+00, -8.238390e+00, 6.405832e+00), (-2.989803e-01, 4.300779e-01, -8.518473e-01), 5.653774e+03, 4.454958e-05, 1.000000e+00, 22, 2338, 3) - ((5.417387e+00, -8.109017e+00, 6.149584e+00), (-2.989803e-01, 4.300779e-01, -8.518473e-01), 5.653774e+03, 4.455247e-05, 1.000000e+00, 21, 2338, 2) - ((5.162017e+00, -7.741671e+00, 5.421991e+00), (7.522612e-01, -1.036919e-01, -6.506543e-01), 5.619608e+03, 4.456069e-05, 1.000000e+00, 21, 2338, 2) - ((5.184146e+00, -7.744722e+00, 5.402851e+00), (7.522612e-01, -1.036919e-01, -6.506543e-01), 5.619608e+03, 4.456097e-05, 1.000000e+00, 22, 2338, 3) - ((5.348057e+00, -7.767315e+00, 5.261079e+00), (7.522612e-01, -1.036919e-01, -6.506543e-01), 5.619608e+03, 4.456307e-05, 1.000000e+00, 23, 2338, 1) - ((5.581568e+00, -7.799502e+00, 5.059108e+00), (2.029690e-01, -4.131185e-01, -8.877706e-01), 3.359662e+03, 4.456606e-05, 1.000000e+00, 23, 2338, 1) - ((5.707007e+00, -8.054818e+00, 4.510447e+00), (3.894183e-01, -7.459178e-01, -5.403333e-01), 3.303714e+03, 4.457377e-05, 1.000000e+00, 23, 2338, 1) - ((5.725160e+00, -8.089590e+00, 4.485259e+00), (3.894183e-01, -7.459178e-01, -5.403333e-01), 3.303714e+03, 4.457436e-05, 1.000000e+00, 23, 2339, 1) - ((5.750893e+00, -8.138881e+00, 4.449554e+00), (-2.879829e-01, -5.545287e-01, -7.807456e-01), 1.744626e+03, 4.457519e-05, 1.000000e+00, 23, 2339, 1) - ((5.725160e+00, -8.188431e+00, 4.379790e+00), (-2.879829e-01, -5.545287e-01, -7.807456e-01), 1.744626e+03, 4.457674e-05, 1.000000e+00, 23, 2338, 1) - ((5.532143e+00, -8.560097e+00, 3.856504e+00), (-6.185172e-01, -7.766669e-01, -1.192687e-01), 8.559363e+02, 4.458834e-05, 1.000000e+00, 23, 2338, 1) - ((5.522333e+00, -8.572415e+00, 3.854613e+00), (-3.452053e-01, -2.657159e-02, -9.381510e-01), 9.272133e+01, 4.458873e-05, 1.000000e+00, 23, 2338, 1) - ((5.366948e+00, -8.584375e+00, 3.432328e+00), (4.761677e-01, -8.187551e-01, -3.207871e-01), 6.522002e+00, 4.462253e-05, 1.000000e+00, 23, 2338, 1) - ((5.516634e+00, -8.841755e+00, 3.331487e+00), (4.237115e-01, -6.022578e-01, 6.765752e-01), 9.968491e-01, 4.471152e-05, 1.000000e+00, 23, 2338, 1) - ((5.625629e+00, -8.996680e+00, 3.505530e+00), (4.237115e-01, -6.022578e-01, 6.765752e-01), 9.968491e-01, 4.489779e-05, 1.000000e+00, 23, 2325, 1) - ((5.723424e+00, -9.135684e+00, 3.661687e+00), (7.706137e-01, -6.358415e-01, 4.312932e-02), 5.695813e-01, 4.506493e-05, 1.000000e+00, 23, 2325, 1) - ((5.725160e+00, -9.137116e+00, 3.661784e+00), (7.706137e-01, -6.358415e-01, 4.312932e-02), 5.695813e-01, 4.506708e-05, 1.000000e+00, 23, 2326, 1) - ((6.079210e+00, -9.429247e+00, 3.681599e+00), (7.706137e-01, -6.358415e-01, 4.312932e-02), 5.695813e-01, 4.550721e-05, 1.000000e+00, 22, 2326, 3) - ((6.147194e+00, -9.485341e+00, 3.685404e+00), (7.706137e-01, -6.358415e-01, 4.312932e-02), 5.695813e-01, 4.559172e-05, 1.000000e+00, 21, 2326, 2) - ((6.864744e+00, -1.007740e+01, 3.725564e+00), (3.888690e-01, -8.895503e-01, -2.397522e-01), 5.691123e-01, 4.648372e-05, 1.000000e+00, 21, 2326, 2) - ((6.908415e+00, -1.017730e+01, 3.698639e+00), (3.888690e-01, -8.895503e-01, -2.397522e-01), 5.691123e-01, 4.659135e-05, 1.000000e+00, 22, 2326, 3) - ((6.945959e+00, -1.026318e+01, 3.675492e+00), (3.888690e-01, -8.895503e-01, -2.397522e-01), 5.691123e-01, 4.668388e-05, 1.000000e+00, 23, 2326, 1) - ((6.966122e+00, -1.030930e+01, 3.663060e+00), (7.493672e-01, -6.303754e-01, 2.026713e-01), 2.849108e-01, 4.673357e-05, 1.000000e+00, 23, 2326, 1) - ((7.350254e+00, -1.063244e+01, 3.766951e+00), (7.493672e-01, -6.303754e-01, 2.026713e-01), 2.849108e-01, 4.742789e-05, 1.000000e+00, 23, 2311, 1) - ((7.360920e+00, -1.064141e+01, 3.769836e+00), (7.493672e-01, -6.303754e-01, 2.026713e-01), 2.849108e-01, 4.744717e-05, 1.000000e+00, 23, 2312, 1) - ((7.449168e+00, -1.071565e+01, 3.793703e+00), (1.626881e-01, -1.480918e-01, 9.755006e-01), 2.025207e-01, 4.760667e-05, 1.000000e+00, 23, 2312, 1) - ((7.495754e+00, -1.075805e+01, 4.073039e+00), (-1.185723e-01, -6.787603e-01, 7.247241e-01), 2.121260e-01, 4.806671e-05, 1.000000e+00, 23, 2312, 1) - ((7.451135e+00, -1.101347e+01, 4.345753e+00), (-4.978877e-01, -3.750598e-02, 8.664301e-01), 2.609768e-02, 4.865741e-05, 1.000000e+00, 23, 2312, 1) - ((7.426401e+00, -1.101533e+01, 4.388795e+00), (9.221835e-01, -6.407530e-02, 3.814078e-01), 2.031765e-02, 4.887973e-05, 1.000000e+00, 23, 2312, 1) - ((7.438938e+00, -1.101621e+01, 4.393980e+00), (8.832139e-01, 3.563144e-01, 3.049151e-01), 2.038019e-02, 4.894869e-05, 1.000000e+00, 23, 2312, 1) - ((7.578355e+00, -1.095996e+01, 4.442112e+00), (5.564936e-01, 8.135970e-01, 1.684482e-01), 4.869241e-02, 4.974811e-05, 1.000000e+00, 23, 2312, 1) - ((7.802376e+00, -1.063244e+01, 4.509922e+00), (5.564936e-01, 8.135970e-01, 1.684482e-01), 4.869241e-02, 5.106705e-05, 1.000000e+00, 23, 2327, 1) - ((7.826035e+00, -1.059785e+01, 4.517083e+00), (-8.227572e-01, -5.662268e-01, 4.957651e-02), 8.202195e-02, 5.120634e-05, 1.000000e+00, 23, 2327, 1) - ((7.775776e+00, -1.063244e+01, 4.520112e+00), (-8.227572e-01, -5.662268e-01, 4.957651e-02), 8.202195e-02, 5.136055e-05, 1.000000e+00, 23, 2312, 1) - ((7.360920e+00, -1.091795e+01, 4.545109e+00), (-8.227572e-01, -5.662268e-01, 4.957651e-02), 8.202195e-02, 5.263343e-05, 1.000000e+00, 23, 2311, 1) - ((7.180267e+00, -1.104227e+01, 4.555995e+00), (5.568446e-01, -6.706436e-01, -4.900625e-01), 5.560680e-02, 5.318772e-05, 1.000000e+00, 23, 2311, 1) - ((7.207392e+00, -1.107494e+01, 4.532123e+00), (9.936512e-01, 4.529367e-02, -1.029847e-01), 8.142074e-02, 5.333706e-05, 1.000000e+00, 23, 2311, 1) - ((7.252245e+00, -1.107290e+01, 4.527474e+00), (9.936512e-01, 4.529367e-02, -1.029847e-01), 8.142074e-02, 5.345144e-05, 0.000000e+00, 23, 2311, 1)] +neutron [((6.474155e+00, -5.192870e+00, 5.413003e+00), (-9.112559e-01, 3.950037e-01, 1.165536e-01), 2.052226e+06, 4.450859e-05, 1.000000e+00, 21, 2367, 2) + ((6.037250e+00, -5.003484e+00, 5.468885e+00), (-9.112559e-01, 3.950037e-01, 1.165536e-01), 2.052226e+06, 4.450883e-05, 1.000000e+00, 22, 2367, 3) + ((5.942573e+00, -4.962444e+00, 5.480995e+00), (-9.112559e-01, 3.950037e-01, 1.165536e-01), 2.052226e+06, 4.450889e-05, 1.000000e+00, 23, 2367, 1) + ((5.861800e+00, -4.927431e+00, 5.491326e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.450893e-05, 1.000000e+00, 23, 2367, 1) + ((5.725160e+00, -4.971424e+00, 5.491002e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.450903e-05, 1.000000e+00, 23, 2366, 1) + ((5.494150e+00, -5.045802e+00, 5.490454e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.450919e-05, 1.000000e+00, 22, 2366, 3) + ((5.392865e+00, -5.078412e+00, 5.490213e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.450927e-05, 1.000000e+00, 21, 2366, 2) + ((4.612759e+00, -5.329579e+00, 5.488362e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.450982e-05, 1.000000e+00, 22, 2366, 3) + ((4.511474e+00, -5.362189e+00, 5.488121e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.450989e-05, 1.000000e+00, 23, 2366, 1) + ((4.089400e+00, -5.498082e+00, 5.487119e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.451019e-05, 1.000000e+00, 23, 2365, 1) + ((3.384113e+00, -5.725160e+00, 5.485445e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.451069e-05, 1.000000e+00, 23, 2351, 1) + ((2.453640e+00, -6.024740e+00, 5.483237e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.451136e-05, 1.000000e+00, 23, 2350, 1) + ((2.086813e+00, -6.142846e+00, 5.482366e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.451162e-05, 1.000000e+00, 22, 2350, 3) + ((1.993594e+00, -6.172859e+00, 5.482145e+00), (-9.518772e-01, -3.064714e-01, -2.259335e-03), 1.141417e+06, 4.451168e-05, 1.000000e+00, 21, 2350, 2) + ((1.325704e+00, -6.387896e+00, 5.480560e+00), (8.986086e-01, -4.380574e-01, -2.466265e-02), 9.775839e+05, 4.451216e-05, 1.000000e+00, 21, 2350, 2) + ((2.061403e+00, -6.746538e+00, 5.460368e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451276e-05, 1.000000e+00, 21, 2350, 2) + ((1.122794e+00, -6.498940e+00, 4.743664e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451375e-05, 1.000000e+00, 22, 2350, 3) + ((1.036483e+00, -6.476172e+00, 4.677758e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451384e-05, 1.000000e+00, 23, 2350, 1) + ((8.178800e-01, -6.418507e+00, 4.510837e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451407e-05, 1.000000e+00, 23, 2349, 1) + ((5.725264e-01, -6.353784e+00, 4.323490e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451432e-05, 1.000000e+00, 22, 2349, 3) + ((4.668297e-01, -6.325902e+00, 4.242782e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451444e-05, 1.000000e+00, 21, 2349, 2) + ((-2.989816e-01, -6.123888e+00, 3.658023e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451524e-05, 1.000000e+00, 22, 2349, 3) + ((-4.046782e-01, -6.096006e+00, 3.577315e+00), (-7.778764e-01, 2.051975e-01, -5.939716e-01), 7.813219e+05, 4.451535e-05, 1.000000e+00, 23, 2349, 1) + ((-8.040445e-01, -5.990656e+00, 3.272367e+00), (-7.989001e-01, -1.890553e-01, -5.709787e-01), 6.637114e+05, 4.451577e-05, 1.000000e+00, 23, 2349, 1) + ((-8.178800e-01, -5.993930e+00, 3.262478e+00), (-7.989001e-01, -1.890553e-01, -5.709787e-01), 6.637114e+05, 4.451579e-05, 1.000000e+00, 23, 2348, 1) + ((-1.077910e+00, -6.055465e+00, 3.076633e+00), (-4.487118e-01, 1.670254e-01, -8.779295e-01), 4.550608e+05, 4.451608e-05, 1.000000e+00, 23, 2348, 1) + ((-1.215611e+00, -6.004208e+00, 2.807214e+00), (7.872329e-01, 4.481433e-01, -4.235941e-01), 3.544207e+03, 4.451641e-05, 1.000000e+00, 23, 2348, 1) + ((-1.100296e+00, -5.938564e+00, 2.745166e+00), (8.468456e-01, 5.310954e-01, 2.811230e-02), 2.812308e+03, 4.451819e-05, 1.000000e+00, 23, 2348, 1) + ((-8.178800e-01, -5.761448e+00, 2.754541e+00), (8.468456e-01, 5.310954e-01, 2.811230e-02), 2.812308e+03, 4.452273e-05, 1.000000e+00, 23, 2349, 1) + ((-7.600184e-01, -5.725160e+00, 2.756462e+00), (8.468456e-01, 5.310954e-01, 2.811230e-02), 2.812308e+03, 4.452366e-05, 1.000000e+00, 23, 2363, 1) + ((-2.947156e-01, -5.433347e+00, 2.771908e+00), (8.468456e-01, 5.310954e-01, 2.811230e-02), 2.812308e+03, 4.453115e-05, 1.000000e+00, 22, 2363, 3) + ((-2.073333e-01, -5.378546e+00, 2.774809e+00), (8.468456e-01, 5.310954e-01, 2.811230e-02), 2.812308e+03, 4.453256e-05, 1.000000e+00, 21, 2363, 2) + ((-1.746705e-01, -5.358062e+00, 2.775893e+00), (5.278774e-01, 5.459205e-01, 6.506276e-01), 2.806481e+03, 4.453309e-05, 1.000000e+00, 21, 2363, 2) + ((-8.681718e-02, -5.267205e+00, 2.884176e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.453536e-05, 1.000000e+00, 21, 2363, 2) + ((-3.684221e-01, -5.266924e+00, 2.745840e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.453967e-05, 1.000000e+00, 22, 2363, 3) + ((-4.840903e-01, -5.266809e+00, 2.689019e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.454144e-05, 1.000000e+00, 23, 2363, 1) + ((-8.178800e-01, -5.266475e+00, 2.525049e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.454656e-05, 1.000000e+00, 23, 2362, 1) + ((-1.151175e+00, -5.266142e+00, 2.361321e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.455166e-05, 1.000000e+00, 22, 2362, 3) + ((-1.266464e+00, -5.266027e+00, 2.304687e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.455343e-05, 1.000000e+00, 21, 2362, 2) + ((-2.005772e+00, -5.265288e+00, 1.941509e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.456475e-05, 1.000000e+00, 22, 2362, 3) + ((-2.121061e+00, -5.265173e+00, 1.884875e+00), (-8.975500e-01, 8.968076e-04, -4.409119e-01), 2.764929e+03, 4.456652e-05, 1.000000e+00, 23, 2362, 1) + ((-2.393759e+00, -5.264900e+00, 1.750915e+00), (-9.607392e-01, -1.749373e-01, 2.153533e-01), 1.619469e+03, 4.457070e-05, 1.000000e+00, 23, 2362, 1) + ((-2.453640e+00, -5.275804e+00, 1.764337e+00), (-9.607392e-01, -1.749373e-01, 2.153533e-01), 1.619469e+03, 4.457182e-05, 1.000000e+00, 23, 2361, 1) + ((-2.470658e+00, -5.278903e+00, 1.768152e+00), (-6.728606e-01, -2.916408e-01, -6.798561e-01), 4.873672e+02, 4.457214e-05, 1.000000e+00, 23, 2361, 1) + ((-3.463692e+00, -5.709318e+00, 7.647939e-01), (-2.249302e-01, -9.330150e-01, -2.808728e-01), 1.790901e+02, 4.462047e-05, 1.000000e+00, 23, 2361, 1) + ((-3.467511e+00, -5.725160e+00, 7.600247e-01), (-2.249302e-01, -9.330150e-01, -2.808728e-01), 1.790901e+02, 4.462139e-05, 1.000000e+00, 23, 2347, 1) + ((-3.533785e+00, -6.000066e+00, 6.772677e-01), (-2.249302e-01, -9.330150e-01, -2.808728e-01), 1.790901e+02, 4.463730e-05, 1.000000e+00, 22, 2347, 3) + ((-3.562245e+00, -6.118119e+00, 6.417291e-01), (-2.249302e-01, -9.330150e-01, -2.808728e-01), 1.790901e+02, 4.464414e-05, 1.000000e+00, 21, 2347, 2) + ((-3.723934e+00, -6.788806e+00, 4.398272e-01), (-2.249302e-01, -9.330150e-01, -2.808728e-01), 1.790901e+02, 4.468297e-05, 1.000000e+00, 22, 2347, 3) + ((-3.752394e+00, -6.906859e+00, 4.042885e-01), (-2.249302e-01, -9.330150e-01, -2.808728e-01), 1.790901e+02, 4.468981e-05, 1.000000e+00, 23, 2347, 1) + ((-3.848515e+00, -7.305571e+00, 2.842613e-01), (6.498448e-01, -3.243413e-01, -6.873896e-01), 2.328979e+01, 4.471290e-05, 1.000000e+00, 23, 2347, 1) + ((-3.737619e+00, -7.360920e+00, 1.669579e-01), (6.498448e-01, -3.243413e-01, -6.873896e-01), 2.328979e+01, 4.473846e-05, 1.000000e+00, 11, 1750, 1) + ((-3.574308e+00, -7.442429e+00, -5.788041e-03), (6.794505e-01, 3.157106e-01, -6.623246e-01), 1.590416e+01, 4.477611e-05, 1.000000e+00, 11, 1750, 1) + ((-3.398889e+00, -7.360920e+00, -1.767852e-01), (6.794505e-01, 3.157106e-01, -6.623246e-01), 1.590416e+01, 4.482292e-05, 1.000000e+00, 23, 2347, 1) + ((-2.904712e+00, -7.131298e+00, -6.585068e-01), (-4.836985e-02, -2.819627e-01, -9.582053e-01), 2.610202e+00, 4.495477e-05, 1.000000e+00, 23, 2347, 1) + ((-2.923579e+00, -7.241285e+00, -1.032280e+00), (-6.089807e-01, -2.347428e-01, -7.576532e-01), 1.671268e+00, 4.512933e-05, 1.000000e+00, 23, 2347, 1) + ((-3.012516e+00, -7.275567e+00, -1.142930e+00), (3.221931e-01, -5.406104e-01, -7.771306e-01), 1.275709e-01, 4.521100e-05, 1.000000e+00, 23, 2347, 1) + ((-2.984032e+00, -7.323360e+00, -1.211633e+00), (-8.629564e-01, -1.719529e-01, -4.751195e-01), 1.897424e-02, 4.538995e-05, 1.000000e+00, 23, 2347, 1) + ((-3.172528e+00, -7.360920e+00, -1.315413e+00), (-8.629564e-01, -1.719529e-01, -4.751195e-01), 1.897424e-02, 4.653641e-05, 1.000000e+00, 11, 1750, 1) + ((-3.602328e+00, -7.446562e+00, -1.552049e+00), (-1.530190e-01, -7.092235e-01, 6.881767e-01), 1.306951e-02, 4.915052e-05, 1.000000e+00, 11, 1750, 1) + ((-3.625236e+00, -7.552741e+00, -1.449021e+00), (-1.976867e-01, 2.826475e-01, 9.386322e-01), 2.145548e-02, 5.009730e-05, 1.000000e+00, 11, 1750, 1) + ((-3.636290e+00, -7.536936e+00, -1.396537e+00), (1.266676e-01, 2.265353e-01, -9.657314e-01), 1.815564e-02, 5.037329e-05, 1.000000e+00, 11, 1750, 1) + ((-3.621792e+00, -7.511008e+00, -1.507069e+00), (-4.275550e-01, 8.441443e-01, 3.234457e-01), 1.848049e-02, 5.098741e-05, 1.000000e+00, 11, 1750, 1) + ((-3.697811e+00, -7.360920e+00, -1.449560e+00), (-4.275550e-01, 8.441443e-01, 3.234457e-01), 1.848049e-02, 5.193300e-05, 1.000000e+00, 23, 2347, 1) + ((-3.703436e+00, -7.349814e+00, -1.445305e+00), (-7.832167e-01, 5.713670e-01, 2.451762e-01), 1.861705e-02, 5.200297e-05, 1.000000e+00, 23, 2347, 1) + ((-3.823243e+00, -7.262414e+00, -1.407801e+00), (-9.917106e-01, 5.069164e-02, 1.180695e-01), 4.703334e-02, 5.281350e-05, 1.000000e+00, 23, 2347, 1) + ((-4.089400e+00, -7.248809e+00, -1.376113e+00), (-9.917106e-01, 5.069164e-02, 1.180695e-01), 4.703334e-02, 5.370820e-05, 1.000000e+00, 23, 2346, 1) + ((-4.131081e+00, -7.246679e+00, -1.371151e+00), (9.108632e-01, -4.018526e-01, 9.403556e-02), 8.057393e-02, 5.384831e-05, 1.000000e+00, 23, 2346, 1) + ((-4.089400e+00, -7.265067e+00, -1.366848e+00), (9.108632e-01, -4.018526e-01, 9.403556e-02), 8.057393e-02, 5.396486e-05, 1.000000e+00, 23, 2347, 1) + ((-3.872134e+00, -7.360920e+00, -1.344418e+00), (9.108632e-01, -4.018526e-01, 9.403556e-02), 8.057393e-02, 5.457240e-05, 1.000000e+00, 11, 1750, 1) + ((-3.673062e+00, -7.448746e+00, -1.323866e+00), (2.976906e-01, 8.174443e-01, -4.931178e-01), 5.538060e-02, 5.512905e-05, 1.000000e+00, 11, 1750, 1) + ((-3.658580e+00, -7.408978e+00, -1.347855e+00), (-5.409120e-01, 8.345378e-01, -1.046943e-01), 8.122576e-02, 5.527851e-05, 1.000000e+00, 11, 1750, 1) + ((-3.682981e+00, -7.371331e+00, -1.352578e+00), (-5.409120e-01, 8.345378e-01, -1.046943e-01), 8.122576e-02, 5.539295e-05, 0.000000e+00, 11, 1750, 1)] diff --git a/tests/regression_tests/track_output/test.py b/tests/regression_tests/track_output/test.py index 299e1aa34..62526117d 100644 --- a/tests/regression_tests/track_output/test.py +++ b/tests/regression_tests/track_output/test.py @@ -1,6 +1,7 @@ import glob import os from pathlib import Path +from subprocess import call import numpy as np import openmc @@ -25,8 +26,8 @@ class TrackTestHarness(TestHarness): # For MPI mode, combine track files if config['mpi']: - track_files = list(glob.glob('tracks_p*.h5')) - openmc.Tracks.combine(track_files, 'tracks.h5') + call(['../../../scripts/openmc-track-combine', '-o', 'tracks.h5'] + + glob.glob('tracks_p*.h5')) # Get string of track file information outstr = '' diff --git a/tests/regression_tests/translation/results_true.dat b/tests/regression_tests/translation/results_true.dat index 6e03d2224..f832aa296 100644 --- a/tests/regression_tests/translation/results_true.dat +++ b/tests/regression_tests/translation/results_true.dat @@ -1,2 +1,2 @@ k-combined: -4.076610E-01 6.454244E-03 +4.087580E-01 4.466279E-03 diff --git a/tests/regression_tests/trigger_batch_interval/results_true.dat b/tests/regression_tests/trigger_batch_interval/results_true.dat index 92fa99d87..0571d6c4f 100644 --- a/tests/regression_tests/trigger_batch_interval/results_true.dat +++ b/tests/regression_tests/trigger_batch_interval/results_true.dat @@ -1,28 +1,28 @@ k-combined: -9.863217E-01 6.499354E-03 +9.767929E-01 5.327552E-03 tally 1: -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 tally 2: -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 diff --git a/tests/regression_tests/trigger_no_batch_interval/results_true.dat b/tests/regression_tests/trigger_no_batch_interval/results_true.dat index 92fa99d87..0571d6c4f 100644 --- a/tests/regression_tests/trigger_no_batch_interval/results_true.dat +++ b/tests/regression_tests/trigger_no_batch_interval/results_true.dat @@ -1,28 +1,28 @@ k-combined: -9.863217E-01 6.499354E-03 +9.767929E-01 5.327552E-03 tally 1: -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 tally 2: -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 diff --git a/tests/regression_tests/trigger_no_status/results_true.dat b/tests/regression_tests/trigger_no_status/results_true.dat index a62e1b3fe..fb6c0086a 100644 --- a/tests/regression_tests/trigger_no_status/results_true.dat +++ b/tests/regression_tests/trigger_no_status/results_true.dat @@ -1,28 +1,28 @@ k-combined: -9.858966E-01 1.500542E-02 +9.682315E-01 3.302924E-03 tally 1: -7.081828E+00 -1.003709E+01 -1.607382E+00 -5.171386E-01 -1.559242E+00 -4.866413E-01 -5.474447E+00 -5.997737E+00 -7.081828E+00 -1.003709E+01 -1.607382E+00 -5.171386E-01 -1.559242E+00 -4.866413E-01 -5.474447E+00 -5.997737E+00 +7.046510E+00 +9.932168E+00 +1.591675E+00 +5.067777E-01 +1.541572E+00 +4.753743E-01 +5.454835E+00 +5.951990E+00 +7.046510E+00 +9.932168E+00 +1.591675E+00 +5.067777E-01 +1.541572E+00 +4.753743E-01 +5.454835E+00 +5.951990E+00 tally 2: -7.081828E+00 -1.003709E+01 -1.607382E+00 -5.171386E-01 -1.559242E+00 -4.866413E-01 -5.474447E+00 -5.997737E+00 +7.046510E+00 +9.932168E+00 +1.591675E+00 +5.067777E-01 +1.541572E+00 +4.753743E-01 +5.454835E+00 +5.951990E+00 diff --git a/tests/regression_tests/trigger_statepoint_restart/inputs_true.dat b/tests/regression_tests/trigger_statepoint_restart/inputs_true.dat index 59a829700..6f0b629eb 100644 --- a/tests/regression_tests/trigger_statepoint_restart/inputs_true.dat +++ b/tests/regression_tests/trigger_statepoint_restart/inputs_true.dat @@ -1,14 +1,14 @@ - - - + + + - + eigenvalue @@ -16,7 +16,7 @@ 15 10 - 0.002 + 0.003 std_dev diff --git a/tests/regression_tests/trigger_statepoint_restart/results_true.dat b/tests/regression_tests/trigger_statepoint_restart/results_true.dat index 3cb1e230d..3e6619d74 100644 --- a/tests/regression_tests/trigger_statepoint_restart/results_true.dat +++ b/tests/regression_tests/trigger_statepoint_restart/results_true.dat @@ -1,5 +1,5 @@ k-combined: -2.948661E-01 1.949846E-03 +3.014717E-01 2.864764E-03 tally 1: -5.515170E+01 -4.349007E+02 +8.946107E+01 +7.281263E+02 diff --git a/tests/regression_tests/trigger_statepoint_restart/test.py b/tests/regression_tests/trigger_statepoint_restart/test.py index b242f7f1c..8144c1d0b 100644 --- a/tests/regression_tests/trigger_statepoint_restart/test.py +++ b/tests/regression_tests/trigger_statepoint_restart/test.py @@ -29,7 +29,7 @@ def model(): settings.inactive = 10 settings.particles = 400 # Choose a sufficiently low threshold to enable use of trigger - settings.keff_trigger = {'type': 'std_dev', 'threshold': 0.002} + settings.keff_trigger = {'type': 'std_dev', 'threshold': 0.003} settings.trigger_max_batches = 1000 settings.trigger_batch_interval = 1 settings.trigger_active = True @@ -41,10 +41,10 @@ def model(): tallies = openmc.Tallies([t]) # Put it all together - model = openmc.Model(materials=materials, - geometry=geometry, - settings=settings, - tallies=tallies) + model = openmc.model.Model(materials=materials, + geometry=geometry, + settings=settings, + tallies=tallies) return model diff --git a/tests/regression_tests/trigger_tallies/results_true.dat b/tests/regression_tests/trigger_tallies/results_true.dat index 92fa99d87..0571d6c4f 100644 --- a/tests/regression_tests/trigger_tallies/results_true.dat +++ b/tests/regression_tests/trigger_tallies/results_true.dat @@ -1,28 +1,28 @@ k-combined: -9.863217E-01 6.499354E-03 +9.767929E-01 5.327552E-03 tally 1: -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 tally 2: -1.423436E+01 -2.027258E+01 -3.223740E+00 -1.039872E+00 -3.125016E+00 -9.771709E-01 -1.101062E+01 -1.212977E+01 +1.405471E+01 +1.976444E+01 +3.186139E+00 +1.015515E+00 +3.088643E+00 +9.542994E-01 +1.086857E+01 +1.182011E+01 diff --git a/tests/regression_tests/triso/inputs_true.dat b/tests/regression_tests/triso/inputs_true.dat index c96684568..37f37af78 100644 --- a/tests/regression_tests/triso/inputs_true.dat +++ b/tests/regression_tests/triso/inputs_true.dat @@ -1,38 +1,38 @@ - - - - - - + + + + + + - - + + - - + + - - - - - + + + + + - - + + - - + + @@ -42,171 +42,171 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -253,187 +253,187 @@ 24 25 26 21 22 23 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + eigenvalue 100 4 0 - + 0.0 0.0 0.0 diff --git a/tests/regression_tests/triso/results_true.dat b/tests/regression_tests/triso/results_true.dat index d9850e410..fa1842e54 100644 --- a/tests/regression_tests/triso/results_true.dat +++ b/tests/regression_tests/triso/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.604832E+00 2.031393E-03 +1.716873E+00 5.266107E-02 diff --git a/tests/regression_tests/uniform_fs/results_true.dat b/tests/regression_tests/uniform_fs/results_true.dat index f7ceecfb7..46654b49b 100644 --- a/tests/regression_tests/uniform_fs/results_true.dat +++ b/tests/regression_tests/uniform_fs/results_true.dat @@ -1,2 +1,2 @@ k-combined: -3.675645E-01 4.342970E-03 +3.685309E-01 1.861720E-03 diff --git a/tests/regression_tests/universe/results_true.dat b/tests/regression_tests/universe/results_true.dat index 97b997ae6..bbf03de94 100644 --- a/tests/regression_tests/universe/results_true.dat +++ b/tests/regression_tests/universe/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.940336E-01 7.338463E-04 +3.070134E-01 3.900396E-03 diff --git a/tests/regression_tests/unstructured_mesh/inputs_true.dat b/tests/regression_tests/unstructured_mesh/inputs_true.dat index e7a485b4d..07486d3e0 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_hexes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true0.dat b/tests/regression_tests/unstructured_mesh/inputs_true0.dat index 2508c25b3..c6b28d890 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true0.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true0.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets_w_holes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true1.dat b/tests/regression_tests/unstructured_mesh/inputs_true1.dat index 04bbdb4b2..40183c89b 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true1.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true1.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true10.dat b/tests/regression_tests/unstructured_mesh/inputs_true10.dat index 169f0a6b4..81dfbdc52 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true10.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true10.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets_w_holes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true11.dat b/tests/regression_tests/unstructured_mesh/inputs_true11.dat index 8163750ca..b224a3ebc 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true11.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true11.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true12.dat b/tests/regression_tests/unstructured_mesh/inputs_true12.dat index be0655e98..a18aee627 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true12.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true12.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets_w_holes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true13.dat b/tests/regression_tests/unstructured_mesh/inputs_true13.dat index 42c0cc122..0e9123c90 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true13.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true13.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true14.dat b/tests/regression_tests/unstructured_mesh/inputs_true14.dat index a27c7445d..9d4db4904 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true14.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true14.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets_w_holes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true15.dat b/tests/regression_tests/unstructured_mesh/inputs_true15.dat index c69bd15d0..eab97b952 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true15.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true15.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true2.dat b/tests/regression_tests/unstructured_mesh/inputs_true2.dat index ba9d477b5..3521ac7b8 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true2.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true2.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets_w_holes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true3.dat b/tests/regression_tests/unstructured_mesh/inputs_true3.dat index d840bfa09..a376b401d 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true3.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true3.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true4.dat b/tests/regression_tests/unstructured_mesh/inputs_true4.dat index db8e37177..843632fdd 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true4.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true4.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source - 1000 + 100 10 - - - + + + 1.0 1.0 @@ -56,33 +56,34 @@ 0.0 1.0 + 15000000.0 1.0 - + 10 10 10 -10.0 -10.0 -10.0 10.0 10.0 10.0 - - test_mesh_tets_w_holes.e + + test_mesh_tets_w_holes.exo - - 1 + + 9 - - 2 + + 10 - - 1 + + 9 flux tracklength - - 2 + + 10 flux tracklength diff --git a/tests/regression_tests/unstructured_mesh/inputs_true5.dat b/tests/regression_tests/unstructured_mesh/inputs_true5.dat index b2bbc7e16..dc9129d98 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true5.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true5.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source - 1000 + 100 10 - - - + + + 1.0 1.0 @@ -56,33 +56,34 @@ 0.0 1.0 + 15000000.0 1.0 - + 10 10 10 -10.0 -10.0 -10.0 10.0 10.0 10.0 - - test_mesh_tets.e + + test_mesh_tets.exo - - 1 + + 11 - - 2 + + 12 - - 1 + + 11 flux tracklength - - 2 + + 12 flux tracklength diff --git a/tests/regression_tests/unstructured_mesh/inputs_true6.dat b/tests/regression_tests/unstructured_mesh/inputs_true6.dat index d6ad0d98d..82bc30703 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true6.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true6.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source - 1000 + 100 10 - - - + + + 1.0 1.0 @@ -56,33 +56,34 @@ 0.0 1.0 + 15000000.0 1.0 - + 10 10 10 -10.0 -10.0 -10.0 10.0 10.0 10.0 - - test_mesh_tets_w_holes.e + + test_mesh_tets_w_holes.exo - - 1 + + 13 - - 2 + + 14 - - 1 + + 13 flux tracklength - - 2 + + 14 flux tracklength diff --git a/tests/regression_tests/unstructured_mesh/inputs_true7.dat b/tests/regression_tests/unstructured_mesh/inputs_true7.dat index 924790a8c..b982c40d0 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true7.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true7.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source - 1000 + 100 10 - - - + + + 1.0 1.0 @@ -56,33 +56,34 @@ 0.0 1.0 + 15000000.0 1.0 - + 10 10 10 -10.0 -10.0 -10.0 10.0 10.0 10.0 - - test_mesh_tets.e + + test_mesh_tets.exo - - 1 + + 15 - - 2 + + 16 - - 1 + + 15 flux tracklength - - 2 + + 16 flux tracklength diff --git a/tests/regression_tests/unstructured_mesh/inputs_true8.dat b/tests/regression_tests/unstructured_mesh/inputs_true8.dat index c04beb211..7994e1add 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true8.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true8.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets_w_holes.e diff --git a/tests/regression_tests/unstructured_mesh/inputs_true9.dat b/tests/regression_tests/unstructured_mesh/inputs_true9.dat index 111898ff2..4fff123d7 100644 --- a/tests/regression_tests/unstructured_mesh/inputs_true9.dat +++ b/tests/regression_tests/unstructured_mesh/inputs_true9.dat @@ -1,54 +1,54 @@ - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + fixed source 1000 10 - - - + + + 1.0 1.0 @@ -67,7 +67,7 @@ -10.0 -10.0 -10.0 10.0 10.0 10.0 - + test_mesh_tets.e diff --git a/tests/regression_tests/unstructured_mesh/test.py b/tests/regression_tests/unstructured_mesh/test.py index 7607531d8..0082198dd 100644 --- a/tests/regression_tests/unstructured_mesh/test.py +++ b/tests/regression_tests/unstructured_mesh/test.py @@ -256,7 +256,7 @@ for i, (lib, estimator, ext_geom, holes) in enumerate(product(*param_values)): def test_unstructured_mesh_tets(model, test_opts): # skip the test if the library is not enabled if test_opts['library'] == 'moab' and not openmc.lib._dagmc_enabled(): - pytest.skip("DAGMC (and MOAB) mesh not enabled in this build.") + pytest.skip("DAGMC (and MOAB) mesh not enbaled in this build.") if test_opts['library'] == 'libmesh' and not openmc.lib._libmesh_enabled(): pytest.skip("LibMesh is not enabled in this build.") diff --git a/tests/regression_tests/unstructured_mesh/test_mesh_dagmc_tets.vtk b/tests/regression_tests/unstructured_mesh/test_mesh_dagmc_tets.vtk deleted file mode 100644 index 2ddd228cf..000000000 --- a/tests/regression_tests/unstructured_mesh/test_mesh_dagmc_tets.vtk +++ /dev/null @@ -1,159 +0,0 @@ -# vtk DataFile Version 2.0 -made_with_cad_to_dagmc_package, Created by Gmsh 4.12.1 -ASCII -DATASET UNSTRUCTURED_GRID -POINTS 14 double --0.5 -0.5 0.5 --0.5 -0.5 -0.5 --0.5 0.5 0.5 --0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 --0.5 0 0 -0.5 0 0 -0 -0.5 0 -0 0.5 0 -0 0 -0.5 -0 0 0.5 - -CELLS 68 268 -1 0 -1 1 -1 2 -1 3 -1 4 -1 5 -1 6 -1 7 -2 1 0 -2 0 2 -2 3 2 -2 1 3 -2 5 4 -2 4 6 -2 7 6 -2 5 7 -2 1 5 -2 0 4 -2 3 7 -2 2 6 -3 1 0 8 -3 0 2 8 -3 3 1 8 -3 2 3 8 -3 5 9 4 -3 4 9 6 -3 7 9 5 -3 6 9 7 -3 0 1 10 -3 4 0 10 -3 1 5 10 -3 5 4 10 -3 2 11 3 -3 6 11 2 -3 3 11 7 -3 7 11 6 -3 1 3 12 -3 5 1 12 -3 3 7 12 -3 7 5 12 -3 0 13 2 -3 4 13 0 -3 2 13 6 -3 6 13 4 -4 13 8 12 10 -4 11 8 12 13 -4 12 11 13 9 -4 10 12 13 9 -4 12 3 11 7 -4 13 2 8 0 -4 8 12 1 3 -4 11 3 8 2 -4 10 8 1 0 -4 0 10 13 4 -4 1 12 10 5 -4 11 2 13 6 -4 4 9 13 6 -4 6 9 11 7 -4 10 9 4 5 -4 7 9 12 5 -4 3 8 12 11 -4 1 12 8 10 -4 8 11 2 13 -4 10 13 8 0 -4 13 10 9 4 -4 11 13 9 6 -4 12 11 9 7 -4 9 10 12 5 - -CELL_TYPES 68 -1 -1 -1 -1 -1 -1 -1 -1 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 diff --git a/tests/regression_tests/void/inputs_true.dat b/tests/regression_tests/void/inputs_true.dat index cd2d14206..7fee0779e 100644 --- a/tests/regression_tests/void/inputs_true.dat +++ b/tests/regression_tests/void/inputs_true.dat @@ -2,8 +2,8 @@ - - + + @@ -58,62 +58,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fixed source 1000 3 - + 0.0 0.0 0.0 diff --git a/tests/regression_tests/volume_calc/inputs_true.dat b/tests/regression_tests/volume_calc/inputs_true.dat index ed7024c57..e3a8162e3 100644 --- a/tests/regression_tests/volume_calc/inputs_true.dat +++ b/tests/regression_tests/volume_calc/inputs_true.dat @@ -2,27 +2,27 @@ - - - - + + + + - - - - + + + + - - - - - + + + + + volume @@ -53,7 +53,7 @@ 100 -1.0 -1.0 -6.0 1.0 1.0 6.0 - + material @@ -61,7 +61,7 @@ 100 -1.0 -1.0 -6.0 1.0 1.0 6.0 - + cell @@ -69,7 +69,7 @@ 100 -1.0 -1.0 -6.0 1.0 1.0 6.0 - + diff --git a/tests/regression_tests/volume_calc/inputs_true_mg.dat b/tests/regression_tests/volume_calc/inputs_true_mg.dat index 127566084..2ace5cd3c 100644 --- a/tests/regression_tests/volume_calc/inputs_true_mg.dat +++ b/tests/regression_tests/volume_calc/inputs_true_mg.dat @@ -3,26 +3,26 @@ mg_lib.h5 - - - - + + + + - - - - + + + + - - - - - + + + + + volume @@ -54,7 +54,7 @@ 100 -1.0 -1.0 -6.0 1.0 1.0 6.0 - + material @@ -62,7 +62,7 @@ 100 -1.0 -1.0 -6.0 1.0 1.0 6.0 - + cell @@ -70,7 +70,7 @@ 100 -1.0 -1.0 -6.0 1.0 1.0 6.0 - + diff --git a/tests/regression_tests/weightwindows/generators/test.py b/tests/regression_tests/weightwindows/generators/test.py index 4dc0ab80d..d6a40b44f 100644 --- a/tests/regression_tests/weightwindows/generators/test.py +++ b/tests/regression_tests/weightwindows/generators/test.py @@ -46,14 +46,14 @@ def test_ww_generator(run_in_tmpdir): # just test that the generation happens successfully here assert os.path.exists('weight_windows.h5') - wws_mean = openmc.WeightWindowsList.from_hdf5() + wws_mean = openmc.hdf5_to_wws() assert len(wws_mean) == 1 # check that generation using the relative error works too wwg.update_parameters['value'] = 'rel_err' model.run() - wws_rel_err = openmc.WeightWindowsList.from_hdf5() + wws_rel_err = openmc.hdf5_to_wws() assert len(wws_rel_err) == 1 # we should not get the same set of weight windows when switching to use of diff --git a/tests/regression_tests/weightwindows/inputs_true.dat b/tests/regression_tests/weightwindows/inputs_true.dat new file mode 100644 index 000000000..dcc41ae84 --- /dev/null +++ b/tests/regression_tests/weightwindows/inputs_true.dat @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fixed source + 200 + 2 + + + 0.001 0.001 0.001 + + + 14000000.0 1.0 + + + true + + 2 + neutron + 0.0 0.5 20000000.0 + -1.0 0.007673145137236567 6.542700644645627e-07 0.0017541380096893788 0.0007245451610090619 7.476545089278482e-06 2.253382683081525e-06 2.1040609012865134e-05 0.08285899874014539 -1.0 1.0262431550731535e-13 3.3164825349503764e-16 0.0064803314120165335 3.5981031766416143e-06 -1.0 1.6205064883026195e-11 1.7770136411255912e-05 0.0001670700632870335 4.323138781337963e-05 -1.0 -1.0 6.922231352729155e-05 0.06550426960512012 -1.0 2.5639656866250453e-06 1.4508262073256659e-13 -1.0 -1.0 0.0009127050763987511 3.8523247550378815e-12 -1.0 0.0008175033526488423 -1.0 0.015148978428271613 2.5157355790201773e-07 2.1612150425221703e-06 1.3181562352445092e-10 2.9282097947816224e-05 2.762955748645507e-05 2.936268747135548e-14 1.6859219614058024e-19 3.937160538176268e-07 2.6011787393916806e-06 0.001570829313580841 -1.0 1.7041669224797384e-09 1.6421491993751715e-11 0.4899999304038166 6.948292975998466e-07 -1.0 -1.0 0.08657573566388353 0.006639379668946672 1.681305446488884e-11 2.2487617828938326e-05 4.109066205029878e-05 0.08288806458368345 -1.0 0.007385384405891666 -1.0 -1.0 1.008394964750947e-06 6.655926357459275e-08 0.0016279794552427574 1.4825219199133353e-12 -1.0 1.93847081892941e-05 1.284759166582202e-05 5.1161740516205715e-05 2.5447281241730366e-07 3.853097455417877e-06 -1.0 8.887234042637684e-05 0.01621821782442112 -1.0 1.8747824667478637e-14 5.97653814110781e-06 -1.0 -1.0 1.2296747260635405e-06 -1.0 -1.0 7.754700849337902e-06 7.091263906557291e-05 3.2799045883372075e-06 0.00020573181450240786 5.6949597066784976e-05 1.271128669411295e-07 0.0010019432401508087 -1.0 -1.0 6.848642863465585e-07 5.783974359937857e-06 2.380955631371226e-06 4.756872959630257e-05 2.1360401784344975e-18 0.00046029617115127556 1.0092905083158804e-11 0.08095280568305474 3.89841667138598e-08 4.354946981329799e-05 -1.0 0.5 0.0015447823995470042 -1.0 -1.0 0.001959411999677113 0.48573842213878143 -1.0 7.962899789920809e-06 5.619835883512353e-14 0.0835648710074336 2.7207433165796702e-11 0.00027464244062887683 4.076762579823379e-17 2.124999182004655e-05 8.037131813528501e-07 8.846493399850663e-06 1.080711295768551e-05 -1.0 -1.0 0.0010737081832502356 2.679340942769232e-06 2.1648918040467363e-05 0.0002668579837809081 1.3455341306162382e-05 2.5629068330446215e-05 1.3228013765525015e-05 -1.0 -1.0 7.002861620919232e-08 1.5172912057312398e-14 -1.0 7.989579285134734e-06 2.639268952045579e-10 -1.0 0.013330619853379314 0.00021534568699157805 2.4469456008493614e-09 8.211982683649991e-09 1.951356547084204e-15 0.00016419031150495913 5.985108617124989e-06 1.28584557092134e-05 1.5476769237571295e-14 5.5379154134462336e-08 0.0016637126543321873 2.499931357628383e-07 8.020767115181574e-07 2.7697233171399416e-13 -1.0 0.007197662162700777 -1.0 0.0833931797381589 2.8226276944532696e-05 3.353295403842037e-05 5.504813693036933e-12 0.007136750029575816 0.08636569925236791 -1.0 -1.0 6.315154082213375e-07 0.4877856021170283 -1.0 3.7051518220083886e-06 -1.0 0.0017950613169359904 7.84289689494925e-06 9.041149893307806e-07 -1.0 8.48176145671274e-10 9.03108551826469e-05 3.634644995026692e-05 2.0295213621716706e-09 1.0305672698745657e-11 1.5550455959178486e-06 0.01664109232689093 8.533030345699353e-17 0.0009252532821720597 -1.0 7.695031155172816e-14 0.0007151459162818186 -1.0 -1.0 5.182269672663266e-10 3.0160758454323657e-07 -1.0 0.06539005235506369 3.452537179033895e-05 -1.0 -1.0 3.855884234344845e-06 0.00017699858357744463 2.594951085377588e-06 1.1333627604823673e-09 -1.0 2.4306375693722205e-06 0.0063790654507599135 2.2060992580622125e-11 -1.0 -1.0 0.0848872967381878 3.932389299316285e-06 1.2911827198500372e-08 1.957092814065688e-05 0.0007213722022489493 0.0018327593437608 1.6699254277734109e-06 0.007188410694198128 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 + -10.0 0.07673145137236567 6.5427006446456266e-06 0.017541380096893787 0.0072454516100906195 7.476545089278483e-05 2.253382683081525e-05 0.00021040609012865135 0.828589987401454 -10.0 1.0262431550731535e-12 3.3164825349503764e-15 0.06480331412016534 3.5981031766416144e-05 -10.0 1.6205064883026195e-10 0.0001777013641125591 0.001670700632870335 0.0004323138781337963 -10.0 -10.0 0.0006922231352729155 0.6550426960512012 -10.0 2.5639656866250452e-05 1.4508262073256658e-12 -10.0 -10.0 0.009127050763987512 3.852324755037882e-11 -10.0 0.008175033526488424 -10.0 0.15148978428271614 2.515735579020177e-06 2.1612150425221703e-05 1.3181562352445092e-09 0.00029282097947816227 0.0002762955748645507 2.9362687471355483e-13 1.6859219614058023e-18 3.937160538176268e-06 2.6011787393916804e-05 0.015708293135808408 -10.0 1.7041669224797384e-08 1.6421491993751715e-10 4.899999304038166 6.948292975998466e-06 -10.0 -10.0 0.8657573566388354 0.06639379668946672 1.681305446488884e-10 0.00022487617828938325 0.0004109066205029878 0.8288806458368345 -10.0 0.07385384405891665 -10.0 -10.0 1.0083949647509469e-05 6.655926357459275e-07 0.016279794552427576 1.4825219199133352e-11 -10.0 0.000193847081892941 0.0001284759166582202 0.0005116174051620571 2.5447281241730365e-06 3.853097455417877e-05 -10.0 0.0008887234042637684 0.16218217824421122 -10.0 1.8747824667478637e-13 5.97653814110781e-05 -10.0 -10.0 1.2296747260635405e-05 -10.0 -10.0 7.754700849337902e-05 0.0007091263906557291 3.2799045883372076e-05 0.0020573181450240785 0.0005694959706678497 1.271128669411295e-06 0.010019432401508087 -10.0 -10.0 6.848642863465585e-06 5.7839743599378564e-05 2.380955631371226e-05 0.0004756872959630257 2.1360401784344976e-17 0.004602961711512756 1.0092905083158804e-10 0.8095280568305474 3.89841667138598e-07 0.00043549469813297995 -10.0 5.0 0.015447823995470043 -10.0 -10.0 0.01959411999677113 4.8573842213878144 -10.0 7.96289978992081e-05 5.619835883512353e-13 0.8356487100743359 2.7207433165796704e-10 0.002746424406288768 4.076762579823379e-16 0.00021249991820046548 8.037131813528501e-06 8.846493399850663e-05 0.0001080711295768551 -10.0 -10.0 0.010737081832502356 2.679340942769232e-05 0.00021648918040467362 0.0026685798378090807 0.00013455341306162382 0.00025629068330446217 0.00013228013765525016 -10.0 -10.0 7.002861620919232e-07 1.51729120573124e-13 -10.0 7.989579285134734e-05 2.639268952045579e-09 -10.0 0.13330619853379314 0.0021534568699157807 2.4469456008493615e-08 8.211982683649991e-08 1.951356547084204e-14 0.0016419031150495913 5.985108617124989e-05 0.000128584557092134 1.5476769237571296e-13 5.537915413446234e-07 0.016637126543321872 2.499931357628383e-06 8.020767115181574e-06 2.7697233171399415e-12 -10.0 0.07197662162700777 -10.0 0.8339317973815891 0.000282262769445327 0.00033532954038420373 5.504813693036933e-11 0.07136750029575815 0.8636569925236791 -10.0 -10.0 6.3151540822133754e-06 4.877856021170283 -10.0 3.7051518220083885e-05 -10.0 0.017950613169359905 7.84289689494925e-05 9.041149893307805e-06 -10.0 8.48176145671274e-09 0.000903108551826469 0.0003634644995026692 2.0295213621716707e-08 1.0305672698745658e-10 1.5550455959178486e-05 0.1664109232689093 8.533030345699353e-16 0.009252532821720597 -10.0 7.695031155172816e-13 0.007151459162818186 -10.0 -10.0 5.182269672663266e-09 3.0160758454323656e-06 -10.0 0.6539005235506369 0.0003452537179033895 -10.0 -10.0 3.855884234344845e-05 0.0017699858357744464 2.594951085377588e-05 1.1333627604823672e-08 -10.0 2.4306375693722206e-05 0.06379065450759913 2.2060992580622125e-10 -10.0 -10.0 0.848872967381878 3.9323892993162844e-05 1.2911827198500372e-07 0.0001957092814065688 0.0072137220224894934 0.018327593437608 1.669925427773411e-05 0.07188410694198127 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 + 3 + 1.5 + 10 + 1e-38 + + + 5 6 7 + -240 -240 -240 + 240 240 240 + + + 2 + neutron + 0.0 0.5 20000000.0 + -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.06827568359008944 0.00017329528628152923 0.018541112907970003 0.011113024641218336 8.76041935303527e-05 8.168081568291806e-05 0.00046693784586018913 0.4952432605379829 2.2512327083641865e-10 4.6258592060517866e-07 2.7044817176109556e-05 0.054902816619122045 0.00014126153603265097 8.304845400451923e-08 2.2950716170641463e-05 0.0001335621430311088 0.003432919201293737 0.0005197081842709918 5.726152701849347e-16 -1.0 0.0013332554437480327 0.4346984808472855 7.691527781829036e-17 0.00011042047857307253 3.0571050855707084e-06 -1.0 4.986698316296507e-06 0.011128424196387618 1.3106335518133802e-05 5.447493368067179e-10 0.011440381012864086 4.670673837764874e-08 0.12364069326350118 0.00012558879474108074 3.136829920007009e-05 2.34750482787598e-05 0.001537590300149361 0.0017693279949094218 6.717625881826167e-05 4.587143797469485e-08 2.6211239246796104e-05 0.00030002326388383244 0.01729816946709781 4.5757238372058234e-11 6.92296299242814e-05 3.792209399652396e-06 -1.0 9.256616392487858e-05 8.541606727879512e-07 -1.0 0.49317081643076643 0.05500108683629957 1.298062961617927e-05 0.0006870228272606287 0.0008231482263927564 0.5 3.419181071650816e-06 0.06433819434431046 6.574706543646946e-16 4.0404626147344e-13 0.0003782322077390033 0.00012637534695610975 0.017602971074583987 1.0044390728858277e-05 -1.0 0.0008787411098754915 0.00023686818807101741 0.0009304497896205121 6.949587369646497e-05 0.00012918433677593975 2.0707648529746894e-06 0.0023295401596005313 0.11819165666519223 -1.0 2.1606550732170693e-05 0.00022057970761624768 -1.0 1.0325207105027347e-08 0.0002029396545382813 2.1234980618763222e-13 -1.0 0.00024175998138228048 0.001178616843705956 0.0001399807456616496 0.0038811025614225057 0.0011076796092102186 0.00010814452764860558 0.010955637485319249 -1.0 9.382800796426366e-17 5.098747893974248e-05 0.00027052054298385255 0.00021305826462238593 0.000808100901275472 4.233410073487772e-06 0.0051513292132259495 8.616027294555462e-07 0.4873897581604287 2.9093345975075226e-05 0.000469589568463265 -1.0 -1.0 0.017802624844035688 1.3116807133030035e-15 2.617878055106949e-16 0.01884234453311008 -1.0 2.027381220364608e-16 0.0004299195570308035 1.4628847959717225e-05 0.4899952354672477 2.774067049392004e-07 0.004441328419270369 4.279460329782799e-09 0.0012297303081805393 0.0002792896409558745 0.0006934466049804711 8.370896020975689e-05 3.8270536025799805e-15 -1.0 0.01208261392046878 0.0001497958445994315 0.0015016500045374082 0.005384625561469684 0.00025519632243117644 0.0011028020390507682 0.0002362355168421952 -1.0 -1.0 8.862760180332873e-05 1.3806577785135177e-06 -1.0 0.0001319677450153934 2.6866894852481906e-05 -1.0 0.11510120013926417 0.002672923773363389 1.2257360246712472e-05 8.544159282151438e-05 2.777791741571174e-05 0.0014957033281168012 0.0003257646134837451 0.0008919466185572302 1.2907171695294846e-13 4.6842350882367666e-05 0.01721806295736377 0.00025106741008066317 0.00022234471595443313 2.101790478097517e-09 5.752120832330886e-11 0.06428782790571179 3.2478301680021854e-08 0.4903495510314233 0.001146714816952061 0.0004777967757842694 1.0882011018684852e-06 0.05708498338352203 0.4981497862127628 -1.0 3.2790914744011534e-06 0.00010077009726691265 -1.0 2.210707325798542e-07 4.3166052799897375e-05 -1.0 0.01825795827020865 0.0003182108781955478 3.8561696337086434e-05 1.0995322456277382e-06 9.53380658669839e-06 0.001550036616828061 0.0012648333883989995 5.272021975060514e-06 1.9257248009114363e-05 0.00016757997590048827 0.11891251244906934 5.515522196186723e-06 0.01102706140784316 9.904481358675478e-13 3.520674728719278e-05 0.011294708566804167 7.239087311622819e-08 -1.0 3.5740607788414942e-06 0.00035983547999740665 1.0588257623722672e-07 0.42372713683725016 0.0011273340972061078 8.582011716859219e-15 1.1514579117272292e-10 0.00043130977711323417 0.0027847329307350423 0.00017287873387910357 6.401055165502384e-06 1.722191123879782e-08 0.00020848309220162036 0.05639071613735579 1.8064550990294753e-05 1.289814511028015e-06 1.078687446476881e-14 0.4897735047310072 0.0002981891705231209 0.00016079768514218546 9.332371598523186e-05 0.011724714376848187 0.019040707071165303 0.00014242053195529864 0.06684484191345574 -1.0 + -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.6827568359008944 0.0017329528628152924 0.18541112907970003 0.11113024641218336 0.0008760419353035269 0.0008168081568291806 0.004669378458601891 4.952432605379829 2.2512327083641864e-09 4.625859206051786e-06 0.00027044817176109554 0.5490281661912204 0.0014126153603265096 8.304845400451923e-07 0.00022950716170641464 0.001335621430311088 0.03432919201293737 0.0051970818427099184 5.726152701849347e-15 -10.0 0.013332554437480326 4.346984808472855 7.6915277818290365e-16 0.0011042047857307254 3.0571050855707086e-05 -10.0 4.986698316296507e-05 0.11128424196387618 0.000131063355181338 5.447493368067179e-09 0.11440381012864086 4.670673837764874e-07 1.2364069326350118 0.0012558879474108074 0.0003136829920007009 0.000234750482787598 0.01537590300149361 0.01769327994909422 0.0006717625881826168 4.587143797469485e-07 0.000262112392467961 0.0030002326388383245 0.1729816946709781 4.5757238372058235e-10 0.0006922962992428139 3.792209399652396e-05 -10.0 0.0009256616392487858 8.541606727879512e-06 -10.0 4.931708164307665 0.5500108683629957 0.00012980629616179268 0.006870228272606287 0.008231482263927564 5.0 3.419181071650816e-05 0.6433819434431045 6.574706543646946e-15 4.0404626147344005e-12 0.003782322077390033 0.0012637534695610975 0.17602971074583987 0.00010044390728858278 -10.0 0.008787411098754914 0.002368681880710174 0.00930449789620512 0.0006949587369646498 0.0012918433677593976 2.0707648529746893e-05 0.023295401596005315 1.1819165666519222 -10.0 0.00021606550732170693 0.0022057970761624767 -10.0 1.0325207105027347e-07 0.0020293965453828133 2.123498061876322e-12 -10.0 0.0024175998138228046 0.01178616843705956 0.0013998074566164962 0.03881102561422506 0.011076796092102187 0.0010814452764860557 0.10955637485319249 -10.0 9.382800796426367e-16 0.0005098747893974248 0.0027052054298385255 0.0021305826462238594 0.00808100901275472 4.233410073487772e-05 0.0515132921322595 8.61602729455546e-06 4.873897581604287 0.0002909334597507523 0.0046958956846326495 -10.0 -10.0 0.1780262484403569 1.3116807133030034e-14 2.6178780551069492e-15 0.1884234453311008 -10.0 2.027381220364608e-15 0.004299195570308035 0.00014628847959717226 4.899952354672477 2.774067049392004e-06 0.04441328419270369 4.279460329782799e-08 0.012297303081805393 0.002792896409558745 0.006934466049804711 0.0008370896020975689 3.8270536025799805e-14 -10.0 0.1208261392046878 0.001497958445994315 0.015016500045374082 0.05384625561469684 0.0025519632243117644 0.011028020390507681 0.002362355168421952 -10.0 -10.0 0.0008862760180332873 1.3806577785135176e-05 -10.0 0.001319677450153934 0.00026866894852481903 -10.0 1.1510120013926417 0.026729237733633893 0.00012257360246712473 0.0008544159282151438 0.0002777791741571174 0.014957033281168012 0.0032576461348374514 0.008919466185572301 1.2907171695294846e-12 0.00046842350882367664 0.17218062957363772 0.0025106741008066318 0.0022234471595443312 2.101790478097517e-08 5.752120832330886e-10 0.6428782790571179 3.2478301680021856e-07 4.903495510314233 0.01146714816952061 0.004777967757842694 1.0882011018684853e-05 0.5708498338352204 4.981497862127628 -10.0 3.279091474401153e-05 0.0010077009726691265 -10.0 2.210707325798542e-06 0.00043166052799897375 -10.0 0.1825795827020865 0.0031821087819554777 0.00038561696337086434 1.0995322456277382e-05 9.53380658669839e-05 0.01550036616828061 0.012648333883989995 5.272021975060514e-05 0.00019257248009114364 0.0016757997590048828 1.1891251244906933 5.515522196186723e-05 0.1102706140784316 9.904481358675478e-12 0.0003520674728719278 0.11294708566804167 7.239087311622819e-07 -10.0 3.574060778841494e-05 0.0035983547999740664 1.0588257623722672e-06 4.237271368372502 0.011273340972061077 8.582011716859219e-14 1.151457911727229e-09 0.004313097771132342 0.027847329307350423 0.0017287873387910357 6.401055165502385e-05 1.722191123879782e-07 0.0020848309220162036 0.5639071613735579 0.00018064550990294753 1.289814511028015e-05 1.078687446476881e-13 4.897735047310072 0.002981891705231209 0.0016079768514218546 0.0009332371598523186 0.11724714376848187 0.19040707071165303 0.0014242053195529865 0.6684484191345574 -10.0 + 3 + 1.5 + 10 + 1e-38 + + 200 + + + + 5 10 15 + -240 -240 -240 + 240 240 240 + + + 1 + + + 0.0 0.5 20000000.0 + + + neutron photon + + + 1 2 3 + flux + + + diff --git a/tests/regression_tests/weightwindows/local/inputs_true.dat b/tests/regression_tests/weightwindows/local/inputs_true.dat deleted file mode 100644 index 57dc42ca4..000000000 --- a/tests/regression_tests/weightwindows/local/inputs_true.dat +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - fixed source - 500 - 2 - - - 0.001 0.001 0.001 - - - 14000000.0 1.0 - - - true - - 2 - neutron - 0.0 0.5 20000000.0 - -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0008758251780046591 -1.0 -1.0 -1.0 -1.0 0.00044494017319042853 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.6620271125067025e-05 0.0006278777700923334 3.3816651814344154e-05 -1.0 -1.0 0.0024363004681119066 0.04404124277352227 0.002389900091734746 -1.0 -1.0 0.001096572213298872 0.04862206884590391 0.0011530054432113332 -1.0 -1.0 -1.0 0.00029204950777272335 2.2332845991385424e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0001298973206651331 0.0028826281529980655 0.00018941326535850932 -1.0 5.4657521927731274e-05 0.014670839729146354 0.49999999999999994 0.011271060592765664 -1.0 -1.0 0.014846491082523524 0.4897211700090108 0.013284874451810723 -1.0 -1.0 5.14657989105535e-05 0.0010115278438204965 0.0008429411802845685 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0009344129479768359 -1.0 -1.0 -1.0 0.0024828273390431962 0.04299740304329489 0.0020539079252555113 -1.0 -1.0 0.003034165905819096 0.04870927636605937 0.00313101668086297 -1.0 -1.0 -1.0 6.339910999436737e-05 7.442176086066386e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.00011276372995589871 0.0002236100157024887 9.56304298913265e-08 -1.0 -1.0 0.0001596955110781239 9.960576598335084e-06 5.3833030623153676e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 4.0453018186074215e-05 4.6013290110121894e-05 2.709738801641897e-05 -1.0 -1.0 -1.0 9.538410811938703e-05 1.992978141244964e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0723231851298364e-05 -1.0 -1.0 -1.0 -1.0 0.0008030100296698905 0.017386220476187222 0.0005027758935317528 -1.0 -1.0 0.00103568411326969 0.015609071124009234 0.0007473731339616588 -1.0 -1.0 -1.0 6.979537549963374e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0014257756927429828 5.9098070539559466e-05 -1.0 5.0168071459366625e-06 0.005588863190166347 0.5 0.003930588100414563 -1.0 -1.0 0.005163345217476071 0.48250750993887326 0.003510432129522241 -1.0 -1.0 3.371977841720992e-05 0.0006640103276501794 9.554899988419713e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.000187872910697387 -1.0 -1.0 -1.0 0.0009134587866163143 0.017081858078684467 0.0002972747357542354 -1.0 -1.0 0.0007973472495507653 0.019300903254809747 0.000902203032280694 -1.0 -1.0 6.170015233787292e-05 1.898984300674969e-05 9.85411583595722e-07 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0173913765490095e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 - -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.008758251780046591 -10.0 -10.0 -10.0 -10.0 0.004449401731904285 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00016620271125067024 0.006278777700923334 0.00033816651814344155 -10.0 -10.0 0.024363004681119065 0.4404124277352227 0.02389900091734746 -10.0 -10.0 0.01096572213298872 0.4862206884590391 0.011530054432113333 -10.0 -10.0 -10.0 0.0029204950777272335 0.00022332845991385425 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.0012989732066513312 0.028826281529980655 0.0018941326535850931 -10.0 0.0005465752192773128 0.14670839729146354 4.999999999999999 0.11271060592765664 -10.0 -10.0 0.14846491082523525 4.897211700090108 0.13284874451810724 -10.0 -10.0 0.000514657989105535 0.010115278438204964 0.008429411802845685 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00934412947976836 -10.0 -10.0 -10.0 0.024828273390431962 0.4299740304329489 0.020539079252555114 -10.0 -10.0 0.03034165905819096 0.48709276366059373 0.0313101668086297 -10.0 -10.0 -10.0 0.0006339910999436737 0.0007442176086066385 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.0011276372995589871 0.002236100157024887 9.56304298913265e-07 -10.0 -10.0 0.001596955110781239 9.960576598335084e-05 0.0005383303062315367 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00040453018186074213 0.00046013290110121896 0.0002709738801641897 -10.0 -10.0 -10.0 0.0009538410811938703 0.00019929781412449641 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00010723231851298364 -10.0 -10.0 -10.0 -10.0 0.008030100296698905 0.17386220476187222 0.0050277589353175285 -10.0 -10.0 0.010356841132696899 0.15609071124009233 0.007473731339616587 -10.0 -10.0 -10.0 0.0006979537549963374 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.014257756927429827 0.0005909807053955946 -10.0 5.016807145936663e-05 0.055888631901663474 5.0 0.039305881004145636 -10.0 -10.0 0.05163345217476071 4.825075099388733 0.03510432129522241 -10.0 -10.0 0.00033719778417209923 0.006640103276501793 0.0009554899988419713 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00187872910697387 -10.0 -10.0 -10.0 0.009134587866163143 0.17081858078684467 0.002972747357542354 -10.0 -10.0 0.007973472495507653 0.19300903254809748 0.009022030322806941 -10.0 -10.0 0.0006170015233787292 0.0001898984300674969 9.85411583595722e-06 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00010173913765490096 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 - 3.0 - 1.5 - 10 - 1e-38 - - - 5 6 7 - -240 -240 -240 - 240 240 240 - - - 2 - photon - 0.0 0.5 20000000.0 - -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 2.0445691096074744e-05 -1.0 -1.0 -1.0 0.00013281328509288383 0.0006267128082339883 -1.0 -1.0 -1.0 -1.0 0.0004209808495056742 5.340221214300681e-05 -1.0 -1.0 -1.0 1.553693492042344e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 3.7096847855980484e-05 -1.0 -1.0 5.41969614042385e-05 0.0007918090215756442 9.763572147337743e-05 -1.0 -1.0 0.0026398319229115233 0.04039871468258457 0.002806654735003014 -1.0 -1.0 0.0027608366482897244 0.040190978087723005 0.0025084416103979975 -1.0 -1.0 9.774868433298412e-05 0.0006126404916879651 0.00014841730774317252 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 9.75342408717107e-06 1.7610849405640072e-05 -1.0 -1.0 0.0001160370359598608 0.002822592083222468 0.0003897177301239376 -1.0 -1.0 0.014965179733172532 0.5 0.011723491704290401 -1.0 2.260493623875525e-05 0.015157364795884922 0.49376993953402387 0.013111419473204967 -1.0 -1.0 0.00014919915366377564 0.002197964829133137 0.0003209711829219673 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.4806422867046436e-05 -1.0 -1.0 -1.0 9.207268175745281e-05 0.0007066033561638983 -1.0 -1.0 -1.0 0.003246064903858183 0.03905493028065908 0.0025380574501073605 -1.0 -1.0 0.0032499260211917933 0.04335567738779479 0.0031577214557017056 4.521352809838806e-05 -1.0 0.00018268090756001903 0.0004353654810741932 0.00011273259573092372 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 9.650194311662424e-06 0.00029403373970835075 0.00013506203419326438 -1.0 -1.0 4.5065302725431816e-06 0.00027725323638744237 3.547290864255937e-05 -1.0 -1.0 -1.0 8.786172732576295e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 - -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00020445691096074745 -10.0 -10.0 -10.0 0.0013281328509288383 0.006267128082339883 -10.0 -10.0 -10.0 -10.0 0.004209808495056742 0.0005340221214300681 -10.0 -10.0 -10.0 0.00015536934920423439 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00037096847855980485 -10.0 -10.0 0.000541969614042385 0.007918090215756443 0.0009763572147337743 -10.0 -10.0 0.026398319229115234 0.4039871468258457 0.02806654735003014 -10.0 -10.0 0.027608366482897245 0.40190978087723006 0.025084416103979976 -10.0 -10.0 0.0009774868433298411 0.0061264049168796506 0.0014841730774317252 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 9.753424087171071e-05 0.00017610849405640073 -10.0 -10.0 0.001160370359598608 0.02822592083222468 0.003897177301239376 -10.0 -10.0 0.14965179733172532 5.0 0.11723491704290401 -10.0 0.0002260493623875525 0.15157364795884923 4.937699395340239 0.13111419473204966 -10.0 -10.0 0.0014919915366377564 0.02197964829133137 0.003209711829219673 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00014806422867046437 -10.0 -10.0 -10.0 0.0009207268175745281 0.007066033561638983 -10.0 -10.0 -10.0 0.03246064903858183 0.39054930280659084 0.025380574501073606 -10.0 -10.0 0.03249926021191793 0.4335567738779479 0.03157721455701706 0.0004521352809838806 -10.0 0.0018268090756001904 0.004353654810741932 0.001127325957309237 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 9.650194311662424e-05 0.0029403373970835075 0.0013506203419326437 -10.0 -10.0 4.5065302725431816e-05 0.002772532363874424 0.0003547290864255937 -10.0 -10.0 -10.0 0.0008786172732576295 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 - 3.0 - 1.5 - 10 - 1e-38 - - false - - true - true - - 200 - - - - 5 10 15 - -240 -240 -240 - 240 240 240 - - - 1 - - - 0.0 0.5 20000000.0 - - - neutron photon - - - 1 2 3 - flux - - - diff --git a/tests/regression_tests/weightwindows/local/results_true.dat b/tests/regression_tests/weightwindows/local/results_true.dat deleted file mode 100644 index ebff4edac..000000000 --- a/tests/regression_tests/weightwindows/local/results_true.dat +++ /dev/null @@ -1 +0,0 @@ -41d8ba482783b724c61bf058a67ff701109076ac460f0be69b3a33c7a9e3e2aa5b5773442d33561b71c69500a9535f1ffb0f5e81f6ce364288c5094bbbc0a292 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows/results_true.dat b/tests/regression_tests/weightwindows/results_true.dat new file mode 100644 index 000000000..6c05af31a --- /dev/null +++ b/tests/regression_tests/weightwindows/results_true.dat @@ -0,0 +1 @@ +ebc761815175b25fc95a226174928c226a3ab5dbf3b2a2abf09e079a0b87dee1dee74aa9b9eaec35acd58b8c481d264be7e9b3f052905bcc14ccd76f36b01549 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows/shared/inputs_true.dat b/tests/regression_tests/weightwindows/shared/inputs_true.dat deleted file mode 100644 index 6ec7d12e3..000000000 --- a/tests/regression_tests/weightwindows/shared/inputs_true.dat +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - fixed source - 500 - 2 - - - 0.001 0.001 0.001 - - - 14000000.0 1.0 - - - true - - 2 - neutron - 0.0 0.5 20000000.0 - -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0008758251780046591 -1.0 -1.0 -1.0 -1.0 0.00044494017319042853 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.6620271125067025e-05 0.0006278777700923334 3.3816651814344154e-05 -1.0 -1.0 0.0024363004681119066 0.04404124277352227 0.002389900091734746 -1.0 -1.0 0.001096572213298872 0.04862206884590391 0.0011530054432113332 -1.0 -1.0 -1.0 0.00029204950777272335 2.2332845991385424e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0001298973206651331 0.0028826281529980655 0.00018941326535850932 -1.0 5.4657521927731274e-05 0.014670839729146354 0.49999999999999994 0.011271060592765664 -1.0 -1.0 0.014846491082523524 0.4897211700090108 0.013284874451810723 -1.0 -1.0 5.14657989105535e-05 0.0010115278438204965 0.0008429411802845685 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0009344129479768359 -1.0 -1.0 -1.0 0.0024828273390431962 0.04299740304329489 0.0020539079252555113 -1.0 -1.0 0.003034165905819096 0.04870927636605937 0.00313101668086297 -1.0 -1.0 -1.0 6.339910999436737e-05 7.442176086066386e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.00011276372995589871 0.0002236100157024887 9.56304298913265e-08 -1.0 -1.0 0.0001596955110781239 9.960576598335084e-06 5.3833030623153676e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 4.0453018186074215e-05 4.6013290110121894e-05 2.709738801641897e-05 -1.0 -1.0 -1.0 9.538410811938703e-05 1.992978141244964e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0723231851298364e-05 -1.0 -1.0 -1.0 -1.0 0.0008030100296698905 0.017386220476187222 0.0005027758935317528 -1.0 -1.0 0.00103568411326969 0.015609071124009234 0.0007473731339616588 -1.0 -1.0 -1.0 6.979537549963374e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.0014257756927429828 5.9098070539559466e-05 -1.0 5.0168071459366625e-06 0.005588863190166347 0.5 0.003930588100414563 -1.0 -1.0 0.005163345217476071 0.48250750993887326 0.003510432129522241 -1.0 -1.0 3.371977841720992e-05 0.0006640103276501794 9.554899988419713e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.000187872910697387 -1.0 -1.0 -1.0 0.0009134587866163143 0.017081858078684467 0.0002972747357542354 -1.0 -1.0 0.0007973472495507653 0.019300903254809747 0.000902203032280694 -1.0 -1.0 6.170015233787292e-05 1.898984300674969e-05 9.85411583595722e-07 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0173913765490095e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 - -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.008758251780046591 -10.0 -10.0 -10.0 -10.0 0.004449401731904285 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00016620271125067024 0.006278777700923334 0.00033816651814344155 -10.0 -10.0 0.024363004681119065 0.4404124277352227 0.02389900091734746 -10.0 -10.0 0.01096572213298872 0.4862206884590391 0.011530054432113333 -10.0 -10.0 -10.0 0.0029204950777272335 0.00022332845991385425 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.0012989732066513312 0.028826281529980655 0.0018941326535850931 -10.0 0.0005465752192773128 0.14670839729146354 4.999999999999999 0.11271060592765664 -10.0 -10.0 0.14846491082523525 4.897211700090108 0.13284874451810724 -10.0 -10.0 0.000514657989105535 0.010115278438204964 0.008429411802845685 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00934412947976836 -10.0 -10.0 -10.0 0.024828273390431962 0.4299740304329489 0.020539079252555114 -10.0 -10.0 0.03034165905819096 0.48709276366059373 0.0313101668086297 -10.0 -10.0 -10.0 0.0006339910999436737 0.0007442176086066385 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.0011276372995589871 0.002236100157024887 9.56304298913265e-07 -10.0 -10.0 0.001596955110781239 9.960576598335084e-05 0.0005383303062315367 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00040453018186074213 0.00046013290110121896 0.0002709738801641897 -10.0 -10.0 -10.0 0.0009538410811938703 0.00019929781412449641 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00010723231851298364 -10.0 -10.0 -10.0 -10.0 0.008030100296698905 0.17386220476187222 0.0050277589353175285 -10.0 -10.0 0.010356841132696899 0.15609071124009233 0.007473731339616587 -10.0 -10.0 -10.0 0.0006979537549963374 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.014257756927429827 0.0005909807053955946 -10.0 5.016807145936663e-05 0.055888631901663474 5.0 0.039305881004145636 -10.0 -10.0 0.05163345217476071 4.825075099388733 0.03510432129522241 -10.0 -10.0 0.00033719778417209923 0.006640103276501793 0.0009554899988419713 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00187872910697387 -10.0 -10.0 -10.0 0.009134587866163143 0.17081858078684467 0.002972747357542354 -10.0 -10.0 0.007973472495507653 0.19300903254809748 0.009022030322806941 -10.0 -10.0 0.0006170015233787292 0.0001898984300674969 9.85411583595722e-06 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00010173913765490096 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 - 3.0 - 1.5 - 10 - 1e-38 - - - 5 6 7 - -240 -240 -240 - 240 240 240 - - - 2 - photon - 0.0 0.5 20000000.0 - -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 2.0445691096074744e-05 -1.0 -1.0 -1.0 0.00013281328509288383 0.0006267128082339883 -1.0 -1.0 -1.0 -1.0 0.0004209808495056742 5.340221214300681e-05 -1.0 -1.0 -1.0 1.553693492042344e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 3.7096847855980484e-05 -1.0 -1.0 5.41969614042385e-05 0.0007918090215756442 9.763572147337743e-05 -1.0 -1.0 0.0026398319229115233 0.04039871468258457 0.002806654735003014 -1.0 -1.0 0.0027608366482897244 0.040190978087723005 0.0025084416103979975 -1.0 -1.0 9.774868433298412e-05 0.0006126404916879651 0.00014841730774317252 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 9.75342408717107e-06 1.7610849405640072e-05 -1.0 -1.0 0.0001160370359598608 0.002822592083222468 0.0003897177301239376 -1.0 -1.0 0.014965179733172532 0.5 0.011723491704290401 -1.0 2.260493623875525e-05 0.015157364795884922 0.49376993953402387 0.013111419473204967 -1.0 -1.0 0.00014919915366377564 0.002197964829133137 0.0003209711829219673 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.4806422867046436e-05 -1.0 -1.0 -1.0 9.207268175745281e-05 0.0007066033561638983 -1.0 -1.0 -1.0 0.003246064903858183 0.03905493028065908 0.0025380574501073605 -1.0 -1.0 0.0032499260211917933 0.04335567738779479 0.0031577214557017056 4.521352809838806e-05 -1.0 0.00018268090756001903 0.0004353654810741932 0.00011273259573092372 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 9.650194311662424e-06 0.00029403373970835075 0.00013506203419326438 -1.0 -1.0 4.5065302725431816e-06 0.00027725323638744237 3.547290864255937e-05 -1.0 -1.0 -1.0 8.786172732576295e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 - -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00020445691096074745 -10.0 -10.0 -10.0 0.0013281328509288383 0.006267128082339883 -10.0 -10.0 -10.0 -10.0 0.004209808495056742 0.0005340221214300681 -10.0 -10.0 -10.0 0.00015536934920423439 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00037096847855980485 -10.0 -10.0 0.000541969614042385 0.007918090215756443 0.0009763572147337743 -10.0 -10.0 0.026398319229115234 0.4039871468258457 0.02806654735003014 -10.0 -10.0 0.027608366482897245 0.40190978087723006 0.025084416103979976 -10.0 -10.0 0.0009774868433298411 0.0061264049168796506 0.0014841730774317252 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 9.753424087171071e-05 0.00017610849405640073 -10.0 -10.0 0.001160370359598608 0.02822592083222468 0.003897177301239376 -10.0 -10.0 0.14965179733172532 5.0 0.11723491704290401 -10.0 0.0002260493623875525 0.15157364795884923 4.937699395340239 0.13111419473204966 -10.0 -10.0 0.0014919915366377564 0.02197964829133137 0.003209711829219673 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 0.00014806422867046437 -10.0 -10.0 -10.0 0.0009207268175745281 0.007066033561638983 -10.0 -10.0 -10.0 0.03246064903858183 0.39054930280659084 0.025380574501073606 -10.0 -10.0 0.03249926021191793 0.4335567738779479 0.03157721455701706 0.0004521352809838806 -10.0 0.0018268090756001904 0.004353654810741932 0.001127325957309237 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 9.650194311662424e-05 0.0029403373970835075 0.0013506203419326437 -10.0 -10.0 4.5065302725431816e-05 0.002772532363874424 0.0003547290864255937 -10.0 -10.0 -10.0 0.0008786172732576295 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 -10.0 - 3.0 - 1.5 - 10 - 1e-38 - - true - - true - true - - 200 - - - - 5 10 15 - -240 -240 -240 - 240 240 240 - - - 1 - - - 0.0 0.5 20000000.0 - - - neutron photon - - - 1 2 3 - flux - - - diff --git a/tests/regression_tests/weightwindows/shared/results_true.dat b/tests/regression_tests/weightwindows/shared/results_true.dat deleted file mode 100644 index 01381db32..000000000 --- a/tests/regression_tests/weightwindows/shared/results_true.dat +++ /dev/null @@ -1 +0,0 @@ -27c2d218ecf46161088003fbb39ccd63495f80d6e0b27dbc3b3e845b49b282dabf0eaba4fb619be15c6116fc963ec5ce1fe4197efbe4084972ec761e02e70eb5 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows/survival_biasing/__init__.py b/tests/regression_tests/weightwindows/survival_biasing/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/weightwindows/survival_biasing/local/inputs_true.dat b/tests/regression_tests/weightwindows/survival_biasing/local/inputs_true.dat deleted file mode 100644 index fe144dc62..000000000 --- a/tests/regression_tests/weightwindows/survival_biasing/local/inputs_true.dat +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - fixed source - 50 - 5 - - - - 0.01 1.0 - - - - - - - 14100000.0 1.0 - - - true - - 1 - neutron - 0.46135961568957096 0.2874485390202603 0.13256013950494605 0.052765209609807295 0.020958440832685638 0.006317250035749876 0.002627037175682506 0.00030032343592437284 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4611178493390162 0.28624862560842024 0.13999870622621136 0.05508479408959756 0.018281241958254993 0.0055577764872361555 0.0015265432226293397 0.00024298772352636966 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.46294957913063317 0.2857734367546051 0.13365623190336945 0.05034742166227103 0.017525851812913266 0.005096725451851077 0.0026297640951531403 0.00033732424392026144 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.45772598750472554 0.281494921471495 0.13604397962762246 0.054792881472295364 0.019802376898755525 0.0073351745579128495 0.002067392946066426 9.529474085926143e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4739762983490318 0.28419061537046764 0.12757509901507888 0.0516920293019733 0.01919167874787235 0.007593035964707848 0.0017488176314107277 9.678267909681988e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.47560199098558276 0.27728389146956994 0.12760802572535623 0.05251965811713552 0.022498960644951632 0.01063372459325151 0.004242071054914633 0.00045603112202665183 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.47659199471934693 0.28886666944252215 0.1258637573398161 0.05818862375955657 0.020476313720744762 0.007143193244018263 0.0022364083022515273 0.0003953123781408474 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4693487369606823 0.27180862139490125 0.12833455570423483 0.055146743559938344 0.020667403529470333 0.007891508723137146 0.001643551705407358 0.0006501416781353278 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4538724931023337 0.2824491421084296 0.1275341706351566 0.055027501141893705 0.02305114640508087 0.008599303158607198 0.0025082611194161804 0.000518530311231696 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.45258444753220123 0.26839102466484255 0.12991633918797083 0.05442263709947767 0.019695895223471486 0.005353204961887518 0.0015074698293840157 0.0001598680898180058 8.872047880811405e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4482467985982804 0.2813276470183359 0.13449860790768647 0.056103278190533436 0.026274320334196962 0.006884071908429303 0.0033099390738735458 0.0005337454397674922 0.0001386380399465575 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4875748950139487 0.2908586705316248 0.14212060658392278 0.06068108009637272 0.019467970468789477 0.00637102427946399 0.0028510425266191687 0.0012184421778115488 0.00029404541567146187 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.5 0.2852101551297824 0.13622307172321643 0.058302519884339946 0.023124734915152625 0.007401527839638796 0.002527635652743992 0.0008509612315162482 0.00018213334574554768 7.815977984795461e-06 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.47706397688984176 0.28313436859495966 0.13170624744221976 0.0525453512766549 0.021111753158319105 0.0067451713955609645 0.003204270539718037 0.0010308107242263192 0.0002759210144794204 0.00013727805365387318 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.48641988659284513 0.2816173231471242 0.131541850061199 0.054793200248327956 0.016517701691156576 0.006757591781856257 0.0025425350750908644 0.0006383278085839443 2.279421641064226e-05 0.0003597432472224371 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4307755159245372 0.2652713784080849 0.12753857957535653 0.05470396852881577 0.02049817309420563 0.00566559741247352 0.0007213846765465147 6.848024591311009e-05 -1.0 8.609308814924014e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.43631324024956025 0.2639077825530567 0.13368737962742414 0.05213531603720763 0.020628860469743833 0.008268384844678654 0.0028599221013934375 0.00013059757129982714 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.45926287238219 0.2635824148883888 0.13104280996799478 0.055379812186041905 0.019255042561941074 0.007252095690246872 0.0018026593488140996 0.0003215836458542421 9.14840176000331e-06 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4574378998400604 0.28714971179927723 0.1363507911051337 0.05010315954654347 0.017963278989571074 0.0058998176297971605 0.0021393135666168 0.00015677575033083482 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4821442782978812 0.27704132233083506 0.14149074035662307 0.05546042815834048 0.016800649382269998 0.004096804603054233 0.0019161108398578026 0.0005289600253155307 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 - 2.306798078447855 1.4372426951013015 0.6628006975247303 0.2638260480490365 0.10479220416342819 0.03158625017874938 0.013135185878412529 0.0015016171796218643 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.3055892466950807 1.4312431280421012 0.6999935311310568 0.2754239704479878 0.09140620979127496 0.027788882436180776 0.007632716113146698 0.0012149386176318483 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.314747895653166 1.4288671837730256 0.6682811595168472 0.25173710831135515 0.08762925906456634 0.025483627259255386 0.013148820475765701 0.0016866212196013073 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.288629937523628 1.407474607357475 0.6802198981381123 0.2739644073614768 0.09901188449377762 0.036675872789564246 0.01033696473033213 0.00047647370429630714 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.369881491745159 1.4209530768523382 0.6378754950753944 0.2584601465098665 0.09595839373936176 0.03796517982353924 0.008744088157053638 0.00048391339548409945 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.3780099549279137 1.3864194573478497 0.6380401286267812 0.26259829058567763 0.11249480322475816 0.053168622966257545 0.021210355274573163 0.0022801556101332593 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.382959973596735 1.4443333472126108 0.6293187866990806 0.29094311879778284 0.10238156860372381 0.035715966220091315 0.011182041511257637 0.001976561890704237 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.3467436848034113 1.3590431069745064 0.6416727785211741 0.2757337177996917 0.10333701764735166 0.03945754361568573 0.00821775852703679 0.0032507083906766388 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.2693624655116684 1.412245710542148 0.637670853175783 0.27513750570946854 0.11525573202540434 0.04299651579303599 0.012541305597080901 0.00259265155615848 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.262922237661006 1.3419551233242126 0.6495816959398542 0.2721131854973884 0.09847947611735743 0.02676602480943759 0.007537349146920078 0.000799340449090029 0.0004436023940405703 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.2412339929914022 1.4066382350916795 0.6724930395384323 0.28051639095266717 0.1313716016709848 0.03442035954214652 0.016549695369367727 0.0026687271988374613 0.0006931901997327875 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.4378744750697434 1.4542933526581239 0.7106030329196139 0.3034054004818636 0.09733985234394739 0.03185512139731995 0.014255212633095843 0.006092210889057744 0.0014702270783573093 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.5 1.4260507756489118 0.6811153586160822 0.2915125994216997 0.11562367457576313 0.03700763919819398 0.012638178263719959 0.004254806157581241 0.0009106667287277384 3.9079889923977307e-05 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.385319884449209 1.4156718429747983 0.6585312372110987 0.2627267563832745 0.10555876579159552 0.03372585697780482 0.016021352698590185 0.005154053621131596 0.001379605072397102 0.000686390268269366 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.432099432964226 1.4080866157356209 0.657709250305995 0.2739660012416398 0.08258850845578287 0.03378795890928128 0.012712675375454322 0.0031916390429197216 0.0001139710820532113 0.0017987162361121855 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.1538775796226863 1.3263568920404245 0.6376928978767826 0.27351984264407886 0.10249086547102815 0.028327987062367603 0.0036069233827325737 0.0003424012295655504 -5.0 0.0004304654407462007 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.181566201247801 1.3195389127652835 0.6684368981371207 0.2606765801860381 0.10314430234871916 0.041341924223393264 0.014299610506967188 0.0006529878564991358 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.29631436191095 1.317912074441944 0.6552140498399739 0.27689906093020955 0.09627521280970537 0.03626047845123436 0.009013296744070498 0.0016079182292712106 4.574200880001655e-05 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.287189499200302 1.435748558996386 0.6817539555256685 0.25051579773271737 0.08981639494785537 0.029499088148985803 0.010696567833083998 0.0007838787516541741 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.410721391489406 1.3852066116541752 0.7074537017831153 0.2773021407917024 0.08400324691134999 0.020484023015271167 0.009580554199289014 0.0026448001265776534 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 - 3.0 - 10 - 1e-38 - - - 20 20 1 - 0.0 0.0 0.0 - 160.0 160.0 160.0 - - false - - true - true - - - - - 1 - - - 1 - flux - - - diff --git a/tests/regression_tests/weightwindows/survival_biasing/local/results_true.dat b/tests/regression_tests/weightwindows/survival_biasing/local/results_true.dat deleted file mode 100644 index b457a245c..000000000 --- a/tests/regression_tests/weightwindows/survival_biasing/local/results_true.dat +++ /dev/null @@ -1 +0,0 @@ -386e507008ed3c72c6e1a101aafc01cfaaff2c0b10555558d1eab6332441f7b17264b55002d721151bac2f3e7c1a8aac4c5ed243f5270533d171850f985206ed \ No newline at end of file diff --git a/tests/regression_tests/weightwindows/survival_biasing/shared/inputs_true.dat b/tests/regression_tests/weightwindows/survival_biasing/shared/inputs_true.dat deleted file mode 100644 index bafff89c1..000000000 --- a/tests/regression_tests/weightwindows/survival_biasing/shared/inputs_true.dat +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - fixed source - 50 - 5 - - - - 0.01 1.0 - - - - - - - 14100000.0 1.0 - - - true - - 1 - neutron - 0.46135961568957096 0.2874485390202603 0.13256013950494605 0.052765209609807295 0.020958440832685638 0.006317250035749876 0.002627037175682506 0.00030032343592437284 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4611178493390162 0.28624862560842024 0.13999870622621136 0.05508479408959756 0.018281241958254993 0.0055577764872361555 0.0015265432226293397 0.00024298772352636966 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.46294957913063317 0.2857734367546051 0.13365623190336945 0.05034742166227103 0.017525851812913266 0.005096725451851077 0.0026297640951531403 0.00033732424392026144 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.45772598750472554 0.281494921471495 0.13604397962762246 0.054792881472295364 0.019802376898755525 0.0073351745579128495 0.002067392946066426 9.529474085926143e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4739762983490318 0.28419061537046764 0.12757509901507888 0.0516920293019733 0.01919167874787235 0.007593035964707848 0.0017488176314107277 9.678267909681988e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.47560199098558276 0.27728389146956994 0.12760802572535623 0.05251965811713552 0.022498960644951632 0.01063372459325151 0.004242071054914633 0.00045603112202665183 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.47659199471934693 0.28886666944252215 0.1258637573398161 0.05818862375955657 0.020476313720744762 0.007143193244018263 0.0022364083022515273 0.0003953123781408474 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4693487369606823 0.27180862139490125 0.12833455570423483 0.055146743559938344 0.020667403529470333 0.007891508723137146 0.001643551705407358 0.0006501416781353278 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4538724931023337 0.2824491421084296 0.1275341706351566 0.055027501141893705 0.02305114640508087 0.008599303158607198 0.0025082611194161804 0.000518530311231696 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.45258444753220123 0.26839102466484255 0.12991633918797083 0.05442263709947767 0.019695895223471486 0.005353204961887518 0.0015074698293840157 0.0001598680898180058 8.872047880811405e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4482467985982804 0.2813276470183359 0.13449860790768647 0.056103278190533436 0.026274320334196962 0.006884071908429303 0.0033099390738735458 0.0005337454397674922 0.0001386380399465575 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4875748950139487 0.2908586705316248 0.14212060658392278 0.06068108009637272 0.019467970468789477 0.00637102427946399 0.0028510425266191687 0.0012184421778115488 0.00029404541567146187 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.5 0.2852101551297824 0.13622307172321643 0.058302519884339946 0.023124734915152625 0.007401527839638796 0.002527635652743992 0.0008509612315162482 0.00018213334574554768 7.815977984795461e-06 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.47706397688984176 0.28313436859495966 0.13170624744221976 0.0525453512766549 0.021111753158319105 0.0067451713955609645 0.003204270539718037 0.0010308107242263192 0.0002759210144794204 0.00013727805365387318 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.48641988659284513 0.2816173231471242 0.131541850061199 0.054793200248327956 0.016517701691156576 0.006757591781856257 0.0025425350750908644 0.0006383278085839443 2.279421641064226e-05 0.0003597432472224371 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4307755159245372 0.2652713784080849 0.12753857957535653 0.05470396852881577 0.02049817309420563 0.00566559741247352 0.0007213846765465147 6.848024591311009e-05 -1.0 8.609308814924014e-05 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.43631324024956025 0.2639077825530567 0.13368737962742414 0.05213531603720763 0.020628860469743833 0.008268384844678654 0.0028599221013934375 0.00013059757129982714 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.45926287238219 0.2635824148883888 0.13104280996799478 0.055379812186041905 0.019255042561941074 0.007252095690246872 0.0018026593488140996 0.0003215836458542421 9.14840176000331e-06 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4574378998400604 0.28714971179927723 0.1363507911051337 0.05010315954654347 0.017963278989571074 0.0058998176297971605 0.0021393135666168 0.00015677575033083482 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 0.4821442782978812 0.27704132233083506 0.14149074035662307 0.05546042815834048 0.016800649382269998 0.004096804603054233 0.0019161108398578026 0.0005289600253155307 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 - 2.306798078447855 1.4372426951013015 0.6628006975247303 0.2638260480490365 0.10479220416342819 0.03158625017874938 0.013135185878412529 0.0015016171796218643 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.3055892466950807 1.4312431280421012 0.6999935311310568 0.2754239704479878 0.09140620979127496 0.027788882436180776 0.007632716113146698 0.0012149386176318483 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.314747895653166 1.4288671837730256 0.6682811595168472 0.25173710831135515 0.08762925906456634 0.025483627259255386 0.013148820475765701 0.0016866212196013073 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.288629937523628 1.407474607357475 0.6802198981381123 0.2739644073614768 0.09901188449377762 0.036675872789564246 0.01033696473033213 0.00047647370429630714 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.369881491745159 1.4209530768523382 0.6378754950753944 0.2584601465098665 0.09595839373936176 0.03796517982353924 0.008744088157053638 0.00048391339548409945 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.3780099549279137 1.3864194573478497 0.6380401286267812 0.26259829058567763 0.11249480322475816 0.053168622966257545 0.021210355274573163 0.0022801556101332593 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.382959973596735 1.4443333472126108 0.6293187866990806 0.29094311879778284 0.10238156860372381 0.035715966220091315 0.011182041511257637 0.001976561890704237 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.3467436848034113 1.3590431069745064 0.6416727785211741 0.2757337177996917 0.10333701764735166 0.03945754361568573 0.00821775852703679 0.0032507083906766388 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.2693624655116684 1.412245710542148 0.637670853175783 0.27513750570946854 0.11525573202540434 0.04299651579303599 0.012541305597080901 0.00259265155615848 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.262922237661006 1.3419551233242126 0.6495816959398542 0.2721131854973884 0.09847947611735743 0.02676602480943759 0.007537349146920078 0.000799340449090029 0.0004436023940405703 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.2412339929914022 1.4066382350916795 0.6724930395384323 0.28051639095266717 0.1313716016709848 0.03442035954214652 0.016549695369367727 0.0026687271988374613 0.0006931901997327875 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.4378744750697434 1.4542933526581239 0.7106030329196139 0.3034054004818636 0.09733985234394739 0.03185512139731995 0.014255212633095843 0.006092210889057744 0.0014702270783573093 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.5 1.4260507756489118 0.6811153586160822 0.2915125994216997 0.11562367457576313 0.03700763919819398 0.012638178263719959 0.004254806157581241 0.0009106667287277384 3.9079889923977307e-05 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.385319884449209 1.4156718429747983 0.6585312372110987 0.2627267563832745 0.10555876579159552 0.03372585697780482 0.016021352698590185 0.005154053621131596 0.001379605072397102 0.000686390268269366 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.432099432964226 1.4080866157356209 0.657709250305995 0.2739660012416398 0.08258850845578287 0.03378795890928128 0.012712675375454322 0.0031916390429197216 0.0001139710820532113 0.0017987162361121855 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.1538775796226863 1.3263568920404245 0.6376928978767826 0.27351984264407886 0.10249086547102815 0.028327987062367603 0.0036069233827325737 0.0003424012295655504 -5.0 0.0004304654407462007 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.181566201247801 1.3195389127652835 0.6684368981371207 0.2606765801860381 0.10314430234871916 0.041341924223393264 0.014299610506967188 0.0006529878564991358 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.29631436191095 1.317912074441944 0.6552140498399739 0.27689906093020955 0.09627521280970537 0.03626047845123436 0.009013296744070498 0.0016079182292712106 4.574200880001655e-05 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.287189499200302 1.435748558996386 0.6817539555256685 0.25051579773271737 0.08981639494785537 0.029499088148985803 0.010696567833083998 0.0007838787516541741 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 2.410721391489406 1.3852066116541752 0.7074537017831153 0.2773021407917024 0.08400324691134999 0.020484023015271167 0.009580554199289014 0.0026448001265776534 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 - 3.0 - 10 - 1e-38 - - - 20 20 1 - 0.0 0.0 0.0 - 160.0 160.0 160.0 - - true - - true - true - - - - - 1 - - - 1 - flux - - - diff --git a/tests/regression_tests/weightwindows/survival_biasing/shared/results_true.dat b/tests/regression_tests/weightwindows/survival_biasing/shared/results_true.dat deleted file mode 100644 index 11e5ffa77..000000000 --- a/tests/regression_tests/weightwindows/survival_biasing/shared/results_true.dat +++ /dev/null @@ -1 +0,0 @@ -d17a437262d3316985fba4b48e21a7fcd5f32ac2d96ef0e66849f567deaeadc1e0f18d5d0bf5e9cab4246dbf823e7f43f249a1f67e928b27ae8c70b89f3cefbf \ No newline at end of file diff --git a/tests/regression_tests/weightwindows/survival_biasing/test.py b/tests/regression_tests/weightwindows/survival_biasing/test.py deleted file mode 100644 index c3a3e91a2..000000000 --- a/tests/regression_tests/weightwindows/survival_biasing/test.py +++ /dev/null @@ -1,91 +0,0 @@ -from pathlib import Path - -import pytest -import numpy as np -import openmc -from openmc.utility_funcs import change_directory - -from tests.testing_harness import HashedPyAPITestHarness - - -def build_model(shared_secondary): - openmc.reset_auto_ids() - - # Material - w = openmc.Material(name='Tungsten') - w.add_element('W', 1.0) - w.set_density('g/cm3', 19.25) - - materials = openmc.Materials([w]) - - # Geometry surfaces - x0 = openmc.XPlane(x0=0.0, boundary_type='reflective') - x1 = openmc.XPlane(x0=160.0, boundary_type='vacuum') - y0 = openmc.YPlane(y0=0.0, boundary_type='reflective') - y1 = openmc.YPlane(y0=160.0, boundary_type='reflective') - z0 = openmc.ZPlane(z0=0.0, boundary_type='reflective') - z1 = openmc.ZPlane(z0=160.0, boundary_type='reflective') - - region = +x0 & -x1 & +y0 & -y1 & +z0 & -z1 - cell = openmc.Cell(region=region, fill=w) - root = openmc.Universe(cells=[cell]) - geometry = openmc.Geometry(root) - - # Source: planar on x=0, mono-directional along +x, 14.1 MeV neutrons - space = openmc.stats.CartesianIndependent( - openmc.stats.Discrete([0.01], [1.0]), - openmc.stats.Uniform(0.0, 160.0), - openmc.stats.Uniform(0.0, 160.0), - ) - angle = openmc.stats.Monodirectional((1.0, 0.0, 0.0)) - energy = openmc.stats.Discrete([14.1e6], [1.0]) - - source = openmc.IndependentSource(space=space, angle=angle, energy=energy) - - settings = openmc.Settings() - settings.run_mode = 'fixed source' - settings.batches = 5 - settings.particles = 50 - settings.source = source - settings.shared_secondary_bank = shared_secondary - - model = openmc.Model(geometry=geometry, materials=materials, settings=settings) - - # Mesh tally: 1 cm voxels, flux only - mesh = openmc.RegularMesh() - mesh.dimension = (20, 20, 1) - mesh.lower_left = (0.0, 0.0, 0.0) - mesh.upper_right = (160.0, 160.0, 160.0) - - mesh_filter = openmc.MeshFilter(mesh) - flux_tally = openmc.Tally(name='flux') - flux_tally.filters = [mesh_filter] - flux_tally.scores = ['flux'] - tallies = openmc.Tallies([flux_tally]) - model.tallies = tallies - - parent_dir = Path(__file__).parent - lower_ww_bounds = np.loadtxt(parent_dir / 'ww_n.txt') - - weight_windows = openmc.WeightWindows(mesh, - lower_ww_bounds, - upper_bound_ratio=5.0, - particle_type='neutron') - - model.settings.weight_windows = weight_windows - model.settings.weight_window_checkpoints = {'surface': True, - 'collision': True} - model.settings.survival_biasing = True - - return model - - -@pytest.mark.parametrize("shared_secondary,subdir", [ - (False, "local"), - (True, "shared"), -]) -def test_weight_windows_with_survival_biasing(shared_secondary, subdir): - with change_directory(subdir): - model = build_model(shared_secondary) - harness = HashedPyAPITestHarness('statepoint.5.h5', model) - harness.main() diff --git a/tests/regression_tests/weightwindows/survival_biasing/ww_n.txt b/tests/regression_tests/weightwindows/survival_biasing/ww_n.txt deleted file mode 100644 index aea1ff132..000000000 --- a/tests/regression_tests/weightwindows/survival_biasing/ww_n.txt +++ /dev/null @@ -1,400 +0,0 @@ -4.613596156895709566e-01 -4.611178493390161726e-01 -4.629495791306331709e-01 -4.577259875047255400e-01 -4.739762983490318216e-01 -4.756019909855827565e-01 -4.765919947193469342e-01 -4.693487369606823001e-01 -4.538724931023336850e-01 -4.525844475322012284e-01 -4.482467985982804271e-01 -4.875748950139486837e-01 -5.000000000000000000e-01 -4.770639768898417565e-01 -4.864198865928451299e-01 -4.307755159245372223e-01 -4.363132402495602524e-01 -4.592628723821899905e-01 -4.574378998400603913e-01 -4.821442782978812014e-01 -2.874485390202602964e-01 -2.862486256084202374e-01 -2.857734367546050924e-01 -2.814949214714950187e-01 -2.841906153704676363e-01 -2.772838914695699430e-01 -2.888666694425221504e-01 -2.718086213949012508e-01 -2.824491421084295850e-01 -2.683910246648425479e-01 -2.813276470183359024e-01 -2.908586705316247856e-01 -2.852101551297823723e-01 -2.831343685949596622e-01 -2.816173231471241767e-01 -2.652713784080849013e-01 -2.639077825530566912e-01 -2.635824148883887941e-01 -2.871497117992772297e-01 -2.770413223308350603e-01 -1.325601395049460507e-01 -1.399987062262113557e-01 -1.336562319033694490e-01 -1.360439796276224633e-01 -1.275750990150788799e-01 -1.276080257253562333e-01 -1.258637573398161125e-01 -1.283345557042348262e-01 -1.275341706351565962e-01 -1.299163391879708251e-01 -1.344986079076864738e-01 -1.421206065839227817e-01 -1.362230717232164323e-01 -1.317062474422197593e-01 -1.315418500611990060e-01 -1.275385795753565255e-01 -1.336873796274241355e-01 -1.310428099679947778e-01 -1.363507911051337063e-01 -1.414907403566230681e-01 -5.276520960980729535e-02 -5.508479408959755796e-02 -5.034742166227103299e-02 -5.479288147229536415e-02 -5.169202930197330098e-02 -5.251965811713552035e-02 -5.818862375955657223e-02 -5.514674355993834376e-02 -5.502750114189370462e-02 -5.442263709947767203e-02 -5.610327819053343573e-02 -6.068108009637272066e-02 -5.830251988433994559e-02 -5.254535127665489747e-02 -5.479320024832795566e-02 -5.470396852881576760e-02 -5.213531603720762686e-02 -5.537981218604190459e-02 -5.010315954654347148e-02 -5.546042815834047873e-02 -2.095844083268563751e-02 -1.828124195825499287e-02 -1.752585181291326649e-02 -1.980237689875552487e-02 -1.919167874787235106e-02 -2.249896064495163217e-02 -2.047631372074476194e-02 -2.066740352947033302e-02 -2.305114640508086968e-02 -1.969589522347148583e-02 -2.627432033419696208e-02 -1.946797046878947710e-02 -2.312473491515262478e-02 -2.111175315831910482e-02 -1.651770169115657563e-02 -2.049817309420563088e-02 -2.062886046974383297e-02 -1.925504256194107353e-02 -1.796327898957107358e-02 -1.680064938226999774e-02 -6.317250035749876098e-03 -5.557776487236155451e-03 -5.096725451851077254e-03 -7.335174557912849461e-03 -7.593035964707848043e-03 -1.063372459325150933e-02 -7.143193244018263000e-03 -7.891508723137145853e-03 -8.599303158607197670e-03 -5.353204961887517849e-03 -6.884071908429303423e-03 -6.371024279463989581e-03 -7.401527839638795750e-03 -6.745171395560964518e-03 -6.757591781856257113e-03 -5.665597412473520264e-03 -8.268384844678653561e-03 -7.252095690246871881e-03 -5.899817629797160512e-03 -4.096804603054233183e-03 -2.627037175682505905e-03 -1.526543222629339657e-03 -2.629764095153140288e-03 -2.067392946066426082e-03 -1.748817631410727689e-03 -4.242071054914632773e-03 -2.236408302251527251e-03 -1.643551705407358000e-03 -2.508261119416180414e-03 -1.507469829384015672e-03 -3.309939073873545759e-03 -2.851042526619168658e-03 -2.527635652743991969e-03 -3.204270539718037138e-03 -2.542535075090864363e-03 -7.213846765465147101e-04 -2.859922101393437468e-03 -1.802659348814099642e-03 -2.139313566616799812e-03 -1.916110839857802610e-03 -3.003234359243728432e-04 -2.429877235263696591e-04 -3.373242439202614419e-04 -9.529474085926143009e-05 -9.678267909681988429e-05 -4.560311220266518293e-04 -3.953123781408473961e-04 -6.501416781353277531e-04 -5.185303112316960250e-04 -1.598680898180058108e-04 -5.337454397674922446e-04 -1.218442177811548824e-03 -8.509612315162482432e-04 -1.030810724226319166e-03 -6.383278085839443235e-04 -6.848024591311008757e-05 -1.305975712998271444e-04 -3.215836458542421176e-04 -1.567757503308348204e-04 -5.289600253155306818e-04 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -8.872047880811405188e-05 -1.386380399465574921e-04 -2.940454156714618719e-04 -1.821333457455476831e-04 -2.759210144794204192e-04 -2.279421641064226044e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 -9.148401760003310179e-06 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -7.815977984795461318e-06 -1.372780536538731832e-04 -3.597432472224371168e-04 -8.609308814924013556e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 diff --git a/tests/regression_tests/weightwindows/test.py b/tests/regression_tests/weightwindows/test.py index c5b6bd889..864f4f062 100644 --- a/tests/regression_tests/weightwindows/test.py +++ b/tests/regression_tests/weightwindows/test.py @@ -1,23 +1,22 @@ -from pathlib import Path - +from copy import deepcopy import pytest import numpy as np import openmc from openmc.stats import Discrete, Point -from openmc.utility_funcs import change_directory from tests.testing_harness import HashedPyAPITestHarness -def build_model(shared_secondary): - openmc.reset_auto_ids() +@pytest.fixture +def model(): model = openmc.Model() # materials (M4 steel alloy) m4 = openmc.Material() m4.set_density('g/cc', 2.3) m4.add_nuclide('H1', 0.168018676) + m4.add_nuclide("H2", 1.93244e-05) m4.add_nuclide("O16", 0.561814465) m4.add_nuclide("O17", 0.00021401) m4.add_nuclide("Na23", 0.021365) @@ -27,9 +26,14 @@ def build_model(shared_secondary): m4.add_nuclide("Si30", 0.006273944) m4.add_nuclide("Ca40", 0.018026179) m4.add_nuclide("Ca42", 0.00012031) + m4.add_nuclide("Ca43", 2.51033e-05) m4.add_nuclide("Ca44", 0.000387892) + m4.add_nuclide("Ca46", 7.438e-07) + m4.add_nuclide("Ca48", 3.47727e-05) m4.add_nuclide("Fe54", 0.000248179) m4.add_nuclide("Fe56", 0.003895875) + m4.add_nuclide("Fe57", 8.99727e-05) + m4.add_nuclide("Fe58", 1.19737e-05) s0 = openmc.Sphere(r=240) s1 = openmc.Sphere(r=250, boundary_type='vacuum') @@ -42,13 +46,10 @@ def build_model(shared_secondary): # settings settings = model.settings settings.run_mode = 'fixed source' - settings.particles = 500 + settings.particles = 200 settings.batches = 2 settings.max_history_splits = 200 settings.photon_transport = True - settings.shared_secondary_bank = shared_secondary - settings.weight_window_checkpoints = {'surface': True, - 'collision': True} space = Point((0.001, 0.001, 0.001)) energy = Discrete([14E6], [1.0]) @@ -75,10 +76,10 @@ def build_model(shared_secondary): # weight windows - # load pre-generated weight windows from parent directory - parent_dir = Path(__file__).parent - ww_n_lower_bnds = np.loadtxt(parent_dir / 'ww_n.txt') - ww_p_lower_bnds = np.loadtxt(parent_dir / 'ww_p.txt') + # load pre-generated weight windows + # (created using the same tally as above) + ww_n_lower_bnds = np.loadtxt('ww_n.txt') + ww_p_lower_bnds = np.loadtxt('ww_p.txt') # create a mesh matching the one used # to generate the weight windows @@ -92,7 +93,6 @@ def build_model(shared_secondary): None, 10.0, e_bnds, - 'neutron', max_lower_bound_ratio=1.5) ww_p = openmc.WeightWindows(ww_mesh, @@ -100,7 +100,6 @@ def build_model(shared_secondary): None, 10.0, e_bnds, - 'photon', max_lower_bound_ratio=1.5) model.settings.weight_windows = [ww_n, ww_p] @@ -108,75 +107,14 @@ def build_model(shared_secondary): return model -@pytest.mark.parametrize("shared_secondary,subdir", [ - (False, "local"), - (True, "shared"), -]) -def test_weightwindows(shared_secondary, subdir): - with change_directory(subdir): - model = build_model(shared_secondary) - test = HashedPyAPITestHarness('statepoint.2.h5', model) - test.main() - - -def test_zero_bound_windows_play_no_game(tmp_path): - # A weight window lower bound of zero means no weight window information - # exists there (MCNP wwinp files use zero to turn the game off in a cell), - # so transport must proceed as if weight windows were disabled. Previously, - # zero-bound windows demanded a split at every checkpoint (weight/0 -> - # max_split), multiplying the particle population until terminated by the - # split or weight cutoff limits. - model = build_model(False) - for ww in model.settings.weight_windows: - ww.lower_ww_bounds = np.zeros_like(ww.lower_ww_bounds) - ww.upper_ww_bounds = np.zeros_like(ww.upper_ww_bounds) - sp_zero = model.run(cwd=tmp_path / 'zero_windows') - - model.settings.weight_windows_on = False - sp_off = model.run(cwd=tmp_path / 'windows_off') - - with openmc.StatePoint(sp_zero) as sp: - flux_zero = list(sp.tallies.values())[0].mean - with openmc.StatePoint(sp_off) as sp: - flux_off = list(sp.tallies.values())[0].mean - - np.testing.assert_allclose(flux_zero, flux_off, rtol=1e-12) - - -def test_zero_and_negative_bounds_equivalent(tmp_path): - # Zero and negative lower bounds both mean that no weight window - # information exists in a cell (generators mark such cells with -1, and - # MCNP wwinp files use zero), so they must produce identical transport. - # Unlike the all-zero case above, here particles are born under valid - # windows and encounter the no-information region in flight; previously a - # zero lower bound in that situation demanded a split at every checkpoint - # in the cell (weight/0 -> max_split), multiplying the particle population, - # while -1 played no game. - def run_with(bound_value, subdir): - model = build_model(False) - for ww in model.settings.weight_windows: - lb = np.array(ww.lower_ww_bounds, copy=True) - ub = np.array(ww.upper_ww_bounds, copy=True) - lb[3:, :, :, :] = bound_value - ub[3:, :, :, :] = bound_value - ww.lower_ww_bounds = lb - ww.upper_ww_bounds = ub - return model.run(cwd=tmp_path / subdir) - - sp_zero = run_with(0.0, 'zero_region') - sp_negative = run_with(-1.0, 'negative_region') - - with openmc.StatePoint(sp_zero) as sp: - flux_zero = list(sp.tallies.values())[0].mean - with openmc.StatePoint(sp_negative) as sp: - flux_negative = list(sp.tallies.values())[0].mean - - np.testing.assert_allclose(flux_zero, flux_negative, rtol=1e-12) +def test_weightwindows(model): + test = HashedPyAPITestHarness('statepoint.2.h5', model) + test.main() def test_wwinp_cylindrical(): - ww = openmc.WeightWindowsList.from_wwinp('ww_n_cyl.txt')[0] + ww = openmc.wwinp_to_wws('ww_n_cyl.txt')[0] mesh = ww.mesh @@ -206,7 +144,7 @@ def test_wwinp_cylindrical(): def test_wwinp_spherical(): - ww = openmc.WeightWindowsList.from_wwinp('ww_n_sph.txt')[0] + ww = openmc.wwinp_to_wws('ww_n_sph.txt')[0] mesh = ww.mesh diff --git a/tests/regression_tests/weightwindows/ww_n.txt b/tests/regression_tests/weightwindows/ww_n.txt index 36d7673c6..dbb49537b 100644 --- a/tests/regression_tests/weightwindows/ww_n.txt +++ b/tests/regression_tests/weightwindows/ww_n.txt @@ -10,30 +10,43 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +7.695031155172815952e-14 -1.000000000000000000e+00 +7.476545089278482294e-06 -1.000000000000000000e+00 +2.161215042522170282e-06 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.136040178434497494e-18 -1.000000000000000000e+00 +1.345534130616238158e-05 -1.000000000000000000e+00 +3.353295403842037074e-05 -1.000000000000000000e+00 +3.016075845432365699e-07 -1.000000000000000000e+00 +1.026243155073153453e-13 -1.000000000000000000e+00 +1.685921961405802360e-19 -1.000000000000000000e+00 +3.853097455417877125e-06 -1.000000000000000000e+00 +4.354946981329799215e-05 -1.000000000000000000e+00 +7.002861620919231721e-08 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.620506488302619488e-11 -1.000000000000000000e+00 +1.704166922479738429e-09 -1.000000000000000000e+00 +1.874782466747863741e-14 -1.000000000000000000e+00 -1.000000000000000000e+00 -5.465752192773127422e-05 -5.016807145936662541e-06 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 @@ -47,329 +60,301 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +5.619835883512352867e-14 -1.000000000000000000e+00 +1.951356547084204088e-15 -1.000000000000000000e+00 +8.481761456712739755e-10 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.450826207325665860e-13 -1.000000000000000000e+00 +4.109066205029878035e-05 -1.000000000000000000e+00 +2.057318145024078612e-04 -1.000000000000000000e+00 +2.124999182004654892e-05 -1.000000000000000000e+00 +5.537915413446233643e-08 -1.000000000000000000e+00 +1.555045595917848555e-06 -1.000000000000000000e+00 +7.213722022489493227e-04 -1.000000000000000000e+00 +7.673145137236566868e-03 -1.000000000000000000e+00 +8.175033526488423340e-04 -1.000000000000000000e+00 +1.008394964750946906e-06 -1.000000000000000000e+00 +6.848642863465584904e-07 -1.000000000000000000e+00 +1.073708183250235556e-03 -1.000000000000000000e+00 +7.197662162700776967e-03 -1.000000000000000000e+00 +7.151459162818185784e-04 -1.000000000000000000e+00 +2.253382683081525085e-06 -1.000000000000000000e+00 +1.318156235244509166e-10 -1.000000000000000000e+00 +1.938470818929409920e-05 -1.000000000000000000e+00 +4.602961711512755646e-04 -1.000000000000000000e+00 +2.562906833044621533e-05 -1.000000000000000000e+00 +5.504813693036932910e-12 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +3.316482534950376351e-16 -1.000000000000000000e+00 +3.937160538176268057e-07 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.517291205731239772e-14 -1.000000000000000000e+00 +6.315154082213375425e-07 -1.000000000000000000e+00 +3.855884234344844889e-06 -1.000000000000000000e+00 +1.777013641125591191e-05 -1.000000000000000000e+00 +1.642149199375171522e-11 -1.000000000000000000e+00 +5.976538141107809983e-06 -1.000000000000000000e+00 +1.959411999677113103e-03 -1.000000000000000000e+00 +1.333061985337931354e-02 -1.000000000000000000e+00 +1.795061316935990395e-03 -1.000000000000000000e+00 +2.430637569372220458e-06 -1.000000000000000000e+00 +6.922231352729155390e-05 -1.000000000000000000e+00 +8.657573566388353237e-02 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +8.356487100743359431e-02 -1.000000000000000000e+00 +1.641903115049591277e-04 -1.000000000000000000e+00 +9.031085518264690009e-05 -1.000000000000000000e+00 +8.488729673818780352e-02 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.662027112506702498e-05 -1.072323185129836366e-05 -1.298973206651331117e-04 +8.288806458368344621e-02 -1.000000000000000000e+00 +5.694959706678497628e-05 -1.000000000000000000e+00 +8.037131813528500897e-07 -1.000000000000000000e+00 +1.663712654332187308e-03 -1.000000000000000000e+00 +1.664109232689093068e-02 -1.000000000000000000e+00 +1.832759343760799985e-03 -1.000000000000000000e+00 +6.542700644645626997e-07 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +6.655926357459274907e-08 -1.000000000000000000e+00 -4.045301818607421548e-05 -2.436300468111906627e-03 -8.030100296698905113e-04 -1.467083972914635416e-02 -5.588863190166347417e-03 -2.482827339043196246e-03 -9.134587866163143164e-04 -1.127637299558987091e-04 +5.783974359937856763e-06 -1.000000000000000000e+00 +2.679340942769232109e-06 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.104060901286513389e-05 -1.000000000000000000e+00 -1.096572213298871923e-03 -1.035684113269689892e-03 -1.484649108252352433e-02 -5.163345217476070746e-03 -3.034165905819096072e-03 -7.973472495507652599e-04 -1.596955110781238946e-04 +2.928209794781622450e-05 -1.000000000000000000e+00 +1.284759166582201940e-05 -1.000000000000000000e+00 +1.009290508315880392e-11 -1.000000000000000000e+00 +1.322801376552501482e-05 -1.000000000000000000e+00 +7.136750029575815620e-03 -1.000000000000000000e+00 +6.539005235506369085e-02 -1.000000000000000000e+00 +6.480331412016533503e-03 -1.000000000000000000e+00 +2.601178739391680563e-06 -1.000000000000000000e+00 +8.887234042637683843e-05 -1.000000000000000000e+00 -5.146579891055349870e-05 -3.371977841720992210e-05 --1.000000000000000000e+00 -6.170015233787291603e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -6.278777700923334273e-04 --1.000000000000000000e+00 -2.882628152998065532e-03 -1.425775692742982772e-03 -9.344129479768359435e-04 -1.878729106973870018e-04 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -8.758251780046590789e-04 -4.601329011012189428e-05 -4.404124277352226835e-02 -1.738622047618722244e-02 -4.999999999999999445e-01 5.000000000000000000e-01 -4.299740304329489199e-02 -1.708185807868446704e-02 -2.236100157024886888e-04 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +4.877856021170283163e-01 -1.000000000000000000e+00 +1.769985835774446302e-04 -1.000000000000000000e+00 -4.449401731904285297e-04 -9.538410811938702620e-05 -4.862206884590390688e-02 -1.560907112400923384e-02 -4.897211700090107755e-01 -4.825075099388732580e-01 -4.870927636605937305e-02 -1.930090325480974742e-02 -9.960576598335083693e-06 +1.670700632870335029e-04 -1.000000000000000000e+00 +4.899999304038166192e-01 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +4.857384221387814338e-01 -1.000000000000000000e+00 +2.153456869915780514e-04 -1.000000000000000000e+00 +7.842896894949250204e-06 -1.000000000000000000e+00 -2.920495077727233452e-04 -6.979537549963373846e-05 -1.011527843820496462e-03 -6.640103276501793748e-04 -6.339910999436736800e-05 -1.898984300674969044e-05 +6.379065450759913505e-03 -1.000000000000000000e+00 +6.550426960512012453e-02 -1.000000000000000000e+00 +6.639379668946672301e-03 -1.000000000000000000e+00 +7.754700849337902260e-06 -1.000000000000000000e+00 +2.720743316579670241e-11 -1.000000000000000000e+00 +5.985108617124988932e-06 -1.000000000000000000e+00 +3.634644995026691954e-05 -1.000000000000000000e+00 +3.932389299316284718e-06 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.271128669411294917e-07 -1.000000000000000000e+00 +8.846493399850662704e-06 -1.000000000000000000e+00 +2.499931357628383163e-07 -1.000000000000000000e+00 +8.533030345699353466e-17 -1.000000000000000000e+00 +1.669925427773410862e-06 -1.000000000000000000e+00 +1.754138009689378778e-03 -1.000000000000000000e+00 +1.514897842827161306e-02 -1.000000000000000000e+00 +1.627979455242757438e-03 -1.000000000000000000e+00 +2.380955631371225994e-06 -1.000000000000000000e+00 +2.164891804046736287e-05 -1.000000000000000000e+00 +8.339317973815890683e-02 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +8.285899874014539257e-02 -1.000000000000000000e+00 +2.762955748645507000e-05 -1.000000000000000000e+00 +5.116174051620571477e-05 -1.000000000000000000e+00 +8.095280568305474045e-02 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +8.636569925236790846e-02 -1.000000000000000000e+00 +3.452537179033895228e-05 -1.000000000000000000e+00 +3.598103176641614321e-06 -1.000000000000000000e+00 +1.570829313580840913e-03 -1.000000000000000000e+00 +1.621821782442112170e-02 -1.000000000000000000e+00 -3.381665181434415378e-05 --1.000000000000000000e+00 -1.894132653585093196e-04 -5.909807053955946611e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -2.709738801641897098e-05 -2.389900091734746025e-03 -5.027758935317528299e-04 -1.127106059276566409e-02 -3.930588100414563434e-03 -2.053907925255511312e-03 -2.972747357542354098e-04 -9.563042989132649486e-08 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -1.992978141244964075e-05 -1.153005443211333218e-03 -7.473731339616587841e-04 -1.328487445181072285e-02 -3.510432129522240985e-03 -3.131016680862970091e-03 -9.022030322806940360e-04 -5.383303062315367556e-05 -1.017391376549009493e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -2.233284599138542407e-05 --1.000000000000000000e+00 -8.429411802845684617e-04 -9.554899988419712775e-05 -7.442176086066385897e-05 -9.854115835957219834e-07 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 +1.544782399547004175e-03 -1.000000000000000000e+00 +7.989579285134733983e-06 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.594951085377587857e-06 -1.000000000000000000e+00 +4.323138781337962887e-05 -1.000000000000000000e+00 +6.948292975998465777e-07 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.446945600849361415e-09 -1.000000000000000000e+00 +9.041149893307805599e-07 -1.000000000000000000e+00 +2.206099258062212484e-11 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.681305446488883933e-11 -1.000000000000000000e+00 +7.091263906557290927e-05 -1.000000000000000000e+00 +2.746424406288768276e-04 -1.000000000000000000e+00 +1.285845570921339974e-05 -1.000000000000000000e+00 +2.029521362171670568e-09 -1.000000000000000000e+00 +1.291182719850037242e-08 -1.000000000000000000e+00 +9.127050763987511325e-04 -1.000000000000000000e+00 +7.385384405891665810e-03 -1.000000000000000000e+00 +1.001943240150808675e-03 -1.000000000000000000e+00 +1.080711295768550941e-05 -1.000000000000000000e+00 +8.020767115181573972e-07 -1.000000000000000000e+00 +9.252532821720597109e-04 -1.000000000000000000e+00 +7.188410694198127913e-03 -1.000000000000000000e+00 +7.245451610090619275e-04 -1.000000000000000000e+00 +2.515735579020177281e-07 -1.000000000000000000e+00 +1.482521919913335348e-12 -1.000000000000000000e+00 +4.756872959630257218e-05 -1.000000000000000000e+00 +2.668579837809080925e-04 -1.000000000000000000e+00 +2.822627694453269613e-05 -1.000000000000000000e+00 +5.182269672663266089e-10 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.936268747135548187e-14 -1.000000000000000000e+00 +2.544728124173036570e-07 -1.000000000000000000e+00 +3.898416671385980035e-08 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 @@ -385,27 +370,41 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.639268952045578987e-10 -1.000000000000000000e+00 +3.705151822008388643e-06 -1.000000000000000000e+00 +1.133362760482367266e-09 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.229674726063540458e-06 -1.000000000000000000e+00 +7.962899789920809096e-06 -1.000000000000000000e+00 +8.211982683649991481e-09 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.563965686625045276e-06 -1.000000000000000000e+00 +2.248761782893832567e-05 -1.000000000000000000e+00 +3.279904588337207471e-06 -1.000000000000000000e+00 +4.076762579823379031e-17 -1.000000000000000000e+00 +1.547676923757129466e-14 -1.000000000000000000e+00 +1.030567269874565733e-11 -1.000000000000000000e+00 +1.957092814065688094e-05 -1.000000000000000000e+00 +3.852324755037881526e-12 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 @@ -413,6 +412,7 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.769723317139941641e-13 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 diff --git a/tests/regression_tests/weightwindows/ww_n_cyl.txt b/tests/regression_tests/weightwindows/ww_n_cyl.txt index 6f6144ca3..89232628f 100644 --- a/tests/regression_tests/weightwindows/ww_n_cyl.txt +++ b/tests/regression_tests/weightwindows/ww_n_cyl.txt @@ -2,7 +2,7 @@ 1 8.0000 7.0000 8.0000 0.0000 0.0000 -9.0001 2.0000 2.0000 4.0000 0.0000 0.0000 0.0000 -1.0000 0.0000 -9.0001 2.0000 +0.0000 0.0000 0.0000 2.0000 0.0000 3.0000 3.0200 1.0000 5.0000 6.0001 1.0000 0.0000 4.0000 8.0080 1.0000 3.0000 14.002 diff --git a/tests/regression_tests/weightwindows/ww_n_sph.txt b/tests/regression_tests/weightwindows/ww_n_sph.txt index a4418ceeb..3f9b8dab6 100644 --- a/tests/regression_tests/weightwindows/ww_n_sph.txt +++ b/tests/regression_tests/weightwindows/ww_n_sph.txt @@ -2,7 +2,7 @@ 1 8.0000 7.0000 8.0000 0.0000 0.0000 -9.0001 2.0000 4.0000 4.0000 0.0000 0.0000 0.0000 -1.0000 0.0000 -9.0001 3.0000 +0.0000 0.0000 0.0000 3.0000 0.0000 3.0000 3.0200 1.0000 5.0000 6.0001 1.0000 0.0000 2.0000 0.25000 1.0000 1.0000 0.50000 diff --git a/tests/regression_tests/weightwindows/ww_p.txt b/tests/regression_tests/weightwindows/ww_p.txt index da69b9e13..09ff01ebd 100644 --- a/tests/regression_tests/weightwindows/ww_p.txt +++ b/tests/regression_tests/weightwindows/ww_p.txt @@ -1,241 +1,205 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +5.447493368067179064e-10 -1.000000000000000000e+00 +4.040462614734400249e-13 -1.000000000000000000e+00 +9.382800796426366364e-17 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +5.752120832330885919e-11 -1.000000000000000000e+00 +3.520674728719278012e-05 -1.000000000000000000e+00 +8.760419353035269667e-05 -1.000000000000000000e+00 +3.136829920007008993e-05 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +4.233410073487771971e-06 -1.000000000000000000e+00 +2.551963224311764450e-04 -1.000000000000000000e+00 +4.777967757842694024e-04 -1.000000000000000000e+00 +3.598354799974066488e-04 -1.000000000000000000e+00 +4.625859206051786618e-07 -1.000000000000000000e+00 +4.587143797469485258e-08 -1.000000000000000000e+00 +1.291843367759397518e-04 -1.000000000000000000e+00 +4.695895684632649786e-04 -1.000000000000000000e+00 +8.862760180332873163e-05 -1.000000000000000000e+00 +3.279091474401153391e-06 -1.000000000000000000e+00 +1.151457911727229161e-10 -1.000000000000000000e+00 +2.295071617064146262e-05 -1.000000000000000000e+00 +6.922962992428139458e-05 -1.000000000000000000e+00 +2.160655073217069276e-05 -1.000000000000000000e+00 +2.617878055106949035e-16 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.722191123879781983e-08 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.123498061876322157e-13 -1.000000000000000000e+00 +1.462884795971722476e-05 -1.000000000000000000e+00 +2.777791741571173956e-05 -1.000000000000000000e+00 +9.533806586698390583e-06 -1.000000000000000000e+00 +1.078687446476880940e-14 -1.000000000000000000e+00 +3.057105085570708401e-06 -1.000000000000000000e+00 +8.231482263927564300e-04 -1.000000000000000000e+00 +3.881102561422505696e-03 -1.000000000000000000e+00 +1.229730308180539307e-03 -1.000000000000000000e+00 +4.684235088236766580e-05 -1.000000000000000000e+00 +1.675799759004882713e-04 -1.000000000000000000e+00 -2.260493623875524987e-05 +1.172471437684818700e-02 -1.000000000000000000e+00 +6.827568359008943932e-02 -1.000000000000000000e+00 +1.144038101286408600e-02 -1.000000000000000000e+00 +3.782322077390032930e-04 -1.000000000000000000e+00 +5.098747893974247782e-05 -1.000000000000000000e+00 +1.208261392046878005e-02 -1.000000000000000000e+00 +6.428782790571178907e-02 -1.000000000000000000e+00 +1.129470856680416663e-02 -1.000000000000000000e+00 +8.168081568291806404e-05 -1.000000000000000000e+00 +2.347504827875979927e-05 -1.000000000000000000e+00 +8.787411098754914583e-04 -1.000000000000000000e+00 +5.151329213225949548e-03 -1.000000000000000000e+00 +1.102802039050768210e-03 -1.000000000000000000e+00 +1.088201101868485208e-06 -1.000000000000000000e+00 +1.058825762372267240e-07 -1.000000000000000000e+00 +2.704481717610955638e-05 -1.000000000000000000e+00 +2.621123924679610439e-05 -1.000000000000000000e+00 +2.070764852974689408e-06 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.380657778513517658e-06 -1.000000000000000000e+00 +1.007700972669126494e-04 -1.000000000000000000e+00 +4.313097771132341687e-04 -1.000000000000000000e+00 +1.335621430311087867e-04 -1.000000000000000000e+00 +3.792209399652395984e-06 -1.000000000000000000e+00 +2.205797076162476780e-04 -1.000000000000000000e+00 +1.884234453311008084e-02 -1.000000000000000000e+00 +1.151012001392641704e-01 -1.000000000000000000e+00 +1.825795827020864834e-02 -1.000000000000000000e+00 +2.084830922016203648e-04 -1.000000000000000000e+00 +1.333255443748032664e-03 -1.000000000000000000e+00 +4.931708164307664344e-01 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +4.899952354672477139e-01 -1.000000000000000000e+00 +1.495703328116801227e-03 -1.000000000000000000e+00 +1.550036616828060930e-03 -1.000000000000000000e+00 +4.897735047310072254e-01 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -5.419696140423850144e-05 --1.000000000000000000e+00 -1.160370359598607949e-04 --1.000000000000000000e+00 -9.207268175745281452e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -1.328132850928838340e-04 --1.000000000000000000e+00 -2.639831922911523281e-03 --1.000000000000000000e+00 -1.496517973317253170e-02 --1.000000000000000000e+00 -3.246064903858183071e-03 --1.000000000000000000e+00 -9.650194311662423557e-06 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -2.760836648289724440e-03 --1.000000000000000000e+00 -1.515736479588492176e-02 --1.000000000000000000e+00 -3.249926021191793316e-03 --1.000000000000000000e+00 -4.506530272543181565e-06 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -9.774868433298411941e-05 --1.000000000000000000e+00 -1.491991536637756388e-04 --1.000000000000000000e+00 -1.826809075600190318e-04 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -9.753424087171070478e-06 --1.000000000000000000e+00 -1.480642286704643632e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -2.044569109607474437e-05 --1.000000000000000000e+00 -7.918090215756442467e-04 --1.000000000000000000e+00 -2.822592083222468049e-03 --1.000000000000000000e+00 -7.066033561638982710e-04 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -6.267128082339882807e-04 --1.000000000000000000e+00 -4.039871468258456749e-02 --1.000000000000000000e+00 5.000000000000000000e-01 -1.000000000000000000e+00 -3.905493028065908090e-02 +1.107679609210218599e-03 -1.000000000000000000e+00 -2.940337397083507467e-04 +2.792896409558744781e-04 -1.000000000000000000e+00 +1.721806295736377085e-02 -1.000000000000000000e+00 +1.189125124490693353e-01 -1.000000000000000000e+00 +1.904070707116530328e-02 -1.000000000000000000e+00 +1.732952862815292309e-04 -1.000000000000000000e+00 -4.209808495056741907e-04 +4.670673837764873805e-08 -1.000000000000000000e+00 -4.019097808772300467e-02 +1.263753469561097525e-04 -1.000000000000000000e+00 -4.937699395340238717e-01 +2.705205429838525473e-04 -1.000000000000000000e+00 -4.335567738779479152e-02 +1.497958445994315019e-04 -1.000000000000000000e+00 -2.772532363874423726e-04 +3.247830168002185438e-08 -1.000000000000000000e+00 +7.239087311622818554e-08 -1.000000000000000000e+00 +4.669378458601891341e-04 -1.000000000000000000e+00 +1.537590300149361015e-03 -1.000000000000000000e+00 +2.368681880710174145e-04 -1.000000000000000000e+00 -1.553693492042343928e-05 +8.616027294555461632e-07 -1.000000000000000000e+00 -6.126404916879650987e-04 +2.362355168421952122e-04 -1.000000000000000000e+00 -2.197964829133136882e-03 +5.708498338352203244e-02 -1.000000000000000000e+00 -4.353654810741931802e-04 +4.237271368372501623e-01 -1.000000000000000000e+00 -8.786172732576294898e-05 +5.490281661912204542e-02 -1.000000000000000000e+00 +3.000232638838324392e-04 -1.000000000000000000e+00 +2.329540159600531311e-03 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 @@ -243,7 +207,9 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.784732930735042255e-03 -1.000000000000000000e+00 +3.432919201293736875e-03 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 @@ -251,170 +217,204 @@ -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +2.672923773363389179e-03 -1.000000000000000000e+00 +3.182108781955477806e-04 -1.000000000000000000e+00 +5.639071613735578692e-02 -1.000000000000000000e+00 +4.346984808472855177e-01 -1.000000000000000000e+00 -3.709684785598048377e-05 +5.500108683629956891e-02 -1.000000000000000000e+00 -1.761084940564007186e-05 +2.417599813822804812e-04 -1.000000000000000000e+00 +2.774067049392004042e-07 -1.000000000000000000e+00 +3.257646134837451210e-04 -1.000000000000000000e+00 +1.264833388398999524e-03 -1.000000000000000000e+00 +2.981891705231208794e-04 -1.000000000000000000e+00 +4.986698316296506713e-06 -1.000000000000000000e+00 +3.419181071650815928e-06 -1.000000000000000000e+00 +1.081445276486055809e-04 -1.000000000000000000e+00 +6.934466049804711161e-04 -1.000000000000000000e+00 +2.510674100806631662e-04 -1.000000000000000000e+00 +5.515522196186722918e-06 -1.000000000000000000e+00 -9.763572147337742902e-05 +1.424205319552986396e-04 -1.000000000000000000e+00 -3.897177301239375825e-04 +1.854111290797000322e-02 -1.000000000000000000e+00 +1.236406932635011752e-01 -1.000000000000000000e+00 +1.760297107458398680e-02 -1.000000000000000000e+00 +2.130582646223859260e-04 -1.000000000000000000e+00 +1.501650004537408200e-03 -1.000000000000000000e+00 +4.903495510314233030e-01 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +4.952432605379828989e-01 -1.000000000000000000e+00 +1.769327994909421784e-03 -1.000000000000000000e+00 +9.304497896205120647e-04 -1.000000000000000000e+00 -2.806654735003014187e-03 +4.873897581604286766e-01 -1.000000000000000000e+00 -1.172349170429040112e-02 -1.000000000000000000e+00 -2.538057450107360485e-03 -1.000000000000000000e+00 -1.350620341932643788e-04 +4.981497862127627907e-01 -1.000000000000000000e+00 +1.127334097206107765e-03 -1.000000000000000000e+00 +1.412615360326509664e-04 -1.000000000000000000e+00 +1.729816946709781048e-02 -1.000000000000000000e+00 +1.181916566651922268e-01 -1.000000000000000000e+00 -5.340221214300680991e-05 +1.780262484403568810e-02 -1.000000000000000000e+00 -2.508441610397997481e-03 +1.319677450153934042e-04 -1.000000000000000000e+00 -1.311141947320496742e-02 +2.210707325798542070e-07 -1.000000000000000000e+00 -3.157721455701705589e-03 +1.728787338791035720e-04 -1.000000000000000000e+00 -3.547290864255936898e-05 +5.197081842709918220e-04 -1.000000000000000000e+00 +9.256616392487857544e-05 -1.000000000000000000e+00 +1.032520710502734699e-08 -1.000000000000000000e+00 +2.027381220364608057e-16 -1.000000000000000000e+00 +1.225736024671247218e-05 -1.000000000000000000e+00 +3.856169633708643398e-05 -1.000000000000000000e+00 +1.806455099029475317e-05 -1.000000000000000000e+00 -1.484173077431725238e-04 +7.691527781829036254e-17 -1.000000000000000000e+00 -3.209711829219673144e-04 +1.298062961617926916e-05 -1.000000000000000000e+00 -1.127325957309237157e-04 +1.178616843705955963e-03 -1.000000000000000000e+00 +4.441328419270368887e-03 -1.000000000000000000e+00 +8.919466185572301909e-04 -1.000000000000000000e+00 +5.272021975060514019e-06 -1.000000000000000000e+00 +1.607976851421854571e-04 -1.000000000000000000e+00 +1.112842419638761758e-02 -1.000000000000000000e+00 +6.433819434431045647e-02 -1.000000000000000000e+00 +1.095563748531924904e-02 -1.000000000000000000e+00 +8.370896020975688591e-05 -1.000000000000000000e+00 +2.223447159544331337e-04 -1.000000000000000000e+00 +1.102706140784315975e-02 -1.000000000000000000e+00 +6.684484191345574366e-02 -1.000000000000000000e+00 +1.111302464121833623e-02 -1.000000000000000000e+00 +1.255887947410807431e-04 -1.000000000000000000e+00 +1.004439072885827748e-05 -1.000000000000000000e+00 +8.081009012754719698e-04 -1.000000000000000000e+00 +5.384625561469683769e-03 -1.000000000000000000e+00 +1.146714816952060971e-03 -1.000000000000000000e+00 +3.574060778841494232e-06 -1.000000000000000000e+00 +2.251232708364186507e-10 -1.000000000000000000e+00 +6.717625881826167172e-05 -1.000000000000000000e+00 +6.949587369646497293e-05 -1.000000000000000000e+00 +2.909334597507522605e-05 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +8.582011716859218622e-15 -1.000000000000000000e+00 +8.304845400451923449e-08 -1.000000000000000000e+00 +4.575723837205823402e-11 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +1.311680713303003522e-15 -1.000000000000000000e+00 +2.686689485248190559e-05 -1.000000000000000000e+00 +4.316605279989737501e-05 -1.000000000000000000e+00 +6.401055165502384025e-06 -1.000000000000000000e+00 +5.726152701849347207e-16 -1.000000000000000000e+00 +8.541606727879512040e-07 -1.000000000000000000e+00 +2.029396545382813118e-04 -1.000000000000000000e+00 +4.299195570308034968e-04 -1.000000000000000000e+00 +8.544159282151438236e-05 -1.000000000000000000e+00 +1.099532245627738225e-06 -1.000000000000000000e+00 +1.289814511028014912e-06 -1.000000000000000000e+00 +1.104204785730725317e-04 -1.000000000000000000e+00 +6.870228272606287295e-04 -1.000000000000000000e+00 +1.399807456616496116e-04 -1.000000000000000000e+00 +4.279460329782799377e-09 -1.000000000000000000e+00 +1.290717169529484602e-13 -1.000000000000000000e+00 +1.925724800911436302e-05 -1.000000000000000000e+00 +9.332371598523186474e-05 -1.000000000000000000e+00 +1.310633551813380206e-05 -1.000000000000000000e+00 +6.574706543646946099e-16 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 +3.827053602579980514e-15 -1.000000000000000000e+00 +2.101790478097516960e-09 -1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 -4.521352809838806062e-05 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 --1.000000000000000000e+00 +9.904481358675477728e-13 -1.000000000000000000e+00 -1.000000000000000000e+00 diff --git a/tests/regression_tests/weightwindows_fw_cadis/__init__.py b/tests/regression_tests/weightwindows_fw_cadis/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/weightwindows_fw_cadis/inputs_true.dat b/tests/regression_tests/weightwindows_fw_cadis/inputs_true.dat deleted file mode 100644 index 6bdabfbee..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis/inputs_true.dat +++ /dev/null @@ -1,262 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 90 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - - 1 - neutron - 10 - 1 - true - fw_cadis - - - - 6 6 6 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - naive - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/weightwindows_fw_cadis/results_true.dat b/tests/regression_tests/weightwindows_fw_cadis/results_true.dat deleted file mode 100644 index e39b2e239..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis/results_true.dat +++ /dev/null @@ -1,442 +0,0 @@ -RegularMesh - ID = 1 - Name = - Dimensions = 3 - Voxels = [6 6 6] - Lower left = [0. 0. 0.] - Upper Right = [np.float64(30.0), np.float64(30.0), np.float64(30.0)] - Width = [5. 5. 5.] -Lower Bounds -1.50e-01 -1.54e-01 -1.43e-01 -1.30e-01 -1.30e-01 -1.97e-01 -1.46e-01 -1.25e-01 -1.34e-01 -1.32e-01 -1.27e-01 -3.40e-01 -1.36e-01 -1.13e-01 -1.09e-01 -1.19e-01 -1.25e-01 -3.08e-01 -1.38e-01 -1.18e-01 -9.49e-02 -1.19e-01 -1.35e-01 -1.96e-01 -1.12e-01 -9.60e-02 -9.33e-02 -9.74e-02 -1.37e-01 -2.76e-01 -4.53e-02 -1.31e-01 -2.47e-01 -7.36e-02 -1.72e-01 -1.38e-01 -1.55e-01 -1.54e-01 -1.48e-01 -1.36e-01 -1.29e-01 -1.88e-01 -1.40e-01 -1.51e-01 -1.28e-01 -1.18e-01 -1.29e-01 -2.86e-01 -1.42e-01 -1.26e-01 -1.28e-01 -1.16e-01 -1.22e-01 -2.81e-01 -1.38e-01 -1.22e-01 -1.04e-01 -9.81e-02 -1.08e-01 -1.97e-01 -1.34e-01 -1.32e-01 -1.10e-01 -8.69e-02 -1.03e-01 -1.33e-01 -2.51e-01 -3.39e-01 -1.13e-01 -6.92e-02 -1.54e-01 -5.71e-02 -1.60e-01 -1.52e-01 -1.34e-01 -1.32e-01 -1.28e-01 -2.53e-01 -1.33e-01 -1.35e-01 -1.15e-01 -1.32e-01 -1.37e-01 -3.13e-01 -1.27e-01 -1.36e-01 -1.35e-01 -1.10e-01 -1.08e-01 -8.81e-02 -1.51e-01 -1.32e-01 -1.13e-01 -9.89e-02 -9.25e-02 -5.04e-02 -1.40e-01 -1.56e-01 -1.40e-01 -9.19e-02 -6.54e-02 -2.05e-02 -3.35e-01 -1.88e-01 -3.16e-01 -1.80e-01 -5.78e-02 -5.36e-03 -1.43e-01 -1.35e-01 -1.47e-01 -1.33e-01 -1.47e-01 -4.95e-01 -1.42e-01 -1.45e-01 -1.27e-01 -1.31e-01 -1.26e-01 -1.43e-01 -1.49e-01 -1.23e-01 -1.24e-01 -1.13e-01 -9.69e-02 -1.07e-01 -1.65e-01 -1.50e-01 -1.24e-01 -1.07e-01 -8.90e-02 -8.81e-02 -1.48e-01 -1.58e-01 -1.20e-01 -7.93e-02 -7.19e-02 -3.94e-02 -2.29e-01 -1.95e-01 -2.66e-01 -1.51e-01 -3.52e-02 -3.68e-03 -1.48e-01 -1.18e-01 -1.47e-01 -1.41e-01 -1.37e-01 -2.71e-01 -1.70e-01 -1.70e-01 -1.29e-01 -1.33e-01 -1.28e-01 -2.79e-01 -1.84e-01 -1.42e-01 -1.18e-01 -1.25e-01 -1.26e-01 -1.64e-01 -1.73e-01 -1.37e-01 -1.12e-01 -9.01e-02 -1.13e-01 -1.68e-01 -1.60e-01 -1.52e-01 -1.30e-01 -8.71e-02 -7.72e-02 -3.76e-02 -1.57e-01 -9.31e-02 -1.63e-01 -6.80e-02 -6.22e-02 -3.37e-03 -2.47e-01 -2.17e-01 -1.48e-01 -2.01e-01 -1.54e-01 -5.69e-02 -2.89e-01 -3.59e-01 -1.17e-01 -8.64e-02 -3.34e-01 -1.50e-01 -5.00e-01 -2.16e-01 -1.22e-01 -1.66e-01 -1.44e-01 -4.98e-02 -4.28e-01 -1.17e-01 -8.73e-02 -1.11e-01 -1.09e-01 -9.69e-02 -3.26e-01 -2.28e-01 -2.49e-01 -3.55e-02 -1.69e-02 -3.95e-03 -1.03e-01 -4.89e-02 -1.90e-01 -4.61e-02 -9.75e-03 -3.00e-04 -Upper Bounds -7.49e-01 -7.71e-01 -7.13e-01 -6.51e-01 -6.48e-01 -9.85e-01 -7.31e-01 -6.26e-01 -6.69e-01 -6.59e-01 -6.33e-01 -1.70e+00 -6.82e-01 -5.67e-01 -5.45e-01 -5.94e-01 -6.24e-01 -1.54e+00 -6.92e-01 -5.91e-01 -4.75e-01 -5.96e-01 -6.77e-01 -9.82e-01 -5.59e-01 -4.80e-01 -4.67e-01 -4.87e-01 -6.84e-01 -1.38e+00 -2.26e-01 -6.55e-01 -1.24e+00 -3.68e-01 -8.59e-01 -6.88e-01 -7.73e-01 -7.70e-01 -7.42e-01 -6.78e-01 -6.46e-01 -9.40e-01 -7.00e-01 -7.57e-01 -6.39e-01 -5.92e-01 -6.43e-01 -1.43e+00 -7.12e-01 -6.29e-01 -6.40e-01 -5.78e-01 -6.09e-01 -1.40e+00 -6.90e-01 -6.10e-01 -5.21e-01 -4.91e-01 -5.42e-01 -9.87e-01 -6.71e-01 -6.60e-01 -5.52e-01 -4.35e-01 -5.14e-01 -6.65e-01 -1.26e+00 -1.70e+00 -5.63e-01 -3.46e-01 -7.72e-01 -2.86e-01 -8.00e-01 -7.58e-01 -6.70e-01 -6.59e-01 -6.41e-01 -1.26e+00 -6.65e-01 -6.76e-01 -5.76e-01 -6.60e-01 -6.86e-01 -1.57e+00 -6.35e-01 -6.81e-01 -6.75e-01 -5.51e-01 -5.39e-01 -4.40e-01 -7.56e-01 -6.62e-01 -5.67e-01 -4.95e-01 -4.63e-01 -2.52e-01 -6.98e-01 -7.78e-01 -6.99e-01 -4.59e-01 -3.27e-01 -1.02e-01 -1.67e+00 -9.38e-01 -1.58e+00 -9.00e-01 -2.89e-01 -2.68e-02 -7.16e-01 -6.75e-01 -7.35e-01 -6.63e-01 -7.34e-01 -2.47e+00 -7.11e-01 -7.23e-01 -6.34e-01 -6.54e-01 -6.32e-01 -7.14e-01 -7.45e-01 -6.15e-01 -6.19e-01 -5.64e-01 -4.85e-01 -5.37e-01 -8.26e-01 -7.51e-01 -6.21e-01 -5.36e-01 -4.45e-01 -4.40e-01 -7.40e-01 -7.92e-01 -5.99e-01 -3.96e-01 -3.60e-01 -1.97e-01 -1.14e+00 -9.76e-01 -1.33e+00 -7.55e-01 -1.76e-01 -1.84e-02 -7.42e-01 -5.90e-01 -7.37e-01 -7.07e-01 -6.84e-01 -1.36e+00 -8.52e-01 -8.49e-01 -6.46e-01 -6.63e-01 -6.42e-01 -1.40e+00 -9.19e-01 -7.08e-01 -5.89e-01 -6.24e-01 -6.28e-01 -8.21e-01 -8.64e-01 -6.87e-01 -5.58e-01 -4.50e-01 -5.64e-01 -8.40e-01 -7.99e-01 -7.62e-01 -6.51e-01 -4.36e-01 -3.86e-01 -1.88e-01 -7.85e-01 -4.66e-01 -8.13e-01 -3.40e-01 -3.11e-01 -1.68e-02 -1.24e+00 -1.09e+00 -7.40e-01 -1.00e+00 -7.72e-01 -2.85e-01 -1.44e+00 -1.79e+00 -5.85e-01 -4.32e-01 -1.67e+00 -7.50e-01 -2.50e+00 -1.08e+00 -6.10e-01 -8.32e-01 -7.19e-01 -2.49e-01 -2.14e+00 -5.87e-01 -4.36e-01 -5.57e-01 -5.47e-01 -4.84e-01 -1.63e+00 -1.14e+00 -1.25e+00 -1.78e-01 -8.43e-02 -1.97e-02 -5.17e-01 -2.44e-01 -9.49e-01 -2.31e-01 -4.87e-02 -1.50e-03 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows_fw_cadis/test.py b/tests/regression_tests/weightwindows_fw_cadis/test.py deleted file mode 100644 index 7a4718ed5..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis/test.py +++ /dev/null @@ -1,33 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_three_region_cube - -from tests.testing_harness import WeightWindowPyAPITestHarness - - -class MGXSTestHarness(WeightWindowPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_random_ray_adjoint_fixed_source(): - model = random_ray_three_region_cube() - - ww_mesh = openmc.RegularMesh() - n = 6 - width = 30.0 - ww_mesh.dimension = (n, n, n) - ww_mesh.lower_left = (0.0, 0.0, 0.0) - ww_mesh.upper_right = (width, width, width) - - wwg = openmc.WeightWindowGenerator( - method="fw_cadis", mesh=ww_mesh, max_realizations=model.settings.batches) - model.settings.weight_window_generators = wwg - model.settings.random_ray['volume_estimator'] = 'naive' - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/weightwindows_fw_cadis_local/__init__.py b/tests/regression_tests/weightwindows_fw_cadis_local/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/weightwindows_fw_cadis_local/inputs_true.dat b/tests/regression_tests/weightwindows_fw_cadis_local/inputs_true.dat deleted file mode 100644 index ffdd977ec..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_local/inputs_true.dat +++ /dev/null @@ -1,273 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - - - - - - fixed source - 500 - 10 - 5 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - - 2 - neutron - 10 - 1 - true - fw_cadis - 1 2 - - - - 7 7 7 - 0.0 0.0 0.0 - 35.0 35.0 35.0 - - - 800.0 - 100.0 - - - - 0.0 0.0 0.0 35.0 35.0 35.0 - - - - true - - - - - - naive - - - 14 14 14 - 0.0 0.0 0.0 - 35.0 35.0 35.0 - - - - - 6 - - - 7 - - - 1 - flux - tracklength - - - 2 - flux - tracklength - - - diff --git a/tests/regression_tests/weightwindows_fw_cadis_local/results_true.dat b/tests/regression_tests/weightwindows_fw_cadis_local/results_true.dat deleted file mode 100644 index 5991fc621..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_local/results_true.dat +++ /dev/null @@ -1,696 +0,0 @@ -RegularMesh - ID = 2 - Name = - Dimensions = 3 - Voxels = [7 7 7] - Lower left = [0. 0. 0.] - Upper Right = [np.float64(35.0), np.float64(35.0), np.float64(35.0)] - Width = [5. 5. 5.] -Lower Bounds -1.52e-01 -1.53e-01 -1.78e-01 -1.97e-01 -2.41e-01 -3.94e-01 -2.26e-03 -1.43e-01 -1.58e-01 -1.75e-01 -1.86e-01 -2.06e-01 -4.83e-02 -2.11e-03 -1.31e-01 -1.37e-01 -1.61e-01 -1.76e-01 -2.04e-01 -1.15e-01 -5.04e-03 -1.05e-01 -1.31e-01 -1.49e-01 -1.72e-01 -1.81e-01 -4.24e-02 -5.31e-03 -6.79e-02 -9.98e-02 -1.56e-01 -1.68e-01 -1.78e-01 -1.39e-02 -5.49e-03 -2.69e-03 -6.66e-03 -2.36e-02 -1.65e-02 -1.71e-02 -1.12e-02 -1.94e-03 -1.12e-04 -5.43e-04 -1.23e-03 -1.51e-03 -1.51e-03 -1.31e-03 -1.21e-03 -1.52e-01 -1.60e-01 -1.81e-01 -2.03e-01 -2.16e-01 -2.58e-02 -2.07e-03 -1.45e-01 -1.59e-01 -1.84e-01 -2.07e-01 -2.14e-01 -8.82e-02 -2.92e-03 -1.36e-01 -1.53e-01 -1.61e-01 -1.92e-01 -2.28e-01 -1.82e-01 -2.70e-03 -1.18e-01 -1.42e-01 -1.52e-01 -1.81e-01 -1.98e-01 -2.87e-02 -6.46e-03 -1.00e-01 -1.41e-01 -1.80e-01 -1.73e-01 -2.05e-01 -1.09e-01 -3.29e-03 -5.37e-03 -1.44e-02 -4.53e-02 -2.16e-02 -7.53e-02 -2.38e-02 -1.38e-03 -4.52e-04 -1.11e-03 -1.39e-03 -1.33e-03 -1.26e-03 -1.22e-03 -9.78e-04 -1.83e-01 -1.77e-01 -1.83e-01 -2.03e-01 -2.27e-01 -7.70e-02 -3.55e-03 -1.63e-01 -1.80e-01 -1.87e-01 -1.86e-01 -2.20e-01 -4.43e-02 -2.00e-03 -1.68e-01 -1.60e-01 -1.63e-01 -1.78e-01 -2.12e-01 -9.86e-02 -2.96e-03 -1.56e-01 -1.59e-01 -1.63e-01 -1.72e-01 -1.81e-01 -7.15e-02 -1.77e-03 -1.58e-01 -1.80e-01 -1.87e-01 -1.66e-01 -1.66e-01 -1.22e-02 -2.65e-03 -2.11e-02 -3.01e-02 -4.85e-02 -1.48e-02 -4.67e-02 -5.38e-03 -1.01e-03 -8.10e-04 -8.55e-04 -1.43e-03 -1.63e-03 -1.05e-03 -1.04e-03 -6.84e-04 -2.01e-01 -2.17e-01 -2.26e-01 -2.37e-01 -2.45e-01 -3.25e-02 -2.68e-02 -2.09e-01 -2.09e-01 -2.07e-01 -2.02e-01 -2.15e-01 -2.42e-02 -2.97e-03 -2.01e-01 -1.94e-01 -1.93e-01 -1.80e-01 -1.72e-01 -1.32e-02 -1.54e-03 -1.84e-01 -1.87e-01 -1.63e-01 -1.49e-01 -1.50e-01 -6.42e-02 -1.91e-03 -1.93e-01 -2.15e-01 -1.93e-01 -1.42e-01 -1.22e-01 -7.21e-03 -9.37e-04 -1.67e-02 -5.33e-02 -5.24e-02 -1.13e-02 -1.23e-02 -4.44e-03 -6.14e-04 -7.25e-04 -6.85e-04 -8.30e-04 -9.75e-04 -6.78e-04 -5.52e-04 -5.29e-04 -2.82e-01 -2.73e-01 -2.85e-01 -2.57e-01 -2.70e-01 -2.24e-02 -2.57e-03 -2.52e-01 -2.49e-01 -2.38e-01 -2.53e-01 -2.37e-01 -1.48e-02 -2.30e-03 -2.18e-01 -2.22e-01 -2.20e-01 -1.96e-01 -1.80e-01 -1.93e-02 -1.53e-03 -2.21e-01 -2.39e-01 -1.99e-01 -1.67e-01 -1.45e-01 -1.11e-02 -8.58e-04 -2.57e-01 -2.32e-01 -1.89e-01 -1.26e-01 -8.31e-02 -8.12e-03 -6.25e-04 -8.53e-02 -7.87e-02 -1.53e-02 -1.22e-02 -7.53e-03 -1.75e-03 -3.39e-04 -1.08e-03 -8.97e-04 -6.11e-04 -5.24e-04 -4.33e-04 -2.49e-04 -2.36e-04 -4.78e-01 -1.38e-01 -5.00e-01 -2.99e-02 -3.12e-02 -1.07e-01 -1.42e-03 -3.01e-01 -4.37e-02 -1.79e-01 -2.39e-01 -7.54e-02 -1.13e-02 -1.17e-03 -3.44e-01 -2.30e-01 -5.55e-02 -5.69e-02 -1.70e-02 -8.02e-03 -8.18e-04 -1.77e-01 -6.57e-02 -6.14e-02 -3.20e-02 -1.32e-02 -6.75e-03 -6.17e-04 -3.49e-02 -1.65e-02 -1.95e-02 -8.71e-03 -9.02e-03 -2.07e-03 -3.41e-04 -7.97e-02 -2.60e-02 -1.65e-02 -6.67e-03 -2.61e-03 -5.74e-04 -1.41e-04 -1.62e-03 -1.49e-03 -8.36e-04 -3.95e-04 -2.37e-04 -1.32e-04 -5.59e-05 -1.07e-03 -9.93e-04 -1.63e-03 -6.02e-03 -1.30e-03 -2.86e-03 -2.98e-03 -1.02e-03 -1.31e-03 -1.39e-03 -2.62e-03 -1.69e-03 -2.40e-03 -3.96e-03 -1.26e-03 -1.78e-03 -1.30e-03 -1.06e-03 -1.79e-03 -1.40e-03 -3.18e-03 -1.93e-03 -1.72e-03 -1.78e-03 -8.41e-04 -8.66e-04 -8.00e-04 -1.01e-03 -1.54e-03 -1.30e-03 -1.11e-03 -9.80e-04 -5.02e-04 -3.11e-04 -3.49e-04 -1.24e-03 -1.66e-03 -8.20e-04 -5.29e-04 -3.62e-04 -1.27e-04 -6.03e-05 -6.28e-04 -6.20e-04 -5.01e-04 -4.28e-04 -2.95e-04 -5.38e-05 -6.24e-06 -Upper Bounds -7.61e-01 -7.65e-01 -8.88e-01 -9.87e-01 -1.21e+00 -1.97e+00 -1.13e-02 -7.17e-01 -7.88e-01 -8.74e-01 -9.32e-01 -1.03e+00 -2.41e-01 -1.06e-02 -6.53e-01 -6.86e-01 -8.03e-01 -8.82e-01 -1.02e+00 -5.77e-01 -2.52e-02 -5.23e-01 -6.53e-01 -7.46e-01 -8.58e-01 -9.06e-01 -2.12e-01 -2.66e-02 -3.40e-01 -4.99e-01 -7.82e-01 -8.41e-01 -8.89e-01 -6.94e-02 -2.75e-02 -1.34e-02 -3.33e-02 -1.18e-01 -8.26e-02 -8.54e-02 -5.62e-02 -9.71e-03 -5.62e-04 -2.72e-03 -6.16e-03 -7.54e-03 -7.55e-03 -6.53e-03 -6.05e-03 -7.58e-01 -7.99e-01 -9.04e-01 -1.01e+00 -1.08e+00 -1.29e-01 -1.03e-02 -7.25e-01 -7.95e-01 -9.18e-01 -1.03e+00 -1.07e+00 -4.41e-01 -1.46e-02 -6.80e-01 -7.67e-01 -8.04e-01 -9.61e-01 -1.14e+00 -9.09e-01 -1.35e-02 -5.92e-01 -7.08e-01 -7.60e-01 -9.05e-01 -9.92e-01 -1.43e-01 -3.23e-02 -5.02e-01 -7.06e-01 -9.01e-01 -8.64e-01 -1.02e+00 -5.44e-01 -1.64e-02 -2.68e-02 -7.22e-02 -2.27e-01 -1.08e-01 -3.77e-01 -1.19e-01 -6.91e-03 -2.26e-03 -5.54e-03 -6.95e-03 -6.66e-03 -6.32e-03 -6.08e-03 -4.89e-03 -9.15e-01 -8.87e-01 -9.13e-01 -1.02e+00 -1.13e+00 -3.85e-01 -1.78e-02 -8.13e-01 -9.00e-01 -9.37e-01 -9.28e-01 -1.10e+00 -2.22e-01 -9.99e-03 -8.40e-01 -8.02e-01 -8.17e-01 -8.90e-01 -1.06e+00 -4.93e-01 -1.48e-02 -7.81e-01 -7.93e-01 -8.16e-01 -8.61e-01 -9.05e-01 -3.58e-01 -8.84e-03 -7.91e-01 -9.00e-01 -9.34e-01 -8.31e-01 -8.31e-01 -6.09e-02 -1.33e-02 -1.06e-01 -1.50e-01 -2.43e-01 -7.38e-02 -2.33e-01 -2.69e-02 -5.07e-03 -4.05e-03 -4.28e-03 -7.13e-03 -8.17e-03 -5.26e-03 -5.20e-03 -3.42e-03 -1.01e+00 -1.09e+00 -1.13e+00 -1.18e+00 -1.22e+00 -1.62e-01 -1.34e-01 -1.05e+00 -1.04e+00 -1.03e+00 -1.01e+00 -1.07e+00 -1.21e-01 -1.49e-02 -1.00e+00 -9.68e-01 -9.64e-01 -9.01e-01 -8.62e-01 -6.59e-02 -7.71e-03 -9.19e-01 -9.37e-01 -8.13e-01 -7.43e-01 -7.51e-01 -3.21e-01 -9.55e-03 -9.63e-01 -1.07e+00 -9.67e-01 -7.12e-01 -6.10e-01 -3.60e-02 -4.68e-03 -8.33e-02 -2.66e-01 -2.62e-01 -5.67e-02 -6.16e-02 -2.22e-02 -3.07e-03 -3.63e-03 -3.42e-03 -4.15e-03 -4.88e-03 -3.39e-03 -2.76e-03 -2.65e-03 -1.41e+00 -1.36e+00 -1.42e+00 -1.28e+00 -1.35e+00 -1.12e-01 -1.28e-02 -1.26e+00 -1.24e+00 -1.19e+00 -1.26e+00 -1.18e+00 -7.42e-02 -1.15e-02 -1.09e+00 -1.11e+00 -1.10e+00 -9.79e-01 -9.01e-01 -9.64e-02 -7.63e-03 -1.11e+00 -1.19e+00 -9.95e-01 -8.35e-01 -7.23e-01 -5.53e-02 -4.29e-03 -1.28e+00 -1.16e+00 -9.47e-01 -6.30e-01 -4.16e-01 -4.06e-02 -3.13e-03 -4.27e-01 -3.94e-01 -7.67e-02 -6.12e-02 -3.77e-02 -8.74e-03 -1.70e-03 -5.41e-03 -4.48e-03 -3.06e-03 -2.62e-03 -2.16e-03 -1.25e-03 -1.18e-03 -2.39e+00 -6.90e-01 -2.50e+00 -1.50e-01 -1.56e-01 -5.36e-01 -7.11e-03 -1.50e+00 -2.18e-01 -8.93e-01 -1.20e+00 -3.77e-01 -5.66e-02 -5.84e-03 -1.72e+00 -1.15e+00 -2.77e-01 -2.84e-01 -8.51e-02 -4.01e-02 -4.09e-03 -8.84e-01 -3.28e-01 -3.07e-01 -1.60e-01 -6.60e-02 -3.37e-02 -3.08e-03 -1.74e-01 -8.27e-02 -9.77e-02 -4.36e-02 -4.51e-02 -1.03e-02 -1.71e-03 -3.98e-01 -1.30e-01 -8.25e-02 -3.33e-02 -1.30e-02 -2.87e-03 -7.05e-04 -8.08e-03 -7.43e-03 -4.18e-03 -1.97e-03 -1.18e-03 -6.58e-04 -2.80e-04 -5.36e-03 -4.96e-03 -8.16e-03 -3.01e-02 -6.48e-03 -1.43e-02 -1.49e-02 -5.08e-03 -6.57e-03 -6.95e-03 -1.31e-02 -8.44e-03 -1.20e-02 -1.98e-02 -6.30e-03 -8.90e-03 -6.49e-03 -5.28e-03 -8.94e-03 -7.00e-03 -1.59e-02 -9.64e-03 -8.62e-03 -8.88e-03 -4.21e-03 -4.33e-03 -4.00e-03 -5.04e-03 -7.71e-03 -6.51e-03 -5.56e-03 -4.90e-03 -2.51e-03 -1.55e-03 -1.75e-03 -6.19e-03 -8.31e-03 -4.10e-03 -2.65e-03 -1.81e-03 -6.34e-04 -3.01e-04 -3.14e-03 -3.10e-03 -2.51e-03 -2.14e-03 -1.47e-03 -2.69e-04 -3.12e-05 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows_fw_cadis_local/test.py b/tests/regression_tests/weightwindows_fw_cadis_local/test.py deleted file mode 100644 index abd3f2098..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_local/test.py +++ /dev/null @@ -1,42 +0,0 @@ -import os - -import openmc -from openmc.examples import random_ray_three_region_cube_with_detectors - -from tests.testing_harness import WeightWindowPyAPITestHarness - - -class MGXSTestHarness(WeightWindowPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -def test_weight_windows_fw_cadis_local(): - model = random_ray_three_region_cube_with_detectors() - - for tally in list(model.tallies): - if tally.name in {"Source Tally", "Absorber Tally", "Cavity Tally"}: - # leave only the tallies of interest - model.tallies.remove(tally) - - ww_mesh = openmc.RegularMesh() - n = 7 - width = 35.0 - ww_mesh.dimension = (n, n, n) - ww_mesh.lower_left = (0.0, 0.0, 0.0) - ww_mesh.upper_right = (width, width, width) - - wwg = openmc.WeightWindowGenerator( - method="fw_cadis", - targets=model.tallies, - mesh=ww_mesh, - max_realizations=model.settings.batches - ) - model.settings.weight_window_generators = wwg - model.settings.random_ray['volume_estimator'] = 'naive' - - harness = MGXSTestHarness('statepoint.10.h5', model) - harness.main() diff --git a/tests/regression_tests/weightwindows_fw_cadis_mesh/__init__.py b/tests/regression_tests/weightwindows_fw_cadis_mesh/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/weightwindows_fw_cadis_mesh/flat/inputs_true.dat b/tests/regression_tests/weightwindows_fw_cadis_mesh/flat/inputs_true.dat deleted file mode 100644 index a0d84257a..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_mesh/flat/inputs_true.dat +++ /dev/null @@ -1,267 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 750 - 30 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - - 1 - neutron - 10 - 1 - true - fw_cadis - - - - 15 15 15 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - - flat - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/weightwindows_fw_cadis_mesh/flat/results_true.dat b/tests/regression_tests/weightwindows_fw_cadis_mesh/flat/results_true.dat deleted file mode 100644 index 0354501d1..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_mesh/flat/results_true.dat +++ /dev/null @@ -1,6760 +0,0 @@ -RegularMesh - ID = 1 - Name = - Dimensions = 3 - Voxels = [15 15 15] - Lower left = [0. 0. 0.] - Upper Right = [np.float64(30.0), np.float64(30.0), np.float64(30.0)] - Width = [2. 2. 2.] -Lower Bounds -1.71e-01 -1.73e-01 -1.72e-01 -1.73e-01 -1.71e-01 -1.63e-01 -1.66e-01 -1.70e-01 -1.68e-01 -1.76e-01 -1.73e-01 -1.79e-01 -2.62e-01 -4.44e-01 -1.68e-01 -1.63e-01 -1.76e-01 -1.73e-01 -1.52e-01 -1.66e-01 -1.72e-01 -1.68e-01 -1.68e-01 -1.66e-01 -1.67e-01 -1.76e-01 -1.73e-01 -2.44e-01 -3.63e-01 -1.22e-01 -1.71e-01 -1.66e-01 -1.69e-01 -1.70e-01 -1.67e-01 -1.71e-01 -1.64e-01 -1.55e-01 -1.67e-01 -1.64e-01 -1.68e-01 -1.82e-01 -2.60e-01 -4.13e-01 -1.55e-01 -1.68e-01 -1.62e-01 -1.66e-01 -1.65e-01 -1.62e-01 -1.64e-01 -1.63e-01 -1.66e-01 -1.63e-01 -1.67e-01 -1.58e-01 -1.79e-01 -2.52e-01 -4.10e-01 -1.35e-01 -1.65e-01 -1.74e-01 -1.67e-01 -1.71e-01 -1.66e-01 -1.62e-01 -1.60e-01 -1.66e-01 -1.55e-01 -1.67e-01 -1.66e-01 -1.82e-01 -2.68e-01 -3.46e-01 -1.32e-01 -1.70e-01 -1.70e-01 -1.68e-01 -1.68e-01 -1.69e-01 -1.59e-01 -1.62e-01 -1.59e-01 -1.57e-01 -1.55e-01 -1.72e-01 -1.80e-01 -2.59e-01 -2.97e-01 -1.06e-01 -1.68e-01 -1.60e-01 -1.58e-01 -1.61e-01 -1.58e-01 -1.59e-01 -1.56e-01 -1.53e-01 -1.57e-01 -1.52e-01 -1.59e-01 -1.54e-01 -2.42e-01 -3.30e-01 -1.22e-01 -1.64e-01 -1.65e-01 -1.69e-01 -1.64e-01 -1.60e-01 -1.66e-01 -1.60e-01 -1.52e-01 -1.45e-01 -1.53e-01 -1.57e-01 -1.40e-01 -2.08e-01 -1.90e-01 -7.93e-02 -1.65e-01 -1.65e-01 -1.71e-01 -1.72e-01 -1.63e-01 -1.61e-01 -1.57e-01 -1.54e-01 -1.49e-01 -1.41e-01 -1.45e-01 -1.53e-01 -2.36e-01 -1.80e-01 -5.76e-02 -1.67e-01 -1.75e-01 -1.74e-01 -1.71e-01 -1.66e-01 -1.54e-01 -1.55e-01 -1.52e-01 -1.53e-01 -1.41e-01 -1.53e-01 -1.49e-01 -2.14e-01 -1.76e-01 -6.70e-02 -1.72e-01 -1.66e-01 -1.74e-01 -1.70e-01 -1.69e-01 -1.57e-01 -1.50e-01 -1.53e-01 -1.48e-01 -1.47e-01 -1.62e-01 -1.49e-01 -2.03e-01 -1.35e-01 -4.07e-02 -1.81e-01 -1.80e-01 -1.72e-01 -1.65e-01 -1.84e-01 -1.74e-01 -1.58e-01 -1.68e-01 -1.59e-01 -1.57e-01 -1.58e-01 -1.48e-01 -2.16e-01 -1.05e-01 -3.37e-02 -2.61e-01 -2.52e-01 -2.37e-01 -2.51e-01 -2.64e-01 -2.42e-01 -2.39e-01 -2.32e-01 -2.32e-01 -2.29e-01 -2.22e-01 -2.19e-01 -2.07e-01 -8.02e-02 -2.21e-02 -5.00e-01 -3.68e-01 -3.88e-01 -2.65e-01 -2.86e-01 -3.17e-01 -2.60e-01 -2.38e-01 -1.88e-01 -1.97e-01 -1.84e-01 -1.50e-01 -9.98e-02 -3.88e-02 -1.90e-02 -2.18e-01 -1.48e-01 -1.61e-01 -8.76e-02 -9.43e-02 -1.16e-01 -8.45e-02 -8.13e-02 -7.00e-02 -6.16e-02 -6.49e-02 -4.46e-02 -3.71e-02 -1.62e-02 -7.33e-03 -1.70e-01 -1.69e-01 -1.70e-01 -1.68e-01 -1.63e-01 -1.59e-01 -1.75e-01 -1.69e-01 -1.59e-01 -1.64e-01 -1.77e-01 -1.79e-01 -2.63e-01 -3.92e-01 -1.48e-01 -1.73e-01 -1.74e-01 -1.70e-01 -1.66e-01 -1.68e-01 -1.62e-01 -1.62e-01 -1.67e-01 -1.60e-01 -1.64e-01 -1.67e-01 -1.80e-01 -2.42e-01 -3.72e-01 -1.45e-01 -1.71e-01 -1.65e-01 -1.67e-01 -1.65e-01 -1.69e-01 -1.70e-01 -1.64e-01 -1.68e-01 -1.60e-01 -1.70e-01 -1.70e-01 -1.74e-01 -2.62e-01 -3.29e-01 -1.15e-01 -1.73e-01 -1.75e-01 -1.70e-01 -1.69e-01 -1.69e-01 -1.63e-01 -1.66e-01 -1.63e-01 -1.61e-01 -1.61e-01 -1.70e-01 -1.79e-01 -2.47e-01 -3.64e-01 -1.32e-01 -1.72e-01 -1.73e-01 -1.71e-01 -1.66e-01 -1.63e-01 -1.63e-01 -1.67e-01 -1.60e-01 -1.56e-01 -1.63e-01 -1.72e-01 -1.71e-01 -2.52e-01 -3.43e-01 -1.40e-01 -1.68e-01 -1.70e-01 -1.67e-01 -1.66e-01 -1.72e-01 -1.61e-01 -1.56e-01 -1.56e-01 -1.53e-01 -1.55e-01 -1.65e-01 -1.78e-01 -2.53e-01 -3.66e-01 -1.33e-01 -1.70e-01 -1.69e-01 -1.60e-01 -1.64e-01 -1.70e-01 -1.63e-01 -1.53e-01 -1.50e-01 -1.50e-01 -1.48e-01 -1.53e-01 -1.66e-01 -2.34e-01 -2.99e-01 -1.15e-01 -1.65e-01 -1.63e-01 -1.59e-01 -1.57e-01 -1.59e-01 -1.54e-01 -1.54e-01 -1.47e-01 -1.40e-01 -1.38e-01 -1.27e-01 -1.22e-01 -1.99e-01 -1.77e-01 -7.13e-02 -1.58e-01 -1.75e-01 -1.68e-01 -1.66e-01 -1.66e-01 -1.58e-01 -1.56e-01 -1.44e-01 -1.48e-01 -1.45e-01 -1.37e-01 -1.40e-01 -2.01e-01 -1.36e-01 -4.17e-02 -1.65e-01 -1.76e-01 -1.69e-01 -1.69e-01 -1.57e-01 -1.67e-01 -1.56e-01 -1.50e-01 -1.53e-01 -1.43e-01 -1.51e-01 -1.41e-01 -2.04e-01 -1.50e-01 -4.51e-02 -1.69e-01 -1.75e-01 -1.71e-01 -1.63e-01 -1.69e-01 -1.67e-01 -1.60e-01 -1.50e-01 -1.53e-01 -1.44e-01 -1.57e-01 -1.49e-01 -2.02e-01 -1.35e-01 -4.08e-02 -1.79e-01 -1.72e-01 -1.73e-01 -1.70e-01 -1.74e-01 -1.78e-01 -1.68e-01 -1.59e-01 -1.57e-01 -1.62e-01 -1.62e-01 -1.57e-01 -1.95e-01 -9.20e-02 -3.15e-02 -2.48e-01 -2.65e-01 -2.54e-01 -2.58e-01 -2.80e-01 -2.53e-01 -2.33e-01 -2.40e-01 -2.16e-01 -2.19e-01 -2.43e-01 -2.22e-01 -1.99e-01 -6.18e-02 -1.77e-02 -3.13e-01 -2.98e-01 -2.98e-01 -3.16e-01 -3.67e-01 -3.51e-01 -2.81e-01 -2.76e-01 -2.24e-01 -1.66e-01 -1.70e-01 -1.65e-01 -1.10e-01 -3.67e-02 -1.54e-02 -1.11e-01 -1.10e-01 -1.18e-01 -1.08e-01 -1.34e-01 -1.41e-01 -9.92e-02 -9.96e-02 -9.39e-02 -5.19e-02 -5.40e-02 -5.45e-02 -4.22e-02 -1.88e-02 -7.33e-03 -1.73e-01 -1.68e-01 -1.74e-01 -1.68e-01 -1.60e-01 -1.60e-01 -1.61e-01 -1.59e-01 -1.70e-01 -1.61e-01 -1.62e-01 -1.76e-01 -2.90e-01 -4.08e-01 -1.58e-01 -1.72e-01 -1.68e-01 -1.62e-01 -1.66e-01 -1.59e-01 -1.63e-01 -1.58e-01 -1.60e-01 -1.59e-01 -1.65e-01 -1.63e-01 -1.77e-01 -2.45e-01 -3.92e-01 -1.64e-01 -1.71e-01 -1.74e-01 -1.72e-01 -1.57e-01 -1.65e-01 -1.63e-01 -1.63e-01 -1.69e-01 -1.58e-01 -1.61e-01 -1.61e-01 -1.77e-01 -2.45e-01 -3.36e-01 -1.29e-01 -1.57e-01 -1.67e-01 -1.66e-01 -1.63e-01 -1.63e-01 -1.59e-01 -1.61e-01 -1.65e-01 -1.56e-01 -1.59e-01 -1.65e-01 -1.59e-01 -2.43e-01 -3.30e-01 -1.08e-01 -1.62e-01 -1.62e-01 -1.61e-01 -1.54e-01 -1.63e-01 -1.64e-01 -1.50e-01 -1.57e-01 -1.51e-01 -1.50e-01 -1.67e-01 -1.72e-01 -2.44e-01 -2.79e-01 -8.59e-02 -1.61e-01 -1.64e-01 -1.57e-01 -1.55e-01 -1.57e-01 -1.57e-01 -1.51e-01 -1.49e-01 -1.54e-01 -1.56e-01 -1.67e-01 -1.69e-01 -2.42e-01 -3.48e-01 -1.32e-01 -1.67e-01 -1.73e-01 -1.64e-01 -1.62e-01 -1.60e-01 -1.61e-01 -1.56e-01 -1.47e-01 -1.51e-01 -1.54e-01 -1.57e-01 -1.59e-01 -2.26e-01 -2.53e-01 -9.32e-02 -1.63e-01 -1.63e-01 -1.60e-01 -1.55e-01 -1.57e-01 -1.58e-01 -1.54e-01 -1.47e-01 -1.46e-01 -1.48e-01 -1.43e-01 -1.50e-01 -2.09e-01 -1.68e-01 -6.28e-02 -1.57e-01 -1.64e-01 -1.64e-01 -1.60e-01 -1.60e-01 -1.58e-01 -1.58e-01 -1.57e-01 -1.47e-01 -1.50e-01 -1.52e-01 -1.43e-01 -2.11e-01 -1.66e-01 -6.17e-02 -1.65e-01 -1.72e-01 -1.62e-01 -1.64e-01 -1.66e-01 -1.57e-01 -1.57e-01 -1.50e-01 -1.40e-01 -1.48e-01 -1.46e-01 -1.44e-01 -1.95e-01 -1.25e-01 -4.98e-02 -1.61e-01 -1.66e-01 -1.70e-01 -1.64e-01 -1.67e-01 -1.67e-01 -1.68e-01 -1.58e-01 -1.43e-01 -1.45e-01 -1.46e-01 -1.43e-01 -1.94e-01 -1.25e-01 -3.60e-02 -1.61e-01 -1.74e-01 -1.74e-01 -1.76e-01 -1.73e-01 -1.72e-01 -1.68e-01 -1.61e-01 -1.59e-01 -1.56e-01 -1.59e-01 -1.57e-01 -1.77e-01 -1.09e-01 -3.74e-02 -2.48e-01 -2.48e-01 -2.49e-01 -2.42e-01 -2.47e-01 -2.55e-01 -2.19e-01 -2.25e-01 -2.25e-01 -2.17e-01 -2.21e-01 -2.26e-01 -2.15e-01 -6.24e-02 -1.90e-02 -3.68e-01 -2.72e-01 -3.41e-01 -3.58e-01 -3.64e-01 -2.32e-01 -2.34e-01 -2.20e-01 -1.88e-01 -1.77e-01 -1.34e-01 -1.25e-01 -1.07e-01 -4.68e-02 -1.29e-02 -1.29e-01 -8.63e-02 -1.42e-01 -1.36e-01 -1.37e-01 -8.94e-02 -8.09e-02 -8.37e-02 -5.69e-02 -6.45e-02 -3.15e-02 -3.86e-02 -3.51e-02 -2.57e-02 -1.29e-02 -1.69e-01 -1.62e-01 -1.66e-01 -1.70e-01 -1.69e-01 -1.61e-01 -1.58e-01 -1.51e-01 -1.52e-01 -1.53e-01 -1.52e-01 -1.73e-01 -2.54e-01 -4.12e-01 -1.51e-01 -1.68e-01 -1.75e-01 -1.65e-01 -1.59e-01 -1.62e-01 -1.56e-01 -1.57e-01 -1.55e-01 -1.59e-01 -1.66e-01 -1.59e-01 -1.67e-01 -2.35e-01 -3.25e-01 -1.29e-01 -1.62e-01 -1.64e-01 -1.68e-01 -1.59e-01 -1.51e-01 -1.59e-01 -1.53e-01 -1.53e-01 -1.55e-01 -1.63e-01 -1.60e-01 -1.65e-01 -2.33e-01 -2.78e-01 -1.07e-01 -1.62e-01 -1.63e-01 -1.60e-01 -1.61e-01 -1.54e-01 -1.57e-01 -1.59e-01 -1.51e-01 -1.51e-01 -1.58e-01 -1.54e-01 -1.61e-01 -2.39e-01 -2.48e-01 -1.01e-01 -1.55e-01 -1.54e-01 -1.61e-01 -1.66e-01 -1.55e-01 -1.53e-01 -1.56e-01 -1.51e-01 -1.48e-01 -1.53e-01 -1.63e-01 -1.62e-01 -2.42e-01 -3.21e-01 -1.18e-01 -1.66e-01 -1.52e-01 -1.62e-01 -1.62e-01 -1.56e-01 -1.52e-01 -1.55e-01 -1.57e-01 -1.55e-01 -1.53e-01 -1.53e-01 -1.64e-01 -2.46e-01 -3.02e-01 -1.11e-01 -1.63e-01 -1.59e-01 -1.68e-01 -1.59e-01 -1.52e-01 -1.54e-01 -1.56e-01 -1.49e-01 -1.49e-01 -1.51e-01 -1.45e-01 -1.49e-01 -2.22e-01 -2.88e-01 -1.02e-01 -1.66e-01 -1.62e-01 -1.61e-01 -1.50e-01 -1.50e-01 -1.51e-01 -1.59e-01 -1.46e-01 -1.43e-01 -1.42e-01 -1.41e-01 -1.51e-01 -2.22e-01 -1.88e-01 -6.51e-02 -1.60e-01 -1.59e-01 -1.57e-01 -1.61e-01 -1.55e-01 -1.57e-01 -1.53e-01 -1.53e-01 -1.45e-01 -1.44e-01 -1.47e-01 -1.59e-01 -2.35e-01 -1.91e-01 -5.69e-02 -1.62e-01 -1.59e-01 -1.63e-01 -1.59e-01 -1.55e-01 -1.54e-01 -1.50e-01 -1.47e-01 -1.50e-01 -1.46e-01 -1.43e-01 -1.43e-01 -2.21e-01 -1.37e-01 -5.36e-02 -1.66e-01 -1.65e-01 -1.50e-01 -1.68e-01 -1.65e-01 -1.61e-01 -1.55e-01 -1.49e-01 -1.47e-01 -1.51e-01 -1.43e-01 -1.50e-01 -1.92e-01 -9.97e-02 -2.93e-02 -1.73e-01 -1.65e-01 -1.70e-01 -1.66e-01 -1.73e-01 -1.78e-01 -1.65e-01 -1.50e-01 -1.60e-01 -1.55e-01 -1.57e-01 -1.55e-01 -1.89e-01 -8.91e-02 -2.68e-02 -2.32e-01 -2.36e-01 -2.40e-01 -2.31e-01 -2.41e-01 -2.39e-01 -2.01e-01 -2.12e-01 -2.21e-01 -2.12e-01 -2.04e-01 -2.02e-01 -2.14e-01 -8.26e-02 -2.65e-02 -3.06e-01 -2.51e-01 -2.10e-01 -2.95e-01 -2.86e-01 -2.41e-01 -1.69e-01 -1.21e-01 -1.92e-01 -1.82e-01 -1.29e-01 -1.24e-01 -1.04e-01 -4.53e-02 -1.74e-02 -1.16e-01 -8.31e-02 -8.94e-02 -9.43e-02 -1.16e-01 -9.01e-02 -7.46e-02 -3.83e-02 -6.35e-02 -6.43e-02 -4.23e-02 -4.16e-02 -3.17e-02 -2.60e-02 -1.26e-02 -1.63e-01 -1.58e-01 -1.60e-01 -1.62e-01 -1.60e-01 -1.59e-01 -1.60e-01 -1.51e-01 -1.47e-01 -1.55e-01 -1.51e-01 -1.68e-01 -2.47e-01 -3.18e-01 -1.27e-01 -1.64e-01 -1.61e-01 -1.56e-01 -1.63e-01 -1.63e-01 -1.54e-01 -1.50e-01 -1.49e-01 -1.56e-01 -1.58e-01 -1.58e-01 -1.64e-01 -2.39e-01 -3.04e-01 -1.13e-01 -1.65e-01 -1.63e-01 -1.62e-01 -1.57e-01 -1.57e-01 -1.57e-01 -1.53e-01 -1.49e-01 -1.57e-01 -1.63e-01 -1.63e-01 -1.70e-01 -2.39e-01 -2.29e-01 -8.46e-02 -1.62e-01 -1.63e-01 -1.58e-01 -1.58e-01 -1.56e-01 -1.55e-01 -1.50e-01 -1.51e-01 -1.52e-01 -1.60e-01 -1.57e-01 -1.64e-01 -2.46e-01 -2.16e-01 -7.36e-02 -1.56e-01 -1.54e-01 -1.56e-01 -1.62e-01 -1.52e-01 -1.50e-01 -1.55e-01 -1.52e-01 -1.52e-01 -1.50e-01 -1.58e-01 -1.67e-01 -2.47e-01 -3.21e-01 -1.15e-01 -1.57e-01 -1.55e-01 -1.56e-01 -1.58e-01 -1.48e-01 -1.43e-01 -1.42e-01 -1.56e-01 -1.49e-01 -1.52e-01 -1.51e-01 -1.58e-01 -2.31e-01 -2.63e-01 -9.53e-02 -1.48e-01 -1.56e-01 -1.59e-01 -1.52e-01 -1.60e-01 -1.43e-01 -1.43e-01 -1.44e-01 -1.45e-01 -1.43e-01 -1.48e-01 -1.51e-01 -2.09e-01 -2.10e-01 -7.84e-02 -1.57e-01 -1.60e-01 -1.55e-01 -1.53e-01 -1.57e-01 -1.44e-01 -1.44e-01 -1.36e-01 -1.36e-01 -1.46e-01 -1.43e-01 -1.46e-01 -2.17e-01 -1.67e-01 -7.08e-02 -1.59e-01 -1.56e-01 -1.56e-01 -1.54e-01 -1.53e-01 -1.52e-01 -1.50e-01 -1.42e-01 -1.37e-01 -1.39e-01 -1.41e-01 -1.47e-01 -2.03e-01 -1.75e-01 -5.51e-02 -1.63e-01 -1.62e-01 -1.57e-01 -1.53e-01 -1.45e-01 -1.52e-01 -1.52e-01 -1.43e-01 -1.41e-01 -1.38e-01 -1.39e-01 -1.52e-01 -2.05e-01 -1.61e-01 -6.97e-02 -1.62e-01 -1.56e-01 -1.58e-01 -1.55e-01 -1.58e-01 -1.56e-01 -1.53e-01 -1.53e-01 -1.49e-01 -1.41e-01 -1.44e-01 -1.57e-01 -2.11e-01 -1.22e-01 -4.27e-02 -1.66e-01 -1.69e-01 -1.61e-01 -1.62e-01 -1.68e-01 -1.74e-01 -1.60e-01 -1.57e-01 -1.57e-01 -1.62e-01 -1.48e-01 -1.54e-01 -2.17e-01 -1.14e-01 -3.49e-02 -2.43e-01 -2.30e-01 -2.33e-01 -2.43e-01 -2.45e-01 -2.48e-01 -2.46e-01 -2.21e-01 -2.22e-01 -2.12e-01 -2.00e-01 -2.02e-01 -2.14e-01 -8.94e-02 -3.01e-02 -2.79e-01 -2.63e-01 -2.52e-01 -2.63e-01 -3.00e-01 -2.68e-01 -2.93e-01 -1.90e-01 -2.03e-01 -1.54e-01 -1.13e-01 -1.27e-01 -8.82e-02 -3.87e-02 -1.55e-02 -1.03e-01 -9.09e-02 -9.09e-02 -8.99e-02 -1.07e-01 -8.75e-02 -1.17e-01 -5.67e-02 -7.16e-02 -5.22e-02 -3.31e-02 -3.49e-02 -2.69e-02 -1.66e-02 -1.14e-02 -1.46e-01 -1.55e-01 -1.57e-01 -1.59e-01 -1.63e-01 -1.54e-01 -1.49e-01 -1.48e-01 -1.45e-01 -1.48e-01 -1.48e-01 -1.54e-01 -2.45e-01 -2.69e-01 -8.34e-02 -1.54e-01 -1.59e-01 -1.57e-01 -1.51e-01 -1.55e-01 -1.57e-01 -1.60e-01 -1.49e-01 -1.54e-01 -1.50e-01 -1.54e-01 -1.62e-01 -2.41e-01 -2.97e-01 -1.15e-01 -1.60e-01 -1.61e-01 -1.61e-01 -1.53e-01 -1.56e-01 -1.52e-01 -1.53e-01 -1.57e-01 -1.52e-01 -1.52e-01 -1.55e-01 -1.69e-01 -2.49e-01 -2.52e-01 -8.15e-02 -1.59e-01 -1.59e-01 -1.52e-01 -1.50e-01 -1.53e-01 -1.59e-01 -1.47e-01 -1.51e-01 -1.51e-01 -1.56e-01 -1.56e-01 -1.64e-01 -2.40e-01 -2.46e-01 -8.06e-02 -1.58e-01 -1.59e-01 -1.58e-01 -1.56e-01 -1.53e-01 -1.46e-01 -1.48e-01 -1.48e-01 -1.47e-01 -1.53e-01 -1.48e-01 -1.62e-01 -2.39e-01 -2.66e-01 -1.02e-01 -1.55e-01 -1.54e-01 -1.57e-01 -1.52e-01 -1.48e-01 -1.50e-01 -1.40e-01 -1.37e-01 -1.50e-01 -1.50e-01 -1.46e-01 -1.52e-01 -2.23e-01 -2.22e-01 -8.99e-02 -1.58e-01 -1.60e-01 -1.54e-01 -1.47e-01 -1.47e-01 -1.45e-01 -1.42e-01 -1.28e-01 -1.33e-01 -1.40e-01 -1.51e-01 -1.53e-01 -2.08e-01 -1.44e-01 -5.19e-02 -1.57e-01 -1.54e-01 -1.54e-01 -1.42e-01 -1.51e-01 -1.44e-01 -1.35e-01 -1.28e-01 -1.11e-01 -1.40e-01 -1.49e-01 -1.55e-01 -2.22e-01 -1.31e-01 -4.13e-02 -1.56e-01 -1.53e-01 -1.57e-01 -1.42e-01 -1.52e-01 -1.49e-01 -1.45e-01 -1.32e-01 -1.30e-01 -1.27e-01 -1.41e-01 -1.41e-01 -2.11e-01 -1.55e-01 -4.43e-02 -1.49e-01 -1.52e-01 -1.53e-01 -1.56e-01 -1.47e-01 -1.45e-01 -1.40e-01 -1.37e-01 -1.43e-01 -1.35e-01 -1.34e-01 -1.42e-01 -1.98e-01 -1.25e-01 -3.99e-02 -1.57e-01 -1.48e-01 -1.49e-01 -1.52e-01 -1.50e-01 -1.48e-01 -1.50e-01 -1.48e-01 -1.44e-01 -1.43e-01 -1.35e-01 -1.39e-01 -1.94e-01 -1.07e-01 -3.11e-02 -1.62e-01 -1.61e-01 -1.61e-01 -1.63e-01 -1.63e-01 -1.60e-01 -1.55e-01 -1.55e-01 -1.50e-01 -1.56e-01 -1.43e-01 -1.32e-01 -1.83e-01 -1.02e-01 -2.51e-02 -2.34e-01 -2.25e-01 -2.20e-01 -2.27e-01 -2.41e-01 -2.34e-01 -2.13e-01 -2.04e-01 -2.13e-01 -2.16e-01 -2.20e-01 -1.80e-01 -1.76e-01 -9.68e-02 -3.54e-02 -3.12e-01 -2.64e-01 -2.26e-01 -2.68e-01 -2.60e-01 -2.43e-01 -2.35e-01 -1.81e-01 -1.60e-01 -1.47e-01 -1.51e-01 -1.34e-01 -7.35e-02 -4.05e-02 -2.19e-02 -1.06e-01 -9.90e-02 -8.77e-02 -9.61e-02 -9.91e-02 -7.56e-02 -1.05e-01 -6.20e-02 -5.67e-02 -3.97e-02 -4.31e-02 -4.78e-02 -2.87e-02 -1.59e-02 -8.92e-03 -1.61e-01 -1.59e-01 -1.56e-01 -1.59e-01 -1.51e-01 -1.49e-01 -1.54e-01 -1.51e-01 -1.53e-01 -1.48e-01 -1.52e-01 -1.48e-01 -2.27e-01 -1.82e-01 -8.22e-02 -1.61e-01 -1.54e-01 -1.57e-01 -1.56e-01 -1.53e-01 -1.49e-01 -1.46e-01 -1.41e-01 -1.51e-01 -1.51e-01 -1.52e-01 -1.52e-01 -2.22e-01 -2.08e-01 -7.81e-02 -1.54e-01 -1.58e-01 -1.52e-01 -1.53e-01 -1.48e-01 -1.49e-01 -1.45e-01 -1.43e-01 -1.44e-01 -1.48e-01 -1.58e-01 -1.55e-01 -2.25e-01 -2.48e-01 -1.01e-01 -1.57e-01 -1.48e-01 -1.51e-01 -1.47e-01 -1.46e-01 -1.52e-01 -1.48e-01 -1.47e-01 -1.46e-01 -1.48e-01 -1.49e-01 -1.57e-01 -2.21e-01 -1.69e-01 -6.52e-02 -1.57e-01 -1.55e-01 -1.55e-01 -1.53e-01 -1.51e-01 -1.55e-01 -1.46e-01 -1.49e-01 -1.42e-01 -1.45e-01 -1.45e-01 -1.57e-01 -2.19e-01 -1.36e-01 -4.96e-02 -1.57e-01 -1.50e-01 -1.53e-01 -1.57e-01 -1.54e-01 -1.50e-01 -1.45e-01 -1.40e-01 -1.30e-01 -1.38e-01 -1.42e-01 -1.51e-01 -2.13e-01 -1.41e-01 -4.31e-02 -1.56e-01 -1.57e-01 -1.53e-01 -1.52e-01 -1.51e-01 -1.44e-01 -1.42e-01 -1.28e-01 -1.21e-01 -1.26e-01 -1.40e-01 -1.53e-01 -2.16e-01 -1.61e-01 -4.81e-02 -1.48e-01 -1.48e-01 -1.47e-01 -1.49e-01 -1.49e-01 -1.43e-01 -1.40e-01 -1.23e-01 -8.97e-02 -1.34e-01 -1.43e-01 -1.48e-01 -2.10e-01 -1.68e-01 -5.02e-02 -1.53e-01 -1.48e-01 -1.47e-01 -1.48e-01 -1.43e-01 -1.46e-01 -1.42e-01 -1.27e-01 -1.24e-01 -1.31e-01 -1.42e-01 -1.48e-01 -2.01e-01 -1.56e-01 -5.15e-02 -1.50e-01 -1.52e-01 -1.52e-01 -1.47e-01 -1.42e-01 -1.35e-01 -1.39e-01 -1.38e-01 -1.37e-01 -1.35e-01 -1.36e-01 -1.36e-01 -1.92e-01 -1.22e-01 -4.76e-02 -1.52e-01 -1.61e-01 -1.49e-01 -1.45e-01 -1.40e-01 -1.40e-01 -1.34e-01 -1.35e-01 -1.38e-01 -1.38e-01 -1.27e-01 -1.35e-01 -1.77e-01 -7.50e-02 -2.64e-02 -1.58e-01 -1.55e-01 -1.50e-01 -1.45e-01 -1.50e-01 -1.50e-01 -1.42e-01 -1.42e-01 -1.52e-01 -1.46e-01 -1.38e-01 -1.30e-01 -1.44e-01 -6.83e-02 -2.86e-02 -2.28e-01 -2.11e-01 -2.08e-01 -2.12e-01 -2.17e-01 -2.09e-01 -2.06e-01 -1.89e-01 -2.08e-01 -1.88e-01 -1.88e-01 -1.66e-01 -1.33e-01 -4.13e-02 -1.70e-02 -2.67e-01 -2.70e-01 -2.31e-01 -1.72e-01 -1.66e-01 -2.16e-01 -1.96e-01 -1.52e-01 -1.41e-01 -1.31e-01 -1.44e-01 -1.17e-01 -4.82e-02 -2.09e-02 -8.63e-03 -9.47e-02 -1.04e-01 -9.02e-02 -5.55e-02 -5.39e-02 -6.95e-02 -7.10e-02 -4.92e-02 -4.73e-02 -3.52e-02 -4.69e-02 -4.03e-02 -1.69e-02 -9.25e-03 -5.98e-03 -1.46e-01 -1.50e-01 -1.48e-01 -1.53e-01 -1.56e-01 -1.57e-01 -1.56e-01 -1.54e-01 -1.44e-01 -1.42e-01 -1.44e-01 -1.52e-01 -2.10e-01 -1.56e-01 -5.53e-02 -1.50e-01 -1.57e-01 -1.57e-01 -1.57e-01 -1.54e-01 -1.51e-01 -1.52e-01 -1.42e-01 -1.42e-01 -1.39e-01 -1.45e-01 -1.50e-01 -2.11e-01 -1.18e-01 -3.92e-02 -1.49e-01 -1.48e-01 -1.55e-01 -1.54e-01 -1.51e-01 -1.50e-01 -1.48e-01 -1.48e-01 -1.41e-01 -1.38e-01 -1.45e-01 -1.54e-01 -2.08e-01 -1.62e-01 -5.89e-02 -1.48e-01 -1.49e-01 -1.51e-01 -1.50e-01 -1.51e-01 -1.49e-01 -1.48e-01 -1.47e-01 -1.34e-01 -1.33e-01 -1.53e-01 -1.54e-01 -1.96e-01 -1.55e-01 -6.15e-02 -1.51e-01 -1.53e-01 -1.59e-01 -1.48e-01 -1.51e-01 -1.48e-01 -1.45e-01 -1.41e-01 -1.38e-01 -1.37e-01 -1.49e-01 -1.46e-01 -2.06e-01 -1.25e-01 -3.47e-02 -1.51e-01 -1.47e-01 -1.52e-01 -1.53e-01 -1.44e-01 -1.40e-01 -1.45e-01 -1.38e-01 -1.39e-01 -1.34e-01 -1.36e-01 -1.50e-01 -1.95e-01 -1.29e-01 -4.48e-02 -1.49e-01 -1.43e-01 -1.49e-01 -1.46e-01 -1.48e-01 -1.42e-01 -1.35e-01 -1.27e-01 -1.24e-01 -1.26e-01 -1.29e-01 -1.38e-01 -1.87e-01 -1.53e-01 -5.84e-02 -1.46e-01 -1.51e-01 -1.44e-01 -1.45e-01 -1.45e-01 -1.41e-01 -1.31e-01 -1.24e-01 -1.29e-01 -1.30e-01 -1.43e-01 -1.42e-01 -1.91e-01 -1.36e-01 -5.08e-02 -1.39e-01 -1.40e-01 -1.43e-01 -1.39e-01 -1.43e-01 -1.39e-01 -1.35e-01 -1.27e-01 -1.23e-01 -1.22e-01 -1.41e-01 -1.37e-01 -1.86e-01 -1.09e-01 -3.41e-02 -1.44e-01 -1.41e-01 -1.44e-01 -1.37e-01 -1.37e-01 -1.39e-01 -1.29e-01 -1.33e-01 -1.20e-01 -1.18e-01 -1.29e-01 -1.36e-01 -1.94e-01 -1.23e-01 -3.96e-02 -1.50e-01 -1.47e-01 -1.48e-01 -1.39e-01 -1.35e-01 -1.36e-01 -1.34e-01 -1.40e-01 -1.32e-01 -1.27e-01 -1.23e-01 -1.26e-01 -1.61e-01 -8.34e-02 -2.18e-02 -1.58e-01 -1.51e-01 -1.50e-01 -1.46e-01 -1.45e-01 -1.35e-01 -1.30e-01 -1.41e-01 -1.39e-01 -1.36e-01 -1.32e-01 -1.22e-01 -1.45e-01 -5.48e-02 -1.56e-02 -2.28e-01 -2.05e-01 -2.09e-01 -1.89e-01 -2.03e-01 -1.97e-01 -1.63e-01 -1.67e-01 -1.68e-01 -1.92e-01 -1.83e-01 -1.55e-01 -1.14e-01 -3.43e-02 -1.15e-02 -2.24e-01 -2.31e-01 -1.67e-01 -1.43e-01 -1.53e-01 -1.76e-01 -1.13e-01 -9.76e-02 -8.62e-02 -1.49e-01 -1.29e-01 -8.35e-02 -4.44e-02 -1.21e-02 -4.84e-03 -7.75e-02 -7.83e-02 -5.37e-02 -5.23e-02 -4.63e-02 -6.06e-02 -4.19e-02 -3.16e-02 -2.72e-02 -5.09e-02 -4.06e-02 -2.76e-02 -1.94e-02 -8.81e-03 -2.34e-03 -1.54e-01 -1.58e-01 -1.62e-01 -1.48e-01 -1.57e-01 -1.52e-01 -1.49e-01 -1.54e-01 -1.42e-01 -1.36e-01 -1.36e-01 -1.50e-01 -2.08e-01 -1.23e-01 -3.56e-02 -1.51e-01 -1.53e-01 -1.59e-01 -1.57e-01 -1.46e-01 -1.55e-01 -1.50e-01 -1.49e-01 -1.41e-01 -1.41e-01 -1.42e-01 -1.48e-01 -2.00e-01 -1.32e-01 -4.13e-02 -1.48e-01 -1.50e-01 -1.53e-01 -1.52e-01 -1.54e-01 -1.42e-01 -1.48e-01 -1.50e-01 -1.40e-01 -1.37e-01 -1.38e-01 -1.53e-01 -2.20e-01 -1.65e-01 -5.51e-02 -1.52e-01 -1.44e-01 -1.49e-01 -1.46e-01 -1.48e-01 -1.48e-01 -1.45e-01 -1.46e-01 -1.38e-01 -1.40e-01 -1.43e-01 -1.39e-01 -1.95e-01 -1.78e-01 -7.38e-02 -1.48e-01 -1.45e-01 -1.44e-01 -1.47e-01 -1.46e-01 -1.44e-01 -1.42e-01 -1.45e-01 -1.43e-01 -1.37e-01 -1.43e-01 -1.49e-01 -1.94e-01 -1.37e-01 -4.11e-02 -1.52e-01 -1.48e-01 -1.45e-01 -1.38e-01 -1.38e-01 -1.40e-01 -1.41e-01 -1.32e-01 -1.36e-01 -1.36e-01 -1.37e-01 -1.48e-01 -2.02e-01 -1.53e-01 -5.25e-02 -1.45e-01 -1.44e-01 -1.44e-01 -1.36e-01 -1.36e-01 -1.36e-01 -1.33e-01 -1.32e-01 -1.26e-01 -1.32e-01 -1.37e-01 -1.38e-01 -1.71e-01 -1.19e-01 -4.26e-02 -1.40e-01 -1.43e-01 -1.46e-01 -1.39e-01 -1.38e-01 -1.34e-01 -1.29e-01 -1.26e-01 -1.28e-01 -1.28e-01 -1.34e-01 -1.39e-01 -1.70e-01 -7.71e-02 -3.01e-02 -1.38e-01 -1.35e-01 -1.38e-01 -1.41e-01 -1.44e-01 -1.46e-01 -1.34e-01 -1.28e-01 -1.24e-01 -1.20e-01 -1.22e-01 -1.33e-01 -1.84e-01 -8.77e-02 -2.26e-02 -1.45e-01 -1.37e-01 -1.37e-01 -1.29e-01 -1.34e-01 -1.37e-01 -1.34e-01 -1.29e-01 -1.23e-01 -1.19e-01 -1.21e-01 -1.25e-01 -1.84e-01 -9.18e-02 -2.31e-02 -1.48e-01 -1.32e-01 -1.36e-01 -1.34e-01 -1.41e-01 -1.34e-01 -1.32e-01 -1.27e-01 -1.27e-01 -1.20e-01 -1.10e-01 -1.17e-01 -1.65e-01 -9.68e-02 -2.83e-02 -1.48e-01 -1.35e-01 -1.35e-01 -1.43e-01 -1.44e-01 -1.40e-01 -1.43e-01 -1.35e-01 -1.34e-01 -1.29e-01 -1.17e-01 -9.99e-02 -9.90e-02 -5.49e-02 -1.66e-02 -2.22e-01 -2.00e-01 -2.03e-01 -2.10e-01 -2.09e-01 -1.99e-01 -1.86e-01 -1.93e-01 -1.79e-01 -1.90e-01 -1.70e-01 -1.45e-01 -1.22e-01 -4.35e-02 -1.22e-02 -2.30e-01 -1.84e-01 -1.79e-01 -1.67e-01 -1.72e-01 -1.61e-01 -1.13e-01 -1.16e-01 -1.06e-01 -1.13e-01 -1.20e-01 -8.32e-02 -4.37e-02 -1.70e-02 -5.87e-03 -7.01e-02 -5.48e-02 -4.65e-02 -4.76e-02 -5.00e-02 -5.48e-02 -3.77e-02 -3.45e-02 -3.12e-02 -3.14e-02 -3.88e-02 -2.77e-02 -1.27e-02 -6.38e-03 -1.50e-03 -1.48e-01 -1.54e-01 -1.58e-01 -1.56e-01 -1.55e-01 -1.46e-01 -1.44e-01 -1.47e-01 -1.42e-01 -1.44e-01 -1.40e-01 -1.54e-01 -1.94e-01 -1.38e-01 -5.04e-02 -1.51e-01 -1.53e-01 -1.49e-01 -1.49e-01 -1.49e-01 -1.53e-01 -1.51e-01 -1.50e-01 -1.45e-01 -1.36e-01 -1.42e-01 -1.57e-01 -2.09e-01 -1.55e-01 -4.56e-02 -1.55e-01 -1.48e-01 -1.43e-01 -1.44e-01 -1.46e-01 -1.53e-01 -1.50e-01 -1.51e-01 -1.54e-01 -1.38e-01 -1.36e-01 -1.52e-01 -2.10e-01 -1.66e-01 -5.44e-02 -1.48e-01 -1.47e-01 -1.46e-01 -1.43e-01 -1.49e-01 -1.48e-01 -1.51e-01 -1.49e-01 -1.42e-01 -1.38e-01 -1.39e-01 -1.49e-01 -1.94e-01 -1.42e-01 -5.42e-02 -1.43e-01 -1.39e-01 -1.46e-01 -1.48e-01 -1.48e-01 -1.42e-01 -1.41e-01 -1.46e-01 -1.40e-01 -1.38e-01 -1.43e-01 -1.43e-01 -1.95e-01 -1.20e-01 -3.81e-02 -1.49e-01 -1.42e-01 -1.47e-01 -1.42e-01 -1.43e-01 -1.43e-01 -1.42e-01 -1.41e-01 -1.36e-01 -1.33e-01 -1.38e-01 -1.42e-01 -1.87e-01 -1.10e-01 -4.00e-02 -1.46e-01 -1.44e-01 -1.42e-01 -1.42e-01 -1.42e-01 -1.43e-01 -1.36e-01 -1.37e-01 -1.32e-01 -1.37e-01 -1.30e-01 -1.42e-01 -1.97e-01 -1.41e-01 -4.74e-02 -1.42e-01 -1.46e-01 -1.45e-01 -1.44e-01 -1.40e-01 -1.37e-01 -1.29e-01 -1.32e-01 -1.28e-01 -1.22e-01 -1.29e-01 -1.44e-01 -1.79e-01 -8.11e-02 -2.49e-02 -1.36e-01 -1.40e-01 -1.42e-01 -1.45e-01 -1.42e-01 -1.35e-01 -1.28e-01 -1.25e-01 -1.21e-01 -1.20e-01 -1.24e-01 -1.37e-01 -1.76e-01 -8.67e-02 -2.55e-02 -1.41e-01 -1.39e-01 -1.39e-01 -1.42e-01 -1.37e-01 -1.33e-01 -1.30e-01 -1.23e-01 -1.22e-01 -1.24e-01 -1.16e-01 -1.28e-01 -1.68e-01 -1.03e-01 -3.30e-02 -1.41e-01 -1.35e-01 -1.34e-01 -1.33e-01 -1.33e-01 -1.34e-01 -1.37e-01 -1.31e-01 -1.21e-01 -1.17e-01 -1.11e-01 -1.13e-01 -1.57e-01 -8.80e-02 -2.97e-02 -1.53e-01 -1.39e-01 -1.45e-01 -1.45e-01 -1.38e-01 -1.49e-01 -1.41e-01 -1.36e-01 -1.24e-01 -1.23e-01 -1.14e-01 -9.70e-02 -1.01e-01 -5.74e-02 -1.83e-02 -2.39e-01 -1.91e-01 -1.80e-01 -2.07e-01 -1.97e-01 -2.03e-01 -1.92e-01 -2.07e-01 -1.99e-01 -2.04e-01 -1.76e-01 -1.35e-01 -1.07e-01 -3.67e-02 -1.30e-02 -1.91e-01 -1.54e-01 -1.49e-01 -1.68e-01 -1.82e-01 -1.72e-01 -1.48e-01 -1.49e-01 -1.30e-01 -1.06e-01 -9.60e-02 -7.06e-02 -4.00e-02 -1.71e-02 -7.45e-03 -7.31e-02 -6.14e-02 -6.36e-02 -5.75e-02 -6.28e-02 -5.80e-02 -4.73e-02 -4.31e-02 -4.49e-02 -3.41e-02 -3.27e-02 -2.30e-02 -1.26e-02 -7.67e-03 -3.56e-03 -1.42e-01 -1.47e-01 -1.56e-01 -1.59e-01 -1.58e-01 -1.56e-01 -1.58e-01 -1.63e-01 -1.48e-01 -1.51e-01 -1.49e-01 -1.44e-01 -1.75e-01 -9.73e-02 -3.77e-02 -1.45e-01 -1.50e-01 -1.49e-01 -1.50e-01 -1.53e-01 -1.52e-01 -1.51e-01 -1.54e-01 -1.52e-01 -1.51e-01 -1.48e-01 -1.46e-01 -1.93e-01 -1.30e-01 -4.16e-02 -1.46e-01 -1.48e-01 -1.46e-01 -1.53e-01 -1.47e-01 -1.54e-01 -1.58e-01 -1.45e-01 -1.47e-01 -1.46e-01 -1.45e-01 -1.50e-01 -1.99e-01 -1.42e-01 -4.85e-02 -1.46e-01 -1.48e-01 -1.56e-01 -1.44e-01 -1.54e-01 -1.56e-01 -1.52e-01 -1.46e-01 -1.44e-01 -1.37e-01 -1.38e-01 -1.46e-01 -1.94e-01 -1.11e-01 -3.61e-02 -1.45e-01 -1.48e-01 -1.51e-01 -1.46e-01 -1.54e-01 -1.54e-01 -1.45e-01 -1.44e-01 -1.48e-01 -1.40e-01 -1.46e-01 -1.49e-01 -1.93e-01 -1.06e-01 -3.16e-02 -1.45e-01 -1.48e-01 -1.50e-01 -1.56e-01 -1.46e-01 -1.51e-01 -1.44e-01 -1.41e-01 -1.32e-01 -1.41e-01 -1.41e-01 -1.39e-01 -2.04e-01 -1.15e-01 -3.10e-02 -1.41e-01 -1.46e-01 -1.41e-01 -1.48e-01 -1.45e-01 -1.45e-01 -1.44e-01 -1.38e-01 -1.34e-01 -1.34e-01 -1.38e-01 -1.42e-01 -1.85e-01 -1.26e-01 -3.53e-02 -1.38e-01 -1.45e-01 -1.45e-01 -1.49e-01 -1.41e-01 -1.40e-01 -1.33e-01 -1.34e-01 -1.33e-01 -1.36e-01 -1.35e-01 -1.37e-01 -1.76e-01 -1.16e-01 -4.10e-02 -1.35e-01 -1.39e-01 -1.44e-01 -1.43e-01 -1.44e-01 -1.40e-01 -1.27e-01 -1.29e-01 -1.24e-01 -1.24e-01 -1.21e-01 -1.25e-01 -1.74e-01 -9.17e-02 -2.60e-02 -1.39e-01 -1.35e-01 -1.40e-01 -1.43e-01 -1.45e-01 -1.32e-01 -1.32e-01 -1.29e-01 -1.20e-01 -1.22e-01 -1.14e-01 -1.15e-01 -1.43e-01 -8.26e-02 -2.82e-02 -1.37e-01 -1.36e-01 -1.37e-01 -1.38e-01 -1.39e-01 -1.32e-01 -1.34e-01 -1.31e-01 -1.19e-01 -1.18e-01 -1.10e-01 -1.13e-01 -1.51e-01 -5.50e-02 -1.63e-02 -1.36e-01 -1.38e-01 -1.40e-01 -1.44e-01 -1.37e-01 -1.43e-01 -1.44e-01 -1.39e-01 -1.26e-01 -1.21e-01 -1.14e-01 -1.05e-01 -1.24e-01 -4.77e-02 -1.43e-02 -1.96e-01 -1.79e-01 -1.80e-01 -1.95e-01 -1.99e-01 -1.94e-01 -1.81e-01 -1.92e-01 -1.80e-01 -1.60e-01 -1.61e-01 -1.34e-01 -7.13e-02 -2.07e-02 -7.42e-03 -1.76e-01 -9.49e-02 -1.22e-01 -1.31e-01 -1.35e-01 -1.34e-01 -1.06e-01 -1.42e-01 -1.15e-01 -7.49e-02 -8.42e-02 -5.97e-02 -2.86e-02 -1.13e-02 -3.88e-03 -5.74e-02 -3.06e-02 -3.68e-02 -4.09e-02 -5.26e-02 -4.71e-02 -3.30e-02 -4.67e-02 -3.85e-02 -2.55e-02 -2.40e-02 -1.51e-02 -1.04e-02 -6.23e-03 -3.39e-03 -1.51e-01 -1.61e-01 -1.68e-01 -1.62e-01 -1.62e-01 -1.64e-01 -1.64e-01 -1.55e-01 -1.53e-01 -1.51e-01 -1.54e-01 -1.44e-01 -1.43e-01 -3.50e-02 -1.38e-02 -1.65e-01 -1.68e-01 -1.64e-01 -1.54e-01 -1.51e-01 -1.54e-01 -1.57e-01 -1.50e-01 -1.50e-01 -1.49e-01 -1.55e-01 -1.49e-01 -1.60e-01 -6.68e-02 -2.43e-02 -1.59e-01 -1.68e-01 -1.59e-01 -1.54e-01 -1.55e-01 -1.66e-01 -1.64e-01 -1.60e-01 -1.47e-01 -1.49e-01 -1.42e-01 -1.60e-01 -2.06e-01 -1.03e-01 -2.77e-02 -1.56e-01 -1.59e-01 -1.54e-01 -1.54e-01 -1.59e-01 -1.65e-01 -1.63e-01 -1.43e-01 -1.52e-01 -1.45e-01 -1.35e-01 -1.44e-01 -1.79e-01 -9.16e-02 -3.06e-02 -1.50e-01 -1.51e-01 -1.54e-01 -1.55e-01 -1.59e-01 -1.59e-01 -1.54e-01 -1.47e-01 -1.53e-01 -1.51e-01 -1.40e-01 -1.45e-01 -1.90e-01 -1.07e-01 -2.94e-02 -1.50e-01 -1.52e-01 -1.48e-01 -1.54e-01 -1.52e-01 -1.51e-01 -1.50e-01 -1.43e-01 -1.47e-01 -1.46e-01 -1.38e-01 -1.35e-01 -1.78e-01 -9.46e-02 -3.09e-02 -1.41e-01 -1.42e-01 -1.53e-01 -1.56e-01 -1.53e-01 -1.48e-01 -1.48e-01 -1.41e-01 -1.38e-01 -1.40e-01 -1.40e-01 -1.30e-01 -1.49e-01 -9.60e-02 -3.33e-02 -1.42e-01 -1.46e-01 -1.40e-01 -1.50e-01 -1.45e-01 -1.45e-01 -1.50e-01 -1.45e-01 -1.41e-01 -1.33e-01 -1.36e-01 -1.37e-01 -1.71e-01 -7.74e-02 -2.54e-02 -1.45e-01 -1.43e-01 -1.47e-01 -1.51e-01 -1.49e-01 -1.54e-01 -1.42e-01 -1.37e-01 -1.34e-01 -1.33e-01 -1.27e-01 -1.27e-01 -1.66e-01 -7.29e-02 -2.38e-02 -1.44e-01 -1.39e-01 -1.51e-01 -1.49e-01 -1.48e-01 -1.46e-01 -1.38e-01 -1.29e-01 -1.23e-01 -1.18e-01 -1.23e-01 -1.14e-01 -1.60e-01 -7.60e-02 -2.69e-02 -1.34e-01 -1.33e-01 -1.39e-01 -1.41e-01 -1.50e-01 -1.43e-01 -1.31e-01 -1.28e-01 -1.23e-01 -1.19e-01 -1.12e-01 -1.08e-01 -1.37e-01 -5.02e-02 -1.48e-02 -1.33e-01 -1.31e-01 -1.34e-01 -1.36e-01 -1.35e-01 -1.30e-01 -1.37e-01 -1.40e-01 -1.27e-01 -1.22e-01 -1.08e-01 -1.01e-01 -1.15e-01 -4.47e-02 -1.28e-02 -1.73e-01 -1.60e-01 -1.60e-01 -1.70e-01 -1.65e-01 -1.66e-01 -1.67e-01 -1.80e-01 -1.81e-01 -1.46e-01 -1.35e-01 -1.18e-01 -6.95e-02 -2.21e-02 -7.42e-03 -1.30e-01 -7.02e-02 -8.47e-02 -1.05e-01 -8.11e-02 -8.16e-02 -7.32e-02 -7.94e-02 -1.08e-01 -7.59e-02 -5.62e-02 -4.38e-02 -2.63e-02 -6.47e-03 -2.09e-03 -5.13e-02 -2.67e-02 -3.48e-02 -3.62e-02 -2.93e-02 -2.83e-02 -2.47e-02 -2.60e-02 -3.29e-02 -2.55e-02 -1.63e-02 -1.59e-02 -1.02e-02 -3.46e-03 -1.50e-03 -2.17e-01 -2.25e-01 -2.43e-01 -2.43e-01 -2.31e-01 -2.22e-01 -2.22e-01 -2.12e-01 -2.21e-01 -1.98e-01 -1.99e-01 -2.04e-01 -1.57e-01 -3.11e-02 -7.85e-03 -2.30e-01 -2.10e-01 -2.47e-01 -2.20e-01 -2.20e-01 -2.29e-01 -2.22e-01 -2.06e-01 -1.98e-01 -2.04e-01 -1.90e-01 -1.83e-01 -1.78e-01 -5.75e-02 -1.61e-02 -2.24e-01 -2.08e-01 -2.36e-01 -2.21e-01 -2.12e-01 -2.36e-01 -2.08e-01 -2.30e-01 -2.06e-01 -2.08e-01 -1.93e-01 -1.84e-01 -2.10e-01 -9.89e-02 -3.10e-02 -2.25e-01 -2.06e-01 -2.18e-01 -2.25e-01 -2.19e-01 -2.39e-01 -2.22e-01 -2.20e-01 -2.12e-01 -2.02e-01 -1.75e-01 -1.62e-01 -1.73e-01 -6.25e-02 -1.80e-02 -2.16e-01 -2.06e-01 -2.12e-01 -2.21e-01 -2.09e-01 -2.25e-01 -2.54e-01 -2.18e-01 -2.16e-01 -2.23e-01 -1.99e-01 -1.77e-01 -1.57e-01 -7.90e-02 -2.92e-02 -2.13e-01 -1.96e-01 -2.07e-01 -2.04e-01 -2.00e-01 -2.17e-01 -2.17e-01 -2.01e-01 -2.06e-01 -2.15e-01 -1.92e-01 -1.66e-01 -1.68e-01 -8.03e-02 -2.44e-02 -1.90e-01 -1.93e-01 -2.12e-01 -2.07e-01 -2.00e-01 -2.08e-01 -2.04e-01 -1.97e-01 -1.68e-01 -1.90e-01 -1.82e-01 -1.49e-01 -1.55e-01 -6.10e-02 -1.96e-02 -1.94e-01 -1.89e-01 -2.00e-01 -2.16e-01 -2.22e-01 -2.06e-01 -2.02e-01 -1.99e-01 -1.77e-01 -1.77e-01 -1.83e-01 -1.68e-01 -1.29e-01 -3.50e-02 -1.16e-02 -1.93e-01 -2.00e-01 -2.02e-01 -2.11e-01 -2.16e-01 -1.93e-01 -2.15e-01 -2.05e-01 -1.80e-01 -1.82e-01 -1.71e-01 -1.65e-01 -1.61e-01 -4.47e-02 -1.50e-02 -1.94e-01 -2.06e-01 -2.19e-01 -2.03e-01 -2.12e-01 -1.96e-01 -2.02e-01 -1.81e-01 -1.66e-01 -1.60e-01 -1.62e-01 -1.62e-01 -1.56e-01 -4.92e-02 -1.53e-02 -1.78e-01 -1.86e-01 -2.05e-01 -2.04e-01 -1.97e-01 -2.15e-01 -1.88e-01 -1.63e-01 -1.57e-01 -1.38e-01 -1.47e-01 -1.39e-01 -1.01e-01 -4.20e-02 -1.54e-02 -1.47e-01 -1.52e-01 -1.77e-01 -1.74e-01 -1.84e-01 -1.91e-01 -2.00e-01 -1.85e-01 -1.68e-01 -1.42e-01 -1.34e-01 -1.28e-01 -9.77e-02 -2.94e-02 -1.17e-02 -1.28e-01 -1.39e-01 -1.56e-01 -1.44e-01 -1.64e-01 -1.66e-01 -1.39e-01 -1.87e-01 -1.87e-01 -1.57e-01 -1.18e-01 -9.64e-02 -6.30e-02 -1.82e-02 -8.08e-03 -7.18e-02 -4.39e-02 -5.20e-02 -6.11e-02 -4.96e-02 -4.82e-02 -4.41e-02 -5.38e-02 -8.79e-02 -5.77e-02 -2.70e-02 -2.61e-02 -1.49e-02 -4.93e-03 -2.78e-03 -2.74e-02 -1.41e-02 -1.81e-02 -1.93e-02 -1.48e-02 -1.51e-02 -1.60e-02 -1.57e-02 -2.80e-02 -2.17e-02 -1.10e-02 -8.28e-03 -4.76e-03 -2.53e-03 -9.95e-04 -2.15e-01 -2.13e-01 -2.69e-01 -1.97e-01 -2.97e-01 -2.44e-01 -2.16e-01 -2.27e-01 -1.95e-01 -1.69e-01 -1.21e-01 -1.27e-01 -1.07e-01 -2.85e-02 -7.97e-03 -2.71e-01 -1.94e-01 -3.20e-01 -3.60e-01 -2.90e-01 -2.34e-01 -1.99e-01 -2.04e-01 -1.73e-01 -1.40e-01 -1.29e-01 -1.08e-01 -8.99e-02 -4.08e-02 -1.48e-02 -2.36e-01 -2.27e-01 -2.95e-01 -2.38e-01 -1.88e-01 -2.38e-01 -1.95e-01 -2.03e-01 -1.85e-01 -1.65e-01 -1.78e-01 -1.40e-01 -7.70e-02 -4.33e-02 -2.87e-02 -2.64e-01 -2.27e-01 -2.72e-01 -3.07e-01 -2.33e-01 -2.58e-01 -2.71e-01 -2.36e-01 -2.17e-01 -1.73e-01 -1.26e-01 -9.14e-02 -6.26e-02 -3.03e-02 -1.37e-02 -2.60e-01 -1.95e-01 -2.57e-01 -3.08e-01 -2.65e-01 -2.75e-01 -2.70e-01 -2.25e-01 -1.83e-01 -1.71e-01 -1.54e-01 -8.13e-02 -5.27e-02 -2.61e-02 -1.31e-02 -2.09e-01 -1.59e-01 -2.23e-01 -2.30e-01 -1.63e-01 -1.84e-01 -2.17e-01 -1.62e-01 -1.39e-01 -1.79e-01 -1.60e-01 -1.05e-01 -5.74e-02 -2.47e-02 -1.55e-02 -1.50e-01 -1.80e-01 -2.09e-01 -2.09e-01 -1.82e-01 -2.00e-01 -1.82e-01 -1.57e-01 -1.32e-01 -1.22e-01 -9.76e-02 -6.91e-02 -4.61e-02 -2.65e-02 -1.49e-02 -1.12e-01 -1.42e-01 -1.70e-01 -1.73e-01 -1.86e-01 -1.93e-01 -1.34e-01 -1.27e-01 -9.53e-02 -8.75e-02 -9.91e-02 -7.87e-02 -4.52e-02 -2.11e-02 -7.92e-03 -1.22e-01 -1.39e-01 -1.69e-01 -2.22e-01 -1.74e-01 -1.60e-01 -1.21e-01 -1.47e-01 -1.19e-01 -1.07e-01 -9.89e-02 -8.43e-02 -5.88e-02 -2.01e-02 -8.74e-03 -9.13e-02 -1.61e-01 -2.14e-01 -1.61e-01 -1.43e-01 -1.01e-01 -1.25e-01 -1.42e-01 -1.15e-01 -9.15e-02 -8.87e-02 -6.91e-02 -5.19e-02 -2.72e-02 -8.44e-03 -9.87e-02 -1.23e-01 -1.61e-01 -1.11e-01 -1.42e-01 -1.45e-01 -1.19e-01 -1.11e-01 -8.68e-02 -5.91e-02 -7.60e-02 -6.84e-02 -4.18e-02 -2.17e-02 -9.67e-03 -8.56e-02 -7.21e-02 -1.04e-01 -9.72e-02 -9.63e-02 -1.38e-01 -1.19e-01 -7.48e-02 -6.52e-02 -5.51e-02 -5.18e-02 -5.14e-02 -3.71e-02 -9.91e-03 -3.65e-03 -4.31e-02 -5.32e-02 -6.28e-02 -4.91e-02 -5.90e-02 -8.59e-02 -7.51e-02 -7.34e-02 -6.10e-02 -6.19e-02 -4.42e-02 -3.60e-02 -2.68e-02 -1.01e-02 -4.00e-03 -1.92e-02 -2.02e-02 -2.30e-02 -1.98e-02 -2.54e-02 -3.35e-02 -2.56e-02 -3.19e-02 -3.49e-02 -2.85e-02 -1.72e-02 -1.18e-02 -8.37e-03 -4.19e-03 -2.02e-03 -1.38e-02 -7.42e-03 -8.36e-03 -8.57e-03 -9.08e-03 -1.23e-02 -8.17e-03 -1.02e-02 -1.45e-02 -1.35e-02 -6.28e-03 -3.59e-03 -3.28e-03 -1.49e-03 -5.93e-04 -7.32e-02 -7.34e-02 -9.95e-02 -6.68e-02 -1.09e-01 -8.20e-02 -7.49e-02 -7.93e-02 -7.32e-02 -5.71e-02 -3.93e-02 -3.97e-02 -3.57e-02 -2.10e-02 -7.29e-03 -1.10e-01 -5.23e-02 -1.07e-01 -1.46e-01 -1.24e-01 -8.85e-02 -7.13e-02 -6.52e-02 -6.37e-02 -5.06e-02 -3.96e-02 -3.23e-02 -2.70e-02 -1.79e-02 -8.68e-03 -8.76e-02 -6.93e-02 -1.01e-01 -9.79e-02 -5.28e-02 -8.50e-02 -7.16e-02 -6.22e-02 -6.61e-02 -4.64e-02 -6.19e-02 -5.31e-02 -2.85e-02 -1.22e-02 -1.28e-02 -8.68e-02 -7.27e-02 -1.06e-01 -1.20e-01 -8.06e-02 -8.67e-02 -9.61e-02 -8.95e-02 -8.71e-02 -6.56e-02 -4.39e-02 -3.10e-02 -2.08e-02 -1.24e-02 -5.85e-03 -1.06e-01 -7.84e-02 -9.79e-02 -1.14e-01 -1.02e-01 -9.64e-02 -1.00e-01 -7.46e-02 -7.16e-02 -5.01e-02 -5.24e-02 -2.38e-02 -1.47e-02 -8.69e-03 -5.50e-03 -6.48e-02 -5.48e-02 -7.05e-02 -7.64e-02 -6.18e-02 -5.28e-02 -6.84e-02 -5.17e-02 -4.47e-02 -5.44e-02 -5.78e-02 -4.35e-02 -2.02e-02 -8.44e-03 -4.29e-03 -6.15e-02 -5.80e-02 -7.42e-02 -8.23e-02 -4.82e-02 -5.80e-02 -5.99e-02 -5.52e-02 -5.07e-02 -4.11e-02 -3.25e-02 -2.74e-02 -1.58e-02 -7.93e-03 -7.33e-03 -3.07e-02 -5.33e-02 -5.17e-02 -5.32e-02 -5.86e-02 -6.36e-02 -3.92e-02 -4.20e-02 -3.02e-02 -2.37e-02 -2.60e-02 -2.49e-02 -1.38e-02 -1.14e-02 -8.22e-03 -3.87e-02 -4.20e-02 -5.55e-02 -6.88e-02 -6.66e-02 -6.23e-02 -3.77e-02 -4.86e-02 -4.16e-02 -3.47e-02 -2.92e-02 -2.68e-02 -2.21e-02 -9.30e-03 -3.87e-03 -2.33e-02 -4.93e-02 -6.49e-02 -6.24e-02 -4.58e-02 -2.96e-02 -4.02e-02 -4.66e-02 -4.25e-02 -2.79e-02 -2.67e-02 -2.26e-02 -1.37e-02 -1.36e-02 -7.38e-03 -3.11e-02 -5.02e-02 -5.87e-02 -3.06e-02 -4.64e-02 -4.05e-02 -2.71e-02 -3.77e-02 -3.09e-02 -2.18e-02 -2.34e-02 -1.91e-02 -1.39e-02 -1.02e-02 -7.91e-03 -2.26e-02 -2.44e-02 -3.23e-02 -2.90e-02 -2.99e-02 -4.72e-02 -4.07e-02 -3.01e-02 -2.01e-02 -1.70e-02 -1.57e-02 -1.51e-02 -1.50e-02 -4.17e-03 -1.63e-03 -1.86e-02 -1.84e-02 -2.18e-02 -2.46e-02 -1.84e-02 -3.15e-02 -2.72e-02 -2.27e-02 -1.73e-02 -2.03e-02 -1.19e-02 -1.20e-02 -1.14e-02 -4.19e-03 -1.45e-03 -6.21e-03 -9.69e-03 -9.74e-03 -7.36e-03 -1.15e-02 -1.57e-02 -1.41e-02 -1.64e-02 -1.88e-02 -1.03e-02 -1.09e-02 -6.84e-03 -4.29e-03 -2.69e-03 -2.28e-03 -4.54e-03 -5.03e-03 -5.40e-03 -5.12e-03 -6.04e-03 -1.01e-02 -6.83e-03 -6.36e-03 -1.16e-02 -7.66e-03 -5.81e-03 -3.71e-03 -1.48e-03 -1.00e-03 -1.45e-03 -Upper Bounds -8.55e-01 -8.64e-01 -8.59e-01 -8.67e-01 -8.53e-01 -8.16e-01 -8.31e-01 -8.50e-01 -8.39e-01 -8.80e-01 -8.66e-01 -8.96e-01 -1.31e+00 -2.22e+00 -8.38e-01 -8.15e-01 -8.82e-01 -8.67e-01 -7.61e-01 -8.32e-01 -8.60e-01 -8.41e-01 -8.42e-01 -8.32e-01 -8.34e-01 -8.80e-01 -8.65e-01 -1.22e+00 -1.82e+00 -6.12e-01 -8.56e-01 -8.31e-01 -8.43e-01 -8.52e-01 -8.33e-01 -8.57e-01 -8.19e-01 -7.77e-01 -8.33e-01 -8.19e-01 -8.41e-01 -9.08e-01 -1.30e+00 -2.06e+00 -7.76e-01 -8.38e-01 -8.08e-01 -8.28e-01 -8.25e-01 -8.10e-01 -8.21e-01 -8.13e-01 -8.31e-01 -8.17e-01 -8.36e-01 -7.91e-01 -8.95e-01 -1.26e+00 -2.05e+00 -6.73e-01 -8.25e-01 -8.69e-01 -8.34e-01 -8.56e-01 -8.29e-01 -8.11e-01 -8.01e-01 -8.32e-01 -7.75e-01 -8.33e-01 -8.31e-01 -9.11e-01 -1.34e+00 -1.73e+00 -6.60e-01 -8.48e-01 -8.49e-01 -8.41e-01 -8.41e-01 -8.43e-01 -7.95e-01 -8.08e-01 -7.96e-01 -7.85e-01 -7.74e-01 -8.58e-01 -8.98e-01 -1.29e+00 -1.49e+00 -5.32e-01 -8.39e-01 -7.98e-01 -7.91e-01 -8.03e-01 -7.88e-01 -7.96e-01 -7.81e-01 -7.66e-01 -7.83e-01 -7.62e-01 -7.93e-01 -7.72e-01 -1.21e+00 -1.65e+00 -6.11e-01 -8.18e-01 -8.25e-01 -8.44e-01 -8.18e-01 -8.00e-01 -8.28e-01 -8.00e-01 -7.60e-01 -7.23e-01 -7.65e-01 -7.83e-01 -7.01e-01 -1.04e+00 -9.49e-01 -3.97e-01 -8.24e-01 -8.27e-01 -8.57e-01 -8.58e-01 -8.13e-01 -8.03e-01 -7.83e-01 -7.70e-01 -7.46e-01 -7.07e-01 -7.24e-01 -7.65e-01 -1.18e+00 -9.01e-01 -2.88e-01 -8.34e-01 -8.73e-01 -8.70e-01 -8.56e-01 -8.29e-01 -7.71e-01 -7.75e-01 -7.58e-01 -7.63e-01 -7.06e-01 -7.64e-01 -7.43e-01 -1.07e+00 -8.82e-01 -3.35e-01 -8.58e-01 -8.29e-01 -8.72e-01 -8.48e-01 -8.46e-01 -7.87e-01 -7.50e-01 -7.65e-01 -7.38e-01 -7.34e-01 -8.10e-01 -7.43e-01 -1.02e+00 -6.73e-01 -2.03e-01 -9.03e-01 -9.01e-01 -8.60e-01 -8.26e-01 -9.18e-01 -8.72e-01 -7.91e-01 -8.39e-01 -7.94e-01 -7.87e-01 -7.88e-01 -7.38e-01 -1.08e+00 -5.23e-01 -1.69e-01 -1.31e+00 -1.26e+00 -1.18e+00 -1.25e+00 -1.32e+00 -1.21e+00 -1.20e+00 -1.16e+00 -1.16e+00 -1.14e+00 -1.11e+00 -1.10e+00 -1.03e+00 -4.01e-01 -1.10e-01 -2.50e+00 -1.84e+00 -1.94e+00 -1.32e+00 -1.43e+00 -1.59e+00 -1.30e+00 -1.19e+00 -9.40e-01 -9.83e-01 -9.19e-01 -7.51e-01 -4.99e-01 -1.94e-01 -9.48e-02 -1.09e+00 -7.40e-01 -8.05e-01 -4.38e-01 -4.72e-01 -5.81e-01 -4.22e-01 -4.06e-01 -3.50e-01 -3.08e-01 -3.25e-01 -2.23e-01 -1.85e-01 -8.09e-02 -3.66e-02 -8.48e-01 -8.45e-01 -8.50e-01 -8.39e-01 -8.13e-01 -7.97e-01 -8.76e-01 -8.44e-01 -7.95e-01 -8.18e-01 -8.84e-01 -8.93e-01 -1.31e+00 -1.96e+00 -7.41e-01 -8.63e-01 -8.69e-01 -8.49e-01 -8.32e-01 -8.42e-01 -8.08e-01 -8.09e-01 -8.36e-01 -7.99e-01 -8.20e-01 -8.33e-01 -9.00e-01 -1.21e+00 -1.86e+00 -7.23e-01 -8.57e-01 -8.27e-01 -8.35e-01 -8.27e-01 -8.44e-01 -8.48e-01 -8.19e-01 -8.39e-01 -8.01e-01 -8.48e-01 -8.52e-01 -8.70e-01 -1.31e+00 -1.65e+00 -5.73e-01 -8.64e-01 -8.75e-01 -8.50e-01 -8.46e-01 -8.43e-01 -8.17e-01 -8.28e-01 -8.15e-01 -8.07e-01 -8.04e-01 -8.51e-01 -8.94e-01 -1.24e+00 -1.82e+00 -6.58e-01 -8.61e-01 -8.65e-01 -8.57e-01 -8.28e-01 -8.15e-01 -8.13e-01 -8.36e-01 -8.01e-01 -7.82e-01 -8.17e-01 -8.58e-01 -8.55e-01 -1.26e+00 -1.71e+00 -6.99e-01 -8.39e-01 -8.48e-01 -8.35e-01 -8.30e-01 -8.61e-01 -8.03e-01 -7.79e-01 -7.79e-01 -7.65e-01 -7.73e-01 -8.23e-01 -8.92e-01 -1.26e+00 -1.83e+00 -6.65e-01 -8.50e-01 -8.43e-01 -8.01e-01 -8.18e-01 -8.51e-01 -8.15e-01 -7.63e-01 -7.50e-01 -7.52e-01 -7.40e-01 -7.66e-01 -8.29e-01 -1.17e+00 -1.50e+00 -5.74e-01 -8.23e-01 -8.15e-01 -7.95e-01 -7.87e-01 -7.97e-01 -7.70e-01 -7.69e-01 -7.35e-01 -6.98e-01 -6.91e-01 -6.35e-01 -6.08e-01 -9.93e-01 -8.87e-01 -3.56e-01 -7.90e-01 -8.73e-01 -8.38e-01 -8.31e-01 -8.29e-01 -7.89e-01 -7.80e-01 -7.18e-01 -7.42e-01 -7.23e-01 -6.87e-01 -7.01e-01 -1.01e+00 -6.82e-01 -2.08e-01 -8.24e-01 -8.78e-01 -8.46e-01 -8.43e-01 -7.84e-01 -8.35e-01 -7.79e-01 -7.48e-01 -7.63e-01 -7.14e-01 -7.56e-01 -7.03e-01 -1.02e+00 -7.48e-01 -2.25e-01 -8.45e-01 -8.73e-01 -8.56e-01 -8.15e-01 -8.44e-01 -8.36e-01 -7.99e-01 -7.51e-01 -7.67e-01 -7.20e-01 -7.86e-01 -7.45e-01 -1.01e+00 -6.73e-01 -2.04e-01 -8.93e-01 -8.60e-01 -8.64e-01 -8.51e-01 -8.70e-01 -8.90e-01 -8.41e-01 -7.94e-01 -7.85e-01 -8.08e-01 -8.08e-01 -7.83e-01 -9.73e-01 -4.60e-01 -1.58e-01 -1.24e+00 -1.32e+00 -1.27e+00 -1.29e+00 -1.40e+00 -1.26e+00 -1.17e+00 -1.20e+00 -1.08e+00 -1.09e+00 -1.21e+00 -1.11e+00 -9.96e-01 -3.09e-01 -8.83e-02 -1.56e+00 -1.49e+00 -1.49e+00 -1.58e+00 -1.83e+00 -1.75e+00 -1.41e+00 -1.38e+00 -1.12e+00 -8.28e-01 -8.50e-01 -8.27e-01 -5.48e-01 -1.84e-01 -7.71e-02 -5.56e-01 -5.50e-01 -5.89e-01 -5.41e-01 -6.72e-01 -7.04e-01 -4.96e-01 -4.98e-01 -4.70e-01 -2.59e-01 -2.70e-01 -2.72e-01 -2.11e-01 -9.38e-02 -3.66e-02 -8.67e-01 -8.42e-01 -8.70e-01 -8.39e-01 -7.98e-01 -8.02e-01 -8.06e-01 -7.94e-01 -8.48e-01 -8.04e-01 -8.10e-01 -8.81e-01 -1.45e+00 -2.04e+00 -7.89e-01 -8.58e-01 -8.42e-01 -8.10e-01 -8.30e-01 -7.96e-01 -8.14e-01 -7.91e-01 -8.00e-01 -7.94e-01 -8.24e-01 -8.16e-01 -8.86e-01 -1.22e+00 -1.96e+00 -8.18e-01 -8.56e-01 -8.69e-01 -8.58e-01 -7.87e-01 -8.24e-01 -8.16e-01 -8.16e-01 -8.43e-01 -7.92e-01 -8.05e-01 -8.03e-01 -8.83e-01 -1.22e+00 -1.68e+00 -6.47e-01 -7.87e-01 -8.37e-01 -8.29e-01 -8.15e-01 -8.16e-01 -7.97e-01 -8.04e-01 -8.23e-01 -7.82e-01 -7.95e-01 -8.24e-01 -7.97e-01 -1.22e+00 -1.65e+00 -5.42e-01 -8.09e-01 -8.09e-01 -8.04e-01 -7.72e-01 -8.14e-01 -8.20e-01 -7.50e-01 -7.87e-01 -7.53e-01 -7.48e-01 -8.36e-01 -8.59e-01 -1.22e+00 -1.39e+00 -4.29e-01 -8.07e-01 -8.21e-01 -7.86e-01 -7.76e-01 -7.84e-01 -7.85e-01 -7.56e-01 -7.44e-01 -7.72e-01 -7.80e-01 -8.33e-01 -8.47e-01 -1.21e+00 -1.74e+00 -6.61e-01 -8.36e-01 -8.64e-01 -8.19e-01 -8.11e-01 -8.00e-01 -8.07e-01 -7.80e-01 -7.34e-01 -7.56e-01 -7.70e-01 -7.83e-01 -7.96e-01 -1.13e+00 -1.26e+00 -4.66e-01 -8.16e-01 -8.15e-01 -7.98e-01 -7.75e-01 -7.87e-01 -7.91e-01 -7.70e-01 -7.35e-01 -7.31e-01 -7.42e-01 -7.14e-01 -7.50e-01 -1.05e+00 -8.42e-01 -3.14e-01 -7.86e-01 -8.18e-01 -8.21e-01 -8.01e-01 -7.99e-01 -7.90e-01 -7.88e-01 -7.83e-01 -7.33e-01 -7.48e-01 -7.58e-01 -7.15e-01 -1.06e+00 -8.32e-01 -3.09e-01 -8.27e-01 -8.58e-01 -8.09e-01 -8.21e-01 -8.32e-01 -7.85e-01 -7.86e-01 -7.50e-01 -7.01e-01 -7.38e-01 -7.30e-01 -7.22e-01 -9.77e-01 -6.23e-01 -2.49e-01 -8.03e-01 -8.31e-01 -8.48e-01 -8.19e-01 -8.34e-01 -8.33e-01 -8.42e-01 -7.89e-01 -7.16e-01 -7.24e-01 -7.28e-01 -7.16e-01 -9.71e-01 -6.27e-01 -1.80e-01 -8.04e-01 -8.69e-01 -8.69e-01 -8.82e-01 -8.64e-01 -8.59e-01 -8.38e-01 -8.03e-01 -7.94e-01 -7.80e-01 -7.95e-01 -7.83e-01 -8.87e-01 -5.44e-01 -1.87e-01 -1.24e+00 -1.24e+00 -1.24e+00 -1.21e+00 -1.24e+00 -1.28e+00 -1.10e+00 -1.13e+00 -1.12e+00 -1.09e+00 -1.11e+00 -1.13e+00 -1.07e+00 -3.12e-01 -9.52e-02 -1.84e+00 -1.36e+00 -1.70e+00 -1.79e+00 -1.82e+00 -1.16e+00 -1.17e+00 -1.10e+00 -9.39e-01 -8.87e-01 -6.70e-01 -6.23e-01 -5.35e-01 -2.34e-01 -6.47e-02 -6.44e-01 -4.31e-01 -7.11e-01 -6.80e-01 -6.87e-01 -4.47e-01 -4.04e-01 -4.19e-01 -2.85e-01 -3.23e-01 -1.57e-01 -1.93e-01 -1.76e-01 -1.29e-01 -6.44e-02 -8.45e-01 -8.09e-01 -8.31e-01 -8.52e-01 -8.43e-01 -8.05e-01 -7.88e-01 -7.57e-01 -7.58e-01 -7.66e-01 -7.61e-01 -8.67e-01 -1.27e+00 -2.06e+00 -7.56e-01 -8.40e-01 -8.74e-01 -8.23e-01 -7.97e-01 -8.08e-01 -7.78e-01 -7.85e-01 -7.76e-01 -7.95e-01 -8.30e-01 -7.95e-01 -8.37e-01 -1.18e+00 -1.62e+00 -6.44e-01 -8.11e-01 -8.19e-01 -8.40e-01 -7.94e-01 -7.57e-01 -7.93e-01 -7.66e-01 -7.66e-01 -7.76e-01 -8.15e-01 -7.99e-01 -8.24e-01 -1.16e+00 -1.39e+00 -5.36e-01 -8.08e-01 -8.15e-01 -7.99e-01 -8.03e-01 -7.68e-01 -7.86e-01 -7.93e-01 -7.55e-01 -7.56e-01 -7.89e-01 -7.68e-01 -8.06e-01 -1.20e+00 -1.24e+00 -5.05e-01 -7.77e-01 -7.72e-01 -8.04e-01 -8.28e-01 -7.74e-01 -7.64e-01 -7.80e-01 -7.54e-01 -7.38e-01 -7.65e-01 -8.13e-01 -8.11e-01 -1.21e+00 -1.61e+00 -5.92e-01 -8.28e-01 -7.61e-01 -8.10e-01 -8.12e-01 -7.80e-01 -7.60e-01 -7.76e-01 -7.84e-01 -7.75e-01 -7.67e-01 -7.63e-01 -8.21e-01 -1.23e+00 -1.51e+00 -5.55e-01 -8.13e-01 -7.95e-01 -8.40e-01 -7.97e-01 -7.59e-01 -7.72e-01 -7.80e-01 -7.46e-01 -7.44e-01 -7.55e-01 -7.27e-01 -7.44e-01 -1.11e+00 -1.44e+00 -5.11e-01 -8.31e-01 -8.12e-01 -8.03e-01 -7.49e-01 -7.48e-01 -7.53e-01 -7.93e-01 -7.32e-01 -7.17e-01 -7.10e-01 -7.05e-01 -7.55e-01 -1.11e+00 -9.42e-01 -3.25e-01 -8.00e-01 -7.96e-01 -7.87e-01 -8.07e-01 -7.73e-01 -7.86e-01 -7.64e-01 -7.65e-01 -7.27e-01 -7.21e-01 -7.35e-01 -7.93e-01 -1.18e+00 -9.54e-01 -2.85e-01 -8.11e-01 -7.95e-01 -8.15e-01 -7.97e-01 -7.74e-01 -7.69e-01 -7.52e-01 -7.33e-01 -7.51e-01 -7.28e-01 -7.13e-01 -7.16e-01 -1.10e+00 -6.86e-01 -2.68e-01 -8.31e-01 -8.25e-01 -7.50e-01 -8.42e-01 -8.24e-01 -8.05e-01 -7.74e-01 -7.47e-01 -7.33e-01 -7.57e-01 -7.16e-01 -7.50e-01 -9.60e-01 -4.98e-01 -1.46e-01 -8.65e-01 -8.27e-01 -8.48e-01 -8.31e-01 -8.65e-01 -8.92e-01 -8.23e-01 -7.50e-01 -8.02e-01 -7.77e-01 -7.85e-01 -7.73e-01 -9.44e-01 -4.45e-01 -1.34e-01 -1.16e+00 -1.18e+00 -1.20e+00 -1.16e+00 -1.20e+00 -1.19e+00 -1.01e+00 -1.06e+00 -1.10e+00 -1.06e+00 -1.02e+00 -1.01e+00 -1.07e+00 -4.13e-01 -1.32e-01 -1.53e+00 -1.26e+00 -1.05e+00 -1.47e+00 -1.43e+00 -1.20e+00 -8.45e-01 -6.05e-01 -9.60e-01 -9.09e-01 -6.43e-01 -6.18e-01 -5.18e-01 -2.26e-01 -8.71e-02 -5.78e-01 -4.15e-01 -4.47e-01 -4.72e-01 -5.79e-01 -4.50e-01 -3.73e-01 -1.91e-01 -3.18e-01 -3.21e-01 -2.12e-01 -2.08e-01 -1.59e-01 -1.30e-01 -6.29e-02 -8.13e-01 -7.92e-01 -7.98e-01 -8.10e-01 -8.01e-01 -7.94e-01 -7.98e-01 -7.55e-01 -7.35e-01 -7.76e-01 -7.54e-01 -8.38e-01 -1.23e+00 -1.59e+00 -6.35e-01 -8.22e-01 -8.05e-01 -7.80e-01 -8.16e-01 -8.13e-01 -7.71e-01 -7.48e-01 -7.45e-01 -7.82e-01 -7.91e-01 -7.88e-01 -8.20e-01 -1.19e+00 -1.52e+00 -5.64e-01 -8.23e-01 -8.14e-01 -8.08e-01 -7.83e-01 -7.86e-01 -7.83e-01 -7.67e-01 -7.43e-01 -7.86e-01 -8.17e-01 -8.13e-01 -8.52e-01 -1.19e+00 -1.15e+00 -4.23e-01 -8.08e-01 -8.13e-01 -7.88e-01 -7.92e-01 -7.82e-01 -7.73e-01 -7.50e-01 -7.57e-01 -7.60e-01 -8.01e-01 -7.85e-01 -8.21e-01 -1.23e+00 -1.08e+00 -3.68e-01 -7.79e-01 -7.72e-01 -7.80e-01 -8.09e-01 -7.59e-01 -7.50e-01 -7.76e-01 -7.62e-01 -7.59e-01 -7.48e-01 -7.90e-01 -8.33e-01 -1.23e+00 -1.60e+00 -5.75e-01 -7.85e-01 -7.73e-01 -7.79e-01 -7.88e-01 -7.39e-01 -7.13e-01 -7.08e-01 -7.78e-01 -7.45e-01 -7.61e-01 -7.55e-01 -7.92e-01 -1.16e+00 -1.31e+00 -4.76e-01 -7.40e-01 -7.79e-01 -7.94e-01 -7.59e-01 -7.99e-01 -7.16e-01 -7.14e-01 -7.21e-01 -7.25e-01 -7.16e-01 -7.41e-01 -7.53e-01 -1.04e+00 -1.05e+00 -3.92e-01 -7.83e-01 -8.02e-01 -7.76e-01 -7.66e-01 -7.84e-01 -7.21e-01 -7.22e-01 -6.78e-01 -6.82e-01 -7.30e-01 -7.15e-01 -7.28e-01 -1.08e+00 -8.33e-01 -3.54e-01 -7.96e-01 -7.79e-01 -7.80e-01 -7.68e-01 -7.67e-01 -7.60e-01 -7.52e-01 -7.12e-01 -6.86e-01 -6.95e-01 -7.05e-01 -7.37e-01 -1.02e+00 -8.76e-01 -2.76e-01 -8.13e-01 -8.09e-01 -7.86e-01 -7.66e-01 -7.26e-01 -7.62e-01 -7.59e-01 -7.17e-01 -7.04e-01 -6.89e-01 -6.94e-01 -7.59e-01 -1.02e+00 -8.04e-01 -3.49e-01 -8.12e-01 -7.81e-01 -7.92e-01 -7.74e-01 -7.90e-01 -7.78e-01 -7.64e-01 -7.66e-01 -7.45e-01 -7.07e-01 -7.19e-01 -7.86e-01 -1.05e+00 -6.12e-01 -2.13e-01 -8.28e-01 -8.45e-01 -8.05e-01 -8.12e-01 -8.40e-01 -8.71e-01 -8.00e-01 -7.85e-01 -7.85e-01 -8.08e-01 -7.39e-01 -7.70e-01 -1.09e+00 -5.71e-01 -1.75e-01 -1.22e+00 -1.15e+00 -1.17e+00 -1.21e+00 -1.23e+00 -1.24e+00 -1.23e+00 -1.10e+00 -1.11e+00 -1.06e+00 -1.00e+00 -1.01e+00 -1.07e+00 -4.47e-01 -1.50e-01 -1.39e+00 -1.31e+00 -1.26e+00 -1.31e+00 -1.50e+00 -1.34e+00 -1.46e+00 -9.51e-01 -1.01e+00 -7.68e-01 -5.65e-01 -6.36e-01 -4.41e-01 -1.94e-01 -7.74e-02 -5.17e-01 -4.55e-01 -4.54e-01 -4.50e-01 -5.33e-01 -4.37e-01 -5.86e-01 -2.84e-01 -3.58e-01 -2.61e-01 -1.66e-01 -1.75e-01 -1.34e-01 -8.28e-02 -5.70e-02 -7.29e-01 -7.75e-01 -7.84e-01 -7.97e-01 -8.15e-01 -7.72e-01 -7.47e-01 -7.39e-01 -7.27e-01 -7.42e-01 -7.41e-01 -7.72e-01 -1.22e+00 -1.35e+00 -4.17e-01 -7.68e-01 -7.93e-01 -7.83e-01 -7.57e-01 -7.76e-01 -7.86e-01 -7.98e-01 -7.43e-01 -7.68e-01 -7.51e-01 -7.70e-01 -8.08e-01 -1.20e+00 -1.48e+00 -5.74e-01 -7.98e-01 -8.06e-01 -8.03e-01 -7.63e-01 -7.79e-01 -7.61e-01 -7.64e-01 -7.83e-01 -7.61e-01 -7.60e-01 -7.76e-01 -8.43e-01 -1.25e+00 -1.26e+00 -4.08e-01 -7.94e-01 -7.94e-01 -7.59e-01 -7.50e-01 -7.63e-01 -7.94e-01 -7.36e-01 -7.53e-01 -7.57e-01 -7.78e-01 -7.78e-01 -8.22e-01 -1.20e+00 -1.23e+00 -4.03e-01 -7.88e-01 -7.93e-01 -7.89e-01 -7.79e-01 -7.63e-01 -7.30e-01 -7.40e-01 -7.42e-01 -7.36e-01 -7.64e-01 -7.39e-01 -8.10e-01 -1.19e+00 -1.33e+00 -5.12e-01 -7.75e-01 -7.68e-01 -7.84e-01 -7.62e-01 -7.39e-01 -7.49e-01 -7.00e-01 -6.85e-01 -7.48e-01 -7.48e-01 -7.30e-01 -7.60e-01 -1.12e+00 -1.11e+00 -4.49e-01 -7.89e-01 -8.02e-01 -7.72e-01 -7.35e-01 -7.33e-01 -7.24e-01 -7.11e-01 -6.42e-01 -6.64e-01 -7.00e-01 -7.57e-01 -7.64e-01 -1.04e+00 -7.18e-01 -2.59e-01 -7.83e-01 -7.69e-01 -7.68e-01 -7.09e-01 -7.54e-01 -7.20e-01 -6.74e-01 -6.39e-01 -5.53e-01 -6.99e-01 -7.47e-01 -7.76e-01 -1.11e+00 -6.53e-01 -2.06e-01 -7.78e-01 -7.65e-01 -7.86e-01 -7.09e-01 -7.60e-01 -7.43e-01 -7.27e-01 -6.62e-01 -6.51e-01 -6.35e-01 -7.03e-01 -7.07e-01 -1.06e+00 -7.73e-01 -2.21e-01 -7.46e-01 -7.60e-01 -7.63e-01 -7.80e-01 -7.34e-01 -7.24e-01 -7.02e-01 -6.87e-01 -7.13e-01 -6.75e-01 -6.69e-01 -7.11e-01 -9.92e-01 -6.25e-01 -1.99e-01 -7.86e-01 -7.39e-01 -7.47e-01 -7.61e-01 -7.48e-01 -7.41e-01 -7.50e-01 -7.38e-01 -7.18e-01 -7.15e-01 -6.76e-01 -6.94e-01 -9.71e-01 -5.36e-01 -1.55e-01 -8.10e-01 -8.03e-01 -8.04e-01 -8.15e-01 -8.13e-01 -8.02e-01 -7.77e-01 -7.76e-01 -7.50e-01 -7.78e-01 -7.13e-01 -6.60e-01 -9.13e-01 -5.08e-01 -1.25e-01 -1.17e+00 -1.12e+00 -1.10e+00 -1.13e+00 -1.21e+00 -1.17e+00 -1.07e+00 -1.02e+00 -1.07e+00 -1.08e+00 -1.10e+00 -8.99e-01 -8.82e-01 -4.84e-01 -1.77e-01 -1.56e+00 -1.32e+00 -1.13e+00 -1.34e+00 -1.30e+00 -1.22e+00 -1.17e+00 -9.07e-01 -7.99e-01 -7.33e-01 -7.55e-01 -6.69e-01 -3.68e-01 -2.03e-01 -1.10e-01 -5.31e-01 -4.95e-01 -4.39e-01 -4.81e-01 -4.96e-01 -3.78e-01 -5.25e-01 -3.10e-01 -2.83e-01 -1.99e-01 -2.15e-01 -2.39e-01 -1.44e-01 -7.93e-02 -4.46e-02 -8.04e-01 -7.95e-01 -7.82e-01 -7.95e-01 -7.54e-01 -7.47e-01 -7.72e-01 -7.56e-01 -7.67e-01 -7.42e-01 -7.58e-01 -7.40e-01 -1.14e+00 -9.11e-01 -4.11e-01 -8.04e-01 -7.68e-01 -7.85e-01 -7.81e-01 -7.65e-01 -7.45e-01 -7.31e-01 -7.07e-01 -7.56e-01 -7.56e-01 -7.59e-01 -7.59e-01 -1.11e+00 -1.04e+00 -3.91e-01 -7.71e-01 -7.89e-01 -7.60e-01 -7.67e-01 -7.41e-01 -7.47e-01 -7.26e-01 -7.15e-01 -7.19e-01 -7.39e-01 -7.88e-01 -7.73e-01 -1.12e+00 -1.24e+00 -5.06e-01 -7.87e-01 -7.40e-01 -7.55e-01 -7.36e-01 -7.30e-01 -7.59e-01 -7.40e-01 -7.37e-01 -7.32e-01 -7.38e-01 -7.44e-01 -7.85e-01 -1.11e+00 -8.43e-01 -3.26e-01 -7.83e-01 -7.76e-01 -7.73e-01 -7.64e-01 -7.54e-01 -7.73e-01 -7.28e-01 -7.45e-01 -7.11e-01 -7.24e-01 -7.27e-01 -7.83e-01 -1.10e+00 -6.80e-01 -2.48e-01 -7.83e-01 -7.52e-01 -7.66e-01 -7.85e-01 -7.69e-01 -7.48e-01 -7.23e-01 -6.99e-01 -6.49e-01 -6.92e-01 -7.08e-01 -7.57e-01 -1.07e+00 -7.05e-01 -2.16e-01 -7.82e-01 -7.85e-01 -7.66e-01 -7.58e-01 -7.56e-01 -7.22e-01 -7.09e-01 -6.42e-01 -6.03e-01 -6.32e-01 -6.99e-01 -7.64e-01 -1.08e+00 -8.03e-01 -2.40e-01 -7.40e-01 -7.41e-01 -7.33e-01 -7.45e-01 -7.43e-01 -7.15e-01 -6.99e-01 -6.15e-01 -4.48e-01 -6.70e-01 -7.13e-01 -7.40e-01 -1.05e+00 -8.40e-01 -2.51e-01 -7.67e-01 -7.41e-01 -7.36e-01 -7.41e-01 -7.16e-01 -7.28e-01 -7.11e-01 -6.33e-01 -6.18e-01 -6.57e-01 -7.08e-01 -7.42e-01 -1.00e+00 -7.79e-01 -2.57e-01 -7.51e-01 -7.62e-01 -7.59e-01 -7.36e-01 -7.09e-01 -6.77e-01 -6.94e-01 -6.91e-01 -6.86e-01 -6.77e-01 -6.81e-01 -6.82e-01 -9.60e-01 -6.08e-01 -2.38e-01 -7.58e-01 -8.07e-01 -7.45e-01 -7.27e-01 -7.02e-01 -6.98e-01 -6.68e-01 -6.74e-01 -6.92e-01 -6.88e-01 -6.37e-01 -6.76e-01 -8.84e-01 -3.75e-01 -1.32e-01 -7.90e-01 -7.77e-01 -7.49e-01 -7.25e-01 -7.49e-01 -7.50e-01 -7.08e-01 -7.12e-01 -7.61e-01 -7.28e-01 -6.88e-01 -6.51e-01 -7.19e-01 -3.41e-01 -1.43e-01 -1.14e+00 -1.06e+00 -1.04e+00 -1.06e+00 -1.09e+00 -1.05e+00 -1.03e+00 -9.47e-01 -1.04e+00 -9.40e-01 -9.42e-01 -8.31e-01 -6.65e-01 -2.06e-01 -8.49e-02 -1.33e+00 -1.35e+00 -1.16e+00 -8.61e-01 -8.28e-01 -1.08e+00 -9.81e-01 -7.58e-01 -7.04e-01 -6.54e-01 -7.20e-01 -5.86e-01 -2.41e-01 -1.04e-01 -4.32e-02 -4.74e-01 -5.21e-01 -4.51e-01 -2.77e-01 -2.70e-01 -3.48e-01 -3.55e-01 -2.46e-01 -2.37e-01 -1.76e-01 -2.35e-01 -2.02e-01 -8.43e-02 -4.62e-02 -2.99e-02 -7.31e-01 -7.48e-01 -7.39e-01 -7.66e-01 -7.81e-01 -7.83e-01 -7.79e-01 -7.68e-01 -7.20e-01 -7.09e-01 -7.19e-01 -7.61e-01 -1.05e+00 -7.78e-01 -2.76e-01 -7.52e-01 -7.85e-01 -7.84e-01 -7.87e-01 -7.71e-01 -7.57e-01 -7.62e-01 -7.09e-01 -7.08e-01 -6.96e-01 -7.23e-01 -7.49e-01 -1.06e+00 -5.92e-01 -1.96e-01 -7.43e-01 -7.38e-01 -7.76e-01 -7.70e-01 -7.56e-01 -7.48e-01 -7.41e-01 -7.42e-01 -7.06e-01 -6.90e-01 -7.25e-01 -7.69e-01 -1.04e+00 -8.10e-01 -2.94e-01 -7.40e-01 -7.47e-01 -7.57e-01 -7.48e-01 -7.55e-01 -7.44e-01 -7.42e-01 -7.35e-01 -6.70e-01 -6.64e-01 -7.63e-01 -7.71e-01 -9.80e-01 -7.74e-01 -3.07e-01 -7.55e-01 -7.66e-01 -7.97e-01 -7.40e-01 -7.53e-01 -7.39e-01 -7.26e-01 -7.07e-01 -6.89e-01 -6.87e-01 -7.44e-01 -7.30e-01 -1.03e+00 -6.26e-01 -1.73e-01 -7.55e-01 -7.36e-01 -7.61e-01 -7.64e-01 -7.21e-01 -7.01e-01 -7.26e-01 -6.89e-01 -6.95e-01 -6.71e-01 -6.81e-01 -7.49e-01 -9.77e-01 -6.44e-01 -2.24e-01 -7.44e-01 -7.16e-01 -7.45e-01 -7.32e-01 -7.41e-01 -7.10e-01 -6.77e-01 -6.35e-01 -6.21e-01 -6.30e-01 -6.43e-01 -6.90e-01 -9.34e-01 -7.67e-01 -2.92e-01 -7.32e-01 -7.55e-01 -7.18e-01 -7.24e-01 -7.26e-01 -7.05e-01 -6.53e-01 -6.21e-01 -6.43e-01 -6.52e-01 -7.13e-01 -7.09e-01 -9.53e-01 -6.82e-01 -2.54e-01 -6.97e-01 -7.00e-01 -7.14e-01 -6.97e-01 -7.15e-01 -6.93e-01 -6.77e-01 -6.33e-01 -6.17e-01 -6.11e-01 -7.05e-01 -6.87e-01 -9.29e-01 -5.46e-01 -1.70e-01 -7.20e-01 -7.06e-01 -7.18e-01 -6.87e-01 -6.85e-01 -6.94e-01 -6.44e-01 -6.64e-01 -5.99e-01 -5.89e-01 -6.44e-01 -6.80e-01 -9.68e-01 -6.14e-01 -1.98e-01 -7.51e-01 -7.34e-01 -7.39e-01 -6.97e-01 -6.75e-01 -6.82e-01 -6.70e-01 -7.02e-01 -6.60e-01 -6.35e-01 -6.16e-01 -6.32e-01 -8.05e-01 -4.17e-01 -1.09e-01 -7.89e-01 -7.57e-01 -7.50e-01 -7.29e-01 -7.26e-01 -6.77e-01 -6.48e-01 -7.04e-01 -6.97e-01 -6.79e-01 -6.60e-01 -6.12e-01 -7.24e-01 -2.74e-01 -7.82e-02 -1.14e+00 -1.03e+00 -1.04e+00 -9.43e-01 -1.02e+00 -9.87e-01 -8.16e-01 -8.35e-01 -8.39e-01 -9.59e-01 -9.15e-01 -7.74e-01 -5.71e-01 -1.72e-01 -5.75e-02 -1.12e+00 -1.16e+00 -8.35e-01 -7.13e-01 -7.64e-01 -8.80e-01 -5.67e-01 -4.88e-01 -4.31e-01 -7.46e-01 -6.47e-01 -4.18e-01 -2.22e-01 -6.04e-02 -2.42e-02 -3.88e-01 -3.92e-01 -2.68e-01 -2.61e-01 -2.31e-01 -3.03e-01 -2.09e-01 -1.58e-01 -1.36e-01 -2.55e-01 -2.03e-01 -1.38e-01 -9.69e-02 -4.41e-02 -1.17e-02 -7.71e-01 -7.88e-01 -8.12e-01 -7.42e-01 -7.85e-01 -7.60e-01 -7.46e-01 -7.71e-01 -7.11e-01 -6.80e-01 -6.82e-01 -7.51e-01 -1.04e+00 -6.16e-01 -1.78e-01 -7.57e-01 -7.66e-01 -7.96e-01 -7.87e-01 -7.31e-01 -7.75e-01 -7.52e-01 -7.45e-01 -7.07e-01 -7.05e-01 -7.08e-01 -7.39e-01 -9.99e-01 -6.60e-01 -2.06e-01 -7.40e-01 -7.48e-01 -7.67e-01 -7.62e-01 -7.72e-01 -7.12e-01 -7.41e-01 -7.52e-01 -6.99e-01 -6.87e-01 -6.89e-01 -7.63e-01 -1.10e+00 -8.27e-01 -2.75e-01 -7.59e-01 -7.19e-01 -7.47e-01 -7.32e-01 -7.40e-01 -7.41e-01 -7.25e-01 -7.31e-01 -6.89e-01 -7.01e-01 -7.16e-01 -6.95e-01 -9.76e-01 -8.88e-01 -3.69e-01 -7.39e-01 -7.23e-01 -7.22e-01 -7.34e-01 -7.32e-01 -7.19e-01 -7.08e-01 -7.23e-01 -7.13e-01 -6.86e-01 -7.13e-01 -7.47e-01 -9.68e-01 -6.85e-01 -2.05e-01 -7.59e-01 -7.40e-01 -7.23e-01 -6.89e-01 -6.89e-01 -6.98e-01 -7.04e-01 -6.61e-01 -6.79e-01 -6.79e-01 -6.86e-01 -7.42e-01 -1.01e+00 -7.65e-01 -2.63e-01 -7.27e-01 -7.22e-01 -7.21e-01 -6.82e-01 -6.82e-01 -6.79e-01 -6.66e-01 -6.58e-01 -6.31e-01 -6.61e-01 -6.87e-01 -6.88e-01 -8.56e-01 -5.97e-01 -2.13e-01 -7.02e-01 -7.13e-01 -7.28e-01 -6.93e-01 -6.91e-01 -6.69e-01 -6.46e-01 -6.28e-01 -6.40e-01 -6.38e-01 -6.71e-01 -6.96e-01 -8.50e-01 -3.86e-01 -1.50e-01 -6.91e-01 -6.77e-01 -6.91e-01 -7.07e-01 -7.18e-01 -7.31e-01 -6.70e-01 -6.39e-01 -6.18e-01 -6.02e-01 -6.11e-01 -6.66e-01 -9.21e-01 -4.38e-01 -1.13e-01 -7.24e-01 -6.84e-01 -6.84e-01 -6.47e-01 -6.69e-01 -6.83e-01 -6.69e-01 -6.47e-01 -6.14e-01 -5.97e-01 -6.05e-01 -6.26e-01 -9.22e-01 -4.59e-01 -1.15e-01 -7.38e-01 -6.58e-01 -6.82e-01 -6.72e-01 -7.05e-01 -6.71e-01 -6.60e-01 -6.37e-01 -6.35e-01 -6.02e-01 -5.50e-01 -5.85e-01 -8.26e-01 -4.84e-01 -1.41e-01 -7.40e-01 -6.73e-01 -6.74e-01 -7.15e-01 -7.22e-01 -6.98e-01 -7.17e-01 -6.74e-01 -6.70e-01 -6.46e-01 -5.85e-01 -5.00e-01 -4.95e-01 -2.74e-01 -8.29e-02 -1.11e+00 -9.99e-01 -1.02e+00 -1.05e+00 -1.05e+00 -9.96e-01 -9.29e-01 -9.64e-01 -8.97e-01 -9.51e-01 -8.48e-01 -7.23e-01 -6.11e-01 -2.17e-01 -6.09e-02 -1.15e+00 -9.21e-01 -8.94e-01 -8.34e-01 -8.60e-01 -8.05e-01 -5.65e-01 -5.80e-01 -5.28e-01 -5.64e-01 -6.00e-01 -4.16e-01 -2.18e-01 -8.48e-02 -2.93e-02 -3.50e-01 -2.74e-01 -2.33e-01 -2.38e-01 -2.50e-01 -2.74e-01 -1.88e-01 -1.72e-01 -1.56e-01 -1.57e-01 -1.94e-01 -1.39e-01 -6.35e-02 -3.19e-02 -7.49e-03 -7.41e-01 -7.68e-01 -7.90e-01 -7.78e-01 -7.76e-01 -7.30e-01 -7.18e-01 -7.37e-01 -7.09e-01 -7.20e-01 -7.00e-01 -7.72e-01 -9.68e-01 -6.90e-01 -2.52e-01 -7.57e-01 -7.64e-01 -7.45e-01 -7.47e-01 -7.46e-01 -7.65e-01 -7.54e-01 -7.52e-01 -7.26e-01 -6.82e-01 -7.09e-01 -7.86e-01 -1.04e+00 -7.77e-01 -2.28e-01 -7.74e-01 -7.42e-01 -7.17e-01 -7.21e-01 -7.29e-01 -7.67e-01 -7.52e-01 -7.57e-01 -7.68e-01 -6.89e-01 -6.78e-01 -7.59e-01 -1.05e+00 -8.28e-01 -2.72e-01 -7.40e-01 -7.34e-01 -7.31e-01 -7.16e-01 -7.44e-01 -7.39e-01 -7.56e-01 -7.44e-01 -7.10e-01 -6.88e-01 -6.97e-01 -7.44e-01 -9.71e-01 -7.11e-01 -2.71e-01 -7.13e-01 -6.97e-01 -7.29e-01 -7.42e-01 -7.39e-01 -7.08e-01 -7.05e-01 -7.31e-01 -6.98e-01 -6.88e-01 -7.17e-01 -7.13e-01 -9.73e-01 -6.01e-01 -1.91e-01 -7.45e-01 -7.09e-01 -7.35e-01 -7.10e-01 -7.14e-01 -7.15e-01 -7.08e-01 -7.06e-01 -6.78e-01 -6.67e-01 -6.90e-01 -7.12e-01 -9.35e-01 -5.48e-01 -2.00e-01 -7.32e-01 -7.22e-01 -7.10e-01 -7.08e-01 -7.09e-01 -7.14e-01 -6.79e-01 -6.85e-01 -6.58e-01 -6.83e-01 -6.50e-01 -7.09e-01 -9.87e-01 -7.05e-01 -2.37e-01 -7.08e-01 -7.29e-01 -7.25e-01 -7.21e-01 -7.00e-01 -6.83e-01 -6.43e-01 -6.62e-01 -6.42e-01 -6.10e-01 -6.47e-01 -7.20e-01 -8.94e-01 -4.05e-01 -1.25e-01 -6.82e-01 -6.98e-01 -7.11e-01 -7.24e-01 -7.09e-01 -6.74e-01 -6.40e-01 -6.25e-01 -6.06e-01 -6.01e-01 -6.22e-01 -6.85e-01 -8.81e-01 -4.33e-01 -1.27e-01 -7.04e-01 -6.95e-01 -6.94e-01 -7.08e-01 -6.83e-01 -6.66e-01 -6.52e-01 -6.14e-01 -6.08e-01 -6.22e-01 -5.79e-01 -6.40e-01 -8.39e-01 -5.15e-01 -1.65e-01 -7.06e-01 -6.74e-01 -6.69e-01 -6.66e-01 -6.63e-01 -6.70e-01 -6.87e-01 -6.53e-01 -6.03e-01 -5.84e-01 -5.54e-01 -5.65e-01 -7.87e-01 -4.40e-01 -1.48e-01 -7.67e-01 -6.97e-01 -7.26e-01 -7.26e-01 -6.91e-01 -7.44e-01 -7.07e-01 -6.80e-01 -6.22e-01 -6.16e-01 -5.70e-01 -4.85e-01 -5.06e-01 -2.87e-01 -9.16e-02 -1.20e+00 -9.57e-01 -8.98e-01 -1.03e+00 -9.83e-01 -1.01e+00 -9.58e-01 -1.03e+00 -9.95e-01 -1.02e+00 -8.79e-01 -6.76e-01 -5.34e-01 -1.83e-01 -6.50e-02 -9.53e-01 -7.68e-01 -7.45e-01 -8.42e-01 -9.10e-01 -8.62e-01 -7.39e-01 -7.46e-01 -6.49e-01 -5.31e-01 -4.80e-01 -3.53e-01 -2.00e-01 -8.55e-02 -3.73e-02 -3.66e-01 -3.07e-01 -3.18e-01 -2.87e-01 -3.14e-01 -2.90e-01 -2.36e-01 -2.15e-01 -2.24e-01 -1.70e-01 -1.63e-01 -1.15e-01 -6.32e-02 -3.84e-02 -1.78e-02 -7.11e-01 -7.35e-01 -7.78e-01 -7.95e-01 -7.89e-01 -7.78e-01 -7.90e-01 -8.15e-01 -7.38e-01 -7.56e-01 -7.46e-01 -7.19e-01 -8.73e-01 -4.87e-01 -1.89e-01 -7.24e-01 -7.51e-01 -7.47e-01 -7.52e-01 -7.63e-01 -7.61e-01 -7.53e-01 -7.69e-01 -7.59e-01 -7.54e-01 -7.39e-01 -7.28e-01 -9.65e-01 -6.51e-01 -2.08e-01 -7.30e-01 -7.39e-01 -7.32e-01 -7.64e-01 -7.35e-01 -7.69e-01 -7.88e-01 -7.27e-01 -7.35e-01 -7.32e-01 -7.27e-01 -7.49e-01 -9.97e-01 -7.08e-01 -2.42e-01 -7.30e-01 -7.41e-01 -7.80e-01 -7.20e-01 -7.72e-01 -7.80e-01 -7.58e-01 -7.29e-01 -7.22e-01 -6.85e-01 -6.91e-01 -7.32e-01 -9.70e-01 -5.55e-01 -1.80e-01 -7.25e-01 -7.42e-01 -7.54e-01 -7.29e-01 -7.69e-01 -7.68e-01 -7.23e-01 -7.19e-01 -7.39e-01 -6.99e-01 -7.30e-01 -7.43e-01 -9.67e-01 -5.29e-01 -1.58e-01 -7.27e-01 -7.38e-01 -7.50e-01 -7.78e-01 -7.29e-01 -7.53e-01 -7.20e-01 -7.07e-01 -6.58e-01 -7.03e-01 -7.03e-01 -6.97e-01 -1.02e+00 -5.77e-01 -1.55e-01 -7.04e-01 -7.29e-01 -7.04e-01 -7.41e-01 -7.23e-01 -7.27e-01 -7.22e-01 -6.89e-01 -6.68e-01 -6.72e-01 -6.90e-01 -7.11e-01 -9.24e-01 -6.32e-01 -1.76e-01 -6.92e-01 -7.24e-01 -7.27e-01 -7.47e-01 -7.06e-01 -7.02e-01 -6.65e-01 -6.69e-01 -6.63e-01 -6.78e-01 -6.76e-01 -6.84e-01 -8.81e-01 -5.82e-01 -2.05e-01 -6.77e-01 -6.97e-01 -7.18e-01 -7.16e-01 -7.22e-01 -6.99e-01 -6.33e-01 -6.46e-01 -6.22e-01 -6.20e-01 -6.04e-01 -6.27e-01 -8.72e-01 -4.58e-01 -1.30e-01 -6.94e-01 -6.76e-01 -6.98e-01 -7.16e-01 -7.24e-01 -6.61e-01 -6.58e-01 -6.43e-01 -5.98e-01 -6.12e-01 -5.72e-01 -5.75e-01 -7.13e-01 -4.13e-01 -1.41e-01 -6.83e-01 -6.80e-01 -6.85e-01 -6.92e-01 -6.94e-01 -6.60e-01 -6.70e-01 -6.56e-01 -5.95e-01 -5.92e-01 -5.52e-01 -5.66e-01 -7.57e-01 -2.75e-01 -8.14e-02 -6.80e-01 -6.88e-01 -6.98e-01 -7.21e-01 -6.86e-01 -7.14e-01 -7.21e-01 -6.93e-01 -6.28e-01 -6.06e-01 -5.69e-01 -5.25e-01 -6.18e-01 -2.39e-01 -7.13e-02 -9.78e-01 -8.94e-01 -9.02e-01 -9.75e-01 -9.93e-01 -9.72e-01 -9.04e-01 -9.60e-01 -9.01e-01 -8.02e-01 -8.03e-01 -6.71e-01 -3.57e-01 -1.04e-01 -3.71e-02 -8.79e-01 -4.74e-01 -6.09e-01 -6.57e-01 -6.73e-01 -6.70e-01 -5.29e-01 -7.08e-01 -5.73e-01 -3.74e-01 -4.21e-01 -2.98e-01 -1.43e-01 -5.64e-02 -1.94e-02 -2.87e-01 -1.53e-01 -1.84e-01 -2.04e-01 -2.63e-01 -2.36e-01 -1.65e-01 -2.34e-01 -1.92e-01 -1.28e-01 -1.20e-01 -7.57e-02 -5.20e-02 -3.12e-02 -1.69e-02 -7.55e-01 -8.03e-01 -8.38e-01 -8.11e-01 -8.12e-01 -8.21e-01 -8.19e-01 -7.76e-01 -7.65e-01 -7.57e-01 -7.69e-01 -7.22e-01 -7.14e-01 -1.75e-01 -6.92e-02 -8.24e-01 -8.38e-01 -8.21e-01 -7.68e-01 -7.55e-01 -7.68e-01 -7.83e-01 -7.52e-01 -7.51e-01 -7.46e-01 -7.74e-01 -7.44e-01 -8.02e-01 -3.34e-01 -1.21e-01 -7.93e-01 -8.41e-01 -7.94e-01 -7.70e-01 -7.76e-01 -8.31e-01 -8.21e-01 -7.99e-01 -7.37e-01 -7.45e-01 -7.12e-01 -8.00e-01 -1.03e+00 -5.16e-01 -1.38e-01 -7.80e-01 -7.93e-01 -7.72e-01 -7.70e-01 -7.94e-01 -8.27e-01 -8.15e-01 -7.14e-01 -7.62e-01 -7.24e-01 -6.76e-01 -7.22e-01 -8.97e-01 -4.58e-01 -1.53e-01 -7.51e-01 -7.55e-01 -7.71e-01 -7.75e-01 -7.94e-01 -7.94e-01 -7.68e-01 -7.35e-01 -7.64e-01 -7.55e-01 -7.00e-01 -7.25e-01 -9.50e-01 -5.35e-01 -1.47e-01 -7.48e-01 -7.62e-01 -7.42e-01 -7.69e-01 -7.62e-01 -7.55e-01 -7.49e-01 -7.15e-01 -7.33e-01 -7.29e-01 -6.88e-01 -6.77e-01 -8.92e-01 -4.73e-01 -1.54e-01 -7.07e-01 -7.12e-01 -7.63e-01 -7.78e-01 -7.67e-01 -7.38e-01 -7.39e-01 -7.04e-01 -6.90e-01 -7.02e-01 -7.00e-01 -6.50e-01 -7.45e-01 -4.80e-01 -1.67e-01 -7.10e-01 -7.31e-01 -7.02e-01 -7.48e-01 -7.25e-01 -7.23e-01 -7.48e-01 -7.26e-01 -7.06e-01 -6.63e-01 -6.82e-01 -6.87e-01 -8.55e-01 -3.87e-01 -1.27e-01 -7.27e-01 -7.16e-01 -7.34e-01 -7.54e-01 -7.46e-01 -7.70e-01 -7.11e-01 -6.87e-01 -6.70e-01 -6.64e-01 -6.35e-01 -6.35e-01 -8.28e-01 -3.65e-01 -1.19e-01 -7.19e-01 -6.95e-01 -7.56e-01 -7.46e-01 -7.40e-01 -7.30e-01 -6.89e-01 -6.43e-01 -6.17e-01 -5.90e-01 -6.17e-01 -5.70e-01 -7.99e-01 -3.80e-01 -1.34e-01 -6.68e-01 -6.64e-01 -6.96e-01 -7.05e-01 -7.48e-01 -7.14e-01 -6.55e-01 -6.42e-01 -6.17e-01 -5.96e-01 -5.59e-01 -5.39e-01 -6.83e-01 -2.51e-01 -7.41e-02 -6.65e-01 -6.54e-01 -6.72e-01 -6.79e-01 -6.77e-01 -6.50e-01 -6.85e-01 -6.99e-01 -6.33e-01 -6.12e-01 -5.40e-01 -5.07e-01 -5.77e-01 -2.24e-01 -6.42e-02 -8.66e-01 -8.00e-01 -8.01e-01 -8.48e-01 -8.27e-01 -8.32e-01 -8.36e-01 -9.02e-01 -9.05e-01 -7.29e-01 -6.75e-01 -5.88e-01 -3.48e-01 -1.10e-01 -3.71e-02 -6.49e-01 -3.51e-01 -4.24e-01 -5.24e-01 -4.05e-01 -4.08e-01 -3.66e-01 -3.97e-01 -5.38e-01 -3.80e-01 -2.81e-01 -2.19e-01 -1.32e-01 -3.23e-02 -1.05e-02 -2.57e-01 -1.34e-01 -1.74e-01 -1.81e-01 -1.46e-01 -1.42e-01 -1.23e-01 -1.30e-01 -1.65e-01 -1.27e-01 -8.17e-02 -7.95e-02 -5.09e-02 -1.73e-02 -7.50e-03 -1.08e+00 -1.13e+00 -1.22e+00 -1.22e+00 -1.16e+00 -1.11e+00 -1.11e+00 -1.06e+00 -1.11e+00 -9.89e-01 -9.97e-01 -1.02e+00 -7.84e-01 -1.55e-01 -3.93e-02 -1.15e+00 -1.05e+00 -1.23e+00 -1.10e+00 -1.10e+00 -1.14e+00 -1.11e+00 -1.03e+00 -9.91e-01 -1.02e+00 -9.48e-01 -9.15e-01 -8.91e-01 -2.88e-01 -8.05e-02 -1.12e+00 -1.04e+00 -1.18e+00 -1.10e+00 -1.06e+00 -1.18e+00 -1.04e+00 -1.15e+00 -1.03e+00 -1.04e+00 -9.63e-01 -9.19e-01 -1.05e+00 -4.94e-01 -1.55e-01 -1.12e+00 -1.03e+00 -1.09e+00 -1.12e+00 -1.10e+00 -1.19e+00 -1.11e+00 -1.10e+00 -1.06e+00 -1.01e+00 -8.73e-01 -8.08e-01 -8.67e-01 -3.12e-01 -9.00e-02 -1.08e+00 -1.03e+00 -1.06e+00 -1.10e+00 -1.05e+00 -1.13e+00 -1.27e+00 -1.09e+00 -1.08e+00 -1.12e+00 -9.93e-01 -8.86e-01 -7.84e-01 -3.95e-01 -1.46e-01 -1.07e+00 -9.78e-01 -1.03e+00 -1.02e+00 -1.00e+00 -1.09e+00 -1.08e+00 -1.01e+00 -1.03e+00 -1.07e+00 -9.59e-01 -8.28e-01 -8.42e-01 -4.01e-01 -1.22e-01 -9.48e-01 -9.63e-01 -1.06e+00 -1.04e+00 -9.98e-01 -1.04e+00 -1.02e+00 -9.83e-01 -8.41e-01 -9.51e-01 -9.08e-01 -7.45e-01 -7.77e-01 -3.05e-01 -9.78e-02 -9.70e-01 -9.47e-01 -9.99e-01 -1.08e+00 -1.11e+00 -1.03e+00 -1.01e+00 -9.93e-01 -8.83e-01 -8.87e-01 -9.14e-01 -8.38e-01 -6.43e-01 -1.75e-01 -5.80e-02 -9.67e-01 -9.99e-01 -1.01e+00 -1.06e+00 -1.08e+00 -9.67e-01 -1.08e+00 -1.02e+00 -8.98e-01 -9.10e-01 -8.57e-01 -8.25e-01 -8.06e-01 -2.24e-01 -7.49e-02 -9.69e-01 -1.03e+00 -1.10e+00 -1.01e+00 -1.06e+00 -9.81e-01 -1.01e+00 -9.04e-01 -8.30e-01 -8.02e-01 -8.09e-01 -8.11e-01 -7.80e-01 -2.46e-01 -7.63e-02 -8.90e-01 -9.28e-01 -1.02e+00 -1.02e+00 -9.83e-01 -1.07e+00 -9.40e-01 -8.16e-01 -7.84e-01 -6.91e-01 -7.33e-01 -6.96e-01 -5.05e-01 -2.10e-01 -7.72e-02 -7.36e-01 -7.62e-01 -8.86e-01 -8.71e-01 -9.21e-01 -9.57e-01 -1.00e+00 -9.26e-01 -8.38e-01 -7.10e-01 -6.68e-01 -6.38e-01 -4.88e-01 -1.47e-01 -5.84e-02 -6.38e-01 -6.97e-01 -7.81e-01 -7.21e-01 -8.22e-01 -8.29e-01 -6.94e-01 -9.33e-01 -9.36e-01 -7.85e-01 -5.91e-01 -4.82e-01 -3.15e-01 -9.11e-02 -4.04e-02 -3.59e-01 -2.19e-01 -2.60e-01 -3.06e-01 -2.48e-01 -2.41e-01 -2.20e-01 -2.69e-01 -4.39e-01 -2.88e-01 -1.35e-01 -1.30e-01 -7.47e-02 -2.46e-02 -1.39e-02 -1.37e-01 -7.05e-02 -9.05e-02 -9.63e-02 -7.38e-02 -7.57e-02 -7.98e-02 -7.83e-02 -1.40e-01 -1.09e-01 -5.52e-02 -4.14e-02 -2.38e-02 -1.27e-02 -4.98e-03 -1.08e+00 -1.06e+00 -1.34e+00 -9.87e-01 -1.49e+00 -1.22e+00 -1.08e+00 -1.13e+00 -9.74e-01 -8.45e-01 -6.07e-01 -6.33e-01 -5.34e-01 -1.43e-01 -3.98e-02 -1.35e+00 -9.68e-01 -1.60e+00 -1.80e+00 -1.45e+00 -1.17e+00 -9.94e-01 -1.02e+00 -8.65e-01 -7.01e-01 -6.46e-01 -5.40e-01 -4.49e-01 -2.04e-01 -7.38e-02 -1.18e+00 -1.14e+00 -1.48e+00 -1.19e+00 -9.38e-01 -1.19e+00 -9.74e-01 -1.01e+00 -9.23e-01 -8.23e-01 -8.89e-01 -7.01e-01 -3.85e-01 -2.16e-01 -1.44e-01 -1.32e+00 -1.14e+00 -1.36e+00 -1.53e+00 -1.16e+00 -1.29e+00 -1.36e+00 -1.18e+00 -1.09e+00 -8.66e-01 -6.32e-01 -4.57e-01 -3.13e-01 -1.52e-01 -6.87e-02 -1.30e+00 -9.74e-01 -1.29e+00 -1.54e+00 -1.33e+00 -1.38e+00 -1.35e+00 -1.13e+00 -9.14e-01 -8.56e-01 -7.71e-01 -4.06e-01 -2.63e-01 -1.30e-01 -6.54e-02 -1.05e+00 -7.94e-01 -1.12e+00 -1.15e+00 -8.13e-01 -9.20e-01 -1.09e+00 -8.11e-01 -6.93e-01 -8.96e-01 -8.00e-01 -5.26e-01 -2.87e-01 -1.23e-01 -7.75e-02 -7.48e-01 -9.01e-01 -1.04e+00 -1.05e+00 -9.12e-01 -1.00e+00 -9.12e-01 -7.83e-01 -6.62e-01 -6.12e-01 -4.88e-01 -3.46e-01 -2.31e-01 -1.33e-01 -7.44e-02 -5.62e-01 -7.11e-01 -8.51e-01 -8.66e-01 -9.29e-01 -9.65e-01 -6.70e-01 -6.37e-01 -4.77e-01 -4.37e-01 -4.96e-01 -3.94e-01 -2.26e-01 -1.06e-01 -3.96e-02 -6.10e-01 -6.97e-01 -8.44e-01 -1.11e+00 -8.69e-01 -7.98e-01 -6.03e-01 -7.36e-01 -5.96e-01 -5.37e-01 -4.95e-01 -4.22e-01 -2.94e-01 -1.01e-01 -4.37e-02 -4.56e-01 -8.07e-01 -1.07e+00 -8.05e-01 -7.16e-01 -5.03e-01 -6.26e-01 -7.10e-01 -5.73e-01 -4.58e-01 -4.44e-01 -3.45e-01 -2.60e-01 -1.36e-01 -4.22e-02 -4.93e-01 -6.13e-01 -8.04e-01 -5.55e-01 -7.11e-01 -7.23e-01 -5.94e-01 -5.56e-01 -4.34e-01 -2.96e-01 -3.80e-01 -3.42e-01 -2.09e-01 -1.08e-01 -4.84e-02 -4.28e-01 -3.61e-01 -5.20e-01 -4.86e-01 -4.81e-01 -6.92e-01 -5.95e-01 -3.74e-01 -3.26e-01 -2.76e-01 -2.59e-01 -2.57e-01 -1.85e-01 -4.96e-02 -1.83e-02 -2.15e-01 -2.66e-01 -3.14e-01 -2.45e-01 -2.95e-01 -4.30e-01 -3.75e-01 -3.67e-01 -3.05e-01 -3.09e-01 -2.21e-01 -1.80e-01 -1.34e-01 -5.03e-02 -2.00e-02 -9.60e-02 -1.01e-01 -1.15e-01 -9.88e-02 -1.27e-01 -1.67e-01 -1.28e-01 -1.60e-01 -1.75e-01 -1.43e-01 -8.60e-02 -5.91e-02 -4.18e-02 -2.09e-02 -1.01e-02 -6.92e-02 -3.71e-02 -4.18e-02 -4.29e-02 -4.54e-02 -6.16e-02 -4.09e-02 -5.12e-02 -7.23e-02 -6.74e-02 -3.14e-02 -1.80e-02 -1.64e-02 -7.47e-03 -2.97e-03 -3.66e-01 -3.67e-01 -4.98e-01 -3.34e-01 -5.46e-01 -4.10e-01 -3.75e-01 -3.97e-01 -3.66e-01 -2.85e-01 -1.96e-01 -1.98e-01 -1.79e-01 -1.05e-01 -3.65e-02 -5.51e-01 -2.62e-01 -5.35e-01 -7.29e-01 -6.22e-01 -4.43e-01 -3.56e-01 -3.26e-01 -3.18e-01 -2.53e-01 -1.98e-01 -1.61e-01 -1.35e-01 -8.96e-02 -4.34e-02 -4.38e-01 -3.47e-01 -5.06e-01 -4.90e-01 -2.64e-01 -4.25e-01 -3.58e-01 -3.11e-01 -3.30e-01 -2.32e-01 -3.09e-01 -2.65e-01 -1.43e-01 -6.12e-02 -6.39e-02 -4.34e-01 -3.64e-01 -5.30e-01 -6.02e-01 -4.03e-01 -4.34e-01 -4.80e-01 -4.48e-01 -4.35e-01 -3.28e-01 -2.19e-01 -1.55e-01 -1.04e-01 -6.22e-02 -2.93e-02 -5.28e-01 -3.92e-01 -4.89e-01 -5.69e-01 -5.08e-01 -4.82e-01 -5.01e-01 -3.73e-01 -3.58e-01 -2.50e-01 -2.62e-01 -1.19e-01 -7.33e-02 -4.35e-02 -2.75e-02 -3.24e-01 -2.74e-01 -3.53e-01 -3.82e-01 -3.09e-01 -2.64e-01 -3.42e-01 -2.59e-01 -2.24e-01 -2.72e-01 -2.89e-01 -2.17e-01 -1.01e-01 -4.22e-02 -2.14e-02 -3.08e-01 -2.90e-01 -3.71e-01 -4.11e-01 -2.41e-01 -2.90e-01 -2.99e-01 -2.76e-01 -2.53e-01 -2.06e-01 -1.62e-01 -1.37e-01 -7.91e-02 -3.97e-02 -3.67e-02 -1.54e-01 -2.66e-01 -2.58e-01 -2.66e-01 -2.93e-01 -3.18e-01 -1.96e-01 -2.10e-01 -1.51e-01 -1.19e-01 -1.30e-01 -1.25e-01 -6.88e-02 -5.68e-02 -4.11e-02 -1.94e-01 -2.10e-01 -2.78e-01 -3.44e-01 -3.33e-01 -3.12e-01 -1.89e-01 -2.43e-01 -2.08e-01 -1.74e-01 -1.46e-01 -1.34e-01 -1.11e-01 -4.65e-02 -1.94e-02 -1.16e-01 -2.46e-01 -3.24e-01 -3.12e-01 -2.29e-01 -1.48e-01 -2.01e-01 -2.33e-01 -2.12e-01 -1.40e-01 -1.33e-01 -1.13e-01 -6.83e-02 -6.78e-02 -3.69e-02 -1.55e-01 -2.51e-01 -2.94e-01 -1.53e-01 -2.32e-01 -2.02e-01 -1.35e-01 -1.89e-01 -1.55e-01 -1.09e-01 -1.17e-01 -9.56e-02 -6.95e-02 -5.08e-02 -3.96e-02 -1.13e-01 -1.22e-01 -1.62e-01 -1.45e-01 -1.49e-01 -2.36e-01 -2.03e-01 -1.50e-01 -1.01e-01 -8.51e-02 -7.83e-02 -7.56e-02 -7.49e-02 -2.08e-02 -8.15e-03 -9.29e-02 -9.19e-02 -1.09e-01 -1.23e-01 -9.19e-02 -1.58e-01 -1.36e-01 -1.13e-01 -8.64e-02 -1.01e-01 -5.95e-02 -6.00e-02 -5.68e-02 -2.10e-02 -7.24e-03 -3.10e-02 -4.84e-02 -4.87e-02 -3.68e-02 -5.75e-02 -7.85e-02 -7.07e-02 -8.18e-02 -9.39e-02 -5.13e-02 -5.46e-02 -3.42e-02 -2.14e-02 -1.34e-02 -1.14e-02 -2.27e-02 -2.51e-02 -2.70e-02 -2.56e-02 -3.02e-02 -5.07e-02 -3.42e-02 -3.18e-02 -5.82e-02 -3.83e-02 -2.90e-02 -1.85e-02 -7.38e-03 -5.00e-03 -7.27e-03 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows_fw_cadis_mesh/linear/inputs_true.dat b/tests/regression_tests/weightwindows_fw_cadis_mesh/linear/inputs_true.dat deleted file mode 100644 index 62f847858..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_mesh/linear/inputs_true.dat +++ /dev/null @@ -1,267 +0,0 @@ - - - - mgxs.h5 - - - - - - - - - - - - - - - - - - - - - 2.5 2.5 2.5 - 12 12 12 - 0.0 0.0 0.0 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 -2 2 2 2 2 2 2 2 2 2 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 - - - - - - - - - - fixed source - 750 - 30 - 20 - - - 100.0 1.0 - - - universe - 1 - - - multi-group - - - 1 - neutron - 10 - 1 - true - fw_cadis - - - - 15 15 15 - 0.0 0.0 0.0 - 30.0 30.0 30.0 - - - 500.0 - 100.0 - - - - 0.0 0.0 0.0 30.0 30.0 30.0 - - - - true - - - - - - linear - - - - - 1 - - - 2 - - - 3 - - - 3 - flux - tracklength - - - 2 - flux - tracklength - - - 1 - flux - tracklength - - - diff --git a/tests/regression_tests/weightwindows_fw_cadis_mesh/linear/results_true.dat b/tests/regression_tests/weightwindows_fw_cadis_mesh/linear/results_true.dat deleted file mode 100644 index c1066ae82..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_mesh/linear/results_true.dat +++ /dev/null @@ -1,6760 +0,0 @@ -RegularMesh - ID = 1 - Name = - Dimensions = 3 - Voxels = [15 15 15] - Lower left = [0. 0. 0.] - Upper Right = [np.float64(30.0), np.float64(30.0), np.float64(30.0)] - Width = [2. 2. 2.] -Lower Bounds -1.77e-01 -1.81e-01 -1.81e-01 -1.81e-01 -1.78e-01 -1.74e-01 -1.70e-01 -1.76e-01 -1.80e-01 -1.88e-01 -1.75e-01 -1.93e-01 -2.76e-01 -4.28e-01 -1.58e-01 -1.74e-01 -1.82e-01 -1.81e-01 -1.63e-01 -1.78e-01 -1.81e-01 -1.77e-01 -1.77e-01 -1.74e-01 -1.72e-01 -1.81e-01 -1.82e-01 -2.58e-01 -3.27e-01 -1.07e-01 -1.82e-01 -1.75e-01 -1.81e-01 -1.82e-01 -1.76e-01 -1.77e-01 -1.74e-01 -1.66e-01 -1.66e-01 -1.69e-01 -1.76e-01 -1.87e-01 -2.67e-01 -4.16e-01 -1.57e-01 -1.76e-01 -1.74e-01 -1.72e-01 -1.76e-01 -1.67e-01 -1.68e-01 -1.70e-01 -1.75e-01 -1.72e-01 -1.73e-01 -1.65e-01 -1.84e-01 -2.67e-01 -3.99e-01 -1.28e-01 -1.75e-01 -1.82e-01 -1.82e-01 -1.84e-01 -1.72e-01 -1.72e-01 -1.67e-01 -1.67e-01 -1.66e-01 -1.74e-01 -1.69e-01 -1.90e-01 -2.82e-01 -3.31e-01 -1.29e-01 -1.80e-01 -1.79e-01 -1.79e-01 -1.78e-01 -1.76e-01 -1.69e-01 -1.68e-01 -1.63e-01 -1.70e-01 -1.66e-01 -1.71e-01 -1.92e-01 -2.70e-01 -2.88e-01 -1.02e-01 -1.76e-01 -1.72e-01 -1.68e-01 -1.71e-01 -1.66e-01 -1.68e-01 -1.65e-01 -1.66e-01 -1.62e-01 -1.60e-01 -1.61e-01 -1.66e-01 -2.39e-01 -3.32e-01 -1.23e-01 -1.82e-01 -1.81e-01 -1.79e-01 -1.70e-01 -1.67e-01 -1.72e-01 -1.65e-01 -1.62e-01 -1.47e-01 -1.56e-01 -1.56e-01 -1.44e-01 -2.01e-01 -1.76e-01 -7.55e-02 -1.76e-01 -1.76e-01 -1.80e-01 -1.82e-01 -1.71e-01 -1.67e-01 -1.65e-01 -1.62e-01 -1.54e-01 -1.55e-01 -1.54e-01 -1.55e-01 -2.28e-01 -1.67e-01 -5.36e-02 -1.77e-01 -1.85e-01 -1.83e-01 -1.81e-01 -1.79e-01 -1.61e-01 -1.64e-01 -1.58e-01 -1.61e-01 -1.60e-01 -1.55e-01 -1.53e-01 -2.33e-01 -1.74e-01 -6.51e-02 -1.81e-01 -1.79e-01 -1.83e-01 -1.79e-01 -1.80e-01 -1.69e-01 -1.58e-01 -1.66e-01 -1.59e-01 -1.59e-01 -1.70e-01 -1.56e-01 -2.11e-01 -1.28e-01 -3.74e-02 -1.90e-01 -1.90e-01 -1.82e-01 -1.71e-01 -1.90e-01 -1.82e-01 -1.72e-01 -1.79e-01 -1.69e-01 -1.69e-01 -1.66e-01 -1.51e-01 -2.22e-01 -9.62e-02 -3.14e-02 -2.75e-01 -2.73e-01 -2.51e-01 -2.62e-01 -2.73e-01 -2.67e-01 -2.53e-01 -2.43e-01 -2.41e-01 -2.42e-01 -2.39e-01 -2.23e-01 -2.12e-01 -7.28e-02 -2.10e-02 -5.00e-01 -3.50e-01 -3.91e-01 -2.55e-01 -2.81e-01 -3.18e-01 -2.54e-01 -2.37e-01 -1.86e-01 -1.97e-01 -1.81e-01 -1.50e-01 -9.74e-02 -3.76e-02 -1.86e-02 -2.17e-01 -1.42e-01 -1.63e-01 -8.18e-02 -9.18e-02 -1.14e-01 -8.12e-02 -7.94e-02 -6.97e-02 -6.23e-02 -6.28e-02 -4.48e-02 -3.69e-02 -1.59e-02 -7.16e-03 -1.71e-01 -1.76e-01 -1.78e-01 -1.74e-01 -1.77e-01 -1.76e-01 -1.81e-01 -1.77e-01 -1.69e-01 -1.76e-01 -1.83e-01 -1.84e-01 -2.71e-01 -3.99e-01 -1.54e-01 -1.79e-01 -1.79e-01 -1.80e-01 -1.75e-01 -1.76e-01 -1.71e-01 -1.74e-01 -1.74e-01 -1.72e-01 -1.73e-01 -1.77e-01 -1.85e-01 -2.54e-01 -3.67e-01 -1.34e-01 -1.80e-01 -1.76e-01 -1.74e-01 -1.77e-01 -1.76e-01 -1.77e-01 -1.74e-01 -1.78e-01 -1.72e-01 -1.80e-01 -1.81e-01 -1.81e-01 -2.66e-01 -3.32e-01 -1.15e-01 -1.82e-01 -1.86e-01 -1.81e-01 -1.83e-01 -1.74e-01 -1.67e-01 -1.72e-01 -1.75e-01 -1.70e-01 -1.69e-01 -1.75e-01 -1.84e-01 -2.58e-01 -3.55e-01 -1.26e-01 -1.80e-01 -1.82e-01 -1.79e-01 -1.73e-01 -1.66e-01 -1.70e-01 -1.77e-01 -1.69e-01 -1.68e-01 -1.69e-01 -1.78e-01 -1.83e-01 -2.75e-01 -3.02e-01 -1.32e-01 -1.75e-01 -1.78e-01 -1.77e-01 -1.69e-01 -1.79e-01 -1.69e-01 -1.65e-01 -1.63e-01 -1.63e-01 -1.67e-01 -1.74e-01 -1.87e-01 -2.69e-01 -3.43e-01 -1.20e-01 -1.80e-01 -1.82e-01 -1.68e-01 -1.67e-01 -1.77e-01 -1.70e-01 -1.59e-01 -1.60e-01 -1.58e-01 -1.61e-01 -1.65e-01 -1.67e-01 -2.34e-01 -2.93e-01 -1.13e-01 -1.71e-01 -1.72e-01 -1.65e-01 -1.65e-01 -1.65e-01 -1.60e-01 -1.57e-01 -1.46e-01 -1.43e-01 -1.50e-01 -1.48e-01 -1.06e-01 -1.93e-01 -1.68e-01 -7.02e-02 -1.69e-01 -1.86e-01 -1.75e-01 -1.74e-01 -1.77e-01 -1.65e-01 -1.61e-01 -1.54e-01 -1.53e-01 -1.55e-01 -1.47e-01 -1.41e-01 -1.98e-01 -1.23e-01 -3.84e-02 -1.78e-01 -1.86e-01 -1.76e-01 -1.77e-01 -1.65e-01 -1.75e-01 -1.66e-01 -1.54e-01 -1.59e-01 -1.54e-01 -1.63e-01 -1.52e-01 -2.17e-01 -1.45e-01 -4.33e-02 -1.80e-01 -1.87e-01 -1.79e-01 -1.73e-01 -1.81e-01 -1.76e-01 -1.67e-01 -1.60e-01 -1.63e-01 -1.60e-01 -1.69e-01 -1.55e-01 -2.16e-01 -1.34e-01 -4.11e-02 -1.88e-01 -1.80e-01 -1.84e-01 -1.81e-01 -1.84e-01 -1.87e-01 -1.74e-01 -1.69e-01 -1.66e-01 -1.73e-01 -1.70e-01 -1.62e-01 -2.01e-01 -8.29e-02 -2.86e-02 -2.58e-01 -2.81e-01 -2.59e-01 -2.69e-01 -2.95e-01 -2.69e-01 -2.46e-01 -2.56e-01 -2.33e-01 -2.31e-01 -2.59e-01 -2.41e-01 -2.08e-01 -5.36e-02 -1.40e-02 -3.12e-01 -2.97e-01 -2.71e-01 -3.04e-01 -3.70e-01 -3.54e-01 -2.77e-01 -2.79e-01 -2.19e-01 -1.62e-01 -1.62e-01 -1.63e-01 -1.08e-01 -3.47e-02 -1.48e-02 -1.09e-01 -1.08e-01 -1.05e-01 -1.01e-01 -1.35e-01 -1.42e-01 -9.52e-02 -9.99e-02 -9.32e-02 -5.18e-02 -5.18e-02 -5.34e-02 -4.23e-02 -1.87e-02 -7.19e-03 -1.80e-01 -1.75e-01 -1.82e-01 -1.75e-01 -1.71e-01 -1.70e-01 -1.69e-01 -1.65e-01 -1.75e-01 -1.71e-01 -1.68e-01 -1.86e-01 -3.12e-01 -4.27e-01 -1.66e-01 -1.81e-01 -1.77e-01 -1.70e-01 -1.73e-01 -1.73e-01 -1.72e-01 -1.64e-01 -1.66e-01 -1.66e-01 -1.73e-01 -1.70e-01 -1.89e-01 -2.63e-01 -4.02e-01 -1.64e-01 -1.79e-01 -1.80e-01 -1.83e-01 -1.71e-01 -1.73e-01 -1.71e-01 -1.70e-01 -1.75e-01 -1.69e-01 -1.68e-01 -1.68e-01 -1.80e-01 -2.49e-01 -3.42e-01 -1.29e-01 -1.63e-01 -1.73e-01 -1.74e-01 -1.71e-01 -1.68e-01 -1.65e-01 -1.68e-01 -1.73e-01 -1.72e-01 -1.65e-01 -1.72e-01 -1.69e-01 -2.52e-01 -3.19e-01 -1.06e-01 -1.67e-01 -1.70e-01 -1.72e-01 -1.64e-01 -1.71e-01 -1.71e-01 -1.57e-01 -1.64e-01 -1.61e-01 -1.62e-01 -1.73e-01 -1.79e-01 -2.63e-01 -2.66e-01 -7.74e-02 -1.68e-01 -1.72e-01 -1.64e-01 -1.66e-01 -1.65e-01 -1.66e-01 -1.58e-01 -1.59e-01 -1.63e-01 -1.63e-01 -1.70e-01 -1.75e-01 -2.51e-01 -3.47e-01 -1.31e-01 -1.72e-01 -1.79e-01 -1.70e-01 -1.70e-01 -1.69e-01 -1.71e-01 -1.70e-01 -1.55e-01 -1.59e-01 -1.65e-01 -1.70e-01 -1.71e-01 -2.43e-01 -2.46e-01 -9.20e-02 -1.70e-01 -1.70e-01 -1.66e-01 -1.63e-01 -1.66e-01 -1.63e-01 -1.59e-01 -1.58e-01 -1.57e-01 -1.60e-01 -1.55e-01 -1.53e-01 -2.20e-01 -1.63e-01 -6.37e-02 -1.70e-01 -1.70e-01 -1.73e-01 -1.69e-01 -1.66e-01 -1.64e-01 -1.63e-01 -1.64e-01 -1.52e-01 -1.54e-01 -1.53e-01 -1.49e-01 -2.12e-01 -1.64e-01 -6.14e-02 -1.74e-01 -1.78e-01 -1.73e-01 -1.75e-01 -1.74e-01 -1.65e-01 -1.67e-01 -1.59e-01 -1.48e-01 -1.57e-01 -1.55e-01 -1.59e-01 -2.06e-01 -1.23e-01 -4.80e-02 -1.69e-01 -1.78e-01 -1.77e-01 -1.74e-01 -1.77e-01 -1.73e-01 -1.74e-01 -1.68e-01 -1.52e-01 -1.58e-01 -1.58e-01 -1.55e-01 -2.12e-01 -1.22e-01 -3.34e-02 -1.75e-01 -1.85e-01 -1.86e-01 -1.90e-01 -1.80e-01 -1.79e-01 -1.76e-01 -1.71e-01 -1.67e-01 -1.71e-01 -1.69e-01 -1.69e-01 -1.86e-01 -1.02e-01 -3.54e-02 -2.66e-01 -2.66e-01 -2.64e-01 -2.50e-01 -2.60e-01 -2.58e-01 -2.34e-01 -2.42e-01 -2.35e-01 -2.29e-01 -2.33e-01 -2.42e-01 -2.28e-01 -5.44e-02 -1.71e-02 -3.77e-01 -2.75e-01 -3.41e-01 -3.51e-01 -3.64e-01 -2.31e-01 -2.32e-01 -2.18e-01 -1.82e-01 -1.77e-01 -1.28e-01 -1.16e-01 -1.03e-01 -4.16e-02 -1.06e-02 -1.33e-01 -8.71e-02 -1.41e-01 -1.34e-01 -1.37e-01 -8.83e-02 -7.82e-02 -8.36e-02 -5.61e-02 -6.39e-02 -2.90e-02 -3.69e-02 -3.46e-02 -2.60e-02 -1.24e-02 -1.77e-01 -1.71e-01 -1.75e-01 -1.79e-01 -1.73e-01 -1.71e-01 -1.64e-01 -1.66e-01 -1.59e-01 -1.61e-01 -1.55e-01 -1.79e-01 -2.67e-01 -4.26e-01 -1.56e-01 -1.75e-01 -1.82e-01 -1.71e-01 -1.65e-01 -1.69e-01 -1.66e-01 -1.69e-01 -1.63e-01 -1.65e-01 -1.74e-01 -1.69e-01 -1.76e-01 -2.47e-01 -3.31e-01 -1.30e-01 -1.69e-01 -1.73e-01 -1.77e-01 -1.67e-01 -1.55e-01 -1.67e-01 -1.59e-01 -1.63e-01 -1.58e-01 -1.70e-01 -1.69e-01 -1.84e-01 -2.44e-01 -2.71e-01 -1.02e-01 -1.69e-01 -1.70e-01 -1.73e-01 -1.69e-01 -1.66e-01 -1.67e-01 -1.64e-01 -1.60e-01 -1.62e-01 -1.63e-01 -1.63e-01 -1.67e-01 -2.48e-01 -2.40e-01 -9.84e-02 -1.62e-01 -1.64e-01 -1.69e-01 -1.71e-01 -1.62e-01 -1.58e-01 -1.62e-01 -1.58e-01 -1.62e-01 -1.61e-01 -1.71e-01 -1.67e-01 -2.50e-01 -3.22e-01 -1.17e-01 -1.74e-01 -1.60e-01 -1.69e-01 -1.72e-01 -1.67e-01 -1.60e-01 -1.65e-01 -1.68e-01 -1.62e-01 -1.60e-01 -1.63e-01 -1.76e-01 -2.53e-01 -2.99e-01 -1.10e-01 -1.69e-01 -1.67e-01 -1.76e-01 -1.64e-01 -1.59e-01 -1.58e-01 -1.64e-01 -1.59e-01 -1.55e-01 -1.59e-01 -1.51e-01 -1.60e-01 -2.50e-01 -2.88e-01 -1.01e-01 -1.72e-01 -1.71e-01 -1.68e-01 -1.63e-01 -1.59e-01 -1.61e-01 -1.66e-01 -1.56e-01 -1.54e-01 -1.51e-01 -1.49e-01 -1.58e-01 -2.33e-01 -1.85e-01 -6.62e-02 -1.69e-01 -1.65e-01 -1.63e-01 -1.67e-01 -1.62e-01 -1.63e-01 -1.63e-01 -1.61e-01 -1.55e-01 -1.53e-01 -1.59e-01 -1.69e-01 -2.48e-01 -1.87e-01 -5.29e-02 -1.71e-01 -1.66e-01 -1.73e-01 -1.68e-01 -1.65e-01 -1.64e-01 -1.59e-01 -1.52e-01 -1.60e-01 -1.52e-01 -1.48e-01 -1.54e-01 -2.32e-01 -1.35e-01 -5.41e-02 -1.76e-01 -1.78e-01 -1.68e-01 -1.79e-01 -1.73e-01 -1.69e-01 -1.62e-01 -1.61e-01 -1.59e-01 -1.61e-01 -1.58e-01 -1.60e-01 -2.06e-01 -9.41e-02 -2.78e-02 -1.88e-01 -1.77e-01 -1.78e-01 -1.76e-01 -1.82e-01 -1.90e-01 -1.76e-01 -1.62e-01 -1.69e-01 -1.69e-01 -1.69e-01 -1.68e-01 -1.97e-01 -7.83e-02 -2.27e-02 -2.47e-01 -2.50e-01 -2.59e-01 -2.51e-01 -2.57e-01 -2.55e-01 -2.15e-01 -2.28e-01 -2.42e-01 -2.25e-01 -2.12e-01 -2.14e-01 -2.28e-01 -7.82e-02 -2.46e-02 -3.10e-01 -2.49e-01 -2.07e-01 -2.92e-01 -2.88e-01 -2.33e-01 -1.62e-01 -1.13e-01 -1.90e-01 -1.80e-01 -1.16e-01 -1.07e-01 -9.41e-02 -4.21e-02 -1.63e-02 -1.17e-01 -8.58e-02 -8.78e-02 -9.13e-02 -1.15e-01 -8.57e-02 -6.78e-02 -3.63e-02 -6.34e-02 -6.38e-02 -4.06e-02 -3.60e-02 -2.77e-02 -2.56e-02 -1.21e-02 -1.71e-01 -1.68e-01 -1.63e-01 -1.68e-01 -1.72e-01 -1.66e-01 -1.65e-01 -1.51e-01 -1.57e-01 -1.63e-01 -1.57e-01 -1.78e-01 -2.58e-01 -3.15e-01 -1.24e-01 -1.72e-01 -1.71e-01 -1.66e-01 -1.69e-01 -1.71e-01 -1.63e-01 -1.58e-01 -1.51e-01 -1.62e-01 -1.68e-01 -1.67e-01 -1.76e-01 -2.54e-01 -3.04e-01 -1.12e-01 -1.75e-01 -1.72e-01 -1.70e-01 -1.68e-01 -1.63e-01 -1.64e-01 -1.63e-01 -1.54e-01 -1.65e-01 -1.69e-01 -1.68e-01 -1.76e-01 -2.52e-01 -2.21e-01 -8.02e-02 -1.68e-01 -1.71e-01 -1.65e-01 -1.66e-01 -1.63e-01 -1.64e-01 -1.61e-01 -1.62e-01 -1.61e-01 -1.66e-01 -1.64e-01 -1.72e-01 -2.60e-01 -2.09e-01 -7.14e-02 -1.63e-01 -1.61e-01 -1.63e-01 -1.69e-01 -1.61e-01 -1.62e-01 -1.62e-01 -1.61e-01 -1.58e-01 -1.54e-01 -1.64e-01 -1.76e-01 -2.59e-01 -3.27e-01 -1.16e-01 -1.60e-01 -1.60e-01 -1.63e-01 -1.68e-01 -1.62e-01 -1.54e-01 -1.50e-01 -1.64e-01 -1.63e-01 -1.58e-01 -1.58e-01 -1.68e-01 -2.43e-01 -2.59e-01 -9.33e-02 -1.61e-01 -1.63e-01 -1.68e-01 -1.62e-01 -1.69e-01 -1.53e-01 -1.53e-01 -1.57e-01 -1.50e-01 -1.54e-01 -1.57e-01 -1.59e-01 -2.17e-01 -2.06e-01 -7.58e-02 -1.71e-01 -1.70e-01 -1.63e-01 -1.57e-01 -1.61e-01 -1.53e-01 -1.56e-01 -1.49e-01 -1.49e-01 -1.59e-01 -1.49e-01 -1.55e-01 -2.27e-01 -1.62e-01 -6.88e-02 -1.71e-01 -1.67e-01 -1.66e-01 -1.60e-01 -1.61e-01 -1.62e-01 -1.63e-01 -1.54e-01 -1.50e-01 -1.48e-01 -1.51e-01 -1.55e-01 -2.15e-01 -1.65e-01 -4.95e-02 -1.71e-01 -1.73e-01 -1.68e-01 -1.62e-01 -1.57e-01 -1.62e-01 -1.59e-01 -1.56e-01 -1.53e-01 -1.47e-01 -1.49e-01 -1.62e-01 -2.14e-01 -1.58e-01 -6.86e-02 -1.70e-01 -1.66e-01 -1.69e-01 -1.66e-01 -1.67e-01 -1.62e-01 -1.63e-01 -1.63e-01 -1.58e-01 -1.52e-01 -1.54e-01 -1.67e-01 -2.26e-01 -1.15e-01 -4.03e-02 -1.74e-01 -1.82e-01 -1.70e-01 -1.72e-01 -1.77e-01 -1.85e-01 -1.68e-01 -1.65e-01 -1.63e-01 -1.74e-01 -1.63e-01 -1.66e-01 -2.29e-01 -1.07e-01 -3.27e-02 -2.58e-01 -2.47e-01 -2.50e-01 -2.57e-01 -2.60e-01 -2.66e-01 -2.59e-01 -2.39e-01 -2.35e-01 -2.29e-01 -2.16e-01 -2.25e-01 -2.33e-01 -8.96e-02 -3.01e-02 -2.73e-01 -2.51e-01 -2.52e-01 -2.63e-01 -3.05e-01 -2.69e-01 -2.91e-01 -1.85e-01 -2.00e-01 -1.47e-01 -1.01e-01 -1.17e-01 -8.80e-02 -3.85e-02 -1.53e-02 -1.00e-01 -8.71e-02 -9.09e-02 -9.00e-02 -1.08e-01 -8.70e-02 -1.17e-01 -5.47e-02 -7.04e-02 -5.07e-02 -3.08e-02 -3.14e-02 -2.64e-02 -1.69e-02 -1.16e-02 -1.60e-01 -1.64e-01 -1.63e-01 -1.67e-01 -1.70e-01 -1.62e-01 -1.54e-01 -1.52e-01 -1.52e-01 -1.55e-01 -1.57e-01 -1.63e-01 -2.61e-01 -2.58e-01 -7.58e-02 -1.59e-01 -1.68e-01 -1.63e-01 -1.58e-01 -1.65e-01 -1.65e-01 -1.67e-01 -1.52e-01 -1.58e-01 -1.56e-01 -1.60e-01 -1.69e-01 -2.49e-01 -2.88e-01 -1.11e-01 -1.66e-01 -1.69e-01 -1.70e-01 -1.63e-01 -1.63e-01 -1.59e-01 -1.63e-01 -1.65e-01 -1.58e-01 -1.58e-01 -1.60e-01 -1.75e-01 -2.57e-01 -2.53e-01 -8.19e-02 -1.67e-01 -1.68e-01 -1.58e-01 -1.58e-01 -1.61e-01 -1.67e-01 -1.54e-01 -1.55e-01 -1.61e-01 -1.61e-01 -1.63e-01 -1.70e-01 -2.53e-01 -2.35e-01 -7.59e-02 -1.63e-01 -1.66e-01 -1.68e-01 -1.64e-01 -1.59e-01 -1.59e-01 -1.57e-01 -1.58e-01 -1.58e-01 -1.56e-01 -1.58e-01 -1.66e-01 -2.50e-01 -2.58e-01 -9.81e-02 -1.60e-01 -1.61e-01 -1.64e-01 -1.61e-01 -1.60e-01 -1.56e-01 -1.51e-01 -1.50e-01 -1.63e-01 -1.64e-01 -1.57e-01 -1.64e-01 -2.37e-01 -2.18e-01 -9.03e-02 -1.68e-01 -1.69e-01 -1.64e-01 -1.56e-01 -1.58e-01 -1.53e-01 -1.51e-01 -1.43e-01 -1.51e-01 -1.53e-01 -1.55e-01 -1.63e-01 -2.19e-01 -1.33e-01 -4.89e-02 -1.67e-01 -1.60e-01 -1.61e-01 -1.55e-01 -1.64e-01 -1.56e-01 -1.49e-01 -1.45e-01 -1.44e-01 -1.51e-01 -1.57e-01 -1.64e-01 -2.32e-01 -1.18e-01 -3.65e-02 -1.62e-01 -1.67e-01 -1.68e-01 -1.55e-01 -1.59e-01 -1.57e-01 -1.58e-01 -1.46e-01 -1.43e-01 -1.39e-01 -1.48e-01 -1.54e-01 -2.26e-01 -1.45e-01 -4.05e-02 -1.55e-01 -1.63e-01 -1.63e-01 -1.67e-01 -1.56e-01 -1.53e-01 -1.50e-01 -1.49e-01 -1.49e-01 -1.45e-01 -1.47e-01 -1.53e-01 -2.10e-01 -1.20e-01 -3.82e-02 -1.65e-01 -1.59e-01 -1.61e-01 -1.61e-01 -1.56e-01 -1.56e-01 -1.60e-01 -1.59e-01 -1.54e-01 -1.53e-01 -1.48e-01 -1.52e-01 -2.07e-01 -1.01e-01 -3.00e-02 -1.77e-01 -1.71e-01 -1.68e-01 -1.71e-01 -1.75e-01 -1.69e-01 -1.64e-01 -1.68e-01 -1.61e-01 -1.61e-01 -1.53e-01 -1.46e-01 -1.95e-01 -9.40e-02 -2.21e-02 -2.46e-01 -2.38e-01 -2.31e-01 -2.41e-01 -2.54e-01 -2.50e-01 -2.28e-01 -2.20e-01 -2.21e-01 -2.26e-01 -2.35e-01 -2.02e-01 -1.88e-01 -9.58e-02 -3.52e-02 -3.06e-01 -2.59e-01 -2.23e-01 -2.61e-01 -2.57e-01 -2.36e-01 -2.32e-01 -1.78e-01 -1.53e-01 -1.37e-01 -1.47e-01 -1.36e-01 -7.24e-02 -4.03e-02 -2.23e-02 -1.04e-01 -9.82e-02 -8.79e-02 -9.20e-02 -9.75e-02 -7.29e-02 -1.04e-01 -6.06e-02 -5.37e-02 -3.67e-02 -4.29e-02 -4.85e-02 -2.87e-02 -1.59e-02 -9.17e-03 -1.71e-01 -1.67e-01 -1.65e-01 -1.69e-01 -1.59e-01 -1.60e-01 -1.62e-01 -1.62e-01 -1.57e-01 -1.49e-01 -1.52e-01 -1.53e-01 -2.42e-01 -1.80e-01 -8.19e-02 -1.68e-01 -1.63e-01 -1.67e-01 -1.65e-01 -1.63e-01 -1.54e-01 -1.59e-01 -1.52e-01 -1.59e-01 -1.52e-01 -1.48e-01 -1.55e-01 -2.25e-01 -2.01e-01 -7.57e-02 -1.63e-01 -1.59e-01 -1.62e-01 -1.61e-01 -1.57e-01 -1.56e-01 -1.50e-01 -1.51e-01 -1.48e-01 -1.53e-01 -1.61e-01 -1.58e-01 -2.32e-01 -2.49e-01 -1.01e-01 -1.67e-01 -1.54e-01 -1.55e-01 -1.52e-01 -1.55e-01 -1.61e-01 -1.57e-01 -1.54e-01 -1.54e-01 -1.54e-01 -1.56e-01 -1.64e-01 -2.25e-01 -1.56e-01 -6.14e-02 -1.67e-01 -1.65e-01 -1.61e-01 -1.57e-01 -1.58e-01 -1.62e-01 -1.55e-01 -1.57e-01 -1.50e-01 -1.54e-01 -1.55e-01 -1.68e-01 -2.32e-01 -1.28e-01 -4.68e-02 -1.63e-01 -1.57e-01 -1.60e-01 -1.63e-01 -1.61e-01 -1.58e-01 -1.50e-01 -1.46e-01 -1.43e-01 -1.52e-01 -1.55e-01 -1.61e-01 -2.25e-01 -1.35e-01 -4.13e-02 -1.64e-01 -1.62e-01 -1.60e-01 -1.62e-01 -1.61e-01 -1.51e-01 -1.50e-01 -1.41e-01 -1.46e-01 -1.49e-01 -1.51e-01 -1.64e-01 -2.31e-01 -1.50e-01 -4.56e-02 -1.53e-01 -1.55e-01 -1.54e-01 -1.57e-01 -1.55e-01 -1.49e-01 -1.50e-01 -1.44e-01 -1.43e-01 -1.47e-01 -1.51e-01 -1.57e-01 -2.19e-01 -1.63e-01 -4.89e-02 -1.64e-01 -1.55e-01 -1.57e-01 -1.53e-01 -1.48e-01 -1.53e-01 -1.52e-01 -1.40e-01 -1.38e-01 -1.40e-01 -1.50e-01 -1.57e-01 -2.10e-01 -1.54e-01 -5.14e-02 -1.56e-01 -1.58e-01 -1.61e-01 -1.57e-01 -1.52e-01 -1.47e-01 -1.51e-01 -1.48e-01 -1.44e-01 -1.48e-01 -1.44e-01 -1.43e-01 -2.07e-01 -1.20e-01 -4.74e-02 -1.62e-01 -1.71e-01 -1.62e-01 -1.57e-01 -1.52e-01 -1.51e-01 -1.44e-01 -1.43e-01 -1.46e-01 -1.46e-01 -1.36e-01 -1.45e-01 -1.86e-01 -7.07e-02 -2.51e-02 -1.70e-01 -1.71e-01 -1.63e-01 -1.56e-01 -1.60e-01 -1.61e-01 -1.56e-01 -1.55e-01 -1.59e-01 -1.53e-01 -1.48e-01 -1.41e-01 -1.55e-01 -6.13e-02 -2.68e-02 -2.40e-01 -2.25e-01 -2.22e-01 -2.27e-01 -2.31e-01 -2.20e-01 -2.21e-01 -1.99e-01 -2.15e-01 -1.98e-01 -2.02e-01 -1.80e-01 -1.35e-01 -3.74e-02 -1.62e-02 -2.64e-01 -2.69e-01 -2.32e-01 -1.55e-01 -1.50e-01 -1.99e-01 -1.79e-01 -1.44e-01 -1.30e-01 -1.25e-01 -1.44e-01 -1.15e-01 -4.22e-02 -1.96e-02 -8.51e-03 -9.50e-02 -1.04e-01 -8.97e-02 -4.80e-02 -4.87e-02 -6.43e-02 -6.38e-02 -4.70e-02 -4.40e-02 -3.28e-02 -4.72e-02 -4.03e-02 -1.52e-02 -8.66e-03 -6.14e-03 -1.56e-01 -1.57e-01 -1.54e-01 -1.60e-01 -1.65e-01 -1.66e-01 -1.65e-01 -1.58e-01 -1.47e-01 -1.40e-01 -1.36e-01 -1.59e-01 -2.22e-01 -1.52e-01 -5.31e-02 -1.61e-01 -1.62e-01 -1.69e-01 -1.63e-01 -1.58e-01 -1.58e-01 -1.59e-01 -1.47e-01 -1.45e-01 -1.39e-01 -1.30e-01 -1.48e-01 -2.15e-01 -1.09e-01 -3.46e-02 -1.58e-01 -1.57e-01 -1.62e-01 -1.63e-01 -1.59e-01 -1.57e-01 -1.56e-01 -1.58e-01 -1.52e-01 -1.45e-01 -1.50e-01 -1.60e-01 -2.17e-01 -1.56e-01 -5.66e-02 -1.60e-01 -1.57e-01 -1.60e-01 -1.57e-01 -1.60e-01 -1.58e-01 -1.54e-01 -1.53e-01 -1.47e-01 -1.42e-01 -1.56e-01 -1.66e-01 -2.10e-01 -1.46e-01 -6.02e-02 -1.62e-01 -1.61e-01 -1.68e-01 -1.54e-01 -1.54e-01 -1.59e-01 -1.50e-01 -1.49e-01 -1.50e-01 -1.46e-01 -1.58e-01 -1.59e-01 -2.16e-01 -1.18e-01 -3.24e-02 -1.61e-01 -1.55e-01 -1.60e-01 -1.59e-01 -1.50e-01 -1.45e-01 -1.50e-01 -1.45e-01 -1.47e-01 -1.46e-01 -1.48e-01 -1.58e-01 -2.13e-01 -1.24e-01 -4.33e-02 -1.58e-01 -1.55e-01 -1.58e-01 -1.51e-01 -1.57e-01 -1.54e-01 -1.50e-01 -1.39e-01 -1.40e-01 -1.40e-01 -1.39e-01 -1.49e-01 -2.03e-01 -1.50e-01 -5.78e-02 -1.51e-01 -1.59e-01 -1.53e-01 -1.53e-01 -1.52e-01 -1.52e-01 -1.46e-01 -1.43e-01 -1.42e-01 -1.41e-01 -1.52e-01 -1.52e-01 -2.06e-01 -1.37e-01 -5.13e-02 -1.55e-01 -1.52e-01 -1.56e-01 -1.49e-01 -1.53e-01 -1.49e-01 -1.45e-01 -1.39e-01 -1.35e-01 -1.33e-01 -1.48e-01 -1.46e-01 -1.98e-01 -1.08e-01 -3.36e-02 -1.53e-01 -1.53e-01 -1.49e-01 -1.43e-01 -1.45e-01 -1.48e-01 -1.38e-01 -1.42e-01 -1.29e-01 -1.29e-01 -1.38e-01 -1.45e-01 -2.11e-01 -1.20e-01 -3.89e-02 -1.60e-01 -1.55e-01 -1.59e-01 -1.49e-01 -1.48e-01 -1.48e-01 -1.47e-01 -1.50e-01 -1.41e-01 -1.37e-01 -1.31e-01 -1.36e-01 -1.77e-01 -7.63e-02 -1.94e-02 -1.69e-01 -1.64e-01 -1.65e-01 -1.57e-01 -1.52e-01 -1.48e-01 -1.44e-01 -1.54e-01 -1.48e-01 -1.49e-01 -1.40e-01 -1.31e-01 -1.53e-01 -4.85e-02 -1.42e-02 -2.42e-01 -2.23e-01 -2.24e-01 -2.03e-01 -2.18e-01 -2.15e-01 -1.75e-01 -1.74e-01 -1.73e-01 -2.02e-01 -2.01e-01 -1.69e-01 -1.22e-01 -3.16e-02 -1.08e-02 -2.16e-01 -2.25e-01 -1.60e-01 -1.34e-01 -1.44e-01 -1.68e-01 -1.02e-01 -8.69e-02 -7.20e-02 -1.43e-01 -1.29e-01 -8.21e-02 -4.29e-02 -1.08e-02 -4.27e-03 -7.45e-02 -7.65e-02 -5.07e-02 -4.76e-02 -4.31e-02 -5.72e-02 -3.77e-02 -2.92e-02 -2.28e-02 -4.79e-02 -4.01e-02 -2.76e-02 -1.93e-02 -8.26e-03 -2.13e-03 -1.63e-01 -1.66e-01 -1.71e-01 -1.63e-01 -1.67e-01 -1.59e-01 -1.56e-01 -1.61e-01 -1.49e-01 -1.45e-01 -1.38e-01 -1.54e-01 -2.17e-01 -1.17e-01 -3.57e-02 -1.59e-01 -1.61e-01 -1.68e-01 -1.63e-01 -1.62e-01 -1.62e-01 -1.60e-01 -1.56e-01 -1.49e-01 -1.47e-01 -1.44e-01 -1.52e-01 -2.09e-01 -1.26e-01 -3.94e-02 -1.57e-01 -1.61e-01 -1.58e-01 -1.59e-01 -1.60e-01 -1.51e-01 -1.56e-01 -1.60e-01 -1.49e-01 -1.45e-01 -1.44e-01 -1.61e-01 -2.41e-01 -1.63e-01 -5.31e-02 -1.60e-01 -1.54e-01 -1.60e-01 -1.53e-01 -1.56e-01 -1.57e-01 -1.55e-01 -1.53e-01 -1.46e-01 -1.47e-01 -1.49e-01 -1.47e-01 -2.08e-01 -1.76e-01 -7.44e-02 -1.55e-01 -1.52e-01 -1.53e-01 -1.52e-01 -1.52e-01 -1.51e-01 -1.51e-01 -1.53e-01 -1.48e-01 -1.40e-01 -1.50e-01 -1.61e-01 -2.05e-01 -1.29e-01 -4.01e-02 -1.60e-01 -1.58e-01 -1.50e-01 -1.47e-01 -1.42e-01 -1.46e-01 -1.50e-01 -1.46e-01 -1.45e-01 -1.42e-01 -1.48e-01 -1.60e-01 -2.17e-01 -1.50e-01 -5.21e-02 -1.53e-01 -1.53e-01 -1.52e-01 -1.45e-01 -1.45e-01 -1.43e-01 -1.40e-01 -1.38e-01 -1.37e-01 -1.36e-01 -1.46e-01 -1.49e-01 -1.88e-01 -1.14e-01 -4.21e-02 -1.48e-01 -1.50e-01 -1.52e-01 -1.43e-01 -1.48e-01 -1.44e-01 -1.36e-01 -1.34e-01 -1.37e-01 -1.37e-01 -1.46e-01 -1.47e-01 -1.84e-01 -7.19e-02 -2.90e-02 -1.48e-01 -1.44e-01 -1.48e-01 -1.48e-01 -1.49e-01 -1.54e-01 -1.45e-01 -1.38e-01 -1.29e-01 -1.30e-01 -1.31e-01 -1.39e-01 -1.93e-01 -7.96e-02 -2.03e-02 -1.53e-01 -1.46e-01 -1.46e-01 -1.41e-01 -1.47e-01 -1.45e-01 -1.42e-01 -1.37e-01 -1.29e-01 -1.27e-01 -1.30e-01 -1.33e-01 -1.95e-01 -8.81e-02 -2.19e-02 -1.56e-01 -1.42e-01 -1.45e-01 -1.43e-01 -1.52e-01 -1.48e-01 -1.44e-01 -1.40e-01 -1.41e-01 -1.31e-01 -1.18e-01 -1.31e-01 -1.83e-01 -9.55e-02 -2.75e-02 -1.63e-01 -1.47e-01 -1.48e-01 -1.57e-01 -1.55e-01 -1.50e-01 -1.56e-01 -1.42e-01 -1.44e-01 -1.39e-01 -1.29e-01 -1.20e-01 -1.52e-01 -5.41e-02 -1.62e-02 -2.32e-01 -2.08e-01 -2.20e-01 -2.22e-01 -2.23e-01 -2.17e-01 -1.99e-01 -2.05e-01 -1.92e-01 -2.03e-01 -1.97e-01 -1.60e-01 -1.37e-01 -4.00e-02 -1.07e-02 -2.25e-01 -1.79e-01 -1.71e-01 -1.67e-01 -1.69e-01 -1.54e-01 -1.02e-01 -1.09e-01 -9.88e-02 -1.08e-01 -1.18e-01 -8.29e-02 -4.15e-02 -1.49e-02 -5.20e-03 -6.83e-02 -5.09e-02 -4.28e-02 -4.83e-02 -4.92e-02 -5.19e-02 -3.56e-02 -3.22e-02 -2.88e-02 -3.04e-02 -3.83e-02 -2.79e-02 -1.21e-02 -5.81e-03 -1.30e-03 -1.57e-01 -1.62e-01 -1.67e-01 -1.62e-01 -1.61e-01 -1.50e-01 -1.52e-01 -1.57e-01 -1.53e-01 -1.51e-01 -1.43e-01 -1.61e-01 -2.04e-01 -1.43e-01 -5.22e-02 -1.59e-01 -1.63e-01 -1.58e-01 -1.58e-01 -1.58e-01 -1.62e-01 -1.60e-01 -1.58e-01 -1.58e-01 -1.43e-01 -1.49e-01 -1.59e-01 -2.21e-01 -1.56e-01 -4.57e-02 -1.63e-01 -1.57e-01 -1.51e-01 -1.54e-01 -1.53e-01 -1.60e-01 -1.55e-01 -1.60e-01 -1.60e-01 -1.45e-01 -1.40e-01 -1.59e-01 -2.23e-01 -1.66e-01 -5.44e-02 -1.53e-01 -1.54e-01 -1.54e-01 -1.50e-01 -1.57e-01 -1.53e-01 -1.59e-01 -1.56e-01 -1.48e-01 -1.45e-01 -1.45e-01 -1.58e-01 -2.07e-01 -1.44e-01 -5.45e-02 -1.50e-01 -1.46e-01 -1.56e-01 -1.56e-01 -1.54e-01 -1.48e-01 -1.50e-01 -1.54e-01 -1.46e-01 -1.46e-01 -1.50e-01 -1.52e-01 -2.09e-01 -1.16e-01 -3.68e-02 -1.56e-01 -1.50e-01 -1.56e-01 -1.48e-01 -1.50e-01 -1.51e-01 -1.48e-01 -1.49e-01 -1.43e-01 -1.41e-01 -1.46e-01 -1.53e-01 -2.02e-01 -1.07e-01 -3.92e-02 -1.55e-01 -1.55e-01 -1.53e-01 -1.49e-01 -1.47e-01 -1.48e-01 -1.41e-01 -1.44e-01 -1.41e-01 -1.41e-01 -1.37e-01 -1.51e-01 -2.06e-01 -1.37e-01 -4.68e-02 -1.52e-01 -1.53e-01 -1.54e-01 -1.53e-01 -1.48e-01 -1.43e-01 -1.32e-01 -1.41e-01 -1.35e-01 -1.27e-01 -1.35e-01 -1.52e-01 -1.90e-01 -7.26e-02 -2.22e-02 -1.47e-01 -1.47e-01 -1.49e-01 -1.50e-01 -1.49e-01 -1.42e-01 -1.39e-01 -1.32e-01 -1.28e-01 -1.26e-01 -1.34e-01 -1.45e-01 -1.87e-01 -8.17e-02 -2.42e-02 -1.49e-01 -1.48e-01 -1.47e-01 -1.50e-01 -1.45e-01 -1.43e-01 -1.38e-01 -1.30e-01 -1.29e-01 -1.31e-01 -1.22e-01 -1.36e-01 -1.78e-01 -1.04e-01 -3.33e-02 -1.48e-01 -1.45e-01 -1.44e-01 -1.42e-01 -1.41e-01 -1.43e-01 -1.46e-01 -1.38e-01 -1.29e-01 -1.25e-01 -1.18e-01 -1.25e-01 -1.79e-01 -8.54e-02 -2.89e-02 -1.64e-01 -1.47e-01 -1.55e-01 -1.56e-01 -1.47e-01 -1.59e-01 -1.48e-01 -1.44e-01 -1.36e-01 -1.33e-01 -1.26e-01 -1.11e-01 -1.31e-01 -5.72e-02 -1.80e-02 -2.46e-01 -2.05e-01 -1.90e-01 -2.18e-01 -2.16e-01 -2.14e-01 -2.02e-01 -2.24e-01 -2.13e-01 -2.23e-01 -1.86e-01 -1.51e-01 -1.18e-01 -3.41e-02 -1.21e-02 -1.87e-01 -1.53e-01 -1.50e-01 -1.67e-01 -1.83e-01 -1.69e-01 -1.39e-01 -1.42e-01 -1.29e-01 -1.05e-01 -9.27e-02 -6.73e-02 -3.93e-02 -1.65e-02 -7.05e-03 -7.21e-02 -6.08e-02 -6.40e-02 -5.53e-02 -6.28e-02 -5.59e-02 -4.39e-02 -4.02e-02 -4.46e-02 -3.36e-02 -3.13e-02 -2.12e-02 -1.23e-02 -7.79e-03 -3.56e-03 -1.51e-01 -1.56e-01 -1.63e-01 -1.66e-01 -1.67e-01 -1.65e-01 -1.66e-01 -1.70e-01 -1.53e-01 -1.56e-01 -1.51e-01 -1.51e-01 -1.83e-01 -9.73e-02 -3.81e-02 -1.53e-01 -1.59e-01 -1.54e-01 -1.57e-01 -1.61e-01 -1.59e-01 -1.57e-01 -1.58e-01 -1.58e-01 -1.58e-01 -1.52e-01 -1.52e-01 -2.00e-01 -1.30e-01 -4.17e-02 -1.54e-01 -1.56e-01 -1.53e-01 -1.62e-01 -1.55e-01 -1.59e-01 -1.66e-01 -1.53e-01 -1.56e-01 -1.56e-01 -1.52e-01 -1.57e-01 -2.13e-01 -1.42e-01 -4.79e-02 -1.53e-01 -1.59e-01 -1.67e-01 -1.55e-01 -1.64e-01 -1.66e-01 -1.61e-01 -1.55e-01 -1.54e-01 -1.50e-01 -1.45e-01 -1.54e-01 -2.09e-01 -1.08e-01 -3.44e-02 -1.54e-01 -1.57e-01 -1.60e-01 -1.54e-01 -1.62e-01 -1.59e-01 -1.56e-01 -1.54e-01 -1.57e-01 -1.52e-01 -1.52e-01 -1.56e-01 -2.03e-01 -9.74e-02 -2.86e-02 -1.52e-01 -1.57e-01 -1.58e-01 -1.62e-01 -1.56e-01 -1.57e-01 -1.52e-01 -1.48e-01 -1.44e-01 -1.47e-01 -1.50e-01 -1.51e-01 -2.12e-01 -1.09e-01 -2.91e-02 -1.51e-01 -1.54e-01 -1.48e-01 -1.58e-01 -1.54e-01 -1.52e-01 -1.51e-01 -1.44e-01 -1.44e-01 -1.43e-01 -1.45e-01 -1.51e-01 -1.99e-01 -1.23e-01 -3.39e-02 -1.48e-01 -1.50e-01 -1.55e-01 -1.59e-01 -1.47e-01 -1.46e-01 -1.37e-01 -1.40e-01 -1.41e-01 -1.47e-01 -1.42e-01 -1.45e-01 -1.87e-01 -1.10e-01 -3.91e-02 -1.43e-01 -1.48e-01 -1.52e-01 -1.52e-01 -1.56e-01 -1.49e-01 -1.38e-01 -1.38e-01 -1.34e-01 -1.30e-01 -1.26e-01 -1.34e-01 -1.85e-01 -8.58e-02 -2.44e-02 -1.48e-01 -1.45e-01 -1.47e-01 -1.50e-01 -1.53e-01 -1.41e-01 -1.37e-01 -1.35e-01 -1.27e-01 -1.27e-01 -1.23e-01 -1.24e-01 -1.55e-01 -8.15e-02 -2.87e-02 -1.44e-01 -1.47e-01 -1.45e-01 -1.44e-01 -1.45e-01 -1.40e-01 -1.42e-01 -1.37e-01 -1.27e-01 -1.29e-01 -1.17e-01 -1.21e-01 -1.63e-01 -5.00e-02 -1.53e-02 -1.47e-01 -1.48e-01 -1.47e-01 -1.53e-01 -1.45e-01 -1.50e-01 -1.52e-01 -1.47e-01 -1.34e-01 -1.29e-01 -1.22e-01 -1.13e-01 -1.35e-01 -4.55e-02 -1.41e-02 -2.05e-01 -1.89e-01 -1.85e-01 -2.07e-01 -2.14e-01 -2.10e-01 -1.91e-01 -1.99e-01 -1.97e-01 -1.79e-01 -1.74e-01 -1.47e-01 -7.71e-02 -1.94e-02 -6.96e-03 -1.71e-01 -9.07e-02 -1.18e-01 -1.23e-01 -1.31e-01 -1.29e-01 -1.02e-01 -1.39e-01 -1.15e-01 -7.59e-02 -8.17e-02 -5.28e-02 -2.69e-02 -1.04e-02 -3.19e-03 -5.55e-02 -2.88e-02 -3.51e-02 -3.72e-02 -5.09e-02 -4.45e-02 -3.21e-02 -4.62e-02 -3.95e-02 -2.61e-02 -2.32e-02 -1.25e-02 -9.62e-03 -6.12e-03 -3.33e-03 -1.57e-01 -1.68e-01 -1.76e-01 -1.71e-01 -1.70e-01 -1.76e-01 -1.72e-01 -1.62e-01 -1.62e-01 -1.58e-01 -1.58e-01 -1.48e-01 -1.49e-01 -3.17e-02 -1.30e-02 -1.73e-01 -1.78e-01 -1.74e-01 -1.61e-01 -1.60e-01 -1.64e-01 -1.67e-01 -1.62e-01 -1.58e-01 -1.56e-01 -1.59e-01 -1.53e-01 -1.62e-01 -5.38e-02 -2.31e-02 -1.66e-01 -1.78e-01 -1.66e-01 -1.64e-01 -1.63e-01 -1.71e-01 -1.77e-01 -1.69e-01 -1.55e-01 -1.57e-01 -1.50e-01 -1.66e-01 -2.15e-01 -9.77e-02 -2.59e-02 -1.65e-01 -1.70e-01 -1.68e-01 -1.65e-01 -1.69e-01 -1.74e-01 -1.78e-01 -1.61e-01 -1.64e-01 -1.57e-01 -1.44e-01 -1.50e-01 -1.92e-01 -8.51e-02 -2.93e-02 -1.60e-01 -1.58e-01 -1.61e-01 -1.66e-01 -1.68e-01 -1.71e-01 -1.64e-01 -1.61e-01 -1.62e-01 -1.60e-01 -1.44e-01 -1.42e-01 -1.97e-01 -1.03e-01 -2.80e-02 -1.55e-01 -1.62e-01 -1.58e-01 -1.62e-01 -1.63e-01 -1.64e-01 -1.60e-01 -1.52e-01 -1.55e-01 -1.57e-01 -1.44e-01 -1.41e-01 -1.88e-01 -9.04e-02 -2.91e-02 -1.49e-01 -1.51e-01 -1.62e-01 -1.64e-01 -1.61e-01 -1.56e-01 -1.57e-01 -1.49e-01 -1.46e-01 -1.48e-01 -1.45e-01 -1.41e-01 -1.63e-01 -9.25e-02 -3.25e-02 -1.52e-01 -1.51e-01 -1.52e-01 -1.59e-01 -1.57e-01 -1.54e-01 -1.55e-01 -1.52e-01 -1.48e-01 -1.42e-01 -1.43e-01 -1.45e-01 -1.82e-01 -6.97e-02 -2.31e-02 -1.55e-01 -1.54e-01 -1.58e-01 -1.59e-01 -1.58e-01 -1.62e-01 -1.50e-01 -1.47e-01 -1.42e-01 -1.42e-01 -1.33e-01 -1.37e-01 -1.74e-01 -6.53e-02 -2.18e-02 -1.52e-01 -1.45e-01 -1.60e-01 -1.58e-01 -1.58e-01 -1.54e-01 -1.50e-01 -1.37e-01 -1.30e-01 -1.26e-01 -1.30e-01 -1.23e-01 -1.71e-01 -7.09e-02 -2.53e-02 -1.42e-01 -1.41e-01 -1.47e-01 -1.47e-01 -1.58e-01 -1.48e-01 -1.36e-01 -1.35e-01 -1.33e-01 -1.29e-01 -1.19e-01 -1.14e-01 -1.45e-01 -4.24e-02 -1.27e-02 -1.43e-01 -1.40e-01 -1.44e-01 -1.45e-01 -1.42e-01 -1.37e-01 -1.42e-01 -1.47e-01 -1.33e-01 -1.30e-01 -1.15e-01 -1.07e-01 -1.24e-01 -3.91e-02 -1.19e-02 -1.85e-01 -1.70e-01 -1.73e-01 -1.81e-01 -1.77e-01 -1.76e-01 -1.75e-01 -1.93e-01 -1.94e-01 -1.58e-01 -1.45e-01 -1.24e-01 -7.16e-02 -2.05e-02 -7.17e-03 -1.27e-01 -6.46e-02 -8.27e-02 -1.04e-01 -7.86e-02 -7.86e-02 -7.04e-02 -6.74e-02 -1.02e-01 -7.60e-02 -5.37e-02 -4.16e-02 -2.54e-02 -6.01e-03 -1.97e-03 -5.06e-02 -2.49e-02 -3.45e-02 -3.64e-02 -2.84e-02 -2.70e-02 -2.34e-02 -2.43e-02 -3.12e-02 -2.55e-02 -1.56e-02 -1.52e-02 -9.91e-03 -3.26e-03 -1.47e-03 -2.30e-01 -2.43e-01 -2.55e-01 -2.55e-01 -2.51e-01 -2.39e-01 -2.30e-01 -2.27e-01 -2.29e-01 -2.07e-01 -2.02e-01 -2.14e-01 -1.61e-01 -2.95e-02 -7.43e-03 -2.45e-01 -2.22e-01 -2.61e-01 -2.31e-01 -2.30e-01 -2.40e-01 -2.34e-01 -2.18e-01 -2.03e-01 -2.11e-01 -1.97e-01 -1.92e-01 -1.80e-01 -4.88e-02 -1.49e-02 -2.38e-01 -2.17e-01 -2.52e-01 -2.29e-01 -2.25e-01 -2.44e-01 -2.15e-01 -2.39e-01 -2.19e-01 -2.19e-01 -2.01e-01 -1.92e-01 -2.20e-01 -9.45e-02 -2.94e-02 -2.36e-01 -2.27e-01 -2.34e-01 -2.40e-01 -2.35e-01 -2.56e-01 -2.38e-01 -2.37e-01 -2.25e-01 -2.08e-01 -1.82e-01 -1.60e-01 -1.81e-01 -5.67e-02 -1.61e-02 -2.29e-01 -2.18e-01 -2.26e-01 -2.37e-01 -2.21e-01 -2.35e-01 -2.69e-01 -2.31e-01 -2.30e-01 -2.32e-01 -2.01e-01 -1.47e-01 -1.58e-01 -7.81e-02 -2.93e-02 -2.28e-01 -2.05e-01 -2.20e-01 -2.25e-01 -2.12e-01 -2.31e-01 -2.33e-01 -2.13e-01 -2.09e-01 -2.24e-01 -1.97e-01 -1.71e-01 -1.79e-01 -7.52e-02 -2.31e-02 -2.03e-01 -2.07e-01 -2.27e-01 -2.19e-01 -2.11e-01 -2.22e-01 -2.17e-01 -2.08e-01 -1.77e-01 -2.01e-01 -1.89e-01 -1.57e-01 -1.63e-01 -5.48e-02 -1.75e-02 -2.07e-01 -2.13e-01 -2.09e-01 -2.25e-01 -2.36e-01 -2.27e-01 -2.11e-01 -2.10e-01 -1.87e-01 -1.89e-01 -1.88e-01 -1.79e-01 -1.33e-01 -3.03e-02 -1.06e-02 -2.08e-01 -2.14e-01 -2.12e-01 -2.27e-01 -2.27e-01 -2.05e-01 -2.29e-01 -2.21e-01 -1.93e-01 -2.02e-01 -1.81e-01 -1.73e-01 -1.67e-01 -4.08e-02 -1.39e-02 -2.00e-01 -2.19e-01 -2.28e-01 -2.14e-01 -2.28e-01 -2.06e-01 -2.17e-01 -1.92e-01 -1.79e-01 -1.74e-01 -1.72e-01 -1.71e-01 -1.60e-01 -4.62e-02 -1.43e-02 -1.82e-01 -1.92e-01 -2.16e-01 -2.14e-01 -2.12e-01 -2.26e-01 -1.94e-01 -1.68e-01 -1.64e-01 -1.50e-01 -1.55e-01 -1.48e-01 -1.04e-01 -4.02e-02 -1.44e-02 -1.56e-01 -1.60e-01 -1.93e-01 -1.87e-01 -1.94e-01 -2.01e-01 -2.07e-01 -1.85e-01 -1.76e-01 -1.49e-01 -1.39e-01 -1.38e-01 -1.04e-01 -2.84e-02 -1.17e-02 -1.33e-01 -1.46e-01 -1.65e-01 -1.58e-01 -1.74e-01 -1.70e-01 -1.37e-01 -1.94e-01 -1.93e-01 -1.64e-01 -1.20e-01 -1.02e-01 -6.63e-02 -1.85e-02 -8.29e-03 -6.84e-02 -4.09e-02 -5.11e-02 -6.13e-02 -4.88e-02 -4.65e-02 -3.93e-02 -4.74e-02 -8.51e-02 -5.59e-02 -2.40e-02 -2.44e-02 -1.30e-02 -4.68e-03 -2.65e-03 -2.59e-02 -1.30e-02 -1.81e-02 -1.96e-02 -1.49e-02 -1.49e-02 -1.50e-02 -1.42e-02 -2.71e-02 -2.16e-02 -1.05e-02 -7.72e-03 -4.11e-03 -2.35e-03 -9.64e-04 -2.21e-01 -2.15e-01 -2.72e-01 -1.92e-01 -3.01e-01 -2.43e-01 -2.13e-01 -2.18e-01 -1.88e-01 -1.66e-01 -1.13e-01 -1.21e-01 -1.08e-01 -2.92e-02 -8.37e-03 -2.75e-01 -1.89e-01 -3.28e-01 -3.64e-01 -2.91e-01 -2.34e-01 -1.86e-01 -1.90e-01 -1.53e-01 -1.35e-01 -1.21e-01 -1.01e-01 -8.79e-02 -3.91e-02 -1.37e-02 -2.37e-01 -2.28e-01 -2.92e-01 -2.21e-01 -1.70e-01 -2.29e-01 -1.86e-01 -1.95e-01 -1.65e-01 -1.42e-01 -1.73e-01 -1.38e-01 -7.39e-02 -4.16e-02 -2.91e-02 -2.73e-01 -2.33e-01 -2.78e-01 -3.06e-01 -2.31e-01 -2.52e-01 -2.69e-01 -2.39e-01 -2.13e-01 -1.63e-01 -1.20e-01 -8.39e-02 -5.83e-02 -2.86e-02 -1.32e-02 -2.63e-01 -1.92e-01 -2.54e-01 -3.11e-01 -2.65e-01 -2.75e-01 -2.71e-01 -2.21e-01 -1.81e-01 -1.68e-01 -1.49e-01 -7.05e-02 -5.03e-02 -2.54e-02 -1.28e-02 -2.09e-01 -1.61e-01 -2.21e-01 -2.28e-01 -1.55e-01 -1.78e-01 -2.16e-01 -1.50e-01 -1.32e-01 -1.76e-01 -1.57e-01 -1.01e-01 -5.61e-02 -2.32e-02 -1.53e-02 -1.50e-01 -1.81e-01 -2.03e-01 -2.04e-01 -1.79e-01 -1.94e-01 -1.81e-01 -1.52e-01 -1.26e-01 -1.13e-01 -9.16e-02 -6.72e-02 -3.94e-02 -2.35e-02 -1.45e-02 -1.06e-01 -1.43e-01 -1.61e-01 -1.57e-01 -1.80e-01 -1.80e-01 -1.23e-01 -1.22e-01 -8.18e-02 -7.30e-02 -9.33e-02 -7.39e-02 -3.89e-02 -2.07e-02 -8.17e-03 -1.13e-01 -1.37e-01 -1.61e-01 -2.20e-01 -1.71e-01 -1.51e-01 -1.16e-01 -1.45e-01 -1.13e-01 -1.05e-01 -9.41e-02 -7.14e-02 -5.35e-02 -1.91e-02 -7.31e-03 -8.55e-02 -1.58e-01 -2.08e-01 -1.60e-01 -1.37e-01 -8.33e-02 -1.16e-01 -1.39e-01 -1.15e-01 -9.22e-02 -8.69e-02 -6.24e-02 -4.30e-02 -2.48e-02 -7.57e-03 -9.22e-02 -1.13e-01 -1.60e-01 -1.04e-01 -1.40e-01 -1.35e-01 -1.08e-01 -1.02e-01 -8.56e-02 -5.91e-02 -7.46e-02 -6.28e-02 -3.81e-02 -2.04e-02 -9.21e-03 -7.85e-02 -6.83e-02 -1.01e-01 -9.42e-02 -9.47e-02 -1.38e-01 -1.13e-01 -6.40e-02 -6.03e-02 -5.21e-02 -4.63e-02 -4.67e-02 -3.57e-02 -9.24e-03 -3.46e-03 -3.82e-02 -4.99e-02 -6.21e-02 -4.80e-02 -5.79e-02 -8.37e-02 -6.86e-02 -6.66e-02 -5.19e-02 -5.77e-02 -4.00e-02 -3.46e-02 -2.69e-02 -9.16e-03 -3.73e-03 -1.66e-02 -1.94e-02 -2.26e-02 -1.79e-02 -2.45e-02 -3.08e-02 -2.00e-02 -2.89e-02 -3.35e-02 -2.83e-02 -1.58e-02 -1.10e-02 -7.32e-03 -3.83e-03 -1.85e-03 -1.35e-02 -7.32e-03 -8.41e-03 -8.10e-03 -9.00e-03 -1.12e-02 -5.57e-03 -9.30e-03 -1.48e-02 -1.39e-02 -6.30e-03 -3.42e-03 -2.99e-03 -1.40e-03 -5.26e-04 -7.56e-02 -7.51e-02 -1.02e-01 -6.63e-02 -1.09e-01 -8.00e-02 -7.46e-02 -7.69e-02 -7.23e-02 -5.75e-02 -3.77e-02 -3.71e-02 -3.59e-02 -2.14e-02 -7.54e-03 -1.13e-01 -5.14e-02 -1.11e-01 -1.48e-01 -1.23e-01 -8.67e-02 -6.58e-02 -5.93e-02 -5.79e-02 -5.00e-02 -3.78e-02 -2.92e-02 -2.64e-02 -1.76e-02 -8.34e-03 -8.71e-02 -6.82e-02 -1.03e-01 -9.93e-02 -4.68e-02 -8.00e-02 -6.54e-02 -5.73e-02 -5.88e-02 -4.17e-02 -6.05e-02 -5.26e-02 -2.82e-02 -1.18e-02 -1.25e-02 -8.93e-02 -6.93e-02 -1.05e-01 -1.22e-01 -7.82e-02 -8.44e-02 -9.53e-02 -9.08e-02 -8.61e-02 -6.38e-02 -4.26e-02 -2.94e-02 -1.95e-02 -1.16e-02 -5.85e-03 -1.07e-01 -7.48e-02 -9.61e-02 -1.16e-01 -1.00e-01 -9.56e-02 -1.01e-01 -7.22e-02 -7.15e-02 -4.92e-02 -5.10e-02 -2.14e-02 -1.39e-02 -8.55e-03 -5.42e-03 -6.30e-02 -5.46e-02 -6.94e-02 -7.56e-02 -5.76e-02 -4.99e-02 -6.77e-02 -4.79e-02 -4.29e-02 -5.31e-02 -5.73e-02 -4.32e-02 -2.01e-02 -8.20e-03 -4.18e-03 -6.21e-02 -5.98e-02 -7.34e-02 -7.91e-02 -4.60e-02 -5.72e-02 -6.01e-02 -5.26e-02 -5.01e-02 -3.98e-02 -3.12e-02 -2.62e-02 -1.44e-02 -6.44e-03 -6.95e-03 -2.95e-02 -5.38e-02 -4.94e-02 -4.81e-02 -5.65e-02 -6.07e-02 -3.70e-02 -3.88e-02 -2.59e-02 -2.05e-02 -2.51e-02 -2.29e-02 -1.19e-02 -1.08e-02 -8.34e-03 -3.62e-02 -4.00e-02 -5.20e-02 -6.63e-02 -6.42e-02 -5.90e-02 -3.69e-02 -4.87e-02 -4.00e-02 -3.31e-02 -2.85e-02 -2.46e-02 -2.05e-02 -8.72e-03 -3.45e-03 -2.17e-02 -4.81e-02 -6.28e-02 -6.24e-02 -4.43e-02 -2.41e-02 -3.73e-02 -4.41e-02 -4.25e-02 -2.80e-02 -2.62e-02 -2.10e-02 -1.12e-02 -1.28e-02 -6.90e-03 -2.96e-02 -4.88e-02 -5.84e-02 -2.83e-02 -4.58e-02 -3.78e-02 -2.43e-02 -3.47e-02 -3.08e-02 -2.18e-02 -2.32e-02 -1.70e-02 -1.26e-02 -9.95e-03 -8.03e-03 -2.02e-02 -2.21e-02 -3.09e-02 -2.79e-02 -2.92e-02 -4.73e-02 -3.85e-02 -2.69e-02 -1.89e-02 -1.70e-02 -1.44e-02 -1.42e-02 -1.51e-02 -4.21e-03 -1.55e-03 -1.72e-02 -1.70e-02 -2.18e-02 -2.50e-02 -1.84e-02 -3.18e-02 -2.53e-02 -2.01e-02 -1.37e-02 -1.89e-02 -1.02e-02 -1.15e-02 -1.16e-02 -3.85e-03 -1.22e-03 -5.45e-03 -9.53e-03 -9.49e-03 -6.68e-03 -1.08e-02 -1.59e-02 -1.34e-02 -1.53e-02 -1.86e-02 -1.03e-02 -1.07e-02 -6.50e-03 -3.98e-03 -2.38e-03 -2.29e-03 -4.46e-03 -5.06e-03 -5.22e-03 -4.55e-03 -5.72e-03 -1.00e-02 -6.07e-03 -5.95e-03 -1.20e-02 -8.03e-03 -5.95e-03 -3.61e-03 -1.35e-03 -8.82e-04 -1.47e-03 -Upper Bounds -8.83e-01 -9.04e-01 -9.04e-01 -9.06e-01 -8.90e-01 -8.71e-01 -8.51e-01 -8.82e-01 -8.99e-01 -9.42e-01 -8.75e-01 -9.67e-01 -1.38e+00 -2.14e+00 -7.89e-01 -8.70e-01 -9.11e-01 -9.06e-01 -8.15e-01 -8.92e-01 -9.06e-01 -8.84e-01 -8.83e-01 -8.68e-01 -8.58e-01 -9.07e-01 -9.12e-01 -1.29e+00 -1.63e+00 -5.33e-01 -9.10e-01 -8.73e-01 -9.05e-01 -9.08e-01 -8.81e-01 -8.85e-01 -8.70e-01 -8.31e-01 -8.30e-01 -8.46e-01 -8.79e-01 -9.36e-01 -1.33e+00 -2.08e+00 -7.86e-01 -8.80e-01 -8.72e-01 -8.61e-01 -8.81e-01 -8.35e-01 -8.38e-01 -8.52e-01 -8.74e-01 -8.62e-01 -8.63e-01 -8.27e-01 -9.20e-01 -1.33e+00 -2.00e+00 -6.39e-01 -8.76e-01 -9.10e-01 -9.11e-01 -9.20e-01 -8.60e-01 -8.61e-01 -8.34e-01 -8.36e-01 -8.28e-01 -8.72e-01 -8.44e-01 -9.49e-01 -1.41e+00 -1.65e+00 -6.46e-01 -9.01e-01 -8.97e-01 -8.94e-01 -8.90e-01 -8.81e-01 -8.46e-01 -8.38e-01 -8.15e-01 -8.49e-01 -8.29e-01 -8.56e-01 -9.61e-01 -1.35e+00 -1.44e+00 -5.12e-01 -8.79e-01 -8.59e-01 -8.42e-01 -8.55e-01 -8.31e-01 -8.41e-01 -8.24e-01 -8.31e-01 -8.11e-01 -7.99e-01 -8.06e-01 -8.32e-01 -1.19e+00 -1.66e+00 -6.17e-01 -9.09e-01 -9.03e-01 -8.95e-01 -8.51e-01 -8.33e-01 -8.62e-01 -8.26e-01 -8.10e-01 -7.35e-01 -7.80e-01 -7.82e-01 -7.20e-01 -1.00e+00 -8.79e-01 -3.78e-01 -8.81e-01 -8.79e-01 -8.98e-01 -9.09e-01 -8.56e-01 -8.36e-01 -8.26e-01 -8.10e-01 -7.69e-01 -7.73e-01 -7.71e-01 -7.76e-01 -1.14e+00 -8.33e-01 -2.68e-01 -8.83e-01 -9.23e-01 -9.16e-01 -9.05e-01 -8.94e-01 -8.03e-01 -8.19e-01 -7.89e-01 -8.04e-01 -7.99e-01 -7.77e-01 -7.67e-01 -1.16e+00 -8.69e-01 -3.26e-01 -9.04e-01 -8.93e-01 -9.15e-01 -8.96e-01 -8.99e-01 -8.47e-01 -7.92e-01 -8.32e-01 -7.94e-01 -7.96e-01 -8.49e-01 -7.81e-01 -1.06e+00 -6.40e-01 -1.87e-01 -9.49e-01 -9.48e-01 -9.08e-01 -8.57e-01 -9.51e-01 -9.10e-01 -8.62e-01 -8.93e-01 -8.43e-01 -8.47e-01 -8.29e-01 -7.55e-01 -1.11e+00 -4.81e-01 -1.57e-01 -1.38e+00 -1.37e+00 -1.26e+00 -1.31e+00 -1.37e+00 -1.34e+00 -1.26e+00 -1.21e+00 -1.21e+00 -1.21e+00 -1.20e+00 -1.12e+00 -1.06e+00 -3.64e-01 -1.05e-01 -2.50e+00 -1.75e+00 -1.96e+00 -1.28e+00 -1.40e+00 -1.59e+00 -1.27e+00 -1.18e+00 -9.31e-01 -9.87e-01 -9.06e-01 -7.50e-01 -4.87e-01 -1.88e-01 -9.31e-02 -1.08e+00 -7.08e-01 -8.14e-01 -4.09e-01 -4.59e-01 -5.72e-01 -4.06e-01 -3.97e-01 -3.49e-01 -3.11e-01 -3.14e-01 -2.24e-01 -1.84e-01 -7.93e-02 -3.58e-02 -8.56e-01 -8.80e-01 -8.90e-01 -8.72e-01 -8.83e-01 -8.79e-01 -9.07e-01 -8.87e-01 -8.46e-01 -8.81e-01 -9.13e-01 -9.22e-01 -1.35e+00 -1.99e+00 -7.68e-01 -8.95e-01 -8.96e-01 -9.01e-01 -8.77e-01 -8.78e-01 -8.57e-01 -8.71e-01 -8.72e-01 -8.61e-01 -8.65e-01 -8.84e-01 -9.25e-01 -1.27e+00 -1.84e+00 -6.71e-01 -9.00e-01 -8.80e-01 -8.68e-01 -8.83e-01 -8.82e-01 -8.83e-01 -8.68e-01 -8.89e-01 -8.61e-01 -9.00e-01 -9.04e-01 -9.06e-01 -1.33e+00 -1.66e+00 -5.75e-01 -9.10e-01 -9.28e-01 -9.04e-01 -9.15e-01 -8.68e-01 -8.37e-01 -8.58e-01 -8.74e-01 -8.49e-01 -8.43e-01 -8.73e-01 -9.20e-01 -1.29e+00 -1.77e+00 -6.31e-01 -8.99e-01 -9.11e-01 -8.97e-01 -8.66e-01 -8.29e-01 -8.48e-01 -8.85e-01 -8.47e-01 -8.39e-01 -8.47e-01 -8.91e-01 -9.17e-01 -1.38e+00 -1.51e+00 -6.62e-01 -8.74e-01 -8.88e-01 -8.84e-01 -8.46e-01 -8.97e-01 -8.43e-01 -8.27e-01 -8.17e-01 -8.15e-01 -8.35e-01 -8.69e-01 -9.33e-01 -1.35e+00 -1.72e+00 -6.01e-01 -9.01e-01 -9.12e-01 -8.41e-01 -8.34e-01 -8.86e-01 -8.49e-01 -7.94e-01 -7.99e-01 -7.91e-01 -8.03e-01 -8.26e-01 -8.34e-01 -1.17e+00 -1.46e+00 -5.66e-01 -8.53e-01 -8.62e-01 -8.25e-01 -8.26e-01 -8.26e-01 -7.99e-01 -7.85e-01 -7.29e-01 -7.14e-01 -7.51e-01 -7.41e-01 -5.28e-01 -9.65e-01 -8.41e-01 -3.51e-01 -8.43e-01 -9.30e-01 -8.75e-01 -8.72e-01 -8.86e-01 -8.25e-01 -8.05e-01 -7.70e-01 -7.66e-01 -7.77e-01 -7.36e-01 -7.06e-01 -9.91e-01 -6.14e-01 -1.92e-01 -8.89e-01 -9.28e-01 -8.82e-01 -8.85e-01 -8.26e-01 -8.77e-01 -8.28e-01 -7.72e-01 -7.97e-01 -7.70e-01 -8.14e-01 -7.60e-01 -1.08e+00 -7.25e-01 -2.17e-01 -8.99e-01 -9.33e-01 -8.95e-01 -8.67e-01 -9.07e-01 -8.80e-01 -8.33e-01 -7.98e-01 -8.16e-01 -7.99e-01 -8.47e-01 -7.75e-01 -1.08e+00 -6.72e-01 -2.06e-01 -9.39e-01 -8.99e-01 -9.19e-01 -9.05e-01 -9.21e-01 -9.37e-01 -8.70e-01 -8.47e-01 -8.32e-01 -8.66e-01 -8.48e-01 -8.12e-01 -1.00e+00 -4.14e-01 -1.43e-01 -1.29e+00 -1.41e+00 -1.29e+00 -1.35e+00 -1.47e+00 -1.34e+00 -1.23e+00 -1.28e+00 -1.17e+00 -1.16e+00 -1.29e+00 -1.20e+00 -1.04e+00 -2.68e-01 -6.98e-02 -1.56e+00 -1.49e+00 -1.36e+00 -1.52e+00 -1.85e+00 -1.77e+00 -1.39e+00 -1.40e+00 -1.09e+00 -8.12e-01 -8.12e-01 -8.15e-01 -5.39e-01 -1.74e-01 -7.42e-02 -5.46e-01 -5.41e-01 -5.27e-01 -5.05e-01 -6.76e-01 -7.08e-01 -4.76e-01 -5.00e-01 -4.66e-01 -2.59e-01 -2.59e-01 -2.67e-01 -2.12e-01 -9.34e-02 -3.59e-02 -8.98e-01 -8.76e-01 -9.11e-01 -8.74e-01 -8.57e-01 -8.49e-01 -8.45e-01 -8.23e-01 -8.73e-01 -8.56e-01 -8.41e-01 -9.32e-01 -1.56e+00 -2.14e+00 -8.32e-01 -9.04e-01 -8.85e-01 -8.48e-01 -8.66e-01 -8.66e-01 -8.58e-01 -8.22e-01 -8.28e-01 -8.32e-01 -8.65e-01 -8.49e-01 -9.47e-01 -1.32e+00 -2.01e+00 -8.20e-01 -8.96e-01 -9.02e-01 -9.15e-01 -8.55e-01 -8.63e-01 -8.56e-01 -8.51e-01 -8.73e-01 -8.47e-01 -8.41e-01 -8.38e-01 -8.99e-01 -1.24e+00 -1.71e+00 -6.45e-01 -8.13e-01 -8.67e-01 -8.68e-01 -8.57e-01 -8.41e-01 -8.27e-01 -8.41e-01 -8.63e-01 -8.60e-01 -8.27e-01 -8.62e-01 -8.45e-01 -1.26e+00 -1.59e+00 -5.28e-01 -8.37e-01 -8.48e-01 -8.61e-01 -8.18e-01 -8.55e-01 -8.57e-01 -7.87e-01 -8.18e-01 -8.05e-01 -8.09e-01 -8.66e-01 -8.95e-01 -1.31e+00 -1.33e+00 -3.87e-01 -8.40e-01 -8.59e-01 -8.21e-01 -8.32e-01 -8.27e-01 -8.30e-01 -7.89e-01 -7.95e-01 -8.16e-01 -8.14e-01 -8.48e-01 -8.74e-01 -1.25e+00 -1.74e+00 -6.56e-01 -8.62e-01 -8.97e-01 -8.49e-01 -8.48e-01 -8.43e-01 -8.56e-01 -8.49e-01 -7.73e-01 -7.97e-01 -8.23e-01 -8.50e-01 -8.53e-01 -1.22e+00 -1.23e+00 -4.60e-01 -8.51e-01 -8.51e-01 -8.30e-01 -8.17e-01 -8.30e-01 -8.17e-01 -7.95e-01 -7.91e-01 -7.83e-01 -7.99e-01 -7.74e-01 -7.63e-01 -1.10e+00 -8.15e-01 -3.18e-01 -8.51e-01 -8.51e-01 -8.64e-01 -8.45e-01 -8.30e-01 -8.19e-01 -8.14e-01 -8.18e-01 -7.60e-01 -7.72e-01 -7.64e-01 -7.45e-01 -1.06e+00 -8.19e-01 -3.07e-01 -8.70e-01 -8.92e-01 -8.63e-01 -8.73e-01 -8.70e-01 -8.23e-01 -8.34e-01 -7.96e-01 -7.41e-01 -7.85e-01 -7.76e-01 -7.97e-01 -1.03e+00 -6.15e-01 -2.40e-01 -8.46e-01 -8.88e-01 -8.83e-01 -8.69e-01 -8.83e-01 -8.65e-01 -8.68e-01 -8.40e-01 -7.58e-01 -7.91e-01 -7.91e-01 -7.77e-01 -1.06e+00 -6.09e-01 -1.67e-01 -8.76e-01 -9.27e-01 -9.32e-01 -9.51e-01 -9.02e-01 -8.97e-01 -8.78e-01 -8.56e-01 -8.35e-01 -8.55e-01 -8.47e-01 -8.43e-01 -9.29e-01 -5.11e-01 -1.77e-01 -1.33e+00 -1.33e+00 -1.32e+00 -1.25e+00 -1.30e+00 -1.29e+00 -1.17e+00 -1.21e+00 -1.18e+00 -1.15e+00 -1.16e+00 -1.21e+00 -1.14e+00 -2.72e-01 -8.55e-02 -1.89e+00 -1.37e+00 -1.71e+00 -1.75e+00 -1.82e+00 -1.16e+00 -1.16e+00 -1.09e+00 -9.10e-01 -8.87e-01 -6.38e-01 -5.79e-01 -5.13e-01 -2.08e-01 -5.28e-02 -6.66e-01 -4.35e-01 -7.04e-01 -6.72e-01 -6.85e-01 -4.41e-01 -3.91e-01 -4.18e-01 -2.80e-01 -3.20e-01 -1.45e-01 -1.85e-01 -1.73e-01 -1.30e-01 -6.20e-02 -8.83e-01 -8.54e-01 -8.74e-01 -8.97e-01 -8.66e-01 -8.53e-01 -8.20e-01 -8.29e-01 -7.95e-01 -8.07e-01 -7.74e-01 -8.95e-01 -1.34e+00 -2.13e+00 -7.78e-01 -8.75e-01 -9.11e-01 -8.53e-01 -8.24e-01 -8.43e-01 -8.30e-01 -8.44e-01 -8.16e-01 -8.23e-01 -8.70e-01 -8.45e-01 -8.80e-01 -1.24e+00 -1.66e+00 -6.51e-01 -8.43e-01 -8.65e-01 -8.86e-01 -8.33e-01 -7.75e-01 -8.33e-01 -7.93e-01 -8.14e-01 -7.91e-01 -8.49e-01 -8.47e-01 -9.21e-01 -1.22e+00 -1.35e+00 -5.11e-01 -8.45e-01 -8.50e-01 -8.67e-01 -8.43e-01 -8.32e-01 -8.35e-01 -8.18e-01 -8.02e-01 -8.09e-01 -8.16e-01 -8.13e-01 -8.33e-01 -1.24e+00 -1.20e+00 -4.92e-01 -8.11e-01 -8.21e-01 -8.46e-01 -8.56e-01 -8.12e-01 -7.90e-01 -8.09e-01 -7.88e-01 -8.08e-01 -8.07e-01 -8.57e-01 -8.34e-01 -1.25e+00 -1.61e+00 -5.85e-01 -8.68e-01 -7.99e-01 -8.45e-01 -8.59e-01 -8.33e-01 -7.98e-01 -8.23e-01 -8.40e-01 -8.11e-01 -8.01e-01 -8.15e-01 -8.78e-01 -1.27e+00 -1.49e+00 -5.48e-01 -8.43e-01 -8.36e-01 -8.81e-01 -8.18e-01 -7.95e-01 -7.90e-01 -8.20e-01 -7.94e-01 -7.74e-01 -7.96e-01 -7.56e-01 -8.00e-01 -1.25e+00 -1.44e+00 -5.06e-01 -8.60e-01 -8.53e-01 -8.41e-01 -8.13e-01 -7.94e-01 -8.04e-01 -8.30e-01 -7.78e-01 -7.68e-01 -7.54e-01 -7.46e-01 -7.89e-01 -1.17e+00 -9.24e-01 -3.31e-01 -8.47e-01 -8.25e-01 -8.14e-01 -8.34e-01 -8.09e-01 -8.13e-01 -8.14e-01 -8.04e-01 -7.77e-01 -7.65e-01 -7.94e-01 -8.47e-01 -1.24e+00 -9.33e-01 -2.64e-01 -8.55e-01 -8.28e-01 -8.67e-01 -8.38e-01 -8.25e-01 -8.22e-01 -7.96e-01 -7.62e-01 -7.99e-01 -7.61e-01 -7.38e-01 -7.68e-01 -1.16e+00 -6.75e-01 -2.70e-01 -8.80e-01 -8.88e-01 -8.39e-01 -8.93e-01 -8.67e-01 -8.43e-01 -8.12e-01 -8.07e-01 -7.97e-01 -8.03e-01 -7.88e-01 -8.01e-01 -1.03e+00 -4.71e-01 -1.39e-01 -9.42e-01 -8.84e-01 -8.89e-01 -8.81e-01 -9.12e-01 -9.52e-01 -8.80e-01 -8.12e-01 -8.44e-01 -8.47e-01 -8.47e-01 -8.42e-01 -9.87e-01 -3.92e-01 -1.14e-01 -1.24e+00 -1.25e+00 -1.29e+00 -1.25e+00 -1.29e+00 -1.28e+00 -1.08e+00 -1.14e+00 -1.21e+00 -1.12e+00 -1.06e+00 -1.07e+00 -1.14e+00 -3.91e-01 -1.23e-01 -1.55e+00 -1.24e+00 -1.03e+00 -1.46e+00 -1.44e+00 -1.17e+00 -8.10e-01 -5.67e-01 -9.52e-01 -9.00e-01 -5.78e-01 -5.33e-01 -4.71e-01 -2.10e-01 -8.15e-02 -5.84e-01 -4.29e-01 -4.39e-01 -4.57e-01 -5.73e-01 -4.28e-01 -3.39e-01 -1.82e-01 -3.17e-01 -3.19e-01 -2.03e-01 -1.80e-01 -1.39e-01 -1.28e-01 -6.06e-02 -8.53e-01 -8.41e-01 -8.16e-01 -8.39e-01 -8.62e-01 -8.30e-01 -8.25e-01 -7.57e-01 -7.84e-01 -8.17e-01 -7.85e-01 -8.91e-01 -1.29e+00 -1.58e+00 -6.19e-01 -8.62e-01 -8.53e-01 -8.28e-01 -8.47e-01 -8.54e-01 -8.13e-01 -7.89e-01 -7.56e-01 -8.10e-01 -8.39e-01 -8.37e-01 -8.80e-01 -1.27e+00 -1.52e+00 -5.61e-01 -8.76e-01 -8.58e-01 -8.51e-01 -8.40e-01 -8.16e-01 -8.22e-01 -8.17e-01 -7.68e-01 -8.23e-01 -8.47e-01 -8.38e-01 -8.80e-01 -1.26e+00 -1.11e+00 -4.01e-01 -8.41e-01 -8.55e-01 -8.26e-01 -8.31e-01 -8.17e-01 -8.22e-01 -8.05e-01 -8.08e-01 -8.05e-01 -8.32e-01 -8.20e-01 -8.61e-01 -1.30e+00 -1.05e+00 -3.57e-01 -8.15e-01 -8.06e-01 -8.14e-01 -8.44e-01 -8.05e-01 -8.12e-01 -8.12e-01 -8.06e-01 -7.90e-01 -7.71e-01 -8.19e-01 -8.79e-01 -1.29e+00 -1.63e+00 -5.79e-01 -7.99e-01 -7.98e-01 -8.14e-01 -8.39e-01 -8.09e-01 -7.70e-01 -7.51e-01 -8.22e-01 -8.15e-01 -7.92e-01 -7.89e-01 -8.42e-01 -1.22e+00 -1.30e+00 -4.67e-01 -8.04e-01 -8.15e-01 -8.41e-01 -8.12e-01 -8.44e-01 -7.64e-01 -7.65e-01 -7.83e-01 -7.51e-01 -7.69e-01 -7.83e-01 -7.94e-01 -1.09e+00 -1.03e+00 -3.79e-01 -8.53e-01 -8.48e-01 -8.17e-01 -7.87e-01 -8.03e-01 -7.66e-01 -7.80e-01 -7.47e-01 -7.47e-01 -7.94e-01 -7.46e-01 -7.73e-01 -1.13e+00 -8.10e-01 -3.44e-01 -8.55e-01 -8.35e-01 -8.31e-01 -8.01e-01 -8.04e-01 -8.11e-01 -8.17e-01 -7.71e-01 -7.52e-01 -7.41e-01 -7.55e-01 -7.73e-01 -1.08e+00 -8.26e-01 -2.48e-01 -8.55e-01 -8.65e-01 -8.39e-01 -8.10e-01 -7.84e-01 -8.10e-01 -7.97e-01 -7.80e-01 -7.63e-01 -7.36e-01 -7.45e-01 -8.12e-01 -1.07e+00 -7.90e-01 -3.43e-01 -8.52e-01 -8.31e-01 -8.47e-01 -8.29e-01 -8.34e-01 -8.10e-01 -8.15e-01 -8.13e-01 -7.91e-01 -7.58e-01 -7.69e-01 -8.34e-01 -1.13e+00 -5.77e-01 -2.01e-01 -8.71e-01 -9.08e-01 -8.51e-01 -8.61e-01 -8.87e-01 -9.24e-01 -8.39e-01 -8.24e-01 -8.13e-01 -8.68e-01 -8.13e-01 -8.31e-01 -1.14e+00 -5.34e-01 -1.63e-01 -1.29e+00 -1.23e+00 -1.25e+00 -1.29e+00 -1.30e+00 -1.33e+00 -1.29e+00 -1.19e+00 -1.17e+00 -1.14e+00 -1.08e+00 -1.12e+00 -1.16e+00 -4.48e-01 -1.51e-01 -1.37e+00 -1.25e+00 -1.26e+00 -1.31e+00 -1.52e+00 -1.34e+00 -1.46e+00 -9.26e-01 -1.00e+00 -7.33e-01 -5.03e-01 -5.86e-01 -4.40e-01 -1.93e-01 -7.63e-02 -5.00e-01 -4.36e-01 -4.55e-01 -4.50e-01 -5.38e-01 -4.35e-01 -5.87e-01 -2.73e-01 -3.52e-01 -2.53e-01 -1.54e-01 -1.57e-01 -1.32e-01 -8.46e-02 -5.80e-02 -7.99e-01 -8.20e-01 -8.15e-01 -8.33e-01 -8.51e-01 -8.10e-01 -7.68e-01 -7.62e-01 -7.58e-01 -7.77e-01 -7.87e-01 -8.14e-01 -1.30e+00 -1.29e+00 -3.79e-01 -7.97e-01 -8.41e-01 -8.13e-01 -7.89e-01 -8.26e-01 -8.24e-01 -8.37e-01 -7.59e-01 -7.92e-01 -7.78e-01 -7.98e-01 -8.46e-01 -1.24e+00 -1.44e+00 -5.54e-01 -8.32e-01 -8.44e-01 -8.48e-01 -8.16e-01 -8.13e-01 -7.97e-01 -8.17e-01 -8.24e-01 -7.90e-01 -7.89e-01 -7.98e-01 -8.75e-01 -1.29e+00 -1.26e+00 -4.10e-01 -8.34e-01 -8.40e-01 -7.91e-01 -7.91e-01 -8.06e-01 -8.33e-01 -7.71e-01 -7.76e-01 -8.05e-01 -8.07e-01 -8.15e-01 -8.50e-01 -1.26e+00 -1.18e+00 -3.80e-01 -8.13e-01 -8.32e-01 -8.39e-01 -8.18e-01 -7.93e-01 -7.93e-01 -7.84e-01 -7.91e-01 -7.91e-01 -7.82e-01 -7.90e-01 -8.30e-01 -1.25e+00 -1.29e+00 -4.90e-01 -8.01e-01 -8.04e-01 -8.21e-01 -8.03e-01 -7.98e-01 -7.82e-01 -7.55e-01 -7.51e-01 -8.14e-01 -8.19e-01 -7.83e-01 -8.19e-01 -1.18e+00 -1.09e+00 -4.51e-01 -8.40e-01 -8.47e-01 -8.18e-01 -7.81e-01 -7.89e-01 -7.65e-01 -7.53e-01 -7.17e-01 -7.54e-01 -7.65e-01 -7.76e-01 -8.17e-01 -1.09e+00 -6.64e-01 -2.45e-01 -8.36e-01 -7.99e-01 -8.04e-01 -7.74e-01 -8.20e-01 -7.78e-01 -7.45e-01 -7.25e-01 -7.18e-01 -7.55e-01 -7.86e-01 -8.22e-01 -1.16e+00 -5.88e-01 -1.82e-01 -8.12e-01 -8.33e-01 -8.42e-01 -7.73e-01 -7.95e-01 -7.85e-01 -7.91e-01 -7.28e-01 -7.16e-01 -6.95e-01 -7.39e-01 -7.71e-01 -1.13e+00 -7.23e-01 -2.02e-01 -7.76e-01 -8.13e-01 -8.17e-01 -8.37e-01 -7.81e-01 -7.65e-01 -7.51e-01 -7.47e-01 -7.44e-01 -7.26e-01 -7.33e-01 -7.63e-01 -1.05e+00 -6.00e-01 -1.91e-01 -8.26e-01 -7.94e-01 -8.07e-01 -8.05e-01 -7.80e-01 -7.80e-01 -8.00e-01 -7.93e-01 -7.69e-01 -7.64e-01 -7.39e-01 -7.58e-01 -1.04e+00 -5.07e-01 -1.50e-01 -8.87e-01 -8.55e-01 -8.41e-01 -8.56e-01 -8.73e-01 -8.47e-01 -8.19e-01 -8.38e-01 -8.05e-01 -8.07e-01 -7.65e-01 -7.30e-01 -9.77e-01 -4.70e-01 -1.10e-01 -1.23e+00 -1.19e+00 -1.16e+00 -1.21e+00 -1.27e+00 -1.25e+00 -1.14e+00 -1.10e+00 -1.11e+00 -1.13e+00 -1.17e+00 -1.01e+00 -9.39e-01 -4.79e-01 -1.76e-01 -1.53e+00 -1.30e+00 -1.11e+00 -1.31e+00 -1.28e+00 -1.18e+00 -1.16e+00 -8.91e-01 -7.64e-01 -6.86e-01 -7.35e-01 -6.78e-01 -3.62e-01 -2.02e-01 -1.12e-01 -5.19e-01 -4.91e-01 -4.40e-01 -4.60e-01 -4.87e-01 -3.65e-01 -5.18e-01 -3.03e-01 -2.69e-01 -1.84e-01 -2.14e-01 -2.43e-01 -1.44e-01 -7.93e-02 -4.59e-02 -8.53e-01 -8.34e-01 -8.24e-01 -8.44e-01 -7.93e-01 -7.98e-01 -8.11e-01 -8.08e-01 -7.84e-01 -7.45e-01 -7.60e-01 -7.66e-01 -1.21e+00 -9.01e-01 -4.10e-01 -8.39e-01 -8.13e-01 -8.33e-01 -8.25e-01 -8.17e-01 -7.68e-01 -7.94e-01 -7.61e-01 -7.94e-01 -7.58e-01 -7.42e-01 -7.76e-01 -1.12e+00 -1.01e+00 -3.78e-01 -8.15e-01 -7.96e-01 -8.12e-01 -8.03e-01 -7.86e-01 -7.79e-01 -7.51e-01 -7.57e-01 -7.42e-01 -7.66e-01 -8.04e-01 -7.92e-01 -1.16e+00 -1.25e+00 -5.04e-01 -8.34e-01 -7.68e-01 -7.75e-01 -7.60e-01 -7.73e-01 -8.04e-01 -7.86e-01 -7.68e-01 -7.69e-01 -7.72e-01 -7.79e-01 -8.19e-01 -1.12e+00 -7.80e-01 -3.07e-01 -8.35e-01 -8.24e-01 -8.03e-01 -7.87e-01 -7.88e-01 -8.12e-01 -7.74e-01 -7.87e-01 -7.48e-01 -7.70e-01 -7.77e-01 -8.41e-01 -1.16e+00 -6.39e-01 -2.34e-01 -8.17e-01 -7.87e-01 -7.98e-01 -8.15e-01 -8.06e-01 -7.88e-01 -7.52e-01 -7.32e-01 -7.17e-01 -7.60e-01 -7.74e-01 -8.04e-01 -1.13e+00 -6.75e-01 -2.06e-01 -8.22e-01 -8.10e-01 -8.02e-01 -8.08e-01 -8.05e-01 -7.56e-01 -7.48e-01 -7.03e-01 -7.31e-01 -7.43e-01 -7.54e-01 -8.22e-01 -1.16e+00 -7.52e-01 -2.28e-01 -7.64e-01 -7.75e-01 -7.68e-01 -7.87e-01 -7.73e-01 -7.45e-01 -7.48e-01 -7.22e-01 -7.13e-01 -7.34e-01 -7.57e-01 -7.86e-01 -1.10e+00 -8.15e-01 -2.44e-01 -8.21e-01 -7.75e-01 -7.87e-01 -7.66e-01 -7.39e-01 -7.65e-01 -7.62e-01 -6.99e-01 -6.88e-01 -6.98e-01 -7.52e-01 -7.85e-01 -1.05e+00 -7.70e-01 -2.57e-01 -7.79e-01 -7.89e-01 -8.06e-01 -7.85e-01 -7.59e-01 -7.34e-01 -7.57e-01 -7.39e-01 -7.18e-01 -7.39e-01 -7.21e-01 -7.16e-01 -1.03e+00 -6.02e-01 -2.37e-01 -8.09e-01 -8.54e-01 -8.12e-01 -7.85e-01 -7.60e-01 -7.56e-01 -7.18e-01 -7.13e-01 -7.31e-01 -7.31e-01 -6.81e-01 -7.25e-01 -9.31e-01 -3.54e-01 -1.26e-01 -8.50e-01 -8.54e-01 -8.14e-01 -7.80e-01 -8.02e-01 -8.05e-01 -7.81e-01 -7.77e-01 -7.97e-01 -7.65e-01 -7.40e-01 -7.05e-01 -7.73e-01 -3.06e-01 -1.34e-01 -1.20e+00 -1.12e+00 -1.11e+00 -1.13e+00 -1.15e+00 -1.10e+00 -1.10e+00 -9.95e-01 -1.08e+00 -9.88e-01 -1.01e+00 -9.01e-01 -6.74e-01 -1.87e-01 -8.09e-02 -1.32e+00 -1.34e+00 -1.16e+00 -7.75e-01 -7.51e-01 -9.97e-01 -8.93e-01 -7.22e-01 -6.51e-01 -6.25e-01 -7.18e-01 -5.73e-01 -2.11e-01 -9.82e-02 -4.26e-02 -4.75e-01 -5.18e-01 -4.49e-01 -2.40e-01 -2.44e-01 -3.22e-01 -3.19e-01 -2.35e-01 -2.20e-01 -1.64e-01 -2.36e-01 -2.02e-01 -7.60e-02 -4.33e-02 -3.07e-02 -7.81e-01 -7.87e-01 -7.72e-01 -8.00e-01 -8.24e-01 -8.30e-01 -8.27e-01 -7.88e-01 -7.35e-01 -7.02e-01 -6.79e-01 -7.96e-01 -1.11e+00 -7.59e-01 -2.66e-01 -8.05e-01 -8.08e-01 -8.45e-01 -8.16e-01 -7.90e-01 -7.90e-01 -7.97e-01 -7.35e-01 -7.24e-01 -6.97e-01 -6.50e-01 -7.41e-01 -1.08e+00 -5.46e-01 -1.73e-01 -7.91e-01 -7.84e-01 -8.12e-01 -8.13e-01 -7.93e-01 -7.86e-01 -7.80e-01 -7.88e-01 -7.62e-01 -7.25e-01 -7.48e-01 -8.00e-01 -1.08e+00 -7.80e-01 -2.83e-01 -7.99e-01 -7.86e-01 -8.00e-01 -7.83e-01 -8.01e-01 -7.89e-01 -7.68e-01 -7.67e-01 -7.34e-01 -7.08e-01 -7.82e-01 -8.28e-01 -1.05e+00 -7.28e-01 -3.01e-01 -8.10e-01 -8.05e-01 -8.41e-01 -7.70e-01 -7.70e-01 -7.93e-01 -7.51e-01 -7.44e-01 -7.48e-01 -7.29e-01 -7.92e-01 -7.97e-01 -1.08e+00 -5.90e-01 -1.62e-01 -8.06e-01 -7.76e-01 -8.01e-01 -7.96e-01 -7.50e-01 -7.27e-01 -7.51e-01 -7.26e-01 -7.36e-01 -7.31e-01 -7.40e-01 -7.92e-01 -1.07e+00 -6.18e-01 -2.17e-01 -7.91e-01 -7.77e-01 -7.90e-01 -7.54e-01 -7.85e-01 -7.70e-01 -7.48e-01 -6.96e-01 -6.99e-01 -7.02e-01 -6.96e-01 -7.43e-01 -1.02e+00 -7.52e-01 -2.89e-01 -7.56e-01 -7.94e-01 -7.67e-01 -7.64e-01 -7.61e-01 -7.60e-01 -7.28e-01 -7.14e-01 -7.09e-01 -7.03e-01 -7.62e-01 -7.59e-01 -1.03e+00 -6.86e-01 -2.56e-01 -7.75e-01 -7.59e-01 -7.81e-01 -7.45e-01 -7.66e-01 -7.46e-01 -7.25e-01 -6.93e-01 -6.75e-01 -6.66e-01 -7.38e-01 -7.31e-01 -9.88e-01 -5.41e-01 -1.68e-01 -7.63e-01 -7.64e-01 -7.46e-01 -7.17e-01 -7.23e-01 -7.40e-01 -6.88e-01 -7.11e-01 -6.45e-01 -6.43e-01 -6.92e-01 -7.27e-01 -1.06e+00 -5.99e-01 -1.94e-01 -7.99e-01 -7.77e-01 -7.94e-01 -7.47e-01 -7.40e-01 -7.39e-01 -7.34e-01 -7.52e-01 -7.06e-01 -6.86e-01 -6.55e-01 -6.81e-01 -8.86e-01 -3.82e-01 -9.69e-02 -8.46e-01 -8.18e-01 -8.26e-01 -7.84e-01 -7.60e-01 -7.38e-01 -7.20e-01 -7.68e-01 -7.41e-01 -7.47e-01 -7.02e-01 -6.54e-01 -7.66e-01 -2.43e-01 -7.12e-02 -1.21e+00 -1.12e+00 -1.12e+00 -1.01e+00 -1.09e+00 -1.07e+00 -8.74e-01 -8.72e-01 -8.67e-01 -1.01e+00 -1.01e+00 -8.47e-01 -6.09e-01 -1.58e-01 -5.39e-02 -1.08e+00 -1.12e+00 -8.01e-01 -6.68e-01 -7.20e-01 -8.39e-01 -5.11e-01 -4.35e-01 -3.60e-01 -7.14e-01 -6.43e-01 -4.11e-01 -2.15e-01 -5.39e-02 -2.14e-02 -3.73e-01 -3.83e-01 -2.54e-01 -2.38e-01 -2.15e-01 -2.86e-01 -1.89e-01 -1.46e-01 -1.14e-01 -2.39e-01 -2.00e-01 -1.38e-01 -9.65e-02 -4.13e-02 -1.06e-02 -8.16e-01 -8.31e-01 -8.55e-01 -8.17e-01 -8.37e-01 -7.96e-01 -7.81e-01 -8.05e-01 -7.46e-01 -7.27e-01 -6.91e-01 -7.68e-01 -1.08e+00 -5.87e-01 -1.78e-01 -7.93e-01 -8.07e-01 -8.40e-01 -8.16e-01 -8.12e-01 -8.09e-01 -7.98e-01 -7.79e-01 -7.43e-01 -7.35e-01 -7.18e-01 -7.62e-01 -1.05e+00 -6.30e-01 -1.97e-01 -7.86e-01 -8.04e-01 -7.90e-01 -7.96e-01 -8.02e-01 -7.57e-01 -7.79e-01 -7.99e-01 -7.43e-01 -7.26e-01 -7.20e-01 -8.04e-01 -1.21e+00 -8.14e-01 -2.65e-01 -8.01e-01 -7.70e-01 -8.02e-01 -7.66e-01 -7.78e-01 -7.86e-01 -7.74e-01 -7.63e-01 -7.30e-01 -7.36e-01 -7.45e-01 -7.37e-01 -1.04e+00 -8.80e-01 -3.72e-01 -7.76e-01 -7.61e-01 -7.65e-01 -7.59e-01 -7.59e-01 -7.54e-01 -7.53e-01 -7.66e-01 -7.40e-01 -7.01e-01 -7.50e-01 -8.07e-01 -1.03e+00 -6.47e-01 -2.01e-01 -8.00e-01 -7.91e-01 -7.50e-01 -7.33e-01 -7.09e-01 -7.28e-01 -7.48e-01 -7.31e-01 -7.26e-01 -7.09e-01 -7.38e-01 -8.00e-01 -1.08e+00 -7.50e-01 -2.61e-01 -7.64e-01 -7.65e-01 -7.60e-01 -7.25e-01 -7.24e-01 -7.17e-01 -6.99e-01 -6.92e-01 -6.87e-01 -6.82e-01 -7.32e-01 -7.47e-01 -9.42e-01 -5.70e-01 -2.11e-01 -7.38e-01 -7.50e-01 -7.58e-01 -7.14e-01 -7.38e-01 -7.21e-01 -6.80e-01 -6.69e-01 -6.84e-01 -6.84e-01 -7.32e-01 -7.33e-01 -9.18e-01 -3.59e-01 -1.45e-01 -7.38e-01 -7.18e-01 -7.38e-01 -7.39e-01 -7.46e-01 -7.70e-01 -7.25e-01 -6.90e-01 -6.46e-01 -6.49e-01 -6.56e-01 -6.97e-01 -9.65e-01 -3.98e-01 -1.02e-01 -7.64e-01 -7.31e-01 -7.32e-01 -7.05e-01 -7.34e-01 -7.26e-01 -7.09e-01 -6.85e-01 -6.43e-01 -6.34e-01 -6.51e-01 -6.67e-01 -9.76e-01 -4.41e-01 -1.09e-01 -7.80e-01 -7.12e-01 -7.26e-01 -7.17e-01 -7.58e-01 -7.39e-01 -7.19e-01 -7.02e-01 -7.03e-01 -6.55e-01 -5.91e-01 -6.53e-01 -9.17e-01 -4.78e-01 -1.37e-01 -8.17e-01 -7.34e-01 -7.39e-01 -7.85e-01 -7.75e-01 -7.52e-01 -7.79e-01 -7.11e-01 -7.19e-01 -6.96e-01 -6.43e-01 -6.00e-01 -7.61e-01 -2.70e-01 -8.10e-02 -1.16e+00 -1.04e+00 -1.10e+00 -1.11e+00 -1.11e+00 -1.08e+00 -9.95e-01 -1.02e+00 -9.59e-01 -1.01e+00 -9.84e-01 -7.98e-01 -6.84e-01 -2.00e-01 -5.36e-02 -1.12e+00 -8.97e-01 -8.53e-01 -8.36e-01 -8.45e-01 -7.72e-01 -5.11e-01 -5.45e-01 -4.94e-01 -5.38e-01 -5.92e-01 -4.14e-01 -2.08e-01 -7.44e-02 -2.60e-02 -3.41e-01 -2.55e-01 -2.14e-01 -2.42e-01 -2.46e-01 -2.60e-01 -1.78e-01 -1.61e-01 -1.44e-01 -1.52e-01 -1.91e-01 -1.39e-01 -6.05e-02 -2.90e-02 -6.48e-03 -7.87e-01 -8.11e-01 -8.37e-01 -8.09e-01 -8.06e-01 -7.52e-01 -7.59e-01 -7.86e-01 -7.65e-01 -7.53e-01 -7.16e-01 -8.07e-01 -1.02e+00 -7.17e-01 -2.61e-01 -7.93e-01 -8.13e-01 -7.88e-01 -7.89e-01 -7.88e-01 -8.08e-01 -8.00e-01 -7.90e-01 -7.89e-01 -7.16e-01 -7.47e-01 -7.97e-01 -1.11e+00 -7.82e-01 -2.29e-01 -8.16e-01 -7.85e-01 -7.57e-01 -7.70e-01 -7.67e-01 -7.99e-01 -7.75e-01 -7.99e-01 -8.00e-01 -7.26e-01 -7.00e-01 -7.95e-01 -1.12e+00 -8.32e-01 -2.72e-01 -7.66e-01 -7.71e-01 -7.72e-01 -7.50e-01 -7.83e-01 -7.66e-01 -7.97e-01 -7.79e-01 -7.41e-01 -7.26e-01 -7.24e-01 -7.90e-01 -1.04e+00 -7.19e-01 -2.72e-01 -7.50e-01 -7.28e-01 -7.78e-01 -7.78e-01 -7.70e-01 -7.41e-01 -7.52e-01 -7.68e-01 -7.29e-01 -7.30e-01 -7.52e-01 -7.62e-01 -1.04e+00 -5.78e-01 -1.84e-01 -7.79e-01 -7.50e-01 -7.82e-01 -7.38e-01 -7.48e-01 -7.53e-01 -7.41e-01 -7.47e-01 -7.17e-01 -7.06e-01 -7.29e-01 -7.63e-01 -1.01e+00 -5.33e-01 -1.96e-01 -7.73e-01 -7.74e-01 -7.65e-01 -7.47e-01 -7.35e-01 -7.39e-01 -7.07e-01 -7.21e-01 -7.07e-01 -7.06e-01 -6.86e-01 -7.53e-01 -1.03e+00 -6.87e-01 -2.34e-01 -7.58e-01 -7.65e-01 -7.72e-01 -7.64e-01 -7.41e-01 -7.16e-01 -6.58e-01 -7.03e-01 -6.75e-01 -6.34e-01 -6.76e-01 -7.61e-01 -9.52e-01 -3.63e-01 -1.11e-01 -7.33e-01 -7.35e-01 -7.46e-01 -7.50e-01 -7.43e-01 -7.09e-01 -6.97e-01 -6.61e-01 -6.39e-01 -6.31e-01 -6.70e-01 -7.26e-01 -9.35e-01 -4.08e-01 -1.21e-01 -7.44e-01 -7.40e-01 -7.34e-01 -7.49e-01 -7.23e-01 -7.13e-01 -6.92e-01 -6.51e-01 -6.43e-01 -6.54e-01 -6.11e-01 -6.81e-01 -8.92e-01 -5.18e-01 -1.67e-01 -7.39e-01 -7.24e-01 -7.18e-01 -7.10e-01 -7.07e-01 -7.17e-01 -7.28e-01 -6.89e-01 -6.45e-01 -6.27e-01 -5.89e-01 -6.27e-01 -8.94e-01 -4.27e-01 -1.44e-01 -8.20e-01 -7.35e-01 -7.73e-01 -7.79e-01 -7.33e-01 -7.94e-01 -7.38e-01 -7.21e-01 -6.82e-01 -6.66e-01 -6.30e-01 -5.53e-01 -6.56e-01 -2.86e-01 -9.02e-02 -1.23e+00 -1.02e+00 -9.49e-01 -1.09e+00 -1.08e+00 -1.07e+00 -1.01e+00 -1.12e+00 -1.07e+00 -1.12e+00 -9.32e-01 -7.55e-01 -5.90e-01 -1.70e-01 -6.04e-02 -9.34e-01 -7.67e-01 -7.48e-01 -8.36e-01 -9.13e-01 -8.43e-01 -6.94e-01 -7.11e-01 -6.45e-01 -5.23e-01 -4.64e-01 -3.36e-01 -1.97e-01 -8.24e-02 -3.52e-02 -3.61e-01 -3.04e-01 -3.20e-01 -2.77e-01 -3.14e-01 -2.79e-01 -2.19e-01 -2.01e-01 -2.23e-01 -1.68e-01 -1.56e-01 -1.06e-01 -6.15e-02 -3.90e-02 -1.78e-02 -7.55e-01 -7.78e-01 -8.17e-01 -8.31e-01 -8.37e-01 -8.23e-01 -8.31e-01 -8.49e-01 -7.67e-01 -7.79e-01 -7.53e-01 -7.56e-01 -9.13e-01 -4.87e-01 -1.90e-01 -7.63e-01 -7.96e-01 -7.72e-01 -7.84e-01 -8.07e-01 -7.97e-01 -7.85e-01 -7.92e-01 -7.90e-01 -7.89e-01 -7.62e-01 -7.60e-01 -9.99e-01 -6.50e-01 -2.08e-01 -7.70e-01 -7.78e-01 -7.67e-01 -8.10e-01 -7.76e-01 -7.97e-01 -8.29e-01 -7.63e-01 -7.81e-01 -7.78e-01 -7.59e-01 -7.86e-01 -1.06e+00 -7.09e-01 -2.39e-01 -7.64e-01 -7.94e-01 -8.36e-01 -7.73e-01 -8.21e-01 -8.29e-01 -8.06e-01 -7.74e-01 -7.69e-01 -7.48e-01 -7.26e-01 -7.70e-01 -1.04e+00 -5.38e-01 -1.72e-01 -7.68e-01 -7.86e-01 -7.98e-01 -7.72e-01 -8.10e-01 -7.96e-01 -7.80e-01 -7.69e-01 -7.86e-01 -7.59e-01 -7.61e-01 -7.80e-01 -1.02e+00 -4.87e-01 -1.43e-01 -7.60e-01 -7.84e-01 -7.88e-01 -8.10e-01 -7.80e-01 -7.87e-01 -7.60e-01 -7.40e-01 -7.18e-01 -7.35e-01 -7.48e-01 -7.57e-01 -1.06e+00 -5.45e-01 -1.46e-01 -7.56e-01 -7.71e-01 -7.41e-01 -7.88e-01 -7.68e-01 -7.62e-01 -7.57e-01 -7.22e-01 -7.18e-01 -7.13e-01 -7.27e-01 -7.54e-01 -9.95e-01 -6.13e-01 -1.70e-01 -7.39e-01 -7.50e-01 -7.74e-01 -7.93e-01 -7.34e-01 -7.32e-01 -6.83e-01 -7.01e-01 -7.06e-01 -7.36e-01 -7.12e-01 -7.25e-01 -9.34e-01 -5.51e-01 -1.95e-01 -7.17e-01 -7.39e-01 -7.59e-01 -7.62e-01 -7.78e-01 -7.43e-01 -6.89e-01 -6.89e-01 -6.69e-01 -6.52e-01 -6.30e-01 -6.68e-01 -9.23e-01 -4.29e-01 -1.22e-01 -7.39e-01 -7.23e-01 -7.35e-01 -7.50e-01 -7.65e-01 -7.07e-01 -6.87e-01 -6.74e-01 -6.35e-01 -6.34e-01 -6.14e-01 -6.22e-01 -7.74e-01 -4.07e-01 -1.43e-01 -7.20e-01 -7.36e-01 -7.25e-01 -7.20e-01 -7.27e-01 -7.02e-01 -7.08e-01 -6.86e-01 -6.37e-01 -6.43e-01 -5.84e-01 -6.05e-01 -8.14e-01 -2.50e-01 -7.65e-02 -7.35e-01 -7.38e-01 -7.34e-01 -7.63e-01 -7.24e-01 -7.52e-01 -7.60e-01 -7.35e-01 -6.72e-01 -6.44e-01 -6.12e-01 -5.65e-01 -6.76e-01 -2.27e-01 -7.04e-02 -1.03e+00 -9.44e-01 -9.23e-01 -1.03e+00 -1.07e+00 -1.05e+00 -9.55e-01 -9.95e-01 -9.86e-01 -8.94e-01 -8.68e-01 -7.36e-01 -3.85e-01 -9.70e-02 -3.48e-02 -8.54e-01 -4.54e-01 -5.88e-01 -6.14e-01 -6.53e-01 -6.43e-01 -5.10e-01 -6.95e-01 -5.75e-01 -3.80e-01 -4.09e-01 -2.64e-01 -1.34e-01 -5.20e-02 -1.59e-02 -2.77e-01 -1.44e-01 -1.76e-01 -1.86e-01 -2.54e-01 -2.23e-01 -1.61e-01 -2.31e-01 -1.97e-01 -1.30e-01 -1.16e-01 -6.26e-02 -4.81e-02 -3.06e-02 -1.67e-02 -7.86e-01 -8.39e-01 -8.82e-01 -8.55e-01 -8.50e-01 -8.79e-01 -8.60e-01 -8.12e-01 -8.09e-01 -7.89e-01 -7.90e-01 -7.42e-01 -7.44e-01 -1.58e-01 -6.48e-02 -8.67e-01 -8.89e-01 -8.72e-01 -8.03e-01 -7.98e-01 -8.19e-01 -8.35e-01 -8.10e-01 -7.91e-01 -7.79e-01 -7.97e-01 -7.65e-01 -8.12e-01 -2.69e-01 -1.15e-01 -8.28e-01 -8.91e-01 -8.28e-01 -8.22e-01 -8.14e-01 -8.56e-01 -8.86e-01 -8.46e-01 -7.76e-01 -7.84e-01 -7.49e-01 -8.31e-01 -1.07e+00 -4.88e-01 -1.30e-01 -8.26e-01 -8.49e-01 -8.39e-01 -8.27e-01 -8.44e-01 -8.70e-01 -8.88e-01 -8.04e-01 -8.19e-01 -7.85e-01 -7.20e-01 -7.52e-01 -9.62e-01 -4.26e-01 -1.46e-01 -8.01e-01 -7.89e-01 -8.03e-01 -8.28e-01 -8.39e-01 -8.53e-01 -8.18e-01 -8.07e-01 -8.12e-01 -8.02e-01 -7.19e-01 -7.09e-01 -9.85e-01 -5.13e-01 -1.40e-01 -7.74e-01 -8.11e-01 -7.91e-01 -8.10e-01 -8.13e-01 -8.20e-01 -7.99e-01 -7.62e-01 -7.73e-01 -7.84e-01 -7.21e-01 -7.04e-01 -9.41e-01 -4.52e-01 -1.46e-01 -7.47e-01 -7.56e-01 -8.11e-01 -8.22e-01 -8.04e-01 -7.79e-01 -7.83e-01 -7.46e-01 -7.28e-01 -7.40e-01 -7.25e-01 -7.07e-01 -8.17e-01 -4.63e-01 -1.62e-01 -7.58e-01 -7.56e-01 -7.60e-01 -7.96e-01 -7.87e-01 -7.69e-01 -7.75e-01 -7.58e-01 -7.39e-01 -7.10e-01 -7.14e-01 -7.27e-01 -9.10e-01 -3.49e-01 -1.16e-01 -7.76e-01 -7.69e-01 -7.90e-01 -7.93e-01 -7.91e-01 -8.11e-01 -7.48e-01 -7.33e-01 -7.10e-01 -7.10e-01 -6.65e-01 -6.83e-01 -8.72e-01 -3.27e-01 -1.09e-01 -7.58e-01 -7.27e-01 -8.00e-01 -7.89e-01 -7.90e-01 -7.69e-01 -7.48e-01 -6.87e-01 -6.49e-01 -6.32e-01 -6.50e-01 -6.16e-01 -8.53e-01 -3.55e-01 -1.26e-01 -7.12e-01 -7.03e-01 -7.35e-01 -7.34e-01 -7.90e-01 -7.42e-01 -6.78e-01 -6.75e-01 -6.64e-01 -6.43e-01 -5.93e-01 -5.68e-01 -7.24e-01 -2.12e-01 -6.37e-02 -7.13e-01 -6.99e-01 -7.21e-01 -7.24e-01 -7.11e-01 -6.84e-01 -7.09e-01 -7.37e-01 -6.65e-01 -6.48e-01 -5.74e-01 -5.37e-01 -6.18e-01 -1.95e-01 -5.93e-02 -9.23e-01 -8.49e-01 -8.63e-01 -9.07e-01 -8.87e-01 -8.82e-01 -8.74e-01 -9.65e-01 -9.71e-01 -7.90e-01 -7.23e-01 -6.21e-01 -3.58e-01 -1.02e-01 -3.58e-02 -6.33e-01 -3.23e-01 -4.14e-01 -5.18e-01 -3.93e-01 -3.93e-01 -3.52e-01 -3.37e-01 -5.09e-01 -3.80e-01 -2.69e-01 -2.08e-01 -1.27e-01 -3.00e-02 -9.83e-03 -2.53e-01 -1.24e-01 -1.72e-01 -1.82e-01 -1.42e-01 -1.35e-01 -1.17e-01 -1.22e-01 -1.56e-01 -1.28e-01 -7.82e-02 -7.58e-02 -4.95e-02 -1.63e-02 -7.34e-03 -1.15e+00 -1.21e+00 -1.27e+00 -1.27e+00 -1.26e+00 -1.19e+00 -1.15e+00 -1.14e+00 -1.15e+00 -1.04e+00 -1.01e+00 -1.07e+00 -8.04e-01 -1.47e-01 -3.71e-02 -1.23e+00 -1.11e+00 -1.30e+00 -1.15e+00 -1.15e+00 -1.20e+00 -1.17e+00 -1.09e+00 -1.02e+00 -1.06e+00 -9.84e-01 -9.61e-01 -9.02e-01 -2.44e-01 -7.45e-02 -1.19e+00 -1.09e+00 -1.26e+00 -1.15e+00 -1.13e+00 -1.22e+00 -1.07e+00 -1.19e+00 -1.10e+00 -1.09e+00 -1.01e+00 -9.62e-01 -1.10e+00 -4.73e-01 -1.47e-01 -1.18e+00 -1.14e+00 -1.17e+00 -1.20e+00 -1.17e+00 -1.28e+00 -1.19e+00 -1.18e+00 -1.12e+00 -1.04e+00 -9.10e-01 -8.02e-01 -9.06e-01 -2.84e-01 -8.05e-02 -1.14e+00 -1.09e+00 -1.13e+00 -1.18e+00 -1.11e+00 -1.18e+00 -1.35e+00 -1.16e+00 -1.15e+00 -1.16e+00 -1.00e+00 -7.35e-01 -7.88e-01 -3.90e-01 -1.47e-01 -1.14e+00 -1.03e+00 -1.10e+00 -1.12e+00 -1.06e+00 -1.15e+00 -1.16e+00 -1.07e+00 -1.05e+00 -1.12e+00 -9.87e-01 -8.55e-01 -8.93e-01 -3.76e-01 -1.15e-01 -1.02e+00 -1.04e+00 -1.14e+00 -1.09e+00 -1.05e+00 -1.11e+00 -1.08e+00 -1.04e+00 -8.85e-01 -1.00e+00 -9.45e-01 -7.84e-01 -8.14e-01 -2.74e-01 -8.75e-02 -1.04e+00 -1.06e+00 -1.04e+00 -1.12e+00 -1.18e+00 -1.13e+00 -1.06e+00 -1.05e+00 -9.34e-01 -9.47e-01 -9.38e-01 -8.93e-01 -6.67e-01 -1.52e-01 -5.28e-02 -1.04e+00 -1.07e+00 -1.06e+00 -1.13e+00 -1.13e+00 -1.03e+00 -1.15e+00 -1.11e+00 -9.63e-01 -1.01e+00 -9.05e-01 -8.67e-01 -8.37e-01 -2.04e-01 -6.93e-02 -1.00e+00 -1.10e+00 -1.14e+00 -1.07e+00 -1.14e+00 -1.03e+00 -1.08e+00 -9.61e-01 -8.93e-01 -8.70e-01 -8.58e-01 -8.57e-01 -8.01e-01 -2.31e-01 -7.13e-02 -9.12e-01 -9.60e-01 -1.08e+00 -1.07e+00 -1.06e+00 -1.13e+00 -9.68e-01 -8.42e-01 -8.21e-01 -7.51e-01 -7.76e-01 -7.41e-01 -5.22e-01 -2.01e-01 -7.22e-02 -7.80e-01 -7.99e-01 -9.64e-01 -9.33e-01 -9.70e-01 -1.00e+00 -1.03e+00 -9.27e-01 -8.81e-01 -7.47e-01 -6.96e-01 -6.90e-01 -5.22e-01 -1.42e-01 -5.84e-02 -6.66e-01 -7.30e-01 -8.24e-01 -7.89e-01 -8.68e-01 -8.50e-01 -6.87e-01 -9.72e-01 -9.67e-01 -8.19e-01 -6.02e-01 -5.08e-01 -3.32e-01 -9.24e-02 -4.14e-02 -3.42e-01 -2.04e-01 -2.56e-01 -3.06e-01 -2.44e-01 -2.32e-01 -1.97e-01 -2.37e-01 -4.25e-01 -2.80e-01 -1.20e-01 -1.22e-01 -6.52e-02 -2.34e-02 -1.33e-02 -1.30e-01 -6.51e-02 -9.03e-02 -9.81e-02 -7.43e-02 -7.44e-02 -7.50e-02 -7.08e-02 -1.36e-01 -1.08e-01 -5.23e-02 -3.86e-02 -2.05e-02 -1.18e-02 -4.82e-03 -1.10e+00 -1.08e+00 -1.36e+00 -9.59e-01 -1.50e+00 -1.22e+00 -1.06e+00 -1.09e+00 -9.39e-01 -8.29e-01 -5.63e-01 -6.05e-01 -5.41e-01 -1.46e-01 -4.18e-02 -1.38e+00 -9.47e-01 -1.64e+00 -1.82e+00 -1.45e+00 -1.17e+00 -9.32e-01 -9.52e-01 -7.63e-01 -6.75e-01 -6.06e-01 -5.05e-01 -4.40e-01 -1.95e-01 -6.83e-02 -1.18e+00 -1.14e+00 -1.46e+00 -1.11e+00 -8.51e-01 -1.15e+00 -9.29e-01 -9.75e-01 -8.23e-01 -7.12e-01 -8.66e-01 -6.90e-01 -3.69e-01 -2.08e-01 -1.46e-01 -1.36e+00 -1.17e+00 -1.39e+00 -1.53e+00 -1.15e+00 -1.26e+00 -1.34e+00 -1.20e+00 -1.06e+00 -8.13e-01 -6.01e-01 -4.19e-01 -2.92e-01 -1.43e-01 -6.62e-02 -1.31e+00 -9.58e-01 -1.27e+00 -1.56e+00 -1.32e+00 -1.38e+00 -1.36e+00 -1.10e+00 -9.06e-01 -8.42e-01 -7.44e-01 -3.53e-01 -2.51e-01 -1.27e-01 -6.42e-02 -1.05e+00 -8.06e-01 -1.10e+00 -1.14e+00 -7.77e-01 -8.88e-01 -1.08e+00 -7.49e-01 -6.61e-01 -8.78e-01 -7.85e-01 -5.07e-01 -2.81e-01 -1.16e-01 -7.65e-02 -7.49e-01 -9.07e-01 -1.01e+00 -1.02e+00 -8.96e-01 -9.71e-01 -9.06e-01 -7.59e-01 -6.31e-01 -5.64e-01 -4.58e-01 -3.36e-01 -1.97e-01 -1.17e-01 -7.24e-02 -5.31e-01 -7.16e-01 -8.03e-01 -7.87e-01 -9.01e-01 -9.00e-01 -6.17e-01 -6.08e-01 -4.09e-01 -3.65e-01 -4.67e-01 -3.69e-01 -1.95e-01 -1.03e-01 -4.09e-02 -5.66e-01 -6.84e-01 -8.03e-01 -1.10e+00 -8.56e-01 -7.53e-01 -5.80e-01 -7.25e-01 -5.65e-01 -5.23e-01 -4.71e-01 -3.57e-01 -2.67e-01 -9.56e-02 -3.66e-02 -4.28e-01 -7.89e-01 -1.04e+00 -7.98e-01 -6.86e-01 -4.17e-01 -5.80e-01 -6.93e-01 -5.76e-01 -4.61e-01 -4.35e-01 -3.12e-01 -2.15e-01 -1.24e-01 -3.78e-02 -4.61e-01 -5.64e-01 -7.98e-01 -5.21e-01 -7.00e-01 -6.75e-01 -5.39e-01 -5.12e-01 -4.28e-01 -2.95e-01 -3.73e-01 -3.14e-01 -1.91e-01 -1.02e-01 -4.60e-02 -3.92e-01 -3.42e-01 -5.06e-01 -4.71e-01 -4.73e-01 -6.89e-01 -5.67e-01 -3.20e-01 -3.01e-01 -2.61e-01 -2.32e-01 -2.34e-01 -1.79e-01 -4.62e-02 -1.73e-02 -1.91e-01 -2.50e-01 -3.10e-01 -2.40e-01 -2.89e-01 -4.18e-01 -3.43e-01 -3.33e-01 -2.60e-01 -2.88e-01 -2.00e-01 -1.73e-01 -1.35e-01 -4.58e-02 -1.87e-02 -8.30e-02 -9.70e-02 -1.13e-01 -8.94e-02 -1.22e-01 -1.54e-01 -1.00e-01 -1.45e-01 -1.68e-01 -1.41e-01 -7.91e-02 -5.48e-02 -3.66e-02 -1.92e-02 -9.23e-03 -6.77e-02 -3.66e-02 -4.21e-02 -4.05e-02 -4.50e-02 -5.61e-02 -2.78e-02 -4.65e-02 -7.38e-02 -6.93e-02 -3.15e-02 -1.71e-02 -1.50e-02 -7.02e-03 -2.63e-03 -3.78e-01 -3.76e-01 -5.09e-01 -3.31e-01 -5.46e-01 -4.00e-01 -3.73e-01 -3.85e-01 -3.61e-01 -2.87e-01 -1.88e-01 -1.85e-01 -1.79e-01 -1.07e-01 -3.77e-02 -5.65e-01 -2.57e-01 -5.55e-01 -7.39e-01 -6.13e-01 -4.33e-01 -3.29e-01 -2.97e-01 -2.89e-01 -2.50e-01 -1.89e-01 -1.46e-01 -1.32e-01 -8.81e-02 -4.17e-02 -4.36e-01 -3.41e-01 -5.13e-01 -4.96e-01 -2.34e-01 -4.00e-01 -3.27e-01 -2.87e-01 -2.94e-01 -2.08e-01 -3.02e-01 -2.63e-01 -1.41e-01 -5.88e-02 -6.26e-02 -4.46e-01 -3.47e-01 -5.27e-01 -6.11e-01 -3.91e-01 -4.22e-01 -4.76e-01 -4.54e-01 -4.31e-01 -3.19e-01 -2.13e-01 -1.47e-01 -9.76e-02 -5.82e-02 -2.92e-02 -5.35e-01 -3.74e-01 -4.80e-01 -5.78e-01 -5.02e-01 -4.78e-01 -5.06e-01 -3.61e-01 -3.58e-01 -2.46e-01 -2.55e-01 -1.07e-01 -6.95e-02 -4.27e-02 -2.71e-02 -3.15e-01 -2.73e-01 -3.47e-01 -3.78e-01 -2.88e-01 -2.50e-01 -3.39e-01 -2.40e-01 -2.15e-01 -2.65e-01 -2.87e-01 -2.16e-01 -1.00e-01 -4.10e-02 -2.09e-02 -3.10e-01 -2.99e-01 -3.67e-01 -3.96e-01 -2.30e-01 -2.86e-01 -3.00e-01 -2.63e-01 -2.50e-01 -1.99e-01 -1.56e-01 -1.31e-01 -7.20e-02 -3.22e-02 -3.48e-02 -1.47e-01 -2.69e-01 -2.47e-01 -2.40e-01 -2.82e-01 -3.03e-01 -1.85e-01 -1.94e-01 -1.29e-01 -1.02e-01 -1.25e-01 -1.15e-01 -5.95e-02 -5.42e-02 -4.17e-02 -1.81e-01 -2.00e-01 -2.60e-01 -3.31e-01 -3.21e-01 -2.95e-01 -1.85e-01 -2.44e-01 -2.00e-01 -1.66e-01 -1.43e-01 -1.23e-01 -1.02e-01 -4.36e-02 -1.72e-02 -1.08e-01 -2.40e-01 -3.14e-01 -3.12e-01 -2.21e-01 -1.20e-01 -1.86e-01 -2.21e-01 -2.13e-01 -1.40e-01 -1.31e-01 -1.05e-01 -5.58e-02 -6.38e-02 -3.45e-02 -1.48e-01 -2.44e-01 -2.92e-01 -1.42e-01 -2.29e-01 -1.89e-01 -1.21e-01 -1.73e-01 -1.54e-01 -1.09e-01 -1.16e-01 -8.49e-02 -6.30e-02 -4.98e-02 -4.02e-02 -1.01e-01 -1.10e-01 -1.55e-01 -1.40e-01 -1.46e-01 -2.37e-01 -1.93e-01 -1.34e-01 -9.47e-02 -8.48e-02 -7.21e-02 -7.09e-02 -7.53e-02 -2.10e-02 -7.74e-03 -8.60e-02 -8.49e-02 -1.09e-01 -1.25e-01 -9.19e-02 -1.59e-01 -1.27e-01 -1.01e-01 -6.87e-02 -9.44e-02 -5.12e-02 -5.73e-02 -5.81e-02 -1.92e-02 -6.09e-03 -2.72e-02 -4.77e-02 -4.74e-02 -3.34e-02 -5.41e-02 -7.93e-02 -6.69e-02 -7.67e-02 -9.31e-02 -5.17e-02 -5.34e-02 -3.25e-02 -1.99e-02 -1.19e-02 -1.14e-02 -2.23e-02 -2.53e-02 -2.61e-02 -2.28e-02 -2.86e-02 -5.00e-02 -3.04e-02 -2.98e-02 -5.98e-02 -4.02e-02 -2.97e-02 -1.80e-02 -6.73e-03 -4.41e-03 -7.35e-03 \ No newline at end of file diff --git a/tests/regression_tests/weightwindows_fw_cadis_mesh/test.py b/tests/regression_tests/weightwindows_fw_cadis_mesh/test.py deleted file mode 100644 index 680e9dc6d..000000000 --- a/tests/regression_tests/weightwindows_fw_cadis_mesh/test.py +++ /dev/null @@ -1,49 +0,0 @@ -import os - -import openmc -from openmc.utility_funcs import change_directory -from openmc.examples import random_ray_three_region_cube -import pytest - -from tests.testing_harness import WeightWindowPyAPITestHarness - - -class MGXSTestHarness(WeightWindowPyAPITestHarness): - def _cleanup(self): - super()._cleanup() - f = 'mgxs.h5' - if os.path.exists(f): - os.remove(f) - - -@pytest.mark.parametrize("shape", ["flat", "linear"]) -def test_weight_windows_fw_cadis_mesh(shape): - with change_directory(shape): - openmc.reset_auto_ids() - - model = random_ray_three_region_cube() - - # The base model has a resolution of 12, so we overlay - # something else for FW-CADIS - n = 15 - width = 30.0 - ww_mesh = openmc.RegularMesh() - ww_mesh.dimension = (n, n, n) - ww_mesh.lower_left = (0.0, 0.0, 0.0) - ww_mesh.upper_right = (width, width, width) - - wwg = openmc.WeightWindowGenerator( - method="fw_cadis", mesh=ww_mesh, max_realizations=model.settings.batches) - model.settings.weight_window_generators = wwg - - root = model.geometry.root_universe - model.settings.random_ray['source_region_meshes'] = [(ww_mesh, [root])] - - model.settings.particles = 750 - model.settings.batches = 30 - model.settings.inactive = 20 - - model.settings.random_ray['source_shape'] = shape - - harness = MGXSTestHarness('statepoint.30.h5', model) - harness.main() diff --git a/tests/regression_tests/weightwindows_pulse_height/__init__.py b/tests/regression_tests/weightwindows_pulse_height/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression_tests/weightwindows_pulse_height/local/inputs_true.dat b/tests/regression_tests/weightwindows_pulse_height/local/inputs_true.dat deleted file mode 100644 index 4cd24d529..000000000 --- a/tests/regression_tests/weightwindows_pulse_height/local/inputs_true.dat +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - fixed source - 100 - 5 - - - 1000000.0 1.0 - - - true - - 1 - photon - 0.0 2000000.0 - 0.01 - 0.05 - 3.0 - 10 - 1e-38 - - - 1 1 1 - -2 -2 -2 - 2 2 2 - - false - - true - true - - 50 - - - - 1 - - - 0.0 10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 150000.0 160000.0 170000.0 180000.0 190000.0 200000.0 210000.0 220000.0 230000.0 240000.0 250000.0 260000.0 270000.0 280000.0 290000.0 300000.0 310000.0 320000.0 330000.0 340000.0 350000.0 360000.0 370000.0 380000.0 390000.0 400000.0 410000.0 420000.0 430000.0 440000.0 450000.0 460000.0 470000.0 480000.0 490000.0 500000.0 510000.0 520000.0 530000.0 540000.0 550000.0 560000.0 570000.0 580000.0 590000.0 600000.0 610000.0 620000.0 630000.0 640000.0 650000.0 660000.0 670000.0 680000.0 690000.0 700000.0 710000.0 720000.0 730000.0 740000.0 750000.0 760000.0 770000.0 780000.0 790000.0 800000.0 810000.0 820000.0 830000.0 840000.0 850000.0 860000.0 870000.0 880000.0 890000.0 900000.0 910000.0 920000.0 930000.0 940000.0 950000.0 960000.0 970000.0 980000.0 990000.0 1000000.0 - - - 1 2 - pulse-height - - - diff --git a/tests/regression_tests/weightwindows_pulse_height/local/results_true.dat b/tests/regression_tests/weightwindows_pulse_height/local/results_true.dat deleted file mode 100644 index c57e8ff1c..000000000 --- a/tests/regression_tests/weightwindows_pulse_height/local/results_true.dat +++ /dev/null @@ -1,201 +0,0 @@ -tally 1: -4.140000E+00 -3.443000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -2.000000E-02 -4.000000E-04 -2.000000E-02 -4.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.000000E-02 -3.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.000000E-02 -6.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -2.000000E-02 -4.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-01 -8.600000E-03 diff --git a/tests/regression_tests/weightwindows_pulse_height/shared/inputs_true.dat b/tests/regression_tests/weightwindows_pulse_height/shared/inputs_true.dat deleted file mode 100644 index 8bb499a73..000000000 --- a/tests/regression_tests/weightwindows_pulse_height/shared/inputs_true.dat +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - fixed source - 100 - 5 - - - 1000000.0 1.0 - - - true - - 1 - photon - 0.0 2000000.0 - 0.01 - 0.05 - 3.0 - 10 - 1e-38 - - - 1 1 1 - -2 -2 -2 - 2 2 2 - - true - - true - true - - 50 - - - - 1 - - - 0.0 10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 150000.0 160000.0 170000.0 180000.0 190000.0 200000.0 210000.0 220000.0 230000.0 240000.0 250000.0 260000.0 270000.0 280000.0 290000.0 300000.0 310000.0 320000.0 330000.0 340000.0 350000.0 360000.0 370000.0 380000.0 390000.0 400000.0 410000.0 420000.0 430000.0 440000.0 450000.0 460000.0 470000.0 480000.0 490000.0 500000.0 510000.0 520000.0 530000.0 540000.0 550000.0 560000.0 570000.0 580000.0 590000.0 600000.0 610000.0 620000.0 630000.0 640000.0 650000.0 660000.0 670000.0 680000.0 690000.0 700000.0 710000.0 720000.0 730000.0 740000.0 750000.0 760000.0 770000.0 780000.0 790000.0 800000.0 810000.0 820000.0 830000.0 840000.0 850000.0 860000.0 870000.0 880000.0 890000.0 900000.0 910000.0 920000.0 930000.0 940000.0 950000.0 960000.0 970000.0 980000.0 990000.0 1000000.0 - - - 1 2 - pulse-height - - - diff --git a/tests/regression_tests/weightwindows_pulse_height/shared/results_true.dat b/tests/regression_tests/weightwindows_pulse_height/shared/results_true.dat deleted file mode 100644 index c57e8ff1c..000000000 --- a/tests/regression_tests/weightwindows_pulse_height/shared/results_true.dat +++ /dev/null @@ -1,201 +0,0 @@ -tally 1: -4.140000E+00 -3.443000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -2.000000E-02 -4.000000E-04 -2.000000E-02 -4.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -3.000000E-02 -3.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -4.000000E-02 -6.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -2.000000E-02 -4.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -2.000000E-02 -2.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -3.000000E-02 -5.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -1.000000E-02 -1.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-02 -2.000000E-04 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -0.000000E+00 -2.000000E-01 -8.600000E-03 diff --git a/tests/regression_tests/weightwindows_pulse_height/test.py b/tests/regression_tests/weightwindows_pulse_height/test.py deleted file mode 100644 index b6b49be26..000000000 --- a/tests/regression_tests/weightwindows_pulse_height/test.py +++ /dev/null @@ -1,73 +0,0 @@ -import numpy as np -import openmc -import pytest -from openmc.utility_funcs import change_directory - -from tests.testing_harness import PyAPITestHarness - - -@pytest.mark.parametrize("shared_secondary,subdir", [ - (False, "local"), - (True, "shared"), -]) -def test_weightwindows_pulse_height(shared_secondary, subdir): - with change_directory(subdir): - openmc.reset_auto_ids() - model = openmc.Model() - - # Define materials (NaI scintillator) - NaI = openmc.Material() - NaI.set_density('g/cc', 3.7) - NaI.add_element('Na', 1.0) - NaI.add_element('I', 1.0) - - model.materials = openmc.Materials([NaI]) - - # Define geometry: NaI sphere inside vacuum sphere - s1 = openmc.Sphere(r=1) - s2 = openmc.Sphere(r=2, boundary_type='vacuum') - inner_sphere = openmc.Cell(name='inner sphere', fill=NaI, region=-s1) - outer_sphere = openmc.Cell(name='outer sphere', region=+s1 & -s2) - model.geometry = openmc.Geometry([inner_sphere, outer_sphere]) - - # Define settings - model.settings.run_mode = 'fixed source' - model.settings.batches = 5 - model.settings.particles = 100 - model.settings.photon_transport = True - model.settings.shared_secondary_bank = shared_secondary - model.settings.max_history_splits = 50 - model.settings.weight_window_checkpoints = { - 'surface': True, - 'collision': True, - } - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(1e6), - particle='photon' - ) - - # Define pulse-height tally - tally = openmc.Tally(name="pht tally") - tally.scores = ['pulse-height'] - cell_filter = openmc.CellFilter(inner_sphere) - energy_filter = openmc.EnergyFilter(np.linspace(0, 1_000_000, 101)) - tally.filters = [cell_filter, energy_filter] - model.tallies = [tally] - - # Define weight windows on a simple mesh covering the geometry - ww_mesh = openmc.RegularMesh() - ww_mesh.lower_left = (-2, -2, -2) - ww_mesh.upper_right = (2, 2, 2) - ww_mesh.dimension = (1, 1, 1) - - # Single energy bin for photons - e_bnds = [0.0, 2e6] - - # Uniform weight window bounds (low enough to trigger some splitting) - lower_bounds = np.array([0.01]) - - ww = openmc.WeightWindows(ww_mesh, lower_bounds, None, 5.0, e_bnds, 'photon') - model.settings.weight_windows = [ww] - - harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() diff --git a/tests/regression_tests/white_plane/results_true.dat b/tests/regression_tests/white_plane/results_true.dat index ffb19491d..6f1d064eb 100644 --- a/tests/regression_tests/white_plane/results_true.dat +++ b/tests/regression_tests/white_plane/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.274312E+00 4.223342E-03 +2.279719E+00 5.380792E-03 diff --git a/tests/testing_harness.py b/tests/testing_harness.py index c1977556d..81527452b 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -1,4 +1,5 @@ from difflib import unified_diff +from subprocess import check_call import filecmp import glob import h5py @@ -68,7 +69,7 @@ class TestHarness: if config['mpi']: mpi_args = [config['mpiexec'], '-n', config['mpi_np']] openmc.run(openmc_exec=config['exe'], mpi_args=mpi_args, - event_based=config['event']) + event_based=config['event']) else: openmc.run(openmc_exec=config['exe'], event_based=config['event']) @@ -143,8 +144,7 @@ class TestHarness: def _cleanup(self): """Delete statepoints, tally, and test files.""" output = glob.glob('statepoint.*.h5') - output += ['tallies.out', 'tallies.forward.out'] - output += ['results_test.dat', 'summary.h5'] + output += ['tallies.out', 'results_test.dat', 'summary.h5'] output += glob.glob('volume_*.h5') for f in output: if os.path.exists(f): @@ -306,12 +306,9 @@ class PyAPITestHarness(TestHarness): else: self.execute_test() - def execute_test(self, change_dir=False): + def execute_test(self): """Build input XMLs, run OpenMC, and verify correct results.""" - base_dir = os.getcwd() if change_dir else None try: - if change_dir: - os.chdir(self.workdir) self._build_inputs() inputs = self._get_inputs() self._write_inputs(inputs) @@ -323,15 +320,10 @@ class PyAPITestHarness(TestHarness): self._compare_results() finally: self._cleanup() - if base_dir: - os.chdir(base_dir) - def update_results(self, change_dir=False): + def update_results(self): """Update results_true.dat and inputs_true.dat""" - base_dir = os.getcwd() if change_dir else None try: - if change_dir: - os.chdir(self.workdir) self._build_inputs() inputs = self._get_inputs() self._write_inputs(inputs) @@ -343,8 +335,6 @@ class PyAPITestHarness(TestHarness): self._overwrite_results() finally: self._cleanup() - if base_dir: - os.chdir(base_dir) def _build_inputs(self): """Write input XML files.""" @@ -382,8 +372,7 @@ class PyAPITestHarness(TestHarness): """Delete XMLs, statepoints, tally, and test files.""" super()._cleanup() output = ['materials.xml', 'geometry.xml', 'settings.xml', - 'tallies.xml', 'plots.xml', 'inputs_test.dat', 'model.xml', - 'collision_track.h5', 'collision_track.mcpl'] + 'tallies.xml', 'plots.xml', 'inputs_test.dat', 'model.xml'] for f in output: if os.path.exists(f): os.remove(f) @@ -401,7 +390,6 @@ class TolerantPyAPITestHarness(PyAPITestHarness): due to single precision usage (e.g., as in the random ray solver). """ - def _are_files_equal(self, actual_path, expected_path, tolerance): def isfloat(value): try: @@ -441,8 +429,7 @@ class TolerantPyAPITestHarness(PyAPITestHarness): def _compare_results(self): """Make sure the current results agree with the reference.""" - compare = self._are_files_equal( - 'results_test.dat', 'results_true.dat', 1e-6) + compare = self._are_files_equal('results_test.dat', 'results_true.dat', 1e-6) if not compare: expected = open('results_true.dat').readlines() actual = open('results_test.dat').readlines() @@ -454,43 +441,8 @@ class TolerantPyAPITestHarness(PyAPITestHarness): assert compare, 'Results do not agree' -class WeightWindowPyAPITestHarness(PyAPITestHarness): - def _get_results(self): - """Digest info in the weight window file and return as a string.""" - ww = openmc.WeightWindowsList.from_hdf5()[0] - - # Access the weight window bounds - lower_bound = ww.lower_ww_bounds - upper_bound = ww.upper_ww_bounds - - # Flatten both arrays - flattened_lower_bound = lower_bound.flatten() - flattened_upper_bound = upper_bound.flatten() - - # Convert each element to a string in scientific notation with 2 decimal places - formatted_lower_bound = [f'{x:.2e}' for x in flattened_lower_bound] - formatted_upper_bound = [f'{x:.2e}' for x in flattened_upper_bound] - - # Concatenate the formatted arrays - concatenated_strings = ["Lower Bounds"] + formatted_lower_bound + \ - ["Upper Bounds"] + formatted_upper_bound - - # Join the concatenated strings into a single string with newline characters - final_string = '\n'.join(concatenated_strings) - - # Prepend the mesh text description and return final string - return str(ww.mesh) + final_string - - def _cleanup(self): - super()._cleanup() - f = 'weight_windows.h5' - if os.path.exists(f): - os.remove(f) - - class PlotTestHarness(TestHarness): """Specialized TestHarness for running OpenMC plotting tests.""" - def __init__(self, plot_names, voxel_convert_checks=[]): super().__init__(None) self._plot_names = plot_names @@ -501,7 +453,8 @@ class PlotTestHarness(TestHarness): # Check that voxel h5 can be converted to vtk for voxel_h5_filename in self._voxel_convert_checks: - openmc.voxel_to_vtk(voxel_h5_filename) + check_call(['../../../scripts/openmc-voxel-to-vtk'] + + glob.glob(voxel_h5_filename)) def _test_output_created(self): """Make sure *.png has been created.""" @@ -538,124 +491,3 @@ class PlotTestHarness(TestHarness): outstr = sha512.hexdigest() return outstr - - -class CollisionTrackTestHarness(PyAPITestHarness): - def __init__(self, statepoint_name, model=None, inputs_true=None, workdir=None): - super().__init__(statepoint_name, model, inputs_true) - self.workdir = workdir - - def _test_output_created(self): - """Make sure collision_track.h5 has also been created.""" - if self._model.settings.collision_track: - assert os.path.exists( - "collision_track.h5" - ), "collision_track file has not been created." - - def _compare_results(self): - """Compare collision_track.h5 files.""" - if self._model.settings.collision_track: - collision_track_true = self._return_collision_track_data( - "collision_track_true.h5") - collision_track_test = self._return_collision_track_data( - "collision_track.h5") - assert collision_track_true.shape == collision_track_test.shape - np.testing.assert_allclose( - collision_track_true, collision_track_test, rtol=1e-07) - - def main(self): - """Accept commandline arguments and either run or update tests.""" - if config["build_inputs"]: - self.build_inputs() - elif config["update"]: - self.update_results(change_dir=True) - else: - self.execute_test(change_dir=True) - - def build_inputs(self): - """Build inputs.""" - base_dir = os.getcwd() - try: - os.chdir(self.workdir) - self._build_inputs() - finally: - os.chdir(base_dir) - - def _overwrite_results(self): - """Also add the 'collision_track.h5' file during overwriting.""" - if os.path.exists("collision_track.h5"): - shutil.copyfile("collision_track.h5", "collision_track_true.h5") - - def _write_results(self, results_string): - # The result file for this test are written by the OpenMC executable itself - pass - - @staticmethod - def _return_collision_track_data(filepath): - """ - Read a collision_track file and return a sorted array composed of - flattened collision records. - - Parameters - ---------- - filepath : str - Path to the collision_track file - - Returns - ------- - data : np.array - Sorted array composed of flattened collision-track records. - """ - source = openmc.read_collision_track_file(filepath) - columns = [ - source['r']['x'], - source['r']['y'], - source['r']['z'], - source['u']['x'], - source['u']['y'], - source['u']['z'], - source['E'], - source['dE'], - source['time'], - source['wgt'], - source['event_mt'], - source['delayed_group'], - source['cell_id'], - source['nuclide_id'], - source['material_id'], - source['universe_id'], - source['n_collision'], - source['particle'], - source['parent_id'], - source['progeny_id'], - ] - data = np.column_stack(columns) - - # Sort by the complete record, prioritizing stable integer identifiers - # before floating-point fields. This removes dependence on the order in - # which threads append otherwise reproducible collision records. - sort_columns = [ - source['parent_id'], - source['progeny_id'], - source['n_collision'], - source['particle'], - source['cell_id'], - source['material_id'], - source['universe_id'], - source['nuclide_id'], - source['event_mt'], - source['delayed_group'], - source['r']['x'], - source['r']['y'], - source['r']['z'], - source['u']['x'], - source['u']['y'], - source['u']['z'], - source['E'], - source['dE'], - source['time'], - source['wgt'], - ] - sorted_idx = np.lexsort(tuple(reversed(sort_columns))) - - return data[sorted_idx] diff --git a/tests/unit_tests/__init__.py b/tests/unit_tests/__init__.py index 44b5a5018..e97ab13e2 100644 --- a/tests/unit_tests/__init__.py +++ b/tests/unit_tests/__init__.py @@ -14,12 +14,3 @@ def assert_unbounded(obj): ll, ur = obj.bounding_box assert ll == pytest.approx((-np.inf, -np.inf, -np.inf)) assert ur == pytest.approx((np.inf, np.inf, np.inf)) - - -def assert_sample_mean(samples, expected_mean): - # Calculate sample standard deviation - std_dev = samples.std() / np.sqrt(samples.size - 1) - - # Means should agree within 4 sigma 99.993% of the time. Note that this is - # expected to fail about 1 out of 16,000 times - assert np.abs(expected_mean - samples.mean()) < 4*std_dev diff --git a/tests/unit_tests/dagmc/dagmc_tetrahedral_no_graveyard.h5m b/tests/unit_tests/dagmc/dagmc_tetrahedral_no_graveyard.h5m deleted file mode 100644 index 2aa72956b..000000000 Binary files a/tests/unit_tests/dagmc/dagmc_tetrahedral_no_graveyard.h5m and /dev/null differ diff --git a/tests/unit_tests/dagmc/test_convert_to_multigroup.py b/tests/unit_tests/dagmc/test_convert_to_multigroup.py deleted file mode 100644 index 57c93727e..000000000 --- a/tests/unit_tests/dagmc/test_convert_to_multigroup.py +++ /dev/null @@ -1,53 +0,0 @@ -"""Test that convert_to_multigroup works with DAGMC models without requiring -particles/batches to be set beforehand. -""" - -from pathlib import Path -import pytest -import openmc -import openmc.lib - -pytestmark = pytest.mark.skipif( - not openmc.lib._dagmc_enabled(), - reason="DAGMC CAD geometry is not enabled.") - - -def test_convert_to_multigroup_without_particles_batches(run_in_tmpdir): - """Test that convert_to_multigroup works with DAGMC model without - setting particles/batches beforehand.""" - openmc.reset_auto_ids() - - mat = openmc.Material(name="mat") - mat.add_nuclide("Fe56", 1.0) - mat.set_density("g/cm3", 7.0) - - # Use minimal tetrahedral DAGMC file - dagmc_file = Path(__file__).parent / "dagmc_tetrahedral_no_graveyard.h5m" - dagmc_univ = openmc.DAGMCUniverse(dagmc_file, auto_geom_ids=True) - bound_dagmc_univ = dagmc_univ.bounded_universe(padding_distance=1) - - # Create model WITHOUT setting particles or batches - model = openmc.Model() - model.materials = openmc.Materials([mat]) - model.geometry = openmc.Geometry(bound_dagmc_univ) - model.settings = openmc.Settings() # Note: no particles or batches set! - - model.settings.run_mode = 'fixed source' - - # Create a point source - my_source = openmc.IndependentSource() - my_source.space = openmc.stats.Point((0.25, 0.25, 0.25)) - my_source.energy = openmc.stats.delta_function(14e6) - model.settings.source = my_source - - # This should work without requiring particles/batches to be set - # convert_to_multigroup handles initialization internally using non-transport mode - model.convert_to_multigroup( - method='material_wise', - groups='CASMO-2', - particles=10, - overwrite_mgxs_library=True - ) - - # Verify the model was converted successfully - assert model.settings.energy_mode == 'multi-group' diff --git a/tests/unit_tests/dagmc/test_lost_particles.py b/tests/unit_tests/dagmc/test_lost_particles.py index 48b6cf165..502bd795e 100644 --- a/tests/unit_tests/dagmc/test_lost_particles.py +++ b/tests/unit_tests/dagmc/test_lost_particles.py @@ -57,16 +57,11 @@ def broken_dagmc_model(request): model.settings.inactive = 2 model.settings.output = {'summary': False} - # Limit max particle events to prevent particles from getting stuck in the - # implicit complement of the non-root DAGMC universe. - model.settings.max_particle_events = 100 - model.export_to_xml() return model -@pytest.mark.skip(reason="Test causes CI to hang intermittently") def test_lost_particles(run_in_tmpdir, broken_dagmc_model): broken_dagmc_model.export_to_xml() # ensure that particles will be lost when cell intersections can't be found @@ -75,12 +70,12 @@ def test_lost_particles(run_in_tmpdir, broken_dagmc_model): openmc.run() # run this again, but with the dagmc universe as the root unvierse - # to ensure that lost particles are still caught in this case for univ in broken_dagmc_model.geometry.get_all_universes().values(): if isinstance(univ, openmc.DAGMCUniverse): - broken_dagmc_model.geometry.root_universe = univ + broken_dagmc_model.geometry.root_unvierse = univ break broken_dagmc_model.export_to_xml() with pytest.raises(RuntimeError, match='Maximum number of lost particles has been reached.'): openmc.run() + diff --git a/tests/unit_tests/dagmc/test_model.py b/tests/unit_tests/dagmc/test_model.py deleted file mode 100644 index 5889fa542..000000000 --- a/tests/unit_tests/dagmc/test_model.py +++ /dev/null @@ -1,365 +0,0 @@ -from pathlib import Path - -import lxml.etree as ET -import numpy as np -import pytest -import openmc -import openmc.lib -from openmc.utility_funcs import change_directory - -pytestmark = pytest.mark.skipif( - not openmc.lib._dagmc_enabled(), - reason="DAGMC CAD geometry is not enabled.") - - -@pytest.fixture() -def model(request): - pitch = 1.26 - - mats = {} - mats["no-void fuel"] = openmc.Material(1, name="no-void fuel") - mats["no-void fuel"].add_nuclide("U235", 0.03) - mats["no-void fuel"].add_nuclide("U238", 0.97) - mats["no-void fuel"].add_nuclide("O16", 2.0) - mats["no-void fuel"].set_density("g/cm3", 10.0) - - mats["41"] = openmc.Material(name="41") - mats["41"].add_nuclide("H1", 2.0) - mats["41"].add_element("O", 1.0) - mats["41"].set_density("g/cm3", 1.0) - mats["41"].add_s_alpha_beta("c_H_in_H2O") - - p = Path(request.fspath).parent / "dagmc.h5m" - - daguniv = openmc.DAGMCUniverse(p, name='simple-dagmc', auto_geom_ids=True) - - lattice = openmc.RectLattice() - lattice.dimension = [2, 2] - lattice.lower_left = [-pitch, -pitch] - lattice.pitch = [pitch, pitch] - lattice.universes = [ - [daguniv, daguniv], - [daguniv, daguniv]] - - box = openmc.model.RectangularParallelepiped(-pitch, pitch, -pitch, pitch, -5, 5) - - root = openmc.Universe(cells=[openmc.Cell(region=-box, fill=lattice)]) - - settings = openmc.Settings() - settings.batches = 100 - settings.inactive = 10 - settings.particles = 1000 - - ll, ur = root.bounding_box - mat_vol = openmc.VolumeCalculation([mats["no-void fuel"]], 1000000, ll, ur) - cell_vol = openmc.VolumeCalculation(list(root.cells.values()), 1000000, ll, ur) - settings.volume_calculations = [mat_vol, cell_vol] - - model = openmc.Model() - model.materials = openmc.Materials(mats.values()) - model.geometry = openmc.Geometry(root=root) - model.settings = settings - - with change_directory(tmpdir=True): - try: - model.init_lib() - model.sync_dagmc_universes() - yield model - finally: - model.finalize_lib() - openmc.reset_auto_ids() - - -def test_dagmc_sync_cell_names(model): - dag_univ = None - for univ in model.geometry.get_all_universes().values(): - if isinstance(univ, openmc.DAGMCUniverse): - dag_univ = univ - break - - assert dag_univ is not None - - for cell_id, cell in dag_univ.cells.items(): - assert cell.name == openmc.lib.cells[cell_id].name - - assert any(cell.name == "implicit complement" - for cell in dag_univ.cells.values()) - - -def test_dagmc_add_material_override_with_id(model): - mats = {} - mats["foo"] = openmc.Material(name="foo") - mats["foo"].add_nuclide("H1", 2.0) - mats["foo"].add_element("O", 1.0) - mats["foo"].set_density("g/cm3", 1.0) - mats["foo"].add_s_alpha_beta("c_H_in_H2O") - - for univ in model.geometry.get_all_universes().values(): - if not isinstance(univ, openmc.DAGMCUniverse): - break - - cells_with_41 = [] - for cell in univ.cells.values(): - if cell.fill is None: - continue - if cell.fill.name == "41": - cells_with_41.append(cell.id) - univ.add_material_override(cell.id, mats["foo"]) - for cell_id in cells_with_41: - assert univ.cells[cell_id].fill == mats["foo"] - - -def test_dagmc_add_material_override_with_cell(model): - mats = {} - mats["foo"] = openmc.Material(name="foo") - mats["foo"].add_nuclide("H1", 2.0) - mats["foo"].add_element("O", 1.0) - mats["foo"].set_density("g/cm3", 1.0) - mats["foo"].add_s_alpha_beta("c_H_in_H2O") - - for univ in model.geometry.get_all_universes().values(): - if not isinstance(univ, openmc.DAGMCUniverse): - break - - cells_with_41 = [] - for cell in univ.cells.values(): - if cell.fill is None: - continue - if cell.fill.name == "41": - cells_with_41.append(cell.id) - univ.add_material_override(cell, mats["foo"]) - for cell_id in cells_with_41: - assert univ.cells[cell_id].fill == mats["foo"] - - -def test_model_differentiate_depletable_with_dagmc(model, run_in_tmpdir): - model.calculate_volumes() - - # Get the volume of the no-void fuel material before differentiation - volume_before = np.sum([m.volume for m in model.materials if m.name == "no-void fuel"]) - - # Differentiate the depletable materials - model.differentiate_depletable_mats(diff_volume_method="divide equally") - # Get the volume of the no-void fuel material after differentiation - volume_after = np.sum([m.volume for m in model.materials if "fuel" in m.name]) - assert np.isclose(volume_before, volume_after) - assert len(model.materials) == 4*2 +1 - - -def test_model_differentiate_with_dagmc(model): - root = model.geometry.root_universe - ll, ur = root.bounding_box - model.calculate_volumes() - # Get the volume of the no-void fuel material before differentiation - volume_before = np.sum([m.volume for m in model.materials if m.name == "no-void fuel"]) - - # Differentiate all the materials - model.differentiate_mats(depletable_only=False) - - # Get the volume of the no-void fuel material after differentiation - mat_vol = openmc.VolumeCalculation(model.materials, 1000000, ll, ur) - model.settings.volume_calculations = [mat_vol] - model.init_lib() # need to reinitialize the lib after differentiating the materials - model.calculate_volumes() - volume_after = np.sum([m.volume for m in model.materials if "fuel" in m.name]) - assert np.isclose(volume_before, volume_after) - assert len(model.materials) == 4*2 + 4 - - -def test_dagmc_xml(model): - override_mat = openmc.Material(name="41") - override_mat.add_nuclide("H1", 2.0) - override_mat.add_element("O", 1.0) - override_mat.set_density("g/cm3", 1.0) - override_mat.add_s_alpha_beta("c_H_in_H2O") - model.materials.append(override_mat) - - for univ in model.geometry.get_all_universes().values(): - if isinstance(univ, openmc.DAGMCUniverse): - dag_univ = univ - break - - dag_univ.add_material_override(5, override_mat) - - # Tesing the XML subelement generation - root = ET.Element('dagmc_universe') - dag_univ.create_xml_subelement(root) - dagmc_ele = root.find('dagmc_universe') - - assert dagmc_ele.get('id') == str(dag_univ.id) - assert dagmc_ele.get('name') == str(dag_univ.name) - assert dagmc_ele.get('filename') == str(dag_univ.filename) - assert dagmc_ele.get('auto_geom_ids') == str(dag_univ.auto_geom_ids).lower() - - assert dagmc_ele.find('material_overrides') is None - - override_elements = dagmc_ele.findall('cell') - assert len(override_elements) == len(dag_univ.cells) - xml_cells = {int(elem.get('id')): elem for elem in override_elements} - for cell_id, cell in dag_univ.cells.items(): - assert cell_id in xml_cells - xml_cell = xml_cells[cell_id] - if cell.fill_type == 'void': - assert xml_cell.get('material') == 'void' - elif cell.fill_type == 'material': - assert xml_cell.get('material') == str(cell.fill.id) - elif cell.fill_type == 'distribmat': - mat_list = xml_cell.find('material').text.split() - expected = ["void" if m is None else str(m.id) for m in cell.fill] - assert mat_list == expected - else: - pytest.fail(f"Unexpected DAGMC cell fill type: {cell.fill_type}") - - model.export_to_model_xml() - - xml_model = openmc.Model.from_model_xml() - - for univ in xml_model.geometry.get_all_universes().values(): - if isinstance(univ, openmc.DAGMCUniverse): - xml_dagmc_univ = univ - break - - assert xml_dagmc_univ.cells.keys() == dag_univ.cells.keys() - - for cell_id, cell in dag_univ.cells.items(): - xml_cell = xml_dagmc_univ.cells[cell_id] - assert xml_cell.fill_type == cell.fill_type - if cell.fill_type == 'void': - assert xml_cell.fill is None - elif cell.fill_type == 'material': - assert xml_cell.fill.id == cell.fill.id - elif cell.fill_type == 'distribmat': - xml_ids = [m.id if m is not None else None for m in xml_cell.fill] - model_ids = [m.id if m is not None else None for m in cell.fill] - assert xml_ids == model_ids - else: - pytest.fail(f"Unexpected DAGMC cell fill type: {cell.fill_type}") - - -def test_dagmc_xml_reject_fill_override(): - mats = {'1': openmc.Material(1), 'void': None} - elem = ET.fromstring( - '' - '' - '' - ) - with pytest.raises(ValueError, match="cannot specify 'fill'"): - openmc.DAGMCUniverse.from_xml_element(elem, mats) - - -def test_dagmc_xml_reject_region_override(): - mats = {'1': openmc.Material(1), 'void': None} - elem = ET.fromstring( - '' - '' - '' - ) - with pytest.raises(ValueError, match="cannot specify 'region'"): - openmc.DAGMCUniverse.from_xml_element(elem, mats) - - -def _legacy_xml(cell_overrides): - """Helper to build a with old-format .""" - inner = ''.join( - f'{mids}' - for cid, mids in cell_overrides.items() - ) - return ET.fromstring( - f'' - f'{inner}' - f'' - ) - - -def test_dagmc_xml_legacy_single_material_compat(): - mat = openmc.Material(1) - mats = {'1': mat, 'void': None} - elem = _legacy_xml({3: '1'}) - with pytest.warns(DeprecationWarning, match="deprecated"): - univ = openmc.DAGMCUniverse.from_xml_element(elem, mats) - assert 3 in univ.cells - assert univ.cells[3].fill is mat - - -def test_dagmc_xml_legacy_distribmat_compat(): - mat1, mat2 = openmc.Material(2), openmc.Material(3) - mats = {'2': mat1, '3': mat2, 'void': None} - elem = _legacy_xml({5: '2 3'}) - with pytest.warns(DeprecationWarning): - univ = openmc.DAGMCUniverse.from_xml_element(elem, mats) - assert univ.cells[5].fill_type == 'distribmat' - assert list(univ.cells[5].fill) == [mat1, mat2] - - -def test_dagmc_xml_legacy_void_compat(): - mats = {'void': None} - elem = _legacy_xml({7: 'void'}) - with pytest.warns(DeprecationWarning): - univ = openmc.DAGMCUniverse.from_xml_element(elem, mats) - assert univ.cells[7].fill_type == 'void' - - -def test_dagmc_xml_legacy_both_raises(): - mat = openmc.Material(1) - mats = {'1': mat, 'void': None} - elem = ET.fromstring( - '' - '' - '1' - '' - '' - '' - ) - with pytest.raises(ValueError, match="both"): - openmc.DAGMCUniverse.from_xml_element(elem, mats) - - -def test_dagmc_xml_legacy_deprecation_warning(): - mats = {'1': openmc.Material(1), 'void': None} - elem = _legacy_xml({3: '1'}) - with pytest.warns(DeprecationWarning): - openmc.DAGMCUniverse.from_xml_element(elem, mats) - - -def test_dagmc_xml_legacy_roundtrip(): - """Old-format XML loads correctly and re-exports using the new format.""" - mat = openmc.Material(1) - mats = {'1': mat, 'void': None} - elem = _legacy_xml({3: '1'}) - with pytest.warns(DeprecationWarning): - univ = openmc.DAGMCUniverse.from_xml_element(elem, mats) - - root = ET.Element('geometry') - univ.create_xml_subelement(root) - dagmc_elem = root.find('dagmc_universe') - - assert dagmc_elem.find('material_overrides') is None - cell_elems = dagmc_elem.findall('cell') - assert len(cell_elems) == 1 - assert int(cell_elems[0].get('id')) == 3 - assert cell_elems[0].get('material') == '1' - - -def test_dagmc_xml_temperature_roundtrip(): - mat = openmc.Material(1) - mats = {'1': mat, 'void': None} - - elem = ET.fromstring( - '' - '' - '' - ) - - dag_univ = openmc.DAGMCUniverse.from_xml_element(elem, mats) - assert dag_univ.cells[7].fill.id == 1 - assert dag_univ.cells[7].temperature == pytest.approx(825.0) - - root = ET.Element('geometry') - dag_univ.create_xml_subelement(root) - dagmc_elem = root.find('dagmc_universe') - xml_cell = dagmc_elem.find('cell') - assert xml_cell.get('temperature') == '825.0' - - dag_univ_roundtrip = openmc.DAGMCUniverse.from_xml_element(dagmc_elem, mats) - assert dag_univ_roundtrip.cells[7].fill.id == 1 - assert dag_univ_roundtrip.cells[7].temperature == pytest.approx(825.0) diff --git a/tests/unit_tests/dagmc/test_plot.py b/tests/unit_tests/dagmc/test_plot.py deleted file mode 100644 index 6ce1d79a2..000000000 --- a/tests/unit_tests/dagmc/test_plot.py +++ /dev/null @@ -1,71 +0,0 @@ -import pytest -import openmc -import openmc.lib - - -pytestmark = pytest.mark.skipif( - not openmc.lib._dagmc_enabled(), reason="DAGMC CAD geometry is not enabled." -) - -def test_plotting_dagmc_model(request): - """Test plotting a DAGMC model with OpenMC. This is different to CSG - model plotting as the path to the DAGMC file needs handling.""" - - dag_universe = openmc.DAGMCUniverse(request.path.parent / 'dagmc.h5m') - csg_with_dag_inside = dag_universe.bounded_universe() - model = openmc.Model() - model.geometry = openmc.Geometry(csg_with_dag_inside) - - for mat_name in dag_universe.material_names: - material = openmc.Material(name=mat_name) - material.add_nuclide("Fe56", 1.0) - material.set_density("g/cm3", 7.0) - model.materials.append(material) - - # putting the source at the center of the bounding box of the DAGMC - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Point(dag_universe.bounding_box.center) - ) - model.settings.batches = 10 - model.settings.particles = 50 - - model.plot() - - -def test_plotting_dagmc_universe(request): - """Test plotting a DAGMCUniverse with OpenMC. This is different to plotting - UniverseBase as the materials are not defined withing the DAGMCUniverse.""" - - dag_universe = openmc.DAGMCUniverse(request.path.parent / 'dagmc.h5m') - dag_universe.plot() - - -def test_plotting_geometry_filled_with_dagmc_universe(request): - """Test plotting a geometry with OpenMC. This is an edge case when plotting - geometry as often geometry objects don't include a DAGMCUniverse. The - inclusion of a DAGMCUniverse requires special handling for the materials.""" - - dag_universe = openmc.DAGMCUniverse(request.path.parent / 'dagmc.h5m', auto_geom_ids=True) - - sphere1 = openmc.Sphere(r=50.0) - sphere2 = openmc.Sphere(r=60.0) - sphere2 = openmc.Sphere(r=70.0, boundary_type='vacuum') - - # Adding a material to the CSG Universe to check universe materials are accounted for - csg_material = openmc.Material(name='csg_material') - csg_material.add_nuclide("H1", 1.0) - - # Adding a material with the same name as a dagmc material to check that - # the plot can handel two materials with the same name from different universes - csg_material = openmc.Material(name=dag_universe.material_names[0]) - csg_material.add_nuclide("H1", 1.0) - - cell1 = openmc.Cell(fill=dag_universe, region=-sphere1) - cell2 = openmc.Cell(fill=csg_material, region=+sphere1 & -sphere2) - - geometry = openmc.Geometry([cell1, cell2]) - geometry.plot() - - # Close plot to avoid warning - import matplotlib.pyplot as plt - plt.close() diff --git a/tests/unit_tests/mesh_to_vtk/test.py b/tests/unit_tests/mesh_to_vtk/test.py index f00aa4626..3ee6c0298 100644 --- a/tests/unit_tests/mesh_to_vtk/test.py +++ b/tests/unit_tests/mesh_to_vtk/test.py @@ -49,10 +49,7 @@ sphere_mesh = openmc.SphericalMesh( def mesh_data(mesh_dims): data = 100 * np.arange(np.prod(mesh_dims), dtype=float) - # data is returned reshaped with order 'F' to ensure that - # the resulting data is interpreted correctly by the - # write_data_to_vtk method - return data.reshape(*mesh_dims, order='F') + return data.reshape(*mesh_dims) test_data = ((reg_mesh, False, 'regular'), (rect_mesh, False, 'rectilinear'), @@ -86,6 +83,7 @@ def test_mesh_write_vtk(mesh_params, run_in_tmpdir): # check data writing def test_mesh_write_vtk_data(run_in_tmpdir): + data = {'ascending_data': mesh_data(cyl_mesh.dimension)} filename_expected = full_path('cyl-data.vtk') filename_actual = full_path('cyl-data-actual.vtk') diff --git a/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py b/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py index 366ce18ef..0b6acf5aa 100644 --- a/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py +++ b/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py @@ -90,7 +90,7 @@ def test_write_data_to_vtk(mesh, tmpdir): # kji (i changing fastest) orering is expected for input data # by using the volumes transposed as the data here, we can ensure the # normalization is happening correctly - data = mesh.volumes + data = mesh.volumes.T # RUN mesh.write_data_to_vtk(filename=filename, datasets={"label1": data, "label2": data}) @@ -131,7 +131,7 @@ def test_write_data_to_vtk_size_mismatch(mesh): mesh : openmc.StructuredMesh The mesh to test """ - right_size = mesh.n_elements + right_size = mesh.num_mesh_cells data = np.random.random(right_size + 1) # Error message has \ in to escape characters that are otherwise recognized @@ -139,7 +139,7 @@ def test_write_data_to_vtk_size_mismatch(mesh): # string when using the match argument as that uses regular expression expected_error_msg = ( fr"The size of the dataset 'label' \({len(data)}\) should be equal to " - fr"the number of mesh cells \({mesh.n_elements}\)" + fr"the number of mesh cells \({mesh.num_mesh_cells}\)" ) with pytest.raises(ValueError, match=expected_error_msg): mesh.write_data_to_vtk(filename="out.vtk", datasets={"label": data}) diff --git a/tests/unit_tests/test_cell.py b/tests/unit_tests/test_cell.py index 8d39c071b..95c8249bb 100644 --- a/tests/unit_tests/test_cell.py +++ b/tests/unit_tests/test_cell.py @@ -20,12 +20,6 @@ def test_contains(): assert (10.0, -4., 2.0) in c -def test_id(): - openmc.Cell(cell_id=0) - with pytest.raises(ValueError): - openmc.Cell(cell_id=-1) - - def test_repr(cell_with_lattice): cells, mats, univ, lattice = cell_with_lattice repr(cells[0]) # cell with distributed materials @@ -132,29 +126,6 @@ def test_temperature(cell_with_lattice): c.temperature = (300., 600., 900.) -def test_densities(cell_with_lattice): - # Make sure density propagates through universes - m = openmc.Material() - s = openmc.XPlane() - c1 = openmc.Cell(fill=m, region=+s) - c2 = openmc.Cell(fill=m, region=-s) - u1 = openmc.Universe(cells=[c1, c2]) - c = openmc.Cell(fill=u1) - - c.density = 1. - assert c1.density == 1. - assert c2.density == 1. - with pytest.raises(ValueError): - c.density = -1. - c.density = None - assert c1.density == None - assert c2.density == None - - # distributed density - cells, _, _, _ = cell_with_lattice - c = cells[0] - c.density = (1., 2., 3.) - def test_rotation(): u = openmc.Universe() c = openmc.Cell(fill=u) @@ -374,49 +345,6 @@ def test_rotation_from_xml(rotation): np.testing.assert_allclose(new_cell.rotation, cell.rotation) -def test_dagmccell_from_xml_element(): - """DAGMCCell.from_xml_element parses material, temperature, density, - and volume; rejects unsupported attributes.""" - mat = openmc.Material(1) - mat.add_nuclide('U235', 1.0) - mats = {'1': mat} - # In practice, from_xml_element is always called from DAGMCUniverse - # during XML parsing. A placeholder universe is used here so the test - # can exercise the method directly without a real DAGMC model file. - placeholder_univ = openmc.DAGMCUniverse('model.h5m') - - # material + temperature + density round-trip - xml = '' - cell = openmc.DAGMCCell.from_xml_element(ET.fromstring(xml), mats, placeholder_univ) - assert cell.id == 5 - assert cell.name == 'fuel' - assert cell.fill is mat - assert cell.density == 10.5 - assert cell.temperature == 900.0 - - # volume round-trip - xml = '' - cell = openmc.DAGMCCell.from_xml_element(ET.fromstring(xml), mats, placeholder_univ) - assert cell.volume == 42.0 - - # forbidden: region, fill, universe - for tag, val in [('region', '-1'), ('fill', '2'), ('universe', '0')]: - xml = f'' - with pytest.raises(ValueError, match=tag): - openmc.DAGMCCell.from_xml_element(ET.fromstring(xml), mats, placeholder_univ) - - # forbidden: translation, rotation - for tag, val in [('translation', '1 0 0'), ('rotation', '0 0 90')]: - xml = f'' - with pytest.raises(ValueError, match=tag): - openmc.DAGMCCell.from_xml_element(ET.fromstring(xml), mats, placeholder_univ) - - # missing material raises - xml = '' - with pytest.raises(ValueError, match='material'): - openmc.DAGMCCell.from_xml_element(ET.fromstring(xml), mats, placeholder_univ) - - def test_plot(run_in_tmpdir): zcyl = openmc.ZCylinder() c = openmc.Cell(region=-zcyl) diff --git a/tests/unit_tests/test_collision_track.py b/tests/unit_tests/test_collision_track.py deleted file mode 100644 index 96676e2cd..000000000 --- a/tests/unit_tests/test_collision_track.py +++ /dev/null @@ -1,170 +0,0 @@ -"""Test the 'collision_track' setting used to store particle information -during specified collision conditions in a file for a given simulation.""" - -import openmc -import pytest -import h5py -import numpy as np -import shutil - -from tests.testing_harness import CollisionTrackTestHarness as ctt - - -@pytest.fixture(scope="module") -def geometry(): - """Simple hydrogen sphere geometry""" - openmc.reset_auto_ids() - material = openmc.Material(name="H1") - material.add_element("H", 1.0) - sphere = openmc.Sphere(r=1.0, boundary_type="vacuum") - cell = openmc.Cell(region=-sphere, fill=material) - return openmc.Geometry([cell]) - - -@pytest.mark.parametrize( - "parameter", - [ - {"max_collisions": 200}, - {"max_collisions": 200, "reactions": ["(n,disappear)"]}, - {"max_collisions": 200, "cell_ids": [1]}, - {"max_collisions": 200, "material_ids": [1]}, - {"max_collisions": 200, "universe_ids": [1]}, - {"max_collisions": 200, "nuclides": ["H1"]}, - {"max_collisions": 200, "deposited_E_threshold": 200000.0}, - {"max_collisions": 200, "mcpl": True} - - ], - ids=str -) -def test_xml_serialization(parameter, run_in_tmpdir): - """Check that the different use cases can be written and read in XML.""" - settings = openmc.Settings() - settings.collision_track = parameter - settings.export_to_xml() - - read_settings = openmc.Settings.from_xml() - assert read_settings.collision_track == parameter - - -@pytest.fixture -def model(): - """Simple hydrogen sphere divided in two hemispheres - by a z-plane to form 2 cells.""" - openmc.reset_auto_ids() - model = openmc.Model() - - # Material - material = openmc.Material(name="H1") - material.add_element("H", 1.0) - - # Geometry - radius = 1.0 - sphere = openmc.Sphere(r=radius, boundary_type="reflective") - plane = openmc.ZPlane(0.0) - cell_1 = openmc.Cell(region=-sphere & -plane, fill=material, cell_id=1) - cell_2 = openmc.Cell(region=-sphere & +plane, fill=material, cell_id=2) - root = openmc.Universe(cells=[cell_1, cell_2]) - model.geometry = openmc.Geometry(root) - - # Settings - model.settings = openmc.Settings() - model.settings.run_mode = "fixed source" - model.settings.particles = 1 - model.settings.batches = 1 - model.settings.seed = 2 - - bounds = [-radius, -radius, -radius, radius, radius, radius] - distribution = openmc.stats.Box(bounds[:3], bounds[3:]) - model.settings.source = openmc.IndependentSource(space=distribution) - - return model - - -def test_particle_location(run_in_tmpdir, model): - """Test the location of particles with respected to the "cell_ids" - and the location x, y, z of the particle itself. the upper sphere will - have positive z component and the bottom sphere a negative z compnent. - - """ - model.settings.collision_track = { - "max_collisions": 200, - "reactions": ["elastic"], - "cell_ids": [1, 2] - } - model.run() - - with h5py.File("collision_track.h5", "r") as f: - source = f["collision_track_bank"] - - assert len(source) == 60 - - # We want to verify that the collisions happenening are in the right cells - # and the position of the particle is either positive or negative relative - # to the z plane. In this case, we track the position of the particle - # relative to the cell_id already set. - for point in source: - if point['cell_id'] == 1: - assert point['r'][2] < 0.0 # z component negative - elif point['cell_id'] == 2: - assert point["r"][2] > 0.0 # z component positive - else: - assert False - - -@pytest.mark.skipif(shutil.which("mcpl-config") is None, reason="MCPL is not available.") -def test_format_similarity(run_in_tmpdir, model): - model.settings.collision_track = {"max_collisions": 200, "reactions": ['elastic'], - "cell_ids": [1, 2], "mcpl": False} - model.run() - data_h5 = ctt._return_collision_track_data('collision_track.h5') - - model.settings.collision_track["mcpl"] = True - model.run() - data_mcpl = ctt._return_collision_track_data('collision_track.mcpl') - - assert len(data_h5) == 60 - assert len(data_mcpl) == 60 - - np.testing.assert_allclose(data_h5, data_mcpl, rtol=1e-05) - # tolerance not that low due to the strings that is saved in MCPL, - # not enough precision! - - -def test_photon_particles(run_in_tmpdir, model): - """Test that the collision track can be used to track photon particles.""" - model.settings.collision_track = {"max_collisions": 200, "cell_ids": [1, 2]} - - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box(*model.geometry.bounding_box), - energy=openmc.stats.delta_function(1e5), - particle='photon' - ) - model.run() - - with h5py.File("collision_track.h5", "r") as f: - source = f["collision_track_bank"] - - assert len(source) < 200 - - allowed_particles = (openmc.ParticleType.PHOTON, openmc.ParticleType.ELECTRON) - - for point in source: - particle_type = openmc.ParticleType(point['particle']) - assert particle_type in allowed_particles - - if particle_type == openmc.ParticleType.ELECTRON: - assert point['nuclide_id'] == 0 - - -def test_collision_track_two_threads(model, run_in_tmpdir): - # This test checks that the `max_collisions` setting is honored: - # no collisions beyond the specified limit should be recorded. - # - # The exact set of events in the capped bank is not reproducible with - # multiple threads because the bank stores whichever thread appends first - # until capacity is reached. - model.settings.collision_track = {"max_collisions": 200} - model.run(threads=2, particles=500) - - collision_track = openmc.read_collision_track_hdf5("collision_track.h5") - assert len(collision_track) == 200 diff --git a/tests/unit_tests/test_config.py b/tests/unit_tests/test_config.py index 45e6a7e5a..1d3c0f173 100644 --- a/tests/unit_tests/test_config.py +++ b/tests/unit_tests/test_config.py @@ -1,104 +1,43 @@ from collections.abc import Mapping import os -from pathlib import Path import openmc -from openmc.config import _default_config -from openmc.data import decay import pytest -@pytest.fixture(autouse=True, scope='function') -def reset_config_and_env(): - """A fixture to ensure each test has a clean config, env, and CWD.""" - original_env = dict(os.environ) - original_cwd = os.getcwd() - original_resolve_paths = openmc.config["resolve_paths"] - - # Reset environment variables that affect config - for key in ['OPENMC_CROSS_SECTIONS', 'OPENMC_MG_CROSS_SECTIONS', 'OPENMC_CHAIN_FILE']: - if key in os.environ: - del os.environ[key] - - # Re-initialize the global config object - openmc.config = _default_config() - +@pytest.fixture(autouse=True, scope='module') +def reset_config(): + config = dict(openmc.config) try: yield finally: - # Restore environment, CWD and resolve_paths - os.environ.clear() - os.environ.update(original_env) - os.chdir(original_cwd) - - # Restore config one last time for safety between modules - openmc.config = _default_config(resolve_paths=original_resolve_paths) + openmc.config.clear() + openmc.config.update(config) def test_config_basics(): assert isinstance(openmc.config, Mapping) - with pytest.warns(UserWarning): - openmc.config['cross_sections'] = '/path/to/cross_sections.xml' + for key, value in openmc.config.items(): + assert isinstance(key, str) + assert isinstance(value, os.PathLike) + + # Set and delete + openmc.config['cross_sections'] = '/path/to/cross_sections.xml' del openmc.config['cross_sections'] assert 'cross_sections' not in openmc.config assert 'OPENMC_CROSS_SECTIONS' not in os.environ - with pytest.raises(KeyError, match="Unrecognized config key: nuke"): - openmc.config['nuke'] = '/like/to/eat/bacon' - with pytest.raises(TypeError): - openmc.config['resolve_paths'] = 'not a bool' + + # Can't use any key + with pytest.raises(KeyError): + openmc.config['🐖'] = '/like/to/eat/bacon' -def test_config_path_resolution(tmp_path): - """Test path resolution logic.""" - os.chdir(tmp_path) - relative_path = Path("some/file.xml") - absolute_path = relative_path.resolve() +def test_config_set_envvar(): + openmc.config['cross_sections'] = '/path/to/cross_sections.xml' + assert os.environ['OPENMC_CROSS_SECTIONS'] == '/path/to/cross_sections.xml' - # Test with resolve_paths = True (default) - with pytest.warns(UserWarning): - openmc.config['cross_sections'] = relative_path - assert openmc.config['cross_sections'] == absolute_path - assert openmc.config['cross_sections'].is_absolute() + openmc.config['mg_cross_sections'] = '/path/to/mg_cross_sections.h5' + assert os.environ['OPENMC_MG_CROSS_SECTIONS'] == '/path/to/mg_cross_sections.h5' - # Test with resolve_paths = False - with openmc.config.patch('resolve_paths', False): - with pytest.warns(UserWarning): - openmc.config['chain_file'] = relative_path - assert openmc.config['chain_file'] == relative_path - assert not openmc.config['chain_file'].is_absolute() - - assert openmc.config['resolve_paths'] is True - - -def test_config_patch(tmp_path): - file_a = tmp_path / "a.xml"; file_a.touch() - file_b = tmp_path / "b.xml"; file_b.touch() - openmc.config['cross_sections'] = file_a - with openmc.config.patch('cross_sections', file_b): - assert openmc.config['cross_sections'] == file_b.resolve() - assert openmc.config['cross_sections'] == file_a.resolve() - -def test_config_set_envvar(tmp_path): - """Test that setting config also sets environment variables correctly.""" - os.chdir(tmp_path) - relative_path = Path("relative.xml") - with pytest.warns(UserWarning): - openmc.config['cross_sections'] = relative_path - expected_path = str(relative_path.resolve()) - assert os.environ['OPENMC_CROSS_SECTIONS'] == expected_path - - -def test_config_warning_nonexistent_path(tmp_path): - """Test that a warning is issued for a path that does not exist.""" - bad_path = tmp_path / "a/path/that/does/not/exist.xml" - with pytest.warns(UserWarning, match=f"Path '{bad_path}' does not exist."): - openmc.config['chain_file'] = bad_path - - -def test_config_chain_side_effect(tmp_path): - """Test that modifying chain_file clears decay data caches.""" - chain_file = tmp_path / "chain.xml"; chain_file.touch() - decay._DECAY_ENERGY['U235'] = (1.0, 2.0) - decay._DECAY_PHOTON_ENERGY['PU239'] = {} - openmc.config['chain_file'] = chain_file - assert not decay._DECAY_ENERGY and not decay._DECAY_PHOTON_ENERGY + openmc.config['chain_file'] = '/path/to/chain_file.xml' + assert os.environ['OPENMC_CHAIN_FILE'] == '/path/to/chain_file.xml' diff --git a/tests/unit_tests/test_cylindrical_mesh.py b/tests/unit_tests/test_cylindrical_mesh.py index 645269825..b408bc0e9 100644 --- a/tests/unit_tests/test_cylindrical_mesh.py +++ b/tests/unit_tests/test_cylindrical_mesh.py @@ -49,7 +49,6 @@ def model(): return openmc.Model(geometry=geom, settings=settings, tallies=tallies) - def test_origin_read_write_to_xml(run_in_tmpdir, model): """Tests that the origin attribute can be written and read back to XML """ @@ -64,9 +63,8 @@ def test_origin_read_write_to_xml(run_in_tmpdir, model): np.testing.assert_equal(new_mesh.origin, mesh.origin) estimators = ('tracklength', 'collision') -offset = geom_size + 0.001 -origins = set(permutations((-offset , 0, 0))) -origins |= set(permutations((offset, 0, 0))) +origins = set(permutations((-geom_size, 0, 0))) +origins |= set(permutations((geom_size, 0, 0))) test_cases = product(estimators, origins) @@ -76,9 +74,8 @@ def label(p): if isinstance(p, str): return f'estimator:{p}' - @pytest.mark.parametrize('estimator,origin', test_cases, ids=label) -def test_offset_mesh(model, estimator, origin): +def test_offset_mesh(run_in_tmpdir, model, estimator, origin): """Tests that the mesh has been moved based on tally results """ mesh = model.tallies[0].filters[0].mesh @@ -106,7 +103,6 @@ def test_offset_mesh(model, estimator, origin): else: mean[i, j, k] != 0.0 - @pytest.fixture() def void_coincident_geom_model(): """A model with many geometric boundaries coincident with mesh boundaries @@ -159,7 +155,6 @@ def _check_void_cylindrical_tally(statepoint_filename): d_r = mesh.r_grid[1] - mesh.r_grid[0] assert neutron_flux == pytest.approx(d_r) - def test_void_geom_pnt_src(run_in_tmpdir, void_coincident_geom_model): src = openmc.IndependentSource() src.space = openmc.stats.Point() diff --git a/tests/unit_tests/test_d1s.py b/tests/unit_tests/test_d1s.py deleted file mode 100644 index 49c1b3049..000000000 --- a/tests/unit_tests/test_d1s.py +++ /dev/null @@ -1,156 +0,0 @@ -from pathlib import Path -from math import exp - -import numpy as np -import pytest -import openmc -import openmc.deplete -from openmc.deplete import d1s - - -CHAIN_PATH = Path(__file__).parents[1] / "chain_ni.xml" - - -@pytest.fixture -def model(): - """Simple model with natural Ni""" - mat = openmc.Material() - mat.add_element('Ni', 1.0) - geom = openmc.Geometry([openmc.Cell(fill=mat)]) - return openmc.Model(geometry=geom) - - -def test_get_radionuclides(model): - # Check that radionuclides are correct and are unstable - chain = openmc.deplete.Chain.from_xml(CHAIN_PATH) - nuclides = d1s.get_radionuclides(model, chain) - assert sorted(nuclides) == [ - 'Co58', 'Co60', 'Co61', 'Co62', 'Co64', - 'Fe55', 'Fe59', 'Fe61', 'Ni57', 'Ni59', 'Ni63', 'Ni65' - ] - for nuc in nuclides: - assert openmc.data.half_life(nuc) is not None - - -@pytest.mark.parametrize("nuclide", ['Co60', 'Ni63', 'H3', 'Na24', 'K40']) -def test_time_correction_factors(nuclide): - # Irradiation schedule turning unit neutron source on and off - timesteps = [1.0, 1.0, 1.0] - source_rates = [1.0, 0.0, 1.0] - - # Compute expected solution - decay_rate = openmc.data.decay_constant(nuclide) - g = exp(-decay_rate) - expected = [0.0, (1 - g), (1 - g)*g, (1 - g)*(1 + g*g)] - - # Test against expected solution - tcf = d1s.time_correction_factors([nuclide], timesteps, source_rates) - assert tcf[nuclide] == pytest.approx(expected) - - # Make sure all values at first timestep and onward are positive (K40 case - # has very small decay constant that stresses this) - assert np.all(tcf[nuclide][1:] > 0.0) - - # Timesteps as a tuple - timesteps = [(1.0, 's'), (1.0, 's'), (1.0, 's')] - tcf = d1s.time_correction_factors([nuclide], timesteps, source_rates) - assert tcf[nuclide] == pytest.approx(expected) - - # Test changing units - timesteps = [1.0/60.0, 1.0/60.0, 1.0/60.0] - tcf = d1s.time_correction_factors([nuclide], timesteps, source_rates, - timestep_units='min') - assert tcf[nuclide] == pytest.approx(expected) - - -def test_prepare_tallies(model): - tally = openmc.Tally() - tally.filters = [openmc.ParticleFilter('photon')] - tally.scores = ['flux'] - model.tallies = [tally] - - # Check that prepare_tallies adds a ParentNuclideFilter - nuclides = ['Co58', 'Co60', 'Fe55'] - d1s.prepare_tallies(model, nuclides, chain_file=CHAIN_PATH) - assert tally.contains_filter(openmc.ParentNuclideFilter) - assert list(tally.filters[-1].bins) == nuclides - - # Get rid of parent nuclide filter - tally.filters.pop() - - # With no nuclides specified, filter should use get_radionuclides - radionuclides = d1s.get_radionuclides(model, CHAIN_PATH) - d1s.prepare_tallies(model, chain_file=CHAIN_PATH) - assert tally.contains_filter(openmc.ParentNuclideFilter) - assert sorted(tally.filters[-1].bins) == sorted(radionuclides) - - assert len(tally.filters) == 2 - # calling prepare_tallies twice should not add another ParentNuclideFilter - d1s.prepare_tallies(model, chain_file=CHAIN_PATH) - assert len(tally.filters) == 2 - - -def test_apply_time_correction(run_in_tmpdir): - # Make simple sphere model with elemental Ni - mat = openmc.Material() - mat.add_element('Ni', 1.0) - sphere = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(fill=mat, region=-sphere) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.run_mode = 'fixed source' - model.settings.batches = 3 - model.settings.particles = 10 - model.settings.photon_transport = True - model.settings.use_decay_photons = True - particle_filter = openmc.ParticleFilter('photon') - tally = openmc.Tally() - tally.filters = [particle_filter] - tally.scores = ['flux'] - model.tallies = [tally] - - # Prepare tallies for D1S and compute time correction factors - nuclides = d1s.prepare_tallies(model, chain_file=CHAIN_PATH) - factors = d1s.time_correction_factors(nuclides, [1.0e10], [1.0]) - - # Run OpenMC and get tally result - with openmc.config.patch('chain_file', CHAIN_PATH): - output_path = model.run() - with openmc.StatePoint(output_path) as sp: - tally = sp.tallies[tally.id] - flux = tally.mean.flatten() - - # Copy attributes from original tally - tally_filters = list(tally.filters) - tally_sum = tally.sum.copy() - tally_sum_sq = tally.sum_sq.copy() - tally_mean = tally.mean.copy() - tally_std_dev = tally.std_dev.copy() - - # Apply TCF and make sure results are consistent - result = d1s.apply_time_correction(tally, factors, sum_nuclides=False) - tcf = np.array([factors[nuc][-1] for nuc in nuclides]) - assert result.mean.flatten() == pytest.approx(tcf * flux) - - # Make sure summed results match a manual sum - result_summed = d1s.apply_time_correction(tally, factors) - assert result_summed.mean.flatten()[0] == pytest.approx(result.mean.sum()) - - # Make sure original tally is unchanged - assert tally.filters == tally_filters - assert np.all(tally.sum == tally_sum) - assert np.all(tally.sum_sq == tally_sum_sq) - assert np.all(tally.mean == tally_mean) - assert np.all(tally.std_dev == tally_std_dev) - - # Make sure various tally methods work - result.get_values() - result_summed.get_values() - result.get_reshaped_data() - result_summed.get_reshaped_data() - result.get_pandas_dataframe() - result_summed.get_pandas_dataframe() - - # The summed tally is derived, so sum/sum_sq are None - assert result_summed.sum is None - assert result_summed.sum_sq is None diff --git a/tests/unit_tests/test_data_decay.py b/tests/unit_tests/test_data_decay.py index f81f857e0..8900e7eac 100644 --- a/tests/unit_tests/test_data_decay.py +++ b/tests/unit_tests/test_data_decay.py @@ -17,22 +17,25 @@ def ufloat_close(a, b): @pytest.fixture(scope='module') -def nb90(endf_data): +def nb90(): """Nb90 decay data.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'decay', 'dec-041_Nb_090.endf') return openmc.data.Decay.from_endf(filename) @pytest.fixture(scope='module') -def ba137m(endf_data): +def ba137m(): """Ba137_m1 decay data.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'decay', 'dec-056_Ba_137m1.endf') return openmc.data.Decay.from_endf(filename) @pytest.fixture(scope='module') -def u235_yields(endf_data): +def u235_yields(): """U235 fission product yield data.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'nfy', 'nfy-092_U_235.endf') return openmc.data.FissionProductYields.from_endf(filename) @@ -100,28 +103,6 @@ def test_fpy(u235_yields): ufloat_close(thermal['I135'], ufloat(0.0292737, 0.000819663)) -def test_decay_from_endf_material(endf_data): - filename = os.path.join(endf_data, 'decay', 'dec-041_Nb_090.endf') - material = openmc.data.endf.get_evaluations(filename)[0] - - data = openmc.data.Decay.from_endf(material) - - assert data.nuclide['name'] == 'Nb90' - assert not data.nuclide['stable'] - assert len(data.modes) == 2 - - -def test_fpy_from_endf_material(endf_data): - filename = os.path.join(endf_data, 'nfy', 'nfy-092_U_235.endf') - material = openmc.data.endf.get_evaluations(filename)[0] - - data = openmc.data.FissionProductYields.from_endf(material) - - assert data.nuclide['name'] == 'U235' - assert data.energies == pytest.approx([0.0253, 500.e3, 1.4e7]) - assert 'I135' in data.cumulative[0] - - def test_sources(ba137m, nb90): # Running .sources twice should give same objects sources = ba137m.sources @@ -155,16 +136,16 @@ def test_decay_photon_energy(): with pytest.raises(DataError): openmc.data.decay_photon_energy('I135') - # Temporarily Set chain file to simple chain - with openmc.config.patch('chain_file', Path(__file__).parents[1] / 'chain_simple.xml'): + # Set chain file to simple chain + openmc.config['chain_file'] = Path(__file__).parents[1] / "chain_simple.xml" - # Check strength of I135 source and presence of specific spectral line - src = openmc.data.decay_photon_energy('I135') - assert isinstance(src, openmc.stats.Discrete) - assert src.integral() == pytest.approx(3.920996223799345e-05) - assert 1260409. in src.x + # Check strength of I135 source and presence of specific spectral line + src = openmc.data.decay_photon_energy('I135') + assert isinstance(src, openmc.stats.Discrete) + assert src.integral() == pytest.approx(3.920996223799345e-05) + assert 1260409. in src.x - # Check Xe135 source, which should be tabular - src = openmc.data.decay_photon_energy('Xe135') - assert isinstance(src, openmc.stats.Tabular) - assert src.integral() == pytest.approx(2.076506258964966e-05) + # Check Xe135 source, which should be tabular + src = openmc.data.decay_photon_energy('Xe135') + assert isinstance(src, openmc.stats.Tabular) + assert src.integral() == pytest.approx(2.076506258964966e-05) diff --git a/tests/unit_tests/test_data_dose.py b/tests/unit_tests/test_data_dose.py index 32be5eb89..348143e0b 100644 --- a/tests/unit_tests/test_data_dose.py +++ b/tests/unit_tests/test_data_dose.py @@ -22,65 +22,8 @@ def test_dose_coefficients(): assert energy[-1] == approx(10e9) assert dose[-1] == approx(699.0) - energy, dose = dose_coefficients('photon', data_source='icrp74') - assert energy[0] == approx(0.01e6) - assert dose[0] == approx(7.43*0.00653) - assert energy[-1] == approx(10.0e6) - assert dose[-1] == approx(24.0*0.990) - - energy, dose = dose_coefficients('neutron', 'LLAT', data_source='icrp74') - assert energy[0] == approx(1e-3) - assert dose[0] == approx(1.68) - assert energy[-1] == approx(20.0e6) - assert dose[-1] == approx(338.0) - - energy, dose = dose_coefficients( - 'neutron', data_source='icrp74', dose_quantity='ambient') - assert energy[0] == approx(1e-3) - assert dose[0] == approx(6.60) - assert energy[-1] == approx(20.0e6) - assert dose[-1] == approx(600) - - energy, dose = dose_coefficients( - 'photon', data_source='icrp74', dose_quantity='ambient') - assert energy[0] == approx(0.01e6) - assert dose[0] == approx(0.061) - assert energy[-1] == approx(10e6) - assert dose[-1] == approx(25.6) - # Invalid particle/geometry should raise an exception with raises(ValueError): dose_coefficients('slime', 'LAT') with raises(ValueError): dose_coefficients('neutron', 'ZZ') - with raises(ValueError): - dose_coefficients('neutron', data_source='icrp7000') - with raises(ValueError): - dose_coefficients('neutron', dose_quantity='banana') - with raises(ValueError): - dose_coefficients( - 'neutron', data_source='icrp116', dose_quantity='ambient') - with raises(ValueError): - dose_coefficients( - 'neutron', 'ISO', data_source='icrp74', dose_quantity='ambient') - with raises(ValueError) as excinfo: - dose_coefficients("photons", data_source="icrp116") - expected_particles = [ - "electron", - "helium", - "mu+", - "mu-", - "neutron", - "photon", - "photon kerma", - "pi+", - "pi-", - "positron", - "proton", - ] - expected_msg = ( - "'photons' has no effective dose data in data source icrp116. " - "Available particles for icrp116 with dose quantity effective are: " - f"{expected_particles}" - ) - assert str(excinfo.value) == expected_msg diff --git a/tests/unit_tests/test_data_kalbach_mann.py b/tests/unit_tests/test_data_kalbach_mann.py index 5d06669f7..3b837af7d 100644 --- a/tests/unit_tests/test_data_kalbach_mann.py +++ b/tests/unit_tests/test_data_kalbach_mann.py @@ -7,7 +7,6 @@ import pytest import numpy as np -import openmc from openmc.data import IncidentNeutron from openmc.data.kalbach_mann import _separation_energy, _AtomicRepresentation from openmc.data import kalbach_slope @@ -130,7 +129,7 @@ def test_kalbach_slope(): ('Hg204.h5', 'n-080_Hg_204.endf') ] ) -def test_comparison_slope_hdf5(hdf5_filename, endf_filename, endf_data): +def test_comparison_slope_hdf5(hdf5_filename, endf_filename): """Test the calculation of the Kalbach-Mann slope done by OpenMC by comparing it to HDF5 data. The test is based on the first product of MT=5 (neutron). The isotopes tested have been selected because the @@ -148,13 +147,13 @@ def test_comparison_slope_hdf5(hdf5_filename, endf_filename, endf_data): """ # HDF5 data - hdf5_directory = Path(openmc.config.get('cross_sections')).parent + hdf5_directory = Path(os.environ['OPENMC_CROSS_SECTIONS']).parent hdf5_data = IncidentNeutron.from_hdf5(hdf5_directory / hdf5_filename) hdf5_product = hdf5_data[5].products[0] hdf5_distribution = hdf5_product.distribution[0] # ENDF data - endf_directory = Path(endf_data) + endf_directory = Path(os.environ['OPENMC_ENDF_DATA']) endf_path = endf_directory / 'neutrons' / endf_filename endf_data = IncidentNeutron.from_endf(endf_path) endf_product = endf_data[5].products[0] diff --git a/tests/unit_tests/test_data_mass_attenuation.py b/tests/unit_tests/test_data_mass_attenuation.py deleted file mode 100644 index 0fe12a7db..000000000 --- a/tests/unit_tests/test_data_mass_attenuation.py +++ /dev/null @@ -1,53 +0,0 @@ -from pytest import approx, raises - -from openmc.data import mass_energy_absorption_coefficient, mass_attenuation_coefficient -from openmc.data.function import Tabulated1D - - -def test_mass_attenuation_type(): - mu = mass_attenuation_coefficient(26) # Fe - assert isinstance(mu, Tabulated1D) - - -def test_mass_attenuation_spot_values(): - # Spot checks for Fe (Z=26) against NIST data: first/last tabulated points - # and a mid-range value at 1 MeV - mu = mass_attenuation_coefficient(26) - assert mu(1e3) == approx(9085.0) - assert mu(1e6) == approx(0.05995) - assert mu(2e7) == approx(0.03224) - - -def test_mass_attenuation_caching(): - # Repeated calls with the same Z should return the identical object - mu1 = mass_attenuation_coefficient(26) - mu2 = mass_attenuation_coefficient('Fe') - assert mu1 is mu2 - - -def test_mass_attenuation_invalid_z(): - with raises(ValueError, match="Z=0"): - mass_attenuation_coefficient(0) - with raises(ValueError, match="Z=200"): - mass_attenuation_coefficient(200) - - -def test_mass_energy_absorption_type(): - # Spot checks on values from NIST tables - mu_en = mass_energy_absorption_coefficient("air") - assert isinstance(mu_en, Tabulated1D) - - -def test_mass_energy_absorption_spot_values(): - mu_en = mass_energy_absorption_coefficient("air") - assert mu_en(1e3) == approx(3.599e3) - assert mu_en(10.e3) == approx(4.742) - assert mu_en(2e7) == approx(1.311e-2) - - -def test_mass_energy_absorption_invalid(): - # Invalid material/data_source should raise an exception - with raises(ValueError): - mass_energy_absorption_coefficient("pasta") - with raises(ValueError): - mass_energy_absorption_coefficient("air", data_source="nist000") diff --git a/tests/unit_tests/test_data_misc.py b/tests/unit_tests/test_data_misc.py index 320d09eda..226d848a5 100644 --- a/tests/unit_tests/test_data_misc.py +++ b/tests/unit_tests/test_data_misc.py @@ -7,7 +7,6 @@ from pathlib import Path import numpy as np import pytest import openmc.data -from openmc.deplete import Chain, Nuclide def test_data_library(tmpdir): @@ -31,7 +30,7 @@ def test_data_library(tmpdir): assert os.path.exists(filename) new_lib = openmc.data.DataLibrary() - directory = os.path.dirname(openmc.config.get('cross_sections')) + directory = os.path.dirname(os.environ['OPENMC_CROSS_SECTIONS']) new_lib.register_file(os.path.join(directory, 'H1.h5')) assert new_lib[-1]['type'] == 'neutron' new_lib.register_file(os.path.join(directory, 'c_Zr_in_ZrH.h5')) @@ -132,11 +131,9 @@ def test_zam(): assert openmc.data.zam('Am242_m10') == (95, 242, 10) with pytest.raises(ValueError): openmc.data.zam('garbage') - with pytest.raises(ValueError): - openmc.data.zam('Am242-m1') -def test_half_life(tmp_path): +def test_half_life(): assert openmc.data.half_life('H2') is None assert openmc.data.half_life('U235') == pytest.approx(2.22102e16) assert openmc.data.half_life('Am242') == pytest.approx(57672.0) @@ -145,32 +142,3 @@ def test_half_life(tmp_path): assert openmc.data.decay_constant('U235') == pytest.approx(log(2.0)/2.22102e16) assert openmc.data.decay_constant('Am242') == pytest.approx(log(2.0)/57672.0) assert openmc.data.decay_constant('Am242_m1') == pytest.approx(log(2.0)/4449622000.0) - - # Create minimal chain with H3 and Am242 to test half-life and decay - # constant retrieval from chain file - chain = Chain() - h3 = Nuclide("H3") - h3.half_life = 1.0 - chain.add_nuclide(h3) - am242 = Nuclide("Am242") - chain.add_nuclide(am242) - - assert openmc.data.half_life('H3', chain_file=chain) == 1.0 - assert openmc.data.decay_constant('H3', chain_file=chain) == pytest.approx(log(2.0)) - - # Nuclides that are present but stable in the chain should not fall back to - # ENDF/B-VIII.0 data. - assert openmc.data.half_life('Am242', chain_file=chain) is None - assert openmc.data.decay_constant('Am242', chain_file=chain) == 0.0 - - # Nuclides missing from the chain fall back to ENDF/B-VIII.0 data. - assert openmc.data.half_life('U235', chain_file=chain) == pytest.approx(2.22102e16) - - chain_path = tmp_path / "chain.xml" - chain.export_to_xml(chain_path) - assert openmc.data.half_life('H3', chain_file=chain_path) == 1.0 - - endf_h3 = openmc.data.half_life('H3') - with openmc.config.patch('chain_file', chain_path): - assert openmc.data.half_life('H3', chain_file=None) == 1.0 - assert openmc.data.half_life('H3', chain_file=False) == endf_h3 diff --git a/tests/unit_tests/test_data_multipole.py b/tests/unit_tests/test_data_multipole.py index a58ab4865..4c2ba96d6 100644 --- a/tests/unit_tests/test_data_multipole.py +++ b/tests/unit_tests/test_data_multipole.py @@ -8,14 +8,14 @@ import openmc.data @pytest.fixture(scope='module') def u235(): - directory = pathlib.Path(openmc.config.get('cross_sections')).parent + directory = pathlib.Path(os.environ['OPENMC_CROSS_SECTIONS']).parent u235 = directory / 'wmp' / '092235.h5' return openmc.data.WindowedMultipole.from_hdf5(u235) @pytest.fixture(scope='module') def b10(): - directory = pathlib.Path(openmc.config.get('cross_sections')).parent + directory = pathlib.Path(os.environ['OPENMC_CROSS_SECTIONS']).parent b10 = directory / 'wmp' / '005010.h5' return openmc.data.WindowedMultipole.from_hdf5(b10) @@ -48,41 +48,17 @@ def test_export_to_hdf5(tmpdir, u235): assert os.path.exists(filename) -def test_from_endf(endf_data): +def test_from_endf(): + pytest.importorskip('vectfit') + endf_data = os.environ['OPENMC_ENDF_DATA'] endf_file = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') - assert openmc.data.WindowedMultipole.from_endf( - endf_file, - log=True, - # Keep the test lightweight - vf_options={ - "njoy_error": 5e-3, - "vf_pieces": 1, - "rtol": 5e-2, - "atol": 1e-3, - "orders": [8, 12], - "n_vf_iter": 6, - }, - wmp_options={"n_win": 50, "n_cf": 3, "rtol": 5e-2, "atol": 1e-3}, - ) + return openmc.data.WindowedMultipole.from_endf( + endf_file, log=True, wmp_options={"n_win": 400, "n_cf": 3}) -def test_from_endf_search(endf_data): - endf_file = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') - assert openmc.data.WindowedMultipole.from_endf( - endf_file, - log=True, - vf_options={ - "njoy_error": 5e-3, - "vf_pieces": 1, - "rtol": 5e-2, - "atol": 1e-3, - "orders": [8, 12], - "n_vf_iter": 6, - }, - wmp_options={ - "search": True, - "rtol": 5e-2, - "search_n_win": 3, - "search_cf_orders": [5, 3], - }, - ) +def test_from_endf_search(): + pytest.importorskip('vectfit') + endf_data = os.environ['OPENMC_ENDF_DATA'] + endf_file = os.path.join(endf_data, 'neutrons', 'n-095_Am_244.endf') + return openmc.data.WindowedMultipole.from_endf( + endf_file, log=True, wmp_options={"search": True, 'rtol':1e-2}) diff --git a/tests/unit_tests/test_data_neutron.py b/tests/unit_tests/test_data_neutron.py index c767f0171..c0d6a1f15 100644 --- a/tests/unit_tests/test_data_neutron.py +++ b/tests/unit_tests/test_data_neutron.py @@ -14,113 +14,128 @@ _TEMPERATURES = [300., 600., 900.] @pytest.fixture(scope='module') def pu239(): """Pu239 HDF5 data.""" - directory = os.path.dirname(openmc.config.get('cross_sections')) + directory = os.path.dirname(os.environ['OPENMC_CROSS_SECTIONS']) filename = os.path.join(directory, 'Pu239.h5') return openmc.data.IncidentNeutron.from_hdf5(filename) @pytest.fixture(scope='module') -def xe135(endf_data): +def xe135(): """Xe135 ENDF data (contains SLBW resonance range)""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-054_Xe_135.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def sm150(endf_data): +def sm150(): """Sm150 ENDF data (contains MLBW resonance range)""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-062_Sm_150.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def gd154(endf_data): +def gd154(): """Gd154 ENDF data (contains Reich Moore resonance range and reosnance covariance with LCOMP=1).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-064_Gd_154.endf') return openmc.data.IncidentNeutron.from_endf(filename, covariance=True) @pytest.fixture(scope='module') -def cl35(endf_data): +def cl35(): """Cl35 ENDF data (contains RML resonance range)""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-017_Cl_035.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def am241(endf_data): +def am241(): """Am241 ENDF data (contains Madland-Nix fission energy distribution).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-095_Am_241.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def u233(endf_data): +def u233(): """U233 ENDF data (contains Watt fission energy distribution).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-092_U_233.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def u236(endf_data): +def u236(): """U236 ENDF data (contains Watt fission energy distribution).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-092_U_236.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def na22(endf_data): +def na22(): """Na22 ENDF data (contains evaporation spectrum).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-011_Na_022.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def na23(endf_data): +def na23(): """Na23 ENDF data (contains MLBW resonance covariance with LCOMP=0).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-011_Na_023.endf') return openmc.data.IncidentNeutron.from_endf(filename, covariance=True) @pytest.fixture(scope='module') -def be9(endf_data): +def be9(): """Be9 ENDF data (contains laboratory angle-energy distribution).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-004_Be_009.endf') return openmc.data.IncidentNeutron.from_endf(filename) @pytest.fixture(scope='module') -def h2(endf_data): +def h2(): + endf_data = os.environ['OPENMC_ENDF_DATA'] endf_file = os.path.join(endf_data, 'neutrons', 'n-001_H_002.endf') return openmc.data.IncidentNeutron.from_njoy( endf_file, temperatures=_TEMPERATURES) @pytest.fixture(scope='module') -def am244(endf_data): +def am244(): + endf_data = os.environ['OPENMC_ENDF_DATA'] endf_file = os.path.join(endf_data, 'neutrons', 'n-095_Am_244.endf') return openmc.data.IncidentNeutron.from_njoy(endf_file) @pytest.fixture(scope='module') -def ti50(endf_data): +def ti50(): """Ti50 ENDF data (contains Multi-level Breit-Wigner resonance range and resonance covariance with LCOMP=1).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-022_Ti_050.endf') return openmc.data.IncidentNeutron.from_endf(filename, covariance=True) @pytest.fixture(scope='module') -def cf252(endf_data): +def cf252(): """Cf252 ENDF data (contains RM resonance covariance with LCOMP=0).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-098_Cf_252.endf') return openmc.data.IncidentNeutron.from_endf(filename, covariance=True) @pytest.fixture(scope='module') -def th232(endf_data): +def th232(): """Th232 ENDF data (contains RM resonance covariance with LCOMP=2).""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-090_Th_232.endf') return openmc.data.IncidentNeutron.from_endf(filename, covariance=True) @@ -133,28 +148,6 @@ def test_attributes(pu239): assert pu239.atomic_weight_ratio == pytest.approx(236.9986) -def test_from_endf_material(endf_data): - filename = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') - material = openmc.data.endf.get_evaluations(filename)[0] - - data = openmc.data.IncidentNeutron.from_endf(material) - - assert data.name == 'H1' - assert data.atomic_number == 1 - assert data.mass_number == 1 - assert 2 in data.reactions - - -def test_fission_energy_from_endf_material(endf_data): - filename = os.path.join(endf_data, 'neutrons', 'n-092_U_235.endf') - material = openmc.data.endf.get_evaluations(filename)[0] - neutron = openmc.data.IncidentNeutron.from_endf(material) - - data = openmc.data.FissionEnergyRelease.from_endf(material, neutron) - - assert data.fragments(0.0) > 0.0 - - def test_fission_energy(pu239): fer = pu239.fission_energy assert isinstance(fer, openmc.data.FissionEnergyRelease) @@ -289,6 +282,10 @@ def test_slbw(xe135): s = resolved.parameters.iloc[0] assert s['energy'] == pytest.approx(0.084) + xs = resolved.reconstruct([10., 30., 100.]) + assert sorted(xs.keys()) == [2, 18, 102] + assert np.all(xs[18] == 0.0) + def test_mlbw(sm150): resolved = sm150.resonances.resolved @@ -297,6 +294,10 @@ def test_mlbw(sm150): assert resolved.energy_max == pytest.approx(1570.) assert resolved.target_spin == 0.0 + xs = resolved.reconstruct([10., 100., 1000.]) + assert sorted(xs.keys()) == [2, 18, 102] + assert np.all(xs[18] == 0.0) + def test_reichmoore(gd154): res = gd154.resonances @@ -318,6 +319,7 @@ def test_reichmoore(gd154): elastic = gd154.reactions[2].xs['0K'] assert isinstance(elastic, openmc.data.ResonancesWithBackground) + assert elastic(0.0253) == pytest.approx(5.7228949796394524) def test_rml(cl35): @@ -345,6 +347,8 @@ def test_mlbw_cov_lcomp0(cf252): assert not subset.parameters.empty assert (subset.file2res.parameters['energy'] < 100).all() samples = cov.sample(1) + xs = samples[0].reconstruct([10., 100., 1000.]) + assert sorted(xs.keys()) == [2, 18, 102] def test_mlbw_cov_lcomp1(ti50): @@ -361,7 +365,9 @@ def test_mlbw_cov_lcomp1(ti50): subset = cov.subset('L', [1, 1]) assert not subset.parameters.empty assert (subset.file2res.parameters['L'] == 1).all() - cov.sample(1) + samples = cov.sample(1) + xs = samples[0].reconstruct([10., 100., 1000.]) + assert sorted(xs.keys()) == [2, 18, 102] def test_mlbw_cov_lcomp2(na23): @@ -378,7 +384,9 @@ def test_mlbw_cov_lcomp2(na23): subset = cov.subset('L', [1, 1]) assert not subset.parameters.empty assert (subset.file2res.parameters['L'] == 1).all() - cov.sample(1) + samples = cov.sample(1) + xs = samples[0].reconstruct([10., 100., 1000.]) + assert sorted(xs.keys()) == [2, 18, 102] def test_rmcov_lcomp1(gd154): @@ -395,7 +403,9 @@ def test_rmcov_lcomp1(gd154): subset = cov.subset('energy', [0, 100]) assert not subset.parameters.empty assert (subset.file2res.parameters['energy'] < 100).all() - cov.sample(1) + samples = cov.sample(1) + xs = samples[0].reconstruct([10., 100., 1000.]) + assert sorted(xs.keys()) == [2, 18, 102] def test_rmcov_lcomp2(th232): @@ -412,7 +422,9 @@ def test_rmcov_lcomp2(th232): subset = cov.subset('energy', [0, 100]) assert not subset.parameters.empty assert (subset.file2res.parameters['energy'] < 100).all() - cov.sample(1) + samples = cov.sample(1) + xs = samples[0].reconstruct([10., 100., 1000.]) + assert sorted(xs.keys()) == [2, 18, 102] def test_madland_nix(am241): @@ -460,7 +472,8 @@ def test_laboratory(be9): @needs_njoy -def test_correlated(tmpdir, endf_data): +def test_correlated(tmpdir): + endf_data = os.environ['OPENMC_ENDF_DATA'] endf_file = os.path.join(endf_data, 'neutrons', 'n-014_Si_030.endf') si30 = openmc.data.IncidentNeutron.from_njoy(endf_file, heatr=False) @@ -486,7 +499,8 @@ def test_nbody(tmpdir, h2): @needs_njoy -def test_ace_convert(run_in_tmpdir, endf_data): +def test_ace_convert(run_in_tmpdir): + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') ace_ascii = 'ace_ascii' ace_binary = 'ace_binary' @@ -520,7 +534,8 @@ def test_ace_table_types(): @needs_njoy -def test_high_temperature(endf_data): +def test_high_temperature(): + endf_data = os.environ['OPENMC_ENDF_DATA'] endf_file = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') # Ensure that from_njoy works when given a high temperature diff --git a/tests/unit_tests/test_data_photon.py b/tests/unit_tests/test_data_photon.py index aceb82c3a..010ac1f35 100644 --- a/tests/unit_tests/test_data_photon.py +++ b/tests/unit_tests/test_data_photon.py @@ -9,8 +9,9 @@ import openmc.data @pytest.fixture(scope='module') -def elements_endf(endf_data): +def elements_endf(): """Dictionary of element ENDF data indexed by atomic symbol.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] elements = {'H': 1, 'O': 8, 'Al': 13, 'Cu': 29, 'Ag': 47, 'U': 92, 'Pu': 94} data = {} for symbol, Z in elements.items(): @@ -144,32 +145,8 @@ def test_export_to_hdf5(tmpdir, element): element2.export_to_hdf5(filename, 'w') -def test_photodat_only(run_in_tmpdir, endf_data): - endf_dir = Path(endf_data) +def test_photodat_only(run_in_tmpdir): + endf_dir = Path(os.environ['OPENMC_ENDF_DATA']) photoatomic_file = endf_dir / 'photoat' / 'photoat-001_H_000.endf' data = openmc.data.IncidentPhoton.from_endf(photoatomic_file) data.export_to_hdf5('tmp.h5', 'w') - - -def test_from_endf_material(endf_data): - endf_dir = Path(endf_data) - photoatomic_file = endf_dir / 'photoat' / 'photoat-001_H_000.endf' - relaxation_file = endf_dir / 'atomic_relax' / 'atom-001_H_000.endf' - photoatomic = openmc.data.endf.get_evaluations(photoatomic_file)[0] - relaxation = openmc.data.endf.get_evaluations(relaxation_file)[0] - - data = openmc.data.IncidentPhoton.from_endf(photoatomic, relaxation) - - assert data.atomic_number == 1 - assert 502 in data.reactions - assert data.atomic_relaxation.binding_energy['K'] == pytest.approx(13.61) - - -def test_atomic_relaxation_from_endf_material(endf_data): - filename = Path(endf_data) / 'atomic_relax' / 'atom-001_H_000.endf' - material = openmc.data.endf.get_evaluations(filename)[0] - - data = openmc.data.AtomicRelaxation.from_endf(material) - - assert data.binding_energy['K'] == pytest.approx(13.61) - assert data.num_electrons['K'] == pytest.approx(1.0) diff --git a/tests/unit_tests/test_data_thermal.py b/tests/unit_tests/test_data_thermal.py index 81ed42b41..9f5a8cb40 100644 --- a/tests/unit_tests/test_data_thermal.py +++ b/tests/unit_tests/test_data_thermal.py @@ -6,8 +6,6 @@ import random import numpy as np import pytest import openmc.data -from openmc.data.thermal import _THERMAL_NAMES -from openmc.data.njoy import _THERMAL_DATA from . import needs_njoy @@ -15,7 +13,7 @@ from . import needs_njoy @pytest.fixture(scope='module') def h2o(): """H in H2O thermal scattering data.""" - directory = os.path.dirname(openmc.config.get('cross_sections')) + directory = os.path.dirname(os.environ['OPENMC_CROSS_SECTIONS']) filename = os.path.join(directory, 'c_H_in_H2O.h5') return openmc.data.ThermalScattering.from_hdf5(filename) @@ -23,14 +21,15 @@ def h2o(): @pytest.fixture(scope='module') def graphite(): """Graphite thermal scattering data.""" - directory = os.path.dirname(openmc.config.get('cross_sections')) + directory = os.path.dirname(os.environ['OPENMC_CROSS_SECTIONS']) filename = os.path.join(directory, 'c_Graphite.h5') return openmc.data.ThermalScattering.from_hdf5(filename) @pytest.fixture(scope='module') -def h2o_njoy(endf_data): +def h2o_njoy(): """H in H2O generated using NJOY.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] path_h1 = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') path_h2o = os.path.join(endf_data, 'thermal_scatt', 'tsl-HinH2O.endf') return openmc.data.ThermalScattering.from_njoy( @@ -38,15 +37,17 @@ def h2o_njoy(endf_data): @pytest.fixture(scope='module') -def hzrh(endf_data): +def hzrh(): """H in ZrH thermal scattering data.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'thermal_scatt', 'tsl-HinZrH.endf') - return openmc.data.ThermalScattering.from_endf(filename, divide_incoherent_elastic=True) + return openmc.data.ThermalScattering.from_endf(filename) @pytest.fixture(scope='module') -def hzrh_njoy(endf_data): +def hzrh_njoy(): """H in ZrH generated using NJOY.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] path_h1 = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') path_hzrh = os.path.join(endf_data, 'thermal_scatt', 'tsl-HinZrH.endf') with_endf_data = openmc.data.ThermalScattering.from_njoy( @@ -59,10 +60,11 @@ def hzrh_njoy(endf_data): @pytest.fixture(scope='module') -def sio2(endf_data): +def sio2(): """SiO2 thermal scattering data.""" + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'thermal_scatt', 'tsl-SiO2.endf') - return openmc.data.ThermalScattering.from_endf(filename, divide_incoherent_elastic=True) + return openmc.data.ThermalScattering.from_endf(filename) def test_h2o_attributes(h2o): @@ -100,7 +102,8 @@ def test_graphite_xs(graphite): assert elastic([1e-3, 1.0]) == pytest.approx([0.0, 0.62586153]) @needs_njoy -def test_graphite_njoy(endf_data): +def test_graphite_njoy(): + endf_data = os.environ['OPENMC_ENDF_DATA'] path_c0 = os.path.join(endf_data, 'neutrons', 'n-006_C_000.endf') path_gr = os.path.join(endf_data, 'thermal_scatt', 'tsl-graphite.endf') graphite = openmc.data.ThermalScattering.from_njoy( @@ -138,9 +141,10 @@ def test_continuous_dist(h2o_njoy): assert isinstance(dist, openmc.data.IncoherentInelasticAE) -def test_h2o_endf(endf_data): +def test_h2o_endf(): + endf_data = os.environ['OPENMC_ENDF_DATA'] filename = os.path.join(endf_data, 'thermal_scatt', 'tsl-HinH2O.endf') - h2o = openmc.data.ThermalScattering.from_endf(filename, divide_incoherent_elastic=True) + h2o = openmc.data.ThermalScattering.from_endf(filename) assert not h2o.elastic assert h2o.atomic_weight_ratio == pytest.approx(0.99917) assert h2o.energy_max == pytest.approx(3.99993) @@ -148,18 +152,6 @@ def test_h2o_endf(endf_data): '600K', '650K', '800K'] -def test_from_endf_material(endf_data): - filename = os.path.join(endf_data, 'thermal_scatt', 'tsl-HinH2O.endf') - material = openmc.data.endf.get_evaluations(filename)[0] - - h2o = openmc.data.ThermalScattering.from_endf( - material, divide_incoherent_elastic=True) - - assert not h2o.elastic - assert h2o.atomic_weight_ratio == pytest.approx(0.99917) - assert h2o.temperatures[0] == '294K' - - def test_hzrh_attributes(hzrh): assert hzrh.atomic_weight_ratio == pytest.approx(0.99917) assert hzrh.energy_max == pytest.approx(1.9734) @@ -272,27 +264,6 @@ def test_get_thermal_name(): assert f('boogie_monster') == 'c_boogie_monster' -def test_thermal_names_data_consistency(): - # Check that keys in _THERMAL_NAMES are also in _THERMAL_DATA - names_only = set(_THERMAL_NAMES.keys()) - set(_THERMAL_DATA.keys()) - assert not names_only, f"Keys in _THERMAL_NAMES but not in _THERMAL_DATA: {names_only}" - - # Check that keys in _THERMAL_DATA are also in _THERMAL_NAMES - data_only = set(_THERMAL_DATA.keys()) - set(_THERMAL_NAMES.keys()) - assert not data_only, f"Keys in _THERMAL_DATA but not in _THERMAL_NAMES: {data_only}" - - # Check that the name from each ThermalTuple in _THERMAL_DATA appears as - # a recognized alias in _THERMAL_NAMES for the same key - missing_aliases = [] - for key, thermal_tuple in _THERMAL_DATA.items(): - name = thermal_tuple.name - if name not in _THERMAL_NAMES[key]: - missing_aliases.append((key, name, _THERMAL_NAMES[key])) - assert not missing_aliases, ( - f"ThermalTuple names not in _THERMAL_NAMES aliases: {missing_aliases}" - ) - - @pytest.fixture def fake_mixed_elastic(): fake_tsl = openmc.data.ThermalScattering("c_D_in_7LiD", 1.9968, 4.9, [0.0253]) diff --git a/tests/unit_tests/test_deplete_activation.py b/tests/unit_tests/test_deplete_activation.py index 2f1713880..6afea8c9f 100644 --- a/tests/unit_tests/test_deplete_activation.py +++ b/tests/unit_tests/test_deplete_activation.py @@ -45,11 +45,10 @@ ENERGIES = np.logspace(log10(1e-5), log10(2e7), 100) @pytest.mark.parametrize("reaction_rate_mode,reaction_rate_opts,tolerance", [ ("direct", {}, 1e-5), - ("flux", {'energies': ENERGIES}, 0.1), + ("flux", {'energies': ENERGIES}, 0.01), ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)']}, 1e-5), ("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)'], 'nuclides': ['W186', 'H3']}, 1e-2), ]) -@pytest.mark.flaky(reruns=1) def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts, tolerance): # Determine (n.gamma) reaction rate using initial run sp = model.run() @@ -62,10 +61,11 @@ def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts w186 = openmc.deplete.Nuclide('W186') w186.add_reaction('(n,gamma)', None, 0.0, 1.0) chain.add_nuclide(w186) + chain.export_to_xml('test_chain.xml') # Create transport operator op = openmc.deplete.CoupledOperator( - model, chain, + model, 'test_chain.xml', normalization_mode="source-rate", reaction_rate_mode=reaction_rate_mode, reaction_rate_opts=reaction_rate_opts, @@ -113,11 +113,6 @@ def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts assert atoms[0] == pytest.approx(n0) assert atoms[1] / atoms[0] == pytest.approx(0.5, rel=tolerance) - # Check that material name is preserved in depletion results - step_result = results[0] - mat_from_results = step_result.get_material(f"{w.id}") - assert mat_from_results.name == 'tungsten' - def test_decay(run_in_tmpdir): """Test decay-only timesteps where no transport solve is performed""" diff --git a/tests/unit_tests/test_deplete_chain.py b/tests/unit_tests/test_deplete_chain.py index ef8cb9ef2..9753a53f7 100644 --- a/tests/unit_tests/test_deplete_chain.py +++ b/tests/unit_tests/test_deplete_chain.py @@ -54,11 +54,11 @@ def simple_chain(): @pytest.fixture(scope='module') -def endf_chain(endf_data): - endf_dir = Path(endf_data) - decay_data = (endf_dir / 'decay').glob('*.endf') - fpy_data = (endf_dir / 'nfy').glob('*.endf') - neutron_data = (endf_dir / 'neutrons').glob('*.endf') +def endf_chain(): + endf_data = Path(os.environ['OPENMC_ENDF_DATA']) + decay_data = (endf_data / 'decay').glob('*.endf') + fpy_data = (endf_data / 'nfy').glob('*.endf') + neutron_data = (endf_data / 'neutrons').glob('*.endf') return Chain.from_endf(decay_data, fpy_data, neutron_data) @@ -86,14 +86,6 @@ def test_from_endf(endf_chain): assert nuc == chain[nuc.name] -def test_unstable_nuclides(simple_chain: Chain): - assert [nuc.name for nuc in simple_chain.unstable_nuclides] == ["A", "B"] - - -def test_stable_nuclides(simple_chain: Chain): - assert [nuc.name for nuc in simple_chain.stable_nuclides] == ["H1", "C"] - - def test_from_xml(simple_chain): """Read chain_test.xml and ensure all values are correct.""" # Unfortunately, this routine touches a lot of the code, but most of @@ -246,29 +238,6 @@ def test_form_matrix(simple_chain): assert new_mat[r, c] == mat[r, c] -def test_decay_matrix(simple_chain): - """Test that decay_matrix contains only radioactive decay terms.""" - # Nuclide order: H1(0), A(1), B(2), C(3) - decay_A = log(2) / 2.36520E+04 - decay_B = log(2) / 3.29040E+04 - - expected = np.zeros((4, 4)) - expected[1, 1] = -decay_A # Loss: A decays - expected[2, 1] = decay_A * 0.6 # A -> B (branching ratio 0.6) - expected[3, 1] = decay_A * 0.4 # A -> C (branching ratio 0.4) - expected[1, 2] = decay_B # B -> A (branching ratio 1.0) - expected[2, 2] = -decay_B # Loss: B decays - - assert np.allclose(expected, simple_chain.decay_matrix.toarray()) - - -def test_decay_matrix_cached(simple_chain): - """Test that decay_matrix is lazily computed and returns the same object.""" - m1 = simple_chain.decay_matrix - m2 = simple_chain.decay_matrix - assert m1 is m2 - - def test_getitem(): """Test nuc_by_ind converter function.""" chain = Chain() @@ -333,7 +302,8 @@ def test_capture_branch_infer_ground(): # Create nuclide to be added into the chain xe136m = nuclide.Nuclide("Xe136_m1") - chain.add_nuclide(xe136m) + chain.nuclides.append(xe136m) + chain.nuclide_dict[xe136m.name] = len(chain.nuclides) - 1 chain.set_branch_ratios(infer_br, "(n,gamma)") @@ -349,7 +319,8 @@ def test_capture_branch_no_rxn(): u5m = nuclide.Nuclide("U235_m1") - chain.add_nuclide(u5m) + chain.nuclides.append(u5m) + chain.nuclide_dict[u5m.name] = len(chain.nuclides) - 1 with pytest.raises(AttributeError, match="U234"): chain.set_branch_ratios(u4br) diff --git a/tests/unit_tests/test_deplete_continue.py b/tests/unit_tests/test_deplete_continue.py deleted file mode 100644 index 1b6eac238..000000000 --- a/tests/unit_tests/test_deplete_continue.py +++ /dev/null @@ -1,114 +0,0 @@ -"""Unit tests for openmc.deplete continue run capability. - -These tests run in two steps: first a normal run and then a continue run using the previous results -""" - -import pytest -import numpy as np -import openmc.deplete - -from tests import dummy_operator - - -def test_continue(run_in_tmpdir): - """Test to ensure that a properly defined continue run works""" - # set up the problem - bundle = dummy_operator.SCHEMES['predictor'] - operator = dummy_operator.DummyOperator() - - # initial depletion - bundle.solver(operator, [1.0, 2.0], [1.0, 2.0]).integrate(write_rates=True) - - # set up continue run - prev_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - operator = dummy_operator.DummyOperator(prev_res) - - # if continue run happens, test passes - bundle.solver(operator, [1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 3.0, 4.0], - continue_timesteps=True).integrate(write_rates=True) - - final_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - - assert np.array_equal( - np.diff(final_res.get_times(time_units="s")), - [1.0, 2.0, 3.0, 4.0] - ) - - -def test_continue_continue(run_in_tmpdir): - """Test to ensure that a continue run can be continued""" - # set up the problem - bundle = dummy_operator.SCHEMES['predictor'] - operator = dummy_operator.DummyOperator() - - # initial depletion - bundle.solver(operator, [1.0, 2.0], [1.0, 2.0]).integrate(write_rates=True) - - # set up continue run - prev_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - operator = dummy_operator.DummyOperator(prev_res) - - # first continue run - bundle.solver(operator, [1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 3.0, 4.0], - continue_timesteps=True).integrate(write_rates=True) - - prev_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - # second continue run - bundle.solver(operator, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], - continue_timesteps=True).integrate() - - final_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - - assert np.array_equal( - np.diff(final_res.get_times(time_units="s")), - [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] - ) - - -def test_mismatched_initial_times(run_in_tmpdir): - """Test to ensure that a continue run with different initial steps is properly caught""" - # set up the problem - bundle = dummy_operator.SCHEMES['predictor'] - operator = dummy_operator.DummyOperator() - - # perform initial steps - bundle.solver(operator, [0.75, 0.75], [1.0, 1.0]).integrate() - - # restart - prev_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - operator = dummy_operator.DummyOperator(prev_res) - - with pytest.raises( - ValueError, - match="You are attempting to continue a run in which the previous timesteps " - "do not have the same initial timesteps as those provided to the " - "Integrator. Please make sure you are using the correct timesteps.", - ): - bundle.solver( - operator, [0.75, 0.5, 0.75], [1.0, 1.0, 1.0], continue_timesteps=True - ).integrate() - - -def test_mismatched_initial_source_rates(run_in_tmpdir): - """Test to ensure that a continue run with different initial steps is properly caught""" - # set up the problem - bundle = dummy_operator.SCHEMES['predictor'] - operator = dummy_operator.DummyOperator() - - # perform initial steps - bundle.solver(operator, [0.75, 0.75], [1.0, 1.0]).integrate() - - # restart - prev_res = openmc.deplete.Results(operator.output_dir / "depletion_results.h5") - operator = dummy_operator.DummyOperator(prev_res) - - with pytest.raises( - ValueError, - match="You are attempting to continue a run in which the previous results " - "do not have the same initial source rates, powers, or power densities " - "as those provided to the Integrator. Please make sure you are using " - "the correct powers, power densities, or source rates and previous results file.", - ): - bundle.solver( - operator, [0.75, 0.75, 0.75], [1.0, 2.0, 1.0], continue_timesteps=True - ).integrate() diff --git a/tests/unit_tests/test_deplete_coupled_operator.py b/tests/unit_tests/test_deplete_coupled_operator.py index 119a15923..fe79d621b 100644 --- a/tests/unit_tests/test_deplete_coupled_operator.py +++ b/tests/unit_tests/test_deplete_coupled_operator.py @@ -5,7 +5,7 @@ from pathlib import Path import pytest -from openmc.deplete import CoupledOperator, Chain +from openmc.deplete import CoupledOperator import openmc import numpy as np @@ -106,17 +106,15 @@ def test_diff_volume_method_match_cell(model_with_volumes): def test_diff_volume_method_divide_equally(model_with_volumes): """Tests the volumes assigned to the materials are divided equally""" - chain = Chain.from_xml(CHAIN_PATH) - operator = openmc.deplete.CoupledOperator( model=model_with_volumes, diff_burnable_mats=True, diff_volume_method='divide equally', - chain_file=chain + chain_file=CHAIN_PATH ) all_cells = list(operator.model.geometry.get_all_cells().values()) - assert all_cells[0].fill.volume == 51 - assert all_cells[1].fill.volume == 51 + assert all_cells[0].fill[0].volume == 51 + assert all_cells[1].fill[0].volume == 51 # mat2 is not depletable assert all_cells[2].fill.volume is None diff --git a/tests/unit_tests/test_deplete_cram.py b/tests/unit_tests/test_deplete_cram.py index 64cff3a8b..8987fbd7a 100644 --- a/tests/unit_tests/test_deplete_cram.py +++ b/tests/unit_tests/test_deplete_cram.py @@ -1,15 +1,12 @@ -"""Tests for cram.py. +""" Tests for cram.py Compares a few Mathematica matrix exponentials to CRAM16/CRAM48. -Tests substep accuracy against self-converged reference solutions. """ -import numpy as np -import pytest -import scipy.sparse as sp from pytest import approx -from openmc.deplete.cram import (CRAM16, CRAM48, Cram16Solver, Cram48Solver, - IPFCramSolver) +import numpy as np +import scipy.sparse as sp +from openmc.deplete.cram import CRAM16, CRAM48 def test_CRAM16(): @@ -38,63 +35,3 @@ def test_CRAM48(): z0 = np.array((0.904837418035960, 0.576799023327476)) assert z == approx(z0) - - -def test_substeps1_matches_original(): - """substeps=1 must be bitwise identical to original spsolve path.""" - x = np.array([1.0, 1.0]) - mat = sp.csr_matrix([[-1.0, 0.0], [-2.0, -3.0]]) - dt = 0.1 - - z_orig = CRAM48(mat, x, dt) - z_sub1 = CRAM48(mat, x, dt, substeps=1) - - np.testing.assert_array_equal(z_sub1, z_orig) - - -def test_substeps2_matches_two_half_steps(): - """substeps=2 must match two independent CRAM calls with dt/2.""" - x = np.array([1.0, 1.0]) - mat = sp.csr_matrix([[-1.0, 0.0], [-2.0, -3.0]]) - dt = 1.0 - - # Two manual half-steps using original spsolve path - z_half = CRAM48(mat, x, dt / 2) - z_two = CRAM48(mat, z_half, dt / 2) - - # Single call with substeps=2 - z_sub2 = CRAM48(mat, x, dt, substeps=2) - - assert z_sub2 == approx(z_two, rel=1e-12) - - -@pytest.mark.parametrize("substeps", [0, -1]) -def test_invalid_substeps(substeps): - """substeps must be a positive integer at call time.""" - x = np.array([1.0, 1.0]) - mat = sp.csr_matrix([[-1.0, 0.0], [-2.0, -3.0]]) - - with pytest.raises(ValueError, match="substeps"): - CRAM48(mat, x, 0.1, substeps=substeps) - - -def test_substeps_self_convergence(): - """Increasing substeps converges toward reference solution. - - Uses CRAM16 (alpha0 ~ 2e-16) where substep convergence is visible. - CRAM48 (alpha0 ~ 2e-47) is already near machine precision for small - systems; its correctness is verified by the other substep tests. - """ - mat = sp.csr_matrix([[-1.0, 0.0], [-2.0, -3.0]]) - x = np.array([1.0, 1.0]) - dt = 50 # lambda*dt = 50 and 150, stresses CRAM16 - - n_ref = CRAM16(mat, x, dt, substeps=128) - - prev_err = np.inf - for s in [1, 2, 4, 8, 16]: - n_s = CRAM16(mat, x, dt, substeps=s) - err = np.linalg.norm(n_s - n_ref) / np.linalg.norm(n_ref) - assert err < prev_err, \ - f"substeps={s} error {err:.2e} not less than previous {prev_err:.2e}" - prev_err = err diff --git a/tests/unit_tests/test_deplete_decay.py b/tests/unit_tests/test_deplete_decay.py index db96fcbe2..aca812560 100644 --- a/tests/unit_tests/test_deplete_decay.py +++ b/tests/unit_tests/test_deplete_decay.py @@ -20,7 +20,7 @@ def test_deplete_decay_products(run_in_tmpdir): """) # Create MicroXS object with no cross sections - micro_xs = openmc.deplete.MicroXS(np.empty((0, 0, 0)), [], []) + micro_xs = openmc.deplete.MicroXS(np.empty((0, 0)), [], []) # Create depletion operator with no reactions op = openmc.deplete.IndependentOperator.from_nuclides( @@ -40,9 +40,8 @@ def test_deplete_decay_products(run_in_tmpdir): # Get concentration of H1 and He4 results = openmc.deplete.Results('depletion_results.h5') - mat_id = op.materials[0].id - _, h1 = results.get_atoms(f"{mat_id}", "H1") - _, he4 = results.get_atoms(f"{mat_id}", "He4") + _, h1 = results.get_atoms("1", "H1") + _, he4 = results.get_atoms("1", "He4") # Since we started with 1e24 atoms of Li5, we should have 1e24 atoms of both # H1 and He4 @@ -59,7 +58,7 @@ def test_deplete_decay_step_fissionable(run_in_tmpdir): """ # Set up a pure decay operator - micro_xs = openmc.deplete.MicroXS(np.empty((0, 0, 0)), [], []) + micro_xs = openmc.deplete.MicroXS(np.empty((0, 0)), [], []) mat = openmc.Material() mat.name = 'I do not decay.' mat.add_nuclide('U238', 1.0, 'ao') @@ -79,11 +78,6 @@ def test_deplete_decay_step_fissionable(run_in_tmpdir): # Get concentration of U238. It should be unchanged since this chain has no U238 decay. results = openmc.deplete.Results('depletion_results.h5') - _, u238 = results.get_atoms(f"{mat.id}", "U238") + _, u238 = results.get_atoms("1", "U238") assert u238[1] == pytest.approx(original_atoms) - - # Check that material name is preserved in depletion results - step_result = results[0] - mat_from_results = step_result.get_material(f"{mat.id}") - assert mat_from_results.name == 'I do not decay.' diff --git a/tests/unit_tests/test_deplete_external_source_rates.py b/tests/unit_tests/test_deplete_external_source_rates.py deleted file mode 100644 index a8cf9dde5..000000000 --- a/tests/unit_tests/test_deplete_external_source_rates.py +++ /dev/null @@ -1,170 +0,0 @@ -""" Tests for ExternalSourceRates class """ - -from pathlib import Path - -import pytest -import numpy as np -import re - -import openmc -from openmc.data import AVOGADRO, atomic_mass -from openmc.deplete import CoupledOperator -from openmc.deplete.transfer_rates import ExternalSourceRates -from openmc.deplete.abc import (_SECONDS_PER_MINUTE, _SECONDS_PER_HOUR, - _SECONDS_PER_DAY, _SECONDS_PER_JULIAN_YEAR) - -CHAIN_PATH = Path(__file__).parents[1] / "chain_simple.xml" - -@pytest.fixture -def model(): - openmc.reset_auto_ids() - f = openmc.Material(name="f") - f.add_element("U", 1, enrichment=4.25) - f.add_element("O", 2) - f.set_density("g/cm3", 10.4) - - w = openmc.Material(name="w") - w.add_element("O", 1) - w.add_element("H", 2) - w.set_density("g/cm3", 1.0) - w.depletable = True - - # material just to test multiple destination material - h = openmc.Material(name="h") - h.add_element("He", 1) - h.set_density("g/cm3", 1.78e-4) - - radii = [0.42, 0.45] - f.volume = np.pi * radii[0] ** 2 - w.volume = np.pi * (radii[1]**2 - radii[0]**2) - h.volume = 1 - materials = openmc.Materials([f, w, h]) - - surf_f = openmc.Sphere(r=radii[0]) - surf_w = openmc.Sphere(r=radii[1], boundary_type='vacuum') - surf_h = openmc.Sphere(x0=10, r=1, boundary_type='vacuum') - cell_f = openmc.Cell(fill=f, region=-surf_f) - cell_w = openmc.Cell(fill=w, region=+surf_f & -surf_w) - cell_h = openmc.Cell(fill=h, region=-surf_h) - geometry = openmc.Geometry([cell_f, cell_w, cell_h]) - - settings = openmc.Settings() - settings.particles = 1000 - settings.inactive = 10 - settings.batches = 50 - - return openmc.Model(geometry, materials, settings) - - -@pytest.mark.parametrize( -"case_name, external_source_vectors, external_source_rate, timesteps", [ - ('elements', [{'U': 0.9, 'Xe': 0.1}], 1, None), - ('nuclides', [{'I135': 0.1, 'Gd156': 0.3, 'Gd157': 0.6}], 1, None), - ('nuclides_elements', [{'I135': 0.01, 'Gd156': 0.1, 'Gd157': 0.01, 'U': 0.8, - 'Xe': 0.08}], 1, None), - ('elements_nuclides', [{'U': 0.78, 'Xe': 0.1, 'I135': 0.01, 'Gd156': 0.1, - 'Gd157': 0.01}], 1, None), - ('multiple_vectors', [{'U': 1.}, {'Xe': 1}], 1, None), - ('timesteps', [{'U': 0.9, 'Xe': 0.1}], 1, [1]), - ('rates_invalid_1', [{'Gb': 1.}], 1, None), - ('rates_invalid_2', [{'Pu': 1.}], 1, None) - ]) -def test_get_set(model, case_name, external_source_vectors, external_source_rate, - timesteps): - """Tests the get/set methods""" - - op = CoupledOperator(model, CHAIN_PATH) - number_of_timesteps = 2 - transfer = ExternalSourceRates(op, model.materials, number_of_timesteps) - - if timesteps is None: - timesteps = np.arange(number_of_timesteps) - - # Test by Openmc material, material name and material id - material= [m for m in model.materials if m.depletable][0] - - for material_input in [material, material.name, material.id]: - for external_source_vector in external_source_vectors: - if case_name == 'rates_invalid_1': - with pytest.raises(ValueError, match='Gb is not a valid ' - 'nuclide or element.'): - transfer.set_external_source_rate(material_input, - external_source_vector, - external_source_rate) - elif case_name == 'rates_invalid_2': - with pytest.raises(ValueError, match='Cannot add element Pu'): - transfer.set_external_source_rate(material_input, - external_source_vector, - external_source_rate) - else: - transfer.set_external_source_rate(material_input, - external_source_vector, - external_source_rate, - timesteps=timesteps) - for component, percent in external_source_vector.items(): - split_component = re.split(r'\d+', component) - if len(split_component) == 1: - for nuc, frac in openmc.data.isotopes(component): - val = external_source_rate * percent * frac * \ - AVOGADRO / atomic_mass(nuc) - assert transfer.get_external_rate( - material_input, nuc, timesteps)[0] == pytest.approx(val) - else: - val = external_source_rate * percent * AVOGADRO / atomic_mass(component) - assert transfer.get_external_rate( - material_input, component, timesteps)[0] == pytest.approx(val) - - assert np.all(transfer.external_timesteps == timesteps) - - -@pytest.mark.parametrize("units, unit_conv", [ - ('g/s', 1), - ('g/sec', 1), - ('g/min', _SECONDS_PER_MINUTE), - ('g/minute', _SECONDS_PER_MINUTE), - ('g/h', _SECONDS_PER_HOUR), - ('g/hr', _SECONDS_PER_HOUR), - ('g/hour', _SECONDS_PER_HOUR), - ('g/d', _SECONDS_PER_DAY), - ('g/day', _SECONDS_PER_DAY), - ('g/a', _SECONDS_PER_JULIAN_YEAR), - ('g/year', _SECONDS_PER_JULIAN_YEAR), - ]) -def test_units(units, unit_conv, model): - """ Units testing""" - # create external rate Xe - components = ['Xe135', 'U235'] - external_source_rate = 1.0 - number_of_timesteps = 2 - op = CoupledOperator(model, CHAIN_PATH) - transfer = ExternalSourceRates(op, model.materials, number_of_timesteps) - timesteps = np.arange(number_of_timesteps) - - for component in components: - rate = external_source_rate * unit_conv * atomic_mass(component) / AVOGADRO - transfer.set_external_source_rate('f', {component: 1}, rate, rate_units=units) - assert transfer.get_external_rate( - 'f', component, timesteps)[0] == pytest.approx(external_source_rate) - - -def test_external_source(run_in_tmpdir, model): - """Tests external source depletion class without neither reaction rates nor - decay but only external source rates""" - # create transfer rate for U - vector = {'U235': 1} - external_source = 10 # grams - op = CoupledOperator(model, CHAIN_PATH) - integrator = openmc.deplete.PredictorIntegrator( - op, [1, 1], 0.0, timestep_units = 'd') - integrator.add_external_source_rate('f', vector, external_source/(24*3600)) - integrator.integrate() - - # Get number of U238 atoms from results - results = openmc.deplete.Results('depletion_results.h5') - _, atoms = results.get_atoms(model.materials[0], "U235") - - # Ensure number of atoms equal external source - assert atoms[1] - atoms[0] == pytest.approx( - external_source * AVOGADRO / atomic_mass('U235')) - assert atoms[2] - atoms[1] == pytest.approx( - external_source * AVOGADRO / atomic_mass('U235')) diff --git a/tests/unit_tests/test_deplete_independent_operator.py b/tests/unit_tests/test_deplete_independent_operator.py index aca83399a..9129cf064 100644 --- a/tests/unit_tests/test_deplete_independent_operator.py +++ b/tests/unit_tests/test_deplete_independent_operator.py @@ -6,8 +6,8 @@ from pathlib import Path import pytest -from openmc import Material -from openmc.deplete import IndependentOperator, MicroXS, Chain +from openmc import Material, Materials +from openmc.deplete import IndependentOperator, MicroXS CHAIN_PATH = Path(__file__).parents[1] / "chain_simple.xml" ONE_GROUP_XS = Path(__file__).parents[1] / "micro_xs_simple.csv" @@ -25,9 +25,8 @@ def test_operator_init(): 'O17': 1.7588724018066158e+19} flux = 1.0 micro_xs = MicroXS.from_csv(ONE_GROUP_XS) - chain = Chain.from_xml(CHAIN_PATH) IndependentOperator.from_nuclides( - volume, nuclides, flux, micro_xs, chain, nuc_units='atom/cm3') + volume, nuclides, flux, micro_xs, CHAIN_PATH, nuc_units='atom/cm3') fuel = Material(name="uo2") fuel.add_element("U", 1, percent_type="ao", enrichment=4.25) @@ -35,7 +34,7 @@ def test_operator_init(): fuel.set_density("g/cc", 10.4) fuel.depletable = True fuel.volume = 1 - materials = [fuel] + materials = Materials([fuel]) fluxes = [1.0] micros = [micro_xs] IndependentOperator(materials, fluxes, micros, CHAIN_PATH) @@ -48,7 +47,7 @@ def test_error_handling(): fuel.set_density("g/cc", 1) fuel.depletable = True fuel.volume = 1 - materials = [fuel] + materials = Materials([fuel]) fluxes = [1.0, 2.0] micros = [micro_xs] with pytest.raises(ValueError, match=r"The length of fluxes \(2\)"): diff --git a/tests/unit_tests/test_deplete_integrator.py b/tests/unit_tests/test_deplete_integrator.py index ec886e707..b1d2cb950 100644 --- a/tests/unit_tests/test_deplete_integrator.py +++ b/tests/unit_tests/test_deplete_integrator.py @@ -10,7 +10,6 @@ import copy from random import uniform from unittest.mock import MagicMock -import h5py import numpy as np from uncertainties import ufloat import pytest @@ -19,7 +18,7 @@ from openmc.mpi import comm from openmc.deplete import ( ReactionRates, StepResult, Results, OperatorResult, PredictorIntegrator, CECMIntegrator, CF4Integrator, CELIIntegrator, EPCRK4Integrator, - LEQIIntegrator, SICELIIntegrator, SILEQIIntegrator, cram, pool) + LEQIIntegrator, SICELIIntegrator, SILEQIIntegrator, cram) from tests import dummy_operator @@ -39,6 +38,8 @@ INTEGRATORS = [ def test_results_save(run_in_tmpdir): """Test data save module""" + stages = 3 + rng = np.random.RandomState(comm.rank) # Mock geometry @@ -59,26 +60,34 @@ def test_results_save(run_in_tmpdir): burn_list = full_burn_list[2*comm.rank: 2*comm.rank + 2] nuc_list = ["na", "nb"] - name_list = {mat: "" for mat in full_burn_list} op.get_results_info.return_value = ( - vol_dict, nuc_list, burn_list, full_burn_list, name_list) + vol_dict, nuc_list, burn_list, full_burn_list) - # Construct end-of-step concentrations - x1 = [rng.random(2), rng.random(2)] - x2 = [rng.random(2), rng.random(2)] + # Construct x + x1 = [] + x2 = [] - # Construct reaction rates + for i in range(stages): + x1.append([rng.random(2), rng.random(2)]) + x2.append([rng.random(2), rng.random(2)]) + + # Construct r r1 = ReactionRates(burn_list, ["na", "nb"], ["ra", "rb"]) r1[:] = rng.random((2, 2, 2)) - rate1 = copy.deepcopy(r1) - r2 = ReactionRates(burn_list, ["na", "nb"], ["ra", "rb"]) - r2[:] = rng.random((2, 2, 2)) - rate2 = copy.deepcopy(r2) + rate1 = [] + rate2 = [] - # Create global terms (eigenvalue and uncertainty) - eigvl1 = rng.random(2) - eigvl2 = rng.random(2) + for i in range(stages): + rate1.append(copy.deepcopy(r1)) + r1[:] = rng.random((2, 2, 2)) + rate2.append(copy.deepcopy(r1)) + r1[:] = rng.random((2, 2, 2)) + + # Create global terms + # Col 0: eig, Col 1: uncertainty + eigvl1 = rng.random((stages, 2)) + eigvl2 = rng.random((stages, 2)) eigvl1 = comm.bcast(eigvl1, root=0) eigvl2 = comm.bcast(eigvl2, root=0) @@ -86,35 +95,29 @@ def test_results_save(run_in_tmpdir): t1 = [0.0, 1.0] t2 = [1.0, 2.0] - op_result1 = OperatorResult(ufloat(*eigvl1), rate1) - op_result2 = OperatorResult(ufloat(*eigvl2), rate2) + op_result1 = [OperatorResult(ufloat(*k), rates) + for k, rates in zip(eigvl1, rate1)] + op_result2 = [OperatorResult(ufloat(*k), rates) + for k, rates in zip(eigvl2, rate2)] # saves within a subdirectory - StepResult.save( - op, - x1, - op_result1, - t1, - 0, - 0, - write_rates=True, - path='out/put/depletion.h5' - ) + StepResult.save(op, x1, op_result1, t1, 0, 0, path='out/put/depletion.h5') res = Results('out/put/depletion.h5') # saves with default filename - StepResult.save(op, x1, op_result1, t1, 0, 0, write_rates=True) - StepResult.save(op, x2, op_result2, t2, 0, 1, write_rates=True) + StepResult.save(op, x1, op_result1, t1, 0, 0) + StepResult.save(op, x2, op_result2, t2, 0, 1) # Load the files res = Results("depletion_results.h5") - for mat_i, mat in enumerate(burn_list): - for nuc_i, nuc in enumerate(nuc_list): - assert res[0][mat, nuc] == x1[mat_i][nuc_i] - assert res[1][mat, nuc] == x2[mat_i][nuc_i] - np.testing.assert_array_equal(res[0].rates, rate1) - np.testing.assert_array_equal(res[1].rates, rate2) + for i in range(stages): + for mat_i, mat in enumerate(burn_list): + for nuc_i, nuc in enumerate(nuc_list): + assert res[0][i, mat, nuc] == x1[i][mat_i][nuc_i] + assert res[1][i, mat, nuc] == x2[i][mat_i][nuc_i] + np.testing.assert_array_equal(res[0].rates[i], rate1[i]) + np.testing.assert_array_equal(res[1].rates[i], rate2[i]) np.testing.assert_array_equal(res[0].k, eigvl1) np.testing.assert_array_equal(res[0].time, t1) @@ -123,32 +126,6 @@ def test_results_save(run_in_tmpdir): np.testing.assert_array_equal(res[1].time, t2) -def test_results_save_without_rates(run_in_tmpdir): - """StepResult.save skips reaction-rate datasets by default""" - - op = MagicMock() - op.prev_res = None - vol_dict = {"0": 1.0} - nuc_list = ["na"] - burn_list = ["0"] - name_list = {mat: "" for mat in burn_list} - op.get_results_info.return_value = (vol_dict, nuc_list, burn_list, burn_list, name_list) - - x = [np.array([1.0])] - rates = ReactionRates(burn_list, nuc_list, ["ra"]) - rates[:] = np.array([[[2.0]]]) - op_result = OperatorResult(ufloat(1.0, 0.1), rates) - - StepResult.save(op, x, op_result, [0.0, 1.0], 0.0, 0) - - with h5py.File('depletion_results.h5', 'r') as handle: - assert 'reaction rates' not in handle - assert 'reactions' not in handle - - res = Results('depletion_results.h5') - assert res[0].rates.size == 0 - - def test_bad_integrator_inputs(): """Test failure modes for Integrator inputs""" @@ -183,39 +160,15 @@ def test_bad_integrator_inputs(): with pytest.raises(TypeError, match=".*callable.*NoneType"): PredictorIntegrator(op, timesteps, power=1, solver=None) - with pytest.raises(ValueError, match="four arguments"): + with pytest.raises(ValueError, match=".*arguments"): PredictorIntegrator(op, timesteps, power=1, solver=mock_bad_solver_nargs) - with pytest.raises(ValueError, match="default to 1"): - PredictorIntegrator(op, timesteps, power=1, - solver=mock_bad_solver_fourth_required) - with pytest.raises(ValueError, match="substeps"): - PredictorIntegrator(op, timesteps, power=1, substeps=0) - - with pytest.raises(ValueError, match="substeps"): - PredictorIntegrator(op, timesteps, power=1, substeps=-1) - - -def mock_good_solver(A, n, t, substeps=1): - return n.copy() - - -def mock_good_solver_substeps(A, n, t, substeps=1): - return n + substeps - - -def mock_unsupported_substeps_solver(A, n, t, substeps=1): - if substeps > 1: - raise NotImplementedError("substeps > 1 not supported") - return n.copy() - - -def mock_bad_solver_nargs(A, n): +def mock_good_solver(A, n, t): pass -def mock_bad_solver_fourth_required(A, n, t, substeps): +def mock_bad_solver_nargs(A, n): pass @@ -250,71 +203,13 @@ def test_integrator(run_in_tmpdir, scheme): integrator = bundle.solver(operator, [0.75], 1, solver="cram16") assert integrator.solver is cram.CRAM16 - integrator = bundle.solver(operator, [0.75], 1, solver=cram.Cram48Solver, - substeps=2) - assert integrator.solver is cram.Cram48Solver - assert integrator.substeps == 2 - integrator.solver = mock_good_solver assert integrator.solver is mock_good_solver - lfunc = lambda A, n, t, substeps=1: mock_good_solver(A, n, t, substeps) + lfunc = lambda A, n, t: mock_good_solver(A, n, t) integrator.solver = lfunc assert integrator.solver is lfunc - integrator.solver = mock_good_solver_substeps - assert integrator.solver is mock_good_solver_substeps - - -def test_custom_solver_with_default_substeps(monkeypatch): - operator = dummy_operator.DummyOperator() - n = operator.initial_condition() - rates = operator(n, 1.0).rates - integrator = PredictorIntegrator( - operator, [0.75], power=1.0, solver=mock_good_solver) - monkeypatch.setattr(pool, "USE_MULTIPROCESSING", False) - - _, result = integrator._timed_deplete(n, rates, 0.75) - - np.testing.assert_array_equal(result[0], n[0]) - - -def test_substep_aware_custom_solver_receives_substeps(monkeypatch): - operator = dummy_operator.DummyOperator() - n = operator.initial_condition() - rates = operator(n, 1.0).rates - integrator = PredictorIntegrator( - operator, [0.75], power=1.0, solver=mock_good_solver_substeps, - substeps=3) - monkeypatch.setattr(pool, "USE_MULTIPROCESSING", False) - - _, result = integrator._timed_deplete(n, rates, 0.75) - - np.testing.assert_array_equal(result[0], n[0] + 3) - - -def test_custom_solver_propagates_substeps_error(monkeypatch): - operator = dummy_operator.DummyOperator() - n = operator.initial_condition() - rates = operator(n, 1.0).rates - integrator = PredictorIntegrator( - operator, [0.75], power=1.0, - solver=mock_unsupported_substeps_solver, substeps=2) - monkeypatch.setattr(pool, "USE_MULTIPROCESSING", False) - - with pytest.raises(NotImplementedError, match="not supported"): - integrator._timed_deplete(n, rates, 0.75) - - -def test_custom_solver_requires_four_args(): - op = MagicMock() - op.prev_res = None - op.chain = None - op.heavy_metal = 1.0 - - with pytest.raises(ValueError, match="four arguments"): - PredictorIntegrator(op, [1], power=1, solver=mock_bad_solver_nargs) - @pytest.mark.parametrize("integrator", INTEGRATORS) def test_timesteps(integrator): diff --git a/tests/unit_tests/test_deplete_keff_search_control.py b/tests/unit_tests/test_deplete_keff_search_control.py deleted file mode 100644 index 425b8f840..000000000 --- a/tests/unit_tests/test_deplete_keff_search_control.py +++ /dev/null @@ -1,116 +0,0 @@ -""" Tests for KeffSearchControl class """ - -from pathlib import Path - -import pytest -import numpy as np - -import openmc -import openmc.lib -from openmc.deplete import CoupledOperator - -CHAIN_PATH = Path(__file__).parents[1] / "chain_simple.xml" - - -def make_model(): - f = openmc.Material(name="fuel") - f.add_element("U", 1, percent_type="ao", enrichment=4.25) - f.add_element("O", 2) - f.set_density("g/cc", 10.4) - f.temperature = 293.15 - - w = openmc.Material(name="water") - w.add_element("O", 1) - w.add_element("H", 2) - w.set_density("g/cc", 1.0) - w.temperature = 293.15 - w.depletable = True - - h = openmc.Material(name='helium') - h.add_element('He', 1) - h.set_density('g/cm3', 0.001598) - - radii = [0.42, 0.45] - height = 0.5 - - f.volume = np.pi * radii[0] ** 2 * height - w.volume = np.pi * (radii[1]**2 - radii[0]**2) * height/2 - - materials = openmc.Materials([f, w, h]) - - surf_interface = openmc.ZPlane(z0=0) - surf_top = openmc.ZPlane(z0=height/2) - surf_bot = openmc.ZPlane(z0=-height/2) - surf_in = openmc.Sphere(r=radii[0]) - surf_out = openmc.Sphere(r=radii[1], boundary_type='vacuum') - - cell_water = openmc.Cell(fill=w, region=-surf_interface) - cell_helium = openmc.Cell(fill=h, region=+surf_interface) - universe = openmc.Universe(cells=(cell_water, cell_helium)) - cell_fuel = openmc.Cell(name='fuel_cell', fill=f, - region=-surf_in & -surf_top & +surf_bot) - cell_universe = openmc.Cell(name='universe_cell',fill=universe, - region=+surf_in & -surf_out & -surf_top & +surf_bot) - geometry = openmc.Geometry([cell_fuel, cell_universe]) - - settings = openmc.Settings() - settings.particles = 1000 - settings.inactive = 10 - settings.batches = 50 - - return openmc.Model(geometry, materials, settings) - - -def translate_cell(position): - """Helper function to translate a cell""" - cell = [c for c in openmc.lib.cells.values() if c.name == 'universe_cell'][0] - openmc.lib.cells[cell.id].translation = [0, 0, position] - return position - - -def rotate_cell(angle): - """Helper function to rotate a cell""" - cell = [c for c in openmc.lib.cells.values() if c.name == 'universe_cell'][0] - openmc.lib.cells[cell.id].rotation = [0, 0, angle] - return angle - - -def set_u235_density(u235_density): - """Helper function to set the U235 density directly""" - fuel = [m for m in openmc.lib.materials.values() if m.name == 'fuel'][0] - nuclides = openmc.lib.materials[fuel.id].nuclides - densities = openmc.lib.materials[fuel.id].densities - u235_idx = nuclides.index('U235') - densities[u235_idx] = u235_density - openmc.lib.materials[fuel.id].set_densities(nuclides, densities) - return u235_density - - -@pytest.mark.parametrize("function, x0, x1, bracket", [ - (translate_cell, -1.0, 1.0, (-5.0, 5.0)), - (rotate_cell, -45.0, 45.0, (-90.0, 90.0)), - (set_u235_density, 0.8, 1.2, (0.5, 1.5)) -]) -def test_integrator_add_keff_search_control(run_in_tmpdir, function, x0, x1, bracket): - """Test adding add_keff_search_control to integrator""" - model = make_model() - operator = CoupledOperator(model, CHAIN_PATH) - integrator = openmc.deplete.PredictorIntegrator( - operator, [1, 1], 0.0, timestep_units='d') - - integrator.add_keff_search_control( - function=function, - x0=x0, - x1=x1, - bracket=bracket, - k_tol=0.1, - output=False, - ) - - assert integrator._keff_search_control.x0 == x0 - assert integrator._keff_search_control.x1 == x1 - assert integrator._keff_search_control.function == function - assert integrator._keff_search_control.search_kwargs['x_min'] == bracket[0] - assert integrator._keff_search_control.search_kwargs['x_max'] == bracket[1] - assert integrator._keff_search_control.search_kwargs['k_tol'] == 0.1 - assert not integrator._keff_search_control.search_kwargs['output'] diff --git a/tests/unit_tests/test_deplete_microxs.py b/tests/unit_tests/test_deplete_microxs.py index 0b1937fac..ad54026f0 100644 --- a/tests/unit_tests/test_deplete_microxs.py +++ b/tests/unit_tests/test_deplete_microxs.py @@ -6,15 +6,12 @@ to a custom file with new depletion_chain node from os import remove from pathlib import Path -from unittest.mock import patch import pytest -import openmc -from openmc.deplete import MicroXS, get_microxs_and_flux +from openmc.deplete import MicroXS import numpy as np ONE_GROUP_XS = Path(__file__).parents[1] / "micro_xs_simple.csv" -CHAIN_FILE = Path(__file__).parents[1] / "chain_simple.xml" def test_from_array(): @@ -49,7 +46,9 @@ def test_from_array(): data.shape = (12, 2, 1) MicroXS(data, nuclides, reactions) - with pytest.raises(ValueError, match='Data array must be 3D'): + with pytest.raises(ValueError, match=r'Nuclides list of length \d* and ' + r'reactions array of length \d* do not ' + r'match dimensions of data array of shape \(\d*\, \d*\)'): MicroXS(data[:, 0], nuclides, reactions) @@ -97,13 +96,9 @@ def test_multigroup_flux_same(): energies = [0., 6.25e-1, 5.53e3, 8.21e5, 2.e7] flux_per_ev = [0.3, 0.3, 1.0, 1.0] flux = flux_per_ev * np.diff(energies) - flux_sum = flux.sum() microxs_4g = MicroXS.from_multigroup_flux( energies=energies, multigroup_flux=flux, chain_file=chain_file) - # from_multigroup_flux should not modify the flux - assert flux.sum() == flux_sum - # Generate micro XS based on 2-group flux, where the boundaries line up with # the 4 group flux and have the same flux per eV across the full energy # range @@ -114,200 +109,3 @@ def test_multigroup_flux_same(): energies=energies, multigroup_flux=flux, chain_file=chain_file) assert microxs_4g.data == pytest.approx(microxs_2g.data) - - -def test_microxs_zero_flux(): - chain_file = Path(__file__).parents[1] / 'chain_simple.xml' - - # Generate micro XS based on zero flux - energies = [0., 6.25e-1, 5.53e3, 8.21e5, 2.e7] - flux = [0.0, 0.0, 0.0, 0.0] - microxs = MicroXS.from_multigroup_flux( - energies=energies, multigroup_flux=flux, chain_file=chain_file) - - # All microscopic cross sections should be zero - assert np.all(microxs.data == 0.0) - - -def test_hybrid_tally_setup(): - """In hybrid mode a 1-group RR tally is added alongside the flux tally.""" - # Create a simple model with one material and a few nuclides for testing - model = openmc.Model() - mat = openmc.Material(components={'U235': 1.0, 'O16': 2.0}) - sphere = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere, fill=mat) - model.geometry = openmc.Geometry([cell]) - model.settings.batches = 2 - model.settings.particles = 10 - - # Define 2-group energy structure for the test - energies = [0., 0.625, 2.0e7] - - # Function to replace Model.run and capture the tallies that were created - captured = {} - def capture_run(**kwargs): - captured['tallies'] = list(model.tallies) - raise StopIteration - - # Call get_microxs_and_flux but replace Model.run with a function that - # captures the tallies and raises StopIteration to exit early - with patch.object(model, 'run', side_effect=capture_run): - with pytest.raises(StopIteration): - get_microxs_and_flux( - model, [mat], - nuclides=['U235', 'O16'], - reactions=['fission', '(n,gamma)'], - energies=energies, - reaction_rate_mode='flux', - reaction_rate_opts={'nuclides': ['U235'], 'reactions': ['fission']}, - chain_file=CHAIN_FILE, - ) - - # Check that both tallies were created with the expected properties - tally_names = [t.name for t in captured['tallies']] - assert 'MicroXS flux 0' in tally_names - assert 'MicroXS RR 0' in tally_names - - # Check that the RR tally has the expected nuclides and reactions - rr = next(t for t in captured['tallies'] if t.name == 'MicroXS RR 0') - assert rr.nuclides == ['U235'] - assert rr.scores == ['fission'] - - # RR tally must use a 1-group energy filter spanning the full energy range - ef = next(f for f in rr.filters if isinstance(f, openmc.EnergyFilter)) - assert len(ef.values) == 2 - assert ef.values[0] == pytest.approx(energies[0]) - assert ef.values[-1] == pytest.approx(energies[-1]) - - -def _simple_model(): - model = openmc.Model() - mat = openmc.Material(components={'H1': 1.0, 'H2': 1.0}, - density=5.0, density_units='g/cm3') - sphere = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere, fill=mat) - model.geometry = openmc.Geometry([cell]) - model.settings.particles = 100 - model.settings.batches = 5 - model.settings.run_mode = 'fixed source' - return model, mat - - -def test_hybrid_tally_defaults_to_all_nuclides(run_in_tmpdir): - energies = [0., 0.625, 2.0e7] - kwargs = { - 'nuclides': ['H1', 'H2'], - 'reactions': ['(n,2n)', '(n,gamma)'], - 'energies': energies, - 'reaction_rate_mode': 'flux', - 'chain_file': CHAIN_FILE, - } - - model, mat = _simple_model() - default_fluxes, default_micros = get_microxs_and_flux( - model, [mat], reaction_rate_opts={'reactions': ['(n,2n)']}, **kwargs - ) - - model, mat = _simple_model() - explicit_fluxes, explicit_micros = get_microxs_and_flux( - model, [mat], - reaction_rate_opts={ - 'nuclides': ['H1', 'H2'], - 'reactions': ['(n,2n)'] - }, - **kwargs - ) - - np.testing.assert_allclose(default_fluxes[0], explicit_fluxes[0]) - np.testing.assert_allclose(default_micros[0].data, explicit_micros[0].data) - assert default_micros[0].nuclides == explicit_micros[0].nuclides - assert default_micros[0].reactions == explicit_micros[0].reactions - - -def test_flux_mode_returns_one_group_flux(run_in_tmpdir): - model, mat = _simple_model() - fluxes, micros = get_microxs_and_flux( - model, [mat], - nuclides=['H1'], - reactions=['(n,2n)'], - energies=[0., 0.625, 2.0e7], - reaction_rate_mode='flux', - chain_file=CHAIN_FILE, - ) - - assert fluxes[0].shape == (1,) - assert micros[0].data.shape == (1, 1, 1) - assert fluxes[0][0] > 0.0 - -# --------------------------------------------------------------------------- -# Tests for MicroXS.merge() -# --------------------------------------------------------------------------- - -def _make_microxs(nuclides, reactions, values, groups=1): - """Helper: build a MicroXS from a flat list of values (nuclide-major order).""" - data = np.array(values, dtype=float).reshape( - len(nuclides), len(reactions), groups) - return MicroXS(data, nuclides, reactions) - - -def test_merge_disjoint(): - """Merging two MicroXS with no overlapping nuclides or reactions.""" - m1 = _make_microxs(['U235', 'U238'], ['fission', '(n,gamma)'], - [1., 2., 3., 4.]) - m2 = _make_microxs(['Pu239'], ['(n,2n)'], [5.]) - - merged = m1.merge(m2) - - assert merged.nuclides == ['U235', 'U238', 'Pu239'] - assert merged.reactions == ['fission', '(n,gamma)', '(n,2n)'] - assert merged.data.shape == (3, 3, 1) - - # Self data preserved - assert merged['U235', 'fission'] == pytest.approx([1.]) - assert merged['U238', '(n,gamma)'] == pytest.approx([4.]) - # New data from other - assert merged['Pu239', '(n,2n)'] == pytest.approx([5.]) - # Cross-terms that had no data should be zero - assert merged['U235', '(n,2n)'] == pytest.approx([0.]) - assert merged['Pu239', 'fission'] == pytest.approx([0.]) - - -def test_merge_prefer_other(): - """prefer='other': other overwrites shared entries, adds new ones.""" - # m1: U235 and U238, reactions fission and (n,gamma) - m1 = _make_microxs(['U235', 'U238'], ['fission', '(n,gamma)'], - [1., 2., 3., 4.]) - # m2: only U235, reactions fission (overlap) and (n,2n) (new) - m2 = _make_microxs(['U235'], ['fission', '(n,2n)'], [9., 5.]) - - merged = m1.merge(m2) - - # Nuclide/reaction sets - assert set(merged.nuclides) == {'U235', 'U238'} - assert set(merged.reactions) == {'fission', '(n,gamma)', '(n,2n)'} - - # U235/fission overwritten by m2 - assert merged['U235', 'fission'] == pytest.approx([9.]) - # U235/(n,gamma) untouched - assert merged['U235', '(n,gamma)'] == pytest.approx([2.]) - # New reaction added from m2 - assert merged['U235', '(n,2n)'] == pytest.approx([5.]) - # U238 data preserved - assert merged['U238', 'fission'] == pytest.approx([3.]) - assert merged['U238', '(n,gamma)'] == pytest.approx([4.]) - # U238/(n,2n) not in either → zero - assert merged['U238', '(n,2n)'] == pytest.approx([0.]) - - -def test_merge_prefer_self(): - """prefer='self': shared pairs keep self's value; new entries use other's value.""" - m1 = _make_microxs(['U235', 'U238'], ['fission', '(n,gamma)'], - [1., 2., 3., 4.]) - m2 = _make_microxs(['U235'], ['fission', '(n,2n)'], [9., 5.]) - - merged = m1.merge(m2, prefer='self') - - # U235/fission: self wins - assert merged['U235', 'fission'] == pytest.approx([1.]) - # U235/(n,2n): other used - assert merged['U235', '(n,2n)'] == pytest.approx([5.]) diff --git a/tests/unit_tests/test_deplete_restart.py b/tests/unit_tests/test_deplete_restart.py index 1cbff30a5..e8bfc062a 100644 --- a/tests/unit_tests/test_deplete_restart.py +++ b/tests/unit_tests/test_deplete_restart.py @@ -21,7 +21,7 @@ def test_restart_predictor_cecm(run_in_tmpdir): # Perform simulation using the predictor algorithm dt = [0.75] power = 1.0 - openmc.deplete.PredictorIntegrator(op, dt, power).integrate(write_rates=True) + openmc.deplete.PredictorIntegrator(op, dt, power).integrate() # Load the files prev_res = openmc.deplete.Results(op.output_dir / "depletion_results.h5") @@ -30,6 +30,10 @@ def test_restart_predictor_cecm(run_in_tmpdir): op = dummy_operator.DummyOperator(prev_res) op.output_dir = output_dir + # check ValueError is raised, indicating previous and current stages + with pytest.raises(ValueError, match="incompatible.* 1.*2"): + openmc.deplete.CECMIntegrator(op, dt, power) + def test_restart_cecm_predictor(run_in_tmpdir): """Integral regression test of integrator algorithm using CE/CM for the @@ -43,7 +47,7 @@ def test_restart_cecm_predictor(run_in_tmpdir): dt = [0.75] power = 1.0 cecm = openmc.deplete.CECMIntegrator(op, dt, power) - cecm.integrate(write_rates=True) + cecm.integrate() # Load the files prev_res = openmc.deplete.Results(op.output_dir / "depletion_results.h5") @@ -52,6 +56,10 @@ def test_restart_cecm_predictor(run_in_tmpdir): op = dummy_operator.DummyOperator(prev_res) op.output_dir = output_dir + # check ValueError is raised, indicating previous and current stages + with pytest.raises(ValueError, match="incompatible.* 2.*1"): + openmc.deplete.PredictorIntegrator(op, dt, power) + @pytest.mark.parametrize("scheme", dummy_operator.SCHEMES) def test_restart(run_in_tmpdir, scheme): @@ -62,7 +70,7 @@ def test_restart(run_in_tmpdir, scheme): operator = dummy_operator.DummyOperator() # take first step - bundle.solver(operator, [0.75], 1.0).integrate(write_rates=True) + bundle.solver(operator, [0.75], 1.0).integrate() # restart prev_res = openmc.deplete.Results( diff --git a/tests/unit_tests/test_deplete_resultslist.py b/tests/unit_tests/test_deplete_resultslist.py index bc1a078b0..b22a78650 100644 --- a/tests/unit_tests/test_deplete_resultslist.py +++ b/tests/unit_tests/test_deplete_resultslist.py @@ -1,12 +1,10 @@ """Tests the Results class""" -from math import inf from pathlib import Path +from math import inf import numpy as np import pytest - -import openmc import openmc.deplete @@ -23,14 +21,14 @@ def test_get_activity(res): t_ref = np.array([0.0, 1296000.0, 2592000.0, 3888000.0]) a_ref = np.array( - [1.25167956e+06, 3.69842310e+11, 3.70099291e+11, 3.53629755e+11]) + [1.25167956e+06, 3.71938527e+11, 4.43264300e+11, 3.55547176e+11]) np.testing.assert_allclose(t, t_ref) np.testing.assert_allclose(a, a_ref) # Check by_nuclide a_xe135_ref = np.array( - [2.10657422e+05, 1.12825236e+11, 1.09055177e+11, 1.07491257e+11]) + [2.106574218e+05, 1.227519888e+11, 1.177491828e+11, 1.031986176e+11]) t_nuc, a_nuc = res.get_activity("1", by_nuclide=True) a_xe135 = np.array([a_nuc_i["Xe135"] for a_nuc_i in a_nuc]) @@ -39,43 +37,13 @@ def test_get_activity(res): np.testing.assert_allclose(a_xe135, a_xe135_ref) -def test_get_activity_chain_file(res, tmp_path): - """Tests evaluating activity with chain half-life data""" - _, a_endf = res.get_activity("1", by_nuclide=True, chain_file=False) - xe135_endf = np.array([a["Xe135"] for a in a_endf]) - - chain = openmc.deplete.Chain() - xe135 = openmc.deplete.Nuclide("Xe135") - xe135.half_life = openmc.data.half_life("Xe135") / 2.0 - chain.add_nuclide(xe135) - - t_chain, a_chain = res.get_activity("1", by_nuclide=True, chain_file=chain) - xe135_chain = np.array([a["Xe135"] for a in a_chain]) - - t_ref = np.array([0.0, 1296000.0, 2592000.0, 3888000.0]) - np.testing.assert_allclose(t_chain, t_ref) - np.testing.assert_allclose(xe135_chain, 2.0 * xe135_endf) - - chain_path = tmp_path / "chain.xml" - chain.export_to_xml(chain_path) - with openmc.config.patch('chain_file', chain_path): - _, a_config = res.get_activity("1", by_nuclide=True) - xe135_config = np.array([a["Xe135"] for a in a_config]) - np.testing.assert_allclose(xe135_config, xe135_chain) - - stable_chain = openmc.deplete.Chain() - stable_chain.add_nuclide(openmc.deplete.Nuclide("Xe135")) - _, a_stable = res.get_activity("1", by_nuclide=True, chain_file=stable_chain) - assert all(a["Xe135"] == 0.0 for a in a_stable) - - def test_get_atoms(res): """Tests evaluating single nuclide concentration.""" t, n = res.get_atoms("1", "Xe135") t_ref = np.array([0.0, 1296000.0, 2592000.0, 3888000.0]) n_ref = np.array( - [6.67473282e+08, 3.57489567e+14, 3.45544042e+14, 3.40588723e+14]) + [6.67473282e+08, 3.88942731e+14, 3.73091215e+14, 3.26987387e+14]) np.testing.assert_allclose(t, t_ref) np.testing.assert_allclose(n, n_ref) @@ -103,7 +71,7 @@ def test_get_decay_heat(res): t_ref = np.array([0.0, 1296000.0, 2592000.0, 3888000.0]) dh_ref = np.array( - [1.27933813e-09, 5.95370258e-03, 6.01335600e-03, 5.69831173e-03]) + [1.27933813e-09, 5.85347232e-03, 7.38773010e-03, 5.79954067e-03]) t, dh = res.get_decay_heat("1") @@ -112,7 +80,7 @@ def test_get_decay_heat(res): # Check by nuclide dh_xe135_ref = np.array( - [1.27933813e-09, 6.85196014e-04, 6.62300168e-04, 6.52802366e-04]) + [1.27933813e-09, 7.45481920e-04, 7.15099509e-04, 6.26732849e-04]) t_nuc, dh_nuc = res.get_decay_heat("1", by_nuclide=True) dh_nuc_xe135 = np.array([dh_nuc_i["Xe135"] for dh_nuc_i in dh_nuc]) @@ -127,7 +95,7 @@ def test_get_mass(res): t_ref = np.array([0.0, 1296000.0, 2592000.0, 3888000.0]) n_ref = np.array( - [6.67473282e+08, 3.57489567e+14, 3.45544042e+14, 3.40588723e+14]) + [6.67473282e+08, 3.88942731e+14, 3.73091215e+14, 3.26987387e+14]) # Get g n_ref *= openmc.data.atomic_mass('Xe135') / openmc.data.AVOGADRO @@ -155,8 +123,8 @@ def test_get_reaction_rate(res): t, r = res.get_reaction_rate("1", "Xe135", "(n,gamma)") t_ref = [0.0, 1296000.0, 2592000.0, 3888000.0] - n_ref = [6.67473282e+08, 3.57489567e+14, 3.45544042e+14, 3.40588723e+14] - xs_ref = [3.10220818e-05, 3.36754072e-05, 3.12740350e-05, 3.86717693e-05] + n_ref = [6.67473282e+08, 3.88942731e+14, 3.73091215e+14, 3.26987387e+14] + xs_ref = [2.53336104e-05, 4.21747011e-05, 3.48616127e-05, 3.61775563e-05] np.testing.assert_allclose(t, t_ref) np.testing.assert_allclose(r, np.array(n_ref) * xs_ref) @@ -168,8 +136,8 @@ def test_get_keff(res): t_min, k = res.get_keff(time_units='min') t_ref = [0.0, 1296000.0, 2592000.0, 3888000.0] - k_ref = [1.1773089172, 1.2231748584, 1.1611455694, 1.1714783649] - u_ref = [0.0384666252, 0.0311915665, 0.0226370102, 0.0315964732] + k_ref = [1.1596402556, 1.1914183335, 1.2292570871, 1.1797030302] + u_ref = [0.0270680649, 0.0219163444, 0.024268508 , 0.0221401194] np.testing.assert_allclose(t, t_ref) np.testing.assert_allclose(t_min * 60, t_ref) @@ -252,12 +220,5 @@ def test_stepresult_get_material(res): # Spot check number densities densities = mat1.get_nuclide_atom_densities() assert densities['Xe135'] == pytest.approx(1e-14) + assert densities['I135'] == pytest.approx(1e-21) assert densities['U234'] == pytest.approx(1.00506e-05) - - -def test_stepresult_get_material_mat_id_as_int(res): - # Get material at first timestep using int mat_id - step_result = res[0] - mat1 = step_result.get_material(1) - assert mat1.id == 1 - assert mat1.volume == step_result.volume["1"] diff --git a/tests/unit_tests/test_deplete_transfer_rates.py b/tests/unit_tests/test_deplete_transfer_rates.py index a6dcb2b27..847606be4 100644 --- a/tests/unit_tests/test_deplete_transfer_rates.py +++ b/tests/unit_tests/test_deplete_transfer_rates.py @@ -16,7 +16,6 @@ CHAIN_PATH = Path(__file__).parents[1] / "chain_simple.xml" @pytest.fixture def model(): - openmc.reset_auto_ids() f = openmc.Material(name="f") f.add_element("U", 1, percent_type="ao", enrichment=4.25) f.add_element("O", 2) @@ -55,35 +54,31 @@ def model(): return openmc.Model(geometry, materials, settings) -@pytest.mark.parametrize("case_name, transfer_rates, timesteps", [ - ('elements', {'U': 0.01, 'Xe': 0.1}, None), - ('nuclides', {'I135': 0.01, 'Gd156': 0.1, 'Gd157': 0.01}, None), +@pytest.mark.parametrize("case_name, transfer_rates", [ + ('elements', {'U': 0.01, 'Xe': 0.1}), + ('nuclides', {'I135': 0.01, 'Gd156': 0.1, 'Gd157': 0.01}), ('nuclides_elements', {'I135': 0.01, 'Gd156': 0.1, 'Gd157': 0.01, 'U': 0.01, - 'Xe': 0.1}, None), + 'Xe': 0.1}), ('elements_nuclides', {'U': 0.01, 'Xe': 0.1, 'I135': 0.01, 'Gd156': 0.1, - 'Gd157': 0.01}, None), + 'Gd157': 0.01}), ('multiple_transfer', {'U': 0.01, 'Xe': 0.1, 'I135': 0.01, 'Gd156': 0.1, - 'Gd157': 0.01}, None), - ('timesteps', {'U': 0.01, 'Xe': 0.1}, [1]), - ('rates_invalid_1', {'Gd': 0.01, 'Gd157': 0.01, 'Gd156': 0.01}, None), - ('rates_invalid_2', {'Gd156': 0.01, 'Gd157': 0.01, 'Gd': 0.01}, None), - ('rates_invalid_3', {'Gb156': 0.01}, None), - ('rates_invalid_4', {'Gb': 0.01}, None) + 'Gd157': 0.01}), + ('rates_invalid_1', {'Gd': 0.01, 'Gd157': 0.01, 'Gd156': 0.01}), + ('rates_invalid_2', {'Gd156': 0.01, 'Gd157': 0.01, 'Gd': 0.01}), + ('rates_invalid_3', {'Gb156': 0.01}), + ('rates_invalid_4', {'Gb': 0.01}) ]) -def test_get_set(model, case_name, transfer_rates, timesteps): +def test_get_set(model, case_name, transfer_rates): """Tests the get/set methods""" - op = CoupledOperator(model, CHAIN_PATH) - number_of_timesteps = 2 - transfer = TransferRates(op, model.materials, number_of_timesteps) - if timesteps is None: - timesteps = np.arange(number_of_timesteps) + op = CoupledOperator(model, CHAIN_PATH) + transfer = TransferRates(op, model) # Test by Openmc material, material name and material id material, dest_material, dest_material2 = [m for m in model.materials if m.depletable] for material_input in [material, material.name, material.id]: - for dest_material_input in [None, dest_material, dest_material.name, + for dest_material_input in [dest_material, dest_material.name, dest_material.id]: if case_name == 'rates_invalid_1': with pytest.raises(ValueError, match='Cannot add transfer ' @@ -121,21 +116,14 @@ def test_get_set(model, case_name, transfer_rates, timesteps): for component, transfer_rate in transfer_rates.items(): transfer.set_transfer_rate(material_input, [component], transfer_rate, - timesteps=timesteps, destination_material=\ dest_material_input) - assert transfer.get_external_rate( - material_input, component, timesteps, - dest_material_input)[0] == transfer_rate - assert np.all(transfer.external_timesteps == timesteps) - - if timesteps is not None: - for timestep in timesteps: - assert transfer.get_components(material_input, timestep, - dest_material_input) == list(transfer_rates.keys()) - else: - assert transfer.get_components(material_input, timesteps, - dest_material_input) == list(transfer_rates.keys()) + assert transfer.get_transfer_rate( + material_input, component)[0] == transfer_rate + assert transfer.get_destination_material( + material_input, component)[0] == str(dest_material.id) + assert transfer.get_components(material_input) == \ + transfer_rates.keys() if case_name == 'multiple_transfer': for dest2_material_input in [dest_material2, dest_material2.name, @@ -146,8 +134,10 @@ def test_get_set(model, case_name, transfer_rates, timesteps): destination_material=\ dest2_material_input) for id, dest_mat in zip([0,1],[dest_material,dest_material2]): - assert transfer.get_external_rate( - material_input, component, timesteps)[0] == transfer_rate + assert transfer.get_transfer_rate( + material_input, component)[id] == transfer_rate + assert transfer.get_destination_material( + material_input, component)[id] == str(dest_mat.id) @pytest.mark.parametrize("transfer_rate_units, unit_conv", [ ('1/s', 1), @@ -167,15 +157,13 @@ def test_units(transfer_rate_units, unit_conv, model): # create transfer rate Xe components = ['Xe', 'U235'] transfer_rate = 1e-5 - number_of_timesteps = 2 op = CoupledOperator(model, CHAIN_PATH) - transfer = TransferRates(op, model.materials, number_of_timesteps) + transfer = TransferRates(op, model) for component in components: transfer.set_transfer_rate('f', [component], transfer_rate * unit_conv, transfer_rate_units=transfer_rate_units) - for timestep in range(transfer.number_of_timesteps): - assert transfer.get_external_rate('f', component, timestep)[0] == transfer_rate + assert transfer.get_transfer_rate('f', component)[0] == transfer_rate def test_transfer(run_in_tmpdir, model): @@ -198,35 +186,3 @@ def test_transfer(run_in_tmpdir, model): # Ensure number of atoms equal transfer decay assert atoms[1] == pytest.approx(atoms[0]*exp(-transfer_rate*3600*24)) assert atoms[2] == pytest.approx(atoms[1]*exp(-transfer_rate*3600*24)) - -@pytest.mark.parametrize("case_name, buffer, ox", [ - ('redox', {'Gd157':1}, {'Gd': 3, 'U': 4}), - ('buffer_invalid', {'Gd158':1}, {'Gd': 3, 'U': 4}), - ('elm_invalid', {'Gd157':1}, {'Gb': 3, 'U': 4}), - ]) -def test_redox(case_name, buffer, ox, model): - op = CoupledOperator(model, CHAIN_PATH) - number_of_timesteps = 2 - transfer = TransferRates(op, model.materials, number_of_timesteps) - - # Test by Openmc material, material name and material id - material, dest_material, dest_material2 = [m for m in model.materials - if m.depletable] - for material_input in [material, material.name, material.id]: - for dest_material_input in [dest_material, dest_material.name, - dest_material.id]: - - if case_name == 'buffer_invalid': - with pytest.raises(ValueError, match='Gd158 is not a valid ' - 'nuclide.'): - transfer.set_redox(material_input, buffer, ox) - - elif case_name == 'elm_invalid': - with pytest.raises(ValueError, match='Gb is not a valid ' - 'element.'): - transfer.set_redox(material_input, buffer, ox) - else: - transfer.set_redox(material_input, buffer, ox) - mat_id = transfer._get_material_id(material_input) - assert transfer.redox[mat_id][0] == buffer - assert transfer.redox[mat_id][1] == ox diff --git a/tests/unit_tests/test_element.py b/tests/unit_tests/test_element.py index 82e526ec3..d3555701e 100644 --- a/tests/unit_tests/test_element.py +++ b/tests/unit_tests/test_element.py @@ -44,13 +44,6 @@ def test_expand_no_isotopes(): element.expand(100.0, 'ao') -def test_expand_ta(): - ref = {'Ta181': 100.0} - element = openmc.Element('Ta') - for isotope in element.expand(100.0, 'ao'): - assert isotope[1] == approx(ref[isotope[0]]) - - def test_expand_exceptions(): """ Test that correct exceptions are raised for invalid input """ diff --git a/tests/unit_tests/test_endf.py b/tests/unit_tests/test_endf.py index cdd21d7a6..1d4982054 100644 --- a/tests/unit_tests/test_endf.py +++ b/tests/unit_tests/test_endf.py @@ -2,17 +2,6 @@ from openmc.data import endf from pytest import approx -def test_evaluation_from_material(endf_data): - filename = f'{endf_data}/neutrons/n-001_H_001.endf' - material = endf.get_evaluations(filename)[0] - evaluation = endf.Evaluation(material) - - assert evaluation.material == material.MAT - assert evaluation.gnds_name == 'H1' - assert evaluation.section == material.section_text - assert evaluation.reaction_list == material[1, 451]['section_list'] - - def test_float_endf(): assert endf.float_endf('+3.2146') == approx(3.2146) assert endf.float_endf('.12345') == approx(0.12345) diff --git a/tests/unit_tests/test_filter_distribcell.py b/tests/unit_tests/test_filter_distribcell.py deleted file mode 100644 index d5734a2c0..000000000 --- a/tests/unit_tests/test_filter_distribcell.py +++ /dev/null @@ -1,53 +0,0 @@ -import openmc -import pandas as pd - - -def test_distribcell_filter_apply_tally_results(run_in_tmpdir): - # Reset IDs to ensure consistent paths - openmc.reset_auto_ids() - - mat = openmc.Material() - mat.add_nuclide("U235", 1.0) - mat.set_density("g/cm3", 1.0) - - # Define 2x2 lattice with a cylinder in each universe - cyl = openmc.ZCylinder(r=1.0) - cell1 = openmc.Cell(fill=mat, region=-cyl) - cell2 = openmc.Cell(fill=None, region=+cyl) - univ = openmc.Universe(cells=[cell1, cell2]) - lattice = openmc.RectLattice() - lattice.lower_left = (-3.0, -3.0) - lattice.pitch = (3.0, 3.0) - lattice.universes = [[univ, univ], [univ, univ]] - box = openmc.model.RectangularPrism(6., 6., boundary_type='reflective') - root_cell = openmc.Cell(region=-box, fill=lattice) - geometry = openmc.Geometry([root_cell]) - - # Create model and add tally with distribcell filter - model = openmc.Model(geometry) - model.settings.batches = 10 - model.settings.particles = 1000 - tally = openmc.Tally() - distribcell_filter = openmc.DistribcellFilter(cell1) - tally.filters = [distribcell_filter] - tally.scores = ['flux'] - model.tallies = [tally] - - # Run OpenMC and apply tally results - model.run(apply_tally_results=True) - - # Check that mean and standard deviation are available on tally - assert tally.mean.shape == (4, 1, 1) - assert tally.std_dev.shape == (4, 1, 1) - - # Make sure paths attribute on filter is correct - assert distribcell_filter.paths == [ - 'u3->c3->l2(0,0)->u1->c1', - 'u3->c3->l2(1,0)->u1->c1', - 'u3->c3->l2(0,1)->u1->c1', - 'u3->c3->l2(1,1)->u1->c1', - ] - - # Check that we can get a DataFrame from the tally - df = tally.get_pandas_dataframe() - assert isinstance(df, pd.DataFrame) diff --git a/tests/unit_tests/test_filter_mesh.py b/tests/unit_tests/test_filter_mesh.py index e26bea337..a8bd4996d 100644 --- a/tests/unit_tests/test_filter_mesh.py +++ b/tests/unit_tests/test_filter_mesh.py @@ -259,154 +259,3 @@ def test_get_reshaped_data(run_in_tmpdir): assert data1.shape == (2, 19*3*2, 1, 1) assert data2.shape == (2, 19, 3, 2, 1, 1) - -def test_mesh_filter_rotation_roundtrip(run_in_tmpdir): - """Test that MeshFilter rotation works as expected""" - - - mesh = openmc.RegularMesh() - mesh.lower_left = [-10, -10, -10] - mesh.upper_right = [10, 10, 10] - mesh.dimension = [2, 3, 4] - - # check that rotatoin is round-tripped correctly for a set of angles - mesh_filter = openmc.MeshFilter(mesh) - mesh_filter.rotation = [0, 0, 90] # Rotate around z-axis by 90 degrees - - elem = mesh_filter.to_xml_element() - mesh_filter_xml = openmc.MeshFilter.from_xml_element(elem, meshes={mesh.id: mesh}) - assert all(mesh_filter_xml.rotation == mesh_filter.rotation) - - # check that rotation matrix is round-tripped correctly for a rotation matrix - mesh_filter.rotation = np.array([[0.7071, 0, 0.7071], - [0, 1, 0], - [-0.7071, 0, 0.7071]]) - - elem = mesh_filter.to_xml_element() - mesh_filter_xml = openmc.MeshFilter.from_xml_element(elem, meshes={mesh.id: mesh}) - assert np.allclose(mesh_filter_xml.rotation, mesh_filter.rotation) - - -def test_mesh_filter_dataframe_regular_3d(): - """Test MeshFilter.get_pandas_dataframe with a 3D RegularMesh.""" - mesh = openmc.RegularMesh() - mesh.lower_left = [0, 0, 0] - mesh.upper_right = [3, 4, 5] - mesh.dimension = [3, 4, 5] - - f = openmc.MeshFilter(mesh) - data_size = 3 * 4 * 5 - df = f.get_pandas_dataframe(data_size, stride=1) - - mesh_key = f'mesh {mesh.id}' - assert (mesh_key, 'x') in df.columns - assert (mesh_key, 'y') in df.columns - assert (mesh_key, 'z') in df.columns - assert len(df) == data_size - # x varies fastest (stride=1), then y (stride=3), then z (stride=12) - assert list(df[(mesh_key, 'x')][:3]) == [1, 2, 3] - assert df[(mesh_key, 'y')].iloc[0] == 1 - assert df[(mesh_key, 'y')].iloc[3] == 2 - - -def test_mesh_filter_dataframe_regular_2d(): - """Test MeshFilter.get_pandas_dataframe with a 2D RegularMesh.""" - mesh = openmc.RegularMesh() - mesh.lower_left = [0, 0] - mesh.upper_right = [2, 3] - mesh.dimension = [2, 3] - - f = openmc.MeshFilter(mesh) - data_size = 2 * 3 - df = f.get_pandas_dataframe(data_size, stride=1) - - mesh_key = f'mesh {mesh.id}' - assert (mesh_key, 'x') in df.columns - assert (mesh_key, 'y') in df.columns - # Should NOT have a z column for a 2D mesh - assert (mesh_key, 'z') not in df.columns - assert len(df) == data_size - - -def test_mesh_filter_dataframe_regular_1d(): - """Test MeshFilter.get_pandas_dataframe with a 1D RegularMesh.""" - mesh = openmc.RegularMesh() - mesh.lower_left = [0] - mesh.upper_right = [5] - mesh.dimension = [5] - - f = openmc.MeshFilter(mesh) - data_size = 5 - df = f.get_pandas_dataframe(data_size, stride=1) - - mesh_key = f'mesh {mesh.id}' - assert (mesh_key, 'x') in df.columns - assert (mesh_key, 'y') not in df.columns - assert (mesh_key, 'z') not in df.columns - assert len(df) == data_size - assert list(df[(mesh_key, 'x')]) == [1, 2, 3, 4, 5] - - -def test_mesh_filter_dataframe_cylindrical(): - """Test MeshFilter.get_pandas_dataframe with a CylindricalMesh.""" - mesh = openmc.CylindricalMesh( - r_grid=[0.0, 1.0, 2.0], - phi_grid=[0.0, math.pi], - z_grid=[0.0, 5.0, 10.0] - ) - - f = openmc.MeshFilter(mesh) - nr, nphi, nz = mesh.dimension # 2, 1, 2 - data_size = nr * nphi * nz - df = f.get_pandas_dataframe(data_size, stride=1) - - mesh_key = f'mesh {mesh.id}' - assert (mesh_key, 'r') in df.columns - assert (mesh_key, 'phi') in df.columns - assert (mesh_key, 'z') in df.columns - # Should NOT have x, y columns - assert (mesh_key, 'x') not in df.columns - assert (mesh_key, 'y') not in df.columns - assert len(df) == data_size - # r varies fastest - assert list(df[(mesh_key, 'r')][:nr]) == [1, 2] - - -def test_mesh_filter_dataframe_spherical(): - """Test MeshFilter.get_pandas_dataframe with a SphericalMesh.""" - mesh = openmc.SphericalMesh( - r_grid=[0.0, 1.0, 2.0, 3.0], - theta_grid=[0, math.pi], - phi_grid=[0, 2 * math.pi] - ) - - f = openmc.MeshFilter(mesh) - nr, ntheta, nphi = mesh.dimension # 3, 1, 1 - data_size = nr * ntheta * nphi - df = f.get_pandas_dataframe(data_size, stride=1) - - mesh_key = f'mesh {mesh.id}' - assert (mesh_key, 'r') in df.columns - assert (mesh_key, 'theta') in df.columns - assert (mesh_key, 'phi') in df.columns - assert (mesh_key, 'x') not in df.columns - assert len(df) == data_size - - -def test_mesh_filter_dataframe_rectilinear(): - """Test MeshFilter.get_pandas_dataframe with a RectilinearMesh.""" - mesh = openmc.RectilinearMesh() - mesh.x_grid = [0.0, 1.0, 2.0] - mesh.y_grid = [0.0, 1.0, 2.0, 3.0] - mesh.z_grid = [0.0, 5.0] - - f = openmc.MeshFilter(mesh) - nx, ny, nz = mesh.dimension # 2, 3, 1 - data_size = nx * ny * nz - df = f.get_pandas_dataframe(data_size, stride=1) - - mesh_key = f'mesh {mesh.id}' - assert (mesh_key, 'x') in df.columns - assert (mesh_key, 'y') in df.columns - assert (mesh_key, 'z') in df.columns - assert len(df) == data_size diff --git a/tests/unit_tests/test_filter_meshmaterial.py b/tests/unit_tests/test_filter_meshmaterial.py deleted file mode 100644 index a05ed5a12..000000000 --- a/tests/unit_tests/test_filter_meshmaterial.py +++ /dev/null @@ -1,66 +0,0 @@ -import numpy as np -import openmc -from pytest import approx - - -def test_filter_mesh_material(run_in_tmpdir): - # Create four identical materials - openmc.reset_auto_ids() - materials = [] - for i in range(4): - mat = openmc.Material() - mat.id = 10*(i+1) - mat.add_nuclide('Fe56', 1.0) - materials.append(mat) - - # Create a slab model with four cells - z_values = [-10., -5., 0., 5., 10.] - planes = [openmc.ZPlane(z) for z in z_values] - planes[0].boundary_type = 'vacuum' - planes[-1].boundary_type = 'vacuum' - regions = [+left & -right for left, right in zip(planes[:-1], planes[1:])] - cells = [openmc.Cell(fill=m, region=r) for r, m in zip(regions, materials)] - model = openmc.Model() - model.geometry = openmc.Geometry(cells) - model.settings.particles = 1_000 - model.settings.batches = 5 - model.settings.run_mode = 'fixed source' - - # Create a mesh that does not align with all planar surfaces - mesh = openmc.RegularMesh() - mesh.lower_left = (-1., -1., -10.) - mesh.upper_right = (1., 1., 10.) - mesh.dimension = (1, 1, 5) - - # Determine material volumes in each mesh element and use result to create a - # MeshMaterialFilter with corresponding bins - vols = mesh.material_volumes(model) - mmf = openmc.MeshMaterialFilter.from_volumes(mesh, vols) - expected_bins = [(0, 10), (1, 10), (1, 20), (2, 20), (2, 30), (3, 40), (3, 30), (4, 40)] - np.testing.assert_equal(mmf.bins, expected_bins) - - # Create two tallies, one with a mesh filter and one with mesh-material - mesh_tally = openmc.Tally() - mesh_tally.filters = [openmc.MeshFilter(mesh)] - mesh_tally.scores = ['flux'] - mesh_material_tally = openmc.Tally() - mesh_material_tally.filters = [mmf] - mesh_material_tally.scores = ['flux'] - model.tallies = [mesh_tally, mesh_material_tally] - - # Run model to get results on the two tallies - model.run(apply_tally_results=True) - - # The sum of the flux in each mesh-material combination within a single mesh - # element should be equal to the flux in that mesh element - mesh_mean = mesh_tally.mean.ravel() - meshmat_mean = mesh_material_tally.mean.ravel() - assert mesh_mean[0] == approx(meshmat_mean[0]) - assert mesh_mean[1] == approx(meshmat_mean[1] + meshmat_mean[2]) - assert mesh_mean[2] == approx(meshmat_mean[3] + meshmat_mean[4]) - assert mesh_mean[3] == approx(meshmat_mean[5] + meshmat_mean[6]) - assert mesh_mean[4] == approx(meshmat_mean[7]) - assert mesh_tally.mean.sum() == approx(mesh_material_tally.mean.sum()) - - # Make sure get_pandas_dataframe method works - mesh_material_tally.get_pandas_dataframe() diff --git a/tests/unit_tests/test_filter_musurface.py b/tests/unit_tests/test_filter_musurface.py deleted file mode 100644 index ca0db71f0..000000000 --- a/tests/unit_tests/test_filter_musurface.py +++ /dev/null @@ -1,38 +0,0 @@ -import openmc - - -def test_musurface(run_in_tmpdir): - sphere = openmc.Sphere(r=1.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.particles = 1000 - model.settings.batches = 10 - E = 1.0 - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Point(), - angle=openmc.stats.Isotropic(), - energy=openmc.stats.delta_function(E), - ) - model.settings.run_mode = "fixed source" - - filter1 = openmc.MuSurfaceFilter(200) - filter2 = openmc.SurfaceFilter(sphere) - tally = openmc.Tally() - tally.filters = [filter1, filter2] - tally.scores = ['current'] - model.tallies = openmc.Tallies([tally]) - - # Run OpenMC - sp_filename = model.run() - - # Get current binned by mu - with openmc.StatePoint(sp_filename) as sp: - current_mu = sp.tallies[tally.id].mean.ravel() - - # All contributions should show up in last bin - assert current_mu[-1] == 1.0 - for element in current_mu[:-1]: - assert element == 0.0 - - diff --git a/tests/unit_tests/test_filter_reaction.py b/tests/unit_tests/test_filter_reaction.py deleted file mode 100644 index df8fc9d7b..000000000 --- a/tests/unit_tests/test_filter_reaction.py +++ /dev/null @@ -1,87 +0,0 @@ -import pytest -import openmc - - -def test_reaction_filter_construction_with_strings(): - f = openmc.ReactionFilter(['(n,elastic)', '(n,gamma)']) - assert len(f.bins) == 2 - assert f.bins[0] == '(n,elastic)' - assert f.bins[1] == '(n,gamma)' - - -def test_reaction_filter_construction_with_mt(): - f = openmc.ReactionFilter([2, 102]) - assert len(f.bins) == 2 - assert f.bins[0] == '(n,elastic)' - assert f.bins[1] == '(n,gamma)' - - -def test_reaction_filter_mixed(): - f = openmc.ReactionFilter([2, '(n,gamma)']) - assert f.bins[0] == '(n,elastic)' - assert f.bins[1] == '(n,gamma)' - - -def test_reaction_filter_single_bin_string(): - f = openmc.ReactionFilter('(n,elastic)') - assert len(f.bins) == 1 - assert f.bins[0] == '(n,elastic)' - - -def test_reaction_filter_single_bin_mt(): - f = openmc.ReactionFilter(2) - assert len(f.bins) == 1 - assert f.bins[0] == '(n,elastic)' - - -def test_reaction_filter_single_bin_naming(): - f = openmc.ReactionFilter('total') - assert len(f.bins) == 1 - assert f.bins[0] == '(n,total)' - - -def test_reaction_filter_invalid_mt(): - with pytest.raises(ValueError, match="No known reaction"): - openmc.ReactionFilter([999999]) - - -def test_reaction_filter_invalid_string(): - with pytest.raises(ValueError, match="Unknown reaction name"): - openmc.ReactionFilter(['not-a-reaction']) - - -def test_reaction_filter_invalid_type(): - with pytest.raises(TypeError, match="Expected str or int"): - openmc.ReactionFilter([3.14]) - - -def test_reaction_filter_xml_roundtrip(): - f = openmc.ReactionFilter([2, 102], filter_id=42) - elem = f.to_xml_element() - f2 = openmc.ReactionFilter.from_xml_element(elem) - assert f2.id == 42 - assert len(f2.bins) == 2 - assert f2.bins[0] == '(n,elastic)' - assert f2.bins[1] == '(n,gamma)' - - -def test_reaction_filter_num_bins(): - f = openmc.ReactionFilter(['(n,elastic)', '(n,fission)', '(n,gamma)']) - assert f.num_bins == 3 - - -def test_reaction_filter_repr(): - f = openmc.ReactionFilter([2, 102]) - r = repr(f) - assert 'ReactionFilter' in r - - -def test_reaction_filter_short_name(): - assert openmc.ReactionFilter.short_name == 'Reaction' - - -def test_reaction_filter_total_warning(): - """Test that using 'total' emits a warning about ambiguity.""" - with pytest.warns(UserWarning, match="ambiguous"): - f = openmc.ReactionFilter(['total']) - assert f.bins[0] == '(n,total)' diff --git a/tests/unit_tests/test_filter_weight.py b/tests/unit_tests/test_filter_weight.py deleted file mode 100644 index 878929ee0..000000000 --- a/tests/unit_tests/test_filter_weight.py +++ /dev/null @@ -1,44 +0,0 @@ -import openmc -import numpy as np - - -def test_weightfilter(run_in_tmpdir): - steel = openmc.Material(name='Stainless Steel') - steel.set_density('g/cm3', 8.00) - steel.add_nuclide('Fe56', 1.0) - - sphere = openmc.Sphere(r=50.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere, fill=steel) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.particles = 100 - model.settings.batches = 10 - - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(14e6), - ) - model.settings.run_mode = "fixed source" - - radius = list(range(1, 50)) - sphere_mesh = openmc.SphericalMesh(radius) - mesh_filter = openmc.MeshFilter(sphere_mesh) - weight_filter = openmc.WeightFilter( - [0.999, 0.9999, 0.99999, 0.999999, 1.0, 1.000001 ,1.00001, 1.0001, 1.001] - ) - - tally = openmc.Tally() - tally.filters = [mesh_filter, weight_filter] - tally.estimator = 'analog' - tally.scores = ['flux'] - model.tallies = openmc.Tallies([tally]) - - # Run OpenMC - model.run(apply_tally_results=True) - - # Get current binned by mu - neutron_flux = tally.mean.reshape(48, 8) - - # All contributions should show up in the fourth bin - assert np.all(neutron_flux[:, 3] != 0.0) - neutron_flux[:, 3] = 0.0 - assert np.all(neutron_flux == 0.0) diff --git a/tests/unit_tests/test_filters.py b/tests/unit_tests/test_filters.py index 2e7481c87..55bb62075 100644 --- a/tests/unit_tests/test_filters.py +++ b/tests/unit_tests/test_filters.py @@ -17,16 +17,14 @@ def box_model(): model.settings.particles = 100 model.settings.batches = 10 model.settings.inactive = 0 - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Point()) + model.settings.source = openmc.IndependentSource(space=openmc.stats.Point()) return model def test_cell_instance(): c1 = openmc.Cell() c2 = openmc.Cell() - f = openmc.CellInstanceFilter( - [(c1, 0), (c1, 1), (c1, 2), (c2, 0), (c2, 1)]) + f = openmc.CellInstanceFilter([(c1, 0), (c1, 1), (c1, 2), (c2, 0), (c2, 1)]) # Make sure __repr__ works repr(f) @@ -236,8 +234,7 @@ def test_first_moment(run_in_tmpdir, box_model): flux, scatter = sp.tallies[plain_tally.id].mean.ravel() # Check that first moment matches - def first_score(t): - return sp.tallies[t.id].mean.ravel()[0] + first_score = lambda t: sp.tallies[t.id].mean.ravel()[0] assert first_score(leg_tally) == scatter assert first_score(leg_sptl_tally) == scatter assert first_score(sph_scat_tally) == scatter @@ -261,8 +258,7 @@ def test_lethargy_bin_width(): assert len(f.lethargy_bin_width) == 175 energy_bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175'] assert f.lethargy_bin_width[0] == np.log10(energy_bins[1]/energy_bins[0]) - assert f.lethargy_bin_width[-1] == np.log10( - energy_bins[-1]/energy_bins[-2]) + assert f.lethargy_bin_width[-1] == np.log10(energy_bins[-1]/energy_bins[-2]) def test_energyfunc(): @@ -296,172 +292,5 @@ def test_tabular_from_energyfilter(): # 'histogram' is the default assert tab.interpolation == 'histogram' - tab = efilter.get_tabular(values=np.array( - [10, 10, 5]), interpolation='linear-linear') + tab = efilter.get_tabular(values=np.array([10, 10, 5]), interpolation='linear-linear') assert tab.interpolation == 'linear-linear' - - -def test_energy_filter(): - - # testing that bins descending value raises error - msg = "Values 1.0 and 0.5 appear to be out of order" - with raises(ValueError, match=msg): - openmc.EnergyFilter([0.0, 1.0, 0.5]) - - # testing that bins with same value raises error - msg = "Values 0.25 and 0.25 appear to be out of order" - with raises(ValueError, match=msg): - openmc.EnergyFilter([0.0, 0.25, 0.25]) - - # testing that negative bins values raises error - msg = 'Unable to set "filter value" to "-1.2" since it is less than "0.0"' - with raises(ValueError, match=msg): - openmc.EnergyFilter([-1.2, 0.25, 0.5]) - - -def test_particle_production_filter(): - energy_bins = [1e3, 1e4, 1e5, 1e6] - - # --- Single particle with energy bins --- - f = openmc.ParticleProductionFilter('photon', energy_bins) - - # particles getter always returns a list - assert isinstance(f.particles, list) - assert len(f.particles) == 1 - assert f.particles[0] == openmc.ParticleType.PHOTON - - assert f.num_energy_bins == 3 - assert f.num_bins == 3 - assert f.shape == (1, 3) - assert len(f.bins) == 3 - # Each bin is (particle_name, e_low, e_high) - assert f.bins[0] == ('photon', 1e3, 1e4) - assert f.bins[2] == ('photon', 1e5, 1e6) - - # __repr__ check - repr(f) - - # to_xml_element() - elem = f.to_xml_element() - assert elem.tag == 'filter' - assert elem.attrib['type'] == 'particleproduction' - assert elem.find('particles').text == 'photon' - assert elem.find('energies').text.split()[0] == str(energy_bins[0]) - - # from_xml_element() - new_f = openmc.Filter.from_xml_element(elem) - assert new_f.id == f.id - assert new_f.particles == f.particles - assert np.allclose(new_f.energies, f.energies) - - # pandas output (with energy bins -> 3 MultiIndex columns) - df = f.get_pandas_dataframe(data_size=3, stride=1) - assert df.shape[0] == 3 - assert ('particleproduction', 'particle') in df.columns - assert ('particleproduction', 'energy low [eV]') in df.columns - assert ('particleproduction', 'energy high [eV]') in df.columns - - # --- Multiple particles with energy bins --- - f2 = openmc.ParticleProductionFilter(['photon', 'neutron'], energy_bins) - assert len(f2.particles) == 2 - assert f2.num_bins == 6 # 2 particles * 3 energy bins - assert f2.shape == (2, 3) - assert len(f2.bins) == 6 - # First 3 bins are photon, next 3 are neutron - assert f2.bins[0] == ('photon', 1e3, 1e4) - assert f2.bins[3] == ('neutron', 1e3, 1e4) - - df2 = f2.get_pandas_dataframe(data_size=6, stride=1) - assert df2.shape[0] == 6 - assert list(df2[('particleproduction', 'particle')]) == \ - ['photon'] * 3 + ['neutron'] * 3 - - # XML round-trip - elem2 = f2.to_xml_element() - new_f2 = openmc.Filter.from_xml_element(elem2) - assert len(new_f2.particles) == 2 - assert np.allclose(new_f2.energies, energy_bins) - - # --- Multiple particles without energy bins --- - f3 = openmc.ParticleProductionFilter(['photon', 'neutron', 'electron']) - assert f3.energies is None - assert f3.num_bins == 3 - assert f3.num_energy_bins == 1 - assert f3.shape == (3, 1) - assert f3.bins == ['photon', 'neutron', 'electron'] - - repr(f3) - - df3 = f3.get_pandas_dataframe(data_size=3, stride=1) - assert df3.shape[0] == 3 - assert ('particleproduction', 'particle') in df3.columns - # Should not have energy columns - assert ('particleproduction', 'energy low [eV]') not in df3.columns - - # XML round-trip without energies - elem3 = f3.to_xml_element() - assert elem3.find('energies') is None - new_f3 = openmc.Filter.from_xml_element(elem3) - assert new_f3.energies is None - assert len(new_f3.particles) == 3 - - # --- Energies from group structure name --- - f4 = openmc.ParticleProductionFilter('photon', energies='CCFE-709') - expected = openmc.mgxs.GROUP_STRUCTURES['CCFE-709'] - assert np.allclose(f4.energies, expected) - assert f4.num_energy_bins == len(expected) - 1 - assert f4.num_bins == len(expected) - 1 - - -def test_weight(): - f = openmc.WeightFilter([0.01, 0.1, 1.0, 10.0]) - expected_bins = [[0.01, 0.1], [0.1, 1.0], [1.0, 10.0]] - - assert np.allclose(f.bins, expected_bins) - assert len(f.bins) == 3 - - # Make sure __repr__ works - repr(f) - - # to_xml_element() - elem = f.to_xml_element() - assert elem.tag == 'filter' - assert elem.attrib['type'] == 'weight' - - # from_xml_element() - new_f = openmc.Filter.from_xml_element(elem) - assert new_f.id == f.id - assert np.allclose(new_f.bins, f.bins) - - -def test_mesh_material(): - mat1 = openmc.Material() - mat2 = openmc.Material() - - mesh = openmc.RegularMesh() - mesh.lower_left = (-1., -1., -1.) - mesh.upper_right = (1., 1., 1.) - mesh.dimension = (2, 4, 1) - bins = [(0, mat1), (0, mat2), (6, mat1), (7, mat2)] - f = openmc.MeshMaterialFilter(mesh, bins) - - expected_bins = [(0, mat1.id), (0, mat2.id), (6, mat1.id), (7, mat2.id)] - assert np.allclose(f.bins, expected_bins) - assert f.mesh == mesh - assert f.shape == (4,) - - # to_xml_element() - elem = f.to_xml_element() - assert elem.tag == 'filter' - assert elem.attrib['type'] == 'meshmaterial' - - # from_xml_element() - new_f = openmc.Filter.from_xml_element(elem, meshes={mesh.id: mesh}) - assert isinstance(new_f, openmc.MeshMaterialFilter) - assert new_f.id == f.id - assert new_f.mesh == f.mesh - assert np.allclose(new_f.bins, expected_bins) - - # Test hash and str - hash(f) - str(f) diff --git a/tests/unit_tests/test_ifp.py b/tests/unit_tests/test_ifp.py deleted file mode 100644 index e527f1624..000000000 --- a/tests/unit_tests/test_ifp.py +++ /dev/null @@ -1,88 +0,0 @@ -"""Test the Iterated Fission Probability (IFP) method to compute adjoint-weighted -kinetics parameters using dedicated tallies.""" - -import pytest -import openmc - - -def test_xml_serialization(run_in_tmpdir): - """Check that a simple use case can be written and read in XML.""" - parameter = 5 - settings = openmc.Settings() - settings.ifp_n_generation = parameter - settings.export_to_xml() - - read_settings = openmc.Settings.from_xml() - assert read_settings.ifp_n_generation == parameter - - -@pytest.fixture(scope="module") -def geometry(): - openmc.reset_auto_ids() - material = openmc.Material() - material.add_nuclide("U235", 1.0) - sphere = openmc.Sphere(r=1.0, boundary_type="vacuum") - cell = openmc.Cell(region=-sphere, fill=material) - return openmc.Geometry([cell]) - - -@pytest.mark.parametrize( - "options, error", - [ - ({"ifp_n_generation": 0}, ValueError), - ({"ifp_n_generation": -1}, ValueError), - ({"run_mode": "fixed source"}, RuntimeError), - ({"inactive": 5, "ifp_n_generation": 6}, RuntimeError), - ({"inactive": 9}, RuntimeError) - ], -) -def test_exceptions(options, error, run_in_tmpdir, geometry): - """Test settings configuration that should return an error.""" - with pytest.raises(error): - settings = openmc.Settings(**options) - settings.particles = 100 - settings.batches = 15 - tally = openmc.Tally(name="ifp-scores") - tally.scores = ["ifp-time-numerator", "ifp-beta-numerator", "ifp-denominator"] - tallies = openmc.Tallies([tally]) - model = openmc.Model(geometry=geometry, settings=settings, tallies=tallies) - model.run() - - -@pytest.mark.parametrize( - "num_groups, use_auto_tallies", - [ - (None, True), - (None, False), - (6, True), - (6, False), - ], -) -def test_get_kinetics_parameters(run_in_tmpdir, geometry, num_groups, use_auto_tallies): - # Create basic model - model = openmc.Model(geometry=geometry) - model.settings.particles = 1000 - model.settings.batches = 20 - model.settings.inactive = 5 - model.settings.ifp_n_generation = 5 - - # Add IFP tallies either via the convenience method or manually - if use_auto_tallies: - model.add_kinetics_parameters_tallies(num_groups=num_groups) - else: - for score in ["ifp-time-numerator", "ifp-beta-numerator", "ifp-denominator"]: - tally = openmc.Tally() - tally.scores = [score] - if score == "ifp-beta-numerator" and num_groups is not None: - tally.filters = [openmc.DelayedGroupFilter(list(range(1, num_groups + 1)))] - model.tallies.append(tally) - - # Run and get kinetics parameters - sp_file = model.run() - with openmc.StatePoint(sp_file) as sp: - params = sp.get_kinetics_parameters() - assert isinstance(params, openmc.KineticsParameters) - assert params.generation_time is not None - assert params.beta_effective is not None - if num_groups is not None: - assert len(params.beta_effective) == num_groups diff --git a/tests/unit_tests/test_lib.py b/tests/unit_tests/test_lib.py index 4cfae0df2..e3c7ce3b7 100644 --- a/tests/unit_tests/test_lib.py +++ b/tests/unit_tests/test_lib.py @@ -5,7 +5,6 @@ import os import numpy as np import pytest import openmc -from openmc.examples import random_ray_pin_cell import openmc.exceptions as exc import openmc.lib @@ -84,19 +83,6 @@ def uo2_trigger_model(): yield -@pytest.fixture(scope='module') -def random_ray_pincell_model(): - """Set up a random ray model to test with and delete files when done""" - openmc.reset_auto_ids() - # Write XML and MGXS files in tmpdir - with cdtemp(): - model = random_ray_pin_cell() - model.settings.batches = 200 - model.settings.inactive = 50 - model.settings.particles = 50 - model.export_to_xml() - yield - @pytest.fixture(scope='module') def lib_init(pincell_model, mpi_intracomm): openmc.lib.init(intracomm=mpi_intracomm) @@ -173,34 +159,6 @@ def test_properties_temperature(lib_init): assert cell.get_temperature() == pytest.approx(200.0) -def test_cell_density(lib_init): - cell = openmc.lib.cells[1] - print('density', cell.get_density()) - orig_density = cell.get_density() - try: - cell.set_density(1.5, 0) - assert cell.get_density(0) == pytest.approx(1.5) - cell.set_density(2.0) - assert cell.get_density() == pytest.approx(2.0) - finally: - cell.set_density(orig_density) - - -def test_properties_cell_density(lib_init): - # Cell density should be 2.0 from above test - cell = openmc.lib.cells[1] - orig_density = cell.get_density() - - # Export properties and change density - openmc.lib.export_properties('properties.h5') - cell.set_density(3.0) - assert cell.get_density() == pytest.approx(3.0) - - # Import properties and check that density is restored - openmc.lib.import_properties('properties.h5') - assert cell.get_density() == pytest.approx(orig_density) - - def test_new_cell(lib_init): with pytest.raises(exc.AllocationError): openmc.lib.Cell(1) @@ -251,9 +209,9 @@ def test_material(lib_init): m.name = "Not hot borated water" assert m.name == "Not hot borated water" - assert not m.depletable + assert m.depletable == False m.depletable = True - assert m.depletable + assert m.depletable == True def test_properties_density(lib_init): @@ -510,6 +468,9 @@ def test_set_n_batches(lib_run): for i in range(7): openmc.lib.next_batch() + # Setting n_batches less than current_batch should raise error + with pytest.raises(exc.InvalidArgumentError): + settings.set_batches(6) # n_batches should stay the same assert settings.get_batches() == 10 @@ -609,12 +570,6 @@ def test_regular_mesh(lib_init): np.testing.assert_allclose(mesh.volumes, 1.0) - # bounding box - mesh.set_parameters(lower_left=ll, upper_right=ur) - bbox = mesh.bounding_box - np.testing.assert_allclose(bbox.lower_left, ll) - np.testing.assert_allclose(bbox.upper_right, ur) - meshes = openmc.lib.meshes assert isinstance(meshes, Mapping) assert len(meshes) == 1 @@ -622,13 +577,6 @@ def test_regular_mesh(lib_init): assert isinstance(mesh, openmc.lib.RegularMesh) assert mesh_id == mesh.id - rotation = (180.0, 0.0, 0.0) - - mf = openmc.lib.MeshFilter(mesh) - assert mf.mesh == mesh - mf.rotation = rotation - assert np.allclose(mf.rotation, rotation) - translation = (1.0, 2.0, 3.0) mf = openmc.lib.MeshFilter(mesh) @@ -647,18 +595,18 @@ def test_regular_mesh(lib_init): mesh.set_parameters(lower_left=(-0.63, -0.63, -0.5), upper_right=(0.63, 0.63, 0.5)) vols = mesh.material_volumes() - assert vols.num_elements == 4 - for i in range(vols.num_elements): - elem_vols = vols.by_element(i) + assert len(vols) == 4 + for elem_vols in vols: assert sum(f[1] for f in elem_vols) == pytest.approx(1.26 * 1.26 / 4) - # If the mesh extends beyond the boundaries of the model, we should get a - # GeometryError + # If the mesh extends beyond the boundaries of the model, the volumes should + # still be reported correctly mesh.dimension = (1, 1, 1) mesh.set_parameters(lower_left=(-1.0, -1.0, -0.5), upper_right=(1.0, 1.0, 0.5)) - with pytest.raises(exc.GeometryError, match="not fully contained"): - vols = mesh.material_volumes() + vols = mesh.material_volumes(100_000) + for elem_vols in vols: + assert sum(f[1] for f in elem_vols) == pytest.approx(1.26 * 1.26, 1e-2) def test_regular_mesh_get_plot_bins(lib_init): @@ -702,11 +650,6 @@ def test_rectilinear_mesh(lib_init): np.testing.assert_allclose(mesh.volumes, 1000.0) - # bounding box - bbox = mesh.bounding_box - np.testing.assert_allclose(bbox.lower_left, (-10., 0., 10.)) - np.testing.assert_allclose(bbox.upper_right, (10., 20., 30.)) - with pytest.raises(exc.AllocationError): mesh2 = openmc.lib.RectilinearMesh(mesh.id) @@ -729,11 +672,11 @@ def test_rectilinear_mesh(lib_init): mesh.set_grid([-w/2, -w/4, w/2], [-w/2, -w/4, w/2], [-0.5, 0.5]) vols = mesh.material_volumes() - assert vols.num_elements == 4 - assert sum(f[1] for f in vols.by_element(0)) == pytest.approx(w/4 * w/4) - assert sum(f[1] for f in vols.by_element(1)) == pytest.approx(w/4 * 3*w/4) - assert sum(f[1] for f in vols.by_element(2)) == pytest.approx(3*w/4 * w/4) - assert sum(f[1] for f in vols.by_element(3)) == pytest.approx(3*w/4 * 3*w/4) + assert len(vols) == 4 + assert sum(f[1] for f in vols[0]) == pytest.approx(w/4 * w/4) + assert sum(f[1] for f in vols[1]) == pytest.approx(w/4 * 3*w/4) + assert sum(f[1] for f in vols[2]) == pytest.approx(3*w/4 * w/4) + assert sum(f[1] for f in vols[3]) == pytest.approx(3*w/4 * 3*w/4) def test_cylindrical_mesh(lib_init): @@ -754,11 +697,6 @@ def test_cylindrical_mesh(lib_init): np.testing.assert_allclose(mesh.volumes[::2], 10/360 * pi * 5**2 * 10) np.testing.assert_allclose(mesh.volumes[1::2], 10/360 * pi * (10**2 - 5**2) * 10) - # bounding box - bbox = mesh.bounding_box - np.testing.assert_allclose(bbox.lower_left, (-10., -10., 10.)) - np.testing.assert_allclose(bbox.upper_right, (10., 10., 30.)) - with pytest.raises(exc.AllocationError): mesh2 = openmc.lib.CylindricalMesh(mesh.id) @@ -783,11 +721,11 @@ def test_cylindrical_mesh(lib_init): mesh.set_grid(r_grid, phi_grid, z_grid) vols = mesh.material_volumes() - assert vols.num_elements == 6 + assert len(vols) == 6 for i in range(0, 6, 2): - assert sum(f[1] for f in vols.by_element(i)) == pytest.approx(pi * 0.25**2 / 3) + assert sum(f[1] for f in vols[i]) == pytest.approx(pi * 0.25**2 / 3) for i in range(1, 6, 2): - assert sum(f[1] for f in vols.by_element(i)) == pytest.approx(pi * (0.5**2 - 0.25**2) / 3) + assert sum(f[1] for f in vols[i]) == pytest.approx(pi * (0.5**2 - 0.25**2) / 3) def test_spherical_mesh(lib_init): @@ -812,11 +750,6 @@ def test_spherical_mesh(lib_init): np.testing.assert_allclose(mesh.volumes[2::4], f * 5**3 * dtheta(10., 20.)) np.testing.assert_allclose(mesh.volumes[3::4], f * (10**3 - 5**3) * dtheta(10., 20.)) - # bounding box - bbox = mesh.bounding_box - np.testing.assert_allclose(bbox.lower_left, (-10., -10., -10.)) - np.testing.assert_allclose(bbox.upper_right, (10., 10., 10.)) - with pytest.raises(exc.AllocationError): mesh2 = openmc.lib.SphericalMesh(mesh.id) @@ -841,14 +774,14 @@ def test_spherical_mesh(lib_init): mesh.set_grid(r_grid, theta_grid, phi_grid) vols = mesh.material_volumes() - assert vols.num_elements == 12 + assert len(vols) == 12 d_theta = theta_grid[1] - theta_grid[0] d_phi = phi_grid[1] - phi_grid[0] for i in range(0, 12, 2): - assert sum(f[1] for f in vols.by_element(i)) == pytest.approx( + assert sum(f[1] for f in vols[i]) == pytest.approx( 0.25**3 / 3 * d_theta * d_phi * 2/pi) for i in range(1, 12, 2): - assert sum(f[1] for f in vols.by_element(i)) == pytest.approx( + assert sum(f[1] for f in vols[i]) == pytest.approx( (0.5**3 - 0.25**3) / 3 * d_theta * d_phi * 2/pi) @@ -895,23 +828,22 @@ def test_load_nuclide(lib_init): openmc.lib.load_nuclide('Pu3') -class LegacySlicePlot: - origin = (0.0, 0.0, 0.0) - width = 1.26 - height = 1.26 - basis = 'xy' - h_res = 3 - v_res = 3 - level = -1 - - def test_id_map(lib_init): expected_ids = np.array([[(3, 0, 3), (2, 0, 2), (3, 0, 3)], [(2, 0, 2), (1, 0, 1), (2, 0, 2)], [(3, 0, 3), (2, 0, 2), (3, 0, 3)]], dtype='int32') - with pytest.warns(FutureWarning, match="deprecated"): - ids = openmc.lib.id_map(LegacySlicePlot()) + # create a plot object + s = openmc.lib.plot._PlotBase() + s.width = 1.26 + s.height = 1.26 + s.v_res = 3 + s.h_res = 3 + s.origin = (0.0, 0.0, 0.0) + s.basis = 'xy' + s.level = -1 + + ids = openmc.lib.plot.id_map(s) assert np.array_equal(expected_ids, ids) @@ -921,81 +853,20 @@ def test_property_map(lib_init): [ (293.6, 6.55), (293.6, 10.29769), (293.6, 6.55)], [(293.6, 0.740582), (293.6, 6.55), (293.6, 0.740582)]], dtype='float') - with pytest.warns(FutureWarning, match="deprecated"): - properties = openmc.lib.property_map(LegacySlicePlot()) + # create a plot object + s = openmc.lib.plot._PlotBase() + s.width = 1.26 + s.height = 1.26 + s.v_res = 3 + s.h_res = 3 + s.origin = (0.0, 0.0, 0.0) + s.basis = 'xy' + s.level = -1 + + properties = openmc.lib.plot.property_map(s) assert np.allclose(expected_properties, properties, atol=1e-04) -def test_slice_data(lib_init): - expected_properties = np.array( - [[(293.6, 0.740582), (293.6, 6.55), (293.6, 0.740582)], - [ (293.6, 6.55), (293.6, 10.29769), (293.6, 6.55)], - [(293.6, 0.740582), (293.6, 6.55), (293.6, 0.740582)]], dtype='float') - origin = (0.0, 0.0, 0.0) - _, properties = openmc.lib.slice_data( - origin, - width=(1.26, 1.26), - basis='xy', - pixels=(3, 3), - include_properties=True - ) - assert np.allclose(expected_properties, properties, atol=1e-04) - - -def test_solid_raytrace_plot(lib_init, pincell_model): - # Ensure plot mapping can be accessed and grows after allocation - n0 = len(openmc.lib.plots) - plot = openmc.lib.SolidRayTracePlot() - assert len(openmc.lib.plots) == n0 + 1 - assert plot.id in openmc.lib.plots - assert openmc.lib.plots[plot.id] is plot - - # Exercise plot property getters/setters - plot.pixels = (8, 6) - assert plot.pixels == (8, 6) - - plot.color_by = openmc.lib.SolidRayTracePlot.COLOR_BY_MATERIAL - assert plot.color_by == openmc.lib.SolidRayTracePlot.COLOR_BY_MATERIAL - - plot.camera_position = (2.0, 0.0, 1.0) - plot.look_at = (0.0, 0.0, 0.0) - plot.up = (0.0, 0.0, 1.0) - plot.light_position = (3.0, 2.0, 4.0) - plot.fov = 60.0 - plot.diffuse_fraction = 0.4 - assert plot.camera_position == pytest.approx((2.0, 0.0, 1.0)) - assert plot.look_at == pytest.approx((0.0, 0.0, 0.0)) - assert plot.up == pytest.approx((0.0, 0.0, 1.0)) - assert plot.light_position == pytest.approx((3.0, 2.0, 4.0)) - assert plot.fov == pytest.approx(60.0) - assert plot.diffuse_fraction == pytest.approx(0.4) - - # Exercise color/visibility CAPI wrappers - plot.set_default_colors() - plot.set_color(1, (12, 34, 56)) - assert plot.get_color(1) == (12, 34, 56) - plot.set_visibility(1, False) - plot.set_visibility(1, True) - - # Confirm image creation path works and dimensions match pixels - plot.update_view() - image = plot.create_image() - assert image.shape == (6, 8, 3) - assert image.dtype == np.uint8 - - # Change some properties and confirm image changes - plot.set_color(1, (255, 0, 0)) - plot.update_view() - image2 = plot.create_image() - assert not np.array_equal(image, image2) - - # Solid raytrace uses Phong/diffuse shading, so rendered RGB values are - # generally modulated and need not exactly match the assigned palette. - changed = np.any(image != image2, axis=2) - assert np.any(changed) - assert np.mean(image2[..., 0][changed]) > np.mean(image[..., 0][changed]) - - def test_position(lib_init): pos = openmc.lib.plot._Position(1.0, 2.0, 3.0) @@ -1122,29 +993,9 @@ def test_sample_external_source(run_in_tmpdir, mpi_intracomm): assert p1.time == p2.time assert p1.wgt == p2.wgt - # as_array should return a numpy structured array with matching values - arr = openmc.lib.sample_external_source(10, prn_seed=3, as_array=True) - assert isinstance(arr, np.ndarray) - assert len(arr) == 10 - for p, row in zip(particles, arr): - assert p.r == pytest.approx(row['r']) - assert p.E == pytest.approx(row['E']) - openmc.lib.finalize() # Make sure sampling works in volume calculation mode openmc.lib.init(["-c"]) openmc.lib.sample_external_source(100) openmc.lib.finalize() - - -def test_random_ray(random_ray_pincell_model, mpi_intracomm): - openmc.lib.finalize() - openmc.lib.init(intracomm=mpi_intracomm) - openmc.lib.simulation_init() - openmc.lib.run_random_ray() - keff = openmc.lib.keff() - - assert keff[0]==pytest.approx(1.3236826574065745) - - openmc.lib.finalize() diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 12d363376..44c0730fb 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -3,11 +3,8 @@ from pathlib import Path import pytest -import numpy as np - import openmc from openmc.data import decay_photon_energy -from openmc.deplete import Chain, Nuclide import openmc.examples import openmc.model import openmc.stats @@ -77,13 +74,6 @@ def test_add_components(): with pytest.raises(ValueError): m.add_components({'H1': 1.0}, percent_type = 'oa') - -def test_id(): - openmc.Material(material_id=0) - with pytest.raises(ValueError): - openmc.Material(material_id=-1) - - def test_nuclides_to_ignore(run_in_tmpdir): """Test nuclides_to_ignore when exporting a material to XML""" m = openmc.Material() @@ -390,28 +380,6 @@ def test_get_nuclide_atom_densities_specific(uo2): assert all_nuc['O16'] == one_nuc['O16'] -def test_get_element_atom_densities(uo2): - for element, density in uo2.get_element_atom_densities().items(): - assert element in ('U', 'O') - assert density > 0 - - -def test_get_element_atom_densities_specific(uo2): - one_nuc = uo2.get_element_atom_densities('O') - assert list(one_nuc.keys()) == ['O'] - assert list(one_nuc.values())[0] > 0 - - one_nuc = uo2.get_element_atom_densities('uranium') - assert list(one_nuc.keys()) == ['U'] - assert list(one_nuc.values())[0] > 0 - - with pytest.raises(ValueError, match='not found'): - uo2.get_element_atom_densities('Li') - - with pytest.raises(ValueError, match='not recognized'): - uo2.get_element_atom_densities('proximium') - - def test_get_nuclide_atoms(): mat = openmc.Material() mat.add_nuclide('Li6', 1.0) @@ -488,7 +456,6 @@ def test_borated_water(): # Test the density override m = openmc.model.borated_water(975, 566.5, 15.51, density=0.9) assert m.density == pytest.approx(0.9, 1e-3) - assert m.temperature == pytest.approx(566.5) def test_from_xml(run_in_tmpdir): @@ -544,13 +511,11 @@ def test_mix_materials(): dens4 = 1. / (f0 / m1dens + f1 / m2dens) dens5 = f0*m1dens + f1*m2dens m3 = openmc.Material.mix_materials([m1, m2], [f0, f1], percent_type='ao') - m4 = openmc.Material.mix_materials([m1, m2], [f0, f1], percent_type='wo', material_id=999) - m5 = openmc.Material.mix_materials([m1, m2], [f0, f1], percent_type='vo', name='m5') + m4 = openmc.Material.mix_materials([m1, m2], [f0, f1], percent_type='wo') + m5 = openmc.Material.mix_materials([m1, m2], [f0, f1], percent_type='vo') assert m3.density == pytest.approx(dens3) assert m4.density == pytest.approx(dens4) assert m5.density == pytest.approx(dens5) - assert m4.id == 999 - assert m5.name == 'm5' def test_get_activity(): @@ -561,10 +526,6 @@ def test_get_activity(): m1.add_element("Fe", 0.7) m1.add_element("Li", 0.3) m1.set_density('g/cm3', 1.5) - with pytest.raises(ValueError, match="Volume must be set"): - m1.get_activity(units='Bq') - with pytest.raises(ValueError, match="Volume must be set"): - m1.get_activity(units='Ci') # activity in Bq/cc and Bq/g should not require volume setting assert m1.get_activity(units='Bq/cm3') == 0 assert m1.get_activity(units='Bq/g') == 0 @@ -594,12 +555,9 @@ def test_get_activity(): m4.add_nuclide("H3", 1) m4.set_density('g/cm3', 1.5) assert pytest.approx(m4.get_activity(units='Bq/g')) == 355978108155965.94 # [Bq/g] - assert pytest.approx(m4.get_activity(units='Bq/kg')) == 355978108155965940 # [Bq/kg] assert pytest.approx(m4.get_activity(units='Bq/g', by_nuclide=True)["H3"]) == 355978108155965.94 # [Bq/g] assert pytest.approx(m4.get_activity(units='Bq/cm3')) == 355978108155965.94*3/2 # [Bq/cc] assert pytest.approx(m4.get_activity(units='Bq/cm3', by_nuclide=True)["H3"]) == 355978108155965.94*3/2 # [Bq/cc] - assert pytest.approx(m4.get_activity(units='Bq/m3')) == 355978108155965.94*3/2*1e6 # [Bq/m3] - assert pytest.approx(m4.get_activity(units='Bq/m3', by_nuclide=True)["H3"]) == 355978108155965.94*3/2*1e6 # [Bq/m3] # volume is required to calculate total activity m4.volume = 10. assert pytest.approx(m4.get_activity(units='Bq')) == 355978108155965.94*3/2*10 # [Bq] @@ -607,41 +565,6 @@ def test_get_activity(): # Test with volume specified as argument assert pytest.approx(m4.get_activity(units='Bq', volume=1.0)) == 355978108155965.94*3/2 - # Test units based on Ci - bq = m4.get_activity(units='Bq') - m3 = m4.volume * 1e-6 - assert (ci := m4.get_activity(units='Ci')) == pytest.approx(bq/3.7e10) - assert m4.get_activity(units='Ci/m3') == pytest.approx(ci/m3) - - -def test_get_activity_chain_file(tmp_path): - m = openmc.Material() - m.add_nuclide("H3", 1.0) - m.set_density('g/cm3', 1.0) - - chain = Chain() - h3 = Nuclide("H3") - h3.half_life = 1.0 - chain.add_nuclide(h3) - - atoms_per_bcm = m.get_nuclide_atom_densities()["H3"] - expected = np.log(2.0) * 1e24 * atoms_per_bcm - - assert m.get_activity(chain_file=chain) == pytest.approx(expected) - - chain_path = tmp_path / "chain.xml" - chain.export_to_xml(chain_path) - assert m.get_activity(chain_file=chain_path) == pytest.approx(expected) - - endf_activity = m.get_activity(chain_file=False) - with openmc.config.patch('chain_file', chain_path): - assert m.get_activity() == pytest.approx(expected) - assert m.get_activity(chain_file=False) == pytest.approx(endf_activity) - - stable_chain = Chain() - stable_chain.add_nuclide(Nuclide("H3")) - assert m.get_activity(chain_file=stable_chain) == 0.0 - def test_get_decay_heat(): # Set chain file for testing @@ -652,8 +575,6 @@ def test_get_decay_heat(): m1.add_nuclide("U235", 0.2) m1.add_nuclide("U238", 0.8) m1.set_density('g/cm3', 10.5) - with pytest.raises(ValueError, match="Volume must be set"): - m1.get_decay_heat(units='W') # decay heat in W/cc and W/g should not require volume setting assert m1.get_decay_heat(units='W/cm3') == 0 assert m1.get_decay_heat(units='W/g') == 0 @@ -683,12 +604,9 @@ def test_get_decay_heat(): m4.add_nuclide("I135", 1) m4.set_density('g/cm3', 1.5) assert pytest.approx(m4.get_decay_heat(units='W/g')) == 40175.15720273193 # [W/g] - assert pytest.approx(m4.get_decay_heat(units='W/kg')) == 40175157.20273193 # [W/kg] assert pytest.approx(m4.get_decay_heat(units='W/g', by_nuclide=True)["I135"]) == 40175.15720273193 # [W/g] assert pytest.approx(m4.get_decay_heat(units='W/cm3')) == 40175.15720273193*3/2 # [W/cc] assert pytest.approx(m4.get_decay_heat(units='W/cm3', by_nuclide=True)["I135"]) == 40175.15720273193*3/2 #[W/cc] - assert pytest.approx(m4.get_decay_heat(units='W/m3')) == 40175.15720273193*3/2*1e6 # [W/m3] - assert pytest.approx(m4.get_decay_heat(units='W/m3', by_nuclide=True)["I135"]) == 40175.15720273193*3/2*1e6 # [W/m3] # volume is required to calculate total decay heat m4.volume = 10. assert pytest.approx(m4.get_decay_heat(units='W')) == 40175.15720273193*3/2*10 # [W] @@ -716,11 +634,6 @@ def test_decay_photon_energy(): assert src.p * 2.0 == pytest.approx(src_v2.p) src_per_cm3 = m.get_decay_photon_energy(units='Bq/cm3', volume=100.0) assert (src.p == src_per_cm3.p).all() - src_per_bqg = m.get_decay_photon_energy(units='Bq/g') - src_per_bqkg = m.get_decay_photon_energy(units='Bq/kg') - assert pytest.approx(src_per_bqg.integral()) == src_per_bqkg.integral() / 1000. - src_per_bqm3 = m.get_decay_photon_energy(units='Bq/m3') - assert pytest.approx(src_per_bqm3.integral()) == src_per_cm3.integral() * 1e6 # If we add Xe135 (which has a tabular distribution), the photon source # should be a mixture distribution @@ -748,177 +661,3 @@ def test_decay_photon_energy(): stable.add_nuclide('Gd156', 1.0) stable.volume = 1.0 assert stable.get_decay_photon_energy() is None - - -def test_avoid_subnormal(run_in_tmpdir): - # Write a materials.xml with a material that has a nuclide density that is - # represented as a subnormal floating point value - mat = openmc.Material() - mat.add_nuclide('H1', 1.0) - mat.add_nuclide('H2', 1.0e-315) - mats = openmc.Materials([mat]) - mats.export_to_xml() - - # When read back in, the density should be zero - mats = openmc.Materials.from_xml() - assert mats[0].get_nuclide_atom_densities()['H2'] == 0.0 - - -def test_material_deplete(): - pristine_material = openmc.Material() - pristine_material.add_nuclide("Ni58", 1.0) - pristine_material.set_density("g/cm3", 7.87) - pristine_material.depletable = True - pristine_material.temperature = 293.6 - pristine_material.volume = 1. - - mg_flux = [0.5e11] * 42 - - chain = Chain.from_xml( - Path(__file__).parents[1] / "chain_ni.xml" - ) - - depleted_material = pristine_material.deplete( - multigroup_flux=mg_flux, - energy_group_structure="VITAMIN-J-42", - timesteps=[10, 70.86], - source_rates=[1e19, 0.0], - timestep_units="d", - chain_file=chain, - ) - - for i_step, material in enumerate(depleted_material): - assert isinstance(material, openmc.Material) - if i_step > 0: - assert len(material.get_nuclides()) > len(pristine_material.get_nuclides()) - - Co58_mat_1_step_0 = depleted_material[0].get_nuclide_atom_densities("Co58").get("Co58", 0.0) - Co58_mat_1_step_1 = depleted_material[1].get_nuclide_atom_densities("Co58")["Co58"] - Co58_mat_1_step_2 = depleted_material[2].get_nuclide_atom_densities("Co58")["Co58"] - - assert Co58_mat_1_step_0 == 0.0 - - # Check that Co58 is produced in the first step - assert Co58_mat_1_step_1 > 0.0 - - # Check that Co58 is halved in the second step which is one halflife later - assert np.allclose(Co58_mat_1_step_1 * 0.5, Co58_mat_1_step_2) - - -def test_mean_free_path(): - - mat1 = openmc.Material() - mat1.add_nuclide('Si28', 1.0) - mat1.set_density('g/cm3', 2.32) - assert mat1.mean_free_path(energy=14e6) == pytest.approx(11.41, abs=1e-2) - - mat2 = openmc.Material() - mat2.add_nuclide('Pb208', 1.0) - mat2.set_density('g/cm3', 11.34) - assert mat2.mean_free_path(energy=14e6) == pytest.approx(5.65, abs=1e-2) - - -def test_material_from_constructor(): - # Test that components and percent_type work in the constructor - components = { - 'Li': {'percent': 0.5, 'enrichment': 60.0, 'enrichment_target': 'Li7'}, - 'O16': 1.0, - 'Be': 0.5 - } - mat = openmc.Material( - material_id=123, - name="test-mat", - components=components, - percent_type="ao" - ) - # Check that nuclides were added - nuclide_names = [nuc.name for nuc in mat.nuclides] - assert 'O16' in nuclide_names - assert 'Be9' in nuclide_names - assert 'Li7' in nuclide_names - assert 'Li6' in nuclide_names - assert mat.id == 123 - assert mat.name == "test-mat" - - mat1 = openmc.Material( - **{ - "material_id": 1, - "name": "neutron_star", - "density": 1e17, - "density_units": "kg/m3", - } - ) - assert mat1.id == 1 - assert mat1.name == "neutron_star" - assert mat1._density == 1e17 - assert mat1._density_units == "kg/m3" - assert mat1.nuclides == [] - - mat2 = openmc.Material( - material_id=42, - name="plasma", - temperature=None, - density=1e-7, - density_units="g/cm3", - ) - assert mat2.id == 42 - assert mat2.name == "plasma" - assert mat2.temperature is None - assert mat2.density == 1e-7 - assert mat2.density_units == "g/cm3" - assert mat2.nuclides == [] - - -def test_get_photon_contact_dose_rate(): - # Set chain file for testing - openmc.config['chain_file'] = Path(__file__).parents[1] / 'chain_simple.xml' - - # A purely stable material (Fe) should give zero dose - m_stable = openmc.Material() - m_stable.add_element('Fe', 1.0) - m_stable.set_density('g/cm3', 7.87) - assert m_stable.get_photon_contact_dose_rate('absorbed-air') == 0.0 - assert m_stable.get_photon_contact_dose_rate('effective') == 0.0 - - # I135 has a Discrete photon source (lines) - m_i135 = openmc.Material() - m_i135.add_nuclide('I135', 1.0) - m_i135.set_density('atom/b-cm', 1.0) - - cdr_abs = m_i135.get_photon_contact_dose_rate('absorbed-air') - cdr_eff = m_i135.get_photon_contact_dose_rate('effective') - assert cdr_abs == pytest.approx(6.091547e10, rel=1e-4) # [Gy/h] - assert cdr_eff == pytest.approx(6.102167e10, rel=1e-4) # [Sv/h] - - # Xe135 has a Tabular photon source (continuous distribution) - m_xe135 = openmc.Material() - m_xe135.add_nuclide('Xe135', 1.0) - m_xe135.set_density('atom/b-cm', 1.0) - - cdr_xe_abs = m_xe135.get_photon_contact_dose_rate('absorbed-air') - cdr_xe_eff = m_xe135.get_photon_contact_dose_rate('effective') - assert cdr_xe_abs == pytest.approx(7.886077e8, rel=1e-4) # [Gy/h] - assert cdr_xe_eff == pytest.approx(9.488298e8, rel=1e-4) # [Sv/h] - - # by_nuclide=True should return a dict whose values sum to the total - cdr_by_nuc = m_i135.get_photon_contact_dose_rate('absorbed-air', by_nuclide=True) - assert isinstance(cdr_by_nuc, dict) - assert 'I135' in cdr_by_nuc - assert sum(cdr_by_nuc.values()) == pytest.approx(cdr_abs) - - # For a mixed material the sum over nuclides must equal the total - m_mix = openmc.Material() - m_mix.add_nuclide('I135', 0.5) - m_mix.add_nuclide('Xe135', 0.5) - m_mix.set_density('atom/b-cm', 1.0) - cdr_mix_total = m_mix.get_photon_contact_dose_rate('absorbed-air') - cdr_mix_nuc = m_mix.get_photon_contact_dose_rate('absorbed-air', by_nuclide=True) - assert sum(cdr_mix_nuc.values()) == pytest.approx(cdr_mix_total) - - # Input validation - with pytest.raises(ValueError): - m_i135.get_photon_contact_dose_rate('invalid-quantity') - with pytest.raises(TypeError): - m_i135.get_photon_contact_dose_rate('absorbed-air', build_up='two') - with pytest.raises(ValueError): - m_i135.get_photon_contact_dose_rate('absorbed-air', build_up=-1.0) diff --git a/tests/unit_tests/test_materials.py b/tests/unit_tests/test_materials.py deleted file mode 100644 index 6620402fd..000000000 --- a/tests/unit_tests/test_materials.py +++ /dev/null @@ -1,129 +0,0 @@ -from pathlib import Path - -import pytest - -import openmc -from openmc.deplete import Chain - - -def test_materials_deplete(): - pristine_material_1 = openmc.Material() - pristine_material_1.add_nuclide("Ni58", 1.) - pristine_material_1.set_density("g/cm3", 7.87) - pristine_material_1.depletable = True - pristine_material_1.temperature = 293.6 - pristine_material_1.volume = 1. - - pristine_material_2 = openmc.Material() - pristine_material_2.add_nuclide("Ni60", 1.) - pristine_material_2.set_density("g/cm3", 7.87) - pristine_material_2.depletable = True - pristine_material_2.temperature = 293.6 - pristine_material_2.volume = 1. - - pristine_materials = openmc.Materials([pristine_material_1, pristine_material_2]) - - mg_flux = [0.5e11] * 42 - - chain = Chain.from_xml( - Path(__file__).parents[1] / "chain_ni.xml" - ) - - depleted_material = pristine_materials.deplete( - multigroup_fluxes=[mg_flux, mg_flux], - energy_group_structures=["VITAMIN-J-42", "VITAMIN-J-42"], - timesteps=[100, 100], - source_rates=[1e19, 0.0], - timestep_units="d", - chain_file=chain, - ) - - assert list(depleted_material.keys()) == [pristine_material_1.id, pristine_material_2.id] - for mat_id, materials in depleted_material.items(): - for i_step, material in enumerate(materials): - assert isinstance(material, openmc.Material) - if i_step > 0: - assert len(material.get_nuclides()) > 1 - assert mat_id == material.id - - mats = depleted_material[pristine_material_1.id] - Co58_mat_1_step_0 = mats[0].get_nuclide_atom_densities("Co58").get("Co58", 0.0) - Co58_mat_1_step_1 = mats[1].get_nuclide_atom_densities("Co58")["Co58"] - Co58_mat_1_step_2 = mats[2].get_nuclide_atom_densities("Co58")["Co58"] - - assert Co58_mat_1_step_0 == 0.0 - # Co58 is the main activation product of Ni58 in the first irradiation step. - # It then decays in the second cooling step (flux = 0) - assert Co58_mat_1_step_1 > 0.0 and Co58_mat_1_step_1 > Co58_mat_1_step_2 - - Ni59_mat_1_step_0 = mats[0].get_nuclide_atom_densities("Ni59").get("Ni59", 0.0) - Ni59_mat_1_step_1 = mats[1].get_nuclide_atom_densities("Ni59")["Ni59"] - Ni59_mat_1_step_2 = mats[2].get_nuclide_atom_densities("Ni59")["Ni59"] - - assert Ni59_mat_1_step_0 == 0.0 - # Ni59 is one of the main activation product of Ni60 in the first irradiation - # step. It then decays in the second cooling step (flux = 0) - assert Ni59_mat_1_step_1 > 0.0 and Ni59_mat_1_step_1 > Ni59_mat_1_step_2 - - -def test_export_duplicate_materials_to_xml(run_in_tmpdir): - """ - Test exporting Materials to xml with a duplicate and checking that only - unique entities are exported. - """ - my_mat = openmc.Material(name="my_mat") - my_mat2 = openmc.Material(name="my_mat2") - - materials = openmc.Materials([my_mat, my_mat2, my_mat]) - - materials.export_to_xml("materials.xml") - - materials_in = openmc.Materials.from_xml("materials.xml") - assert len(materials_in) == 2 - - -def test_materials_deplete_length_mismatch(): - mats = openmc.Materials([openmc.Material()]) - - with pytest.raises(ValueError, match="multigroup_fluxes length"): - mats.deplete( - multigroup_fluxes=[], - energy_group_structures=["VITAMIN-J-42"], - timesteps=[1.0], - source_rates=1.0, - ) - - with pytest.raises(ValueError, match="energy_group_structures length"): - mats.deplete( - multigroup_fluxes=[[1.0]], - energy_group_structures=[], - timesteps=[1.0], - source_rates=1.0, - ) - - -def test_materials_deplete_missing_volume(monkeypatch): - mat = openmc.Material() - mat.add_nuclide("Ni58", 1.0) - mat.set_density("g/cm3", 7.87) - - mats = openmc.Materials([mat]) - - class DummySession: - def __enter__(self): - return self - - def __exit__(self, exc_type, exc, tb): - return False - - monkeypatch.setattr(openmc.lib, "TemporarySession", DummySession) - - chain = Path(__file__).parents[1] / "chain_ni.xml" - with pytest.raises(ValueError, match="has no volume"): - mats.deplete( - multigroup_fluxes=[[1.0]], - energy_group_structures=["VITAMIN-J-42"], - timesteps=[1.0], - source_rates=1.0, - chain_file=chain, - ) diff --git a/tests/unit_tests/test_mcpl_stat_sum.py b/tests/unit_tests/test_mcpl_stat_sum.py deleted file mode 100644 index b69192956..000000000 --- a/tests/unit_tests/test_mcpl_stat_sum.py +++ /dev/null @@ -1,69 +0,0 @@ -"""Test for MCPL stat:sum functionality""" - -from pathlib import Path -import shutil - -import pytest -import openmc - - -@pytest.mark.skipif(shutil.which("mcpl-config") is None, reason="MCPL is not available.") -def test_mcpl_stat_sum_field(run_in_tmpdir): - """Test that MCPL files contain proper stat:sum field with particle count. - - This test verifies that when OpenMC creates MCPL source files, they contain - the stat:sum field. Since MCPL functions are not exposed in the Python API, - this test creates an actual OpenMC simulation to generate MCPL files and - then checks their content. - """ - - mcpl = pytest.importorskip("mcpl") - - # Create a minimal working model that will generate MCPL files - model = openmc.examples.pwr_pin_cell() - model.settings.batches = 5 - model.settings.inactive = 2 - model.settings.particles = 1000 - model.settings.sourcepoint = {'mcpl': True, 'separate': True} - - # Run a short simulation to generate MCPL files - model.run(output=False) - - # Find the generated MCPL file (from the last batch) - mcpl_file = Path('source.5.mcpl') - assert mcpl_file.exists(), "No MCPL files were generated" - - # Open and verify the stat:sum field exists - with mcpl.MCPLFile(mcpl_file) as f: - # Check if stat:sum field exists using convenience property - if hasattr(f, 'stat_sum'): - # Use the convenience .stat_sum property directly - stat_sum_dict = f.stat_sum - assert 'openmc_np1' in stat_sum_dict, "openmc_np1 key not found in stat_sum" - stat_sum_value = int(stat_sum_dict['openmc_np1']) - else: - # Fallback to checking comments for older MCPL versions - comments = f.comments - - # Check for stat:sum in comments (MCPL stores these as comments) - stat_sum_value = None - - for comment in comments: - if 'stat:sum:openmc_np1' in comment: - # Extract the value - parts = comment.split(':') - if len(parts) >= 4: - stat_sum_value = int(parts[3].strip()) - break - else: - pytest.skip("stat:sum field not found - may be running with MCPL < 2.1.0") - - # Verify the stat:sum value is reasonable - assert stat_sum_value != -1, "stat:sum was not updated from initial -1 value" - - # In eigenvalue mode, active batches generate source particles - active_batches = model.settings.batches - model.settings.inactive # 3 active batches - expected_particles = active_batches * model.settings.particles # 3000 total - - assert stat_sum_value == expected_particles, \ - f"stat:sum value {stat_sum_value} doesn't match expected {expected_particles}" diff --git a/tests/unit_tests/test_mesh.py b/tests/unit_tests/test_mesh.py index 9b1469fc5..ed08be816 100644 --- a/tests/unit_tests/test_mesh.py +++ b/tests/unit_tests/test_mesh.py @@ -1,17 +1,8 @@ -from math import pi, sqrt -from tempfile import TemporaryDirectory -from pathlib import Path -import itertools -import random +from math import pi -import h5py import numpy as np -from scipy.stats import chi2 import pytest import openmc -import openmc.lib -from openmc.utility_funcs import change_directory -from uncertainties.unumpy import uarray, nominal_values, std_devs @pytest.mark.parametrize("val_left,val_right", [(0, 0), (-1., -1.), (2.0, 2)]) @@ -366,27 +357,6 @@ def test_CylindricalMesh_get_indices_at_coords(): assert mesh.get_indices_at_coords([102, 199.1, 299]) == (0, 3, 0) # forth angle quadrant -def test_mesh_name_roundtrip(run_in_tmpdir): - - mesh = openmc.RegularMesh() - mesh.name = 'regular-mesh' - mesh.lower_left = (-1, -1, -1) - mesh.width = (1, 1, 1) - mesh.dimension = (1, 1, 1) - - mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() - tally.filters = [mesh_filter] - tally.scores = ['flux'] - - openmc.Tallies([tally]).export_to_xml() - - xml_tallies = openmc.Tallies.from_xml() - - mesh = xml_tallies[0].find_filter(openmc.MeshFilter).mesh - assert mesh.name == 'regular-mesh' - - def test_umesh_roundtrip(run_in_tmpdir, request): umesh = openmc.UnstructuredMesh(request.path.parent / 'test_mesh_tets.e', 'moab') umesh.output = True @@ -407,193 +377,6 @@ def test_umesh_roundtrip(run_in_tmpdir, request): assert umesh.id == xml_mesh.id -@pytest.fixture(scope='module') -def simple_umesh(request): - """Fixture returning UnstructuredMesh with all attributes""" - surf1 = openmc.Sphere(r=20.0, boundary_type="vacuum") - material1 = openmc.Material() - material1.add_element("H", 1.0) - material1.set_density('g/cm3', 1.0) - - materials = openmc.Materials([material1]) - cell1 = openmc.Cell(region=-surf1, fill=material1) - geometry = openmc.Geometry([cell1]) - - umesh = openmc.UnstructuredMesh( - filename=request.path.parent.parent - / "regression_tests/external_moab/test_mesh_tets.h5m", - library="moab", - mesh_id=1 - ) - # setting ID to make it easier to get the mesh from the statepoint later - mesh_filter = openmc.MeshFilter(umesh) - - # Create flux mesh tally to score alpha production - mesh_tally = openmc.Tally(name="test_tally") - mesh_tally.filters = [mesh_filter] - mesh_tally.scores = ["total"] - - tallies = openmc.Tallies([mesh_tally]) - - settings = openmc.Settings() - settings.run_mode = "fixed source" - settings.batches = 2 - settings.particles = 100 - settings.source = openmc.IndependentSource( - space=openmc.stats.Point((0.1, 0.1, 0.1)) - ) - - model = openmc.Model( - materials=materials, geometry=geometry, settings=settings, tallies=tallies - ) - - with change_directory(tmpdir=True): - statepoint_file = model.run() - with openmc.StatePoint(statepoint_file) as sp: - return sp.meshes[1] - - -@pytest.mark.skipif(not openmc.lib._dagmc_enabled(), reason="DAGMC not enabled.") -@pytest.mark.parametrize('export_type', ('.vtk', '.vtu')) -def test_umesh(run_in_tmpdir, simple_umesh, export_type): - """Performs a minimal UnstructuredMesh simulation, reads in the resulting - statepoint file and writes the mesh data to vtk and vtkhdf files. It is - necessary to read in the unstructured mesh from a statepoint file to ensure - it has all the required attributes - """ - # Get VTK modules - vtkIOLegacy = pytest.importorskip("vtkmodules.vtkIOLegacy") - vtkIOXML = pytest.importorskip("vtkmodules.vtkIOXML") - - # Sample some random data and write to VTK - rng = np.random.default_rng() - ref_data = rng.random(simple_umesh.dimension) - filename = f"test_mesh{export_type}" - simple_umesh.write_data_to_vtk(datasets={"mean": ref_data}, filename=filename) - - assert Path(filename).exists() - - if export_type == ".vtk": - reader = vtkIOLegacy.vtkGenericDataObjectReader() - elif export_type == ".vtu": - reader = vtkIOXML.vtkXMLGenericDataObjectReader() - reader.SetFileName(str(filename)) - reader.Update() - - # Get mean from file and make sure it matches original data - arr = reader.GetOutput().GetCellData().GetArray("mean") - mean = np.array([arr.GetTuple1(i) for i in range(ref_data.size)]) - np.testing.assert_almost_equal(mean, ref_data) - - # attempt to apply a dataset with an improper size to a VTK write - with pytest.raises(ValueError, match='Cannot apply dataset "mean"'): - simple_umesh.write_data_to_vtk(datasets={'mean': ref_data[:-2]}, filename=filename) - - -vtkhdf_tests = [ - ( - Path("test_mesh_dagmc_tets.vtk"), - "moab" - ), - ( - Path("test_mesh_hexes.exo"), - "libmesh" - ) -] -@pytest.mark.parametrize('mesh_file, mesh_library', vtkhdf_tests) -def test_write_vtkhdf(mesh_file, mesh_library, request, run_in_tmpdir): - """Performs a minimal UnstructuredMesh simulation, reads in the resulting - statepoint file and writes the mesh data to vtk and vtkhdf files. It is - necessary to read in the unstructured mesh from a statepoint file to ensure - it has all the required attributes - """ - if mesh_library == 'moab' and not openmc.lib._dagmc_enabled(): - pytest.skip("DAGMC not enabled.") - if mesh_library == 'libmesh' and not openmc.lib._libmesh_enabled(): - pytest.skip("LibMesh not enabled.") - - model = openmc.Model() - - surf1 = openmc.Sphere(r=1000.0, boundary_type="vacuum") - cell1 = openmc.Cell(region=-surf1) - model.geometry = openmc.Geometry([cell1]) - - umesh = openmc.UnstructuredMesh( - request.path.parent / mesh_file, - mesh_library, - mesh_id = 1 - ) - mesh_filter = openmc.MeshFilter(umesh) - - # Create flux mesh tally to score alpha production - mesh_tally = openmc.Tally(name="test_tally") - mesh_tally.filters = [mesh_filter] - mesh_tally.scores = ["flux"] - if mesh_library == "libmesh": - mesh_tally.estimator = "collision" - - model.tallies = [mesh_tally] - - model.settings.run_mode = "fixed source" - model.settings.batches = 2 - model.settings.particles = 10 - - statepoint_file = model.run() - - with openmc.StatePoint(statepoint_file) as statepoint: - my_tally = statepoint.get_tally(name="test_tally") - - umesh_from_sp = statepoint.meshes[umesh.id] - - datasets={ - "mean": my_tally.mean.flatten(), - "std_dev": my_tally.std_dev.flatten() - } - - umesh_from_sp.write_data_to_vtk(datasets=datasets, filename="test_mesh.vtkhdf") - umesh_from_sp.write_data_to_vtk(datasets=datasets, filename="test_mesh.vtk") - - with pytest.raises(ValueError, match="Unsupported file extension"): - # Supported file extensions are vtk or vtkhdf, not hdf5, so this should raise an error - umesh_from_sp.write_data_to_vtk( - datasets=datasets, - filename="test_mesh.hdf5", - ) - with pytest.raises(ValueError, match="Cannot apply dataset"): - # The shape of the data should match the shape of the mesh, so this should raise an error - umesh_from_sp.write_data_to_vtk( - datasets={'incorrectly_shaped_data': np.array(([1,2,3]))}, - filename="test_mesh_incorrect_shape.vtkhdf", - ) - - assert Path("test_mesh.vtk").exists() - assert Path("test_mesh.vtkhdf").exists() - - # just ensure we can open the file without error - with h5py.File("test_mesh.vtkhdf", "r"): - ... - - import vtk - reader = vtk.vtkHDFReader() - reader.SetFileName("test_mesh.vtkhdf") - reader.Update() - - # Get mean from file and make sure it matches original data - num_elements = reader.GetOutput().GetNumberOfCells() - assert num_elements == umesh_from_sp.n_elements - - num_vertices = reader.GetOutput().GetNumberOfPoints() - assert num_vertices == umesh_from_sp.vertices.shape[0] - - arr = reader.GetOutput().GetCellData().GetArray("mean") - mean = np.array([arr.GetTuple1(i) for i in range(my_tally.mean.size)]) - np.testing.assert_almost_equal(mean, my_tally.mean.flatten()/umesh_from_sp.volumes) - - arr = reader.GetOutput().GetCellData().GetArray("std_dev") - std_dev = np.array([arr.GetTuple1(i) for i in range(my_tally.std_dev.size)]) - np.testing.assert_almost_equal(std_dev, my_tally.std_dev.flatten()/umesh_from_sp.volumes) - - def test_mesh_get_homogenized_materials(): """Test the get_homogenized_materials method""" # Simple model with 1 cm of Fe56 next to 1 cm of H1 @@ -619,7 +402,7 @@ def test_mesh_get_homogenized_materials(): mesh.lower_left = (-1., -1., -1.) mesh.upper_right = (1., 1., 1.) mesh.dimension = (3, 1, 1) - m1, m2, m3 = mesh.get_homogenized_materials(model, n_samples=10_000) + m1, m2, m3 = mesh.get_homogenized_materials(model, n_samples=1_000_000) # Left mesh element should be only Fe56 assert m1.get_mass_density('Fe56') == pytest.approx(5.0) @@ -635,7 +418,7 @@ def test_mesh_get_homogenized_materials(): mesh_void.lower_left = (0.5, 0.5, -1.) mesh_void.upper_right = (1.5, 1.5, 1.) mesh_void.dimension = (1, 1, 1) - m4, = mesh_void.get_homogenized_materials(model, n_samples=(100, 100, 0)) + m4, = mesh_void.get_homogenized_materials(model, n_samples=1_000_000) # Mesh element that overlaps void should have half density assert m4.get_mass_density('H1') == pytest.approx(0.5, rel=1e-2) @@ -645,512 +428,3 @@ def test_mesh_get_homogenized_materials(): m5, = mesh_void.get_homogenized_materials( model, n_samples=1000, include_void=False) assert m5.get_mass_density('H1') == pytest.approx(1.0) - - -@pytest.fixture -def sphere_model(): - openmc.reset_auto_ids() - # Model with three materials separated by planes x=0 and z=0 - mats = [] - for i in range(3): - mat = openmc.Material() - mat.add_nuclide('H1', 1.0) - mat.set_density('g/cm3', float(i + 1)) - mats.append(mat) - - sph = openmc.Sphere(r=25.0, boundary_type='vacuum') - x0 = openmc.XPlane(0.0) - z0 = openmc.ZPlane(0.0) - cell1 = openmc.Cell(fill=mats[0], region=-sph & +x0 & +z0) - cell2 = openmc.Cell(fill=mats[1], region=-sph & -x0 & +z0) - cell3 = openmc.Cell(fill=mats[2], region=-sph & -z0) - model = openmc.Model() - model.geometry = openmc.Geometry([cell1, cell2, cell3]) - model.materials = openmc.Materials(mats) - return model - - -@pytest.mark.parametrize("n_rays", [1000, (10, 10, 0), (10, 0, 10), (0, 10, 10)]) -def test_material_volumes_regular_mesh(sphere_model, n_rays): - """Test the material_volumes method on a regular mesh""" - mesh = openmc.RegularMesh() - mesh.lower_left = (-1., -1., -1.) - mesh.upper_right = (1., 1., 1.) - mesh.dimension = (2, 2, 2) - volumes = mesh.material_volumes(sphere_model, n_rays) - mats = sphere_model.materials - np.testing.assert_almost_equal(volumes[mats[0].id], [0., 0., 0., 0., 0., 1., 0., 1.]) - np.testing.assert_almost_equal(volumes[mats[1].id], [0., 0., 0., 0., 1., 0., 1., 0.]) - np.testing.assert_almost_equal(volumes[mats[2].id], [1., 1., 1., 1., 0., 0., 0., 0.]) - assert volumes.by_element(4) == [(mats[1].id, 1.)] - assert volumes.by_element(0) == [(mats[2].id, 1.)] - - -def test_material_volumes_cylindrical_mesh(sphere_model): - """Test the material_volumes method on a cylindrical mesh""" - cyl_mesh = openmc.CylindricalMesh( - [0., 1.], [-1., 0., 1.,], [0.0, pi/4, 3*pi/4, 5*pi/4, 7*pi/4, 2*pi]) - volumes = cyl_mesh.material_volumes(sphere_model, (0, 100, 100)) - mats = sphere_model.materials - np.testing.assert_almost_equal(volumes[mats[0].id], [ - 0., 0., 0., 0., 0., - pi/8, pi/8, 0., pi/8, pi/8 - ]) - np.testing.assert_almost_equal(volumes[mats[1].id], [ - 0., 0., 0., 0., 0., - 0., pi/8, pi/4, pi/8, 0. - ]) - np.testing.assert_almost_equal(volumes[mats[2].id], [ - pi/8, pi/4, pi/4, pi/4, pi/8, - 0., 0., 0., 0., 0. - ]) - - -def test_mesh_material_volumes_serialize(): - materials = np.array([ - [1, -1, -2], - [-1, -2, -2], - [2, 1, -2], - [2, -2, -2] - ]) - volumes = np.array([ - [0.5, 0.5, 0.0], - [1.0, 0.0, 0.0], - [0.5, 0.5, 0.0], - [1.0, 0.0, 0.0] - ]) - volumes = openmc.MeshMaterialVolumes(materials, volumes) - with TemporaryDirectory() as tmpdir: - path = f'{tmpdir}/volumes.npz' - volumes.save(path) - new_volumes = openmc.MeshMaterialVolumes.from_npz(path) - - assert new_volumes.by_element(0) == [(1, 0.5), (None, 0.5)] - assert new_volumes.by_element(1) == [(None, 1.0)] - assert new_volumes.by_element(2) == [(2, 0.5), (1, 0.5)] - assert new_volumes.by_element(3) == [(2, 1.0)] - - -def test_mesh_material_volumes_serialize_with_bboxes(): - materials = np.array([ - [1, -1, -2], - [-1, -2, -2], - [2, 1, -2], - [2, -2, -2] - ]) - volumes = np.array([ - [0.5, 0.5, 0.0], - [1.0, 0.0, 0.0], - [0.5, 0.5, 0.0], - [1.0, 0.0, 0.0] - ]) - - # (xmin, ymin, zmin, xmax, ymax, zmax) - bboxes = np.empty((4, 3, 6)) - bboxes[..., 0:3] = np.inf - bboxes[..., 3:6] = -np.inf - bboxes[0, 0] = [-1.0, -2.0, -3.0, 1.0, 2.0, 3.0] # material 1 - bboxes[0, 1] = [-5.0, -6.0, -7.0, 5.0, 6.0, 7.0] # void - bboxes[1, 0] = [0.0, 0.0, 0.0, 10.0, 1.0, 2.0] # void - bboxes[2, 0] = [-1.0, -1.0, -1.0, 0.0, 0.0, 0.0] # material 2 - bboxes[2, 1] = [0.0, 0.0, 0.0, 1.0, 1.0, 1.0] # material 1 - bboxes[3, 0] = [-2.0, -2.0, -2.0, 2.0, 2.0, 2.0] # material 2 - - mmv = openmc.MeshMaterialVolumes(materials, volumes, bboxes) - with TemporaryDirectory() as tmpdir: - path = f'{tmpdir}/volumes_bboxes.npz' - mmv.save(path) - loaded = openmc.MeshMaterialVolumes.from_npz(path) - - assert loaded.has_bounding_boxes - first = loaded.by_element(0, include_bboxes=True)[0][2] - assert isinstance(first, openmc.BoundingBox) - np.testing.assert_array_equal(first.lower_left, (-1.0, -2.0, -3.0)) - np.testing.assert_array_equal(first.upper_right, (1.0, 2.0, 3.0)) - - second = loaded.by_element(0, include_bboxes=True)[1][2] - assert isinstance(second, openmc.BoundingBox) - np.testing.assert_array_equal(second.lower_left, (-5.0, -6.0, -7.0)) - np.testing.assert_array_equal(second.upper_right, (5.0, 6.0, 7.0)) - - -def test_mesh_material_volumes_boundary_conditions(sphere_model): - """Test the material volumes method using a regular mesh - that overlaps with a vacuum boundary condition.""" - - mesh = openmc.SphericalMesh.from_domain(sphere_model.geometry, dimension=(1, 1, 1)) - # extend mesh beyond the outer sphere surface to test rays crossing the boundary condition - mesh.r_grid[-1] += 5.0 - - # add a new cell to the modelthat occupies the outside of the sphere - sphere_surfaces = list(filter(lambda s: isinstance(s, openmc.Sphere), - sphere_model.geometry.get_all_surfaces().values())) - outer_cell = openmc.Cell(region=+sphere_surfaces[0]) - sphere_model.geometry.root_universe.add_cell(outer_cell) - - volumes = mesh.material_volumes(sphere_model, (0, 100, 100)) - sphere_volume = 4/3*np.pi*25**3 - mats = sphere_model.materials - expected_volumes = [(mats[0].id, 0.25*sphere_volume), - (mats[1].id, 0.25*sphere_volume), - (mats[2].id, 0.5*sphere_volume), - (None, 4/3*np.pi*mesh.r_grid[-1]**3 - sphere_volume)] - - for evaluated, expected in zip(volumes.by_element(0), expected_volumes): - assert evaluated[0] == expected[0] - assert evaluated[1] == pytest.approx(expected[1], rel=1e-2) - - -def test_mesh_material_volumes_bounding_boxes(): - # Create a model with 8 spherical cells at known locations with random radii - box = openmc.model.RectangularParallelepiped( - -10, 10, -10, 10, -10, 10, boundary_type='vacuum') - - mat = openmc.Material() - mat.add_nuclide('H1', 1.0) - - sph_cells = [] - for x, y, z in itertools.product((-5., 5.), repeat=3): - mat_i = mat.clone() - sph = openmc.Sphere(x, y, z, r=random.uniform(0.5, 1.5)) - sph_cells.append(openmc.Cell(region=-sph, fill=mat_i)) - background = openmc.Cell(region=-box & openmc.Intersection([~c.region for c in sph_cells])) - - model = openmc.Model() - model.geometry = openmc.Geometry(sph_cells + [background]) - model.settings.particles = 1000 - model.settings.batches = 10 - - # Create a one-element mesh that encompasses the entire geometry - mesh = openmc.RegularMesh() - mesh.lower_left = (-10., -10., -10.) - mesh.upper_right = (10., 10., 10.) - mesh.dimension = (1, 1, 1) - - # Run material volume calculation with bounding boxes - n_samples = (400, 400, 400) - mmv = mesh.material_volumes(model, n_samples, max_materials=10, bounding_boxes=True) - assert mmv.has_bounding_boxes - - # Create a mapping of material ID to bounding box - bbox_by_mat = { - mat_id: bbox - for mat_id, vol, bbox in mmv.by_element(0, include_bboxes=True) - if mat_id is not None and vol > 0.0 - } - - # Match the mesh ray spacing used for the bounding box estimator. - tol = 0.5 * mesh.bounding_box.width[0] / n_samples[0] - for cell in sph_cells: - bbox = bbox_by_mat[cell.fill.id] - cell_bbox = cell.bounding_box - np.testing.assert_allclose(bbox.lower_left, cell_bbox.lower_left, atol=tol) - np.testing.assert_allclose(bbox.upper_right, cell_bbox.upper_right, atol=tol) - - -def test_raytrace_mesh_infinite_loop(run_in_tmpdir): - # Create a model with one large spherical cell - sphere = openmc.Sphere(r=100, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - - # Create a regular mesh and associated tally - mesh_surface = openmc.RegularMesh() - mesh_surface.lower_left = (-30, -30, 30) - mesh_surface.upper_right = (30, 30, 60) - mesh_surface.dimension = (1, 1, 1) - reg_filter = openmc.MeshSurfaceFilter(mesh_surface) - mesh_surface_tally = openmc.Tally() - mesh_surface_tally.filters = [reg_filter] - mesh_surface_tally.scores = ['current'] - model.tallies = [mesh_surface_tally] - - # Define a source such that the z position is on a mesh boundary with a very - # small directional cosine in the z direction - polar = openmc.stats.delta_function(1.75e-7) - azimuthal = openmc.stats.Uniform(0.0, 2.0*pi) - model.settings.source = openmc.IndependentSource( - angle=openmc.stats.PolarAzimuthal(polar, azimuthal) - ) - model.settings.run_mode = 'fixed source' - model.settings.particles = 10 - model.settings.batches = 1 - - # Run the model; this should not cause an infinite loop - model.run() - - -def test_filter_time_mesh(run_in_tmpdir): - """Test combination of TimeFilter and MeshFilter""" - - # Define material - mat = openmc.Material() - mat.add_nuclide('Fe56', 1.0) - mat.set_density('g/cm3', 7.8) - - # Define geometry - surf_Z1 = openmc.XPlane(x0=-1e10, boundary_type="reflective") - surf_Z2 = openmc.XPlane(x0=1e10, boundary_type="reflective") - cell_F = openmc.Cell(fill=mat, region=+surf_Z1 & -surf_Z2) - model = openmc.Model() - model.geometry = openmc.Geometry([cell_F]) - - # Define settings - model.settings.run_mode = "fixed source" - model.settings.particles = 1000 - model.settings.batches = 20 - model.settings.output = {"tallies": False} - model.settings.cutoff = {"time_neutron": 1e-7} - - # Define tallies - - # Create a mesh filter that can be used in a tally - mesh = openmc.RegularMesh() - mesh.dimension = (21, 1, 1) - mesh.lower_left = (-20.5, -1e10, -1e10) - mesh.upper_right = (20.5, 1e10, 1e10) - time_grid = np.linspace(0.0, 1e-7, 21) - - mesh_filter = openmc.MeshFilter(mesh) - time_filter = openmc.TimeFilter(time_grid) - - # Now use the mesh filter in a tally and indicate what scores are desired - tally1 = openmc.Tally(name="collision") - tally1.estimator = "collision" - tally1.filters = [time_filter, mesh_filter] - tally1.scores = ["flux"] - tally2 = openmc.Tally(name="tracklength") - tally2.estimator = "tracklength" - tally2.filters = [time_filter, mesh_filter] - tally2.scores = ["flux"] - model.tallies = openmc.Tallies([tally1, tally2]) - - # Run and post-process - model.run(apply_tally_results=True) - - # Get radial flux distribution - flux_collision = tally1.mean.ravel() - flux_collision_unc = tally1.std_dev.ravel() - flux_tracklength = tally2.mean.ravel() - flux_tracklength_unc = tally2.std_dev.ravel() - - # Construct arrays with uncertainties - collision = uarray(flux_collision, flux_collision_unc) - tracklength = uarray(flux_tracklength, flux_tracklength_unc) - delta = collision - tracklength - - # Compute differences and standard deviations - diff = nominal_values(delta) - std_dev = std_devs(delta) - - # Exclude zero-uncertainty bins - mask = std_dev > 0.0 - dof = int(np.sum(mask)) - - # Global chi-square consistency test between collision and tracklength - # estimators. Target false positive rate ~1e-4 (1 in 10,000) - z = diff[mask] / std_dev[mask] - chi2_stat = np.sum(z * z) - alpha = 1.0e-4 - crit = chi2.ppf(1 - alpha, dof) - assert chi2_stat < crit, ( - f"Collision vs tracklength tallies disagree: chi2={chi2_stat:.2f} " - f">= {crit=:.2f} ({dof=}, {alpha=})" - ) - - -def test_regular_mesh_get_indices_at_coords(): - """Test get_indices_at_coords method for RegularMesh""" - # Create a 10x10x10 mesh from (0,0,0) to (1,1,1) - # Each voxel is 0.1 x 0.1 x 0.1 - mesh = openmc.RegularMesh() - mesh.lower_left = (0, 0, 0) - mesh.upper_right = (1, 1, 1) - mesh.dimension = [10, 10, 10] - - # Test lower-left corner maps to first voxel (0, 0, 0) - assert mesh.get_indices_at_coords([0.0, 0.0, 0.0]) == (0, 0, 0) - - # Test centroid of first voxel - # Voxel 0 spans [0.0, 0.1], so centroid is at 0.05 - assert mesh.get_indices_at_coords([0.05, 0.05, 0.05]) == (0, 0, 0) - - # Test centroid of last voxel maps correctly - # Voxel 9 spans [0.9, 1.0], so centroid is at 0.95 - assert mesh.get_indices_at_coords([0.95, 0.95, 0.95]) == (9, 9, 9) - - # Test a middle voxel - # Voxel 4 spans [0.4, 0.5], so 0.45 should map to it - assert mesh.get_indices_at_coords([0.45, 0.45, 0.45]) == (4, 4, 4) - - # Test mixed indices - assert mesh.get_indices_at_coords([0.05, 0.45, 0.95]) == (0, 4, 9) - assert mesh.get_indices_at_coords([0.95, 0.05, 0.45]) == (9, 0, 4) - - # Test coordinates outside mesh bounds raise ValueError - with pytest.raises(ValueError): - mesh.get_indices_at_coords([-0.5, 0.5, 0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([1.5, 0.5, 0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([0.5, -0.5, 0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([0.5, 1.5, 0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([0.5, 0.5, -0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([0.5, 0.5, 1.5]) - - # Test that results match expected dimensionality (3D mesh returns 3-tuple) - result = mesh.get_indices_at_coords([0.5, 0.5, 0.5]) - assert isinstance(result, tuple) - assert len(result) == 3 - - # Test that indices can be used directly with centroids array - idx = mesh.get_indices_at_coords([0.95, 0.95, 0.95]) - centroid = mesh.centroids[idx] - np.testing.assert_array_almost_equal(centroid, [0.95, 0.95, 0.95]) - - # Test with a 2D mesh - mesh_2d = openmc.RegularMesh() - mesh_2d.lower_left = (0, 0) - mesh_2d.upper_right = (1, 1) - mesh_2d.dimension = [10, 10] - result_2d = mesh_2d.get_indices_at_coords([0.5, 0.5, 999.0]) - assert isinstance(result_2d, tuple) - assert len(result_2d) == 2 - assert result_2d == (5, 5) - - # Test with a 1D mesh - mesh_1d = openmc.RegularMesh() - mesh_1d.lower_left = [0] - mesh_1d.upper_right = [1] - mesh_1d.dimension = [10] - result_1d = mesh_1d.get_indices_at_coords([0.5, 999.0, 999.0]) - assert isinstance(result_1d, tuple) - assert len(result_1d) == 1 - assert result_1d == (5,) - - -def test_rectilinear_mesh_get_indices_at_coords(): - """Test get_indices_at_coords method for RectilinearMesh""" - # Create a 3x2x2 rectilinear mesh with non-uniform spacing - mesh = openmc.RectilinearMesh() - mesh.x_grid = [0., 1., 5., 10.] - mesh.y_grid = [-10., -5., 0.] - mesh.z_grid = [-100., 0., 100.] - - # Test lower-left corner maps to first voxel (0, 0, 0) - assert mesh.get_indices_at_coords([0.0, -10., -100.]) == (0, 0, 0) - - # Test centroid of first voxel - assert mesh.get_indices_at_coords([0.5, -7.5, -50.]) == (0, 0, 0) - - # Test centroid of last voxel maps correctly - assert mesh.get_indices_at_coords([7.5, -2.5, 50.]) == (2, 1, 1) - - # Test upper_right corner maps to last voxel - assert mesh.get_indices_at_coords([10., 0., 100.]) == (2, 1, 1) - - # Test a middle voxel - assert mesh.get_indices_at_coords([2., -5., 0.]) == (1, 1, 1) - - # Test coordinates outside mesh bounds raise ValueError - with pytest.raises(ValueError): - mesh.get_indices_at_coords([-0.5, 0.5, 0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([1.5, 0.5, 0.5]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([0.5, -0.5, 110.]) - with pytest.raises(ValueError): - mesh.get_indices_at_coords([0.5, -20., 110.]) - - -def test_SphericalMesh_get_indices_at_coords(): - """Test get_indices_at_coords method for SphericalMesh""" - - # Basic mesh with default phi and theta grids (single angular bin) - mesh = openmc.SphericalMesh(r_grid=(0, 5, 10)) - - assert mesh.get_indices_at_coords([3, 0, 0]) == (0, 0, 0) - assert mesh.get_indices_at_coords([0, 0, 3]) == (0, 0, 0) - assert mesh.get_indices_at_coords([0, 0, -3]) == (0, 0, 0) - assert mesh.get_indices_at_coords([7, 0, 0]) == (1, 0, 0) - assert mesh.get_indices_at_coords([10, 0, 0]) == (1, 0, 0) - - # Out-of-bounds r - with pytest.raises(ValueError): - mesh.get_indices_at_coords([11, 0, 0]) - - mesh2 = openmc.SphericalMesh(r_grid=(2, 5, 10)) - with pytest.raises(ValueError): - mesh2.get_indices_at_coords([1, 0, 0]) - - # Multi-bin angular grids: use points clearly inside bins - mesh3 = openmc.SphericalMesh( - r_grid=(0, 5, 10), - theta_grid=(0, pi/4, pi/2, pi), - phi_grid=(0, pi/2, pi, 3*pi/2, 2*pi) - ) - - # Near z-axis: theta~0 -> bin 0 - assert mesh3.get_indices_at_coords([0.01, 0, 3]) == (0, 0, 0) - - # theta in (0, pi/4) -> bin 0: [1, 0, 2] theta=arccos(2/sqrt(5))~0.46 - assert mesh3.get_indices_at_coords([1, 0, 2]) == (0, 0, 0) - - # theta in (pi/4, pi/2) -> bin 1: [2, 0, 1] theta=arccos(1/sqrt(5))~1.107 - assert mesh3.get_indices_at_coords([2, 0, 1]) == (0, 1, 0) - - # theta in (pi/2, pi) -> bin 2: [1, 0, -2] theta=arccos(-2/sqrt(5))~2.034 - assert mesh3.get_indices_at_coords([1, 0, -2]) == (0, 2, 0) - - # phi in (pi/2, pi) -> bin 1: [-1, 1, 0.5] - assert mesh3.get_indices_at_coords([-1, 1, 0.5]) == (0, 1, 1) - - # phi in (pi, 3*pi/2) -> bin 2: [-1, -1, 0.5] - assert mesh3.get_indices_at_coords([-1, -1, 0.5]) == (0, 1, 2) - - # phi in (3*pi/2, 2*pi) -> bin 3: [1, -1, 0.5] - assert mesh3.get_indices_at_coords([1, -1, 0.5]) == (0, 1, 3) - - # Non-default origin - mesh4 = openmc.SphericalMesh( - r_grid=(0, 5, 10), - origin=(100, 200, 300) - ) - - assert mesh4.get_indices_at_coords([103, 200, 300]) == (0, 0, 0) - assert mesh4.get_indices_at_coords([100, 200, 307]) == (1, 0, 0) - - with pytest.raises(ValueError): - mesh4.get_indices_at_coords([111, 200, 300]) - - # Degenerate case: point at origin with r_grid starting at 0 - mesh5 = openmc.SphericalMesh(r_grid=(0, 5)) - assert mesh5.get_indices_at_coords([0, 0, 0]) == (0, 0, 0) - - # Out-of-bounds theta: restricted theta grid - mesh6 = openmc.SphericalMesh( - r_grid=(0, 10), - theta_grid=(0, pi/4) - ) - with pytest.raises(ValueError): - mesh6.get_indices_at_coords([5, 0, 0]) # theta=pi/2 > pi/4 - - # Out-of-bounds phi: restricted phi grid - mesh7 = openmc.SphericalMesh( - r_grid=(0, 10), - phi_grid=(0, pi/2) - ) - with pytest.raises(ValueError): - mesh7.get_indices_at_coords([-5, 0, 0]) # phi=pi > pi/2 - - # Diagonal point: verify r, theta, phi all computed correctly - r = 6.0 - val = r / sqrt(3) - result = mesh3.get_indices_at_coords([val, val, val]) - assert result[0] == 1 # r=6 in second bin [5, 10] - assert result[1] == 1 # theta=arccos(1/sqrt(3))~0.955, in (pi/4, pi/2) - assert result[2] == 0 # phi=pi/4, in [0, pi/2) diff --git a/tests/unit_tests/test_mesh_dagmc_tets.vtk b/tests/unit_tests/test_mesh_dagmc_tets.vtk deleted file mode 120000 index 9f7000175..000000000 --- a/tests/unit_tests/test_mesh_dagmc_tets.vtk +++ /dev/null @@ -1 +0,0 @@ -../regression_tests/unstructured_mesh/test_mesh_dagmc_tets.vtk \ No newline at end of file diff --git a/tests/unit_tests/test_mesh_from_domain.py b/tests/unit_tests/test_mesh_from_domain.py index 46d22f0d2..0cbe413e8 100644 --- a/tests/unit_tests/test_mesh_from_domain.py +++ b/tests/unit_tests/test_mesh_from_domain.py @@ -16,31 +16,6 @@ def test_reg_mesh_from_cell(): assert np.array_equal(mesh.upper_right, cell.bounding_box[1]) -def test_reg_mesh_from_bounding_box(): - """Tests a RegularMesh can be made from a BoundingBox directly.""" - bb = openmc.BoundingBox([-8, -7, -5], [12, 13, 15]) - - mesh = openmc.RegularMesh.from_domain(domain=bb, dimension=[7, 11, 13]) - assert isinstance(mesh, openmc.RegularMesh) - assert np.array_equal(mesh.dimension, (7, 11, 13)) - assert np.array_equal(mesh.lower_left, bb[0]) - assert np.array_equal(mesh.upper_right, bb[1]) - - -def test_rectilinear_mesh_from_bounding_box(): - """Tests a RectilinearMesh can be made from a BoundingBox directly.""" - bb = openmc.BoundingBox([-8, -7, -5], [12, 13, 15]) - - mesh = openmc.RectilinearMesh.from_bounding_box(bb, dimension=[2, 4, 5]) - assert isinstance(mesh, openmc.RectilinearMesh) - assert np.array_equal(mesh.dimension, (2, 4, 5)) - assert np.array_equal(mesh.lower_left, bb[0]) - assert np.array_equal(mesh.upper_right, bb[1]) - assert np.array_equal(mesh.x_grid, [-8., 2., 12.]) - assert np.array_equal(mesh.y_grid, [-7., -2., 3., 8., 13.]) - assert np.array_equal(mesh.z_grid, [-5., -1., 3., 7., 11., 15.]) - - def test_cylindrical_mesh_from_cell(): """Tests a CylindricalMesh can be made from a Cell and the specified dimensions are propagated through.""" @@ -65,7 +40,7 @@ def test_cylindrical_mesh_from_cell(): assert isinstance(mesh, openmc.CylindricalMesh) assert np.array_equal(mesh.dimension, (1, 1, 1)) - assert np.array_equal(mesh.r_grid, [0., 50.]) + assert np.array_equal(mesh.r_grid, [0., 150.]) assert np.array_equal(mesh.origin, [100., 0., 10.]) # Cell is not centralized on Z, X or Y axis @@ -74,7 +49,7 @@ def test_cylindrical_mesh_from_cell(): mesh = openmc.CylindricalMesh.from_domain(domain=cell, dimension=[1, 1, 1]) assert isinstance(mesh, openmc.CylindricalMesh) - assert np.array_equal(mesh.r_grid, [0., 50.]) + assert np.array_equal(mesh.r_grid, [0., 220.]) assert np.array_equal(mesh.origin, [100., 170., 10.]) @@ -112,34 +87,6 @@ def test_cylindrical_mesh_from_region(): assert np.array_equal(mesh.origin, (0.0, 0.0, -30.)) -def test_spherical_mesh_from_domain(): - """Tests a SphericalMesh can be made from a Region and the specified - dimensions are propagated through. Cell is not centralized""" - sphere = openmc.Sphere(r=5, x0=2, y0=3, z0=4) - region = -sphere - - geometry = openmc.Geometry(openmc.Universe(cells=[openmc.Cell(region=region)])) - - region_mesh = openmc.SphericalMesh.from_domain( - domain=region, dimension=(4, 3, 4)) - universe_mesh = openmc.SphericalMesh.from_domain( - domain=geometry.root_universe, dimension=(4, 3, 4)) - geometry_mesh = openmc.SphericalMesh.from_domain( - domain=geometry, dimension=(4, 3, 4)) - - - for mesh in (region_mesh, universe_mesh, geometry_mesh): - assert isinstance(mesh, openmc.SphericalMesh) - assert np.array_equal(mesh.dimension, (4, 3, 4)) - assert np.array_equal(mesh.r_grid, [0., 1.25, 2.5, 3.75, 5.0]) - assert np.array_equal(mesh.theta_grid, [0., np.pi/3., 2*np.pi/3., np.pi]) - assert np.array_equal(mesh.phi_grid, [0., np.pi/2., np.pi, 3*np.pi/2., 2*np.pi]) - assert np.array_equal(mesh.origin, (2.0, 3.0, 4.0)) - - for p in mesh.centroids.reshape(-1, 3): - assert p in mesh.bounding_box - - def test_reg_mesh_from_universe(): """Tests a RegularMesh can be made from a Universe and the default dimensions are propagated through. Universe is centralized""" @@ -172,27 +119,3 @@ def test_reg_mesh_from_geometry(): def test_error_from_unsupported_object(): with pytest.raises(TypeError): openmc.RegularMesh.from_domain("vacuum energy") - - -def test_regularmesh_from_domain_error_from_small_dimensions(): - surface = openmc.Sphere(r=20) - cell = openmc.Cell(region=-surface) - with pytest.raises( - ValueError, match='Unable to set "dimension" to "-2" since it is less than "1"' - ): - openmc.RegularMesh.from_domain(domain=cell, dimension=-2) - - -def test_dimensions_from_domain_dimensions_from_int(): - region = openmc.model.RectangularParallelepiped( - xmin=-100, - xmax=150, - ymin=-50, - ymax=200, - zmin=300, - zmax=400, - boundary_type="vacuum", - ) - cell = openmc.Cell(region=-region) - mesh = openmc.RegularMesh.from_domain(domain=cell, dimension=1000) - assert mesh.dimension == (14, 14, 5) diff --git a/tests/unit_tests/test_mesh_hexes.exo b/tests/unit_tests/test_mesh_hexes.exo deleted file mode 120000 index 272da92a4..000000000 --- a/tests/unit_tests/test_mesh_hexes.exo +++ /dev/null @@ -1 +0,0 @@ -../regression_tests/unstructured_mesh/test_mesh_hexes.exo \ No newline at end of file diff --git a/tests/unit_tests/test_mg_inverse_velocity.py b/tests/unit_tests/test_mg_inverse_velocity.py deleted file mode 100644 index b520e48d1..000000000 --- a/tests/unit_tests/test_mg_inverse_velocity.py +++ /dev/null @@ -1,59 +0,0 @@ -import openmc -import numpy as np -import pytest - -@pytest.fixture -def one_group_lib(): - groups = openmc.mgxs.EnergyGroups([0.0, 20.0e6]) - xsdata = openmc.XSdata('slab_mat', groups) - xsdata.order = 0 - xsdata.set_total([0.0]) - xsdata.set_absorption([0.0]) - xsdata.set_scatter_matrix([[[0.0]]]) - - mg_library = openmc.MGXSLibrary(groups) - mg_library.add_xsdata(xsdata) - name = 'mgxs.h5' - mg_library.export_to_hdf5(name) - yield name - -@pytest.fixture -def slab_model(one_group_lib): - model = openmc.Model() - mat = openmc.Material(name='slab_material') - mat.set_density('macro', 1.0) - mat.add_macroscopic('slab_mat') - - model.materials = openmc.Materials([mat]) - model.materials.cross_sections = one_group_lib - - x_min = openmc.XPlane(x0=0.0, boundary_type='vacuum') - x_max = openmc.XPlane(x0=10.0, boundary_type='vacuum') - - y_min = openmc.YPlane(y0=-10.0, boundary_type='vacuum') - y_max = openmc.YPlane(y0=10.0, boundary_type='vacuum') - z_min = openmc.ZPlane(z0=-10.0, boundary_type='vacuum') - z_max = openmc.ZPlane(z0=19.0, boundary_type='vacuum') - - cell = openmc.Cell(fill=mat, region=+z_min & -x_max & +y_min & -y_max & +z_min & -z_max) - model.geometry = openmc.Geometry([cell]) - - model.settings = openmc.Settings() - model.settings.energy_mode = 'multi-group' - model.settings.run_mode = 'fixed source' - model.settings.batches = 3 - model.settings.particles = 10 - - source = openmc.IndependentSource() - source.space = openmc.stats.Point((5.0, 0.0, 0.0)) - model.settings.source = source - return model - -def test_inverse_velocity(run_in_tmpdir, slab_model): - tally = openmc.Tally() - tally.scores = ['flux','inverse-velocity'] - slab_model.tallies = [tally] - slab_model.run(apply_tally_results=True) - inverse_velocity = tally.mean.squeeze()[1]/tally.mean.squeeze()[0] - - assert inverse_velocity == pytest.approx(1.6144e-5, rel=1e-4) diff --git a/tests/unit_tests/test_mgxs_convert_flux.py b/tests/unit_tests/test_mgxs_convert_flux.py deleted file mode 100644 index e235f88e0..000000000 --- a/tests/unit_tests/test_mgxs_convert_flux.py +++ /dev/null @@ -1,62 +0,0 @@ -"""Tests for openmc.mgxs.convert_flux_groups function.""" - -import numpy as np -import pytest -from pytest import approx - -import openmc.mgxs - - -def test_coarse_to_fine(): - """Test coarse to fine conversion with flux conservation.""" - source = openmc.mgxs.EnergyGroups([1.0, 10.0, 100.0]) - target = openmc.mgxs.EnergyGroups([1.0, 5.0, 10.0, 50.0, 100.0]) - flux_source = np.array([1e8, 2e8]) - - flux_target = openmc.mgxs.convert_flux_groups(flux_source, source, target) - - # Check conservation - assert np.sum(flux_target) == approx(np.sum(flux_source)) - assert len(flux_target) == 4 - assert np.all(flux_target >= 0) - - -def test_fine_to_coarse(): - """Test fine to coarse conversion (reverse direction).""" - source = openmc.mgxs.EnergyGroups([1.0, 5.0, 10.0, 50.0, 100.0]) - target = openmc.mgxs.EnergyGroups([1.0, 10.0, 100.0]) - flux_source = np.array([1e7, 2e7, 3e7, 4e7]) - - flux_target = openmc.mgxs.convert_flux_groups(flux_source, source, target) - - assert np.sum(flux_target) == approx(np.sum(flux_source)) - assert len(flux_target) == 2 - - -def test_lethargy_distribution(): - """Test that flux is distributed by lethargy, not linear energy.""" - # Single group from 1 to 100 eV - source = openmc.mgxs.EnergyGroups([1.0, 100.0]) - # Split into two groups: 1-10 eV and 10-100 eV - target = openmc.mgxs.EnergyGroups([1.0, 10.0, 100.0]) - flux_source = np.array([1e8]) - - flux_target = openmc.mgxs.convert_flux_groups(flux_source, source, target) - - # Each target group spans one decade (ln(10) lethargy each) - # So flux should be split 50/50 by lethargy - assert flux_target[0] == approx(5e7) - assert flux_target[1] == approx(5e7) - - -def test_fns_ccfe709_to_ukaea1102(): - """Test CCFE-709 to UKAEA-1102 conversion with real FNS flux spectrum.""" - from pathlib import Path - flux_file = Path(__file__).parent.parent / 'fns_flux_709.npy' - fns_flux_709 = np.load(flux_file) - - flux_1102 = openmc.mgxs.convert_flux_groups(fns_flux_709, 'CCFE-709', 'UKAEA-1102') - - assert len(flux_1102) == 1102 - assert np.sum(flux_1102) == approx(np.sum(fns_flux_709), rel=1e-10) - assert np.all(flux_1102 >= 0) diff --git a/tests/unit_tests/test_model.py b/tests/unit_tests/test_model.py index 5e3ba7e31..404235bef 100644 --- a/tests/unit_tests/test_model.py +++ b/tests/unit_tests/test_model.py @@ -7,7 +7,6 @@ import pytest import openmc import openmc.lib -from openmc.plots import id_map_to_rgb @pytest.fixture(scope='function') @@ -74,13 +73,13 @@ def pin_model_attributes(): tal.scores = ['flux', 'fission'] tals.append(tal) - plot1 = openmc.SlicePlot(plot_id=1) + plot1 = openmc.Plot(plot_id=1) plot1.origin = (0., 0., 0.) plot1.width = (pitch, pitch) plot1.pixels = (300, 300) plot1.color_by = 'material' plot1.filename = 'test' - plot2 = openmc.SlicePlot(plot_id=2) + plot2 = openmc.Plot(plot_id=2) plot2.origin = (0., 0., 0.) plot2.width = (pitch, pitch) plot2.pixels = (300, 300) @@ -252,11 +251,10 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm): model = openmc.examples.pwr_pin_cell() model.init_lib(output=False, intracomm=mpi_intracomm) - # Change cell fuel temperature, density, material density and export properties + # Change fuel temperature and density and export properties cell = openmc.lib.cells[1] cell.set_temperature(600.0) cell.fill.set_density(5.0, 'g/cm3') - cell.set_density(10.0) openmc.lib.export_properties(output=False) # Import properties to existing model @@ -265,12 +263,10 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm): # Check to see that values are assigned to the C and python representations # First python cell = model.geometry.get_all_cells()[1] - assert cell.temperature == 600.0 - assert cell.density == pytest.approx(10.0, 1e-5) + assert cell.temperature == [600.0] assert cell.fill.get_mass_density() == pytest.approx(5.0) # Now C assert openmc.lib.cells[1].get_temperature() == 600. - assert openmc.lib.cells[1].get_density() == pytest.approx(10.0, 1e-5) assert openmc.lib.materials[1].get_density('g/cm3') == pytest.approx(5.0) # Clear the C API @@ -286,8 +282,7 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm): 'with_properties/settings.xml' ) cell = model_with_properties.geometry.get_all_cells()[1] - assert cell.temperature == 600.0 - assert cell.density == pytest.approx(10.0, 1e-5) + assert cell.temperature == [600.0] assert cell.fill.get_mass_density() == pytest.approx(5.0) @@ -453,7 +448,7 @@ def test_deplete(run_in_tmpdir, pin_model_attributes, mpi_intracomm): # In this test we first run without pre-initializing the shared library # data and then compare. Then we repeat with the C API already initialized # and make sure we get the same answer - test_model.deplete(timesteps=[1e6], method='predictor', final_step=False, + test_model.deplete([1e6], 'predictor', final_step=False, operator_kwargs=op_kwargs, power=1., output=False) # Get the new Xe136 and U235 atom densities @@ -487,7 +482,7 @@ def test_deplete(run_in_tmpdir, pin_model_attributes, mpi_intracomm): # Now we can re-run with the pre-initialized API test_model.init_lib(output=False, intracomm=mpi_intracomm) - test_model.deplete(timesteps=[1e6], method='predictor', final_step=False, + test_model.deplete([1e6], 'predictor', final_step=False, operator_kwargs=op_kwargs, power=1., output=False) # Get the new Xe136 and U235 atom densities @@ -596,653 +591,3 @@ def test_single_xml_exec(run_in_tmpdir): os.mkdir('subdir') pincell_model.run(path='subdir') - - -def test_nuclides_to_ignore(run_in_tmpdir, pin_model_attributes): - """Test nuclides_to_ignore when exporting a model XML""" - materials, geometry, settings = pin_model_attributes[:3] - model = openmc.Model(geometry=geometry, settings=settings) - - # grab one of the nuclides present in this model as a test - test_nuclide = list(materials[0].get_nuclides())[0] - - # exclude the test nuclide from the XML file during export - model.export_to_model_xml(nuclides_to_ignore=[test_nuclide]) - - # ensure that the nuclide doesn't appear after reading in - # the resulting XML model - xml_model = openmc.Model.from_model_xml() - for material in xml_model.materials: - assert test_nuclide not in material.get_nuclides() - - -def test_model_plot(): - # plots the geometry with source location and checks the resulting - # matplotlib includes the correct coordinates for the scatter plot for all - # basis. - - surface = openmc.Sphere(r=600, boundary_type="vacuum") - cell = openmc.Cell(region=-surface) - geometry = openmc.Geometry([cell]) - source = openmc.IndependentSource(space=openmc.stats.Point((1, 2, 3))) - settings = openmc.Settings(particles=1, batches=1, source=source) - model = openmc.Model(geometry, settings=settings) - - plot = model.plot(n_samples=1, plane_tolerance=4.0, basis="xy") - coords = plot.axes.collections[0].get_offsets().data.flatten() - assert (coords == np.array([1.0, 2.0])).all() - - plot = model.plot(n_samples=1, plane_tolerance=4.0, basis="xz") - coords = plot.axes.collections[0].get_offsets().data.flatten() - assert (coords == np.array([1.0, 3.0])).all() - - plot = model.plot(n_samples=1, plane_tolerance=4.0, basis="yz") - coords = plot.axes.collections[0].get_offsets().data.flatten() - assert (coords == np.array([2.0, 3.0])).all() - - plot = model.plot(n_samples=1, plane_tolerance=0.1, basis="xy") - coords = plot.axes.collections[0].get_offsets().data.flatten() - assert (coords == np.array([])).all() - - # modify model to include another cell that overlaps the original cell entirely - model.geometry.root_universe.add_cell(openmc.Cell(region=-surface)) - axes = model.plot(show_overlaps=True) - white = np.array((1.0, 1.0, 1.0)) - red = np.array((1.0, 0.0, 0.0)) - axes_image = axes.get_images()[0] - image_data = axes_image.get_array() - # ensure that all of the data in the image data is either white or red - test_mask = (image_data == white) | (image_data == red) - assert np.all(test_mask), "Colors other than white or red found in overlap plot image" - - # Close plots to avoid warning - import matplotlib.pyplot as plt - plt.close('all') - - -def test_model_plot_invalid_inputs(): - surface = openmc.Sphere(r=10.0, boundary_type="vacuum") - cell = openmc.Cell(region=-surface) - model = openmc.Model(openmc.Geometry([cell])) - - with pytest.raises(ValueError): - model.plot(n_samples=-1) - with pytest.raises(TypeError): - model.plot(n_samples=1.5) - with pytest.raises(ValueError): - model.plot(plane_tolerance=0.0) - with pytest.raises(TypeError): - model.plot(plane_tolerance='1') - with pytest.raises(ValueError): - model.plot(pixels=-1) - with pytest.raises(ValueError): - model.plot(pixels=(0, 100)) - with pytest.raises(ValueError): - model.plot(pixels=(100,)) - with pytest.raises(ValueError): - model.slice_data(u_span=(2, 0, 0), v_span=(0, 2, 0), pixels=-1) - - -def test_model_id_map_initialization(run_in_tmpdir): - model = openmc.examples.pwr_assembly() - model.init_lib(output=False) - - id_map = model.id_map( - pixels=(100, 100), - basis='xy', - origin=(0, 0, 0), - width=(10, 10), - ) - - assert id_map.shape == (100, 100, 3) - assert id_map.dtype == np.int32 - - max_cell_id = max(model.geometry.get_all_cells().keys()) - max_material_id = max(model.geometry.get_all_materials().keys()) - - # add some spot checks for the id_map - # Check that the array contains valid cell/material IDs (not all -2) - # The -2 values indicate outside the geometry - assert not np.all(id_map == -2), "All values are -2, indicating no valid geometry found" - - # Check that we have valid cell IDs (first dimension) - valid_cell_ids = id_map[:, :, 0] - assert np.any(valid_cell_ids >= 0), "No valid cell IDs found in the id_map" - - # Check that we have valid material IDs (third dimension) - valid_material_ids = id_map[:, :, 2] - assert np.any(valid_material_ids >= 0), "No valid material IDs found in the id_map" - - # Check that the middle dimension (cell instances) is consistent - # Cell instances should be >= 0 when cell IDs are valid - cell_instances = id_map[:, :, 1] - valid_cells = valid_cell_ids >= 0 - if np.any(valid_cells): - assert np.all(cell_instances[valid_cells] >= 0), "Invalid cell instances found for valid cells" - - # Check that the array contains reasonable ranges of values - # Cell IDs should be within the expected range for the assembly - if np.any(valid_cell_ids >= 0): - max_map_cell_id = np.max(valid_cell_ids) - assert max_map_cell_id <= max_cell_id, \ - f"Cell ID {max_map_cell_id} in the map is greater than the maximum cell ID {max_cell_id}" - - # Material IDs should be within the expected range - if np.any(valid_material_ids >= 0): - max_map_material_id = np.max(valid_material_ids) - assert max_map_material_id <= max_material_id, \ - f"Material ID {max_map_material_id} in the map is greater than the maximum material ID {max_material_id}" - - # Test id_map with pixels outside the model geometry - # Use a plot that's far from the model center to ensure we get -2 values - outside_id_map = model.id_map( - pixels=(50, 50), - basis='xy', - origin=(1000, 1000, 0), # Far from the model center - width=(10, 10), - ) - - assert outside_id_map.shape == (50, 50, 3) - assert outside_id_map.dtype == np.int32 - - # All values should be -2 (outside geometry) for this plot - assert np.all(outside_id_map == -2), "Expected all values to be -2 for plot outside model geometry" - - # Verify that the outside plot has the correct structure - assert np.all(outside_id_map[:, :, 0] == -2), "Cell IDs should all be -2 outside geometry" - assert np.all(outside_id_map[:, :, 1] == -2), "Cell instances should all be -2 outside geometry" - assert np.all(outside_id_map[:, :, 2] == -2), "Material IDs should all be -2 outside geometry" - - # if the model is already initialized, it should not be finalized - # after calling this method - model.id_map( - pixels=(100, 100), - basis='xy', - origin=(0, 0, 0), - width=(10, 10), - ) - assert model.is_initialized - - # if the model is not initialized, it should be finalized - # before exiting this method - model.finalize_lib() - model.id_map( - pixels=(100, 100), - basis='xy', - origin=(0, 0, 0), - width=(10, 10), - ) - assert not model.is_initialized - - -def test_id_map_aligned_model(): - """Test id_map with a 2x2 lattice where pixel boundaries align to cell boundaries""" - # Create materials -- identical compositions, different IDs - mat1 = openmc.Material(material_id=1, name='Material 1') - mat1.set_density('g/cm3', 1.0) - mat1.add_element('H', 1.0) - - mat2 = openmc.Material(material_id=2, name='Material 2') - mat2.set_density('g/cm3', 1.0) - mat2.add_element('H', 1.0) - - mat3 = openmc.Material(material_id=3, name='Material 3') - mat3.set_density('g/cm3', 1.0) - mat3.add_element('H', 1.0) - - mat4 = openmc.Material(material_id=4, name='Material 4') - mat4.set_density('g/cm3', 1.0) - mat4.add_element('H', 1.0) - - outer_mat = openmc.Material(material_id=5, name='Material 5') - outer_mat.set_density('g/cm3', 1.0) - outer_mat.add_element('H', 1.0) - - inner_materials = [mat1, mat2, mat3, mat4] - - # Create square surface that fits inside the lattice cell - # Lattice cell is 1 cm x 1 cm, so square will be 0.6 cm x 0.6 cm centered on the origin - square = openmc.model.RectangularPrism(0.6, 0.6, boundary_type='transmission') - - # Create cells for this universe - inner_cell = openmc.Cell(cell_id=10, region=-square, name='inner_cell') - inner_cell.fill = inner_materials - - outer_cell = openmc.Cell(cell_id=20, region=+square, name='outer_cell') - outer_cell.fill = outer_mat - - # Create universe - universe = openmc.Universe(universe_id=100, cells=[inner_cell, outer_cell]) - - # Create 2x2 lattice - lattice = openmc.RectLattice(lattice_id=1) - lattice.lower_left = [-1.0, -1.0] - lattice.pitch = [1.0, 1.0] - lattice.universes = [[universe, universe], [universe, universe]] - - # Create outer boundary - outer_boundary = openmc.model.RectangularPrism(2.0, 2.0, boundary_type='vacuum') - - # Create root cell - root_cell = openmc.Cell(cell_id=1, name='root', fill=lattice, region=-outer_boundary) - - # Create geometry - geometry = openmc.Geometry([root_cell]) - - # Create settings - settings = openmc.Settings() - settings.particles = 1000 - settings.batches = 10 - - # Create model - model = openmc.Model(settings=settings, geometry=geometry) - - # Generate id_map with pixel boundaries aligned to cell boundaries - # The model is 2 cm x 2 cm, so we'll use 200x200 pixels to get 0.01 cm resolution - # This allows us to align pixels with the squares inside each lattice cell - id_map = model.id_map( - pixels=(200, 200), - basis='xy', - origin=(0.0, 0.0, 0.0), # Align with lattice lower_left - width=(2.0, 2.0), # Align with lattice size - ) - - # Verify id_map properties - assert id_map.shape == (200, 200, 3) - assert id_map.dtype == np.int32 - - cell_id_map = id_map[:, :, 0] - material_ids_map = id_map[:, :, 2] - - # Check that we have valid cell IDs (not all -2) - assert np.any(cell_id_map >= 0), "No valid cell IDs found in the id_map" - - # Check that we have valid material IDs - assert np.any(material_ids_map >= 0), "No valid material IDs found in the id_map" - - # Check that the expected cell IDs are present - expected_cell_ids = [10, 20] # Root cell, inner cell, outer cell - found_cell_ids = np.unique(cell_id_map[cell_id_map >= 0]) - for cell_id in expected_cell_ids: - assert cell_id in found_cell_ids, f"Expected cell ID {cell_id} not found in id_map" - - # Check that the expected material IDs are present - expected_material_ids = [1, 2, 3, 4, 5] # All materials defined above - found_material_ids = np.unique(material_ids_map[material_ids_map >= 0]) - for mat_id in expected_material_ids: - assert mat_id in found_material_ids, f"Expected material ID {mat_id} not found in id_map" - - # Test specific regions to verify lattice structure - # Check center of each lattice cell (should be inner cells) - # Lattice cell centers are at (-0.5, -0.5), (0.5, -0.5), (-0.5, 0.5), (0.5, 0.5) - # With 200x200 pixels over 2x2 units, each pixel is 0.01 units - - # Bottom-left lattice cell center (should be inner cell 10) - bl_cell, bl_instance, bl_material = id_map[-50, 50] - assert bl_cell == 10, f"Expected cell ID 10 at bottom-left center, got {bl_cell}" - assert bl_instance == 0, f"Expected cell instance 0 at bottom-left center, got {bl_instance}" - assert bl_material == 1, f"Expected material ID 1 at bottom-left center, got {bl_material}" - - # Bottom-right lattice cell center (should be inner cell 10) - br_cell, br_instance, br_material = id_map[-50, 150] - assert br_cell == 10, f"Expected cell ID 10 at bottom-right center, got {br_cell}" - assert br_instance == 1, f"Expected cell instance 1 at bottom-right center, got {br_instance}" - assert br_material == 2, f"Expected material ID 2 at bottom-right center, got {br_material}" - - # Top-left lattice cell center (should be inner cell 10) - tl_cell, tl_instance, tl_material = id_map[-150, 50] - assert tl_cell == 10, f"Expected cell ID 10 at top-left center, got {tl_cell}" - assert tl_instance == 2, f"Expected cell instance 2 at top-left center, got {tl_instance}" - assert tl_material == 3, f"Expected material ID 3 at top-left center, got {tl_material}" - - # Top-right lattice cell center (should be inner cell 10) - tr_cell, tr_instance, tr_material = id_map[-150, 150] - assert tr_cell == 10, f"Expected cell ID 10 at top-right center, got {tr_cell}" - assert tr_instance == 3, f"Expected cell instance 3 at top-right center, got {tr_instance}" - assert tr_material == 4, f"Expected material ID 4 at top-right center, got {tr_material}" - - # Check that the model is properly finalized after id_map call - assert not model.is_initialized, "Model should be finalized after id_map call" - - # Check that the values at the corners are correctly set as the outer cell and material - bl_cell, bl_instance, bl_material = id_map[-1, 0] - assert bl_cell == 20, f"Expected cell ID 20 at bottom-left corner, got {bl_cell}" - assert bl_instance == 0, f"Expected cell instance 0 at bottom-left corner, got {bl_instance}" - assert bl_material == 5, f"Expected material ID 5 at bottom-left corner, got {bl_material}" - - br_cell, br_instance, br_material = id_map[-1, -1] - assert br_cell == 20, f"Expected cell ID 20 at bottom-right corner, got {br_cell}" - assert br_instance == 1, f"Expected cell instance 1 at bottom-right corner, got {br_instance}" - assert br_material == 5, f"Expected material ID 5 at bottom-right corner, got {br_material}" - - tl_cell, tl_instance, tl_material = id_map[0, 0] - assert tl_cell == 20, f"Expected cell ID 20 at top-left corner, got {tl_cell}" - assert tl_instance == 2, f"Expected cell instance 2 at top-left corner, got {tl_instance}" - assert tl_material == 5, f"Expected material ID 5 at top-left corner, got {tl_material}" - - tr_cell, tr_instance, tr_material = id_map[0, -1] - assert tr_cell == 20, f"Expected cell ID 20 at top-right corner, got {tr_cell}" - assert tr_instance == 3, f"Expected cell instance 3 at top-right corner, got {tr_instance}" - assert tr_material == 5, f"Expected material ID 5 at top-right corner, got {tr_material}" - - -def test_id_map_model_with_overlaps(): - """Test id_map with a model that has overlaps and color_overlaps option""" - surface1 = openmc.Sphere(r=50, boundary_type="vacuum") - surface2 = openmc.Sphere(r=30) - cell1 = openmc.Cell(region=-surface1) - cell2 = openmc.Cell(region=-surface2) - geometry = openmc.Geometry([cell1, cell2]) - settings = openmc.Settings() - model = openmc.Model(geometry=geometry, settings=settings) - id_slice = model.id_map( - pixels=(10, 10), - basis='xy', - origin=(0, 0, 0), - width=(100, 100), - ) - assert -3 not in id_slice # -3 indicates overlap region - id_slice = model.id_map( - pixels=(10, 10), - basis='xy', - origin=(0, 0, 0), - width=(100, 100), - color_overlaps=True, # enables id_map to return -3 for overlaps - ) - assert -3 in id_slice - - -def test_setter_from_list(): - mat = openmc.Material() - model = openmc.Model(materials=[mat]) - assert isinstance(model.materials, openmc.Materials) - - tally = openmc.Tally() - model = openmc.Model(tallies=[tally]) - assert isinstance(model.tallies, openmc.Tallies) - - plot = openmc.SlicePlot() - model = openmc.Model(plots=[plot]) - assert isinstance(model.plots, openmc.Plots) - - -def test_keff_search(run_in_tmpdir): - """Test the Model.keff_search method""" - - # Create model of a sphere of U235 - mat = openmc.Material() - mat.set_density('g/cm3', 18.9) - mat.add_nuclide('U235', 1.0) - sphere = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(fill=mat, region=-sphere) - geometry = openmc.Geometry([cell]) - settings = openmc.Settings(particles=1000, inactive=10, batches=30) - model = openmc.Model(geometry=geometry, settings=settings) - - # Define function to modify sphere radius - def modify_radius(radius): - sphere.r = radius - - # Perform keff search - k_tol = 4e-3 - sigma_final = 2e-3 - result = model.keff_search( - func=modify_radius, - x0=6.0, - x1=9.0, - k_tol=k_tol, - sigma_final=sigma_final, - output=True, - ) - - final_keff = result.means[-1] + 1.0 # Add back target since means are (keff - target) - final_sigma = result.stdevs[-1] - - # Check for convergence and that tolerances are met - assert result.converged, "keff_search did not converge" - assert abs(final_keff - 1.0) <= k_tol, \ - f"Final keff {final_keff:.5f} not within k_tol {k_tol}" - assert final_sigma <= sigma_final, \ - f"Final uncertainty {final_sigma:.5f} exceeds sigma_final {sigma_final}" - - # Check type of result - assert isinstance(result, openmc.model.SearchResult) - - # Check that we have function evaluation history - assert len(result.parameters) >= 2 - assert len(result.means) == len(result.parameters) - assert len(result.stdevs) == len(result.parameters) - assert len(result.batches) == len(result.parameters) - - # Check that function_calls property works - assert result.function_calls == len(result.parameters) - - # Check that total_batches property works - assert result.total_batches == sum(result.batches) - assert result.total_batches > 0 - - -def test_id_map_to_rgb(): - """Test conversion of ID map to RGB image array.""" - # Create a simple model - mat = openmc.Material() - mat.set_density('g/cm3', 1.0) - mat.add_nuclide('Li7', 1.0) - - sphere = openmc.Sphere(r=5.0, boundary_type='vacuum') - cell = openmc.Cell(fill=mat, region=-sphere) - geometry = openmc.Geometry([cell]) - settings = openmc.Settings( - batches=10, particles=100, run_mode='fixed source' - ) - model = openmc.Model(geometry, settings=settings) - - id_data = np.zeros((10, 10, 3), dtype=np.int32) - id_data[:, :, 0] = cell.id # Cell IDs - id_data[:, :, 2] = mat.id # Material IDs - - # Test color_by with default colors - for color_by in ['cell', 'material']: - rgb = id_map_to_rgb(id_data, color_by=color_by) - assert rgb.shape == (10, 10, 3) - assert rgb.dtype == float - assert np.all((rgb >= 0) & (rgb <= 1)) # RGB values in [0, 1] - - # Test with custom colors - colors = {cell.id: (255, 0, 0)} # Red - rgb_custom = id_map_to_rgb(id_data, color_by='cell', colors=colors) - assert np.allclose(rgb_custom, [1.0, 0.0, 0.0]) # All pixels should be red - - # Test with overlaps - id_data_overlap = id_data.copy() - id_data_overlap[5:, 5:, 0] = -3 # Mark some pixels as overlaps - rgb_overlap = id_map_to_rgb( - id_data_overlap, overlap_color=(0, 255, 0) - ) - # Check that overlap region is green - assert np.allclose(rgb_overlap[5:, 5:], [0.0, 1.0, 0.0]) - - -def test_convert_to_multigroup_preserves_material_names(run_in_tmpdir): - """convert_to_multigroup leaves the user's material names unchanged and keys - the MGXS library by a unique sanitised name + id, so distinct materials that - share a name do not collapse to a single cross section.""" - a = openmc.Material(name="Steel Plate #1") - a.add_element("Fe", 1.0) - a.set_density("g/cm3", 7.9) - b = openmc.Material(name="Steel Plate #1") # same name, distinct material - b.add_element("Fe", 1.0) - b.set_density("g/cm3", 7.9) - - s1 = openmc.Sphere(r=1.0) - s2 = openmc.Sphere(r=2.0, boundary_type="vacuum") - c1 = openmc.Cell(fill=a, region=-s1) - c2 = openmc.Cell(fill=b, region=+s1 & -s2) - model = openmc.Model(openmc.Geometry([c1, c2]), openmc.Materials([a, b])) - - # Pre-create the library so MGXS generation (and transport) is skipped. - Path("mgxs.h5").touch() - model.convert_to_multigroup(method="material_wise", mgxs_path="mgxs.h5") - - # User names are preserved, not sanitised or de-duplicated. - assert [m.name for m in model.materials] == ["Steel Plate #1", "Steel Plate #1"] - # Each material reads a unique, sanitised library entry (name + id). - macro = [m._macroscopic for m in model.materials] - assert macro == [f"Steel_Plate__1_{a.id}", f"Steel_Plate__1_{b.id}"] - assert len(set(macro)) == 2 - - -class _GenerationCaptured(Exception): - """Raised by the patched MGXS library builder to end generation early.""" - - -def _steel_water_model(): - a = openmc.Material(name='steel') - a.add_element('Fe', 1.0) - a.set_density('g/cm3', 7.9) - b = openmc.Material(name='water') - b.add_element('H', 2.0) - b.add_element('O', 1.0) - b.set_density('g/cm3', 1.0) - s1 = openmc.Sphere(r=1.0) - s2 = openmc.Sphere(r=2.0, boundary_type='vacuum') - c1 = openmc.Cell(fill=a, region=-s1) - c2 = openmc.Cell(fill=b, region=+s1 & -s2) - return openmc.Model(openmc.Geometry([c1, c2]), openmc.Materials([a, b])) - - -def _capture_generation_settings(monkeypatch, model, **kwargs): - """Return the Settings of the MGXS generation run by capturing the - generation model just before transport would start.""" - captured = {} - - def fake_auto_generate(gen_model, groups, correction, directory): - captured['settings'] = gen_model.settings - raise _GenerationCaptured() - - monkeypatch.setattr(openmc.Model, '_auto_generate_mgxs_lib', - fake_auto_generate) - with pytest.raises(_GenerationCaptured): - model.convert_to_multigroup(**kwargs) - return captured['settings'] - - -def test_convert_to_multigroup_material_wise(run_in_tmpdir, monkeypatch): - model = _steel_water_model() - model.settings.run_mode = 'fixed source' - model.settings.source = openmc.IndependentSource(space=openmc.stats.Point()) - model.settings.photon_transport = True - model.settings.batches = 1200 # tuned for the final multigroup solve - - gen = _capture_generation_settings( - monkeypatch, model, method='material_wise', particles=12345, seed=7) - - # Keyword-argument overrides take precedence over the generation - # defaults... - assert gen.particles == 12345 - assert gen.seed == 7 - # ...the generation defaults override the model's own settings... - assert gen.batches == 200 - assert gen.inactive == 100 - assert gen.output == {'summary': True, 'tallies': False} - # ...and everything else is inherited from the model - assert gen.run_mode == 'fixed source' - assert gen.photon_transport is True - assert len(gen.source) == 1 - - # The run mode is owned by the generation method: material_wise always - # takes it from the model, even when given as an override - model.settings.run_mode = 'eigenvalue' - gen = _capture_generation_settings( - monkeypatch, model, method='material_wise', run_mode='fixed source') - assert gen.run_mode == 'eigenvalue' - - -def test_convert_to_multigroup_stochastic_slab(run_in_tmpdir, monkeypatch): - model = _steel_water_model() - src = openmc.IndependentSource(space=openmc.stats.Point()) - - with pytest.warns(UserWarning, match='constructs its own'): - gen = _capture_generation_settings( - monkeypatch, model, method='stochastic_slab', particles=999, - batches=50, max_history_splits=42, source=src) - - assert gen.particles == 999 - assert gen.batches == 50 - assert gen.max_history_splits == 42 - # The method constructs its own source and run mode; the user's source - # was discarded with a warning - assert gen.run_mode == 'fixed source' - assert gen.create_fission_neutrons is False - assert len(gen.source) > 0 - assert all(s is not src for s in gen.source) - - -def test_convert_to_multigroup_weight_windows(run_in_tmpdir, monkeypatch): - model = _steel_water_model() - ww_path = Path('ww.h5').resolve() - - gen = _capture_generation_settings( - monkeypatch, model, method='material_wise', - weight_windows_file=ww_path) - - # A weight windows file is passed through to the "material_wise" - # generation run (specifying a file turns weight windows on at run time) - assert gen.weight_windows_file == ww_path - - # An explicit weight_windows_on=False rides along with the file and - # overrides the run-time file-implied enable - gen = _capture_generation_settings( - monkeypatch, model, method='material_wise', - weight_windows_file=ww_path, weight_windows_on=False) - assert gen.weight_windows_file == ww_path - assert gen.weight_windows_on is False - - # The surrogate-geometry methods ignore the file with a warning - with pytest.warns(UserWarning, match='material_wise'): - gen = _capture_generation_settings( - monkeypatch, model, method='stochastic_slab', - weight_windows_file=ww_path) - assert gen.weight_windows_file is None - - -def test_convert_to_multigroup_validation(run_in_tmpdir): - model = _steel_water_model() - - with pytest.raises(ValueError): - model.convert_to_multigroup(method='not_a_method') - - # The deprecated arguments cannot be combined with keyword overrides - with pytest.raises(ValueError, match='deprecated'), \ - pytest.warns(FutureWarning): - model.convert_to_multigroup(nparticles=1000, particles=500) - with pytest.raises(ValueError, match='deprecated'), \ - pytest.warns(FutureWarning): - model.convert_to_multigroup( - temperature_settings={'method': 'interpolation'}, - temperature={'method': 'interpolation'}) - - -def test_convert_to_multigroup_deprecated_args(run_in_tmpdir, monkeypatch): - # The deprecated arguments still work, with a FutureWarning - model = _steel_water_model() - with pytest.warns(FutureWarning, match='deprecated'): - gen = _capture_generation_settings( - monkeypatch, model, method='stochastic_slab', nparticles=1234, - temperature_settings={'method': 'interpolation'}) - assert gen.particles == 1234 - assert gen.temperature == {'method': 'interpolation'} - assert gen.batches == 200 # generation default unchanged - - -def test_convert_to_multigroup_materials_from_geometry(run_in_tmpdir): - # A model whose materials are only referenced through the geometry gets - # its materials collection populated (sorted by ID) for the conversion - model = _steel_water_model() - model.materials = openmc.Materials() - ids = sorted(model.geometry.get_all_materials()) - - Path('mgxs.h5').touch() - model.convert_to_multigroup( - method='stochastic_slab', mgxs_path='mgxs.h5') - assert [m.id for m in model.materials] == ids diff --git a/tests/unit_tests/test_no_reduce.py b/tests/unit_tests/test_no_reduce.py deleted file mode 100644 index 00ddb5a95..000000000 --- a/tests/unit_tests/test_no_reduce.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Test the settings.no_reduce feature to ensure tallies are correctly -reduced across MPI processes.""" - -import openmc -import pytest - -from tests.testing_harness import config - - -@pytest.mark.parametrize('no_reduce', [True, False]) -def test_no_reduce(no_reduce, run_in_tmpdir): - """Test that tally results are correct with and without no_reduce.""" - - # Create simple sphere model with vacuum - model = openmc.Model() - sphere = openmc.Sphere(r=1.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere) - model.geometry = openmc.Geometry([cell]) - model.settings.run_mode = 'fixed source' - model.settings.batches = 10 - model.settings.particles = 100 - model.settings.source = openmc.IndependentSource(space=openmc.stats.Point()) - model.settings.no_reduce = no_reduce - - # Tally: surface current on vacuum boundary - surf_filter = openmc.SurfaceFilter(sphere) - tally = openmc.Tally() - tally.filters = [surf_filter] - tally.scores = ['current'] - model.tallies = [tally] - - # Run OpenMC with proper MPI arguments if needed - kwargs = {'apply_tally_results': True, 'openmc_exec': config['exe']} - if config['mpi']: - kwargs['mpi_args'] = [config['mpiexec'], '-n', config['mpi_np']] - model.run(**kwargs) - - # The tally should be ~1.0 (every particle crosses the surface once) - tally_mean = tally.mean.flatten()[0] - assert tally_mean == pytest.approx(1.0) diff --git a/tests/unit_tests/test_nuclide_heating.py b/tests/unit_tests/test_nuclide_heating.py deleted file mode 100644 index e00d57b4f..000000000 --- a/tests/unit_tests/test_nuclide_heating.py +++ /dev/null @@ -1,39 +0,0 @@ -import openmc -from pytest import approx - - -def test_nuclide_heating(run_in_tmpdir): - mat = openmc.Material() - mat.add_nuclide("Li6", 0.5) - mat.add_nuclide("Li7", 0.5) - mat.set_density("g/cm3", 1.0) - - sphere = openmc.Sphere(r=20, boundary_type="reflective") - inside_sphere = openmc.Cell(fill=mat, region=-sphere) - model = openmc.Model() - model.geometry = openmc.Geometry([inside_sphere]) - - model.settings.particles = 1000 - model.settings.batches = 1 - model.settings.photon_transport = True - model.settings.electron_treatment = "ttb" - model.settings.cutoff = {"energy_photon": 1000} - model.settings.run_mode = "fixed source" - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(10.0e6), - particle="photon" - ) - - # Create two tallies, one with heating by nuclide and one with total heating - tally1 = openmc.Tally() - tally1.scores = ["heating"] - tally1.nuclides = mat.get_nuclides() - tally2 = openmc.Tally() - tally2.scores = ["heating"] - model.tallies = [tally1, tally2] - - # Run the model - model.run(apply_tally_results=True) - - # Make sure the heating results are consistent - assert tally1.mean.sum() == approx(tally2.mean.sum()) diff --git a/tests/unit_tests/test_particle_type.py b/tests/unit_tests/test_particle_type.py deleted file mode 100644 index 67e385ea6..000000000 --- a/tests/unit_tests/test_particle_type.py +++ /dev/null @@ -1,298 +0,0 @@ -"""Unit tests for ParticleType class.""" - -import pytest -from openmc import ParticleType - - -# Tests for creating ParticleType instances - -def test_create_from_int(): - """Test creation from PDG number.""" - p = ParticleType(2112) - assert p.pdg_number == 2112 - assert int(p) == 2112 - - -def test_create_from_string_name(): - """Test creation from particle name.""" - p = ParticleType('neutron') - assert p.pdg_number == 2112 - - p = ParticleType('photon') - assert p.pdg_number == 22 - - -def test_create_from_string_aliases(): - """Test creation from particle aliases.""" - assert ParticleType('n').pdg_number == 2112 - assert ParticleType('gamma').pdg_number == 22 - assert ParticleType('p').pdg_number == 2212 - assert ParticleType('proton').pdg_number == 2212 - assert ParticleType('d').pdg_number == 1000010020 - assert ParticleType('t').pdg_number == 1000010030 - - -def test_create_from_string_nuclide(): - """Test creation from GNDS nuclide name.""" - p = ParticleType('He4') - assert p.pdg_number == 1000020040 - - p = ParticleType('U235') - assert p.pdg_number == 1000922350 - - p = ParticleType('Am242_m1') - assert p.pdg_number == 1000952421 - - -def test_create_from_string_pdg_prefix(): - """Test creation with pdg: prefix.""" - p = ParticleType('pdg:2112') - assert p.pdg_number == 2112 - - p = ParticleType('PDG:22') - assert p.pdg_number == 22 - - -def test_create_from_particle_type(): - """Test creation from existing ParticleType.""" - p1 = ParticleType(2112) - p2 = ParticleType(p1) - assert p1 == p2 - assert p1 is not p2 # Different instances - - -def test_legacy_particle_indices(): - """Test backward compatibility with legacy indices 0-3.""" - assert ParticleType(0) == ParticleType.NEUTRON - assert ParticleType(1) == ParticleType.PHOTON - assert ParticleType(2) == ParticleType.ELECTRON - assert ParticleType(3) == ParticleType.POSITRON - - -def test_create_invalid_type(): - """Test creation with invalid type raises TypeError.""" - with pytest.raises(TypeError): - ParticleType([2112]) - - with pytest.raises(TypeError): - ParticleType({'pdg': 2112}) - - -def test_create_invalid_string(): - """Test creation with invalid string raises ValueError.""" - with pytest.raises(ValueError): - ParticleType('') - - with pytest.raises(ValueError): - ParticleType('pdg:invalid') - - -def test_create_case_insensitive(): - """Test that string parsing is case insensitive for aliases.""" - assert ParticleType('NEUTRON').pdg_number == 2112 - assert ParticleType('Neutron').pdg_number == 2112 - assert ParticleType('PHOTON').pdg_number == 22 - - -# Tests for equality and comparison - -def test_equality_same_pdg(): - """Test that instances with same PDG are equal.""" - p1 = ParticleType(2112) - p2 = ParticleType(2112) - assert p1 == p2 - - -def test_equality_int(): - """Test equality comparison with int.""" - p = ParticleType(2112) - assert p == 2112 - assert 2112 == p - - -def test_equality_string(): - """Test equality comparison with string.""" - p = ParticleType(2112) - assert p == 'neutron' - assert p == 'pdg:2112' - assert p == 'n' - - -def test_inequality(): - """Test inequality comparisons.""" - p1 = ParticleType(2112) - p2 = ParticleType(22) - assert p1 != p2 - assert p1 != 22 - assert p1 != 'photon' - - -def test_equality_with_constants(): - """Test equality with class constants.""" - p = ParticleType(2112) - assert p == ParticleType.NEUTRON - assert ParticleType.NEUTRON == p - - -def test_equality_invalid_string(): - """Test equality with invalid string returns False.""" - p = ParticleType(2112) - assert not (p == 'invalid_particle') - assert p != 'invalid_particle' - - -# Tests for hashing behavior - -def test_hash_consistency(): - """Test that equal instances hash to the same value.""" - p1 = ParticleType(2112) - p2 = ParticleType(2112) - assert hash(p1) == hash(p2) - - -def test_set_deduplication(): - """Test that equal instances deduplicate in sets.""" - p1 = ParticleType(2112) - p2 = ParticleType(2112) - s = {p1, p2} - assert len(s) == 1 - - -def test_dict_key(): - """Test use as dictionary key.""" - p1 = ParticleType(2112) - p2 = ParticleType(2112) - d = {p1: 'neutron'} - assert d[p2] == 'neutron' - - -def test_hash_different_particles(): - """Test that different particles have different hashes (usually).""" - p1 = ParticleType(2112) - p2 = ParticleType(22) - # Different PDG numbers should (almost always) have different hashes - assert hash(p1) != hash(p2) - - -# Tests for properties and computed attributes - -def test_pdg_number_property(): - """Test pdg_number property.""" - p = ParticleType(2112) - assert p.pdg_number == 2112 - assert isinstance(p.pdg_number, int) - - -def test_int_conversion(): - """Test __int__ conversion.""" - p = ParticleType(1000020040) - assert int(p) == 1000020040 - - -def test_zam_elementary(): - """Test zam property for elementary particles.""" - assert ParticleType.NEUTRON.zam is None - assert ParticleType.PHOTON.zam is None - assert ParticleType.ELECTRON.zam is None - assert ParticleType.POSITRON.zam is None - - -def test_zam_nucleus(): - """Test zam property for nuclear particles.""" - he4 = ParticleType('He4') - assert he4.zam == (2, 4, 0) - - u235 = ParticleType('U235') - Z, A, m = u235.zam - assert Z == 92 - assert A == 235 - assert m == 0 - - -def test_zam_metastable(): - """Test zam property for metastable nuclei.""" - # Am242m has m=1 - am242m = ParticleType('Am242_m1') - Z, A, m = am242m.zam - assert Z == 95 - assert A == 242 - assert m == 1 - - -def test_is_nucleus_false(): - """Test is_nucleus for elementary particles.""" - assert not ParticleType.NEUTRON.is_nucleus - assert not ParticleType.PHOTON.is_nucleus - assert not ParticleType.ELECTRON.is_nucleus - assert not ParticleType.POSITRON.is_nucleus - - -def test_is_nucleus_true(): - """Test is_nucleus for nuclear particles.""" - assert ParticleType.ALPHA.is_nucleus - assert ParticleType('He4').is_nucleus - assert ParticleType('U235').is_nucleus - assert ParticleType.DEUTERON.is_nucleus - assert ParticleType.TRITON.is_nucleus - - -# Tests for __str__ and __repr__ - -def test_str_elementary(): - """Test string representation of elementary particles.""" - assert str(ParticleType.NEUTRON) == 'neutron' - assert str(ParticleType.PHOTON) == 'photon' - assert str(ParticleType.ELECTRON) == 'electron' - assert str(ParticleType.POSITRON) == 'positron' - assert str(ParticleType.PROTON) == 'H1' - - -def test_str_nucleus(): - """Test string representation of nuclei.""" - assert str(ParticleType.ALPHA) == 'He4' - assert str(ParticleType('U235')) == 'U235' - assert str(ParticleType.DEUTERON) == 'H2' - assert str(ParticleType.TRITON) == 'H3' - - -def test_str_arbitrary_pdg(): - """Test string representation of arbitrary PDG number.""" - # PDG number that doesn't match any known particle - p = ParticleType(12345) - assert str(p) == 'pdg:12345' - - -def test_repr(): - """Test repr includes PDG number.""" - p = ParticleType.NEUTRON - repr_str = repr(p) - assert 'ParticleType' in repr_str - assert 'PDG=2112' in repr_str - assert 'neutron' in repr_str - - -def test_repr_nucleus(): - """Test repr for nuclear particles.""" - p = ParticleType.ALPHA - repr_str = repr(p) - assert 'ParticleType' in repr_str - assert 'PDG=1000020040' in repr_str - assert 'He4' in repr_str - - -def test_create_from_numpy_int(): - """Test creation from numpy integer types.""" - import numpy as np - p = ParticleType(np.int32(2112)) - assert p.pdg_number == 2112 - - p = ParticleType(np.int64(22)) - assert p.pdg_number == 22 - - -def test_equality_numpy_int(): - """Test equality comparison with numpy integer types.""" - import numpy as np - p = ParticleType(2112) - assert p == np.int32(2112) - assert p == np.int64(2112) diff --git a/tests/unit_tests/test_pathlike_simple.py b/tests/unit_tests/test_pathlike_simple.py deleted file mode 100644 index e0116bf01..000000000 --- a/tests/unit_tests/test_pathlike_simple.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Simple test for PathLike filename support""" - -from pathlib import Path - -import pytest -import openmc -from openmc.checkvalue import check_type, PathLike - - -def test_pathlike_type_checking(): - """Test that PathLike type checking works correctly""" - - # Test with string (should work) - check_type('filename', 'test.txt', PathLike) - - # Test with Path object (should work) - path_obj = Path('test.txt') - check_type('filename', path_obj, PathLike) - - # Test with Path object containing subdirectories (should work) - path_with_subdir = Path('subdir') / 'test.txt' - check_type('filename', path_with_subdir, PathLike) - - # Test with invalid type (should raise TypeError) - with pytest.raises(TypeError): - check_type('filename', 123, PathLike) - - -def test_plot_filename_pathlike(): - """Test that plot filename accepts Path objects""" - - plot = openmc.Plot() - - # Test with string (should still work) - plot.filename = "test_plot" - assert plot.filename == "test_plot" - - # Test with Path object - path_obj = Path("test_plot_path") - plot.filename = path_obj - assert plot.filename == path_obj - - # Test with Path object containing subdirectories - path_with_subdir = Path("subdir") / "test_plot" - plot.filename = path_with_subdir - assert plot.filename == path_with_subdir diff --git a/tests/unit_tests/test_periodic_bc.py b/tests/unit_tests/test_periodic_bc.py deleted file mode 100644 index 4cc126abc..000000000 --- a/tests/unit_tests/test_periodic_bc.py +++ /dev/null @@ -1,47 +0,0 @@ -from math import cos, sin, radians -import random - -import openmc -import pytest - - -@pytest.mark.parametrize("angle", [30., 45., 60., 90., 120.]) -def test_rotational_periodic_bc(angle): - # Pick random starting angle - start = random.uniform(0., 360.) - degrees = angle - ang1 = radians(start) - ang2 = radians(start + degrees) - - # Define three points on each plane and then randomly shuffle them - p1_points = [(0., 0., 0.), (cos(ang1), sin(ang1), 0.), (0., 0., 1.)] - p2_points = [(0., 0., 0.), (cos(ang2), sin(ang2), 0.), (0., 0., 1.)] - random.shuffle(p1_points) - random.shuffle(p2_points) - - # Create periodic planes and a cylinder - p1 = openmc.Plane.from_points(*p1_points, boundary_type='periodic') - p2 = openmc.Plane.from_points(*p2_points, boundary_type='periodic') - p1.periodic_surface = p2 - zcyl = openmc.ZCylinder(r=5., boundary_type='vacuum') - - # Figure out which side of planes to use based on a point in the middle - ang_mid = radians(start + degrees/2.) - mid_point = (cos(ang_mid), sin(ang_mid), 0.) - r1 = -p1 if mid_point in -p1 else +p1 - r2 = -p2 if mid_point in -p2 else +p2 - - # Create one cell bounded by the two planes and the cylinder - mat = openmc.Material(density=1.0, density_units='g/cm3', components={'U235': 1.0}) - cell = openmc.Cell(fill=mat, region=r1 & r2 & -zcyl) - - # Make the model complete - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.source = openmc.IndependentSource(space=openmc.stats.Point(mid_point)) - model.settings.particles = 1000 - model.settings.batches = 10 - model.settings.inactive = 5 - - # Run the model - model.run() diff --git a/tests/unit_tests/test_photon_heating.py b/tests/unit_tests/test_photon_heating.py deleted file mode 100644 index 05473f5c6..000000000 --- a/tests/unit_tests/test_photon_heating.py +++ /dev/null @@ -1,30 +0,0 @@ -import openmc - - -def test_negative_positron_heating(): - m = openmc.Material() - m.add_element('Li', 1.0) - m.set_density('g/cm3', 10.0) - - surf = openmc.Sphere(r=100.0, boundary_type='reflective') - cell = openmc.Cell(fill=m, region=-surf) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.run_mode = 'fixed source' - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Point(), - energy=openmc.stats.Discrete([5.0e6], [1.0]), - particle='photon', - ) - model.settings.particles = 7 - model.settings.batches = 1 - model.settings.electron_treatment = 'led' - model.settings.seed = 513836 - - tally = openmc.Tally() - tally.filters = [openmc.ParticleFilter(['photon', 'electron', 'positron'])] - tally.scores = ['heating'] - model.tallies = openmc.Tallies([tally]) - model.run(apply_tally_results=True) - - assert (tally.mean >= 0.0).all(), "Negative heating detected" diff --git a/tests/unit_tests/test_pin.py b/tests/unit_tests/test_pin.py index 53665b1a6..5496a3b73 100644 --- a/tests/unit_tests/test_pin.py +++ b/tests/unit_tests/test_pin.py @@ -46,6 +46,11 @@ def test_failure(pin_mats, good_radii): with pytest.raises(ValueError, match="length"): pin(good_surfaces[:len(pin_mats) - 2], pin_mats) + # Non-positive radii + rad = [openmc.ZCylinder(r=-0.1)] + good_surfaces[1:] + with pytest.raises(ValueError, match="index 0"): + pin(rad, pin_mats) + # Non-increasing radii surfs = tuple(reversed(good_surfaces)) with pytest.raises(ValueError, match="index 1"): diff --git a/tests/unit_tests/test_plots.py b/tests/unit_tests/test_plots.py index 98a93e44b..a1e15016a 100644 --- a/tests/unit_tests/test_plots.py +++ b/tests/unit_tests/test_plots.py @@ -4,16 +4,15 @@ import openmc import openmc.examples import pytest -from openmc.plots import _SVG_COLORS - @pytest.fixture(scope='module') def myplot(): - plot = openmc.SlicePlot(name='myplot') + plot = openmc.Plot(name='myplot') plot.width = (100., 100.) plot.origin = (2., 3., -10.) plot.pixels = (500, 500) plot.filename = './not-a-dir/myplot' + plot.type = 'slice' plot.basis = 'yz' plot.background = 'black' plot.background = (0, 0, 0) @@ -43,7 +42,7 @@ def myplot(): @pytest.fixture(scope='module') def myprojectionplot(): - plot = openmc.WireframeRayTracePlot(name='myprojectionplot') + plot = openmc.ProjectionPlot(name='myprojectionplot') plot.look_at = (0.0, 0.0, 0.0) plot.camera_position = (4.0, 3.0, 0.0) plot.pixels = (500, 500) @@ -79,7 +78,8 @@ def test_voxel_plot(run_in_tmpdir): geometry.export_to_xml() materials = openmc.Materials() materials.export_to_xml() - vox_plot = openmc.VoxelPlot() + vox_plot = openmc.Plot() + vox_plot.type = 'voxel' vox_plot.id = 12 vox_plot.width = (1500., 1500., 1500.) vox_plot.pixels = (200, 200, 200) @@ -90,14 +90,13 @@ def test_voxel_plot(run_in_tmpdir): assert Path('test_voxel_plot.vti').is_file() vox_plot.filename = 'h5_voxel_plot' - vox_plot.to_vtk(Path('another_test_voxel_plot.vti')) + vox_plot.to_vtk('another_test_voxel_plot.vti') assert Path('h5_voxel_plot.h5').is_file() assert Path('another_test_voxel_plot.vti').is_file() - # SlicePlot should not have to_vtk method - slice_plot = openmc.SlicePlot() - with pytest.raises(AttributeError): + slice_plot = openmc.Plot() + with pytest.raises(ValueError): slice_plot.to_vtk('shimmy.vti') @@ -119,31 +118,6 @@ def test_repr_proj(myprojectionplot): assert isinstance(r, str) -def test_projection_plot_roundtrip(myprojectionplot): - - elem = myprojectionplot.to_xml_element() - - xml_plot = openmc.WireframeRayTracePlot.from_xml_element(elem) - - svg_colors = _SVG_COLORS - - assert xml_plot.name == myprojectionplot.name - assert xml_plot.look_at == myprojectionplot.look_at - assert xml_plot.camera_position == myprojectionplot.camera_position - assert xml_plot.pixels == myprojectionplot.pixels - assert xml_plot.filename == myprojectionplot.filename - assert xml_plot.background == svg_colors[myprojectionplot.background] - assert xml_plot.color_by == myprojectionplot.color_by - expected_colors = {m.id: svg_colors[c] for m, c in myprojectionplot.colors.items()} - assert xml_plot.colors == expected_colors - # TODO: needs geometry information - # assert xml_plot.mask_components == myprojectionplot.mask_components - assert xml_plot.mask_background == svg_colors[myprojectionplot.mask_background] - # assert xml_plot.overlap_color == svg_colors[myprojectionplot.overlap_color] - assert xml_plot.wireframe_thickness == myprojectionplot.wireframe_thickness - assert xml_plot.level == myprojectionplot.level - - def test_from_geometry(): width = 25. s = openmc.Sphere(r=width/2, boundary_type='vacuum') @@ -152,14 +126,14 @@ def test_from_geometry(): geom = openmc.Geometry(univ) for basis in ('xy', 'yz', 'xz'): - plot = openmc.SlicePlot.from_geometry(geom, basis) + plot = openmc.Plot.from_geometry(geom, basis) assert plot.origin == pytest.approx((0., 0., 0.)) assert plot.width == pytest.approx((width, width)) assert plot.basis == basis def test_highlight_domains(): - plot = openmc.SlicePlot() + plot = openmc.Plot() plot.color_by = 'material' plots = openmc.Plots([plot]) @@ -178,8 +152,8 @@ def test_xml_element(myplot): assert elem.find('pixels') is not None assert elem.find('background').text == '0 0 0' - newplot = openmc.SlicePlot.from_xml_element(elem) - attributes = ('id', 'color_by', 'filename', 'basis', 'level', + newplot = openmc.Plot.from_xml_element(elem) + attributes = ('id', 'color_by', 'filename', 'type', 'basis', 'level', 'meshlines', 'show_overlaps', 'origin', 'width', 'pixels', 'background', 'mask_background') for attr in attributes: @@ -199,20 +173,20 @@ def test_to_xml_element_proj(myprojectionplot): def test_plots(run_in_tmpdir): - p1 = openmc.SlicePlot(name='plot1') + p1 = openmc.Plot(name='plot1') p1.origin = (5., 5., 5.) p1.colors = {10: (255, 100, 0)} p1.mask_components = [2, 4, 6] - p2 = openmc.SlicePlot(name='plot2') + p2 = openmc.Plot(name='plot2') p2.origin = (-3., -3., -3.) plots = openmc.Plots([p1, p2]) assert len(plots) == 2 - p3 = openmc.WireframeRayTracePlot(name='plot3') + p3 = openmc.ProjectionPlot(name='plot3') plots = openmc.Plots([p1, p2, p3]) assert len(plots) == 3 - p4 = openmc.VoxelPlot(name='plot4') + p4 = openmc.Plot(name='plot4') plots.append(p4) assert len(plots) == 4 @@ -229,7 +203,8 @@ def test_plots(run_in_tmpdir): def test_voxel_plot_roundtrip(): # Define a voxel plot and create XML element - plot = openmc.VoxelPlot(name='my voxel plot') + plot = openmc.Plot(name='my voxel plot') + plot.type = 'voxel' plot.filename = 'voxel1' plot.pixels = (50, 50, 50) plot.origin = (0., 0., 0.) @@ -241,53 +216,20 @@ def test_voxel_plot_roundtrip(): new_plot = plot.from_xml_element(elem) assert new_plot.name == plot.name assert new_plot.filename == plot.filename + assert new_plot.type == plot.type assert new_plot.pixels == plot.pixels assert new_plot.origin == plot.origin assert new_plot.width == plot.width assert new_plot.color_by == plot.color_by -def test_phong_plot_roundtrip(): - plot = openmc.SolidRayTracePlot(name='my phong plot') - plot.id = 2300 - plot.filename = 'phong1' - plot.pixels = (50, 50) - plot.look_at = (11., 12., 13.) - plot.camera_position = (22., 23., 24.) - plot.diffuse_fraction = 0.5 - plot.horizontal_field_of_view = 90.0 - plot.color_by = 'material' - plot.light_position = (8., 9., 10.) - plot.opaque_domains = [6, 7, 8] - - elem = plot.to_xml_element() - - repr(plot) - - new_plot = openmc.SolidRayTracePlot.from_xml_element(elem) - - assert new_plot.name == plot.name - assert new_plot.id == plot.id - assert new_plot.filename == plot.filename - assert new_plot.pixels == plot.pixels - assert new_plot.look_at == plot.look_at - assert new_plot.camera_position == plot.camera_position - assert new_plot.diffuse_fraction == plot.diffuse_fraction - assert new_plot.horizontal_field_of_view == plot.horizontal_field_of_view - assert new_plot.color_by == plot.color_by - assert new_plot.light_position == plot.light_position - assert new_plot.opaque_domains == plot.opaque_domains - - # ensure the new object is valid to re-write to XML - new_elem = new_plot.to_xml_element() - - def test_plot_directory(run_in_tmpdir): pwr_pin = openmc.examples.pwr_pin_cell() - # create a standard slice plot, expected to work - plot = openmc.SlicePlot() + # create a standard plot, expected to work + plot = openmc.Plot() plot.filename = 'plot_1' + plot.type = 'slice' plot.pixels = (10, 10) plot.color_by = 'material' plot.width = (100., 100.) diff --git a/tests/unit_tests/test_pulse_height.py b/tests/unit_tests/test_pulse_height.py deleted file mode 100644 index 1f27cc6f2..000000000 --- a/tests/unit_tests/test_pulse_height.py +++ /dev/null @@ -1,59 +0,0 @@ -import numpy as np -import pytest -import openmc - - -@pytest.fixture -def model(): - openmc.reset_auto_ids() - model = openmc.Model() - - # Define materials - NaI = openmc.Material() - NaI.set_density('g/cm3', 3.7) - NaI.add_element('Na', 1.0) - NaI.add_element('I', 1.0) - - # Define geometry: two spheres in each other - s1 = openmc.Sphere(r=1) - s2 = openmc.Sphere(r=2, boundary_type='vacuum') - inner_sphere = openmc.Cell(name='inner sphere', fill=NaI, region=-s1) - outer_sphere = openmc.Cell(name='outer sphere', fill=NaI, region=+s1 & -s2) - model.geometry = openmc.Geometry([inner_sphere, outer_sphere]) - - # Define settings - model.settings.run_mode = 'fixed source' - model.settings.batches = 1 - model.settings.particles = 10000 - model.settings.photon_transport = True - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(1e6), - particle='photon' - ) - - # Define tallies - energy_filter = openmc.EnergyFilter([1e3, 1e7]) - - tally1 = openmc.Tally() - tally1.scores = ['pulse-height'] - cell_filter1 = openmc.CellFilter([inner_sphere, outer_sphere]) - tally1.filters = [cell_filter1, energy_filter] - - tally2 = openmc.Tally() - tally2.scores = ['pulse-height'] - cell_filter2 = openmc.CellFilter([outer_sphere, inner_sphere]) - tally2.filters = [cell_filter2, energy_filter] - - model.tallies = [tally1, tally2] - return model - - -def test_pulse_height(model, run_in_tmpdir): - sp_path = model.run() - sp = openmc.StatePoint(sp_path) - t1 = sp.tallies[1].mean.squeeze() - t2 = sp.tallies[2].mean.squeeze() - - np.testing.assert_array_equal(t1, t2[::-1]) - - diff --git a/tests/unit_tests/test_r2s.py b/tests/unit_tests/test_r2s.py deleted file mode 100644 index 5e617919d..000000000 --- a/tests/unit_tests/test_r2s.py +++ /dev/null @@ -1,325 +0,0 @@ -from pathlib import Path - -import pytest -import openmc -from openmc.deplete import Chain, R2SManager - - -@pytest.fixture -def simple_model_and_mesh(): - # Define two materials: water and Ni - h2o = openmc.Material() - h2o.add_nuclide("H1", 2.0) - h2o.add_nuclide("O16", 1.0) - h2o.set_density("g/cm3", 1.0) - nickel = openmc.Material() - nickel.add_element("Ni", 1.0) - nickel.set_density("g/cm3", 4.0) - - # Geometry: two half-spaces split by x=0 plane - left = openmc.XPlane(0.0) - x_min = openmc.XPlane(-10.0, boundary_type='vacuum') - x_max = openmc.XPlane(10.0, boundary_type='vacuum') - y_min = openmc.YPlane(-10.0, boundary_type='vacuum') - y_max = openmc.YPlane(10.0, boundary_type='vacuum') - z_min = openmc.ZPlane(-10.0, boundary_type='vacuum') - z_max = openmc.ZPlane(10.0, boundary_type='vacuum') - - c1 = openmc.Cell(fill=h2o, region=+x_min & -left & +y_min & -y_max & +z_min & -z_max) - c2 = openmc.Cell(fill=nickel, region=+left & -x_max & +y_min & -y_max & +z_min & -z_max) - c1.volume = 4000.0 - c2.volume = 4000.0 - geometry = openmc.Geometry([c1, c2]) - - # Simple settings with a point source - settings = openmc.Settings() - settings.batches = 2 - settings.particles = 250 - settings.run_mode = 'fixed source' - settings.source = openmc.IndependentSource() - model = openmc.Model(geometry, settings=settings) - - mesh = openmc.RegularMesh() - mesh.lower_left = (-10.0, -10.0, -10.0) - mesh.upper_right = (10.0, 10.0, 10.0) - mesh.dimension = (1, 1, 1) - return model, (c1, c2), mesh - - -@pytest.fixture -def source_stage_manager(simple_model_and_mesh): - model, (c1, c2), _ = simple_model_and_mesh - r2s = R2SManager(model, [c1, c2]) - r2s.results['depletion_results'] = [None, None] - r2s.results['activation_materials'] = [c1.fill, c2.fill] - bounding_boxes = {c1.id: c1.bounding_box, c2.id: c2.bounding_box} - return r2s, bounding_boxes - - -def test_r2s_mesh_expected_output(simple_model_and_mesh, tmp_path): - model, (c1, c2), mesh = simple_model_and_mesh - - # Use mesh-based domains - r2s = R2SManager(model, mesh) - - # Use custom reduced chain file for Ni - chain = Chain.from_xml(Path(__file__).parents[1] / "chain_ni.xml") - - # Run R2S calculation - outdir = r2s.run( - timesteps=[(1.0, 'd')], - source_rates=[1.0], - output_dir=tmp_path, - chain_file=chain, - micro_kwargs={'nuclides': ['Ni58'], 'reactions': ['(n,p)']}, - ) - - # Check directories and files exist - nt = Path(outdir) / 'neutron_transport' - assert (nt / 'fluxes.npy').exists() - assert (nt / 'micros.h5').exists() - assert (nt / 'mesh_material_volumes_0.npz').exists() - act = Path(outdir) / 'activation' - assert (act / 'depletion_results.h5').exists() - pt = Path(outdir) / 'photon_transport' - assert (pt / 'tally_ids.json').exists() - assert not (pt / 'time_0').exists() - assert (pt / 'time_1' / 'statepoint.2.h5').exists() - - # Basic results structure checks - assert len(r2s.results['fluxes']) == 2 - assert len(r2s.results['micros']) == 2 - assert len(r2s.results['mesh_material_volumes']) == 1 - assert len(r2s.results['mesh_material_volumes'][0]) == 2 - assert len(r2s.results['activation_materials']) == 2 - assert len(r2s.results['depletion_results']) == 2 - assert list(r2s.results['photon_sources']) == [1] - assert r2s.results['photon_sources'][1] - - # Check activation materials - amats = r2s.results['activation_materials'] - assert all(m.depletable for m in amats) - # Volumes preserved - assert {m.volume for m in amats} == {c1.volume, c2.volume} - - # Check loading results - r2s_loaded = R2SManager(model, mesh) - r2s_loaded.load_results(outdir) - assert len(r2s_loaded.results['fluxes']) == 2 - assert len(r2s_loaded.results['micros']) == 2 - assert len(r2s_loaded.results['mesh_material_volumes']) == 1 - assert len(r2s_loaded.results['mesh_material_volumes'][0]) == 2 - assert len(r2s_loaded.results['activation_materials']) == 2 - assert len(r2s_loaded.results['depletion_results']) == 2 - - -def test_r2s_multi_mesh(simple_model_and_mesh, tmp_path): - model, _, _ = simple_model_and_mesh - - # Two 1x1x1 meshes that together cover the full domain, split along y. - # Each mesh element spans the full x range [-10, 10], crossing the x=0 - # material boundary, so both meshes contain both materials within their - # single element. - mesh1 = openmc.RegularMesh() - mesh1.lower_left = (-10.0, -10.0, -10.0) - mesh1.upper_right = (10.0, 0.0, 10.0) - mesh1.dimension = (1, 1, 1) - mesh2 = openmc.RegularMesh() - mesh2.lower_left = (-10.0, 0.0, -10.0) - mesh2.upper_right = (10.0, 10.0, 10.0) - mesh2.dimension = (1, 1, 1) - - r2s = R2SManager(model, [mesh1, mesh2]) - chain = Chain.from_xml(Path(__file__).parents[1] / "chain_ni.xml") - - outdir = r2s.run( - timesteps=[(1.0, 'd')], - source_rates=[1.0], - photon_time_indices=[1], - output_dir=tmp_path, - chain_file=chain, - micro_kwargs={'nuclides': ['Ni58'], 'reactions': ['(n,p)']}, - ) - - # Check that per-mesh MMV files were written - nt = Path(outdir) / 'neutron_transport' - assert (nt / 'fluxes.npy').exists() - assert (nt / 'micros.h5').exists() - assert (nt / 'mesh_material_volumes_0.npz').exists() - assert (nt / 'mesh_material_volumes_1.npz').exists() - act = Path(outdir) / 'activation' - assert (act / 'depletion_results.h5').exists() - pt = Path(outdir) / 'photon_transport' - assert (pt / 'tally_ids.json').exists() - assert (pt / 'time_1' / 'statepoint.2.h5').exists() - - # Two meshes, each with 1 element containing both materials → - # 2 element-material combinations per mesh, 4 total - assert len(r2s.results['mesh_material_volumes']) == 2 - assert len(r2s.results['mesh_material_volumes'][0]) == 2 - assert len(r2s.results['mesh_material_volumes'][1]) == 2 - assert len(r2s.results['fluxes']) == 4 - assert len(r2s.results['micros']) == 4 - assert len(r2s.results['activation_materials']) == 4 - assert len(r2s.results['depletion_results']) == 2 - - # Activation material names encode mesh index - amats = r2s.results['activation_materials'] - assert all(m.depletable for m in amats) - assert any('Mesh 0' in m.name for m in amats) - assert any('Mesh 1' in m.name for m in amats) - - # Check loading results - r2s_loaded = R2SManager(model, [mesh1, mesh2]) - r2s_loaded.load_results(outdir) - assert len(r2s_loaded.results['mesh_material_volumes']) == 2 - assert len(r2s_loaded.results['mesh_material_volumes'][0]) == 2 - assert len(r2s_loaded.results['mesh_material_volumes'][1]) == 2 - assert len(r2s_loaded.results['activation_materials']) == 4 - assert len(r2s_loaded.results['depletion_results']) == 2 - - -def test_r2s_cell_expected_output(simple_model_and_mesh, tmp_path): - model, (c1, c2), _ = simple_model_and_mesh - tally = openmc.Tally() - tally.scores = ['flux'] - model.tallies = [tally] - - # Use cell-based domains - r2s = R2SManager(model, [c1, c2]) - - # Use custom reduced chain file for Ni - chain = Chain.from_xml(Path(__file__).parents[1] / "chain_ni.xml") - - # Run R2S calculation - bounding_boxes = {c1.id: c1.bounding_box, c2.id: c2.bounding_box} - outdir = r2s.run( - timesteps=[(1.0, 'd')], - source_rates=[1.0], - photon_time_indices=[1], - by_parent_nuclide=True, - output_dir=tmp_path, - bounding_boxes=bounding_boxes, - chain_file=chain, - micro_kwargs={'nuclides': ['Ni58'], 'reactions': ['(n,p)']}, - ) - - # Check directories and files exist - nt = Path(outdir) / 'neutron_transport' - assert (nt / 'fluxes.npy').exists() - assert (nt / 'micros.h5').exists() - act = Path(outdir) / 'activation' - assert (act / 'depletion_results.h5').exists() - pt = Path(outdir) / 'photon_transport' - assert (pt / 'tally_ids.json').exists() - assert (pt / 'time_1' / 'statepoint.2.h5').exists() - - # Basic results structure checks - assert len(r2s.results['fluxes']) == 2 - assert len(r2s.results['micros']) == 2 - assert len(r2s.results['activation_materials']) == 2 - assert len(r2s.results['depletion_results']) == 2 - assert r2s.photon_model.tallies[0].contains_filter( - openmc.ParentNuclideFilter) - - # Check activation materials - amats = r2s.results['activation_materials'] - assert all(m.depletable for m in amats) - # Names include cell IDs - assert any(f"Cell {c1.id}" in m.name for m in amats) - assert any(f"Cell {c2.id}" in m.name for m in amats) - # Volumes preserved - assert {m.volume for m in amats} == {c1.volume, c2.volume} - - # Check loading results - r2s_loaded = R2SManager(model, [c1, c2]) - r2s_loaded.load_results(outdir) - assert len(r2s_loaded.results['fluxes']) == 2 - assert len(r2s_loaded.results['micros']) == 2 - assert len(r2s_loaded.results['activation_materials']) == 2 - assert len(r2s_loaded.results['depletion_results']) == 2 - - -def test_step4_requires_photon_sources(simple_model_and_mesh, tmp_path): - model, (c1, c2), _ = simple_model_and_mesh - r2s = R2SManager(model, [c1, c2]) - output_dir = tmp_path / 'photon' - - with pytest.raises(RuntimeError, match='step3_photon_source'): - r2s.step4_photon_transport(output_dir) - - r2s.results['photon_sources'] = {} - with pytest.raises(RuntimeError, match='No decay photon sources'): - r2s.step4_photon_transport(output_dir) - - assert not output_dir.exists() - - -def test_default_photon_times_skip_empty_sources( - source_stage_manager, tmp_path, monkeypatch -): - r2s, bounding_boxes = source_stage_manager - source = object() - sources_by_time = {0: [], 1: [source]} - monkeypatch.setattr( - r2s, '_create_photon_sources', - lambda time_index, work_items: sources_by_time[time_index]) - - r2s.step3_photon_source( - bounding_boxes=bounding_boxes, output_dir=tmp_path) - - assert r2s.results['photon_sources'] == {1: [source]} - - -def test_explicit_empty_photon_source_fails( - source_stage_manager, tmp_path, monkeypatch -): - r2s, bounding_boxes = source_stage_manager - source = object() - sources_by_time = {0: [], 1: [source]} - monkeypatch.setattr( - r2s, '_create_photon_sources', - lambda time_index, work_items: sources_by_time[time_index]) - r2s.results['photon_sources'] = {99: [source]} - - with pytest.raises(RuntimeError, match='requested time indices: 0'): - r2s.step3_photon_source( - [0, 1], bounding_boxes, output_dir=tmp_path) - - assert 'photon_sources' not in r2s.results - - -def test_default_photon_times_require_a_source( - source_stage_manager, tmp_path, monkeypatch -): - r2s, bounding_boxes = source_stage_manager - monkeypatch.setattr( - r2s, '_create_photon_sources', - lambda time_index, work_items: []) - - with pytest.raises(RuntimeError, match='at any depletion time'): - r2s.step3_photon_source( - bounding_boxes=bounding_boxes, output_dir=tmp_path) - - assert 'photon_sources' not in r2s.results - - -@pytest.mark.parametrize( - ('time_indices', 'exception'), - [ - ([], ValueError), - ([2], IndexError), - ([-3], IndexError), - ([1.0], TypeError), - ], -) -def test_photon_time_index_validation( - source_stage_manager, tmp_path, time_indices, exception -): - r2s, bounding_boxes = source_stage_manager - - with pytest.raises(exception): - r2s.step3_photon_source( - time_indices, bounding_boxes, output_dir=tmp_path) - - assert 'photon_sources' not in r2s.results diff --git a/tests/unit_tests/test_region.py b/tests/unit_tests/test_region.py index cb9fa171b..8c9e0afe4 100644 --- a/tests/unit_tests/test_region.py +++ b/tests/unit_tests/test_region.py @@ -106,7 +106,7 @@ def test_complement(reset): assert_unbounded(outside_equiv) # string represention - assert str(inside) == '(-1 2 -3)' + assert str(inside) == '~(1 | -2 | 3)' # evaluate method assert (0, 0, 0) in inside @@ -248,10 +248,6 @@ def test_plot(): c_before = openmc.Cell() region.plot() - # Close plot to avoid warning - import matplotlib.pyplot as plt - plt.close() - # Ensure that calling plot doesn't affect cell ID space c_after = openmc.Cell() assert c_after.id - 1 == c_before.id diff --git a/tests/unit_tests/test_settings.py b/tests/unit_tests/test_settings.py index bdb3ea8fe..650bfd186 100644 --- a/tests/unit_tests/test_settings.py +++ b/tests/unit_tests/test_settings.py @@ -1,17 +1,8 @@ -from pathlib import Path - -import h5py -import pytest - import openmc -import openmc.lib import openmc.stats def test_export_to_xml(run_in_tmpdir): - - tmp_properties_file = 'properties_test.h5' - s = openmc.Settings(run_mode='fixed source', batches=1000, seed=17) s.generations_per_batch = 10 s.inactive = 100 @@ -30,14 +21,11 @@ def test_export_to_xml(run_in_tmpdir): s.statepoint = {'batches': [50, 150, 500, 1000]} s.surf_source_read = {'path': 'surface_source_1.h5'} s.surf_source_write = {'surface_ids': [2], 'max_particles': 200} - s.surface_grazing_ratio = 0.7 - s.surface_grazing_cutoff = 0.1 s.confidence_intervals = True s.ptables = True s.plot_seed = 100 s.survival_biasing = True s.cutoff = {'weight': 0.25, 'weight_avg': 0.5, 'energy_neutron': 1.0e-5, - 'survival_normalization': True, 'energy_photon': 1000.0, 'energy_electron': 1.0e-5, 'energy_positron': 1.0e-5, 'time_neutron': 1.0e-5, 'time_photon': 1.0e-5, 'time_electron': 1.0e-5, @@ -54,7 +42,6 @@ def test_export_to_xml(run_in_tmpdir): s.tabular_legendre = {'enable': True, 'num_points': 50} s.temperature = {'default': 293.6, 'method': 'interpolation', 'multipole': True, 'range': (200., 1000.)} - s.properties_file = tmp_properties_file s.trace = (10, 1, 20) s.track = [(1, 1, 1), (2, 1, 1)] s.ufs_mesh = mesh @@ -69,36 +56,21 @@ def test_export_to_xml(run_in_tmpdir): s.log_grid_bins = 2000 s.photon_transport = False s.electron_treatment = 'led' - s.atomic_relaxation = False s.write_initial_source = True s.weight_window_checkpoints = {'surface': True, 'collision': False} - source_region_mesh = openmc.RegularMesh() - source_region_mesh.dimension = [2, 2, 2] - source_region_mesh.lower_left = [-2, -2, -2] - source_region_mesh.upper_right = [2, 2, 2] - root_universe = openmc.Universe() s.random_ray = { 'distance_inactive': 10.0, 'distance_active': 100.0, 'ray_source': openmc.IndependentSource( space=openmc.stats.Box((-1., -1., -1.), (1., 1., 1.)) - ), - 'source_region_meshes': [(source_region_mesh, [root_universe])], - 'volume_estimator': 'hybrid', - 'source_shape': 'linear', - 'volume_normalized_flux_tallies': True, - 'adjoint': False, - 'sample_method': 'halton' + ) } + s.max_particle_events = 100 - s.max_secondaries = 1_000_000 - s.source_rejection_fraction = 0.01 - s.free_gas_threshold = 800.0 # Make sure exporting XML works s.export_to_xml() - # Generate settings from XML s = openmc.Settings.from_xml() assert s.run_mode == 'fixed source' @@ -119,17 +91,14 @@ def test_export_to_xml(run_in_tmpdir): assert s.sourcepoint == {'batches': [50, 150, 500, 1000], 'separate': True, 'write': True, 'overwrite': True, 'mcpl': True} assert s.statepoint == {'batches': [50, 150, 500, 1000]} - assert s.surf_source_read['path'].name == 'surface_source_1.h5' + assert s.surf_source_read == {'path': 'surface_source_1.h5'} assert s.surf_source_write == {'surface_ids': [2], 'max_particles': 200} - assert s.surface_grazing_ratio == 0.7 - assert s.surface_grazing_cutoff == 0.1 assert s.confidence_intervals assert s.ptables assert s.plot_seed == 100 assert s.seed == 17 assert s.survival_biasing assert s.cutoff == {'weight': 0.25, 'weight_avg': 0.5, - 'survival_normalization': True, 'energy_neutron': 1.0e-5, 'energy_photon': 1000.0, 'energy_electron': 1.0e-5, 'energy_positron': 1.0e-5, 'time_neutron': 1.0e-5, 'time_photon': 1.0e-5, @@ -145,7 +114,6 @@ def test_export_to_xml(run_in_tmpdir): assert s.tabular_legendre == {'enable': True, 'num_points': 50} assert s.temperature == {'default': 293.6, 'method': 'interpolation', 'multipole': True, 'range': [200., 1000.]} - assert s.properties_file == Path(tmp_properties_file) assert s.trace == [10, 1, 20] assert s.track == [(1, 1, 1), (2, 1, 1)] assert isinstance(s.ufs_mesh, openmc.RegularMesh) @@ -160,8 +128,7 @@ def test_export_to_xml(run_in_tmpdir): assert s.log_grid_bins == 2000 assert not s.photon_transport assert s.electron_treatment == 'led' - assert not s.atomic_relaxation - assert s.write_initial_source + assert s.write_initial_source == True assert len(s.volume_calculations) == 1 vol = s.volume_calculations[0] assert vol.domain_type == 'cell' @@ -175,74 +142,3 @@ def test_export_to_xml(run_in_tmpdir): assert s.random_ray['distance_active'] == 100.0 assert s.random_ray['ray_source'].space.lower_left == [-1., -1., -1.] assert s.random_ray['ray_source'].space.upper_right == [1., 1., 1.] - assert 'source_region_meshes' in s.random_ray - assert len(s.random_ray['source_region_meshes']) == 1 - mesh_and_domains = s.random_ray['source_region_meshes'][0] - recovered_mesh = mesh_and_domains[0] - assert recovered_mesh.dimension == (2, 2, 2) - assert recovered_mesh.lower_left == [-2., -2., -2.] - assert recovered_mesh.upper_right == [2., 2., 2.] - assert s.random_ray['volume_estimator'] == 'hybrid' - assert s.random_ray['source_shape'] == 'linear' - assert s.random_ray['volume_normalized_flux_tallies'] - assert not s.random_ray['adjoint'] - assert s.random_ray['sample_method'] == 'halton' - assert s.max_secondaries == 1_000_000 - assert s.source_rejection_fraction == 0.01 - assert s.free_gas_threshold == 800.0 - - -def test_properties_file_load(tmp_path, mpi_intracomm): - model = openmc.examples.pwr_assembly() - - # Session 1: export a structurally valid properties file via the C++ API, - # then collect the cell/material structure so we can patch it with h5py. - cell_instances = {} # {cell_id: n_instances} — material cells only - mat_densities = {} # {mat_id: original atom/b-cm density} - - props_path = tmp_path / 'properties.h5' - with openmc.lib.TemporarySession(model, intracomm=mpi_intracomm): - openmc.lib.export_properties(str(props_path)) - for cell_id, cell in openmc.lib.cells.items(): - try: - cell.fill # raises NotImplementedError for non-material cells - cell_instances[cell_id] = cell.num_instances - except NotImplementedError: - pass - for mat_id, mat in openmc.lib.materials.items(): - mat_densities[mat_id] = mat.get_density('atom/b-cm') - - assert any(n > 1 for n in cell_instances.values()) - - # Patch the exported properties file overwriting temperatures - # with per-instance values and scale material atom densities. - density_factor = 0.75 - with h5py.File(props_path, 'r+') as f: - cells_grp = f['geometry/cells'] - for cell_id, n in cell_instances.items(): - cell_grp = cells_grp[f'cell {cell_id}'] - del cell_grp['temperature'] - cell_grp.create_dataset( - 'temperature', data=[500.0 + 5.0 * i for i in range(n)] - ) - - for mat_id, orig_density in mat_densities.items(): - f['materials'][f'material {mat_id}'].attrs['atom_density'] = \ - orig_density * density_factor - - # now apply the newly patched properties file using the settings - # and load the model again, checking that the new temperature and - # density values match those in the new file - model.settings.properties_file = props_path - - with openmc.lib.TemporarySession(model, intracomm=mpi_intracomm): - for cell_id, n in cell_instances.items(): - cell = openmc.lib.cells[cell_id] - for i in range(n): - assert cell.get_temperature(i) == pytest.approx(500.0 + 5.0 * i) - - for mat_id, orig_density in mat_densities.items(): - mat = openmc.lib.materials[mat_id] - assert mat.get_density('atom/b-cm') == pytest.approx( - orig_density * density_factor, rel=1e-5 - ) diff --git a/tests/unit_tests/test_slice_data.py b/tests/unit_tests/test_slice_data.py deleted file mode 100644 index cc5fb0474..000000000 --- a/tests/unit_tests/test_slice_data.py +++ /dev/null @@ -1,168 +0,0 @@ -import numpy as np -import openmc -from openmc.examples import pwr_pin_cell - - -def test_slice_data_basic(run_in_tmpdir): - """Test basic slice_data functionality.""" - model = pwr_pin_cell() - geom_data, prop_data = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(100, 100), - basis='xy' - ) - - # Without filter, should have 3 fields - assert geom_data.shape == (100, 100, 3) - assert geom_data.dtype == np.int32 - assert prop_data.shape == (100, 100, 2) - assert prop_data.dtype == np.float64 - - # Check we have valid geometry - assert np.any(geom_data[:, :, 0] >= 0) # Valid cell IDs - assert np.any(prop_data[:, :, 0] > 0) # Valid temperatures - - -def test_slice_data_no_properties(run_in_tmpdir): - """Test slice_data without property data.""" - model = pwr_pin_cell() - geom_data, prop_data = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(50, 50), - include_properties=False - ) - - # Without filter, should have 3 fields - assert geom_data.shape == (50, 50, 3) - assert prop_data is None - - -def test_slice_data_with_filter(run_in_tmpdir): - """Test slice_data with a cell filter.""" - model = pwr_pin_cell() - cell_ids = [c.id for c in model.geometry.get_all_cells().values()] - cell_filter = openmc.CellFilter(cell_ids) - - geom_data, _ = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(50, 50), - filter=cell_filter, - include_properties=False - ) - - # With filter, should have 4 fields - assert geom_data.shape == (50, 50, 4) - - # Filter bin index should be populated where cells exist - filter_bins = geom_data[:, :, 3] - valid_cells = geom_data[:, :, 0] >= 0 - assert np.any(filter_bins[valid_cells] >= 0) - - -def test_slice_data_overlaps(run_in_tmpdir): - """Test slice_data with overlap detection.""" - model = pwr_pin_cell() - geom_data, _ = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(50, 50), - show_overlaps=True, - include_properties=False - ) - - # Without filter, should have 3 fields - assert geom_data.shape == (50, 50, 3) - # Check for overlap markers (-3) if any exist - # Note: This test may pass without finding overlaps if geometry is correct - - -def test_slice_data_overlaps_with_filter(run_in_tmpdir): - """Test that overlaps don't overwrite filter bin data.""" - model = pwr_pin_cell() - cell_ids = [c.id for c in model.geometry.get_all_cells().values()] - cell_filter = openmc.CellFilter(cell_ids) - - geom_data, _ = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(50, 50), - filter=cell_filter, - show_overlaps=True, - include_properties=False - ) - - assert geom_data.shape == (50, 50, 4) - - # If any overlaps exist, verify filter bin is still valid (not -3) - overlap_pixels = geom_data[:, :, 0] == -3 - if np.any(overlap_pixels): - # Filter bins at overlap locations should NOT be -3 - filter_bins_at_overlaps = geom_data[overlap_pixels, 3] - assert not np.all(filter_bins_at_overlaps == -3), \ - "Filter bins should be preserved even where overlaps are detected" - - -def test_slice_data_different_bases(run_in_tmpdir): - """Test slice_data with different basis planes.""" - model = pwr_pin_cell() - - for basis in ['xy', 'xz', 'yz']: - geom_data, prop_data = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(25, 25), - basis=basis - ) - - assert geom_data.shape == (25, 25, 3) - assert prop_data.shape == (25, 25, 2) - - -def test_slice_data_oriented_spans(run_in_tmpdir): - """Test slice_data with oriented span vectors.""" - model = pwr_pin_cell() - - geom_data, prop_data = model.slice_data( - origin=(0, 0, 0), - u_span=(1.0, 0.0, 0.0), - v_span=(0.0, 0.0, 1.0), - pixels=(25, 25) - ) - - assert geom_data.shape == (25, 25, 3) - assert prop_data.shape == (25, 25, 2) - - -def test_slice_data_level(run_in_tmpdir): - """Test slice_data with specific universe level.""" - model = pwr_pin_cell() - geom_data, _ = model.slice_data( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(50, 50), - level=0, # Root universe only - include_properties=False - ) - - assert geom_data.shape == (50, 50, 3) - - -def test_id_map_reverted(run_in_tmpdir): - """Test that id_map returns 3D array without filter support.""" - model = pwr_pin_cell() - id_data = model.id_map( - origin=(0, 0, 0), - width=(1.0, 1.0), - pixels=(50, 50), - basis='xy' - ) - - # Should have 3 fields (cell_id, cell_instance, material_id) - assert id_data.shape == (50, 50, 3) - assert id_data.dtype == np.int32 - - # Check valid data - assert np.any(id_data[:, :, 0] >= 0) # Valid cell IDs diff --git a/tests/unit_tests/test_slice_data_overlap_info.py b/tests/unit_tests/test_slice_data_overlap_info.py deleted file mode 100644 index e5f08245d..000000000 --- a/tests/unit_tests/test_slice_data_overlap_info.py +++ /dev/null @@ -1,89 +0,0 @@ -import pytest -import numpy as np -import openmc -import openmc.lib - -# Sentinel value matching _OVERLAP in plotmodel.py and OVERLAP in plot.cpp -_OVERLAP = -3 - - -@pytest.fixture(scope='module') -def overlap_model(): - openmc.reset_auto_ids() - - # Three cylinders: cyl1 and cyl2 overlap near x=0, cyl2 and cyl3 overlap - # near x=4. This gives us two spatially distinct overlap regions in one model. - mat1 = openmc.Material(components={'H1': 1.0}) - mat2 = openmc.Material(components={'H1': 1.0}) - mat3 = openmc.Material(components={'H1': 1.0}) - - # cyl1 and cyl2 overlap on the left, cyl2 and cyl3 overlap on the right - cyl1 = openmc.ZCylinder(x0=-2.0, r=2.5) - cyl2 = openmc.ZCylinder(x0=0.0, r=2.5) - cyl3 = openmc.ZCylinder(x0=2.0, r=2.5) - boundary = openmc.Sphere(r=20.0, boundary_type='vacuum') - cell1 = openmc.Cell(region=-cyl1, fill=mat1) - cell2 = openmc.Cell(region=-cyl2, fill=mat2) - cell3 = openmc.Cell(region=-cyl3, fill=mat3) - cell_outside = openmc.Cell(region=+cyl1 & +cyl2 & +cyl3 & -boundary) - geometry = openmc.Geometry([cell1, cell2, cell3, cell_outside]) - - settings = openmc.Settings() - settings.run_mode = 'fixed source' - settings.particles = 100 - settings.batches = 1 - model = openmc.Model(geometry=geometry, settings=settings) - - with openmc.lib.TemporarySession(model, args=['-s', '1']): - yield - - -def run_slice(origin=(0.0, 0.0, 0.0), width=(10.0, 6.0), show_overlaps=True): - # Helper that runs a slice over a region covering both overlap zones - geom_data, _ = openmc.lib.slice_data( - origin=origin, - width=width, - basis='xy', - pixels=(100, 60), - show_overlaps=show_overlaps, - include_properties=False, - ) - return geom_data - - -def test_overlaps_enabled(overlap_model): - # Run a single slice with overlap detection enabled and check all - # expected properties in one pass. - geom_data = run_slice() - overlap_info = openmc.lib.slice_data_overlap_info() - n = overlap_info.shape[0] - cell_ids = geom_data[:, :, 0] - - # cell_ids should contain values more negative than _OVERLAP; RasterData - # encodes each unique overlap as OVERLAP - overlap_idx - 1 into slot 2. - assert np.any(cell_ids < _OVERLAP) - - # overlap_keys should have 2 entries for the two distinct overlapping - # cylinder pairs in this model. - assert n == 2, f"Expected exactly 2 overlap entries, got {n}" - - # Each entry is a (universe_id, cell1_id, cell2_id) triple; verify values. - for i in range(n): - universe_id = int(overlap_info[i, 0]) - cell1_id = int(overlap_info[i, 1]) - cell2_id = int(overlap_info[i, 2]) - assert universe_id == 1 - assert cell1_id in {1, 2, 3} - assert cell2_id in {1, 2, 3} - assert cell1_id != cell2_id - - -def test_overlaps_disabled(overlap_model): - # With show_overlaps=False, set_overlap is never called and overlap_keys - # is never written to, so the image and map should both be clean. - geom_data = run_slice(show_overlaps=False) - overlap_info = openmc.lib.slice_data_overlap_info() - n = overlap_info.shape[0] - - assert not np.any(geom_data[:, :, 2] < _OVERLAP) - assert n == 0 diff --git a/tests/unit_tests/test_slice_voxel_plots.py b/tests/unit_tests/test_slice_voxel_plots.py deleted file mode 100644 index 48ca31b7a..000000000 --- a/tests/unit_tests/test_slice_voxel_plots.py +++ /dev/null @@ -1,273 +0,0 @@ -"""Tests for SlicePlot and VoxelPlot classes - -This module tests the functionality of the new SlicePlot and VoxelPlot -classes that replace the legacy Plot class. -""" -import warnings - -import pytest -import openmc - - -def test_slice_plot_initialization(): - """Test SlicePlot initialization with defaults""" - plot = openmc.SlicePlot() - assert plot.width == [4.0, 4.0] - assert plot.pixels == [400, 400] - assert plot.basis == 'xy' - assert plot.origin == [0., 0., 0.] - - -def test_slice_plot_width_validation(): - """Test that SlicePlot only accepts 2 values for width""" - plot = openmc.SlicePlot() - - # Should accept 2 values - plot.width = [10.0, 20.0] - assert plot.width == [10.0, 20.0] - - # Should reject 1 value - with pytest.raises(ValueError, match='must be of length "2"'): - plot.width = [10.0] - - # Should reject 3 values - with pytest.raises(ValueError, match='must be of length "2"'): - plot.width = [10.0, 20.0, 30.0] - - -def test_slice_plot_pixels_validation(): - """Test that SlicePlot only accepts 2 values for pixels""" - plot = openmc.SlicePlot() - - # Should accept 2 values - plot.pixels = [100, 200] - assert plot.pixels == [100, 200] - - # Should reject 1 value - with pytest.raises(ValueError, match='must be of length "2"'): - plot.pixels = [100] - - # Should reject 3 values - with pytest.raises(ValueError, match='must be of length "2"'): - plot.pixels = [100, 200, 300] - - -def test_slice_plot_basis(): - """Test that SlicePlot has basis attribute""" - plot = openmc.SlicePlot() - - # Test all valid basis values - for basis in ['xy', 'xz', 'yz']: - plot.basis = basis - assert plot.basis == basis - - # Test invalid basis - with pytest.raises(ValueError): - plot.basis = 'invalid' - - -def test_slice_plot_meshlines(): - """Test that SlicePlot has meshlines attribute""" - plot = openmc.SlicePlot() - - meshlines = { - 'type': 'tally', - 'id': 1, - 'linewidth': 2, - 'color': (255, 0, 0) - } - plot.meshlines = meshlines - assert plot.meshlines == meshlines - - -def test_slice_plot_xml_roundtrip(): - """Test SlicePlot XML serialization and deserialization""" - plot = openmc.SlicePlot(name='test_slice') - plot.width = [15.0, 25.0] - plot.pixels = [150, 250] - plot.basis = 'xz' - plot.origin = [1.0, 2.0, 3.0] - plot.color_by = 'material' - plot.filename = 'test_plot' - - # Convert to XML and back - elem = plot.to_xml_element() - new_plot = openmc.SlicePlot.from_xml_element(elem) - - # Check all attributes preserved - assert new_plot.name == plot.name - assert new_plot.width == pytest.approx(plot.width) - assert new_plot.pixels == tuple(plot.pixels) - assert new_plot.basis == plot.basis - assert new_plot.origin == pytest.approx(plot.origin) - assert new_plot.color_by == plot.color_by - assert new_plot.filename == plot.filename - - -def test_slice_plot_from_geometry(): - """Test creating SlicePlot from geometry""" - # Create simple geometry - s = openmc.Sphere(r=10.0, boundary_type='vacuum') - c = openmc.Cell(region=-s) - univ = openmc.Universe(cells=[c]) - geom = openmc.Geometry(univ) - - # Test all basis options - for basis in ['xy', 'xz', 'yz']: - plot = openmc.SlicePlot.from_geometry(geom, basis=basis) - assert plot.basis == basis - assert plot.width == pytest.approx([20.0, 20.0]) - assert plot.origin == pytest.approx([0.0, 0.0, 0.0]) - - -def test_voxel_plot_initialization(): - """Test VoxelPlot initialization with defaults""" - plot = openmc.VoxelPlot() - assert plot.width == [4.0, 4.0, 4.0] - assert plot.pixels == [400, 400, 400] - assert plot.origin == [0., 0., 0.] - - -def test_voxel_plot_width_validation(): - """Test that VoxelPlot only accepts 3 values for width""" - plot = openmc.VoxelPlot() - - # Should accept 3 values - plot.width = [10.0, 20.0, 30.0] - assert plot.width == [10.0, 20.0, 30.0] - - # Should reject 2 values - with pytest.raises(ValueError, match='must be of length "3"'): - plot.width = [10.0, 20.0] - - # Should reject 1 value - with pytest.raises(ValueError, match='must be of length "3"'): - plot.width = [10.0] - - -def test_voxel_plot_pixels_validation(): - """Test that VoxelPlot only accepts 3 values for pixels""" - plot = openmc.VoxelPlot() - - # Should accept 3 values - plot.pixels = [100, 200, 300] - assert plot.pixels == [100, 200, 300] - - # Should reject 2 values - with pytest.raises(ValueError, match='must be of length "3"'): - plot.pixels = [100, 200] - - # Should reject 1 value - with pytest.raises(ValueError, match='must be of length "3"'): - plot.pixels = [100] - - -def test_voxel_plot_xml_roundtrip(): - """Test VoxelPlot XML serialization and deserialization""" - plot = openmc.VoxelPlot(name='test_voxel') - plot.width = [10.0, 20.0, 30.0] - plot.pixels = [100, 200, 300] - plot.origin = [1.0, 2.0, 3.0] - plot.color_by = 'cell' - plot.filename = 'voxel_plot' - - # Convert to XML and back - elem = plot.to_xml_element() - new_plot = openmc.VoxelPlot.from_xml_element(elem) - - # Check all attributes preserved - assert new_plot.name == plot.name - assert new_plot.width == pytest.approx(plot.width) - assert new_plot.pixels == tuple(plot.pixels) - assert new_plot.origin == pytest.approx(plot.origin) - assert new_plot.color_by == plot.color_by - assert new_plot.filename == plot.filename - - -def test_plot_deprecation_warning(): - """Test that Plot class raises deprecation warning""" - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - openmc.Plot() - - assert len(w) == 1 - assert issubclass(w[0].category, FutureWarning) - assert "deprecated" in str(w[0].message).lower() - - -def test_plot_returns_slice_plot(): - """Test that Plot() returns a SlicePlot instance""" - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - plot = openmc.Plot() - - # Should be an actual SlicePlot instance - assert isinstance(plot, openmc.SlicePlot) - - -def test_plot_type_setter_raises_error(): - """Test that setting plot.type raises a helpful error""" - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - plot = openmc.Plot() - - with pytest.raises(TypeError, match="no longer supported"): - plot.type = 'voxel' - - with pytest.raises(TypeError, match="no longer supported"): - plot.type = 'slice' - - -def test_plot_type_getter_warns(): - """Test that getting plot.type raises a deprecation warning""" - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - plot = openmc.Plot() - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - plot_type = plot.type - - assert plot_type == 'slice' - assert len(w) == 1 - assert issubclass(w[0].category, FutureWarning) - assert "deprecated" in str(w[0].message).lower() - - -def test_plots_collection_mixed_types(): - """Test Plots collection with different plot types""" - slice_plot = openmc.SlicePlot(name='slice') - voxel_plot = openmc.VoxelPlot(name='voxel') - wireframe_plot = openmc.WireframeRayTracePlot(name='wireframe') - - plots = openmc.Plots([slice_plot, voxel_plot, wireframe_plot]) - - assert len(plots) == 3 - assert isinstance(plots[0], openmc.SlicePlot) - assert isinstance(plots[1], openmc.VoxelPlot) - assert isinstance(plots[2], openmc.WireframeRayTracePlot) - - -def test_plots_collection_xml_roundtrip(run_in_tmpdir): - """Test XML export and import with new plot types""" - s1 = openmc.SlicePlot(name='slice1') - s1.width = [10.0, 20.0] - s1.basis = 'xz' - - v1 = openmc.VoxelPlot(name='voxel1') - v1.width = [10.0, 20.0, 30.0] - - plots = openmc.Plots([s1, v1]) - plots.export_to_xml() - - # Read back - new_plots = openmc.Plots.from_xml() - - assert len(new_plots) == 2 - assert isinstance(new_plots[0], openmc.SlicePlot) - assert isinstance(new_plots[1], openmc.VoxelPlot) - assert new_plots[0].name == 'slice1' - assert new_plots[1].name == 'voxel1' - assert new_plots[0].basis == 'xz' - assert new_plots[0].width == pytest.approx([10.0, 20.0]) - assert new_plots[1].width == pytest.approx([10.0, 20.0, 30.0]) diff --git a/tests/unit_tests/test_source.py b/tests/unit_tests/test_source.py index 394c09e73..9a19f6f24 100644 --- a/tests/unit_tests/test_source.py +++ b/tests/unit_tests/test_source.py @@ -1,6 +1,4 @@ -from collections import Counter from math import pi -from pathlib import Path import openmc import openmc.lib @@ -36,134 +34,26 @@ def test_source(): assert src.strength == 1.0 -def test_point_cloud(): - positions = [(1, 0, 2), (0, 1, 0), (0, 0, 3), (4, 9, 2)] - strengths = [1, 2, 3, 4] +def test_spherical_uniform(): + r_outer = 2.0 + r_inner = 1.0 + thetas = (0.0, pi/2) + phis = (0.0, pi) + origin = (0.0, 1.0, 2.0) - space = openmc.stats.PointCloud(positions, strengths) - np.testing.assert_equal(space.positions, positions) - np.testing.assert_equal(space.strengths, strengths) + sph_indep_function = openmc.stats.spherical_uniform(r_outer, + r_inner, + thetas, + phis, + origin) - src = openmc.IndependentSource(space=space) - assert src.space == space - np.testing.assert_equal(src.space.positions, positions) - np.testing.assert_equal(src.space.strengths, strengths) - - elem = src.to_xml_element() - src = openmc.IndependentSource.from_xml_element(elem) - np.testing.assert_equal(src.space.positions, positions) - np.testing.assert_equal(src.space.strengths, strengths) - - -def test_point_cloud_invalid(): - with pytest.raises(ValueError, match='2D'): - openmc.stats.PointCloud([1, 0, 2, 0, 1, 0]) - - with pytest.raises(ValueError, match='3 values'): - openmc.stats.PointCloud([(1, 0, 2, 3), (4, 5, 2, 3)]) - - with pytest.raises(ValueError, match='1D'): - openmc.stats.PointCloud([(1, 0, 2), (4, 5, 2)], [(1, 2), (3, 4)]) - - with pytest.raises(ValueError, match='same length'): - openmc.stats.PointCloud([(1, 0, 2), (4, 5, 2)], [1, 2, 4]) - - -def test_point_cloud_strengths(run_in_tmpdir, sphere_box_model): - positions = [(1., 0., 2.), (0., 1., 0.), (0., 0., 3.), (-1., -1., 2.)] - strengths = [1, 2, 3, 4] - space = openmc.stats.PointCloud(positions, strengths) - - model = sphere_box_model[0] - model.settings.run_mode = 'fixed source' - model.settings.source = openmc.IndependentSource(space=space) - - try: - model.init_lib() - n_samples = 50_000 - sites = openmc.lib.sample_external_source(n_samples) - finally: - model.finalize_lib() - - count = Counter(s.r for s in sites) - for i, (strength, position) in enumerate(zip(strengths, positions)): - sampled_strength = count[position] / n_samples - expected_strength = pytest.approx(strength/sum(strengths), abs=0.02) - assert sampled_strength == expected_strength, f'Strength incorrect for {positions[i]}' - - -def test_decay_spectrum_parent_nuclide(run_in_tmpdir): - chain_file = Path('chain_decay_spectrum_parent.xml') - chain_file.write_text(""" - - - - 1000000.0 1.0 - - - - - 2000000.0 1.0 - - - -""") - - inner_sphere = openmc.Sphere(r=10.0) - outer_sphere = openmc.Sphere(r=20.0, boundary_type='vacuum') - - shell_mat = openmc.Material() - shell_mat.add_nuclide('H1', 1.0) - shell_mat.set_density('atom/b-cm', 1.0e-12) - - void_cell = openmc.Cell(region=-inner_sphere) - shell_cell = openmc.Cell(fill=shell_mat, region=+inner_sphere & -outer_sphere) - - model = openmc.Model() - model.geometry = openmc.Geometry([void_cell, shell_cell]) - model.materials = [shell_mat] - model.settings.run_mode = 'fixed source' - model.settings.photon_transport = True - model.settings.particles = 1000 - model.settings.batches = 5 - model.settings.source = openmc.IndependentSource( - particle='photon', - space=openmc.stats.Point((0.0, 0.0, 0.0)), - energy=openmc.stats.DecaySpectrum( - {'ParentA': 1.0, 'ParentB': 1.0}, - volume=1.0 - ) - ) - - tally = openmc.Tally() - tally.filters = [ - openmc.CellFilter([void_cell]), - openmc.ParticleFilter(['photon']), - openmc.EnergyFilter([0.0, 1.5e6, 2.5e6]), - openmc.ParentNuclideFilter(['ParentA', 'ParentB']) - ] - tally.scores = ['flux'] - model.tallies = [tally] - - with openmc.config.patch('chain_file', chain_file): - sp_filename = model.run() - - with openmc.StatePoint(sp_filename) as sp: - tally_out = sp.tallies[tally.id] - mean = tally_out.get_reshaped_data('mean').squeeze() - - assert mean.shape == (2, 2) - assert mean[0, 0] > 0.0 - assert mean[1, 1] > 0.0 - assert mean[0, 1] == 0.0 - assert mean[1, 0] == 0.0 - assert np.count_nonzero(mean) == 2 + assert isinstance(sph_indep_function, openmc.stats.SphericalIndependent) def test_source_file(): filename = 'source.h5' src = openmc.FileSource(path=filename) - assert src.path.name == filename + assert src.path == filename elem = src.to_xml_element() assert 'strength' in elem.attrib @@ -171,9 +61,9 @@ def test_source_file(): def test_source_dlopen(): - library = 'libsource.so' - src = openmc.CompiledSource(library) - assert src.library.name == library + library = './libsource.so' + src = openmc.CompiledSource(library=library) + assert src.library == library elem = src.to_xml_element() assert 'library' in elem.attrib @@ -318,35 +208,20 @@ def test_constraints_file(sphere_box_model, run_in_tmpdir): @pytest.mark.skipif(config['mpi'], reason='Not compatible with MPI') -def test_rejection_fraction(run_in_tmpdir): - mat = openmc.Material() - mat.add_nuclide('H1', 1.0) - w = 0.25 - rpp1 = openmc.model.RectangularParallelepiped( - -w/2, w/2, -w/2, w/2, -w/2, w/2) - rpp2 = openmc.model.RectangularParallelepiped( - -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, boundary_type='vacuum') - cell1 = openmc.Cell(fill=mat, region=-rpp1) - cell2 = openmc.Cell(region=+rpp1 & -rpp2) - model = openmc.Model() - model.geometry = openmc.Geometry([cell1, cell2]) +def test_rejection_limit(sphere_box_model, run_in_tmpdir): + model, cell1 = sphere_box_model[:2] - # Create a box source over a 1 cm³ volume that is constrained to the source - # cell of volume (0.25 cm)³ = 0.0125 cm³, which means the default rejection - # fraction of 0.05 won't work - model.settings.particles = 1000 - model.settings.batches = 1 - model.settings.run_mode = 'fixed source' + # Define a point source that will get rejected 100% of the time model.settings.source = openmc.IndependentSource( - space=openmc.stats.Box(*(-rpp2).bounding_box), + space=openmc.stats.Point((-3., 0., 0.)), constraints={'domains': [cell1]} ) - with pytest.raises(RuntimeError, match='Too few source sites'): - model.run(openmc_exec=config['exe']) - # With a source rejection fraction below 0.0125, the simulation should run - model.settings.source_rejection_fraction = 0.005 - model.run(openmc_exec=config['exe']) + # Confirm that OpenMC doesn't run in an infinite loop. Note that this may + # work when running with MPI since it won't necessarily capture the error + # message correctly + with pytest.raises(RuntimeError, match="rejected"): + model.run(openmc_exec=config['exe']) def test_exceptions(): diff --git a/tests/unit_tests/test_source_biasing.py b/tests/unit_tests/test_source_biasing.py deleted file mode 100644 index 12588594c..000000000 --- a/tests/unit_tests/test_source_biasing.py +++ /dev/null @@ -1,276 +0,0 @@ -"""Tests for source biasing using C++ sampling routines via openmc.lib - -This test module validates that the C++ distribution sampling implementations -correctly handle both unbiased and biased sampling when used in source -definitions. Each test: - -1. Creates a minimal model with a source using a specific energy distribution -2. Uses model.sample_external_source() to generate samples via openmc.lib -3. Extracts energies from the returned particle list -4. Validates that: - - Unbiased sampling produces the expected mean - - Biased sampling with importance weighting produces the expected mean - - Weights are correctly applied (non-unity for biased case) - -These tests complement the Python-level tests in test_stats.py by exercising -the full C++ sampling codepath that is used during actual simulations. -""" - -import numpy as np -import pytest -import openmc - -from tests.unit_tests import assert_sample_mean - - -@pytest.fixture -def model(): - """Create a minimal model for source sampling tests.""" - sphere = openmc.Sphere(r=100.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere) - geometry = openmc.Geometry([cell]) - settings = openmc.Settings(particles=100, batches=1) - space = openmc.stats.Point() - angle = openmc.stats.Monodirectional((1.0, 0.0, 0.0)) - settings.source = openmc.IndependentSource(space=space, angle=angle) - return openmc.Model(geometry=geometry, settings=settings) - - -@pytest.mark.flaky(reruns=1) -def test_discrete(run_in_tmpdir, model): - """Test Discrete distribution sampling via C++ routines.""" - vals = np.array([1.0, 2.0, 3.0]) - probs = np.array([0.1, 0.7, 0.2]) - exp_mean = (vals * probs).sum() - - # Create source with discrete energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.Discrete(vals, probs) - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample from biased distribution - energy_dist.bias = np.array([0.2, 0.1, 0.7]) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_uniform(run_in_tmpdir, model): - """Test Uniform distribution sampling via C++ routines.""" - a, b = 5.0, 10.0 - exp_mean = 0.5 * (a + b) - - # Create source with uniform energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.Uniform(a, b) - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample from biased distribution - energy_dist.bias = openmc.stats.PowerLaw(a, b, 2) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_powerlaw(run_in_tmpdir, model): - """Test PowerLaw distribution sampling via C++ routines.""" - a, b, n = 1.0, 20.0, 2.0 - - # Determine mean of distribution - exp_mean = (n+1)*(b**(n+2) - a**(n+2))/((n+2)*(b**(n+1) - a**(n+1))) - - # Create source with powerlaw energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.PowerLaw(a, b, n) - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample from biased distribution - energy_dist.bias = openmc.stats.Uniform(a, b) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_maxwell(run_in_tmpdir, model): - """Test Maxwell distribution sampling via C++ routines.""" - theta = 1.2895e6 - exp_mean = 3/2 * theta - - # Create source with Maxwell energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.Maxwell(theta) - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample from biased distribution - energy_dist.bias = openmc.stats.Maxwell(theta * 1.1) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_watt(run_in_tmpdir, model): - """Test Watt distribution sampling via C++ routines.""" - a, b = 0.965e6, 2.29e-6 - exp_mean = 3/2 * a + a**2 * b / 4 - - # Create source with Watt energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.Watt(a, b) - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample from biased distribution - energy_dist.bias = openmc.stats.Watt(a*1.05, b) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_tabular(run_in_tmpdir, model): - """Test Tabular distribution sampling via C++ routines.""" - # Test linear-linear sampling - x = np.array([0.0, 5.0, 7.0, 10.0]) - p = np.array([10.0, 20.0, 5.0, 6.0]) - - # Create tabular distribution and normalize to get expected mean - model.settings.source[0].energy = energy_dist = openmc.stats.Tabular(x, p, 'linear-linear') - energy_dist.normalize() - exp_mean = energy_dist.mean() - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample from biased distribution - energy_dist.bias = openmc.stats.Uniform(x[0], x[-1]) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_mixture(run_in_tmpdir, model): - """Test Mixture distribution sampling via C++ routines.""" - d1 = openmc.stats.Uniform(0, 5) - d2 = openmc.stats.Uniform(3, 7) - p = [0.5, 0.5] - - # Create mixture energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.Mixture(p, [d1, d2]) - exp_mean = (2.5 + 5.0) / 2 - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, exp_mean) - - # Sample using biased sub-distribution - energy_dist.distribution[0].bias = openmc.stats.PowerLaw(0, 5, 2) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, exp_mean) - assert np.any(weights != 1.0) - - -@pytest.mark.flaky(reruns=1) -def test_normal(run_in_tmpdir, model): - """Test Normal distribution sampling via C++ routines.""" - mean_val = 25.0 - std_dev = 2.0 - - # Create source with normal energy distribution - model.settings.source[0].energy = energy_dist = openmc.stats.Normal(mean_val, std_dev) - - # Sample using C++ routines and extract energies - n_samples = 10_000 - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - - # Check unbiased mean - assert_sample_mean(energies, mean_val) - - # Sample from biased distribution - energy_dist.bias = openmc.stats.Normal(mean_val * 1.1, std_dev) - particles = model.sample_external_source(n_samples) - energies = np.array([p.E for p in particles]) - weights = np.array([p.wgt for p in particles]) - - # Check biased weighted mean - weighted_energies = energies * weights - assert_sample_mean(weighted_energies, mean_val) - assert np.any(weights != 1.0) diff --git a/tests/unit_tests/test_source_file.py b/tests/unit_tests/test_source_file.py index f19ea74a6..1b5549b00 100644 --- a/tests/unit_tests/test_source_file.py +++ b/tests/unit_tests/test_source_file.py @@ -42,11 +42,13 @@ def test_source_file(run_in_tmpdir): assert np.all(arr['E'] == n - np.arange(n)) assert np.all(arr['wgt'] == 1.0) assert np.all(arr['delayed_group'] == 0) - assert np.all(arr['particle'] == 2112) # PDG number for neutron + assert np.all(arr['particle'] == 0) + # Ensure sites read in are consistent - sites = openmc.ParticleList.from_hdf5('test_source.h5') + sites = openmc.read_source_file('test_source.h5') + assert filetype == b'source' xs = np.array([site.r[0] for site in sites]) ys = np.array([site.r[1] for site in sites]) zs = np.array([site.r[2] for site in sites]) @@ -64,33 +66,7 @@ def test_source_file(run_in_tmpdir): dgs = np.array([s.delayed_group for s in sites]) assert np.all(dgs == 0) p_types = np.array([s.particle for s in sites]) - assert np.all(p_types == 2112) # PDG number for neutron - - # Ensure a ParticleList item is a SourceParticle - site = sites[0] - assert isinstance(site, openmc.SourceParticle) - assert site.E == pytest.approx(n) - - # Ensure site slice read in and exported are consistent - sites_slice = sites[:10] - sites_slice.export_to_hdf5("test_source_slice.h5") - sites_slice = openmc.ParticleList.from_hdf5('test_source_slice.h5') - - assert isinstance(sites_slice, openmc.ParticleList) - assert len(sites_slice) == 10 - E = np.array([s.E for s in sites_slice]) - np.testing.assert_allclose(E, n - np.arange(10)) - - # Ensure site list read in and exported are consistent - df = sites.to_dataframe() - sites_filtered = sites[df[df.E <= 10.0].index.tolist()] - sites_filtered.export_to_hdf5("test_source_filtered.h5") - sites_filtered = openmc.read_source_file('test_source_filtered.h5') - - assert isinstance(sites_filtered, openmc.ParticleList) - assert len(sites_filtered) == 10 - E = np.array([s.E for s in sites_filtered]) - np.testing.assert_allclose(E, np.arange(10, 0, -1)) + assert np.all(p_types == 0) def test_wrong_source_attributes(run_in_tmpdir): @@ -145,27 +121,3 @@ def test_source_file_transport(run_in_tmpdir): # Try running OpenMC model.run() - - -def test_source_file_photon_transport(run_in_tmpdir): - # Create a source file containing a photon. Note that photon_transport is - # not explicitly enabled in the settings -- it should be turned on - # automatically because the source file contains a photon. - particle = openmc.SourceParticle(E=1.0e6, particle='photon') - openmc.write_source_file([particle], 'photon_source.h5') - - # Create simple model to use the photon source file - model = openmc.Model() - al = openmc.Material() - al.add_element('Al', 1.0) - al.set_density('g/cm3', 2.7) - sph = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(fill=al, region=-sph) - model.geometry = openmc.Geometry([cell]) - model.settings.source = openmc.FileSource(path='photon_source.h5') - model.settings.particles = 10 - model.settings.batches = 3 - model.settings.run_mode = 'fixed source' - - # Running OpenMC should succeed - model.run() diff --git a/tests/unit_tests/test_source_mesh.py b/tests/unit_tests/test_source_mesh.py index 2550cb87e..43bb1678c 100644 --- a/tests/unit_tests/test_source_mesh.py +++ b/tests/unit_tests/test_source_mesh.py @@ -1,7 +1,5 @@ from itertools import product from pathlib import Path -from math import sqrt -import random import pytest import numpy as np @@ -336,10 +334,13 @@ def test_umesh_source_independent(run_in_tmpdir, request, void_model, library): n_elements = 12_000 model.settings.source = openmc.MeshSource(uscd_mesh, n_elements*[ind_source]) model.export_to_model_xml() - with openmc.lib.run_in_memory(): + try: + openmc.lib.init() openmc.lib.simulation_init() sites = openmc.lib.sample_external_source(10) openmc.lib.statepoint_write('statepoint.h5') + finally: + openmc.lib.finalize() with openmc.StatePoint('statepoint.h5') as sp: uscd_mesh = sp.meshes[uscd_mesh.id] @@ -350,86 +351,32 @@ def test_umesh_source_independent(run_in_tmpdir, request, void_model, library): assert site.r in bounding_box -def test_mesh_source_constraints(run_in_tmpdir): - """Test application of constraints to underlying mesh element sources""" +def test_mesh_source_file(run_in_tmpdir): + # Creating a source file with a single particle + source_particle = openmc.SourceParticle(time=10.0) + openmc.write_source_file([source_particle], 'source.h5') + file_source = openmc.FileSource('source.h5') - # Create simple model with two cells - m1 = openmc.Material() - m1.add_nuclide('H1', 1.0) - m2 = m1.clone() - sph = openmc.Sphere(r=100, boundary_type='vacuum') - box1 = openmc.model.RectangularParallelepiped(-1, 0, -1, 1, -1, 1) - box2 = openmc.model.RectangularParallelepiped(0, 2, -1, 1, -1, 1) - cell1 = openmc.Cell(fill=m1, region=-box1) - cell2 = openmc.Cell(fill=m2, region=-box2) - outer = openmc.Cell(region=-sph & (+box1 | +box2)) - model = openmc.Model() - model.geometry = openmc.Geometry([cell1, cell2, outer]) - - # Define a mesh covering the two cells: the first mesh element contains - # cell1 (-1 < x < 0) and the second element contains cells2 (0 < x < 2) - mesh = openmc.RegularMesh() - mesh.lower_left = (-3., -1., -1.) - mesh.upper_right = (3., 1., 1.) - mesh.dimension = (2, 1, 1) - - # Define a mesh source with a randomly chosen probability - p = random.random() - src1 = openmc.IndependentSource(strength=p, constraints={'domains': [cell1]}) - src2 = openmc.IndependentSource(strength=1 - p, constraints={'domains': [cell2]}) - model.settings.source = openmc.MeshSource(mesh, [src1, src2]) - - # Finish settings and export - model.settings.particles = 100 - model.settings.batches = 1 - model.export_to_model_xml() - - with openmc.lib.run_in_memory(): - # Sample sites from the source - sites = openmc.lib.sample_external_source(N := 1000) - - # Check that all sites are either in cell1 or cell2 - xs = np.array([s.r[0] for s in sites]) - assert (xs >= -1.0).all() - assert (xs <= 2.0).all() - - # Check that the correct percentage of the sites are in cell1 - sigma = sqrt(p*(1- p)/N) - frac = xs[(-1.0 <= xs) & (xs <= 0.0)].size / N - assert frac == pytest.approx(p, abs=5*sigma) - - -@pytest.mark.parametrize("mesh_type", ('rectangular', 'cylindrical', 'spherical')) -def test_mesh_spatial(run_in_tmpdir, mesh_type): - """Test that a spherical mesh source works as expected.""" model = openmc.Model() - # Set up geometry, a box that is shifted in x, y, and z - box = openmc.model.RectangularParallelepiped(5.0, 25.0, -20.0, 20.0, -30.0, 30.0, boundary_type='vacuum') + rect_prism = openmc.model.RectangularParallelepiped( + -5.0, 5.0, -5.0, 5.0, -5.0, 5.0, boundary_type='vacuum') + mat = openmc.Material() mat.add_nuclide('H1', 1.0) - model.geometry = openmc.Geometry([openmc.Cell(fill=mat, region=-box)]) - # Create a mesh of each type in turn - if mesh_type == 'rectangular': - mesh = openmc.RegularMesh.from_domain(model.geometry, (10, 2, 2)) - elif mesh_type == 'cylindrical': - mesh = openmc.CylindricalMesh.from_domain(model.geometry, (10, 2, 2)) - assert max(mesh.r_grid) == 10.0, "Cylindrical mesh radius exceeds geometry bounds" - assert mesh.origin[0] == 15.0, "Cylindrical mesh origin x-coordinate is incorrect" - elif mesh_type == 'spherical': - mesh = openmc.SphericalMesh.from_domain(model.geometry, (10, 2, 2)) - assert max(mesh.r_grid) == 10.0, "Spherical mesh radius exceeds geometry bounds" - assert mesh.origin[0] == 15.0, "Spherical mesh origin x-coordinate is incorrect" - - # Create a mesh source with a single particle - ind_source = openmc.IndependentSource(space=openmc.stats.MeshSpatial(mesh, np.prod(mesh.dimension)*[1.0])) - model.settings.source = ind_source - - model.settings.particles = 100 + model.geometry = openmc.Geometry([openmc.Cell(fill=mat, region=-rect_prism)]) + model.settings.particles = 1000 model.settings.batches = 10 model.settings.run_mode = 'fixed source' + mesh = openmc.RegularMesh() + mesh.lower_left = (-1, -2, -3) + mesh.upper_right = (2, 3, 4) + mesh.dimension = (1, 1, 1) + + model.settings.source = openmc.MeshSource(mesh, [file_source]) + model.export_to_model_xml() openmc.lib.init() @@ -438,7 +385,14 @@ def test_mesh_spatial(run_in_tmpdir, mesh_type): openmc.lib.simulation_finalize() openmc.lib.finalize() - # Check that the sites are within the spherical mesh bounds + # The mesh bounds do not contain the point of the lone source site in the + # file source, so it should not appear in the set of source sites produced + # from the mesh source. Additionally, the source should be located within + # the mesh bbox = mesh.bounding_box for site in sites: + assert site.r != (0, 0, 0) + assert site.E == source_particle.E + assert site.u == source_particle.u + assert site.time == source_particle.time assert site.r in bbox diff --git a/tests/unit_tests/test_source_tokamak.py b/tests/unit_tests/test_source_tokamak.py deleted file mode 100644 index f926c2007..000000000 --- a/tests/unit_tests/test_source_tokamak.py +++ /dev/null @@ -1,263 +0,0 @@ -import numpy as np -import pytest - -import openmc -import openmc.stats - -from tests.unit_tests import assert_sample_mean - - -def make_source(**kwargs): - """Build a valid TokamakSource, overriding defaults via kwargs.""" - r_over_a = np.linspace(0.0, 1.0, 10) - params = dict( - major_radius=620.0, - minor_radius=200.0, - elongation=1.8, - triangularity=0.45, - shafranov_shift=10.0, - r_over_a=r_over_a, - emission_density=(1.0 - r_over_a**2), - energy=openmc.stats.muir(e0=14.08e6, m_rat=5.0, kt=2.0e4), - ) - params.update(kwargs) - return openmc.TokamakSource(**params) - - -def test_tokamak_source_roundtrip(): - src = make_source( - phi_start=0.1, phi_extent=np.pi, n_alpha=51, vertical_shift=5.0, - strength=2.0, time=openmc.stats.Uniform(0.0, 1e-6)) - - elem = src.to_xml_element() - assert elem.get('type') == 'tokamak' - - new = openmc.SourceBase.from_xml_element(elem) - assert isinstance(new, openmc.TokamakSource) - assert new.major_radius == src.major_radius - assert new.minor_radius == src.minor_radius - assert new.elongation == src.elongation - assert new.triangularity == src.triangularity - assert new.shafranov_shift == src.shafranov_shift - assert new.phi_start == src.phi_start - assert new.phi_extent == src.phi_extent - assert new.n_alpha == src.n_alpha - assert new.vertical_shift == src.vertical_shift - assert new.strength == src.strength - np.testing.assert_allclose(new.r_over_a, src.r_over_a) - np.testing.assert_allclose(new.emission_density, src.emission_density) - assert len(new.energy) == 1 - assert isinstance(new.time, openmc.stats.Uniform) - assert new.time.a == src.time.a - assert new.time.b == src.time.b - - -def test_tokamak_source_default_time(): - src = make_source() - assert src.time is None - - new = openmc.SourceBase.from_xml_element(src.to_xml_element()) - assert new.time is None - - with pytest.raises(TypeError): - make_source(time=1.0) - - -def test_tokamak_source_multiple_energies(): - r_over_a = np.linspace(0.0, 1.0, 5) - energies = [openmc.stats.muir(e0=14.08e6, m_rat=5.0, kt=kt) - for kt in (1.0e4, 1.5e4, 2.0e4, 2.5e4, 3.0e4)] - src = make_source(r_over_a=r_over_a, - emission_density=np.ones_like(r_over_a), - energy=energies) - assert len(src.energy) == len(r_over_a) - - new = openmc.SourceBase.from_xml_element(src.to_xml_element()) - assert len(new.energy) == len(r_over_a) - - -@pytest.mark.parametrize("kwargs, match", [ - (dict(minor_radius=700.0), "smaller than major_radius"), - (dict(shafranov_shift=150.0), "half the minor_radius"), - (dict(emission_density=np.ones(5)), "same length as r_over_a"), - (dict(energy=[openmc.stats.muir(14.08e6, 5.0, 2.0e4)] * 2), - "Number of energy distributions"), - (dict(r_over_a=np.linspace(0.1, 1.0, 10)), "must start at 0"), - (dict(r_over_a=np.linspace(0.0, 0.9, 10)), "must end at 1"), - (dict(emission_density=-np.linspace(0.0, 1.0, 10)), "cannot be negative"), - (dict(emission_density=np.zeros(10)), "must contain a positive value"), -]) -def test_tokamak_source_invalid(kwargs, match): - with pytest.raises(ValueError, match=match): - make_source(**kwargs) - - -@pytest.mark.parametrize("value", [-1.5, 1.5]) -def test_tokamak_source_invalid_triangularity(value): - with pytest.raises(ValueError): - make_source(triangularity=value) - - -def test_tokamak_source_invalid_n_alpha(): - with pytest.raises(ValueError): - make_source(n_alpha=2) - - -@pytest.mark.parametrize(("attribute", "value", "match"), [ - ("minor_radius", 700.0, "smaller than major_radius"), - ("shafranov_shift", 150.0, "half the minor_radius"), - ("emission_density", np.ones(5), "same length as r_over_a"), - ("energy", [openmc.stats.delta_function(1.0)] * 2, - "Number of energy distributions"), -]) -def test_tokamak_source_mutation_validation(attribute, value, match): - src = make_source() - setattr(src, attribute, value) - with pytest.raises(ValueError, match=match): - src.to_xml_element() - - -@pytest.mark.parametrize(("emission_density", "expected_mean"), [ - ([1.0, 1.0], 2.0 / 3.0), - ([1.0, 0.0], 0.5), -]) -def test_tokamak_source_radial_sampling( - run_in_tmpdir, emission_density, expected_mean -): - """Check radial sampling for profiles on the coarsest valid grid.""" - major_radius = 620.0 - minor_radius = 200.0 - src = make_source( - major_radius=major_radius, - minor_radius=minor_radius, - elongation=1.0, - triangularity=0.0, - shafranov_shift=0.0, - r_over_a=[0.0, 1.0], - emission_density=emission_density, - energy=openmc.stats.delta_function(14.07e6), - ) - - sphere = openmc.Sphere(r=2000.0, boundary_type='vacuum') - model = openmc.Model( - geometry=openmc.Geometry([openmc.Cell(region=-sphere)]), - settings=openmc.Settings( - particles=100, batches=1, run_mode='fixed source', source=src), - ) - - sites = model.sample_external_source(20_000) - xyz = np.array([site.r for site in sites]) - major_r = np.hypot(xyz[:, 0], xyz[:, 1]) - r_over_a = np.hypot(major_r - major_radius, xyz[:, 2]) / minor_radius - assert_sample_mean(r_over_a, expected_mean) - - -def test_tokamak_source_poloidal_sampling(run_in_tmpdir): - """Check linear-linear poloidal sampling on a coarse internal grid.""" - major_radius = 620.0 - minor_radius = 200.0 - with pytest.warns(UserWarning, match="below 51"): - src = make_source( - major_radius=major_radius, - minor_radius=minor_radius, - elongation=1.0, - triangularity=0.0, - shafranov_shift=0.0, - emission_density=np.ones(10), - n_alpha=3, - energy=openmc.stats.delta_function(14.07e6), - ) - - sphere = openmc.Sphere(r=2000.0, boundary_type='vacuum') - model = openmc.Model( - geometry=openmc.Geometry([openmc.Cell(region=-sphere)]), - settings=openmc.Settings( - particles=100, batches=1, run_mode='fixed source', source=src), - ) - - sites = model.sample_external_source(100_000) - xyz = np.array([site.r for site in sites]) - major_r = np.hypot(xyz[:, 0], xyz[:, 1]) - - # With three alpha points, linear interpolation of cos(alpha) on [0, pi] - # gives 1 - 2*alpha/pi. Integrating the resulting density gives this mean. - expected_R = ( - major_radius - + 2.0 * minor_radius**2 / (np.pi**2 * major_radius) - ) - assert_sample_mean(major_r, expected_R) - - -@pytest.mark.flaky(reruns=1) -def test_tokamak_source_sampling(run_in_tmpdir): - """Exercise the compiled C++ sampling path and check invariants. - - Sampled moments are compared against direct numerical quadrature of the - exact source density S(r)*R*|J|, where the Jacobian J of the flux-surface - map is computed from analytic partial derivatives. This check is - independent of the Bernstein-mixture factorization used by the - implementation. - """ - R0, a, kappa, delta = 620.0, 200.0, 1.8, -0.5 - shafranov, zshift = 40.0, 25.0 - phi_start, phi_extent = 0.5, np.pi / 2 - - # Fine grids to make discretization error negligible relative to - # statistical uncertainty - r_over_a = np.linspace(0.0, 1.0, 200) - src = make_source( - major_radius=R0, minor_radius=a, elongation=kappa, - triangularity=delta, shafranov_shift=shafranov, vertical_shift=zshift, - r_over_a=r_over_a, emission_density=1.0 - r_over_a**2, - phi_start=phi_start, phi_extent=phi_extent, n_alpha=201, - energy=openmc.stats.delta_function(14.07e6)) - - sphere = openmc.Sphere(r=2000.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere) - settings = openmc.Settings( - particles=100, batches=1, run_mode='fixed source', source=src) - model = openmc.Model(geometry=openmc.Geometry([cell]), settings=settings) - - n_samples = 20_000 - sites = model.sample_external_source(n_samples) - - xyz = np.array([s.r for s in sites]) - R = np.hypot(xyz[:, 0], xyz[:, 1]) - z = xyz[:, 2] - - # Energy, weight, and time invariants - assert np.all([s.E == 14.07e6 for s in sites]) - assert np.all([s.wgt == 1.0 for s in sites]) - assert np.all([s.time == 0.0 for s in sites]) - - # Toroidal angle within the requested sector - phi = np.arctan2(xyz[:, 1], xyz[:, 0]) - assert phi.min() >= phi_start - assert phi.max() <= phi_start + phi_extent - - # Positions bounded by the last closed flux surface - assert R.min() >= R0 - a - assert R.max() <= R0 + a + shafranov - assert np.abs(z - zshift).max() <= kappa * a - - # Up-down symmetry about the vertical shift - assert_sample_mean(z, zshift) - - # Reference moments by 2D quadrature of the exact density - r = np.linspace(0.0, 1.0, 1001)[:, np.newaxis] # r/a - alpha = np.linspace(0.0, 2 * np.pi, 2001)[np.newaxis, :] - psi = alpha + delta * np.sin(alpha) - R_map = R0 + a * r * np.cos(psi) + shafranov * (1.0 - r**2) - Z_map = kappa * a * r * np.sin(alpha) - dR_dr = a * np.cos(psi) - 2.0 * shafranov * r - dR_da = -a * r * np.sin(psi) * (1.0 + delta * np.cos(alpha)) - dZ_dr = kappa * a * np.sin(alpha) * np.ones_like(psi) - dZ_da = kappa * a * r * np.cos(alpha) - jac = np.abs(dR_dr * dZ_da - dR_da * dZ_dr) - dens = (1.0 - r**2) * R_map * jac - norm = dens.sum() - expected_R = (R_map * dens).sum() / norm - expected_z2 = (Z_map**2 * dens).sum() / norm - - assert_sample_mean(R, expected_R) - assert_sample_mean((z - zshift)**2, expected_z2) diff --git a/tests/unit_tests/test_spherical_mesh.py b/tests/unit_tests/test_spherical_mesh.py index a95a4151a..0b579be35 100644 --- a/tests/unit_tests/test_spherical_mesh.py +++ b/tests/unit_tests/test_spherical_mesh.py @@ -63,6 +63,8 @@ def test_origin_read_write_to_xml(run_in_tmpdir, model): np.testing.assert_equal(new_mesh.origin, mesh.origin) estimators = ('tracklength', 'collision') +# TODO: determine why this is needed for spherical mesh +# but not cylindrical mesh offset = geom_size + 0.001 origins = set(permutations((-offset, 0, 0))) diff --git a/tests/unit_tests/test_statepoint.py b/tests/unit_tests/test_statepoint.py deleted file mode 100644 index 7ffaf7ec2..000000000 --- a/tests/unit_tests/test_statepoint.py +++ /dev/null @@ -1,65 +0,0 @@ -import openmc - - -def test_get_tally_filter_type(run_in_tmpdir): - """Test various ways of retrieving tallies from a StatePoint object.""" - - mat = openmc.Material() - mat.add_nuclide("H1", 1.0) - mat.set_density("g/cm3", 10.0) - - sphere = openmc.Sphere(r=10.0, boundary_type="vacuum") - cell = openmc.Cell(fill=mat, region=-sphere) - geometry = openmc.Geometry([cell]) - - settings = openmc.Settings() - settings.particles = 10 - settings.batches = 2 - settings.run_mode = "fixed source" - - reg_mesh = openmc.RegularMesh().from_domain(cell) - tally1 = openmc.Tally(tally_id=1) - mesh_filter = openmc.MeshFilter(reg_mesh) - tally1.filters = [mesh_filter] - tally1.scores = ["flux"] - - tally2 = openmc.Tally(tally_id=2, name="heating tally") - cell_filter = openmc.CellFilter(cell) - tally2.filters = [cell_filter] - tally2.scores = ["heating"] - - tallies = openmc.Tallies([tally1, tally2]) - model = openmc.Model( - geometry=geometry, materials=[mat], settings=settings, tallies=tallies - ) - - sp_filename = model.run() - - sp = openmc.StatePoint(sp_filename) - - tally_found = sp.get_tally(filter_type=openmc.MeshFilter) - assert tally_found.id == 1 - - tally_found = sp.get_tally(filter_type=openmc.CellFilter) - assert tally_found.id == 2 - - tally_found = sp.get_tally(filters=[mesh_filter]) - assert tally_found.id == 1 - - tally_found = sp.get_tally(filters=[cell_filter]) - assert tally_found.id == 2 - - tally_found = sp.get_tally(scores=["heating"]) - assert tally_found.id == 2 - - tally_found = sp.get_tally(name="heating tally") - assert tally_found.id == 2 - - tally_found = sp.get_tally(name=None) - assert tally_found.id == 1 - - tally_found = sp.get_tally(id=1) - assert tally_found.id == 1 - - tally_found = sp.get_tally(id=2) - assert tally_found.id == 2 diff --git a/tests/unit_tests/test_statepoint_batches.py b/tests/unit_tests/test_statepoint_batches.py deleted file mode 100644 index bf54e1878..000000000 --- a/tests/unit_tests/test_statepoint_batches.py +++ /dev/null @@ -1,26 +0,0 @@ -from pathlib import Path - -import openmc - - -def test_statepoint_batches(run_in_tmpdir): - # Create a minimal model - mat = openmc.Material() - mat.add_nuclide('U235', 1.0) - mat.set_density('g/cm3', 4.5) - sphere = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(fill=mat, region=-sphere) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.batches = 10 - model.settings.inactive = 5 - model.settings.particles = 100 - - # Specify when statepoints should be written - model.settings.statepoint = {'batches': [3, 6, 9]} - - # Run model and ensure that statepoints are created - model.run() - sp_files = ['statepoint.03.h5', 'statepoint.06.h5', 'statepoint.09.h5'] - for f in sp_files: - assert Path(f).is_file() diff --git a/tests/unit_tests/test_stats.py b/tests/unit_tests/test_stats.py index 2754cf5d0..5451c0a2c 100644 --- a/tests/unit_tests/test_stats.py +++ b/tests/unit_tests/test_stats.py @@ -1,17 +1,21 @@ from math import pi -from pathlib import Path import numpy as np import pytest import openmc import openmc.stats -from openmc.stats.univariate import _INTERPOLATION_SCHEMES, DecaySpectrum from scipy.integrate import trapezoid -from tests.unit_tests import assert_sample_mean + +def assert_sample_mean(samples, expected_mean): + # Calculate sample standard deviation + std_dev = samples.std() / np.sqrt(samples.size - 1) + + # Means should agree within 4 sigma 99.993% of the time. Note that this is + # expected to fail about 1 out of 16,000 times + assert np.abs(expected_mean - samples.mean()) < 4*std_dev -@pytest.mark.flaky(reruns=1) def test_discrete(): x = [0.0, 1.0, 10.0] p = [0.3, 0.2, 0.5] @@ -42,26 +46,8 @@ def test_discrete(): # sample discrete distribution and check that the mean of the samples is # within 4 std. dev. of the expected mean n_samples = 1_000_000 - samples, weights = d3.sample(n_samples) + samples = d3.sample(n_samples) assert_sample_mean(samples, exp_mean) - assert np.all(weights == 1.0) - - # Test biased distribution - d3.bias = np.array([0.2, 0.1, 0.7]) - bias_elem = d3.to_xml_element('distribution') - d4 = openmc.stats.Univariate.from_xml_element(bias_elem) - np.testing.assert_array_equal(d4.bias, [0.2, 0.1, 0.7]) - samples, weights = d4.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, exp_mean) - assert np.all(weights != 1.0) - - -def test_delta_function(): - d = openmc.stats.delta_function(14.1e6) - assert isinstance(d, openmc.stats.Discrete) - np.testing.assert_array_equal(d.x, [14.1e6]) - np.testing.assert_array_equal(d.p, [1.0]) def test_merge_discrete(): @@ -89,28 +75,6 @@ def test_merge_discrete(): assert triple.integral() == pytest.approx(6.0) -def test_merge_discrete_with_bias(): - # Two discrete distributions with different biases - d1 = openmc.stats.Discrete([1.0, 2.0], [0.5, 0.5]) - d2 = openmc.stats.Discrete([2.0, 3.0], [0.3, 0.7], bias=[0.1, 0.9]) - - merged = openmc.stats.Discrete.merge([d1, d2], [0.6, 0.4]) - exp_mean = 0.6 * d1.mean() + 0.4 * d2.mean() - - # Verify merged distribution has correct x values - assert set(merged.x) == {1.0, 2.0, 3.0} - - # Bias should not be changed in original distributions - assert d1.bias is None - assert np.all(d2.bias == [0.1, 0.9]) - - # Sample and verify bias is applied correctly - samples, weights = merged.sample(10_000) - - # Verify weighted mean matches expected unbiased mean - assert_sample_mean(samples*weights, exp_mean) - - def test_clip_discrete(): # Create discrete distribution with two points that are not important, one # because the x value is very small, and one because the p value is very @@ -133,7 +97,6 @@ def test_clip_discrete(): d.clip(5) -@pytest.mark.flaky(reruns=1) def test_uniform(): a, b = 10.0, 20.0 d = openmc.stats.Uniform(a, b) @@ -153,22 +116,10 @@ def test_uniform(): # std. dev. of the expected mean exp_mean = 0.5 * (a + b) n_samples = 1_000_000 - samples, weights = d.sample(n_samples) + samples = d.sample(n_samples) assert_sample_mean(samples, exp_mean) - assert np.all(weights == 1.0) - - # Test biased distribution - d.bias = openmc.stats.PowerLaw(a, b, 2) - bias_elem = d.to_xml_element('distribution') - d2 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d2.bias, openmc.stats.PowerLaw) - samples, weights = d2.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, exp_mean) - assert np.all(weights != 1.0) -@pytest.mark.flaky(reruns=1) def test_powerlaw(): a, b, n = 10.0, 100.0, 2.0 d = openmc.stats.PowerLaw(a, b, n) @@ -186,22 +137,10 @@ def test_powerlaw(): # sample power law distribution and check that the mean of the samples is # within 4 std. dev. of the expected mean n_samples = 1_000_000 - samples, weights = d.sample(n_samples) + samples = d.sample(n_samples) assert_sample_mean(samples, exp_mean) - assert np.all(weights == 1.0) - - # Test biased distribution - d.bias = openmc.stats.Uniform(a, b) - bias_elem = d.to_xml_element('distribution') - d2 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d2.bias, openmc.stats.Uniform) - samples, weights = d2.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, exp_mean) - assert np.all(weights != 1.0) -@pytest.mark.flaky(reruns=1) def test_maxwell(): theta = 1.2895e6 d = openmc.stats.Maxwell(theta) @@ -216,28 +155,15 @@ def test_maxwell(): # sample maxwell distribution and check that the mean of the samples is # within 4 std. dev. of the expected mean n_samples = 1_000_000 - samples, weights = d.sample(n_samples) + samples = d.sample(n_samples) assert_sample_mean(samples, exp_mean) - assert np.all(weights == 1.0) # A second sample starting from a different seed - samples_2, weights_2 = d.sample(n_samples) + samples_2 = d.sample(n_samples) assert_sample_mean(samples_2, exp_mean) assert samples_2.mean() != samples.mean() - assert np.all(weights_2 == 1) - - # Test biased distribution - d.bias = openmc.stats.Maxwell((theta * 1.1)) - bias_elem = d.to_xml_element('distribution') - d2 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d2.bias, openmc.stats.Maxwell) - samples, weights = d2.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, exp_mean) - assert np.all(weights != 1.0) -@pytest.mark.flaky(reruns=1) def test_watt(): a, b = 0.965e6, 2.29e-6 d = openmc.stats.Watt(a, b) @@ -257,83 +183,11 @@ def test_watt(): # sample Watt distribution and check that the mean of the samples is within # 4 std. dev. of the expected mean n_samples = 1_000_000 - samples, weights = d.sample(n_samples) + samples = d.sample(n_samples) assert_sample_mean(samples, exp_mean) - assert np.all(weights == 1.0) - - # Test biased distribution with 5 percent higher T_e - d.bias = openmc.stats.Watt(a*1.05, b) - bias_elem = d.to_xml_element('distribution') - d2 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d2.bias, openmc.stats.Watt) - samples, weights = d2.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, exp_mean) - assert np.all(weights != 1.0) -@pytest.mark.flaky(reruns=1) def test_tabular(): - # test linear-linear sampling - x = np.array([0.001, 5.0, 7.0, 10.0]) - p = np.array([10.0, 20.0, 5.0, 6.0]) - d = openmc.stats.Tabular(x, p, 'linear-linear') - n_samples = 100_000 - samples, weights = d.sample(n_samples) - assert_sample_mean(samples, d.mean()) - assert np.all(weights == 1.0) - - for scheme in _INTERPOLATION_SCHEMES: - # test sampling - d = openmc.stats.Tabular(x, p, scheme) - n_samples = 100_000 - samples = d.sample(n_samples)[0] - assert_sample_mean(samples, d.mean()) - - # test histogram sampling - d = openmc.stats.Tabular(x, p, interpolation='histogram') - samples, weights = d.sample(n_samples) - assert_sample_mean(samples, d.mean()) - assert np.all(weights == 1.0) - - # Multiplying the probabilities should preserve the mean but change the integral - d2 = openmc.stats.Tabular(x, p*2, interpolation='histogram') - assert d2.mean() == pytest.approx(d.mean()) - assert d2.integral() == pytest.approx(2.0*d.integral()) - - # Normalizing should result in an integral of 1 - d.normalize() - assert d.integral() == pytest.approx(1.0) - - # ensure that passing a set of probabilities shorter than x works - # for histogram interpolation - d = openmc.stats.Tabular(x, p[:-1], interpolation='histogram') - d.cdf() - d.mean() - assert_sample_mean(d.sample(n_samples)[0], d.mean()) - - # passing a shorter probability set should raise an error for linear-linear - with pytest.raises(ValueError): - d = openmc.stats.Tabular(x, p[:-1], interpolation='linear-linear') - d.cdf() - - # Use probabilities of correct length for linear-linear interpolation and - # call the CDF method - d = openmc.stats.Tabular(x, p, interpolation='linear-linear') - d.cdf() - - # Test biased distribution - d.bias = openmc.stats.Uniform(x[0], x[-1]) - bias_elem = d.to_xml_element('distribution') - d2 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d2.bias, openmc.stats.Uniform) - samples, weights = d2.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, d2.mean()) - assert np.all(weights != 1.0) - - -def test_tabular_from_xml(): x = np.array([0.0, 5.0, 7.0, 10.0]) p = np.array([10.0, 20.0, 5.0, 6.0]) d = openmc.stats.Tabular(x, p, 'linear-linear') @@ -345,14 +199,40 @@ def test_tabular_from_xml(): assert d.interpolation == 'linear-linear' assert len(d) == len(x) - # Make sure XML roundtrip works with len(x) == len(p) + 1 - x = np.array([0.0, 5.0, 7.0, 10.0]) - p = np.array([10.0, 20.0, 5.0]) - d = openmc.stats.Tabular(x, p, 'histogram') - elem = d.to_xml_element('distribution') - d = openmc.stats.Tabular.from_xml_element(elem) - assert all(d.x == x) - assert all(d.p == p) + # test linear-linear sampling + d = openmc.stats.Tabular(x, p) + n_samples = 100_000 + samples = d.sample(n_samples) + assert_sample_mean(samples, d.mean()) + + # test linear-linear normalization + d.normalize() + assert d.integral() == pytest.approx(1.0) + + # test histogram sampling + d = openmc.stats.Tabular(x, p, interpolation='histogram') + samples = d.sample(n_samples) + assert_sample_mean(samples, d.mean()) + + d.normalize() + assert d.integral() == pytest.approx(1.0) + + # ensure that passing a set of probabilities shorter than x works + # for histogram interpolation + d = openmc.stats.Tabular(x, p[:-1], interpolation='histogram') + d.cdf() + d.mean() + assert_sample_mean(d.sample(n_samples), d.mean()) + + # passing a shorter probability set should raise an error for linear-linear + with pytest.raises(ValueError): + d = openmc.stats.Tabular(x, p[:-1], interpolation='linear-linear') + d.cdf() + + # Use probabilities of correct length for linear-linear interpolation and + # call the CDF method + d = openmc.stats.Tabular(x, p, interpolation='linear-linear') + d.cdf() def test_legendre(): @@ -370,49 +250,27 @@ def test_legendre(): d.to_xml_element('distribution') -@pytest.mark.flaky(reruns=1) def test_mixture(): d1 = openmc.stats.Uniform(0, 5) d2 = openmc.stats.Uniform(3, 7) p = [0.5, 0.5] mix = openmc.stats.Mixture(p, [d1, d2]) - np.testing.assert_allclose(mix.probability, p) + assert mix.probability == p assert mix.distribution == [d1, d2] assert len(mix) == 4 # Sample and make sure sample mean is close to expected mean n_samples = 1_000_000 - samples, weights = mix.sample(n_samples) + samples = mix.sample(n_samples) assert_sample_mean(samples, (2.5 + 5.0)/2) - assert np.all(weights == 1.0) elem = mix.to_xml_element('distribution') d = openmc.stats.Mixture.from_xml_element(elem) - np.testing.assert_allclose(d.probability, p) + assert d.probability == p assert d.distribution == [d1, d2] assert len(d) == 4 - # Test biased sub-distribution - d.distribution[0].bias = openmc.stats.PowerLaw(0, 5, 2) - bias_elem = d.to_xml_element('distribution') - d3 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d3.distribution[0].bias, openmc.stats.PowerLaw) - samples, weights = d3.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, (2.5 + 5.0)/2) - - # Test biased meta-probability - d.distribution[0].bias = None - d.bias = [0.25, 0.75] - bias_elem_2 = d.to_xml_element('distribution') - d4 = openmc.stats.Univariate.from_xml_element(bias_elem_2) - assert isinstance (d4.bias, np.ndarray) - samples, weights = d4.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, (2.5 + 5.0)/2) - assert np.all(weights != 1.0) - def test_mixture_clip(): # Create mixture distribution containing a discrete distribution with two @@ -431,27 +289,6 @@ def test_mixture_clip(): mix_same = mix.clip(1e-6, inplace=True) assert mix_same is mix - # Make sure clip removes low probability distributions - d_small = openmc.stats.Uniform(0., 1.) - d_large = openmc.stats.Uniform(2., 5.) - mix = openmc.stats.Mixture([1e-10, 1.0], [d_small, d_large]) - mix_clip = mix.clip(1e-3) - assert mix_clip.distribution == [d_large] - - # Make sure warning is raised if tolerance is exceeded - d1 = openmc.stats.Discrete([1.0, 1.001], [1.0, 0.7e-6]) - d2 = openmc.stats.Tabular([0.0, 1.0], [0.7e-6], interpolation='histogram') - mix = openmc.stats.Mixture([1.0, 1.0], [d1, d2]) - with pytest.warns(UserWarning): - mix_clip = mix.clip(1e-6) - - # Make sure warning is raised if a biased Discrete is clipped - d3 = openmc.stats.Discrete([1.0, 1.001], [1.0, 0.7e-8]) - d3.bias = [0.9, 0.1] - mix = openmc.stats.Mixture([1.0, 1.0], [d3, d2]) - with pytest.raises(RuntimeError): - mix_clip = mix.clip(1e-6) - def test_polar_azimuthal(): # default polar-azimuthal should be uniform in mu and phi @@ -487,17 +324,12 @@ def test_polar_azimuthal(): def test_isotropic(): d = openmc.stats.Isotropic() - mu = openmc.stats.Uniform(-1.0, 1.0) - phi = openmc.stats.PowerLaw(0., 2*np.pi, 2) - d2 = openmc.stats.PolarAzimuthal(mu, phi) - d.bias = d2 elem = d.to_xml_element() assert elem.tag == 'angle' assert elem.attrib['type'] == 'isotropic' d = openmc.stats.Isotropic.from_xml_element(elem) assert isinstance(d, openmc.stats.Isotropic) - assert isinstance(d.bias, openmc.stats.PolarAzimuthal) def test_monodirectional(): @@ -514,7 +346,6 @@ def test_cartesian(): x = openmc.stats.Uniform(-10., 10.) y = openmc.stats.Uniform(-10., 10.) z = openmc.stats.Uniform(0., 20.) - z.bias = openmc.stats.PowerLaw(0., 20., 3) d = openmc.stats.CartesianIndependent(x, y, z) elem = d.to_xml_element() @@ -530,7 +361,6 @@ def test_cartesian(): d = openmc.stats.Spatial.from_xml_element(elem) assert isinstance(d, openmc.stats.CartesianIndependent) - assert isinstance (d.z.bias, openmc.stats.PowerLaw) def test_box(): @@ -561,114 +391,6 @@ def test_point(): assert d.xyz == pytest.approx(p) -def test_spherical_uniform(): - r_outer = 2.0 - r_inner = 1.0 - thetas = (0.0, pi/2) - phis = (0.0, pi) - origin = (0.0, 1.0, 2.0) - - sph_indep_function = openmc.stats.spherical_uniform(r_outer, - r_inner, - thetas, - phis, - origin) - - assert isinstance(sph_indep_function, openmc.stats.SphericalIndependent) - - -def test_cylindrical_uniform(): - r_outer = 2.0 - r_inner = 1.0 - height = 1.0 - phis = (0.0, pi) - origin = (0.0, 1.0, 2.0) - - dist = openmc.stats.cylindrical_uniform(r_outer, height, r_inner, phis, - origin=origin) - - assert isinstance(dist, openmc.stats.CylindricalIndependent) - - # Check r distribution (PowerLaw with exponent 1 for uniform area sampling) - assert isinstance(dist.r, openmc.stats.PowerLaw) - assert dist.r.a == pytest.approx(r_inner) - assert dist.r.b == pytest.approx(r_outer) - assert dist.r.n == pytest.approx(1.0) - - # Check phi distribution - assert isinstance(dist.phi, openmc.stats.Uniform) - assert dist.phi.a == pytest.approx(phis[0]) - assert dist.phi.b == pytest.approx(phis[1]) - - # Check z distribution (centered on origin along z_dir) - assert isinstance(dist.z, openmc.stats.Uniform) - assert dist.z.a == pytest.approx(-height / 2) - assert dist.z.b == pytest.approx(height / 2) - - # Check origin and default directions - np.testing.assert_allclose(dist.origin, origin) - np.testing.assert_allclose(dist.r_dir, [1., 0., 0.]) - np.testing.assert_allclose(dist.z_dir, [0., 0., 1.]) - - # XML round-trip preserves all parameters - elem = dist.to_xml_element() - dist2 = openmc.stats.CylindricalIndependent.from_xml_element(elem) - np.testing.assert_allclose(dist2.origin, origin) - np.testing.assert_allclose(dist2.r_dir, dist.r_dir) - np.testing.assert_allclose(dist2.z_dir, dist.z_dir) - - -def test_cylindrical_uniform_tilted(): - # Test with non-default axis orientation (y-axis as cylinder axis) - dist = openmc.stats.cylindrical_uniform( - r_outer=3.0, height=2.0, r_dir=(1., 0., 0.), z_dir=(0., 1., 0.) - ) - np.testing.assert_allclose(dist.z_dir, [0., 1., 0.]) - np.testing.assert_allclose(dist.r_dir, [1., 0., 0.]) - - # XML round-trip preserves tilted directions - elem = dist.to_xml_element() - dist2 = openmc.stats.CylindricalIndependent.from_xml_element(elem) - np.testing.assert_allclose(dist2.z_dir, dist.z_dir) - np.testing.assert_allclose(dist2.r_dir, dist.r_dir) - - -def test_cylindrical_uniform_ring(): - # height=0 should produce a flat ring (delta function at z=0) - r_outer = 2.0 - r_inner = 1.0 - phis = (0.0, pi) - origin = (0.0, 1.0, 2.0) - - dist = openmc.stats.cylindrical_uniform(r_outer, 0.0, r_inner, phis, - origin=origin) - - assert isinstance(dist, openmc.stats.CylindricalIndependent) - - # Check r distribution - assert isinstance(dist.r, openmc.stats.PowerLaw) - assert dist.r.a == pytest.approx(r_inner) - assert dist.r.b == pytest.approx(r_outer) - assert dist.r.n == pytest.approx(1.0) - - # Check phi distribution - assert isinstance(dist.phi, openmc.stats.Uniform) - assert dist.phi.a == pytest.approx(phis[0]) - assert dist.phi.b == pytest.approx(phis[1]) - - # z distribution must be a delta function at 0.0 (local frame) - assert isinstance(dist.z, openmc.stats.Discrete) - assert dist.z.x[0] == pytest.approx(0.0) - - # XML round-trip - elem = dist.to_xml_element() - dist2 = openmc.stats.CylindricalIndependent.from_xml_element(elem) - np.testing.assert_allclose(dist2.origin, origin) - np.testing.assert_allclose(dist2.r_dir, dist.r_dir) - np.testing.assert_allclose(dist2.z_dir, dist.z_dir) - - -@pytest.mark.flaky(reruns=1) def test_normal(): mean = 10.0 std_dev = 2.0 @@ -684,108 +406,10 @@ def test_normal(): # sample normal distribution n_samples = 100_000 - samples, weights = d.sample(n_samples) + samples = d.sample(n_samples) assert_sample_mean(samples, mean) - assert np.all(weights == 1.0) - - # Test biased distribution - d.bias = openmc.stats.Normal(10.0, 4.0) - bias_elem = d.to_xml_element('distribution') - d2 = openmc.stats.Univariate.from_xml_element(bias_elem) - assert isinstance (d2.bias, openmc.stats.Normal) - samples, weights = d2.sample(n_samples) - weighted_sample = samples * weights - assert_sample_mean(weighted_sample, mean) - assert np.all(weights != 1.0) -@pytest.mark.flaky(reruns=1) -def test_normal_truncated(): - mean = 10.0 - std_dev = 2.0 - lower = 6.0 - upper = 14.0 - - d = openmc.stats.Normal(mean, std_dev, lower, upper) - - # Check attributes - assert d.mean_value == pytest.approx(mean) - assert d.std_dev == pytest.approx(std_dev) - assert d.lower == pytest.approx(lower) - assert d.upper == pytest.approx(upper) - assert len(d) == 4 - assert d.support == (lower, upper) - - # Test XML round-trip - elem = d.to_xml_element('distribution') - assert elem.attrib['type'] == 'normal' - params = elem.attrib['parameters'].split() - assert len(params) == 4 - - d2 = openmc.stats.Normal.from_xml_element(elem) - assert d2.mean_value == pytest.approx(mean) - assert d2.std_dev == pytest.approx(std_dev) - assert d2.lower == pytest.approx(lower) - assert d2.upper == pytest.approx(upper) - - # Test PDF evaluation - # PDF should be zero outside bounds - assert d.evaluate(lower - 1.0) == 0.0 - assert d.evaluate(upper + 1.0) == 0.0 - - # PDF should be positive inside bounds - assert d.evaluate(mean) > 0.0 - - # PDF should be higher than untruncated at the mean (due to renormalization) - d_unbounded = openmc.stats.Normal(mean, std_dev) - assert d.evaluate(mean) > d_unbounded.evaluate(mean) - - # Verify that PDF integrates to approximately 1 - x = np.linspace(lower, upper, 1000) - integral = trapezoid(d.evaluate(x), x) - assert integral == pytest.approx(1.0, rel=0.01) - - # Sample truncated distribution - n_samples = 10_000 - samples, weights = d.sample(n_samples) - - # All samples should be within bounds - assert np.all(samples >= lower) - assert np.all(samples <= upper) - - # Weights should all be 1 (no biasing) - assert np.all(weights == 1.0) - - -def test_normal_truncated_one_sided(): - # Test lower-bounded only (positive half-normal centered at 0) - d_lower = openmc.stats.Normal(0.0, 1.0, lower=0.0) - assert d_lower.lower == 0.0 - assert d_lower.upper == np.inf - assert d_lower.evaluate(-1.0) == 0.0 - assert d_lower.evaluate(1.0) > 0.0 - - # PDF at 0 should be approximately 2 * 0.3989 ≈ 0.798 (half-normal) - assert d_lower.evaluate(0.0) == pytest.approx(0.798, rel=0.01) - - # Test upper-bounded only - d_upper = openmc.stats.Normal(0.0, 1.0, upper=0.0) - assert d_upper.lower == -np.inf - assert d_upper.upper == 0.0 - assert d_upper.evaluate(1.0) == 0.0 - assert d_upper.evaluate(-1.0) > 0.0 - - -def test_normal_truncated_errors(): - # Invalid bounds (lower >= upper) - with pytest.raises(ValueError): - openmc.stats.Normal(0.0, 1.0, lower=1.0, upper=0.0) - - with pytest.raises(ValueError): - openmc.stats.Normal(0.0, 1.0, lower=1.0, upper=1.0) - - -@pytest.mark.flaky(reruns=1) def test_muir(): mean = 10.0 mass = 5.0 @@ -801,12 +425,10 @@ def test_muir(): # sample muir distribution n_samples = 100_000 - samples, weights = d.sample(n_samples) + samples = d.sample(n_samples) assert_sample_mean(samples, mean) - assert np.all(weights == 1.0) -@pytest.mark.flaky(reruns=1) def test_combine_distributions(): # Combine two discrete (same data as in test_merge_discrete) x1 = [0.0, 1.0, 10.0] @@ -836,313 +458,17 @@ def test_combine_distributions(): assert isinstance(mixed, openmc.stats.Mixture) assert len(mixed.distribution) == 2 assert len(mixed.probability) == 2 - assert mixed == openmc.stats.combine_distributions([mixed], [1.0]) - - # Mixture combined with another distribution: probabilities should be - # correctly scaled when the Mixture is flattened - d_a = openmc.stats.delta_function(1.0) - d_b = openmc.stats.delta_function(2.0) - m = openmc.stats.Mixture([0.3, 0.7], [d_a, d_b]) - extra = openmc.stats.delta_function(3.0) - result = openmc.stats.combine_distributions([m, extra], [0.5, 0.5]) - assert isinstance(result, openmc.stats.Discrete) - assert result.x == pytest.approx([1.0, 2.0, 3.0]) - assert result.p == pytest.approx([0.5*0.3, 0.5*0.7, 0.5]) - - # Passing a Mixture with a bias should warn that the bias is dropped - biased_m = openmc.stats.Mixture([0.5, 0.5], [d_a, d_b], bias=[0.8, 0.2]) - with pytest.warns(UserWarning, match='bias'): - openmc.stats.combine_distributions([biased_m], [1.0]) - - # Single tabular returns a tabular distribution with scaled probabilities - t_single = openmc.stats.Tabular([0.0, 1.0], [2.0, 0.0]) - scaled = openmc.stats.combine_distributions([t_single], [0.25]) - assert isinstance(scaled, openmc.stats.Tabular) - assert scaled.p == pytest.approx([0.5, 0.0]) - - # Mixture with biased tabular should preserve unbiased mean via weights - bias = openmc.stats.Tabular([0.0, 1.0], [2.0, 0.0]) - t_biased = openmc.stats.Tabular([0.0, 1.0], [1.0, 1.0], bias=bias) - d1 = openmc.stats.delta_function(0.0) - mixed = openmc.stats.combine_distributions([t_biased, d1], [0.5, 0.5]) - assert isinstance(mixed, openmc.stats.Mixture) - samples, weights = mixed.sample(10_000) - assert_sample_mean(samples*weights, 0.25) # Combine 1 discrete and 2 tabular -- the tabular distributions should # combine to produce a uniform distribution with mean 0.5. The combined # distribution should have a mean of 0.25. t1 = openmc.stats.Tabular([0., 1.], [2.0, 0.0]) t2 = openmc.stats.Tabular([0., 1.], [0.0, 2.0]) - d1 = openmc.stats.delta_function(0.0) + d1 = openmc.stats.Discrete([0.0], [1.0]) combined = openmc.stats.combine_distributions([t1, t2, d1], [0.25, 0.25, 0.5]) assert combined.integral() == pytest.approx(1.0) # Sample the combined distribution and make sure the sample mean is within # uncertainty of the expected value - samples, weights = combined.sample(10_000) + samples = combined.sample(10_000) assert_sample_mean(samples, 0.25) - assert np.all(weights == 1.0) - - # If biased/unbiased Discrete distributions are combined, unbiased probability - # should be conserved and points from both original distributions should be - # assigned bias probabilities. - x1 = [0.0, 1.0, 10.0] - p1 = [0.3, 0.2, 0.5] - b1 = [0.2, 0.5, 0.3] - d1 = openmc.stats.Discrete(x1, p1, b1) - x2 = [0.5, 1.0, 5.0] - p2 = [0.4, 0.5, 0.1] - d2 = openmc.stats.Discrete(x2, p2) - combined = openmc.stats.combine_distributions([d1, d2, t1], [0.25, 0.25, 0.5]) - - p3 = [0.075, 0.1, 0.175, 0.025, 0.125] - b3 = [0.05, 0.1, 0.25, 0.025, 0.075] - assert all(combined.distribution[-1].p == p3) - assert all(combined.distribution[-1].bias == b3) - - -def test_reference_vwu_projection(): - """When a non-orthogonal vector is provided, the setter should project out - any component along reference_uvw so the stored vector is orthogonal. - """ - pa = openmc.stats.PolarAzimuthal() # default reference_uvw == (0, 0, 1) - - # Provide a vector that is not orthogonal to (0,0,1) - pa.reference_vwu = (2.0, 0.5, 0.3) - - reference_v = np.asarray(pa.reference_vwu) - reference_u = np.asarray(pa.reference_uvw) - - # reference_v should be orthogonal to reference_u - assert abs(np.dot(reference_v, reference_u)) < 1e-6 - - -def test_reference_vwu_normalization(): - """When a non-normalized vector is provided, the setter should normalize - the projected vector to unit length. - """ - pa = openmc.stats.PolarAzimuthal() # default reference_uvw == (0, 0, 1) - - # Provide a vector that is neither orthogonal to (0,0,1) nor unit-length - pa.reference_vwu = (2.0, 0.5, 0.3) - - reference_v = np.asarray(pa.reference_vwu) - - # reference_v should be unit length - assert np.isclose(np.linalg.norm(reference_v), 1.0, atol=1e-12) - - -def test_fusion_spectrum_dd(): - d = openmc.stats.fusion_neutron_spectrum(10e3, 'DD') - assert isinstance(d, openmc.stats.Normal) - - # E_0 for D(d,n)3He is ~2.45 MeV; thermal shift at 10 keV should be - # several tens of keV, so mean should be noticeably above E_0 - assert d.mean_value > 2.45e6 - assert d.mean_value < 2.6e6 - - # Standard deviation should be positive and on order of ~50-100 keV - assert d.std_dev > 30e3 - assert d.std_dev < 200e3 - - -def test_fusion_spectrum_dt(): - d = openmc.stats.fusion_neutron_spectrum(10e3, 'DT') - assert isinstance(d, openmc.stats.Normal) - - # E_0 for T(d,n)alpha is ~14.02 MeV; with thermal shift mean should be - # above E_0 by several tens of keV - assert d.mean_value > 14.02e6 - assert d.mean_value < 14.2e6 - - # Standard deviation should be on order of ~200-400 keV - assert d.std_dev > 100e3 - assert d.std_dev < 500e3 - - -def test_fusion_spectrum_temp_continuity(): - # Verify the low-T and high-T formulas produce nearly identical results - # at the 40 keV switchover point - d_lo = openmc.stats.fusion_neutron_spectrum(39.99e3, 'DT') - d_hi = openmc.stats.fusion_neutron_spectrum(40.01e3, 'DT') - - assert d_lo.mean_value == pytest.approx(d_hi.mean_value, rel=1e-3) - assert d_lo.std_dev == pytest.approx(d_hi.std_dev, rel=1e-3) - - # Same check for DD - d_lo = openmc.stats.fusion_neutron_spectrum(39.99e3, 'DD') - d_hi = openmc.stats.fusion_neutron_spectrum(40.01e3, 'DD') - - assert d_lo.mean_value == pytest.approx(d_hi.mean_value, rel=1e-3) - assert d_lo.std_dev == pytest.approx(d_hi.std_dev, rel=1e-3) - - -def test_fusion_spectrum_high_temp(): - # At T_i = 80 keV (high-T regime), ensure the function still produces - # reasonable results using Table IV formulas - for reactants in ('DD', 'DT'): - d = openmc.stats.fusion_neutron_spectrum(80e3, reactants) - assert isinstance(d, openmc.stats.Normal) - assert d.mean_value > 0 - assert d.std_dev > 0 - - # DT mean at 80 keV should be higher than at 10 keV - d_10 = openmc.stats.fusion_neutron_spectrum(10e3, 'DT') - d_80 = openmc.stats.fusion_neutron_spectrum(80e3, 'DT') - assert d_80.mean_value > d_10.mean_value - assert d_80.std_dev > d_10.std_dev - - -def test_fusion_spectrum_zero_temp(): - # At very low temperature, mean should approach E_0 and width should - # approach zero - d = openmc.stats.fusion_neutron_spectrum(1.0, 'DT') - assert d.mean_value == pytest.approx(14.049e6, rel=1e-3) - assert d.std_dev < 5e3 # width approaches zero at low temperature - - -def test_fusion_spectrum_invalid(): - # Invalid reactant string should raise an error - with pytest.raises(ValueError): - openmc.stats.fusion_neutron_spectrum(10e3, '🐔🧇') - - # Negative temperature should raise an error - with pytest.raises(ValueError): - openmc.stats.fusion_neutron_spectrum(-10e3, 'DT') - - # Temperature above 100 keV should raise an error - with pytest.raises(ValueError): - openmc.stats.fusion_neutron_spectrum(101e3, 'DT') - - -@pytest.fixture(autouse=False) -def decay_spectrum_chain(): - """Set chain_file for the duration of a test and clear the _photon_integral - cache so results from a different chain don't bleed across tests.""" - CHAIN_FILE = (Path(__file__).parents[1] / 'chain_simple.xml').resolve() - DecaySpectrum._photon_integral.cache_clear() - with openmc.config.patch('chain_file', CHAIN_FILE): - yield - DecaySpectrum._photon_integral.cache_clear() - - -def test_decay_spectrum_construction(): - nuclides = {'I135': 1.5e-3, 'Xe135': 8.2e-4} - d = openmc.stats.DecaySpectrum(nuclides, volume=100.0) - assert d.nuclides == nuclides - assert d.volume == pytest.approx(100.0) - assert len(d) == 2 - - -def test_decay_spectrum_validation(): - # nuclides must be a dict - with pytest.raises(TypeError): - openmc.stats.DecaySpectrum(['I135'], volume=1.0) - - # densities must be > 0 - with pytest.raises(ValueError): - openmc.stats.DecaySpectrum({'I135': -1.0}, volume=1.0) - - # volume must be > 0 - with pytest.raises(ValueError): - openmc.stats.DecaySpectrum({'I135': 1e-3}, volume=-1.0) - - with pytest.raises(ValueError): - openmc.stats.DecaySpectrum({'I135': 1e-3}, volume=0.0) - - -def test_decay_spectrum_xml_roundtrip(): - nuclides = {'I135': 1.5e-3, 'Xe135': 8.2e-4} - d = openmc.stats.DecaySpectrum(nuclides, volume=100.0) - - elem = d.to_xml_element('energy') - assert elem.get('type') == 'decay_spectrum' - assert float(elem.get('volume')) == pytest.approx(100.0) - assert elem.findtext('nuclides').split() == list(nuclides) - assert [float(x) for x in elem.findtext('parameters').split()] == pytest.approx( - list(nuclides.values())) - - # Round-trip via DecaySpectrum.from_xml_element - d2 = openmc.stats.DecaySpectrum.from_xml_element(elem) - assert d2.nuclides == nuclides - assert d2.volume == pytest.approx(100.0) - - # Round-trip via the Univariate dispatcher - d3 = openmc.stats.Univariate.from_xml_element(elem) - assert isinstance(d3, openmc.stats.DecaySpectrum) - assert d3 == d - - -def test_decay_spectrum_to_distribution(decay_spectrum_chain): - # Single emitting nuclide -> concrete distribution, not None - d = openmc.stats.DecaySpectrum({'I135': 1e-3}, volume=10.0) - dist = d.to_distribution() - assert dist is not None - - # Result is cached on second call - dist2 = d.to_distribution() - assert dist2 is dist - - # Nuclide with no photon source -> None - d_stable = openmc.stats.DecaySpectrum({'Xe136': 1e-3}, volume=10.0) - assert d_stable.to_distribution() is None - - # Mixture of emitters -> non-None combined distribution - d_mix = openmc.stats.DecaySpectrum( - {'I135': 1e-3, 'Xe135': 5e-4}, volume=10.0 - ) - dist_mix = d_mix.to_distribution() - assert dist_mix is not None - - -def test_decay_spectrum_integral(decay_spectrum_chain): - # For an emitting nuclide, integral should be > 0 - d = openmc.stats.DecaySpectrum({'I135': 1e-3}, volume=10.0) - assert d.integral() > 0.0 - - # Proportional to density: doubling density doubles integral - d2 = openmc.stats.DecaySpectrum({'I135': 2e-3}, volume=10.0) - assert d2.integral() == pytest.approx(2.0 * d.integral()) - - # Proportional to volume - d3 = openmc.stats.DecaySpectrum({'I135': 1e-3}, volume=20.0) - assert d3.integral() == pytest.approx(2.0 * d.integral()) - - # Pure non-emitter -> 0.0 - d_stable = openmc.stats.DecaySpectrum({'Xe136': 1e-3}, volume=10.0) - assert d_stable.integral() == pytest.approx(0.0) - - -def test_decay_spectrum_clip(decay_spectrum_chain): - # Stable / non-emitting nuclides are removed unconditionally - d = openmc.stats.DecaySpectrum( - {'I135': 1e-3, 'Xe135': 5e-4, 'Xe136': 1.0, 'Cs135': 1.0}, - volume=10.0, - ) - d_clip = d.clip() - assert 'Xe136' not in d_clip.nuclides - assert 'Cs135' not in d_clip.nuclides - assert 'I135' in d_clip.nuclides - assert 'Xe135' in d_clip.nuclides - # Original is unchanged - assert 'Xe136' in d.nuclides - - # inplace=True modifies and returns the same object - d_same = d.clip(inplace=True) - assert d_same is d - assert 'Xe136' not in d.nuclides - - # A nuclide with negligible emission rate is removed by tolerance clipping. - # U235 has a very small integral (~4e-17 Bq/atom) compared with I135 (~4e-5) - d_tight = openmc.stats.DecaySpectrum( - {'I135': 1e-3, 'U235': 1e-3}, volume=10.0 - ) - d_tight_clip = d_tight.clip(tolerance=1e-9) - assert 'U235' not in d_tight_clip.nuclides - assert 'I135' in d_tight_clip.nuclides - - # All non-emitters -> empty nuclides dict - d_empty = openmc.stats.DecaySpectrum({'Xe136': 1e-3}, volume=10.0) - d_empty.clip(inplace=True) - assert d_empty.nuclides == {} diff --git a/tests/unit_tests/test_summary.py b/tests/unit_tests/test_summary.py deleted file mode 100644 index 315ac0ba5..000000000 --- a/tests/unit_tests/test_summary.py +++ /dev/null @@ -1,41 +0,0 @@ -import openmc - - -def test_periodic_surface_roundtrip(run_in_tmpdir): - # Create a simple model with periodic surfaces - mat = openmc.Material() - mat.add_nuclide('H1', 1.0) - mat.set_density('g/cm3', 1.0) - cyl = openmc.ZCylinder(r=1.0) - x0 = openmc.XPlane(-5.0, boundary_type='periodic') - y0 = openmc.YPlane(-5.0, boundary_type='periodic') - z0 = openmc.ZPlane(-5.0, boundary_type='periodic') - x1 = openmc.XPlane(5.0, boundary_type='periodic') - y1 = openmc.YPlane(5.0, boundary_type='periodic') - z1 = openmc.ZPlane(5.0, boundary_type='periodic') - x0.periodic_surface = x1 - y0.periodic_surface = y1 - z0.periodic_surface = z1 - cell1 = openmc.Cell(fill=mat, region=-cyl) - cell2 = openmc.Cell(fill=mat, region=+cyl & +x0 & -x1 & +y0 & -y1 & +z0 & -z1) - model = openmc.Model() - model.geometry = openmc.Geometry([cell1, cell2]) - model.settings.particles = 100 - model.settings.batches = 1 - model.settings.run_mode = 'fixed source' - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(1.0e4) - ) - - # Run model - model.run() - - # Load summary data and check periodic surfaces - summary = openmc.Summary('summary.h5') - surfs = summary.geometry.get_all_surfaces() - for s in [x0, y0, z0, x1, y1, z1]: - assert surfs[s.id].boundary_type == 'periodic' - pairs = [(x0, x1), (y0, y1), (z0, z1)] - for s0, s1 in pairs: - assert surfs[s0.id].periodic_surface == surfs[s1.id] - assert surfs[s1.id].periodic_surface == surfs[s0.id] diff --git a/tests/unit_tests/test_surface.py b/tests/unit_tests/test_surface.py index f5c0b8f8b..12cd8c9d2 100644 --- a/tests/unit_tests/test_surface.py +++ b/tests/unit_tests/test_surface.py @@ -7,12 +7,6 @@ import openmc import pytest -def test_id(): - for i in range(-10, 1): - with pytest.raises(ValueError): - openmc.Plane(a=1, b=2, c=-1, d=3, surface_id=i) - - def assert_infinite_bb(s): ll, ur = (-s).bounding_box assert np.all(np.isinf(ll)) @@ -195,12 +189,6 @@ def test_cylinder(): assert s.dy == -1 assert s.dz == 1 assert s.r == 2 - - # Check radius must be positive - with pytest.raises(ValueError): - openmc.Cylinder(x0=x0, y0=y0, z0=z0, dx=dx, dy=dy, dz=dz, r=0.0) - with pytest.raises(ValueError): - openmc.Cylinder(x0=x0, y0=y0, z0=z0, dx=dx, dy=dy, dz=dz, r=-1.0) # Check bounding box assert_infinite_bb(s) @@ -250,12 +238,6 @@ def test_xcylinder(): assert s.y0 == y assert s.z0 == z assert s.r == r - - # Check radius must be positive - with pytest.raises(ValueError): - openmc.XCylinder(y0=y, z0=z, r=0.0) - with pytest.raises(ValueError): - openmc.XCylinder(y0=y, z0=z, r=-1.0) # Check bounding box ll, ur = (+s).bounding_box @@ -302,12 +284,6 @@ def test_ycylinder(): assert s.x0 == x assert s.z0 == z assert s.r == r - - # Check radius must be positive - with pytest.raises(ValueError): - openmc.YCylinder(x0=x, z0=z, r=0.0) - with pytest.raises(ValueError): - openmc.YCylinder(x0=x, z0=z, r=-1.0) # Check bounding box ll, ur = (+s).bounding_box @@ -345,12 +321,6 @@ def test_zcylinder(): assert s.x0 == x assert s.y0 == y assert s.r == r - - # Check radius must be positive - with pytest.raises(ValueError): - openmc.ZCylinder(x0=x, y0=y, r=0.0) - with pytest.raises(ValueError): - openmc.ZCylinder(x0=x, y0=y, r=-1.0) # Check bounding box ll, ur = (+s).bounding_box @@ -389,12 +359,6 @@ def test_sphere(): assert s.y0 == y assert s.z0 == z assert s.r == r - - # Check radius must be positive - with pytest.raises(ValueError): - openmc.Sphere(x0=x, y0=y, z0=z, r=0.0) - with pytest.raises(ValueError): - openmc.Sphere(x0=x, y0=y, z0=z, r=-1.0) # Check bounding box ll, ur = (+s).bounding_box @@ -434,12 +398,6 @@ def cone_common(apex, r2, cls): assert s.y0 == y assert s.z0 == z assert s.r2 == r2 - - # Check radius must be positive - with pytest.raises(ValueError): - cls(x0=x, y0=y, z0=z, r2=0.0) - with pytest.raises(ValueError): - cls(x0=x, y0=y, z0=z, r2=-1.0) # Check bounding box assert_infinite_bb(s) @@ -478,12 +436,6 @@ def test_cone(): assert s.dy == -1 assert s.dz == 1 assert s.r2 == 4 - - # Check radius must be positive - with pytest.raises(ValueError): - openmc.Cone(x0=x0, y0=y0, z0=z0, dx=dx, dy=dy, dz=dz, r2=0.0) - with pytest.raises(ValueError): - openmc.Cone(x0=x0, y0=y0, z0=z0, dx=dx, dy=dy, dz=dz, r2=-1.0) # Check bounding box assert_infinite_bb(s) @@ -664,13 +616,6 @@ def torus_common(center, R, r1, r2, cls): assert s.a == R assert s.b == r1 assert s.c == r2 - - # Check radius must be positive - params = [(0.0, r1, r2), (R, 0.0, r2), (R, r1, 0.0), - (-1.0, r1, r2), (R, -1.0, r2), (R, r1, -1.0)] - for a,b,c in params: - with pytest.raises(ValueError): - cls(x0=x, y0=y, z0=z, a=a, b=b, c=c) # evaluate method assert s.evaluate((x, y, z)) > 0.0 @@ -808,16 +753,3 @@ def test_ztorus(): assert isinstance(sr, openmc.YTorus) sr = s.rotate((0., 90., 0.)) assert isinstance(sr, openmc.XTorus) - - -def test_normalize(): - """Test that equivalent planes give same normalized coefficients""" - p1 = openmc.Plane(a=0.0, b=1.0, c=0.0, d=1.0) - p2 = openmc.Plane(a=0.0, b=2.0, c=0.0, d=2.0) - assert p1.normalize() == p2.normalize() - - p2 = openmc.Plane(a=0.0, b=-1.0, c=0.0, d=-1.0) - assert p1.normalize() == p2.normalize() - - p2 = openmc.YPlane(1.0) - assert p1.normalize() == p2.normalize() diff --git a/tests/unit_tests/test_surface_composite.py b/tests/unit_tests/test_surface_composite.py index a04fc73c5..01c827223 100644 --- a/tests/unit_tests/test_surface_composite.py +++ b/tests/unit_tests/test_surface_composite.py @@ -207,19 +207,6 @@ def test_cylinder_sector(axis, indices, center): assert point_neg[indices] in -s assert point_neg[indices] not in +s - # Check __contains__ for sector with reflex angle - s_reflex = openmc.model.CylinderSector( - r1, r2, 0., 270., center=center, axis=axis.lower()) - points = [ - np.array([c1 + r1 + d, c2 + 0.01, 0.]), - np.array([c1, c2 + r1 + d, 0.]), - np.array([c1 - r1 - d, c2, 0.]), - np.array([c1 - 0.01, c2 - r1 - d, 0.]) - ] - for point_neg in points: - assert point_neg[indices] in -s_reflex - assert point_neg[indices] not in +s_reflex - # translate method t = uniform(-5.0, 5.0) s_t = s.translate((t, t, t)) @@ -360,13 +347,10 @@ def test_polygon(): assert any([points_in[i] in reg for reg in star_poly.regions]) assert points_in[i] not in +star_poly assert (0, 0, 0) not in -star_poly - if basis != "rz": - for offsets in [0.6, np.array([0.6] * 10), [0.6] * 10]: - offset_star = star_poly.offset(offsets) - assert (0, 0, 0) in -offset_star - assert any([(0, 0, 0) in reg for reg in offset_star.regions]) - with pytest.raises(ValueError): - star_poly.offset([0.6, 0.6]) + if basis != 'rz': + offset_star = star_poly.offset(.6) + assert (0, 0, 0) in -offset_star + assert any([(0, 0, 0) in reg for reg in offset_star.regions]) # check invalid Polygon input points # duplicate points not just at start and end @@ -514,150 +498,3 @@ def test_cruciform_prism(axis): openmc.model.CruciformPrism([1.0, 0.5, 2.0, 3.0]) with pytest.raises(ValueError): openmc.model.CruciformPrism([3.0, 2.0, 0.5, 1.0]) - - -def test_box(): - v = (-1.0, -1.0, -2.5) - a1 = (2.0, -1.0, 0.0) - a2 = (1.0, 2.0, 0.0) - a3 = (0.0, 0.0, 5.0) - s = openmc.model.OrthogonalBox(v, a1, a2, a3) - for num in (1, 2, 3): - assert isinstance(getattr(s, f'ax{num}_min'), openmc.Plane) - assert isinstance(getattr(s, f'ax{num}_max'), openmc.Plane) - - # Make sure boundary condition propagates - s.boundary_type = 'reflective' - assert s.boundary_type == 'reflective' - for num in (1, 2, 3): - assert getattr(s, f'ax{num}_min').boundary_type == 'reflective' - assert getattr(s, f'ax{num}_max').boundary_type == 'reflective' - - # Check bounding box - ll, ur = (+s).bounding_box - assert np.all(np.isinf(ll)) - assert np.all(np.isinf(ur)) - ll, ur = (-s).bounding_box - assert ll[2] == pytest.approx(-2.5) - assert ur[2] == pytest.approx(2.5) - - # __contains__ on associated half-spaces - assert (0., 0., 0.) in -s - assert (-2., 0., 0.) not in -s - assert (0., 0.9, 0.) in -s - assert (0., 0., -3.) in +s - assert (0., 0., 3.) in +s - - # translate method - s_t = s.translate((1., 1., 0.)) - assert (-0.01, 0., 0.) in +s_t - assert (0.01, 0., 0.) in -s_t - - # Make sure repr works - repr(s) - - # Version with infinite 3rd dimension - s = openmc.model.OrthogonalBox(v, a1, a2) - assert not hasattr(s, 'ax3_min') - assert not hasattr(s, 'ax3_max') - ll, ur = (-s).bounding_box - assert np.all(np.isinf(ll)) - assert np.all(np.isinf(ur)) - assert (0., 0., 0.) in -s - assert (-2., 0., 0.) not in -s - assert (0., 0.9, 0.) in -s - assert (0., 0., -3.) not in +s - assert (0., 0., 3.) not in +s - - -def test_conical_frustum(): - center_base = (0.0, 0.0, -3) - axis = (0., 0., 3.) - r1 = 2.0 - r2 = 0.5 - s = openmc.model.ConicalFrustum(center_base, axis, r1, r2) - assert isinstance(s.cone, openmc.Cone) - assert isinstance(s.plane_bottom, openmc.Plane) - assert isinstance(s.plane_top, openmc.Plane) - - # Make sure boundary condition propagates - s.boundary_type = 'reflective' - assert s.boundary_type == 'reflective' - assert s.cone.boundary_type == 'reflective' - assert s.plane_bottom.boundary_type == 'reflective' - assert s.plane_top.boundary_type == 'reflective' - - # Check bounding box - ll, ur = (+s).bounding_box - assert np.all(np.isinf(ll)) - assert np.all(np.isinf(ur)) - ll, ur = (-s).bounding_box - assert ll[2] == pytest.approx(-3.0) - assert ur[2] == pytest.approx(0.0) - - # __contains__ on associated half-spaces - assert (0., 0., -1.) in -s - assert (0., 0., -4.) not in -s - assert (0., 0., 1.) not in -s - assert (1., 1., -2.99) in -s - assert (1., 1., -0.01) in +s - - # translate method - s_t = s.translate((1., 1., 0.)) - assert (1., 1., -0.01) in -s_t - - # Make sure repr works - repr(s) - - # Denegenerate case with r1 = r2 - s = openmc.model.ConicalFrustum(center_base, axis, r1, r1) - assert (1., 1., -0.01) in -s - - -def test_vessel(): - center = (3.0, 2.0) - r = 1.0 - p1, p2 = -5.0, 5.0 - h1 = h2 = 1.0 - s = openmc.model.Vessel(r, p1, p2, h1, h2, center) - assert isinstance(s.cyl, openmc.Cylinder) - assert isinstance(s.plane_bottom, openmc.Plane) - assert isinstance(s.plane_top, openmc.Plane) - assert isinstance(s.bottom, openmc.Quadric) - assert isinstance(s.top, openmc.Quadric) - - # Make sure boundary condition propagates (but not for planes) - s.boundary_type = 'reflective' - assert s.boundary_type == 'reflective' - assert s.cyl.boundary_type == 'reflective' - assert s.bottom.boundary_type == 'reflective' - assert s.top.boundary_type == 'reflective' - assert s.plane_bottom.boundary_type == 'transmission' - assert s.plane_top.boundary_type == 'transmission' - - # Check bounding box - ll, ur = (+s).bounding_box - assert np.all(np.isinf(ll)) - assert np.all(np.isinf(ur)) - ll, ur = (-s).bounding_box - assert np.all(np.isinf(ll)) - assert np.all(np.isinf(ur)) - - # __contains__ on associated half-spaces - assert (3., 2., 0.) in -s - assert (3., 2., -5.0) in -s - assert (3., 2., 5.0) in -s - assert (3., 2., -5.9) in -s - assert (3., 2., 5.9) in -s - assert (3., 2., -6.1) not in -s - assert (3., 2., 6.1) not in -s - assert (4.5, 2., 0.) in +s - assert (3., 3.2, 0.) in +s - assert (3., 2., 7.) in +s - - # translate method - s_t = s.translate((0., 0., 1.)) - assert (3., 2., 6.1) in -s_t - - # Make sure repr works - repr(s) diff --git a/tests/unit_tests/test_surface_flux.py b/tests/unit_tests/test_surface_flux.py deleted file mode 100644 index e4419252e..000000000 --- a/tests/unit_tests/test_surface_flux.py +++ /dev/null @@ -1,164 +0,0 @@ -"""Tests for surface flux tallying via flux score + SurfaceFilter.""" - -import math -import pytest - -import openmc - - -@pytest.fixture -def two_cell_model(): - """Simple two-cell slab model with a monodirectional fixed source. - - Cell1 occupies x in [-10, 0], cell2 x in [0, 10]. The source fires all - particles from (-5, 0, 0) in the +x direction with weight 1. Every - particle therefore crosses the surface at x=0 from cell1 into cell2 at - mu = 1 (normal incidence). - """ - openmc.reset_auto_ids() - model = openmc.Model() - - xmin = openmc.XPlane(-10.0, boundary_type="vacuum") - xmid = openmc.XPlane(0.0) - xmax = openmc.XPlane(10.0, boundary_type="vacuum") - ymin = openmc.YPlane(-10.0, boundary_type="vacuum") - ymax = openmc.YPlane(10.0, boundary_type="vacuum") - zmin = openmc.ZPlane(-10.0, boundary_type="vacuum") - zmax = openmc.ZPlane(10.0, boundary_type="vacuum") - - cell1 = openmc.Cell(region=+xmin & -xmid & +ymin & -ymax & +zmin & -zmax) - cell2 = openmc.Cell(region=+xmid & -xmax & +ymin & -ymax & +zmin & -zmax) - model.geometry = openmc.Geometry([cell1, cell2]) - - src = openmc.IndependentSource() - src.space = openmc.stats.Point((-5.0, 0.0, 0.0)) - src.angle = openmc.stats.Monodirectional((1.0, 0.0, 0.0)) - - model.settings.run_mode = 'fixed source' - model.settings.batches = 1 - model.settings.particles = 100 - model.settings.source = src - - return model, xmid, cell1, cell2 - - -def test_surface_filter_flux_normal_incidence(two_cell_model, run_in_tmpdir): - """SurfaceFilter + flux at mu=1 gives w/|mu| = 1.0 per source particle.""" - model, xmid, *_ = two_cell_model - - surf_filter = openmc.SurfaceFilter([xmid]) - flux_tally = openmc.Tally() - flux_tally.filters = [surf_filter] - flux_tally.scores = ['flux'] - model.tallies = [flux_tally] - - model.run(apply_tally_results=True) - flux_mean = flux_tally.mean.flat[0] - - # Every particle crosses at mu=1 with weight 1, so flux = 1.0 - assert flux_mean == pytest.approx(1.0, rel=1e-8) - - -def test_surface_filter_current_outward(two_cell_model, run_in_tmpdir): - """SurfaceFilter + current gives +1.0 for purely outward crossings.""" - model, xmid, *_ = two_cell_model - - surf_filter = openmc.SurfaceFilter([xmid]) - current_tally = openmc.Tally() - current_tally.filters = [surf_filter] - current_tally.scores = ['current'] - model.tallies = [current_tally] - - model.run(apply_tally_results=True) - current_mean = current_tally.mean.flat[0] - - # All crossings are outward → net current = +1.0 - assert current_mean == pytest.approx(1.0) - - -def test_surface_filter_flux_angled(two_cell_model, run_in_tmpdir): - """Surface flux at 60-degree incidence gives w/|mu| = 2.0.""" - model, xmid, *_ = two_cell_model - - # Modify source to use 60-degree angle from normal: mu = cos(60°) = 0.5 - mu = ux = 0.5 - uy = math.sqrt(1.0 - ux**2) - model.settings.source[0].angle = openmc.stats.Monodirectional((ux, uy, 0.0)) - - surf_filter = openmc.SurfaceFilter([xmid]) - flux_tally = openmc.Tally() - flux_tally.filters = [surf_filter] - flux_tally.scores = ['flux'] - model.tallies = [flux_tally] - - model.run(apply_tally_results=True) - flux_mean = flux_tally.mean.flat[0] - - # flux = w/|mu| = 1/0.5 = 2.0 - assert flux_mean == pytest.approx(1.0 / mu) - - -def test_surface_tally_during_lattice_crossing(run_in_tmpdir): - openmc.reset_auto_ids() - model = openmc.Model() - - xmin = openmc.XPlane(-1.0, boundary_type="vacuum") - xmax = openmc.XPlane(1.0, boundary_type="vacuum") - ymin = openmc.YPlane(-1.0, boundary_type="vacuum") - ymax = openmc.YPlane(1.0, boundary_type="vacuum") - zmin = openmc.ZPlane(-1.0, boundary_type="vacuum") - zmax = openmc.ZPlane(1.0, boundary_type="vacuum") - - inner_cell = openmc.Cell() - inner_univ = openmc.Universe(cells=[inner_cell]) - - tile_cell = openmc.Cell(fill=inner_univ) - tile_univ = openmc.Universe(cells=[tile_cell]) - - lattice = openmc.RectLattice() - lattice.lower_left = (-1.0, -1.0) - lattice.pitch = (1.0, 2.0) - lattice.universes = [[tile_univ, tile_univ]] - - root_cell = openmc.Cell( - fill=lattice, region=+xmin & -xmax & +ymin & -ymax & +zmin & -zmax) - model.geometry = openmc.Geometry([root_cell]) - - src = openmc.IndependentSource() - src.space = openmc.stats.Point((-0.5, 0.0, 0.0)) - src.angle = openmc.stats.Monodirectional((1.0, 0.0, 0.0)) - - model.settings.run_mode = 'fixed source' - model.settings.batches = 1 - model.settings.particles = 5 - model.settings.source = src - - current_tally = openmc.Tally() - current_tally.filters = [openmc.SurfaceFilter(xmax)] - current_tally.scores = ['current'] - model.tallies = [current_tally] - - model.run(apply_tally_results=True) - assert current_tally.mean.flat[0] == pytest.approx(1.0) - - -def test_cellfrom_filter_flux_directional(two_cell_model, run_in_tmpdir): - """SurfaceFilter + CellFromFilter + flux scores only the correct direction.""" - model, xmid, cell1, cell2 = two_cell_model - - surf_filter = openmc.SurfaceFilter([xmid]) - cellfrom_filter = openmc.CellFromFilter([cell1, cell2]) - - tally = openmc.Tally() - tally.filters = [surf_filter, cellfrom_filter] - tally.scores = ['flux'] - - model.tallies = [tally] - model.run(apply_tally_results=True) - mean_from1 = tally.mean.flat[0] - mean_from2 = tally.mean.flat[1] - - # All particles cross xmid from cell1 at mu=1 → flux = 1.0 - assert mean_from1 == pytest.approx(1.0) - # No particles cross xmid from cell2 → flux = 0 - assert mean_from2 == pytest.approx(0.0) diff --git a/tests/unit_tests/test_surface_source_write.py b/tests/unit_tests/test_surface_source_write.py index 6f18d32b7..472363073 100644 --- a/tests/unit_tests/test_surface_source_write.py +++ b/tests/unit_tests/test_surface_source_write.py @@ -32,7 +32,6 @@ def geometry(): {"max_particles": 200, "surface_ids": [2], "cell": 1}, {"max_particles": 200, "surface_ids": [2], "cellto": 1}, {"max_particles": 200, "surface_ids": [2], "cellfrom": 1}, - {"max_particles": 200, "surface_ids": [2], "max_source_files": 1}, ], ) def test_xml_serialization(parameter, run_in_tmpdir): @@ -45,58 +44,6 @@ def test_xml_serialization(parameter, run_in_tmpdir): assert read_settings.surf_source_write == parameter -@pytest.fixture(scope="module") -def model(): - """Simple hydrogen sphere geometry""" - openmc.reset_auto_ids() - model = openmc.Model() - - # Material - h1 = openmc.Material(name="H1") - h1.add_nuclide("H1", 1.0) - h1.set_density('g/cm3', 1e-7) - - # Geometry - radius = 1.0 - sphere = openmc.Sphere(r=radius, boundary_type="vacuum") - cell = openmc.Cell(region=-sphere, fill=h1) - model.geometry = openmc.Geometry([cell]) - - # Settings - model.settings = openmc.Settings() - model.settings.run_mode = "fixed source" - model.settings.particles = 100 - model.settings.batches = 3 - model.settings.seed = 1 - - distribution = openmc.stats.Point() - model.settings.source = openmc.IndependentSource(space=distribution) - return model - - -@pytest.mark.parametrize( - "max_particles, max_source_files", - [ - (100, 2), - (100, 3), - (100, 1), - ], -) -def test_number_surface_source_file_created(max_particles, max_source_files, - run_in_tmpdir, model): - """Check the number of surface source files written.""" - model.settings.surf_source_write = { - "max_particles": max_particles, - "max_source_files": max_source_files - } - model.run() - should_be_numbered = max_source_files > 1 - for i in range(1, max_source_files + 1): - if should_be_numbered: - assert Path(f"surface_source.{i}.h5").exists() - if not should_be_numbered: - assert Path("surface_source.h5").exists() - ERROR_MSG_1 = ( "A maximum number of particles needs to be specified " "using the 'max_particles' parameter to store surface " diff --git a/tests/unit_tests/test_tallies.py b/tests/unit_tests/test_tallies.py index 7b1bf0a2f..544443312 100644 --- a/tests/unit_tests/test_tallies.py +++ b/tests/unit_tests/test_tallies.py @@ -1,8 +1,6 @@ -from math import sqrt import numpy as np -import pytest + import openmc -import scipy.stats as sps def test_xml_roundtrip(run_in_tmpdir): @@ -43,336 +41,4 @@ def test_xml_roundtrip(run_in_tmpdir): assert len(new_tally.triggers) == 1 assert new_tally.triggers[0].trigger_type == tally.triggers[0].trigger_type assert new_tally.triggers[0].threshold == tally.triggers[0].threshold - assert new_tally.triggers[0].scores == tally.triggers[0].scores - assert new_tally.multiply_density == tally.multiply_density - - -def test_tally_equivalence(): - tally_a = openmc.Tally() - tally_b = openmc.Tally(tally_id=tally_a.id) - - tally_a.name = 'new name' - assert tally_a != tally_b - tally_b.name = tally_a.name - assert tally_a == tally_b - - assert tally_a == tally_b - ef_a = openmc.EnergyFilter([0.0, 0.1, 1.0, 10.0e6]) - ef_b = openmc.EnergyFilter([0.0, 0.1, 1.0, 10.0e6]) - - tally_a.filters = [ef_a] - assert tally_a != tally_b - tally_b.filters = [ef_b] - assert tally_a == tally_b - - tally_a.scores = ['flux', 'absorption', 'fission', 'scatter'] - assert tally_a != tally_b - tally_b.scores = ['flux', 'absorption', 'fission', 'scatter'] - assert tally_a == tally_b - - tally_a.nuclides = [] - tally_b.nuclides = [] - assert tally_a == tally_b - - tally_a.nuclides = ['total'] - assert tally_a == tally_b - - # a tally with an estimator set to None is equal to - # a tally with an estimator specified - tally_a.estimator = 'collision' - assert tally_a == tally_b - tally_b.estimator = 'collision' - assert tally_a == tally_b - - tally_a.multiply_density = False - assert tally_a != tally_b - tally_b.multiply_density = False - assert tally_a == tally_b - - trigger_a = openmc.Trigger('rel_err', 0.025) - trigger_b = openmc.Trigger('rel_err', 0.025) - - tally_a.triggers = [trigger_a] - assert tally_a != tally_b - tally_b.triggers = [trigger_b] - assert tally_a == tally_b - - -def test_figure_of_merit(sphere_model, run_in_tmpdir): - # Run model with a few simple tally scores - tally = openmc.Tally() - tally.scores = ['total', 'absorption', 'scatter'] - sphere_model.tallies = [tally] - sp_path = sphere_model.run(apply_tally_results=True) - - # Get execution time and relative error - with openmc.StatePoint(sp_path) as sp: - time = sp.runtime['simulation'] - rel_err = tally.std_dev / tally.mean - - # Check that figure of merit is calculated correctly - assert tally.figure_of_merit == pytest.approx(1 / (rel_err**2 * time)) - - -def test_tally_application(sphere_model, run_in_tmpdir): - # Create a tally with most possible gizmos - tally = openmc.Tally(name='test tally') - ef = openmc.EnergyFilter([0.0, 0.1, 1.0, 10.0e6]) - mesh = openmc.RegularMesh.from_domain(sphere_model.geometry, (2, 2, 2)) - mf = openmc.MeshFilter(mesh) - tally.filters = [ef, mf] - tally.scores = ['flux', 'absorption', 'fission', 'scatter'] - sphere_model.tallies = [tally] - - # FIRST RUN - # run the simulation and apply results - sp_file = sphere_model.run(apply_tally_results=True) - # before calling for any property requiring results (including the equivalence check below), - # the following internal attributes of the original should be unset - assert tally._mean is None - assert tally._std_dev is None - assert tally._sum is None - assert tally._sum_sq is None - assert tally._num_realizations == 0 - # the statepoint file property should be set, however - assert tally._sp_filename == sp_file - - with openmc.StatePoint(sp_file) as sp: - assert tally in sp.tallies.values() - sp_tally = sp.tallies[tally.id] - - # at this point the tally information regarding results should be the same - assert (sp_tally.std_dev == tally.std_dev).all() - assert (sp_tally.mean == tally.mean).all() - assert sp_tally.nuclides == tally.nuclides - - # SECOND RUN - # change the number of particles and ensure that the results are different - sphere_model.settings.particles += 1 - sp_file = sphere_model.run(apply_tally_results=True) - - assert (sp_tally.std_dev != tally.std_dev).any() - assert (sp_tally.mean != tally.mean).any() - - # now re-read data from the new stateopint file and - # ensure that the new results match those in - # the latest statepoint - with openmc.StatePoint(sp_file) as sp: - assert tally in sp.tallies.values() - sp_tally = sp.tallies[tally.id] - - # at this point the tally information regarding results should be the same - assert (sp_tally.std_dev == tally.std_dev).all() - assert (sp_tally.mean == tally.mean).all() - assert sp_tally.nuclides == tally.nuclides - -def _tally_from_data(x, *, higher_moments=True, normality=True): - t = openmc.Tally() - t.scores = ["flux"] # 1 score - t.nuclides = [openmc.Nuclide("H1")] # 1 nuclide - t._sp_filename = "dummy.h5" # mark "results available" - t._results_read = True # don't try to read from disk - t._num_realizations = int(len(x)) # n - t.higher_moments = bool(higher_moments) - - x = np.asarray(x, dtype=float) - # (num_filter_bins=1, num_nuclides=1, num_scores=1) -> (1,1,1) arrays - t._sum = np.array([[[np.sum(x)]]], dtype=float) - t._sum_sq = np.array([[[np.sum(x**2)]]], dtype=float) - if higher_moments: - t._sum_third = np.array([[[np.sum(x**3)]]], dtype=float) - t._sum_fourth = np.array([[[np.sum(x**4)]]], dtype=float) - return t - -@pytest.mark.parametrize( - "x, skew_true, kurt_true", - [ # Rademacher distribution - (np.array([1.0, -1.0] * 200), 0.0, 1.0), - # Two-point {0,3} with p(0)=3/4, p(3)=1/4 - (np.concatenate([np.zeros(600), np.full(200, 3.0)]), 2.0 / sqrt(3.0), 7.0 / 3.0), - # Bernoulli distribution - (np.concatenate([np.ones(300), np.zeros(700)]), (1 - 2 * 0.3) / sqrt(0.3 * 0.7), (1 - 3 * 0.3 + 3 * 0.3**2) / (0.3 * 0.7)), - ], -) -def test_b1_b2_analytical_against_tally(x, skew_true, kurt_true): - t = _tally_from_data(x, higher_moments=True, normality=False) - - g1 = t.skew(bias=True)[0, 0, 0] - b2 = t.kurtosis(bias=True, fisher=False)[0, 0, 0] - - assert np.isclose(g1, skew_true, rtol=0, atol=1e-12) - assert np.isclose(b2, kurt_true, rtol=0, atol=1e-12) - -@pytest.mark.parametrize( - "draw, skew_true, kurt_true", - [(lambda rng, n: rng.normal(0, 1, n), 0.0, 3.0), # Normal - (lambda rng, n: rng.random(n), 0.0, 1.8), # Uniform(0,1) - (lambda rng, n: rng.exponential(1.0, n), 2.0, 9.0), # Exp(1) - (lambda rng, n: (rng.random(n) < 0.3).astype(float), - (1 - 2 * 0.3) / sqrt(0.3 * 0.7), - (1 - 3 * 0.3 + 3 * 0.3**2) / (0.3 * 0.7),),],) - -def test_b1_b2_scipy_and_theory(draw, skew_true, kurt_true): - rng = np.random.default_rng(12345) - N = 200_000 - x = draw(rng, N) - - # Tally outputs - t = _tally_from_data(x, higher_moments=True, normality=False) - g1_t = t.skew(bias=True)[0, 0, 0] - b2_t = t.kurtosis(bias=True, fisher=False)[0, 0, 0] - - # SciPy (population, bias=True to match population-moment style) - skew_sp = sps.skew(x, bias=True) - kurt_sp = sps.kurtosis(x, fisher=False, bias=True) - - # Compare to SciPy numerically - assert np.isclose(g1_t, skew_sp, rtol=0, atol=5e-3) - assert np.isclose(b2_t, kurt_sp, rtol=0, atol=5e-3) - - # Compare to analytical targets with size-dependent tolerances - tol_skew = 0.02 if abs(skew_true) < 0.5 else 0.05 - tol_kurt = 0.03 if kurt_true < 4 else 0.1 - assert abs(g1_t - skew_true) < tol_skew - assert abs(b2_t - kurt_true) < tol_kurt - - -def test_kurtosis_bias_fisher_combinations(): - """Test that all combinations of bias and fisher match scipy.stats.kurtosis""" - rng = np.random.default_rng(42) - x = rng.normal(0, 1, 10000) - - t = _tally_from_data(x, higher_moments=True, normality=False) # Test all four combinations - # 1. bias=True, fisher=False (Pearson's kurtosis, b2) - b2_tally = t.kurtosis(bias=True, fisher=False)[0, 0, 0] - b2_scipy = sps.kurtosis(x, fisher=False, bias=True) - assert np.isclose(b2_tally, b2_scipy, rtol=0, atol=1e-10) - assert np.isclose(b2_tally, 3.0, rtol=0.05, atol=0.1) # Should be ~3 for normal - - # 2. bias=True, fisher=True (excess kurtosis, g2) - g2_tally = t.kurtosis(bias=True, fisher=True)[0, 0, 0] - g2_scipy = sps.kurtosis(x, fisher=True, bias=True) - assert np.isclose(g2_tally, g2_scipy, rtol=0, atol=1e-10) - assert np.isclose(g2_tally, 0.0, rtol=0, atol=0.1) # Should be ~0 for normal - assert np.isclose(g2_tally, b2_tally - 3.0, rtol=0, atol=1e-10) # g2 = b2 - 3 - - # 3. bias=False, fisher=True (adjusted excess kurtosis, G2) - G2_tally = t.kurtosis(bias=False, fisher=True)[0, 0, 0] - G2_tally_default = t.kurtosis()[0, 0, 0] # Should be same as default - G2_scipy = sps.kurtosis(x, fisher=True, bias=False) - assert np.isclose(G2_tally, G2_tally_default, rtol=0, atol=1e-10) - assert np.isclose(G2_tally, G2_scipy, rtol=0, atol=1e-10) - assert np.isclose(G2_tally, 0.0, rtol=0, atol=0.1) # Should be ~0 for normal - - # 4. bias=False, fisher=False (adjusted Pearson's kurtosis) - adj_b2_tally = t.kurtosis(bias=False, fisher=False)[0, 0, 0] - adj_b2_scipy = sps.kurtosis(x, fisher=False, bias=False) - assert np.isclose(adj_b2_tally, adj_b2_scipy, rtol=0, atol=1e-10) - assert np.isclose(adj_b2_tally, 3.0, rtol=0.05, atol=0.1) # Should be ~3 for normal - assert np.isclose(adj_b2_tally, G2_tally + 3.0, rtol=0, atol=1e-10) # adj_b2 = G2 + 3 - - -def test_ztests_scipy_comparison(): - rng = np.random.default_rng(987) - x_norm = rng.normal(size=50_000) - x_exp = rng.exponential(size=50_000) - - # -------- Normal dataset (should not reject) -------- - t0 = _tally_from_data(x_norm, higher_moments=True, normality=True) - Zb1_0, p_skew_0 = t0.skewtest(alternative="two-sided") - Zb2_0, p_kurt_0 = t0.kurtosistest(alternative="two-sided") - K2_0, p_omni_0 = t0.normaltest(alternative="two-sided") - - Zb1_0 = Zb1_0.ravel()[0] - p_skew_0 = p_skew_0.ravel()[0] - Zb2_0 = Zb2_0.ravel()[0] - p_kurt_0 = p_kurt_0.ravel()[0] - K2_0 = K2_0.ravel()[0] - p_omni_0 = p_omni_0.ravel()[0] - - z_skew_sp0, p_skew_sp0 = sps.skewtest(x_norm) - z_kurt_sp0, p_kurt_sp0 = sps.kurtosistest(x_norm) - k2_sp0, p_omni_sp0 = sps.normaltest(x_norm) - - assert np.isclose(Zb1_0, z_skew_sp0, atol=0.15) - assert np.isclose(Zb2_0, z_kurt_sp0, atol=0.15) - assert np.isclose(K2_0, k2_sp0, atol=0.30) - assert np.isclose(p_skew_0, p_skew_sp0, atol=5e-3) - assert np.isclose(p_kurt_0, p_kurt_sp0, atol=5e-3) - assert np.isclose(p_omni_0, p_omni_sp0, atol=5e-3) - - # -------- Exponential dataset (should strongly reject) -------- - t1 = _tally_from_data(x_exp, higher_moments=True, normality=True) - - Zb1_1, p_skew_1 = t1.skewtest(alternative="two-sided") - Zb2_1, p_kurt_1 = t1.kurtosistest(alternative="two-sided") - K2_1, p_omni_1 = t1.normaltest(alternative="two-sided") - - Zb1_1 = Zb1_1.ravel()[0] - p_skew_1 = p_skew_1.ravel()[0] - Zb2_1 = Zb2_1.ravel()[0] - p_kurt_1 = p_kurt_1.ravel()[0] - K2_1 = K2_1.ravel()[0] - p_omni_1 = p_omni_1.ravel()[0] - - z_skew_sp1, p_skew_sp1 = sps.skewtest(x_exp) - z_kurt_sp1, p_kurt_sp1 = sps.kurtosistest(x_exp) - k2_sp1, p_omni_sp1 = sps.normaltest(x_exp) - - # Both pipelines should reject very strongly - assert p_skew_1 < 1e-6 and p_skew_sp1 < 1e-6 - assert p_kurt_1 < 1e-6 and p_kurt_sp1 < 1e-6 - assert p_omni_1 < 1e-6 and p_omni_sp1 < 1e-6 - - # Right-skewed and heavy-tailed → large positive Z-statistics - assert Zb1_1 > 30 and z_skew_sp1 > 30 - assert Zb2_1 > 30 and z_kurt_sp1 > 30 - assert K2_1 > 2000 and k2_sp1 > 2000 - -def test_vov_stochastic(sphere_model, run_in_tmpdir): - tally = openmc.Tally(name="test tally") - ef = openmc.EnergyFilter([0.0, 0.1, 1.0, 10.0e6]) - mesh = openmc.RegularMesh.from_domain(sphere_model.geometry, (2, 2, 2)) - mf = openmc.MeshFilter(mesh) - tally.filters = [ef, mf] - tally.scores = ["flux", "absorption", "fission", "scatter"] - tally.higher_moments = True - sphere_model.tallies = [tally] - - sp_file = sphere_model.run(apply_tally_results=True) - - assert tally._mean is None - assert tally._std_dev is None - assert tally._sum is None - assert tally._sum_sq is None - assert tally._sum_third is None - assert tally._sum_fourth is None - assert tally._num_realizations == 0 - assert tally._sp_filename == sp_file - - with openmc.StatePoint(sp_file) as sp: - assert tally in sp.tallies.values() - sp_tally = sp.tallies[tally.id] - - assert np.all(sp_tally.std_dev == tally.std_dev) - assert np.all(sp_tally.mean == tally.mean) - assert np.all(sp_tally.vov == tally.vov) - assert sp_tally.nuclides == tally.nuclides - - n = sp_tally.num_realizations - mean = sp_tally.mean - sum_ = sp_tally._sum - sum_sq = sp_tally._sum_sq - sum_third = sp_tally._sum_third - sum_fourth = sp_tally._sum_fourth - - expected_vov = np.zeros_like(mean) - nonzero = np.abs(mean) > 0 - - num = (sum_fourth - (4.0*sum_third*sum_)/n + (6.0*sum_sq*sum_**2)/(n**2) - - (3.0*sum_**4)/(n**3)) - den = (sum_sq - (1.0/n)*sum_**2)**2 - - expected_vov[nonzero] = num[nonzero]/den[nonzero] - 1.0/n - - assert np.allclose(expected_vov, sp_tally.vov, rtol=1e-7, atol=0.0) + assert new_tally.triggers[0].scores == tally.triggers[0].scores \ No newline at end of file diff --git a/tests/unit_tests/test_tally.py b/tests/unit_tests/test_tally.py deleted file mode 100644 index 7136a621b..000000000 --- a/tests/unit_tests/test_tally.py +++ /dev/null @@ -1,63 +0,0 @@ -import openmc - - -def test_tally_init_args(): - """Test that Tally constructor kwargs are applied correctly.""" - filter = openmc.EnergyFilter([0.0, 1.0, 20.0e6]) - tally = openmc.Tally( - name='my tally', - scores=['flux', 'fission'], - filters=[filter], - nuclides=['U235'], - estimator='tracklength', - ) - - assert tally.name == 'my tally' - assert tally.scores == ['flux', 'fission'] - assert tally.filters == [filter] - assert tally.nuclides == ['U235'] - assert tally.estimator == 'tracklength' - - -def test_heating_estimator_with_photon_transport(run_in_tmpdir): - """Test that a neutron-only heating tally uses the tracklength estimator - even when photon transport is enabled. - - Without a neutron particle filter, photon heating requires the collision - estimator (analog energy balance). But neutron heating has kerma - coefficients that support tracklength scoring, so a neutron-only tally - should keep the tracklength estimator. - """ - mat = openmc.Material() - mat.add_nuclide('Si28', 1.0) - mat.set_density('g/cm3', 2.3) - sph = openmc.Sphere(r=10.0, boundary_type='vacuum') - cell = openmc.Cell(fill=mat, region=-sph) - - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - model.settings.run_mode = 'fixed source' - model.settings.particles = 100 - model.settings.batches = 1 - model.settings.photon_transport = True - model.settings.source = openmc.IndependentSource( - space=openmc.stats.Point() - ) - - neutron_filter = openmc.ParticleFilter(['neutron']) - - # Neutron-only heating — should get tracklength estimator - t_neutron = openmc.Tally(name='heating_neutron') - t_neutron.filters = [neutron_filter] - t_neutron.scores = ['heating'] - - # No particle filter — should get collision estimator - t_all = openmc.Tally(name='heating_all') - t_all.scores = ['heating'] - - model.tallies = [t_neutron, t_all] - - sp_filename = model.run() - with openmc.StatePoint(sp_filename) as sp: - assert sp.tallies[t_neutron.id].estimator == 'tracklength' - assert sp.tallies[t_all.id].estimator == 'collision' diff --git a/tests/unit_tests/test_temp_interp.py b/tests/unit_tests/test_temp_interp.py index 4566070cf..4c2882347 100644 --- a/tests/unit_tests/test_temp_interp.py +++ b/tests/unit_tests/test_temp_interp.py @@ -152,7 +152,7 @@ def model(tmp_path_factory): mat = openmc.Material() mat.add_nuclide('U235', 1.0) model.materials.append(mat) - model.materials.cross_sections = 'cross_sections_fake.xml' + model.materials.cross_sections = str(Path('cross_sections_fake.xml').resolve()) sph = openmc.Sphere(r=100.0, boundary_type='reflective') cell = openmc.Cell(fill=mat, region=-sph) @@ -257,7 +257,7 @@ def test_temperature_slightly_above(run_in_tmpdir): mat2.add_nuclide('U235', 1.0) mat2.temperature = 600.0 model.materials.extend([mat1, mat2]) - model.materials.cross_sections = 'cross_sections_fake.xml' + model.materials.cross_sections = str(Path('cross_sections_fake.xml').resolve()) sph1 = openmc.Sphere(r=1.0) sph2 = openmc.Sphere(r=4.0, boundary_type='reflective') diff --git a/tests/unit_tests/test_tracks.py b/tests/unit_tests/test_tracks.py index 74da83552..fa8664159 100644 --- a/tests/unit_tests/test_tracks.py +++ b/tests/unit_tests/test_tracks.py @@ -70,7 +70,7 @@ def test_tracks(sphere_model, particle, run_in_tmpdir): particle_track = track.particle_tracks[0] assert isinstance(particle_track, openmc.ParticleTrack) - assert str(particle_track.particle).lower() == particle + assert particle_track.particle.name.lower() == particle assert isinstance(particle_track.states, np.ndarray) # Sanity checks on actual data @@ -140,10 +140,8 @@ def test_filter(sphere_model, run_in_tmpdir): assert matches == tracks matches = tracks.filter(state_filter=lambda s: s['E'] > 0.0) assert matches == tracks - matches = tracks.filter(particle='proton') + matches = tracks.filter(particle='bunnytron') assert matches == [] - with pytest.raises(ValueError): - tracks.filter(particle='bunnytron') def test_write_to_vtk(sphere_model): diff --git a/tests/unit_tests/test_triggers.py b/tests/unit_tests/test_triggers.py index 14bda0cce..6b9e54eeb 100644 --- a/tests/unit_tests/test_triggers.py +++ b/tests/unit_tests/test_triggers.py @@ -113,34 +113,3 @@ def test_tally_trigger_zero_ignored(run_in_tmpdir): total_batches = sp.n_realizations + sp.n_inactive assert total_batches < pincell.settings.trigger_max_batches - - -def test_trigger_he3_production(run_in_tmpdir): - li6 = openmc.Material() - li6.set_density('g/cm3', 1.0) - li6.add_nuclide('Li6', 1.0) - - sph = openmc.Sphere(r=20, boundary_type='vacuum') - outer_cell = openmc.Cell(fill=li6, region=-sph) - model = openmc.Model() - model.geometry = openmc.Geometry([outer_cell]) - model.settings.source = openmc.IndependentSource( - energy=openmc.stats.delta_function(14.1e6) - ) - model.settings.batches = 10 - model.settings.particles = 100 - model.settings.run_mode = 'fixed source' - model.settings.trigger_active = True - model.settings.trigger_batch_interval = 10 - model.settings.trigger_max_batches = 30 - - # Define tally with trigger - trigger = openmc.Trigger(trigger_type='rel_err', threshold=0.0001) - trigger.scores = ['He3-production'] - he3_production_tally = openmc.Tally() - he3_production_tally.scores = ['He3-production'] - he3_production_tally.triggers = [trigger] - model.tallies = openmc.Tallies([he3_production_tally]) - - # Run model to verify that trigger works - model.run() diff --git a/tests/unit_tests/test_uniform_source_sampling.py b/tests/unit_tests/test_uniform_source_sampling.py deleted file mode 100644 index 0d1930328..000000000 --- a/tests/unit_tests/test_uniform_source_sampling.py +++ /dev/null @@ -1,82 +0,0 @@ -import openmc -import pytest - - -@pytest.fixture -def sphere_model(): - mat = openmc.Material() - mat.add_nuclide('Li6', 1.0) - mat.set_density('g/cm3', 1.0) - sphere = openmc.Sphere(r=1.0, boundary_type='vacuum') - cell = openmc.Cell(region=-sphere, fill=mat) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - - model.settings.particles = 100 - model.settings.batches = 1 - src1 = openmc.IndependentSource( - energy=openmc.stats.delta_function(1.0e3), - strength=75.0 - ) - src2 = openmc.IndependentSource( - energy=openmc.stats.delta_function(1.0e3), - strength=25.0 - ) - model.settings.source = [src1, src2] - model.settings.run_mode = "fixed source" - model.settings.surf_source_write = { - "max_particles": 100, - } - - tally = openmc.Tally() - tally.scores = ['flux'] - model.tallies = [tally] - return model - - -def test_source_weight(run_in_tmpdir, sphere_model): - # Run OpenMC without uniform source sampling and check that banked particles - # have weight 1 - sphere_model.settings.uniform_source_sampling = False - sphere_model.run() - particles = openmc.ParticleList.from_hdf5('surface_source.h5') - assert set(p.wgt for p in particles) == {1.0} - - # Run with uniform source sampling and check that banked particles have - # weight == strength - sphere_model.settings.uniform_source_sampling = True - sphere_model.run() - particles = openmc.ParticleList.from_hdf5('surface_source.h5') - assert set(p.wgt for p in particles) == {0.5, 1.5} - - -def test_tally_mean(run_in_tmpdir, sphere_model): - # Use only one source - sphere_model.settings.source.pop() - - # Run without uniform source sampling - sphere_model.settings.uniform_source_sampling = False - sp_file = sphere_model.run() - with openmc.StatePoint(sp_file) as sp: - reference_mean = sp.tallies[sphere_model.tallies[0].id].mean - - # Run with uniform source sampling - sphere_model.settings.uniform_source_sampling = True - sp_file = sphere_model.run() - with openmc.StatePoint(sp_file) as sp: - mean = sp.tallies[sphere_model.tallies[0].id].mean - - # Check that tally means match - assert mean == pytest.approx(reference_mean) - - -def test_multiple_sources(sphere_model): - low_strength_src = openmc.IndependentSource( - energy=openmc.stats.delta_function(1.0e6), strength=1e-7) - sphere_model.settings.source.append(low_strength_src) - sphere_model.settings.uniform_source_sampling = True - - # Sample particles from source and make sure 1 MeV shows up despite - # negligible strength - particles = sphere_model.sample_external_source(100) - assert {p.E for p in particles} == {1.0e3, 1.0e6} diff --git a/tests/unit_tests/test_universe.py b/tests/unit_tests/test_universe.py index 0955347f7..46d4ec3f7 100644 --- a/tests/unit_tests/test_universe.py +++ b/tests/unit_tests/test_universe.py @@ -1,5 +1,3 @@ -from pathlib import Path - import lxml.etree as ET import numpy as np import openmc @@ -49,12 +47,6 @@ def test_bounding_box(): assert_unbounded(u) -def test_id(): - openmc.Universe(universe_id=0) - with pytest.raises(ValueError): - openmc.Universe(universe_id=-1) - - def test_plot(run_in_tmpdir, sphere_model): # model with -inf and inf in the bounding box @@ -107,47 +99,6 @@ def test_plot(run_in_tmpdir, sphere_model): pixels=100, ) - # Close plots to avoid warning - import matplotlib.pyplot as plt - plt.close('all') - - -def test_mg_plot(run_in_tmpdir): - # Create a simple universe with macroscopic data - h2o_data = openmc.Macroscopic('LWTR') - water = openmc.Material(name='Water') - water.set_density('macro', 1.0) - water.add_macroscopic(h2o_data) - sph = openmc.Sphere(r=10, boundary_type="vacuum") - cell = openmc.Cell(region=-sph, fill=water) - univ = openmc.Universe(cells=[cell]) - - # Create MGXS library and export to HDF5 - groups = openmc.mgxs.EnergyGroups([1e-5, 20.0e6]) - h2o_xsdata = openmc.XSdata('LWTR', groups) - h2o_xsdata.order = 0 - h2o_xsdata.set_total([1.0]) - h2o_xsdata.set_absorption([0.5]) - scatter_matrix = np.array([[[0.5]]]) - scatter_matrix = np.rollaxis(scatter_matrix, 0, 3) - h2o_xsdata.set_scatter_matrix(scatter_matrix) - mg_library = openmc.MGXSLibrary(groups) - mg_library.add_xsdatas([h2o_xsdata]) - mgxs_path = Path.cwd() / 'mgxs.h5' - mg_library.export_to_hdf5(mgxs_path) - - # Set MG cross sections in config and plot - with openmc.config.patch('mg_cross_sections', mgxs_path): - univ.plot(width=(200, 200), basis='yz', color_by='cell') - univ.plot(width=(200, 200), basis='yz', color_by='material') - - with pytest.raises(RuntimeError): - univ.plot(width=(200, 200), basis='yz', color_by='cell') - - # Close plots to avoid warning - import matplotlib.pyplot as plt - plt.close('all') - def test_get_nuclides(uo2): c = openmc.Cell(fill=uo2) diff --git a/tests/unit_tests/test_vectfit.py b/tests/unit_tests/test_vectfit.py deleted file mode 100644 index f7b2e905d..000000000 --- a/tests/unit_tests/test_vectfit.py +++ /dev/null @@ -1,224 +0,0 @@ -""" -Initially from Jingang Liang: https://github.com/mit-crpg/vectfit.git -""" - -import numpy as np -import pytest -from openmc.data.vectfit import evaluate, vectfit - - -@pytest.fixture -def ref_poles(): - """Reference poles for real-pole test.""" - return np.array( - [ - 9.709261771920490e02 + 0.0j, - -1.120960794075339e03 + 0.0j, - 1.923889557426567e00 + 7.543700246109742e01j, - 1.923889557426567e00 - 7.543700246109742e01j, - 1.159741300380281e02 + 3.595650922556496e-02j, - 1.159741300380281e02 - 3.595650922556496e-02j, - 1.546932165729394e02 + 8.728391144940301e-02j, - 1.546932165729394e02 - 8.728391144940301e-02j, - 2.280349190818197e02 + 2.814037559718684e-01j, - 2.280349190818197e02 - 2.814037559718684e-01j, - 2.313004772627853e02 + 3.004628477692201e-01j, - 2.313004772627853e02 - 3.004628477692201e-01j, - 2.787470098364861e02 + 3.414179169920170e-01j, - 2.787470098364861e02 - 3.414179169920170e-01j, - 3.570711338764254e02 + 4.485587371149193e-01j, - 3.570711338764254e02 - 4.485587371149193e-01j, - 4.701059001346060e02 + 6.598089307174224e-01j, - 4.701059001346060e02 - 6.598089307174224e-01j, - 7.275819506342254e02 + 1.189678974845038e03j, - 7.275819506342254e02 - 1.189678974845038e03j, - ] - ) - - -@pytest.fixture -def ref_residues(): - """Reference residues for real-pole test.""" - return np.array( - [ - [ - -3.269879776751686e07 + 0.0j, - 1.131087935798761e09 + 0.0j, - 1.634151281869857e04 + 2.251103589277891e05j, - 1.634151281869857e04 - 2.251103589277891e05j, - 3.281792303833561e03 - 1.756079516325274e04j, - 3.281792303833561e03 + 1.756079516325274e04j, - 1.110800880243503e04 - 4.324813594540043e04j, - 1.110800880243503e04 + 4.324813594540043e04j, - 8.812700704117636e04 - 2.256520243571103e05j, - 8.812700704117636e04 + 2.256520243571103e05j, - 5.842090495551535e04 - 1.442159380741478e05j, - 5.842090495551535e04 + 1.442159380741478e05j, - 1.339410514130921e05 - 2.640767909713812e05j, - 1.339410514130921e05 + 2.640767909713812e05j, - 2.211245633333130e05 - 3.222447758311512e05j, - 2.211245633333130e05 + 3.222447758311512e05j, - 4.124430059785149e05 - 4.076023108323907e05j, - 4.124430059785149e05 + 4.076023108323907e05j, - 1.607378314999252e09 - 1.401163320110452e08j, - 1.607378314999252e09 + 1.401163320110452e08j, - ] - ] - ) - - -@pytest.fixture -def vector_test_data(): - """Simple 2-signal test with known poles and residues.""" - Ns = 101 - s = np.linspace(3.0, 7.0, Ns) - poles = [5.0 + 0.1j, 5.0 - 0.1j] - residues = [[0.5 - 11.0j, 0.5 + 11.0j], [1.5 - 20.0j, 1.5 + 20.0j]] - f = np.zeros((2, Ns)) - for i in range(2): - f[i, :] = np.real( - residues[i][0] / (s - poles[0]) + residues[i][1] / (s - poles[1]) - ) - weight = 1.0 / f - init_poles = [3.5 + 0.035j, 3.5 - 0.035j] - return s, poles, residues, f, weight, init_poles - - -@pytest.fixture -def poly_test_data(): - """Test data with rational function plus polynomial terms.""" - Ns = 201 - s = np.linspace(0.0, 5.0, Ns) - poles = [-20.0 + 30.0j, -20.0 - 30.0j] - residues = [[5.0 + 10.0j, 5.0 - 10.0j]] - polys = [[1.0, 2.0, 0.3]] - f = evaluate(s, poles, residues, polys) - weight = 1.0 / f - init_poles = [2.5 + 0.025j, 2.5 - 0.025j] - return s, poles, residues, polys, f, weight, init_poles - - -@pytest.fixture -def real_poles_data(ref_poles, ref_residues): - """Large-scale signal using complex and real poles.""" - Ns = 2000 - s = np.linspace(1.0e-2, 5.0e3, Ns) - f = np.zeros((1, Ns)) - for p, r in zip(ref_poles, ref_residues[0]): - f[0] += (r / (s - p)).real - weight = 1.0 / f - poles = np.linspace(1.1e-2, 4.8e3, 10) - poles = poles + poles * 0.01j - poles = np.sort(np.append(poles, np.conj(poles))) - return s, f, weight, poles - - -@pytest.fixture -def large_test_data(): - """Stress test data with thousands of poles and samples.""" - Ns = 3000 - N = 200 - s = np.linspace(1.0e-2, 5.0e3, Ns) - poles = np.linspace(1.1e-2, 4.8e3, N // 2) + 0.01j * np.linspace( - 1.1e-2, 4.8e3, N // 2 - ) - poles = np.sort(np.append(poles, np.conj(poles))) - residues = np.linspace(1e2, 1e6, N // 2) + 0.5j * np.linspace(1e2, 1e6, N // 2) - residues = np.sort(np.append(residues, np.conj(residues))).reshape((1, N)) - f = np.zeros((1, Ns)) - for p, r in zip(poles, residues[0]): - f[0] += (r / (s - p)).real - weight = 1.0 / f - init_poles = np.linspace(1.2e-2, 4.7e3, N // 2) + 0.01j * np.linspace( - 1.2e-2, 4.7e3, N // 2 - ) - init_poles = np.sort(np.append(init_poles, np.conj(init_poles))) - return s, f, weight, init_poles - - -@pytest.fixture -def eval_test_data(): - """Reference data for evaluating rational + polynomial models.""" - Ns = 101 - s = np.linspace(-5.0, 5.0, Ns) - poles = [-2.0 + 30.0j, -2.0 - 30.0j] - residues = [5.0 + 10.0j, 5.0 - 10.0j] - polys = [1.0, 2.0, 0.3] - return s, poles, residues, polys - - -def test_vector(vector_test_data): - """Test vectfit with vector samples and simple poles. - It is expected to get exact results with one iteration. - """ - s, expected_poles, expected_residues, f, weight, init_poles = vector_test_data - poles, residues, _, fit, _ = vectfit(f, s, init_poles, weight) - assert np.allclose( - np.sort_complex(poles), np.sort_complex(expected_poles), rtol=1e-7 - ) - assert np.allclose(f, evaluate(s, poles, residues), rtol=1e-7) - assert np.allclose(f, fit, rtol=1e-5) - - -def test_poly(poly_test_data): - """Test vectfit with polynomials.""" - s, expected_poles, expected_residues, expected_polys, f, weight, init_poles = ( - poly_test_data - ) - poles, residues, cf, fit, _ = vectfit(f, s, init_poles, weight, n_polys=3) - poles, residues, cf, fit, _ = vectfit(f, s, poles, weight, n_polys=3) - assert np.allclose( - np.sort_complex(poles), np.sort_complex(expected_poles), rtol=1e-5 - ) - assert np.allclose(f, evaluate(s, poles, residues, cf), rtol=1e-5) - assert np.allclose(cf, expected_polys, rtol=1e-5) - assert np.allclose(f, fit, rtol=1e-4) - - -def test_real_poles(real_poles_data, ref_poles, ref_residues): - """Test vectfit with more poles including real poles""" - s, f, weight, poles = real_poles_data - for _ in range(6): - poles, residues, _, fit, _ = vectfit(f, s, poles, weight) - assert np.allclose( - np.sort_complex(poles), np.sort_complex(ref_poles), rtol=1e-5, atol=1e-8 - ) - assert np.allclose(f, evaluate(s, poles, residues), rtol=1e-4) - assert np.allclose(f, fit, rtol=1e-3) - - -def test_large(large_test_data): - """Test vectfit with a large set of poles and samples""" - s, f, weight, init_poles = large_test_data - poles_fit, residues_fit, _, f_fit, _ = vectfit(f, s, init_poles, weight) - assert np.allclose(f, f_fit, rtol=1e-3) - - -def test_evaluate(eval_test_data): - """Test evaluate function""" - s, poles, residues, polys = eval_test_data - - # Single signal, no polynomial - f_ref = np.real(residues[0] / (s - poles[0]) + residues[1] / (s - poles[1])) - f = evaluate(s, poles, residues) - assert np.allclose(f[0], f_ref) - - # Single signal, with polynomial - for n, c in enumerate(polys): - f_ref += c * np.power(s, n) - f = evaluate(s, poles, residues, polys) - assert np.allclose(f[0], f_ref) - - # Multi-signal, multi-residue, multi-poly - poles = [5.0 + 0.1j, 5.0 - 0.1j] - residues = [[0.5 - 11.0j, 0.5 + 11.0j], [1.5 - 20.0j, 1.5 + 20.0j]] - polys = [[1.0, 2.0, 0.3], [4.0, -2.0, -10.0]] - f_ref = np.zeros((2, len(s))) - for i in range(2): - f_ref[i, :] = np.real( - residues[i][0] / (s - poles[0]) + residues[i][1] / (s - poles[1]) - ) - for n, c in enumerate(polys[i]): - f_ref[i, :] += c * np.power(s, n) - f = evaluate(s, poles, residues, polys) - assert np.allclose(f, f_ref) diff --git a/tests/unit_tests/test_void.py b/tests/unit_tests/test_void.py deleted file mode 100644 index 8713d4b0b..000000000 --- a/tests/unit_tests/test_void.py +++ /dev/null @@ -1,42 +0,0 @@ -import numpy as np -import openmc -import pytest - - -@pytest.fixture -def empty_sphere(): - openmc.reset_auto_ids() - model = openmc.Model() - surf = openmc.Sphere(r=10, boundary_type='vacuum') - cell = openmc.Cell(region=-surf) - model.geometry = openmc.Geometry([cell]) - - model.settings.run_mode = 'fixed source' - model.settings.batches = 3 - model.settings.particles = 1000 - - tally = openmc.Tally() - tally.scores = ['total', 'elastic'] - tally.nuclides = ['U235'] - tally.multiply_density = False - model.tallies.append(tally) - - return model - - -def test_equivalent_microxs(empty_sphere, run_in_tmpdir): - sp_file = empty_sphere.run() - with openmc.StatePoint(sp_file) as sp: - tally1 = sp.tallies[1] - - mat = openmc.Material() - mat.add_nuclide('H1', 1e-16) - - empty_sphere.geometry.get_all_cells()[1].fill = mat - - sp_file = empty_sphere.run() - with openmc.StatePoint(sp_file) as sp: - tally2 = sp.tallies[1] - - assert np.isclose(tally1.mean.sum(), tally2.mean.sum(), rtol=1e-10, atol=0) - assert tally1.mean.sum() > 0 diff --git a/tests/unit_tests/test_waste_classification.py b/tests/unit_tests/test_waste_classification.py deleted file mode 100644 index 072590df9..000000000 --- a/tests/unit_tests/test_waste_classification.py +++ /dev/null @@ -1,102 +0,0 @@ -import random - -import openmc -import pytest - - -@pytest.mark.parametrize("metal", [False, True]) -def test_waste_classification_long(metal): - """Test classification when determined by long-lived radionuclides""" - f = 10.0 if metal else 1.0 - limit = 8.0*f - mat = openmc.Material() - mat.add_nuclide('C14', 1e-9*f) - assert mat.get_activity('Ci/m3') < 0.1 * limit - assert mat.waste_classification(metal=metal) == 'Class A' - - mat = openmc.Material() - mat.add_nuclide('C14', 1e-8*f) - assert 0.1 * limit < mat.get_activity('Ci/m3') < limit - assert mat.waste_classification(metal=metal) == 'Class C' - - mat = openmc.Material() - mat.add_nuclide('C14', 1e-7*f) - assert mat.get_activity('Ci/m3') > limit - assert mat.waste_classification(metal=metal) == 'GTCC' - - -@pytest.mark.parametrize("metal", [False, True]) -def test_waste_classification_short(metal): - """Test classification when determined by short-lived radionuclides""" - f = 10.0 if metal else 1.0 - col1, col2, col3 = 3.5*f, 70.0*f, 700.0*f - - mat = openmc.Material() - mat.add_nuclide('Ni63', 1e-10*f) - assert mat.get_activity('Ci/m3') < col1 - assert mat.waste_classification(metal=metal) == 'Class A' - - mat = openmc.Material() - mat.add_nuclide('Ni63', 1e-10*10*f) - assert col1 < mat.get_activity('Ci/m3') < col2 - assert mat.waste_classification(metal=metal) == 'Class B' - - mat = openmc.Material() - mat.add_nuclide('Ni63', 1e-10*200*f) - assert col2 < mat.get_activity('Ci/m3') < col3 - assert mat.waste_classification(metal=metal) == 'Class C' - - mat = openmc.Material() - mat.add_nuclide('Ni63', 1e-10*2000*f) - assert mat.get_activity('Ci/m3') > col3 - assert mat.waste_classification(metal=metal) == 'GTCC' - - -def test_waste_classification_mix(): - """Test classification when determined by a mix of radionuclides""" - # Check example from 10 CFR 61.55 with mix of Sr90 and Cs137 - mat = openmc.Material() - mat.add_nuclide('Sr90', 2.425e-9) - mat.add_nuclide('Cs137', 1.115e-9) - - # In example, activity of Sr90 is 50.0 Ci/m3 and Cs137 is 22.0 Ci/m3 - activity = mat.get_activity(units='Ci/m3', by_nuclide=True) - assert activity['Sr90'] == pytest.approx(50.0, 0.01) - assert activity['Cs137'] == pytest.approx(22.0, 0.01) - - # According to example, the waste should be class B - assert mat.waste_classification() == 'Class B' - - -def test_waste_rating_fetter(): - """Test waste classification using the Fetter limits""" - # For Tc99, Fetter has a more strict limit. Here, we create a material with - # Tc99 at 1 Ci/m3 which exceeds Fetter but not NRC - density = 3.5561e-7 - mat = openmc.Material() - mat.add_nuclide('Tc99', density) - assert mat.get_activity('Ci/m3') == pytest.approx(1.0, 1e-3) - assert mat.waste_disposal_rating(limits='NRC_short_C') < 1.0 - assert mat.waste_disposal_rating(limits='Fetter') > 1.0 - - # With a lower density, it should be Class C under Fetter limits and Class A - # under NRC limits - mat = openmc.Material() - mat.add_nuclide('Tc99', 5.0e-2*density) - assert mat.waste_disposal_rating(limits='NRC_short_A') < 1.0 - assert mat.waste_disposal_rating(limits='Fetter') < 1.0 - - -def test_waste_disposal_rating(): - """Test waste_disposal_rating method""" - mat = openmc.Material() - mat.add_nuclide('K40', random.random()) - - # Check for correct classification based on actual activity - ci_m3 = mat.get_activity('Ci/m3') - assert mat.waste_disposal_rating(limits={'K40': 2*ci_m3}) < 1.0 - assert mat.waste_disposal_rating(limits={'K40': 0.5*ci_m3}) > 1.0 - - wdr = mat.waste_disposal_rating(limits={'K40': 4*ci_m3}, by_nuclide=True) - assert isinstance(wdr, dict) - assert wdr['K40'] == pytest.approx(1/4) diff --git a/tests/unit_tests/weightwindows/dagmc/__init__.py b/tests/unit_tests/weightwindows/dagmc/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/unit_tests/weightwindows/dagmc/nested_shell_geometry.h5m b/tests/unit_tests/weightwindows/dagmc/nested_shell_geometry.h5m deleted file mode 100644 index af1d5563d..000000000 Binary files a/tests/unit_tests/weightwindows/dagmc/nested_shell_geometry.h5m and /dev/null differ diff --git a/tests/unit_tests/weightwindows/dagmc/test.py b/tests/unit_tests/weightwindows/dagmc/test.py deleted file mode 100644 index ed01a93ed..000000000 --- a/tests/unit_tests/weightwindows/dagmc/test.py +++ /dev/null @@ -1,98 +0,0 @@ -import pytest - -import openmc -import openmc.lib - -pytestmark = pytest.mark.skipif( - not openmc.lib._dagmc_enabled(), - reason="DAGMC CAD geometry is not enabled.", -) - - -def test_dagmc_weight_windows_near_boundary(run_in_tmpdir, request): - """Ensure splitting near a boundary doesn't lose particles due to - a stale DAGMC history on the particle object.""" - - # DAGMC model overview: - # * Three nested cubes; innermost cube contains a fusion neutron source. - # * Two outer cubes filled with tungsten. Weight windows defined on a mesh - # cause particles to split moving outward. - # Outer cubes are similar in size (outer slightly larger) so particles - # frequently cross the problem boundary immediately after splitting. No lost - # particles are allowed to the correct DAGMC history after splitting is used. - model = openmc.Model() - - dagmc_file = request.path.parent / 'nested_shell_geometry.h5m' - dagmc_univ = openmc.DAGMCUniverse(dagmc_file) - model.geometry = openmc.Geometry(dagmc_univ) - - tungsten = openmc.Material(name='shell') - tungsten.add_element('W', 1.0) - tungsten.set_density('g/cm3', 7.8) - materials = openmc.Materials([tungsten]) - model.materials = materials - - settings = openmc.Settings() - settings.output = {'tallies': False, 'summary': False} - - source = openmc.IndependentSource() - source.space = openmc.stats.Point((0.0, 0.0, 0.0)) - source.angle = openmc.stats.Isotropic() - source.energy = openmc.stats.Discrete([14.1e6], [1.0]) - settings.source = source - - settings.batches = 2 - settings.particles = 500 - settings.run_mode = 'fixed source' - settings.survival_biasing = False - settings.max_lost_particles = 1 - settings.max_history_splits = 10_000_000 - - settings.weight_window_checkpoints = { - 'surface': True, - 'collision': True, - } - - mesh = openmc.RegularMesh() - mesh.lower_left = (-60.0, -60.0, -60.0) - mesh.upper_right = (60.0, 60.0, 60.0) - mesh.dimension = (24, 1, 1) - - weight_windows_lower = [ - 0.030750733294361156, - 0.056110505674355333, - 0.08187875047968339, - 0.1101743496347699, - 0.13982370013053508, - 0.17443799246829372, - 0.21576286623367483, - 0.26416659508033646, - 0.318574932646899, - 0.3804031702117963, - 0.42899359749256355, - 0.4954283294279403, - 0.49999999999999994, - 0.43432341070872266, - 0.38302303850488206, - 0.32148375935490886, - 0.2637416945702018, - 0.21498369367288853, - 0.17163611765361744, - 0.13832102142074995, - 0.10717772257151495, - 0.07986176041282561, - 0.05499644859408233, - 0.03058023506703803, - ] - - weight_windows = openmc.WeightWindows( - mesh, - lower_ww_bounds=weight_windows_lower, - upper_bound_ratio=5.0, - ) - weight_windows.max_lower_bound_ratio = 1.0 - settings.weight_windows = weight_windows - settings.weight_windows_on = True - model.settings = settings - - model.run() \ No newline at end of file diff --git a/tests/unit_tests/weightwindows/test.py b/tests/unit_tests/weightwindows/test.py index c9b24e305..d3da0cd11 100644 --- a/tests/unit_tests/weightwindows/test.py +++ b/tests/unit_tests/weightwindows/test.py @@ -4,6 +4,7 @@ from pathlib import Path import numpy as np import pytest from uncertainties import ufloat + import openmc import openmc.lib from openmc.stats import Discrete, Point @@ -122,8 +123,7 @@ def model(): return model -@pytest.mark.parametrize("shared_secondary", [False, True]) -def test_weightwindows(model, wws, shared_secondary): +def test_weightwindows(model, wws): ww_files = ('ww_n.txt', 'ww_p.txt') cwd = Path(__file__).parent.absolute() @@ -132,7 +132,6 @@ def test_weightwindows(model, wws, shared_secondary): with cdtemp(filepaths): # run once with variance reduction off model.settings.weight_windows_on = False - model.settings.shared_secondary_bank = shared_secondary analog_sp = model.run() os.rename(analog_sp, 'statepoint.analog.h5') @@ -225,53 +224,6 @@ def test_lower_ww_bounds_shape(): assert ww.lower_ww_bounds.shape == (2, 3, 4, 1) -@pytest.mark.parametrize("shared_secondary", [False, True]) -def test_photon_heating(run_in_tmpdir, shared_secondary): - water = openmc.Material() - water.add_nuclide('H1', 1.0) - water.add_nuclide('O16', 2.0) - water.set_density('g/cm3', 1.0) - - box = openmc.model.RectangularParallelepiped( - -300, 300, -300, 300, -300, 300, boundary_type='reflective') - cell = openmc.Cell(region=-box, fill=water) - model = openmc.Model() - model.geometry = openmc.Geometry([cell]) - - mesh = openmc.RegularMesh.from_domain(model.geometry, dimension=(5, 5, 5)) - wwg = openmc.WeightWindowGenerator(mesh, particle_type='photon') - model.settings.weight_window_generators = [wwg] - - space = openmc.stats.Point((0, 0, 0)) - energy = openmc.stats.delta_function(5e6) - model.settings.source = openmc.IndependentSource( - space=space, energy=energy, particle='photon') - - model.settings.run_mode = 'fixed source' - model.settings.batches = 5 - model.settings.particles = 100 - model.settings.shared_secondary_bank = shared_secondary - - tally = openmc.Tally() - tally.scores = ['heating'] - tally.filters = [ - openmc.ParticleFilter(['photon']), - openmc.MeshFilter(mesh) - ] - model.tallies = [tally] - - sp_file = model.run() - with openmc.StatePoint(sp_file) as sp: - tally_mean = sp.tallies[tally.id].mean - - # Note: Our current physics model actually does allow this tally to - # occasionally go slightly negative. However, larger bugs can - # make this more common. We have selected a particle count for - # this test that happens to produce no negative tallies for both - # the shared and non-shared secondary PRNG streams. - assert np.all(tally_mean >= 0) - - def test_roundtrip(run_in_tmpdir, model, wws): model.settings.weight_windows = wws @@ -297,11 +249,11 @@ def test_ww_attrs_python(model): # is successful wws = openmc.WeightWindows(mesh, lower_bounds, upper_bound_ratio=10.0) - assert wws.energy_bounds is None + assert wws.energy_bounds == None wwg = openmc.WeightWindowGenerator(mesh) - assert wwg.energy_bounds is None + assert wwg.energy_bounds == None def test_ww_attrs_capi(run_in_tmpdir, model): model.export_to_xml() @@ -344,40 +296,4 @@ def test_ww_attrs_capi(run_in_tmpdir, model): assert wws.id == 2 assert wws.particle == openmc.ParticleType.PHOTON - openmc.lib.finalize() - - -@pytest.mark.parametrize('library', ('libmesh', 'moab')) -def test_unstructured_mesh_applied_wws(request, run_in_tmpdir, library): - """ - Ensure that weight windows on unstructured mesh work when - they aren't part of a tally or weight window generator - """ - - if library == 'libmesh' and not openmc.lib._libmesh_enabled(): - pytest.skip('LibMesh not enabled in this build.') - if library == 'moab' and not openmc.lib._dagmc_enabled(): - pytest.skip('DAGMC (and MOAB) mesh not enabled in this build.') - - water = openmc.Material(name='water') - water.add_nuclide('H1', 2.0) - water.add_nuclide('O16', 1.0) - water.set_density('g/cc', 1.0) - box = openmc.model.RectangularParallelepiped(*(3*[-10, 10]), boundary_type='vacuum') - cell = openmc.Cell(region=-box, fill=water) - - geometry = openmc.Geometry([cell]) - mesh_file = str(request.fspath.dirpath() / 'test_mesh_tets.exo') - mesh = openmc.UnstructuredMesh(mesh_file, library) - - dummy_wws = np.ones((12_000,)) - - wws = openmc.WeightWindows(mesh, dummy_wws, upper_bound_ratio=5.0) - - model = openmc.Model(geometry) - model.settings.weight_windows = wws - model.settings.weight_windows_on = True - model.settings.run_mode = 'fixed source' - model.settings.particles = 100 - model.settings.batches = 2 - model.run() + openmc.lib.finalize() \ No newline at end of file diff --git a/tests/unit_tests/weightwindows/test_mesh_tets.exo b/tests/unit_tests/weightwindows/test_mesh_tets.exo deleted file mode 120000 index 5bf23b369..000000000 --- a/tests/unit_tests/weightwindows/test_mesh_tets.exo +++ /dev/null @@ -1 +0,0 @@ -../../regression_tests/unstructured_mesh/test_mesh_tets.e \ No newline at end of file diff --git a/tests/unit_tests/weightwindows/test_ww_gen.py b/tests/unit_tests/weightwindows/test_ww_gen.py index 9cb61f0ef..555421461 100644 --- a/tests/unit_tests/weightwindows/test_ww_gen.py +++ b/tests/unit_tests/weightwindows/test_ww_gen.py @@ -1,4 +1,3 @@ -import copy from itertools import permutations from pathlib import Path @@ -304,7 +303,7 @@ def test_python_hdf5_roundtrip(run_in_tmpdir, model): openmc.lib.finalize() - wws_hdf5 = openmc.WeightWindowsList.from_hdf5()[0] + wws_hdf5 = openmc.hdf5_to_wws()[0] # ensure assert all(wws.energy_bounds == wws_hdf5.energy_bounds) @@ -333,72 +332,3 @@ def test_ww_bounds_set_in_memory(run_in_tmpdir, model): wws.bounds = (bounds, bounds) openmc.lib.finalize() - - -@pytest.mark.skipif(not openmc.lib._dagmc_enabled(), reason="DAGMC CAD geometry is not enabled.") -def test_ww_generation_with_dagmc(run_in_tmpdir): - mat1 = openmc.Material(name="1") - mat1.add_nuclide("H1", 1, percent_type="ao") - mat1.set_density("g/cm3", 0.001) - - materials = openmc.Materials([mat1]) - dag_univ = openmc.DAGMCUniverse( - Path(__file__).parent.parent / "dagmc" / "dagmc_tetrahedral_no_graveyard.h5m") - bound_dag_univ = dag_univ.bounded_universe(padding_distance=1) - geometry = openmc.Geometry(bound_dag_univ) - - settings = openmc.Settings() - settings.batches = 6 - settings.particles = 30 - settings.run_mode = "fixed source" - - # Create a point source which are supported by random ray mode - my_source = openmc.IndependentSource() - my_source.space = openmc.stats.Point((0.25, 0.25, 0.25)) - my_source.energy = openmc.stats.delta_function(14e6) - settings.source = my_source - - model = openmc.Model(geometry, materials, settings) - - rr_model = copy.deepcopy(model) - rr_model.settings.inactive = 3 - - rr_model.convert_to_multigroup( - method="stochastic_slab", - overwrite_mgxs_library=True, - particles=10, - groups="CASMO-2" - ) - - rr_model.convert_to_random_ray() - - mesh = openmc.RegularMesh.from_domain(rr_model, dimension=(4, 4, 4)) - - # avoid writing files we don't make use of - rr_model.settings.output = {"summary": False, "tallies": False} - - # Subdivide random ray source regions - rr_model.settings.random_ray["source_region_meshes"] = [ - (mesh, [rr_model.geometry.root_universe]) - ] - - # less likely to get negative values in the weight window - rr_model.settings.random_ray["volume_estimator"] = "naive" - - # Add a weight window generator to the model - rr_model.settings.weight_window_generators = openmc.WeightWindowGenerator( - method="fw_cadis", - mesh=mesh, - max_realizations=42, - particle_type='neutron', - energy_bounds=[0.0, 100e6] - ) - - rr_model.run() - - model.settings.weight_windows_on = True - model.settings.weight_window_checkpoints = {"collision": True, "surface": True} - model.settings.survival_biasing = False - model.settings.weight_windows = openmc.WeightWindowsList.from_hdf5() - - model.run() diff --git a/tests/unit_tests/weightwindows/test_ww_list.py b/tests/unit_tests/weightwindows/test_ww_list.py deleted file mode 100644 index d148f382a..000000000 --- a/tests/unit_tests/weightwindows/test_ww_list.py +++ /dev/null @@ -1,23 +0,0 @@ -import openmc - - -def test_ww_roundtrip(request, run_in_tmpdir): - # Load weight windows from a wwinp file - wwinp_file = request.path.with_name('wwinp_n') - wws = openmc.WeightWindowsList.from_wwinp(wwinp_file) - - # Roundtrip them, writing to HDF5 and reading back in - wws.export_to_hdf5('ww.h5') - wws_new = openmc.WeightWindowsList.from_hdf5('ww.h5') - - # Check that the new weight windows are the same as the original - assert len(wws) == len(wws_new) - for ww, ww_new in zip(wws, wws_new): - assert ww.particle_type == ww_new.particle_type - assert (ww.lower_ww_bounds == ww_new.lower_ww_bounds).all() - assert (ww.upper_ww_bounds == ww_new.upper_ww_bounds).all() - assert ww.survival_ratio == ww_new.survival_ratio - assert ww.num_energy_bins == ww_new.num_energy_bins - assert ww.max_split == ww_new.max_split - assert ww.weight_cutoff == ww_new.weight_cutoff - assert ww.mesh.id == ww_new.mesh.id diff --git a/tests/unit_tests/weightwindows/test_ww_mg.py b/tests/unit_tests/weightwindows/test_ww_mg.py deleted file mode 100644 index 23e09ea0c..000000000 --- a/tests/unit_tests/weightwindows/test_ww_mg.py +++ /dev/null @@ -1,51 +0,0 @@ -import numpy as np -import openmc - - -def test_weight_windows_mg(request, run_in_tmpdir): - # import basic random ray model - model = openmc.examples.random_ray_three_region_cube() - - # create a mesh tally - mesh = openmc.RegularMesh.from_domain(model.geometry, (3, 3, 3)) - mesh_tally = openmc.Tally() - mesh_tally.filters = [openmc.MeshFilter(mesh)] - mesh_tally.scores = ['flux'] - model.tallies = [mesh_tally] - - # replace random ray settings with fixed source settings - settings = openmc.Settings() - settings.particles = 5000 - settings.batches = 10 - settings.energy_mode = 'multi-group' - settings.run_mode = 'fixed source' - space = openmc.stats.Point((1, 1, 1)) - energy = openmc.stats.delta_function(1e6) - settings.source = openmc.IndependentSource(space=space, energy=energy) - model.settings = settings - - # perform analog simulation - statepoint = model.run() - - # extract flux from analog simulation - with openmc.StatePoint(statepoint) as sp: - tally_out = sp.get_tally(id=mesh_tally.id) - flux_analog = tally_out.mean - - # load the weight windows for this problem and apply them - ww_lower_bnds = np.loadtxt(request.path.parent / 'ww_mg.txt') - weight_windows = openmc.WeightWindows(mesh, lower_ww_bounds=ww_lower_bnds, upper_bound_ratio=5.0) - model.settings.weight_windows = weight_windows - model.settings.weight_windows_on = True - - # re-run with weight windows - statepoint = model.run() - with openmc.StatePoint(statepoint) as sp: - tally_out = sp.get_tally(id=mesh_tally.id) - flux_ww = tally_out.mean - - # the sum of the fluxes should approach the same value (no bias introduced) - analog_sum = flux_analog.sum() - ww_sum = flux_ww.sum() - assert np.allclose(analog_sum, ww_sum, rtol=1e-2) - diff --git a/tests/unit_tests/weightwindows/test_wwinp_reader.py b/tests/unit_tests/weightwindows/test_wwinp_reader.py index 601517d47..434a36753 100644 --- a/tests/unit_tests/weightwindows/test_wwinp_reader.py +++ b/tests/unit_tests/weightwindows/test_wwinp_reader.py @@ -52,7 +52,7 @@ n_mesh.z_grid = np.array([-100.0, n_e_bounds = (np.array([0.0, 100000.0, 146780.0]),) -n_particles = [openmc.ParticleType.NEUTRON] +n_particles = ('neutron',) # expected results - neutron and photon data np_mesh = openmc.RectilinearMesh() @@ -63,7 +63,7 @@ np_mesh.z_grid = n_mesh.z_grid np_e_bounds = (np.array([0.0, 100000.0, 146780.0, 215440.0]), np.array([0.0, 1.0E8])) -np_particles = [openmc.ParticleType.NEUTRON, openmc.ParticleType.PHOTON] +np_particles = ('neutron', 'photon') # expected results - photon data only p_mesh = openmc.RectilinearMesh() @@ -74,7 +74,7 @@ p_mesh.y_grid = np_mesh.y_grid p_mesh.z_grid = np.array([-50.0, 50.0]) p_e_bounds = (np.array([0.0, 100000.0, 146780.0, 215440.0, 316230.0]),) -p_particles = [openmc.ParticleType.PHOTON] +p_particles = ('photon',) expected_results = [('wwinp_n', n_mesh, n_particles, n_e_bounds), ('wwinp_np', np_mesh, np_particles, np_e_bounds), @@ -96,7 +96,7 @@ def id_fn(params): def test_wwinp_reader(wwinp_data, request): wwinp_file, mesh, particle_types, energy_bounds = wwinp_data - wws = openmc.WeightWindowsList.from_wwinp(request.node.path.parent / wwinp_file) + wws = openmc.wwinp_to_wws(request.node.path.parent / wwinp_file) for i, ww in enumerate(wws): e_bounds = energy_bounds[i] @@ -140,4 +140,4 @@ def test_wwinp_reader_failures(wwinp_data, request): filename, expected_failure = wwinp_data with pytest.raises(expected_failure): - _ = openmc.WeightWindowsList.from_wwinp(request.node.path.parent / filename) + _ = openmc.wwinp_to_wws(request.node.path.parent / filename) diff --git a/tests/unit_tests/weightwindows/ww_mg.txt b/tests/unit_tests/weightwindows/ww_mg.txt deleted file mode 100644 index 7bcc59d97..000000000 --- a/tests/unit_tests/weightwindows/ww_mg.txt +++ /dev/null @@ -1,27 +0,0 @@ -5.000000000000000278e-02 -1.023184121346435924e-02 -3.006624096325660397e-03 -1.030178532774538719e-02 -6.058877789444589400e-03 -2.216914234856166583e-03 -3.061186967456217597e-03 -2.148267952185671601e-03 -1.026171712186230980e-03 -1.040022203443005666e-02 -6.040633813799485378e-03 -2.364143118752318716e-03 -6.119726639841410569e-03 -4.329097093078606955e-03 -1.873104469085542763e-03 -2.246957229279350661e-03 -1.851165248260521617e-03 -7.825824911598703530e-04 -3.021300894848398706e-03 -2.286420236345795311e-03 -9.318583473482396160e-04 -2.234702678114806364e-03 -1.813664566119888152e-03 -7.969287848384389462e-04 -1.017895970086981662e-03 -7.707144532950136471e-04 -3.386087166633241791e-04 diff --git a/tools/ci/gha-install-dagmc.sh b/tools/ci/gha-install-dagmc.sh index 8d0648a50..82759c9bc 100755 --- a/tools/ci/gha-install-dagmc.sh +++ b/tools/ci/gha-install-dagmc.sh @@ -3,7 +3,7 @@ set -ex # MOAB Variables -MOAB_BRANCH='5.5.1' +MOAB_BRANCH='Version5.1.0' MOAB_REPO='https://bitbucket.org/fathomteam/moab/' MOAB_INSTALL_DIR=$HOME/MOAB/ @@ -19,7 +19,7 @@ cd $HOME mkdir MOAB && cd MOAB git clone -b $MOAB_BRANCH $MOAB_REPO mkdir build && cd build -cmake ../moab -DENABLE_HDF5=ON -DENABLE_NETCDF=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$MOAB_INSTALL_DIR +cmake ../moab -DENABLE_HDF5=ON -DENABLE_NETCDF=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$MOAB_INSTALL_DIR -DENABLE_BLASLAPACK=OFF make -j && make -j install rm -rf $HOME/MOAB/moab $HOME/MOAB/build diff --git a/tools/ci/gha-install-libmesh.sh b/tools/ci/gha-install-libmesh.sh index d4557d2d3..cb808ae5b 100755 --- a/tools/ci/gha-install-libmesh.sh +++ b/tools/ci/gha-install-libmesh.sh @@ -16,6 +16,7 @@ else ../libmesh/configure --prefix=$HOME/LIBMESH --enable-exodus --disable-netcdf-4 --disable-eigen --disable-lapack --disable-mpi fi make -j4 install +export LIBMESH_PC=$HOME/LIBMESH/lib/pkgconfig/ rm -rf $HOME/LIBMESH/build popd diff --git a/tools/ci/gha-install-mcpl.sh b/tools/ci/gha-install-mcpl.sh new file mode 100755 index 000000000..9b8609398 --- /dev/null +++ b/tools/ci/gha-install-mcpl.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -ex +cd $HOME +git clone https://github.com/mctools/mcpl +cd mcpl +mkdir build && cd build +cmake .. && make 2>/dev/null && sudo make install diff --git a/tools/ci/gha-install-ncrystal.sh b/tools/ci/gha-install-ncrystal.sh new file mode 100755 index 000000000..16f77e13e --- /dev/null +++ b/tools/ci/gha-install-ncrystal.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -ex +cd $HOME + +#Use the NCrystal develop branch (in the near future we can move this to master): +git clone https://github.com/mctools/ncrystal --branch develop --single-branch --depth 1 ncrystal_src + +SRC_DIR="$PWD/ncrystal_src" +BLD_DIR="$PWD/ncrystal_bld" +INST_DIR="$PWD/ncrystal_inst" +PYTHON=$(which python3) + +CPU_COUNT=1 + +mkdir "$BLD_DIR" +cd ncrystal_bld + +cmake \ + "${SRC_DIR}" \ + -DBUILD_SHARED_LIBS=ON \ + -DNCRYSTAL_NOTOUCH_CMAKE_BUILD_TYPE=ON \ + -DNCRYSTAL_MODIFY_RPATH=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DNCRYSTAL_ENABLE_EXAMPLES=OFF \ + -DNCRYSTAL_ENABLE_SETUPSH=OFF \ + -DNCRYSTAL_ENABLE_DATA=EMBED \ + -DCMAKE_INSTALL_PREFIX="${INST_DIR}" \ + -DPython3_EXECUTABLE="$PYTHON" + +make -j${CPU_COUNT:-1} +make install + +#Note: There is no "make test" or "make ctest" functionality for NCrystal +# yet. If it appears in the future, we should add it here. + +# Output the configuration to the log + +"${INST_DIR}/bin/ncrystal-config" --setup + +# Change environmental variables + +eval $( "${INST_DIR}/bin/ncrystal-config" --setup ) + +# Check installation worked + +nctool --test diff --git a/tools/ci/gha-install-njoy.sh b/tools/ci/gha-install-njoy.sh index 168fcd4a7..8255ffea8 100755 --- a/tools/ci/gha-install-njoy.sh +++ b/tools/ci/gha-install-njoy.sh @@ -1,7 +1,7 @@ #!/bin/bash set -ex cd $HOME -git clone -b 2016.78 https://github.com/njoy/NJOY2016 +git clone https://github.com/njoy/NJOY2016 cd NJOY2016 mkdir build && cd build cmake -Dstatic=on .. && make 2>/dev/null && sudo make install diff --git a/tools/ci/gha-install-vectfit.sh b/tools/ci/gha-install-vectfit.sh new file mode 100755 index 000000000..bd38e1ea8 --- /dev/null +++ b/tools/ci/gha-install-vectfit.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -ex + +PYBIND_BRANCH='master' +PYBIND_REPO='https://github.com/pybind/pybind11' + +XTL_BRANCH='0.6.13' +XTL_REPO='https://github.com/xtensor-stack/xtl' + +XTENSOR_BRANCH='0.21.3' +XTENSOR_REPO='https://github.com/xtensor-stack/xtensor' + +XTENSOR_PYTHON_BRANCH='0.24.1' +XTENSOR_PYTHON_REPO='https://github.com/xtensor-stack/xtensor-python' + +XTENSOR_BLAS_BRANCH='0.17.1' +XTENSOR_BLAS_REPO='https://github.com/xtensor-stack/xtensor-blas' + +cd $HOME +git clone -b $PYBIND_BRANCH $PYBIND_REPO +cd pybind11 && mkdir build && cd build && cmake .. && sudo make install +pip install $HOME/pybind11 + +cd $HOME +git clone -b $XTL_BRANCH $XTL_REPO +cd xtl && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTENSOR_BRANCH $XTENSOR_REPO +cd xtensor && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTENSOR_PYTHON_BRANCH $XTENSOR_PYTHON_REPO +cd xtensor-python && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTENSOR_BLAS_BRANCH $XTENSOR_BLAS_REPO +cd xtensor-blas && mkdir build && cd build && cmake .. && sudo make install + +# Install wheel (remove when vectfit supports installation with build isolation) +pip install wheel + +# Install vectfit +cd $HOME +git clone https://github.com/liangjg/vectfit.git +pip install --no-build-isolation ./vectfit diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 5488b9547..f4b2fbb31 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -2,15 +2,31 @@ import os import shutil import subprocess +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) -def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False): + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + return None + + +def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrystal=False): # Create build directory and change to it shutil.rmtree('build', ignore_errors=True) os.mkdir('build') os.chdir('build') - # Build in RelWithDebInfo mode by default with support for MCPL - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DOPENMC_USE_MCPL=on'] + # Build in debug mode by default with support for MCPL + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] # Turn off OpenMP if specified if not omp: @@ -31,21 +47,21 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False): if dagmc: cmake_cmd.append('-DOPENMC_USE_DAGMC=ON') - cmake_cmd.append('-DOPENMC_USE_UWUW=ON') - dagmc_path = os.environ.get('HOME') + '/DAGMC' - cmake_cmd.append('-DCMAKE_PREFIX_PATH=' + dagmc_path) + cmake_cmd.append('-DCMAKE_PREFIX_PATH=~/DAGMC') if libmesh: cmake_cmd.append('-DOPENMC_USE_LIBMESH=ON') libmesh_path = os.environ.get('HOME') + '/LIBMESH' cmake_cmd.append('-DCMAKE_PREFIX_PATH=' + libmesh_path) + if ncrystal: + cmake_cmd.append('-DOPENMC_USE_NCRYSTAL=ON') + ncrystal_cmake_path = os.environ.get('HOME') + '/ncrystal_inst/lib/cmake' + cmake_cmd.append(f'-DCMAKE_PREFIX_PATH={ncrystal_cmake_path}') + # Build in coverage mode for coverage testing cmake_cmd.append('-DOPENMC_ENABLE_COVERAGE=on') - # Enable strict FP for cross-platform reproducibility in CI - cmake_cmd.append('-DOPENMC_ENABLE_STRICT_FP=on') - # Build and install cmake_cmd.append('..') print(' '.join(cmake_cmd)) @@ -59,10 +75,11 @@ def main(): mpi = (os.environ.get('MPI') == 'y') phdf5 = (os.environ.get('PHDF5') == 'y') dagmc = (os.environ.get('DAGMC') == 'y') + ncrystal = (os.environ.get('NCRYSTAL') == 'y') libmesh = (os.environ.get('LIBMESH') == 'y') # Build and install - install(omp, mpi, phdf5, dagmc, libmesh) + install(omp, mpi, phdf5, dagmc, libmesh, ncrystal) if __name__ == '__main__': main() diff --git a/tools/ci/gha-install.sh b/tools/ci/gha-install.sh index 4cf62afbb..2cef974d3 100755 --- a/tools/ci/gha-install.sh +++ b/tools/ci/gha-install.sh @@ -14,9 +14,15 @@ if [[ $DAGMC = 'y' ]]; then ./tools/ci/gha-install-dagmc.sh fi -# Install NCrystal and verify installation -pip install 'ncrystal>=4.1.0' -nctool --test +# Install NCrystal if needed +if [[ $NCRYSTAL = 'y' ]]; then + ./tools/ci/gha-install-ncrystal.sh +fi + +# Install vectfit for WMP generation if needed +if [[ $VECTFIT = 'y' ]]; then + ./tools/ci/gha-install-vectfit.sh +fi # Install libMesh if needed if [[ $LIBMESH = 'y' ]]; then @@ -24,7 +30,7 @@ if [[ $LIBMESH = 'y' ]]; then fi # Install MCPL -pip install mcpl +./tools/ci/gha-install-mcpl.sh # For MPI configurations, make sure mpi4py and h5py are built against the # correct version of MPI @@ -34,13 +40,18 @@ if [[ $MPI == 'y' ]]; then export CC=mpicc export HDF5_MPI=ON export HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/mpich - # Install h5py without build isolation to pick up already installed mpi4py - pip install setuptools Cython pkgconfig - pip install --no-build-isolation --no-binary=h5py h5py + pip install wheel "cython<3.0" + pip install --no-binary=h5py --no-build-isolation h5py fi # Build and install OpenMC executable python tools/ci/gha-install.py # Install Python API in editable mode -pip install -e .[test,vtk,ci] +pip install -e .[test,vtk] + +# For coverage testing of the C++ source files +pip install cpp-coveralls + +# For coverage testing of the Python source files +pip install coveralls diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index b40238ffb..9de84f3e5 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -14,8 +14,12 @@ if [[ $EVENT == 'y' ]]; then args="${args} --event " fi -# Run unit tests and then regression tests -pytest -v $args \ - tests/test_matplotlib_import.py \ - tests/unit_tests \ - tests/regression_tests +# Check NCrystal installation +if [[ $NCRYSTAL = 'y' ]]; then + # Change environmental variables + eval $( "${HOME}/ncrystal_inst/bin/ncrystal-config" --setup ) + nctool --test +fi + +# Run regression and unit tests +pytest --cov=openmc -v $args tests diff --git a/tools/dev/generate_release_notes.py b/tools/dev/generate_release_notes.py deleted file mode 100644 index dee46ac49..000000000 --- a/tools/dev/generate_release_notes.py +++ /dev/null @@ -1,17 +0,0 @@ -import argparse -import re -import subprocess - -parser = argparse.ArgumentParser() -parser.add_argument('tag') -args = parser.parse_args() - -proc = subprocess.run(["git", "log", "--format=%s", f"{args.tag}.."], capture_output=True, text=True) -data = [] -for line in proc.stdout.rstrip().split('\n'): - m = re.match(r'(.*) \(\#(\d+)\)', line) - if m is not None: - data.append(m.groups()) - -for comment, num in sorted(data, key=lambda x: int(x[1])): - print(f'- {comment} (`#{num} `_)') diff --git a/vendor/fmt b/vendor/fmt index 0c9fce2ff..d141cdbeb 160000 --- a/vendor/fmt +++ b/vendor/fmt @@ -1 +1 @@ -Subproject commit 0c9fce2ffefecfdce794e1859584e25877b7b592 +Subproject commit d141cdbeb0fb422a3fb7173b285fd38e0d1772dc diff --git a/vendor/gsl-lite b/vendor/gsl-lite new file mode 160000 index 000000000..913e86d49 --- /dev/null +++ b/vendor/gsl-lite @@ -0,0 +1 @@ +Subproject commit 913e86d49c6a1acca980f4e325378f9dc393493a diff --git a/vendor/pugixml b/vendor/pugixml index ee86beb30..41b6ff21c 160000 --- a/vendor/pugixml +++ b/vendor/pugixml @@ -1 +1 @@ -Subproject commit ee86beb30e4973f5feffe3ce63bfa4fbadf72f38 +Subproject commit 41b6ff21c455865bb8ef67c5952b7f895b62bacc diff --git a/vendor/xtensor b/vendor/xtensor new file mode 160000 index 000000000..3634f2ded --- /dev/null +++ b/vendor/xtensor @@ -0,0 +1 @@ +Subproject commit 3634f2ded19e0cf38208c8b86cea9e1d7c8e397d diff --git a/vendor/xtl b/vendor/xtl new file mode 160000 index 000000000..a7c1c5444 --- /dev/null +++ b/vendor/xtl @@ -0,0 +1 @@ +Subproject commit a7c1c5444dfc57f76620391af4c94785ff82c8d6