Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pytrnsys/run_api/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def replace_variable_value(self, variable: str, value: float | str) -> None:

@_dc.dataclass
class Ddcks:
# TODO: provide set_global as an input? # pylint: disable=fixme
"""
Settings class to include ddcks and change file assignments for, e.g. printers.

Expand All @@ -81,6 +80,7 @@ class Ddcks:
String path to the location of the "end.ddck" using a known alias.
This defaults to "DDCK$ generic/end".
"""

_assign: dict = _dc.field(default_factory=dict)
_ddcks: dict = _dc.field(default_factory=dict)
head_ddck: str = _dc.field(default="DDCK$ generic/head global")
Expand Down Expand Up @@ -272,7 +272,7 @@ def add_path_alias(self, alias: str, path: str) -> None:


@_dc.dataclass
class Generic:
class Generic: # pylint: disable=too-many-instance-attributes
"""
General settings to control pytrnsys behavior.

Expand Down Expand Up @@ -316,6 +316,12 @@ class Generic:
"runFromCases" starts the simulations from the prepared files.
"runFromFolder" starts the simulation of a specific folder.
run_mode defaults to "runFromConfig".

default_visibility: str
Flag to use local or global variables for ddcks by default.
When using "global", individual ddcks can be set to local using "component_name" in "ddcks.add_ddck".
When using "local", individual ddcks can be set to global using "is_global" in "ddcks.add_ddck".
This is "local" by default.
"""

leave_n_cpus_available: int = _dc.field(default=4)
Expand All @@ -325,6 +331,7 @@ class Generic:
output_level: _tp.Literal["INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL"] = _dc.field(default="INFO")
base_name_for_dcks: None | str = _dc.field(default=None)
run_mode: _tp.Literal["runFromConfig", "runFromCases", "runFromFolder"] = _dc.field(default="runFromConfig")
default_visibility: _tp.Literal["global", "local"] = _dc.field(default="local")


@_dc.dataclass
Expand Down Expand Up @@ -536,6 +543,7 @@ def _generic_lines(self, generic: Generic) -> list[str]:
self._add_bool_line("checkDeck", generic.check_dck),
self._add_string_line("outputLevel", generic.output_level),
self._add_string_line("runType", generic.run_mode),
self._add_string_line("defaultVisibility", generic.default_visibility),
]

if generic.base_name_for_dcks is not None:
Expand Down Expand Up @@ -593,8 +601,10 @@ def _variation_lines(self, variations: ParametricVariations) -> list[str]:
f"Lengths of the variations: {n_values}"
)

for _, variation in variations._variations.items(): # pylint: disable=protected-access
lines.append(f'variation {variation["trnsys_variable"]} {" ".join(map(str, variation["values"]))}')
for variation_name, variation in variations._variations.items(): # pylint: disable=protected-access
lines.append(
f'variation {variation_name} {variation["trnsys_variable"]} {" ".join(map(str, variation["values"]))}'
)

for original_ddck, ddcks in variations._ddck_file_variations.items(): # pylint: disable=protected-access
lines.append(f'changeDDckFile {original_ddck}{" ".join(map(str, ddcks))}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bool runCases True
bool checkDeck True
string outputLevel 'INFO'
string runType 'runFromConfig'
string defaultVisibility 'local'
string nameRef 'dual_loop'

############# AUTOMATIC WORK BOOL##################
Expand All @@ -27,8 +28,8 @@ string scaling 'False'

############# PARAMETRIC VARIATIONS ###############
bool combineAllCases True
variation AcollAp 2 3 4 6 8 10
variation volPerM2Col 75 100
variation Ac AcollAp 2 3 4 6 8 10
variation VTes volPerM2Col 75 100
changeDDckFile CityBAS_dryK CityBAS_dryK CityCDF_dryK CityLUG_dryK

############# ADJUSTED VARIABLE IN DCK ###############
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bool runCases True
bool checkDeck True
string outputLevel 'INFO'
string runType 'runFromConfig'
string defaultVisibility 'local'
string nameRef 'dummies_only'

############# AUTOMATIC WORK BOOL##################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bool runCases True
bool checkDeck True
string outputLevel 'INFO'
string runType 'runFromConfig'
string defaultVisibility 'local'
string nameRef 'dummies_only'

############# AUTOMATIC WORK BOOL##################
Expand Down
Loading