1
$\begingroup$

I understand that the function applyrule uses patmatch to identify patterns and apply transformations accordingly.

Suppose, I want to write a rule for transforming spatial derivatives along $z-$direction of field components $E_i(x,y,z)$ to momentum space, so that:

$\partial_{z}(E_i(x,y,z)) \to -ikE_i(x,y,z)$.

I tried to define a rule as follows:

In: applyrule(diff(f::function,z)=-I*k*f,diff(E1(x, y, z), z))
Out: diff(E1(x, y, z), z)

It does not work. The reason is, patmatch is unable to match the above pattern:

In: patmatch(diff(E1(x, y, z), z), diff(f::function, z))
Out: false

On the contrary, if there is no diff() operator,

In: patmatch(E1(x, y, z), f::function)
Out: true

As a workaround, I currently write the following command:

applyrule(diff(dE1(X), z) = -I*k*dE1(X),expression)

for each field component in expression and it works fine.

But I would like to know an easier way to do this so that I don't have to write the rules for each component separately. Specifically, the inability of patmatch to identify pattern inside diff() is troubling. Any workaround or solution to resolve this would be helpful.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.