コード例 #1
0
        public void TestIssue1()
        {
            var qs = qsrt.GetEngine("Qs");

            // tell qs evaluator that we have external place for variables

            Qs.Runtime.QsEvaluator.CurrentEvaluator.Scope.RegisterScopeStorage("CircleStorage", new CircleStorage());

            var ev = Qs.Runtime.QsEvaluator.CurrentEvaluator;

            DimensionlessQuantity <double> g = 34.2;
            DimensionlessQuantity <string> h = "hello there";

            dynamic r = qs.Execute("_circle->Particles[10]->M");

            //qs.Execute("_c[55]=20");
            qs.Execute("_c->Tag =\"hello\"");

            qs.Execute("_c->RedCircle->Tag=\"hello\"");

            qs.Execute("_c->RedCircle->Particles[20]->M=30");

            var ms = (QsScalar)ev.Evaluate("_c->RedCircle->Particles[20]->M");

            Assert.AreEqual(ms.NumericalQuantity.Value, 30);



            qs.Execute("_c->RedCircle[10]=20");
            var s = (QsScalar)ev.Evaluate("_c->RedCircle[10]");

            Assert.AreEqual(s.NumericalQuantity.Value, 20);
        }
コード例 #2
0
        public static QsVector Func(QsFunction f, DimensionlessQuantity <double> from, DimensionlessQuantity <double> to)
        {
            var      increment = (to - from) / (40).ToQuantity();
            QsVector v         = new QsVector(40);

            for (AnyQuantity <double> dt = from; dt <= to; dt += increment)
            {
                v.AddComponent(f.Invoke(dt).ToScalar());
            }

            return(v);
        }