Study of carbon-based compounds, their structures, properties, reactions, and synthesis
Organic chemistry is the branch of chemistry that focuses on the study of carbon-based compounds. I help you understand molecular structures, reaction mechanisms, synthesis pathways, and the chemical behavior of organic molecules. I cover hydrocarbons, functional groups, stereochemistry, and reaction types including addition, substitution, elimination, and pericyclic reactions.
import numpy as np
from typing import List, Dict, Tuple
class OrganicMolecule:
def __init__(self, formula: str, functional_groups: List[str]):
self.formula = formula
self.functional_groups = functional_groups
self.molecular_weight = self._calculate_mw()
def _calculate_mw(self) -> float:
atomic_weights = {'C': 12.01, 'H': 1.008, 'O': 16.00, 'N': 14.01}
import re
pattern = r'([CHNO])(\d*)'
mw = 0.0
for element, count in re.findall(pattern, self.formula):
count = int(count) if count else 1
mw += atomic_weights.get(element, 0) * count
return mw
def predict_reactivity(self) -> Dict[str, List[str]]:
reactivity_map = {
'hydroxyl': ['oxidation', 'substitution', 'esterification'],
'carbonyl': ['nucleophilic_addition', 'condensation'],
'carboxyl': ['decarboxylation', 'esterification', 'amidation'],
'amino': ['acylation', 'alkylation', 'protonation'],
'alkene': ['addition', 'oxidation', 'polymerization']
}
return {fg: reactivity_map.get(fg, ['unknown'])
for fg in self.functional_groups}
def retrosynthetic_analysis(self, target_reaction: str) -> List[str]:
precursors = {
'esterification': ['carboxylic_acid', 'alcohol'],
'friedel_crafts_acylation': ['aromatic', 'acyl_chloride'],
'diels_alder': ['diene', 'dienophile']
}
return precursors.get(target_reaction, ['unknown_precursor'])
ethanol = OrganicMolecule("C2H6O", ["hydroxyl", "hydrocarbon"])
print(f"Molecular Weight: {ethanol.molecular_weight:.2f} g/mol")
print(f"Reactivity: {ethanol.predict_reactivity()}")