Post History
There are two elements to your question. The first is the similarity to an existing work. That question is answered here: Is my story too similar to an existing published work? The second is the s...
Answer
#4: Attribution notice removed
Source: https://writers.stackexchange.com/a/41023 License name: CC BY-SA 3.0 License URL: https://creativecommons.org/licenses/by-sa/3.0/
#3: Attribution notice added
Source: https://writers.stackexchange.com/a/41023 License name: CC BY-SA 3.0 License URL: https://creativecommons.org/licenses/by-sa/3.0/
#2: Initial revision
There are two elements to your question. The first is the similarity to an existing work. That question is answered here: [Is my story too similar to an existing published work?](https://writing.stackexchange.com/q/37951/14704) The second is the shared universe. Now that is a problem. Some authors have explicitly allowed their universe to be used by other authors. J.K. Rowling did not. Her world is copyrighted, and no other author may write stories in it. That said, if you do not use Rowling's locations and characters, if a lot of core concepts are different, why do you need her world at all? Give your spells different names, and it's a different world that just happens to share some similarities with Rowling's work - you're in the clear. (That's assuming there are indeed only a few similarities - I'm basing this statement on your description of your story.) There are examples of stories originally written as fanfics, "recoloured" and published as stand-alones. _Fifty Shades of Grey_ is an infamous example. Alternatively, you could publish your work as a Harry Potter fanfic. What that means is that your work is published free on the internet - you cannot sell it, and you clearly label it as a fanfic work, with _Harry Potter_ being the original. That route is perfectly legal, and quite common. _[Harry Potter and the Methods of Rationality](http://www.hpmor.com/)_ is a famous example. The disadvantage is you receive no money for your work.