public void IsomerGammaEmission(Particle p, double deltaDepth, int i) { Random random = new Random(); double pp = SimpleRNG.GetUniform(); if (pp < pp_IsomerGammaEmission(deltaDepth, i)) { Particle p_gamma = new Particle(p_type.photon); list_newParticles.Add(p_gamma); } }
public void NewParticles(Particle p, double deltaDepth, int i) { if (p.p_t != p_type.neutron || p.p_t != p_type.proton) { Random random = new Random(); double pp = SimpleRNG.GetUniform(); if (pp < 0.01) // improve the prob. of fragmentation { list_removeParticles.Add(p); // the primary disappears int n_products = 10; // should be a random number of secondaries for (int j = 0; j < n_products / 2; j++) { Particle p_born = new Particle(p_type.proton); // a constructor for a proton; later add more secondaries, like neutrons, light ions, etc. list_newParticles.Add(p_born); } for (int j = 0; j < n_products / 2; j++) { Particle p_born = new Particle(p_type.neutron); // a constructor for a proton; later add more secondaries, like neutrons, light ions, etc. list_newParticles.Add(p_born); } //double z = p.Z - 2; // crude model of fragmentation // zzz //double e = 0.8 * p.E; //double a = p.A - n_products / 2; //Particle p_primary_frag; //if (p.GetPtype(a, z, e) == p_type.not_known) //{ // p_primary_frag = new Particle(); // p_primary_frag.Initialize(a, z, e); //} //else // p_primary_frag = new Particle(p.GetPtype(a, z, e)); // primary fragment //list_newParticles.Add(p_primary_frag); //Particle p_target_frag = new Particle(); //p_target_frag.Initialize(14 + 13 - n_products / 2, 13 - 2, 0.2 * p.E); // give it Al A, Z, E for now // target fragment //list_newParticles.Add(p_target_frag); } } }
// public static bool ApplyRad2RWs(RadiationSchema rs, RandomWalk rw, DSBs DSBdata) { int ndsb = 0; try { double dose; double dose_total = 0.0; for (int nb = 0; nb < rs.nBeams; nb++) // iterate over all beams { foreach (int j in rw.nmonomer) { dose = Dconst; dose_total += Dconst; try { for (int i = 0; i < amorphous_partile_tracks[nb].track_struct.ntracks; i++) { int x = amorphous_partile_tracks[nb].track_struct.X[i]; int y = amorphous_partile_tracks[nb].track_struct.Y[i]; int dist2 = (x - rw.LL[j].X) * (x - rw.LL[j].X) + (y - rw.LL[j].Y) * (y - rw.LL[j].Y); if (dist2 < Convert.ToInt32((RadiationSchema.Pr / lattice_dim) * (RadiationSchema.Pr / lattice_dim))) { int t = Convert.ToInt32(MainForm.Particle.Tracks.grid * lattice_dim * Math.Sqrt(dist2) / RadiationSchema.Pr); // microns dose += amorphous_partile_tracks[nb].track_struct.dose[t]; dose_total += amorphous_partile_tracks[nb].track_struct.dose[t]; } } } catch { return(false); } double Q = 0.812 * 35.0 / 25.0; // multiply by 35./25. for high/low LET; also 1e-5 is factored out if (amorphous_partile_tracks[nb].p_t == MainForm.Radiation.p_type.photon) { Q = 0.812; // multiply by 35./25. for high LET } else { Q = 0.812 * 35.0 / 25.0; // multiply by 35./25. for high LET } Q *= 1.0e-5; // Q is determined from PFGE experiments Random random = new Random(); try { if (SimpleRNG.GetUniform() < 1.0 - Math.Exp(-Q * dose)) { ndsb++; DSBs.DSBstruct new_dsb = new DSBs.DSBstruct { ndsb = ndsb, L = rw.LL[j], position = rw.nmonomer[j], entry_time = rs.entryTime[nb], exit_time = rs.exitTime[nb] }; new_dsb.random_time = SimpleRNG.GetUniform() * (new_dsb.exit_time - new_dsb.entry_time) + new_dsb.entry_time; // a DSB is created sometime during the fractionation interval double r = SimpleRNG.GetUniform(); if (r < DSBs.DSBcomplP[0]) { new_dsb.DSBcmplx = DSBs.DSBstruct.DSBcomplexity.simpleDSB; } else { if (r >= DSBs.DSBcomplP[0] && r < DSBs.DSBcomplP[1]) // zzz can a DSB appear more than 1 time at the same monomer { new_dsb.DSBcmplx = DSBs.DSBstruct.DSBcomplexity.DSBplus; } else { new_dsb.DSBcmplx = DSBs.DSBstruct.DSBcomplexity.DSBplusplus; } } DSBdata.listDSBs.Add(new_dsb); } } catch { return(false); } } } dose_total /= Convert.ToDouble(rw.nmonomer.Length); // total dose integrated over all monomers // zzz might wanna output somewhere return(true); } catch { return(false); } }
// public bool RestitutionKinetics(List <Object> listObjs) { // the class FreeEnds is derived from DSBs class and is based on DSBdata // Free_end class is for Objects (which are fragments that can have free ends) Random random = new Random(); try { for (int i = 0; i < Convert.ToInt32(expTime / tau); i++) // number of elementary time steps { if (!SplitObjects(listObjs, i * tau, (i + 1) * tau)) { return(false); // split only using DSBs avaibale in time interval timeIncrement / tau } int availableFreeEnds = 0; foreach (Object o in listObjs) { foreach (Free_end fe in o.md.f_e) { if (fe.FE_type == MetaData.FreeEndType.reactive) { availableFreeEnds++; } } } if (availableFreeEnds != 0) { for (int j = 0; j < availableFreeEnds / 2; j++) // cycle through all pairs of Free Ends in one elementary time step { int availableFreeEnds1 = 0; foreach (Object o in listObjs) { foreach (Free_end fe in o.md.f_e) { if (fe.FE_type == MetaData.FreeEndType.reactive) { availableFreeEnds1++; // determine the number of free ends, which are still reactive } } } int end1, end2; while (true) { end1 = random.Next(0, availableFreeEnds1); end2 = random.Next(0, availableFreeEnds1); if (end1 != end2) { break; } } int itemp = 0; Free_end freeend1 = null, freeend2 = null; foreach (Object o in listObjs) { bool b = false; foreach (Free_end fe in o.md.f_e) { if (fe.FE_type == MetaData.FreeEndType.reactive) { if (itemp == end1) { fe.Reacting = true; freeend1 = fe; b = true; break; } itemp++; } } if (b) { break; } } itemp = 0; foreach (Object o in listObjs) { bool b = false; foreach (Free_end fe in o.md.f_e) { if (fe.FE_type == MetaData.FreeEndType.reactive) { if (itemp == end2) { fe.Reacting = true; // this marks a free end for rejoining/misrejoining freeend2 = fe; b = true; break; } itemp++; } } if (b) { break; } } if (freeend1 != null && freeend2 != null) { if (freeend1.Position == freeend2.Position) // proper ends { if (SimpleRNG.GetUniform() < P) { Object o_new = new Object(); if (CreateMergedObj(o_new, listObjs)) // merge the chosen reactive ends in the chosen objects and remove the objs with this pair of free ends { listObjs.Add(o_new); // renumber bands in the whole genome int[] b_index = new int[46]; foreach (Object o in listObjs) { foreach (Band b in o.md.chromo_bands) { b_index[b.Chromo_num]++; b.Ordinal_number = b_index[b.Chromo_num]; } } } else { o_new = null; // this happens when one if the members of listObjs becomes a ring } } } else { if (SimpleRNG.GetUniform() < MisrejoiningProb(freeend1, freeend2)) { Object o_new = new Object(); if (CreateMergedObj(o_new, listObjs)) // merge the chosen reactive ends in the chosen objects { listObjs.Add(o_new); // renumber bands in the whole genome int[] b_index = new int[46]; foreach (Object o in listObjs) { foreach (Band b in o.md.chromo_bands) { b_index[b.Chromo_num]++; b.Ordinal_number = b_index[b.Chromo_num]; } } } else { o_new = null; // this happens when one if the members of listObjs becomes a ring } } } // if nothing happens de-activate free ends foreach (Object o in listObjs) { foreach (Free_end fe in o.md.f_e) { if (fe.Reacting) { fe.Reacting = false; } } } } } } } if (CheckDSBlist(DSBdata) && CheckObjList(listObjs)) { return(true); } else { return(false); } } catch { // merge failure Detailed_checkObjList(listObjs); Detailed_checkDSBlist(DSBdata); return(false); } }