void Neuron::calcError() { if (!error_recalc) return; error_recalc = false; calcEnergy(); double sum = 0; for (Link * i: outputs) { sum += i->getError(); } error = ::activation_function_derivative(energy) * sum; }
void outputData(Tsph & sph) { if(RP::Time >= RP::TimeAscii) { char filename[64]; sprintf(filename, "snap/sph_t%04d.dat", RP::NumberOfAscii); sph.writeParticleAscii(filename); RP::TimeAscii += RP::TimestepAscii; RP::NumberOfAscii++; } PS::F64 etot = calcEnergy(sph); PS::F64vec vtot = calcMomentum(sph); if(PS::Comm::getRank() == 0) { fprintf(RP::FilePointerForLog, "time: %.10f %+e %+e %+e %+e\n", RP::Time, RP::Timestep, etot, vtot[0], WT::getTimeTotal()); WT::dump(RP::Time, RP::FilePointerForTime); fflush(RP::FilePointerForLog); } }
void fill_stdhep(int i) { int j, k, num; num = i * 20; hepevt_.nevhep = i; hepevt_.nhep = num; for (j = 0; j < num; j++) { hepevt_.idhep[j] = 211; hepevt_.isthep[j] = 1; for (k = 0; k < 2; k++) { hepevt_.jmohep[j][k] = j - 1; hepevt_.jdahep[j][k] = j + 1; } for (k = 0; k < 3; k++) hepevt_.phep[j][k] = 10.2 * k + 0.31 * i; hepevt_.phep[j][4] = .511 + i * 0.04; hepevt_.phep[j][3] = calcEnergy(j); for (k = 0; k < 4; k++) hepevt_.vhep[j][k] = .0001; } }
int main(int argc, char *argv[]) { PS::F32 time = 0.0; PS::F32 tend = 10.0; PS::F32 dtime = 1.0 / 128.0; PS::F32 dtout = 1.0 / 8.0; PS::S64 ntot = 1024; PS::Initialize(argc, argv); PS::DomainInfo dinfo; dinfo.initialize(); PS::ParticleSystem<FPGrav> system_grav; system_grav.initialize(); PS::TreeForForceLong<FPGrav, FPGrav, FPGrav>:: Monopole tree_grav; tree_grav.initialize(ntot); setParticleColdUniformSphere(system_grav, ntot); dinfo.decomposeDomainAll(system_grav); system_grav.exchangeParticle(dinfo); tree_grav.calcForceAllAndWriteBack (CalcGravity<FPGrav>(), CalcGravity<PS::SPJMonopole>(), system_grav, dinfo); PS::F64 etot0 = calcEnergy(system_grav); if(PS::Comm::getRank() == 0) { fprintf(stderr, "time: %10.7f energy: %+e energy error: %+e\n", time, etot0, (etot0 - etot0) / etot0); } while(time < tend) { predict(system_grav, dtime); dinfo.decomposeDomainAll(system_grav); system_grav.exchangeParticle(dinfo); tree_grav.calcForceAllAndWriteBack (CalcGravity<FPGrav>(), CalcGravity<PS::SPJMonopole>(), system_grav, dinfo); correct(system_grav, dtime); time += dtime; PS::F64 etot1 = calcEnergy(system_grav); if(fmod(time, dtout) == 0.0 && PS::Comm::getRank() == 0) { fprintf(stderr, "time: %10.7f energy: %+e energy error: %+e\n", time, etot1, (etot1 - etot0) / etot0); } } PS::Finalize(); return 0; }
double Neuron::getSignal() { calcEnergy(); return energy; }