This chapter summarizes previous efforts in numerical simulations of prismatic HTGRs.
The simulation of prismatic HTGRs require the coupled modeling of the neutronics and thermal-fluid phenomena.
This chapter comprises the following sections: Section \ref{sec:litreview-neut} addresses diffusion methods for solving the neutronics, Section \ref{sec:litrev-thermalf} focuses on the thermal-fluids, and Section \ref{sec:litreview-multi} studies the coupled simulations.

\section{Prismatic HTGR Diffusion Solvers}
\label{sec:litreview-neut}

Currently, several software programs solve the neutronics of prismatic \glspl{HTGR}.
Most of these programs rely on one of the following methods: stochastic transport (Monte Carlo), deterministic transport, or deterministic diffusion.
This section focuses on the last class.
% If time permits work on a brief description of the Monte Carlo and deterministic transport maybe.
% Why? Deterministic diffusion solvers have lower computational requirements than other methods reference ??
% The utilization of the Monte Carlo codes is unattractive because of the tremendous problem size and the need for a large number of neutron histories \cite{lee_status_2006}.
% It is one of the simplest means to solve neutron transport problems \cite{leppanen_development_2007}.
% Here I say the following
% Deterministic diffusion methods are computationally cheaper than the other methods.
% This characteristic makes it a good candidate for coupled calculations.

The history of deterministic diffusion solvers began in the late 1950s with the \gls{FDM} application to the analysis of \glspl{LWR}.
In \gls{FDM}, mesh spacings are usually of the order of the diffusion length.
While solving large multi-dimensional problems, this feature causes the mesh points to reach intractable numbers \cite{lewis_finite_1986}.
The computational expense of these calculations motivated the generation of more computationally efficient techniques \cite{lawrence_progress_1986}.
Although substantial overlaps exist, the most common techniques fall into two broad categories: nodal methods and \gls{FEM}.

% NODAL
FLARE \cite{delp_flare_1964} is a three-dimensional \gls{BWR} simulator, and it is representative of the first generation of nodal methods.
This approach used adjusted parameters to match actual operating data or the results of more accurate calculations.
Most of these methods were implementations of the so-called "1.5 group theory" \cite{gupta_nodal_1981}.
The second generation of nodal methods derived spatial coupling relationships by applying the \gls{TIP}.
This procedure obtains equivalent one-dimensional equations by integrating the multi-dimensional diffusion equation over directions transverse to each coordinate axis \cite{lawrence_progress_1986}.
This approach proved to be highly efficient and accurate in Cartesian geometries.

In 1981, a formulation based on the \gls{NEM} first demonstrated the feasibility of nodal methods in hexagonal geometries \cite{duracz_nodal_1981}.
However, this method would introduce non-physical singular terms that required the utilization of discontinuous polynomials.
This drawback motivated the development of more effective formulations.
HEXNOD, introduced in 1988 by Wagner \cite{wagner_three-dimensional_1989}, is an example of such formulations.
This algorithm uses the \gls{TIP} and, in contrast to the \gls{NEM}, solves the resulting differential equation analytically.
Wagner's article demonstrated the method's good accuracy by comparing to \gls{FDM} and Monte Carlo calculations for a few benchmark problems.

HEXPEDITE \cite{fitzpatrick_hexpedite_1992} introduced a new method that is another example of more effective formulations.
HEXPEDITE uses the \gls{TIP} formulation to derive a pseudo-one-dimensional equation.
The resulting differential equation is solved analytically.
The difference from HEXNOD is that HEXPEDITE uses a simpler and more efficient coupling scheme.
Different works \cite{fitzpatrick_hexpedite_1992}\cite{fitzpatrick_developments_1995} on the HEXPEDITE methodology tested the approach against the \gls{NEM} and the \gls{FDM}.
These studies established HEXPEDITE’s superiority in terms of accuracy and runtime.
HEXPEDITE's use prevailed in the analysis of \glspl{HTGR} until recently.
In 2010, \gls{INL} conducted a study \cite{ortensi_deterministic_2010-1} in which they compared HEXPEDITE's results against several diffusion solvers, as well as the Monte Carlo solvers MCNP5 \cite{x-5_monte_carlo_team_mcnp_2003} and Serpent \cite{leppanen_serpent_2015}.

DIF3D \cite{lawrence_dif3d_1983} and PARCS \cite{downar_parcs_2004} are other examples of prevalent nodal diffusion tools.
DIF3D has several solution options, such as the diffusion \gls{FDM}, diffusion \gls{NEM} based on \gls{TIP}, and the VARIANT nodal transport method.
% VARIANT: variational nodal \cite{palmiotti_variant_1995}
PARCS has several solution options as well, such as a diffusion \gls{FDM}, diffusion \gls{NEM} based on \gls{TIP}, and the multi-group transport simplified P$_3$ with \gls{FDM} and \gls{NEM} discretizations.

% from ortensi_deterministic_2010-1 and wang_modified_2018
Nodal methods solve relatively coarse meshes for approximate solutions.
This characteristic makes the process efficient.
On the other hand, the method does not provide detailed point-wise accurate solutions without flux reconstruction methods \cite{kang_finite_1973} \cite{boeer_fast_1992}.
Additionally, the derivation of nodal methods happens in a specific coordinate system for a particular node shape.
The application to complex problems is not flexible as different geometries require customized configurations.
This lack of flexibility limits the applications of nodal methods to regular geometries only.

% FEM
% Moltres is a diffusion FEM application.
The FEM is a well-established method in applied mathematics and engineering.
FEM is a numerical technique for finding approximate solutions to partial differential equations by deriving their weak or variational form.
Most applications make \gls{FEM} preferable due to its flexibility in the treatment of curved or irregular geometries.
Also, the use of high order elements attains higher rates of convergence \cite{cavdar_finite_2004}.
The first engineering application of \gls{FEM} was in the field of structural engineering, dating back to 1956.
In successive years, \gls{FEM} became the most extensively used technique in almost every branch of engineering.
\glspl{FEM} have several advantages over the nodal methods.
It provides flexibility in the geometry definition, a firm mathematical basis, ease in extension to the multi-group application, and detailed point-wise accurate solutions \cite{lee_development_2008}.

In 1973, Kang et al. \cite{kang_finite_1973} described the first application of \gls{FEM} to neutron diffusion theory.
The fundamental motivation for this development was the impractical application of the \gls{FDM} to three-dimensional problems.
In this early work, the author compared different \gls{FEM} approaches to the \gls{FDM} in one-dimensional and two-dimensional problems.
The studies showed a higher order of convergence achieved by the \gls{FEM}.
Throughout the last four decades, many software programs utilized the \gls{FEM} to solve the diffusion equation.
Some of the most recent software for diffusion simulations are CRONOS2 \cite{lautard_cronos_1990}, \gls{CAPP} \cite{lee_development_2011}, and Rattlesnake \cite{wang_rattlesnake_2019}.
The list of \gls{FEM} diffusion solvers is more extensive, but this thesis focuses on the best-documented software in the open literature.

% CRONOS
\gls{CEA} developed CRONOS2 \cite{lautard_cronos_1990} as part of the SAPHYR system.
CRONOS2 conducts steady-state and transient multi-group calculations, based on the diffusion equation or the transport equation using the S$_N$ method and an FDM or a FEM discretization.
In 2008, Damian et al. \cite{damian_vhtr_2008} presented the code suite NEPTHIS\cite{cavalier_presentation_2005}/CAST3M\cite{studer_cast3marcturus_2007}, software that relied on CRONOS2.
Section \ref{sec:litreview-multi} describes further the coupling scheme.

% CAPP
In 2008, the \gls{KAERI} published an article \cite{lee_development_2008} that presented CAPP.
Its purposes are to conduct steady-state core physics analysis, core depletion analysis, and core transient analysis.
The article validated the software with two benchmark problems: the IAEA PWR benchmark problem, and Phase I Exercise 1 of the OECD/NEA PBMR-400 Benchmark \cite{reitsma_oecd-neansc_2008}.
In 2011, Lee et al. published an article \cite{lee_development_2011} that extended CAPP's functionalities to prismatic HTGRs.
To validate CAPP, they had to integrate a simplified thermal-fluids tool into the software.
Section \ref{sec:litreview-multi} describes the thermal-fluids tool and the coupling scheme.

% Proghorn and Rattlesnake
RattleSnake \cite{wang_rattlesnake_2019} is the MOOSE \cite{gaston_moose_2009} based application for simulating the transport equation.
\gls{INL} had initially developed Pronghorn \cite{novak_pronghorn_2018} to model \glspl{PBMR} \cite{strydom_inl_2013}.
The MOOSE neutronics kernel library Yak incorporated the neutron diffusion models initially in Pronghorn.
Currently, RattleSnake is the primary tool for solving the linearized Boltzmann neutron transport equation within MOOSE and relies heavily on Yak.
Various solvers are available under RattleSnake, including low-order multi-group diffusion, spherical harmonics transport, and discrete ordinates transport, all solved with the \gls{FEM}.
% Both RattleSnake and Pronghorn yielded the same exact results when using the continuous \gls{FEM} multigroup diffusion option in RattleSnake.

% strydom_inl_2013
In 2013, \gls{INL} conducted the OECD/NEA MHTGR-350 Benchmark \cite{oecd_nea_benchmark_2017}\cite{strydom_inl_2013} without further simplifications.
The \gls{INL} team solved Phase I Exercise 1 using INSTANT-P1 \cite{wang_krylov_2011}, Pronghorn, and RattleSnake.
INSTANT-P1 is a transport solver that relies on the spherical harmonics discretization of angles.
The results for Pronghorn and RattleSnake were identical, and all presented results exhibited good agreement with the benchmark results.

\subsection{Energy group structure analysis}
\label{sec:energy-struct}

% Number of energy groups impact over the calculations
In the context of this thesis, Moltres uses homogenized group constants previously generated by neutron transport solvers.
The choice of the energy group structure for the group constant homogenization affects the diffusion calculation accuracy.
The longer neutron mean free path in \glspl{HTGR} compared to \gls{LWR} increases the spectral interactions between elements.
For this reason, HTGR analyses require more energy groups than conventional \gls{LWR} analyses.
This section summarizes previous studies on the impact of the energy group structure over the diffusion calculations.

