Skip to content

Commit

Permalink
Make initial trajectories in TestSimulateMmc and TestMexSimulateMmc p…
Browse files Browse the repository at this point in the history
…hase-agnostic
  • Loading branch information
olejodd10 committed Apr 12, 2024
1 parent 8782bfd commit 26e471e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions test/mex/TestMexSimulateMmc.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ function TestMexSimulateMmc(output_dir, N, simulation_timesteps)
x = zeros(N_X, N, 'double');
u = zeros(N_U, N, 'double');
for i = 1:N
x(1,i) = Iv_ref_amp*sin(PHASE_0 + Iv_phase + 2*pi*FREQ*Ts*(i-1));
x(2,i) = Icir_0;
x(3,i) = Vsigma_u_0;
x(4,i) = Vsigma_l_0;
u(1,i) = (N_SM/2)*sin(PHASE_0 - Vf_phase + 2*pi*FREQ*Ts*(i-1)) + N_SM/2;
u(2,i) = (N_SM/2)*sin(PHASE_0 + Vf_phase + 2*pi*FREQ*Ts*(i-1)) + N_SM/2;
x(1,i) = 0.0;
x(2,i) = Icir_ref;
x(3,i) = Vdc;
x(4,i) = Vdc;
u(1,i) = N_SM/2.0;
u(2,i) = N_SM/2.0;
end

% Allocate model matrices
Expand Down
12 changes: 6 additions & 6 deletions test/src/TestSimulateMmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ static int simulate_mmc(const char* output_dir, size_t N, size_t simulation_time
// Initialize trajectory
real_t omega = 2.0*M_PI*FREQ*Ts;
for (size_t i = 0; i < N; ++i) {
x[i*N_X + 0] = Iv_ref_amp*sin(omega*(real_t)i + PHASE_0 + Iv_phase);
x[i*N_X + 1] = Icir_0;
x[i*N_X + 2] = Vsigma_u_0;
x[i*N_X + 3] = Vsigma_l_0;
x[i*N_X + 0] = 0.0;
x[i*N_X + 1] = Icir_ref;
x[i*N_X + 2] = Vdc;
x[i*N_X + 3] = Vdc;
}
for (size_t i = 0; i < N; ++i) {
u[i*N_U + 0] = N_SM/2.0*sin(omega*(real_t)i + PHASE_0 - Vf_phase) + N_SM/2.0;
u[i*N_U + 1] = N_SM/2.0*sin(omega*(real_t)i + PHASE_0 + Vf_phase) + N_SM/2.0;
u[i*N_U + 0] = N_SM/2.0;
u[i*N_U + 1] = N_SM/2.0;
}

long long simulation_time_ns = 0;
Expand Down

0 comments on commit 26e471e

Please sign in to comment.