Skip to content

Commit 9e50788

Browse files
added LD type 7 from 4nec2
1 parent e275894 commit 9e50788

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

src/calculations.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ int apply_impedance_loading(nec_context_t *ctx, int *ldtyp, int *ldtag, int *ldt
353353

354354
/* ldtyp is validated (0–6) by control.c before storage; this should
355355
* never fire. If it does, it is a programming error, not a user error. */
356-
assert(ldtyp[istepx] <= 6 && "INTERNAL: IMPROPER LOAD TYPE stored in zload.load_types");
356+
assert(ldtyp[istepx] <= 7 && "INTERNAL: IMPROPER LOAD TYPE stored in zload.load_types");
357357

358358
/* search segments for proper itags */
359359
ldtags= ldtag[istepx];
@@ -454,6 +454,23 @@ int apply_impedance_loading(nec_context_t *ctx, int *ldtyp, int *ldtag, int *ldt
454454
break;
455455
}
456456

457+
case 8: {
458+
/* LD type 7: insulated wire coating (Cebik method).
459+
* F1 = dielectric constant (epsilon), F2 = outer radius R (m).
460+
* r = bare wire radius (m) = geometry.radius[i] * wavelength.
461+
* Converts to distributed series inductance (H/m) per the 4nec2 formula:
462+
* L = 2e-7 * (eps*R/r)^(1/12) * (1 - 1/eps) * ln(R/r)
463+
* then applies as a series per-unit-length load (same as LD type 2, case 3). */
464+
double eps = zlr[istepx]; /* dielectric constant */
465+
double R = zli[istepx]; /* outer (insulation) radius, metres */
466+
double r = ctx->geometry.radius[i] * ctx->geometry.wavelength; /* wire radius, metres */
467+
double ratio = R / r;
468+
double L_pm = 2.0e-7 * pow(eps * ratio, 1.0/12.0) * (1.0 - 1.0/eps) * log(ratio);
469+
/* series distributed impedance per half-length: jω·L_pm·(2·half_len) / (2·half_len) = jω·L_pm */
470+
zt = tpcj * ctx->geometry.half_len[i] * L_pm / ctx->geometry.wavelength;
471+
break;
472+
}
473+
457474
} /* switch( jump ) */
458475

459476
if(( fabs( creal( ctx->zload.seg_impedance[i]))+ fabs( cimag( ctx->zload.seg_impedance[i]))) > 1.0e-20) {
@@ -526,6 +543,10 @@ int apply_impedance_loading(nec_context_t *ctx, int *ldtyp, int *ldtag, int *ldt
526543

527544
case 7:
528545
add_loading_output(ctx, ldtags, ldtagf[istepx], ldtagt[istepx], 0.0, zli[istepx], zlc[istepx], "LC-TRAP");
546+
break;
547+
548+
case 8:
549+
add_loading_output(ctx, ldtags, ldtagf[istepx], ldtagt[istepx], zlr[istepx], zli[istepx], 0.0, "INSULATED WIRE");
529550

530551
} /* switch( jump ) */
531552
} /* while( true ) */

src/control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static int process_next_batch(nec_context_t *ctx, deck_t *deck, int *batch_start
653653
continue;
654654
}
655655

656-
if (i1 > 6) {
656+
if (i1 > 7) {
657657
char msg[MAX_ERROR_LEN];
658658
snprintf(msg, sizeof(msg), "LD on line %d: type %d is not supported.", card_idx + 1, i1);
659659
add_error(ctx, &ctx->errors, msg, FATAL);

src/deck_validations.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ void test_deck_structure(const nec_context_t *ctx, const deck_t *deck, errors_li
561561
int tag = deck->cards[i].i[2];
562562
int seg1 = deck->cards[i].i[3];
563563
int seg2 = deck->cards[i].i[4];
564-
if (type < -1 || (type > 6 && type != -1))
564+
if (type < -1 || (type > 7 && type != -1))
565565
{
566566
snprintf(msg, sizeof(msg), "LD on line %d: unexpected type I1=%d.", i, type);
567567
add_error(ctx, errors, msg, 0);
@@ -597,6 +597,15 @@ void test_deck_structure(const nec_context_t *ctx, const deck_t *deck, errors_li
597597
add_error(ctx, errors, msg, 0);
598598
}
599599
}
600+
// LD type 7 (insulated wire): dielectric constant and coat radius are required
601+
if (deck->cards[i].ints_used >= 1 && deck->cards[i].i[1] == 7)
602+
{
603+
if (deck->cards[i].flts_used < 2 || deck->cards[i].f[1] <= 0.0 || deck->cards[i].f[2] <= 0.0)
604+
{
605+
snprintf(msg, sizeof(msg), "LD on line %d (insulated wire): F1 (dielectric constant) and F2 (coat radius) must be positive.", i);
606+
add_error(ctx, errors, msg, 0);
607+
}
608+
}
600609
}
601610
// record for open-end placement validation later (only for LD cards)
602611
if (strcmp(code, "LD") == 0 && deck->cards[i].ints_used >= 3)

test/ld7_insulated_test.deck

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CM Insulated wire test (LD type 7)
2+
CM Simple dipole with PVC insulation (diel=3.5) on tag 2; coat radius = 3mm
3+
CM Wire radius (GW) = 1mm, coating adds 2mm => outer radius = 0.003m
4+
CE
5+
GW 1 10 0 0 0 0.1 0 0 0.001
6+
GW 2 16 0.1 0 0 0.2 0 0 0.001
7+
GE 0
8+
FR 0 1 0 0 145
9+
LD 7 2 1 16 3.5 0.003
10+
EX 0 1 5 0 1 0
11+
RP 0 1 1 1000 90 0 0 0
12+
EN

0 commit comments

Comments
 (0)