Skip to main content

02 - Component Metadata Mapping

How CAD components map to ML model input parameters


Overview​

Each component in the Water Treatment Plant 3D model contains metadata representing water quality parameters at that specific stage. When a user selects a component and clicks "Fetch", this metadata populates the input form.


Metadata Structure​

interface ComponentMetadata {
// Component identification
id: string;
tagId: string; // P&ID tag (e.g., "AER-01", "CL-01")
name: string;
type: WTPComponentType;

// Position in 3D space
position: [number, number, number];
rotation: [number, number, number];
scale: [number, number, number];

// Visual properties
color: string;
highlightColor: string;

// Description
description: string;
processDescription: string;

// Associated instruments (from P&ID)
instruments: InstrumentTag[];

// Inlet/Outlet stream IDs
inletStream?: string; // e.g., "S-103"
outletStream?: string; // e.g., "S-104"

// Water quality parameters at this stage
waterQuality: WaterQualityMetadata;

// Operational parameters
operational: OperationalMetadata;
}

interface InstrumentTag {
tagId: string; // e.g., "FIT-101", "AIT-PH-101"
parameter: string; // e.g., "flow_rate", "pH"
description: string; // e.g., "Influent Flow Transmitter"
value?: number; // Current/default value
unit: string; // e.g., "m³/hr", "pH", "mg/L"
}

interface WaterQualityMetadata {
// Common parameters (maps to TreatmentInput)
pH: number;
TSS: number; // mg/L
Turbidity: number; // NTU
BOD: number; // mg/L
COD: number; // mg/L
NH4_N: number; // mg/L
Total_Nitrogen: number; // mg/L
Phosphate: number; // mg/L
Fecal_Coliform: number; // count
Oil_Grease: number; // mg/L
TDS: number; // mg/L
Heavy_Metals: number; // concentration
}

interface OperationalMetadata {
// Maps to WastewaterInput
flow_rate: number; // m³/day
aeration_rate?: number; // kg O₂/hr
chemical_dose?: number; // mg/L
sludge_recycle_rate?: number; // %
retention_time?: number; // hours
temperature?: number; // °C
}

Component-Specific Metadata​

1. Inlet / Raw Water Intake (S-101)​

const inletMetadata: ComponentMetadata = {
id: "inlet",
tagId: "S-101", // Stream tag
name: "Raw Water Inlet",
type: "inlet",
position: [-10, 0, 0],
rotation: [0, 0, 0],
scale: [1, 1, 1],
color: "#8B4513",
highlightColor: "#D2691E",
description: "Raw wastewater entry point",
processDescription: "Untreated wastewater enters the treatment plant here",

// Associated P&ID instruments
instruments: [{ tagId: "FIT-101", parameter: "flow_rate", description: "Influent Flow", value: 1000, unit: "m³/hr" }],

outletStream: "S-101",

waterQuality: {
// Typical raw wastewater values
pH: 6.8,
TSS: 250,
Turbidity: 150,
BOD: 300,
COD: 600,
NH4_N: 35,
Total_Nitrogen: 50,
Phosphate: 12,
Fecal_Coliform: 100000,
Oil_Grease: 50,
TDS: 800,
Heavy_Metals: 1.5,
},

operational: {
flow_rate: 1000,
temperature: 25,
},
};

2. Screening Unit​

const screeningMetadata: ComponentMetadata = {
id: "screening",
name: "Screening Unit",
type: "screening",
position: [-7, 0, 0],
rotation: [0, 0, 0],
scale: [1, 1, 1],
color: "#696969",
highlightColor: "#A9A9A9",
description: "Coarse solids removal",
processDescription: "Removes large debris, rags, and floating materials",

waterQuality: {
// Slightly improved after screening
pH: 6.8,
TSS: 230,
Turbidity: 140,
BOD: 290,
COD: 580,
NH4_N: 35,
Total_Nitrogen: 50,
Phosphate: 12,
Fecal_Coliform: 95000,
Oil_Grease: 45,
TDS: 790,
Heavy_Metals: 1.4,
},

operational: {
flow_rate: 1000,
temperature: 25,
},
};

3. Grit Chamber​

const gritChamberMetadata: ComponentMetadata = {
id: "grit_chamber",
name: "Grit Chamber",
type: "grit_chamber",
position: [-4, 0, 0],
rotation: [0, 0, 0],
scale: [1.5, 1, 1],
color: "#808080",
highlightColor: "#C0C0C0",
description: "Sand and grit removal",
processDescription: "Removes sand, gravel, and heavy inorganic particles",

waterQuality: {
pH: 6.9,
TSS: 200,
Turbidity: 120,
BOD: 280,
COD: 560,
NH4_N: 34,
Total_Nitrogen: 48,
Phosphate: 11,
Fecal_Coliform: 90000,
Oil_Grease: 40,
TDS: 780,
Heavy_Metals: 1.2,
},

operational: {
flow_rate: 1000,
retention_time: 0.5,
temperature: 25,
},
};

4. Primary Clarifier​

const primaryClarifierMetadata: ComponentMetadata = {
id: "primary_clarifier",
name: "Primary Clarifier",
type: "primary_clarifier",
position: [0, 0, 0],
rotation: [0, 0, 0],
scale: [2, 1.5, 2],
color: "#4682B4",
highlightColor: "#87CEEB",
description: "Primary sedimentation tank",
processDescription: "Settles suspended solids through gravity separation",

waterQuality: {
// Significant TSS reduction
pH: 7.0,
TSS: 120,
Turbidity: 80,
BOD: 200,
COD: 400,
NH4_N: 32,
Total_Nitrogen: 45,
Phosphate: 10,
Fecal_Coliform: 70000,
Oil_Grease: 25,
TDS: 750,
Heavy_Metals: 1.0,
},

operational: {
flow_rate: 1000,
retention_time: 2,
sludge_recycle_rate: 0,
temperature: 24,
},
};

5. Aeration Tank​

const aerationTankMetadata: ComponentMetadata = {
id: "aeration_tank",
name: "Aeration Tank",
type: "aeration_tank",
position: [5, 0, 0],
rotation: [0, 0, 0],
scale: [3, 1.5, 2],
color: "#20B2AA",
highlightColor: "#48D1CC",
description: "Biological treatment zone",
processDescription: "Aerobic bacteria break down organic matter",

waterQuality: {
// Major BOD/COD reduction
pH: 7.2,
TSS: 150, // Increases due to biomass
Turbidity: 60,
BOD: 80,
COD: 180,
NH4_N: 15,
Total_Nitrogen: 30,
Phosphate: 6,
Fecal_Coliform: 40000,
Oil_Grease: 10,
TDS: 700,
Heavy_Metals: 0.8,
},

operational: {
flow_rate: 1000,
aeration_rate: 50,
retention_time: 6,
sludge_recycle_rate: 25,
temperature: 22,
},
};

6. Secondary Clarifier​

const secondaryClarifierMetadata: ComponentMetadata = {
id: "secondary_clarifier",
name: "Secondary Clarifier",
type: "secondary_clarifier",
position: [10, 0, 0],
rotation: [0, 0, 0],
scale: [2, 1.5, 2],
color: "#5F9EA0",
highlightColor: "#7FFFD4",
description: "Secondary sedimentation",
processDescription: "Settles biological floc from aeration tank",

waterQuality: {
pH: 7.3,
TSS: 40,
Turbidity: 25,
BOD: 30,
COD: 80,
NH4_N: 10,
Total_Nitrogen: 20,
Phosphate: 4,
Fecal_Coliform: 20000,
Oil_Grease: 5,
TDS: 650,
Heavy_Metals: 0.5,
},

operational: {
flow_rate: 1000,
retention_time: 3,
sludge_recycle_rate: 30,
temperature: 22,
},
};

7. Filtration Unit​

const filtrationMetadata: ComponentMetadata = {
id: "filtration",
name: "Filtration Unit",
type: "filtration",
position: [14, 0, 0],
rotation: [0, 0, 0],
scale: [1.5, 1, 1.5],
color: "#DEB887",
highlightColor: "#F5DEB3",
description: "Tertiary filtration",
processDescription: "Sand/media filtration removes remaining particles",

waterQuality: {
pH: 7.4,
TSS: 10,
Turbidity: 5,
BOD: 15,
COD: 40,
NH4_N: 5,
Total_Nitrogen: 12,
Phosphate: 2,
Fecal_Coliform: 5000,
Oil_Grease: 2,
TDS: 600,
Heavy_Metals: 0.3,
},

operational: {
flow_rate: 1000,
retention_time: 0.5,
temperature: 21,
},
};

8. Disinfection Unit​

