├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── N2A ├── .classpath ├── .gitignore ├── .project ├── .pydevproject ├── assembly.xml ├── logo │ ├── Icon.svg │ ├── N2A.svg │ ├── graphic-40.gif │ ├── n2a_logo.pdn │ └── p5487_neuron.gif ├── pom.xml └── src │ ├── META-INF │ └── services │ │ ├── gov.sandia.n2a.plugins.Plugin │ │ └── java.nio.file.spi.FileSystemProvider │ └── gov │ └── sandia │ └── n2a │ ├── Main.java │ ├── N2APlugin.java │ ├── backend │ ├── c │ │ ├── BackendC.java │ │ ├── BackendDataC.java │ │ ├── Compiler.java │ │ ├── CompilerCL.java │ │ ├── CompilerClang.java │ │ ├── CompilerFactory.java │ │ ├── CompilerGCC.java │ │ ├── ExportCbinary.java │ │ ├── ExportCshared.java │ │ ├── ExportCstatic.java │ │ ├── JobC.java │ │ ├── MultiplyElementwiseC.java │ │ ├── NativeIOvector.java │ │ ├── NativeResource.java │ │ ├── NativeSimulator.java │ │ ├── PluginC.java │ │ ├── ProvideOperator.java │ │ ├── RendererC.java │ │ ├── RendererCfp.java │ │ ├── SettingsC.java │ │ ├── VideoIn.java │ │ ├── VideoOut.java │ │ ├── c-16.png │ │ └── runtime │ │ │ ├── CanvasImage.cc │ │ │ ├── Image.cc │ │ │ ├── ImageFileFormat.cc │ │ │ ├── ImageFileFormatBMP.cc │ │ │ ├── KDTree.h │ │ │ ├── KHR │ │ │ └── khrplatform.h │ │ │ ├── MNode.cc │ │ │ ├── MNode.h │ │ │ ├── Matrix.tcc │ │ │ ├── MatrixFixed.tcc │ │ │ ├── MatrixSparse.tcc │ │ │ ├── NativeIOvector.cc │ │ │ ├── NativeResource.cc │ │ │ ├── NativeResource.h │ │ │ ├── OutputHolder.h │ │ │ ├── OutputParser.h │ │ │ ├── PixelBuffer.cc │ │ │ ├── PixelFormat.cc │ │ │ ├── Shader.fp │ │ │ ├── Shader.vp │ │ │ ├── Video.cc │ │ │ ├── VideoFileFormatFFMPEG.cc │ │ │ ├── canvas.h │ │ │ ├── fixedpoint.cc │ │ │ ├── glcorearb.h │ │ │ ├── holder.cc │ │ │ ├── holder.h │ │ │ ├── holder.tcc │ │ │ ├── image.h │ │ │ ├── matrix.h │ │ │ ├── myendian.h │ │ │ ├── mymath.h │ │ │ ├── mystring.h │ │ │ ├── nosys.h │ │ │ ├── pointer.h │ │ │ ├── profiling.cc │ │ │ ├── profiling.h │ │ │ ├── runtime.cc │ │ │ ├── runtime.h │ │ │ ├── runtime.tcc │ │ │ ├── shared.h │ │ │ ├── video.h │ │ │ └── wglext.h │ ├── glif │ │ ├── ImportGLIF.java │ │ └── PluginGLIF.java │ ├── internal │ │ ├── Event.java │ │ ├── EventFactory.java │ │ ├── EventSpike.java │ │ ├── EventSpikeMulti.java │ │ ├── EventSpikeMultiLatch.java │ │ ├── EventSpikeSingle.java │ │ ├── EventSpikeSingleLatch.java │ │ ├── EventStep.java │ │ ├── InstanceConnect.java │ │ ├── InstanceInit.java │ │ ├── InstanceTemporaries.java │ │ ├── InternalBackend.java │ │ ├── InternalBackendData.java │ │ ├── InternalPlugin.java │ │ ├── KDTree.java │ │ ├── Part.java │ │ ├── Population.java │ │ ├── Simulator.java │ │ └── Wrapper.java │ ├── neuroml │ │ ├── BackendNeuroML.java │ │ ├── ExportJob.java │ │ ├── ExportNeuroML.java │ │ ├── ImportJob.java │ │ ├── ImportNeuroML.java │ │ ├── LEMS_v0.7.6.xsd │ │ ├── NeuroML.png │ │ ├── NeuroML_v2.2.xsd │ │ ├── PartMap.java │ │ ├── PluginNeuroML.java │ │ ├── Sequencer.java │ │ ├── SettingsNeuroML.java │ │ └── XMLutility.java │ ├── neuron │ │ ├── BackendNeuron.java │ │ └── PluginNeuron.java │ ├── python │ │ ├── BackendDataPython.java │ │ ├── JobPython.java │ │ ├── PluginPython.java │ │ ├── RendererPython.java │ │ ├── SettingsPython.java │ │ ├── python logo simple.svg │ │ ├── python-16.png │ │ ├── python-32.png │ │ └── runtime │ │ │ ├── n2a │ │ │ ├── MNode.py │ │ │ ├── OutputHolder.py │ │ │ ├── OutputParser.py │ │ │ ├── __init__.py │ │ │ └── runtime.py │ │ │ └── setup.py │ ├── stacs │ │ ├── BackendDataSTACS.java │ │ ├── BackendSTACS.java │ │ ├── JobSTACS.java │ │ ├── PluginSTACS.java │ │ ├── SettingsSTACS.java │ │ └── stacs.png │ ├── vensim │ │ ├── ColumnCode.java │ │ ├── ImportJob.java │ │ ├── ImportVensim.java │ │ ├── Lookup.java │ │ ├── PluginVensim.java │ │ ├── ProvideSpreadsheet.java │ │ ├── Spreadsheet.java │ │ └── runtime │ │ │ ├── miniz.c │ │ │ ├── miniz.h │ │ │ ├── pugiconfig.hpp │ │ │ ├── pugixml.cpp │ │ │ ├── pugixml.hpp │ │ │ ├── spreadsheet.cc │ │ │ ├── spreadsheet.h │ │ │ └── spreadsheet.tcc │ └── xyce │ │ ├── SettingsXyce.java │ │ ├── XyceBackend.java │ │ ├── XyceBackendData.java │ │ ├── XycePlugin.java │ │ ├── device │ │ ├── Neuron1.java │ │ ├── Neuron7.java │ │ ├── Neuron9.java │ │ ├── Synapse3.java │ │ ├── Synapse4.java │ │ └── XyceDevice.java │ │ ├── function │ │ └── Sinewave.java │ │ ├── netlist │ │ ├── Device.java │ │ ├── Symbol.java │ │ ├── SymbolConstantIC.java │ │ ├── SymbolFunc.java │ │ ├── SymbolParam.java │ │ ├── SymbolPulse.java │ │ ├── SymbolSinewave.java │ │ ├── SymbolStateVar0.java │ │ ├── SymbolStateVar1.java │ │ ├── XyceRenderer.java │ │ └── Xyceisms.java │ │ ├── xyce-150.png │ │ ├── xyce-16.png │ │ └── xyce-32.png │ ├── db │ ├── AppData.java │ ├── JSON.java │ ├── MCombo.java │ ├── MDir.java │ ├── MDoc.java │ ├── MDocGroup.java │ ├── MNode.java │ ├── MNodeListener.java │ ├── MPart.java │ ├── MPartRepo.java │ ├── MPersistent.java │ ├── MVolatile.java │ ├── Schema.java │ ├── Schema1.java │ └── Schema2.java │ ├── eqset │ ├── Equality.java │ ├── EquationEntry.java │ ├── EquationSet.java │ ├── Variable.java │ └── VariableReference.java │ ├── host │ ├── Connection.java │ ├── Host.java │ ├── Remote.java │ ├── RemoteLSF.java │ ├── RemoteSlurm.java │ ├── RemoteUnix.java │ ├── SshFileSystem.java │ ├── SshFileSystemProvider.java │ ├── SshPath.java │ ├── Unix.java │ └── Windows.java │ ├── language │ ├── AccessElement.java │ ├── AccessVariable.java │ ├── BuildMatrix.java │ ├── Comparison.java │ ├── Constant.java │ ├── EvaluationException.java │ ├── Function.java │ ├── Identifier.java │ ├── MatrixVisitable.java │ ├── Operator.java │ ├── OperatorArithmetic.java │ ├── OperatorBinary.java │ ├── OperatorLogical.java │ ├── OperatorLogicalInput.java │ ├── OperatorUnary.java │ ├── ParseException.java │ ├── Renderer.java │ ├── Split.java │ ├── Transformer.java │ ├── Type.java │ ├── UnitValue.java │ ├── UnsupportedFunctionException.java │ ├── Visitor.java │ ├── function │ │ ├── AbsoluteValue.java │ │ ├── Atan.java │ │ ├── Ceil.java │ │ ├── Columns.java │ │ ├── Cosine.java │ │ ├── Delay.java │ │ ├── Draw.java │ │ ├── Draw2D.java │ │ ├── Draw3D.java │ │ ├── DrawCube.java │ │ ├── DrawCylinder.java │ │ ├── DrawDisc.java │ │ ├── DrawLight.java │ │ ├── DrawPlane.java │ │ ├── DrawSegment.java │ │ ├── DrawSphere.java │ │ ├── DrawSquare.java │ │ ├── Equal.java │ │ ├── Event.java │ │ ├── Exp.java │ │ ├── Floor.java │ │ ├── Gaussian.java │ │ ├── Grid.java │ │ ├── HyperbolicTangent.java │ │ ├── Input.java │ │ ├── Log.java │ │ ├── Max.java │ │ ├── Mcount.java │ │ ├── Mfile.java │ │ ├── Min.java │ │ ├── Mkey.java │ │ ├── Mmatrix.java │ │ ├── Mnumber.java │ │ ├── Mstring.java │ │ ├── Norm.java │ │ ├── Output.java │ │ ├── Pulse.java │ │ ├── ReadImage.java │ │ ├── ReadMatrix.java │ │ ├── Round.java │ │ ├── Rows.java │ │ ├── Sat.java │ │ ├── Signum.java │ │ ├── Sine.java │ │ ├── Sphere.java │ │ ├── SquareRoot.java │ │ ├── SumSquares.java │ │ ├── Tangent.java │ │ ├── Uniform.java │ │ ├── UnitMap.java │ │ ├── glFrustum.java │ │ ├── glLookAt.java │ │ ├── glOrtho.java │ │ ├── glPerspective.java │ │ ├── glRotate.java │ │ ├── glScale.java │ │ └── glTranslate.java │ ├── operator │ │ ├── AND.java │ │ ├── Add.java │ │ ├── Divide.java │ │ ├── EQ.java │ │ ├── GE.java │ │ ├── GT.java │ │ ├── LE.java │ │ ├── LT.java │ │ ├── Modulo.java │ │ ├── Multiply.java │ │ ├── MultiplyElementwise.java │ │ ├── NE.java │ │ ├── NOT.java │ │ ├── Negate.java │ │ ├── OR.java │ │ ├── Power.java │ │ ├── Subtract.java │ │ └── Transpose.java │ ├── parse │ │ └── grammar.jjt │ └── type │ │ ├── Instance.java │ │ ├── Matrix.java │ │ ├── Scalar.java │ │ └── Text.java │ ├── linear │ ├── Factorization.java │ ├── FactorizationBK.java │ ├── FactorizationQR.java │ ├── MatrixBoolean.java │ ├── MatrixDense.java │ └── MatrixSparse.java │ ├── plugins │ ├── ExtensionPoint.java │ ├── Plugin.java │ ├── PluginManager.java │ └── extpoints │ │ ├── Activity.java │ │ ├── Backend.java │ │ ├── Export.java │ │ ├── ExportModel.java │ │ ├── Import.java │ │ ├── ImportModel.java │ │ ├── Service.java │ │ ├── Settings.java │ │ ├── ShutdownHook.java │ │ └── StudyHook.java │ ├── transfer │ ├── ExportNative.java │ └── ImportNative.java │ └── ui │ ├── CompoundEdit.java │ ├── GradientPanel.java │ ├── Lay.java │ ├── MCheckBox.java │ ├── MPasswordField.java │ ├── MTextField.java │ ├── MainFrame.java │ ├── MainTabbedPane.java │ ├── NTextField.java │ ├── SafeTextTransferHandler.java │ ├── UndoManager.java │ ├── Undoable.java │ ├── Utility.java │ ├── WrapLayout.java │ ├── eq │ ├── ActivityModel.java │ ├── EquationTreeCellEditor.java │ ├── EquationTreeCellRenderer.java │ ├── FilteredTreeModel.java │ ├── GraphEdge.java │ ├── GraphNode.java │ ├── GraphParent.java │ ├── PanelEquationGraph.java │ ├── PanelEquationTree.java │ ├── PanelEquations.java │ ├── PanelMRU.java │ ├── PanelModel.java │ ├── PanelSearch.java │ ├── StoredPath.java │ ├── TransferableNode.java │ ├── search │ │ ├── NameEditor.java │ │ ├── NodeBase.java │ │ ├── NodeCategory.java │ │ └── NodeModel.java │ ├── tree │ │ ├── NodeAnnotation.java │ │ ├── NodeAnnotations.java │ │ ├── NodeBase.java │ │ ├── NodeContainer.java │ │ ├── NodeEquation.java │ │ ├── NodeIO.java │ │ ├── NodeInherit.java │ │ ├── NodePart.java │ │ ├── NodeReference.java │ │ ├── NodeReferences.java │ │ └── NodeVariable.java │ └── undo │ │ ├── AddAnnotation.java │ │ ├── AddAnnotations.java │ │ ├── AddDoc.java │ │ ├── AddEditable.java │ │ ├── AddEquation.java │ │ ├── AddInherit.java │ │ ├── AddPart.java │ │ ├── AddReference.java │ │ ├── AddReferences.java │ │ ├── AddVariable.java │ │ ├── ChangeAnnotation.java │ │ ├── ChangeAnnotations.java │ │ ├── ChangeCategory.java │ │ ├── ChangeDoc.java │ │ ├── ChangeEquation.java │ │ ├── ChangeInherit.java │ │ ├── ChangeOrder.java │ │ ├── ChangePart.java │ │ ├── ChangeReference.java │ │ ├── ChangeReferences.java │ │ ├── ChangeVariable.java │ │ ├── ChangeVariableToInherit.java │ │ ├── CompoundEditView.java │ │ ├── DeleteAnnotation.java │ │ ├── DeleteAnnotations.java │ │ ├── DeleteDoc.java │ │ ├── DeleteEquation.java │ │ ├── DeleteInherit.java │ │ ├── DeletePart.java │ │ ├── DeleteReference.java │ │ ├── DeleteReferences.java │ │ ├── DeleteVariable.java │ │ ├── NodeFactory.java │ │ ├── Outsource.java │ │ └── UndoableView.java │ ├── images │ ├── ImageUtil.java │ ├── add.gif │ ├── analysis.gif │ ├── assign.png │ ├── book.gif │ ├── commit.png │ ├── comp.gif │ ├── complete.gif │ ├── connect.gif │ ├── connection.png │ ├── copy.png │ ├── delta.png │ ├── disconnect.gif │ ├── disconnected.png │ ├── document.png │ ├── edit.gif │ ├── equation-16.png │ ├── equation-32.png │ ├── export.gif │ ├── fileImage-16.png │ ├── fileImage-32.png │ ├── fileImage-64.png │ ├── fileVideo.png │ ├── file_err.gif │ ├── file_in.gif │ ├── file_obj.gif │ ├── file_out.gif │ ├── filter.png │ ├── filterFilled.png │ ├── help.gif │ ├── import.gif │ ├── inherit.png │ ├── lingering.png │ ├── locked-16.png │ ├── locked.png │ ├── n2a-128.png │ ├── n2a-16.png │ ├── n2a-32.png │ ├── n2a-48.png │ ├── n2a-splash.png │ ├── pause-16.png │ ├── pause-32.png │ ├── pin.png │ ├── preparing-16.png │ ├── preparing-32.png │ ├── preparing-64.png │ ├── print.png │ ├── properties.gif │ ├── pull.png │ ├── push.png │ ├── queue-16.png │ ├── queue-32.png │ ├── raster.png │ ├── refresh.gif │ ├── remove.gif │ ├── repo.gif │ ├── run-16.png │ ├── run-32.png │ ├── save.gif │ ├── settings.png │ ├── slow-16.png │ ├── stop.gif │ ├── straight.png │ ├── study-16.png │ ├── study-32.png │ ├── subtract.gif │ ├── tableSorted.png │ ├── topic-16.png │ ├── unlocked.png │ ├── view.gif │ ├── viewBottom.png │ ├── viewGraph.png │ ├── viewOptions.png │ ├── viewSide.png │ ├── warn.gif │ └── watch.png │ ├── jobs │ ├── ActivityRun.java │ ├── NodeBase.java │ ├── NodeError.java │ ├── NodeFile.java │ ├── NodeImage.java │ ├── NodeJob.java │ ├── NodeOutput.java │ ├── NodeSTACS.java │ ├── NodeVideo.java │ ├── OutputParser.java │ ├── PanelChart.java │ ├── PanelRun.java │ ├── Picture.java │ ├── Plot.java │ ├── Raster.java │ ├── RasterSTACS.java │ ├── Table.java │ ├── TextPaneANSI.java │ └── Video.java │ ├── ref │ ├── ActivityReference.java │ ├── ExportBibTeX.java │ ├── ExportBibliography.java │ ├── ImportBibTeX.java │ ├── ImportBibliography.java │ ├── ImportEndNote.java │ ├── ImportPubMed.java │ ├── ImportRIS.java │ ├── PanelEntry.java │ ├── PanelMRU.java │ ├── PanelReference.java │ ├── PanelSearch.java │ ├── TransferableReference.java │ └── undo │ │ ├── AddEntry.java │ │ ├── AddTag.java │ │ ├── ChangeEntry.java │ │ ├── ChangeTag.java │ │ ├── DeleteEntry.java │ │ ├── DeleteTag.java │ │ └── RenameTag.java │ ├── settings │ ├── ActivitySettings.java │ ├── PanelDiff.java │ ├── PanelSettings.java │ ├── SettingsAbout.java │ ├── SettingsBackend.java │ ├── SettingsGeneral.java │ ├── SettingsHost.java │ ├── SettingsLookAndFeel.java │ ├── SettingsRepo.java │ └── licenses │ │ ├── JOGL │ │ ├── JavaEWAH │ │ ├── LICENSE │ │ ├── apache-sshd │ │ ├── eclipse │ │ ├── eddsa │ │ ├── indriya │ │ ├── jfreechart │ │ ├── jgit │ │ ├── miniz │ │ ├── opengl │ │ ├── pugixml │ │ ├── si-units │ │ ├── slf4j │ │ ├── unit-api │ │ ├── uom-lib │ │ └── uom-systems │ └── studies │ ├── ActivityStudy.java │ ├── IteratorGroup.java │ ├── IteratorIndexed.java │ ├── IteratorList.java │ ├── IteratorPermute.java │ ├── IteratorRandom.java │ ├── IteratorRange.java │ ├── OptimizerLM.java │ ├── OptimizerLM2.java │ ├── PanelStudy.java │ ├── Study.java │ └── StudyIterator.java ├── README.md ├── style-cpp.xml └── style-java.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.project text=lf 3 | *.svg text=lf 4 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | push: 8 | branches: [ master, development ] 9 | pull_request: 10 | branches: [ master, development ] 11 | 12 | jobs: 13 | build_and_test: 14 | 15 | runs-on: ${{ matrix.runs-on }} 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | java: [ '17', '19' ] 20 | runs-on: [ubuntu-latest, macos-latest, windows-latest] 21 | 22 | name: Test on Java ${{ matrix.Java }} on ${{ matrix.runs-on }} 23 | steps: 24 | - uses: actions/checkout@v3 25 | 26 | - name: Set up JDK ${{ matrix.Java }} 27 | uses: actions/setup-java@v3 28 | with: 29 | java-version: ${{ matrix.Java }} 30 | distribution: 'temurin' 31 | 32 | - name: Test with Maven 33 | run: | 34 | cd N2A 35 | mvn install 36 | 37 | - name: Further tests, non Win 38 | if: ${{ matrix.runs-on != 'windows-latest' }} 39 | run: | 40 | pwd 41 | ls -alt 42 | 43 | # ... 44 | 45 | - name: Further tests, Windows 46 | if: ${{ matrix.runs-on == 'windows-latest' }} 47 | run: | 48 | pwd 49 | dir 50 | 51 | # ... 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .metadata/ 2 | .recommenders/ 3 | .settings/ 4 | bin/ 5 | lib/ 6 | target/ 7 | N2A/src/gov/sandia/n2a/db/initialDB.zip 8 | N2A/src/gov/sandia/n2a/language/parse/*.java 9 | N2A/src/gov/sandia/n2a/language/parse/*.jj 10 | -------------------------------------------------------------------------------- /N2A/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /N2A/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /N2A/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | N2A 4 | 5 | 6 | 7 | 8 | 9 | org.python.pydev.PyDevBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.m2e.core.maven2Nature 26 | org.eclipse.jdt.core.javanature 27 | org.python.pydev.pythonNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /N2A/.pydevproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | Default 4 | python interpreter 5 | 6 | -------------------------------------------------------------------------------- /N2A/assembly.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | executable-jar 7 | 8 | jar 9 | 10 | false 11 | 12 | 13 | / 14 | true 15 | true 16 | runtime 17 | 18 | 19 | 20 | 21 | metaInf-services 22 | 23 | 24 | -------------------------------------------------------------------------------- /N2A/logo/graphic-40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/logo/graphic-40.gif -------------------------------------------------------------------------------- /N2A/logo/n2a_logo.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/logo/n2a_logo.pdn -------------------------------------------------------------------------------- /N2A/logo/p5487_neuron.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/logo/p5487_neuron.gif -------------------------------------------------------------------------------- /N2A/src/META-INF/services/gov.sandia.n2a.plugins.Plugin: -------------------------------------------------------------------------------- 1 | gov.sandia.n2a.backend.internal.InternalPlugin 2 | gov.sandia.n2a.backend.c.PluginC 3 | gov.sandia.n2a.backend.python.PluginPython 4 | gov.sandia.n2a.backend.xyce.XycePlugin 5 | gov.sandia.n2a.backend.neuroml.PluginNeuroML 6 | gov.sandia.n2a.backend.neuron.PluginNeuron 7 | gov.sandia.n2a.backend.stacs.PluginSTACS 8 | gov.sandia.n2a.backend.vensim.PluginVensim 9 | gov.sandia.n2a.backend.glif.PluginGLIF 10 | -------------------------------------------------------------------------------- /N2A/src/META-INF/services/java.nio.file.spi.FileSystemProvider: -------------------------------------------------------------------------------- 1 | gov.sandia.n2a.host.SshFileSystemProvider -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/CompilerClang.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | import java.nio.file.Path; 10 | import java.util.List; 11 | 12 | import gov.sandia.n2a.host.Host; 13 | import gov.sandia.n2a.host.Windows; 14 | 15 | public class CompilerClang extends CompilerGCC 16 | { 17 | public static class Factory extends CompilerGCC.Factory 18 | { 19 | public Factory (Host host, Path gcc) 20 | { 21 | super (host, gcc); 22 | } 23 | 24 | public Compiler compiler (Path localJobDir) 25 | { 26 | return new CompilerClang (host, localJobDir, gcc, Darwin); 27 | } 28 | 29 | public String suffixDebug () 30 | { 31 | if (host instanceof Windows) return ".pdb"; 32 | return ""; 33 | } 34 | 35 | public boolean debugRequired () 36 | { 37 | return host instanceof Windows; 38 | } 39 | 40 | public boolean supportsUnicodeIdentifiers () 41 | { 42 | return true; 43 | } 44 | } 45 | 46 | public CompilerClang (Host host, Path localJobDir, Path gcc, boolean Darwin) 47 | { 48 | super (host, localJobDir, gcc, Darwin); 49 | } 50 | 51 | public void addDebugCompile (List command) 52 | { 53 | if (debug) 54 | { 55 | if (host instanceof Windows) command.add ("-Z7"); 56 | else command.add ("-g"); 57 | } 58 | else 59 | { 60 | command.add (optimize); 61 | } 62 | } 63 | 64 | public void addDebugLink (List command) 65 | { 66 | if (debug && host instanceof Windows) command.add ("-debug"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/CompilerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | import java.nio.file.Path; 10 | 11 | public interface CompilerFactory 12 | { 13 | Compiler compiler (Path localJobDir); 14 | String suffixBinary (); 15 | String suffixLibrary (boolean shared); 16 | String suffixLibraryWrapper (); 17 | String suffixDebug (); 18 | String prefixLibrary (boolean shared); 19 | boolean wrapperRequired (); // Indicates that the shared library wrapper must be used for linking. If false, then compiler can link directly to the shared library, even if it is capable of generating a wrapper. 20 | boolean debugRequired (); // Indicates that debug symbols are stored in a separate file, as opposed to embedded in the executable or shared library file. 21 | boolean supportsUnicodeIdentifiers (); // UFT-8 encoded characters can be inserted directly into identifiers 22 | } 23 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/ExportCbinary.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | public class ExportCbinary extends ExportCstatic 10 | { 11 | public ExportCbinary () 12 | { 13 | shared = true; // Default choice for binaries, unless overridden by metadata in model itself. 14 | lib = false; 15 | } 16 | 17 | @Override 18 | public String getName () 19 | { 20 | return "C binary"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/ExportCshared.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | public class ExportCshared extends ExportCstatic 10 | { 11 | public ExportCshared () 12 | { 13 | shared = true; 14 | } 15 | 16 | @Override 17 | public String getName () 18 | { 19 | return "C library shared"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/MultiplyElementwiseC.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | import gov.sandia.n2a.language.operator.MultiplyElementwise; 10 | 11 | public class MultiplyElementwiseC extends MultiplyElementwise 12 | { 13 | public MultiplyElementwiseC (MultiplyElementwise m) 14 | { 15 | operand0 = m.operand0; 16 | operand1 = m.operand1; 17 | 18 | parent = m.parent; 19 | operand0.parent = this; 20 | operand1.parent = this; 21 | 22 | exponent = m.exponent; 23 | exponentNext = m.exponentNext; 24 | 25 | // These two shouldn't be necessary at the compile stage where this op 26 | // is substituted in, but just being thorough. 27 | unit = m.unit; 28 | center = m.center; 29 | } 30 | 31 | public int precedence () 32 | { 33 | return 8; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/NativeIOvector.java: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | **/ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | public class NativeIOvector extends NativeResource 10 | { 11 | protected static native long construct (String... path); 12 | protected static native int size (long handle); 13 | protected static native double get (long handle, int i); 14 | protected static native void set (long handle, int i, double value); 15 | 16 | /** 17 | Retrieves an IOvector from the simulator. 18 | 19 | @param path Includes the name of each part in the path from the top-level model 20 | to the one in question. If a given part has more than one instance in its population, 21 | the index should appear in the path immediately after the name of that part. 22 | Since the path is all strings, the index should be converted to a string as well. 23 | **/ 24 | public NativeIOvector (String... path) 25 | { 26 | super (construct (path), true); 27 | } 28 | 29 | public int size () 30 | { 31 | return size (handle); 32 | } 33 | 34 | public double get (int i) 35 | { 36 | return get (handle, i); 37 | } 38 | 39 | public void set (int i, double value) 40 | { 41 | set (handle, i, value); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/NativeSimulator.java: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | **/ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | /** 10 | Static methods for starting, stepping and stopping a simulation. 11 | Normally, only one simulator is allowed for the entire process. 12 | If thread-local storage (TLS) is enabled, then there can be a separate 13 | simulator for each thread. Even in that case it is only identified 14 | implicitly, by being on the calling thread. 15 | **/ 16 | public class NativeSimulator 17 | { 18 | public static native void init (String... args); 19 | public static native void run (double until); 20 | public static native void finish (); 21 | } 22 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/PluginC.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.c; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import javax.swing.ImageIcon; 13 | 14 | import gov.sandia.n2a.plugins.Plugin; 15 | import gov.sandia.n2a.db.AppData; 16 | import gov.sandia.n2a.plugins.ExtensionPoint; 17 | 18 | public class PluginC extends Plugin 19 | { 20 | @Override 21 | public String getName () 22 | { 23 | return "N2A C Backend"; 24 | } 25 | 26 | @Override 27 | public String getVersion() 28 | { 29 | return "1.2"; 30 | } 31 | 32 | @Override 33 | public String getProvider () 34 | { 35 | return "Sandia National Laboratories"; 36 | } 37 | 38 | @Override 39 | public ImageIcon getIcon () 40 | { 41 | return null; 42 | } 43 | 44 | @Override 45 | public String getDescription () 46 | { 47 | return "N2A C Backend"; 48 | } 49 | 50 | @Override 51 | @SuppressWarnings("unchecked") 52 | public Class[] getExtensionPoints() 53 | { 54 | return new Class[] 55 | { 56 | ProvideOperator.class 57 | }; 58 | } 59 | 60 | @Override 61 | public ExtensionPoint[] getExtensions () 62 | { 63 | List result = new ArrayList (); 64 | result.add (new BackendC ()); 65 | result.add (new ExportCbinary ()); 66 | result.add (new ExportCstatic ()); 67 | result.add (new ExportCshared ()); 68 | if (! AppData.properties.getBoolean ("headless")) 69 | { 70 | result.add (new SettingsC ()); 71 | } 72 | return result.toArray (new ExtensionPoint[result.size ()]); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/c-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/c/c-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/runtime/NativeResource.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | **/ 6 | 7 | #ifndef native_resource_h 8 | #define native_resource_h 9 | 10 | #include "shared.h" 11 | 12 | class SHARED NativeResource 13 | { 14 | public: 15 | NativeResource (); 16 | virtual ~NativeResource (); 17 | 18 | void * proxy; ///< Java-side object that represents the C++ object. In JNI code this will be a jobject. 19 | 20 | static void * jvm; ///< Java virtual machine that is hosting the JNI connection. Discovered on first setProxy() call. 21 | static int version; ///< Used to retrieve a JNIEnv from the JVM. 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/runtime/Shader.vp: -------------------------------------------------------------------------------- 1 | attribute vec3 vertexPosition; 2 | attribute vec3 vertexNormal; 3 | 4 | uniform mat4 modelViewMatrix; 5 | uniform mat4 normalMatrix; 6 | uniform mat4 projectionMatrix; 7 | 8 | varying vec3 vN; // normal direction 9 | varying vec3 vP; // position in eye space 10 | 11 | void main() 12 | { 13 | // As long as normalMatrix is orthonormal, no need to normalize vN here. 14 | // It gets normalized in the fragment shader. 15 | // This allows us to use the trick for smoother shading of cones. 16 | vN = vec3 (normalMatrix * vec4 (vertexNormal, 0)); 17 | vP = vec3 (modelViewMatrix * vec4 (vertexPosition, 1)); 18 | gl_Position = projectionMatrix * vec4 (vP, 1); 19 | } 20 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/runtime/nosys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | 8 | #ifndef n2a_nosys_h 9 | #define n2a_nosys_h 10 | 11 | 12 | #define N2A_THROW(message) throw message; 13 | 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/runtime/profiling.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | using namespace std; 13 | 14 | 15 | void (*init_cb) (int loadseq, uint64_t version, uint32_t ndevinfos, void * devinfos); 16 | void (*push_region_cb) (const char*); 17 | void (*pop_region_cb) (); 18 | void (*finalize_cb) (); 19 | 20 | #ifndef _WIN32 21 | 22 | #include 23 | void get_callbacks () 24 | { 25 | char *x = getenv ("KOKKOS_PROFILE_LIBRARY"); 26 | if (! x) throw "KOKKOS_PROFILE_LIBRARY environment variable must be specified"; 27 | 28 | void *firstProfileLibrary = dlopen (x, RTLD_NOW | RTLD_GLOBAL); 29 | if (! firstProfileLibrary) throw "dlopen() failed"; 30 | 31 | void *p9 = dlsym (firstProfileLibrary, "kokkosp_push_profile_region"); 32 | void *p10 = dlsym (firstProfileLibrary, "kokkosp_pop_profile_region"); 33 | void *p11 = dlsym (firstProfileLibrary, "kokkosp_init_library"); 34 | void *p12 = dlsym (firstProfileLibrary, "kokkosp_finalize_library"); 35 | 36 | push_region_cb = *reinterpret_cast (&p9); 37 | pop_region_cb = *reinterpret_cast (&p10); 38 | init_cb = *reinterpret_cast (&p11); 39 | finalize_cb = *reinterpret_cast (&p12); 40 | 41 | (*init_cb) (0, 0, 0, nullptr); 42 | } 43 | 44 | #else 45 | 46 | void get_callbacks () 47 | { 48 | throw "Profiling not implemented on WIN32"; 49 | } 50 | 51 | #endif 52 | 53 | void push_region (const std::string& kName) 54 | { 55 | if (push_region_cb) (*push_region_cb) (kName.c_str ()); 56 | } 57 | 58 | void pop_region () 59 | { 60 | if (pop_region_cb) (*pop_region_cb) (); 61 | } 62 | 63 | void finalize_profiling () 64 | { 65 | (*finalize_cb) (); 66 | } 67 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/runtime/profiling.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | 8 | #ifndef n2a_profiling_h 9 | #define n2a_profiling_h 10 | 11 | void get_callbacks (); 12 | void push_region (const std::string&); 13 | void pop_region (); 14 | void finalize_profiling (); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/c/runtime/shared.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | 8 | // Unconditional include, so that we always replace the current definition of SHARED. 9 | // This should be the last include in the source file, to ensure nothing else undoes 10 | // the setting of SHARED or is impacted by it. 11 | #undef SHARED 12 | #ifdef _MSC_VER 13 | # ifdef _USRDLL 14 | # define SHARED __declspec(dllexport) 15 | # elif defined n2a_DLL 16 | # define SHARED __declspec(dllimport) 17 | # else 18 | # define SHARED 19 | # endif 20 | #else 21 | # define SHARED 22 | #endif 23 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/glif/PluginGLIF.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.glif; 8 | 9 | import javax.swing.ImageIcon; 10 | 11 | import gov.sandia.n2a.plugins.ExtensionPoint; 12 | import gov.sandia.n2a.plugins.Plugin; 13 | 14 | public class PluginGLIF extends Plugin 15 | { 16 | @Override 17 | public String getName () 18 | { 19 | return "GLIF"; 20 | } 21 | 22 | public String getVersion() 23 | { 24 | return "0.9"; 25 | } 26 | 27 | public String getProvider () 28 | { 29 | return "Sandia National Laboratories"; 30 | } 31 | 32 | @Override 33 | public ImageIcon getIcon () 34 | { 35 | return null; 36 | } 37 | 38 | @Override 39 | public String getDescription () 40 | { 41 | return "GLIF Import/Export"; 42 | } 43 | 44 | @Override 45 | public ExtensionPoint[] getExtensions () 46 | { 47 | return new ExtensionPoint[] 48 | { 49 | new ImportGLIF () 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/Event.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import gov.sandia.n2a.language.EvaluationException; 10 | 11 | public class Event implements Comparable 12 | { 13 | public double t; 14 | 15 | public void run (Simulator simulator) 16 | { 17 | throw new EvaluationException ("Event is abstract"); 18 | } 19 | 20 | public int compareTo (Event that) 21 | { 22 | if (t > that.t) return 1; 23 | if (t < that.t) return -1; 24 | // Events have the same timestamp, so sort by event type ... 25 | boolean stepA = this instanceof EventStep; 26 | boolean stepB = that instanceof EventStep; 27 | if (stepA && stepB) return 0; // Both are EventStep, so no-care about order. 28 | if (stepA) return - Simulator.instance.get ().sortEvent; 29 | if (stepB) return Simulator.instance.get ().sortEvent; 30 | return 0; // Neither is an EventStep, so no-care about order. 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/EventFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | public class EventFactory 10 | { 11 | public EventStep create (double t, double dt) 12 | { 13 | return new EventStep (t, dt); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/EventSpike.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import gov.sandia.n2a.backend.internal.InternalBackendData.EventTarget; 10 | 11 | public abstract class EventSpike extends Event 12 | { 13 | public EventTarget eventType; 14 | 15 | public void run (Simulator simulator) 16 | { 17 | } 18 | 19 | public void setFlag () 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/EventSpikeMulti.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import java.util.Iterator; 10 | import java.util.List; 11 | 12 | import gov.sandia.n2a.eqset.Variable; 13 | import gov.sandia.n2a.language.type.Instance; 14 | 15 | public class EventSpikeMulti extends EventSpike 16 | { 17 | public List targets; 18 | 19 | public void run (Simulator simulator) 20 | { 21 | setFlag (); 22 | for (Instance i : targets) i.integrate (simulator); 23 | for (Instance i : targets) i.update (simulator); 24 | for (Instance i : targets) 25 | { 26 | boolean live = i.finish (simulator); 27 | InternalBackendData bed = (InternalBackendData) i.equations.backendData; 28 | for (Variable v : bed.eventReferences) ((Instance) i.valuesObject[v.reference.index]).finishEvent (v.reference.variable); 29 | if (! live) i.dequeue (); 30 | } 31 | } 32 | 33 | public void setFlag () 34 | { 35 | Iterator it = targets.iterator (); 36 | while (it.hasNext ()) 37 | { 38 | Instance i = it.next (); 39 | if (i == null) it.remove (); 40 | else eventType.setLatch (i); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/EventSpikeMultiLatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | public class EventSpikeMultiLatch extends EventSpikeMulti 10 | { 11 | public void run (Simulator simulator) 12 | { 13 | setFlag (); 14 | // Note absence of normal cycle processing. 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/EventSpikeSingle.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | import gov.sandia.n2a.language.type.Instance; 11 | 12 | public class EventSpikeSingle extends EventSpike 13 | { 14 | Instance target; 15 | 16 | public void run (Simulator simulator) 17 | { 18 | setFlag (); 19 | target.integrate (simulator); 20 | target.update (simulator); 21 | boolean live = target.finish (simulator); 22 | InternalBackendData bed = (InternalBackendData) target.equations.backendData; 23 | for (Variable v : bed.eventReferences) ((Instance) target.valuesObject[v.reference.index]).finishEvent (v.reference.variable); 24 | if (! live) target.dequeue (); 25 | } 26 | 27 | public void setFlag () 28 | { 29 | eventType.setLatch (target); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/EventSpikeSingleLatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | public class EventSpikeSingleLatch extends EventSpikeSingle 10 | { 11 | public void run (Simulator simulator) 12 | { 13 | setFlag (); 14 | // Note absence of normal cycle processing. 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/InstanceConnect.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | import gov.sandia.n2a.language.Type; 11 | import gov.sandia.n2a.language.type.Instance; 12 | import gov.sandia.n2a.language.type.Scalar; 13 | 14 | public class InstanceConnect extends InstanceTemporaries 15 | { 16 | public InstanceConnect (Instance wrapped, Simulator simulator) 17 | { 18 | super (wrapped, simulator); 19 | } 20 | 21 | public Type get (Variable v) 22 | { 23 | if (v == bed.connect) return new Scalar (1); 24 | if (v == bed.live ) return new Scalar (0); 25 | if (v == bed.dt ) return new Scalar (((Part) wrapped.container).event.dt); // Refer to container, because during connect phase, part has not yet been added to event. 26 | return super.get (v); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/InstanceInit.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | import gov.sandia.n2a.language.Type; 11 | import gov.sandia.n2a.language.type.Instance; 12 | import gov.sandia.n2a.language.type.Scalar; 13 | 14 | public class InstanceInit extends InstanceTemporaries 15 | { 16 | public InstanceInit (Instance wrapped, Simulator simulator) 17 | { 18 | super (wrapped, simulator); 19 | } 20 | 21 | public Type get (Variable v) 22 | { 23 | if (v == bed.init) return new Scalar (1); 24 | if (v == bed.live) return new Scalar (0); 25 | return super.get (v); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/InternalPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import javax.swing.ImageIcon; 10 | 11 | import gov.sandia.n2a.plugins.Plugin; 12 | import gov.sandia.n2a.plugins.ExtensionPoint; 13 | 14 | public class InternalPlugin extends Plugin 15 | { 16 | @Override 17 | public String getName () 18 | { 19 | return "N2A Internal Backend"; 20 | } 21 | 22 | public String getVersion() 23 | { 24 | return "0.9"; 25 | } 26 | 27 | public String getProvider () 28 | { 29 | return "Sandia National Laboratories"; 30 | } 31 | 32 | @Override 33 | public ImageIcon getIcon () 34 | { 35 | return null; 36 | } 37 | 38 | @Override 39 | public String getDescription () 40 | { 41 | return "N2A Internal Backend"; 42 | } 43 | 44 | @Override 45 | public ExtensionPoint[] getExtensions () 46 | { 47 | return new ExtensionPoint[] {new InternalBackend ()}; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/internal/Wrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.internal; 8 | 9 | import gov.sandia.n2a.eqset.EquationSet; 10 | import gov.sandia.n2a.language.EvaluationException; 11 | 12 | public class Wrapper extends Part 13 | { 14 | public Wrapper (EquationSet model) 15 | { 16 | if (model.connectionBindings != null) throw new EvaluationException ("Only compartments may be top-level models."); // What are you going to connect, anyway? 17 | valuesObject = new Object[1]; 18 | valuesObject[0] = new Population (model, this); 19 | } 20 | 21 | public void init (Simulator simulator) 22 | { 23 | ((Population) valuesObject[0]).init (simulator); 24 | } 25 | 26 | public void integrate (Simulator simulator) 27 | { 28 | ((Population) valuesObject[0]).integrate (simulator); 29 | } 30 | 31 | public void update (Simulator simulator) 32 | { 33 | ((Population) valuesObject[0]).update (simulator); 34 | } 35 | 36 | public boolean finish (Simulator simulator) 37 | { 38 | Population p = (Population) valuesObject[0]; 39 | p.finish (simulator); 40 | return p.n > 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/neuroml/NeuroML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/neuroml/NeuroML.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/neuroml/PluginNeuroML.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.neuroml; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import javax.swing.ImageIcon; 13 | 14 | import gov.sandia.n2a.plugins.Plugin; 15 | import gov.sandia.n2a.db.AppData; 16 | import gov.sandia.n2a.plugins.ExtensionPoint; 17 | 18 | public class PluginNeuroML extends Plugin 19 | { 20 | public static PartMap partMap; // initialize the first time an import or export runs 21 | public static Sequencer sequencer; 22 | public static ExportNeuroML exporter = new ExportNeuroML (); 23 | 24 | @Override 25 | public String getName () 26 | { 27 | return "NeuroML Backend"; 28 | } 29 | 30 | public String getVersion() 31 | { 32 | return "0.9"; 33 | } 34 | 35 | public String getProvider () 36 | { 37 | return "Sandia National Laboratories"; 38 | } 39 | 40 | @Override 41 | public ImageIcon getIcon () 42 | { 43 | return null; 44 | } 45 | 46 | @Override 47 | public String getDescription () 48 | { 49 | return "Wrapper for jNeuroML. Imports/exports NeuroML files, and runs models on a range of simulators."; 50 | } 51 | 52 | @Override 53 | public ExtensionPoint[] getExtensions () 54 | { 55 | List result = new ArrayList (); 56 | result.add (new BackendNeuroML ()); 57 | result.add (exporter); 58 | result.add (new ImportNeuroML ()); 59 | if (! AppData.properties.getBoolean ("headless")) 60 | { 61 | result.add (new SettingsNeuroML ()); 62 | } 63 | return result.toArray (new ExtensionPoint[result.size ()]); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/neuroml/SettingsNeuroML.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.neuroml; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.ui.Lay; 11 | import gov.sandia.n2a.ui.MTextField; 12 | import gov.sandia.n2a.ui.settings.SettingsBackend; 13 | 14 | import javax.swing.JLabel; 15 | import javax.swing.JPanel; 16 | 17 | public class SettingsNeuroML extends SettingsBackend 18 | { 19 | protected MTextField fieldHome = new MTextField (40); 20 | 21 | public SettingsNeuroML () 22 | { 23 | key = "neuroml"; 24 | iconFileName = "NeuroML.png"; 25 | } 26 | 27 | @Override 28 | public String getName () 29 | { 30 | return "Backend NeuroML"; 31 | } 32 | 33 | @Override 34 | public void bind (MNode parent) 35 | { 36 | fieldHome.bind (parent, "JNML_HOME", "/usr/local/jNeuroML"); 37 | } 38 | 39 | @Override 40 | public JPanel getEditor () 41 | { 42 | return Lay.BxL ( 43 | Lay.FL (new JLabel ("JNML_HOME"), fieldHome) 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/neuron/BackendNeuron.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.neuron; 8 | 9 | import gov.sandia.n2a.backend.neuroml.BackendNeuroML; 10 | import gov.sandia.n2a.db.MNode; 11 | 12 | public class BackendNeuron extends BackendNeuroML 13 | { 14 | @Override 15 | public String getName () 16 | { 17 | return "NEURON"; 18 | } 19 | 20 | @Override 21 | public void start (MNode job) 22 | { 23 | Thread simulationThread = new SimulationThread (job); 24 | simulationThread.setDaemon (true); 25 | simulationThread.start (); 26 | } 27 | 28 | public class SimulationThread extends BackendNeuroML.SimulationThread 29 | { 30 | public SimulationThread (MNode job) 31 | { 32 | super (job); 33 | target = "neuron"; // Override the simulator string from backend. This is all it takes to switch to NEURON. 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/neuron/PluginNeuron.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.neuron; 8 | 9 | import javax.swing.ImageIcon; 10 | 11 | import gov.sandia.n2a.plugins.Plugin; 12 | import gov.sandia.n2a.plugins.ExtensionPoint; 13 | 14 | public class PluginNeuron extends Plugin 15 | { 16 | @Override 17 | public String getName () 18 | { 19 | return "NEURON Backend"; 20 | } 21 | 22 | public String getVersion() 23 | { 24 | return "0.9"; 25 | } 26 | 27 | public String getProvider () 28 | { 29 | return "Sandia National Laboratories"; 30 | } 31 | 32 | @Override 33 | public ImageIcon getIcon () 34 | { 35 | return null; 36 | } 37 | 38 | @Override 39 | public String getDescription () 40 | { 41 | return "Runs models on the NEURON simulator, using jNeuroML as a converter."; 42 | } 43 | 44 | @Override 45 | public ExtensionPoint[] getExtensions () 46 | { 47 | return new ExtensionPoint[] 48 | { 49 | new BackendNeuron () 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/BackendDataPython.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.python; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | 11 | public class BackendDataPython 12 | { 13 | // TODO: copy BackendDataC and adapt for Python 14 | 15 | public Variable index; 16 | public Variable n; 17 | public Variable p; 18 | } 19 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/JobPython.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.python; 8 | 9 | import java.nio.file.Path; 10 | 11 | import gov.sandia.n2a.backend.c.JobC; 12 | import gov.sandia.n2a.eqset.Variable; 13 | import gov.sandia.n2a.eqset.VariableReference; 14 | import gov.sandia.n2a.ui.eq.tree.NodePart; 15 | 16 | public class JobPython extends Thread 17 | { 18 | // TODO: copy JobC and rewrite for Python 19 | 20 | public Path runtimeDir; // local or remote 21 | 22 | /** 23 | Places resources specific to this backend into runtimeDir. 24 | runtimeDir must be set before calling this function. 25 | **/ 26 | public boolean unpackRuntime () throws Exception 27 | { 28 | boolean changed = false; 29 | Path n2aDir = runtimeDir.resolve ("n2a"); 30 | if (JobC.unpackRuntime (JobPython.class, null, runtimeDir, "runtime/", "setup.py")) changed = true; 31 | if (JobC.unpackRuntime (JobPython.class, null, n2aDir, "runtime/n2a/", "__init__.py", "MNode.py", "OutputHolder.py", "OutputParser.py", "runtime.py")) changed = true; 32 | return changed; 33 | } 34 | 35 | public String mangle (Variable v) 36 | { 37 | return mangle (v.nameString ()); 38 | } 39 | 40 | public String mangle (String prefix, Variable v) 41 | { 42 | return mangle (prefix, v.nameString ()); 43 | } 44 | 45 | public String mangle (String input) 46 | { 47 | return mangle ("_", input); 48 | } 49 | 50 | public String mangle (String prefix, String input) 51 | { 52 | // This assumes rather extensive support for Unicode in Python 3. 53 | // We don't bother supporting Python 2. 54 | return prefix + NodePart.validIdentifierFrom (input).replaceAll (" ", "_"); 55 | } 56 | 57 | public String resolve (VariableReference r, RendererPython context, boolean lvalue) 58 | { 59 | return mangle (r.variable); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/PluginPython.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.python; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import javax.swing.ImageIcon; 13 | 14 | import gov.sandia.n2a.plugins.Plugin; 15 | import gov.sandia.n2a.db.AppData; 16 | import gov.sandia.n2a.plugins.ExtensionPoint; 17 | 18 | public class PluginPython extends Plugin 19 | { 20 | @Override 21 | public String getName () 22 | { 23 | return "Python Backend"; 24 | } 25 | 26 | @Override 27 | public String getVersion() 28 | { 29 | return "1.2"; 30 | } 31 | 32 | @Override 33 | public String getProvider () 34 | { 35 | return "Sandia National Laboratories"; 36 | } 37 | 38 | @Override 39 | public ImageIcon getIcon () 40 | { 41 | return null; 42 | } 43 | 44 | @Override 45 | public String getDescription () 46 | { 47 | return "Python Backend"; 48 | } 49 | 50 | @Override 51 | public ExtensionPoint[] getExtensions () 52 | { 53 | List result = new ArrayList (); 54 | if (! AppData.properties.getBoolean ("headless")) 55 | { 56 | result.add (new SettingsPython ()); 57 | } 58 | return result.toArray (new ExtensionPoint[result.size ()]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/SettingsPython.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.python; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.ui.Lay; 11 | import gov.sandia.n2a.ui.MTextField; 12 | import gov.sandia.n2a.ui.settings.SettingsBackend; 13 | 14 | import javax.swing.JLabel; 15 | import javax.swing.JPanel; 16 | 17 | public class SettingsPython extends SettingsBackend 18 | { 19 | protected MTextField fieldPython = new MTextField (40); 20 | 21 | public SettingsPython () 22 | { 23 | key = "python"; 24 | iconFileName = "python-16.png"; 25 | } 26 | 27 | @Override 28 | public String getName () 29 | { 30 | return "Backend Python"; 31 | } 32 | 33 | @Override 34 | public void bind (MNode parent) 35 | { 36 | fieldPython.bind (parent, "path", "python"); 37 | } 38 | 39 | @Override 40 | public JPanel getEditor () 41 | { 42 | return Lay.BxL ( 43 | Lay.FL (new JLabel ("Python path"), fieldPython) 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/python-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/python/python-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/python-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/python/python-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/runtime/n2a/__init__.py: -------------------------------------------------------------------------------- 1 | from .MNode import * 2 | from .OutputHolder import * 3 | from .OutputParser import * 4 | from .runtime import * 5 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/runtime/n2a/runtime.py: -------------------------------------------------------------------------------- 1 | """ 2 | A collection of classes and routines for running N2A models. 3 | 4 | Copyright 2020-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 5 | Under the terms of Contract DE-NA0003525 with NTESS, 6 | the U.S. Government retains certain rights in this software. 7 | """ 8 | 9 | import numpy 10 | import math 11 | 12 | def gaussian(sigma=1): 13 | if isinstance(sigma, numpy.ndarry): 14 | rows = sigma.shape[0] 15 | cols = 1 16 | if len(sigma.shape) > 1: cols = sigma.shape[1] 17 | if cols == 1: 18 | result = numpy.zeros(rows) 19 | for r in range(rows): result[r] = sigma[r,0] * random.gauss(0,1) 20 | return result 21 | result = numpy.zeros(cols) 22 | for i in range(cols): result[i] = random.gauss(0,1) 23 | return sigma * result 24 | return random.gauss(0,1) * sigma 25 | 26 | def uniform(sigma=1): 27 | if isinstance(sigma, numpy.ndarry): 28 | rows = sigma.shape[0] 29 | cols = 1 30 | if len(sigma.shape) > 1: cols = sigma.shape[1] 31 | if cols == 1: 32 | result = numpy.zeros(rows) 33 | for r in range(rows): result[r] = sigma[r,0] * random.random() # Guarantee a semi-open interval, so don't use uniform(). 34 | return result 35 | result = numpy.zeros(cols) 36 | for i in range(cols): result[i] = random.random() 37 | return sigma * result 38 | return random.random() * sigma 39 | 40 | def grid(i, nx, ny, nz): 41 | sx = ny * nz # stride x 42 | 43 | # compute xyz in stride order 44 | result = numpy.zeros((3)) 45 | result[0] = ((i // sx) + 0.5) / nx # (i // sx) is an integer operation, so remainder is truncated. 46 | i %= sx 47 | result[1] = ((i // nz) + 0.5) / ny 48 | result[2] = ((i % nz) + 0.5) / nz 49 | return result 50 | 51 | def gridRaw(i, nx, ny, nz): 52 | sx = ny * nz # stride x 53 | 54 | # compute xyz in stride order 55 | result = numpy.zeros((3)) 56 | result[0] = i // sx 57 | i %= sx 58 | result[1] = i // nz 59 | result[2] = i % nz 60 | return result 61 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/python/runtime/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name='n2a', 5 | version='1.3', 6 | description='Support routines for accessing N2A files.', 7 | install_requires = ['numpy'], 8 | packages=['n2a'] 9 | ) 10 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/stacs/BackendDataSTACS.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.stacs; 8 | 9 | public class BackendDataSTACS 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/stacs/BackendSTACS.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.stacs; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.plugins.extpoints.Backend; 11 | 12 | public class BackendSTACS extends Backend 13 | { 14 | @Override 15 | public String getName () 16 | { 17 | return "STACS"; 18 | } 19 | 20 | @Override 21 | public void start (final MNode job) 22 | { 23 | Thread t = new JobSTACS (job); 24 | t.setDaemon (true); 25 | t.start (); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/stacs/PluginSTACS.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.stacs; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import javax.swing.ImageIcon; 13 | 14 | import gov.sandia.n2a.plugins.Plugin; 15 | import gov.sandia.n2a.db.AppData; 16 | import gov.sandia.n2a.plugins.ExtensionPoint; 17 | 18 | public class PluginSTACS extends Plugin 19 | { 20 | @Override 21 | public String getName () 22 | { 23 | return "STACS Backend"; 24 | } 25 | 26 | public String getVersion() 27 | { 28 | return "0.9"; 29 | } 30 | 31 | public String getProvider () 32 | { 33 | return "Sandia National Laboratories"; 34 | } 35 | 36 | @Override 37 | public ImageIcon getIcon () 38 | { 39 | return null; 40 | } 41 | 42 | @Override 43 | public String getDescription () 44 | { 45 | return "Backend for STACS neural simulator."; 46 | } 47 | 48 | @Override 49 | public ExtensionPoint[] getExtensions () 50 | { 51 | List result = new ArrayList (); 52 | result.add (new BackendSTACS ()); 53 | if (! AppData.properties.getBoolean ("headless")) 54 | { 55 | result.add (new SettingsSTACS ()); 56 | } 57 | return result.toArray (new ExtensionPoint[result.size ()]); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/stacs/SettingsSTACS.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.stacs; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.ui.Lay; 11 | import gov.sandia.n2a.ui.MTextField; 12 | import gov.sandia.n2a.ui.settings.SettingsBackend; 13 | 14 | import javax.swing.JLabel; 15 | import javax.swing.JPanel; 16 | 17 | public class SettingsSTACS extends SettingsBackend 18 | { 19 | protected MTextField fieldStacs = new MTextField (40); 20 | 21 | public SettingsSTACS () 22 | { 23 | key = "stacs"; 24 | iconFileName = "stacs.png"; 25 | } 26 | 27 | @Override 28 | public String getName () 29 | { 30 | return "Backend STACS"; 31 | } 32 | 33 | @Override 34 | public void bind (MNode parent) 35 | { 36 | fieldStacs.bind (parent, "stacs", "stacs"); 37 | } 38 | 39 | @Override 40 | public JPanel getEditor () 41 | { 42 | return Lay.BxL ( 43 | Lay.FL (new JLabel ("STACS path"), fieldStacs) 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/stacs/stacs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/stacs/stacs.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/vensim/ImportVensim.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.vensim; 8 | 9 | import gov.sandia.n2a.plugins.extpoints.ImportModel; 10 | import gov.sandia.n2a.ui.MainFrame; 11 | import gov.sandia.n2a.ui.eq.undo.AddDoc; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.IOException; 15 | import java.nio.file.Files; 16 | import java.nio.file.Path; 17 | 18 | public class ImportVensim implements ImportModel 19 | { 20 | @Override 21 | public String getName () 22 | { 23 | return "Vensim"; 24 | } 25 | 26 | @Override 27 | public void process (Path source, String name) 28 | { 29 | ImportJob job = new ImportJob (); 30 | job.process (source); 31 | if (job.model.size () > 0) 32 | { 33 | if (name == null) name = job.modelName; 34 | MainFrame.undoManager.apply (new AddDoc (name, job.model)); 35 | } 36 | } 37 | 38 | @Override 39 | public float matches (Path source) 40 | { 41 | try (BufferedReader reader = Files.newBufferedReader (source)) 42 | { 43 | String line = reader.readLine (); 44 | if (line.startsWith ("{UTF-8}")) return 1; // This is a terrible string to search for, but it happens to start Vensim mdl files. 45 | } 46 | catch (IOException e) 47 | { 48 | } 49 | return 0; 50 | } 51 | 52 | @Override 53 | public boolean accept (Path source) 54 | { 55 | if (Files.isDirectory (source)) return true; 56 | String name = source.getFileName ().toString (); 57 | int lastDot = name.lastIndexOf ('.'); 58 | if (lastDot >= 0 && name.substring (lastDot).equalsIgnoreCase (".mdl")) return true; 59 | return false; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/vensim/PluginVensim.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.vensim; 8 | 9 | import javax.swing.ImageIcon; 10 | 11 | import gov.sandia.n2a.plugins.ExtensionPoint; 12 | import gov.sandia.n2a.plugins.Plugin; 13 | 14 | public class PluginVensim extends Plugin 15 | { 16 | @Override 17 | public String getName () 18 | { 19 | return "Vensim Backend"; 20 | } 21 | 22 | public String getVersion() 23 | { 24 | return "0.9-dev"; 25 | } 26 | 27 | public String getProvider () 28 | { 29 | return "Sandia National Laboratories"; 30 | } 31 | 32 | @Override 33 | public ImageIcon getIcon () 34 | { 35 | return null; 36 | } 37 | 38 | @Override 39 | public String getDescription () 40 | { 41 | return "Vensim Backend"; 42 | } 43 | 44 | @Override 45 | public ExtensionPoint[] getExtensions () 46 | { 47 | return new ExtensionPoint[] 48 | { 49 | new ImportVensim (), 50 | new ProvideSpreadsheet (), 51 | Spreadsheet.factory (), 52 | ColumnCode.factory (), 53 | Lookup.factory () 54 | }; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/vensim/runtime/spreadsheet.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | #include "spreadsheet.tcc" 8 | 9 | template class Spreadsheet; 10 | #ifdef n2a_FP 11 | template SHARED Spreadsheet * spreadsheetHelper (const String & fileName, int exponent, Spreadsheet * oldHandle); 12 | #else 13 | template SHARED Spreadsheet * spreadsheetHelper (const String & fileName, Spreadsheet * oldHandle); 14 | #endif 15 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/SettingsXyce.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.ui.Lay; 11 | import gov.sandia.n2a.ui.MTextField; 12 | import gov.sandia.n2a.ui.settings.SettingsBackend; 13 | 14 | import javax.swing.JLabel; 15 | import javax.swing.JPanel; 16 | 17 | public class SettingsXyce extends SettingsBackend 18 | { 19 | protected MTextField fieldXyce = new MTextField (40); 20 | 21 | public SettingsXyce () 22 | { 23 | key = "xyce"; 24 | iconFileName = "xyce-16.png"; 25 | } 26 | 27 | @Override 28 | public String getName () 29 | { 30 | return "Backend Xyce"; 31 | } 32 | 33 | @Override 34 | public void bind (MNode parent) 35 | { 36 | fieldXyce.bind (parent, "path", "xyce"); 37 | } 38 | 39 | @Override 40 | public JPanel getEditor () 41 | { 42 | return Lay.BxL ( 43 | Lay.FL (new JLabel ("Xyce path"), fieldXyce) 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/XycePlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce; 8 | 9 | import gov.sandia.n2a.backend.xyce.function.Sinewave; 10 | import gov.sandia.n2a.db.AppData; 11 | import gov.sandia.n2a.plugins.Plugin; 12 | import gov.sandia.n2a.plugins.ExtensionPoint; 13 | import gov.sandia.n2a.ui.images.ImageUtil; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import javax.swing.ImageIcon; 19 | 20 | public class XycePlugin extends Plugin 21 | { 22 | public String getName () 23 | { 24 | return "Xyce Simulation for N2A"; 25 | } 26 | 27 | public String getVersion () 28 | { 29 | return "0.9"; 30 | } 31 | 32 | public String getProvider () 33 | { 34 | return "Sandia National Laboratories"; 35 | } 36 | 37 | public ImageIcon getIcon () 38 | { 39 | return ImageUtil.getImage("n2a.gif"); 40 | } 41 | 42 | public String getDescription () 43 | { 44 | return "This plug-in provides N2A-Xyce simulator integration.

