How to apply a load force by means of a function.
I have some problems by applying a load force by means of a function. I have checked available information, and tested many ways without success. So, please, could you help me?
The problem is the next. The problem has 5 steps, I want to apply the force in a specific nodes, defined as forze_zone, proportionally to the step number. I think my problem is about the output format of the get_load function. Here is the code.
def get_load(ts, coors, mode='qp',equations=None, term=None, problem=None, **kwargs): if mode == 'qp': val= nm.empty(coors.shape[0], dtype=nm.float64) val=14000*ts.step/ts.n_step/n_coors #force nodes array format [index nodes, ] val.reshape(coors.shape[0], 1, 1) #output format (# of nodes, 1,1) return {'.val': val}
functions = { 'get_pars' : (get_pars,), # funcion used to get material properties 'get_load' : (get_load,), 'get_zone_fix': (_get_zone_fix,), # function to get nodes to fix the part 'get_zone_force': (_get_zone_force,), #function to get nodes to applied the load }
options = { 'ts' : 'ts', 'output_format' : 'vtk', 'save_times' : 'all', 'post_process_hook' : 'post_process', }
mesh = Mesh.from_file(filename_mesh) domain = FEDomain('domain', mesh)#Create a domain aux_coors=nm.copy(mesh.coors) # copy of mesh coordinates n_coors=len(_get_zone_force(aux_coors)) # number of nodes in load zone force_nodes=_get_zone_force(aux_coors) #node index to apply the force gdata = geometry_data['3_4'] nc = len(gdata.coors)
integral_vn = Integral('ivn', coors=gdata.coors, weights=[gdata.volume / nc] * nc)
regions = { 'Omega' : 'all', 'Fix_zone' : ('vertices by get_zone_fix', 'vertex'), 'Force_zone' : ('vertices by get_zone_force','vertex'), }
materials = { 'nonlinear' : 'get_pars', 'Load' : 'get_load', }
fields = { 'displacement': ('real', 'vector', 'Omega', 1), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field', 'displacement', 'u'), }
ebcs = { 'Fixed' : ('Fix_zone', {'u.all' : 0.0}), }
integrals = { 'i': 2, # 2nd order quadrature over a 3 dimensional space. } equations = { 'balance_of_forces in time' : """dw_lin_elastic.2.Omega(nonlinear.D, v, u) = dw_point_load.1.Force_zone(Load.val, v)""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0, }), 'ts' : ('ts.simple', {'t0' : 0.0, 't1' : 1.0, 'dt' : None, 'n_step' : 5, 'quasistatic' : True, 'verbose' : 1, }), }
Thank You Jesus Sanz
Hello Jesus,
I suggest you change the point load term to the tractions term (dw_surface_ltr) and then you can follow [1].
The dw_point_load term is rather finicky as the material function output should be:
The number of rows of the load must be equal to the number of nodes in the region and the number of columns equal to the field dimension.
Also the material function should not use "if mode == 'qp'" but "if mode == 'special'".
If you edit your example code so that I could run it, I might be able to make it work.
r.
[1] https://sfepy.org/doc/examples/linear_elasticity-linear_elastic_tractions.ht...
On 4/25/23 08:58, J. Sanz wrote:
I have some problems by applying a load force by means of a function. I have checked available information, and tested many ways without success. So, please, could you help me?
The problem is the next. The problem has 5 steps, I want to apply the force in a specific nodes, defined as forze_zone, proportionally to the step number. I think my problem is about the output format of the get_load function. Here is the code.
def get_load(ts, coors, mode='qp',equations=None, term=None, problem=None, **kwargs): if mode == 'qp': val= nm.empty(coors.shape[0], dtype=nm.float64) val=14000*ts.step/ts.n_step/n_coors #force nodes array format [index nodes, ] val.reshape(coors.shape[0], 1, 1) #output format (# of nodes, 1,1) return {'.val': val}
functions = { 'get_pars' : (get_pars,), # funcion used to get material properties 'get_load' : (get_load,), 'get_zone_fix': (_get_zone_fix,), # function to get nodes to fix the part 'get_zone_force': (_get_zone_force,), #function to get nodes to applied the load }
options = { 'ts' : 'ts', 'output_format' : 'vtk', 'save_times' : 'all', 'post_process_hook' : 'post_process', }
mesh = Mesh.from_file(filename_mesh) domain = FEDomain('domain', mesh)#Create a domain aux_coors=nm.copy(mesh.coors) # copy of mesh coordinates n_coors=len(_get_zone_force(aux_coors)) # number of nodes in load zone force_nodes=_get_zone_force(aux_coors) #node index to apply the force gdata = geometry_data['3_4'] nc = len(gdata.coors)
integral_vn = Integral('ivn', coors=gdata.coors, weights=[gdata.volume / nc] * nc)
regions = { 'Omega' : 'all', 'Fix_zone' : ('vertices by get_zone_fix', 'vertex'), 'Force_zone' : ('vertices by get_zone_force','vertex'), }
materials = { 'nonlinear' : 'get_pars', 'Load' : 'get_load', }
fields = { 'displacement': ('real', 'vector', 'Omega', 1), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field', 'displacement', 'u'), }
ebcs = { 'Fixed' : ('Fix_zone', {'u.all' : 0.0}), }
integrals = { 'i': 2, # 2nd order quadrature over a 3 dimensional space. } equations = { 'balance_of_forces in time' : """dw_lin_elastic.2.Omega(nonlinear.D, v, u) = dw_point_load.1.Force_zone(Load.val, v)""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0, }), 'ts' : ('ts.simple', {'t0' : 0.0, 't1' : 1.0, 'dt' : None, 'n_step' : 5, 'quasistatic' : True, 'verbose' : 1, }), }
Thank You Jesus Sanz
Hello Robert, I have tried your solution (with point forces) but without success. The solution with dw_surface_ltr works properly !! Anyway could you check the attached code to run the initial case? Thanks, Jesus
El mar, 25 abr 2023 a las 10:06, Robert Cimrman (<cimrman3@ntc.zcu.cz>) escribió:
Hello Jesus,
I suggest you change the point load term to the tractions term (dw_surface_ltr) and then you can follow [1].
The dw_point_load term is rather finicky as the material function output should be:
The number of rows of the load must be equal to the number of nodes in the region and the number of columns equal to the field dimension.
Also the material function should not use "if mode == 'qp'" but "if mode == 'special'".
If you edit your example code so that I could run it, I might be able to make it work.
r.
[1] https://sfepy.org/doc/examples/linear_elasticity-linear_elastic_tractions.ht...
I have some problems by applying a load force by means of a function. I have checked available information, and tested many ways without success. So, please, could you help me?
The problem is the next. The problem has 5 steps, I want to apply the force in a specific nodes, defined as forze_zone, proportionally to the step number. I think my problem is about the output format of the get_load function. Here is the code.
def get_load(ts, coors, mode='qp',equations=None, term=None,
On 4/25/23 08:58, J. Sanz wrote: problem=None, **kwargs):
if mode == 'qp': val= nm.empty(coors.shape[0], dtype=nm.float64) val=14000*ts.step/ts.n_step/n_coors #force nodes array format
[index nodes, ]
val.reshape(coors.shape[0], 1, 1) #output format (# of nodes,
1,1)
return {'.val': val}
functions = { 'get_pars' : (get_pars,), # funcion used to get material properties 'get_load' : (get_load,), 'get_zone_fix': (_get_zone_fix,), # function to get nodes to fix
the part
'get_zone_force': (_get_zone_force,), #function to get nodes to
applied the load
}
options = { 'ts' : 'ts', 'output_format' : 'vtk', 'save_times' : 'all', 'post_process_hook' : 'post_process', }
mesh = Mesh.from_file(filename_mesh) domain = FEDomain('domain', mesh)#Create a domain aux_coors=nm.copy(mesh.coors) # copy of mesh coordinates n_coors=len(_get_zone_force(aux_coors)) # number of nodes in load zone force_nodes=_get_zone_force(aux_coors) #node index to apply the force gdata = geometry_data['3_4'] nc = len(gdata.coors)
integral_vn = Integral('ivn', coors=gdata.coors, weights=[gdata.volume / nc] * nc)
regions = { 'Omega' : 'all', 'Fix_zone' : ('vertices by get_zone_fix', 'vertex'), 'Force_zone' : ('vertices by get_zone_force','vertex'), }
materials = { 'nonlinear' : 'get_pars', 'Load' : 'get_load', }
fields = { 'displacement': ('real', 'vector', 'Omega', 1), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field', 'displacement', 'u'), }
ebcs = { 'Fixed' : ('Fix_zone', {'u.all' : 0.0}), }
integrals = { 'i': 2, # 2nd order quadrature over a 3 dimensional space. } equations = { 'balance_of_forces in time' : """dw_lin_elastic.2.Omega(nonlinear.D, v, u) = dw_point_load.1.Force_zone(Load.val, v)""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0, }), 'ts' : ('ts.simple', {'t0' : 0.0, 't1' : 1.0, 'dt' : None, 'n_step' : 5, 'quasistatic' : True, 'verbose' : 1, }), }
Thank You Jesus Sanz
SfePy mailing list -- sfepy@python.org To unsubscribe send an email to sfepy-leave@python.org https://mail.python.org/mailman3/lists/sfepy.python.org/ Member address: jsanz451@gmail.com
On 4/26/23 15:34, J. Sanz wrote:
Hello Robert, I have tried your solution (with point forces) but without success. The solution with dw_surface_ltr works properly !!
Great!
Anyway could you check the attached code to run the initial case?
There is a quirk in syntax, that is not that obvious in hindsight. In material functions, the 'special' mode argument value makes the dot in parameter name superfluous. So the line
return {'.val': val}
should be
return {'val': val}
I will probably update the code so that both ways work.
r.
El mar, 25 abr 2023 a las 10:06, Robert Cimrman (<cimrman3@ntc.zcu.cz>) escribió:
Hello Jesus,
I suggest you change the point load term to the tractions term (dw_surface_ltr) and then you can follow [1].
The dw_point_load term is rather finicky as the material function output should be:
The number of rows of the load must be equal to the number of nodes in the region and the number of columns equal to the field dimension.
Also the material function should not use "if mode == 'qp'" but "if mode == 'special'".
If you edit your example code so that I could run it, I might be able to make it work.
r.
[1] https://sfepy.org/doc/examples/linear_elasticity-linear_elastic_tractions.ht...
I have some problems by applying a load force by means of a function. I have checked available information, and tested many ways without success. So, please, could you help me?
The problem is the next. The problem has 5 steps, I want to apply the force in a specific nodes, defined as forze_zone, proportionally to the step number. I think my problem is about the output format of the get_load function. Here is the code.
def get_load(ts, coors, mode='qp',equations=None, term=None,
On 4/25/23 08:58, J. Sanz wrote: problem=None, **kwargs):
if mode == 'qp': val= nm.empty(coors.shape[0], dtype=nm.float64) val=14000*ts.step/ts.n_step/n_coors #force nodes array format
[index nodes, ]
val.reshape(coors.shape[0], 1, 1) #output format (# of nodes,
1,1)
return {'.val': val}
functions = { 'get_pars' : (get_pars,), # funcion used to get material properties 'get_load' : (get_load,), 'get_zone_fix': (_get_zone_fix,), # function to get nodes to fix
the part
'get_zone_force': (_get_zone_force,), #function to get nodes to
applied the load
}
options = { 'ts' : 'ts', 'output_format' : 'vtk', 'save_times' : 'all', 'post_process_hook' : 'post_process', }
mesh = Mesh.from_file(filename_mesh) domain = FEDomain('domain', mesh)#Create a domain aux_coors=nm.copy(mesh.coors) # copy of mesh coordinates n_coors=len(_get_zone_force(aux_coors)) # number of nodes in load zone force_nodes=_get_zone_force(aux_coors) #node index to apply the force gdata = geometry_data['3_4'] nc = len(gdata.coors)
integral_vn = Integral('ivn', coors=gdata.coors, weights=[gdata.volume / nc] * nc)
regions = { 'Omega' : 'all', 'Fix_zone' : ('vertices by get_zone_fix', 'vertex'), 'Force_zone' : ('vertices by get_zone_force','vertex'), }
materials = { 'nonlinear' : 'get_pars', 'Load' : 'get_load', }
fields = { 'displacement': ('real', 'vector', 'Omega', 1), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field', 'displacement', 'u'), }
ebcs = { 'Fixed' : ('Fix_zone', {'u.all' : 0.0}), }
integrals = { 'i': 2, # 2nd order quadrature over a 3 dimensional space. } equations = { 'balance_of_forces in time' : """dw_lin_elastic.2.Omega(nonlinear.D, v, u) = dw_point_load.1.Force_zone(Load.val, v)""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0, }), 'ts' : ('ts.simple', {'t0' : 0.0, 't1' : 1.0, 'dt' : None, 'n_step' : 5, 'quasistatic' : True, 'verbose' : 1, }), }
Thank You Jesus Sanz
SfePy mailing list -- sfepy@python.org To unsubscribe send an email to sfepy-leave@python.org https://mail.python.org/mailman3/lists/sfepy.python.org/ Member address: jsanz451@gmail.com
<https://mail.google.com/mail/u/0?ui=2&ik=b0d9374fb2&attid=0.1&permmsgid=msg-a:r820235182976151754&th=187c19e6c7c64298&view=att&disp=safe&realattid=f_lgystlgg0>Great, It works. The file is attached for the interest of anyone.
About your recommendation of use dw_surface_ltr. Which is the difference between dw_surface_ltr and dw_surface_ltr.isurf? cases of application? Thanks, a lot, Jesus
El jue, 27 abr 2023 a las 6:58, Robert Cimrman (<cimrman3@ntc.zcu.cz>) escribió:
On 4/26/23 15:34, J. Sanz wrote:
Hello Robert, I have tried your solution (with point forces) but without success. The solution with dw_surface_ltr works properly !!
Great!
Anyway could you check the attached code to run the initial case?
There is a quirk in syntax, that is not that obvious in hindsight. In material functions, the 'special' mode argument value makes the dot in parameter name superfluous. So the line
return {'.val': val}
should be
return {'val': val}
I will probably update the code so that both ways work.
r.
El mar, 25 abr 2023 a las 10:06, Robert Cimrman (<cimrman3@ntc.zcu.cz>) escribió:
Hello Jesus,
I suggest you change the point load term to the tractions term (dw_surface_ltr) and then you can follow [1].
The dw_point_load term is rather finicky as the material function output should be:
The number of rows of the load must be equal to the number of nodes in
region and the number of columns equal to the field dimension.
Also the material function should not use "if mode == 'qp'" but "if mode == 'special'".
If you edit your example code so that I could run it, I might be able to make it work.
r.
[1]
https://sfepy.org/doc/examples/linear_elasticity-linear_elastic_tractions.ht...
On 4/25/23 08:58, J. Sanz wrote:
I have some problems by applying a load force by means of a function. I have checked available information, and tested many ways without
success.
So, please, could you help me?
The problem is the next. The problem has 5 steps, I want to apply the
force in a specific nodes, defined as forze_zone, proportionally to the step number. I think my problem is about the output format of the get_load function. Here is the code.
def get_load(ts, coors, mode='qp',equations=None, term=None,
problem=None, **kwargs):
if mode == 'qp': val= nm.empty(coors.shape[0], dtype=nm.float64) val=14000*ts.step/ts.n_step/n_coors #force nodes array
[index nodes, ]
val.reshape(coors.shape[0], 1, 1) #output format (# of
nodes, 1,1)
return {'.val': val}
functions = { 'get_pars' : (get_pars,), # funcion used to get material
the format properties
'get_load' : (get_load,), 'get_zone_fix': (_get_zone_fix,), # function to get nodes to fix
the part
'get_zone_force': (_get_zone_force,), #function to get nodes to
applied the load
}
options = { 'ts' : 'ts', 'output_format' : 'vtk', 'save_times' : 'all', 'post_process_hook' : 'post_process', }
mesh = Mesh.from_file(filename_mesh) domain = FEDomain('domain', mesh)#Create a domain aux_coors=nm.copy(mesh.coors) # copy of mesh coordinates n_coors=len(_get_zone_force(aux_coors)) # number of nodes in load zone force_nodes=_get_zone_force(aux_coors) #node index to apply the force gdata = geometry_data['3_4'] nc = len(gdata.coors)
integral_vn = Integral('ivn', coors=gdata.coors, weights=[gdata.volume / nc] * nc)
regions = { 'Omega' : 'all', 'Fix_zone' : ('vertices by get_zone_fix', 'vertex'), 'Force_zone' : ('vertices by get_zone_force','vertex'), }
materials = { 'nonlinear' : 'get_pars', 'Load' : 'get_load', }
fields = { 'displacement': ('real', 'vector', 'Omega', 1), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field', 'displacement', 'u'), }
ebcs = { 'Fixed' : ('Fix_zone', {'u.all' : 0.0}), }
integrals = { 'i': 2, # 2nd order quadrature over a 3 dimensional space. } equations = { 'balance_of_forces in time' : """dw_lin_elastic.2.Omega(nonlinear.D, v, u) = dw_point_load.1.Force_zone(Load.val, v)""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0, }), 'ts' : ('ts.simple', {'t0' : 0.0, 't1' : 1.0, 'dt' : None, 'n_step' : 5, 'quasistatic' : True, 'verbose' : 1, }), }
Thank You Jesus Sanz
SfePy mailing list -- sfepy@python.org To unsubscribe send an email to sfepy-leave@python.org https://mail.python.org/mailman3/lists/sfepy.python.org/ Member address: jsanz451@gmail.com
participants (2)
-
J. Sanz
-
Robert Cimrman