|
11 | 11 | import KratosMultiphysics.MultilevelMonteCarloApplication |
12 | 12 | import xmc |
13 | 13 | import xmc.methodDefs_momentEstimator.computeCentralMoments as mdccm |
14 | | -from exaqute.ExaquteTaskLocal import * |
| 14 | +from exaqute import get_value_from_remote |
| 15 | + |
15 | 16 |
|
16 | 17 | if __name__ == "__main__": |
17 | 18 |
|
|
24 | 25 | with open(parametersPath,'r') as parameter_file: |
25 | 26 | parameters = json.load(parameter_file) |
26 | 27 |
|
27 | | - # add path of the problem folder to python path |
28 | | - problem_id = parameters["solverWrapperInputDictionary"]["problemId"] |
29 | | - sys.path.append(os.path.join("..","xmc","classDefs_solverWrapper","problemDefs_KratosMultiphysics",problem_id)) |
| 28 | + # SolverWrapper |
| 29 | + parameters["solverWrapperInputDictionary"]["qoiEstimator"] = parameters["monteCarloIndexInputDictionary"]["qoiEstimator"] |
30 | 30 |
|
31 | 31 | # SampleGenerator |
32 | 32 | samplerInputDictionary = parameters["samplerInputDictionary"] |
|
37 | 37 | monteCarloIndexInputDictionary = parameters["monteCarloIndexInputDictionary"] |
38 | 38 | monteCarloIndexInputDictionary["samplerInputDictionary"] = samplerInputDictionary |
39 | 39 |
|
40 | | - # Moment Estimators |
41 | | - qoiEstimatorInputDictionary = parameters["qoiEstimatorInputDictionary"] |
42 | | - combinedEstimatorInputDictionary = parameters["combinedEstimatorInputDictionary"] |
43 | | - costEstimatorInputDictionary = parameters["costEstimatorInputDictionary"] |
44 | | - # qoi estimators |
45 | | - monteCarloIndexInputDictionary["qoiEstimator"] = [monteCarloIndexInputDictionary["qoiEstimator"][0] for _ in range (0,parameters["solverWrapperInputDictionary"]["numberQoI"])] |
46 | | - monteCarloIndexInputDictionary["qoiEstimatorInputDictionary"] = [qoiEstimatorInputDictionary]*parameters["solverWrapperInputDictionary"]["numberQoI"] |
47 | | - # combined estimators |
48 | | - monteCarloIndexInputDictionary["combinedEstimator"] = [monteCarloIndexInputDictionary["combinedEstimator"][0] for _ in range (0,parameters["solverWrapperInputDictionary"]["numberCombinedQoi"])] |
49 | | - monteCarloIndexInputDictionary["combinedEstimatorInputDictionary"] = [combinedEstimatorInputDictionary]*parameters["solverWrapperInputDictionary"]["numberCombinedQoi"] |
50 | | - # cost estimator |
51 | | - monteCarloIndexInputDictionary["costEstimatorInputDictionary"] = costEstimatorInputDictionary |
52 | | - |
53 | 40 | # MonoCriterion |
54 | 41 | criteriaArray = [] |
55 | 42 | criteriaInputs = [] |
|
153 | 140 | qoi_dict["qoi_id_"+str(qoi_counter)]["index_"+str(index)] = {"qoi_id":qoi_counter, "index": index, "instances": sample_counter, "S1": S1, "S2": S2, "S3": S3, "S4": S4, "S5": S5, "S6": S6, "S7": S7, "S8": S8, "S9": S9, "S10": S10, "h1": h1, "h2": h2,"type":"scalar_quantity","tag":"lift_coefficient"} |
154 | 141 |
|
155 | 142 | # save pressure coefficient |
| 143 | + qoi_counter = qoi_counter + 1 |
| 144 | + qoi_dict["qoi_id_"+str(qoi_counter)] = {"member_"+str(member): {} for member in range (algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._variableDimension)} |
| 145 | + member = 0 |
156 | 146 | for node in current_model.GetModelPart(model_part_of_interest).Nodes: |
157 | | - qoi_counter = qoi_counter + 1 |
158 | | - qoi_dict["qoi_id_"+str(qoi_counter)] = {"index_"+str(index): {} for index in range (len(algo.monteCarloSampler.indices))} |
| 147 | + qoi_dict["qoi_id_"+str(qoi_counter)]["member_"+str(member)] = {"index_"+str(index): {} for index in range (len(algo.monteCarloSampler.indices))} |
159 | 148 | for index in range (len(algo.monteCarloSampler.indices)): |
160 | 149 | algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter] = get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]) |
161 | 150 | sample_counter = algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._sampleCounter |
162 | | - S1 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[0][0])) |
163 | | - S2 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[1][0])) |
164 | | - S3 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[2][0])) |
165 | | - S4 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[3][0])) |
166 | | - S5 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[4][0])) |
167 | | - S6 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[5][0])) |
168 | | - S7 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[6][0])) |
169 | | - S8 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[7][0])) |
170 | | - S9 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[8][0])) |
171 | | - S10 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[9][0])) |
| 151 | + S1 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._powerSums["1"][member])) |
| 152 | + S2 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._powerSums["2"][member])) |
172 | 153 | h1 = float(get_value_from_remote(mdccm.computeCentralMomentsOrderOneDimensionZero(S1,sample_counter))) |
173 | 154 | h2 = float(get_value_from_remote(mdccm.computeCentralMomentsOrderTwoDimensionZero(S1,S2,sample_counter))) |
174 | | - qoi_dict["qoi_id_"+str(qoi_counter)]["index_"+str(index)] = {"qoi_id":qoi_counter, "index": index, "instances": sample_counter, "S1": S1, "S2": S2, "S3": S3, "S4": S4, "S5": S5, "S6": S6, "S7": S7, "S8": S8, "S9": S9, "S10": S10, "h1": h1, "h2": h2,"type":"scalar_quantity","tag":"pressure coefficent","node_id":node.Id,"node_coordinates":[node.X,node.Y,node.Z]} |
| 155 | + qoi_dict["qoi_id_"+str(qoi_counter)]["member_"+str(member)]["index_"+str(index)] = {"qoi_id":qoi_counter, "member":member, "index": index, "instances": sample_counter, "S1": S1, "S2": S2, "S3": S3, "S4": S4, "S5": S5, "S6": S6, "S7": S7, "S8": S8, "S9": S9, "S10": S10, "h1": h1, "h2": h2,"type":"scalar_quantity","tag":"pressure coefficent","node_id":node.Id,"node_coordinates":[node.X,node.Y,node.Z]} |
| 156 | + member += 1 |
175 | 157 |
|
176 | 158 | # save to file |
177 | 159 | with open('power_sums_outputs/MC_asynchronous_power_sums_' +str(time.time()) + '.json', 'w') as f: |
|
0 commit comments