Coverage for teaser/data/output/modelica_output.py: 100%

16 statements  

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

1"""This module contains functions for all modelica model generations with AixLib, IBPSA and BESMod""" 

2 

3import os 

4import shutil 

5from mako.template import Template 

6import teaser.logic.utilities as utilities 

7 

8 

9def create_package(path, name, uses=None, within=None): 

10 """creates a package.mo file 

11 

12 private function, do not call 

13 

14 Parameters 

15 ---------- 

16 

17 path : string 

18 path of where the package.mo should be placed 

19 name : string 

20 name of the Modelica package 

21 uses : [string] 

22 list of used versions for the package in the form 'Library_name(version="x.x.x")' 

23 within : string 

24 path of Modelica package containing this package 

25 

26 """ 

27 

28 package_template = Template(filename=utilities.get_full_path( 

29 "data/output/modelicatemplate/package")) 

30 with open(os.path.join(path, "package.mo"), 'w') as out_file: 

31 

32 out_file.write(package_template.render_unicode( 

33 name=name, 

34 within=within, 

35 uses=uses)) 

36 out_file.close() 

37 

38 

39def create_package_order(path, package_list, addition=None, extra=None): 

40 """creates a package.order file 

41 

42 private function, do not call 

43 

44 Parameters 

45 ---------- 

46 

47 path : string 

48 path of where the package.order should be placed 

49 package_list : [buildings or thermal_zones] 

50 objects with the attribute name of all models or packages contained in the package 

51 addition : string 

52 if there should be a prefix of package_list.string it can 

53 be specified 

54 extra : [string] 

55 list of extra packages or models not contained in package_list can be 

56 specified 

57 

58 """ 

59 

60 order_template = Template(filename=utilities.get_full_path( 

61 "data/output/modelicatemplate/package_order")) 

62 with open(path + "/" + "package" + ".order", 'w') as out_file: 

63 

64 out_file.write(order_template.render_unicode 

65 (list=package_list, addition=addition, extra=extra)) 

66 out_file.close() 

67 

68 

69def copy_weather_data(source_path, destination_path): 

70 """Copies the imported .mos weather file to the results folder. 

71 

72 Parameters 

73 ---------- 

74 source_path : str 

75 path of local weather file 

76 destination_path : str 

77 path of where the weather file should be placed 

78 """ 

79 

80 shutil.copy2(source_path, destination_path)