Exemplo n.º 1
0
        private IMifEnergy CreateCubicAnisotropy(string[] lines)
        {
            string          name   = helper.GetName(lines[0]);
            int             number = helper.GetIndexOfStringContaining(lines, "K1");
            var             textK1 = helper.GetCodeToClosingBrace(lines, number, '{');
            IMifScalarField k1     = scalarFieldFactory.Create(textK1);

            number = helper.GetIndexOfStringContaining(lines, "axis1");
            var             textAxis = helper.GetCodeToClosingBrace(lines, number, '{');
            IMifVectorField axis1    = vectorFieldFactory.Create(textAxis);

            number   = helper.GetIndexOfStringContaining(lines, "axis2");
            textAxis = helper.GetCodeToClosingBrace(lines, number, '{');
            IMifVectorField axis2 = vectorFieldFactory.Create(textAxis);

            return(new CubicAnisotropy(name, k1, axis1, axis2));
        }
        private IMifEnergy CreateTwoSurfaceExchange(string[] lines)
        {
            Surface surface1, surface2;
            double  sigma1, sigma2;
            string  name        = _helper.GetName(lines[0]);
            var     index       = _helper.GetIndexOfStringContaining(lines, _surface1);
            var     surfaceText = _helper.GetCodeToClosingBrace(lines, index, '{');

            surface1    = CreateSurface(surfaceText);
            index       = _helper.GetIndexOfStringContaining(lines, _surface2);
            surfaceText = _helper.GetCodeToClosingBrace(lines, index, '{');
            surface2    = CreateSurface(surfaceText);
            var sigmaText = GetValueOf(_sigma, lines);

            sigma1    = double.Parse(sigmaText);
            sigmaText = GetValueOf(_sigma + "2", lines);
            sigma2    = double.Parse(sigmaText);

            return(new TwoSurfaceExchange(name, sigma1, sigma2, surface1, surface2));
        }
Exemplo n.º 3
0
        private IMifEnergy CreateUZeeman(string[] text)
        {
            string name       = _helper.GetName(text[0]);
            var    index      = _helper.GetIndexOfStringContaining(text, hRange);
            var    list       = GetHRange(_helper.GetCodeToClosingBrace(text, index, '{'));
            var    multiplier = text.Where(s => s.Contains(_multiplier)).
                                Select(s => s.Substring(s.IndexOf(_multiplier) + _multiplier.Length)).FirstOrDefault();

            multiplier = multiplier.Replace(" ", "");
            double multiplierValue = double.Parse(multiplier);

            return(new UZeeman(name, multiplierValue, list));
        }
        private IMifVectorField CreateAtlasField(string[] lines)
        {
            string atlas = lines.Where(s => s.Contains("atlas")).FirstOrDefault();
            var atlasIEnumerable = atlas.Select((c, i) => new { c, i }).
                Where((c, i) => i > atlas.IndexOf(':')).Select(s => s.c);
            atlas = string.Concat(atlasIEnumerable).Replace(" ", "");
            string valueVectorString = lines.Where(s => s.Contains("default_value"))
                .FirstOrDefault().Replace("default_value", "");
            Vector vector = CreateVector(valueVectorString);
            int lineNumber = helper.GetIndexOfStringContaining(lines, "values");
            var text = helper.GetCodeToClosingBrace(lines, lineNumber, '{');
            text = helper.RemoveFromText(text, "{", "}");
            var list = new List<(string, Vector)>();
            for (int i = 1; i < text.Length - 1; i++)
            {
                var values = text[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                list.Add((values[0],new Vector(double.Parse(values[1]), double.Parse(values[2]),
                    double.Parse(values[3]))));
            }


            return new AtlasVectorField(new AtlasNameOnly(atlas), vector, list);
        }