Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some materials have invalid heat capacity values #767

Open
PGorzalka opened this issue Jul 26, 2024 · 1 comment
Open

Some materials have invalid heat capacity values #767

PGorzalka opened this issue Jul 26, 2024 · 1 comment

Comments

@PGorzalka
Copy link

PGorzalka commented Jul 26, 2024

What is the problem?

Why do we want to solve it?

  • This causes nan values for all the relevant parameters r1, r2, r3, c1, c2 in teaser.logic.buildingobjects.buildingphysics.wall.calc_equivalent_res()

How do we want to solve it?

  • Plausible heat capacity values should be added for those materials, e.g. derived from literature values. As the required unit is kJ / kg K and should mostly be around 1 anyway, adding 1.0 for all of them is a possible hotfix.
@PGorzalka PGorzalka changed the title Some materials cause impossible Some materials have invalid heat capacity values Jul 26, 2024
@PGorzalka
Copy link
Author

reproduce this with the following code, which is the function mentioned above without the self.

import numpy as np

area = 2
nr_of_layer = 2
density = np.array([500, 500])
thermal_conduc = np.array([0.162, 0.7])
heat_capac = np.array([0.0, 1.17])
thickness = np.array([0.2, 0.2])

t_bt = 7
omega = 2 * np.pi / (86400 * t_bt)
r_layer = thickness / thermal_conduc
c_layer = heat_capac * density * thickness * 1000
re11 = np.cosh(np.sqrt(0.5 * omega * r_layer * c_layer)) * \
       np.cos(np.sqrt(0.5 * omega * r_layer * c_layer))
im11 = np.sinh(np.sqrt(0.5 * omega * r_layer * c_layer)) * \
       np.sin(np.sqrt(0.5 * omega * r_layer * c_layer))
re12 = r_layer * np.sqrt(1 / (2 * omega * r_layer * c_layer)) * \
       (np.cosh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.sin(np.sqrt(0.5 * omega * r_layer * c_layer)) +
        np.sinh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.cos(np.sqrt(0.5 * omega * r_layer * c_layer)))
im12 = r_layer * np.sqrt(1 / (2 * omega * r_layer * c_layer)) * \
       (np.cosh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.sin(np.sqrt(0.5 * omega * r_layer * c_layer)) -
        np.sinh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.cos(np.sqrt(0.5 * omega * r_layer * c_layer)))
re21 = (-1 / r_layer) * (np.sqrt(0.5 * omega * r_layer * c_layer)) * \
       (np.cosh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.sin(np.sqrt(0.5 * omega * r_layer * c_layer)) -
        np.sinh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.cos(np.sqrt(0.5 * omega * r_layer * c_layer)))
im21 = (1 / r_layer) * (np.sqrt(0.5 * omega * r_layer * c_layer)) * \
       (np.cosh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.sin(np.sqrt(0.5 * omega * r_layer * c_layer)) +
        np.sinh(np.sqrt(0.5 * omega * r_layer * c_layer)) *
        np.cos(np.sqrt(0.5 * omega * r_layer * c_layer)))
re22 = re11
im22 = im11
# -----setting up the matrix for each layer
a_layer = np.zeros((nr_of_layer, 4, 4))
for i, r in enumerate(re11):
    a_layer[i][0][0] = r
    a_layer[i][0][1] = im11[i]
    a_layer[i][0][2] = re12[i]
    a_layer[i][0][3] = im12[i]
    a_layer[i][1][0] = -im11[i]
    a_layer[i][1][1] = re11[i]
    a_layer[i][1][2] = -im12[i]
    a_layer[i][1][3] = re12[i]
    a_layer[i][2][0] = re21[i]
    a_layer[i][2][1] = im21[i]
    a_layer[i][2][2] = re22[i]
    a_layer[i][2][3] = im22[i]
    a_layer[i][3][0] = -im21[i]
    a_layer[i][3][1] = re21[i]
    a_layer[i][3][2] = -im22[i]
    a_layer[i][3][3] = re22[i]
# -----multiplication of the matrix
new_mat = np.diag(np.ones(4))
for count_layer in a_layer:
    new_mat = np.dot(new_mat, count_layer)

# calculation of equivalent Resistance and capacities of each element
r1 = (1 / area) * ((new_mat[3][3] - 1) *
                   new_mat[0][2] + new_mat[2][3] *
                   new_mat[0][3]) / \
     ((new_mat[3][3] - 1) ** 2 + new_mat[2][3] ** 2)
r2 = (1 / area) * ((new_mat[0][0] - 1) *
                   new_mat[0][2] + new_mat[0][1] *
                   new_mat[0][3]) / \
     ((new_mat[0][0] - 1) ** 2 + new_mat[0][1] ** 2)
c1 = area * ((new_mat[3][3] - 1) ** 2 +
             (new_mat[2][3]) ** 2) / \
     (omega * (new_mat[0][2] * new_mat[2][3] -
               (new_mat[3][3] - 1) * new_mat[0][3]))
c2 = area * ((new_mat[0][0] - 1) ** 2 +
             (new_mat[0][1]) ** 2) / (
             omega * (new_mat[0][2] *
                      new_mat[0][1] -
                      (new_mat[0][0] - 1) *
                      new_mat[0][3]))
r3 = (1 / area) * (np.sum(r_layer)) - r1 - r2
r_wall = r1 + r2 + r3
c1_korr = (1 / (omega * r1)) * ((r_wall * area -
                                 new_mat[0][2] * new_mat[3][
                                     3] -
                                 new_mat[0][3] * new_mat[2][
                                     3]) /
                                (new_mat[3][3] * new_mat[0][
                                    3] -
                                 new_mat[0][2] * new_mat[2][
                                     3]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant