Skip to content

Commit

Permalink
add initial fast solver implementation 🤞
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Jul 12, 2023
1 parent 69f179e commit 6032b89
Show file tree
Hide file tree
Showing 9 changed files with 863 additions and 68 deletions.
142 changes: 142 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
clap = { version = "4.3.10", features = ["derive"] }
csv = "1.2.2"
itertools = "0.11.0"
nalgebra = "0.32.3"
rstest = "0.17.0"
serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.100"
Expand Down
105 changes: 105 additions & 0 deletions src/core/space_heat_demand/building_element.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
use crate::input::{BuildingElement, MassDistributionClass};

pub fn area_for_building_element_input(element: &BuildingElement) -> f64 {
match element {
&BuildingElement::Opaque { area: a, .. } => a,
&BuildingElement::Transparent { area: a, .. } => match a {
Some(a) => a,
None => 0.0, // just to give some nominal value
},
&BuildingElement::Ground { area: a, .. } => a,
&BuildingElement::AdjacentZTC { area: a, .. } => a,
&BuildingElement::AdjacentZTUSimple { area: a, .. } => a,
}
}

/// Calculate the number of nodes for a building element
/// (this is a shortcut to properly implementing building elements!)
pub fn number_of_building_element_nodes(element: &BuildingElement) -> u32 {
let k_pli = match element {
&BuildingElement::Opaque {
mass_distribution_class: ref dist_class,
ref k_m,
..
} => match dist_class {
MassDistributionClass::I => vec![0.0, 0.0, 0.0, 0.0, *k_m],
MassDistributionClass::E => vec![*k_m, 0.0, 0.0, 0.0, 0.0],
MassDistributionClass::IE => {
let k_ie = k_m / 2.0;
vec![k_ie, 0.0, 0.0, 0.0, k_ie]
}
MassDistributionClass::D => {
let k_inner = *k_m / 4.0;
let k_outer = *k_m / 8.0;
vec![k_outer, k_inner, k_inner, k_inner, k_outer]
}
MassDistributionClass::M => vec![0.0, 0.0, *k_m, 0.0, 0.0],
},
&BuildingElement::AdjacentZTC {
mass_distribution_class: ref dist_class,
ref k_m,
..
} => match dist_class {
MassDistributionClass::I => vec![0.0, 0.0, 0.0, 0.0, *k_m],
MassDistributionClass::E => vec![*k_m, 0.0, 0.0, 0.0, 0.0],
MassDistributionClass::IE => {
let k_ie = *k_m / 2.0;
vec![k_ie, 0.0, 0.0, 0.0, k_ie]
}
MassDistributionClass::D => {
let k_inner = *k_m / 4.0;
let k_outer = *k_m / 8.0;
vec![k_outer, k_inner, k_inner, k_inner, k_outer]
}
MassDistributionClass::M => vec![0.0, 0.0, *k_m, 0.0, 0.0],
},
&BuildingElement::AdjacentZTUSimple {
mass_distribution_class: ref dist_class,
ref k_m,
..
} => match dist_class {
MassDistributionClass::I => vec![0.0, 0.0, 0.0, 0.0, *k_m],
MassDistributionClass::E => vec![*k_m, 0.0, 0.0, 0.0, 0.0],
MassDistributionClass::IE => {
let k_ie = k_m / 2.0;
vec![k_ie, 0.0, 0.0, 0.0, k_ie]
}
MassDistributionClass::D => {
let k_inner = *k_m / 4.0;
let k_outer = *k_m / 8.0;
vec![k_outer, k_inner, k_inner, k_inner, k_outer]
}
MassDistributionClass::M => vec![0.0, 0.0, *k_m, 0.0, 0.0],
},
&BuildingElement::Ground {
mass_distribution_class: ref dist_class,
ref k_m,
..
} => {
let k_gr = THICKNESS_GROUND_LAYER * HEAT_CAPACITY_PER_VOLUME_OF_GROUND;
match dist_class {
MassDistributionClass::I => vec![0.0, k_gr, 0.0, 0.0, *k_m],
MassDistributionClass::E => vec![0.0, k_gr, *k_m, 0.0, 0.0],
MassDistributionClass::IE => {
let k_ie = *k_m / 2.0;
vec![0.0, k_gr, k_ie, 0.0, k_ie]
}
MassDistributionClass::D => {
let k_inner = *k_m / 2.0;
let k_outer = *k_m / 4.0;
vec![0.0, k_gr, k_outer, k_inner, k_outer]
}
MassDistributionClass::M => vec![0.0, k_gr, 0.0, *k_m, 0.0],
}
}
&BuildingElement::Transparent { .. } => vec![0.0, 0.0],
};

k_pli.len() as u32
}

// # Thermal properties of ground from BS EN ISO 13370:2017 Table 7
// # Use values for clay or silt (same as BR 443 and SAP 10)
const THERMAL_CONDUCTIVITY_OF_GROUND: f64 = 1.5; // in W/(m.K)
const HEAT_CAPACITY_PER_VOLUME_OF_GROUND: f64 = 3000000.0; // in J/(m3.K)
const THICKNESS_GROUND_LAYER: f64 = 0.5; // in m. Specified in BS EN ISO 52016-1:2017 section 6.5.8.2
2 changes: 2 additions & 0 deletions src/core/space_heat_demand/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
mod building_element;
mod thermal_bridge;
mod ventilation_element;
pub mod zone;
Loading

0 comments on commit 6032b89

Please sign in to comment.