Commit 10d0e160 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Move python scripts to python3

parent e1bdccb3
......@@ -91,8 +91,8 @@ for i in range(402):
E_tot_snap[i] = E_kin_snap[i] + E_pot_snap[i]
Lz_snap[i] = np.sum(Lz)
print "Starting energy:", E_kin_stats[0], E_pot_stats[0], E_tot_stats[0]
print "Ending energy:", E_kin_stats[-1], E_pot_stats[-1], E_tot_stats[-1]
print("Starting energy:", E_kin_stats[0], E_pot_stats[0], E_tot_stats[0])
print("Ending energy:", E_kin_stats[-1], E_pot_stats[-1], E_tot_stats[-1])
# Plot energy evolution
figure()
......
......@@ -36,16 +36,16 @@ const_unit_length_in_cgs = (1000*PARSEC_IN_CGS)
const_unit_mass_in_cgs = (SOLAR_MASS_IN_CGS)
const_unit_velocity_in_cgs = (1e5)
print "UnitMass_in_cgs: ", const_unit_mass_in_cgs
print "UnitLength_in_cgs: ", const_unit_length_in_cgs
print "UnitVelocity_in_cgs: ", const_unit_velocity_in_cgs
print "UnitTime_in_cgs: ", const_unit_length_in_cgs / const_unit_velocity_in_cgs
print("UnitMass_in_cgs: ", const_unit_mass_in_cgs)
print("UnitLength_in_cgs: ", const_unit_length_in_cgs)
print("UnitVelocity_in_cgs: ", const_unit_velocity_in_cgs)
print("UnitTime_in_cgs: ", const_unit_length_in_cgs / const_unit_velocity_in_cgs)
# derived units
const_unit_time_in_cgs = (const_unit_length_in_cgs / const_unit_velocity_in_cgs)
const_G = ((NEWTON_GRAVITY_CGS*const_unit_mass_in_cgs*const_unit_time_in_cgs*const_unit_time_in_cgs/(const_unit_length_in_cgs*const_unit_length_in_cgs*const_unit_length_in_cgs)))
print '---------------------'
print 'G in internal units: ', const_G
print('---------------------')
print('G in internal units: ', const_G)
# Parameters
......@@ -53,7 +53,7 @@ periodic = 1 # 1 For periodic box
boxSize = 100. #
max_radius = boxSize / 4. # maximum radius of particles
Mass = 1e10
print "Mass at the centre: ", Mass
print("Mass at the centre: ", Mass)
numPart = int(sys.argv[1]) # Number of particles
mass = 1.
......@@ -93,9 +93,9 @@ grp1 = file.create_group("/PartType1")
#generate particle positions
radius = max_radius * (numpy.random.rand(numPart))**(1./3.)
print '---------------------'
print 'Radius: minimum = ',min(radius)
print 'Radius: maximum = ',max(radius)
print('---------------------')
print('Radius: minimum = ',min(radius))
print('Radius: maximum = ',max(radius))
radius = numpy.sort(radius)
r = numpy.zeros((numPart, 3))
r[:,0] = radius
......@@ -104,9 +104,9 @@ r[:,0] = radius
speed = numpy.sqrt(const_G * Mass / radius)
omega = speed / radius
period = 2.*math.pi/omega
print '---------------------'
print 'Period: minimum = ',min(period)
print 'Period: maximum = ',max(period)
print('---------------------')
print('Period: minimum = ',min(period))
print('Period: maximum = ',max(period))
v = numpy.zeros((numPart, 3))
v[:,0] = -omega * r[:,1]
......
......@@ -304,7 +304,7 @@ if full_step.size == 13:
print("# MPI mode")
mpimode = True
if ranks == None:
ranks = list(range(int(max(data[:, 0])) + 1))
ranks = list(range(int(max(data[:,0])) + 1))
print(("# Number of ranks:", len(ranks)))
rankcol = 0
threadscol = 1
......@@ -328,7 +328,7 @@ CPU_CLOCK = float(full_step[-1]) / 1000.0
if args.verbose:
print(("# CPU frequency:", CPU_CLOCK * 1000.0))
nthread = int(max(data[:, threadscol])) + 1
nthread = int(max(data[:,threadscol])) + 1
print(("# Number of threads:", nthread))
# Avoid start and end times of zero.
......@@ -367,7 +367,7 @@ for rank in ranks:
tic_step = int(full_step[ticcol])
toc_step = int(full_step[toccol])
print(("# Min tic = ", tic_step))
data = data[1:, :]
data = data[1:,:]
typesseen = []
nethread = 0
......@@ -495,7 +495,7 @@ for rank in ranks:
if expand == 1:
ax.set_ylabel("Thread ID")
else:
ax.set_ylabel("Thread ID * " + str(expand))
ax.set_ylabel("Thread ID * " + str(expand) )
ax.set_yticks(pl.array(list(range(nethread))), True)
loc = plticker.MultipleLocator(base=expand)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment