Hello Rob,

Thank you for the responds. You are partially right, It is possible however also to achieve a small field without current. I managed with the activation of the mhd module in ansys. In the next step i try to create an UDF for defining an AC voltage on the walls as a boundary condition. I am sorry to ask this question, I hate when people post random UDF codes, expecting that other help them but I really struggle with this one. So my code looks like this:

#include "udf.h"
#include "math.h"
DEFINE_PROFILE(voltage_profile, thread, position)
    real t = CURRENT_TIME; // get current simulation time
    real V0 = 220.0; // set peak voltage to 220 V
    real freq = 50.0; // set frequency to 50 Hz
    real w = 2.0*M_PI*freq; // calculate angular frequency
    face_t f;
    real A, V, phase;
    A = V0/2.0; // calculate amplitude of sinusoidal voltage
    phase = 0.0; // set phase shift to zero
    begin_f_loop(f, thread)
        if (BOUNDARY_FACE_THREAD_P(f, thread))
            V = A*sin(w*t + phase); // calculate voltage at current time
            F_PROFILE(f, thread, position) = V; // set voltage at wall face
    end_f_loop(f, thread);
However it is showing me following errors, which are maybe linked to the logic of the code:

Error: C:/Users/49157/AppData/Local/Temp/voltage.c.6596.0.c: line 18: parse error.

Error: C:/Users/49157/AppData/Local/Temp/voltage.c.6596.0.c: line 24: parse error.


Again, I am sorry if this is not the correct place for debugging codes but could you at least give me a small hint.