Hi James,
On 11/08/2017 01:52 AM, James Martino wrote:
> Hi Robert,
>
> Thanks again for your help on my use of SfePy. It has been very instructive
> :)
>
> As you have foreseen, I needed a more complete script to highlight the
> functionality I am seeking to implement my convergence strategy. I have
> attached 2 scripts, one vanilla straight forward solution and another that
> shows the restart capability I seek, called "timestep_diffusion.py" and
> "timestep_diffusion_new.py" respectively. Both these files read from the
> configuration file "time_poisson_explicity_1d.py," which sets up the 1D FE,
> IC Gaussian profile I mentioned earlier in this thread.
>
> In short, I am having trouble solving from a saved state to a future state
> (possibly k steps away) multiple times. For example, the code I have
> attached runs for a total of 15 steps, and I would like to solve steps 6-9
> as many times as I please before completing the simulation. In this simple
> test case I do not change the concentration at any point or boundary
> conditions, so the expected behavior should be as if I only ran steps 6-9
> once. I have output 2 files that write the (sfepystep, point concentration)
> where point concentration is at the left most node. This allows for easy
> comparison between the pure solution and my repetitive solution that solves
> steps 6-9 multiple times (sfepy.c0.dat, and sfepy.new.c0.dat,
> respectively)....From this file comparison it is clear that my retracing of
> steps 6-9 not start from state(step = 6), but rather continues to iterate
> the solution from the last solved step...
There were some problems in your files that I tried to correct, see the
attachment. Also, the issue [1] manifested again. Essentially, writing
state = tss.solve_step(tss.ts, state0)
means that state() (= state.vec) is the new state and state0() (= state0.vec)
is the old/previous state, BUT, state0.variables is state.variables and so
state0.variables['c']() returns the new state(!). That is why
timestep_diffusion.py actually worked, even though there was a mistake:
state = tss.solve_step(tss.ts, state0)
staten1 = state.copy(deep=True)
instead of
state = tss.solve_step(tss.ts, state0)
state0 = state.copy(deep=True)
The main problem in timestep_diffusion_new.py was that setting the current
state to an old state just sets the current time state in the variables, but
does not restore the history - there is dc/dt in the equations and the c
variable stores its history (one level). So to restore both the current and
history states of a time step, Problem.save_restart() and .load_restart() need
to be used, see the attached file.
[1] https://github.com/sfepy/sfepy/issues/378
> My canned routine for iterating from a past state "k times" is called
> "conv_check"
>
> Please let me know if I can help explain any of the above in a clearer
> fashion and I look forward to hearing your advice.
I guess I got what you want. Does the above explanation help?
Cheers,
r.
> On Thu, Oct 26, 2017 at 12:03 PM, Robert Cimrman <cimrman3(a)ntc.zcu.cz>
> wrote:
>
>> Hi James,
>>
>> On 10/26/2017 06:38 AM, James Martino wrote:
>>
>>> Hi Robert,
>>>
>>> I have a specific request which derives from my work to couple SfePy with
>>> SPARRKS (an open source kMC solver by Sandia National Labs). In essence, I
>>> would like a way to recreate the "under the hood" steps that occur inside
>>> the typical for loop presented in many examples:
>>>
>>> for step, time, state in tss():
>>> ....
>>>
>>> I have dug into the source code and came up with what I thought were the
>>> equivalent lines from sfepy.solvers.ts_solvers -->
>>> SimpleTimeSteppingSolver:
>>>
>>
>> Yes.
>>
>> totalsteps = 3
>>> for i in range(totalsteps):
>>>
>>> #### solving commands
>>> state = tss.solve_step(tss.ts, state0)
>>> staten1 = state.copy(deep=True)
>>> problemInstance.advance(tss.ts)
>>>
>>> However, I have found that "state" remains equivalent to "state0", so I
>>> know I've missed some crucial bit of understanding here. I have attached a
>>> simplified version of my code (a diffusion problem solving an initial
>>> gaussian profile over a 1d finite element mesh) that shows my
>>> implementation details.
>>>
>>
>> You are not advancing the time-stepper. The problem is in using
>> for i in range(totalsteps):
>>
>> instead of
>> for i, time in tss.ts.iter_from(0):
>>
>> or simply:
>> for i, time in tss.ts:
>>
>> - this advances tss.ts.step. Check that in your code it stays 0.
>>
>> In greater detail, I will briefly describe our convergence strategy between
>>> the FE and kMC domains and how it pertains to the SfePy functionality we
>>> need. We need to be able to solve for the next FE state from an initial
>>> state with a specific boundary condition (essential/natural). The catch is
>>> that we also need the ability to choose whether to accept this new state
>>> (dependent on our convergence criteria) as the next time step OR if we
>>> need
>>> to change the applied boundary condition (essential/natural) and resolve
>>> from the same initial state. This iterative procedure continues until
>>> convergence is attained and that final state is used as the next FE
>>> timestep.
>>>
>>
>> This should be doable - you can change/update boundary conditions in many
>> ways. Let me know if you need help with that, but a more complete script
>> might be needed so that I could really see what you want.
>>
>> Thank you in advance for your time here, and please let me know if I can
>>> clarify anything in the above. I know it's an atypical request due to my
>>> unique implementation of SfePy.
>>>
>>
>> Looking forward seeing your results/application. :)
>>
>> Cheers,
>> r.
>> _______________________________________________
>> SfePy mailing list
>> sfepy(a)python.org
>> https://mail.python.org/mm3/mailman3/lists/sfepy.python.org/
>>
>

Hi Robert,
I was looking for a postprocessing method to calculate the displacements for points on the surface of the mesh that are not necessarily node points. Precisely I need a interpolation function that gives me the displacement of these points. The input would be the already calculated linear elastic problem from my earlier example with the node displacements as result.
In the sfepy documentation I found the probing described here: http://sfepy.org/doc-devel/primer.html#sec-primer
Is this the right way to solve the interpolation? Do you recommend something different?
Thank you and regards,
Kathrin