507  Digital Twin Worked Examples

507.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Design replication strategies for digital twin state consistency across edge, fog, and cloud layers
  • Implement failover and state recovery protocols for twin platforms during outages
  • Apply digital twin optimization to manufacturing quality control with ROI calculations
  • Configure building energy management twins with predictive control strategies
  • Calculate financial impact and payback periods for twin deployments

507.2 Introduction

This chapter provides four comprehensive worked examples demonstrating digital twin design and implementation across different domains. Each example includes detailed calculations, architectural decisions, and financial analysis that you can adapt to your own projects.

507.3 Worked Example 1: Replication Factor Design for State Consistency

NoteScenario: Wind Farm Digital Twin

A wind farm operator deploys digital twins for 100 turbines. Each twin maintains real-time state (power output, vibration, temperature) that must be consistent across edge, fog, and cloud layers. The system must survive single-node failures while minimizing sync latency and storage costs.

Given:

  • 100 wind turbines, each with 50 sensors reporting every second
  • Twin state per turbine: 2 KB (50 sensors x 40 bytes per reading)
  • Total cluster state: 200 KB updated every second
  • Deployment: 3 edge gateways (at turbine clusters), 2 fog servers (on-site), 1 cloud region
  • Availability target: 99.99% (52 minutes downtime/year max)
  • Latency requirement: P95 < 500ms for state queries from any tier

507.3.1 Step 1: Calculate Base Storage Requirements

  • Real-time state: 100 turbines x 2 KB = 200 KB
  • Historical state (7 days): 200 KB x 86,400 seconds x 7 days = 120.96 GB
  • With replication factor 3: 362.88 GB total storage
  • With replication factor 2: 241.92 GB total storage

507.3.2 Step 2: Design Replication Topology

Layer          Replicas    Latency to Query    Failure Impact
-------------------------------------------------------------
Edge (3 nodes)    1        5-10 ms             33% turbines offline
Fog (2 nodes)     2        20-50 ms            None (redundant)
Cloud (1 region)  3        100-300 ms          None (3-way replication)
  • Edge: Each gateway holds only its local turbines (no replication at edge - cost/power)
  • Fog: Both fog servers replicate all 100 turbine states (synchronous write)
  • Cloud: 3-way replication within region (standard cloud durability)

507.3.3 Step 3: Calculate Replication Sync Traffic

  • Edge to Fog: 200 KB/s (raw telemetry, no replication overhead)
  • Fog to Fog (sync): 200 KB/s x 2 (both fog nodes sync state)
  • Fog to Cloud: 200 KB/s (single stream, cloud handles internal replication)
  • Total WAN traffic: 200 KB/s = 17.28 GB/day to cloud

507.3.4 Step 4: Analyze Failure Scenarios and Availability

Failure Duration Impact Availability Impact
1 edge gateway 4 hours (replace) 33 turbines lose <10ms queries, fog still available 99.95% for affected turbines
1 fog server 1 hour (failover) Zero impact (peer has full replica) 100%
Both fog servers 30 min (unlikely) Edge operates autonomously, cloud queries available 99.9%
Cloud region 4 hours (rare) Fog/edge operate normally, no historical queries 99.95%

Combined availability: 99.99% (single fog failure is transparent due to replication)

507.3.5 Step 5: Optimize Replication Factor by Data Type

Data Type Replication Factor Rationale Storage Cost
Real-time state 2 (fog) + 3 (cloud) Query from any tier 10x raw
Hourly aggregates 3 (cloud only) Historical analysis 3x raw
Raw telemetry 1 (cloud cold storage) Audit/compliance 1x raw

Effective replication factor: 2.5 average (weighted by access frequency)

507.3.6 Result

Replication factor of 2 at fog layer plus 3 at cloud layer achieves 99.99% availability with P95 query latency of 50ms (fog) or 300ms (cloud). Total storage: 362 GB including 7-day history. Annual storage cost: ~$8/year (cloud) + $200 (fog SSDs one-time).

Key Insight: Replication factor should vary by tier and data type. Real-time state needs low-latency local replicas (fog), while historical data only needs durable cloud storage. The key tradeoff is sync latency vs. consistency: synchronous fog-to-fog replication adds 5-10ms but ensures both fog nodes have identical state. For digital twins, this latency is acceptable since control decisions happen at edge (not waiting for fog consensus).

507.4 Worked Example 2: Failover and State Recovery Protocol

NoteScenario: Smart Building Fire Event During Gateway Outage

A smart buildingโ€™s digital twin platform experiences a fog gateway crash during a fire alarm event. The system must recover twin state, replay missed events, and ensure the fire suppression system receives correct commands despite the failure.

Given:

  • 1 building with 500 rooms, each room has a digital twin
  • Fog gateway: Primary failed at 14:32:15, backup activated at 14:32:45 (30-second gap)
  • Event during gap: Fire alarm triggered in Room 312 at 14:32:22
  • Sensors affected: Smoke detector, temperature sensor, sprinkler actuator
  • Edge devices: Continued operating autonomously during fog outage
  • Cloud: Received partial telemetry (some packets lost during transition)
  • Recovery requirement: Reconstruct complete event timeline, verify correct sprinkler activation

507.4.1 Step 1: Timeline Reconstruction

14:32:15.000 - Primary fog gateway crashes (hardware failure)
14:32:15.100 - Edge devices detect fog unavailable (heartbeat timeout)
14:32:15.200 - Edge devices switch to autonomous mode (local safety rules)
14:32:22.450 - Room 312 smoke detector triggers (edge handles locally)
14:32:22.500 - Edge activates sprinkler (local safety rule, no fog needed)
14:32:22.600 - Edge attempts to notify fog (fails, buffers event)
14:32:30.000 - Backup fog detects primary failure (15-second heartbeat timeout)
14:32:30.500 - Backup fog broadcasts takeover announcement
14:32:45.000 - Backup fog fully operational, accepts edge connections
14:32:45.100 - Edge devices reconnect, upload buffered events
14:32:45.500 - Twin state for Room 312 updated with fire event

507.4.2 Step 2: Quantify Data Loss During 30-Second Gap

  • Telemetry rate: 500 rooms x 5 sensors x 1 reading/second = 2,500 readings/second
  • Lost readings: 2,500 x 30 seconds = 75,000 readings
  • Buffered at edge: Each edge device buffers 30 seconds locally = 100% recoverable
  • Lost to cloud: Depends on edge-to-cloud direct path (not implemented in this architecture)

507.4.3 Step 3: Design State Recovery Protocol

Phase 1: Event Replay (Priority: Safety-Critical)

  • Edge devices upload buffered safety events first (fire, intrusion, medical)
  • Room 312 fire event: Smoke detection, sprinkler activation, temperature spike
  • Fog reconstructs twin state for Room 312 including fire event
  • Time: 2-5 seconds for safety events

Phase 2: Telemetry Backfill (Priority: Operational)

  • Edge devices upload buffered routine telemetry (temperature, occupancy)
  • Fog requests missing data from any edge device that has it
  • Cloud notified of gap period for analytics adjustment
  • Time: 30-60 seconds for full backfill

Phase 3: Consistency Verification

  • Fog compares twin state vs. physical state (query edge sensors)
  • Identify any discrepancies (e.g., sprinkler still active?)
  • Generate incident report for building management
  • Time: 5-10 seconds

507.4.4 Step 4: Verify Correct Safety Response Despite Failure

Check Expected Actual Status
Smoke detected 14:32:22 14:32:22.450 PASS
Sprinkler activated Within 10s of smoke 14:32:22.500 (50ms) PASS
Fog notified Within 60s 14:32:45.500 (23s delay) PASS
Twin state accurate Fire active in Room 312 Confirmed PASS
No data loss All events captured 100% via edge buffer PASS

507.4.5 Step 5: Calculate Recovery Completeness

  • Safety events recovered: 100% (1 fire event, correctly logged)
  • Routine telemetry recovered: 100% (75,000 readings from edge buffers)
  • Twin state consistency: 100% (verified against physical sensors)
  • Total recovery time: 45 seconds (30s failover + 15s backfill)

507.4.6 Result

Despite 30-second fog gateway outage during active fire event, the system achieved zero data loss through edge-local buffering. Safety response (sprinkler activation) completed in 50ms using edge-local rules, independent of fog availability. Twin state fully reconstructed within 15 seconds of backup fog activation.

Key Insight: Digital twin failover must account for events that occur during the transition period. The key design principle is โ€œedge-first safetyโ€ - safety-critical decisions (sprinkler activation) execute locally at the edge without waiting for fog confirmation. Fog provides coordination and state management, but edge devices must operate autonomously for safety functions. The 30-second buffer at edge devices ensures no telemetry is lost even during prolonged failover, allowing complete twin state reconstruction post-recovery.

507.5 Worked Example 3: Injection Molding Quality Optimization

NoteScenario: Automotive Component Manufacturing

A plastic injection molding facility produces automotive interior components with tight tolerance requirements. The plant manager wants to use digital twins to reduce defect rates and optimize cycle times across 12 molding machines.

Given:

  • Machine count: 12 injection molding presses (150-500 ton)
  • Production rate: 45 parts/hour per machine (540 total parts/hour)
  • Current defect rate: 3.2% (17.3 defective parts/hour)
  • Defect types: Short shots (42%), sink marks (31%), warpage (18%), flash (9%)
  • Critical parameters monitored: Melt temp, mold temp, injection pressure, hold pressure, cooling time
  • Cycle time: 80 seconds (target: 72 seconds for 10% throughput gain)
  • Material cost per part: $4.20
  • Revenue per good part: $18.50
  • Downtime cost: $1,200/hour per machine

