Код: Выделить всё
load('model.mo') # modelica file, parent script
# change the control stategy in the script
for i in ['control_1', 'control_2', 'control_3', 'control 4']:
# change the amount of electricity generation
find and replace r'moduleName = "control"' with 'moduleName = control_' + str(i)
for j in [3, 7]:
find and replace '.CombiTimeTable solar_data(columns = {2}' with '.CombiTimeTable solar_data(columns = {' + str(j) + '}'
# change the battery size
for k in [2000000000, 4000000000, 6000000000]:
find and replace 'Storage.Battery BESS(EMax = 2000000000, SOC_start = 0.5, pf = 0.9)' with 'Storage.Battery BESS(EMax = ' + str(k) + ', SOC_start = 0.5, pf = 0.9)'
for l in ['4', '8']:
find and replace '.CombiTimeTable ev_data(columns = {2}' with '.CombiTimeTable ev_data(columns = {' + str(i) + '}'
export('child_model_#.mo')
Подробнее здесь: https://stackoverflow.com/questions/785 ... n-a-script