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:

  • Simulate the model over a given time span

  • Analyze the stability of a controller

  • Run a parameter sweep

  • Build an FMU

  • Calibrate the model to data

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 the Julia-Level Analysis Interface (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]
 [1.570795034867126e-7, 5.235985172127158e-12]
 [1.9004744117386418e-5, 6.96868358226933e-9]
 [0.001082229838963192, 3.0097302167917294e-6]
 [0.006225003772697508, 4.2586980271460544e-5]
 [0.015233187179644574, 0.00017120580283004052]
 [0.029154681007367428, 0.0004966351536118307]
 [0.044697643775799545, 0.001086423955575106]
 [0.05821496992128405, 0.0020147352711609875]
 [0.06364655339936032, 0.003246186171341479]

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

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₊integrator1₊x(t)sys₊integrator2₊x(t)
Float64Float64Float64
10.00.00.0
20.00011.5708e-75.23599e-12
30.00111.90047e-56.96868e-9
40.008324110.001082233.00973e-6
50.02024680.0062254.2587e-5
60.03253970.01523320.000171206
70.04732050.02915470.000496635
80.06324560.04469760.00108642
90.0811020.0582150.00201474
100.1009910.06364660.00324619
110.1257760.05378380.00473726
120.1480360.0337940.00572341
130.1711570.01219740.00624562
140.1947590.0004304470.00636544
150.2215040.00699150.00641709
160.2482560.03008750.00689053
170.2729230.05282330.00792576
180.2989670.06364520.00948352
190.3283410.0518570.011239
200.3551640.02668930.0123051
210.3812880.005343640.0126987
220.4083780.001096210.0127355
230.4432460.02512780.0131185
240.4679920.04888020.014041
250.4964270.06346160.0156883
260.5257470.05380470.0174681
270.5546040.02724310.0186562
280.5810370.005483260.0190635
290.6089760.00125720.0191024
300.6445220.02637940.0195175
310.6695850.05020360.0204862
320.6984610.06362460.0221837
330.7285740.05167480.0239834
340.7570090.02487810.0250851
350.7838410.004014220.0254429
360.8120470.002252450.0254738
370.8470860.02892120.0259546
380.8722240.05229240.0269876
390.9012060.06363890.0287246
400.9322760.0486530.0305354
410.9599430.02204870.0315201
420.9871710.002550350.0318199
431.015610.003752620.0318506
441.048260.03009460.0323555
451.073860.05352110.0334405
461.102360.06357450.035164
471.134020.04714960.036985
481.161150.0209080.0379121
491.188540.002039650.0381892
501.217010.004436380.0382225
511.248850.03067950.0387394
521.274570.05403480.0398448
531.302890.06353030.0415642
541.334820.04644020.0433888
551.361720.02037180.0442901
561.389190.001817250.0445567
571.417680.004784560.0445917
581.449180.03100620.0451156
591.474960.05430710.0462317
601.503210.06350020.0479504
611.53530.04601110.0497771
621.562080.02003660.0506635
631.58960.001682470.0509235
641.618120.00501910.05096
651.649410.0312410.0514891
661.675230.05450040.0526127
671.703450.06347520.0543317
681.735680.04567540.0561604
691.762370.01976830.0570354
701.789940.001576910.0572902
711.818480.005217030.057328
721.849620.03144640.0578617
731.875470.05466790.058992
741.903660.0634510.0607116
751.936020.04536610.0625422
761.962640.01951860.0634069
771.990250.001480930.0636569
782.018830.005408150.063696
792.049820.03164840.0642342
802.07570.05483110.065371
812.103880.06342550.0670915
822.136370.0450520.068924
832.162920.01926480.0697784
842.190570.001385760.0700235
852.219180.005608370.0700642
862.250030.03186220.0706072
872.275950.05500180.0717508
882.304110.06339660.0734723
892.336740.04471140.0753069
902.363220.01899030.0761503
912.390920.001285670.0763901
922.419570.005831410.0764325
932.450270.03210280.076981
942.476230.05519150.0781323
952.504370.06336170.0798551
962.537170.04431930.0816921
972.563560.01867530.082523
982.591330.001174660.0827568
992.620030.006095420.0828014
1002.650560.03238920.0833565
1012.676560.05541410.0845167
1022.704690.06331720.0862412
1032.737680.0438410.0880812
1042.763980.01829330.0888969
1052.791820.00104560.0891235
1062.820590.006427580.0891711
1072.850920.03275130.0897344
1082.876970.0556910.0909059
1092.905090.0632560.0926327
1102.938350.0432190.0944765
1112.964530.01780020.095273
1122.992460.0008884830.0954903
1133.021320.006875910.0955421
1143.051410.03324170.0961168
1153.077530.0560580.0973034
1163.105640.06316420.0990335
1173.139280.04234520.100882
1183.16530.01711550.101653
1193.193370.0006886170.101857
1203.222360.007537190.101916
1213.252140.03396620.102507
1223.278360.05658480.103716
1233.306460.06300960.105451
1243.340710.04099010.107308
1253.366490.01607220.108038
1263.394780.0004277350.108224
1273.424010.008637170.108295
1283.453340.03516530.108915
1293.479720.05741790.11016
1303.507840.06270260.111904
1313.543140.03864290.113771
1323.568550.01431720.114436
1333.597230.0001209170.114591
1343.626980.0107650.11469
1353.655620.0374250.115364
1363.68230.05886490.116676
1373.710520.061940.118438
1383.746710.03511560.120269
1393.771770.0117170.120844
1403.800911.32188e-50.120957
1413.831740.01456050.121117
1423.859450.04114770.121881
1433.886650.06090180.123303
1443.915190.06010650.125089
1453.948390.03344280.126693
1463.9740.01003960.127235
1474.002550.0001026440.127324
1484.034220.01669340.127522
1494.061220.04281870.128321
1504.088670.06166630.129793
1514.117280.05908710.13158
1524.149240.03259230.133087
1534.175060.009284330.133611
1544.203350.0001759240.13369
1554.235450.01778480.133909
1564.26210.04364610.134726
1574.289690.0620060.136222
1584.318350.05852020.138009
1594.349780.03205320.139471
1604.375680.008845430.139983
1614.403870.0002358520.140056
1624.436290.0185440.140291
1634.462750.04424210.14112
1644.490440.0622360.142635
1654.519160.05806750.144423
1664.550240.03159020.145852
1674.576220.00847820.146354
1684.604360.0002982120.146423
1694.637080.01926660.146672
1704.663380.04481840.147515
1714.691170.0624460.149047
1724.719980.05759370.150837
1734.750740.03108760.152234
1744.77680.008089190.152725
1754.80490.0003767420.152789
1764.837990.02010820.153056
1774.864120.04548840.153914
1784.892040.0626730.155468
1794.920970.05700220.157259
1804.951380.03044840.15862
1814.977530.007609050.159097
1825.02.28804e-70.159155

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.