More information: http://n2a.sandia.gov"; 45 | } 46 | 47 | public ExtensionPoint[] getExtensions () 48 | { 49 | List result = new ArrayList (); 50 | result.add (new XyceBackend ()); 51 | result.add (Sinewave.factory ()); 52 | if (! AppData.properties.getBoolean ("headless")) 53 | { 54 | result.add (new SettingsXyce ()); 55 | } 56 | return result.toArray (new ExtensionPoint[result.size ()]); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/device/Neuron1.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.device; 8 | 9 | import java.util.Arrays; 10 | 11 | public class Neuron1 extends XyceDevice 12 | { 13 | String[] nodes = {"", "0"}; 14 | String[] modelParams = {"CMEM", "GMEM", "ELEAK", "VREST", "GNA", "ENA", "GK", "EK" }; 15 | String[] instanceParams = {}; 16 | String[] ivars = {"N", "M", "H"}; 17 | 18 | public Neuron1() 19 | { 20 | name = "neuron"; 21 | level = 1; 22 | defaultNodes = Arrays.asList(nodes); 23 | modelParameterNames = Arrays.asList(modelParams); 24 | internalVariables = Arrays.asList(ivars); 25 | } 26 | 27 | @Override 28 | public String getCapacitanceVar() 29 | { 30 | return "CMEM"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/device/Neuron7.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.device; 8 | 9 | import java.util.Arrays; 10 | 11 | public class Neuron7 extends XyceDevice 12 | { 13 | String[] nodes = {""}; 14 | String[] modelParams = {"MEMC", "VT", "VR", "VP", "K", "A", "B", "C", "D", "FALLRATE", "USCALE" }; 15 | String[] instanceParams = {"MEMC", "VT", "VR", "VP", "K", "A", "B", "C", "D", "FALLRATE", "USCALE" }; 16 | String[] ivars = {"U"}; 17 | 18 | public Neuron7() 19 | { 20 | name = "neuron"; 21 | level = 7; 22 | defaultNodes = Arrays.asList(nodes); 23 | modelParameterNames = Arrays.asList(modelParams); 24 | internalVariables = Arrays.asList(ivars); 25 | } 26 | 27 | @Override 28 | public String getCapacitanceVar() 29 | { 30 | return "MEMC"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/device/Neuron9.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.device; 8 | 9 | import java.util.Arrays; 10 | 11 | public class Neuron9 extends XyceDevice 12 | { 13 | String[] nodes = {"", "0"}; 14 | String[] modelParams = {"CMEM", "GMEM", "ELEAK", "VREST", "GNA", "ENA", "GK", "EK" }; 15 | String[] instanceParams = {}; 16 | String[] ivars = {"N", "M", "H"}; 17 | 18 | public Neuron9() 19 | { 20 | name = "neuron"; 21 | level = 9; 22 | defaultNodes = Arrays.asList(nodes); 23 | modelParameterNames = Arrays.asList(modelParams); 24 | internalVariables = Arrays.asList(ivars); 25 | } 26 | 27 | @Override 28 | public String getCapacitanceVar() 29 | { 30 | return "CMEM"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/device/Synapse3.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.device; 8 | 9 | import java.util.Arrays; 10 | 11 | public class Synapse3 extends XyceDevice 12 | { 13 | String[] nodes = {"", ""}; 14 | String[] modelParams = {"TAU1","TAU2","EREV","VTHRESH","DELAY","GMAX", 15 | "ALTD", "ALTP", "L1TAU", "L2TAU", "L3TAU", "R", "S", 16 | "WMIN", "WMAX", "WINIT", "P"}; 17 | String[] ivars = {"A0", "B0", "T0", "W", "VL1", "VL2", "VL3"}; 18 | 19 | public Synapse3() 20 | { 21 | name = "synapse"; 22 | level = 3; 23 | defaultNodes = Arrays.asList(nodes); 24 | modelParameterNames = Arrays.asList(modelParams); 25 | internalVariables = Arrays.asList(ivars); 26 | } 27 | 28 | @Override 29 | public String getCapacitanceVar() 30 | { 31 | return ""; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/device/Synapse4.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.device; 8 | 9 | import java.util.Arrays; 10 | 11 | public class Synapse4 extends XyceDevice 12 | { 13 | String[] nodes = {"", ""}; 14 | String[] modelParams = {"TAU1","TAU2","EREV","VTHRESH","DELAY","GMAX"}; 15 | String[] ivars = {"A0", "B0", "T0"}; 16 | 17 | public Synapse4() 18 | { 19 | name = "synapse"; 20 | level = 4; 21 | defaultNodes = Arrays.asList(nodes); 22 | modelParameterNames = Arrays.asList(modelParams); 23 | internalVariables = Arrays.asList(ivars); 24 | } 25 | 26 | @Override 27 | public String getCapacitanceVar() 28 | { 29 | return ""; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/function/Sinewave.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.function; 8 | 9 | import gov.sandia.n2a.language.Function; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | import gov.sandia.n2a.language.type.Scalar; 14 | 15 | public class Sinewave extends Function 16 | { 17 | public static Factory factory () 18 | { 19 | return new Factory () 20 | { 21 | public String name () 22 | { 23 | return "sinewave"; 24 | } 25 | 26 | public Operator createInstance () 27 | { 28 | return new Sinewave (); 29 | } 30 | }; 31 | } 32 | 33 | public Type eval (Instance context) 34 | { 35 | // TODO: implement equivalent of Xyce sinewave function; alternately, define a generic sinewave function in N2A, similar to generic pulse() 36 | return new Scalar (0); 37 | } 38 | 39 | public String toString () 40 | { 41 | return "sinewave"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/netlist/Symbol.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.netlist; 8 | 9 | import gov.sandia.n2a.eqset.EquationEntry; 10 | 11 | public class Symbol 12 | { 13 | public EquationEntry eq; 14 | 15 | public Symbol (EquationEntry eq) 16 | { 17 | this.eq = eq; 18 | } 19 | 20 | public String getDefinition (XyceRenderer renderer) 21 | { 22 | return ""; 23 | } 24 | 25 | /** 26 | Output code necessary to retrieve the value of this symbol. 27 | Note that this function is not called until external references are resolved 28 | (via recursion in XyceRenderer), so no need to worry about resolving them here. 29 | Default action is to access the voltage of a node. Specific symbol types may 30 | override this. 31 | **/ 32 | public String getReference (XyceRenderer renderer) 33 | { 34 | return Xyceisms.referenceStateVar (eq.variable.name, renderer.pi.hashCode ()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/netlist/SymbolConstantIC.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.netlist; 8 | 9 | import gov.sandia.n2a.eqset.EquationEntry; 10 | import gov.sandia.n2a.language.Type; 11 | import gov.sandia.n2a.language.type.Scalar; 12 | import gov.sandia.n2a.plugins.extpoints.Backend; 13 | 14 | public class SymbolConstantIC extends Symbol 15 | { 16 | public SymbolConstantIC (EquationEntry eq) 17 | { 18 | super (eq); 19 | } 20 | 21 | @Override 22 | public String getReference (XyceRenderer renderer) 23 | { 24 | return Xyceisms.referenceVariable (eq.variable.name, renderer.pi.hashCode ()); 25 | } 26 | 27 | public String getDefinition (XyceRenderer renderer) 28 | { 29 | // Note: this is done for every instance, so they can have different initial values for the same variable. 30 | Type stored = renderer.pi.get (eq.variable); 31 | if (! (stored instanceof Scalar)) 32 | { 33 | Backend.err.get ().println ("unexpected evaluation result for " + eq.toString ()); 34 | throw new Backend.AbortRun (); 35 | } 36 | return Xyceisms.setInitialCondition (eq.variable.name, renderer.pi.hashCode (), ((Scalar) stored).value); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/netlist/SymbolParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.netlist; 8 | 9 | import gov.sandia.n2a.eqset.EquationEntry; 10 | 11 | public class SymbolParam extends Symbol 12 | { 13 | Number value; 14 | 15 | public SymbolParam (EquationEntry eq) 16 | { 17 | super (eq); 18 | } 19 | 20 | @Override 21 | public String getDefinition (XyceRenderer renderer) 22 | { 23 | return Xyceisms.param (eq.variable.name, renderer.pi.hashCode (), renderer.change (eq.expression)); 24 | } 25 | 26 | @Override 27 | public String getReference (XyceRenderer renderer) 28 | { 29 | return Xyceisms.referenceVariable (eq.variable.name, renderer.pi.hashCode ()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/netlist/SymbolSinewave.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.netlist; 8 | 9 | import gov.sandia.n2a.backend.xyce.function.Sinewave; 10 | import gov.sandia.n2a.eqset.EquationEntry; 11 | import gov.sandia.n2a.language.Operator; 12 | import gov.sandia.n2a.language.Visitor; 13 | import java.util.ArrayList; 14 | 15 | public class SymbolSinewave extends Symbol 16 | { 17 | Sinewave sinewave; 18 | 19 | public SymbolSinewave (EquationEntry eq) 20 | { 21 | super (eq); 22 | 23 | eq.visit (new Visitor () 24 | { 25 | public boolean visit (Operator op) 26 | { 27 | if (sinewave != null) return false; 28 | if (op instanceof Sinewave) 29 | { 30 | sinewave = (Sinewave) op; 31 | return false; 32 | } 33 | return true; 34 | } 35 | }); 36 | } 37 | 38 | @Override 39 | public String getDefinition (XyceRenderer renderer) 40 | { 41 | ArrayList params = new ArrayList (5); 42 | for (int a = 0; a < sinewave.operands.length; a++) 43 | { 44 | params.add (renderer.change (sinewave.operands[a])); 45 | } 46 | 47 | return Xyceisms.voltageSinWave (eq.variable.name, renderer.pi.hashCode (), params); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/netlist/SymbolStateVar0.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.netlist; 8 | 9 | import gov.sandia.n2a.eqset.EquationEntry; 10 | 11 | public class SymbolStateVar0 extends Symbol 12 | { 13 | // For state variables defined by an order 0 equation - 14 | // no time derivative 15 | // Note - this class intentionally does not handle cases 16 | // where the variable belongs to a connected part rather than 17 | // this one 18 | 19 | public SymbolStateVar0 (EquationEntry eq) 20 | { 21 | super(eq); 22 | } 23 | 24 | @Override 25 | public String getDefinition (XyceRenderer renderer) 26 | { 27 | return Xyceisms.defineStateVar (eq.variable.name, renderer.pi.hashCode (), renderer.change (eq.expression)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/netlist/SymbolStateVar1.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.backend.xyce.netlist; 8 | 9 | import gov.sandia.n2a.eqset.EquationEntry; 10 | import gov.sandia.n2a.eqset.Variable; 11 | import gov.sandia.n2a.eqset.VariableReference; 12 | import gov.sandia.n2a.language.type.Instance; 13 | 14 | /// For state variables defined by a first-order differential equation 15 | public class SymbolStateVar1 extends Symbol 16 | { 17 | public SymbolStateVar1 (EquationEntry eq) 18 | { 19 | super (eq); 20 | } 21 | 22 | @Override 23 | public String getDefinition (XyceRenderer renderer) 24 | { 25 | String translatedEq = renderer.change (eq.expression); 26 | 27 | Variable v = eq.variable; 28 | VariableReference r = v.reference; 29 | if (r.index < 0) // symbol is defined here; no += allowed within same part 30 | { 31 | return Xyceisms.defineDiffEq (v.name, renderer.pi.hashCode (), translatedEq); 32 | } 33 | 34 | // This symbol refers to a symbol in another part. We don't re-define the 35 | // variable, rather we create another diff eq that updates the existing one. 36 | Instance target = (Instance) renderer.pi.valuesObject[r.index]; 37 | String thisVarname = r.variable.name + "_" + target .hashCode (); 38 | String eqName = v.name + "_" + renderer.pi.hashCode (); 39 | return Xyceisms.updateDiffEq (eqName, thisVarname, translatedEq); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/xyce-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/xyce/xyce-150.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/xyce-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/xyce/xyce-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/backend/xyce/xyce-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/backend/xyce/xyce-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/db/MNodeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.db; 8 | 9 | /** 10 | Notify UI components of changes in an MDoc collection. 11 | **/ 12 | public interface MNodeListener 13 | { 14 | /** 15 | Structure has changed in a way that affects more than one or two children. 16 | **/ 17 | public void changed (); 18 | 19 | /** 20 | A key that was formerly null now has data. 21 | If a key becomes non-null as the result of a move, then childChanged() will be sent instead. 22 | **/ 23 | public void childAdded (String key); 24 | 25 | /** 26 | A key that had data has become null. 27 | If a key becomes null as the result of a move, then childChanged() will be sent instead. 28 | **/ 29 | public void childDeleted (String key); 30 | 31 | /** 32 | Content has changed under two keys. 33 | The newKey will always have new content, and the oldKey will either have new content or become null. 34 | If a move effectively deletes the destination, then a childDeleted() message will be sent instead. 35 | If content changes at a single location, then oldKey==newKey. 36 | **/ 37 | public void childChanged (String oldKey, String newKey); 38 | } 39 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/host/Remote.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.host; 8 | 9 | import java.io.Closeable; 10 | 11 | public interface Remote extends Closeable 12 | { 13 | public void enable (); // Allow this host to ask user for login information. 14 | public boolean isEnabled (); // Indicates that this host is currently able to ask for login, if needed. 15 | public boolean isConnected (); // Indicates that this host has an active ssh (or other protocol) session. 16 | } 17 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/EvaluationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | @SuppressWarnings("serial") 10 | public class EvaluationException extends RuntimeException 11 | { 12 | public EvaluationException (String message) 13 | { 14 | super (message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/Identifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | Utility class for capturing names of functions and variables during parsing. 11 | **/ 12 | public class Identifier 13 | { 14 | public String name; 15 | public boolean hadParens; 16 | public int columnBegin; // position of first character in source line 17 | public int columnEnd; // position of last character in source line. Not necessarily same as columnBegin+name.length()-1, since original text might not be canonical. 18 | public int trailingSpaces; // Leading spaces get skipped by lexer, but trailing spaces are included in token. We save them for use by variable renaming code. 19 | 20 | /** 21 | Parses the given string, which must be properly-formatted number with optional unit specified at end. 22 | **/ 23 | public Identifier (String name, int columnBegin, int columnEnd) 24 | { 25 | this.name = canonical (name); 26 | this.columnBegin = columnBegin; 27 | this.columnEnd = columnEnd; 28 | 29 | int i = name.length () - 1; 30 | while (i >= 0 && name.charAt (i--) == ' ') trailingSpaces++; 31 | } 32 | 33 | public static String canonical (String name) 34 | { 35 | String primes = ""; 36 | String path = name; 37 | int pos = name.indexOf ("'"); 38 | if (pos >= 0) 39 | { 40 | primes = name.substring (pos).trim (); 41 | path = name.substring (0, pos); 42 | } 43 | path = path.trim (); 44 | 45 | String[] pieces = path.split ("\\."); 46 | String result = pieces[0].trim (); 47 | for (int i = 1; i < pieces.length; i++) 48 | { 49 | result += "." + pieces[i].trim (); 50 | } 51 | return result + primes; 52 | } 53 | 54 | public String toString () 55 | { 56 | return name; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/MatrixVisitable.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | Marks a function as something that can visit the elements of a matrix to produce 11 | a new matrix. Used by C backend for code generation. Some visitable functions 12 | might have several different prototypes. Only the single-parameter form is visitable. 13 | **/ 14 | public interface MatrixVisitable 15 | { 16 | default public boolean hasExponentA () 17 | { 18 | return false; 19 | } 20 | 21 | default public boolean hasExponentResult () 22 | { 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/OperatorArithmetic.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | As part of an algebraic expression, this class takes one or two numbers and returns a number. 11 | Basically, anything that's not a Function. 12 | **/ 13 | public interface OperatorArithmetic 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/OperatorLogical.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | Returns a boolean value, either 1 for true or 0 for false. 11 | **/ 12 | public interface OperatorLogical 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/OperatorLogicalInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | Takes boolean values as input. Specifically, only checks whether value is 11 | zero or non-zero. Ignores the specific value of a non-zero input. 12 | **/ 13 | public interface OperatorLogicalInput extends OperatorLogical 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/ParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | import java.io.PrintStream; 10 | 11 | @SuppressWarnings("serial") 12 | public class ParseException extends Exception 13 | { 14 | public String line = ""; 15 | public int column = -1; 16 | 17 | public ParseException () 18 | { 19 | } 20 | 21 | public ParseException (String message) 22 | { 23 | super (message); 24 | } 25 | 26 | public ParseException (String message, String line, int column) 27 | { 28 | super (message); 29 | this.line = line; 30 | this.column = column; 31 | } 32 | 33 | public void print (PrintStream ps) 34 | { 35 | ps.println (getMessage ()); 36 | ps.println (line); 37 | for (int i = 0; i < column; i++) ps.print (" "); 38 | ps.println ("^"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/Renderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | A visitor for Operator which collects a string suitable for either display 11 | or code generation. Subclass this to override the default rendering built 12 | into Operators. 13 | **/ 14 | public class Renderer 15 | { 16 | public StringBuilder result; 17 | 18 | public Renderer () 19 | { 20 | result = new StringBuilder (); 21 | } 22 | 23 | public Renderer (StringBuilder result) 24 | { 25 | this.result = result; 26 | } 27 | 28 | /** 29 | @return true if this function rendered the operator. false if the operator should render itself (using its default method). 30 | **/ 31 | public boolean render (Operator op) 32 | { 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/Split.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | import java.util.ArrayList; 10 | 11 | import gov.sandia.n2a.eqset.EquationSet; 12 | import gov.sandia.n2a.eqset.EquationSet.ExponentContext; 13 | import gov.sandia.n2a.language.parse.ASTIdentifier; 14 | import gov.sandia.n2a.language.parse.ASTList; 15 | import gov.sandia.n2a.language.parse.SimpleNode; 16 | import gov.sandia.n2a.language.type.Instance; 17 | import gov.sandia.n2a.language.type.Scalar; 18 | import tech.units.indriya.AbstractUnit; 19 | 20 | public class Split extends Operator 21 | { 22 | public String[] names; // Untranslated part names 23 | public ArrayList parts; // List of parts to split the current one into 24 | public int index; // of parts in EquationSet.splits 25 | 26 | public void getOperandsFrom (SimpleNode node) throws ParseException 27 | { 28 | ASTList l = (ASTList) node; 29 | int count = l.jjtGetNumChildren (); 30 | names = new String[count]; 31 | for (int i = 0; i < count; i++) 32 | { 33 | ASTIdentifier n = (ASTIdentifier) l.jjtGetChild (i); 34 | Identifier ID = (Identifier) n.jjtGetValue (); 35 | names[i] = ID.name; 36 | } 37 | } 38 | 39 | public void determineExponent (ExponentContext context) 40 | { 41 | updateExponent (context, 0, 0); // integer 42 | } 43 | 44 | public void determineUnit (boolean fatal) throws Exception 45 | { 46 | unit = AbstractUnit.ONE; 47 | } 48 | 49 | public Type getType () 50 | { 51 | return new Scalar (0); 52 | } 53 | 54 | public Type eval (Instance context) throws EvaluationException 55 | { 56 | return new Scalar (index + 1); 57 | } 58 | 59 | public String toString () 60 | { 61 | String result = new String (); 62 | int last = names.length - 1; 63 | for (int i = 0; i <= last; i++) result += "," + names[i]; 64 | return result.substring (1); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/Transformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | A visitor for Operator which replaces the current node with a rewritten tree. 11 | **/ 12 | public interface Transformer 13 | { 14 | /** 15 | @return The modified Operator, or null if no action was taken. When null is 16 | returned, the Operator performs its own default action, which is generally 17 | to recurse down the tree then return itself. An empty implementation would return null. 18 | **/ 19 | public Operator transform (Operator op); 20 | } 21 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/UnsupportedFunctionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | @SuppressWarnings("serial") 10 | public class UnsupportedFunctionException extends Exception 11 | { 12 | public String message; // Initially the name of the function. Later, Variable will add a message and its own name as well. 13 | 14 | public UnsupportedFunctionException (String name) 15 | { 16 | this.message = name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/Visitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language; 8 | 9 | /** 10 | A generic visitor for Operator. 11 | **/ 12 | public interface Visitor 13 | { 14 | /** 15 | @return true to recurse below current node. false if further recursion below this node is not needed. 16 | An empty implementation would return true; 17 | **/ 18 | public boolean visit (Operator op); 19 | } 20 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/AbsoluteValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.language.EvaluationException; 10 | import gov.sandia.n2a.language.Function; 11 | import gov.sandia.n2a.language.Operator; 12 | import gov.sandia.n2a.language.Type; 13 | import gov.sandia.n2a.language.MatrixVisitable; 14 | import gov.sandia.n2a.language.type.Instance; 15 | import gov.sandia.n2a.language.type.Scalar; 16 | import gov.sandia.n2a.language.type.Matrix; 17 | 18 | public class AbsoluteValue extends Function implements MatrixVisitable 19 | { 20 | public static Factory factory () 21 | { 22 | return new Factory () 23 | { 24 | public String name () 25 | { 26 | return "abs"; 27 | } 28 | 29 | public Operator createInstance () 30 | { 31 | return new AbsoluteValue (); 32 | } 33 | }; 34 | } 35 | 36 | public Type eval (Instance context) 37 | { 38 | Type arg = operands[0].eval (context); 39 | if (arg instanceof Scalar) return new Scalar (Math.abs (((Scalar) arg).value)); 40 | if (arg instanceof Matrix) 41 | { 42 | return ((Matrix) arg).visit 43 | ( 44 | new Matrix.Visitor () 45 | { 46 | public double apply (double a) 47 | { 48 | return Math.abs (a); 49 | } 50 | } 51 | ); 52 | } 53 | throw new EvaluationException ("type mismatch"); 54 | } 55 | 56 | public String toString () 57 | { 58 | return "abs"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Columns.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.eqset.EquationSet.ExponentContext; 10 | import gov.sandia.n2a.language.Function; 11 | import gov.sandia.n2a.language.Operator; 12 | import gov.sandia.n2a.language.Type; 13 | import gov.sandia.n2a.language.type.Instance; 14 | import gov.sandia.n2a.language.type.Matrix; 15 | import gov.sandia.n2a.language.type.Scalar; 16 | 17 | public class Columns extends Function 18 | { 19 | public static Factory factory () 20 | { 21 | return new Factory () 22 | { 23 | public String name () 24 | { 25 | return "columns"; 26 | } 27 | 28 | public Operator createInstance () 29 | { 30 | return new Columns (); 31 | } 32 | }; 33 | } 34 | 35 | public void determineExponent (ExponentContext context) 36 | { 37 | updateExponent (context, 0, 0); // small integer 38 | } 39 | 40 | public void determineExponentNext () 41 | { 42 | // No action. The operand is never evaluated. 43 | } 44 | 45 | public Type getType () 46 | { 47 | return new Scalar (); 48 | } 49 | 50 | public Type eval (Instance context) 51 | { 52 | Matrix A = (Matrix) operands[0].eval (context); 53 | return new Scalar (A.columns ()); 54 | } 55 | 56 | public String toString () 57 | { 58 | return "columns"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Draw2D.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.language.Operator; 10 | 11 | public class Draw2D extends Draw 12 | { 13 | public void determineExponentNext () 14 | { 15 | super.determineExponentNext (); 16 | 17 | // Last arg is color, which is always a raw integer. 18 | int last = operands.length - 1; 19 | Operator c = operands[last]; 20 | c.exponentNext = 0; 21 | c.determineExponentNext (); 22 | 23 | // All pixel-valued operands must agree on exponent. 24 | if (last > 1) 25 | { 26 | int avg = 0; 27 | for (int i = 1; i < last; i++) avg += operands[i].exponent; 28 | avg /= last - 1; 29 | for (int i = 1; i < last; i++) 30 | { 31 | Operator op = operands[i]; 32 | op.exponentNext = avg; 33 | op.determineExponentNext (); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Draw3D.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.operator.Multiply; 12 | 13 | public class Draw3D extends Draw 14 | { 15 | public Operator simplify (Variable from, boolean evalOnly) 16 | { 17 | if (operands.length < 2) return super.simplify (from, evalOnly); 18 | 19 | // "center" is present, so fold it into model matrix. 20 | Operator center = operands[1]; 21 | glTranslate t = new glTranslate (); 22 | t.operands = new Operator[1]; 23 | t.operands[0] = center; 24 | center.parent = t; 25 | 26 | Operator model = getKeyword ("model"); 27 | if (model == null) 28 | { 29 | addKeyword ("model", t); 30 | } 31 | else 32 | { 33 | Multiply m = new Multiply (); 34 | m.parent = this; 35 | m.operand0 = t; 36 | m.operand1 = model; 37 | t.parent = m; 38 | model.parent = m; 39 | keywords.put ("model", m); 40 | } 41 | Operator[] nextOperands = new Operator[1]; 42 | nextOperands[0] = operands[0]; 43 | operands = nextOperands; 44 | 45 | from.changed = true; 46 | return this; 47 | } 48 | 49 | public boolean needModelMatrix () 50 | { 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Mmatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.backend.internal.Simulator; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | import gov.sandia.n2a.language.type.Text; 14 | import gov.sandia.n2a.linear.MatrixDense; 15 | 16 | public class Mmatrix extends Mfile 17 | { 18 | public static Factory factory () 19 | { 20 | return new Factory () 21 | { 22 | public String name () 23 | { 24 | return "Mmatrix"; 25 | } 26 | 27 | public Operator createInstance () 28 | { 29 | return new Mmatrix (); 30 | } 31 | }; 32 | } 33 | 34 | public boolean isMatrixInput () 35 | { 36 | return true; 37 | } 38 | 39 | public Type getType () 40 | { 41 | return new MatrixDense (); 42 | } 43 | 44 | public Type eval (Instance context) 45 | { 46 | Simulator simulator = Simulator.instance.get (); 47 | if (simulator == null) return getType (); // absence of simulator indicates analysis phase, so opening files is unnecessary 48 | 49 | String path = ((Text) operands[0].eval (context)).value; 50 | Holder H = Holder.get (simulator, path, context, this); 51 | return H.getMatrix (context, this); 52 | } 53 | 54 | public String toString () 55 | { 56 | return "Mmatrix"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Mnumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.backend.internal.Simulator; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | import gov.sandia.n2a.language.type.Scalar; 14 | import gov.sandia.n2a.language.type.Text; 15 | 16 | public class Mnumber extends Mfile 17 | { 18 | public static Factory factory () 19 | { 20 | return new Factory () 21 | { 22 | public String name () 23 | { 24 | return "Mnumber"; 25 | } 26 | 27 | public Operator createInstance () 28 | { 29 | return new Mnumber (); 30 | } 31 | }; 32 | } 33 | 34 | public Type getType () 35 | { 36 | return new Scalar (); 37 | } 38 | 39 | public Type eval (Instance context) 40 | { 41 | Simulator simulator = Simulator.instance.get (); 42 | if (simulator == null) return getType (); // absence of simulator indicates analysis phase, so opening files is unnecessary 43 | 44 | String path = ((Text) operands[0].eval (context)).value; 45 | Holder H = Holder.get (simulator, path, context, this); 46 | return new Scalar (H.doc.getDouble (Holder.keyPath (context, this, 1))); 47 | } 48 | 49 | public String toString () 50 | { 51 | return "Mnumber"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Mstring.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.backend.internal.Simulator; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | import gov.sandia.n2a.language.type.Text; 14 | 15 | public class Mstring extends Mfile 16 | { 17 | public static Factory factory () 18 | { 19 | return new Factory () 20 | { 21 | public String name () 22 | { 23 | return "Mstring"; 24 | } 25 | 26 | public Operator createInstance () 27 | { 28 | return new Mstring (); 29 | } 30 | }; 31 | } 32 | 33 | public Type getType () 34 | { 35 | return new Text (); 36 | } 37 | 38 | public Type eval (Instance context) 39 | { 40 | Simulator simulator = Simulator.instance.get (); 41 | if (simulator == null) return getType (); // absence of simulator indicates analysis phase, so opening files is unnecessary 42 | 43 | String path = ((Text) operands[0].eval (context)).value; 44 | Holder H = Holder.get (simulator, path, context, this); 45 | return new Text (H.doc.get (Holder.keyPath (context, this, 1))); 46 | } 47 | 48 | public String toString () 49 | { 50 | return "Mstring"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/function/Rows.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.function; 8 | 9 | import gov.sandia.n2a.eqset.EquationSet.ExponentContext; 10 | import gov.sandia.n2a.language.Function; 11 | import gov.sandia.n2a.language.Operator; 12 | import gov.sandia.n2a.language.Type; 13 | import gov.sandia.n2a.language.type.Instance; 14 | import gov.sandia.n2a.language.type.Matrix; 15 | import gov.sandia.n2a.language.type.Scalar; 16 | 17 | public class Rows extends Function 18 | { 19 | public static Factory factory () 20 | { 21 | return new Factory () 22 | { 23 | public String name () 24 | { 25 | return "rows"; 26 | } 27 | 28 | public Operator createInstance () 29 | { 30 | return new Rows (); 31 | } 32 | }; 33 | } 34 | 35 | public void determineExponent (ExponentContext context) 36 | { 37 | updateExponent (context, 0, 0); // small integer 38 | } 39 | 40 | public void determineExponentNext () 41 | { 42 | // No action. The operand is never evaluated. 43 | } 44 | 45 | public Type getType () 46 | { 47 | return new Scalar (); 48 | } 49 | 50 | public Type eval (Instance context) 51 | { 52 | Matrix A = (Matrix) operands[0].eval (context); 53 | return new Scalar (A.rows ()); 54 | } 55 | 56 | public String toString () 57 | { 58 | return "rows"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/EQ.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.language.Comparison; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | 14 | public class EQ extends Comparison 15 | { 16 | public static Factory factory () 17 | { 18 | return new Factory () 19 | { 20 | public String name () 21 | { 22 | return "=="; 23 | } 24 | 25 | public Operator createInstance () 26 | { 27 | return new EQ (); 28 | } 29 | }; 30 | } 31 | 32 | public int precedence () 33 | { 34 | return 7; 35 | } 36 | 37 | public Type eval (Instance context) 38 | { 39 | return operand0.eval (context).EQ (operand1.eval (context)); 40 | } 41 | 42 | public String toString () 43 | { 44 | return "=="; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/GE.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.language.Comparison; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | 14 | public class GE extends Comparison 15 | { 16 | public static Factory factory () 17 | { 18 | return new Factory () 19 | { 20 | public String name () 21 | { 22 | return ">="; 23 | } 24 | 25 | public Operator createInstance () 26 | { 27 | return new GE (); 28 | } 29 | }; 30 | } 31 | 32 | public int precedence () 33 | { 34 | return 6; 35 | } 36 | 37 | public Type eval (Instance context) 38 | { 39 | return operand0.eval (context).GE (operand1.eval (context)); 40 | } 41 | 42 | public String toString () 43 | { 44 | return ">="; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/GT.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | import gov.sandia.n2a.language.Comparison; 11 | import gov.sandia.n2a.language.Constant; 12 | import gov.sandia.n2a.language.Operator; 13 | import gov.sandia.n2a.language.Type; 14 | import gov.sandia.n2a.language.type.Instance; 15 | 16 | public class GT extends Comparison 17 | { 18 | public static Factory factory () 19 | { 20 | return new Factory () 21 | { 22 | public String name () 23 | { 24 | return ">"; 25 | } 26 | 27 | public Operator createInstance () 28 | { 29 | return new GT (); 30 | } 31 | }; 32 | } 33 | 34 | public int precedence () 35 | { 36 | return 6; 37 | } 38 | 39 | public Operator simplify (Variable from, boolean evalOnly) 40 | { 41 | Operator result = super.simplify (from, evalOnly); 42 | if (result != this) return result; 43 | 44 | double a = operand0.getDouble (); 45 | if (Double.isInfinite (a) && a < 0) // negative infinity can never be greater than anything 46 | { 47 | from.changed = true; 48 | result = new Constant (0); 49 | result.parent = parent; 50 | return result; 51 | } 52 | 53 | double b = operand1.getDouble (); 54 | if (Double.isInfinite (b) && b > 0) // nothing can be greater than positive infinity 55 | { 56 | from.changed = true; 57 | result = new Constant (0); 58 | result.parent = parent; 59 | return result; 60 | } 61 | 62 | return this; 63 | } 64 | 65 | public Type eval (Instance context) 66 | { 67 | return operand0.eval (context).GT (operand1.eval (context)); 68 | } 69 | 70 | public String toString () 71 | { 72 | return ">"; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/LE.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.language.Comparison; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | 14 | public class LE extends Comparison 15 | { 16 | public static Factory factory () 17 | { 18 | return new Factory () 19 | { 20 | public String name () 21 | { 22 | return "<="; 23 | } 24 | 25 | public Operator createInstance () 26 | { 27 | return new LE (); 28 | } 29 | }; 30 | } 31 | 32 | public int precedence () 33 | { 34 | return 6; 35 | } 36 | 37 | public Type eval (Instance context) 38 | { 39 | return operand0.eval (context).LE (operand1.eval (context)); 40 | } 41 | 42 | public String toString () 43 | { 44 | return "<="; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/LT.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.eqset.Variable; 10 | import gov.sandia.n2a.language.Comparison; 11 | import gov.sandia.n2a.language.Constant; 12 | import gov.sandia.n2a.language.Operator; 13 | import gov.sandia.n2a.language.Type; 14 | import gov.sandia.n2a.language.type.Instance; 15 | 16 | public class LT extends Comparison 17 | { 18 | public static Factory factory () 19 | { 20 | return new Factory () 21 | { 22 | public String name () 23 | { 24 | return "<"; 25 | } 26 | 27 | public Operator createInstance () 28 | { 29 | return new LT (); 30 | } 31 | }; 32 | } 33 | 34 | public int precedence () 35 | { 36 | return 6; 37 | } 38 | 39 | public Operator simplify (Variable from, boolean evalOnly) 40 | { 41 | Operator result = super.simplify (from, evalOnly); 42 | if (result != this) return result; 43 | 44 | double a = operand0.getDouble (); 45 | if (Double.isInfinite (a) && a > 0) // positive infinity can never be less than anything 46 | { 47 | from.changed = true; 48 | result = new Constant (0); 49 | result.parent = parent; 50 | return result; 51 | } 52 | 53 | double b = operand1.getDouble (); 54 | if (Double.isInfinite (b) && b < 0) // nothing can be less than negative infinity 55 | { 56 | from.changed = true; 57 | result = new Constant (0); 58 | result.parent = parent; 59 | return result; 60 | } 61 | 62 | return this; 63 | } 64 | 65 | public Type eval (Instance context) 66 | { 67 | return operand0.eval (context).LT (operand1.eval (context)); 68 | } 69 | 70 | public String toString () 71 | { 72 | return "<"; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/NE.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.language.Comparison; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | 14 | public class NE extends Comparison 15 | { 16 | public static Factory factory () 17 | { 18 | return new Factory () 19 | { 20 | public String name () 21 | { 22 | return "!="; 23 | } 24 | 25 | public Operator createInstance () 26 | { 27 | return new NE (); 28 | } 29 | }; 30 | } 31 | 32 | public int precedence () 33 | { 34 | return 7; 35 | } 36 | 37 | public Type eval (Instance context) 38 | { 39 | return operand0.eval (context).NE (operand1.eval (context)); 40 | } 41 | 42 | public String toString () 43 | { 44 | return "!="; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/Negate.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.eqset.Equality; 10 | import gov.sandia.n2a.language.EvaluationException; 11 | import gov.sandia.n2a.language.Operator; 12 | import gov.sandia.n2a.language.OperatorUnary; 13 | import gov.sandia.n2a.language.Type; 14 | import gov.sandia.n2a.language.type.Instance; 15 | 16 | public class Negate extends OperatorUnary 17 | { 18 | public static Factory factory () 19 | { 20 | return new Factory () 21 | { 22 | public String name () 23 | { 24 | return "UM"; 25 | } 26 | 27 | public Operator createInstance () 28 | { 29 | return new Negate (); 30 | } 31 | }; 32 | } 33 | 34 | public Associativity associativity () 35 | { 36 | return Associativity.RIGHT_TO_LEFT; 37 | } 38 | 39 | public int precedence () 40 | { 41 | return 3; 42 | } 43 | 44 | public Type eval (Instance context) 45 | { 46 | return operand.eval (context).negate (); 47 | } 48 | 49 | public double getDouble () 50 | { 51 | return - operand.getDouble (); 52 | } 53 | 54 | public boolean isScalar () 55 | { 56 | return operand.isScalar (); 57 | } 58 | 59 | public void solve (Equality statement) throws EvaluationException 60 | { 61 | statement.lhs = operand; 62 | operand = statement.rhs; 63 | statement.rhs = this; 64 | } 65 | 66 | public String toString () 67 | { 68 | return "-"; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/language/operator/Transpose.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.language.operator; 8 | 9 | import gov.sandia.n2a.language.Operator; 10 | import gov.sandia.n2a.language.OperatorUnary; 11 | import gov.sandia.n2a.language.Type; 12 | import gov.sandia.n2a.language.type.Instance; 13 | 14 | public class Transpose extends OperatorUnary 15 | { 16 | public static Factory factory () 17 | { 18 | return new Factory () 19 | { 20 | public String name () 21 | { 22 | return "~"; 23 | } 24 | 25 | public Operator createInstance () 26 | { 27 | return new Transpose (); 28 | } 29 | }; 30 | } 31 | 32 | public Associativity associativity () 33 | { 34 | return Associativity.RIGHT_TO_LEFT; 35 | } 36 | 37 | public int precedence () 38 | { 39 | return 3; 40 | } 41 | 42 | public Type eval (Instance context) 43 | { 44 | return operand.eval (context).transpose (); 45 | } 46 | 47 | public String toString () 48 | { 49 | return "~"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/linear/Factorization.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.linear; 8 | 9 | import gov.sandia.n2a.language.type.Matrix; 10 | 11 | /** 12 | Interface for using matrix factorizations. 13 | 14 | The factorization work is typically done by the constructor. 15 | It takes the matrix to be factored, then sets up internal state 16 | with results of the factorization. This can later be used by 17 | solve() and invert(). 18 | 19 | By default, the functions of this class will not damage the matrices 20 | passed as parameters. Furthermore, the class promises to keep its 21 | internal state in a reusable form, so for example solve() can be 22 | called multiple times. However, a subclass may allow you to pass a 23 | flag that revokes these promises for the sake of memory efficiency. 24 | **/ 25 | public interface Factorization 26 | { 27 | /** 28 | Resets all internal state and stores the factorization of A. 29 | **/ 30 | public void factorize (Matrix A); 31 | 32 | /** 33 | Solve AX=B, where A is the matrix represented by this factorization. 34 | @return X 35 | **/ 36 | public Matrix solve (Matrix B); 37 | 38 | /** 39 | @return The inverse of A, the matrix represented by this factorization. 40 | If A is not square, returns the pseudo-inverse. 41 | If A is not invertible, returns null. 42 | **/ 43 | public Matrix invert (); 44 | } 45 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/ExtensionPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013,2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins; 8 | 9 | /** 10 | * This interface 11 | * 12 | * @author dtrumbo 13 | */ 14 | 15 | public interface ExtensionPoint { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/Activity.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013,2016,2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import java.awt.Component; 10 | 11 | import javax.swing.ImageIcon; 12 | 13 | import gov.sandia.n2a.plugins.ExtensionPoint; 14 | 15 | public interface Activity extends ExtensionPoint 16 | { 17 | public String getName (); 18 | public ImageIcon getIcon (); 19 | 20 | /** 21 | Returns a panel to go in the tabbed pane. Can actually be any AWT component. 22 | **/ 23 | public Component getPanel (); 24 | 25 | /** 26 | Returns the component within the panel which should receive focus when the 27 | panel is exposed for the first time. After that, the tabbed pane code will 28 | keep track of the last-focused component and select it when the panel is 29 | re-exposed. Can return null. 30 | **/ 31 | public Component getInitialFocus (Component panel); 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/Export.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.plugins.ExtensionPoint; 11 | 12 | import java.nio.file.Path; 13 | 14 | 15 | public interface Export extends ExtensionPoint 16 | { 17 | public String getName (); 18 | public void process (MNode document, Path destination) throws Exception; 19 | public boolean accept (Path source); // For the purpose of file dialog filtering. This should be a lightweight test, for example examining only the suffix. 20 | } 21 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/ExportModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | /** 10 | Marks this exporter as specific for models. 11 | **/ 12 | public interface ExportModel extends Export 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/Import.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import java.nio.file.Path; 10 | 11 | import gov.sandia.n2a.plugins.ExtensionPoint; 12 | 13 | public interface Import extends ExtensionPoint 14 | { 15 | public String getName (); 16 | public void process (Path source, String name) throws Exception; // "name" is a hint for the internal key of the created record. May be null. May be ignored by some importers. 17 | public float matches (Path source); // @return The probability that the file contains this format. 18 | public boolean accept (Path source); // For the purpose of file dialog filtering. This should be a lightweight test, for example examining only the suffix. 19 | } 20 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/ImportModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | /** 10 | Marks this importer as specific for models. 11 | **/ 12 | public interface ImportModel extends Import 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import gov.sandia.n2a.plugins.ExtensionPoint; 10 | 11 | public interface Service extends ExtensionPoint 12 | { 13 | public String name (); 14 | 15 | /** 16 | Starts the server on a separate thread. 17 | The thread should be non-daemon, or else the VM will shut down. 18 | The thread runs indefinitely, until it reaches its own termination condition 19 | or the VM receives a signal, such as SIGTERM. 20 | For graceful shutdown, a plugin can also register a ShutdownHook that communicates 21 | with the running server. 22 | **/ 23 | public void start (); 24 | } 25 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/Settings.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import java.awt.Component; 10 | 11 | import javax.swing.ImageIcon; 12 | 13 | import gov.sandia.n2a.plugins.ExtensionPoint; 14 | 15 | public interface Settings extends ExtensionPoint 16 | { 17 | public String getName (); 18 | public ImageIcon getIcon (); 19 | 20 | /** 21 | Returns a panel to go in the settings tab. Can actually be any AWT component. 22 | **/ 23 | public Component getPanel (); 24 | 25 | /** 26 | Returns the component within the panel which should receive focus when the 27 | panel is exposed for the first time. After that, the settings tab code will 28 | keep track of the last-focused component and select it when the panel is 29 | re-exposed. Can return null. 30 | **/ 31 | public Component getInitialFocus (Component panel); 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/ShutdownHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import gov.sandia.n2a.plugins.ExtensionPoint; 10 | 11 | public interface ShutdownHook extends ExtensionPoint 12 | { 13 | /** 14 | An opportunity to do final work before the app shuts down. 15 | This is called before AppData is flushed to disk, so it is OK to store final 16 | state by updating objects contained in AppData. 17 | **/ 18 | public void shutdown (); 19 | } 20 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/plugins/extpoints/StudyHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.plugins.extpoints; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.db.MPart; 11 | import gov.sandia.n2a.plugins.ExtensionPoint; 12 | 13 | public interface StudyHook extends ExtensionPoint 14 | { 15 | /** 16 | @return The key associated with this hook in $meta.study.plugin 17 | **/ 18 | public String name (); 19 | 20 | /** 21 | Makes one-time changes to the study setup, before any samples are generated. 22 | Notice that the plugin key is part of study "config". 23 | **/ 24 | public void modifyStudy (MNode study); 25 | 26 | /** 27 | Makes any needed changes to a study sample before running it. 28 | Called after iterators have been applied and before the modified model is stored to snapshot. 29 | @param model The collated form of the sample model. Changes to this will be saved and 30 | affect the simulation. 31 | @param job The document for managing the job. Can be used to locate the job directory 32 | for further modifications, such as copying files. 33 | **/ 34 | public void modifySample (MPart model, MNode job); 35 | } 36 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/transfer/ExportNative.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.transfer; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.db.Schema; 11 | import gov.sandia.n2a.plugins.extpoints.ExportModel; 12 | 13 | import java.io.BufferedWriter; 14 | import java.io.IOException; 15 | import java.nio.file.Files; 16 | import java.nio.file.Path; 17 | 18 | public class ExportNative implements ExportModel 19 | { 20 | @Override 21 | public String getName () 22 | { 23 | return "N2A Native"; 24 | } 25 | 26 | @Override 27 | public void process (MNode source, Path destination) throws IOException 28 | { 29 | // Write a standard repository file. See MDoc.save() 30 | BufferedWriter writer = Files.newBufferedWriter (destination); 31 | Schema schema = Schema.latest (); 32 | schema.write (writer); 33 | for (MNode n : source) schema.write (n, writer, ""); 34 | writer.close (); 35 | } 36 | 37 | @Override 38 | public boolean accept (Path source) 39 | { 40 | if (Files.isDirectory (source)) return true; 41 | String name = source.getFileName ().toString (); 42 | int lastDot = name.lastIndexOf ('.'); 43 | if (lastDot < 0) return true; // Assume a file with no suffix could be an n2a file. 44 | String suffix = name.substring (lastDot); 45 | if (suffix.equalsIgnoreCase (".n2a")) return true; 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/transfer/ImportNative.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.transfer; 8 | 9 | import gov.sandia.n2a.db.MVolatile; 10 | import gov.sandia.n2a.db.Schema; 11 | import gov.sandia.n2a.plugins.extpoints.ImportModel; 12 | import gov.sandia.n2a.ui.MainFrame; 13 | import gov.sandia.n2a.ui.eq.undo.AddDoc; 14 | 15 | import java.io.BufferedReader; 16 | import java.io.IOException; 17 | import java.nio.file.Files; 18 | import java.nio.file.Path; 19 | 20 | public class ImportNative implements ImportModel 21 | { 22 | @Override 23 | public String getName () 24 | { 25 | return "N2A Native"; 26 | } 27 | 28 | @Override 29 | public void process (Path source, String name) 30 | { 31 | if (name == null) 32 | { 33 | name = source.getFileName ().toString (); 34 | if (name.endsWith (".n2a")) name = name.substring (0, name.length () - 4); 35 | } 36 | 37 | try (BufferedReader reader = Files.newBufferedReader (source)) 38 | { 39 | MVolatile doc = new MVolatile (); 40 | Schema.readAll (doc, reader); 41 | MainFrame.undoManager.apply (new AddDoc (name, doc)); 42 | } 43 | catch (IOException e) 44 | { 45 | } 46 | } 47 | 48 | @Override 49 | public float matches (Path source) 50 | { 51 | try (BufferedReader reader = Files.newBufferedReader (source)) 52 | { 53 | String line = reader.readLine (); 54 | if (line.startsWith ("N2A.schema")) return 1; 55 | } 56 | catch (IOException e) 57 | { 58 | } 59 | return 0; 60 | } 61 | 62 | @Override 63 | public boolean accept (Path source) 64 | { 65 | if (Files.isDirectory (source)) return true; 66 | String name = source.getFileName ().toString (); 67 | int lastDot = name.lastIndexOf ('.'); 68 | if (lastDot >= 0 && name.substring (lastDot).equalsIgnoreCase (".n2a")) return true; 69 | return false; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/CompoundEdit.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui; 8 | 9 | import javax.swing.undo.UndoableEdit; 10 | 11 | @SuppressWarnings("serial") 12 | public class CompoundEdit extends javax.swing.undo.CompoundEdit 13 | { 14 | /** 15 | Implements anihilate on incoming edits. 16 | Assumes that given edit has already been redone by our own extended UndoManager. 17 | **/ 18 | public synchronized boolean addEdit (UndoableEdit edit) 19 | { 20 | if (! super.addEdit (edit)) return false; 21 | if (edit instanceof Undoable && ((Undoable) edit).anihilate ()) 22 | { 23 | edits.remove (edits.size () - 1); 24 | } 25 | return true; 26 | } 27 | 28 | public synchronized boolean isEmpty () 29 | { 30 | return edits.size () == 0; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/ActivityModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013,2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq; 8 | 9 | import java.awt.Component; 10 | 11 | import gov.sandia.n2a.plugins.extpoints.Activity; 12 | import gov.sandia.n2a.ui.images.ImageUtil; 13 | 14 | import javax.swing.ImageIcon; 15 | 16 | public class ActivityModel implements Activity 17 | { 18 | @Override 19 | public ImageIcon getIcon () 20 | { 21 | return ImageUtil.getImage ("comp.gif"); 22 | } 23 | 24 | @Override 25 | public String getName () 26 | { 27 | return "Models"; 28 | } 29 | 30 | @Override 31 | public Component getPanel () 32 | { 33 | return new PanelModel (); 34 | } 35 | 36 | @Override 37 | public Component getInitialFocus (Component panel) 38 | { 39 | return ((PanelModel) panel).panelSearch.textQuery; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/search/NodeCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.search; 8 | 9 | @SuppressWarnings("serial") 10 | public class NodeCategory extends NodeBase 11 | { 12 | public NodeCategory (String name) 13 | { 14 | setUserObject (name); 15 | } 16 | 17 | @Override 18 | public boolean isLeaf () 19 | { 20 | return false; 21 | } 22 | 23 | @Override 24 | public String getCategory () 25 | { 26 | String result = ""; 27 | for (String key : getKeyPath ()) result += "/" + key; 28 | if (result.isEmpty ()) return result; 29 | return result.substring (1); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/tree/NodeIO.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.tree; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.db.MPart; 11 | import gov.sandia.n2a.db.MPartRepo; 12 | import gov.sandia.n2a.db.MVolatile; 13 | 14 | @SuppressWarnings("serial") 15 | public class NodeIO extends NodePart 16 | { 17 | protected String side; 18 | 19 | public NodeIO (String side, NodePart parent) 20 | { 21 | this.side = side; 22 | this.parent = parent; // No real hierarchy established. In particular, container.part does not get node added to its children. 23 | iconCustom16 = NodeVariable.iconBinding; 24 | 25 | MNode empty; 26 | if (side.equals ("in")) 27 | { 28 | empty = new MVolatile (null, "Inputs"); 29 | pinOut = parent.pinIn; 30 | pinOutOrder = parent.pinInOrder; 31 | } 32 | else 33 | { 34 | empty = new MVolatile (null, "Outputs"); 35 | pinIn = parent.pinOut; 36 | pinInOrder = parent.pinOutOrder; 37 | } 38 | source = new MPartRepo (empty); // fake source 39 | } 40 | 41 | @Override 42 | public int getForegroundColor () 43 | { 44 | NodePart np = (NodePart) trueParent; 45 | MPart pin = (MPart) np.source.child ("$meta", "gui", "pin", side); 46 | if (pin != null && pin.isFromTopDocument ()) return OVERRIDE; 47 | return INHERIT; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/undo/AddEditable.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.undo; 8 | 9 | import gov.sandia.n2a.ui.eq.tree.NodeBase; 10 | 11 | public interface AddEditable 12 | { 13 | public NodeBase getCreatedNode (); 14 | } 15 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/undo/AddReferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.undo; 8 | 9 | import java.util.List; 10 | 11 | import gov.sandia.n2a.db.MNode; 12 | import gov.sandia.n2a.db.MPart; 13 | import gov.sandia.n2a.db.MVolatile; 14 | import gov.sandia.n2a.ui.eq.tree.NodeBase; 15 | import gov.sandia.n2a.ui.eq.tree.NodeReferences; 16 | 17 | public class AddReferences extends UndoableView 18 | { 19 | protected List path; ///< to parent of $meta node 20 | protected int index; ///< Position within parent node 21 | protected MVolatile saved; ///< subtree under $meta 22 | protected boolean multi; 23 | protected boolean multiLast; 24 | 25 | public AddReferences (NodeBase parent, int index, MNode data) 26 | { 27 | path = parent.getKeyPath (); 28 | this.index = index; 29 | 30 | saved = new MVolatile (null, "$ref"); 31 | saved.merge (data); 32 | } 33 | 34 | public void setMulti (boolean value) 35 | { 36 | multi = value; 37 | } 38 | 39 | public void setMultiLast (boolean value) 40 | { 41 | multiLast = value; 42 | } 43 | 44 | public void undo () 45 | { 46 | super.undo (); 47 | AddAnnotations.destroy (path, saved.key (), ! multi || multiLast, false, false); 48 | } 49 | 50 | public void redo () 51 | { 52 | super.redo (); 53 | NodeFactory factory = new NodeFactory () 54 | { 55 | public NodeBase create (MPart part) 56 | { 57 | return new NodeReferences (part); 58 | } 59 | }; 60 | AddAnnotations.create (path, index, saved, factory, multi, false, false); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/undo/DeleteInherit.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.undo; 8 | 9 | import java.util.List; 10 | 11 | import javax.swing.undo.UndoableEdit; 12 | 13 | import gov.sandia.n2a.ui.eq.tree.NodeBase; 14 | import gov.sandia.n2a.ui.eq.tree.NodeInherit; 15 | 16 | public class DeleteInherit extends UndoableView 17 | { 18 | protected List path; // to parent part 19 | protected boolean canceled; 20 | protected String value; 21 | protected boolean neutralized; 22 | 23 | public DeleteInherit (NodeInherit node, boolean canceled) 24 | { 25 | NodeBase container = (NodeBase) node.getParent (); 26 | path = container.getKeyPath (); 27 | this.canceled = canceled; 28 | value = node.source.get (); 29 | } 30 | 31 | public void undo () 32 | { 33 | super.undo (); 34 | AddInherit.create (path, value); 35 | } 36 | 37 | public void redo () 38 | { 39 | super.redo (); 40 | AddInherit.destroy (path, canceled); 41 | } 42 | 43 | public boolean replaceEdit (UndoableEdit edit) 44 | { 45 | if (edit instanceof AddInherit) 46 | { 47 | AddInherit ai = (AddInherit) edit; 48 | neutralized = path.equals (ai.path); 49 | } 50 | return neutralized; 51 | } 52 | 53 | public boolean anihilate () 54 | { 55 | return neutralized; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/undo/DeleteReferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.undo; 8 | 9 | import java.util.List; 10 | 11 | import gov.sandia.n2a.db.MPart; 12 | import gov.sandia.n2a.db.MVolatile; 13 | import gov.sandia.n2a.ui.eq.tree.NodeBase; 14 | import gov.sandia.n2a.ui.eq.tree.NodeReferences; 15 | 16 | public class DeleteReferences extends UndoableView 17 | { 18 | protected List path; ///< to parent of $meta node 19 | protected int index; ///< Position within parent node 20 | protected MVolatile saved; ///< subtree under $meta 21 | protected boolean multi; 22 | protected boolean multiLast; 23 | 24 | public DeleteReferences (NodeBase node) 25 | { 26 | NodeBase container = (NodeBase) node.getParent (); 27 | path = container.getKeyPath (); 28 | index = container.getIndex (node); 29 | 30 | saved = new MVolatile (null, "$ref"); 31 | saved.merge (node.source.getSource ()); // We only save top-document data. $meta node is guaranteed to be from top doc, due to guard in NodeAnnotations.delete(). 32 | } 33 | 34 | public void setMulti (boolean value) 35 | { 36 | multi = value; 37 | } 38 | 39 | public void setMultiLast (boolean value) 40 | { 41 | multiLast = value; 42 | } 43 | 44 | public void undo () 45 | { 46 | super.undo (); 47 | NodeFactory factory = new NodeFactory () 48 | { 49 | public NodeBase create (MPart part) 50 | { 51 | return new NodeReferences (part); 52 | } 53 | }; 54 | AddAnnotations.create (path, index, saved, factory, multi, false, false); 55 | } 56 | 57 | public void redo () 58 | { 59 | super.redo (); 60 | AddAnnotations.destroy (path, saved.key (), ! multi || multiLast, false, false); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/undo/NodeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.undo; 8 | 9 | import gov.sandia.n2a.db.MPart; 10 | import gov.sandia.n2a.ui.eq.tree.NodeBase; 11 | 12 | public interface NodeFactory 13 | { 14 | public NodeBase create (MPart part); 15 | } 16 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/eq/undo/UndoableView.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.eq.undo; 8 | 9 | import javax.swing.undo.CannotRedoException; 10 | import javax.swing.undo.CannotUndoException; 11 | import gov.sandia.n2a.ui.Undoable; 12 | import gov.sandia.n2a.ui.eq.PanelModel; 13 | import gov.sandia.n2a.ui.eq.tree.NodeBase; 14 | import gov.sandia.n2a.ui.eq.PanelEquations.StoredView; 15 | 16 | public class UndoableView extends Undoable 17 | { 18 | protected StoredView view; 19 | 20 | public UndoableView () 21 | { 22 | view = PanelModel.instance.panelEquations.new StoredView (); 23 | } 24 | 25 | public UndoableView (NodeBase node) 26 | { 27 | view = PanelModel.instance.panelEquations.new StoredView (node); 28 | } 29 | 30 | public void setMulti (boolean value) 31 | { 32 | } 33 | 34 | /** 35 | For deletes or delete-like operations, sets a flag so that indicates this is the last 36 | item in a compound edit. In this case, it is necessary to determine where the focus 37 | should go after the node disappears. It is also possible that an overridden node 38 | becomes visible, so the focus should go nowhere. Individual undoable classes will know 39 | what to do. 40 | **/ 41 | public void setMultiLast (boolean value) 42 | { 43 | } 44 | 45 | public void undo () throws CannotUndoException 46 | { 47 | super.undo (); 48 | if (view != null) view.restore (); 49 | } 50 | 51 | public void redo () throws CannotRedoException 52 | { 53 | super.redo (); 54 | if (view != null) view.restore (); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/ImageUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013,2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.images; 8 | 9 | import java.net.URL; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | import javax.swing.ImageIcon; 14 | 15 | public class ImageUtil 16 | { 17 | public static Map loadedImages = new HashMap (); 18 | 19 | public static ImageIcon getImage (String name) 20 | { 21 | URL imageURL = ImageUtil.class.getResource (name); 22 | if (imageURL == null) return null; // May cause NPE in caller, which is a fine way to reveal broken internal logic. 23 | ImageIcon icon = loadedImages.get (imageURL); 24 | if (icon == null) 25 | { 26 | icon = new ImageIcon (imageURL); 27 | loadedImages.put (imageURL, icon); 28 | } 29 | return icon; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/add.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/add.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/analysis.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/analysis.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/assign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/assign.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/book.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/book.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/commit.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/comp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/comp.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/complete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/complete.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/connect.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/connect.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/connection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/connection.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/copy.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/delta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/delta.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/disconnect.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/disconnect.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/disconnected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/disconnected.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/document.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/edit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/edit.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/equation-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/equation-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/equation-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/equation-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/export.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/export.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/fileImage-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/fileImage-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/fileImage-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/fileImage-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/fileImage-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/fileImage-64.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/fileVideo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/fileVideo.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/file_err.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/file_err.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/file_in.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/file_in.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/file_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/file_obj.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/file_out.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/file_out.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/filter.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/filterFilled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/filterFilled.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/help.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/help.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/import.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/import.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/inherit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/inherit.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/lingering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/lingering.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/locked-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/locked-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/locked.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/n2a-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/n2a-128.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/n2a-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/n2a-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/n2a-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/n2a-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/n2a-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/n2a-48.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/n2a-splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/n2a-splash.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/pause-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/pause-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/pause-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/pause-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/pin.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/preparing-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/preparing-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/preparing-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/preparing-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/preparing-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/preparing-64.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/print.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/properties.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/properties.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/pull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/pull.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/push.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/queue-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/queue-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/queue-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/queue-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/raster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/raster.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/refresh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/refresh.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/remove.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/remove.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/repo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/repo.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/run-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/run-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/run-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/run-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/save.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/save.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/settings.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/slow-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/slow-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/stop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/stop.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/straight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/straight.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/study-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/study-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/study-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/study-32.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/subtract.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/subtract.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/tableSorted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/tableSorted.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/topic-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/topic-16.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/unlocked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/unlocked.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/view.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/view.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/viewBottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/viewBottom.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/viewGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/viewGraph.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/viewOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/viewOptions.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/viewSide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/viewSide.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/warn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/warn.gif -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/images/watch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandialabs/n2a/096ad63bd82893d84fdfff2ae433ae96fb14c907/N2A/src/gov/sandia/n2a/ui/images/watch.png -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/jobs/ActivityRun.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013,2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.jobs; 8 | 9 | import java.awt.Component; 10 | 11 | import gov.sandia.n2a.plugins.extpoints.Activity; 12 | import gov.sandia.n2a.ui.images.ImageUtil; 13 | 14 | import javax.swing.ImageIcon; 15 | 16 | public class ActivityRun implements Activity 17 | { 18 | @Override 19 | public ImageIcon getIcon () 20 | { 21 | return ImageUtil.getImage ("run-16.png"); 22 | } 23 | 24 | @Override 25 | public String getName () 26 | { 27 | return "Runs"; 28 | } 29 | 30 | @Override 31 | public Component getPanel () 32 | { 33 | return new PanelRun (); 34 | } 35 | 36 | @Override 37 | public Component getInitialFocus (Component panel) 38 | { 39 | return ((PanelRun) panel).tree; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/jobs/NodeBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.jobs; 8 | 9 | import javax.swing.Icon; 10 | import javax.swing.tree.DefaultMutableTreeNode; 11 | 12 | @SuppressWarnings("serial") 13 | public class NodeBase extends DefaultMutableTreeNode 14 | { 15 | public int markDelete; // Indicates that this node should be drawn with strikethru font, indicating that it is queued to be deleted. 16 | 17 | public Icon getIcon (boolean expanded) 18 | { 19 | return null; 20 | } 21 | 22 | public String toString () 23 | { 24 | String result = super.toString (); 25 | if (markDelete > 0) result = "" + result + ""; 26 | return result; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/jobs/NodeError.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.jobs; 8 | 9 | import java.nio.file.Path; 10 | 11 | @SuppressWarnings("serial") 12 | public class NodeError extends NodeFile 13 | { 14 | public NodeError (Path path) 15 | { 16 | super (path); 17 | icon = iconErr; 18 | setUserObject ("Diagnostics"); 19 | } 20 | 21 | @Override 22 | public boolean couldHaveColumns () 23 | { 24 | return false; 25 | } 26 | 27 | @Override 28 | public boolean isGraphable () 29 | { 30 | return false; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/jobs/NodeImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.jobs; 8 | 9 | import java.awt.EventQueue; 10 | import java.nio.file.Path; 11 | 12 | import javax.swing.ImageIcon; 13 | 14 | import gov.sandia.n2a.ui.images.ImageUtil; 15 | import gov.sandia.n2a.ui.jobs.PanelRun.DisplayThread; 16 | 17 | @SuppressWarnings("serial") 18 | public class NodeImage extends NodeFile 19 | { 20 | public static final ImageIcon iconImage = ImageUtil.getImage ("fileImage-16.png"); 21 | 22 | public NodeImage (Path path) 23 | { 24 | super (path); 25 | priority = 2; 26 | icon = iconImage; 27 | } 28 | 29 | @Override 30 | public boolean couldHaveColumns () 31 | { 32 | return false; 33 | } 34 | 35 | @Override 36 | public boolean isGraphable () 37 | { 38 | return false; 39 | } 40 | 41 | @Override 42 | public boolean render (DisplayThread dt) 43 | { 44 | final Picture p = new Picture (path); 45 | EventQueue.invokeLater (new Runnable () 46 | { 47 | public void run () 48 | { 49 | PanelRun pr = PanelRun.instance; 50 | synchronized (pr.displayPane) 51 | { 52 | if (dt != pr.displayThread) return; 53 | pr.displayChart.buttonBar.setVisible (false); 54 | pr.displayPane.setViewportView (p); 55 | } 56 | } 57 | }); 58 | return true; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/jobs/NodeOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.jobs; 8 | 9 | import java.nio.file.Path; 10 | 11 | @SuppressWarnings("serial") 12 | public class NodeOutput extends NodeFile 13 | { 14 | public NodeOutput (Path path) 15 | { 16 | super (path); 17 | priority = 1; 18 | icon = iconOut; 19 | setUserObject ("Output"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/jobs/Picture.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.jobs; 8 | 9 | import java.awt.Dimension; 10 | import java.awt.Graphics; 11 | import java.awt.image.BufferedImage; 12 | import java.io.IOException; 13 | import java.nio.file.Path; 14 | import javax.imageio.ImageIO; 15 | import javax.swing.JPanel; 16 | 17 | @SuppressWarnings("serial") 18 | public class Picture extends JPanel 19 | { 20 | protected BufferedImage image; 21 | 22 | public Picture (Path path) 23 | { 24 | try {image = ImageIO.read (path.toFile ());} 25 | catch (IOException e) {} 26 | } 27 | 28 | public Dimension getPreferredSize () 29 | { 30 | if (image == null) return new Dimension (100, 100); 31 | return new Dimension (image.getWidth (), image.getHeight ()); 32 | } 33 | 34 | public void paintComponent (Graphics g) 35 | { 36 | super.paintComponent (g); 37 | if (image == null) return; 38 | int w = image.getWidth (); 39 | int h = image.getHeight (); 40 | g.drawImage (image, 0, 0, w, h, this); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/ActivityReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref; 8 | 9 | import java.awt.Component; 10 | 11 | import gov.sandia.n2a.plugins.extpoints.Activity; 12 | import gov.sandia.n2a.ui.images.ImageUtil; 13 | 14 | import javax.swing.ImageIcon; 15 | 16 | public class ActivityReference implements Activity 17 | { 18 | @Override 19 | public ImageIcon getIcon () 20 | { 21 | return ImageUtil.getImage ("book.gif"); 22 | } 23 | 24 | @Override 25 | public String getName () 26 | { 27 | return "References"; 28 | } 29 | 30 | @Override 31 | public Component getPanel () 32 | { 33 | return new PanelReference (); 34 | } 35 | 36 | @Override 37 | public Component getInitialFocus (Component panel) 38 | { 39 | return ((PanelReference) panel).panelSearch.textQuery; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/ExportBibTeX.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref; 8 | 9 | import java.io.IOException; 10 | import java.io.Writer; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | 14 | import gov.sandia.n2a.db.MNode; 15 | 16 | public class ExportBibTeX extends ExportBibliography 17 | { 18 | @Override 19 | public String getName () 20 | { 21 | return "BibTeX"; 22 | } 23 | 24 | @Override 25 | public void process (MNode references, Writer writer) throws IOException 26 | { 27 | String nl = String.format ("%n"); 28 | 29 | for (MNode r : references) 30 | { 31 | writer.write ("@" + r.get ("form") + "{" + r.key () + "," + nl); 32 | for (MNode c : r) writer.write (" " + c.key () + "={" + c.get ().replace ("\n", nl) + "}," + nl); 33 | writer.write ("}" + nl); 34 | } 35 | } 36 | 37 | @Override 38 | public boolean accept (Path source) 39 | { 40 | if (Files.isDirectory (source)) return true; 41 | String name = source.getFileName ().toString (); 42 | int lastDot = name.lastIndexOf ('.'); 43 | if (lastDot >= 0) 44 | { 45 | String suffix = name.substring (lastDot); 46 | if (suffix.equalsIgnoreCase (".bib")) return true; 47 | if (suffix.equalsIgnoreCase (".bibtex")) return true; 48 | } 49 | return false; 50 | } 51 | 52 | @Override 53 | public String suffix () 54 | { 55 | return ".bib"; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/ImportBibliography.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | 14 | import gov.sandia.n2a.db.MDir; 15 | import gov.sandia.n2a.db.MNode; 16 | import gov.sandia.n2a.db.MVolatile; 17 | import gov.sandia.n2a.plugins.extpoints.Import; 18 | import gov.sandia.n2a.ui.MainFrame; 19 | import gov.sandia.n2a.ui.ref.undo.AddEntry; 20 | 21 | public abstract class ImportBibliography implements Import 22 | { 23 | @Override 24 | public void process (Path path, String name) 25 | { 26 | try (BufferedReader reader = Files.newBufferedReader (path)) 27 | { 28 | MNode data = new MVolatile (); 29 | parse (reader, data); 30 | 31 | for (MNode n : data) // data can contain several entries 32 | { 33 | String key = MDir.validFilenameFrom (n.key ()); 34 | MainFrame.undoManager.apply (new AddEntry (key, n)); 35 | } 36 | } 37 | catch (IOException e) 38 | { 39 | } 40 | } 41 | 42 | @Override 43 | public float matches (Path source) 44 | { 45 | if (accept (source) && ! Files.isDirectory (source)) return 1; 46 | 47 | try (BufferedReader reader = Files.newBufferedReader (source)) 48 | { 49 | return matches (reader); 50 | } 51 | catch (IOException e) {} 52 | return 0; 53 | } 54 | 55 | public abstract float matches (BufferedReader reader) throws IOException; 56 | public abstract void parse (BufferedReader input, MNode output) throws IOException; 57 | } 58 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/undo/AddTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref.undo; 8 | 9 | import javax.swing.undo.UndoableEdit; 10 | 11 | import gov.sandia.n2a.db.MNode; 12 | import gov.sandia.n2a.ui.Undoable; 13 | import gov.sandia.n2a.ui.ref.PanelReference; 14 | 15 | public class AddTag extends Undoable 16 | { 17 | protected String key; 18 | protected int row; 19 | protected String name; 20 | protected String value; 21 | protected boolean nameIsGenerated; 22 | 23 | public AddTag (MNode doc, int row) 24 | { 25 | key = doc.key (); 26 | this.row = row; 27 | value = ""; 28 | nameIsGenerated = true; 29 | 30 | int suffix = 0; 31 | while (true) 32 | { 33 | name = "k" + suffix++; 34 | if (doc.child (name) == null) break; 35 | } 36 | } 37 | 38 | public AddTag (MNode doc, int row, String name, String value) 39 | { 40 | key = doc.key (); 41 | this.row = row; 42 | this.name = name; 43 | this.value = value; 44 | nameIsGenerated = false; 45 | } 46 | 47 | public void undo () 48 | { 49 | super.undo (); 50 | PanelReference.instance.panelEntry.model.destroy (key, name); 51 | } 52 | 53 | public void redo () 54 | { 55 | super.redo (); 56 | PanelReference.instance.panelEntry.model.create (key, row, name, value, nameIsGenerated); 57 | } 58 | 59 | public boolean addEdit (UndoableEdit edit) 60 | { 61 | if (nameIsGenerated && edit instanceof RenameTag) 62 | { 63 | RenameTag rename = (RenameTag) edit; 64 | if (name.equals (rename.before)) 65 | { 66 | name = rename.after; 67 | nameIsGenerated = false; 68 | return true; 69 | } 70 | } 71 | return false; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/undo/ChangeEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref.undo; 8 | 9 | import gov.sandia.n2a.db.AppData; 10 | import gov.sandia.n2a.db.MNode; 11 | import gov.sandia.n2a.ui.Undoable; 12 | import gov.sandia.n2a.ui.ref.PanelReference; 13 | 14 | public class ChangeEntry extends Undoable 15 | { 16 | protected String before; 17 | protected String after; 18 | 19 | public ChangeEntry (String before, String after) 20 | { 21 | this.before = before; 22 | this.after = after; 23 | } 24 | 25 | public void undo () 26 | { 27 | super.undo (); 28 | rename (after, before); 29 | } 30 | 31 | public void redo () 32 | { 33 | super.redo (); 34 | rename (before, after); 35 | } 36 | 37 | public boolean anihilate () 38 | { 39 | return before.equals (after); 40 | } 41 | 42 | public static void rename (String A, String B) 43 | { 44 | MNode references = AppData.docs.child ("references"); 45 | references.move (A, B); 46 | PanelReference pr = PanelReference.instance; 47 | MNode doc = references.child (B); 48 | pr.panelEntry.model.setRecord (doc); // lazy; only loads if not already loaded 49 | pr.panelEntry.model.fireTableRowsUpdated (0, 0); // If we didn't rebuild in previous line, then we need to update display with changed data. 50 | pr.panelEntry.table.requestFocusInWindow (); // likewise, focus only moves if it is not already on equation tree 51 | pr.panelEntry.table.changeSelection (0, 1, false, false); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/undo/ChangeTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref.undo; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.ui.Undoable; 11 | import gov.sandia.n2a.ui.ref.PanelReference; 12 | 13 | public class ChangeTag extends Undoable 14 | { 15 | protected String key; // of document containing the tag 16 | protected String name; 17 | protected String before; 18 | protected String after; 19 | 20 | /** 21 | @param container The direct container of the node being changed. 22 | **/ 23 | public ChangeTag (MNode doc, String name, String value) 24 | { 25 | key = doc.key (); 26 | this.name = name; 27 | before = doc.get (name); 28 | after = value; 29 | } 30 | 31 | public void undo () 32 | { 33 | super.undo (); 34 | PanelReference.instance.panelEntry.model.changeValue (key, name, before); 35 | } 36 | 37 | public void redo () 38 | { 39 | super.redo (); 40 | PanelReference.instance.panelEntry.model.changeValue (key, name, after); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/undo/DeleteTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref.undo; 8 | 9 | import javax.swing.undo.UndoableEdit; 10 | 11 | import gov.sandia.n2a.db.MNode; 12 | import gov.sandia.n2a.ui.Undoable; 13 | import gov.sandia.n2a.ui.ref.PanelEntry.MNodeTableModel; 14 | import gov.sandia.n2a.ui.ref.PanelReference; 15 | 16 | public class DeleteTag extends Undoable 17 | { 18 | protected String key; 19 | protected int row; 20 | protected String name; 21 | protected String value; 22 | protected boolean neutralized; 23 | 24 | public DeleteTag (MNode doc, String name) 25 | { 26 | key = doc.key (); 27 | this.name = name; 28 | MNodeTableModel model = PanelReference.instance.panelEntry.model; 29 | row = model.keys.indexOf (name); 30 | value = doc.get (name); 31 | } 32 | 33 | public void undo () 34 | { 35 | super.undo (); 36 | PanelReference.instance.panelEntry.model.create (key, row, name, value, false); 37 | } 38 | 39 | public void redo () 40 | { 41 | super.redo (); 42 | PanelReference.instance.panelEntry.model.destroy (key, name); 43 | } 44 | 45 | public boolean replaceEdit (UndoableEdit edit) 46 | { 47 | if (edit instanceof AddTag) 48 | { 49 | AddTag at = (AddTag) edit; 50 | if (key == at.key && name.equals (at.name)) 51 | { 52 | neutralized = true; 53 | return true; 54 | } 55 | } 56 | return false; 57 | } 58 | 59 | public boolean anihilate () 60 | { 61 | return neutralized; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/ref/undo/RenameTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.ref.undo; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.ui.Undoable; 11 | import gov.sandia.n2a.ui.ref.PanelReference; 12 | 13 | public class RenameTag extends Undoable 14 | { 15 | protected String key; 16 | protected int exposedRow; 17 | protected String before; 18 | protected String after; 19 | 20 | public RenameTag (MNode doc, int exposedRow, String before, String after) 21 | { 22 | key = doc.key (); 23 | this.exposedRow = exposedRow; 24 | this.before = before; 25 | this.after = after; 26 | } 27 | 28 | public void undo () 29 | { 30 | super.undo (); 31 | PanelReference.instance.panelEntry.model.rename (key, exposedRow, after, before); 32 | } 33 | 34 | public void redo () 35 | { 36 | super.redo (); 37 | PanelReference.instance.panelEntry.model.rename (key, exposedRow, before, after); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/ActivitySettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.settings; 8 | 9 | import java.awt.Component; 10 | 11 | import gov.sandia.n2a.plugins.extpoints.Activity; 12 | import gov.sandia.n2a.ui.images.ImageUtil; 13 | 14 | import javax.swing.ImageIcon; 15 | 16 | public class ActivitySettings implements Activity 17 | { 18 | @Override 19 | public ImageIcon getIcon () 20 | { 21 | return ImageUtil.getImage ("settings.png"); 22 | } 23 | 24 | @Override 25 | public String getName () 26 | { 27 | return "Settings"; 28 | } 29 | 30 | @Override 31 | public Component getPanel () 32 | { 33 | return new PanelSettings (); 34 | } 35 | 36 | @Override 37 | public Component getInitialFocus (Component panel) 38 | { 39 | return ((PanelSettings) panel).getComponentAt (0); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 2 | 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of NTESS nor the names of its contributors may be used 17 | to endorse or promote products derived from this software without specific 18 | prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/eclipse: -------------------------------------------------------------------------------- 1 | 2 | 3 | This application uses icons from the Eclipse project. See the Eclipse Public License 2.0 for the conditions under which they are used. 4 | 5 | 6 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/indriya: -------------------------------------------------------------------------------- 1 | Units of Measurement Reference Implementation 2 | Copyright (c) 2005-2018, Jean-Marie Dautelle, Werner Keil, Otavio Santana. 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 13 | and the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of JSR-385, Indriya nor the names of their contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/jgit: -------------------------------------------------------------------------------- 1 | This program and the accompanying materials are made available 2 | under the terms of the Eclipse Distribution License v1.0 which 3 | accompanies this distribution, is reproduced below, and is 4 | available at http://www.eclipse.org/org/documents/edl-v10.php 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or 9 | without modification, are permitted provided that the following 10 | conditions are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above 16 | copyright notice, this list of conditions and the following 17 | disclaimer in the documentation and/or other materials provided 18 | with the distribution. 19 | 20 | - Neither the name of the Eclipse Foundation, Inc. nor the 21 | names of its contributors may be used to endorse or promote 22 | products derived from this software without specific prior 23 | written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 26 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 27 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 30 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 32 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 33 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 35 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 37 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/miniz: -------------------------------------------------------------------------------- 1 | Copyright 2013-2014 RAD Game Tools and Valve Software 2 | Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC 3 | 4 | All Rights Reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/opengl: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2018 The Khronos Group Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and/or associated documentation files (the 5 | "Materials"), to deal in the Materials without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Materials, and to 8 | permit persons to whom the Materials are furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Materials. 13 | 14 | THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 21 | 22 | 23 | For generated API headers: 24 | 25 | Copyright 2013-2023 The Khronos Group Inc. 26 | SPDX-License-Identifier: MIT 27 | 28 | This header is generated from the Khronos OpenGL / OpenGL ES XML 29 | API Registry. The current version of the Registry, generator scripts 30 | used to make the header, and the header can be found at 31 | https://github.com/KhronosGroup/OpenGL-Registry 32 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/pugixml: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2006-2022 Arseny Kapoulkine 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/si-units: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2017, Jean-Marie Dautelle, Werner Keil and others. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 12 | and the following disclaimer in the documentation and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of JSR-363, Units of Measurement nor the names of their contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/slf4j: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2017 QOS.ch 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/unit-api: -------------------------------------------------------------------------------- 1 | Units of Measurement API 2 | Copyright (c) 2014-2020, Jean-Marie Dautelle, Werner Keil, Otavio Santana. 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 13 | and the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/uom-lib: -------------------------------------------------------------------------------- 1 | Unit-API - Units of Measurement API for Java 2 | Copyright (c) 2005-2016, Jean-Marie Dautelle, Werner Keil, V2COM. 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 11 | 12 | 3. Neither the name of JSR-363, Unit-API nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 21 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/settings/licenses/uom-systems: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2017, Units of Measurement 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of uom-systems nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/studies/ActivityStudy.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.studies; 8 | 9 | import java.awt.Component; 10 | 11 | import gov.sandia.n2a.plugins.extpoints.Activity; 12 | import gov.sandia.n2a.ui.images.ImageUtil; 13 | 14 | import javax.swing.ImageIcon; 15 | 16 | public class ActivityStudy implements Activity 17 | { 18 | @Override 19 | public ImageIcon getIcon () 20 | { 21 | return ImageUtil.getImage ("study-16.png"); 22 | } 23 | 24 | @Override 25 | public String getName () 26 | { 27 | return "Studies"; 28 | } 29 | 30 | @Override 31 | public Component getPanel () 32 | { 33 | return new PanelStudy (); 34 | } 35 | 36 | @Override 37 | public Component getInitialFocus (Component panel) 38 | { 39 | return ((PanelStudy) panel).list; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/studies/IteratorIndexed.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.studies; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | 11 | /** 12 | An iterator that steps through a discrete set of items. 13 | **/ 14 | public class IteratorIndexed extends StudyIterator 15 | { 16 | protected int index = -1; 17 | protected int count; // Must be set by concrete class constructor. 18 | 19 | public IteratorIndexed (String[] keys) 20 | { 21 | super (keys); 22 | } 23 | 24 | public int count () 25 | { 26 | int result = count; 27 | if (inner != null) result *= inner.count (); 28 | return result; 29 | } 30 | 31 | public void restart () 32 | { 33 | index = 0; 34 | } 35 | 36 | public boolean step () 37 | { 38 | index++; 39 | return index < count; 40 | } 41 | 42 | @Override 43 | public void assign (MNode model) 44 | { 45 | // Do nothing. We simply repeat the run "count" times with an unmodified value. 46 | // If this is set on $meta.seed, then we get Monte-Carlo runs. 47 | // The seed is provided by the backend, which means it is not repeatable 48 | // between studies. To get repeatable MC sampling, specify a random 49 | // generator, eg: $meta.seed.study=uniform(100000) 50 | } 51 | 52 | public void save (MNode study) 53 | { 54 | if (inner != null) inner.save (study); 55 | MNode n = node (study); 56 | n.set (index, "index"); 57 | } 58 | 59 | public void load (MNode study) 60 | { 61 | if (inner != null) inner.load (study); 62 | MNode n = node (study); 63 | index = n.getInt ("index"); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/studies/IteratorList.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.studies; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | import gov.sandia.n2a.db.MNode; 13 | 14 | public class IteratorList extends IteratorIndexed 15 | { 16 | protected List items; 17 | 18 | public IteratorList (String[] keys, String items) 19 | { 20 | super (keys); 21 | this.items = Arrays.asList (items.split (",")); 22 | count = this.items.size (); 23 | } 24 | 25 | public void assign (MNode model) 26 | { 27 | if (inner != null) inner.assign (model); 28 | model.set (items.get (index), keyPath); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/studies/IteratorRandom.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.studies; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.language.Operator; 11 | import gov.sandia.n2a.language.Type; 12 | 13 | public class IteratorRandom extends IteratorIndexed 14 | { 15 | protected Operator expression; 16 | protected Type nextValue; 17 | 18 | public IteratorRandom (String[] keys, String value, MNode n) 19 | { 20 | super (keys); 21 | count = n.getOrDefault (1, "count"); 22 | 23 | try 24 | { 25 | expression = Operator.parse (value); 26 | } 27 | catch (Exception e) 28 | { 29 | // TODO: some form of error reporting for Study. 30 | } 31 | } 32 | 33 | public boolean step () 34 | { 35 | index++; 36 | nextValue = expression.eval (null); 37 | return index < count; 38 | } 39 | 40 | public void assign (MNode model) 41 | { 42 | if (inner != null) inner.assign (model); 43 | model.set (nextValue, keyPath); 44 | } 45 | 46 | public boolean usesRandom () 47 | { 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /N2A/src/gov/sandia/n2a/ui/studies/IteratorRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 3 | Under the terms of Contract DE-NA0003525 with NTESS, 4 | the U.S. Government retains certain rights in this software. 5 | */ 6 | 7 | package gov.sandia.n2a.ui.studies; 8 | 9 | import gov.sandia.n2a.db.MNode; 10 | import gov.sandia.n2a.language.UnitValue; 11 | import gov.sandia.n2a.language.type.Scalar; 12 | 13 | public class IteratorRange extends IteratorIndexed 14 | { 15 | protected double lo; 16 | protected double hi; 17 | protected double step = 1; 18 | protected String rangeUnits = ""; 19 | 20 | public IteratorRange (String[] keys, String range) 21 | { 22 | super (keys); 23 | 24 | String[] pieces = range.split ("]", 2); 25 | if (pieces.length == 2) rangeUnits = pieces[1]; 26 | range = pieces[0]; 27 | 28 | pieces = range.split (","); 29 | hi = new UnitValue (pieces[0]).get (); 30 | if (pieces.length > 1) 31 | { 32 | lo = hi; 33 | hi = new UnitValue (pieces[1]).get (); 34 | } 35 | if (pieces.length > 2) 36 | { 37 | step = new UnitValue (pieces[2]).get (); 38 | } 39 | 40 | count = (int) Math.floor ((hi - lo) / step) + 1; // basic formula 41 | // Compensate for finite precision 42 | double epsilon = 1e-6; 43 | double beyond = lo + step * count; // This should be one full step past hi, but if hi falls slightly short of a step quantum, this could be slightly greater than hi. It will never be less than hi. 44 | if ((beyond - hi) / step < epsilon) count++; 45 | } 46 | 47 | public void assign (MNode model) 48 | { 49 | if (inner != null) inner.assign (model); 50 | model.set (Scalar.print (lo + step * index) + rangeUnits, keyPath); 51 | } 52 | } 53 | --------------------------------------------------------------------------------