507.5.1 Step 1: Design the Digital Twin Architecture

Component Physical Digital Twin Replica
Machine state PLC registers Real-time state model (1-second sync)
Process parameters 47 sensors per press Parameter history + statistical bounds
Part geometry Physical dimensions CAE simulation model (Moldflow)
Material properties Actual resin batch Material database + batch tracking
Quality outcomes CMM measurements Predicted dimensions + defect probability

507.5.2 Step 2: Instrument for Twin Synchronization

Sensor Category Count per Machine Total Fleet Update Rate
Temperature (melt, mold zones) 8 96 100 ms
Pressure (injection, cavity) 4 48 10 ms
Position/velocity (screw) 2 24 10 ms
Cooling water flow 4 48 1 s
Part presence/cycle count 2 24 Per cycle
Total sensors 20 240

507.5.3 Step 3: Build Physics-Based Simulation Model

The digital twin combines physics models with machine learning:

Model Component Input Output Accuracy
Filling simulation Melt temp, injection velocity Fill time, short shot risk 94% correlation
Packing simulation Hold pressure, hold time Sink mark probability 87% correlation
Cooling simulation Mold temp, cooling time Warpage risk, cycle time 91% correlation
ML correction Residuals from physics models Calibration factors +4% accuracy

507.5.4 Step 4: Implement Closed-Loop Optimization

  • Twin predicts defect probability before each shot based on current parameters
  • If short shot risk >15%: Twin recommends +5C melt temp or +3% injection velocity
  • If sink mark risk >20%: Twin recommends +50 bar hold pressure or +0.5s hold time
  • Operator approves or twin auto-adjusts (configurable autonomy level)

507.5.5 Step 5: Measure Improvement After 90-Day Deployment

Metric Before After Improvement
Overall defect rate 3.2% 0.9% -72%
Short shots 42% of defects 18% of defects -57% (absolute)
Sink marks 31% of defects 12% of defects -61% (absolute)
Warpage 18% of defects 8% of defects -56% (absolute)
Cycle time 80 seconds 74 seconds -7.5%
Machine utilization 82% 89% +7%

507.5.6 Step 6: Calculate Financial Impact

Category Calculation Annual Impact
Defect reduction (3.2% - 0.9%) x 540 parts/hr x 5,200 hrs x $4.20 $293,328 saved
Throughput increase (80-74)/80 x 540 x 5,200 x $18.50 x (1-0.009) $489,762 revenue
Reduced downtime 15% fewer parameter-related stops $187,200 saved
Total annual benefit $970,290
Twin system cost Hardware: $340K, Software: $180K, Integration: $120K $640,000 one-time
Annual platform fee $95,000
Payback period 8.2 months

507.5.7 Result

The digital twin deployment reduced defect rates from 3.2% to 0.9% (-72%) and cycle time from 80 to 74 seconds (-7.5%), generating $970,290 in annual benefits against a $640,000 investment. Payback period: 8.2 months. The physics-based simulation model, calibrated with ML correction factors, predicts defect probability with 91% accuracy, enabling proactive parameter adjustment before defects occur.

Key Insight: The twinโ€™s value comes from prediction, not just monitoring. Traditional quality control detects defects after they occur (reactive). The digital twin predicts defect probability before each shot and recommends parameter adjustments to prevent defects (proactive). The 91% prediction accuracy means 9 out of 10 potential defects are prevented by parameter adjustment rather than detected by inspection.

507.6 Worked Example 4: Building Energy Optimization

NoteScenario: Commercial Office Tower in Singapore

A 45-story commercial office building in Singapore wants to reduce HVAC energy consumption using a digital twin while maintaining occupant comfort. The building has high cooling loads due to tropical climate and variable occupancy.

Given:

  • Building: 45 floors, 85,000 m2 gross floor area
  • HVAC system: Central chiller plant (4 x 1,200 RT chillers) + VAV air handling
  • Current energy consumption: 22.5 GWh/year (electricity)
  • HVAC portion: 58% of total = 13.05 GWh/year
  • Energy cost: $0.18/kWh = $2.35M/year for HVAC
  • Occupancy: 6,500 peak occupants, average 72% occupancy
  • Comfort standard: 23-25C, 50-65% RH
  • Current complaints: 340/year (too cold or too hot)

507.6.1 Step 1: Create Building Digital Twin with Zone-Level Granularity