\gls{ANL} directed a study \cite{lee_status_2006} to compare the accuracy of nodal diffusion calculations employing different energy group structures.
The group constant homogenization used the DRAGON neutron transport solver, and the diffusion calculations utilized the application DIF3D.
For the study, the ANL team implemented a one-dimensional fuel-reflector model in which they compared the solution accuracy using 4, 7, 8, 14, and 23 energy groups.
They also used alternative energy group structures for the same number of groups.
For simplicity, the authors used the homogenized fuel compact model and generated all the group constant at 300 K.
One of their conclusions was that the number of energy groups should be more than four, and more than six would be sufficient for uranium fueled HTGRs.
Another finding was that the accuracy of the diffusion calculation is sensitive to the energy group boundaries.
% Mention something about the metrics of the study? To asses the accuracy, they compared the multiplication factor.

% \begin{figure}[htbp!]
% 	\centering
% 	\includegraphics[width=0.40\linewidth]{figures/spectrum}
% 	\caption{Comparison of neutron energy spectra of different reactor designs. PWR=Pressurized Water Reactor, VHTR=Very High-Temperature Gas-Cooled Reactor, SCWR=Supercritical Water Reactor, SFR=Sodium Fast Reactor, GFR=Gas Fast Reactor, LFR=Lead Fast Reactor. Image reproduced from \cite{taiwo_summary_2005}.}
% 	\label{fig:spectrum}
% \end{figure}

% han_sensitivity_2008
Han's MS thesis \cite{han_sensitivity_2008} focused on selecting energy groups for the reactor analysis of the \gls{PBMR}.
The author used COMBINE6 \cite{grimesey_combinepc-portable_1990} for group constant generation and the Penn State nodal diffusion tool NEM \cite{bandini_three-dimensional_1990} for the reactor analysis.
The author compared the results against MCNP5 reference results.
To simplify the setup, the model used uniformly distributed isotopes in the fuel.
The study performed the calculations at 300 and 1000 K.
To arrive at an optimal group structure, the author compared many combinations of group structures using a trial and error strategy.
One conclusion of this work agrees with the previous bibliography \cite{merrill_nuclear_1973} \cite{duderstadt_nuclear_1976} in that the energy spectrum is critical to yield an accurate description of a nuclear reactor using a few groups.

ANL's study helps set up proper nodal diffusion calculations for an \gls{HTGR}.
ANL's team conducted the study at 300 K --- not in the operational range of any \glspl{HTGR}.
On the contrary, Han's thesis included an analysis at 1000 K, and his results showed that the temperature changes have a non-negligible impact.
Additionally, ANL's study used the simplified model of the homogenized fuel compact.
Han highlighted that homogenized fuel models of the \gls{PBMR} underestimate criticality calculations.
In 2015, \gls{INL} presented their results \cite{strydom_results_2015} for an \gls{IAEA} coordinated research project \cite{tyobeka_htgr_2011} and showed that the homogenization of the compact material notably underestimates the multiplication factor.
On the other hand, the open literature has not widely investigated the impact of such simplification over the homogenized group constants.

\subsection{Summary of Prismatic HTGR Diffusion Solvers}

Section \ref{sec:litreview-neut} introduced several deterministic diffusion classes, including FDM, nodal methods, and FEM.
The fundamental motivation for the development of nodal methods and FEM was the impractical application of the \gls{FDM} to three-dimensional problems.
Section \ref{sec:litreview-neut} also discussed the main characteristics of these methods, directing the reader's attention to the advantages of the FEM.
Although nodal methods are efficient, most applications make FEMs preferable due to their flexibility in the treatment of irregular geometries.
Additionally, FEMs have a firm mathematical basis, and its formulation eases the extension to multi-group applications.
Moltres relies on the FEM, counting with all the advantages of the method.

Section \ref{sec:litreview-neut} summarized previous efforts in deterministic diffusion solvers of prismatic HTGRs.
This thesis draws two main conclusions from those earlier efforts.
The first conclusion is that several authors validated their solvers by comparison to other tools.
In the context of this thesis, Chapter \ref{ch:neutronics} describes two exercises: first, a comparison between Moltres and Serpent-derived results, and second, a comparison between Phase I Exercise 1 of the OECD/NEA MHTGR-350 Benchmark results calculated by Moltres and the benchmark's published results.
The second conclusion is that several prismatic HTGR simulators integrate thermal-fluids solvers.
Due to strong thermal feedback, modeling prismatic HTGRs with Moltres requires incorporating a thermal-fluids solver.
Section \ref{sec:litrev-thermalf} discusses previous work in the thermal-fluids modeling of prismatic HTGRs.

% energy group study
Section \ref{sec:energy-struct} outlined the importance of the right choice of energy group structure for group constant homogenization.
Diffusion calculations use homogenized group constants previously generated by neutron transport solvers.
Previous studies focused on nodal diffusion calculations of HTGRs.
% Although further analyses can extrapolate those studies' conclusions to FEM diffusion calculations, such an analysis might be valuable to this thesis.
% Although further analyses can extrapolate those studies' conclusions to FEM diffusion calculations, such an analysis might be valuable to this thesis.
Although these previous studies' conclusions can be extrapolated to FEM diffusion calculations, this type of analysis might be valuable to this thesis.
Chapter \ref{ch:neutronics} studies the accuracy of Moltres diffusion calculations for multiple energy group structures.

\section{Prismatic HTGR Thermal-fluids}
\label{sec:litrev-thermalf}

% sort of motivation
This section of the literature review summarizes previous work on the thermal-fluids modeling of prismatic HTGRs.
Thermal-fluid calculations enable the correct design of \glspl{HTGR}.
Predicting the maximum fuel temperature at steady-state is of paramount importance to succeed in that task.
I emphasize this statement in the case that hydrogen production is desirable, as that process requires higher coolant temperatures, leading to high fuel and reactor vessel temperatures.
This literature review analyzed several approaches that helped to choose a thermal-fluids model to implement in Moltres simulations.

% sort of intro to simplified models
The complex geometry of the hexagonal fuel assembly requires numerical calculations for obtaining accurate evaluations \cite{tak_numerical_2008}.
Thermal-fluids studies for early \glspl{HTGR} consisted mainly of support calculations for \gls{NRC} safety analysis reports.
The analyses employed sets of independent solvers that relied on simplified approximations.
Simplified models help understand some fundamental aspects of prismatic HTGRs and have the advantage of reducing the computational expense of the calculations.

% shenoy_htgr_1974
General Atomics \cite{shenoy_htgr_1974} developed the first set of software libraries that relied on simplified approximations.
The following list introduces and summarizes some of these and their features:

\begin{itemize}
\item FLAC: It determines the coolant flow distribution in the coolant channels and gaps.
It solves the one-dimensional momentum equation for incompressible flow and the continuity equations for mass and energy.

\item POKE: It determines the coolant mass flow, coolant temperature, and fuel temperature distribution.
It solves the steady-state mass and momentum conservation equations for parallel channels.

\item DEMISE: It determines the steady-state three-dimensional temperature distribution in a standard element.
It solves the temperature in a network model.

\item TAC2D: It is a general-purpose thermal analysis software.
It solves the two-dimensional heat conduction equation.
\end{itemize}

Several studies have used these software programs.
% macdonald_ngnp_2003
For example, \gls{INL} conducted in 2003 a design study \cite{macdonald_ngnp_2003} in support of the \gls{NGNP} project.
The authors conducted several parametric studies on the GT-MHR \cite{poiter_gas_1996}, with the objective of increasing the coolant temperature.
Using POKE and TAC2D, they evaluated three major design modifications: reducing the bypass flow, controlling the inlet coolant flow distribution, and increasing the reactor's height.

This thesis differentiates the \textit{flow network}, \textit{equivalent cylindrical}, and \textit{unit cell} models among the simplified approaches.
The flow network model treats the coolant flow paths in the core as a cross-connected flow network \cite{shenoy_htgr_1974}.
Constant pressure nodes connected to flow branches make up the network.
The model uses the one-dimensional conservation equations to solve the pressure loss and coolant temperature in each network node.
The equivalent cylinder model uses a geometrically simpler one-dimensional or two-dimensional design model \cite{shenoy_htgr_1974}\cite{tak_numerical_2008}.
The unit cell model divides the fuel blocks into triangular-shaped unit cells.
The model assumes that the coolant removes all the heat generated in the cell \cite{tak_numerical_2008}.

% flow network model
% reza_design_2006
Using the flow network analysis tool RELAP5-3D/ATHENA \cite{riemke_relap5-3d_2005}, Reza et al. \cite{reza_design_2006} conducted a thermal-fluids study of the GT-MHR.
Reza et al. increased the reactor outlet temperature to enable hydrogen production.
Additionally, they evaluated alternative inlet coolant flow configurations in an attempt to reduce the reactor vessel temperatures.
After finding an optimal configuration, they assessed the fuel and the reactor vessel's maximum temperatures during the \gls{LPCC} and the \gls{HPCC} events.

% equivalent cylindrical model
% no_multi-component_2007
An example of an application using the equivalent cylindrical approach is GAMMA \cite{lim_gamma_2006}\cite{no_multi-component_2007}, a system thermal-fluids analysis tool.
GAMMA's primary motivation is simulating the air ingress event following a LOCA.
Following the depressurization of helium in the core, air could enter the core through the break and oxidize the in-core graphite structure.
Graphite oxidation is an exothermic chemical reaction and, thus, it is a significant concern.
GAMMA solves heat conduction, fluid flow, chemical reactions, and multi-component molecular diffusion.
Together with a multi-dimensional analysis feature, GAMMA has a one-dimensional analysis capability for  modeling a flow network.

% takada_core_2004
Takada et al. \cite{takada_core_2004} carried out another study using the flow network and the equivalent cylindrical model.
They developed a thermal-fluids design tool for modeling the \gls{HTTR}.
This tool used the flow network analysis software FLOWNET \cite{maruyama_verification_1989} for calculating the coolant flow and temperature distributions.
TEMDIM \cite{maruyama_verification_1989} solved the fuel temperatures using the equivalent cylindrical model.
Finally, the authors validated the calculation scheme by comparing its results with the experimental data from the \gls{HTTR}.

% unit cell model
% nakano_conceptual_2008
Nakano et al. \cite{nakano_conceptual_2008} studied different fuel assembly configurations using several simplified approximations.
The authors used FLOWNET and TAC2D for determining the flow distribution and fuel temperature.
The fuel temperature calculation used the equivalent cylindrical model of a unit cell.
However, the unit cell's asymmetry makes the temperature distribution asymmetric in the graphite block, behavior that the equivalent cylindrical model fails to capture.

% in_three-dimensional_2006
In 2006, In et al. \cite{in_three-dimensional_2006} conducted a more detailed analysis using a three-dimensional model of the unit cell in the hot-spot of the GT-MHR 600, spot in the core with the largest power density.
The study predicted the maximum fuel temperature at steady-state at the end of the equilibrium cycle.
The \gls{CFD} software CFX 10 \cite{ansys_cfx_2005} calculated the three-dimensional temperature profile.
The results showed that the maximum fuel temperature surpassed the design limits, so the authors proposed decreasing the power density or the axial power peak as countermeasures.

% more detailed calculations
Previous work used simplified approaches to evaluate different aspects of prismatic HTGRs.
Some of those evaluations include thermal-fluids design, analysis of alternative coolant flow configurations, and accident analysis.
Such simplified approaches are helpful to understand essential aspects of prismatic HTGRs but may yield inaccurate temperature distributions \cite{tak_numerical_2008}.
More detailed thermal-fluids evaluations were rare in the open literature until the last 15 years.
This thesis summarizes some of those evaluations down below.

% tak_numerical_2008
In 2008, an article by Tak et al. \cite{tak_numerical_2008} conducted a three-dimensional CFD analysis of a fuel column of the PMR600, a pre-conceptual reactor designed by \gls{KAERI} whose reference design is the GT-MHR.
The commercial software CFX 11 \cite{ansys_cfx_2006} performed the calculations.
The study considered a $1/12^{th}$ section of the fuel due to its symmetry.
Using the one-dimensional thermal-fluid equations, the model determined the coolant distribution, which served as input to CFX.
However, the friction in the channels is dependent on the viscosity, which is highly dependent on the temperature.
Therefore, obtaining the mass flow rates from a separate solver may introduce errors \cite{sato_computational_2010}.

% sato_computational_2010
Another article \cite{sato_computational_2010} studied a $1/12^{th}$ section of the fuel column of the GT-MHR with the commercial tool FLUENT \cite{fluent_fluent_2006}.
The authors conducted parametric studies of several factors, such as bypass-gap width, turbulence model, axial heat generation profile, and geometry changes due to irradiation.
In this study, FLUENT obtained the coolant distribution as part of the solution.
Their most relevant results showed that the bypass flow caused a large lateral temperature gradient in the block.
Large temperature gradients cause excessive thermal stresses, which raise potential structural issues.

% travis_thermalhydraulics_2013
Despite the recent developments in CFD tools, a detailed full-core analysis of prismatic HTGRs still requires a tremendous computational expense.
This requirement is mostly due to the three-dimensional CFD modeling of the coolant flow.
This drawback motivated the implementation of simplified methods that reduce the computational time and memory requirements while maintaining accurate results.
Such methods combine the accuracy from CFD tools and the light computational expense of system analysis approaches.

% cioni_3d_2005
Cioni et al. \cite{cioni_3d_2005} presented an article in 2005 in which they conducted three-dimensional simulations of HTGR fuel assemblies.
The study's objective was to investigate the blockage of cooling channels in the core.
They used the thermal-fluids tool Trio\_U \cite{bieder_priceles_2000} to carry out the calculations.
The numerical scheme solved the three-dimensional conduction equation in the solid coupled to the coolant's one-dimensional thermal-fluid equations.
The one-dimensional thermal-fluid approximation does not resolve the boundary layer avoiding finer meshes near the walls as well as turbulence conservation equations \cite{tak_development_2014}.
Their results showed that the blockage increased the blocked fuel assembly's temperature only and did not affect the surrounding elements due to the bypass flow.
This study proves the importance of the modeling of the bypass flow.

Travis et al. \cite{travis_thermalhydraulics_2013} presented a comparison between a simplified method and detailed CFD simulations.
Their method solved the three-dimensional heat conduction equation in the solid and the one-dimensional thermal-fluid equations in the coolant channels.
The method's validation analyzed a fuel column and compared the results to those of a three-dimensional CFD simulation using the commercial software STAR-CCM+ \cite{cd-adapco_star-ccm_2012}.
Their simplified scheme reduced the computation time to 2.5\% of the CFD simulation time.
Overall, the method showed good accuracy and less than a 2\% difference to the CFD simulation.

% simoneau_three-dimensional_2007
Simoneau et al. \cite{simoneau_three-dimensional_2007} analyzed the transient behavior of an \gls{HTGR} during the \gls{DCC} and \gls{HPCC} event.
The CFD tool STAR-CD \cite{cd-adapco_star-cd_2004} performed the calculations using the porous media model \cite{nield_convection_1999} to accommodate the different spatial scales.
STAR-CD solved the conductive, convective, and radiation heat transfer in a $1/12^{th}$-section of the core and reactor vessel.

% tak_practical_2012 / tak_development_2014
Tak et al. \cite{tak_practical_2012} \cite{tak_development_2014} developed the thermal-fluids tool CORONA.
CORONA solves the three-dimensional heat conduction equation in the solid and the one-dimensional thermal-fluid equations in the coolant.
To validate CORONA, the authors analyzed a fuel column and compared their results against the CFD tool CFX and experimental results.
The validation results showed that CORONA provided reasonably accurate results.

\subsection{Summary of Prismatic HTGR Thermal-fluids}

Section \ref{sec:litrev-thermalf} summarizes previous work on the thermal-fluids modeling of prismatic HTGRs.
Early studies relied on simplified approximations to carry out the simulations.
These approaches may yield inaccurate temperature distributions requiring more accurate methods, such as CFD techniques.
Although CFD techniques compute detailed temperature profiles, their fine mesh requirement restricts the use of such methods to studies of the local behavior of a single fuel column.
However, a whole-core thermal analysis has many advantages over local models.
In general, the problem setup includes more accurate boundary conditions.
For example, without whole-core modeling, the local models' mass flow distributions are average values of the core flow rate instead of their exact value \cite{huning_novel_2016}.
This simplification leads to under-predicted fuel temperatures for the assemblies with a lower flow rate than the average.
Additionally, a coupled analysis with a reactor physics tool requires a full-core model \cite{tak_practical_2012}.
An alternative for an explicit whole-core analysis are approaches that combine the accuracy from CFD tools and the light computational expense of system analysis applications.

CFD analyses' high computational expense is mostly due to the three-dimensional CFD simulation of the coolant flow \cite{travis_thermalhydraulics_2013}.
Section \ref{sec:litrev-thermalf} presents two alternatives: the porous media model or the combination of the three-dimensional heat conduction equation for the solid structures to the one-dimensional thermal-fluid conservation equations for the coolant.
Due to the more extensive use of the second alternative in the open literature, this thesis focuses on it.
Chapter \ref{ch:thermalfluids} studies the implementation of this alternative in Moltres for studying the thermal-fluids of prismatic HTGRs.

\section{Prismatic HTGR Multi-physics}
\label{sec:litreview-multi}

% sort of intro
Historically, stand-alone simulations have solved the neutronics and thermal-fluids of HTGRs separately.
Nonetheless, these physical phenomena rely heavily on one another.
Hence, a coupled analysis is necessary to consider the interaction between the neutronics and thermal-fluids behavior \cite{tak_cappgamma_2016}.

% damian_vhtr_2008
In 2008, Damian et al. \cite{damian_vhtr_2008} studied the passive safety features of a prismatic HTGR using the coupled software NEPTHIS/CAST3M\cite{cavalier_presentation_2005}\cite{studer_cast3marcturus_2007}.
The study analyzed a three-dimensional core model using the software libraries NEPTHIS and CAST3M/Arcturus for calculating the neutronics and the thermal-fluids, respectively.
NEPHTIS used a transport-diffusion calculation scheme that relied on the transport application APOLLO2 \cite{loubiere_apollo2_1999} and the diffusion application CRONOS2.
CAST3M/Arcturus solved the thermal-fluids using the porous media model.
The authors conducted several parametric studies, including the variation of the bypass flow, the average power density, the core geometry, and fuel loading strategy.

% CAPP
In 2011, Lee et al. published an article \cite{lee_development_2011} in which they extended the functionalities of CAPP to prismatic HTGRs.
To consider the thermal feedback, the authors integrated into CAPP a simplified thermal-fluids tool based on Stainsby's approach \cite{stainsby_investigation_2008}.
This approach uses different length scale models to solve the temperature distribution.
The model divided a fuel column into six triangular prisms, each of them hosting a representative coolant channel, to calculate the axial coolant temperature distribution.
The coolant temperature served as input to a two-dimensional conduction model that solved the moderator and fuel compact temperatures.
Through a TRISO particle conduction model, the model obtained the fuel temperature.
Finally, a three-dimensional conduction model based on the \gls{FDM} calculated the reflector temperature.
To validate this model, the authors solved a two-dimensional model of the PMR-200 and compared the results against HELIOS \cite{casal_helios_1998}.

% tak_cappgamma_2016
Tak et al. \cite{tak_cappgamma_2016} coupled CAPP and GAMMA+.
GAMMA uses the one-dimensional form of the mass, momentum, energy, and species conservation equations to solve the fluid's flow and temperature distribution.
For solids, it uses three different models: (1) heat conduction model of a TRISO particle, (2) implicit coupling to consider the heat exchange between a fuel compact and TRISO particle, and (3) multi-dimensional heat conduction model of the hexagonal fuel and reflector blocks.
In this study, the authors applied the coupled software to study the steady-state performance of the PMR-200.
Some of their most relevant results revealed that neglecting the bypass flow decreased the active core temperatures; consequently, the multiplication factor increased by approximately 300 pcm.
These results prove the importance of the right modeling of the thermal-fluids in coupled simulations of prismatic HTGRs.

% yuk_time-dependent_2020
A recent article by Yuk et al. \cite{yuk_time-dependent_2020} added to CAPP the capability to conduct transient analyses.
This capability solved the time-dependent neutron diffusion equation with the \gls{FEM}.
The primary motivation behind this feature was to perform reactivity insertion accident simulations.
To take into account the thermal feedback, the authors developed a simplified thermal-fluids analysis tool based on Stainsby's approach.
To test the new transient capabilities, they analyzed two control rod ejection scenarios and compared the results to those of CAPP/GAMMA+.

% Benchmarks Intro
The prismatic HTGR simulation tools available have lagged behind tools and methods developed for \glspl{LWR}.
The evolution of HTGR technology demands the development of more accurate and efficient simulation tools.
Additionally, the definition of appropriate benchmarks is essential to compare various tools' capabilities.
% oecd_nea_coupled_2020
In 2012, the \gls{OECD}/\gls{NEA} defined a benchmark for the \gls{MHTGR}-350 MW reactor \cite{oecd_nea_benchmark_2017}.
The purpose of this benchmarking exercise is to compare various reactor physics and thermal-fluid analysis methods.
The MHTGR-350 design serves as a basis for this benchmark.
The scope of the benchmark is twofold: (1) to establish a well-defined problem, based on a common given data set, to compare methods and tools in core simulation and thermal-fluid analysis, and (2) to test the depletion capabilities of various lattice physics tools available for prismatic HTGRs.
Section \ref{sec:ch3-bench} describes the benchmark in more detail.

% j_ortensi_relap-7_2012 j_ortensi_initial_2012
In 2012, \gls{INL} published a study \cite{j_ortensi_initial_2012} that coupled Pronghorn and RELAP-7 \cite{andrs_relap-7_2012}.
Pronghorn solved the coupled equations defining the neutron diffusion, fluid flow, and heat transfer in a three-dimensional model of the core.
RELAP-7 is a MOOSE-based system application and simulated the plant system layout, including the hot and cold ducts, the helium circulator, and the steam generator.
It solved the one-dimensional continuity, momentum, and energy equations for a compressible fluid.
To test the coupling, INL's team carried out the OECD/NEA MHTGR-350 Benchmark \cite{oecd_nea_coupled_2020}.
The original benchmark provides a set of 26 neutron energy group and temperature-dependent cross-sections.
To simplify the debugging, the authors collapsed the 26 groups into two groups.
Although using two groups reduces the model's accuracy, the lower number of groups decreases the calculation time by at least a factor of ten.
In their study, a two-dimensional cylindrical model replaced the three-dimensional geometry defined by the benchmark.
The integrated system testing included two stages: (1) both stand-alone tools underwent several convergence studies, and (2) the integrated system solved the steady-state problem in an integrated manner.
The authors concluded that the coupling between Pronghorn and RELAP-7 was successful.

% tak_coupled_2016
Tak et al. \cite{tak_coupled_2016} developed a neutronics/thermal-fluids coupled software using DeCART \cite{kaeri_decart_2007} and CORONA.
DeCART is a whole-core neutron transport tool, and it was responsible for calculating the power distribution and the fast neutron fluence.
CORONA calculated the temperature distribution.
The authors conducted the OECD/NEA MHTGR-350 benchmark to validate their software and identify technical challenges for future development.
The authors presented an interesting analysis in which they compared the coupled simulation results and the stand-alone simulations.
The difference in the multiplication factor was as high as 2597 pcm.
The axial offset and maximum fuel temperature exhibited significant differences as well.
This study highlights the importance of the integration of neutronics and thermal-fluid solvers for simulating prismatic HTGRs.

% tyobeka_htgr_2011 / strydom_results_2015
Sensitivity analysis and uncertainty analysis methods assess the predictive capabilities of coupled neutronics/thermal-fluids simulations.
In 2013, the IAEA launched a coordinated research project \cite{tyobeka_htgr_2011} on the HTGR Uncertainty Analysis in Modeling.
The coordinated research project's objective was to determine the uncertainty in HTGR calculations at all stages of coupled reactor physics/thermal-fluids and depletion calculations.
This coordinated research project is a natural continuation of the previous IAEA and OECD/NEA international activities \cite{iaea_evaluation_2003}\cite{reitsma_oecd-neansc_2008} on Verification and Validation of available HTGR simulator capabilities.
The technical approach is to establish and utilize a benchmark for uncertainty analysis.
The benchmark defines a series of well-defined problems with complete sets of input specifications and reference experimental data.
The coordinated research project adopted the MHTGR-350 as the reference design using the OECD/NEA MHTGR-350 Benchmark \cite{oecd_nea_benchmark_2017} design specifications.

\subsection{Summary of Prismatic HTGR Multi-physics}

Section \ref{sec:litreview-multi} introduced several prior studies of prismatic HTGR multi-physics.
These studies highlight the importance of the proper integration of the neutronics and thermal-fluids in HTGR modeling.
The neutronics and thermal-fluids physical phenomena rely heavily on each other.
Hence, a coupled analysis is necessary to capture the interaction between the neutronics and the thermal-fluids.
In the context of this thesis, Chapter \ref{ch:thermalfluids} discusses a coupling strategy for the neutronics and thermal-fluids phenomena in Moltres.

Section \ref{sec:litreview-multi} also summarized different articles focusing on Phase I Exercise 3 of the OECD/NEA MHTGR-350 Benchmark.
To validate their software and identify technical challenges for future development, the authors of the different articles conducted the benchmark exercise with and without further simplifications.
For studying the coupling strategy in Moltres, Section \ref{sec:coupled-average} follows a simplified version of the benchmark exercise.


\documentstyle[11pt,reduce]{article}
\title{BOOLEAN: Computing with boolean expressions}
\date{}
\author{
H. Melenk\\[0.05in]
Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
Takustra\"se 7 \\
D--14195 Berlin -- Dahlem \\
Federal Republic of Germany \\[0.05in]
E--mail: melenk@zib.de \\[0.05in]
}

\begin{document}
\maketitle

\section{Introduction}

The package {\bf Boolean} supports the computation with
boolean expressions in the propositional calculus.
The data objects are composed from algebraic expressions (``atomic parts'', ``leafs'')
connected by the infix boolean operators {\bf and}, {\bf or},
{\bf implies}, {\bf equiv}, and the unary prefix operator
{\bf not}. {\bf Boolean} allows you to simplify expressions
built from these operators, and to test properties like
equivalence, subset property etc. Also the reduction of
a boolean expression by a partial evaluation and combination
of its atomic parts is supported.

\section{Entering boolean expressions}

In order to distinguish boolean data expressions from
boolean expressions in the \REDUCE programming
language (e.g. in an {\bf if} statement), each expression
must be tagged explicitly by an operator {\bf boolean}.
Otherwise the boolean operators are not accepted in the
\REDUCE  algebraic mode input.
The first argument of {\bf boolean} can be any boolean expression,
which may contain references to other boolean values.
\begin{verbatim}
    boolean (a and b or c);
    q := boolean(a and b implies c);
    boolean(q or not c);
\end{verbatim}
Brackets are used to override the operator precedence as usual.
The leafs or atoms of a boolean expression are those parts which
do not contain a leading boolean operator. These are
considered as constants during the boolean evaluation. There
are two pre-defined values:
\begin{itemize}
\item {\bf true}, {\bf t} or {\bf 1}
\item {\bf false}, {\bf nil} or {\bf 0}
\end{itemize}
These represent the boolean constants. In a result
form they are used only as {\bf 1} and {\bf 0}.

By default, a {\bf boolean} expression is converted  to a
disjunctive normal form, that is a form where terms are connected
by {\bf or} on the top level and each term is set of leaf
expressions, eventually preceded by {\bf not} and connected
by  {\bf and}. An operators {\bf or} or {\bf and} is omitted
if it would have only one single operand. The result of
the transformation is again an expression with leading
operator {\bf boolean} such that the boolean expressions
remain separated from other algebraic data. Only the boolean
constants {\bf 0} and {\bf 1} are returned untagged.

On output, the
operators {\bf and} and {\bf or} are represented as
\verb+/\+ and \verb+\/+, respectively.
\begin{verbatim}
boolean(true and false);    ->   0
boolean(a or not(b and c)); -> boolean(not(b) \/ not(c) \/ a)
boolean(a equiv not c);     -> boolean(not(a)/\c \/ a/\not(c))
\end{verbatim}

\section{Normal forms}

The {\bf disjunctive} normal form is used by default. It
represents the ``natural'' view and allows us to represent
any form free or parentheses.
Alternatively a {\bf conjunctive} normal form can be
selected as simplification target, which is a form with
leading operator {\bf and}. To produce that form add the keyword  {\bf and}
as an additional argument to a call of {\bf boolean}.
\begin{verbatim}
boolean (a or b implies c);
                    ->
     boolean(not(a)/\not(b) \/ c)

boolean (a or b implies c, and);
                    ->
     boolean((not(a) \/ c)/\(not(b) \/ c))
\end{verbatim}

Usually the result is a fully reduced disjunctive or conjuntive normal
form, where all redundant elements have been eliminated following the
rules

$ a \wedge b \vee \neg a \wedge b \longleftrightarrow b$

$ a \vee b \wedge \neg a \vee b \longleftrightarrow b$

Internally the full normal forms are computed
as intermediate result; in these forms each term contains
all leaf expressions, each one exactly once. This unreduced form is returned
when you set the additional keyword {\bf full}:
\begin{verbatim}
boolean (a or b implies c, full);
                   ->
boolean(a/\b/\c \/ a/\not(b)/\c \/ not(a)/\b/\c \/ not(a)/\not(b)/\c

         \/ not(a)/\not(b)/\not(c))
\end{verbatim}

The keywords {\bf full} and {\bf and} may be combined.

\section{Evaluation of a boolean expression}

If the leafs of the boolean expression are algebraic expressions
which may evaluate to logical values because the environment
has changed (e.g. variables have been bound), you can re--investigate
the expression using the operator {\tt testbool} with the boolean
expression as argument. This operator tries to evaluate all
leaf expressions in \REDUCE boolean style. As many
terms as possible are replaced by their boolean values; the others
remain unchanged. The resulting expression is contracted to a
minimal form. The result {\bf 1} (= true) or {\bf 0} (=false)
signals that the complete expression could be evaluated.

In the following example the leafs are built as numeric greater test.
For using ${\bf >}$ in the expressions the greater sign must
be declared operator first. The error messages are meaningless.
\begin{verbatim}
operator >;
fm:=boolean(x>v or not (u>v));
        ->
    fm := boolean(not(u>v) \/ x>v)

v:=10$

testbool fm;

   ***** u - 10 invalid as number
   ***** x - 10 invalid as number

        ->
   boolean(not(u>10) \/ x>10)

x:=3$
testbool fm;

   ***** u - 10 invalid as number

        ->
   boolean(not(u>10))

x:=17$

testbool fm;

   ***** u - 10 invalid as number

        ->
    1

\end{verbatim}
\end{document}


\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{verbatim}

\title{Linear programming notes}
\author{Marco Marini}

\begin{document}

\maketitle
\tableofcontents

\begin{abstract}
This document contains notes about Linear programming.
\end{abstract}

\section{Supply chain model}

We define a simplified supply chain model as a system
that produces products with a chain of product transformations performed by suppliers.

Let it be
\begin{description}
	\item [$ A = a_1 \dots a_n $]
		the set of supplier types
	\item [$ B = b_1 \dots b_m $]
		the set of product types.
\end{description}

The supplier can perform only a single transformation for the its duration.
Each product can be produced by a single supplier type.

Let it be
\begin{description}
	\item [$ S = s_i \in A $]
		the supplier of product $ i \in B $
	\item [$ N = n_i $]
		the number of suppliers of type $ i \in A $.
	\item[ $ V = v_{i} $ ]
		the value of product $ i \in B $
	\item[ $ Q = q_{i} $ ]
		the quantity of produced product $ i \in B  $l
	\item[ $ T = t_{i} $ ]
		the production interval for product $ i \in B  $
	\item[$ D = d_{ij} $ ]
		the quantity of product $ j \in B $ consumed to produce the product $ i \in B $.
\end{description}

\subsection{Production}

By now we do not consider the constraint on the availability of consuming products. It will be considered later.

Let be
\begin{description}
	\item [$ \theta_{ij} $]
		The matrix that map product $ j \in B $ to the supplier $ i \in A $
	\item [$ \nu i $]
	The number of supplier of product $ i \in B $
\end{description}
such that
\[
\begin{array}{l}
	\theta_{ij} = 1, s_j = i \\
	\theta_{ij} = 0, s_j \ne i \\
	\nu _i = n_{s_j}
\end{array}
\]

When a supplier of type $ i \in A $ is ready to produce we assign a production slot for the product $ j \in B $ such that $ s_j = i $ and the production time is $ t_j w_j $ where
\begin{description}
	\item[ $ W = w_i $ ] is the slot weight for product $ i \in B $
\end{description}
such that
\begin{equation}
\label{equ:YConstraints}
	w_i \ge 0
\end{equation}

Moreover we may put the supplier $ i \in A $ in idle state for a while
\begin{description}
	\item[$ Z = z_i $]
		is the idle time during a whole production cycle
\end{description}
such that
\begin{equation}
\label{equ:ZConstraints}
	z_i \ge 0
\end{equation}

The total time of production cycle for supplier $ i $ is
\[
\begin{array}{l}
	U_i(w_j, z_i) = \sum_{j \in B | s_j = i} t_j w_j + z_i \\
		= \sum_{j \in B} \theta_{ij} t_j  w_j + z_i \\
		= \sum_{j, k \in B} \theta_{ik} T_{kj} w_j + z_i \\
		= U W + Z
\end{array}
\]
such that
\[
	U = u_{ij} = \sum_{k \in B} \theta_{ik} T_{kj} = \Theta T
\]

Let normalize the total time production to 1
\begin{equation}
\label{equ:normalInterval}
	U_i(w_j, z_i) = 1
\end{equation}

During this interval the suppliers produce the product $ i \in A $ at a slot rate
\begin{equation}
\label{equ:prodFreq}
	R_i(w_i) = n_{s_i} \frac{w_i}{y_{s_i}} = n_{s_i} w_i
	= \sum{j \in B} N_{ij} w_j = N W
\end{equation}

The production rate of product $ i \in B $ is
\begin{equation}
\label{equ:prodRate}
	P_i(w_j) = R_i(w_j) q_i
		= Q_{ik} R_k(w_j)
		= Q N W
		= P W
\end{equation}
such that
\[
	P = Q N
\]

\subsection{Consumption}

The (\ref{equ:prodFreq}) expresses the slot rate of a product for specific suppliers.
Therefore we can calculate the consumption rate of a product $ i \in B$ as the sum of consumptions among to produced products
\begin{equation}
\label{equ:consumRate}
	C_i(w_j) = \sum_{k \in B} R_k(w_j) d_{ki}
			= \sum_{k \in B} d'_{ik} R_k(w_j)
			= D' N W
			= C W
\end{equation}
such that
\[
	C = D' N
\]

