Implemented critical property combining in parallel for devices
such as resistors.
This commit is contained in:
parent
17c2bff72b
commit
618f912cac
|
|
@ -3302,6 +3302,7 @@ void PropertyOptimize(struct objlist *ob, struct nlist *tp)
|
||||||
ptop = NULL;
|
ptop = NULL;
|
||||||
pcount = 1;
|
pcount = 1;
|
||||||
crit = -1;
|
crit = -1;
|
||||||
|
ctype = -1;
|
||||||
kl = (struct property *)HashFirst(&(tp->propdict));
|
kl = (struct property *)HashFirst(&(tp->propdict));
|
||||||
while (kl != NULL) {
|
while (kl != NULL) {
|
||||||
// Make a linked list so we don't have to iterate through the hash again
|
// Make a linked list so we don't have to iterate through the hash again
|
||||||
|
|
@ -3319,8 +3320,10 @@ void PropertyOptimize(struct objlist *ob, struct nlist *tp)
|
||||||
// Set critical property index, if there is one (TO-DO: Handle types
|
// Set critical property index, if there is one (TO-DO: Handle types
|
||||||
// other than MERGE_ADD_CRIT, and deal with possibility of multiple
|
// other than MERGE_ADD_CRIT, and deal with possibility of multiple
|
||||||
// critical properties per instance).
|
// critical properties per instance).
|
||||||
if (kl->merge == MERGE_ADD_CRIT) crit = kl->idx;
|
if (kl->merge == MERGE_ADD_CRIT) {
|
||||||
|
crit = kl->idx;
|
||||||
|
ctype = kl->merge;
|
||||||
|
}
|
||||||
kl = (struct property *)HashNext(&(tp->propdict));
|
kl = (struct property *)HashNext(&(tp->propdict));
|
||||||
}
|
}
|
||||||
// Recast the linked list as an array
|
// Recast the linked list as an array
|
||||||
|
|
@ -3473,11 +3476,25 @@ void PropertyOptimize(struct objlist *ob, struct nlist *tp)
|
||||||
vlist[0][j] = &nullvl; // Mark this position
|
vlist[0][j] = &nullvl; // Mark this position
|
||||||
if (crit >= 0) {
|
if (crit >= 0) {
|
||||||
vl = vlist[crit][i];
|
vl = vlist[crit][i];
|
||||||
|
if (ctype == MERGE_ADD_CRIT) {
|
||||||
if (vl->type == PROP_INTEGER)
|
if (vl->type == PROP_INTEGER)
|
||||||
vl->value.ival += vlist[crit][j]->value.ival;
|
vl->value.ival += vlist[crit][j]->value.ival;
|
||||||
else if (vl->type == PROP_DOUBLE)
|
else if (vl->type == PROP_DOUBLE)
|
||||||
vl->value.dval += vlist[crit][j]->value.dval;
|
vl->value.dval += vlist[crit][j]->value.dval;
|
||||||
}
|
}
|
||||||
|
else { /* MERGE_PAR_CRIT */
|
||||||
|
if (vl->type == PROP_INTEGER) {
|
||||||
|
double di = vl->value.ival;
|
||||||
|
double dj = vlist[crit][j]->value.ival;
|
||||||
|
di = 1.0 / (1.0 / di + 1.0 / dj);
|
||||||
|
vl->value.ival = (int)di;
|
||||||
|
}
|
||||||
|
else if (vl->type == PROP_DOUBLE) {
|
||||||
|
vl->value.dval += 1.0 / (1.0 / vl->value.dval +
|
||||||
|
1.0 / vlist[crit][j]->value.dval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
vlist[0][i]->value.ival++;
|
vlist[0][i]->value.ival++;
|
||||||
}
|
}
|
||||||
|
|
@ -3485,6 +3502,7 @@ void PropertyOptimize(struct objlist *ob, struct nlist *tp)
|
||||||
else if (vlist[0][i]->value.ival > 0) {
|
else if (vlist[0][i]->value.ival > 0) {
|
||||||
if (crit >= 0) {
|
if (crit >= 0) {
|
||||||
vl = vlist[crit][i];
|
vl = vlist[crit][i];
|
||||||
|
if (ctype == MERGE_ADD_CRIT) {
|
||||||
if (vl->type == PROP_INTEGER)
|
if (vl->type == PROP_INTEGER)
|
||||||
vl->value.ival += vlist[0][j]->value.ival *
|
vl->value.ival += vlist[0][j]->value.ival *
|
||||||
vlist[crit][j]->value.ival;
|
vlist[crit][j]->value.ival;
|
||||||
|
|
@ -3492,6 +3510,20 @@ void PropertyOptimize(struct objlist *ob, struct nlist *tp)
|
||||||
vl->value.dval += (double)vlist[0][j]->value.ival *
|
vl->value.dval += (double)vlist[0][j]->value.ival *
|
||||||
vlist[crit][j]->value.dval;
|
vlist[crit][j]->value.dval;
|
||||||
}
|
}
|
||||||
|
else { /* MERGE_PAR_CRIT */
|
||||||
|
if (vl->type == PROP_INTEGER) {
|
||||||
|
double d = (double)vlist[crit][j]->value.ival /
|
||||||
|
(double)vlist[0][j]->value.ival;
|
||||||
|
vl->value.ival = (int)(1.0 / (1.0 / (double)vl->value.ival
|
||||||
|
+ 1.0 / d));
|
||||||
|
}
|
||||||
|
else if (vl->type == PROP_DOUBLE) {
|
||||||
|
double d = vlist[crit][j]->value.dval /
|
||||||
|
(double)vlist[0][j]->value.ival;
|
||||||
|
vl->value.dval = 1.0 / (1.0 / vl->value.dval + 1.0 / d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
vlist[0][i]->value.ival += vlist[0][j]->value.ival;
|
vlist[0][i]->value.ival += vlist[0][j]->value.ival;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3029,6 +3029,9 @@ _netcmp_property(ClientData clientData,
|
||||||
PropertyDelete(tp->name, tp->file, "ps");
|
PropertyDelete(tp->name, tp->file, "ps");
|
||||||
PropertyDelete(tp->name, tp->file, "pd");
|
PropertyDelete(tp->name, tp->file, "pd");
|
||||||
break;
|
break;
|
||||||
|
case CLASS_CAP: case CLASS_ECAP: case CLASS_CAP3:
|
||||||
|
PropertyMerge(tp->name, tp->file, "value", MERGE_ADD_CRIT);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
tp = NextCell();
|
tp = NextCell();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue