Lines Matching refs:ctx
41 static PetscErrorCode IFunction(TS ts, PetscReal t, Vec U, Vec Udot, Vec F, AppCtx *ctx) in IFunction() argument
51 …if ((t > ctx->tf) && (t < ctx->tcl)) Pmax = 0.0; /* A short-circuit on the generator terminal that… in IFunction()
52 else if (t >= ctx->tcl) Pmax = ctx->E / 0.745; in IFunction()
53 else Pmax = ctx->Pmax; in IFunction()
54 f[0] = udot[0] - ctx->omega_s * (u[1] - 1.0); in IFunction()
55 f[1] = 2.0 * ctx->H * udot[1] + Pmax * PetscSinScalar(u[0]) + ctx->D * (u[1] - 1.0) - ctx->Pm; in IFunction()
66 …tscErrorCode IJacobian(TS ts, PetscReal t, Vec U, Vec Udot, PetscReal a, Mat A, Mat B, AppCtx *ctx) in IJacobian() argument
75 …if ((t > ctx->tf) && (t < ctx->tcl)) Pmax = 0.0; /* A short-circuit on the generator terminal that… in IJacobian()
76 else if (t >= ctx->tcl) Pmax = ctx->E / 0.745; in IJacobian()
77 else Pmax = ctx->Pmax; in IJacobian()
80 J[0][1] = -ctx->omega_s; in IJacobian()
81 J[1][1] = 2.0 * ctx->H * a + ctx->D; in IJacobian()
120 AppCtx ctx; in main() local
149 ctx.omega_s = 2.0 * PETSC_PI * 60.0; in main()
150 ctx.H = 5.0; in main()
151 PetscCall(PetscOptionsScalar("-Inertia", "", "", ctx.H, &ctx.H, NULL)); in main()
152 ctx.D = 5.0; in main()
153 PetscCall(PetscOptionsScalar("-D", "", "", ctx.D, &ctx.D, NULL)); in main()
154 ctx.E = 1.1378; in main()
155 ctx.V = 1.0; in main()
156 ctx.X = 0.545; in main()
157 ctx.Pmax = ctx.E * ctx.V / ctx.X; in main()
158 PetscCall(PetscOptionsScalar("-Pmax", "", "", ctx.Pmax, &ctx.Pmax, NULL)); in main()
159 ctx.Pm = 0.9; in main()
160 PetscCall(PetscOptionsScalar("-Pm", "", "", ctx.Pm, &ctx.Pm, NULL)); in main()
161 ctx.tf = 1.0; in main()
162 ctx.tcl = 1.05; in main()
163 PetscCall(PetscOptionsReal("-tf", "Time to start fault", "", ctx.tf, &ctx.tf, NULL)); in main()
164 PetscCall(PetscOptionsReal("-tcl", "Time to end fault", "", ctx.tcl, &ctx.tcl, NULL)); in main()
167 ctx.tf = -1; in main()
168 ctx.tcl = -1; in main()
172 u[0] = PetscAsinScalar(ctx.Pm / ctx.Pmax); in main()
181 ctx.tf = -1; in main()
182 ctx.tcl = -1; in main()
193 PetscCall(TSSetIFunction(ts, NULL, (TSIFunctionFn *)IFunction, &ctx)); in main()
194 PetscCall(TSSetIJacobian(ts, A, A, (TSIJacobianFn *)IJacobian, &ctx)); in main()
216 u[0] = PetscAsinScalar(ctx.Pm / ctx.Pmax); in main()
217 u[1] = ctx.omega_s; in main()