@@ -189,6 +189,19 @@ def simulate(
189189 for it in ["startTime" , "stopTime" , "stepSize" ]
190190 )
191191
192+ def _strip_tz (x ):
193+ if isinstance (x , pd .Timestamp ):
194+ return x .tz_localize (None ) if x .tz is not None else x
195+ if isinstance (x , dt .datetime ):
196+ return x .replace (tzinfo = None ) if x .tzinfo is not None else x
197+ return x
198+
199+ start_tz = start .tz if isinstance (start , pd .Timestamp ) \
200+ else getattr (start , "tzinfo" , None )
201+
202+ start = _strip_tz (start )
203+ stop = _strip_tz (stop )
204+
192205 # Output step cannot be used in ompython
193206 start_sec , stop_sec , step_sec , _ = parse_simulation_times (
194207 start , stop , step , step
@@ -267,8 +280,12 @@ def simulate(
267280 if isinstance (start , (pd .Timestamp , dt .datetime )):
268281 res .index = seconds_index_to_datetime_index (res .index , start .year )
269282 res .index = res .index .round ("s" )
270- res = res .tz_localize (start .tz )
283+
284+ if start_tz is not None :
285+ res .index = res .index .tz_localize (start_tz )
286+
271287 res .index .freq = res .index .inferred_freq
288+
272289 else :
273290 res .index = round (res .index .to_series (), 2 )
274291
@@ -335,13 +352,17 @@ def load_library(lib_path):
335352
336353 omc = OMCSessionZMQ ()
337354
338- for root , _ , files in os .walk (lib_path ):
339- for file in files :
340- if file .endswith (".mo" ):
341- file_path = os .path .join (root , file )
342- omc .sendExpression (f'loadFile("{ file_path } ")' )
355+ modelica_path = lib_path .parent .as_posix ()
356+ lib_name = lib_path .stem
357+
358+ omc .sendExpression (f'setModelicaPath("{ modelica_path } ")' )
359+ success = omc .sendExpression (f'loadModel({ lib_name } )' )
360+
361+ if not success :
362+ err = omc .sendExpression ("getErrorString()" )
363+ raise RuntimeError (f"Failed to load Modelica library:\n { err } " )
343364
344- print (f"Library '{ lib_path . stem } ' loaded successfully." )
365+ print (f"Library '{ lib_name } ' loaded successfully." )
345366
346367
347368def library_contents (library_path ):
0 commit comments