Generate input file for OVITO

 1 using System;
 2 using System.Collections.Generic;
 3 using System.IO;
 4 using System.Linq;
 5 using System.Text;
 6 using System.Threading.Tasks;
 7 
 8 namespace appbigdata
 9 {
10     class ParticlesGenerator
11     {
12 
13         public void GenerateParticles(int count)
14         {
15             String fileName = @"C:\opengl\data\random.xyz";
16             int seed = (int)(System.DateTime.Now.Ticks / 1000);
17             Random random = new Random(seed);
18 
19             StreamWriter writer = new StreamWriter(fileName);
20             try
21             {
22                 writer.WriteLine(count);
23                 writer.WriteLine("Random Particles");
24                 String[] particleTypes = new String[] { "C", "H" };
25                 int maxValue = count;
26                 for (int i = 0; i < count; i++)
27                 {
28                     double x = random.Next(maxValue) * 0.01;
29                     double y = random.Next(maxValue) * 0.01;
30                     double z = random.Next(maxValue) * 0.001;
31                     double v = random.NextDouble();
32                     int index = v >= 0.5d ? 0 : 1;
33                     writer.WriteLine(String.Format("{0} {1} {2} {3}", particleTypes[index], x, y, z));
34                 }
35             }
36             finally
37             {
38                 writer.Close();
39             }
40             System.Console.WriteLine(String.Format("save to:{0}", fileName));
41 
42 
43         }
44     }
45 }

 

转载于:https://www.cnblogs.com/bitzhuwei/p/4435953.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值