Skip to main content
Loading navigation
Back to prompt library

Build a Desalination Multi-Train Chemical Pre-Treatment Dosing and Energy Balancer — implementation

Linked challenge: Build a Desalination Multi-Train Chemical Pre-Treatment Dosing and Energy Balancer

Prompt source

implementation75 lines11 sectionsNo variables1 code block
## Build
Evaluate coagulant and antiscalant consumption across seawater reverse osmosis pre-treatment trains. Compare operational dosing regimes against power consumption to formulate cost-effective treatment schedules.

## User
Water Treatment Process Chemist

## Workflow
1. Ingest raw seawater intake telemetry including turbidity, temperature, and total dissolved solids.
2. Model pre-treatment chemical consumption and high-pressure reverse osmosis flux using WaterTAP principles.
3. Calculate chemical dosage costs alongside hourly grid electrical tariff rates.
4. Synthesize operational setpoint recommendations for plant chemical dosing controllers.

## Interface
Multi-train process dashboard displaying intake water quality trends, dosing setpoints, and unit production cost charts.

## Data
Utilize WaterTAP RO flowsheet example parameters parameterized with seasonal Arabian Gulf seawater salinity profiles.
Starter examples below are synthetic. They are not downloaded records.

## Source
[WaterTAP treatment modeling](https://raw.githubusercontent.com/watertap-org/watertap/main/README.md)
Implements WaterTAP unit model relationships for reverse osmosis pressure drops and pre-treatment chemical consumption scaling.

## Tools
ray-serve, watertap, numpy.
Ray Serve efficiently distributes concurrent parameter evaluation across multiple parallel desalination treatment trains.
Local or hosted LLM with strong technical explanation and chemical process parameter formatting.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Parses intake water quality parameters and maps them to membrane fouling indices.
- Computes optimal antiscalant dosage (mg/L) using WaterTAP scaling equations.
- Determines total operating expense per cubic meter including electrical and chemical costs.
- Outputs an operator-ready dosing schedule with high-turbidity alarm flags.

## Starter Examples
```json
[
  {
    "input": {
      "train_id": "TRAIN-B",
      "intake_turbidity_ntu": 4.8,
      "intake_tds_ppm": 42000,
      "intake_temp_c": 31,
      "permeate_flow_m3h": 400,
      "antiscalant_unit_cost_usd_kg": 3.2,
      "electricity_cost_usd_kwh": 0.08
    },
    "expected_output": {
      "recommended_setpoints": {
        "antiscalant_dose_ppm": 2.4,
        "coagulant_dose_ppm": 1.1,
        "feed_pressure_bar": 64.2,
        "chemical_cost_per_m3_usd": 0.011,
        "total_unit_cost_usd_m3": 0.385
      },
      "membrane_scaling_risk": "NOMINAL",
      "requires_chemist_signoff": true
    }
  },
  {
    "input": {
      "train_id": "TRAIN-C",
      "intake_turbidity_ntu": 25,
      "intake_tds_ppm": 42000,
      "intake_temp_c": 31,
      "permeate_flow_m3h": 400,
      "antiscalant_unit_cost_usd_kg": 3.2,
      "electricity_cost_usd_kwh": 0.08
    },
    "expected_output": {
      "recommended_setpoints": {},
      "alarm": "HIGH_TURBIDITY_EXCEEDS_DAF_CAPACITY",
      "membrane_scaling_risk": "CRITICAL",
      "requires_chemist_signoff": true
    }
  }
]
```

## Safety
Simulation and recommendation only; chemical metering pumps remain governed by hard-coded safety PLCs.
Use mock external writes. Require human review before any real deployment.