Coverage for teaser/data/input/material_input_json.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2025-04-29 16:01 +0000

1"""This module contains function to load material classes.""" 

2 

3 

4def load_material(material, mat_name, data_class): 

5 """Material loader with name as identification. 

6 

7 Loads Material specified in the JSON. Sources are 

8 :cite:`DeutschesInstitutfurNormung.Juli2000`, 

9 DeutschesInstitutfurNormung.Februar2013, :cite:`Schramek.2009` and 

10 :cite:`VereinDeutscherIngenieure.2015c`. 

11 

12 Parameters 

13 ---------- 

14 material : Material() 

15 instance of TEASERS Material class 

16 

17 mat_name : str 

18 Code list for Material 

19 

20 data_class : DataClass() 

21 DataClass containing the bindings for TypeBuildingElement and 

22 Material (typically this is the data class stored in prj.data, 

23 but the user can individually change that. 

24 

25 """ 

26 binding = data_class.material_bind 

27 

28 for id, mat in binding.items(): 

29 if mat["name"] == mat_name: 

30 

31 material.material_id = id 

32 material.name = mat["name"] 

33 material.density = mat["density"] 

34 material.thermal_conduc = mat["thermal_conduc"] 

35 material.heat_capac = mat["heat_capac"] 

36 material.solar_absorp = mat["solar_absorp"] 

37 material.thickness_default = mat["thickness_default"] 

38 material.thickness_list = mat["thickness_list"] 

39 

40 

41def load_material_id(material, mat_id, data_class): 

42 """Material loader with id as identification. 

43 

44 Loads Material specified in the JSON by given material_id. 

45 

46 Parameters 

47 ---------- 

48 material : Material() 

49 instance of TEASERS Material class 

50 

51 mat_id : name 

52 id of material from JSON 

53 

54 data_class : DataClass() 

55 DataClass containing the bindings for TypeBuildingElement and 

56 Material (typically this is the data class stored in prj.data, 

57 but the user can individually change that. 

58 

59 """ 

60 binding = data_class.material_bind 

61 

62 for id, mat in binding.items(): 

63 if id == mat_id: 

64 

65 material.material_id = id 

66 material.name = mat["name"] 

67 material.density = mat["density"] 

68 material.thermal_conduc = mat["thermal_conduc"] 

69 material.heat_capac = mat["heat_capac"] 

70 material.solar_absorp = mat["solar_absorp"] 

71 material.thickness_default = mat["thickness_default"] 

72 material.thickness_list = mat["thickness_list"]