
# **********************************************************************
# This file has been auto-generated by a code generation tool.
# Version:   4.2.0
# Date/time: 22 Nov 2024 12:56:21
# Template:  templates/pythonpws/entityschemas.razor.
# **********************************************************************

# ================================================================================
# Python PWS entity schemas.
# ================================================================================

import uuid
from marshmallow import Schema, fields, pre_load, post_load, EXCLUDE
from marshmallow_enum import EnumField

from .enums import *
from .entities import *


# ================================================================================
# Class:        LocalPositionSchema
# Description:  Position with reference to some arbitrary local origin and axes.
# ================================================================================
class LocalPositionSchema(Schema):
    """LocalPositionSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    x = fields.Float(data_key="x")
    y = fields.Float(data_key="y")
    z = fields.Float(data_key="z")

    @post_load
    def make_local_position(self, data, **kwargs):
        """Post-processing of the LocalPositionSchema class."""

        return LocalPosition(**data)

# ================================================================================
# Class:        AssetSchema
# Description:  Any equipment to be modeled, vessels, pipelines
# ================================================================================
class AssetSchema(Schema):
    """AssetSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    location = fields.Nested(LocalPositionSchema, data_key="location")

    @post_load
    def make_asset(self, data, **kwargs):
        """Post-processing of the AssetSchema class."""

        return Asset(**data)

# ================================================================================
# Class:        MaterialComponentSchema
# Description:  Constituent component of a material.
# ================================================================================
class MaterialComponentSchema(Schema):
    """MaterialComponentSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    name = fields.Str(data_key="name")
    mole_fraction = fields.Float(data_key="moleFraction")

    @post_load
    def make_material_component(self, data, **kwargs):
        """Post-processing of the MaterialComponentSchema class."""

        return MaterialComponent(**data)

# ================================================================================
# Class:        MaterialSchema
# Description:  The material to use in calculations.
# ================================================================================
class MaterialSchema(Schema):
    """MaterialSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    name = fields.Str(data_key="name")
    component_count = fields.Int(data_key="componentCount")
    components = fields.Nested(MaterialComponentSchema, allow_none=True, many=True, data_key="components")
    property_template = fields.Enum(PropertyTemplate, by_value=True, data_key="propertyTemplate")

    @post_load
    def make_material(self, data, **kwargs):
        """Post-processing of the MaterialSchema class."""

        return Material(**data)

# ================================================================================
# Class:        StateSchema
# Description:  Description of the fluid state.
# ================================================================================
class StateSchema(Schema):
    """StateSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    pressure = fields.Float(data_key="pressure")
    temperature = fields.Float(data_key="temperature")
    liquid_fraction = fields.Float(data_key="liquidFraction")
    flash_flag = fields.Enum(FluidSpec, by_value=True, data_key="flashFlag")
    mixture_modelling = fields.Enum(MixtureModelling, by_value=True, data_key="mixtureModelling")

    @post_load
    def make_state(self, data, **kwargs):
        """Post-processing of the StateSchema class."""

        return State(**data)

# ================================================================================
# Class:        AtmosphericStorageTankSchema
# Description:  An atmospheric storage tank asset to model events that involve releases from unpressurised containment.
# ================================================================================
class AtmosphericStorageTankSchema(Schema):
    """AtmosphericStorageTankSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    state = fields.Nested(StateSchema, data_key="state")
    diameter = fields.Float(data_key="diameter")
    height = fields.Float(data_key="height")
    material = fields.Nested(MaterialSchema, data_key="material")
    liquid_fill_fraction_by_volume = fields.Float(data_key="liquidFillFractionByVolume")
    location = fields.Nested(LocalPositionSchema, data_key="location")

    @post_load
    def make_atmospheric_storage_tank(self, data, **kwargs):
        """Post-processing of the AtmosphericStorageTankSchema class."""

        return AtmosphericStorageTank(**data)

# ================================================================================
# Class:        BundSchema
# Description:  A bund entity used in the modelling of pool spreading and vaporisation.
# ================================================================================
class BundSchema(Schema):
    """BundSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    bund_height = fields.Float(data_key="bundHeight")
    bund_diameter = fields.Float(data_key="bundDiameter")
    specify_bund = fields.Boolean(data_key="specifyBund")

    @post_load
    def make_bund(self, data, **kwargs):
        """Post-processing of the BundSchema class."""

        return Bund(**data)

# ================================================================================
# Class:        ScenarioSchema
# Description:  Base struct/class for all scenario types.
# ================================================================================
class ScenarioSchema(Schema):
    """ScenarioSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields


    @post_load
    def make_scenario(self, data, **kwargs):
        """Post-processing of the ScenarioSchema class."""

        return Scenario(**data)

