This simulator models a veterinary hospital as a Petri net with 32 places and 32 transitions. Instead of discrete event simulation, it uses continuous ODE solving (mass-action kinetics) to predict patient flow, staff utilization, and financial outcomes across a full clinic day.
The model has three categories of places:
dvm_avail, rvt_avail, exam_room_free, surgery_free — tokens represent available staff and roomswait_exam, wait_tech, wait_surgery — tokens accumulate when patients wait for servicein_wellness, in_spay, in_xray — tokens represent patients currently being treatedA patient flows through the net: arrival → wait_* → in_* → checkout → discharged. Surgery patients detour through in_recovery first.
Resource places create bottlenecks naturally. When all DVMs are busy (0 tokens in dvm_avail),
exam transitions cannot fire and the queue grows — exactly what happens in a real clinic.
Each clinical service has a start/finish transition pair:
start_wellness consumes tokens from wait_exam + dvm_avail + exam_room_free, produces a token in in_wellnessfinish_wellness consumes from in_wellness, returns the DVM and exam room, sends patient to checkoutTriage transitions (triage_to_exam, triage_to_tech, etc.) route arriving patients to the correct queue based on the service mix sliders.
patient_arrives is a source transition with no input places. Its rate directly controls how many patients enter the system per hour. After 5:30 PM, this rate drops to zero — no new arrivals, but in-progress procedures finish.
Instead of stepping through individual events, the simulator solves a system of ordinary differential equations:
d[place]/dt = Σ(producing transitions) - Σ(consuming transitions)
flux(transition) = rate × Π([input_place]^weight)
Staff levels change throughout the day (lunch breaks, part-time shifts ending). The simulator splits the day into segments at each staff change, solving each segment independently and stitching the results together. This captures the 12:30 PM lunch dip and afternoon staffing changes accurately.
The financial dashboard is derived directly from the ODE solution:
The gross profit margin emerges from the interplay of service mix, staffing levels, and patient volume — all encoded in the Petri net topology.
The Schedule view introduces a human dimension to the Petri net model:
rvt_avail drops by 1 for the remaining segmentsThis is where Petri nets shine: the same model works for both the simple slider-based staffing and the detailed per-employee schedule. The ODE solver doesn't care where the numbers come from.