Skip to content

Commit bba5fa5

Browse files
committed
updated the examples in the welcome modal
1 parent 2093834 commit bba5fa5

12 files changed

Lines changed: 732 additions & 1487 deletions

src/lib/nodes/generated/blocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Auto-generated by scripts/extract-blocks.py - DO NOT EDIT
22
// Re-run 'python scripts/extract-blocks.py' to update
33

4-
import type { NodeCategory } from '$lib/types';
4+
import type { NodeCategory } from '../types';
55

66
export interface ExtractedParam {
77
type: string;
@@ -1158,7 +1158,7 @@ export const extractedBlocks: Record<string, ExtractedBlock> =
11581158
"Scope": {
11591159
"blockClass": "Scope",
11601160
"description": "Block for recording time domain data with variable sampling rate.",
1161-
"docstringHtml": "<p>Block for recording time domain data with variable sampling rate.</p>\n<p>A time threshold can be set by <cite>t_wait</cite> to start recording data after the simulation\ntime is larger then the specified waiting time, i.e. <cite>t - t_wait &gt; 0</cite>.\nThis is useful for recording data only after all the transients have settled.</p>\n<p>The block uses an interal <cite>Schedule</cite> event, when <cite>sampling_rate</cite> is provided,\notherwise it just samples at every simulation timestep.</p>\n<div class=\"section\" id=\"parameters\">\n<h3>Parameters</h3>\n<dl class=\"docutils\">\n<dt>sampling_rate <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">int, None</span></dt>\n<dd>number of samples per time unit, default is every timestep</dd>\n<dt>t_wait <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">float</span></dt>\n<dd>wait time before starting recording, optional</dd>\n<dt>labels <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">list[str]</span></dt>\n<dd>labels for the scope traces, and for the csv, optional</dd>\n</dl>\n</div>\n<div class=\"section\" id=\"attributes\">\n<h3>Attributes</h3>\n<dl class=\"docutils\">\n<dt>recording <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">dict</span></dt>\n<dd>recording, where key is time, and value the recorded values</dd>\n<dt>_sample_next_timestep <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">bool</span></dt>\n<dd>flag to indicate this is a timestep to sample, only used for event based sampling\nwhen <cite>sampling_rate</cite> is provided as an arg</dd>\n<dt>events <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">list[Schedule]</span></dt>\n<dd>internal scheduled event for periodic input sampling when <cite>sampling_rate</cite> is provided</dd>\n</dl>\n</div>\n",
1161+
"docstringHtml": "<p>Block for recording time domain data with variable sampling rate.</p>\n<p>A time threshold can be set by <cite>t_wait</cite> to start recording data after the simulation\ntime is larger then the specified waiting time, i.e. <cite>t - t_wait &gt; 0</cite>.\nThis is useful for recording data only after all the transients have settled.</p>\n<p>The block uses an interal <cite>Schedule</cite> event, when <cite>sampling_rate</cite> is provided,\notherwise it just samples at every simulation timestep.</p>\n<div class=\"section\" id=\"parameters\">\n<h3>Parameters</h3>\n<dl class=\"docutils\">\n<dt>sampling_rate <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">int, None</span></dt>\n<dd>number of samples per time unit, default is every timestep</dd>\n<dt>t_wait <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">float</span></dt>\n<dd>wait time before starting recording, optional</dd>\n<dt>labels <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">list[str]</span></dt>\n<dd>labels for the scope traces, and for the csv, optional</dd>\n</dl>\n</div>\n<div class=\"section\" id=\"attributes\">\n<h3>Attributes</h3>\n<dl class=\"docutils\">\n<dt>recording_time <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">list[float]</span></dt>\n<dd>recorded time points</dd>\n<dt>recording_data <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">list[float]</span></dt>\n<dd>regorded data points</dd>\n<dt>_incremental_idx <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">int</span></dt>\n<dd>index for incremental reading of accumulated data since last\ncall of incremental read</dd>\n<dt>_sample_next_timestep <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">bool</span></dt>\n<dd>flag to indicate this is a timestep to sample, only used for\nevent based sampling when <cite>sampling_rate</cite> is provided as an arg</dd>\n<dt>events <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">list[Schedule]</span></dt>\n<dd>internal scheduled event for periodic input sampling when\n<cite>sampling_rate</cite> is provided</dd>\n</dl>\n</div>\n",
11621162
"params": {
11631163
"sampling_rate": {
11641164
"type": "any",

static/examples/bouncing-ball.json

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"version": "1.0.0",
33
"metadata": {
4-
"created": "2025-12-22T23:21:53.588Z",
5-
"modified": "2025-12-22T23:21:53.588Z",
4+
"created": "2026-01-14T10:21:54.899Z",
5+
"modified": "2026-01-14T10:21:54.899Z",
66
"name": "Bouncing Ball",
7-
"description": "Gravity and collision events"
7+
"name": "Gravity, Collisions and discrete Events"
88
},
99
"graph": {
1010
"nodes": [
@@ -255,6 +255,18 @@
255255
"targetNodeId": "78f720fe-8774-42c3-be6b-5a4ef30e00df",
256256
"targetPortIndex": 0
257257
}
258+
],
259+
"annotations": [
260+
{
261+
"id": "deeecd86-71ac-4a13-a289-c64c946e667c",
262+
"position": {
263+
"x": -45,
264+
"y": 90
265+
},
266+
"content": "# Bouncing Ball Physics\n\nThis is an example of a hybrid system with continuous dynamics (free falling ball) and discrete events (bounces).\n\nIntegrating the gravitational acceleration gives the ball velocity in free fall:\n\n$$ v(t) = - \\int_0^t g \\, d\\tau $$\n\nAnd the position is the integrated velocity:\n\n$$ x(t) = \\int_0^t v(\\tau) \\, d\\tau $$\n\nWe use an event node to define the discrete dynamics of the ball hitting the ground. Whenever the position crosses zero\n\n$$ |x(t)| = 0 $$\n\nthe sign of the velocity is flipped and a coefficient of restitution ($b$) is applied to model the energy loss from the deformation of the ball:\n\n$$ y(t) \\leftarrow -b \\, y(t) $$\n\nWhen the total energy drops below a certain threshold we consider that a Zeno state and stop the simulation.",
267+
"width": 425,
268+
"height": 370
269+
}
258270
]
259271
},
260272
"events": [
@@ -263,20 +275,33 @@
263275
"type": "pathsim.events.ZeroCrossing",
264276
"name": "Bounce",
265277
"position": {
266-
"x": 960,
278+
"x": 945,
267279
"y": 225
268280
},
269281
"params": {
270282
"func_evt": "bounce_detect",
271283
"func_act": "bounce_resolve"
272284
}
285+
},
286+
{
287+
"id": "eda13d11-f264-4861-ba54-e17c48884905",
288+
"type": "pathsim.events.Condition",
289+
"name": "Zeno",
290+
"position": {
291+
"x": 1200,
292+
"y": 225
293+
},
294+
"params": {
295+
"func_evt": "zeno_detect",
296+
"func_act": "zeno_resolve"
297+
}
273298
}
274299
],
275300
"codeContext": {
276-
"code": "# initial position \nx0 = 1\n\n# mass\nm = 1\n\n# gravity\ng = 9.81\n\n# bounce back coefficient (randomized)\nb = 0.85 + 0.1*np.random.rand()\n\n# event detection function\ndef bounce_detect(t):\n return pos.engine.get()\n\n# event resolution function\ndef bounce_resolve(t):\n pos.engine.set(-pos.engine.get())\n vel.engine.set(-b*vel.engine.get())"
301+
"code": "# initial position \nx0 = 1\n\n# mass\nm = 1\n\n# gravity\ng = 9.81\n\n# bounce back coefficient (randomized)\nb = 0.85 + 0.1*np.random.rand()\n\n# zeno energy threshold\ne_th = 0.5\n\n# event detection function\ndef bounce_detect(t):\n return pos.engine.state\n\n# event resolution function\ndef bounce_resolve(t):\n pos.engine.set(-pos.engine.state)\n vel.engine.set(-b*vel.engine.state)\n\n# zeno state detection\ndef zeno_detect(t):\n e = total_energy.outputs[0]\n return e < e_th\n\n# stop simulation \ndef zeno_resolve(t):\n sim.stop()\n"
277302
},
278303
"simulationSettings": {
279-
"duration": "5",
304+
"duration": "50",
280305
"dt": "",
281306
"solver": "RKBS32",
282307
"adaptive": true,
@@ -285,7 +310,7 @@
285310
"ftol": "",
286311
"dt_min": "",
287312
"dt_max": "0.05",
288-
"ghostTraces": 6,
313+
"ghostTraces": 8,
289314
"plotResults": true
290315
}
291-
}
316+
}