# ================================================================================
# Class:        InstantaneousSchema
# Description:  Base struct/class for instantaneous release scenarios.
# ================================================================================
class InstantaneousSchema(Schema):
    """InstantaneousSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields


    @post_load
    def make_instantaneous(self, data, **kwargs):
        """Post-processing of the InstantaneousSchema class."""

        return Instantaneous(**data)

# ================================================================================
# Class:        CatastrophicRuptureSchema
# Description:  An instanaeous release of the entire inventory of an associated vessel, intended to model an incident in which the vessel is destroyed by an impact, a crack, or some other failure which propagates very quickly.
# ================================================================================
class CatastrophicRuptureSchema(Schema):
    """CatastrophicRuptureSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields


    @post_load
    def make_catastrophic_rupture(self, data, **kwargs):
        """Post-processing of the CatastrophicRuptureSchema class."""

        return CatastrophicRupture(**data)

# ================================================================================
# Class:        ConcentrationRecordSchema
# Description:  A record containing the cloud concentration at a specified x, y, z position.
# ================================================================================
class ConcentrationRecordSchema(Schema):
    """ConcentrationRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    concentration = fields.Float(data_key="concentration")
    position = fields.Nested(LocalPositionSchema, data_key="position")

    @post_load
    def make_concentration_record(self, data, **kwargs):
        """Post-processing of the ConcentrationRecordSchema class."""

        return ConcentrationRecord(**data)

# ================================================================================
# Class:        ConstantMaterialResultSchema
# Description:  Constant material properties, i.e. critical pressure, temperature, molecular weight
# ================================================================================
class ConstantMaterialResultSchema(Schema):
    """ConstantMaterialResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    critical_pressure = fields.Float(data_key="criticalPressure")
    critical_temperature = fields.Float(data_key="criticalTemperature")
    total_molecular_weight = fields.Float(data_key="totalMolecularWeight")

    @post_load
    def make_constant_material_result(self, data, **kwargs):
        """Post-processing of the ConstantMaterialResultSchema class."""

        return ConstantMaterialResult(**data)

# ================================================================================
# Class:        DischargeParametersSchema
# Description:  A set of parameters used in discharge calculations.
# ================================================================================
class DischargeParametersSchema(Schema):
    """DischargeParametersSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    flash_at_orifice = fields.Enum(FlashAtOrifice, by_value=True, data_key="flashAtOrifice")

    @post_load
    def make_discharge_parameters(self, data, **kwargs):
        """Post-processing of the DischargeParametersSchema class."""

        return DischargeParameters(**data)

# ================================================================================
# Class:        DischargeRecordSchema
# Description:  A record containing discharge results at a given time.
# ================================================================================
class DischargeRecordSchema(Schema):
    """DischargeRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    time = fields.Float(data_key="time")
    mass_flow = fields.Float(data_key="massFlow")
    final_state = fields.Nested(StateSchema, data_key="finalState")
    final_velocity = fields.Float(data_key="finalVelocity")
    orifice_state = fields.Nested(StateSchema, data_key="orificeState")
    orifice_velocity = fields.Float(data_key="orificeVelocity")
    storage_state = fields.Nested(StateSchema, data_key="storageState")
    droplet_diameter = fields.Float(data_key="dropletDiameter")
    expanded_diameter = fields.Float(data_key="expandedDiameter")

    @post_load
    def make_discharge_record(self, data, **kwargs):
        """Post-processing of the DischargeRecordSchema class."""

        return DischargeRecord(**data)

# ================================================================================
# Class:        DischargeResultSchema
# Description:  A set of discharge results that do not vary with time.
# ================================================================================
class DischargeResultSchema(Schema):
    """DischargeResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    expansion_energy = fields.Float(data_key="expansionEnergy")
    release_mass = fields.Float(data_key="releaseMass")
    height = fields.Float(data_key="height")
    angle = fields.Float(data_key="angle")
    release_type = fields.Enum(DynamicType, by_value=True, data_key="releaseType")
    hole_diameter = fields.Float(data_key="holeDiameter")
    pre_dilution_air_rate = fields.Float(data_key="preDilutionAirRate")

    @post_load
    def make_discharge_result(self, data, **kwargs):
        """Post-processing of the DischargeResultSchema class."""

        return DischargeResult(**data)

# ================================================================================
# Class:        DispersionOutputConfigSchema
# Description:  Dispersion plotting and reporting parameters.
# ================================================================================
class DispersionOutputConfigSchema(Schema):
    """DispersionOutputConfigSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    downwind_distance = fields.Float(data_key="downwindDistance")
    time = fields.Float(data_key="time")
    resolution = fields.Enum(Resolution, by_value=True, data_key="resolution")
    elevation = fields.Float(data_key="elevation")
    special_concentration = fields.Enum(SpecialConcentration, by_value=True, data_key="specialConcentration")
    concentration = fields.Float(data_key="concentration")
    crosswind_distance = fields.Float(data_key="crosswindDistance")
    contour_type = fields.Enum(ContourType, by_value=True, data_key="contourType")
    lfl_fraction_value = fields.Float(data_key="lflFractionValue")
    component_to_track_index = fields.Int(data_key="componentToTrackIndex")
    component_to_track_name = fields.Str(data_key="componentToTrackName")

    @post_load
    def make_dispersion_output_config(self, data, **kwargs):
        """Post-processing of the DispersionOutputConfigSchema class."""

        return DispersionOutputConfig(**data)

# ================================================================================
# Class:        DispersionParametersSchema
# Description:  A set of parameters used in dispersion calculations.
# ================================================================================
class DispersionParametersSchema(Schema):
    """DispersionParametersSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    relative_tolerance = fields.Float(data_key="relativeTolerance")
    rainout_thermo_flag = fields.Enum(RainoutThermoFlag, by_value=True, data_key="rainoutThermoFlag")
    fixed_step_size = fields.Float(data_key="fixedStepSize")
    output_step_multiplier = fields.Float(data_key="outputStepMultiplier")
    max_dispersion_distance = fields.Float(data_key="maxDispersionDistance")
    max_dispersion_height = fields.Float(data_key="maxDispersionHeight")
    number_of_release_observers = fields.Int(data_key="numberOfReleaseObservers")
    number_of_pool_observers = fields.Int(data_key="numberOfPoolObservers")
    averaging_time = fields.Float(data_key="averagingTime")
    lfl_fraction_to_stop = fields.Float(data_key="lflFractionToStop")

    @post_load
    def make_dispersion_parameters(self, data, **kwargs):
        """Post-processing of the DispersionParametersSchema class."""

        return DispersionParameters(**data)

# ================================================================================
# Class:        DispersionRecordSchema
# Description:  A record containing observer dispersion results at a given time.
# ================================================================================
class DispersionRecordSchema(Schema):
    """DispersionRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    observer_index = fields.Int(data_key="observerIndex")
    centreline_concentration = fields.Float(data_key="centrelineConcentration")
    downwind_distance = fields.Float(data_key="downwindDistance")
    time = fields.Float(data_key="time")
    centreline_concentration_uncorrected = fields.Float(data_key="centrelineConcentrationUncorrected")
    crosswind_radius = fields.Float(data_key="crosswindRadius")
    vertical_radius = fields.Float(data_key="verticalRadius")
    crosswind_exponent = fields.Float(data_key="crosswindExponent")
    vertical_exponent = fields.Float(data_key="verticalExponent")
    theta = fields.Float(data_key="theta")
    centreline_height = fields.Float(data_key="centrelineHeight")
    liquid_fraction = fields.Float(data_key="liquidFraction")
    vapour_temperature = fields.Float(data_key="vapourTemperature")
    mass_conc = fields.Float(data_key="massConc")
    velocity = fields.Float(data_key="velocity")
    mass_flow = fields.Float(data_key="massFlow")
    inst_con = fields.Enum(DynamicType, by_value=True, data_key="instCon")
    profile_flag = fields.Int(data_key="profileFlag")
    elev_flag = fields.Int(data_key="elevFlag")
    rho_cloud = fields.Float(data_key="rhoCloud")
    liq_temp = fields.Float(data_key="liqTemp")
    effective_width = fields.Float(data_key="effectiveWidth")
    effective_height = fields.Float(data_key="effectiveHeight")
    pass_tran_dist = fields.Float(data_key="passTranDist")
    downwind_radius = fields.Float(data_key="downwindRadius")
    droplet_diameter = fields.Float(data_key="dropletDiameter")
    droplet_height = fields.Float(data_key="dropletHeight")
    droplet_distance = fields.Float(data_key="dropletDistance")
    mass = fields.Float(data_key="mass")

    @post_load
    def make_dispersion_record(self, data, **kwargs):
        """Post-processing of the DispersionRecordSchema class."""

        return DispersionRecord(**data)

# ================================================================================
# Class:        ExplosionConfinedVolumeSchema
# Description:  Confined explosion volume data.
# ================================================================================
class ExplosionConfinedVolumeSchema(Schema):
    """ExplosionConfinedVolumeSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    confined_strength = fields.Float(data_key="confinedStrength")
    confined_volume = fields.Float(data_key="confinedVolume")

    @post_load
    def make_explosion_confined_volume(self, data, **kwargs):
        """Post-processing of the ExplosionConfinedVolumeSchema class."""

        return ExplosionConfinedVolume(**data)

# ================================================================================
# Class:        ExplosionOutputConfigSchema
# Description:  Explosion plotting and reporting parameters.
# ================================================================================
class ExplosionOutputConfigSchema(Schema):
    """ExplosionOutputConfigSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    overpressure_level = fields.Float(data_key="overpressureLevel")
    me_confined_method = fields.Enum(MEConfinedMethod, by_value=True, data_key="mEConfinedMethod")

    @post_load
    def make_explosion_output_config(self, data, **kwargs):
        """Post-processing of the ExplosionOutputConfigSchema class."""

        return ExplosionOutputConfig(**data)

# ================================================================================
# Class:        ExplosionOverpressureResultSchema
# Description:  Worst case explosion summary results for a given overpressure.
# ================================================================================
class ExplosionOverpressureResultSchema(Schema):
    """ExplosionOverpressureResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    overpressure = fields.Float(data_key="overpressure")
    explosion_centre = fields.Float(data_key="explosionCentre")
    maximum_distance = fields.Float(data_key="maximumDistance")
    exploded_mass = fields.Float(data_key="explodedMass")
    ignition_time = fields.Float(data_key="ignitionTime")
    radius = fields.Float(data_key="radius")

    @post_load
    def make_explosion_overpressure_result(self, data, **kwargs):
        """Post-processing of the ExplosionOverpressureResultSchema class."""

        return ExplosionOverpressureResult(**data)

# ================================================================================
# Class:        ExplosionParametersSchema
# Description:  A set of parameters used in explosion calculations.
# ================================================================================
class ExplosionParametersSchema(Schema):
    """ExplosionParametersSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    explosion_uniform_strength = fields.Float(data_key="explosionUniformStrength")

    @post_load
    def make_explosion_parameters(self, data, **kwargs):
        """Post-processing of the ExplosionParametersSchema class."""

        return ExplosionParameters(**data)

# ================================================================================
# Class:        FlameRecordSchema
# Description:  A record containing flame geometry data.
# ================================================================================
class FlameRecordSchema(Schema):
    """FlameRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    x_coordinate = fields.Float(data_key="xCoordinate")
    z_coordinate = fields.Float(data_key="zCoordinate")
    r_coordinate = fields.Float(data_key="rCoordinate")
    phi_coordinate = fields.Float(data_key="phiCoordinate")

    @post_load
    def make_flame_record(self, data, **kwargs):
        """Post-processing of the FlameRecordSchema class."""

        return FlameRecord(**data)

# ================================================================================
# Class:        FlameResultSchema
# Description:  A set of flame results.
# ================================================================================
class FlameResultSchema(Schema):
    """FlameResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    time = fields.Float(data_key="time")
    surface_emissive_power = fields.Float(data_key="surfaceEmissivePower")
    fire_type = fields.Enum(FireType, by_value=True, data_key="fireType")
    flame_length = fields.Float(data_key="flameLength")
    flame_diameter = fields.Float(data_key="flameDiameter")

    @post_load
    def make_flame_result(self, data, **kwargs):
        """Post-processing of the FlameResultSchema class."""

        return FlameResult(**data)

# ================================================================================
# Class:        TransectSchema
# Description:  A line segment, along which results are provided.
# ================================================================================
class TransectSchema(Schema):
    """TransectSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    transect_start_point = fields.Nested(LocalPositionSchema, data_key="transectStartPoint")
    transect_end_point = fields.Nested(LocalPositionSchema, data_key="transectEndPoint")

    @post_load
    def make_transect(self, data, **kwargs):
        """Post-processing of the TransectSchema class."""

        return Transect(**data)

# ================================================================================
# Class:        FlammableOutputConfigSchema
# Description:  Fire and radiation plotting and reporting parameters.
# ================================================================================
class FlammableOutputConfigSchema(Schema):
    """FlammableOutputConfigSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    position = fields.Nested(LocalPositionSchema, data_key="position")
    radiation_type = fields.Enum(RadiationType, by_value=True, data_key="radiationType")
    contour_type = fields.Enum(ContourType, by_value=True, data_key="contourType")
    radiation_level = fields.Float(data_key="radiationLevel")
    radiation_resolution = fields.Enum(Resolution, by_value=True, data_key="radiationResolution")
    transect = fields.Nested(TransectSchema, data_key="transect")
    fixed_orientation = fields.Int(data_key="fixedOrientation")
    orientation = fields.Float(data_key="orientation")
    fixed_inclination = fields.Int(data_key="fixedInclination")
    inclination = fields.Float(data_key="inclination")

    @post_load
    def make_flammable_output_config(self, data, **kwargs):
        """Post-processing of the FlammableOutputConfigSchema class."""

        return FlammableOutputConfig(**data)

