This paper presents a mean-field solution for a one-dimensional spin Hamiltonian in the presence of spatially varying interactions and external field. In a binary alloy, such inhomogeneous interactions appear in the presence of a grain boundary. We derive the model and place it in the context of previous theories. We show how our theory is a natural extension of traditional segregation isotherm models, with the advantages that much finer detail can be observed and that no assumption is required about the grain boundary binding energy. Solving the model requires finding the global minimum of a function of several hundred variables and yields detailed concentration profiles in the presence of spatially inhomogeneous and long-range interactions. We apply the theory to the system of copper with bismuth impurities and observe on an atomic scale how the extent of segregation varies with temperature. The results predict that with lower temperature the impurity concentration in a given layer increases, the segregant peak broadens, and ordering can occur within the boundary. The results also indicate that the presence of segregation at the grain boundary can serve as a nucleus for order-disorder phase transitions in the bulk.