0

I want to create a list called 'parameters' with dictionaries in it, since I will change parameters of a simulation with it. Also I need to save every simulation with a parameter changed with a new name (file_names).

Something like this worked so far:

sizings = np.linspace(1, 4, 4)
parameters = []
file_names = []
for sizing in sizings:
    parameters.append({"parameterStudy.V_flow_factor": sizing})
    name = 'results_(V_T_m)_' + str(int(sizing))
    file_names.append(name)


results = dym_api.simulate(
    parameters=parameters,
    return_option="savepath",
    savepath=result_file,
    result_file_name= file_names)

Now I need to change two more parameters and I want to create simulations with every combination of parameters. I can't really handle this task, I tried with more for-loops, but it didn't really work:

sizings = np.linspace(1, 4, 4)
dT_list = np.linspace(0, 3, 4)
mFac_list = np.linspace(0.05, 0.08, 4)
parameters = []
file_names = []
for sizing in sizings:
    parameters.append({"parameterStudy.V_flow_factor": v_flow_factor * sizing})
    for T_value in dT_list:
        parameters.append({"parameterStudy.dT_Fac": dT_Fac})
        for m_value in mFac_list:
            parameters.append({"parameterStudy.mFac_flow_nominal": m_value})
            name = 'results_(V_T_m)_' + str(int(sizing)) + '_' + str(T_value) + '_' + str(m_value)
            file_names.append(name)


# Or change the savepath by using two keyword arguments.
results = dym_api.simulate(
    parameters=parameters,
    return_option="savepath",
    savepath=result_file,
    result_file_name= file_names)
danronmoon
  • 3,814
  • 5
  • 34
  • 56
  • Try with generators (functions with yield instead of return) inteed of loops. The parameters will be generated during the simulation. – kithuto May 26 '23 at 13:46

0 Answers0