Skip to content

Analyses

In Dyad, an analysis is "the things you can do with a model". A typical workflow in Dyad is to create a set of components, and then create an analysis that runs on the entry point to that set of components. It produces a solution object that provides information about the model, and can be used to build various visualizations.

Analyses can perform a wide variety of model analytics, such as:

and much more. All analyses have a common interface which take in the model, run an analysis, and give back a pre-defined set of artifacts, such as plots of the solution or generated binaries.

Using an Analysis (Dyad Studio)

Dyad Studio includes a lower level interface to define and interact with analyses at the Julia level, with more flexibility than what is exposed in the GUI.

Example: TransientAnalysis of a Simple Block

Using the Dyad-Level Analysis Interface (Dyad Studio)

A TransientAnalysis for the SecondOrderSystemTest component is written in Dyad as:

dyad
analysis SecondOrderSystemTransient
  extends TransientAnalysis(stop=5)
  model = DyadExampleComponents.SecondOrderSystemTest()
end

The Dyad compiler will generate the SecondOrderSystemTransient function that will run the analysis.

julia
result = SecondOrderSystemTransient()
Transient Analysis Solution for TransientAnalysis
retcode: Success
Interpolation: 3rd order Hermite
t: 182-element Vector{Float64}:
 0.0
 9.999999999999999e-5
 0.0010999999999999998
 0.008324114235506148
 0.020246779930185234
 0.03253967894598337
 0.047320529812637624
 0.06324562634002115
 0.08110198582213118
 0.10099103713853302

 4.776797022759093
 4.804900620409804
 4.83799448361324
 4.864115348471153
 4.892044049104142
 4.920967923448576
 4.951383245743508
 4.977527261899837
 5.0
u: 182-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [5.235985172127158e-12, 1.570795034867126e-7]
 [6.96868358226933e-9, 1.9004744117386418e-5]
 [3.0097302167917294e-6, 0.001082229838963192]
 [4.2586980271460544e-5, 0.006225003772697508]
 [0.00017120580283004052, 0.015233187179644574]
 [0.0004966351536118307, 0.029154681007367428]
 [0.001086423955575106, 0.044697643775799545]
 [0.0020147352711609875, 0.05821496992128405]
 [0.003246186171341479, 0.06364655339936032]

 [0.15272489320982, 0.008089192380912012]
 [0.15278920304907562, 0.00037674211351357365]
 [0.1530559990679548, 0.020108237903993548]
 [0.15391424244864715, 0.04548838153343388]
 [0.15546784489516705, 0.06267301888539197]
 [0.1572593431510165, 0.05700223440147551]
 [0.15861955285769966, 0.030448410416964455]
 [0.15909685828945228, 0.0076090530191528305]
 [0.159154823505216, 2.2880449245464218e-7]

We can plot this result, using either Plots.jl or Makie.jl. We'll use Plots here:

julia
using Plots
plot(result)

See the plotting guide for more details on how to plot the results of an analysis.

We can also get artifacts from this result, like:

julia
using DyadInterface: artifacts
artifacts(result, :SimulationSolutionTable)
182×3 DataFrame
Rowtimestampsys₊integrator2₊x(t)sys₊integrator1₊x(t)
Float64Float64Float64
10.00.00.0
20.00015.23599e-121.5708e-7
30.00116.96868e-91.90047e-5
40.008324113.00973e-60.00108223
50.02024684.2587e-50.006225
60.03253970.0001712060.0152332
70.04732050.0004966350.0291547
80.06324560.001086420.0446976
90.0811020.002014740.058215
100.1009910.003246190.0636466
110.1257760.004737260.0537838
120.1480360.005723410.033794
130.1711570.006245620.0121974
140.1947590.006365440.000430447
150.2215040.006417090.0069915
160.2482560.006890530.0300875
170.2729230.007925760.0528233
180.2989670.009483520.0636452
190.3283410.0112390.051857
200.3551640.01230510.0266893
210.3812880.01269870.00534364
220.4083780.01273550.00109621
230.4432460.01311850.0251278
240.4679920.0140410.0488802
250.4964270.01568830.0634616
260.5257470.01746810.0538047
270.5546040.01865620.0272431
280.5810370.01906350.00548326
290.6089760.01910240.0012572
300.6445220.01951750.0263794
310.6695850.02048620.0502036
320.6984610.02218370.0636246
330.7285740.02398340.0516748
340.7570090.02508510.0248781
350.7838410.02544290.00401422
360.8120470.02547380.00225245
370.8470860.02595460.0289212
380.8722240.02698760.0522924
390.9012060.02872460.0636389
400.9322760.03053540.048653
410.9599430.03152010.0220487
420.9871710.03181990.00255035
431.015610.03185060.00375262
441.048260.03235550.0300946
451.073860.03344050.0535211
461.102360.0351640.0635745
471.134020.0369850.0471496
481.161150.03791210.020908
491.188540.03818920.00203965
501.217010.03822250.00443638
511.248850.03873940.0306795
521.274570.03984480.0540348
531.302890.04156420.0635303
541.334820.04338880.0464402
551.361720.04429010.0203718
561.389190.04455670.00181725
571.417680.04459170.00478456
581.449180.04511560.0310062
591.474960.04623170.0543071
601.503210.04795040.0635002
611.53530.04977710.0460111
621.562080.05066350.0200366
631.58960.05092350.00168247
641.618120.050960.0050191
651.649410.05148910.031241
661.675230.05261270.0545004
671.703450.05433170.0634752
681.735680.05616040.0456754
691.762370.05703540.0197683
701.789940.05729020.00157691
711.818480.0573280.00521703
721.849620.05786170.0314464
731.875470.0589920.0546679
741.903660.06071160.063451
751.936020.06254220.0453661
761.962640.06340690.0195186
771.990250.06365690.00148093
782.018830.0636960.00540815
792.049820.06423420.0316484
802.07570.0653710.0548311
812.103880.06709150.0634255
822.136370.0689240.045052
832.162920.06977840.0192648
842.190570.07002350.00138576
852.219180.07006420.00560837
862.250030.07060720.0318622
872.275950.07175080.0550018
882.304110.07347230.0633966
892.336740.07530690.0447114
902.363220.07615030.0189903
912.390920.07639010.00128567
922.419570.07643250.00583141
932.450270.0769810.0321028
942.476230.07813230.0551915
952.504370.07985510.0633617
962.537170.08169210.0443193
972.563560.0825230.0186753
982.591330.08275680.00117466
992.620030.08280140.00609542
1002.650560.08335650.0323892
1012.676560.08451670.0554141
1022.704690.08624120.0633172
1032.737680.08808120.043841
1042.763980.08889690.0182933
1052.791820.08912350.0010456
1062.820590.08917110.00642758
1072.850920.08973440.0327513
1082.876970.09090590.055691
1092.905090.09263270.063256
1102.938350.09447650.043219
1112.964530.0952730.0178002
1122.992460.09549030.000888483
1133.021320.09554210.00687591
1143.051410.09611680.0332417
1153.077530.09730340.056058
1163.105640.09903350.0631642
1173.139280.1008820.0423452
1183.16530.1016530.0171155
1193.193370.1018570.000688617
1203.222360.1019160.00753719
1213.252140.1025070.0339662
1223.278360.1037160.0565848
1233.306460.1054510.0630096
1243.340710.1073080.0409901
1253.366490.1080380.0160722
1263.394780.1082240.000427735
1273.424010.1082950.00863717
1283.453340.1089150.0351653
1293.479720.110160.0574179
1303.507840.1119040.0627026
1313.543140.1137710.0386429
1323.568550.1144360.0143172
1333.597230.1145910.000120917
1343.626980.114690.010765
1353.655620.1153640.037425
1363.68230.1166760.0588649
1373.710520.1184380.06194
1383.746710.1202690.0351156
1393.771770.1208440.011717
1403.800910.1209571.32188e-5
1413.831740.1211170.0145605
1423.859450.1218810.0411477
1433.886650.1233030.0609018
1443.915190.1250890.0601065
1453.948390.1266930.0334428
1463.9740.1272350.0100396
1474.002550.1273240.000102644
1484.034220.1275220.0166934
1494.061220.1283210.0428187
1504.088670.1297930.0616663
1514.117280.131580.0590871
1524.149240.1330870.0325923
1534.175060.1336110.00928433
1544.203350.133690.000175924
1554.235450.1339090.0177848
1564.26210.1347260.0436461
1574.289690.1362220.062006
1584.318350.1380090.0585202
1594.349780.1394710.0320532
1604.375680.1399830.00884543
1614.403870.1400560.000235852
1624.436290.1402910.018544
1634.462750.141120.0442421
1644.490440.1426350.062236
1654.519160.1444230.0580675
1664.550240.1458520.0315902
1674.576220.1463540.0084782
1684.604360.1464230.000298212
1694.637080.1466720.0192666
1704.663380.1475150.0448184
1714.691170.1490470.062446
1724.719980.1508370.0575937
1734.750740.1522340.0310876
1744.77680.1527250.00808919
1754.80490.1527890.000376742
1764.837990.1530560.0201082
1774.864120.1539140.0454884
1784.892040.1554680.062673
1794.920970.1572590.0570022
1804.951380.158620.0304484
1814.977530.1590970.00760905
1825.00.1591552.28804e-7

For the artifacts allowed for a given analysis, see the pages which define the given analysis.

Defining and Running an Analysis

Any analysis is available and meant to run in Julia. For an analysis called MyAnalysis in Dyad, the generated Julia code will be created with the following format:

julia
result = MyAnalysis(; kwargs...)

where the kwargs are keyword arguments corresponding to the arguments of the analysis run definition (i.e. the fields that can be set at the Dyad level). This invocation will be set to automatically have the keyword arguments default to the values defined in the Dyad version, for example for a TransientAnalysis if one had set stop = 10.0, then stop = 10.0 will be the default value in the generated function. These defaults can thus be overruled by declaring the keyword argument, for example MyAnalysis(; stop=20.0) will run a version of the analysis which overrides the stop time to 20.0.

Analysis Result Interface

The analysis results can be interacted with in two ways: there are the customizable plot and the artifacts. The most basic usage is to get the artifacts via:

julia
artifacts(result, name::Symbol)

The allowed artifacts can be queried via:

julia
artifacts(results)

which returns a list of all the available artifact names. For more details about all the artifacts,

julia
AnalysisSolutionMetadata(result)

can be used, which also includes descriptions for all the artifacts.

Additionally, some analyses include a customizable visualization:

julia
customizable_visualization(::AbstractAnalysisSolution, ::PlotlyVisualizationSpec)

This will be defined fully in future versions.

Defining Your Own Analysis

At the lowest level, analyses are implemented in Julia, see the Custom analysis tutorial for more details on how to write your own.