const disinfectionMetadata: ComponentMetadata = {
id: "disinfection",
name: "Disinfection Unit",
type: "disinfection",
position: [17, 0, 0],
rotation: [0, 0, 0],
scale: [1, 1, 1],
color: "#FFD700",
highlightColor: "#FFFF00",
description: "Chlorination/UV treatment",
processDescription: "Kills pathogens using chlorine or UV light",

waterQuality: {
pH: 7.5,
TSS: 8,
Turbidity: 3,
BOD: 10,
COD: 30,
NH4_N: 3,
Total_Nitrogen: 10,
Phosphate: 1.5,
Fecal_Coliform: 100,
Oil_Grease: 1,
TDS: 580,
Heavy_Metals: 0.2,
},

operational: {
flow_rate: 1000,
chemical_dose: 5, // Chlorine dose mg/L
retention_time: 0.5,
temperature: 21,
},
};

9. Outlet / Treated Water​

const outletMetadata: ComponentMetadata = {
id: "outlet",
name: "Treated Water Outlet",
type: "outlet",
position: [20, 0, 0],
rotation: [0, 0, 0],
scale: [1, 1, 1],
color: "#00CED1",
highlightColor: "#00FFFF",
description: "Final effluent discharge",
processDescription: "Treated water ready for discharge or reuse",

waterQuality: {
// Final treated water quality
pH: 7.5,
TSS: 5,
Turbidity: 2,
BOD: 8,
COD: 25,
NH4_N: 2,
Total_Nitrogen: 8,
Phosphate: 1,
Fecal_Coliform: 50,
Oil_Grease: 0.5,
TDS: 550,
Heavy_Metals: 0.1,
},

operational: {
flow_rate: 950, // Slightly less due to sludge removal
temperature: 20,
},
};

Metadata to Input Mapping​

Map to TreatmentInput​

function mapToTreatmentInput(metadata: ComponentMetadata): TreatmentInput {
const { waterQuality, operational } = metadata;

return {
pH: waterQuality.pH,
TSS: waterQuality.TSS,
Turbidity: waterQuality.Turbidity,
BOD: waterQuality.BOD,
COD: waterQuality.COD,
NH4_N: waterQuality.NH4_N,
Total_Nitrogen: waterQuality.Total_Nitrogen,
Phosphate: waterQuality.Phosphate,
Fecal_Coliform: waterQuality.Fecal_Coliform,
Oil_Grease: waterQuality.Oil_Grease,
TDS: waterQuality.TDS,
Heavy_Metals: waterQuality.Heavy_Metals,
flow_rate: operational.flow_rate,
};
}

Map to WastewaterInput​

function mapToWastewaterInput(metadata: ComponentMetadata): WastewaterInput {
const { waterQuality, operational } = metadata;

return {
flow_rate: operational.flow_rate,
influent_BOD: waterQuality.BOD,
influent_COD: waterQuality.COD,
influent_TSS: waterQuality.TSS,
influent_pH: waterQuality.pH,
influent_TDS: waterQuality.TDS,
aeration_rate: operational.aeration_rate,
chemical_dose: operational.chemical_dose,
sludge_recycle_rate: operational.sludge_recycle_rate,
retention_time: operational.retention_time,
temperature: operational.temperature,
};
}

Parameter Ranges by Stage​

StageBOD (mg/L)COD (mg/L)TSS (mg/L)pHFecal Coliform
Raw Inlet250-400500-800200-3506.5-780,000-150,000
After Screening240-380480-760180-3206.5-775,000-140,000
After Grit Chamber230-360460-720160-2806.8-770,000-130,000
After Primary150-250300-50080-1507-7.250,000-100,000
After Aeration50-100120-220100-1807-7.530,000-60,000
After Secondary20-5060-12020-607-7.510,000-30,000
After Filtration10-2530-605-207-7.52,000-10,000
After Disinfection5-1520-503-157-7.550-500
Final Outlet5-1015-402-107-7.5less than 100

Dynamic Metadata (Future Enhancement)​

In future versions, metadata could be:

  1. Fetched from IoT sensors in real-time
  2. Simulated based on time of day/season
  3. User-editable for scenario testing
  4. Historical from database records
interface DynamicMetadataSource {
type: "static" | "iot" | "simulated" | "historical";
updateInterval?: number; // ms for real-time updates
dataSource?: string; // API endpoint or sensor ID
}

Next: 03-WTP-MODEL.md​

Learn about the 3D Water Treatment Plant model structure →