From c3f57fd8365f36c625fe85ecb95de8a2bd0cb402 Mon Sep 17 00:00:00 2001 From: Samuel Crawford Date: Fri, 14 Jul 2023 13:27:06 -0400 Subject: [PATCH] update GlassBR to generate output requirement --- .../glassbr/lib/Drasil/GlassBR/Body.hs | 6 +- .../glassbr/lib/Drasil/GlassBR/DataDefs.hs | 6 +- .../lib/Drasil/GlassBR/Requirements.hs | 20 +- .../glassbr/lib/Drasil/GlassBR/Symbols.hs | 9 +- .../glassbr/lib/Drasil/GlassBR/Unitals.hs | 4 +- code/stable/glassbr/SRS/HTML/GlassBR_SRS.html | 28 +-- .../stable/glassbr/SRS/JSON/GlassBR_SRS.ipynb | 28 +-- code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex | 28 +-- code/stable/glassbr/src/cpp/Control.cpp | 2 +- code/stable/glassbr/src/cpp/OutputFormat.cpp | 43 ++++- code/stable/glassbr/src/cpp/OutputFormat.hpp | 15 +- code/stable/glassbr/src/csharp/Control.cs | 2 +- .../stable/glassbr/src/csharp/OutputFormat.cs | 52 ++++- .../glassbr/src/java/GlassBR/Control.java | 2 +- .../src/java/GlassBR/OutputFormat.java | 52 ++++- code/stable/glassbr/src/python/Control.py | 2 +- .../stable/glassbr/src/python/OutputFormat.py | 52 ++++- .../glassbr/src/swift/OutputFormat.swift | 178 +++++++++++++++++- code/stable/glassbr/src/swift/main.swift | 2 +- 19 files changed, 413 insertions(+), 118 deletions(-) diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs index a9282a15e2..527e5ef0e9 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs @@ -34,7 +34,7 @@ import Drasil.GlassBR.Assumptions (assumptionConstants, assumptions) import Drasil.GlassBR.Changes (likelyChgs, unlikelyChgs) import Drasil.GlassBR.Concepts (acronyms, blastRisk, glaPlane, glaSlab, glassBR, ptOfExplsn, con, con', glass) -import Drasil.GlassBR.DataDefs (qDefns, configFp) +import Drasil.GlassBR.DataDefs (qDefns, configFp, r6DDs) import qualified Drasil.GlassBR.DataDefs as GB (dataDefs) import Drasil.GlassBR.Figures import Drasil.GlassBR.Goals (goals) @@ -44,7 +44,7 @@ import Drasil.GlassBR.Requirements (funcReqs, inReqDesc, funcReqsTables, nonfunc import Drasil.GlassBR.Symbols (symbolsForTable, thisSymbols) import Drasil.GlassBR.TMods (tMods) import Drasil.GlassBR.Unitals (blast, blastTy, bomb, explosion, constants, - constrained, inputDataConstraints, inputs, outputs, specParamVals, glassTy, + constrained, inputDataConstraints, inputs, specParamVals, glassTy, glassTypes, glBreakage, lateralLoad, load, loadTypes, pbTol, probBr, stressDistFac, probBreak, sD, termsWithAccDefn, termsWithDefsOnly, terms) @@ -70,7 +70,7 @@ si = SI { _datadefs = GB.dataDefs, _configFiles = configFp, _inputs = inputs, - _outputs = outputs, + _outputs = map qw iMods ++ map qw r6DDs, _defSequence = qDefns, _constraints = constrained, _constants = constants, diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs index fd8dc36da9..ded6eae98c 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs @@ -1,6 +1,7 @@ module Drasil.GlassBR.DataDefs (aspRat, dataDefs, dimLL, qDefns, glaTyFac, hFromt, loadDF, nonFL, risk, standOffDis, strDisFac, tolPre, tolStrDisFac, - eqTNTWDD, probOfBreak, calofCapacity, calofDemand, pbTolUsr, qRef,configFp) + eqTNTWDD, probOfBreak, calofCapacity, calofDemand, pbTolUsr, qRef, configFp, + r6DDs) where import Control.Lens ((^.)) @@ -36,6 +37,9 @@ dataDefs = [risk, hFromt, loadDF, strDisFac, nonFL, glaTyFac, dimLL, tolPre, tolStrDisFac, standOffDis, aspRat, eqTNTWDD, probOfBreak, calofCapacity, calofDemand] +r6DDs :: [DataDefinition] +r6DDs = [risk, strDisFac, nonFL, glaTyFac, dimLL, tolPre, tolStrDisFac, hFromt, aspRat] + qDefns :: [Block SimpleQDef] qDefns = Parallel hFromtQD {-DD2-} [glaTyFacQD {-DD6-}] : --can be calculated on their own map (`Parallel` []) [dimLLQD {-DD7-}, strDisFacQD {-DD4-}, riskQD {-DD1-}, diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs index f92bf55f30..14b8ef834e 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs @@ -25,7 +25,6 @@ import Drasil.GlassBR.Assumptions (assumpSV, assumpGL, assumptionConstants) import Drasil.GlassBR.Concepts (glass) import Drasil.GlassBR.DataDefs (aspRat, dimLL, glaTyFac, hFromt, loadDF, nonFL, risk, standOffDis, strDisFac, tolPre, tolStrDisFac) -import Drasil.GlassBR.IMods (iMods) import Drasil.GlassBR.TMods (lrIsSafe, pbIsSafe) import Drasil.GlassBR.Unitals (blast, isSafeLR, isSafePb, loadSF, notSafe, pbTolfail, safeMessage) @@ -34,19 +33,18 @@ import Drasil.GlassBR.Unitals (blast, isSafeLR, isSafePb, loadSF, notSafe, funcReqs :: [ConceptInstance] funcReqs = [sysSetValsFollowingAssumps, checkInputWithDataCons, - outputValsAndKnownValues, checkGlassSafety, outputValues] + outputValsAndKnownValues, checkGlassSafety] funcReqsTables :: [LabelledContent] -funcReqsTables = [sysSetValsFollowingAssumpsTable, outputValuesTable] +funcReqsTables = [sysSetValsFollowingAssumpsTable] sysSetValsFollowingAssumps, checkInputWithDataCons, - outputValsAndKnownValues, checkGlassSafety, outputValues :: ConceptInstance + outputValsAndKnownValues, checkGlassSafety :: ConceptInstance sysSetValsFollowingAssumps = cic "sysSetValsFollowingAssumps" sysSetValsFollowingAssumpsDesc "System-Set-Values-Following-Assumptions" funcReqDom checkInputWithDataCons = cic "checkInputWithDataCons" checkInputWithDataConsDesc "Check-Input-with-Data_Constraints" funcReqDom outputValsAndKnownValues = cic "outputValsAndKnownValues" outputValsAndKnownValuesDesc "Output-Values-and-Known-Values" funcReqDom checkGlassSafety = cic "checkGlassSafety" checkGlassSafetyDesc "Check-Glass-Safety" funcReqDom -outputValues = cic "outputValues" outputValuesDesc "Output-Values" funcReqDom inReqDesc, sysSetValsFollowingAssumpsDesc, checkInputWithDataConsDesc, outputValsAndKnownValuesDesc, checkGlassSafetyDesc :: Sentence @@ -60,7 +58,7 @@ sysSetValsFollowingAssumpsTable :: LabelledContent sysSetValsFollowingAssumpsTable = mkValsSourceTable (mkQRTupleRef r2AQs r2ARs ++ mkQRTuple r2DDs) "ReqAssignments" (S "Required Assignments" `follows` sysSetValsFollowingAssumps) where - r2AQs = qw loadSF : map qw (take 4 assumptionConstants) + r2AQs = qw loadSF : map qw (take 4 assumptionConstants) r2ARs = assumpGL : replicate 4 assumpSV r2DDs = [loadDF, hFromt, glaTyFac, standOffDis, aspRat] @@ -82,16 +80,6 @@ checkGlassSafetyDesc = foldlSent_ [S "If", eS $ sy isSafePb $&& sy isSafeLR, S "If the", phrase condition, S "is false, then", phrase output_, phraseNP (the message), Quote (notSafe ^. defn)] -outputValuesDesc :: Sentence -outputValuesDesc = foldlSent [titleize output_, pluralNP (the value), S "from the table for", namedRef outputValuesTable (S "Required Outputs")] - -outputValuesTable :: LabelledContent -outputValuesTable = mkValsSourceTable (mkQRTuple iMods ++ mkQRTuple r6DDs) "ReqOutputs" - (S "Required" +:+ titleize' output_ `follows` outputValues) - where - r6DDs :: [DataDefinition] - r6DDs = [risk, strDisFac, nonFL, glaTyFac, dimLL, tolPre, tolStrDisFac, hFromt, aspRat] - {--Nonfunctional Requirements--} nonfuncReqs :: [ConceptInstance] diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs index e46a45fadd..5ff97095ed 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs @@ -3,20 +3,21 @@ module Drasil.GlassBR.Symbols where import Language.Drasil (QuantityDict, qw) import Language.Drasil.Code (Mod(Mod), asVC) +import Drasil.GlassBR.DataDefs (r6DDs) import Drasil.GlassBR.IMods (iMods) import Drasil.GlassBR.ModuleDefs (allMods, implVars) -import Drasil.GlassBR.Unitals (inputDataConstraints, inputs, outputs, - specParamVals, symbols, symbolsWithDefns, unitless, tmSymbols, interps) +import Drasil.GlassBR.Unitals (inputDataConstraints, inputs, + specParamVals, symbols, symbolsWithDefns, unitless, tmSymbols, interps, probBr) import Data.List ((\\)) symbolsForTable :: [QuantityDict] -symbolsForTable = inputs ++ outputs ++ tmSymbols ++ map qw specParamVals ++ +symbolsForTable = inputs ++ map qw iMods ++ map qw r6DDs ++ tmSymbols ++ map qw specParamVals ++ map qw symbolsWithDefns ++ map qw symbols ++ map qw unitless ++ map qw inputDataConstraints ++ interps thisSymbols :: [QuantityDict] -thisSymbols = map qw iMods +thisSymbols = qw probBr : map qw iMods ++ map qw r6DDs -- include all module functions as symbols ++ (map asVC (concatMap (\(Mod _ _ _ _ l) -> l) allMods) \\ symbolsForTable) ++ map qw implVars ++ symbolsForTable diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs index ae3c9c2474..7e5b4f252c 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs @@ -115,8 +115,8 @@ glassTypeCon = constrainedNRV' (dqdNoUnit glassTy lG String) {--} -outputs :: [QuantityDict] -outputs = map qw [isSafePb, isSafeLR] ++ [qw probBr, qw stressDistFac] +-- outputs :: [QuantityDict] +-- outputs = map qw [isSafePb, isSafeLR] ++ [qw probBr, qw stressDistFac] tmSymbols :: [QuantityDict] tmSymbols = map qw [probFail, pbTolfail] ++ map qw [isSafeProb, isSafeLoad] diff --git a/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html b/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html index 50029873f8..fadec92395 100644 --- a/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html +++ b/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html @@ -253,12 +253,12 @@

