/* This is the one-node variant of the transientCapacitanceC() function. It performs the same steps for a single voltage node related to ground. */ void circuit::transientCapacitanceC2Q (int qpos, int qneg, int vpos, nr_double_t cap, nr_double_t voltage) { nr_double_t g, i; conductor (cap, g); addY (qpos, vpos, +g); addY (qneg, vpos, -g); i = pol * (g * voltage); addI (qpos , +i); addI (qneg , -i); }
/* The function performs a single integration step of the given charge located between the given nodes. It saves the current contributions of the charge itself and considers the polarity of the circuit. */ void circuit::transientCapacitanceQ (int qstate, int qpos, int qneg, nr_double_t charge) { nr_double_t unused, i; int cstate = qstate + 1; setState (qstate, charge); integrate (qstate, 0, unused, unused); i = pol * getState (cstate); addI (qpos , -i); addI (qneg , +i); }
/* The function runs the necessary calculation in order to perform a single integration step of a voltage controlled capacitance placed in between the given nodes. It is assumed that the appropiate charge only depends on the voltage between these nodes. */ void circuit::transientCapacitance (int qstate, int pos, int neg, nr_double_t cap, nr_double_t voltage, nr_double_t charge) { nr_double_t g, i; int cstate = qstate + 1; setState (qstate, charge); integrate (qstate, cap, g, i); addY (pos, pos, +g); addY (neg, neg, +g); addY (pos, neg, -g); addY (neg, pos, -g); i = pol * (getState (cstate) - g * voltage); addI (pos , -i); addI (neg , +i); }
int testDatastruct() { Sample * sample = (Sample *)malloc(sizeof(Sample)); sample->x = 0.1; sample->y = 0.2; sample->z = 0.3; LinkedList * list = makeList(); printf("APPENDING TEST...\n"); for (int i = 0; i < 100; i++) { add(*sample, list); } toStringList(list); printf("\n"); printf("SANDWICHING TEST...\n"); for (int i = 0; i < 100; i++) { addI(i, *sample, list); } toStringList(list); printf("Getting x series...\n"); acc * xs = getSubSeries(X, 0, list->count - 1, list); acc * current = xs; while ((long)(*(current++)) != TERMINATION_VALUE) { printf("next: %2.3f\n", *current); } puts("Finished."); getchar(); }