当前位置: 首页>>代码示例>>C#>>正文


C# Sphere.Calculate方法代码示例

本文整理汇总了C#中Sphere.Calculate方法的典型用法代码示例。如果您正苦于以下问题:C# Sphere.Calculate方法的具体用法?C# Sphere.Calculate怎么用?C# Sphere.Calculate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sphere的用法示例。


在下文中一共展示了Sphere.Calculate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main( string[] args )
        {
            var appName = AppDomain.CurrentDomain.FriendlyName;

            bool needShowHelp = false;

            double anisotropy = Defaults.Anisotropy;
            double saturation = Defaults.Saturation;
            double particleRadius = Defaults.ParticleRadius;

            double dt = Defaults.Dt;
            double epsillon = Defaults.Epsillon;

            double clusterRadius = Defaults.ClusterRadius;

            double minH = Defaults.MinH;
            double maxH = Defaults.MaxH;
            double stepH = Defaults.StepH;

            int particlesCount = 40;
            Utils.VerbosityLevel++;

            var p = new OptionSet();
            p.Add( "n|particles-count=", "Count of particles.", (int v ) => particlesCount = v );

            p.Add( "a|anisotropy=", "Magnetic anisotropy of the material.", (double v ) => anisotropy = v );
            p.Add( "s|saturation=", "Magnetic saturation of the material.", (double v ) => saturation = v );
            p.Add( "p|particle-radius=", "Radius of a particular of the material.", (double v ) => particleRadius = v );

            p.Add( "d|dt=", "", (double v ) => dt = v );
            p.Add( "e|epsillon=", "", (double v ) => epsillon = v );

            p.Add( "c|cluster-radius=", "Radius of the sphere.", (double v ) => clusterRadius = v );

            p.Add( "min=", "Min value of H.", (double v ) => minH = v );
            p.Add( "max=", "Max value of H.", (double v ) => maxH = v );
            p.Add( "step=", "Step for H.", (double v ) => stepH = v );

            p.Add( "h|help", "Show this message and exit", v => needShowHelp = v != null );
            p.Add( "v", "Increase debug message verbosity",
                v => {
                    if( v != null )
                    {
                        Utils.VerbosityLevel++;
                    }
                } );
            
            try
            {
                p.Parse( args );
            }
            catch( OptionException e )
            {
                Console.Write( appName + ": " );
                Console.WriteLine( e.Message );
                Console.WriteLine( "Try `" + appName + " --help' for more information." );
                return;
            }

            if( needShowHelp )
            {
                Usage( appName, p );
                return;
            }

            if( particlesCount <= 0 )
            {
                Console.Write( appName + ": " );
                Console.WriteLine( "Count of the particles must be positive" );
                Console.WriteLine( "Try `" + appName + " --help' for more information." );
                return;
            }

            var material = new Material( anisotropy, saturation, particleRadius );

            var cluster = new Sphere( clusterRadius );

            // Generate particles
            cluster.Particles = Utils.GenerateRandromParticlesInSphere( material, clusterRadius, particlesCount );

            var results = new Dictionary<double, double>();

            for( var i = minH; i <= maxH; i += stepH )
            {
                if( Math.Abs( i ) < double.Epsilon )
                {
                    //continue;
                }

                var externalMagneticField = new Vector( i, 0, 0 );

                var magneticMomentAverage = cluster.Calculate( externalMagneticField, dt, epsillon );

                results.Add( i, magneticMomentAverage.X );
            }

            Console.WriteLine( "Results:" );
            foreach( var pair in results )
            {
                Console.WriteLine( "ExternalMagneticField:\t" + pair.Key + "\tEffectiveMagneticField:\t" + pair.Value );
//.........这里部分代码省略.........
开发者ID:VarLog,项目名称:nano_magnetic.net,代码行数:101,代码来源:Program.cs


注:本文中的Sphere.Calculate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。