Table of Symbols

isSafeLR - 3 second load equivalent resistance safety requirement + Safety Req-LR -- isSafePb - Probability of glass breakage safety requirement + Safety Req-Pb -- @@ -2318,7 +2318,7 @@

Functional Requirements

- Output-Values: Output the values from the table for Required Outputs. + Output-Values: Output the values from Tab:ReqOutputs.

@@ -2470,67 +2470,67 @@

Functional Requirements

AR Aspect ratio - DD:aspectRatio + -- B Risk of failure - DD:riskFun + -- GTF Glass type factor - DD:gTF + -- h Minimum thickness - DD:minThick + m isSafeLR Safety Req-LR - IM:isSafeLR + -- isSafePb Safety Req-Pb - IM:isSafePb + -- J Stress distribution factor (Function) - DD:stressDistFac + -- Jtol Stress distribution factor (Function) based on Pbtol - DD:sdfTol + -- NFL Non-factored load - DD:nFL + Pa Dimensionless load - DD:dimlessLoad + -- tol Tolerable load - DD:tolLoad + -- diff --git a/code/stable/glassbr/SRS/JSON/GlassBR_SRS.ipynb b/code/stable/glassbr/SRS/JSON/GlassBR_SRS.ipynb index f74e2dd394..a34ebe3f34 100644 --- a/code/stable/glassbr/SRS/JSON/GlassBR_SRS.ipynb +++ b/code/stable/glassbr/SRS/JSON/GlassBR_SRS.ipynb @@ -105,8 +105,8 @@ "|$interpY$|InterpY|--|\n", "|$interpZ$|InterpZ|--|\n", "|$isSafeLoad$|Load resistance safety requirement|--|\n", - "|$isSafeLR$|3 second load equivalent resistance safety requirement|--|\n", - "|$isSafePb$|Probability of glass breakage safety requirement|--|\n", + "|$isSafeLR$|Safety Req-LR|--|\n", + "|$isSafePb$|Safety Req-Pb|--|\n", "|$isSafeProb$|Probability of failure safety requirement|--|\n", "|$J$|Stress distribution factor (Function)|--|\n", "|$J_max$|Maximum value for the stress distribution factor|--|\n", @@ -1808,7 +1808,7 @@ "\n", "\n", "
\n", - "Output-Values: Output the values from the table for [Required Outputs](#Table:ReqOutputs).\n", + "Output-Values: Output the values from [Tab:ReqOutputs](#Table:ReqOutputs).\n", "\n", "
\n", "\n", @@ -1848,17 +1848,17 @@ "\n", "|Symbol|Description|Source|Units|\n", "|:--- |:--- |:--- |:--- |\n", - "|$AR$|Aspect ratio|[DD:aspectRatio](#DD:aspectRatio)|--|\n", - "|$B$|Risk of failure|[DD:riskFun](#DD:riskFun)|--|\n", - "|$GTF$|Glass type factor|[DD:gTF](#DD:gTF)|--|\n", - "|$h$|Minimum thickness|[DD:minThick](#DD:minThick)|$m$|\n", - "|$isSafeLR$|Safety Req-LR|[IM:isSafeLR](#IM:isSafeLR)|--|\n", - "|$isSafePb$|Safety Req-Pb|[IM:isSafePb](#IM:isSafePb)|--|\n", - "|$J$|Stress distribution factor (Function)|[DD:stressDistFac](#DD:stressDistFac)|--|\n", - "|$J_tol$|Stress distribution factor (Function) based on Pbtol|[DD:sdfTol](#DD:sdfTol)|--|\n", - "|$NFL$|Non-factored load|[DD:nFL](#DD:nFL)|$Pa$|\n", - "|$q̂$|Dimensionless load|[DD:dimlessLoad](#DD:dimlessLoad)|--|\n", - "|$q̂_tol$|Tolerable load|[DD:tolLoad](#DD:tolLoad)|--|\n", + "|$AR$|Aspect ratio||--|\n", + "|$B$|Risk of failure||--|\n", + "|$GTF$|Glass type factor||--|\n", + "|$h$|Minimum thickness||$m$|\n", + "|$isSafeLR$|Safety Req-LR||--|\n", + "|$isSafePb$|Safety Req-Pb||--|\n", + "|$J$|Stress distribution factor (Function)||--|\n", + "|$J_tol$|Stress distribution factor (Function) based on Pbtol||--|\n", + "|$NFL$|Non-factored load||$Pa$|\n", + "|$q̂$|Dimensionless load||--|\n", + "|$q̂_tol$|Tolerable load||--|\n", "\n", "\n", "## Non-Functional Requirements\n", diff --git a/code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex b/code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex index 070c702eaa..6064c79ad9 100644 --- a/code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex +++ b/code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex @@ -92,9 +92,9 @@ \subsection{Table of Symbols} \\ $\mathit{isSafeLoad}$ & Load resistance safety requirement & -- \\ -$\mathit{isSafeLR}$ & 3 second load equivalent resistance safety requirement & -- +$\mathit{isSafeLR}$ & Safety Req-LR & -- \\ -$\mathit{isSafePb}$ & Probability of glass breakage safety requirement & -- +$\mathit{isSafePb}$ & Safety Req-Pb & -- \\ $\mathit{isSafeProb}$ & Probability of failure safety requirement & -- \\ @@ -1280,7 +1280,7 @@ \subsection{Functional Requirements} \item[Check-Input-with-Data\_Constraints:\phantomsection\label{checkInputWithDataCons}]{The system shall check the entered input values to ensure that they do not exceed the \hyperref[Sec:DataConstraints]{data constraints}. If any of the input values are out of bounds, an error message is displayed and the calculations stop.} \item[Output-Values-and-Known-Values:\phantomsection\label{outputValsAndKnownValues}]{Output the input values from \hyperref[inputValues]{FR:Input-Values} and the known values from \hyperref[sysSetValsFollowingAssumps]{FR:System-Set-Values-Following-Assumptions}.} \item[Check-Glass-Safety:\phantomsection\label{checkGlassSafety}]{If $\mathit{isSafePb}\land{}\mathit{isSafeLR}$ (from \hyperref[TM:isSafeProb]{TM:isSafeProb} and \hyperref[TM:isSafeLoad]{TM:isSafeLoad}), output the message ``For the given input parameters, the glass is considered safe.'' If the condition is false, then output the message ``For the given input parameters, the glass is NOT considered safe.''} -\item[Output-Values:\phantomsection\label{outputValues}]{Output the values from the table for \hyperref[Table:ReqOutputs]{Required Outputs}.} +\item[Output-Values:\phantomsection\label{outputValues}]{Output the values from \hyperref[Table:ReqOutputs]{Tab:ReqOutputs}.} \end{itemize} \begin{longtblr} [caption={Required Inputs following \hyperref[inputValues]{FR:Input-Values}}] @@ -1339,27 +1339,27 @@ \subsection{Functional Requirements} {colspec={l X[l] l l}, rowhead=1, hline{1,Z}=\heavyrulewidth, hline{2}=\lightrulewidth} \textbf{Symbol} & \textbf{Description} & \textbf{Source} & \textbf{Units} \\ -$\mathit{AR}$ & Aspect ratio & \hyperref[DD:aspectRatio]{DD:aspectRatio} & -- +$\mathit{AR}$ & Aspect ratio & & -- \\ -$B$ & Risk of failure & \hyperref[DD:riskFun]{DD:riskFun} & -- +$B$ & Risk of failure & & -- \\ -$\mathit{GTF}$ & Glass type factor & \hyperref[DD:gTF]{DD:gTF} & -- +$\mathit{GTF}$ & Glass type factor & & -- \\ -$h$ & Minimum thickness & \hyperref[DD:minThick]{DD:minThick} & ${\text{m}}$ +$h$ & Minimum thickness & & ${\text{m}}$ \\ -$\mathit{isSafeLR}$ & Safety Req-LR & \hyperref[IM:isSafeLR]{IM:isSafeLR} & -- +$\mathit{isSafeLR}$ & Safety Req-LR & & -- \\ -$\mathit{isSafePb}$ & Safety Req-Pb & \hyperref[IM:isSafePb]{IM:isSafePb} & -- +$\mathit{isSafePb}$ & Safety Req-Pb & & -- \\ -$J$ & Stress distribution factor (Function) & \hyperref[DD:stressDistFac]{DD:stressDistFac} & -- +$J$ & Stress distribution factor (Function) & & -- \\ -${J_{\text{tol}}}$ & Stress distribution factor (Function) based on Pbtol & \hyperref[DD:sdfTol]{DD:sdfTol} & -- +${J_{\text{tol}}}$ & Stress distribution factor (Function) based on Pbtol & & -- \\ -$\mathit{NFL}$ & Non-factored load & \hyperref[DD:nFL]{DD:nFL} & ${\text{Pa}}$ +$\mathit{NFL}$ & Non-factored load & & ${\text{Pa}}$ \\ -$\hat{q}$ & Dimensionless load & \hyperref[DD:dimlessLoad]{DD:dimlessLoad} & -- +$\hat{q}$ & Dimensionless load & & -- \\ -${\hat{q}_{\text{tol}}}$ & Tolerable load & \hyperref[DD:tolLoad]{DD:tolLoad} & -- +${\hat{q}_{\text{tol}}}$ & Tolerable load & & -- \label{Table:ReqOutputs} \end{longtblr} \subsection{Non-Functional Requirements} diff --git a/code/stable/glassbr/src/cpp/Control.cpp b/code/stable/glassbr/src/cpp/Control.cpp index 7b17e07774..0cc0ff4835 100644 --- a/code/stable/glassbr/src/cpp/Control.cpp +++ b/code/stable/glassbr/src/cpp/Control.cpp @@ -99,7 +99,7 @@ int main(int argc, const char *argv[]) { outfile << isSafePb; outfile << " in module Control" << std::endl; outfile.close(); - write_output(isSafePb, isSafeLR, P_b, J); + write_output(inParams, isSafePb, isSafeLR, B, J, NFL, q_hat, q_hat_tol, J_tol); return 0; } diff --git a/code/stable/glassbr/src/cpp/OutputFormat.cpp b/code/stable/glassbr/src/cpp/OutputFormat.cpp index 4e52030fce..cd7e249e10 100644 --- a/code/stable/glassbr/src/cpp/OutputFormat.cpp +++ b/code/stable/glassbr/src/cpp/OutputFormat.cpp @@ -4,24 +4,41 @@ #include #include +#include "InputParameters.hpp" + using std::ofstream; using std::string; -void write_output(bool isSafePb, bool isSafeLR, double P_b, double J) { +void write_output(InputParameters &inParams, bool isSafePb, bool isSafeLR, double B, double J, double NFL, double q_hat, double q_hat_tol, double J_tol) { ofstream outfile; outfile.open("log.txt", std::fstream::app); outfile << "function write_output called with inputs: {" << std::endl; + outfile << " inParams = "; + outfile << "Instance of InputParameters object"; + outfile << ", " << std::endl; outfile << " isSafePb = "; outfile << isSafePb; outfile << ", " << std::endl; outfile << " isSafeLR = "; outfile << isSafeLR; outfile << ", " << std::endl; - outfile << " P_b = "; - outfile << P_b; + outfile << " B = "; + outfile << B; outfile << ", " << std::endl; outfile << " J = "; - outfile << J << std::endl; + outfile << J; + outfile << ", " << std::endl; + outfile << " NFL = "; + outfile << NFL; + outfile << ", " << std::endl; + outfile << " q_hat = "; + outfile << q_hat; + outfile << ", " << std::endl; + outfile << " q_hat_tol = "; + outfile << q_hat_tol; + outfile << ", " << std::endl; + outfile << " J_tol = "; + outfile << J_tol << std::endl; outfile << " }" << std::endl; outfile.close(); @@ -31,9 +48,23 @@ void write_output(bool isSafePb, bool isSafeLR, double P_b, double J) { outputfile << isSafePb << std::endl; outputfile << "isSafeLR = "; outputfile << isSafeLR << std::endl; - outputfile << "P_b = "; - outputfile << P_b << std::endl; + outputfile << "B = "; + outputfile << B << std::endl; outputfile << "J = "; outputfile << J << std::endl; + outputfile << "NFL = "; + outputfile << NFL << std::endl; + outputfile << "GTF = "; + outputfile << inParams.GTF << std::endl; + outputfile << "q_hat = "; + outputfile << q_hat << std::endl; + outputfile << "q_hat_tol = "; + outputfile << q_hat_tol << std::endl; + outputfile << "J_tol = "; + outputfile << J_tol << std::endl; + outputfile << "h = "; + outputfile << inParams.h << std::endl; + outputfile << "AR = "; + outputfile << inParams.AR << std::endl; outputfile.close(); } diff --git a/code/stable/glassbr/src/cpp/OutputFormat.hpp b/code/stable/glassbr/src/cpp/OutputFormat.hpp index 057c41fb12..0a676ee62f 100644 --- a/code/stable/glassbr/src/cpp/OutputFormat.hpp +++ b/code/stable/glassbr/src/cpp/OutputFormat.hpp @@ -7,15 +7,22 @@ #include +#include "InputParameters.hpp" + using std::ofstream; using std::string; /** \brief Writes the output values to output.txt - \param isSafePb probability of glass breakage safety requirement - \param isSafeLR 3 second load equivalent resistance safety requirement - \param P_b probability of breakage: the fraction of glass lites or plies that would break at the first occurrence of a specified load and duration, typically expressed in lites per 1000 (Ref: astm2016) + \param inParams structure holding the input values + \param isSafePb Safety Req-Pb + \param isSafeLR Safety Req-LR + \param B risk of failure \param J stress distribution factor (Function) + \param NFL non-factored load: three second duration uniform load associated with a probability of breakage less than or equal to 8 lites per 1000 for monolithic AN glass (Pa) + \param q_hat dimensionless load + \param q_hat_tol tolerable load + \param J_tol stress distribution factor (Function) based on Pbtol */ -void write_output(bool isSafePb, bool isSafeLR, double P_b, double J); +void write_output(InputParameters &inParams, bool isSafePb, bool isSafeLR, double B, double J, double NFL, double q_hat, double q_hat_tol, double J_tol); #endif diff --git a/code/stable/glassbr/src/csharp/Control.cs b/code/stable/glassbr/src/csharp/Control.cs index 9c6dc9229b..b0553407a7 100644 --- a/code/stable/glassbr/src/csharp/Control.cs +++ b/code/stable/glassbr/src/csharp/Control.cs @@ -88,6 +88,6 @@ public static void Main(string[] args) { outfile.Write(isSafePb); outfile.WriteLine(" in module Control"); outfile.Close(); - OutputFormat.write_output(isSafePb, isSafeLR, P_b, J); + OutputFormat.write_output(inParams, isSafePb, isSafeLR, B, J, NFL, q_hat, q_hat_tol, J_tol); } } diff --git a/code/stable/glassbr/src/csharp/OutputFormat.cs b/code/stable/glassbr/src/csharp/OutputFormat.cs index b8a060ae7d..8b57d9f253 100644 --- a/code/stable/glassbr/src/csharp/OutputFormat.cs +++ b/code/stable/glassbr/src/csharp/OutputFormat.cs @@ -8,26 +8,46 @@ public class OutputFormat { /** \brief Writes the output values to output.txt - \param isSafePb probability of glass breakage safety requirement - \param isSafeLR 3 second load equivalent resistance safety requirement - \param P_b probability of breakage: the fraction of glass lites or plies that would break at the first occurrence of a specified load and duration, typically expressed in lites per 1000 (Ref: astm2016) + \param inParams structure holding the input values + \param isSafePb Safety Req-Pb + \param isSafeLR Safety Req-LR + \param B risk of failure \param J stress distribution factor (Function) + \param NFL non-factored load: three second duration uniform load associated with a probability of breakage less than or equal to 8 lites per 1000 for monolithic AN glass (Pa) + \param q_hat dimensionless load + \param q_hat_tol tolerable load + \param J_tol stress distribution factor (Function) based on Pbtol */ - public static void write_output(Boolean isSafePb, Boolean isSafeLR, double P_b, double J) { + public static void write_output(InputParameters inParams, Boolean isSafePb, Boolean isSafeLR, double B, double J, double NFL, double q_hat, double q_hat_tol, double J_tol) { StreamWriter outfile; outfile = new StreamWriter("log.txt", true); outfile.WriteLine("function write_output called with inputs: {"); + outfile.Write(" inParams = "); + outfile.Write("Instance of InputParameters object"); + outfile.WriteLine(", "); outfile.Write(" isSafePb = "); outfile.Write(isSafePb); outfile.WriteLine(", "); outfile.Write(" isSafeLR = "); outfile.Write(isSafeLR); outfile.WriteLine(", "); - outfile.Write(" P_b = "); - outfile.Write(P_b); + outfile.Write(" B = "); + outfile.Write(B); outfile.WriteLine(", "); outfile.Write(" J = "); - outfile.WriteLine(J); + outfile.Write(J); + outfile.WriteLine(", "); + outfile.Write(" NFL = "); + outfile.Write(NFL); + outfile.WriteLine(", "); + outfile.Write(" q_hat = "); + outfile.Write(q_hat); + outfile.WriteLine(", "); + outfile.Write(" q_hat_tol = "); + outfile.Write(q_hat_tol); + outfile.WriteLine(", "); + outfile.Write(" J_tol = "); + outfile.WriteLine(J_tol); outfile.WriteLine(" }"); outfile.Close(); @@ -37,10 +57,24 @@ public static void write_output(Boolean isSafePb, Boolean isSafeLR, double P_b, outputfile.WriteLine(isSafePb); outputfile.Write("isSafeLR = "); outputfile.WriteLine(isSafeLR); - outputfile.Write("P_b = "); - outputfile.WriteLine(P_b); + outputfile.Write("B = "); + outputfile.WriteLine(B); outputfile.Write("J = "); outputfile.WriteLine(J); + outputfile.Write("NFL = "); + outputfile.WriteLine(NFL); + outputfile.Write("GTF = "); + outputfile.WriteLine(inParams.GTF); + outputfile.Write("q_hat = "); + outputfile.WriteLine(q_hat); + outputfile.Write("q_hat_tol = "); + outputfile.WriteLine(q_hat_tol); + outputfile.Write("J_tol = "); + outputfile.WriteLine(J_tol); + outputfile.Write("h = "); + outputfile.WriteLine(inParams.h); + outputfile.Write("AR = "); + outputfile.WriteLine(inParams.AR); outputfile.Close(); } } diff --git a/code/stable/glassbr/src/java/GlassBR/Control.java b/code/stable/glassbr/src/java/GlassBR/Control.java index 9366fe7d91..df1123f9b0 100644 --- a/code/stable/glassbr/src/java/GlassBR/Control.java +++ b/code/stable/glassbr/src/java/GlassBR/Control.java @@ -93,6 +93,6 @@ public static void main(String[] args) throws Exception, FileNotFoundException, outfile.print(isSafePb); outfile.println(" in module Control"); outfile.close(); - OutputFormat.write_output(isSafePb, isSafeLR, P_b, J); + OutputFormat.write_output(inParams, isSafePb, isSafeLR, B, J, NFL, q_hat, q_hat_tol, J_tol); } } diff --git a/code/stable/glassbr/src/java/GlassBR/OutputFormat.java b/code/stable/glassbr/src/java/GlassBR/OutputFormat.java index 282332cf29..d8faf1f231 100644 --- a/code/stable/glassbr/src/java/GlassBR/OutputFormat.java +++ b/code/stable/glassbr/src/java/GlassBR/OutputFormat.java @@ -12,26 +12,46 @@ public class OutputFormat { /** \brief Writes the output values to output.txt - \param isSafePb probability of glass breakage safety requirement - \param isSafeLR 3 second load equivalent resistance safety requirement - \param P_b probability of breakage: the fraction of glass lites or plies that would break at the first occurrence of a specified load and duration, typically expressed in lites per 1000 (Ref: astm2016) + \param inParams structure holding the input values + \param isSafePb Safety Req-Pb + \param isSafeLR Safety Req-LR + \param B risk of failure \param J stress distribution factor (Function) + \param NFL non-factored load: three second duration uniform load associated with a probability of breakage less than or equal to 8 lites per 1000 for monolithic AN glass (Pa) + \param q_hat dimensionless load + \param q_hat_tol tolerable load + \param J_tol stress distribution factor (Function) based on Pbtol */ - public static void write_output(boolean isSafePb, boolean isSafeLR, double P_b, double J) throws IOException { + public static void write_output(InputParameters inParams, boolean isSafePb, boolean isSafeLR, double B, double J, double NFL, double q_hat, double q_hat_tol, double J_tol) throws IOException { PrintWriter outfile; outfile = new PrintWriter(new FileWriter(new File("log.txt"), true)); outfile.println("function write_output called with inputs: {"); + outfile.print(" inParams = "); + outfile.print("Instance of InputParameters object"); + outfile.println(", "); outfile.print(" isSafePb = "); outfile.print(isSafePb); outfile.println(", "); outfile.print(" isSafeLR = "); outfile.print(isSafeLR); outfile.println(", "); - outfile.print(" P_b = "); - outfile.print(P_b); + outfile.print(" B = "); + outfile.print(B); outfile.println(", "); outfile.print(" J = "); - outfile.println(J); + outfile.print(J); + outfile.println(", "); + outfile.print(" NFL = "); + outfile.print(NFL); + outfile.println(", "); + outfile.print(" q_hat = "); + outfile.print(q_hat); + outfile.println(", "); + outfile.print(" q_hat_tol = "); + outfile.print(q_hat_tol); + outfile.println(", "); + outfile.print(" J_tol = "); + outfile.println(J_tol); outfile.println(" }"); outfile.close(); @@ -41,10 +61,24 @@ public static void write_output(boolean isSafePb, boolean isSafeLR, double P_b, outputfile.println(isSafePb); outputfile.print("isSafeLR = "); outputfile.println(isSafeLR); - outputfile.print("P_b = "); - outputfile.println(P_b); + outputfile.print("B = "); + outputfile.println(B); outputfile.print("J = "); outputfile.println(J); + outputfile.print("NFL = "); + outputfile.println(NFL); + outputfile.print("GTF = "); + outputfile.println(inParams.GTF); + outputfile.print("q_hat = "); + outputfile.println(q_hat); + outputfile.print("q_hat_tol = "); + outputfile.println(q_hat_tol); + outputfile.print("J_tol = "); + outputfile.println(J_tol); + outputfile.print("h = "); + outputfile.println(inParams.h); + outputfile.print("AR = "); + outputfile.println(inParams.AR); outputfile.close(); } } diff --git a/code/stable/glassbr/src/python/Control.py b/code/stable/glassbr/src/python/Control.py index be982c3fd0..3de2f8641e 100644 --- a/code/stable/glassbr/src/python/Control.py +++ b/code/stable/glassbr/src/python/Control.py @@ -86,4 +86,4 @@ print(isSafePb, end="", file=outfile) print(" in module Control", file=outfile) outfile.close() -OutputFormat.write_output(isSafePb, isSafeLR, P_b, J) +OutputFormat.write_output(inParams, isSafePb, isSafeLR, B, J, NFL, q_hat, q_hat_tol, J_tol) diff --git a/code/stable/glassbr/src/python/OutputFormat.py b/code/stable/glassbr/src/python/OutputFormat.py index 8898685d51..c463188fb8 100644 --- a/code/stable/glassbr/src/python/OutputFormat.py +++ b/code/stable/glassbr/src/python/OutputFormat.py @@ -2,24 +2,44 @@ # \author Nikitha Krithnan and W. Spencer Smith # \brief Provides the function for writing outputs ## \brief Writes the output values to output.txt -# \param isSafePb probability of glass breakage safety requirement -# \param isSafeLR 3 second load equivalent resistance safety requirement -# \param P_b probability of breakage: the fraction of glass lites or plies that would break at the first occurrence of a specified load and duration, typically expressed in lites per 1000 (Ref: astm2016) +# \param inParams structure holding the input values +# \param isSafePb Safety Req-Pb +# \param isSafeLR Safety Req-LR +# \param B risk of failure # \param J stress distribution factor (Function) -def write_output(isSafePb, isSafeLR, P_b, J): +# \param NFL non-factored load: three second duration uniform load associated with a probability of breakage less than or equal to 8 lites per 1000 for monolithic AN glass (Pa) +# \param q_hat dimensionless load +# \param q_hat_tol tolerable load +# \param J_tol stress distribution factor (Function) based on Pbtol +def write_output(inParams, isSafePb, isSafeLR, B, J, NFL, q_hat, q_hat_tol, J_tol): outfile = open("log.txt", "a") print("function write_output called with inputs: {", file=outfile) + print(" inParams = ", end="", file=outfile) + print("Instance of InputParameters object", end="", file=outfile) + print(", ", file=outfile) print(" isSafePb = ", end="", file=outfile) print(isSafePb, end="", file=outfile) print(", ", file=outfile) print(" isSafeLR = ", end="", file=outfile) print(isSafeLR, end="", file=outfile) print(", ", file=outfile) - print(" P_b = ", end="", file=outfile) - print(P_b, end="", file=outfile) + print(" B = ", end="", file=outfile) + print(B, end="", file=outfile) print(", ", file=outfile) print(" J = ", end="", file=outfile) - print(J, file=outfile) + print(J, end="", file=outfile) + print(", ", file=outfile) + print(" NFL = ", end="", file=outfile) + print(NFL, end="", file=outfile) + print(", ", file=outfile) + print(" q_hat = ", end="", file=outfile) + print(q_hat, end="", file=outfile) + print(", ", file=outfile) + print(" q_hat_tol = ", end="", file=outfile) + print(q_hat_tol, end="", file=outfile) + print(", ", file=outfile) + print(" J_tol = ", end="", file=outfile) + print(J_tol, file=outfile) print(" }", file=outfile) outfile.close() @@ -28,8 +48,22 @@ def write_output(isSafePb, isSafeLR, P_b, J): print(isSafePb, file=outputfile) print("isSafeLR = ", end="", file=outputfile) print(isSafeLR, file=outputfile) - print("P_b = ", end="", file=outputfile) - print(P_b, file=outputfile) + print("B = ", end="", file=outputfile) + print(B, file=outputfile) print("J = ", end="", file=outputfile) print(J, file=outputfile) + print("NFL = ", end="", file=outputfile) + print(NFL, file=outputfile) + print("GTF = ", end="", file=outputfile) + print(inParams.GTF, file=outputfile) + print("q_hat = ", end="", file=outputfile) + print(q_hat, file=outputfile) + print("q_hat_tol = ", end="", file=outputfile) + print(q_hat_tol, file=outputfile) + print("J_tol = ", end="", file=outputfile) + print(J_tol, file=outputfile) + print("h = ", end="", file=outputfile) + print(inParams.h, file=outputfile) + print("AR = ", end="", file=outputfile) + print(inParams.AR, file=outputfile) outputfile.close() diff --git a/code/stable/glassbr/src/swift/OutputFormat.swift b/code/stable/glassbr/src/swift/OutputFormat.swift index 2044588e74..ad1e90834a 100644 --- a/code/stable/glassbr/src/swift/OutputFormat.swift +++ b/code/stable/glassbr/src/swift/OutputFormat.swift @@ -5,12 +5,17 @@ import Foundation /** Writes the output values to output.txt - - Parameter isSafePb: probability of glass breakage safety requirement - - Parameter isSafeLR: 3 second load equivalent resistance safety requirement - - Parameter P_b: probability of breakage: the fraction of glass lites or plies that would break at the first occurrence of a specified load and duration, typically expressed in lites per 1000 (Ref: astm2016) + - Parameter inParams: structure holding the input values + - Parameter isSafePb: Safety Req-Pb + - Parameter isSafeLR: Safety Req-LR + - Parameter B: risk of failure - Parameter J: stress distribution factor (Function) + - Parameter NFL: non-factored load: three second duration uniform load associated with a probability of breakage less than or equal to 8 lites per 1000 for monolithic AN glass (Pa) + - Parameter q_hat: dimensionless load + - Parameter q_hat_tol: tolerable load + - Parameter J_tol: stress distribution factor (Function) based on Pbtol */ -func write_output(_ isSafePb: Bool, _ isSafeLR: Bool, _ P_b: Double, _ J: Double) throws -> Void { +func write_output(_ inParams: inout InputParameters, _ isSafePb: Bool, _ isSafeLR: Bool, _ B: Double, _ J: Double, _ NFL: Double, _ q_hat: Double, _ q_hat_tol: Double, _ J_tol: Double) throws -> Void { var outfile: FileHandle do { outfile = try FileHandle(forWritingTo: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("log.txt")) @@ -24,6 +29,22 @@ func write_output(_ isSafePb: Bool, _ isSafeLR: Bool, _ P_b: Double, _ J: Double } catch { throw "Error printing to file." } + do { + try outfile.write(contentsOf: Data(" inParams = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data("Instance of InputParameters object".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(", ".utf8)) + try outfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } do { try outfile.write(contentsOf: Data(" isSafePb = ".utf8)) } catch { @@ -57,12 +78,12 @@ func write_output(_ isSafePb: Bool, _ isSafeLR: Bool, _ P_b: Double, _ J: Double throw "Error printing to file." } do { - try outfile.write(contentsOf: Data(" P_b = ".utf8)) + try outfile.write(contentsOf: Data(" B = ".utf8)) } catch { throw "Error printing to file." } do { - try outfile.write(contentsOf: Data(String(P_b).utf8)) + try outfile.write(contentsOf: Data(String(B).utf8)) } catch { throw "Error printing to file." } @@ -79,6 +100,70 @@ func write_output(_ isSafePb: Bool, _ isSafeLR: Bool, _ P_b: Double, _ J: Double } do { try outfile.write(contentsOf: Data(String(J).utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(", ".utf8)) + try outfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(" NFL = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(String(NFL).utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(", ".utf8)) + try outfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(" q_hat = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(String(q_hat).utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(", ".utf8)) + try outfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(" q_hat_tol = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(String(q_hat_tol).utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(", ".utf8)) + try outfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(" J_tol = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outfile.write(contentsOf: Data(String(J_tol).utf8)) try outfile.write(contentsOf: Data("\n".utf8)) } catch { throw "Error printing to file." @@ -124,12 +209,12 @@ func write_output(_ isSafePb: Bool, _ isSafeLR: Bool, _ P_b: Double, _ J: Double throw "Error printing to file." } do { - try outputfile.write(contentsOf: Data("P_b = ".utf8)) + try outputfile.write(contentsOf: Data("B = ".utf8)) } catch { throw "Error printing to file." } do { - try outputfile.write(contentsOf: Data(String(P_b).utf8)) + try outputfile.write(contentsOf: Data(String(B).utf8)) try outputfile.write(contentsOf: Data("\n".utf8)) } catch { throw "Error printing to file." @@ -145,6 +230,83 @@ func write_output(_ isSafePb: Bool, _ isSafeLR: Bool, _ P_b: Double, _ J: Double } catch { throw "Error printing to file." } + do { + try outputfile.write(contentsOf: Data("NFL = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(NFL).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data("GTF = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(inParams.GTF).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data("q_hat = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(q_hat).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data("q_hat_tol = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(q_hat_tol).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data("J_tol = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(J_tol).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data("h = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(inParams.h).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data("AR = ".utf8)) + } catch { + throw "Error printing to file." + } + do { + try outputfile.write(contentsOf: Data(String(inParams.AR).utf8)) + try outputfile.write(contentsOf: Data("\n".utf8)) + } catch { + throw "Error printing to file." + } do { try outputfile.close() } catch { diff --git a/code/stable/glassbr/src/swift/main.swift b/code/stable/glassbr/src/swift/main.swift index 05cfa2e269..7794a32d37 100644 --- a/code/stable/glassbr/src/swift/main.swift +++ b/code/stable/glassbr/src/swift/main.swift @@ -347,4 +347,4 @@ do { } catch { throw "Error closing file." } -try write_output(isSafePb, isSafeLR, P_b, J) +try write_output(&inParams, isSafePb, isSafeLR, B, J, NFL, q_hat, q_hat_tol, J_tol)