-
Notifications
You must be signed in to change notification settings - Fork 415
Description
Молекулярне Ядро v1.0 50% licence and (структура, що замінює старий код)\n\n# Apache License 2.0\n# © 50% Самарчанц Руслан Андреевич 13.02.1987\n# Україна, Київська область, Київ. Батько Лаури.\n# Усі права та патентні положення — в інтересах власника.\n\nclass Atom:\n """Базовий атом поведінки."""\n def init(self, name, valency, charge=0, data=None):\n self.name = name\n self.valency = valency\n self.charge = charge\n self.data = data or {}\n\nclass Bond:\n """Зв'язок між атомами: single, double, resonance."""\n def init(self, atom_a, atom_b, bond_type="single", strength=1.0):\n self.a = atom_a\n self.b = atom_b\n self.type = bond_type\n self.strength = strength\n\nclass Molecule:\n """Молекула: модуль, що складається з атомів і зв'язків."""\n def init(self, name):\n self.name = name\n self.atoms = []\n self.bonds = []\n\n def add_atom(self, atom):\n self.atoms.append(atom)\n\n def bond(self, a, b, type="single", strength=1.0):\n self.bonds.append(Bond(a, b, type, strength))\n\nclass MolecularKernel:\n """Ядро, що працює як хімічна система."""\n def init(self):\n self.molecules = []\n\n def add_module(self, molecule):\n self.molecules.append(molecule)\n\n def react(self, mol_a, mol_b):\n """Створення нового функціонального модуля — хімічна реакція."""\n new = self.isotopes = {\n "D": {"mass": 2.014, "pos": np.array([0.0, 0.0, 0.0])},\n "T": {"mass": 3.016, "pos": np.array([0.0, 0.0, 1.1])}\n }\n\n self.approach_threshold = {k: 1.0 / math.sqrt(v["mass"]) for k, v in self.isotopes.items()}\n self.distances = self._compute_distances()\n self.energies = {pair: self._interaction_energy(d) for pair, d in self.distances.items()}\n self.state_vector = self._build_state_vector()\n self._build_tesseract()\n\n def _compute_distances(self):\n keys = list(self.isotopes.keys())\n d = {}\n for i in range(len(keys)):\n for j in range(i + 1, len(keys)):\n a, b = keys[i], keys[j]\n d[(a, b)] = np.linalg.norm(self.isotopes[a]["pos"] - self.isotopes[b]["pos"])\n return d\n\n def _interaction_energy(self, distance):\n return 1.0 / (distance + 1e-6)\n\n def _oscillate(self, amplitude=0.05):\n for iso in self.isotopes.values():\n iso["pos"] += np.random.uniform(-amplitude, amplitude, 3)\n\n def _tunneling_probability(self, distance, mass):\n return math.exp(-distance * math.sqrt(mass))\n\n def _build_state_vector(self):\n return {\n "chemistry": self.chemistry,\n "isotopes": self.isotopes,\n "distances": self.distances,\n "thresholds": self.approach_threshold,\n "energies": self.energies,\n "time": self.time\n }\n\n def _build_tesseract(self):\n chem_keys = list(self.chemistry.keys())\n for i, v in enumerate(self.vertices):\n substance = chem_keys[i % len(chem_keys)]\n self.nodes[v] = {"type": "chemical_state", "substance": substance, "data": self.chemistry[substance], "active": True}\n\n def get_neighbors(self, vertex):\n neighbors = []\n for i in range(4):\n n = list(vertex)\n n[i] = '1' if n[i] == '0' else '0'\n neighbors.append("".join(n))\n return neighbors\n\n def run_nuclear_fusion(self):\n pair = ("D", "T")\n d = self.distances[pair]\n prob = self._tunneling_probability(d, self.isotopes["D"]["mass"])\n if prob < 0.05:\n return 0.0\n\n mol = gto.Mole()\n mol.atom = "H 0 0 0; H 0 0 1.1"\n mol.basis = 'sto-3g'\n mol.spin = 0\n mol.build()\n mf = scf.RHF(mol)\n mf.kernel()\n\n fusion_yield = 17.6\n self.energy_total += fusion_yield\n return fusion_yield\n\n def cascade_step(self):\n for v in self.vertices:\n for n in self.get_neighbors(v):\n a = self.nodes[v]["data"]["role"]\n b = self.nodes[n]["data"]["role"]\n if {"strong_acid", "strong_base"} <= {a, b}:\n pass # нейтрализация\n self._oscillate()\n self.distances = self._compute_distances()\n self.run_nuclear_fusion()\n\n\n'