Batch

Asked by Mithushan Soundaranathan

Hi,

I have began to work with batch mode. I run a script in batch mode, where I read the materials parameter (k1 and kp) from the table.
The code work in regular mode, but does gives following error message in batch mode:

#0 (k1=700,kp=10) FAILED (exit status 256), duration 00:00:01, log tablet_compaction_dual_punch_PH101.py.k1=700,kp=10.log

Here is my table
k1 kp
700 7000
650 7800
600 12000

here is my code:
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 15 16:29:55 2021

@author: njb18198
"""

#!/usr/bin/env python
#encoding: ascii

# Testing of the Deformation Enginge with Luding Contact Law
# Modified Oedometric Test
# The reference paper [Haustein2017]
from __future__ import print_function
from yade import utils, plot, timing
from yade import pack
import pandas as pd
import numpy as np
from PIL import Image
from yade import pack, export
from scipy.interpolate import interp1d
from csv import writer
import os
readParamsFromTable(k1=700,kp=7000)
from yade.params.table import *

o = Omega()

# Physical parameters
fr = 0.41
rho = 1561
Diameter = 7.9e-5
D=Diameter
r1 = Diameter/2
#r2 = Diameter/2
k1 = k1
kp = kp*k1
kc = k1 * 0.1
ks = k1 * 0.1
DeltaPMax = Diameter/3.0
Chi1 = 0.34

o.dt = 1.0e-7
particleMass = 4.0/3.0*math.pi*r1*r1*r1*rho
m_tot=4e-06
no_p=m_tot/particleMass

Vi1 = math.sqrt(k1/particleMass)*DeltaPMax*Chi1
PhiF1=0.999
#PhiF1 = DeltaPMax*(kp-k1)*(r1+r2)/(kp*2*r1*r2)

Tab_rad=0.001
Cyl_height=0.0092
cross_area=math.pi*(Tab_rad**2)

Comp_press_up= 0.56e8
Comp_force_up=Comp_press_up*cross_area

Comp_press_lp= 0.56e8
Comp_force_lp=Comp_press_lp*cross_area

compression_data_save=[]
sc_por=0.3

#Read exp data
path_data='/home/mithushan/Compaction_data'
Exp=pd.read_csv(os.path.join(path_data,r'Compaction_results_PH101_porosity_22.csv'))
Exp.Compression_pressure=Exp.Compression_pressure/2
idxmax_Exp=Exp.idxmax(axis = 0)
Exp_loading=Exp[0:idxmax_Exp.Compression_pressure+1]
Exp_unloading=Exp[idxmax_Exp.Compression_pressure+1:len(Exp)]
#*************************************
def append_list_as_row(file_name, list_of_elem):
    # Open file in append mode
    with open(file_name, 'a+', newline='') as write_obj:
        # Create a writer object from csv module
        csv_writer = writer(write_obj)
        # Add contents of list as last row in the csv file
        csv_writer.writerow(list_of_elem)

# Add material
mat1 = O.materials.append(LudingMat(frictionAngle=fr, density=rho, k1=k1, kp=kp, ks=ks, kc=kc, PhiF=PhiF1, G0 = 0.0))

# Spheres for compression and walls
sp=pack.SpherePack()
sp.makeCloud((-7.5*Diameter,-7.5*Diameter,-57*Diameter),(7.5*Diameter,7.5*Diameter,57.0*Diameter), rMean=Diameter/2.0,rRelFuzz=0.18,num=round(no_p))
sp.toSimulation(material=mat1)
walls=O.bodies.append(yade.geom.facetCylinder((0,0,0),radius=Tab_rad,height=Cyl_height,segmentsNumber=20,wallMask=6,material=mat1))

# Add engines
o.engines = [
  ForceResetter(),
  InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.05),
                         Bo1_Wall_Aabb(),
                         Bo1_Facet_Aabb()
                         ]),
  InteractionLoop(
    [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=1.05),
     Ig2_Facet_Sphere_ScGeom(),
     Ig2_Wall_Sphere_ScGeom()],
    [Ip2_LudingMat_LudingMat_LudingPhys()],
    [Law2_ScGeom_LudingPhys_Basic()]
  ),
  NewtonIntegrator(damping=0.1, gravity=[0, 0, -9.81]),
  PyRunner(command='checkForce()', realPeriod=1, label="fCheck"),
  #DeformControl(label="DefControl")
]

def checkForce():
    if O.iter < 450000:
        return
    if unbalancedForce() > 1:
        return
    global upper_punch
    upper_punch=O.bodies.append(geom.facetCylinder((0,0,((-Cyl_height/2)+0.0002)+utils.aabbDim()[2]),Tab_rad-.00001,0,segmentsNumber=50,wallMask=1))
    for i in upper_punch:
        body= O.bodies[i]
        body.state.vel = (0,0,-1)
    global lower_punch
    lower_punch= O.bodies.append(geom.facetCylinder((0,0,(-Cyl_height/2)-0.0002),Tab_rad-.00001,0,segmentsNumber=50,wallMask=1))
    for n in lower_punch:
        body= O.bodies[n]
        body.state.vel = (0,0,1)
    #O.engines = O.engines + [PyRunner(command='storeData()', iterPeriod=10)]
    fCheck.command = 'unloadPlate()'

def unloadPlate():
    force_up=0
    for i in upper_punch:
        body= O.bodies[i]
        force_up=force_up+abs(O.forces.f(body.id)[2])
    force_lp=0
    for n in lower_punch:
        body = O.bodies[n]
        force_lp = force_lp + abs(O.forces.f(body.id)[2])
    if ((force_up > Comp_force_up) and (force_lp > Comp_force_lp)):
        for i in upper_punch:
            body= O.bodies[i]
            body.state.vel = (0,0,1)
        for n in lower_punch:
            body= O.bodies[n]
            body.state.vel = (0,0,-1)
        fCheck.command = 'stopUnloading()'

def stopUnloading():
    force_up=0
    for i in upper_punch:
        body= O.bodies[i]
        force_up=force_up+(O.forces.f(body.id)[2])
    force_lp=0
    for n in lower_punch:
        body = O.bodies[n]
        force_lp = force_lp + abs(O.forces.f(body.id)[2])
    if ((force_up==0) and (force_lp==0)):
        plot.saveDataTxt(O.tags['d.id']+'.txt')
        o.pause()

O.run()
# when running with yade-batch, the script must not finish until the simulation is done fully
# this command will wait for that (has no influence in the non-batch mode)
waitIfBatch()

path_save='/home/mithushan/Compaction_data'
compression_data=pd.DataFrame(compression_data_save, columns=['Porosity','Compression_pressure'])
compression_data.to_csv(os.path.join(path_save,r'compression_data.csv'))

Question information

Language:
English Edit question
Status:
Needs information
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,
what is logged in the file
tablet_compaction_dual_punch_PH101.py.k1=700,kp=10.log
?
Cheers
Jan

Revision history for this message
Mithushan Soundaranathan (mithushan93) said :
#2

Hi Jan,

Here is log file:
Welcome to Yade 2021.01a
Using python version: 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0]
Warning: no X rendering available (see https://bbs.archlinux.org/viewtopic.php?id=13189)
XMLRPC info provider on http://localhost:21003
/home/mithushan/myYade/trunk/build/install/lib/x86_64-linux-gnu/yade-2021.01a/py/yade/__init__.py:76: RuntimeWarning: to-Python converter for boost::shared_ptr<yade::PartialSatClayEngine> already registered; second conversion method ignored.
  boot.initialize(plugins,config.confDir)
TCP python prompt on localhost:9003, auth cookie `dskeyu'
Running script tablet_compaction_dual_punch_PH101.py
FATAL: exception not rethrown
Exception ignored in tp_clear of: <class 'IPython.core.formatters.DisplayFormatter'>
RuntimeError: unidentifiable C++ exception
Aborted (core dumped)

=================== JOB SUMMARY ================
id : k1=720,kp=6000
status : 34304 (FAILED)
duration: 01:34:03
command : YADE_BATCH=tut_3.table:2 DISPLAY= /home/mithushan/myYade/trunk/build/install/bin/yade-2021.01a --threads=1 --nice=10 -x tablet_compaction_dual_punch_PH101.py> tablet_compaction_dual_punch_PH101.py.k1=720,kp=6000.log 2>&1
started : Mon Sep 13 10:21:49 2021
finished: Mon Sep 13 11:55:53 2021

Revision history for this message
Jan Stránský (honzik) said :
#3

> Here is my table
> k1 kp
> 700 7000
> 650 7800
> 600 12000

and

> id : k1=720,kp=6000

please try to provide as much same information as you use for the running.
I doubt this is critical, but still..

Would it be possible to make your script MWE [1]?
Running it I got
FileNotFoundError: [Errno 2] No such file or directory: '/home/mithushan/Compaction_data/Compaction_results_PH101_porosity_22.csv'

> FATAL: exception not rethrown
> Exception ignored in tp_clear of: <class 'IPython.core.formatters.DisplayFormatter'>
> RuntimeError: unidentifiable C++ exception
> Aborted (core dumped)

this is the problem. Really difficult to guess what is the problem..

Cheers
Jan

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

Can you help with this problem?

Provide an answer of your own, or ask Mithushan Soundaranathan for more information if necessary.

To post a message you must log in.