# ================================================================================
# Class:        FlammableParametersSchema
# Description:  A set of parameters used in fire and radiation calculations.
# ================================================================================
class FlammableParametersSchema(Schema):
    """FlammableParametersSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    max_exposure_duration = fields.Float(data_key="maxExposureDuration")
    radiation_relative_tolerance = fields.Float(data_key="radiationRelativeTolerance")
    pool_fire_type = fields.Enum(PoolFireType, by_value=True, data_key="poolFireType")
    jet_fire_auto_select = fields.Boolean(data_key="jetFireAutoSelect")
    time_averaging = fields.Boolean(data_key="timeAveraging")
    time_of_interest = fields.Float(data_key="timeOfInterest")

    @post_load
    def make_flammable_parameters(self, data, **kwargs):
        """Post-processing of the FlammableParametersSchema class."""

        return FlammableParameters(**data)

# ================================================================================
# Class:        FlashResultSchema
# Description:  Physical properties for a material generated at a particular pressure and temperature.
# ================================================================================
class FlashResultSchema(Schema):
    """FlashResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    pressure = fields.Float(data_key="pressure")
    temperature = fields.Float(data_key="temperature")
    liquid_mole_fraction = fields.Float(data_key="liquidMoleFraction")
    liquid_density = fields.Float(data_key="liquidDensity")
    vapour_density = fields.Float(data_key="vapourDensity")
    liquid_entropy = fields.Float(data_key="liquidEntropy")
    vapour_entropy = fields.Float(data_key="vapourEntropy")
    liquid_enthalpy = fields.Float(data_key="liquidEnthalpy")
    vapour_enthalpy = fields.Float(data_key="vapourEnthalpy")
    fluid_phase = fields.Enum(Phase, by_value=True, data_key="fluidPhase")
    bubble_point_pressure = fields.Float(data_key="bubblePointPressure")
    bubble_point_temperature = fields.Float(data_key="bubblePointTemperature")
    dew_point_pressure = fields.Float(data_key="dewPointPressure")
    dew_point_temperature = fields.Float(data_key="dewPointTemperature")
    total_fluid_density = fields.Float(data_key="totalFluidDensity")
    liquid_mass_fraction = fields.Float(data_key="liquidMassFraction")

    @post_load
    def make_flash_result(self, data, **kwargs):
        """Post-processing of the FlashResultSchema class."""

        return FlashResult(**data)

# ================================================================================
# Class:        ReleaseOverTimeSchema
# Description:  Scenario representing a release over time.
# ================================================================================
class ReleaseOverTimeSchema(Schema):
    """ReleaseOverTimeSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    release_angle = fields.Float(data_key="releaseAngle")
    time_varying_option = fields.Enum(TimeVaryingOption, by_value=True, data_key="timeVaryingOption")
    release_angle_from_mde = fields.Float(data_key="releaseAngleFromMDE")

    @post_load
    def make_release_over_time(self, data, **kwargs):
        """Post-processing of the ReleaseOverTimeSchema class."""

        return ReleaseOverTime(**data)

# ================================================================================
# Class:        LeakSchema
# Description:  A storage scenario which models a release of material through a hole in a vessel or pipe.
# ================================================================================
class LeakSchema(Schema):
    """LeakSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    hole_diameter = fields.Float(data_key="holeDiameter")
    hole_height_fraction = fields.Float(data_key="holeHeightFraction")
    release_elevation = fields.Float(data_key="releaseElevation")
    release_angle = fields.Float(data_key="releaseAngle")
    time_varying_option = fields.Enum(TimeVaryingOption, by_value=True, data_key="timeVaryingOption")
    release_angle_from_mde = fields.Float(data_key="releaseAngleFromMDE")

    @post_load
    def make_leak(self, data, **kwargs):
        """Post-processing of the LeakSchema class."""

        return Leak(**data)

# ================================================================================
# Class:        LineRuptureSchema
# Description:  A storage scenario which models a release of material due to rupture of a short length of pipework attached to a vessel or any kind of pressure reservoir.
# ================================================================================
class LineRuptureSchema(Schema):
    """LineRuptureSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    pipe_diameter = fields.Float(data_key="pipeDiameter")
    pipe_length = fields.Float(data_key="pipeLength")
    pipe_roughness = fields.Float(data_key="pipeRoughness")
    pipe_height_fraction = fields.Float(data_key="pipeHeightFraction")
    release_angle = fields.Float(data_key="releaseAngle")
    time_varying_option = fields.Enum(TimeVaryingOption, by_value=True, data_key="timeVaryingOption")
    release_angle_from_mde = fields.Float(data_key="releaseAngleFromMDE")

    @post_load
    def make_line_rupture(self, data, **kwargs):
        """Post-processing of the LineRuptureSchema class."""

        return LineRupture(**data)

# ================================================================================
# Class:        MaterialComponentDataItemSchema
# Description:  Material component data item.
# ================================================================================
class MaterialComponentDataItemSchema(Schema):
    """MaterialComponentDataItemSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    description = fields.Str(data_key="description")
    equation_number = fields.Int(data_key="equationNumber")
    equation_string = fields.Str(data_key="equationString")
    equation_coefficients = fields.List(fields.Float, allow_none=True, many=True, data_key="equationCoefficients")
    calculation_limits = fields.List(fields.Float, allow_none=True, many=True, data_key="calculationLimits")
    supercritical_extrapolation = fields.Float(data_key="supercriticalExtrapolation")
    fraction_tc = fields.Float(data_key="fractionTc")

    @post_load
    def make_material_component_data_item(self, data, **kwargs):
        """Post-processing of the MaterialComponentDataItemSchema class."""

        return MaterialComponentDataItem(**data)

