Suppose $X,Y$ are varieties over $\mathbb{C}$, $Y$ is smooth and $X$ is Gorenstein ($X$ is not smooth in my case). Let $f: X \to Y$ be an **affine** morphism, and each fibre of $f$ has the same dimension $n$. Moreover, $f$ can be assumed to be flat.


For $F \in D^b(X)$ and $G \in D^b(Y)$, I expect to have a Grothendieck-Verdier duality:
$${\rm R}f\_\* {\rm R}\mathcal{H}om(F, f^!(G)) \cong {\rm R}\mathcal{H}om({\rm R}f\_\*F, G).$$


However, I don't know how to define the functor $f^!$ here. 


I have checked the book "Residue and Duality" by Hartshorne, it seems that he requires $f$ at least to be **proper** in order to define the duality. Besides, in the book "Fourier-Mukai Transforms in Algebraic Geometry" by Huybrechts (c.f. Theorem 3.34 page 86), he did not require $f$ to be proper, but both $X$ and $Y$ are required to be smooth. So I don't know how to establish the duality in my affine setting.


Any suggestion is welcome!!



Grothendieck-Verdier duality for affine morphisms
You can get some kind right adjoint for $Rf\_\*$ by work of Lipman and Neeman. See the references quoted in the first few sentences here: [Section Tag 0A9D](http://stacks.math.columbia.edu/tag/0A9D). But this does not mean necessarily that one can "compute" the right adjoint. In the generality you are asking about the statement will not sheafify well (so there will not be a formula of the type you are asking for). Anyway, I suggest working out what happens when $Y$ is the spectrum of a field to see the trouble you get into.