The effective production rate is
\[
	F_i(w_j) = P_i(w_j) - C_i(w_j) = (P - C) W = F W
\]
such that
\[
	F = f_{ij} = P - C = (Q - D') N
\]

If
	\[ F_i(w_j) \ge 0 \]
the product is produced at a higher rate then it is consumped creating a surplus that can be sold.

On the other hane we cannot have
	\[ F_i(w_j) < 0 \]
because it cannot consume more product than the produced.

So the system must satisfy the constraint
\begin{equation}
\label{equ:consumptionConstraint}
	F_i(w_j) \ge 0
\end{equation}

\subsection{Profit rate}

The profit rate for the whole supply chain are
\begin{equation}
\label{equ:valueRate}
	G(w_i) =  \sum_{j \in B} v_j F_j(w_i)
	= V' F W
	= G' W
\end{equation}
such that
\[
	G = g_i = (V' F)' ) F' V = N' (Q'-D) V
\]

The problem is to find the optimal production configuration given by the
values of $ w_i $ and $ z_i $ that maximize the value rate $ G(w_i) $.
This is defined by the linear system composed by
(\ref{equ:YConstraints})
(\ref{equ:ZConstraints}),
(\ref{equ:normalInterval}),
(\ref{equ:consumptionConstraint}),
(\ref{equ:valueRate})
\begin{equation}
\label{equ:linsist}
\left\{
\begin{array}{ll}
\max_{(w_i, z_j)} G(w_i) & , i \in B, j \in A \\
U_i(w_j, z_i) = 1 &  , i \in A, j \in B \\
F_i \ge 0 & , i \in B \\
w_i \ge 0 & , i \in B \\
z_i \ge 0 & , i \in A
\end{array}
\right.
\end{equation}

\subsection{Supplier configuration}

Once resolved the system (\ ref {equ: linsist}) we have the distributions of the suppliers production slots.
We have to transform them into a concrete production configuration assigning for each supplier the producing product or inactivity.

The numbers of suppliers that are producing the product $ i \in B $  are given by the total production times of the suppliers for each product rated by the total production times $ U_i(w_i, z_j) = 1 $.
\[
\begin{array}{l}
	\pi_i = n_{s_i} w_i t_i \\
	\Pi = N T W
\end{array}
\]

The integer parts of $ \Pi $ give the number of constant producers by product
\[
	F = floor(\Pi)
\]

The remainder fractional parts determine the variable distributions of remainder suppliers by product.
\[
	R = \Pi - F
\]

The real configuration may be determined by stocastic selection process based on such distribution.

The total numbers of random suppliers are
\[
	R' = ceil(\Theta R)
\]

To generalize the computation of the probability of a product for each random supplier let the total numbers of suppliers be  \[
	R" = max(R', 1) \ge 1
\]

The total numbers of random suppliers by product are
\[
	S = \Theta^T R"
\]

The probabilities of products to be produced by the suppliers are then
\[
	P = diag(S)^{-1} R
\]

To generate a random configurationi with the given distribution $ P $ we need to compute the probabilities of each product$ j \in B $ for each supplier $ i \in A $:
\[
	P' = p'_{ij} = \Theta \, diag(P)
\]

\end{document}


%
%

\chapter{Model checking algorithms} \label{SEC:ModelChecking}

\section{Temporal logic and model checking}

Temporal logic is concerned with properties of discrete-state models and
their evolution in time. It requires that the model define a set of states
$\sset$, a binary relation $\goesto{~}$ on states (the temporal order),
and a function that evaluates the truth value of any atomic proposition in
each state. Starting from a set of atomic predicates, it is then possible
to express more complex assertions. Let $\goesto{*}$ be the transitive and
reflexive closure of $\goesto{~}$.
Given a predicate~$p$ and a state $\vi$,
we can discuss basic questions of the type :

\begin{itemize}
\item
(in the future) $\opF{}p$ holds in~$\vi$ if and only if there exists a state $\vj$
such that $\vi \goesto{*} \vj$ and $p$ holds in~$\vj$.
\item
(in the past) $\opP{}p$ holds in~$\vi$ if and only if there exists a state $\vj$
such that $\vj \goesto{*} \vi$ and $p$ holds in~$\vj$.
\item
(globally) $\opG{}p$ holds in~$\vi $ if and only if~$p$ always holds in
the future states, equivalent to~$\neg\opF{}\neg p$.
\item
(historically) $\opH{}p$ holds in $\vi$ if and only if~$p$ has always held in
the past prior to $\vi$, equivalent to~$\neg\opP{}\neg p$.
\end{itemize}

The adjective ``temporal'' simply refers to the succession of events
leading from a state to another, not to the actual time of their
occurrence. In the literature, both \emph{linear} time logic (LTL) and
\emph{branching} time logic (CTL) have received much attention
\cite{Clarke1999book,McMillan1992thesis};
{\smart} implements the latter. In CTL, operators
occur only in pairs.  The first operator, the path quantifier, is
either~$A$ (on all paths), or~$E$ (there exists a path), while the second
one, the tense operator, is chosen from among~$X$ (next),~$F$ (future, or
finally),~$G$ (globally, or generally), and~$U$ (until).
Fig.~\ref{FIG:CTLops} illustrates the meaning of each of the eight operator
combinations in CTL.
Note that {\smart} also allows the possiblity to talk about the past:
$\opY$ is time-reversed $\opX$,
$\opP$ is time-reversed $\opF$,
$\opH$ is time-reversed $\opG$,
and
$\opS$ is time-reversed $\opH$.

\begin{figure}
  \centering
  \includegraphics[scale=0.8]{figures/CTL.pdf}
  \caption{Examples of CTL formulae. The root node satisfies the
  corresponding formula.}
  \label{FIG:CTLops}
\end{figure}

Given a discrete-state model, a CTL formula uniquely identifies a set of
states that satisfy it. Thus the model checking activity can be thought of
as the identification of the set of states satisfying the formula.
{\smart} uses the type \Code{stateset} to refer to a set of states
of a particular model, e.g., those states satisfying a CTL state formula.
{\smart} supports both \emph{explicit} and \emph{symbolic} model checking.
As discussed in Sec.~\ref{SEC:SSGen},
the state space $\sset$ can be generated and stored explicitly or symbolically;
if $\sset$ is stored explicitly, then all \Code{stateset}s for that model
will also be stored explicitly,
and explicit model checking algorithms will be used
(options allow selection between different algorithms).
Otherwise, if $\sset$ is stored as a decision diagram using Meddly,
then so will all \Code{stateset}s for that model,
and symbolic model checking algorithms will be used.

\section{Model checking in {\smart}}

The set of atomic propositions in {\smart} is represented by boolean
expressions inductively constructed over a set of terms. For Petri net
models, the set of terms includes objects of type \Code{proc bool} and
\Code{proc int}, plus the formalism-dependent types \Code{place} and
\Code{trans}. These terms can be combined using boolean operators
(negation, conjuction, disjunction) between boolean subterms, relational
(equal, less than, etc.) and arithmetic (addition, multiplication, etc.)
operators between arithmetic subterms, and the following
formalism-dependent functions:
\begin{itemize}
  \item \Code{proc int tk(place p)}, which returns the number of tokens in place \Code{p}.
  \item \Code{proc bool enabled(trans t)}, which returns \Code{true} if transition
        \Code{t} is enabled, \Code{false} otherwise.
\end{itemize}

{\smart} provides the type \Code{stateset} to define sets of states in a model.
Any set of states defined for a model is a subset of the ``universe'',
which for explicit storage is the set of reachable states $\sset$,
while for symbolic storage is the set of potential states $\potsset = \sset_K \times \cdots \times \sset_1$
(see Sec.~\ref{SEC:SSGen}).
Hence, it is possible to define sets containing both reachable and unreachable states.
If desired, the
unreachable states can be eliminated from a set by intersecting it with
the state space $\sset$, which is specified in {\smart} as
\Code{reachable}.
\TBD{Do we want to make these consistent, i.e., make a stateset always be a subset
of the reachable states?}

Inside a model block,
a \Code{stateset} for an atomic proposition may be constructed using function
\begin{lstlisting}
    stateset potential(proc bool p)
\end{lstlisting}
where $p$ is a boolean expression that depends on the model state,
and the resulting \Code{stateset} contains the states in which $p$
evaluates to true.
The eight CTL pairs shown in Fig.~\ref{FIG:CTLops},
and their time-reversed counterparts,
correspond to functions in {\smart} with the same name,
that must also be called within a model block.
For example,
\begin{lstlisting}
    stateset EU(stateset p, stateset q)
\end{lstlisting}
returns the \Code{stateset} containing states
satisfying $\opE\,p\,\opU\,q$.
Additionally,
operators \Code{!} (negation / complement), \Code{\&} (conjunction / intersection),
\Code{|} (disjunction / union), \verb|\| (set difference), and \Code{->} (implication)
may be applied to \Code{stateset}s,
and are not required to be used within a model block,
although
it is an error to use \Code{stateset}s from different models
(in fact, from different state spaces)
as operands to the same operator.
The cardinality of a \Code{stateset} may be obtained with
\begin{lstlisting}
    bigint card(stateset p)
\end{lstlisting}
which, in the case of symbolic model checking,
may return a \emph{huge} value.
If instead we only care if a set is empty or not,
it is much more efficient to use
\begin{lstlisting}
    bool empty(stateset p)
\end{lstlisting}
which is (mathematically, but not computationally)
equivalent to $0==card(p)$.
Finally,
the elements of a \Code{stateset} may be printed
using the \Code{print} function;
option \Code{StatesetPrintIndexes}
dictates whether the set is displayed as a list of state indexes
or a list of states.

\begin{developer}
\section{Counterexamples and witnesses}

\TBD{NOT IMPLEMENTED YET; UPDATE AFTER THAT}

One of the most attractive features of model checking is its ability to provide
counter-examples and witnesses for the properties that are checked. The
two notions are dual. Whenever a formula prefixed with the universal path
quantifier,~$A$, is not verified, the model checker provides the user with
an execution trace that proves the negation of the formula (a
\emph{counter-example}). Similarly, for a valid formula prefixed with the
existential path quantifier,~$E$, the model checker delivers a
\emph{witness} to that.

In both cases, the execution traces are in fact proofs for
existentially quantified formulae: $EX p$, $EF p$, $E[p~U~q]$, or $EG p$,
where $p$ is an arbitrary CTL formula.
Among these, only the last three cases are interesting,
since $EX p$ is trivially computed in one step.
$EF p$ and $E[q~U~p]$ witnesses are single finite paths that ``show'' how the
target set of states (satisfying formula $p$ in this case) can be reached
from the initial set of states through a sequence of valid transitions.
In addition, for the $EU$ witness, $q$ must hold along the entire path until
the last state, where $p$ holds.
Finally, an $EG p$ witness is a strongly connected component (SCC) in the
reachability graph where formula $p$ holds on all states.
A typical (non-trivial) SCC is a cycle, with or without chords.
In our model checker, the computation of $EG$ traces is reduced to the
equivalent problem of finding and concatenating two $EU$ traces
forming a cycle plus possibly a third trace leading to that cycle.
Thus, we can limit our discussion to the traces for $EF$ and $EU$.

Since a trace is usually meant to be examined by a human, it is desirable
to compute a minimal-length one.
However, finding such a trace for an
arbitrary formula is an NP-complete problem, thus a sub-optimal trace is
sought in most cases, usually the one that is found first. Due to the
heavy computation price to be paid, our model checker does not compute the
execution traces automatically for each CTL formula that is verified, but
only upon request, by calling one of the three functions:

\begin{itemize}
\item
\LIGHTGREY{
\Code{bool EFtrace(stateset p, stateset q)}\\
  Finds and prints a witness for $EFq$, of shortest length, starting from
  \Code{p}.
  Returns \Code{true} if such a trace exists, \Code{false} otherwise.
}
\item
\LIGHTGREY{
\Code{bool EUtrace(stateset p, stateset q, stateset r)}\\
  Finds and prints a minimal length witness for $E[q~ U~ r]$ that starts at
  \Code{p}.
  Returns \Code{true} if such a trace exists, \Code{false} otherwise.
}
\item \Code{mdd EGtrace(mdd p)}\\
  Finds and prints a shortest witness for $EGq$, starting from the initial state.
  %Returns \Code{true} is such a strace exists, \Code{false} otherwise.
  \DEVELOPER{{\smart} computes this trace by concatenating two traces.}
\end{itemize}

\LIGHTGREY{
The output of the above functions is the sequence of states in the
execution trace along with the identity of the event fired at each step.
See Fig.~\ref{FIG:TraceOutput} for details on the output format.
In addition to these three functions, we provide a distance function:
}
\begin{itemize}
\item
\LIGHTGREY{
\Code{int} \Code{dist(stateset p, stateset q)} \\
  Returns the length of a shortest path from any state in \Code{p}
  to any state in \Code{q}.
  If no such path exists, it returns \Code{infinity}.
}
\end{itemize}

\LIGHTGREY{
The above functions restrict the origin of the trace to a set of states
\Code{p}.
This is more general than assuming that the execution trace always starts
with the initial state.
Our format is more flexible in that it would eventually enable the
concatenation of traces, as required when verifying nested CTL formulae.
The original semantics of the traces is simply obtained by setting the argument
\Code{p} of the functions to the atomic proposition \Code{initialstate}.
}

The computation of traces in {\smart} is implemented by means of symbolic
data structures.
The complete set of traces and the distance function can
be computed with a standard approach that uses a forests of MDDs (with
shared nodes, for efficiency) in conjunction with breadth-first exploration.
A second approach using edge-valued decision diagrams (a generalized form
of EVBDDs \cite{Lai1996EVBDDs}) is also available;
this is much more efficient due to its ability to apply the saturation
strategy, not just breadth-first exploration, but it can only be used to
compute the distance function \Code{dist}, or $EF$ traces.
A third approach uses Algebraic Decision Diagrams (ADDs \cite{Bahar1997ADDs}),
and it, also, can use either a saturation or a breadth-first approach.
The option \Code{TraceStorage}, with possible
values \Code{SHMDD\_BFS}, \Code{ADD\_SAT}, \Code{ADD\_BFS},
\Code{EVMDD\_BFS}, \Code{EVMDD\_SAT} (default) sets the data structure and
iteration strategy used for these two functions
(see \cite{2002FMCAD-EVMDD} for a more detailed description).

Moreover, when shared MDDs are used, the type of BFS exploration is
governed by the option \Code{BFSTrace}, with possible values
\Code{FORWARD}, \Code{BACKWARD}, and \Code{JOIN} (default).
For the first two values, the behavior is symmetric.
A \Code{FORWARD} ($EF$ or $EU$) trace starts at the source and reaches the
target by using a forward BFS exploration, which therefore yields the
shortest length for the generated trace.
A \Code{BACKWARD} trace starts at the target and backtracks to the source.
The \Code{JOIN} strategy uses a divide-and-conquer handshaking algorithm
which starts the BFS exploration at both ends and meets in the middle.
The trace generation continues recursively on the two segments
delimited by the junction point.

We give here a very simplistic guideline to the complexity analysis of the
three variants of trace construction. If~$d$ is the distance from the
source to the target set of states (the length of the shortest path
between them), then \Code{FORWARD} and \Code{BACKWARD} algorithms store
$O(d)$ intermediate sets of states, and take $O(d)$ steps to complete,
while the \Code{JOIN} algorithm stores only two sets of states at all
times, but takes $O(d\log d)$ steps to compute the trace.
The user should adjust the settings according to the desired time/space
tradeoffs.
Note that symbolic data structures may be
counter-intuitive when it comes to representing sets, as the necessary
space is determined by the number of MDD nodes, and not the number of
encoded states (it is often the case that smaller sets take much more
memory than larger sets).
\end{developer}

\section{Examples}

\begin{figure}
  \lstinputlisting[firstline=3]{examples/phils_dead.sm}
\caption{Printing the deadlocked states in the dining philosophers model.}
\label{FIG:PhilsDeadlock}
\end{figure}

The code in Fig.~\ref{FIG:PhilsDeadlock} generates and prints
the deadlocked states (if any exist) in the dining philosophers model.
The \Code{stateset} \Code{NotAbsorb} contains all potential states that have a
some successor, thus all non absorbing states. The \Code{stateset}
\Code{Deadlocked} contains exactly the reachable states not in \Code{NotAbsorb},
that is, all reachable states with no successor.
Outside the model,
we check if set \Code{Deadlocked} is empty, and if not,
we print the deadlocked states.
Note we could have simply printed the set;
{\smart} will display an empty set if asked to print an empty \Code{stateset}.

\begin{figure}
  \centering
  \includegraphics[scale=0.64]{figures/kripke1.pdf}
  \lstinputlisting[firstline=3]{examples/kripke1.sm}
\caption{Illustrating temporal operators on a small example.}
  \label{FIG:kripke1}
\end{figure}

The code in Fig.~\ref{FIG:kripke1} illustrates the difference between
various temporal logic operators.
The model is partitioned into two submodels, each containing a cycle.
The inhibitor arcs in the {\smart} input file are added to ensure the correct
size of the local spaces, they are needed only for methods that pre-generate
the local state spaces in isolation.

\begin{itemize}
\item
The potential state space is $\sset_2 \times \sset_1$,
with $\sset_2 = \{a, b, c, \epsilon\}$ and $\sset_1 = \{\epsilon, d, e\}$,
thus it contains $12$ states
(by  $\epsilon$ we mean the local marking where all places are empty,
by ``$a$'' we mean the local marking where place $a$ contains one token
and places $b$ and $c$ are empty, and so on).
\item
The state space contains five states, corresponding to the token being in
exactly one of the five places.
\item
Three potential states have a token in $a$,
$\{(a,\epsilon),(a,d),(a,e)\}$, but only one, $(a,\epsilon)$, is reachable.
\item
The reachable states that can reach a state with a token in $a$ are
$\{(a,\epsilon), (b,\epsilon), (c,\epsilon)\}$.
If we included the non-reachable states, this set would
contain nine states (same reasoning as in the previous item).
\item
If we search for states that have an outgoing infinite path (i.e., states
included in a strongly connected component) where $a$ always contains a token,
the set $\{(a,d), (a,e)\}$ is found, but these states are non-reachable,
so they are not printed when we show the set \Code{ex.rEGa}.

\item
Instead, if we search for a reachable strongly connected component of states
where $a$, or $b$, or $c$ always contain a token,
we again find nine potential states or three actual states.
\item
The $\opE[c~U~d]$ query finds states $(c,\epsilon)$ and $(d,\epsilon)$,
while $\opA[c~U~d]$ finds only state $(d,\epsilon)$.

\item
The query $\opE[(a \vee b \vee c)~\opU~d]$
finds the set of four states
$\{(a,\epsilon), (b,\epsilon), (c,\epsilon), (d,\epsilon)\}$,
while the query $\opA[(a \vee b \vee c)~\opU~d]$
finds only state $(d, \epsilon)$;
this is because it is possible for the token to circulate
among places $a$, $b$, and $c$ indefinitely.
If we instead use a \emph{stochastic} Petri net model,
where transitions have firing rates,
then the underlying structure becomes a continuous-time Markov chain
(rather than a kripke structure),
and since any path where the token remains indefinitely in places
$a$, $b$, and $c$ has probability measure zero,
in this case the query $\opA[(a \vee b \vee c)~\opU~d]$
will return the same four states as
$\opE[(a \vee b \vee c)~\opU~d]$.

\end{itemize}

\begin{developer}
\TBD{Need to implement execution traces!}

\begin{figure}
\begin{lstlisting}
spn k(int n) := {
  place pm1, pback1, pkan1, pout1,    pm2, pback2, pkan2, pout2,
        pm3, pback3, pkan3, pout3,    pm4, pback4, pkan4, pout4;
  trans tin1, tredo1, tok1, tback1,   tin2, tredo2, tok2, tback2, tout2,
        tredo3, tok3, tback3,         tredo4, tok4, tback4, tout4;
  partition(pm1:pback1:pkan1:pout1,   pm2:pback2:pkan2:pout2,
	    pm3:pback3:pkan3:pout3,   pm4:pback4:pkan4:pout4);
  firing(tin1:expo(1.0), tredo1:expo(0.36), tok1:expo(0.84),
	 tback1:expo(0.3), tin2: expo(0.4), tredo2:expo(0.42),
	 tok2: expo(0.98), tback2:expo(0.3), tout2: expo(0.5),
	 tredo3:expo(0.39), tok3:expo(0.91), tback3:expo(0.3),
	 tredo4:expo(0.33), tok4:expo(0.77), tback4:expo(0.3), tout4:expo(0.9)
	);
  arcs(pkan1:tin1, tin1:pm1, pm1:tredo1, pm1:tok1, tredo1:pback1,
       tok1:pout1, pback1:tback1, tback1:pm1, pout1:tin2, tin2:pkan1,
       pkan2:tin2, tin2:pm2, pm2:tredo2, pm2:tok2, tredo2:pback2,
       tok2:pout2, pback2:tback2, tback2:pm2, pout2:tout2, tout2:pkan2,
       pkan3:tin2, tin2:pm3, pm3:tredo3, pm3:tok3, tredo3:pback3,
       tok3:pout3, pback3:tback3, tback3:pm3, pout3:tout2, tout2:pkan3,
       pkan4:tout2, tout2:pm4, pm4:tredo4, pm4:tok4, tredo4:pback4,
       tok4:pout4, pback4:tback4, tback4:pm4, pout4:tout4, tout4:pkan4);
  init(pkan1:n, pkan2:n, pkan3:n, pkan4:n);
  stateset F := intersection(reachable,
           potential(tk(pout4)==n & tk(pout1)==n & tk(pout2)==n & tk(pout3)==n));
  int  D := dist(initialstate, F);
  bool T := EFtrace(initialstate, F);
};
# StateStorage  MDD_SATURATION
# BFSTrace FORWARD
int N := read_int("N");
print("Distance to the farthest state: ", k(N).D, ".\n");
print("Execution trace:"); compute(k(N).T);
\end{lstlisting}
\caption{Generating CTL execution traces in {\smart}.}
\label{FIG:KanbanTraces}
\end{figure}

The code in Fig.~\ref{FIG:KanbanTraces} illustrates the use of execution
traces on a kanban manufacturing system example (see Fig.~\ref{FIG:kanban}
for the graphical model).
In this case, the computation of the witness is influenced by the value of the
\Code{BFSTrace} option.
Figure \ref{FIG:TraceOutput} shows the two different shortest-length witnesses
obtained when this option is set to either \Code{FORWARD} or \Code{BACKWARD}.

\begin{figure}
When option \Code{BFSTrace} is set to \Code{FORWARD}:
\begin{lstlisting}
EF Trace of length 14
* Starting from state 	=>  { pkan1:1 pkan2:1 pkan3:1 pkan4:1 }
* Step 1: fire event tin1	=>  { pm1:1 pkan2:1 pkan3:1 pkan4:1 }
* Step 2: fire event tok1	=>  { pout1:1 pkan2:1 pkan3:1 pkan4:1 }
* Step 3: fire event tin2	=>  { pkan1:1 pm2:1 pm3:1 pkan4:1 }
* Step 4: fire event tin1	=>  { pm1:1 pm2:1 pm3:1 pkan4:1 }
* Step 5: fire event tok1	=>  { pout1:1 pm2:1 pm3:1 pkan4:1 }
* Step 6: fire event tok2	=>  { pout1:1 pout2:1 pm3:1 pkan4:1 }
* Step 7: fire event tok3	=>  { pout1:1 pout2:1 pout3:1 pkan4:1 }
* Step 8: fire event tout2	=>  { pout1:1 pkan2:1 pkan3:1 pm4:1 }
* Step 9: fire event tin2	=>  { pkan1:1 pm2:1 pm3:1 pm4:1 }
* Step 10: fire event tin1	=>  { pm1:1 pm2:1 pm3:1 pm4:1 }
* Step 11: fire event tok1	=>  { pout1:1 pm2:1 pm3:1 pm4:1 }
* Step 12: fire event tok2	=>  { pout1:1 pout2:1 pm3:1 pm4:1 }
* Step 13: fire event tok3	=>  { pout1:1 pout2:1 pout3:1 pm4:1 }
* Step 14: fire event tok4	=>  { pout1:1 pout2:1 pout3:1 pout4:1 }
\end{lstlisting}

When option \Code{BFSTrace} is set to \Code{BACKWARD}:
\begin{lstlisting}
EF Trace of length 14
* Starting from state 	=>  { pkan1:1 pkan2:1 pkan3:1 pkan4:1 }
* Step 1: fire event tin1	=>  { pm1:1 pkan2:1 pkan3:1 pkan4:1 }
* Step 2: fire event tok1	=>  { pout1:1 pkan2:1 pkan3:1 pkan4:1 }
* Step 3: fire event tin2	=>  { pkan1:1 pm2:1 pm3:1 pkan4:1 }
* Step 4: fire event tok3	=>  { pkan1:1 pm2:1 pout3:1 pkan4:1 }
* Step 5: fire event tok2	=>  { pkan1:1 pout2:1 pout3:1 pkan4:1 }
* Step 6: fire event tout2	=>  { pkan1:1 pkan2:1 pkan3:1 pm4:1 }
* Step 7: fire event tok4	=>  { pkan1:1 pkan2:1 pkan3:1 pout4:1 }
* Step 8: fire event tin1	=>  { pm1:1 pkan2:1 pkan3:1 pout4:1 }
* Step 9: fire event tok1	=>  { pout1:1 pkan2:1 pkan3:1 pout4:1 }
* Step 10: fire event tin2	=>  { pkan1:1 pm2:1 pm3:1 pout4:1 }
* Step 11: fire event tok3	=>  { pkan1:1 pm2:1 pout3:1 pout4:1 }
* Step 12: fire event tok2	=>  { pkan1:1 pout2:1 pout3:1 pout4:1 }
* Step 13: fire event tin1	=>  { pm1:1 pout2:1 pout3:1 pout4:1 }
* Step 14: fire event tok1	=>  { pout1:1 pout2:1 pout3:1 pout4:1 }
\end{lstlisting}
\caption{The output of $EF$ witnesses, depending on the setting of the
\Code{BFSTrace} option.}
\label{FIG:TraceOutput}
\end{figure}

\end{developer}


\documentclass[12pt]{article}

\usepackage{headerfooter}
\usepackage{epsfig}
\usepackage{verbatimfiles}
\usepackage{fullpage}
\usepackage{amsmath}

\newcommand{\HRule}{\rule{\linewidth}{.3mm}}

\bibliographystyle{plain}
\begin{document}

\newcommand{\pd}[2]{\frac{\partial{#1}}{\partial{#2}}}

\begin{center}
{\bf \Large The OpenSees Truss Element}

{\bf August 22, 2001}

{\bf Michael H. Scott}

{\bf PEER, University of California, Berkeley}
\end{center}

This document provides a brief description of the interaction between a truss
element and the UniaxialMaterial class in OpenSees.
Material nonlinearity is abstracted, or separated, from the
element formulation by using the UniaxialMaterial class.
Figure~\ref{fig:TrussClass} shows the class interaction between a truss
element and the UniaxialMaterial class. A truss element can use any one of
ElasticMaterial or HardeningMaterial models. When a new uniaxial material class
is added to the framework, the truss can use the new class without modification.

\begin{figure}[htpb]
\begin{center}
\leavevmode
\hbox{%
\epsffile{./fig_files/TrussClass.eps}}
\end{center}
\caption{Truss class diagram}
\label{fig:TrussClass}
\end{figure}

The formulation of a linear geometry, material nonlinear truss element is covered
in the remainder of this document. First, the linear transformation is described,
followed by the truss element formulation.

\section{Geometric Transformation}
A linear transformation of displacements and forces between the global and basic
frames of reference is assumed. The transformation of global displacements,{\bf u},
to a single axial displacement, $v_1$, is given by the linear relation,

\begin{equation}
\label{eq:v=Tu}
{\bf v} = \left[ \begin{array}{c} v_1 \end{array} \right] = {\bf T}{\bf u}.
\end{equation}

\noindent Based on force equilibrium, the transformation of axial force in the
basic system to global forces is also linear,

\begin{equation}
\label{eq:p=Tq}
{\bf p} = {\bf T}^T{\bf q} = {\bf T}^T \left[ \begin{array}{c} q_1 \end{array} \right].
\end{equation}

The transformation between global and basic systems is shown schematically in
figure~\ref{fig:TrussTransf}. The transformation matrix, {\bf T}, is given in terms
of the element orientation, $\theta$, in the global system,

\begin{equation}
{\bf T} = \left[ \begin{array}{cccc} -\cos\theta & -\sin\theta & \cos\theta & \sin\theta
\end{array} \right].
\end{equation}

\begin{figure}[htpb]
\begin{center}
\leavevmode
\hbox{%
\epsfxsize=6.0in
\epsffile{./fig_files/TrussTransf.eps}}
\end{center}
\caption{Linear geometric transformation}
\label{fig:TrussTransf}
\end{figure}

\section{Truss Element Formulation}
This section describes the formulation of a displacement based truss element.
The governing compatibility and equilibrium equations are covered along with the consistent
element stiffness. Axial deformations are assumed to be small.

\subsection{Compatibility}
For the truss element, there is a strong form of compatibility between
basic displacements, {\bf v}, and section deformations {\bf e}, satisfied
pointwise along the element length,

\begin{equation}
\label{eq:e=av}
{\bf e}(x) =
\left[ \begin{array}{c} \varepsilon(x) \end{array} \right] =
{\bf a}(x) \: v_1,
\end{equation}

\noindent where {\bf a} is the strain-displacement matrix and $v_1$ is computed
from equation~\ref{eq:v=Tu}. There is one section deformation,
the axial strain, $\varepsilon$. Assuming linear axial
displacement the shape function in the basic system is

\begin{equation}
\label{eq:N}
{\bf N}(x) =
\left[ \begin{array}{c} N_1(x) \end{array} \right] =
\left[ \begin{array}{c} \frac{x}{L} \end{array}
\right].
\end{equation}

\noindent The strain-displacement matrix contains the shape function derivative.
Axial strain is the first derivative of the axial displacement,

\begin{equation}
{\bf a}(x) = \left[ \begin{array}{c}
N_{1,x} \end{array}
\right].
\end{equation}

\noindent Using the shape function defined in equation~\ref{eq:N}, the
strain-displacement matrix is then,

\begin{equation}
{\bf a}(x) = \left[ \begin{array}{c} \frac{1}{L}
\end{array}
\right].
\end{equation}

\noindent Thus, the axial strain, $\varepsilon$, is constant along the element
length and equation~\ref{eq:e=av} reduces to

\begin{equation}
\varepsilon(x) = \frac{v_1}{L}.
\end{equation}

After computing the axial strain, the method {\em setTrialStrain()} should be invoked
with the updated strain.

\subsection{Equilibrium}
Using the principle of virtual displacements (virtual work),
equilibrium between element end force, {\bf q}, and section stress
resultant, {\bf s},
is satisfied weakly, or in an average sense, along the element length,

\begin{equation}
\label{eq:q}
{\bf q} =  \left[ \begin{array}{c} q_1 \end{array} \right] =
\int_0^L {\bf a}(x)^T {\bf s}(x) \: dx,
\end{equation}

\noindent where the section stress resultant is the axial force, $P$.
For the truss element, the stress resultant is computed by integrating
constant material stress, $\sigma$, over the cross-section area, $A$,

\begin{equation}
{\bf s}(x) =
\left[ \begin{array}{c} P(x) \end{array} \right] =
\left[ \begin{array}{c} \sigma A \end{array} \right],
\end{equation}

\noindent where $\sigma$ is constant since the axial strain does
not vary along the element length. The integral in equation~\ref{eq:q}
reduces to

\begin{equation}
q_1 = \sigma A,
\end{equation}

\noindent since ${\bf a}(x) = \frac{1}{L}$.
To obtain the current value of material stress, $\sigma$, the method
{\em getStress()} must be invoked. Then the truss force can be transformed
to the global system via equation~\ref{eq:p=Tq}, i.e.,

\begin{equation}
{\bf p} = {\bf T}^T q_1.
\end{equation}

\subsection{Element Stiffness}
To solve the structural system of equations, the element stiffness must be assembled
along with the resisting force. The element stiffness is obtained by taking the
partial derivative of equation~\ref{eq:p=Tq} with respect to displacements,
{\bf u}.

\begin{align}
{\bf k} &= \pd{\bf p}{\bf u}\\
&= \pd{\bf p}{\bf q} \pd{\bf q}{\bf v} \pd{\bf v}{\bf u} \\
{\bf k} &= \label{eq:k} {\bf T}^T {\bf k}_b {\bf T}
\end{align}

\noindent The basic element stiffness, ${\bf k}_b$, is the partial derivative
of the basic forces, {\bf q}, with respect to the basic displacements, ${\bf v}$.
Differentiating equation~\ref{eq:q} gives,

\begin{align}
{\bf k}_b &= \pd{\bf q}{\bf v} \\
&= \int_0^L {\bf a}(x)^T \pd{\bf s}{\bf v} \: dx \\
&= \int_0^L {\bf a}(x)^T \pd{\bf s}{\bf e} \pd{\bf e}{\bf v} \: dx \\
{\bf k}_b &= \int_0^L {\bf a}(x)^T {\bf k}_s(x) {\bf a}(x) \: dx \\
\end{align}

\noindent Recalling that ${\bf a}(x) = \frac{1}{L}$, integration along the
element length gives,

\begin{equation}
{\bf k}_b = \label{eq:kb} \frac{{\bf k}_s}{L},
\end{equation}

\noindent for a prismatic element where ${\bf k}_s$ is constant.

The section tangent stiffness matrix can be manipulated further and put
in terms of the material tangent. Recalling that ${\bf s} = \sigma A$ and
${\bf e} = \varepsilon$,

\begin{align}
{\bf k}_s &= \pd{\bf s}{\bf e} \\
&= \pd{\bf s}{\varepsilon}\pd{\varepsilon}{\bf e} \\
&= \pd{\sigma}{\varepsilon} A \\
{\bf k}_s &= \label{eq:ks} D_t A,
\end{align}

\noindent where $D_t$ is the material tangent, which is returned upon invoking
the method {\em getTangent()}. Combining equations~\ref{eq:k},~\ref{eq:kb},
and~\ref{eq:ks}, the familiar truss stiffness equation is recovered,

\begin{equation}
{\bf k} = {\bf T}^T \frac{D_t A}{L} {\bf T}.
\end{equation}

\end{document}