Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ssp_filename = sys.argv[1]
run_dir = sys.argv[2] + '/FMU'
os.mkdir(run_dir)
os.chdir(run_dir)
print("os.getcwd():", os.getcwd())
print("Simulating %s..." % ssp_filename)
result = simulate_ssp(ssp_filename, stop_time=12960000, step_size=600)
show_plot=True
if show_plot:
dir, _ = os.path.split(run_dir)
save_name = dir + '/ssp.png'
print("Plotting results in directory:",save_name)
print("run_dir:",run_dir)
plot_result(result, names=['time', 'space.TRooMea'], window_title=ssp_filename, filename=save_name)
print('result: ', result)
print('Done.')
#mo_file = "/var/oscli/clones/openstudio-workflow/lib/openstudio/workflow/jobs/HelloWorld.mo"
ssp_filename = sys.argv[1]
run_dir = sys.argv[2] + '/FMU'
os.mkdir(run_dir)
os.chdir(run_dir)
print("os.getcwd():", os.getcwd())
print("Simulating %s..." % ssp_filename)
result = simulate_ssp(ssp_filename, stop_time=12960000, step_size=600)
show_plot=True
if show_plot:
print("Plotting results...")
dir, _ = os.path.split(ssp_filename)
save_name = dir + 'ssp.png'
plot_result(result, names=['time', 'space.TRooMea'], window_title=ssp_filename, filename=save_name)
print('result: ', result)
print('Done.')
if os.path.isfile(in_csv):
input = read_csv(in_csv)
else:
input = None
result = simulate_fmu(fmu,
fmi_type='ModelExchange',
# solver='Euler',
start_values=start_values,
input=input,
output_interval=output_interval
)
write_csv(ref_csv, result)
ref = read_csv(ref_csv)
plot_result(ref, events=True, filename=ref_png)
md_file = os.path.join(src_dir, model_name, 'readme.md')
html_file = os.path.join(src_dir, model_name, 'readme.html')
md = markdown2.markdown_path(md_file, extras=['tables', 'fenced-code-blocks'])
with open(html_file, 'w') as html:
html.write(header1)
html.write("<title>%s</title>" % model_name)
html.write(header2)
html.write(md)
html.write(footer)
filename='CoupledClutches.fmu',
start_time=0,
stop_time=1.5,
solver=solver,
step_size=1e-2,
output_interval=2e-2,
start_values={'CoupledClutches1_freqHz': 0.4},
input=input,
output=output,
validate=False,
fmi_logging=fmi_logging)
if show_plot:
print("Plotting results...")
from fmpy.util import plot_result
plot_result(result=result,
window_title="CoupledClutches.fmu (FMI %s, %s, %s)" % (fmi_version, fmi_type, solver))
print("Done.")
return result
""" Download and simulate ControlledDrivetrain.ssp
Parameters:
show_plot plot the results
"""
ssp_filename = r'ControlledDrivetrain.ssp'
download_file('https://github.com/CATIA-Systems/FMPy/releases/download/v0.1.1/' + ssp_filename, checksum='45e667ed')
print("Simulating %s..." % ssp_filename)
result = simulate_ssp(ssp_filename, stop_time=4, step_size=1e-3)
if show_plot:
print("Plotting results...")
plot_result(result, names=['reference.y', 'drivetrain.w', 'controller.y'], window_title=ssp_filename)
print('Done.')
return result
# advance the time
time += step_size
fmu.terminate()
fmu.freeInstance()
# clean up
shutil.rmtree(unzipdir, ignore_errors=True)
# convert the results to a structured NumPy array
result = np.array(rows, dtype=np.dtype([('time', np.float64), ('inputs', np.float64), ('outputs[4]', np.float64)]))
# plot the results
if show_plot:
plot_result(result)
return time
record_events=not args.dont_record_events,
fmi_type=None,
start_values=start_values,
apply_default_start_values=args.apply_default_start_values,
input=input,
output=args.output_variables,
timeout=args.timeout,
debug_logging=args.debug_logging,
visible=args.visible,
fmi_call_logger=fmi_call_logger)
if args.output_file:
write_csv(filename=args.output_file, result=result)
if args.show_plot:
plot_result(result=result, window_title=args.fmu_filename)