Пример #1
0
batch_run() /* avoid interpreter overhead */
{
	double tstop, tstep, tnext;
	char* filename;
	char* comment;

	tstopunset;
	tstop = chkarg(1,0.,1e20);
	tstep = chkarg(2, 0., 1e20);
	if (ifarg(3)) {
		filename = gargstr(3);
	}else{
		filename = 0;
	}
	if (ifarg(4)) {
		comment = gargstr(4);
	}else{
		comment = "";
	}
	
	if (tree_changed) {
		setup_topology();
	}
#if VECTORIZE
	if (v_structure_change) {
		v_setup_vectors();
	}
#endif
	batch_open(filename, tstop, tstep, comment);
	batch_out();
	if (cvode_active_) {
		while (t < tstop) {
			cvode_fadvance(t+tstep);
			batch_out();
		}
	}else{
		tstep -= dt/4.;
		tstop -= dt/4.;
		tnext = t + tstep;
		while (t < tstop) {
			nrn_fixed_step();
			if (t > tnext) {
				batch_out();
				tnext = t + tstep;
			}
			if (stoprun) { tstopunset; break; }
		}
	}
	batch_close();
	ret(1.);
}
Пример #2
0
int main(int argc, char** argv) {
	MPI_Init(&argc, &argv);
	int rank, size;
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &size);
	assert_valid_configuration(size);
	setup_topology(rank);

	if (rank == 0) {
		top_main(rank);
	} else if (rank < size - 1) {
		middle_main(rank);
	} else {
		bottom_main(rank);
	}
	MPI_Finalize();
	return 0;
}
Пример #3
0
fcurrent()
{
	int i;
	if (tree_changed) {
		setup_topology();
	}
	if (v_structure_change) {
		v_setup_vectors();
	}
	if (diam_changed) {
		recalc_diam();
	}

	dt2thread(-1.);
	nrn_thread_table_check();
	state_discon_allowed_ = 0;
	nrn_multithread_job(setup_tree_matrix);
	state_discon_allowed_ = 1;
	ret(1.);
}
Пример #4
0
fadvance()
{
	tstopunset;
#if CVODE
	if (cvode_active_) {
		cvode_fadvance(-1.);
		tstopunset;
		ret(1.);
		return;
	}
#endif
	if (tree_changed) {
		setup_topology();
	}
	if (v_structure_change) {
		v_setup_vectors();
	}
	if (diam_changed) {
		recalc_diam();
	}
	nrn_fixed_step();
	tstopunset;
	ret(1.);
}
Пример #5
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];
			}
		}
	}