diff --git a/lcax.schema.json b/lcax.schema.json index dbb1703..46da91f 100644 --- a/lcax.schema.json +++ b/lcax.schema.json @@ -146,53 +146,31 @@ } }, "BuildingModelScope": { - "type": "object", - "required": [ - "building_services", - "external_works", + "type": "string", + "enum": [ "facilitating_works", - "ff_e", - "finishes", "substructure", - "superstructure_envelope", "superstructure_frame", - "superstructure_internal_elements" - ], - "properties": { - "building_services": { - "type": "boolean" - }, - "external_works": { - "type": "boolean" - }, - "facilitating_works": { - "type": "boolean" - }, - "ff_e": { - "type": "boolean" - }, - "finishes": { - "type": "boolean" - }, - "substructure": { - "type": "boolean" - }, - "superstructure_envelope": { - "type": "boolean" - }, - "superstructure_frame": { - "type": "boolean" - }, - "superstructure_internal_elements": { - "type": "boolean" - } - } + "superstructure_envelope", + "superstructure_internal_elements", + "finishes", + "building_services", + "external_works", + "ff_e" + ] }, "BuildingType": { "type": "string", "enum": [ - "renovation", - "new" + "new_construction_works", + "demolition", + "deconstruction_and_new_construction_works", + "retrofit_works", + "extension_works", + "retrofit_and_extension_works", + "fit_out_works", + "operations", + "other" ] }, "BuildingTypology": { @@ -673,6 +651,7 @@ "LifeCycleStage": { "type": "string", "enum": [ + "a0", "a1a3", "a4", "a5", @@ -683,6 +662,7 @@ "b5", "b6", "b7", + "b8", "c1", "c2", "c3", @@ -765,14 +745,13 @@ ] }, "buildingModelScope": { - "anyOf": [ - { - "$ref": "#/definitions/BuildingModelScope" - }, - { - "type": "null" - } - ] + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/BuildingModelScope" + } }, "buildingPermitYear": { "type": [ @@ -918,9 +897,12 @@ "ProjectPhase": { "type": "string", "enum": [ - "design", - "ongoing", - "built", + "strategic_design", + "concept_design", + "technical_design", + "construction", + "post_completion", + "in_use", "other" ] }, diff --git a/modules/calculation/tests/datafixtures/project.json b/modules/calculation/tests/datafixtures/project.json index b1207df..e8277dd 100644 --- a/modules/calculation/tests/datafixtures/project.json +++ b/modules/calculation/tests/datafixtures/project.json @@ -123,8 +123,8 @@ "results": null, "projectInfo": { "type": "buildingInfo", - "buildingType": "new", - "buildingTypology": "office", + "buildingType": "new_construction_works", + "buildingTypology": ["office"], "certifications": null, "buildingMass": null, "buildingHeight": null, diff --git a/modules/convert/src/lcabyg/parse.rs b/modules/convert/src/lcabyg/parse.rs index 3b6e7e8..fb81429 100644 --- a/modules/convert/src/lcabyg/parse.rs +++ b/modules/convert/src/lcabyg/parse.rs @@ -221,8 +221,8 @@ fn add_building_data(project: &mut LCAxProject, node: &nodes::Building) { project.reference_study_period = Some(node.calculation_timespan as u8); project.project_info = Some(ProjectInfo::BuildingInfo { 0: BuildingInfo { - building_type: BuildingType::NEW, - building_typology: BuildingTypology::from(&node.building_type), + building_type: BuildingType::NEW_CONSTRUCTION_WORKS, + building_typology: vec![BuildingTypology::from(&node.building_type)], certifications: None, building_mass: None, building_height: None, diff --git a/modules/models/src/life_cycle_base.rs b/modules/models/src/life_cycle_base.rs index 518723d..020b7e3 100644 --- a/modules/models/src/life_cycle_base.rs +++ b/modules/models/src/life_cycle_base.rs @@ -10,6 +10,7 @@ use tsify::Tsify; #[serde(rename_all = "lowercase")] #[cfg_attr(feature = "jsbindings", derive(Tsify))] pub enum LifeCycleStage { + A0, A1A3, A4, A5, @@ -20,6 +21,7 @@ pub enum LifeCycleStage { B5, B6, B7, + B8, C1, C2, C3, @@ -30,6 +32,7 @@ pub enum LifeCycleStage { impl fmt::Display for LifeCycleStage { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + LifeCycleStage::A0 => write!(f, "A0"), LifeCycleStage::A1A3 => write!(f, "A1A3"), LifeCycleStage::A4 => write!(f, "A4"), LifeCycleStage::A5 => write!(f, "A5"), @@ -40,6 +43,7 @@ impl fmt::Display for LifeCycleStage { LifeCycleStage::B5 => write!(f, "B5"), LifeCycleStage::B6 => write!(f, "B6"), LifeCycleStage::B7 => write!(f, "B7"), + LifeCycleStage::B8 => write!(f, "B8"), LifeCycleStage::C1 => write!(f, "C1"), LifeCycleStage::C2 => write!(f, "C2"), LifeCycleStage::C3 => write!(f, "C3"), @@ -54,6 +58,7 @@ impl TryFrom<&str> for LifeCycleStage { fn try_from(value: &str) -> Result { match value.to_lowercase().as_str() { + "a0" => Ok(LifeCycleStage::A0), "a1to3" => Ok(LifeCycleStage::A1A3), "a1a3" => Ok(LifeCycleStage::A1A3), "a1-3" => Ok(LifeCycleStage::A1A3), @@ -66,6 +71,7 @@ impl TryFrom<&str> for LifeCycleStage { "b5" => Ok(LifeCycleStage::B5), "b6" => Ok(LifeCycleStage::B6), "b7" => Ok(LifeCycleStage::B7), + "b8" => Ok(LifeCycleStage::B8), "c1" => Ok(LifeCycleStage::C1), "c2" => Ok(LifeCycleStage::C2), "c3" => Ok(LifeCycleStage::C3), diff --git a/modules/models/src/project.rs b/modules/models/src/project.rs index 9b846e9..0515602 100644 --- a/modules/models/src/project.rs +++ b/modules/models/src/project.rs @@ -60,7 +60,7 @@ impl Project { assemblies: HashMap::new(), results: None, project_info: None, - project_phase: ProjectPhase::DESIGN, + project_phase: ProjectPhase::STRATEGIC_DESIGN, software_info: SoftwareInfo { goal_and_scope_definition: None, lca_software: "lcax".to_string(), @@ -84,9 +84,17 @@ pub struct SoftwareInfo { #[serde(rename_all = "lowercase")] #[cfg_attr(feature = "jsbindings", derive(Tsify))] pub enum ProjectPhase { - DESIGN, - ONGOING, - BUILT, + #[allow(non_camel_case_types)] + STRATEGIC_DESIGN, + #[allow(non_camel_case_types)] + CONCEPT_DESIGN, + #[allow(non_camel_case_types)] + TECHNICAL_DESIGN, + CONSTRUCTION, + #[allow(non_camel_case_types)] + POST_COMPLETION, + #[allow(non_camel_case_types)] + IN_USE, #[default] OTHER, } @@ -114,7 +122,7 @@ pub enum ProjectInfo { #[cfg_attr(feature = "jsbindings", derive(Tsify))] pub struct BuildingInfo { pub building_type: BuildingType, - pub building_typology: BuildingTypology, + pub building_typology: Vec, pub certifications: Option>, pub building_mass: Option, pub building_height: Option, @@ -135,7 +143,7 @@ pub struct BuildingInfo { pub general_energy_class: GeneralEnergyClass, pub local_energy_class: Option, pub building_users: Option, - pub building_model_scope: Option, + pub building_model_scope: Option>, } #[derive(Deserialize, Serialize, JsonSchema, Clone)] @@ -188,24 +196,44 @@ impl From<&String> for GeneralEnergyClass { #[derive(Deserialize, Serialize, JsonSchema, Clone)] #[serde(rename_all = "lowercase")] #[cfg_attr(feature = "jsbindings", derive(Tsify))] -pub struct BuildingModelScope { - pub facilitating_works: bool, - pub substructure: bool, - pub superstructure_frame: bool, - pub superstructure_envelope: bool, - pub superstructure_internal_elements: bool, - pub finishes: bool, - pub building_services: bool, - pub external_works: bool, - pub ff_e: bool, +pub enum BuildingModelScope { + #[allow(non_camel_case_types)] + FACILITATING_WORKS, + SUBSTRUCTURE, + #[allow(non_camel_case_types)] + SUPERSTRUCTURE_FRAME, + #[allow(non_camel_case_types)] + SUPERSTRUCTURE_ENVELOPE, + #[allow(non_camel_case_types)] + SUPERSTRUCTURE_INTERNAL_ELEMENTS, + FINISHES, + #[allow(non_camel_case_types)] + BUILDING_SERVICES, + #[allow(non_camel_case_types)] + EXTERNAL_WORKS, + #[allow(non_camel_case_types)] + FF_E, } #[derive(Deserialize, Serialize, JsonSchema, Clone)] #[serde(rename_all = "lowercase")] #[cfg_attr(feature = "jsbindings", derive(Tsify))] pub enum BuildingType { - RENOVATION, - NEW, + #[allow(non_camel_case_types)] + NEW_CONSTRUCTION_WORKS, + DEMOLITION, + #[allow(non_camel_case_types)] + DECONSTRUCTION_AND_NEW_CONSTRUCTION_WORKS, + #[allow(non_camel_case_types)] + RETROFIT_WORKS, + #[allow(non_camel_case_types)] + EXTENSION_WORKS, + #[allow(non_camel_case_types)] + RETROFIT_AND_EXTENSION_WORKS, + #[allow(non_camel_case_types)] + FIT_OUT_WORKS, + OPERATIONS, + OTHER, } #[derive(Deserialize, Serialize, JsonSchema, Clone)] @@ -219,7 +247,6 @@ pub enum BuildingTypology { INDUSTRIAL, INFRASTRUCTURE, AGRICULTURAL, - MIXEDUSE, OTHER, } @@ -233,7 +260,6 @@ impl From<&String> for BuildingTypology { "industrial" => BuildingTypology::INDUSTRIAL, "infrastructure" => BuildingTypology::INFRASTRUCTURE, "agricultural" => BuildingTypology::AGRICULTURAL, - "mixeduse" => BuildingTypology::MIXEDUSE, _ => BuildingTypology::OTHER, } } diff --git a/packages/python/src/lcax/lcax.abi3.so b/packages/python/src/lcax/lcax.abi3.so index 0c9cc77..0b2f659 100755 Binary files a/packages/python/src/lcax/lcax.abi3.so and b/packages/python/src/lcax/lcax.abi3.so differ diff --git a/packages/python/src/lcax/pydantic.py b/packages/python/src/lcax/pydantic.py index 5ca040f..651ed79 100644 --- a/packages/python/src/lcax/pydantic.py +++ b/packages/python/src/lcax/pydantic.py @@ -7,27 +7,33 @@ from enum import Enum from typing import Any, Dict, List, Optional, Union -from pydantic import BaseModel, ConfigDict, Field, RootModel +from pydantic import BaseModel, ConfigDict, Field -class BuildingModelScope(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - building_services: bool - external_works: bool - facilitating_works: bool - ff_e: bool - finishes: bool - substructure: bool - superstructure_envelope: bool - superstructure_frame: bool - superstructure_internal_elements: bool +class BuildingModelScope(Enum): + FACILITATING_WORKS = 'facilitating_works' + SUBSTRUCTURE = 'substructure' + SUPERSTRUCTURE_FRAME = 'superstructure_frame' + SUPERSTRUCTURE_ENVELOPE = 'superstructure_envelope' + SUPERSTRUCTURE_INTERNAL_ELEMENTS = 'superstructure_internal_elements' + FINISHES = 'finishes' + BUILDING_SERVICES = 'building_services' + EXTERNAL_WORKS = 'external_works' + FF_E = 'ff_e' class BuildingType(Enum): - RENOVATION = 'renovation' - NEW = 'new' + NEW_CONSTRUCTION_WORKS = 'new_construction_works' + DEMOLITION = 'demolition' + DECONSTRUCTION_AND_NEW_CONSTRUCTION_WORKS = ( + 'deconstruction_and_new_construction_works' + ) + RETROFIT_WORKS = 'retrofit_works' + EXTENSION_WORKS = 'extension_works' + RETROFIT_AND_EXTENSION_WORKS = 'retrofit_and_extension_works' + FIT_OUT_WORKS = 'fit_out_works' + OPERATIONS = 'operations' + OTHER = 'other' class BuildingTypology(Enum): @@ -353,6 +359,7 @@ class ImpactCategoryKey(Enum): class LifeCycleStage(Enum): + A0 = 'a0' A1A3 = 'a1a3' A4 = 'a4' A5 = 'a5' @@ -363,6 +370,7 @@ class LifeCycleStage(Enum): B5 = 'b5' B6 = 'b6' B7 = 'b7' + B8 = 'b8' C1 = 'c1' C2 = 'c2' C3 = 'c3' @@ -395,9 +403,12 @@ class ProjectInfo2(BaseModel): class ProjectPhase(Enum): - DESIGN = 'design' - ONGOING = 'ongoing' - BUILT = 'built' + STRATEGIC_DESIGN = 'strategic_design' + CONCEPT_DESIGN = 'concept_design' + TECHNICAL_DESIGN = 'technical_design' + CONSTRUCTION = 'construction' + POST_COMPLETION = 'post_completion' + IN_USE = 'in_use' OTHER = 'other' @@ -574,7 +585,7 @@ class ProjectInfo1(BaseModel): building_footprint: Optional[ValueUnit] = Field(None, alias='buildingFootprint') building_height: Optional[ValueUnit] = Field(None, alias='buildingHeight') building_mass: Optional[ValueUnit] = Field(None, alias='buildingMass') - building_model_scope: Optional[BuildingModelScope] = Field( + building_model_scope: Optional[List[BuildingModelScope]] = Field( None, alias='buildingModelScope' ) building_permit_year: Optional[int] = Field(None, alias='buildingPermitYear', ge=0)