310 likes | 440 Views
A Pilot Framework for Modern Reactor System Analysis Codes. Haihua Zhao Idaho National Laboratory Email: haihua.zhao@inl.gov 2011 International RELAP5 User's Group Seminar and Meeting July 25-28, 2011 Salt Lake City, Utah. Major Contributors. Vincent Mousseau (original PI, now at Sandia)
E N D
A Pilot Framework for Modern Reactor System Analysis Codes Haihua Zhao Idaho National Laboratory Email: haihua.zhao@inl.gov 2011 International RELAP5 User's Group Seminar and Meeting July 25-28, 2011 Salt Lake City, Utah
Major Contributors • Vincent Mousseau (original PI, now at Sandia) • Glen Hansen (original software architect, now at Sandia) • George Griffith (strategy) • Paul Bayless ( user requirement, validation and test) • Scott Lucas (neutronics models) • Bob Martin ( consulting, now at B&W) • Ling Zou ( heat conduction models, CFD)
Outline • Motivations and goals • RELAP5 capabilities to inherit and extend • Overview of software design • Examples • Path forwards • Conclusions
Motivations • The workforce to support RELAP5 is aging; therefore the knowledge to maintain, improve, and run the code is deteriorating. • R7, supported by LWRS and LDRD, is a research project with the long term goal of creating and implementing RISMC. • There is a need for a modern software framework (R6), with early/middle career engineers to support it, that captures the RELAP5 capability and preserves its knowledge base. • This project will focus on quickly capturing RELAP5 capability while providing a quality production software framework to implement the research of R7.
Goals • Modern software engineering that enables an easy and scalable development environment. • Using modern numerical methods that utilize the horse power of modern computers and decades of research on solution methods. • Providing a bridge between High Performance Computing and the nuclear reactor thermal hydraulics. • Providing the foundation for future reactor safety production code development.
RELAP5 Capabilities to Inherit • Breadth of capabilities - it is easy to do one of the many things RELAP5 does better; it is this breadth of capabilities that makes it one of the most used system codes for reactor safety world wide. • Extensive knowledge based on 2 billions dollars of experimental research, such as closure laws for single phase and two-phase flow, flow regimes models, special process models, and physical properties for fluids and solids. • Six equation two phase flow model, staggered grid, finite volume “like” discretization. • Others ...
RELAP5 Capabilities to Extend • Modern software structure based on Object Oriented Programming paradigm: • easy to develop, maintain, and improve, scalable • easy to couple with other modern codes • Modern numerical methods based on parallel nonlinear solvers: • implicit vs. semi implicit: long transient, mass error • tight coupling vs. loose coupling: multi-physics problems • parallel vs. serial • Improved or extended physics models: • remove inconsistent models • add new higher dimensional models for large volumes
Overview of Software Design Solver and Input Processing Based on Trilinos More stable Interface between Trilinos and a component class Abstract component interface EOS Closures The center goal is to form residual vector Concrete components Component developers can reuse or write their own models Parameters Equations Stencils Different grid and spatial discretization methods can be mixed here Terms
Trilinos as the Computational Engine for R6 • Trilinos is a modern parallel, linear and nonlinear solver package developed at Sandia National Lab. • Comparing to other popular solver packages, like PETSC from ANL and Sundials from LLNL, Trilinos is the newest one with full support of OOP. • Open source. • Large user base. • Input processing capability. • Additional capabilities like sensitivity analysis and uncertainty quantification.
Solver Technology: Jacobian-free Newton-Krylov nonlinear solver (JFNK) • Time step loop (number of time steps or final time) • Nonlinear iteration (number of nonlinear iterations or nonlinear convergence criteria) • Preconditioner initial guess • Linear iteration (number of linear iterations or linear convergence criteria) • Preconditioner (RELAP5 solution) Choosing different nonlinear and linear iterations provides a variety of solvers that can be optimized to purpose (speed vs. accuracy)
Component Design • Component contains a vector of state variables and functions to form and update residuals vector. • Boundary information is passed between components through an interface function. • No other component needs to know about your grid, spatial discretization, or residual equations. • Coupling information through the JFNK solver. // Here is the base Component interface that all children must implement virtual void initialState(std::map<std::string, Component *> ComponentMap, std::vector<double> &initial) = 0; virtual void updateComponent(const double *soln, const double *oldsoln) = 0; virtual void evaluate(std::vector<double> &rhs, const double *soln, const double *oldsoln) = 0; virtual Teuchos::RCP<IntFunc> exchPtrIntFunc(std::string end, IntFunc *GlueInterfaceFunc) = 0; virtual void PrintSolution(int &cnt, std::ofstream &output) = 0; virtual const double getDx() = 0; virtual int ndofs() = 0; virtual const std::string getName() = 0;
Two Types of Template Components • Assuming a staggered grid finite volume “like” discretization. • Glue – components with momentum equations on the end. • Phys – components with mass and energy equations on the end. • This is a generalization of the RELAP5 pipe and single junction. • Phys components connect to Glue components. Overall component hierarchy
Pipe Class Hierarchy PipeBase PipeT No of Eqs: 2Mass, Mom PipeErgBase PipeErgT No of Eqs: 3Mass, Mom, Erg WallPipeBase WallPipeT No of Eqs: 4Mass, Mom, Erg, Solid conduction CorePipeT No of Eqs: 6Mass, Mom, Erg, Solid conduction2 Neuron Eq. SteamGenTNo of Eqs: 72 sets of Mass, Mom, Erg, Solid conduction
Other Structures • ComponentParams: check and store input parameters for each concrete component. • Equations and Terms: equations are built from terms; grid independent. • Stencils: process grid dependent information for the equation terms to use. • EOS and Closure classes: • Fluid and solid material properties • Friction, wall and interface • Heat transfer, wall and interface • Mass transfer
Software working environment and quality control • Whole open source working environment: • Linux system • Trilinos • SVN: version control and repository • lcov: line coverage testing (near 100% no unused software) • valgrind: memory leak detection • Zero cost to collaborators • Export controlled or proprietary models employ the same interfaces as the open source part and can be easily managed. • Regression tests: 15 and keep growing, 90% line coverage
One Example: A Simple Reactor Loop System TypATR input deck built by Paul Bayless. Snapshot of input deck
Path Forward • Capture the existing RELAP5 capabilities step by step by adding models and functions for more transients of more types of reactors. • Start with ATR steady state • Add single-phase ATR transients • Add two-phase ATR transients • Add transients for other reactors • Address current problems in RELAP5 • Reduce uncertainty by new numeric methods and better physics
Path Forward • Near term efforts (6 months): • Refining the framework, such as optimizing structures, enhancing input/out processing and adding other utilities. • Adding more components models and closure models. • Adding control system models. • Establishing collaboration with Sandia, which can contribute the development with their expertise in Trilinos and advanced numeric methods, such as parallel computing, preconditioning, uncertainty qualification and optimization.
Path Forward • Midterm efforts (6 months to 2 years): • Adding a general 6-equation 2-phase flow model. • Adding water steam EOS and two phases closure models. • Adding multi-dimensional models for large volumes such as containment space. • Refining code structures. • Training users, V&V the code, and applying the code for selected transients. • Improving numerical methods.
Path Forward • Long term efforts: • Based on the success of R6, developing a new production version of RELAP. • Testing new nearly matured methods and models with the R6 framework. • Combing R6 and matured R7 research into one system.
Conclusions • This project aims at creating a new production software foundation that can grow and improve in the future, based on low risk matured new techniques in software engineering, advanced numerical methods and successfully validated physical models. This is different from those high risk projects working on new cutting-edge methods. • The first goal is to capture the capabilities of current codes like RELAP5 and to encapsulate the knowledge to validate, improve, and run the existing codes (hold ground). • The project also aims at providing a good framework to harvest low hanging fruits in the related research areas and allow efficiently testing new capabilities (grow).
Component Makeup • Initialization – load the components local time zero information into the state vector. • Update – load the state vector into the components local variables. • Boundaries – exchange boundary information with neighboring components. • Evaluate – load the r.h.s. vector with the residuals evaluated with the updated state vector and boundary information.
Preconditioning • Consistent Physics-Based Preconditioning • The RELAP5 operator split (neutronics and thermal conduction) semi-implicit algorithm is the basis of the preconditioner. • The preconditioner uses the same spatial discretization as the nonlinear residuals. • Instead of linearizing about the last time level, the operator split and semi-implicit algorithms are linearized about the last nonlinear iteration. • This provides a fully coupled, fully implicit version of RELAP5 by adding a nonlinear iteration.
Equations • First partition into transient term and steady state term. The steady state equation can then be solved directly when needed (pseudo transient, continuation methods, dynamic time scale) • This enables higher order in time methods. • Two Steady State Equations
Equations These two equations generalize to 3-D and 2 phase. Spatial accuracy can be improved with more accurate fluxes and forces.
Mass Error • Damp void fraction change to prevent over shoot and under shoot • Implicit solution to remove 2 ∆t instabilities • Nonlinear iteration removes mass error caused by linearization of the equation of state
Ill posed & phase appearance disappearance • Mixture mass • Mixture momentum • Mixture energy • Drive disappearing phase to saturation