# ================================================================================
# Class:        MaterialComponentDataSchema
# Description:  Data related to a MaterialComponent.
# ================================================================================
class MaterialComponentDataSchema(Schema):
    """MaterialComponentDataSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    name = fields.Str(data_key="name")
    dippr_version = fields.Int(data_key="dipprVersion")
    cas_id = fields.Int(data_key="casId")
    data_item = fields.Nested(MaterialComponentDataItemSchema, allow_none=True, many=True, data_key="dataItem")
    non_standard = fields.Boolean(data_key="nonStandard")

    @post_load
    def make_material_component_data(self, data, **kwargs):
        """Post-processing of the MaterialComponentDataSchema class."""

        return MaterialComponentData(**data)

# ================================================================================
# Class:        MixtureConstantPropertiesResultSchema
# Description:  Constant properties of a mixture.
# ================================================================================
class MixtureConstantPropertiesResultSchema(Schema):
    """MixtureConstantPropertiesResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    lower_flammability_limit = fields.Float(data_key="lowerFlammabilityLimit")
    upper_flammability_limit = fields.Float(data_key="upperFlammabilityLimit")
    critical_pressure = fields.Float(data_key="criticalPressure")
    critical_temperature = fields.Float(data_key="criticalTemperature")
    flammable_toxic_flag = fields.Enum(FlammableToxic, by_value=True, data_key="flammableToxicFlag")
    flash_point = fields.Float(data_key="flashPoint")
    heat_combustion = fields.Float(data_key="heatCombustion")
    maximum_burn_rate = fields.Float(data_key="maximumBurnRate")
    maximum_sep = fields.Float(data_key="maximumSEP")
    molecular_weight = fields.Float(data_key="molecularWeight")
    bubble_point = fields.Float(data_key="bubblePoint")
    pool_fire_burn_rate_length = fields.Float(data_key="poolFireBurnRateLength")
    luminous_smoky_flame = fields.Enum(LuminousSmokyFlame, by_value=True, data_key="luminousSmokyFlame")
    dew_point = fields.Float(data_key="dewPoint")
    emissive_power_length_scale = fields.Float(data_key="emissivePowerLengthScale")
    laminar_burning_velocity = fields.Float(data_key="laminarBurningVelocity")

    @post_load
    def make_mixture_constant_properties_result(self, data, **kwargs):
        """Post-processing of the MixtureConstantPropertiesResultSchema class."""

        return MixtureConstantPropertiesResult(**data)

# ================================================================================
# Class:        PipeSchema
# Description:  An asset to model events that involve releases from pressurised pipelines.
# ================================================================================
class PipeSchema(Schema):
    """PipeSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    nodes = fields.Nested(LocalPositionSchema, allow_none=True, many=True, data_key="nodes")
    node_count = fields.Int(data_key="nodeCount")
    diameter = fields.Float(data_key="diameter")
    roughness = fields.Float(data_key="roughness")
    material = fields.Nested(MaterialSchema, data_key="material")
    state = fields.Nested(StateSchema, data_key="state")
    pumped_inflow = fields.Float(data_key="pumpedInflow")
    location = fields.Nested(LocalPositionSchema, data_key="location")

    @post_load
    def make_pipe(self, data, **kwargs):
        """Post-processing of the PipeSchema class."""

        return Pipe(**data)

# ================================================================================
# Class:        PipeBreachSchema
# Description:  A storage scenario which models a time-dependent release of material from its process or transport conditions in a pipeline.
# ================================================================================
class PipeBreachSchema(Schema):
    """PipeBreachSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    distance_downstream = fields.Float(data_key="distanceDownstream")
    relative_aperture = fields.Float(data_key="relativeAperture")
    release_angle = fields.Float(data_key="releaseAngle")
    time_varying_option = fields.Enum(TimeVaryingOption, by_value=True, data_key="timeVaryingOption")
    release_angle_from_mde = fields.Float(data_key="releaseAngleFromMDE")

    @post_load
    def make_pipe_breach(self, data, **kwargs):
        """Post-processing of the PipeBreachSchema class."""

        return PipeBreach(**data)

# ================================================================================
# Class:        PoolFireFlameResultSchema
# Description:  Flame results for a pool fire.
# ================================================================================
class PoolFireFlameResultSchema(Schema):
    """PoolFireFlameResultSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    pool_zone_sep = fields.List(fields.Float, allow_none=True, many=True, data_key="poolZoneSEP")
    time = fields.Float(data_key="time")
    surface_emissive_power = fields.Float(data_key="surfaceEmissivePower")
    fire_type = fields.Enum(FireType, by_value=True, data_key="fireType")
    flame_length = fields.Float(data_key="flameLength")
    flame_diameter = fields.Float(data_key="flameDiameter")

    @post_load
    def make_pool_fire_flame_result(self, data, **kwargs):
        """Post-processing of the PoolFireFlameResultSchema class."""

        return PoolFireFlameResult(**data)

# ================================================================================
# Class:        PoolRecordSchema
# Description:  A record containing pool results at a given time.
# ================================================================================
class PoolRecordSchema(Schema):
    """PoolRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    time = fields.Float(data_key="time")
    mass_spilt = fields.Float(data_key="massSpilt")
    mass_vaporised = fields.Float(data_key="massVaporised")
    mass_dissolved = fields.Float(data_key="massDissolved")
    mass_remaining = fields.Float(data_key="massRemaining")
    vapourisation_rate = fields.Float(data_key="vapourisationRate")
    solution_rate = fields.Float(data_key="solutionRate")
    effective_radius = fields.Float(data_key="effectiveRadius")
    depth = fields.Float(data_key="depth")
    temperature = fields.Float(data_key="temperature")
    spill_rate = fields.Float(data_key="spillRate")
    actual_radius = fields.Float(data_key="actualRadius")
    pool_centre = fields.Float(data_key="poolCentre")

    @post_load
    def make_pool_record(self, data, **kwargs):
        """Post-processing of the PoolRecordSchema class."""

        return PoolRecord(**data)

