public ChemicalComposition getCompositionFromElements(List <ChemicalElement> _elements)
        {
            ChemicalComposition newComposition = new ChemicalComposition();

            for (int n = 0; n < _elements.Count; n++)
            {
                newComposition.addElementToComposition(_elements[n], this.get_percentage_per_element(_elements[n]));
            }

            return(newComposition);
        }
Example #2
0
        private void initAtmoSphere(Boolean _isBlackBody = true, int iterations = 10)
        {
            double R, T, M, m;

            R = 8.314462618;
            T = this.Surface_temperature;
            ChemicalComposition composition = new ChemicalComposition();


            double          escapevelocity = Math.Pow((2 * ParametriUtente.Science.G * this.mass) / (this.planetRadius * 1000), (1.0 / 2.0));
            ChemicalElement element        = null;

            for (int i = 0; i < 3; i++)
            {
                ChemicalElement local_element = this.body_composition.getRandomElement_PerType(ElementState.Gas);
                if ((element != null && element.name.Equals(local_element.name)) || (local_element == null))
                {
                    continue;
                }

                element = local_element;

                double percentage = this.body_composition.get_percentage_per_element(element) / 100;

                if (composition.getElementFromName(element.name) == null)
                {
                    composition.addElementToComposition(element, percentage);
                }

                m = element.mass / 1000;
                M = m;
                double meanVelocityForElement = Math.Pow((2 * R * T) / M, (1.0 / 2.0));

                if (meanVelocityForElement > escapevelocity)
                {
                    composition.removeElementFromComposition(element, percentage);
                    this.body_composition.removeElementFromComposition(element, percentage);
                }
            }
            //prendi la lista di gas
            //scegli 3 gas
            // sqrt(2*R*T/M) dove R = gas constant T = Temperature K e M = mass dell'elemento/1000

            if (composition.elements_percentage_list.Count > 0)
            {
                hasAtmosphere = true;
            }

            this.applyChemicalBonds();
        }