Error due to implemention of time dependent BC

Hello everyone,

I had a constant pressure boundary condition, which I wanted to ramp up to the value instead of prescribing the value from t=0. I am using the oasis solver. So I wanted to change

bcp.append(DirichletBC(Q,Constant(270.0),boundaries,inflow_vein))

to

pres_inflow_expres = Expression((‘dt * pmax’),
degree = 1 , dt = dt , pmax = pmax )
bcp.append(DirichletBC(Q,pres_inflow_expres,boundaries,inflow_graft))

This is the total piece of code that doesnt seem to work now

def create_bcs(V, Q,pmax, NS_parameters, **NS_namespace):
“”“Function to define the boundary conditions”“”

pres_inflow_expres = Expression(('dt * pmax'),\
 degree = 1 , dt = dt , pmax = pmax )

#pressure_waveform = Expression()

# Specify empty bcs for the velocity components and the pressure
bcu_x = []
bcu_y = []
bcu_z = []
bcp = []

# Define the boundary conditions for the pressure and the individual
# velocity components

vel_x_wall  = Constant(0.0)
vel_y_wall  = Constant(0.0)
vel_z_wall  = Constant(0.0)

bcu_x.append(DirichletBC(V, vel_x_wall, boundaries, walls))
bcu_y.append(DirichletBC(V, vel_y_wall, boundaries, walls))
bcu_z.append(DirichletBC(V, vel_z_wall, boundaries, walls))

bcu_x.append(DirichletBC(V, Constant(0.0), boundaries, inflow_vein))  	#deze normaal uitzetten
bcu_y.append(DirichletBC(V, Constant(0.0), boundaries, inflow_vein))	#deze normaal uitzetten
bcu_z.append(DirichletBC(V, Constant(0.0), boundaries, inflow_vein))	#deze normaal uitzetten

#bcp.append(DirichletBC(Q,pres_inflow_expres,boundaries,inflow_graft)) 
#bcp.append(DirichletBC(Q,Constant(183.0),boundaries,inflow_vein))		#DEZE normaal aanzetten

#bcp.append(DirichletBC(Q,Constant(0.0),boundaries,outflow)) deze stond aan

bcp_out = (DirichletBC(Q,Constant(0.0),boundaries,outflow))
bcp_graft = (DirichletBC(Q,pres_inflow_expres,boundaries,inflow_graft)) 

        ######
        ###### wellicht alle bcp apart aan p= dictionary toevoegen ipv in een bcp lijst 

bcs =dict(
    u0=bcu_x,
    u1=bcu_y,
    u2=bcu_z,
    p=[bcp_out,bcp_graft]
) 
# Return the boundary conditions

return bcs,  dict(ife = [pres_inflow_expres])

def initialize(p_1,x_1, x_2, bcs, v, q_, **NS_namespace):
for ui in x_1:
[bc.apply(x_1[ui]) for bc in bcs[ui]]
for ui in x_2:
[bc.apply(x_2[ui]) for bc in bcs[ui]]

this now gives the error:

                             1. SETUP PATHS                                 

--------------------------------------------------------------------------------e[0m
e[1;37;34mReading input from: /home/jack/oasis/VenAn_simulation/input/Meshes_p1/followup1_melem_03.xdmf
Saving output to: /home/jack/oasis/output_3D_followup1_2_ramp_tot_270
--------------------------------------------------------------------------------e[0m
e[1;37;34mREADING MESH e[0m
e[1;37;34m DONE
--------------------------------------------------------------------------------e[0m
e[1;37;34mREADING MARKERS e[0m
e[1;37;31mCreating initial folderse[0m
Traceback (most recent call last):
File “NSfracStep.py”, line 137, in
initialize(**vars())
File “/home/jack/anaconda2/envs/fenicsproject/lib/python3.7/site-packages/oasis-2018.1-py3.7.egg/oasis/problems/NSfracStep/PaSpec3D.py”, line 194, in initialize
[bc.apply(x_1[ui]) for bc in bcs[ui]]
TypeError: tuple indices must be integers or slices, not str

I’m not sure what the mistake is I made.

Thanks for your help.
Cheers,
Jack

Please supply a minimal code example that can be used to reproduce the error message.
Especially as you are using oasis, it is very tricky for anyone to help you without a complete code (as your error is in oasis, not in the definition of boundary conditions).