Skip to content
MANUAL

Analyses

Download as a Dyad projecttransient_man.zipOpen in Dyad Studio

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 DyadExampleComponents.SecondOrderSystemTest
with 2 differential equations and 0 algebraic equations

retcode: Success
Interpolation: 3rd order Hermite
t: 182-element Vector{Float64}: [0.0, 9.999999999999999e-5 … 4.994457388635665, 5.0]
u: 182-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [1.5708e-7, 5.23599e-12]
 [0.000218625, 2.72156e-7]
 [0.00306923, 1.45132e-5]
 [0.0104177, 9.42496e-5]
 [0.0224379, 0.000319948]
 [0.037897, 0.000791181]
 [0.0530897, 0.00157842]
 [0.0627454, 0.00269796]
 [0.0604399, 0.00408712]

 [0.000750196, 0.152786]
 [0.00732454, 0.152843]
 [0.0337494, 0.153429]
 [0.056428, 0.154631]
 [0.0630568, 0.156366]
 [0.041306, 0.158224]
 [0.0163165, 0.158963]
 [0.000481232, 0.159153]
 [-1.06822e-7, 0.159154]

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 below 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₊y(t)sys₊integrator2₊y(t)
Float64Float64Float64
10.00.00.0
20.00011.5708e-75.23599e-12
30.003732840.0002186252.72156e-7
40.01409310.003069231.45132e-5
50.02651260.01041779.42496e-5
60.0404650.02243790.000319948
70.05610330.0378970.000791181
80.0732790.05308970.00157842
90.09234260.06274540.00269796
100.1144460.06043990.00408712
110.1394930.04214860.0053987
120.1614340.02064120.00608715
130.1852550.00335470.00634959
140.2100640.001577750.00637151
150.2423710.02427460.00673065
160.2657380.04693510.00756681
170.292790.06284870.00909223
180.3203430.05737990.0108012
190.3498210.03201020.0121483
200.3752660.009135860.0126555
210.40260.0001061040.0127325
220.4338850.01639570.0129249
230.4602570.04191170.0136894
240.4873630.06118630.0151215
250.515420.05999930.0168782
260.547960.03386910.0184532
270.5734210.01046650.0190036
280.6016584.31658e-50.0190986
290.6327470.01541060.019273
300.6598410.04151570.0200382
310.6870150.06104990.0214664
320.7153450.06003410.0232399
330.7481590.03367090.0248261
340.773730.01023890.025373
350.8021167.03303e-50.0254648
360.8334840.01604650.0256507
370.860530.04217030.0264332
380.8878410.06136760.0278831
390.9163060.05957610.0296635
400.9486410.03318990.0312084
410.9743440.009791640.0317454
421.002660.0001114090.0318311
431.034330.01678430.0320308
441.06120.04279710.0328277
451.088610.06164740.0342969
461.117150.05915310.0360798
471.149060.03276890.0375885
481.174850.00942680.0381165
491.20310.0001510290.0381973
501.2350.01738340.0384085
511.261720.0432860.0392164
521.289220.06185390.0407005
531.31780.0588110.0424846
541.349410.03242210.043966
551.375260.009138120.0444865
561.403460.0001878960.0445636
571.435560.01788460.0447846
581.462150.04369250.0456016
591.489730.06201870.0470981
601.518360.05851280.0488834
611.549720.03211220.0503422
621.575620.008886290.0508559
631.603780.000224750.0509298
641.636080.01834930.0511601
651.662560.04406980.0519857
661.69020.06216610.0534939
671.718880.05822330.0552802
681.750030.03180550.0567182
691.775980.008641510.0572252
701.804110.0002650840.0572961
711.83660.01882710.0575361
721.862980.04445680.0583705
731.89070.06231160.0598907
741.919430.05791290.0616782
751.950360.03147260.063095
761.976360.008380440.0635947
772.004470.0003132170.0636624
782.037190.01936440.0639135
792.063460.04489020.0647578
802.091250.06246730.0662916
812.120060.05754970.0680804
822.150750.03107830.0694735
832.176810.008077440.0699646
842.20490.0003760950.0700287
852.23790.02002420.0702937
862.264040.04541860.0711503
872.291940.06264640.0727007
882.320830.05708360.0744912
892.351260.03056910.0758554
902.377390.007695070.0763353
912.405460.0004668140.0763952
922.438860.02091290.0766794
932.464820.04612270.0775523
942.492870.06286580.0791251
952.52190.05642170.0809178
962.551990.02984380.0822435
972.578220.007166660.0827076
982.606270.0006149020.0827618
992.640270.02224930.083076
1002.6660.04716330.0839733
1012.694270.06314690.0855796
1022.723530.05535260.0873753
1032.753160.02867630.0886439
1042.779540.006353180.0890827
1052.807590.0009013730.0891289
1062.842640.02453290.0894976
1072.8680.04889040.0904359
1082.896670.06348770.092098
1092.926420.05331480.0938982
1102.955360.02650050.0950706
1112.9820.004952630.0954628
1123.010140.00160190.0954982
1133.046360.02819410.0959618
1143.071320.05159190.0969687
1153.100530.06365720.0987096
1163.131350.04943330.100518
1173.159310.02265640.101534
1183.186460.002836140.101846
1193.214910.003426060.101876
1203.248120.02994850.102379
1213.273630.05334980.103456
1223.302260.06358110.105186
1233.333910.04724220.107008
1243.361120.02093240.10794
1253.388530.00204530.108217
1263.417030.004446840.108251
1273.448930.03076130.10877
1283.474660.05409750.109878
1293.503010.06351920.1116
1303.535050.04623340.113427
1313.561920.02018340.114322
1323.589440.001736460.114585
1333.617970.004936230.114621
1343.649380.03120880.11515
1353.675190.05446950.116272
1363.703440.0634760.117993
1373.735710.04564120.119824
1383.762420.01972670.120698
1393.790.001557280.120952
1403.818570.005263530.12099
1413.84970.03153350.121526
1423.875560.05473390.122659
1433.903770.06343840.12438
1443.936240.04516480.126214
1453.962830.01934850.127072
1463.990480.001413910.127319
1474.019090.005553860.127359
1484.050.03183430.127902
1494.075910.05497560.129044
1504.104090.0633990.130767
1514.136760.04469350.132603
1524.163240.01897150.133446
1534.190960.001276180.133686
1544.219620.005858120.133728
1554.250330.03215730.134278
1564.276290.05523080.135431
1574.304440.06335220.137155
1584.337330.04416580.138995
1594.36370.01854990.139821
1604.39150.001128950.140053
1614.420230.00621410.140098
1624.450710.03254040.140657
1634.476730.05552780.141822
1644.504860.0632910.143548
1654.538040.04351590.145392
1664.564270.01803410.146198
1674.592170.0009590450.146419
1684.620990.006672020.146469
1694.651210.03303740.147039
1704.67730.05590440.14822
1714.705410.06320230.149949
1724.738970.04263680.151799
1734.765040.01734370.152577
1744.793070.0007501960.152786
1754.822030.007324540.152843
1764.851920.03374940.153429
1774.878110.0564280.154631
1784.906220.06305680.156366
1794.940380.0413060.158224
1804.966210.01631650.158963
1814.994460.0004812320.159153
1825.0-1.06822e-70.159154

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.