# ================================================================================
# Class:        PoolVapourisationParametersSchema
# Description:  Pool vapourisation parameters
# ================================================================================
class PoolVapourisationParametersSchema(Schema):
    """PoolVapourisationParametersSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    toxics_cutoff_rate = fields.Float(data_key="toxicsCutoffRate")
    flammable_cutoff_rate = fields.Float(data_key="flammableCutoffRate")
    relative_tolerance = fields.Float(data_key="relativeTolerance")

    @post_load
    def make_pool_vapourisation_parameters(self, data, **kwargs):
        """Post-processing of the PoolVapourisationParametersSchema class."""

        return PoolVapourisationParameters(**data)

# ================================================================================
# Class:        RadiationRecordSchema
# Description:  A record of the radiation type and level at a specific point (x,y,z).
# ================================================================================
class RadiationRecordSchema(Schema):
    """RadiationRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    position = fields.Nested(LocalPositionSchema, data_key="position")
    radiation_type = fields.Enum(RadiationType, by_value=True, data_key="radiationType")
    radiation_result = fields.Float(data_key="radiationResult")

    @post_load
    def make_radiation_record(self, data, **kwargs):
        """Post-processing of the RadiationRecordSchema class."""

        return RadiationRecord(**data)

# ================================================================================
# Class:        ReliefValveSchema
# Description:  A storage scenario which models a release of material from the vapour side of a vessel due to the lifting of a relief valve.
# ================================================================================
class ReliefValveSchema(Schema):
    """ReliefValveSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    relief_valve_constriction_diameter = fields.Float(data_key="reliefValveConstrictionDiameter")
    pipe_diameter = fields.Float(data_key="pipeDiameter")
    pipe_length = fields.Float(data_key="pipeLength")
    pipe_roughness = fields.Float(data_key="pipeRoughness")
    pipe_height_fraction = fields.Float(data_key="pipeHeightFraction")
    release_angle = fields.Float(data_key="releaseAngle")
    time_varying_option = fields.Enum(TimeVaryingOption, by_value=True, data_key="timeVaryingOption")
    release_angle_from_mde = fields.Float(data_key="releaseAngleFromMDE")

    @post_load
    def make_relief_valve(self, data, **kwargs):
        """Post-processing of the ReliefValveSchema class."""

        return ReliefValve(**data)

# ================================================================================
# Class:        ScalarUdmOutputsSchema
# Description:  Scalar UDM output values required for post processing dispersion results.
# ================================================================================
class ScalarUdmOutputsSchema(Schema):
    """ScalarUdmOutputsSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    observer_count = fields.Int(data_key="observerCount")
    record_count = fields.Int(data_key="recordCount")
    cloud_type = fields.Enum(DynamicType, by_value=True, data_key="cloudType")
    minimum_concentration = fields.Float(data_key="minimumConcentration")
    wind_power = fields.Float(data_key="windPower")
    friction_velocity = fields.Float(data_key="frictionVelocity")
    dispersion_release_duration = fields.Float(data_key="dispersionReleaseDuration")

    @post_load
    def make_scalar_udm_outputs(self, data, **kwargs):
        """Post-processing of the ScalarUdmOutputsSchema class."""

        return ScalarUdmOutputs(**data)

# ================================================================================
# Class:        ShortPipeRuptureSchema
# Description:  Short pipe rupture scenario
# ================================================================================
class ShortPipeRuptureSchema(Schema):
    """ShortPipeRuptureSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    pipe_length = fields.Float(data_key="pipeLength")
    pipe_diameter = fields.Float(data_key="pipeDiameter")
    pipe_roughness = fields.Float(data_key="pipeRoughness")
    pipe_height_fraction = fields.Float(data_key="pipeHeightFraction")
    release_angle = fields.Float(data_key="releaseAngle")
    time_varying_option = fields.Enum(TimeVaryingOption, by_value=True, data_key="timeVaryingOption")
    release_angle_from_mde = fields.Float(data_key="releaseAngleFromMDE")

    @post_load
    def make_short_pipe_rupture(self, data, **kwargs):
        """Post-processing of the ShortPipeRuptureSchema class."""

        return ShortPipeRupture(**data)

# ================================================================================
# Class:        StructureSchema
# Description:  A building or process plant structure.
# ================================================================================
class StructureSchema(Schema):
    """StructureSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    explosion_confined_volume = fields.Nested(ExplosionConfinedVolumeSchema, data_key="explosionConfinedVolume")
    location = fields.Nested(LocalPositionSchema, data_key="location")

    @post_load
    def make_structure(self, data, **kwargs):
        """Post-processing of the StructureSchema class."""

        return Structure(**data)

# ================================================================================
# Class:        SubstrateSchema
# Description:  The ground over which a release is taking place.
# ================================================================================
class SubstrateSchema(Schema):
    """SubstrateSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    surface_roughness = fields.Float(data_key="surfaceRoughness")
    surface_type = fields.Enum(SurfaceType, by_value=True, data_key="surfaceType")
    pool_surface_type = fields.Enum(PoolSurfaceType, by_value=True, data_key="poolSurfaceType")
    bund = fields.Nested(BundSchema, data_key="bund")

    @post_load
    def make_substrate(self, data, **kwargs):
        """Post-processing of the SubstrateSchema class."""

        return Substrate(**data)

# ================================================================================
# Class:        ToxicRecordSchema
# Description:  A record of the toxic result type and level at a specific point (x,y,z).
# ================================================================================
class ToxicRecordSchema(Schema):
    """ToxicRecordSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    position = fields.Nested(LocalPositionSchema, data_key="position")
    toxic_result_type = fields.Enum(ToxicResultType, by_value=True, data_key="toxicResultType")
    toxic_result = fields.Float(data_key="toxicResult")

    @post_load
    def make_toxic_record(self, data, **kwargs):
        """Post-processing of the ToxicRecordSchema class."""

        return ToxicRecord(**data)

# ================================================================================
# Class:        VesselSchema
# Description:  A pressue vessel asset to represent pressurised containment.
# ================================================================================
class VesselSchema(Schema):
    """VesselSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    state = fields.Nested(StateSchema, data_key="state")
    diameter = fields.Float(data_key="diameter")
    height = fields.Float(data_key="height")
    length = fields.Float(data_key="length")
    width = fields.Float(data_key="width")
    shape = fields.Enum(VesselShape, by_value=True, data_key="shape")
    material = fields.Nested(MaterialSchema, data_key="material")
    vessel_conditions = fields.Enum(VesselConditions, by_value=True, data_key="vesselConditions")
    liquid_fill_fraction_by_volume = fields.Float(data_key="liquidFillFractionByVolume")
    location = fields.Nested(LocalPositionSchema, data_key="location")

    @post_load
    def make_vessel(self, data, **kwargs):
        """Post-processing of the VesselSchema class."""

        return Vessel(**data)

# ================================================================================
# Class:        VesselLeakMaxFlammableCloudResultsSchema
# Description:  Results for a linked run of vessel leak followed by dispersion and views from the cloud.
# ================================================================================
class VesselLeakMaxFlammableCloudResultsSchema(Schema):
    """VesselLeakMaxFlammableCloudResultsSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    discharge_rate = fields.Float(data_key="dischargeRate")
    expanded_temperature = fields.Float(data_key="expandedTemperature")
    phase = fields.Enum(Phase, by_value=True, data_key="phase")
    lfl_extent = fields.Float(data_key="lflExtent")
    lfl_area = fields.Float(data_key="lflArea")
    lfl_height = fields.Float(data_key="lflHeight")

    @post_load
    def make_vessel_leak_max_flammable_cloud_results(self, data, **kwargs):
        """Post-processing of the VesselLeakMaxFlammableCloudResultsSchema class."""

        return VesselLeakMaxFlammableCloudResults(**data)

# ================================================================================
# Class:        VesselSphereSchema
# Description:  A spherical pressue vessel asset to represent pressurised containment.
# ================================================================================
class VesselSphereSchema(Schema):
    """VesselSphereSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    state = fields.Nested(StateSchema, data_key="state")
    material = fields.Nested(MaterialSchema, data_key="material")
    mass_inventory = fields.Float(data_key="massInventory")
    location = fields.Nested(LocalPositionSchema, data_key="location")

    @post_load
    def make_vessel_sphere(self, data, **kwargs):
        """Post-processing of the VesselSphereSchema class."""

        return VesselSphere(**data)

# ================================================================================
# Class:        WeatherSchema
# Description:  A set of weather conditions for use in the modelling of a release and its effects.
# ================================================================================
class WeatherSchema(Schema):
    """WeatherSchema used by marshmallow in json serialization/deserialization"""

    class Meta:
        unknown = EXCLUDE  # Exclude unknown fields

    wind_speed = fields.Float(data_key="windSpeed")
    stability_class = fields.Enum(AtmosphericStabilityClass, by_value=True, data_key="stabilityClass")
    temperature = fields.Float(data_key="temperature")
    relative_humidity = fields.Float(data_key="relativeHumidity")
    mixing_layer_height = fields.Float(data_key="mixingLayerHeight")
    solar_radiation = fields.Float(data_key="solarRadiation")

    @post_load
    def make_weather(self, data, **kwargs):
        """Post-processing of the WeatherSchema class."""

        return Weather(**data)