Component Physical Asset Twin Representation
HVAC zones 890 VAV boxes 890 zone models with thermal mass
Chillers 4 x 1,200 RT Thermodynamic performance curves
AHUs 12 air handling units Psychrometric models
Envelope Curtain wall facade Solar heat gain model (hourly)
Occupancy Badge access + Wi-Fi Probabilistic occupancy prediction
Weather Local forecast 48-hour forecast integration

507.6.2 Step 2: Deploy IoT Sensors for Twin Synchronization

Sensor Type Quantity Purpose Update Rate
Zone temperature 890 Actual vs. setpoint 1 min
Zone CO2 445 (50% of zones) Occupancy proxy 5 min
AHU supply/return temps 24 System performance 30 sec
Chiller power meters 4 Efficiency tracking 1 min
Weather station 1 Outdoor conditions 5 min
Occupancy counters 45 (lobby + floors) Headcount 5 min
Total 1,409

507.6.3 Step 3: Implement Predictive Control Strategies

Strategy Twin Capability Savings Mechanism
Pre-cooling Predict high-demand hours from weather + occupancy Shift load to off-peak rates
Demand-based ventilation Predict zone occupancy 2 hours ahead Reduce outside air when zones empty
Chiller sequencing Optimize which chillers run at what load Keep chillers at peak efficiency (0.55 kW/RT)
Setpoint optimization Balance comfort against energy per zone Widen deadband in unoccupied zones
Fault detection Compare actual vs. model-predicted performance Identify stuck dampers, fouled coils

507.6.4 Step 4: Calculate Energy Savings by Strategy

Strategy Baseline Load Reduction Annual Savings
Pre-cooling (demand shift) 13.05 GWh 4% (peak shaving) $18,900 (rate differential)
Demand-based ventilation 2.61 GWh (OA heating/cooling) 18% $84,600
Optimal chiller sequencing 10.44 GWh (chiller load) 8% $150,300
Setpoint optimization 13.05 GWh 6% $141,000
Fault detection N/A 3% of total $70,500
Total energy savings 22.3% $465,300/year

507.6.5 Step 5: Measure Comfort Improvement

Metric Before After Change
Comfort complaints 340/year 85/year -75%
Mean zone temp deviation 1.8C from setpoint 0.6C from setpoint -67%
Occupant satisfaction score 3.2/5.0 4.1/5.0 +28%
Zones with chronic issues 47 8 -83%

Why comfort improved with less energy: The twin identifies zones that are overcooled (wasting energy AND causing complaints) and undercooled zones (causing complaints). Before the twin, operators ran the system conservatively cold to minimize complaints, wasting energy. The twin enables zone-by-zone optimization.

507.6.6 Step 6: Calculate ROI

Category Value
Annual energy savings $465,300
Reduced maintenance (fault detection) $85,000
Productivity gain (fewer complaints) $42,000 (estimated)
Total annual benefit $592,300
Digital twin platform $180,000/year
IoT sensor installation $420,000 one-time
Integration and commissioning $280,000 one-time
Net annual savings $412,300
Payback on capital 1.7 years

507.6.7 Result

The building digital twin reduced HVAC energy consumption by 22.3% (2.91 GWh/year), saving $465,300 annually while simultaneously improving occupant comfort (complaints reduced 75%). Net annual savings after platform fees: $412,300. The twinโ€™s predictive capabilities enable optimization strategies impossible with reactive control, such as pre-cooling based on weather forecasts and setpoint adjustment based on predicted occupancy.

Key Insight: The twin achieves both energy savings AND comfort improvement by eliminating the traditional tradeoff. Without zone-level visibility, operators run systems conservatively (overcooling to avoid complaints), which wastes energy while still missing problem zones. The twin provides granular visibility that enables precision control: cool occupied zones to comfort while allowing unoccupied zones to float, rather than cooling the entire building to the most demanding zoneโ€™s requirements.

507.7 Summary

In this chapter, you learned through four comprehensive worked examples:

  • Replication Factor Design: Tiered replication (factor 2 at fog, factor 3 at cloud) achieves 99.99% availability while controlling storage costs through data-type-specific strategies
  • Failover and State Recovery: Edge-first safety principles ensure critical functions operate during gateway outages; 30-second edge buffers enable complete state recovery
  • Manufacturing Quality Optimization: Physics-based simulation with ML calibration predicts defects before they occur, achieving 72% defect reduction with 8.2-month payback
  • Building Energy Management: Zone-level twin visibility eliminates the energy-comfort tradeoff, achieving 22% energy savings AND 75% fewer complaints with 1.7-year payback

507.8 Whatโ€™s Next

Now that you have detailed implementation patterns and ROI calculations, the final chapter provides hands-on practice through comprehensive quizzes and a complete lab where you build a working digital twin system.

Continue to: Assessment and Hands-On Lab

Related chapters: