Hi @hmemy, thanks for trying out PowerModels! Could you provide a little more details about how the solutions differ (e.g. is it in the objective value, voltage profile, generator dispatch) and also what commands you are running in Matpower to compare?
That is good point that I forgot about! By default PowerModels works in the per_unit convention for its data, while Matpower uses a mixed units convention. You can use make_mixed_units! to turn the PowerModels data into Matpower’s unit convention, but you will have to turn it back with make_per_unit! before using it again in PowerModels.
In terms of saving data, you can try the export_matpower function. It is well tested but the results might look a little different than a pure Matpower case file becouse PowerModels supports a more general model of the network components.
I have created new data dictionaries named: new_bus, new_gen, new_branch, and I would like to save them in a file order to run an optimal power flow analysis. Could you please explain how to achieve this? Many thanks!
If you have created a dictionary network_data that contains all the necessary data in the PowerModels format you don’t need to save it for PowerModels to read it, you can simply feed it directly. Take this example taken from the documentation
# network_data is your dictionary with bus, branch and gen data
pm = instantiate_model(network_data, ACPPowerModel, PowerModels.build_opf)
print(pm.model)
result = optimize_model!(pm, optimizer=with_optimizer(Ipopt.Optimizer))
If for some reason you would like to save the dictionary network_data to work later on it, or send it to a colleague you could save it into a julia data file (*.jld). As for the instantiated model pm I’m not sure how you could save it, but I think it should be possible.
@hmemy, you can also try the export_matpower function provided in PowerModels. Know that you might see some extra data tables in there because PowerModels supports a more general network model than Matpower. That said, if you restrict your self to the Matpower subset, it should work as expected.
Also for general information, I generally think about PowerModels data dicts as an internal data model, but they are JSON serializable. This is quite helpful when building multi-language pipelines.
Hello, @ccoffrin, now I am using export_matpower, the m file show the result, but
there are too many digits after the decimal point.
When I use print_summary, display in repl doesn’t have so many digits.
can I set the number of digits in export_matpower function?
There is no feature to truncate the accuracy of export_matpower and I would generally not encourage this as solutions can easily be sensitive to the 7th decimal place in the voltage magnitude values.
You could do some pre-processing on the PowerModels data dictionary to truncate the data values before calling export_matpower and this should have the effect you are looking for.
Thank you very much @ccoffrin .
Now I am studying SOC-OPF in PowerModelsAnnex, the program have calculated W value, but I can’t find the function calculates V value using W.
Looking forward to your reply!
Yes, that is the model I want.
But when I see the definition of sol_data_model!,I only find the solution of ‘vm’ in function _sol_data_model_w!(solution::Dict)
You know the SOC-OPF result gives ‘w’ 、‘wr’、‘wi’, atan(wi/wr) only gets the angle between vi and vj, but they are not the angle relative to the reference bus, I want to know how to compute the ‘va’ in sol_data_model!
looking forwar your reply, thank you very much.
@Xuekui_wang in general it is not possible to map the wrwi values into va values, this is because wrwi are a higher dimension (|E|) than the va values (|N|), this is part of the reason with SOC-OPF is a relaxation and not an exact solution. So this is not supported by PowerModels by default.