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.0037328214804597352
 0.014093111405860805
 0.026512586001527456
 0.040464952146428486
 0.056103281076902864
 0.07327894048333246
 0.09234258204443475
 0.11444569024719832

 4.793074831671211
 4.822031288572679
 4.851919859218505
 4.878111686134263
 4.906215847950551
 4.940379097494987
 4.966205473489703
 4.994457383038944
 5.0
u: 182-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [5.235985172127158e-12, 1.570795034867126e-7]
 [2.7215207551817354e-7, 0.00021862335257837913]
 [1.451314800158733e-5, 0.0030692170125191775]
 [9.424928373112056e-5, 0.01041764535823106]
 [0.00031994730188876123, 0.02243790095580514]
 [0.000791179255791052, 0.037896940261363754]
 [0.0015784209748530872, 0.05308962364297026]
 [0.0026979574971376834, 0.06274535850132273]
 [0.004087119419703027, 0.06043995336818915]

 [0.1527863092359896, 0.0007501945149313175]
 [0.15284270097957184, 0.0073245471747322]
 [0.1534293241992473, 0.03374944208292945]
 [0.15463130036994885, 0.05642798344729313]
 [0.15636558550310756, 0.06305677773038762]
 [0.15822371101706065, 0.04130597008914553]
 [0.1589632173641125, 0.016316461669252644]
 [0.15915331681724668, 0.00048123324855785146]
 [0.15915420641941797, -1.0682038222130216e-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.003732822.72152e-70.000218623
40.01409311.45131e-50.00306922
50.02651269.42493e-50.0104176
60.0404650.0003199470.0224379
70.05610330.0007911790.0378969
80.07327890.001578420.0530896
90.09234260.002697960.0627454
100.1144460.004087120.06044
110.1394930.00539870.0421486
120.1614340.006087150.0206412
130.1852550.006349590.00335472
140.2100640.006371510.00157774
150.2423710.006730650.0242745
160.2657380.007566810.0469351
170.292790.009092230.0628487
180.3203430.01080120.0573799
190.3498210.01214830.0320102
200.3752660.01265550.00913588
210.40260.01273250.000106102
220.4338850.01292490.0163957
230.4602570.01368940.0419117
240.4873630.01512150.0611863
250.515420.01687820.0599994
260.547960.01845320.0338692
270.5734210.01900360.0104665
280.6016580.01909864.31647e-5
290.6327470.0192730.0154106
300.6598410.02003820.0415157
310.6870150.02146640.0610499
320.7153450.02323990.0600341
330.7481590.02482610.0336709
340.773730.0253730.0102389
350.8021160.02546487.03297e-5
360.8334840.02565070.0160465
370.860530.02643320.0421703
380.8878410.02788310.0613676
390.9163060.02966350.0595761
400.9486410.03120840.0331899
410.9743440.03174540.00979165
421.002660.03183110.000111408
431.034330.03203080.0167843
441.06120.03282770.0427971
451.088610.03429690.0616474
461.117150.03607980.0591531
471.149060.03758850.0327689
481.174850.03811650.0094268
491.20310.03819730.000151029
501.2350.03840850.0173834
511.261720.03921640.043286
521.289220.04070050.0618539
531.31780.04248460.058811
541.349410.0439660.0324221
551.375260.04448650.00913812
561.403460.04456360.000187896
571.435560.04478460.0178846
581.462150.04560160.0436925
591.489730.04709810.0620187
601.518360.04888330.0585128
611.549720.05034220.0321122
621.575620.05085590.00888629
631.603780.05092980.00022475
641.636080.05116010.0183493
651.662560.05198570.0440698
661.69020.05349390.0621661
671.718880.05528020.0582232
681.750030.05671820.0318055
691.775980.05722520.0086415
701.804110.05729610.000265085
711.83660.05753610.0188271
721.862980.05837050.0444568
731.89070.05989070.0623116
741.919430.06167820.0579129
751.950360.0630950.0314726
761.976360.06359470.00838043
772.004470.06366240.000313219
782.037190.06391350.0193644
792.063460.06475780.0448902
802.091250.06629160.0624673
812.120060.06808040.0575496
822.150750.06947350.0310783
832.176810.06996460.00807743
842.20490.07002870.000376097
852.23790.07029370.0200242
862.264040.07115030.0454186
872.291940.07270070.0626464
882.320830.07449120.0570836
892.351260.07585540.0305691
902.377390.07633530.00769506
912.405460.07639520.000466816
922.438860.07667940.0209129
932.464820.07755230.0461228
942.492870.07912510.0628658
952.52190.08091780.0564217
962.551990.08224350.0298438
972.578220.08270760.00716664
982.606270.08276180.000614907
992.640270.0830760.0222494
1002.6660.08397330.0471633
1012.694270.08557960.0631469
1022.723530.08737530.0553526
1032.753160.08864390.0286762
1042.779540.08908270.00635315
1052.807590.08912890.000901383
1062.842640.08949760.024533
1072.8680.09043590.0488905
1082.896670.0920980.0634878
1092.926420.09389820.0533147
1102.955360.09507060.0265004
1112.9820.09546280.00495259
1123.010140.09549820.00160192
1133.046360.09596180.0281941
1143.071320.09696870.0515919
1153.100530.09870960.0636572
1163.131350.1005180.0494332
1173.159310.1015340.0226563
1183.186460.1018460.0028361
1193.214910.1018760.00342609
1203.248120.1023790.0299485
1213.273630.1034560.0533498
1223.302260.1051860.0635811
1233.333910.1070080.0472421
1243.361120.107940.0209323
1253.388530.1082170.00204528
1263.417030.1082510.00444686
1273.448930.108770.0307613
1283.474660.1098780.0540975
1293.503010.11160.0635192
1303.535050.1134270.0462333
1313.561920.1143220.0201833
1323.589440.1145850.00173646
1333.617970.1146210.00493623
1343.649380.115150.0312088
1353.675190.1162720.0544695
1363.703440.1179930.063476
1373.735710.1198240.0456412
1383.762420.1206980.0197267
1393.790.1209520.00155727
1403.818570.120990.00526354
1413.84970.1215260.0315335
1423.875560.1226590.0547339
1433.903770.124380.0634384
1443.936240.1262140.0451647
1453.962830.1270720.0193485
1463.990480.1273190.00141391
1474.019090.1273590.00555386
1484.050.1279020.0318343
1494.075910.1290440.0549756
1504.104090.1307670.063399
1514.136760.1326030.0446935
1524.163240.1334460.0189715
1534.190960.1336860.00127618
1544.219620.1337280.00585812
1554.250330.1342780.0321573
1564.276290.1354310.0552308
1574.304440.1371550.0633522
1584.337330.1389950.0441658
1594.36370.1398210.0185499
1604.39150.1400530.00112895
1614.420230.1400980.00621411
1624.450710.1406570.0325404
1634.476730.1418220.0555278
1644.504860.1435480.063291
1654.538040.1453920.0435159
1664.564270.1461980.0180341
1674.592170.1464190.000959044
1684.620990.1464690.00667202
1694.651210.1470390.0330374
1704.67730.148220.0559044
1714.705410.1499490.0632023
1724.738970.1517990.0426368
1734.765040.1525770.0173437
1744.793070.1527860.000750195
1754.822030.1528430.00732455
1764.851920.1534290.0337494
1774.878110.1546310.056428
1784.906220.1563660.0630568
1794.940380.1582240.041306
1804.966210.1589630.0163165
1814.994460.1591530.000481233
1825.00.159154-1.0682e-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.