bs-simulators 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bs_simulators/__init__.py +44 -0
- bs_simulators/__main__.py +12 -0
- bs_simulators/catalogue/__init__.py +160 -0
- bs_simulators/catalogue/_validation.py +159 -0
- bs_simulators/catalogue/dc-motor.toml +46 -0
- bs_simulators/catalogue/neutralization.toml +63 -0
- bs_simulators/catalogue/pendulum.toml +37 -0
- bs_simulators/cli/__init__.py +5 -0
- bs_simulators/cli/commands.py +154 -0
- bs_simulators/cli/configuration.py +50 -0
- bs_simulators/cli/execution.py +53 -0
- bs_simulators/cli/presentation.py +134 -0
- bs_simulators/comms/__init__.py +5 -0
- bs_simulators/comms/adapters.py +47 -0
- bs_simulators/comms/http.py +179 -0
- bs_simulators/runtime/__init__.py +9 -0
- bs_simulators/runtime/_validation.py +51 -0
- bs_simulators/runtime/core.py +471 -0
- bs_simulators/runtime/protocols.py +174 -0
- bs_simulators/runtime/signals.py +51 -0
- bs_simulators/runtime/steppers.py +275 -0
- bs_simulators/viewers/__init__.py +13 -0
- bs_simulators/viewers/dc-motor.html +25 -0
- bs_simulators/viewers/neutralization.html +25 -0
- bs_simulators/viewers/pendulum.html +25 -0
- bs_simulators/viewers/scenes.js +143 -0
- bs_simulators/viewers/viewer.css +10 -0
- bs_simulators/viewers/viewer.js +48 -0
- bs_simulators-0.1.2.dist-info/METADATA +65 -0
- bs_simulators-0.1.2.dist-info/RECORD +34 -0
- bs_simulators-0.1.2.dist-info/WHEEL +4 -0
- bs_simulators-0.1.2.dist-info/entry_points.txt +5 -0
- bs_simulators-0.1.2.dist-info/licenses/LICENSE +21 -0
- bs_simulators-0.1.2.dist-info/licenses/LICENSE.benchmark-systems +21 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/** Canvas counterparts of benchmark-systems' Matplotlib scenes (schematics only). */
|
|
2
|
+
export const fmt=(v,n=2)=>Number.isFinite(v)?v.toFixed(n):'—';
|
|
3
|
+
const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));
|
|
4
|
+
|
|
5
|
+
/** Preserve declared endpoints and infer only missing ones from a scene's fallback. */
|
|
6
|
+
export function signalRange(signal,fallback){
|
|
7
|
+
const hasLower=Number.isFinite(signal?.lower),hasUpper=Number.isFinite(signal?.upper);
|
|
8
|
+
let lower=hasLower?signal.lower:fallback[0],upper=hasUpper?signal.upper:fallback[1];
|
|
9
|
+
const span=Math.max(fallback[1]-fallback[0],Math.abs(lower)*.1,Math.abs(upper)*.1,1e-3);
|
|
10
|
+
if(hasLower&&!hasUpper&&upper<=lower)upper=lower+span;
|
|
11
|
+
if(hasUpper&&!hasLower&&lower>=upper)lower=upper-span;
|
|
12
|
+
if(lower>upper)throw new Error('Signal lower bound exceeds its upper bound');
|
|
13
|
+
return [lower,upper];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Normalize a reading for drawing only; a zero-width range has its value at the centre. */
|
|
17
|
+
export function scaleFraction(value,[lower,upper]){
|
|
18
|
+
if(lower===upper)return value<lower?0:value>upper?1:.5;
|
|
19
|
+
const scale=Math.max(Math.abs(lower),Math.abs(upper),1);
|
|
20
|
+
return clamp((clamp(value,lower,upper)/scale-lower/scale)/(upper/scale-lower/scale),0,1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Keep small full-scale labels readable without rounding them to zero. */
|
|
24
|
+
export function limitLabel(value){
|
|
25
|
+
if(value===0)return '0';
|
|
26
|
+
return Math.abs(value)<.01||Math.abs(value)>=1e4
|
|
27
|
+
?value.toExponential(1).replace('.0e','e'):Number(value.toPrecision(4)).toString();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Map an equal-aspect model coordinate system into the responsive canvas. */
|
|
31
|
+
function plot(canvas,xmin,xmax,ymin,ymax,padding=12){
|
|
32
|
+
const {width:w,height:h}=canvas.getBoundingClientRect(),dpr=window.devicePixelRatio||1;
|
|
33
|
+
canvas.width=Math.round(w*dpr);canvas.height=Math.round(h*dpr);
|
|
34
|
+
const c=canvas.getContext('2d');c.scale(dpr,dpr);
|
|
35
|
+
const scale=Math.max(1e-9,Math.min((w-2*padding)/(xmax-xmin),(h-2*padding)/(ymax-ymin)));
|
|
36
|
+
const left=(w-scale*(xmax-xmin))/2,top=(h-scale*(ymax-ymin))/2;
|
|
37
|
+
const X=x=>left+(x-xmin)*scale,Y=y=>top+(ymax-y)*scale;
|
|
38
|
+
const line=(x1,y1,x2,y2,color='#444',lw=1)=>{
|
|
39
|
+
c.strokeStyle=color;c.lineWidth=lw;c.beginPath();c.moveTo(X(x1),Y(y1));c.lineTo(X(x2),Y(y2));c.stroke();
|
|
40
|
+
};
|
|
41
|
+
const text=(s,x,y,size=12,color='#222',align='center',bold=false)=>{
|
|
42
|
+
c.font=(bold?'bold ':'')+size+'px Arial';c.fillStyle=color;c.textAlign=align;c.textBaseline='middle';c.fillText(s,X(x),Y(y));
|
|
43
|
+
};
|
|
44
|
+
const circle=(x,y,r,fill,stroke=null,lw=1)=>{
|
|
45
|
+
c.beginPath();c.arc(X(x),Y(y),r*scale,0,2*Math.PI);
|
|
46
|
+
if(fill){c.fillStyle=fill;c.fill();}if(stroke){c.strokeStyle=stroke;c.lineWidth=lw;c.stroke();}
|
|
47
|
+
};
|
|
48
|
+
const rect=(x,y,w0,h0,fill,stroke=null,r=0,lw=1)=>{
|
|
49
|
+
c.beginPath();c.roundRect(X(x),Y(y+h0),w0*scale,h0*scale,r*scale);
|
|
50
|
+
if(fill){c.fillStyle=fill;c.fill();}if(stroke){c.strokeStyle=stroke;c.lineWidth=lw;c.stroke();}
|
|
51
|
+
};
|
|
52
|
+
const arrow=(x1,y1,x2,y2,color='#444')=>{
|
|
53
|
+
line(x1,y1,x2,y2,color,1.5);const a=Math.atan2(y2-y1,x2-x1),r=.12;
|
|
54
|
+
line(x2,y2,x2-r*Math.cos(a-.45),y2-r*Math.sin(a-.45),color,1.5);
|
|
55
|
+
line(x2,y2,x2-r*Math.cos(a+.45),y2-r*Math.sin(a+.45),color,1.5);
|
|
56
|
+
};
|
|
57
|
+
return {c,scale,X,Y,line,text,circle,rect,arrow};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function pendulum(canvas,state){
|
|
61
|
+
const L=state?.parameters?.L||1,lim=1.5*L;
|
|
62
|
+
const p=plot(canvas,-lim*1.30,lim*1.12,-lim*1.30,lim*1.12),{line,text,circle,c,X,Y}=p;
|
|
63
|
+
line(-lim,-lim,lim,-lim,'#222');line(-lim,-lim,-lim,lim,'#222');
|
|
64
|
+
line(-lim,lim,lim,lim,'#222');line(lim,-lim,lim,lim,'#222');
|
|
65
|
+
for(let i=-3;i<=3;i++){
|
|
66
|
+
const v=i*L/2;
|
|
67
|
+
line(v,-lim,v,-lim-.04*L,'#222');text(fmt(v,L<.1?3:1),v,-lim-.16*L,12);
|
|
68
|
+
line(-lim,v,-lim-.04*L,v,'#222');text(fmt(v,L<.1?3:1),-lim-.09*L,v,12,'#222','right');
|
|
69
|
+
}
|
|
70
|
+
text('x (m)',0,-lim-.36*L,12);
|
|
71
|
+
c.save();c.translate(X(-lim-.36*L),Y(0));c.rotate(-Math.PI/2);c.fillText('y (m)',0,0);c.restore();
|
|
72
|
+
line(-lim,0,lim,0,'#b8b8b8',.8);
|
|
73
|
+
if(state){
|
|
74
|
+
const [theta]=state.x,bx=L*Math.sin(theta),by=-L*Math.cos(theta);
|
|
75
|
+
line(0,0,bx,by,'#696969',2);circle(bx,by,.08*L,'steelblue');circle(0,0,.04*L,'black');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let omegaMax=1e-3,currentMax=1e-3;
|
|
80
|
+
function motor(canvas,state,signals={outputs:[]}){
|
|
81
|
+
const p=plot(canvas,-2.5,2.5,-1.5,1.5),{line,text,circle,rect}=p;
|
|
82
|
+
circle(0,0,.9,'rgba(65,105,225,.3)','royalblue',2);
|
|
83
|
+
const [theta,omega,current]=state?.x||[0,0,0];
|
|
84
|
+
line(0,0,.85*Math.sin(theta),.85*Math.cos(theta),'navy',3);
|
|
85
|
+
const omegaRange=signalRange(signals.outputs[1],[-omegaMax,omegaMax]);
|
|
86
|
+
const currentRange=signalRange(signals.outputs[2],[-currentMax,currentMax]);
|
|
87
|
+
for(const [x,value,range,color,label] of [[1.2,omega,omegaRange,'steelblue','omega'],[1.7,current,currentRange,'tomato','I']]){
|
|
88
|
+
rect(x,-.8,.3,1.6,'lightgray','gray',.02);
|
|
89
|
+
const zero=-.8+1.6*scaleFraction(0,range),level=-.8+1.6*scaleFraction(value,range);
|
|
90
|
+
rect(x+.02,Math.min(zero,level),.26,Math.abs(level-zero),color,null,.01);
|
|
91
|
+
if(range[0]<=0&&range[1]>=0)line(x,zero,x+.3,zero,'#777',.6);
|
|
92
|
+
text(limitLabel(range[1]),x+.15,.94,10,'#555');text(limitLabel(range[0]),x+.15,-.91,10,'#555');
|
|
93
|
+
text(label,x+.15,-1.05,12,color==='tomato'?'firebrick':'navy');
|
|
94
|
+
}
|
|
95
|
+
text('theta='+fmt(theta*180/Math.PI,1)+'° omega='+fmt(omega)+' rad/s I='+fmt(current,3)+' A',0,-1.25,12,'dimgray');
|
|
96
|
+
return [{label:'omega (rad/s)',range:omegaRange},{label:'I (A)',range:currentRange}];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A gauge matching the 210° to -30° sweep of the Matplotlib DialGauge. */
|
|
100
|
+
function gauge(p,cx,cy,value,range,label){
|
|
101
|
+
const {c,X,Y,scale,circle,line,text}=p,r=.65,f=scaleFraction(value,range),a=(210-240*f)*Math.PI/180;
|
|
102
|
+
circle(cx,cy,r,'#f8f8f8','#444',1.5);
|
|
103
|
+
c.strokeStyle='#ddd';c.lineWidth=2.5;c.beginPath();c.arc(X(cx),Y(cy),r*.85*scale,-210*Math.PI/180,30*Math.PI/180);c.stroke();
|
|
104
|
+
const colors=[[49,54,149],[69,117,180],[116,173,209],[171,217,233],[224,243,248],[255,255,191],[254,224,144],[253,174,97],[244,109,67],[215,48,39],[165,0,38]];
|
|
105
|
+
const j=Math.min(9,Math.floor(f*10)),mix=f*10-j;
|
|
106
|
+
c.strokeStyle='rgb('+colors[j].map((v,k)=>v+(colors[j+1][k]-v)*mix).join(',')+')';c.beginPath();
|
|
107
|
+
c.arc(X(cx),Y(cy),r*.85*scale,-210*Math.PI/180,-a);c.stroke();
|
|
108
|
+
line(cx,cy,cx+r*.65*Math.cos(a),cy+r*.65*Math.sin(a),'#333',1.2);
|
|
109
|
+
circle(cx,cy,r*.1,'#333');text(label,cx,cy-r*.45,10,'#555');text(fmt(value),cx,cy+r*.45,11,'#222','center',true);
|
|
110
|
+
text(limitLabel(range[0]),cx-.53,cy-.55,9,'#555');text(limitLabel(range[1]),cx+.53,cy-.55,9,'#555');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function neutralization(canvas,state,signals={outputs:[]}){
|
|
114
|
+
const p=plot(canvas,0,8.2,0,9.5),{c,X,Y,scale,line,text,circle,rect,arrow}=p;
|
|
115
|
+
const heightRange=signalRange(signals.outputs[2],[0,25]),phRange=signalRange(signals.outputs[3],[0,14]);
|
|
116
|
+
const heightScale=heightRange[1]>0?heightRange[1]:25;
|
|
117
|
+
const h=state?.x?.[2]??14,ph=state?.x?.[3]??7,fh=6.2*clamp(h/heightScale,0,1),t=clamp(ph/14,0,1);
|
|
118
|
+
const col=`rgba(${255*Math.max(0,1-2*t)},${255*(1-2*Math.abs(t-.5))},${255*Math.max(0,2*t-1)},.38)`;
|
|
119
|
+
rect(.56,.86,4.88,Math.max(fh-.06,.02),col,null,.24);
|
|
120
|
+
rect(.56,.86,4.88,Math.max(fh-.06,.02),'rgba(200,228,245,.48)',null,.24);
|
|
121
|
+
rect(.5,.8,5,6.2,null,'#334455',.32,2);
|
|
122
|
+
rect(2.81,7.05,.38,.36,'#ddd','#555',.04);
|
|
123
|
+
line(5.55,1.3,7.1,1.3,'#444',2);arrow(7.4,1.3,7.8,1.3);text('q4',7.8,1.3,12,'#333','left',true);
|
|
124
|
+
gauge(p,6.45,2.13,ph,phRange,'pH');gauge(p,6.45,3.7275,h,heightRange,'h (cm)');
|
|
125
|
+
for(const [x,label,color,value] of [[3.75,'q1','#5faa22',state?.parameters?.q1],[4.95,'q2','#666',state?.parameters?.d],[1.55,'q3','#c20',state?.u?.[0]]]){
|
|
126
|
+
arrow(x,7.7,x,7.1,color);text(label,x+.12,7.5,12,color,'left',true);
|
|
127
|
+
if(Number.isFinite(value))text(fmt(value,1)+' cm³/s',x,7.95,11,color);
|
|
128
|
+
}
|
|
129
|
+
const by=.8+fh*.38,angle=(state?.t||0)*2*Math.PI;
|
|
130
|
+
line(3,7.05,3,by,'#999',2);
|
|
131
|
+
c.beginPath();c.ellipse(X(3),Y(by-.07),.65*.85*scale,.065*scale,0,0,2*Math.PI);c.strokeStyle='#aaa';c.lineWidth=.8;c.stroke();
|
|
132
|
+
for(const offset of [0,Math.PI]){
|
|
133
|
+
const a=angle+offset;line(3,by,3+.65*Math.cos(a),by+.65*.28*Math.sin(a)-.06,'#555',2.5);
|
|
134
|
+
}
|
|
135
|
+
circle(3,by,.07,'#555');
|
|
136
|
+
return [{label:'pH',range:phRange},{label:'h (cm)',range:heightRange}];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const scenes={
|
|
140
|
+
pendulum:{states:2,aspect:'1 / 1',draw:pendulum},
|
|
141
|
+
'dc-motor':{states:3,aspect:'5 / 3',draw:motor,observe(s){omegaMax=Math.max(omegaMax,Math.abs(s.x[1]));currentMax=Math.max(currentMax,Math.abs(s.x[2]));},reset(){omegaMax=1e-3;currentMax=1e-3;}},
|
|
142
|
+
neutralization:{states:4,aspect:'8.2 / 9.5',draw:neutralization}
|
|
143
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
:root{font:14px Arial,sans-serif;color:#222;background:white;color-scheme:light}
|
|
2
|
+
*{box-sizing:border-box}body{max-width:680px;margin:0 auto;padding:22px 20px}
|
|
3
|
+
h1{font-size:19px;font-weight:400;text-align:center;margin:8px 0 0}
|
|
4
|
+
canvas{display:block;width:100%;aspect-ratio:1 / 1}
|
|
5
|
+
#time{text-align:center;font-size:14px;font-variant-numeric:tabular-nums;margin:8px 0 22px}
|
|
6
|
+
#status{font-size:12px;color:#666;text-align:center;min-height:18px;margin:0 0 16px}
|
|
7
|
+
details{font-size:12px;color:#666;border-top:1px solid #ddd;padding:12px 0;line-height:1.8}
|
|
8
|
+
summary{cursor:pointer;width:fit-content}dl{display:grid;grid-template-columns:auto 1fr;gap:2px 16px;margin:12px 0}
|
|
9
|
+
dd{margin:0;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}#error{color:#9b2424;white-space:pre-wrap}
|
|
10
|
+
@media(max-width:480px){body{padding:12px 8px}dl{grid-template-columns:1fr;gap:0}dd{margin-bottom:8px}}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Observe committed snapshots; rendering never advances the simulation. */
|
|
2
|
+
import {scenes, fmt} from './scenes.js';
|
|
3
|
+
const el=id=>document.getElementById(id);
|
|
4
|
+
const scene=scenes[document.documentElement.dataset.viewer];
|
|
5
|
+
let state=null;
|
|
6
|
+
let signals=null;
|
|
7
|
+
el('scene').style.aspectRatio=scene.aspect;
|
|
8
|
+
function draw(){
|
|
9
|
+
const ranges=scene.draw(el('scene'),state,signals||{outputs:[],inputs:[]});
|
|
10
|
+
el('scales').textContent=ranges?.map(({label,range})=>label+': ['+range.join(', ')+']').join('; ')||'—';
|
|
11
|
+
}
|
|
12
|
+
/** Load ordered signal descriptions once, or again after the observed run restarts. */
|
|
13
|
+
async function loadSignals(){
|
|
14
|
+
const response=await fetch('/api/signals',{cache:'no-store',signal:AbortSignal.timeout(3000)});
|
|
15
|
+
if(!response.ok)throw new Error('Signal metadata: HTTP '+response.status);
|
|
16
|
+
const descriptions=await response.json();
|
|
17
|
+
if(!Array.isArray(descriptions))throw new Error('Invalid signal metadata');
|
|
18
|
+
signals={outputs:descriptions.filter(s=>s.direction==='output').slice(0,scene.states),
|
|
19
|
+
inputs:descriptions.filter(s=>s.direction==='input')};
|
|
20
|
+
}
|
|
21
|
+
async function poll(){
|
|
22
|
+
try{
|
|
23
|
+
const response=await fetch('/api/state',{cache:'no-store',signal:AbortSignal.timeout(3000)});
|
|
24
|
+
if(!response.ok)throw new Error('HTTP '+response.status);
|
|
25
|
+
const next=await response.json();
|
|
26
|
+
if(!Array.isArray(next.x)||next.x.length!==scene.states||!next.x.every(Number.isFinite)||
|
|
27
|
+
!Array.isArray(next.u)||!next.u.every(Number.isFinite))throw new Error('Invalid simulation state');
|
|
28
|
+
const restarted=state&&(next.seq<state.seq||next.t<state.t);
|
|
29
|
+
if(!signals||restarted)await loadSignals();
|
|
30
|
+
if(restarted)scene.reset?.();
|
|
31
|
+
state=next;scene.observe?.(state);
|
|
32
|
+
el('time').textContent='t = '+fmt(state.t,1)+' s';
|
|
33
|
+
const statuses={ready:'Ready',running:'Live',finished:'Experiment finished',stopped:'Simulation stopped',error:'Simulation error'};
|
|
34
|
+
el('status').textContent=statuses[state.status]||state.status;
|
|
35
|
+
el('motion').textContent=state.x.map(v=>fmt(v,6)).join(', ');
|
|
36
|
+
el('input').textContent=state.u.map(v=>fmt(v,4)).join(', ');
|
|
37
|
+
el('parameters').textContent=Object.entries(state.parameters||{}).map(([k,v])=>k+' = '+v).join('; ');
|
|
38
|
+
el('controller').textContent=state.active_controller??'—';
|
|
39
|
+
el('timing').textContent=fmt(state.wall_elapsed)+' s / '+fmt(1000*state.lag,1)+' ms';
|
|
40
|
+
el('sequence').textContent=state.input_seq+' / '+(state.pending_input_seq??'—');
|
|
41
|
+
el('error').textContent=state.error||'';draw();
|
|
42
|
+
}catch(error){
|
|
43
|
+
el('status').textContent=state?'Disconnected · retaining the last image':'Cannot connect to the simulator';
|
|
44
|
+
el('error').textContent=error.message;
|
|
45
|
+
}
|
|
46
|
+
setTimeout(poll,50);
|
|
47
|
+
}
|
|
48
|
+
window.addEventListener('resize',draw);draw();poll();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: bs-simulators
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Live simulators and transport adapters for benchmark-systems models
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.13
|
|
7
|
+
Requires-Dist: benchmark-systems>=1.2.0
|
|
8
|
+
Requires-Dist: numpy>=2.1.0
|
|
9
|
+
Requires-Dist: scipy>=1.14.1
|
|
10
|
+
Requires-Dist: solve-dae>=0.2.4
|
|
11
|
+
Requires-Dist: typer>=0.27.3
|
|
12
|
+
Provides-Extra: replay
|
|
13
|
+
Requires-Dist: benchmark-systems[anim]>=1.2.0; extra == "replay"
|
|
14
|
+
Requires-Dist: Pillow>=11.0.0; extra == "replay"
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# bs-simulators
|
|
18
|
+
|
|
19
|
+
`bs-simulators` runs [benchmark-systems](https://benchmark-systems.readthedocs.io/en/latest/)
|
|
20
|
+
models as virtual plants for live control experiments. A controller interacts
|
|
21
|
+
with the simulation as it would with a physical plant: it reads sensor
|
|
22
|
+
measurements and sends actuator commands while the plant evolves independently.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install from PyPI with Python 3.13 or later:
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
python -m pip install bs-simulators
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
See the [documentation on Read the Docs](https://bs-simulators.readthedocs.io/en/latest/)
|
|
33
|
+
for examples and the API reference.
|
|
34
|
+
|
|
35
|
+
## Run a virtual pendulum
|
|
36
|
+
|
|
37
|
+
After installation, launch the bundled pendulum and open
|
|
38
|
+
<http://127.0.0.1:8765/> to watch it evolve.
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
bs-simulators --catalogue pendulum
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The catalogue also includes a DC motor and a pH neutralization process.
|
|
45
|
+
Use `bs-simulators --list-catalogue` to see the available configurations.
|
|
46
|
+
|
|
47
|
+
## Run a simulation from Python
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from benchmark_systems.models import pendulum
|
|
51
|
+
from bs_simulators import Simulation
|
|
52
|
+
|
|
53
|
+
simulation = Simulation(
|
|
54
|
+
pendulum, x0=[0.6, 0.0], u0=[0.0],
|
|
55
|
+
parameters={"m": 1.0, "L": 1.0},
|
|
56
|
+
)
|
|
57
|
+
simulation.start(duration=1.0)
|
|
58
|
+
simulation.wait()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The [pendulum control example](https://bs-simulators.readthedocs.io/en/latest/pendulum.html)
|
|
62
|
+
shows how to read measurements and send commands in a control loop. A controller
|
|
63
|
+
in a separate process can use the [HTTP interface](https://bs-simulators.readthedocs.io/en/latest/http.html).
|
|
64
|
+
|
|
65
|
+
[MIT License](LICENSE)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
bs_simulators-0.1.2.dist-info/METADATA,sha256=ugZmJvqzXUNqfSyW51kD80kipfCcj1d702Wv_H04jFE,2006
|
|
2
|
+
bs_simulators-0.1.2.dist-info/WHEEL,sha256=IuIk3wbaEnFH1cx75iM2R1CmliRI3dFLXTbRakgvgFQ,90
|
|
3
|
+
bs_simulators-0.1.2.dist-info/entry_points.txt,sha256=RS6LPIO_NrJDGQSSu_gItGw5sjE0aDZqTAWygbFWVuY,78
|
|
4
|
+
bs_simulators-0.1.2.dist-info/licenses/LICENSE,sha256=umO8LgRqY5mzIS8Y1P3R9trMQ3lYMG-UqQRhOosYaTQ,1063
|
|
5
|
+
bs_simulators-0.1.2.dist-info/licenses/LICENSE.benchmark-systems,sha256=7-iNsI4KTjJF6xG8RhKVCu6EDHOTlXl-gsiSh1pPidU,1079
|
|
6
|
+
bs_simulators/__init__.py,sha256=0bmR2eU7pXmYdGBRcnF4a1YK_gdoxvdXhHNbTGdTaBA,1533
|
|
7
|
+
bs_simulators/__main__.py,sha256=ZdjaLyeNItUtPWkQciCrH5fpO1X1j3t0f46b6Nq9zYI,290
|
|
8
|
+
bs_simulators/catalogue/__init__.py,sha256=kT-HbKZMmxBsOnBDz86ZCyj8m2c4X9mYM-fRuwzaHqU,7719
|
|
9
|
+
bs_simulators/catalogue/_validation.py,sha256=-jJerf0osc0ZA9PmP9yWx2GtRYLpUjEaek4yPxkxdHA,7719
|
|
10
|
+
bs_simulators/catalogue/dc-motor.toml,sha256=cg9I0YKzud7-HOofg84HZ59xySRhOHPsWvfYBWENMlI,613
|
|
11
|
+
bs_simulators/catalogue/neutralization.toml,sha256=VbigUJ89Tt1OO8vZ7k4NJdbKCfJB9pwJLQLhonszJHk,883
|
|
12
|
+
bs_simulators/catalogue/pendulum.toml,sha256=uKVfAnOHG5cjUSLkGxXSfzvLkoq7aDDc-d6mgei-KLI,526
|
|
13
|
+
bs_simulators/cli/__init__.py,sha256=HbzIFjJcNZrCXmMWAANZUK2pRDz5LNl6bS5e1ti5zvY,136
|
|
14
|
+
bs_simulators/cli/commands.py,sha256=GqCg_Rsatxz23fX2yovtY-sd5VdqbvqaZ9c7DbE32Us,7796
|
|
15
|
+
bs_simulators/cli/configuration.py,sha256=msqdIc_H0_cRkUjZ6bocZ30dNeDdkFDLhoj9JpcboyU,1751
|
|
16
|
+
bs_simulators/cli/execution.py,sha256=Qx_niLxkr9Kc3IKRNMHXY-ArOMbY1QG48qTesT0_3C8,2078
|
|
17
|
+
bs_simulators/cli/presentation.py,sha256=0xVH_EjzQ4MnZYhdPuk6e9NC-5zKd0pDaBEf5_uZqzY,6203
|
|
18
|
+
bs_simulators/comms/__init__.py,sha256=V7ayQF7F1DVqL_re40MtTh2yO8s_5RmP2k9ZuNpKxKI,145
|
|
19
|
+
bs_simulators/comms/adapters.py,sha256=Tgd3ZakRBj9iqis7wxD81mMkTg2Cr7WCSVeaYMaRRTw,2273
|
|
20
|
+
bs_simulators/comms/http.py,sha256=gMo0eVRVm2mQgqasRd5JXXWVM2BT9nGYY8o5nmd3pzw,8808
|
|
21
|
+
bs_simulators/runtime/__init__.py,sha256=9fb2M8LY7l8zYmWOak5fDGth8aOAiy-X3eZnZpTsPhY,351
|
|
22
|
+
bs_simulators/runtime/_validation.py,sha256=_gZrynHLKqmQC2C1PVjAdpob_ooEYDsJAkx0fi5YRTw,2270
|
|
23
|
+
bs_simulators/runtime/core.py,sha256=fDlk4zzifVlXxFDU9PtDXNfHd6RRMFp-YpCZ86U9rlI,23345
|
|
24
|
+
bs_simulators/runtime/protocols.py,sha256=bH7WIpPJREC3YS0ymrPyKWAPUhpcTFjj5RyNAVrbaYw,7216
|
|
25
|
+
bs_simulators/runtime/signals.py,sha256=B0zVhKLjwFnsnyKkQjp6dBQQUXMhVwZX2Z7oO9E7SmA,2086
|
|
26
|
+
bs_simulators/runtime/steppers.py,sha256=0wUHWM-8JWcFdiFkM9Mq4h9Dq7ORI39IBTDIeX5r0Ko,12925
|
|
27
|
+
bs_simulators/viewers/__init__.py,sha256=1X9ihrxitonmiObdAbTu3ju6pj2zIy--hMMuWpuHkNI,380
|
|
28
|
+
bs_simulators/viewers/dc-motor.html,sha256=BsK0Q5o94SJovIVsEWmVSHliv8ECR2NHtfACni63BZU,948
|
|
29
|
+
bs_simulators/viewers/neutralization.html,sha256=3rahh_U8th5dr1Vviy7G_G-pi-Igh60lukzWZqt3m14,985
|
|
30
|
+
bs_simulators/viewers/pendulum.html,sha256=39woym13FFvY851hjmbBaTz40bNFNghx_kPA5XUdXuU,940
|
|
31
|
+
bs_simulators/viewers/scenes.js,sha256=7ngouZdMK6Bz0EdbjQlsapoX4jUpXT7JjnWvI9zU07o,8204
|
|
32
|
+
bs_simulators/viewers/viewer.css,sha256=idNLUrzP0C_-owqV-6DDAB1y7OKXYG9z4HPxfqVSV8k,880
|
|
33
|
+
bs_simulators/viewers/viewer.js,sha256=xHDuEstv2iQnIyikjYGqftWTNv8Goko3e0VhjQoc0Pc,2683
|
|
34
|
+
bs_simulators-0.1.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ggonzm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SUPPRESS Research Group
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|