File size: 2,895 Bytes
3ea44ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# Copyright (C) 2013,2014,2015,2016 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import print_function
import espressomd
from espressomd import thermostat
import numpy as np

print("""
=======================================================
=                   slice_input.py                    =
=======================================================

Program Information:""")
print(espressomd.features())

dev = "cpu"

# System parameters
#############################################################

box_l = 10.0

# Integration parameters
#############################################################

system = espressomd.System(box_l=[box_l]*3)
system.set_random_state_PRNG()
#system.seed = system.cell_system.get_state()['n_nodes'] * [1234]
np.random.seed(seed=system.seed)

system.time_step = 0.01
system.cell_system.skin = 0.4

system.cell_system.max_num_cells = 2744


#############################################################
#  Setup System                                             #
#############################################################


# Particle setup
#############################################################

n_part = 10

id_list = np.arange(n_part)
pos_list = np.random.random((n_part, 3)) * system.box_l
type_list = np.ones(n_part, dtype=int)

system.part.add(id=id_list, pos=pos_list, type=type_list)


print("TYPE\n%s" % system.part[:].type)
system.part[0:2].type = [3, 3]
print("TYPE_NEW\n%s" % system.part[:].type)

print("POS\n%s" % system.part[:].pos)
system.part[:5].pos = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]
print("POS_NEW\n%s" % system.part[:].pos)

print("V\n%s" % system.part[:].v)
system.part[:2].v = [[1, 2, 3], [2, 3, 4]]
print("V_NEW\n%s" % system.part[:].v)

print("F\n%s" % system.part[:].f)
system.part[:2].f = [[3, 4, 5], [4, 5, 6]]
print("F_NEW\n%s" % system.part[:].f)

if espressomd.has_features(["MASS"]):
    print("MASS\n%s" % system.part[:].mass)
    system.part[:2].mass = [2, 3]
    print("MASS_NEW\n%s" % system.part[:].mass)

if espressomd.has_features(["ELECTROSTATICS"]):
    print("Q\n%s" % system.part[:].q)
    system.part[::2].q = np.ones(n_part / 2)
    system.part[1::2].q = -np.ones(n_part / 2)
    print("Q_NEW\n%s" % system.part[:].q)