Example #1
0
bool SaveState::check(bool warn) {
	hoc_Item* qsec;
	int isec;
	if (nsec_ != section_count) {
		if (warn) {
fprintf(stderr, "SaveState warning: %d sections exist but saved %d\n",
			section_count, nsec_);
		}
		return false;
	}
	if (nroot_ != nrn_global_ncell) {
		if (warn) {
fprintf(stderr, "SaveState warning: %d cells exist but saved %d\n",
			nrn_global_ncell, nroot_);
		}
		return false;
	}
	if (nsec_ && ss_[0].sec == NULL) { // got the data from a read
		isec = 0; ForAllSections(sec)
			ss_[isec].sec = sec;
			section_ref(ss_[isec].sec);
			++isec;
		}
	}
Example #2
0
method3_connection_coef()	/* setup a and b */
{
	int j;
	double dx, diam, ra, coef;
	hoc_Item* qsec;
	Section* sec;
	Node *nd;
	Prop *p, *nrn_mechanism();
	float r, s, t;
	
	if (tree_changed) {
		setup_topology();
	}
/* for now assume diameter between node and parent is constant and located at the node */

	/* r = 6 is standard method, 5 is third order, 4 is modified second order */
	switch (_method3) {
	case 1:
		r = 6.;
		break;
	case 2:
		r = 4.;
		break;
	case 3:
		r = 5.;
		break;
	default:
		hoc_execerror(" invalid spatial method", (char*)0);
	}
	s = 6. - r;
	if (r == 5.) {
		t = 1.;
	}else{
		t = 0.;
	}

	ForAllSections(sec)
		dx = section_length(sec)/((double)(sec->nnode));
		for (j = 0; j < sec->nnode; ++j) {
			nd = sec->pnode[j];
			p = nrn_mechanism(MORPHOLOGY, nd);
			assert(p);
			diam = p->param[0];
			/* dv/(ra*dx) is nanoamps */
			ra = nrn_ra(sec)*4.e-2/(PI * diam*diam);
			/* coef*dx* mA/cm^2 should be nanoamps */
			coef = PI *1e-2* diam;

			nd->area = 100.;
			sec->parentnode->area = 100.;

			nd->toparent.coef0 = coef*r*dx/12.;
			nd->fromparent.coef0 = coef*r*dx/12.;
			nd->toparent.coefn = coef*s*dx/12.;
			nd->fromparent.coefn = coef*s*dx/12.;
			nd->toparent.coefjdot = t*ra*coef*dx*dx/12.;
			nd->fromparent.coefjdot = t*ra*coef*dx*dx/12.;
			nd->toparent.coefdg = t*coef*dx/12.;
			nd->fromparent.coefdg = t*coef*dx/12.;
			nd->toparent.coefj = 1./(ra*dx);
			nd->fromparent.coefj = 1./(ra*dx);
			nd->toparent.nd2 = 0;
			nd->fromparent.nd2 = 0;
		}
		if (sec->nnode > 1) {
			sec->pnode[0]->toparent.nd2 = sec->pnode[1];
			if (sec->nnode > 2) {
				sec->pnode[sec->nnode - 2]->fromparent.nd2 =
					sec->pnode[sec->nnode - 3];
			}else{
			   sec->pnode[sec->nnode - 2]->fromparent.nd2 =
				sec->parentsec->pnode[sec->parentsec->nnode - 1];
			}
		}
	}