AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-729651

sacky0003's questions

Martin Hope
sacky0003
Asked: 2021-04-23 00:09:53 +0800 CST

如何在 perl 中处理格式?

  • -1

我想使用 Perl 脚本以两位小数写数字。这是我的代码。

#!/usr/bin/perl -w

print "Preparing input files\n";

$incr=0.10;

&prepare_input();

exit(0);

sub prepare_input() {
    
    $dist=3;
    while ($dist <= 23) { 
    print "Processing distral: $dist\n";
    &write_mdin0();
    &write_mdin1();
    &write_mdin2();
    &write_disang();
      $dist += $incr;
    }
}

sub write_mdin0 {
    open MDINFILE,'>', "min_mdin.$dist";
    print MDINFILE <<EOF;
#5000 step minimization for $dist ang
 &cntrl
  imin = 1,
  maxcyc=10000, ncyc = 5000,
  ntpr = 100, ntwr = 1000,
  ntf = 1, ntc = 1, cut = 10.0,
  ntb = 1, ntp = 0,
  nmropt = 1,
 &end
 &wt
  type='END',
 &end
DISANG=disang.$dist

EOF
    close MDINFILE;
}
sub write_mdin1 {
    open MDINFILE,'>', "equi_mdin.$dist";
    print MDINFILE <<EOF;
#10 ns NVT equilibration for $dist ang
 &cntrl
  imin = 0, ntx = 1, irest = 0,
  iwrap = 1,
  ntpr = 5000, ntwr = 50000, ntwx = 0,
  ntf = 2, ntc = 2, cut = 10.0,
  ntb = 2, nstlim = 5000000, dt = 0.002,
  tempi=0.0, temp0 = 300.0, ntt = 3,
  gamma_ln = 5.0,
  ntp = 1, pres0 = 1.0, taup = 5.0,
  nmropt = 1, ioutfm=1,
 &end
 &wt
  type='END',
 &end
DISANG=disang.$dist

EOF
    close MDINFILE;
}
sub write_mdin2 {
    open MDINFILE,'>', "prod_mdin.$dist";
    print MDINFILE <<EOF;
#20 ns NPT production for $dist ang
 &cntrl
  imin = 0, ntx = 5, irest = 1,
  iwrap = 1,
  ntpr = 10000, ntwr = 10000, ntwx = 10000,
  ntf = 2, ntc = 2, cut = 10.0,
  ntb = 2, nstlim = 10000000, dt = 0.002,
  temp0 = 300.0, ntt = 3,
  gamma_ln = 5.0,
  ntp = 1, pres0 = 1.0, taup = 5.0,
  nmropt = 1, ioutfm = 1,
 &end
 &wt
  type='DUMPFREQ', istep1=10,
 &end
 &wt
  type='END',
 &end
DISANG=disang.$dist
DUMPAVE=distance_$dist.dat
EOF
    close MDINFILE;
}
sub write_disang {
 $min   = sprintf "%4.6f", $dist;

    open DISANG,'>', "disang.$dist";
    print DISANG <<EOF;
#Harmonic restraints for $dist ang
 &rst iat=-1,-1,0
   r1=0.000000, r2=$min, r3=$min, r4=99.000000, rk2=5.00000, rk3=5.00000,
  IGR1(1)=1,IGR1(2)=5,IGR1(3)=17,IGR1(4)=19,IGR1(5)=21,IGR1(6)=34,IGR1(7)=36,IGR1(8)=38,IGR1(9)=53,IGR1(10)=55,IGR1(11)=57,IGR1(12)=69,IGR1(13)=71,IGR1(14)=73,IGR1(15)=90,IGR1(16)=92,IGR1(17)=94,IGR1(18)=112,
   IGR2(1)=116,IGR2(2)=120,IGR2(3)=132,IGR2(4)=134,IGR2(5)=136,IGR2(6)=149,IGR2(7)=151,IGR2(8)=153,IGR2(9)=168,IGR2(10)=170,IGR2(11)=172,IGR2(12)=184,IGR2(13)=186,IGR2(14)=188,IGR2(15)=205,IGR2(16)=207,IGR2(17)=209,IGR2(18)=227, 
  nstep1=0, nstep2=0,
 &end
EOF
    close DISANG;
}

这些代码生成这种文件:

min_mdin.8.99999999999998
min_mdin.9.09999999999998

我的目标是生成以下类型的文件:

min_mdin.9.00
min_mdin.9.10
perl
  • 1 个回答
  • 41 Views
Martin Hope
sacky0003
Asked: 2018-05-16 06:37:42 +0800 CST

python numpy 或 scipy 错误

  • 0

我想在 python 中工作。当我导入 scipy 或 numpy 时,它会显示以下错误:

saikat@saikat:~/Downloads/Python-2.7.15$ python
Python 2.7.14 |Anaconda, Inc.| (default, Dec  7 2017, 17:05:42) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> 

但是当我使用这个命令时:

sudo pip install numpy scipy

表明:

saikat@saikat:~/Downloads/Python-2.7.15$ sudo pip install numpy scipy
The directory '/home/saikat/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/saikat/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages/numpy-1.14.3-py2.7-linux-x86_64.egg (1.14.3)
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages (1.1.0).

我应该怎么办?

python anaconda numpy
  • 1 个回答
  • 3097 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve