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:
analysis SecondOrderSystemTransient
extends TransientAnalysis(stop=5)
model = DyadExampleComponents.SecondOrderSystemTest()
end
The Dyad compiler will generate the SecondOrderSystemTransient
function that will run the analysis.
result = SecondOrderSystemTransient()
Transient Analysis Solution for TransientAnalysis
retcode: Success
Interpolation: 3rd order Hermite
t: 91-element Vector{Float64}:
0.0
9.999999999999999e-5
0.0010999999999999998
0.008325009772234456
0.020994176283791393
0.0364343358670688
0.05674523514445098
0.08286989819734197
0.11221638932307687
0.14642347979835246
⋮
4.531377144933996
4.600395661887067
4.658489156486032
4.717039575802435
4.797097378344955
4.853010164393907
4.913798996999781
4.986904078860146
5.0
u: 91-element Vector{Vector{Float64}}:
[0.0, 0.0]
[1.570795034867126e-7, 5.235985172127158e-12]
[1.9004744117386418e-5, 6.96868358226933e-9]
[0.0010824613825442051, 3.010699496947032e-6]
[0.006676004188171907, 4.740719263845825e-5]
[0.018672260214054187, 0.00023715849108202821]
[0.03852585131045319, 0.0008157098034480075]
[0.05916280060463827, 0.0021185079283594587]
[0.06134638493866648, 0.003951352196806262]
[0.03540013662961773, 0.005667636390935834]
⋮
[0.04952985663058974, 0.14529342452097024]
[0.000127935674026706, 0.14663964118144118]
[0.04034155170192192, 0.14753118116840172]
[0.05933195621751569, 0.15089699947601312]
[0.0002772715611076463, 0.1530273856659445]
[0.03497875213568734, 0.15371414368230196]
[0.06086038742068811, 0.15709298444433004]
[0.0028132618482891642, 0.15940880929987014]
[0.00015708255353278367, 0.15942252727283682]
We can plot this result, using either Plots.jl or Makie.jl. We'll use Plots here:
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:
using DyadInterface: artifacts
artifacts(result, :SimulationSolutionTable)
Row | timestamp | sys₊integrator1₊x(t) | sys₊integrator2₊x(t) |
---|---|---|---|
Float64 | Float64 | Float64 | |
1 | 0.0 | 0.0 | 0.0 |
2 | 0.0001 | 1.5708e-7 | 5.23599e-12 |
3 | 0.0011 | 1.90047e-5 | 6.96868e-9 |
4 | 0.00832501 | 0.00108246 | 3.0107e-6 |
5 | 0.0209942 | 0.006676 | 4.74072e-5 |
6 | 0.0364343 | 0.0186723 | 0.000237158 |
7 | 0.0567452 | 0.0385259 | 0.00081571 |
8 | 0.0828699 | 0.0591628 | 0.00211851 |
9 | 0.112216 | 0.0613464 | 0.00395135 |
10 | 0.146423 | 0.0354001 | 0.00566764 |
11 | 0.184829 | 0.00354746 | 0.0063481 |
12 | 0.224383 | 0.0088908 | 0.00643985 |
13 | 0.264834 | 0.0461333 | 0.00752472 |
14 | 0.310568 | 0.0619237 | 0.010216 |
15 | 0.362219 | 0.0199111 | 0.0124693 |
16 | 0.411188 | 0.00194739 | 0.0127396 |
17 | 0.466172 | 0.0473151 | 0.0139535 |
18 | 0.516467 | 0.0594961 | 0.016941 |
19 | 0.580588 | 0.00574339 | 0.0190607 |
20 | 0.632796 | 0.0154559 | 0.0192735 |
21 | 0.6872 | 0.0611255 | 0.021478 |
22 | 0.745374 | 0.0364467 | 0.0247294 |
23 | 0.803878 | 0.000242572 | 0.0254656 |
24 | 0.861963 | 0.0435171 | 0.0264955 |
25 | 0.917198 | 0.0591318 | 0.029718 |
26 | 0.989732 | 0.00165813 | 0.0318257 |
27 | 1.04438 | 0.0262546 | 0.0322472 |
28 | 1.10222 | 0.063598 | 0.0351578 |
29 | 1.16647 | 0.0161093 | 0.0380138 |
30 | 1.22394 | 0.00860495 | 0.038271 |
31 | 1.29123 | 0.0624728 | 0.0408316 |
32 | 1.34945 | 0.0323937 | 0.0439749 |
33 | 1.4124 | 0.00240111 | 0.0445805 |
34 | 1.47551 | 0.0547086 | 0.0462708 |
35 | 1.53363 | 0.0475053 | 0.0497086 |
36 | 1.60113 | 3.67886e-5 | 0.0509386 |
37 | 1.65983 | 0.0415178 | 0.0518786 |
38 | 1.71818 | 0.0586226 | 0.0552505 |
39 | 1.79737 | 0.000142258 | 0.057305 |
40 | 1.85342 | 0.0352737 | 0.0579998 |
41 | 1.91401 | 0.0606615 | 0.0613702 |
42 | 1.98676 | 0.00275927 | 0.0636649 |
43 | 2.04403 | 0.0259363 | 0.0640852 |
44 | 2.10312 | 0.0635508 | 0.0670641 |
45 | 2.16924 | 0.0137913 | 0.069906 |
46 | 2.22743 | 0.0111571 | 0.0701579 |
47 | 2.28931 | 0.0619277 | 0.0725662 |
48 | 2.34958 | 0.0323035 | 0.0758348 |
49 | 2.41129 | 0.00203085 | 0.0764362 |
50 | 2.47436 | 0.0539275 | 0.0780685 |
51 | 2.53211 | 0.0488407 | 0.0814976 |
52 | 2.60061 | 5.63697e-5 | 0.0828028 |
53 | 2.65891 | 0.0406761 | 0.0837072 |
54 | 2.71739 | 0.059074 | 0.0870724 |
55 | 2.79728 | 0.000185943 | 0.0891758 |
56 | 2.85322 | 0.0351114 | 0.0898656 |
57 | 2.91396 | 0.0607154 | 0.0932425 |
58 | 2.98705 | 0.00267976 | 0.0955432 |
59 | 3.04434 | 0.0262769 | 0.0959729 |
60 | 3.10355 | 0.0635414 | 0.0989733 |
61 | 3.16994 | 0.0132561 | 0.1018 |
62 | 3.22812 | 0.0117199 | 0.102052 |
63 | 3.289 | 0.06186 | 0.104435 |
64 | 3.34957 | 0.0323441 | 0.107725 |
65 | 3.41102 | 0.00197455 | 0.108329 |
66 | 3.47402 | 0.0537142 | 0.109945 |
67 | 3.53166 | 0.0492557 | 0.113373 |
68 | 3.60048 | 9.09425e-5 | 0.114703 |
69 | 3.65866 | 0.0404666 | 0.115599 |
70 | 3.71718 | 0.0592206 | 0.118964 |
71 | 3.79729 | 0.000221938 | 0.121083 |
72 | 3.85321 | 0.0351384 | 0.121774 |
73 | 3.91401 | 0.0607318 | 0.125157 |
74 | 3.9873 | 0.00262081 | 0.127458 |
75 | 4.04459 | 0.0265607 | 0.127896 |
76 | 4.10388 | 0.0635415 | 0.130912 |
77 | 4.17044 | 0.0128922 | 0.133727 |
78 | 4.22861 | 0.0121332 | 0.133981 |
79 | 4.28881 | 0.0618343 | 0.136349 |
80 | 4.3496 | 0.0323585 | 0.139654 |
81 | 4.41085 | 0.0019565 | 0.140258 |
82 | 4.47381 | 0.0535974 | 0.141866 |
83 | 4.53138 | 0.0495299 | 0.145293 |
84 | 4.6004 | 0.000127936 | 0.14664 |
85 | 4.65849 | 0.0403416 | 0.147531 |
86 | 4.71704 | 0.059332 | 0.150897 |
87 | 4.7971 | 0.000277272 | 0.153027 |
88 | 4.85301 | 0.0349788 | 0.153714 |
89 | 4.9138 | 0.0608604 | 0.157093 |
90 | 4.9869 | 0.00281326 | 0.159409 |
91 | 5.0 | 0.000157083 | 0.159423 |
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:
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:
artifacts(result, name::Symbol)
The allowed artifacts can be queried via:
artifacts(results)
which returns a list of all the available artifact names. For more details about all the artifacts,
AnalysisSolutionMetadata(result)
can be used, which also includes descriptions for all the artifacts.
Additionally, some analyses include a customizable visualization:
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.