Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-17 Thread gaoxuesong
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Status: Answered => Solved

gaoxuesong confirmed that the question is solved:
I have tried and removed the '\r' following your method.

Thanks Jan. Your instructions are really helpful.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-17 Thread Jan Stránský
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Jan Stránský proposed the following answer:
> on Windows 10

^M, carriage return, \n\r... is a "windows newline character" (big
quotation marks). Usually it is OK, but sometimes you might meet a
problem.

> what does the '/\r//' mean in your command?

's/\r//'
= replace string between first slashes with string between second slashes
= replace \r with nothing = remove \r (carriage return)

> Which editor can show the carriage return symbols, such as '^M'?

e.g. vim. Open a file and run
:e ++ff=unix
I am sure emacs can do it, too.

> but there is no format error.

it is not an error, just the newline symbols are different. Text editors should 
have no problem.
But, obviously, SpherePack.load does not count with it.

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-17 Thread gaoxuesong
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

gaoxuesong posted a new comment:
Which editor can show the carriage return symbols, such as '^M'? 
I have opened the translated file using the Ubuntu default editor but there is 
no format error.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-17 Thread gaoxuesong
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

gaoxuesong posted a new comment:
Hi Jan,

I use a Spyder editor integrated in Anaconda on Windows 10 to
conduct the translation code. By the way, what does the '/\r//' mean in
your command?

Thanks.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-16 Thread Jan Stránský
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

if I used the provided file, I got the same error.
However, if I used the code to create a new translated file, I could load it 
without any problem.
After diffing the files, it turned out that in the original files there are 
"^M" (carriage return) symbols at the end of lines.
How/where/on which OS have you produced the translated files?

using terminal command
sed -i 's/\r//' initial_spheres_translate_x.txt
fixes the problem

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-14 Thread gaoxuesong
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Status: Needs information => Open

gaoxuesong gave more information on the question:
Sorry for that. Below is my MWE. 
1. the initial particles set saved by 
sp = pack.SpherePack()
sp.save('initial_spheres-before_translation-x.txt') 

Find file here, 
https://drive.google.com/file/d/1VIYd7qzb5b4iIAyldT49I1Fjko8XxjhI/view?usp=sharing
 

2. the python script to translate those particles in x direction, 
import numpy as np 

data = np.loadtxt('initial_spheres-before-translation-x.txt',
delimiter=' ', skiprows=0)

with open('initial_spheres_translate_x.txt','w') as fd:
for i in range(len(data)):
 fd.write('%.9f %.9f %.9f %.5e %d\n' % (data[i,0]+0.5e-3, 
data[i,1], data[i,2], data[i,3], -1))

Find file here, 
https://drive.google.com/file/d/1P2kVPWFX0VoTzyqVD9uwruodb16Zof5s/view?usp=sharing
 

3. The yade code to load the translated particles, 
from yade import pack,geom,utils  

sp = pack.SpherePack()
sp.load('initial_spheres_translate_x.txt') 
### the initial particles before translation can be loaded ### 
#sp.load('initial_spheres-before-translation-x.txt') 
print('load initial_spheres')
sp.toSimulation()


Thanks.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-12 Thread Jan Stránský
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Status: Open => Needs information

Jan Stránský requested more information:
Please provide a MWE [1] (e.g. a packing with 3 manually inserted
spheres), then it will be much easier to help you..

thanks
Jan

[1] https://www.yade-dem.org/wiki/Howtoask

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-12 Thread gaoxuesong
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Status: Needs information => Open

gaoxuesong gave more information on the question:
The error is shown as,

RuntimeError: bad lexical cast: source type value could not be
interpreted as target

Thanks.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-12 Thread Robert Caulk
Question #688690 on Yade changed:
https://answers.launchpad.net/yade/+question/688690

Status: Open => Needs information

Robert Caulk requested more information:
>there is an format error when reading the file

What is the error?

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #688690]: pack.SpherePack.save() function saved particles data format

2020-02-11 Thread gaoxuesong
New question #688690 on Yade:
https://answers.launchpad.net/yade/+question/688690

Hi. I have a file of spherical particles saved by function of 
pack.SpherePack().save(). It has the format as follows, 

0.000919246 0.000859971 0.000602774 1.20067e-05 -1
0.000959836 0.00055149 0.000975021 2.11065e-05 -1
. 

I want to translate all the particles in x direction and conduct it by the 
following python code,  
===
===
import numpy as np 

data = np.loadtxt('initial_spheres.txt', delimiter=' ', skiprows=0)

with open('initial_spheres_translate_x.txt','w') as fd:
for i in range(len(data)):
fd.write('%.9f %.9f %.9f %.5e %d\n' % (data[i,0]+0.5e-3, data[i,1], 
data[i,2], data[i,3], -1))
===
===
 and i got the data as this, 

0.001919246 0.000859971 0.000602774 1.20067e-05 -1
0.001959836 0.000551490 0.000975021 2.11065e-05 -1

The format seems the same, however, there is an format error when reading the 
file by pack.SpherePack().load() function.  
By the way, i have tried the delimiter as space and tab and both don't work. 

Thanks. 




-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp