Beispiel erweitert
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
// Beispiel für Tabellen 59-62, Beispielwert Spalte1=235
|
||||||
|
|
||||||
|
type DataPoint = {
|
||||||
|
Spalte1: number;
|
||||||
|
Spalte2: number;
|
||||||
|
Spalte3: number;
|
||||||
|
Spalte4: number;
|
||||||
|
Spalte5: number;
|
||||||
|
Spalte6: number;
|
||||||
|
Spalte7: number;
|
||||||
|
Spalte8: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
function interpolateForX(data: DataPoint[], x: number): DataPoint | null {
|
||||||
|
// Sort the data by Spalte1
|
||||||
|
data.sort((a, b) => a.Spalte1 - b.Spalte1);
|
||||||
|
|
||||||
|
// Ensure x is within range
|
||||||
|
if (x < data[0].Spalte1 || x > data[data.length - 1].Spalte1) {
|
||||||
|
console.error("Target value is out of interpolation range.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the two points to interpolate between
|
||||||
|
let lower: DataPoint | null = null;
|
||||||
|
let upper: DataPoint | null = null;
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length - 1; i++) {
|
||||||
|
if (data[i].Spalte1 <= x && data[i + 1].Spalte1 >= x) {
|
||||||
|
lower = data[i];
|
||||||
|
upper = data[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lower || !upper) {
|
||||||
|
console.error("Could not find interpolation bounds.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Linear interpolation function
|
||||||
|
const interpolateValue = (x1: number, y1: number, x2: number, y2: number, x: number) => {
|
||||||
|
return y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Perform interpolation for all columns
|
||||||
|
return {
|
||||||
|
Spalte1: x,
|
||||||
|
Spalte2: interpolateValue(lower.Spalte1, lower.Spalte2, upper.Spalte1, upper.Spalte2, x),
|
||||||
|
Spalte3: interpolateValue(lower.Spalte1, lower.Spalte3, upper.Spalte1, upper.Spalte3, x),
|
||||||
|
Spalte4: interpolateValue(lower.Spalte1, lower.Spalte4, upper.Spalte1, upper.Spalte4, x),
|
||||||
|
Spalte5: interpolateValue(lower.Spalte1, lower.Spalte5, upper.Spalte1, upper.Spalte5, x),
|
||||||
|
Spalte6: interpolateValue(lower.Spalte1, lower.Spalte6, upper.Spalte1, upper.Spalte6, x),
|
||||||
|
Spalte7: interpolateValue(lower.Spalte1, lower.Spalte7, upper.Spalte1, upper.Spalte7, x),
|
||||||
|
Spalte8: interpolateValue(lower.Spalte1, lower.Spalte8, upper.Spalte1, upper.Spalte8, x),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example usage with the complete dataset
|
||||||
|
const dataset: DataPoint[] = [
|
||||||
|
{ Spalte1: 100, Spalte2: 130, Spalte3: 121, Spalte4: 251, Spalte5: 3.36, Spalte6: 1296, Spalte7: 2.04, Spalte8: 1391 },
|
||||||
|
{ Spalte1: 150, Spalte2: 174, Spalte3: 137, Spalte4: 295, Spalte5: 4.51, Spalte6: 1740, Spalte7: 2.73, Spalte8: 1866 },
|
||||||
|
{ Spalte1: 200, Spalte2: 219, Spalte3: 153, Spalte4: 372, Spalte5: 5.67, Spalte6: 2186, Spalte7: 3.43, Spalte8: 2345 },
|
||||||
|
{ Spalte1: 300, Spalte2: 308, Spalte3: 182, Spalte4: 489, Spalte5: 7.98, Spalte6: 3075, Spalte7: 4.83, Spalte8: 3299 },
|
||||||
|
{ Spalte1: 400, Spalte2: 396, Spalte3: 207, Spalte4: 604, Spalte5: 10.27, Spalte6: 3961, Spalte7: 6.22, Spalte8: 4249 },
|
||||||
|
{ Spalte1: 500, Spalte2: 486, Spalte3: 231, Spalte4: 717, Spalte5: 12.59, Spalte6: 4853, Spalte7: 7.62, Spalte8: 5205 },
|
||||||
|
{ Spalte1: 600, Spalte2: 575, Spalte3: 253, Spalte4: 828, Spalte5: 14.89, Spalte6: 5740, Spalte7: 9.01, Spalte8: 6157 },
|
||||||
|
{ Spalte1: 700, Spalte2: 664, Spalte3: 274, Spalte4: 938, Spalte5: 17.2, Spalte6: 6629, Spalte7: 10.41, Spalte8: 7111 },
|
||||||
|
{ Spalte1: 800, Spalte2: 752, Spalte3: 294, Spalte4: 1046, Spalte5: 19.49, Spalte6: 7512, Spalte7: 11.79, Spalte8: 8057 },
|
||||||
|
{ Spalte1: 900, Spalte2: 841, Spalte3: 313, Spalte4: 1154, Spalte5: 21.79, Spalte6: 8400, Spalte7: 13.19, Spalte8: 9010 },
|
||||||
|
{ Spalte1: 1000, Spalte2: 930, Spalte3: 331, Spalte4: 1261, Spalte5: 24.11, Spalte6: 9293, Spalte7: 14.59, Spalte8: 9969 },
|
||||||
|
{ Spalte1: 2000, Spalte2: 1819, Spalte3: 484, Spalte4: 2303, Spalte5: 47.14, Spalte6: 18172, Spalte7: 28.53, Spalte8: 19348 },
|
||||||
|
{ Spalte1: 3000, Spalte2: 2703, Spalte3: 606, Spalte4: 3309, Spalte5: 70.04, Spalte6: 27001, Spalte7: 42.39, Spalte8: 28798 },
|
||||||
|
{ Spalte1: 4000, Spalte2: 3592, Spalte3: 714, Spalte4: 4306, Spalte5: 93.08, Spalte6: 35881, Spalte7: 56.33, Spalte8: 38298 },
|
||||||
|
{ Spalte1: 5000, Spalte2: 4486, Spalte3: 812, Spalte4: 5298, Spalte5: 116.25, Spalte6: 44815, Spalte7: 70.35, Spalte8: 47835 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const x = 235; // Example Spalte1 value to interpolate
|
||||||
|
const interpolatedResult = interpolateForX(dataset, x);
|
||||||
|
|
||||||
|
console.log(interpolatedResult);
|
||||||
@@ -31,4 +31,87 @@ const monatlicherBelastungsgradT90 = monatlicherBelastungsGradT90(
|
|||||||
maxHeizlastZwei
|
maxHeizlastZwei
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("Monatlicher Belastungsgrad T90:", monatlicherBelastungsgradT90);
|
console.log("Monatlicher Belastungsgrad T90:", monatlicherBelastungsgradT90);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Funktion zur Berechnung des monatlichen Belastungsgrades aus Tabelle 9 EFH (Zeitkonstante 90,130)
|
||||||
|
|
||||||
|
type MonthData = {
|
||||||
|
month: string;
|
||||||
|
values: number[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const datasetZeitkonstante90: MonthData[] = [
|
||||||
|
{ month: "Januar", values: [0.562, 0.559, 0.555, 0.548, 0.541, 0.538, 0.536, 0.535] },
|
||||||
|
{ month: "Februar", values: [0.536, 0.532, 0.529, 0.522, 0.515, 0.512, 0.510, 0.510] },
|
||||||
|
{ month: "März", values: [0.453, 0.450, 0.447, 0.441, 0.436, 0.433, 0.431, 0.431] },
|
||||||
|
{ month: "April", values: [0.320, 0.318, 0.316, 0.311, 0.307, 0.306, 0.305, 0.304] },
|
||||||
|
{ month: "Mai", values: [0.175, 0.173, 0.172, 0.170, 0.168, 0.167, 0.166, 0.166] },
|
||||||
|
{ month: "Juni", values: [0.098, 0.097, 0.096, 0.095, 0.094, 0.093, 0.093, 0.093] },
|
||||||
|
{ month: "Juli", values: [0.030, 0.029, 0.029, 0.029, 0.028, 0.028, 0.028, 0.028] },
|
||||||
|
{ month: "August", values: [0.041, 0.041, 0.041, 0.040, 0.040, 0.040, 0.039, 0.039] },
|
||||||
|
{ month: "September", values: [0.169, 0.168, 0.167, 0.164, 0.162, 0.161, 0.161, 0.161] },
|
||||||
|
{ month: "Oktober", values: [0.311, 0.309, 0.307, 0.303, 0.299, 0.297, 0.296, 0.296] },
|
||||||
|
{ month: "November", values: [0.471, 0.467, 0.465, 0.459, 0.453, 0.450, 0.448, 0.448] },
|
||||||
|
{ month: "Dezember", values: [0.565, 0.562, 0.558, 0.551, 0.544, 0.540, 0.539, 0.538] }
|
||||||
|
];
|
||||||
|
|
||||||
|
const datasetZeitkonstante130: MonthData[] = [
|
||||||
|
{ month: "Januar", values: [0.567, 0.563, 0.560, 0.553, 0.545, 0.542, 0.540, 0.539, 0.539] },
|
||||||
|
{ month: "Februar", values: [0.540, 0.537, 0.533, 0.526, 0.520, 0.516, 0.515, 0.514, 0.513] },
|
||||||
|
{ month: "März", values: [0.457, 0.454, 0.451, 0.445, 0.439, 0.435, 0.435, 0.434, 0.434] },
|
||||||
|
{ month: "April", values: [0.322, 0.320, 0.318, 0.314, 0.310, 0.308, 0.307, 0.307, 0.306] },
|
||||||
|
{ month: "Mai", values: [0.176, 0.175, 0.174, 0.172, 0.169, 0.168, 0.168, 0.168, 0.167] },
|
||||||
|
{ month: "Juni", values: [0.098, 0.097, 0.096, 0.095, 0.094, 0.094, 0.094, 0.094, 0.094] },
|
||||||
|
{ month: "Juli", values: [0.030, 0.030, 0.029, 0.029, 0.028, 0.028, 0.028, 0.028, 0.028] },
|
||||||
|
{ month: "August", values: [0.042, 0.041, 0.041, 0.040, 0.040, 0.040, 0.040, 0.040, 0.040] },
|
||||||
|
{ month: "September", values: [0.170, 0.169, 0.168, 0.166, 0.164, 0.163, 0.162, 0.162, 0.162] },
|
||||||
|
{ month: "Oktober", values: [0.313, 0.311, 0.309, 0.305, 0.301, 0.300, 0.299, 0.298, 0.298] },
|
||||||
|
{ month: "November", values: [0.474, 0.471, 0.469, 0.462, 0.456, 0.454, 0.453, 0.451, 0.451] },
|
||||||
|
{ month: "Dezember", values: [0.570, 0.566, 0.563, 0.555, 0.548, 0.545, 0.543, 0.542, 0.542] },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Für "Ohne Teilbeheizung" habe ich hier einfach 0 genommen. Prakmatisch würde ich sagen.
|
||||||
|
const HeizLast = [0, 5, 10, 25, 50, 75, 100, 125, 150];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Linearly interpolates a value for the given x.
|
||||||
|
* @param x The heating load value (e.g., 82).
|
||||||
|
* @param values The array of y-values corresponding to heating loads.
|
||||||
|
* @param loads The array of heating load values (x-axis).
|
||||||
|
* @returns The interpolated value.
|
||||||
|
*/
|
||||||
|
function interpolate(x: number, values: number[], loads: number[]): number {
|
||||||
|
if (x <= loads[0]) return values[0];
|
||||||
|
if (x >= loads[loads.length - 1]) return values[values.length - 1];
|
||||||
|
|
||||||
|
for (let i = 0; i < loads.length - 1; i++) {
|
||||||
|
if (x >= loads[i] && x <= loads[i + 1]) {
|
||||||
|
const x1 = loads[i];
|
||||||
|
const x2 = loads[i + 1];
|
||||||
|
const y1 = values[i];
|
||||||
|
const y2 = values[i + 1];
|
||||||
|
|
||||||
|
return y1 + ((x - x1) * (y2 - y1)) / (x2 - x1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Interpolation error: Value is out of bounds.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example: Interpolate for x = 82 und Zeitkonstante zwischen 90-130
|
||||||
|
const x = 82;
|
||||||
|
const interpolatedValuesZeitkonstante90 = datasetZeitkonstante90.map(data => ({
|
||||||
|
month: data.month,
|
||||||
|
interpolatedValue: interpolate(x, data.values, HeizLast)
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Example: Interpolate for x = 82 und Zeitkonstante >= 130
|
||||||
|
const x = 82;
|
||||||
|
const interpolatedValuesZeitkonstante130 = datasetZeitkonstante130.map(data => ({
|
||||||
|
month: data.month,
|
||||||
|
interpolatedValue: interpolate(x, data.values, HeizLast)
|
||||||
|
}));
|
||||||
|
|
||||||
|
console.log(interpolatedValuesZeitkonstante90);
|
||||||
|
console.log(interpolatedValuesZeitkonstante130);
|
||||||
Reference in New Issue
Block a user