{
    "$id": "https://timdegroot.codeberg.page/GKMC/schemas/input.schema.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "GKMC input",
    "type": "object",
    "required": [
        "simulationId",
        "iterations",
        "energy_eV",
        "max_time_s",
        "seed",
        "output_file",
        "molecule",
        "rates"
    ],
    "properties": {
        "simulationId": {
            "type": "string",
            "description": "Name of the simulation."
        },
        "iterations": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of Monte Carlo iterations to simulate."
        },
        "energy_eV": {
            "type": "number",
            "minimum": 0,
            "description": "Initial internal energy of the molecule in eV."
        },
        "max_time_s": {
            "type": "number",
            "minimum": 0,
            "description": "Maximum simulation time per Monte Carlo iteration in seconds."
        },
        "seed": {
            "type": "integer",
            "minimum": 0,
            "description": "Base-seed passed to the Xoshiro pseudorandom number generator, plus the iteration number."
        },
        "output_file": {
            "type": "string",
            "description": "Path to the JSON simulation output file."
        },
        "molecule": {
            "type": "string",
            "description": "Path to the GraphML molecule file."
        },
        "rates": {
            "type": "array",
            "items": {
                "type": "object",
                "required": [
                    "type",
                    "isotope",
                    "ratefile"
                ],
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": [
                            "scramble",
                            "dissociate"
                        ]
                    },
                    "isotope": {
                        "type": "string",
                        "enum": [
                            "H",
                            "D"
                        ]
                    },
                    "pairs": {
                        "type": "array",
                        "items": {
                            "type": "array",
                            "prefixItems": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "string"
                                }
                            ],
                            "minItems": 2,
                            "maxItems": 2
                        }
                    },
                    "sites": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "ratefile": {
                        "type": "string",
                        "pattern": "^[^\\0]+\\.json$",
                        "description": "Path to an external rate-file JSON document."
                    }
                },
                "allOf": [
                    {
                        "if": {
                            "properties": {
                                "type": {
                                    "const": "scramble"
                                }
                            }
                        },
                        "then": {
                            "required": [
                                "pairs"
                            ],
                            "not": {
                                "required": [
                                    "sites"
                                ]
                            }
                        }
                    },
                    {
                        "if": {
                            "properties": {
                                "type": {
                                    "const": "dissociate"
                                }
                            }
                        },
                        "then": {
                            "required": [
                                "sites"
                            ],
                            "not": {
                                "required": [
                                    "pairs"
                                ]
                            }
                        }
                    }
                ],
                "additionalProperties": false
            }
        }
    },
    "additionalProperties": false
}