Method for controlling a voltage in a DC power grid comprising a master terminal (TM1, TM2) controlling a DC voltage of the master terminal and a slave terminal (TS1,...,TS3) controlling a DC power of the slave terminal, the method comprising: a) receiving a first tolerance range (U N, ΔU) for DC voltages of the master terminal (TM1, TM2) and of the slave terminal (TS1,...,TS3), b) receiving a second tolerance range ( P S1, P S1,..., P S3, P S3) for the DC power of the slave terminal (TS1,...,TS3), c) running, by a processor, a robust optimization process for a set of DC power flow equations combining values for DC voltages and DC powers of the master terminal (TM1, TM2) and of the slave terminal (TS1,...,TS3), d) inputting the first and second tolerance range to the robust optimization process, using the first tolerance range (U N, ΔU) as robust optimization constraint and the second tolerance range ( P S1, P S1,..., P S3, P S3) as robust optimization uncertainty, e) determining by the robust optimization process a DC voltage set point (u st1, u st2) for the master terminal (TM1, TM2) so that the set of DC power flow equations and the robust optimization constraint are fulfilled for the second tolerance range ( P S1, P S1,..., P S3, P S3), and f) controlling the DC voltage of the master terminal (TM1, TM2) according to the determined DC voltage set point (u st1, u st2), wherein a target value (P* M1, P* M2) for a target DC power of the master terminal (TM1, TM2) is received, the target value (P* M1, P* M2) is input to the robust optimization process taking into account a deviation of the target value (P* M1, P* M2) from a DC power of the master terminal (TM1, TM2) in a robust optimization cost function, and the DC voltage set point (u st1, u st2) is determined so that the robust optimization cost function is minimized for the second tolerance range ( P S1, P S1,..., P S3, P S3). a) receiving a first tolerance range (U N, ΔU) for DC voltages of the master terminal (TM1, TM2) and of the slave terminal (TS1,...,TS3), b) receiving a second tolerance range ( P S1, P S1,..., P S3, P S3) for the DC power of the slave terminal (TS1,...,TS3), c) running, by a processor, a robust optimization process for a set of DC power flow equations combining values for DC voltages and DC powers of the master terminal (TM1, TM2) and of the slave terminal (TS1,...,TS3), d) inputting the first and second tolerance range to the robust optimization process, using the first tolerance range (U N, ΔU) as robust optimization constraint and the second tolerance range ( P S1, P S1,..., P S3, P S3) as robust optimization uncertainty, e) determining by the robust optimization process a DC voltage set point (u st1, u st2) for the master terminal (TM1, TM2) so that the set of DC power flow equations and the robust optimization constraint are fulfilled for the second tolerance range ( P S1, P S1,..., P S3, P S3), and f) controlling the DC voltage of the master terminal (TM1, TM2) according to the determined DC voltage set point (u st1, u st2), wherein a target value (P* M1, P* M2) for a target DC power of the master terminal (TM1, TM2) is received, the target value (P* M1, P* M2) is input to the robust optimization process taking into account a deviation of the target value (P* M1, P* M2) from a DC power of the master terminal (TM1, TM2) in a robust optimization cost function, and the DC voltage set point (u st1, u st2) is determined so that the robust optimization cost function is minimized for the second tolerance range ( P S1, P S1,..., P S3, P S3).