Skip to content

Commit

Permalink
track works
Browse files Browse the repository at this point in the history
  • Loading branch information
rdemaria committed Feb 19, 2018
1 parent d9af50a commit 475b2d0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sixtracklib/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ CLKERNEL void Block_track(CLGLOBAL value_t *elems,
elem = elems+elemid;
track_single(particles,partid,elem);
if (elembyelem_flag){
ebe+=nparts;
Particles_copy(particles, elembyelem, partid, ebe+partid);
ebe+=nparts;
}
} //end elem loop
if (turnbyturn_flag){
tbt+=nparts;
Particles_copy(particles, turnbyturn, partid, tbt+partid);
tbt+=nparts;
}
} //end turn loop
}
Expand Down
4 changes: 2 additions & 2 deletions sixtracklib/cblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ def track_cl(self,particles,nturns=1,elembyelem=None,turnbyturn=None):
particles_g=cl.Buffer(ctx, rw, hostbuf=particles._data)
#ElemByElem data
if elembyelem is True:
elembyelem=CParticles(npart=npart*self.nelems*nturns+1)
elembyelem=CParticles(npart=npart*(self.nelems*nturns+1))
if elembyelem is None:
elembyelem_g=cl.Buffer(ctx, rw, hostbuf=np.array([0]))
else:
elembyelem_g=cl.Buffer(ctx, rw, hostbuf=elembyelem._data)
#TurnByTurn data
if turnbyturn is True:
turnbyturn=CParticles(npart=npart*nturns+1)
turnbyturn=CParticles(npart=npart*(nturns+1))
if turnbyturn is None:
turnbyturn_g=cl.Buffer(ctx, rw, hostbuf=np.array([0]))
else:
Expand Down
11 changes: 10 additions & 1 deletion sixtracklib/cobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ def _fill_args(self,nvargs):
nvargs.get(name,prop.default)
elif isinstance(prop.valuetype,CObject):
raise NotImplemented('Nested object not implemented')

def pretty_print(self):
props=self._get_props()
out=['%s('%(self.__class__.__name__)]
for offset,name,prop in props:
val='%s'%getattr(self,name)
out.append(' %-8s = %s,'%(name,val[:70]))
out.append(')')
return '\n'.join(out)
def __repr__(self):
return self.pretty_print()
3 changes: 2 additions & 1 deletion tests/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def test_track():
bunch.y[2]=0.2
bunch.sigma[3]=0.1

particles,ebe,tbt=fodo.track_cl(bunch,1,True,True)
particles,ebe,tbt=fodo.track_cl(bunch,nturns=1,
elembyelem=True,turnbyturn=True)
return particles,ebe,tbt


Expand Down

0 comments on commit 475b2d0

Please sign in to comment.