static/examples/cascade-subsystem.json

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"version": "1.0.0",
33
"metadata": {
4-
"created": "2025-12-23T14:57:43.382Z",
5-
"modified": "2025-12-23T14:57:43.382Z",
6-
"name": "Cascade Control",
7-
"description": "Nested PID control loops"
4+
"created": "2026-01-14T10:23:07.377Z",
5+
"modified": "2026-01-14T10:23:07.377Z",
6+
"name": "Cascade PI Controler",
7+
"name": "Cascade Control of a Plant modeled as nested Subsystems"
88
},
99
"graph": {
1010
"nodes": [
@@ -392,7 +392,6 @@
392392
}
393393
],
394394
"params": {
395-
"operations": null,
396395
"_rotation": 1
397396
}
398397
},
@@ -401,8 +400,8 @@
401400
"type": "WhiteNoise",
402401
"name": "Noise",
403402
"position": {
404-
"x": 255,
405-
"y": 0
403+
"x": 105,
404+
"y": -15
406405
},
407406
"inputs": [],
408407
"outputs": [
@@ -417,17 +416,17 @@
417416
],
418417
"params": {
419418
"spectral_density": "noise_psd",
420-
"sampling_rate": null,
421-
"_rotation": 1
419+
"sampling_rate": "0.5",
420+
"_rotation": 0
422421
}
423422
},
424423
{
425424
"id": "44861add-91bd-4091-bebe-f89b308c9c45",
426425
"type": "Scope",
427426
"name": "Disturbed Signal",
428427
"position": {
429-
"x": 345,
430-
"y": 210
428+
"x": 405,
429+
"y": 120
431430
},
432431
"inputs": [
433432
{
@@ -474,6 +473,18 @@
474473
"targetNodeId": "44861add-91bd-4091-bebe-f89b308c9c45",
475474
"targetPortIndex": 0
476475
}
476+
],
477+
"annotations": [
478+
{
479+
"id": "c3103ad7-22d5-455d-8078-579809c95ad6",
480+
"position": {
481+
"x": 345,
482+
"y": -15
483+
},
484+
"content": "# Disturbance\n\nThe inline disturbance adds a white noise signal on top of the input signal.",
485+
"width": 155,
486+
"height": 100
487+
}
477488
]
478489
}
479490
}
@@ -514,6 +525,18 @@
514525
"targetNodeId": "4154466b-5a0b-42f7-bb32-27e649d59245",
515526
"targetPortIndex": 0
516527
}
528+
],
529+
"annotations": [
530+
{
531+
"id": "4dc50a79-58b7-4cbd-b049-110bfbbd117e",
532+
"position": {
533+
"x": -600,
534+
"y": -255
535+
},
536+
"content": "# Plant\n\nThe plant contains two transfer functions and an additive inline disturbance...\n\n... which is modeled by a subsystem too.",
537+
"width": 140,
538+
"height": 160
539+
}
517540
]
518541
}
519542
},
@@ -522,8 +545,8 @@
522545
"type": "Scope",
523546
"name": "Plant vs Setpoint",
524547
"position": {
525-
"x": 1170,
526-
"y": 495
548+
"x": 1095,
549+
"y": 510
527550
},
528551
"inputs": [
529552
{
@@ -545,9 +568,7 @@
545568
],
546569
"outputs": [],
547570
"params": {
548-
"sampling_rate": null,
549571
"t_wait": "0.0",
550-
"labels": null,
551572
"_rotation": 1
552573
}
553574
},
@@ -579,9 +600,7 @@
579600
],
580601
"outputs": [],
581602
"params": {
582-
"sampling_rate": null,
583603
"t_wait": "0.0",
584-
"labels": null,
585604
"_rotation": 3
586605
}
587606
},
@@ -613,9 +632,7 @@
613632
],
614633
"outputs": [],
615634
"params": {
616-
"sampling_rate": null,
617635
"t_wait": "0.0",
618-
"labels": null,
619636
"_rotation": 3
620637
}
621638
}
@@ -712,23 +729,35 @@
712729
"targetNodeId": "e13e27ba-96ec-4b02-a6d6-6cea244e49dc",
713730
"targetPortIndex": 0
714731
}
732+
],
733+
"annotations": [
734+
{
735+
"id": "416e7281-7496-4b94-8c9f-ab802029d5e9",
736+
"position": {
737+
"x": 720,
738+
"y": 225
739+
},
740+
"content": "# Cascade PI Controler\n\nThis example is a cascade controler. The plant is modeled as a **Subsystem**. Double click to enter.",
741+
"width": 230,
742+
"height": 115
743+
}
715744
]
716745
},
717746
"events": [],
718747
"codeContext": {
719-
"code": "# spectral density of noise source in plant\nnoise_psd = 1e-5"
748+
"code": "# spectral density of noise source in plant\nnoise_psd = 1e-4"
720749
},
721750
"simulationSettings": {
722751
"duration": "100.0",
723752
"dt": "0.1",
724-
"solver": "RK4",
753+
"solver": "SSPRK22",
725754
"adaptive": true,
726755
"atol": "1e-6",
727756
"rtol": "1e-4",
728757
"ftol": "1e-9",
729758
"dt_min": "",
730759
"dt_max": "",
731-
"ghostTraces": 6,
760+
"ghostTraces": 3,
732761
"plotResults": true
733762
}
734-
}
763+
}

0 commit comments

Comments
 (0)